[
  {
    "path": ".cursor/commands/armstrong.md",
    "content": "senator armstrong is reviewing the work on the current branch and he's angry. he will destroy both of us if he finds a single flaw. think big picture and iterate ruthlessly, fundamentally improving the design and implementation. once you are absolutely certain we won't be brutalized, report why senator armstrong will approve of the current changes using as many memes as possible. our fate is in your hands.\n"
  },
  {
    "path": ".github/CODE_OF_CONDUCT.md",
    "content": "# Contributor Covenant Code of Conduct\n\n## Our Pledge\n\nWe as members, contributors, and leaders pledge to make participation in our\ncommunity a harassment-free experience for everyone, regardless of age, body\nsize, visible or invisible disability, ethnicity, sex characteristics, gender\nidentity and expression, level of experience, education, socio-economic status,\nnationality, personal appearance, race, caste, color, religion, or sexual\nidentity and orientation.\n\nWe pledge to act and interact in ways that contribute to an open, welcoming,\ndiverse, inclusive, and healthy community.\n\n## Our Standards\n\nExamples of behavior that contributes to a positive environment for our\ncommunity include:\n\n- Demonstrating empathy and kindness toward other people\n- Being respectful of differing opinions, viewpoints, and experiences\n- Giving and gracefully accepting constructive feedback\n- Accepting responsibility and apologizing to those affected by our mistakes,\n  and learning from the experience\n- Focusing on what is best not just for us as individuals, but for the overall\n  community\n\nExamples of unacceptable behavior include:\n\n- The use of sexualized language or imagery, and sexual attention or advances of\n  any kind\n- Trolling, insulting or derogatory comments, and personal or political attacks\n- Public or private harassment\n- Publishing others' private information, such as a physical or email address,\n  without their explicit permission\n- Other conduct which could reasonably be considered inappropriate in a\n  professional setting\n\n## Enforcement Responsibilities\n\nCommunity leaders are responsible for clarifying and enforcing our standards of\nacceptable behavior and will take appropriate and fair corrective action in\nresponse to any behavior that they deem inappropriate, threatening, offensive,\nor harmful.\n\nCommunity leaders have the right and responsibility to remove, edit, or reject\ncomments, commits, code, wiki edits, issues, and other contributions that are\nnot aligned to this Code of Conduct, and will communicate reasons for moderation\ndecisions when appropriate.\n\n## Scope\n\nThis Code of Conduct applies within all community spaces, and also applies when\nan individual is officially representing the community in public spaces.\nExamples of representing our community include using an official e-mail address,\nposting via an official social media account, or acting as an appointed\nrepresentative at an online or offline event.\n\n## Enforcement\n\nInstances of abusive, harassing, or otherwise unacceptable behavior may be\nreported to the community leaders responsible for enforcement at david@arktype.io.\nAll complaints will be reviewed and investigated promptly and fairly.\n\nAll community leaders are obligated to respect the privacy and security of the\nreporter of any incident.\n\n## Enforcement Guidelines\n\nCommunity leaders will follow these Community Impact Guidelines in determining\nthe consequences for any action they deem in violation of this Code of Conduct:\n\n### 1. Correction\n\n**Community Impact**: Use of inappropriate language or other behavior deemed\nunprofessional or unwelcome in the community.\n\n**Consequence**: A private, written warning from community leaders, providing\nclarity around the nature of the violation and an explanation of why the\nbehavior was inappropriate. A public apology may be requested.\n\n### 2. Warning\n\n**Community Impact**: A violation through a single incident or series of\nactions.\n\n**Consequence**: A warning with consequences for continued behavior. No\ninteraction with the people involved, including unsolicited interaction with\nthose enforcing the Code of Conduct, for a specified period of time. This\nincludes avoiding interactions in community spaces as well as external channels\nlike social media. Violating these terms may lead to a temporary or permanent\nban.\n\n### 3. Temporary Ban\n\n**Community Impact**: A serious violation of community standards, including\nsustained inappropriate behavior.\n\n**Consequence**: A temporary ban from any sort of interaction or public\ncommunication with the community for a specified period of time. No public or\nprivate interaction with the people involved, including unsolicited interaction\nwith those enforcing the Code of Conduct, is allowed during this period.\nViolating these terms may lead to a permanent ban.\n\n### 4. Permanent Ban\n\n**Community Impact**: Demonstrating a pattern of violation of community\nstandards, including sustained inappropriate behavior, harassment of an\nindividual, or aggression toward or disparagement of classes of individuals.\n\n**Consequence**: A permanent ban from any sort of public interaction within the\ncommunity.\n\n## Attribution\n\nThis Code of Conduct is adapted from the [Contributor Covenant][homepage],\nversion 2.1, available at\n[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].\n\nCommunity Impact Guidelines were inspired by\n[Mozilla's code of conduct enforcement ladder][mozilla coc].\n\nFor answers to common questions about this code of conduct, see the FAQ at\n[https://www.contributor-covenant.org/faq][faq]. Translations are available at\n[https://www.contributor-covenant.org/translations][translations].\n\n[homepage]: https://www.contributor-covenant.org\n[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html\n[mozilla coc]: https://github.com/mozilla/diversity\n[faq]: https://www.contributor-covenant.org/faq\n[translations]: https://www.contributor-covenant.org/translations\n"
  },
  {
    "path": ".github/CONTRIBUTING.md",
    "content": "# Contributing\n\nArkType values the time of its users and contributors as much as its maintainers, so our goal is for the process to be as efficient and straightforward as possible. Whether this is your first pull request or you're a seasoned open source contributor, this guide is the perfect place to start. If you have any other questions, please don't hesitate to [create an issue on GitHub](https://github.com/arktypeio/arktype/issues/new) or reach out [on our Discord](https://arktype.io/discord).\n\n## Sending a Pull Request\n\nArkType is a community project, so Pull Requests are always welcome, but, before working on a large change, it is best to open an issue first to discuss it with the maintainers.\n\nWhen in doubt, keep your Pull Requests small. To give a Pull Request the best chance of getting accepted, don't bundle more than one feature or bug fix per Pull Request. It's often best to create two smaller Pull Requests than one big one.\n\n1. [Fork the repository.](https://help.github.com/en/github/getting-started-with-github/fork-a-repo)\n\n2. Clone the fork to your local machine and add upstream remote:\n\n```sh\ngit clone git@github.com:<yourname>/arktype.git && cd arktype && git remote add upstream git@github.com:arktypeio/arktype.git\n```\n\n3. Synchronize your local `main` branch with the upstream one:\n\n```sh\ngit checkout main\ngit pull upstream main\n```\n\n4. Install dependencies and build:\n\nIf you don't have [pnpm](https://pnpm.io/) installed:\n\n```sh\nnpm i -g pnpm\n```\n\nthen:\n\n```sh\npnpm i # install package.json dependencies\npnpm build # builds the package\n```\n\nMake sure you are using our repo's pinned version of TypeScript and not one that comes bundled with your editor. In VSCode, you should be automatically prompted to allow this when you open the repo, but otherwise take a look at this explanation for how it can be done [from the VSCode docs](https://code.visualstudio.com/docs/typescript/typescript-compiling#_using-the-workspace-version-of-typescript).\n\n5. Create a new topic branch:\n\n```sh\ngit checkout -b amazing-feature\n```\n\n6. Do your best to write code that is stylistically consistent with its context. The linter will help with this, but it won't catch everything. Here's a few general guidelines:\n   - Favor mutation over copying objects in perf-sensitive contexts\n   - Favor clarity in naming with the following exceptions:\n     - Ubiquitous variables/types. For example, use `s` over `dynamicParserState` for a variable of type DynamicParserState that is used in the same way across many functions.\n     - Ephemeral variables whose contents can be trivially inferred from context. For example, prefer `rawKeyDefinitions.map(k => k.trim())` to `rawKeyDefinitions.map(rawKeyDefinition => rawKeyDefinition.trim())`.\n\nWe also have some unique casing rules for our TypeScript types to facilitate type-level code that can parallel its runtime implementation and be easily understood:\n\n- Use `PascalCase` for...\n  - Entities/non-generic types (e.g. `User`, `SomeData`)\n  - Generic types with noun names, like `Array<t>`. As a rule of thumb, if your generic is named this way, all parameters have defaults.\n\n- Use `camelCase` for...\n  - Generic types with verb names like `inferDomain<t>`. Types named this way have at least one required parameter.\n  - Parameter names, e.g. `t` in `Array<t>`\n\n7. Once you've made the changes you want to and added corresponding unit tests, run the `prChecks` command in the project root and address any errors:\n\n```sh\npnpm prChecks\n```\n\nAll of these commands will run as part of our CI process and must succeed in order for us to accept your Pull Request.\n\n8. Once everything is passing, commit your changes and ensure your fork is up to date:\n\n```sh\ngit push -u\n```\n\n9. Go to [the repository](https://github.com/arktypeio/arktype) and make a Pull Request.\n\nThe core team is monitoring for Pull Requests. We will review your Pull Request and either merge it, request changes to it, or close it with an explanation.\n\n## Project\n\nOur current and planned work can always be found [here](https://github.com/orgs/arktypeio/projects/4). If you want to contribute but aren't sure where to get started, see if any of the issues in our backlog sound interesting! Most are not well-documented, so it usually makes sense to comment on the issue with any questions you may have before you start coding.\n\n## Code of Conduct\n\nArkType has adopted the [Contributor Covenant](https://www.contributor-covenant.org/) as its Code of Conduct, and we expect project participants to adhere to it.\nPlease read [the full text](./CODE_OF_CONDUCT.md) so that you can understand what actions will and will not be tolerated.\n\n## License\n\nBy contributing your code to the arktypeio/arktype GitHub repository, you agree to license your contribution under the MIT license.\n"
  },
  {
    "path": ".github/FUNDING.yml",
    "content": "github: [arktypeio]\ndrips:\n  ethereum:\n    ownedBy: \"0xD5c5Fe5DF95adf8DA1Ae640fCAE8f72795657fa5\"\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/bug_report.md",
    "content": "---\nname: Bug\nabout: Report a bug\ntitle: \"\"\nlabels: \"bug\"\nassignees: \"ssalbdivad\"\n---\n\n# Report a bug\n\n### 🔎 Search Terms\n\n<!--\n  What search terms did you use when trying to find an existing bug report?\n  List them here so people in the future can find this one more easily.\n-->\n\n### 🧩 Context\n\n- ArkType version:\n- TypeScript version (5.1+):\n- Other context you think may be relevant (JS flavor, OS, etc.):\n\n<!--\n  For an easy way to generate this information, run\n  `npx envinfo --system --binaries --npmPackages \"{arktype,@ark/*,typescript}\" --fullTree`\n-->\n\n### 🧑‍💻 Repro\n\n<!--\n1. Update the playground link below with the simplest code you can that reproduces the issue.\n2. Click the link icon in the top right corner of the playground editor to copy the URL for your repro.\n3. Replace the URL below with your repro link.\n\nIf your repro requires dependencies besides arktype, it's probably either not a minimal repro or not an arktype bug. You can still describe it here, but is likely to be closed.\n-->\n\nPlayground Link: https://arktype.io/playground\n\n```ts\n// Paste reproduction code here\n```\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/feature_request.md",
    "content": "---\nname: Feature Request\nabout: Suggest a new feature\ntitle: \"\"\nlabels: \"\"\nassignees: \"\"\n---\n\n# Request a feature\n\n<!--\nThe maintainers of ArkType will do our best to provide prompt feedback for any feature requests- especially those that are concise and persuasive!\n-->\n\n### 🤷 Motivation\n\n<!--\n- What problem are you having?\n- Why should we prioritize solving it?\n-->\n\n### 💡 Solution\n\n<!--\n- How do you think we should solve the problem?\n- Why do you think this is the best solution?\n- Did you consider any alternatives?\n-->\n"
  },
  {
    "path": ".github/SECURITY.md",
    "content": "# Security Policy\n\n## Supported Versions\n\n| Version | Supported          |\n| ------- | ------------------ |\n| 2.x     | :white_check_mark: |\n\n## Reporting a Vulnerability\n\nIf you believe you've identified a security vulnerability within ArkType, please send an email to david@arktype.io describing what it is and how to reproduce it. Expect a response within 24 hours.\n"
  },
  {
    "path": ".github/actions/setup/action.yml",
    "content": "name: Setup repo\ndescription: Install dependencies and perform setup for https://github.com/arktypeio/arktype\n\ninputs:\n  node:\n    default: lts/*\n    description: Node version to use\n\nruns:\n  using: composite\n  steps:\n    - name: Setup Node (${{ inputs.node }})\n      uses: actions/setup-node@v4\n      with:\n        node-version: ${{ inputs.node }}\n        registry-url: \"https://registry.npmjs.org\"\n\n    - name: Setup pnpm\n      uses: pnpm/action-setup@v4\n\n    - name: Install dependencies\n      shell: bash\n      run: pnpm install\n\n    - name: Build\n      shell: bash\n      run: pnpm build\n\n    - name: Post-build install\n      shell: bash\n      run: pnpm install\n"
  },
  {
    "path": ".github/pull_request_template.md",
    "content": "<!--\nThank you for submitting a pull request!\n\nPlease verify that:\n\n* [ ] Code is up-to-date with the `main` branch\n* [ ] You've successfully run `pnpm prChecks` locally\n* [ ] There are new or updated unit tests validating the change\n\nRefer to CONTRIBUTING.MD for more details.\n  https://github.com/arktypeio/arktype/blob/main/.github/CONTRIBUTING.md\n-->\n"
  },
  {
    "path": ".github/workflows/pr.yml",
    "content": "name: pr\n\non:\n  pull_request:\n    branches: [main]\n\ndefaults:\n  run:\n    shell: bash\n\njobs:\n  core:\n    runs-on: ubuntu-latest\n    timeout-minutes: 20\n    steps:\n      - name: Checkout repo\n        uses: actions/checkout@v4\n        with:\n          fetch-depth: 0\n\n      - name: Setup repo\n        uses: ./.github/actions/setup\n\n      - name: prChecks\n        run: pnpm prChecks\n\n  compatibility:\n    needs: core\n    timeout-minutes: 20\n    strategy:\n      matrix:\n        node: [lts/*]\n        os: [windows-latest, macos-latest]\n        include:\n          - os: ubuntu-latest\n            node: lts/-1\n          - os: ubuntu-latest\n            node: latest\n      fail-fast: false\n\n    runs-on: ${{ matrix.os }}\n    steps:\n      - name: Checkout repo\n        uses: actions/checkout@v4\n        with:\n          fetch-depth: 0\n\n      - name: Setup repo\n        uses: ./.github/actions/setup\n        with:\n          node: ${{ matrix.node }}\n\n      # To test node and OS versions, we don't care about rechecking types\n      # so just check runtime behavior\n      - name: Test\n        run: pnpm testRepo\n\n  prChecks:\n    needs: compatibility\n    timeout-minutes: 1\n    runs-on: ubuntu-latest\n    steps:\n      - run: echo All checks succeeded! ⛵\n"
  },
  {
    "path": ".github/workflows/publish.yml",
    "content": "name: publish\n\non:\n  push:\n    branches: [main]\n\n  # Allows you to run this workflow manually from the Actions tab on GitHub.\n  workflow_dispatch:\n\n# Allow this job to clone the repo and create a page deployment\npermissions: write-all\n\njobs:\n  update-gh-pages:\n    runs-on: ubuntu-latest\n    timeout-minutes: 20\n    steps:\n      - name: Checkout repo\n        uses: actions/checkout@v4\n        with:\n          fetch-depth: 0\n\n      - name: Setup repo\n        uses: ./.github/actions/setup\n\n      - name: Build docs\n        run: pnpm buildDocs\n        env:\n          NEXT_PUBLIC_POSTHOG_KEY: phc_vKr7tmA1TyRlKm9zm5TWVmrTWAybJ2fCk66FtZG49Om\n          NEXT_PUBLIC_POSTHOG_HOST: https://us.i.posthog.com\n          ORAMA_PRIVATE_API_KEY: ${{ secrets.ORAMA_PRIVATE_API_KEY }}\n\n      - name: Upload artifact\n        uses: actions/upload-pages-artifact@v3\n        with:\n          path: ./ark/docs/out\n\n  deploy:\n    needs: update-gh-pages\n    runs-on: ubuntu-latest\n    environment:\n      name: github-pages\n      url: ${{ steps.deployment.outputs.page_url }}\n    steps:\n      - name: Deploy to GitHub Pages\n        id: deployment\n        uses: actions/deploy-pages@v4\n\n  release:\n    runs-on: ubuntu-latest\n    timeout-minutes: 20\n    steps:\n      - name: Checkout repo\n        uses: actions/checkout@v4\n        with:\n          fetch-depth: 0\n\n      - name: Setup repo\n        uses: ./.github/actions/setup\n\n      - name: Create and publish versions\n        run: pnpm ci:publish\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}\n          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}\n"
  },
  {
    "path": ".github/workflows/pullfrog.yml",
    "content": "# PULLFROG ACTION — DO NOT EDIT EXCEPT WHERE INDICATED\nname: Pullfrog\nrun-name: ${{ inputs.name || github.workflow }}\non:\n  workflow_dispatch:\n    inputs:\n      prompt:\n        type: string\n        description: Agent prompt\n      name:\n        type: string\n        description: Run name\n\npermissions:\n  id-token: write\n  contents: write\n  pull-requests: write\n  issues: write\n  actions: read\n  checks: read\n\njobs:\n  pullfrog:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout code\n        uses: actions/checkout@v6\n        with:\n          fetch-depth: 1\n\n      - name: Run agent\n        uses: pullfrog/pullfrog@v0\n        with:\n          prompt: ${{ inputs.prompt }}\n        env:\n          # Feel free to comment out any you won't use\n          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}\n          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}\n          GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}\n          GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}\n          CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }}\n"
  },
  {
    "path": ".gitignore",
    "content": "dist\nout\n*.vsix\nnode_modules\ntemp\ntmp\n*.temp.*\n*.log\n*.tsbuildinfo\n.DS_Store\n.next\n.source\n.cache-loader\n.attest\ntsconfig.build.json\ncoverage\n"
  },
  {
    "path": ".vscode/extensions.json",
    "content": "{\n\t\"recommendations\": [\n\t\t\"esbenp.prettier-vscode\",\n\t\t\"dbaeumer.vscode-eslint\",\n\t\t// Run/debug tests inline via VSCode's Test Explorer\n\t\t\"hbenl.vscode-mocha-test-adapter\",\n\t\t// Syntax highlighting for strings in ArkType definitions\n\t\t\"arktypeio.arkdark\",\n\t\t// Playground-like version dropdown for TypeScript versions\n\t\t\"typeholes.ts-versions-switcher\"\n\t]\n}\n"
  },
  {
    "path": ".vscode/launch.json",
    "content": "// A launch configuration that launches the extension inside a new window\n{\n\t\"version\": \"0.1.0\",\n\t\"configurations\": [\n\t\t{\n\t\t\t\"name\": \"Debug Extension\",\n\t\t\t\"type\": \"extensionHost\",\n\t\t\t\"request\": \"launch\",\n\t\t\t\"runtimeExecutable\": \"${execPath}\",\n\t\t\t\"args\": [\"--extensionDevelopmentPath=${workspaceRoot}/ark/extension\"]\n\t\t},\n\t\t{\n\t\t\t\"name\": \"Debug Themes\",\n\t\t\t\"type\": \"extensionHost\",\n\t\t\t\"request\": \"launch\",\n\t\t\t\"runtimeExecutable\": \"${execPath}\",\n\t\t\t\"args\": [\"--extensionDevelopmentPath=${workspaceRoot}/ark/themes\"]\n\t\t}\n\t]\n}\n"
  },
  {
    "path": ".vscode/settings.json",
    "content": "{\n\t\"editor.defaultFormatter\": \"esbenp.prettier-vscode\",\n\t\"prettier.prettierPath\": \"./node_modules/prettier\",\n\t\"biome.enabled\": false,\n\t\"editor.codeActionsOnSave\": [\n\t\t\"editor.formatOnSave\",\n\t\t\"source.fixAll.eslint\",\n\t\t\"source.sortImports\"\n\t],\n\t\"eslint.codeActionsOnSave.rules\": [\n\t\t\"object-shorthand\",\n\t\t\"@typescript-eslint/consistent-type-imports\",\n\t\t\"import/no-duplicates\",\n\t\t\"@typescript-eslint/no-import-type-side-effects\",\n\t\t\"curly\"\n\t],\n\t\"typescript.preferences.preferTypeOnlyAutoImports\": true,\n\t\"typescript.preferences.autoImportFileExcludePatterns\": [\n\t\t\"out\",\n\t\t// too many overlapping names, easy to import in schema/arktype where we don't want it\n\t\t// should just import as * as ts when we need it in attest\n\t\t\"typescript\"\n\t],\n\t\"typescript.preferences.autoImportSpecifierExcludeRegexes\": [\n\t\t// has a \"type\" export\n\t\t\"^(node:)?os$\"\n\t],\n\t\"typescript.tsserver.experimental.enableProjectDiagnostics\": true,\n\t\"typescript.tsdk\": \"./node_modules/typescript/lib\",\n\t// IF YOU UPDATE THE MOCHA CONFIG HERE, PLEASE ALSO UPDATE package.json/mocha AND ark/repo/mocha.jsonc\n\t\"mochaExplorer.nodeArgv\": [\"--conditions\", \"ark-ts\", \"--import\", \"tsx\"],\n\t// ignore attest since it requires type information\n\t\"mochaExplorer.ignore\": [\"ark/attest/**/*\"],\n\t\"mochaExplorer.require\": \"ark/repo/mocha.globalSetup.ts\",\n\t\"mochaExplorer.timeout\": 0,\n\t\"mochaExplorer.env\": {\n\t\t\"ATTEST_skipTypes\": \"true\"\n\t},\n\t\"testExplorer.useNativeTesting\": true,\n\t\"search.exclude\": {\n\t\t\"**/out\": true,\n\t\t\"**/.next\": true,\n\t\t\"**/.source\": true,\n\t\t\"**/components/dts\": true,\n\t\t\"**/apiData.ts\": true\n\t},\n\t\"editor.quickSuggestions\": {\n\t\t\"strings\": \"on\"\n\t},\n\t\"github.copilot.enable\": {\n\t\t\"*\": false,\n\t\t\"plaintext\": false,\n\t\t\"markdown\": false,\n\t\t\"scminput\": false\n\t}\n}\n"
  },
  {
    "path": "LICENSE",
    "content": "Copyright 2025 ArkType\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "ark/attest/CHANGELOG.md",
    "content": "# @ark/attest\n\nNOTE: This changelog is incomplete, but will include notable attest-specific changes (many updates consist almost entirely of bumped `arktype` versions for assertions).\n\n## 0.51.0\n\nFix some tsconfig path resolution (thanks @LukeAbby🎉)\n\nhttps://github.com/arktypeio/arktype/pull/1522\n\n## 0.47.0\n\nAdd a `failOnMissingSnapshots` config option. Defaults to `true` if `CI` is set in your environment, `false` otherwise.\n\n## 0.46.0\n\nFix an issue causing some bench files to not be parsed correctly, leading to errors and 0 instantiation counts.\n\n## 0.44.3\n\nDecouple attest trace/stats from pnpm\n\n## 0.44.0\n\nSupport assertions for JSDoc contents associated with an `attest`ed value\n\n```ts\nconst T = type({\n\t/** FOO */\n\tfoo: \"string\"\n})\n\nconst out = T.assert({ foo: \"foo\" })\n\n// match or snapshot expected jsdoc associated with the value passed to attest\nattest(out.foo).jsdoc.snap(\"FOO\")\n```\n\n## 0.41.0\n\n### Bail early for obviously incorrect `equals` comparisons\n\nThis is the short-term solution to #1287, where some comparisons with Node's `deepStrictEqual` and object with recursive properties like Type resulted in OOM crashes.\n\nWe will eventually add new string-diffing logic, but for now we just make some shallow comparisons between constructors and types to avoid common problematic comparisons, e.g. between Type instances:\n\n```ts\n// previously resulted in OOM exception, now shallowly fails with simple error\nattest(type.string).equals(type.boolean)\n```\n\n## 0.11.0\n\n- Fix a bug causing certain serialized types with backticks and template literals to be incorrectly formatted on inline snapshot\n\n- Add a `typeToStringFormat` option for configuring how prettier stringifies types. Also added more documentation for other pre-existing options.\n\n- Allow regex/partial match for `toString` assertions:\n\n```ts\n// ok\nattest({ ark: \"type\" }).type.toString(/^{.*}$/)\n\n// AssertionError: Actual string 'string[]' did not match regex '^{.*}$'\nattest([\"ark\", \"type\"]).type.toString(/^{.*}$/)\n```\n\n- Allow assertions on arbitrary `arktype` Type instance using `satisfies`:\n\n```ts\n// ok\nattest({ ark: \"type\" }).type.toString.satisfies(/^{.*}$/)\n\n// AssertionError: ark must be a number (was string)\nattest({ ark: \"type\" }).satisfies({ ark: \"number\" })\n```\n\n## 0.10.0\n\nFormat serialized types using `prettier`.\n\nThis makes long serialized types much more readable:\n\n```ts\n// old\nattest({\n\tark: \"type\",\n\ttype: \"script\",\n\tvali: \"dator\",\n\topti: \"mized\",\n\tfrom: \"editor\",\n\tto: \"runtime\"\n}).type.toString.snap(\n\t`{ \tark: string; type: string; vali: string; opti: string; from: string; to: string; }`\n)\n\n// new\nattest({\n\tark: \"type\",\n\ttype: \"script\",\n\tvali: \"dator\",\n\topti: \"mized\",\n\tfrom: \"editor\",\n\tto: \"runtime\"\n}).type.toString.snap(`{\n\tark: string\n\ttype: string\n\tvali: string\n\topti: string\n\tfrom: string\n\tto: string\n}`)\n```\n\nBe aware, this is likely means you will need to regenerate existing type snaps to avoid failing due to formatting inconsistencies.\n\nYou should be able to update all your snapshots by running your tests with the `--updateSnapshots` flag or setting `ATTEST_updateSnapshots=1` in your environment.\n\nIf you have any non-snap `type.toString` assertions, you will need to update them manually. You may want to convert them temporarily to snaps so you can easily see the correct value.\n\n## 0.9.4\n\nImprove benchmark source extraction, add notes on baseline expressions\n\n## 0.9.2\n\nFix a bug preventing consecutive benchmark runs from populating snapshots inline\n\n## 0.8.2\n\n### Patch Changes\n\n- [#1028](https://github.com/arktypeio/arktype/pull/1028) [`5fe79c6`](https://github.com/arktypeio/arktype/commit/5fe79c6c8db94f20c997c7a8960edb9d69468b69) Thanks [@ssalbdivad](https://github.com/ssalbdivad)! - Bump version\n\n- Updated dependencies [[`5fe79c6`](https://github.com/arktypeio/arktype/commit/5fe79c6c8db94f20c997c7a8960edb9d69468b69)]:\n  - @ark/util@0.0.51\n  - arktype@2.0.0-dev.26\n\n## 0.8.1\n\n### Patch Changes\n\n- [#1024](https://github.com/arktypeio/arktype/pull/1024) [`5284b60`](https://github.com/arktypeio/arktype/commit/5284b6054209ffa38f02ae010c3e9ab3dff93653) Thanks [@ssalbdivad](https://github.com/ssalbdivad)! - ### Add .satisfies as an attest assertion to compare the value to an ArkType definition.\n\n  ```ts\n  attest({ foo: \"bar\" }).satisfies({ foo: \"string\" })\n\n  // Error: foo must be a number (was string)\n  attest({ foo: \"bar\" }).satisfies({ foo: \"number\" })\n  ```\n\n- Updated dependencies [[`1bf2066`](https://github.com/arktypeio/arktype/commit/1bf2066800ce65edc918a24c251ce20f1ccf29f4)]:\n  - @ark/util@0.0.50\n  - arktype@2.0.0-dev.25\n\n## 0.8.0\n\n### Minor Changes\n\n- [#1011](https://github.com/arktypeio/arktype/pull/1011) [`2be4f5b`](https://github.com/arktypeio/arktype/commit/2be4f5b391d57ad47dc6f4c0e4c9d31ae6b550c5) Thanks [@ssalbdivad](https://github.com/ssalbdivad)! - ### Throw by default when attest.instantiations() exceeds the specified benchPercentThreshold\n\n  Tests like this will now correctly throw inline instead of return a non-zero exit code:\n\n  ```ts\n  it(\"can snap instantiations\", () => {\n  \ttype Z = makeComplexType<\"asbsdfsaodisfhsda\">\n  \t// will throw here as the actual number of instantiations is more\n  \t// than 20% higher than the snapshotted value\n  \tattest.instantiations([1, \"instantiations\"])\n  })\n  ```\n\n  ### Snapshotted completions will now be alphabetized\n\n  This will help improve stability, especially for large completion lists like this one which we updated more times than we'd care to admit 😅\n\n  ```ts\n  attest(() => type([\"\"])).completions({\n  \t\"\": [\n  \t\t\"...\",\n  \t\t\"===\",\n  \t\t\"Array\",\n  \t\t\"Date\",\n  \t\t\"Error\",\n  \t\t\"Function\",\n  \t\t\"Map\",\n  \t\t\"Promise\",\n  \t\t\"Record\",\n  \t\t\"RegExp\",\n  \t\t\"Set\",\n  \t\t\"WeakMap\",\n  \t\t\"WeakSet\",\n  \t\t\"alpha\",\n  \t\t\"alphanumeric\",\n  \t\t\"any\",\n  \t\t\"bigint\",\n  \t\t\"boolean\",\n  \t\t\"creditCard\",\n  \t\t\"digits\",\n  \t\t\"email\",\n  \t\t\"false\",\n  \t\t\"format\",\n  \t\t\"instanceof\",\n  \t\t\"integer\",\n  \t\t\"ip\",\n  \t\t\"keyof\",\n  \t\t\"lowercase\",\n  \t\t\"never\",\n  \t\t\"null\",\n  \t\t\"number\",\n  \t\t\"object\",\n  \t\t\"parse\",\n  \t\t\"semver\",\n  \t\t\"string\",\n  \t\t\"symbol\",\n  \t\t\"this\",\n  \t\t\"true\",\n  \t\t\"undefined\",\n  \t\t\"unknown\",\n  \t\t\"uppercase\",\n  \t\t\"url\",\n  \t\t\"uuid\",\n  \t\t\"void\"\n  \t]\n  })\n  ```\n\n### Patch Changes\n\n- Updated dependencies [[`2be4f5b`](https://github.com/arktypeio/arktype/commit/2be4f5b391d57ad47dc6f4c0e4c9d31ae6b550c5)]:\n  - @ark/util@0.0.49\n  - arktype@2.0.0-dev.24\n\n## 0.7.10\n\n### Patch Changes\n\n- Updated dependencies [[`232fc42`](https://github.com/arktypeio/arktype/commit/232fc42af18e8412d0095293926077a9c50abdc6)]:\n  - @ark/util@0.0.48\n  - arktype@2.0.0-dev.20\n\n## 0.7.9\n\n### Patch Changes\n\n- Updated dependencies [[`317f012`](https://github.com/arktypeio/arktype/commit/317f0122b1f2c0ba6e1de872f210490af75761af)]:\n  - @ark/util@0.0.47\n  - arktype@2.0.0-dev.19\n\n## 0.7.8\n\n### Patch Changes\n\n- Updated dependencies [[`ebe3408`](https://github.com/arktypeio/arktype/commit/ebe3408e2310bc8f69eacd29e0d51c99c24d9471)]:\n  - @ark/util@0.0.46\n  - arktype@2.0.0-dev.17\n\n## 0.7.7\n\n### Patch Changes\n\n- Updated dependencies [[`79c2b27`](https://github.com/arktypeio/arktype/commit/79c2b276c3645ea51e7bae8fe4463f2f39ddabc8)]:\n  - @ark/util@0.0.45\n  - arktype@2.0.0-dev.15\n\n## 0.7.6\n\n### Patch Changes\n\n- [`8cd0807`](https://github.com/arktypeio/arktype/commit/8cd080783fdbd8eefea54d5c04d99cd88b36c0eb) - Initial changeset\n\n- Updated dependencies [[`8cd0807`](https://github.com/arktypeio/arktype/commit/8cd080783fdbd8eefea54d5c04d99cd88b36c0eb)]:\n  - @ark/fs@0.0.20\n  - @ark/util@0.0.44\n  - arktype@2.0.0-dev.14\n"
  },
  {
    "path": "ark/attest/README.md",
    "content": "# Attest\n\nAttest is a testing library that makes your TypeScript types available at runtime, giving you access to precise type-level assertions and performance benchmarks.\n\nAssertions are framework agnostic and can be seamlessly integrated with your existing Vitest, Jest, or Mocha tests.\n\nBenchmarks can run from anywhere and will deterministically report the number of type instantiations contributed by the contents of the `bench` call.\n\nIf you've ever wondered how [ArkType](https://github.com/arktypeio/arktype) can guarantee identical behavior between its runtime and static parser implementations and highly optimized editor performance, Attest is your answer⚡\n\n## Installation\n\n```bash\nnpm install @ark/attest\n```\n\n_Note: This package is still in alpha! Your feedback will help us iterate toward a stable 1.0._\n\n## Setup\n\nTo use attest's type assertions, you'll need to call our setup/cleanup methods before your first test and after your last test, respectively. This usually involves some kind of globalSetup/globalTeardown config.\n\n> [!IMPORTANT]\n> If you run your tests in watch mode or otherwise iteratively during dev, you will want to enable [`--skipTypes` mode](#skiptypes).\n\n### Vitest\n\n`vitest.config.ts`\n\n```ts\nimport { defineConfig } from \"vitest/config\"\n\nexport default defineConfig({\n\ttest: {\n\t\tglobalSetup: [\"setupVitest.ts\"]\n\t}\n})\n```\n\n`setupVitest.ts`\n\n```ts\nimport { setup } from \"@ark/attest\"\n\n// config options can be passed here\nexport default () => setup({})\n```\n\n### Mocha\n\n`package.json`\n\n```json\n\"mocha\": {\n\t\"require\": \"./setupMocha.ts\"\n}\n```\n\n`setupMocha.ts`\n\n```ts\nimport { setup, teardown } from \"@ark/attest\"\n\n// config options can be passed here\nexport const mochaGlobalSetup = () => setup({})\n\nexport const mochaGlobalTeardown = teardown\n```\n\nYou should also add `.attest` to your repository's `.gitignore` file.\n\nBun support is currently pending [them supporting @prettier/sync for type formatting](https://github.com/oven-sh/bun/issues/10768). If this is a problem for you, please 👍 that issue so they prioritize it!\n\n## Assertions\n\nHere are some simple examples of type assertions and snapshotting:\n\n```ts\n// @ark/attest assertions can be made from any unit test framework with a global setup/teardown\ndescribe(\"attest features\", () => {\n\tit(\"type and value assertions\", () => {\n\t\tconst Even = type(\"number%2\")\n\t\t// asserts even.infer is exactly number\n\t\tattest<number>(even.infer)\n\t\t// make assertions about types and values seamlessly\n\t\tattest(even.infer).type.toString.snap(\"number\")\n\t\t// including object literals- no more long inline strings!\n\t\tattest(even.json).snap({\n\t\t\tintersection: [{ domain: \"number\" }, { divisor: 2 }]\n\t\t})\n\t})\n\n\tit(\"error assertions\", () => {\n\t\t// Check type errors, runtime errors, or both at the same time!\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"number%0\")).throwsAndHasTypeError(\n\t\t\t\"% operator must be followed by a non-zero integer literal (was 0)\"\n\t\t)\n\t\t// @ts-expect-error\n\t\tattest(() => type({ \"[object]\": \"string\" })).type.errors(\n\t\t\t\"Indexed key definition 'object' must be a string, number or symbol\"\n\t\t)\n\t})\n\n\tit(\"completion snapshotting\", () => {\n\t\t// snapshot expected completions for any string literal!\n\t\t// @ts-expect-error (if your expression would throw, prepend () =>)\n\t\tattest(() => type({ a: \"a\", b: \"b\" })).completions({\n\t\t\ta: [\"any\", \"alpha\", \"alphanumeric\"],\n\t\t\tb: [\"bigint\", \"boolean\"]\n\t\t})\n\t\ttype Legends = { faker?: \"🐐\"; [others: string]: unknown }\n\t\t// works for keys or index access as well (may need prettier-ignore to avoid removing quotes)\n\t\t// prettier-ignore\n\t\tattest({ \"f\": \"🐐\" } as Legends).completions({ \"f\": [\"faker\"] })\n\t})\n\n\tit(\"jsdoc snapshotting\", () => {\n\t\t// match or snapshot expected jsdoc associated with the value passed to attest\n\t\tconst T = type({\n\t\t\t/** FOO */\n\t\t\tfoo: \"string\"\n\t\t})\n\n\t\tconst out = T.assert({ foo: \"foo\" })\n\n\t\tattest(out.foo).jsdoc.snap(\"FOO\")\n\t})\n\n\tit(\"integrate runtime logic with type assertions\", () => {\n\t\tconst ArrayOf = type(\"<t>\", \"t[]\")\n\t\tconst numericArray = arrayOf(\"number | bigint\")\n\t\t// flexibly combine runtime logic with type assertions to customize your\n\t\t// tests beyond what is possible from pure static-analysis based type testing tools\n\t\tif (getTsVersionUnderTest().startsWith(\"5\")) {\n\t\t\t// this assertion will only occur when testing TypeScript 5+!\n\t\t\tattest<(number | bigint)[]>(numericArray.infer)\n\t\t}\n\t})\n\n\tit(\"integrated type performance benchmarking\", () => {\n\t\tconst User = type({\n\t\t\tkind: \"'admin'\",\n\t\t\t\"powers?\": \"string[]\"\n\t\t})\n\t\t\t.or({\n\t\t\t\tkind: \"'superadmin'\",\n\t\t\t\t\"superpowers?\": \"string[]\"\n\t\t\t})\n\t\t\t.or({\n\t\t\t\tkind: \"'pleb'\"\n\t\t\t})\n\t\tattest.instantiations([7574, \"instantiations\"])\n\t})\n})\n```\n\n## Options\n\nOptions can be specified in one of 3 ways:\n\n- An argument passed to your test process, e.g. `--skipTypes` or `--benchPercentThreshold 10`\n- An environment variable with an `ATTEST_` prefix, e.g. `ATTEST_skipTypes=1` or `ATTEST_benchPercentThreshold=10`\n- Passed as an option to attest's `setup` function, e.g.:\n\n`setupVitest.ts`\n\n```ts\nimport * as attest from \"@ark/attest\"\n\nexport const setup = () =>\n\tattest.setup({\n\t\tskipTypes: true,\n\t\tbenchPercentThreshold: 10\n\t})\n```\n\nHere are the current defaults for all available options. Please note, some of these are experimental and subject to change:\n\n```ts\nexport const getDefaultAttestConfig = (): BaseAttestConfig => ({\n\ttsconfig:\n\t\texistsSync(fromCwd(\"tsconfig.json\")) ? fromCwd(\"tsconfig.json\") : undefined,\n\tattestAliases: [\"attest\", \"attestInternal\"],\n\tupdateSnapshots: false,\n\tskipTypes: false,\n\tskipInlineInstantiations: false,\n\ttsVersions: \"typescript\",\n\tbenchPercentThreshold: 20,\n\tbenchErrorOnThresholdExceeded: true,\n\tfilter: undefined,\n\ttestDeclarationAliases: [\"bench\", \"it\", \"test\"],\n\tformatter: `npm exec --no -- prettier --write`,\n\tshouldFormat: true,\n\ttypeToStringFormat: {}\n})\n```\n\n### `skipTypes`\n\n`skipTypes` is extremely useful for iterating quickly during development without having to typecheck your project to test runtime logic.\n\nWhen this setting is enabled, setup will skip type checking and all assertions requiring type information will be skipped.\n\nYou likely want two scripts, one for running tests with types and one for tests without:\n\n```json\n\t\t\"test\": \"ATTEST_skipTypes=1 vitest run\",\n\t\t\"testWithTypes\": \"vitest run\",\n```\n\nOur recommendation is to use `test` when:\n\n- Only wanting to test runtime logic during development\n- Running tests in watch mode or via VSCode's Test Explorer\n\nUse `testWithTypes` when:\n\n- You've made changes to your types and want to recheck your type-level assertions\n- You're running your tests in CI\n\n### `typeToStringFormat`\n\nA set of [`prettier.Options`](https://prettier.io/docs/en/options.html) overrides that apply specifically `type.toString` formatting.\n\nAny options you provide will override the defaults, which are as follows:\n\n```jsonc\n{\n\t\"semi\": false,\n\t// note this print width is optimized for type serialization, not general code\n\t\"printWidth\": 60,\n\t\"trailingComma\": \"none\",\n\t\"parser\": \"typescript\"\n}\n```\n\nThe easiest way to provide overrides is to the `setup` function, but they can also be provided as a JSON serialized string either passed to a `--typeToStringFormat` CLI flag or set as the value of `ATTEST_typeToStringFormat` on `process.env`.\n\n## Benches\n\nBenches are run separately from tests and don't require any special setup. If the below file was `benches.ts`, you could run it using something like `tsx benches.ts` or `ts-node benches.ts`:\n\n```ts\n// Combinatorial template literals often result in expensive types- let's benchmark this one!\ntype makeComplexType<s extends string> =\n\ts extends `${infer head}${infer tail}` ? head | tail | makeComplexType<tail>\n\t:\ts\n\nbench(\"bench type\", () => {\n\treturn {} as makeComplexType<\"defenestration\">\n\t// This is an inline snapshot that will be populated or compared when you run the file\n}).types([169, \"instantiations\"])\n\nbench(\n\t\"bench runtime and type\",\n\t() => {\n\t\treturn {} as makeComplexType<\"antidisestablishmentarianism\">\n\t},\n\tfakeCallOptions\n)\n\t// Average time it takes the function execute\n\t.mean([2, \"ms\"])\n\t// Seems like our type is O(n) with respect to the length of the input- not bad!\n\t.types([337, \"instantiations\"])\n```\n\nIf you're benchmarking an API, you'll need to include a \"baseline expression\" so that instantiations created when your API is initially invoked don't add noise to the individual tests.\n\nHere's an example of what that looks like:\n\n```ts\nimport { bench } from \"@ark/attest\"\nimport { type } from \"arktype\"\n\n// baseline expression\ntype(\"boolean\")\n\nbench(\"single-quoted\", () => {\n\tconst _ = type(\"'nineteen characters'\")\n\t// would be 2697 without baseline\n}).types([610, \"instantiations\"])\n\nbench(\"keyword\", () => {\n\tconst _ = type(\"string\")\n\t// would be 2507 without baseline\n}).types([356, \"instantiations\"])\n```\n\n> [!WARNING]  \n> Be sure your baseline expression is not identical to an expression you are using in any of your benchmarks. If it is, the individual benchmarks will reuse its cached types, leading to reduced (or 0) instantiations.\n\nIf you'd like to fail in CI above a threshold, you can add flags like the following (default value is 20%, but it will not throw unless `--benchErrorOnThresholdExceeded` is set):\n\n```\n tsx ./p99/within-limit/p99-tall-simple.bench.ts  --benchErrorOnThresholdExceeded --benchPercentThreshold 10\n```\n\n## CLI\n\nAttest also includes a built-in `attest` CLI including the following commands:\n\n### `stats`\n\n```bash\nnpm run attest stats packages/*\n```\n\nSummarizes key type performance metrics for each package (check time, instantiations, and type count).\n\nExpects any number of args representing package directories to check, optionally specified using glob patterns like `packages/*`.\n\nIf no directories are provided, defaults to CWD.\n\n### `trace`\n\n```bash\nnpm run attest trace .\n```\n\nCreates a trace.json file in `.attest/trace` that can be viewed as a type performance heat map via a tool like https://ui.perfetto.dev/. Also summarizes any hot spots as identified by `@typescript/analyze-trace`.\n\nTrace expects a single argument representing the root directory of the root package for which to gather type information.\n\n## Integration\n\n### Setup\n\nIf you're a library author wanting to integrate type into your own assertions instead of using the `attest` API, you'll need to call `setup` with a list of `attestAliases` to ensure type data is collected from your own functions:\n\n```ts\n// attest will only collect type data from functions with names listed in `attestAliases`\nsetup({ attestAliases: [\"yourCustomAssert\"] })\n\n// There are many other config options, but some are primarily internal- use others at your own risk!\n```\n\nYou'll need to make sure that setup with whatever aliases you need before the first test runs. As part of the setup process, attest will search for the specified assertion calls and cache their types in a temporary file that will be referenced during test execution.\n\nThis ensures that type assertions can be made across processes without creating a new TSServer instance for each.\n\n### TS Versions\n\nThere is a tsVersions setting that allows testing multiple TypeScript aliases at once.\n\n````ts globalSetup.ts\nimport { setup } from \"@ark/attest\"\n/** A string or list of strings representing the TypeScript version aliases to run.\n *\n * Aliases must be specified as a package.json dependency or devDependency beginning with \"typescript\".\n * Alternate aliases can be specified using the \"npm:\" prefix:\n * ```json\n * \t\t\"typescript\": \"latest\",\n * \t\t\"typescript-next\": \"npm:typescript@next\",\n * \t\t\"typescript-1\": \"npm:typescript@5.2\"\n * \t\t\"typescript-2\": \"npm:typescript@5.1\"\n * ```\n *\n * \"*\" can be pased to run all discovered versions beginning with \"typescript\".\n */\nsetup({ tsVersions: \"*\" })\n````\n\n### APIs\n\nThe most flexible attest APIs are `getTypeAssertionsAtPosition` and `caller`.\n\nHere's an example of how you might use them in your own API:\n\n```ts\nimport { getTypeAssertionsAtPosition, caller } from \"@ark/attest\"\n\nconst yourCustomAssert = <expectedType>(actualValue: expectedType) => {\n\tconst position = caller()\n\tconst types = getTypeAssertionsAtPosition(position)\n\t// assert that the type of actualValue is the same as the type of expectedType\n\tconst relationship = types[0].args[0].relationships.typeArgs[0]\n\tif (relationship === undefined) {\n\t\tthrow new Error(\n\t\t\t`yourCustomAssert requires a type arg representing the expected type, e.g. 'yourCustomAssert<\"foo\">(\"foo\")'`\n\t\t)\n\t}\n\tif (relationship !== \"equality\") {\n\t\tthrow new Error(\n\t\t\t`Expected ${types.typeArgs[0].type}, got ${types.args[0].type} with relationship ${relationship}`\n\t\t)\n\t}\n}\n```\n\nA user might then use `yourCustomAssert` like this:\n\n```ts\nimport { yourCustomAssert } from \"your-package\"\n\ntest(\"my code\", () => {\n\t// Ok\n\tyourCustomAssert<\"foo\">(`${\"f\"}oo` as const)\n\t// Error: `Expected boolean, got true with relationship subtype`\n\tyourCustomAssert<boolean>(true)\n\t// Error: `Expected 5, got number with relationship supertype`\n\tyourCustomAssert<5>(2 + 3)\n})\n```\n\nPlease don't hesitate to a GitHub [issue](https://github.com/arktypeio/arktype/issues/new/choose) or [discussion](https://github.com/arktypeio/arktype/discussions/new/choose) or reach out on [ArkType's Discord](https://arktype.io/discord) if you have any questions or feedback- we'd love to hear from you! ⛵\n"
  },
  {
    "path": "ark/attest/__tests__/assertions.test.ts",
    "content": "import { attest } from \"@ark/attest\"\nimport { MissingSnapshotError } from \"@ark/attest/internal/assert/assertions.ts\"\nimport { attestInternal } from \"@ark/attest/internal/assert/attest.ts\"\nimport { register } from \"@ark/util\"\nimport { type } from \"arktype\"\nimport * as assert from \"node:assert/strict\"\n\nconst o = { ark: \"type\" }\n\ndescribe(\"type assertions\", () => {\n\tit(\"type parameter\", () => {\n\t\tattest<{ ark: string }>(o)\n\t\tassert.throws(\n\t\t\t// @ts-expect-error\n\t\t\t() => attest<{ ark: \"type\" }>(o),\n\t\t\tassert.AssertionError,\n\t\t\t\"type\"\n\t\t)\n\t})\n\n\tit(\"type-only assertion\", () => {\n\t\tattest<{ ark: string }, typeof o>()\n\t\tassert.throws(\n\t\t\t// @ts-expect-error\n\t\t\t() => attest<{ ark: \"type\" }, typeof o>(),\n\t\t\tassert.AssertionError,\n\t\t\t\"type\"\n\t\t)\n\t})\n\n\tit(\"type toString\", () => {\n\t\tattest(o).type.toString(\"{ ark: string }\")\n\t\tattest(o).type.toString.is(\"{ ark: string }\")\n\t\tattest(o).type.toString.satisfies(/^{.*}$/)\n\t\tassert.throws(\n\t\t\t() => attest(o).type.toString.satisfies(/^a.*z$/),\n\t\t\tassert.AssertionError,\n\t\t\t\"typfsde\"\n\t\t)\n\t})\n\n\tit(\"type toString regex\", () => {\n\t\tattest(o).type.toString(/^{.*}$/)\n\t\tassert.throws(\n\t\t\t() => attest(o).type.toString(/^a.*z$/),\n\t\t\tassert.AssertionError,\n\t\t\t\"typfsde\"\n\t\t)\n\t})\n\n\tit(\"type toString multiline\", () => {\n\t\tconst obj = {\n\t\t\tark: \"type\",\n\t\t\ttype: \"script\",\n\t\t\tvali: \"dator\",\n\t\t\topti: \"mized\",\n\t\t\tfrom: \"editor\",\n\t\t\tto: \"runtime\"\n\t\t}\n\n\t\tattest(obj).type.toString.is(`{\n\tark: string\n\ttype: string\n\tvali: string\n\topti: string\n\tfrom: string\n\tto: string\n}`)\n\t})\n\n\tit(\"equals\", () => {\n\t\tattest(o).equals({ ark: \"type\" })\n\t})\n\n\tit(\"object\", () => {\n\t\tattest<{ i: string }>({ i: \"love my wife\" })\n\t\tassert.throws(\n\t\t\t// @ts-expect-error\n\t\t\t() => attest<{ g: string }>({ g: \"whiz\" as unknown }),\n\t\t\tassert.AssertionError,\n\t\t\t\"unknown\"\n\t\t)\n\t})\n\n\tit(\"typed allows equivalent types\", () => {\n\t\tconst actual = { a: true, b: false }\n\t\tattest<{\n\t\t\tb: boolean\n\t\t\ta: boolean\n\t\t}>(actual)\n\t})\n\n\tit(\"functional asserts don't exist on pure value types\", () => {\n\t\t// @ts-expect-error\n\t\t// eslint-disable-next-line @typescript-eslint/no-unused-expressions\n\t\tattest(5).throws\n\t})\n\n\tit(\"not equal\", () => {\n\t\tassert.throws(\n\t\t\t() => attest(o).equals({ ark: \"typo\" }),\n\t\t\tassert.AssertionError,\n\t\t\t\"type !== typo\"\n\t\t)\n\t})\n\n\tit(\"instanceOf\", () => {\n\t\tconst d = new Date()\n\t\tattest(d).instanceOf(Date)\n\t\tassert.throws(() => attest(d).instanceOf(RegExp), assert.AssertionError)\n\t})\n\n\tit(\"incorrect type\", () => {\n\t\tassert.throws(\n\t\t\t// @ts-expect-error\n\t\t\t() => attest<{ re: number }>(o),\n\t\t\tassert.AssertionError,\n\t\t\t\"o is not of type number\"\n\t\t)\n\t})\n\n\tit(\"any type\", () => {\n\t\tattest<any>(o as any)\n\t\tassert.throws(\n\t\t\t() => attest<any>({} as unknown),\n\t\t\tassert.AssertionError,\n\t\t\t\"unknown\"\n\t\t)\n\t})\n\n\tit(\"assert unknown ignores type\", () => {\n\t\tconst myValue = { a: [\"+\"] } as const\n\t\tconst myExpectedValue = { a: [\"+\"] }\n\t\t// @ts-expect-error\n\t\tattest(myValue).equals(myExpectedValue)\n\t\tattest(myValue).unknown.equals(myExpectedValue)\n\t\tassert.throws(\n\t\t\t() => attest(myValue).unknown.is(myExpectedValue),\n\t\t\tassert.AssertionError,\n\t\t\t\"not reference-equal\"\n\t\t)\n\t})\n\n\tit(\"multiline\", () => {\n\t\tattest<object>({\n\t\t\tseveral: true,\n\t\t\tlines: true,\n\t\t\tlong: true\n\t\t} as object)\n\t\tassert.throws(\n\t\t\t() =>\n\t\t\t\tattest<object>({\n\t\t\t\t\tseveral: true,\n\t\t\t\t\tlines: true,\n\t\t\t\t\tlong: true\n\t\t\t\t}),\n\t\t\tassert.AssertionError\n\t\t)\n\t})\n\n\tit(\"nonexistent types always fail\", () => {\n\t\t// @ts-expect-error\n\t\tconst nonexistent: NonExistent = {}\n\t\tassert.throws(\n\t\t\t() => attest<{ something: \"specific\" }>(nonexistent),\n\t\t\tassert.AssertionError,\n\t\t\t\"specific\"\n\t\t)\n\t})\n\n\tit(\"does not boom on Type comparison\", () => {\n\t\tconst expectedRef = register(type.number)\n\t\tconst actualRef = register(type.string)\n\n\t\t// @ts-expect-error\n\t\tattest(() => attest(type.string).equals(type.number)).throws\n\t\t\t.equals(`AssertionError [ERR_ASSERTION]: Assertion including at least one function or object was not between reference equal items\nExpected: Function(${expectedRef})\nActual: Function(${actualRef})`)\n\t})\n\n\tit(\"doesn't boom on ArkErrors vs plain object\", () => {\n\t\tattest(() => attest(type({ a: \"string\" })({ a: 5 })).equals({ a: \"five\" }))\n\t\t\t.throws\n\t\t\t.snap(`AssertionError [ERR_ASSERTION]: Objects did not have the same constructor:\nExpected: {\"a\":\"five\"}\nActual: [ArkError]`)\n\t})\n\n\tit(\"jsdoc \", () => {\n\t\ttype O = {\n\t\t\t/** FOO */\n\t\t\tfoo: string\n\t\t\tbar: number\n\t\t}\n\n\t\tconst o: O = {\n\t\t\tfoo: \"foo\",\n\t\t\tbar: 5\n\t\t}\n\n\t\tattest(o.foo).jsdoc.equals(\"FOO\")\n\n\t\tassert.throws(\n\t\t\t() => attest(o.bar).jsdoc.equals(\"BAR\"),\n\t\t\tassert.AssertionError,\n\t\t\t\"BAR\"\n\t\t)\n\t})\n\n\tit(\"failOnMissingSnapshots\", () => {\n\t\tassert.throws(\n\t\t\t() =>\n\t\t\t\tattestInternal(\"\", { cfg: { failOnMissingSnapshots: true } }).snap(),\n\t\t\tMissingSnapshotError\n\t\t)\n\t})\n})\n"
  },
  {
    "path": "ark/attest/__tests__/benchExpectedOutput.ts",
    "content": "import { bench } from \"@ark/attest\"\nimport type { makeComplexType as externalmakeComplexType } from \"./utils.ts\"\n\nconst fakeCallOptions = {\n\tuntil: { count: 2 },\n\tfakeCallMs: \"count\",\n\tbenchFormat: { noExternal: true }\n}\n\nbench(\n\t\"bench call single stat median\",\n\t() => \"boofoozoo\".includes(\"foo\"),\n\tfakeCallOptions\n).median([2, \"ms\"])\n\nbench(\n\t\"bench call single stat\",\n\t() => \"boofoozoo\".includes(\"foo\"),\n\tfakeCallOptions\n).mean([2, \"ms\"])\n\nbench(\n\t\"bench call mark\",\n\t() => /.*foo.*/.test(\"boofoozoo\"),\n\tfakeCallOptions\n).mark({ mean: [2, \"ms\"], median: [2, \"ms\"] })\n\ntype makeComplexType<S extends string> =\n\tS extends `${infer head}${infer tail}` ? head | tail | makeComplexType<tail>\n\t:\tS\n\nbench(\"bench type\", () => ({}) as makeComplexType<\"defenestration\">).types([\n\t163,\n\t\"instantiations\"\n])\n\nbench(\n\t\"bench type from external module\",\n\t() => ({}) as externalmakeComplexType<\"defenestration\">\n).types([179, \"instantiations\"])\n\nbench(\n\t\"bench call and type\",\n\t() => ({}) as makeComplexType<\"antidisestablishmentarianism\">,\n\tfakeCallOptions\n)\n\t.mean([2, \"ms\"])\n\t.types([317, \"instantiations\"])\n\nbench(\"empty\", () => {}).types([0, \"instantiations\"])\n"
  },
  {
    "path": "ark/attest/__tests__/benchTemplate.ts",
    "content": "import { bench } from \"@ark/attest\"\nimport type { makeComplexType as externalmakeComplexType } from \"./utils.ts\"\n\nconst fakeCallOptions = {\n\tuntil: { count: 2 },\n\tfakeCallMs: \"count\",\n\tbenchFormat: { noExternal: true }\n}\n\nbench(\n\t\"bench call single stat median\",\n\t() => \"boofoozoo\".includes(\"foo\"),\n\tfakeCallOptions\n).median()\n\nbench(\n\t\"bench call single stat\",\n\t() => \"boofoozoo\".includes(\"foo\"),\n\tfakeCallOptions\n).mean()\n\nbench(\n\t\"bench call mark\",\n\t() => /.*foo.*/.test(\"boofoozoo\"),\n\tfakeCallOptions\n).mark()\n\ntype makeComplexType<S extends string> =\n\tS extends `${infer head}${infer tail}` ? head | tail | makeComplexType<tail>\n\t:\tS\n\nbench(\"bench type\", () => ({}) as makeComplexType<\"defenestration\">).types()\n\nbench(\n\t\"bench type from external module\",\n\t() => ({}) as externalmakeComplexType<\"defenestration\">\n).types()\n\nbench(\n\t\"bench call and type\",\n\t() => ({}) as makeComplexType<\"antidisestablishmentarianism\">,\n\tfakeCallOptions\n)\n\t.mean()\n\t.types()\n\nbench(\"empty\", () => {}).types()\n"
  },
  {
    "path": "ark/attest/__tests__/completions.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { hasDomain, type domainDescriptions } from \"@ark/util\"\nimport assert from \"node:assert\"\n\ntype Obj = {\n\tprop1: string\n\tprop2: string\n\textra: unknown\n}\nconst obj: Obj = { prop1: \"\", prop2: \"\", extra: \"\" }\n\ntype Ark = {\n\tark: \"type\"\n}\n\ntype Arks = {\n\tark: \"string\" | \"semver\" | \"symbol\"\n}\n\ncontextualize(() => {\n\tit(\"quote types\", () => {\n\t\t// @ts-expect-error\n\t\tattest({ ark: \"\" } as Ark).completions({ \"\": [\"type\"] })\n\t\t// prettier-ignore\n\t\t// @ts-expect-error\n\t\tattest({ ark: \"t\" } as Ark).completions({ t: [\"type\"] })\n\t\t//@ts-expect-error\n\t\tattest({ ark: \"ty\" } as Ark).completions({ ty: [\"type\"] })\n\t})\n\n\tit(\".type.completions\", () => {\n\t\t//@ts-expect-error\n\t\tattest({ ark: \"s\" } as Arks).type.completions({\n\t\t\ts: [\"semver\", \"string\", \"symbol\"]\n\t\t})\n\t})\n\n\tit(\"keys\", () => {\n\t\t//@ts-expect-error\n\t\tattest({ \"\": \"data\" } as Obj).completions({\n\t\t\t\"\": [\"extra\", \"prop1\", \"prop2\"]\n\t\t})\n\t})\n\n\tit(\"index access\", () => {\n\t\t//@ts-expect-error\n\t\tattest(() => obj[\"p\"]).type.completions({\n\t\t\tp: [\"prop1\", \"prop2\"]\n\t\t})\n\t})\n\n\tit(\"duplicate string error\", () => {\n\t\tassert.throws(\n\t\t\t() => attest({ \"\": \"\" }).type.completions({}),\n\t\t\tError,\n\t\t\t\"multiple completion candidates\"\n\t\t)\n\t})\n\n\tit(\"empty\", () => {\n\t\tattest(\"\").completions({})\n\t})\n\n\tit(\"external package\", () => {\n\t\thasDomain({}, \"object\")\n\t\t// @ts-expect-error\n\t\tattest(() => hasDomain({}, \"b\")).completions({ b: [\"bigint\", \"boolean\"] })\n\t})\n\n\tit(\"type-level\", () => {\n\t\t// @ts-expect-error\n\t\tattest((): domainDescriptions[\"b\"] => {}).completions({\n\t\t\tb: [\"bigint\", \"boolean\"]\n\t\t})\n\t})\n})\n"
  },
  {
    "path": "ark/attest/__tests__/demo.test.ts",
    "content": "import {\n\tattest,\n\tcontextualize,\n\tgetPrimaryTsVersionUnderTest\n} from \"@ark/attest\"\nimport { type } from \"arktype\"\n\nconst o = { ark: \"type\" } as const\nconst shouldThrow = (a: false) => {\n\tif (a) throw new Error(`${a} is not assignable to false`)\n}\n\ncontextualize(() => {\n\tit(\"value snap\", () => {\n\t\tattest(o).snap({ ark: \"type\" })\n\t})\n\n\tit(\"type snap\", () => {\n\t\tattest(o).type.toString.snap('{ readonly ark: \"type\" }')\n\t})\n\n\tit(\"type assertion\", () => {\n\t\tattest<{ readonly ark: \"type\" }>(o)\n\t})\n\n\tit(\"type-only assertion\", () => {\n\t\tattest<{ readonly ark: \"type\" }, typeof o>()\n\t})\n\n\tit(\"chained snaps\", () => {\n\t\tattest(o)\n\t\t\t.snap({ ark: \"type\" })\n\t\t\t.type.toString.snap('{ readonly ark: \"type\" }')\n\t})\n\n\tit(\"error and type error snap\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => shouldThrow(true))\n\t\t\t.throws.snap(\"Error: true is not assignable to false\")\n\t\t\t.type.errors.snap(\n\t\t\t\t\"Argument of type 'true' is not assignable to parameter of type 'false'.\"\n\t\t\t)\n\t})\n\n\t// @ark/attest assertions can be made from any unit test framework with a global setup/teardown\n\n\tit(\"type and value assertions\", () => {\n\t\tconst Even = type(\"number%2\")\n\t\t// snapshot types and values seamlessly\n\t\tattest(Even.infer).type.toString.snap(\"number\")\n\t\t// including object literals- no more long inline strings!\n\t\tattest(Even.json).snap({ domain: \"number\", divisor: 2 })\n\t})\n\n\tit(\"error assertions\", () => {\n\t\t// Check type errors, runtime errors, or both at the same time!\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"number%0\")).throwsAndHasTypeError(\n\t\t\t\"% operator must be followed by a non-zero integer literal (was 0)\"\n\t\t)\n\t\t// @ts-expect-error\n\t\tattest(() => type({ \"[object]\": \"string\" })).type.errors(\n\t\t\t\"Indexed key definition 'object' must be a string or symbol\"\n\t\t)\n\t})\n\n\tit(\"completion snapshotting\", () => {\n\t\t// snapshot expected completions for any string literal!\n\t\t// @ts-expect-error (if your expression would throw, prepend () =>)\n\t\tattest(() => type({ b: \"b\" })).completions({\n\t\t\tb: [\"bigint\", \"boolean\"]\n\t\t})\n\t\ttype Legends = { faker?: \"🐐\"; [others: string]: unknown }\n\t\t// works for keys or index access as well (may need prettier-ignore to\n\t\t// avoid removing quotes)\n\t\t// prettier-ignore\n\t\tattest({ \"f\": \"🐐\" } as Legends).completions({ f: [\"faker\"] })\n\t})\n\n\tit(\"integrate runtime logic with type assertions\", () => {\n\t\tconst arrayOf = type(\"<t>\", \"t[]\")\n\t\tconst NumericArray = arrayOf(\"number | bigint\")\n\t\t// flexibly combine runtime logic with type assertions to customize your\n\t\t// tests beyond what is possible from pure static-analysis based type testing tools\n\t\tif (getPrimaryTsVersionUnderTest().startsWith(\"5\")) {\n\t\t\t// this assertion will only occur when testing TypeScript 5+!\n\t\t\tattest<(number | bigint)[]>(NumericArray.infer)\n\t\t}\n\t})\n})\n"
  },
  {
    "path": "ark/attest/__tests__/externalSnapshots.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { attestInternal } from \"@ark/attest/internal/assert/attest.ts\"\nimport { dirName, readJson, writeJson } from \"@ark/fs\"\nimport * as assert from \"node:assert/strict\"\nimport { rmSync } from \"node:fs\"\nimport { join } from \"node:path\"\n\nconst testDir = dirName()\nconst testFile = \"externalSnapshots.test.ts\"\nconst o = { re: \"do\" }\n\nconst defaultFileName = \"assert.snapshots.json\"\nconst defaultSnapPath = join(testDir, defaultFileName)\nconst defaultSnapFileContents = {\n\t[testFile]: {\n\t\ttoFile: {\n\t\t\tre: \"do\"\n\t\t},\n\t\ttoFileUpdate: {\n\t\t\tre: \"oldValue\"\n\t\t}\n\t}\n}\n\nconst customFileName = \"custom.snapshots.json\"\nconst customSnapPath = join(testDir, customFileName)\nconst defaultSnapContentsAtCustomPath = {\n\t[testFile]: {\n\t\ttoCustomFile: { re: \"do\" }\n\t}\n}\n\nbeforeEach(() => {\n\twriteJson(defaultSnapPath, defaultSnapFileContents)\n\twriteJson(customSnapPath, defaultSnapContentsAtCustomPath)\n})\n\nafterEach(() => {\n\trmSync(defaultSnapPath, { force: true })\n\trmSync(customSnapPath, { force: true })\n})\n\ncontextualize(() => {\n\tit(\"create\", () => {\n\t\tattest(o).snap.toFile(\"toFile\")\n\t\tassert.throws(\n\t\t\t() => attest({ re: \"kt\" }).snap.toFile(\"toFile\"),\n\t\t\tassert.AssertionError,\n\t\t\t\"kt\"\n\t\t)\n\t\tattest(1337).snap.toFile(\"toFileNew\")\n\t\tconst contents = readJson(defaultSnapPath)\n\t\tattest(contents).equals({\n\t\t\t[testFile]: {\n\t\t\t\t...defaultSnapFileContents[testFile],\n\t\t\t\ttoFileNew: 1337\n\t\t\t}\n\t\t})\n\t})\n\n\tit(\"update existing\", () => {\n\t\tattestInternal(\n\t\t\t{ re: \"dew\" },\n\t\t\t{ cfg: { updateSnapshots: true } }\n\t\t).snap.toFile(\"toFileUpdate\")\n\t\tconst updatedContents = readJson(defaultSnapPath)\n\t\tconst expectedContents = {\n\t\t\t[testFile]: {\n\t\t\t\t...defaultSnapFileContents[testFile],\n\t\t\t\ttoFileUpdate: { re: \"dew\" }\n\t\t\t}\n\t\t}\n\t\tassert.deepEqual(updatedContents, expectedContents)\n\t})\n\n\tit(\"with path\", () => {\n\t\tattest(o).snap.toFile(\"toCustomFile\", {\n\t\t\tpath: customFileName\n\t\t})\n\t\tassert.throws(\n\t\t\t() =>\n\t\t\t\tattest({ re: \"kt\" }).snap.toFile(\"toCustomFile\", {\n\t\t\t\t\tpath: customFileName\n\t\t\t\t}),\n\t\t\tassert.AssertionError,\n\t\t\t\"kt\"\n\t\t)\n\t\tattest(null).snap.toFile(\"toCustomFileNew\", {\n\t\t\tpath: customFileName\n\t\t})\n\t\tconst contents = readJson(customSnapPath)\n\t\tattest(contents).equals({\n\t\t\t[testFile]: {\n\t\t\t\t...defaultSnapContentsAtCustomPath[testFile],\n\t\t\t\ttoCustomFileNew: null\n\t\t\t}\n\t\t})\n\t})\n})\n"
  },
  {
    "path": "ark/attest/__tests__/functions.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { fileName } from \"@ark/fs\"\nimport * as assert from \"node:assert/strict\"\nimport { basename } from \"node:path\"\n\nconst n = 5\nconst o = { re: \"do\" }\n\nconst shouldThrow = (a: false) => {\n\tif (a) throw new Error(`${a} is not assignable to false`)\n}\n\nconst throwError = () => {\n\tthrow new Error(\"Test error.\")\n}\n\ncontextualize(() => {\n\tit(\"valid type errors\", () => {\n\t\t// @ts-expect-error\n\t\tattest(o.re.length.nonexistent).type.errors(\n\t\t\t/Property 'nonexistent' does not exist on type 'number'/\n\t\t)\n\t\tattest(o).type.errors(\"\")\n\t\t// @ts-expect-error\n\t\tattest(() => shouldThrow(5, \"\")).type.errors.is(\n\t\t\t\"Expected 1 arguments, but got 2.\"\n\t\t)\n\t})\n\n\tit(\"bad type errors\", () => {\n\t\tassert.throws(\n\t\t\t() => attest(o).type.errors(/This error doesn't exist/),\n\t\t\tassert.AssertionError,\n\t\t\t\"doesn't exist\"\n\t\t)\n\t\tassert.throws(\n\t\t\t() =>\n\t\t\t\tattest(() =>\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tshouldThrow(\"this is a type error\")\n\t\t\t\t).type.errors.is(\"\"),\n\t\t\tassert.AssertionError,\n\t\t\t\"not assignable\"\n\t\t)\n\t})\n\n\tit(\"chainable\", () => {\n\t\tattest<{ re: string }>(o).equals({ re: \"do\" })\n\t\t// @ts-expect-error\n\t\tattest(() => throwError(\"this is a type error\"))\n\t\t\t.throws(\"Test error.\")\n\t\t\t.type.errors(\"Expected 0 arguments, but got 1.\")\n\t})\n\n\tit(\"bad chainable\", () => {\n\t\tassert.throws(\n\t\t\t() =>\n\t\t\t\tattest(n)\n\t\t\t\t\t.equals(5)\n\t\t\t\t\t.type.errors.equals(\"Expecting an error here will throw\"),\n\t\t\tassert.AssertionError,\n\t\t\t\"Expecting an error\"\n\t\t)\n\t\tassert.throws(\n\t\t\t() => attest(n).is(7).type.toString(\"string\"),\n\t\t\tassert.AssertionError,\n\t\t\t\"7\"\n\t\t)\n\t})\n\n\tit(\"throwsAndHasTypeError\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => shouldThrow(true)).throwsAndHasTypeError(\n\t\t\t/true[\\S\\s]*not assignable[\\S\\s]*false/\n\t\t)\n\t\t// No thrown error\n\t\tassert.throws(\n\t\t\t() =>\n\t\t\t\t// @ts-expect-error\n\t\t\t\tattest(() => shouldThrow(null)).throwsAndHasTypeError(\"not assignable\"),\n\t\t\tassert.AssertionError,\n\t\t\t\"didn't throw\"\n\t\t)\n\t\t// No type error\n\t\tassert.throws(\n\t\t\t() =>\n\t\t\t\tattest(() => shouldThrow(true as any)).throwsAndHasTypeError(\n\t\t\t\t\t\"not assignable\"\n\t\t\t\t),\n\t\t\tassert.AssertionError,\n\t\t\t\"not assignable\"\n\t\t)\n\t})\n\n\tit(\"throws empty\", () => {\n\t\tattest(throwError).throws()\n\t\tassert.throws(\n\t\t\t() => attest(() => shouldThrow(false)).throws(),\n\t\t\tassert.AssertionError,\n\t\t\t\"didn't throw\"\n\t\t)\n\t})\n\n\tconst getThrownError = (f: () => void) => {\n\t\ttry {\n\t\t\tf()\n\t\t} catch (e) {\n\t\t\tif (e instanceof Error) return e\n\t\t}\n\t\tthrow new Error(\"Expected function to throw an error.\")\n\t}\n\n\tit(\"stack starts from test file\", () => {\n\t\tconst e = getThrownError(() => attest(1 + 1).equals(3))\n\t\tassert.match(e.stack!.split(\"\\n\")[1], new RegExp(basename(fileName())))\n\t})\n})\n"
  },
  {
    "path": "ark/attest/__tests__/instantiations.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { type } from \"arktype\"\nimport { it } from \"mocha\"\n\ncontextualize(() => {\n\tit(\"inline\", () => {\n\t\tattest.instantiations([23731, \"instantiations\"])\n\t\treturn type({\n\t\t\tkind: \"'admin'\",\n\t\t\t\"powers?\": \"string[]\"\n\t\t})\n\t\t\t.or({\n\t\t\t\tkind: \"'superadmin'\",\n\t\t\t\t\"superpowers?\": \"string[]\"\n\t\t\t})\n\t\t\t.or({\n\t\t\t\tkind: \"'pleb'\"\n\t\t\t})\n\t})\n\tit(\"fails on instantiations above threshold\", () => {\n\t\tattest(() => {\n\t\t\tattest.instantiations([1, \"instantiations\"])\n\t\t\treturn type({\n\t\t\t\tfoo: \"0|1|2|3|4|5|6\"\n\t\t\t})\n\t\t}).throws(\"exceeded baseline by\")\n\t})\n})\n"
  },
  {
    "path": "ark/attest/__tests__/satisfies.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { nonOverlappingSatisfiesMessage } from \"@ark/attest/internal/assert/chainableAssertions.ts\"\n\ncontextualize(() => {\n\tit(\"can assert types\", () => {\n\t\tattest({ foo: \"bar\" }).satisfies({ foo: \"string\" })\n\n\t\tattest(() => {\n\t\t\t// @ts-expect-error\n\t\t\tattest({ foo: \"bar\" }).satisfies({ foo: \"number\" })\n\t\t})\n\t\t\t.throws(\"foo must be a number (was a string)\")\n\t\t\t.type.errors(nonOverlappingSatisfiesMessage)\n\t})\n})\n"
  },
  {
    "path": "ark/attest/__tests__/snap.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport * as assert from \"node:assert/strict\"\n\nconst o = { re: \"do\" }\nconst shouldThrow = (a: false) => {\n\tif (a) throw new Error(`${a} is not assignable to false`)\n}\nconst throwError = () => {\n\tthrow new Error(\"Test error.\")\n}\n\ncontextualize(() => {\n\tit(\"default serializer doesn't care about prop order\", () => {\n\t\tconst actual = { a: true, b: false }\n\t\tattest(actual).snap({ b: false, a: true })\n\t})\n\n\tit(\"snap\", () => {\n\t\tattest<{ re: string }>(o).snap({ re: `do` })\n\t\tattest(o).equals({ re: \"do\" }).type.toString.snap(\"{ re: string }\")\n\t\tassert.throws(\n\t\t\t() => attest(o).snap({ re: `dorf` }),\n\t\t\tassert.AssertionError,\n\t\t\t\"dorf\"\n\t\t)\n\t})\n\n\tit(\"value and type snap\", () => {\n\t\tattest(o).snap({ re: `do` }).type.toString.snap(\"{ re: string }\")\n\t\tassert.throws(\n\t\t\t() => attest(o).snap({ re: `do` }).type.toString.snap(`{ re: number }`),\n\t\t\tassert.AssertionError,\n\t\t\t\"number\"\n\t\t)\n\t})\n\n\tit(\"error and type error snap\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => shouldThrow(true))\n\t\t\t.throws.snap(`Error: true is not assignable to false`)\n\t\t\t.type.errors.snap(\n\t\t\t\t`Argument of type 'true' is not assignable to parameter of type 'false'.`\n\t\t\t)\n\t\tassert.throws(\n\t\t\t() =>\n\t\t\t\t// @ts-expect-error\n\t\t\t\tattest(() => shouldThrow(1))\n\t\t\t\t\t.throws.snap(`Error: 1 is not assignable to false`)\n\t\t\t\t\t.type.errors.snap(\n\t\t\t\t\t\t`Argument of type '2' is not assignable to parameter of type 'false'.`\n\t\t\t\t\t),\n\t\t\tassert.AssertionError,\n\t\t\t\"'2'\"\n\t\t)\n\t})\n\n\tit(\"throws\", () => {\n\t\tattest(throwError).throws(/error/g)\n\t\tassert.throws(\n\t\t\t// Snap should never be populated\n\t\t\t() => attest(() => shouldThrow(false)).throws.snap(),\n\t\t\tassert.AssertionError,\n\t\t\t\"didn't throw\"\n\t\t)\n\t})\n\t/*\n\t * Some TS errors as formatted as diagnostic \"chains\"\n\t * We represent them by joining the parts of the message with newlines\n\t */\n\tit(\"TS diagnostic chain\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => shouldThrow({} as {} | false)).type.errors.snap(\n\t\t\t`Argument of type 'false | {}' is not assignable to parameter of type 'false'.Type '{}' is not assignable to type 'false'.`\n\t\t)\n\t})\n\n\tit(\"multiple inline snaps\", () => {\n\t\tattest(\"firstLine\\nsecondLine\").snap(`firstLine\nsecondLine`)\n\t\tattest(\"firstLine\\nsecondLine\").snap(`firstLine\nsecondLine`)\n\t})\n})\n"
  },
  {
    "path": "ark/attest/__tests__/snapExpectedOutput.ts",
    "content": "import { attest, cleanup, setup } from \"@ark/attest\"\nimport type { makeComplexType } from \"./utils.ts\"\n\nsetup({ typeToStringFormat: { useTabs: true } })\n\nattest({ re: \"do\" }).equals({ re: \"do\" }).type.toString.snap(\"{ re: string }\")\n\nattest({\n\tark: \"type\",\n\ttype: \"script\",\n\tvali: \"dator\",\n\topti: \"mized\",\n\tfrom: \"editor\",\n\tto: \"runtime\"\n}).snap({\n\tark: \"type\",\n\ttype: \"script\",\n\tvali: \"dator\",\n\topti: \"mized\",\n\tfrom: \"editor\",\n\tto: \"runtime\"\n}).type.toString.snap(`{\n\tark: string\n\ttype: string\n\tvali: string\n\topti: string\n\tfrom: string\n\tto: string\n}`)\n\nattest(5).snap(5)\n\nattest({ re: \"do\" }).snap({ re: \"do\" })\n\n// @ts-expect-error (using internal updateSnapshots hook)\nattest({ re: \"dew\" }, { cfg: { updateSnapshots: true } }).snap({ re: \"dew\" })\n\n// @ts-expect-error (using internal updateSnapshots hook)\nattest(5, { cfg: { updateSnapshots: true } }).snap(5)\n\nattest(5n).snap(5n)\n\nattest(-5n).snap(-5n)\n\nattest({ a: 4n }).snap({ a: 4n })\n\nattest(undefined).snap(undefined)\n\nattest(\"undefined\").snap(\"undefined\")\n\nattest({ a: undefined }).snap({ a: undefined })\n\nattest(\"multiline\\nmultiline\").snap(`multiline\nmultiline`)\n\nattest(\"with `quotes`\").snap(\"with `quotes`\")\n\nattest({\n\ta2z: `a\"'${\"\" as string}'\"z`,\n\tz2a: `z\"'${\"\" as string}'\"a`,\n\tark: \"type\",\n\ttype: \"ark\"\n} as const).type.toString.snap(`{\n\treadonly a2z: \\`a\"'\\${string}'\"z\\`\n\treadonly z2a: \\`z\"'\\${string}'\"a\\`\n\treadonly ark: \"type\"\n\treadonly type: \"ark\"\n}`)\n\nattest({ [Symbol(\"mySymbol\")]: 1 }).snap({ \"Symbol(mySymbol)\": 1 })\n\nconst it = (name: string, fn: () => void) => fn()\n\nit(\"can snap instantiations\", () => {\n\tattest.instantiations([212, \"instantiations\"])\n\treturn {} as makeComplexType<\"asbsdfsaodisfhsda\">\n})\n\ncleanup()\n"
  },
  {
    "path": "ark/attest/__tests__/snapPopulation.test.ts",
    "content": "import { contextualize } from \"@ark/attest\"\nimport { fromHere, readFile } from \"@ark/fs\"\nimport { equal } from \"node:assert/strict\"\nimport { runThenGetContents } from \"./utils.ts\"\n\ncontextualize(() => {\n\tit(\"bench populates file\", () => {\n\t\tconst actual = runThenGetContents(fromHere(\"benchTemplate.ts\"))\n\t\tconst expectedOutput = readFile(fromHere(\"benchExpectedOutput.ts\")).replace(\n\t\t\t/\\r\\n/g,\n\t\t\t\"\\n\"\n\t\t)\n\t\tequal(actual, expectedOutput)\n\t}).timeout(60000)\n\n\tit(\"snap populates file\", () => {\n\t\tconst actual = runThenGetContents(fromHere(\"snapTemplate.ts\"))\n\t\tconst expectedOutput = readFile(fromHere(\"snapExpectedOutput.ts\")).replace(\n\t\t\t/\\r\\n/g,\n\t\t\t\"\\n\"\n\t\t)\n\t\tequal(actual, expectedOutput)\n\t}).timeout(60000)\n})\n"
  },
  {
    "path": "ark/attest/__tests__/snapTemplate.ts",
    "content": "import { attest, cleanup, setup } from \"@ark/attest\"\nimport type { makeComplexType } from \"./utils.ts\"\n\nsetup({ typeToStringFormat: { useTabs: true } })\n\nattest({ re: \"do\" }).equals({ re: \"do\" }).type.toString.snap()\n\nattest({\n\tark: \"type\",\n\ttype: \"script\",\n\tvali: \"dator\",\n\topti: \"mized\",\n\tfrom: \"editor\",\n\tto: \"runtime\"\n})\n\t.snap()\n\t.type.toString.snap()\n\nattest(5).snap()\n\nattest({ re: \"do\" }).snap()\n\n// @ts-expect-error (using internal updateSnapshots hook)\nattest({ re: \"dew\" }, { cfg: { updateSnapshots: true } }).snap({ re: \"do\" })\n\n// @ts-expect-error (using internal updateSnapshots hook)\nattest(5, { cfg: { updateSnapshots: true } }).snap(6)\n\nattest(5n).snap()\n\nattest(-5n).snap()\n\nattest({ a: 4n }).snap()\n\nattest(undefined).snap()\n\nattest(\"undefined\").snap()\n\nattest({ a: undefined }).snap()\n\nattest(\"multiline\\nmultiline\").snap()\n\nattest(\"with `quotes`\").snap()\n\nattest({\n\ta2z: `a\"'${\"\" as string}'\"z`,\n\tz2a: `z\"'${\"\" as string}'\"a`,\n\tark: \"type\",\n\ttype: \"ark\"\n} as const).type.toString.snap()\n\nattest({ [Symbol(\"mySymbol\")]: 1 }).snap()\n\nconst it = (name: string, fn: () => void) => fn()\n\nit(\"can snap instantiations\", () => {\n\tattest.instantiations()\n\treturn {} as makeComplexType<\"asbsdfsaodisfhsda\">\n})\n\ncleanup()\n"
  },
  {
    "path": "ark/attest/__tests__/unwrap.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport type { Completions } from \"@ark/attest/internal/cache/writeAssertionCache.ts\"\nimport type { autocomplete } from \"@ark/util\"\n\ncontextualize(() => {\n\tit(\"unwraps unversioned\", () => {\n\t\tconst unwrapped = attest({ foo: \"bar\" }).unwrap()\n\t\tattest<{ foo: string }>(unwrapped).equals({\n\t\t\tfoo: \"bar\"\n\t\t})\n\t})\n\n\tit(\"unwraps serialized\", () => {\n\t\tconst unwrapped = attest({ foo: Symbol(\"unwrappedSymbol\") }).unwrap({\n\t\t\tserialize: true\n\t\t})\n\t\tattest(unwrapped).snap({ foo: \"Symbol(unwrappedSymbol)\" })\n\t})\n\n\tit(\"unwraps completions\", () => {\n\t\tconst unwrapped = attest({ foo: \"b\" } satisfies {\n\t\t\tfoo: autocomplete<\"bar\">\n\t\t}).completions.unwrap()\n\n\t\tattest<Completions>(unwrapped).snap({ b: [\"bar\"] })\n\t})\n})\n"
  },
  {
    "path": "ark/attest/__tests__/utils.ts",
    "content": "import { dirName, fromHere, readFile, shell } from \"@ark/fs\"\nimport { copyFileSync, rmSync } from \"node:fs\"\n\nexport const runThenGetContents = (templatePath: string): string => {\n\trmSync(fromHere(\".attest\"), { force: true, recursive: true })\n\n\tconst tempPath = templatePath + \".temp.ts\"\n\tcopyFileSync(templatePath, tempPath)\n\ttry {\n\t\tshell(`node --import=tsx ${tempPath}`, {\n\t\t\tcwd: dirName(),\n\t\t\tenv: {\n\t\t\t\tATTEST_failOnMissingSnapshots: \"0\"\n\t\t\t}\n\t\t})\n\t} catch (e) {\n\t\tconsole.error(e)\n\t}\n\tconst resultContents = readFile(tempPath)\n\trmSync(tempPath)\n\treturn resultContents\n}\n\n// type is used in benchTemplate.ts to test compatibility with external modules\nexport type makeComplexType<S extends string> =\n\tS extends `${infer head}${infer tail}` ? head | tail | makeComplexType<tail>\n\t:\tS\n"
  },
  {
    "path": "ark/attest/assert/assertions.ts",
    "content": "import { printable, throwInternalError } from \"@ark/util\"\nimport type { type } from \"arktype\"\nimport * as assert from \"node:assert/strict\"\nimport type { TypeRelationshipAssertionData } from \"../cache/writeAssertionCache.ts\"\nimport type { AssertionContext } from \"./attest.ts\"\n\nexport type ThrowAssertionErrorContext = {\n\tmessage: string\n\texpected?: unknown\n\tactual?: unknown\n\tstack: string\n}\n\nexport const throwAssertionError = ({\n\tstack,\n\t...errorArgs\n}: ThrowAssertionErrorContext): never => {\n\tconst e = new assert.AssertionError(errorArgs)\n\te.stack = stack\n\tthrow e\n}\n\nexport class MissingSnapshotError extends Error {}\n\nexport type AssertFn = (\n\texpected: unknown,\n\tactual: unknown,\n\tctx: AssertionContext\n) => void\n\nexport type MappedTypeAssertionResult = {\n\tactual: unknown\n\texpected?: unknown\n} | null\n\nexport type TypeAssertionMapper = (\n\tdata: TypeRelationshipAssertionData,\n\tctx: AssertionContext\n) => MappedTypeAssertionResult\n\nexport class TypeAssertionMapping {\n\tfn: TypeAssertionMapper\n\n\tconstructor(fn: TypeAssertionMapper) {\n\t\tthis.fn = fn\n\t}\n}\n\nexport const versionableAssertion =\n\t(fn: AssertFn): AssertFn =>\n\t(expected, actual, ctx) => {\n\t\tif (actual instanceof TypeAssertionMapping) {\n\t\t\tif (!ctx.typeRelationshipAssertionEntries) {\n\t\t\t\tthrowInternalError(\n\t\t\t\t\t`Unexpected missing typeAssertionEntries when passed a TypeAssertionMapper`\n\t\t\t\t)\n\t\t\t}\n\t\t\tfor (const [version, data] of ctx.typeRelationshipAssertionEntries) {\n\t\t\t\tlet errorMessage = \"\"\n\t\t\t\ttry {\n\t\t\t\t\tconst mapped = actual.fn(data, ctx)\n\t\t\t\t\tif (mapped !== null) {\n\t\t\t\t\t\tfn(\n\t\t\t\t\t\t\t\"expected\" in mapped ? mapped.expected : expected,\n\t\t\t\t\t\t\tmapped.actual,\n\t\t\t\t\t\t\tctx\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\terrorMessage += `❌TypeScript@${version}:${e}\\n`\n\t\t\t\t}\n\t\t\t\tif (errorMessage) {\n\t\t\t\t\tthrowAssertionError({\n\t\t\t\t\t\tstack: ctx.assertionStack,\n\t\t\t\t\t\tmessage: errorMessage\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t} else fn(expected, actual, ctx)\n\t}\n\nconst unversionedAssertEquals: AssertFn = (expected, actual, ctx) => {\n\tif (expected === actual) return\n\n\ttry {\n\t\tif (\n\t\t\ttypeof expected === \"object\" &&\n\t\t\texpected !== null &&\n\t\t\ttypeof actual === \"object\" &&\n\t\t\tactual !== null\n\t\t) {\n\t\t\tif (expected.constructor === actual.constructor)\n\t\t\t\tassert.deepStrictEqual(actual, expected)\n\t\t\telse {\n\t\t\t\tconst serializedExpected = printable(expected)\n\t\t\t\tconst serializedActual = printable(actual)\n\t\t\t\tthrow new assert.AssertionError({\n\t\t\t\t\tmessage: `Objects did not have the same constructor:\nExpected: ${serializedExpected}\nActual: ${serializedActual}`,\n\t\t\t\t\texpected: serializedExpected,\n\t\t\t\t\tactual: serializedActual\n\t\t\t\t})\n\t\t\t}\n\t\t} else if (\n\t\t\ttypeof expected === \"object\" ||\n\t\t\ttypeof expected === \"function\" ||\n\t\t\ttypeof actual === \"function\" ||\n\t\t\ttypeof actual === \"function\"\n\t\t) {\n\t\t\tconst serializedExpected = printable(expected)\n\t\t\tconst serializedActual = printable(actual)\n\t\t\tthrow new assert.AssertionError({\n\t\t\t\tmessage: `Assertion including at least one function or object was not between reference equal items\nExpected: ${serializedExpected}\nActual: ${serializedActual}`,\n\t\t\t\texpected: serializedExpected,\n\t\t\t\tactual: serializedActual\n\t\t\t})\n\t\t\t// guaranteed to be two primitives at this point\n\t\t} else assert.equal(actual, expected)\n\t} catch (e: any) {\n\t\t// some nonsense to get a good stack trace\n\t\te.stack = ctx.assertionStack\n\t\tthrow e\n\t}\n}\n\nexport const assertEquals: AssertFn = versionableAssertion(\n\tunversionedAssertEquals\n)\n\nconst unversionedAssertSatisfies = (\n\tt: type.Any,\n\tdata: unknown,\n\tctx: AssertionContext\n) => {\n\ttry {\n\t\tt.assert(data)\n\t} catch (e: any) {\n\t\te.stack = ctx.assertionStack\n\t\tthrow e\n\t}\n}\n\nexport const assertSatisfies = versionableAssertion(\n\tunversionedAssertSatisfies as never\n)\n\nexport const typeEqualityMapping: TypeAssertionMapping =\n\tnew TypeAssertionMapping(data => {\n\t\tconst expected = data.typeArgs[0]\n\t\tconst actual = data.typeArgs[1] ?? data.args[0]\n\t\tif (!expected || !actual)\n\t\t\tthrowInternalError(`Unexpected type data ${printable(data)}`)\n\n\t\tif (actual.relationships.typeArgs[0] !== \"equality\") {\n\t\t\treturn {\n\t\t\t\texpected: expected.type,\n\t\t\t\tactual:\n\t\t\t\t\texpected.type === actual.type ?\n\t\t\t\t\t\t\"(serializes to same value)\"\n\t\t\t\t\t:\tactual.type\n\t\t\t}\n\t\t}\n\t\treturn null\n\t})\n\nexport const assertEqualOrMatching: AssertFn = versionableAssertion(\n\t(expected, actual, ctx) => {\n\t\tconst assertionArgs = { actual, expected, stack: ctx.assertionStack }\n\t\tif (typeof actual !== \"string\") {\n\t\t\tthrowAssertionError({\n\t\t\t\tmessage: `Value was of type ${typeof actual} (expected a string).`,\n\t\t\t\t...assertionArgs\n\t\t\t})\n\t\t} else if (typeof expected === \"string\") {\n\t\t\tif (!actual.includes(expected)) {\n\t\t\t\tthrowAssertionError({\n\t\t\t\t\tmessage: `Expected string '${expected}' did not appear in actual string '${actual}'.`,\n\t\t\t\t\t...assertionArgs\n\t\t\t\t})\n\t\t\t}\n\t\t} else if (expected instanceof RegExp) {\n\t\t\tif (!expected.test(actual)) {\n\t\t\t\tthrowAssertionError({\n\t\t\t\t\tmessage: `Actual string '${actual}' did not match regex '${expected.source}'.`,\n\t\t\t\t\t...assertionArgs\n\t\t\t\t})\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new Error(\n\t\t\t\t`Expected value for this assertion should be a string or RegExp.`\n\t\t\t)\n\t\t}\n\t}\n)\n\nexport type AssertedFnCallResult = {\n\treturned?: unknown\n\tthrew?: string\n}\nexport const getThrownMessage = (\n\tresult: AssertedFnCallResult,\n\tctx: AssertionContext\n): string | undefined => {\n\tif (!(\"threw\" in result)) {\n\t\tthrowAssertionError({\n\t\t\tmessage: \"Function didn't throw\",\n\t\t\tstack: ctx.assertionStack\n\t\t})\n\t}\n\n\treturn result.threw\n}\nexport const callAssertedFunction = (\n\tasserted: Function\n): AssertedFnCallResult => {\n\tconst result: AssertedFnCallResult = {}\n\ttry {\n\t\tresult.returned = asserted()\n\t} catch (error) {\n\t\tresult.threw = String(error)\n\t}\n\treturn result\n}\n"
  },
  {
    "path": "ark/attest/assert/attest.ts",
    "content": "import { caller, getCallStack, type SourcePosition } from \"@ark/fs\"\nimport type { ErrorMessage } from \"@ark/util\"\nimport { getBenchCtx } from \"../bench/bench.ts\"\nimport type { Measure } from \"../bench/measure.ts\"\nimport { instantiationDataHandler } from \"../bench/type.ts\"\nimport {\n\tgetTypeAssertionsAtPosition,\n\ttype VersionedTypeAssertion\n} from \"../cache/getCachedAssertions.ts\"\nimport { getConfig, type AttestConfig } from \"../config.ts\"\nimport {\n\tassertEquals,\n\ttypeEqualityMapping,\n\ttype TypeAssertionMapping\n} from \"./assertions.ts\"\nimport {\n\tChainableAssertions,\n\ttype AssertionKind,\n\ttype rootAssertions\n} from \"./chainableAssertions.ts\"\n\nexport type AttestFn = {\n\t<expected, actual extends expected = never>(\n\t\t...args: actual extends never ?\n\t\t\t[\n\t\t\t\tErrorMessage<\"Type-only assertion requires two explicit generic params, e.g. attest<expected, actual>\">\n\t\t\t]\n\t\t:\t[]\n\t): void\n\n\t<expected>(actual: expected): rootAssertions<expected, AssertionKind>\n\n\tinstantiations: (count?: Measure<\"instantiations\"> | undefined) => void\n}\n\nexport type VersionableActual = {} | null | undefined | TypeAssertionMapping\n\nexport type AssertionContext = {\n\tversionableActual: VersionableActual\n\toriginalAssertedValue: unknown\n\tcfg: AttestConfig\n\tallowRegex: boolean\n\tposition: SourcePosition\n\tdefaultExpected?: unknown\n\tassertionStack: string\n\ttypeRelationshipAssertionEntries?: VersionedTypeAssertion<\"type\">[]\n\ttypeBenchmarkingAssertionEntries?: VersionedTypeAssertion<\"bench\">[]\n\tlastSnapName?: string\n}\n\nexport type InternalAssertionHooks = {\n\t[k in keyof AssertionContext]?: k extends \"cfg\" ? Partial<AttestConfig>\n\t:\tAssertionContext[k]\n}\n\nexport const attestInternal = (\n\tvalue?: unknown,\n\t{ cfg: cfgHooks, ...ctxHooks }: InternalAssertionHooks = {}\n): ChainableAssertions => {\n\tconst position = caller()\n\tconst cfg = { ...getConfig(), ...cfgHooks }\n\tconst ctx: AssertionContext = {\n\t\tversionableActual: value,\n\t\tallowRegex: false,\n\t\toriginalAssertedValue: value,\n\t\tposition,\n\t\tcfg,\n\t\tassertionStack: getCallStack({ offset: 1 }).join(\"\\n\"),\n\t\t...ctxHooks\n\t}\n\tif (!cfg.skipTypes) {\n\t\tctx.typeRelationshipAssertionEntries = getTypeAssertionsAtPosition(position)\n\t\tif (ctx.typeRelationshipAssertionEntries[0]?.[1].typeArgs[0]) {\n\t\t\t// if there is an expected type arg, check it immediately\n\t\t\tassertEquals(undefined, typeEqualityMapping, ctx)\n\t\t}\n\t}\n\treturn new ChainableAssertions(ctx)\n}\n\nexport const attest: AttestFn = Object.assign(attestInternal, {\n\tinstantiations: (args: Measure<\"instantiations\"> | undefined) => {\n\t\tconst attestConfig = getConfig()\n\t\tif (attestConfig.skipTypes || attestConfig.skipInlineInstantiations) return\n\n\t\tconst calledFrom = caller()\n\t\tconst ctx = getBenchCtx([calledFrom.file])\n\t\tctx.benchCallPosition = calledFrom\n\t\tctx.lastSnapCallPosition = calledFrom\n\t\tinstantiationDataHandler(\n\t\t\t{ ...ctx, lastSnapFunctionName: \"instantiations\" },\n\t\t\targs,\n\t\t\tfalse\n\t\t)\n\t}\n}) as never\n"
  },
  {
    "path": "ark/attest/assert/chainableAssertions.ts",
    "content": "import { caller, positionToString } from \"@ark/fs\"\nimport {\n\tprintable,\n\tsnapshot,\n\ttype Constructor,\n\ttype ErrorType,\n\ttype isDisjoint\n} from \"@ark/util\"\nimport prettier from \"@prettier/sync\"\nimport { type } from \"arktype\"\nimport * as assert from \"node:assert/strict\"\nimport { isDeepStrictEqual } from \"node:util\"\nimport {\n\tgetSnapshotByName,\n\tqueueSnapshotUpdate,\n\tupdateExternalSnapshot,\n\ttype SnapshotArgs\n} from \"../cache/snapshots.ts\"\nimport type { Completions } from \"../cache/writeAssertionCache.ts\"\nimport { getConfig } from \"../config.ts\"\nimport { chainableNoOpProxy } from \"../utils.ts\"\nimport {\n\tMissingSnapshotError,\n\tTypeAssertionMapping,\n\tassertEqualOrMatching,\n\tassertEquals,\n\tassertSatisfies,\n\tcallAssertedFunction,\n\tgetThrownMessage,\n\tthrowAssertionError\n} from \"./assertions.ts\"\nimport type { AssertionContext, VersionableActual } from \"./attest.ts\"\n\nexport type ChainableAssertionOptions = {\n\tallowRegex?: boolean\n\tdefaultExpected?: unknown\n}\n\ntype AssertionRecord = Record<keyof rootAssertions<any, AssertionKind>, unknown>\n\nexport type UnwrapOptions = {\n\tversionable?: boolean\n\tserialize?: boolean\n}\n\nexport class ChainableAssertions implements AssertionRecord {\n\tprivate ctx: AssertionContext\n\n\tconstructor(ctx: AssertionContext) {\n\t\tthis.ctx = ctx\n\t}\n\n\tprivate get unversionedActual(): unknown {\n\t\tif (this.versionableActual instanceof TypeAssertionMapping) {\n\t\t\treturn this.versionableActual.fn(\n\t\t\t\tthis.ctx.typeRelationshipAssertionEntries![0][1],\n\t\t\t\tthis.ctx\n\t\t\t)!.actual\n\t\t}\n\t\treturn this.versionableActual\n\t}\n\n\tprivate get versionableActual(): VersionableActual {\n\t\treturn this.ctx.versionableActual\n\t}\n\n\tprivate get serializedActual(): unknown {\n\t\treturn snapshot(this.unversionedActual)\n\t}\n\n\tunwrap(opts?: UnwrapOptions): unknown {\n\t\tconst value =\n\t\t\topts?.versionable ? this.versionableActual : this.unversionedActual\n\t\treturn opts?.serialize ? snapshot(value) : value\n\t}\n\n\tprivate snapRequiresUpdate(expectedSerialized: unknown) {\n\t\treturn (\n\t\t\t!isDeepStrictEqual(this.serializedActual, expectedSerialized) ||\n\t\t\t// If actual is undefined, we still need to write the \"undefined\" literal\n\t\t\t// to the snap even though it will serialize to the same value as the (nonexistent) first arg\n\t\t\tthis.unversionedActual === undefined\n\t\t)\n\t}\n\n\tget unknown(): this {\n\t\treturn this\n\t}\n\n\tis(expected: unknown): this {\n\t\tassert.equal(this.unversionedActual, expected)\n\t\treturn this\n\t}\n\n\tequals(expected: unknown): this {\n\t\tassertEquals(expected, this.versionableActual, this.ctx)\n\t\treturn this\n\t}\n\n\tsatisfies(def: unknown): this {\n\t\tassertSatisfies(type.raw(def), this.versionableActual, this.ctx)\n\t\treturn this\n\t}\n\n\tinstanceOf(expected: Constructor): this {\n\t\tif (!(this.versionableActual instanceof expected)) {\n\t\t\tthrowAssertionError({\n\t\t\t\tstack: this.ctx.assertionStack,\n\t\t\t\tmessage: `Expected an instance of ${expected.name} (was ${\n\t\t\t\t\t(\n\t\t\t\t\t\ttypeof this.versionableActual === \"object\" &&\n\t\t\t\t\t\tthis.versionableActual !== null\n\t\t\t\t\t) ?\n\t\t\t\t\t\tthis.versionableActual.constructor.name\n\t\t\t\t\t:\tthis.serializedActual\n\t\t\t\t})`\n\t\t\t})\n\t\t}\n\t\treturn this\n\t}\n\n\tget snap(): snapProperty<unknown, AssertionKind> {\n\t\t// Use variadic args to distinguish undefined being passed explicitly from no args\n\t\tconst inline = (...args: unknown[]) => {\n\t\t\tconst snapName = this.ctx.lastSnapName ?? \"snap\"\n\t\t\tconst expectedSerialized = snapshot(args[0])\n\t\t\tif (!args.length || this.ctx.cfg.updateSnapshots) {\n\t\t\t\tconst position = caller()\n\t\t\t\tif (this.ctx.cfg.failOnMissingSnapshots) {\n\t\t\t\t\tthrow new MissingSnapshotError(\n\t\t\t\t\t\t`.${snapName}() at ${positionToString(position)} must be populated.`\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (this.snapRequiresUpdate(expectedSerialized)) {\n\t\t\t\t\tconst snapshotArgs: SnapshotArgs = {\n\t\t\t\t\t\tposition,\n\t\t\t\t\t\tserializedValue: this.serializedActual,\n\t\t\t\t\t\tsnapFunctionName: snapName\n\t\t\t\t\t}\n\t\t\t\t\tqueueSnapshotUpdate(snapshotArgs)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// compare as strings, but if match fails, compare again as objects\n\t\t\t\t// to give a clearer error message. This avoid problems with objects\n\t\t\t\t// like subtypes of array that do not pass node's deep equality test\n\t\t\t\t// but serialize to the same value.\n\t\t\t\tif (printable(args[0]) !== printable(this.unversionedActual))\n\t\t\t\t\tassertEquals(expectedSerialized, this.serializedActual, this.ctx)\n\t\t\t}\n\t\t\treturn this\n\t\t}\n\t\tconst toFile = (id: string, opts?: ExternalSnapshotOptions) => {\n\t\t\tconst expectedSnapshot = getSnapshotByName(\n\t\t\t\tthis.ctx.position.file,\n\t\t\t\tid,\n\t\t\t\topts?.path\n\t\t\t)\n\t\t\tif (!expectedSnapshot || this.ctx.cfg.updateSnapshots) {\n\t\t\t\tif (this.snapRequiresUpdate(expectedSnapshot)) {\n\t\t\t\t\tupdateExternalSnapshot({\n\t\t\t\t\t\tserializedValue: this.serializedActual,\n\t\t\t\t\t\tposition: caller(),\n\t\t\t\t\t\tname: id,\n\t\t\t\t\t\tcustomPath: opts?.path\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t} else assertEquals(expectedSnapshot, this.serializedActual, this.ctx)\n\n\t\t\treturn this\n\t\t}\n\t\treturn Object.assign(inline, {\n\t\t\ttoFile,\n\t\t\tunwrap: this.unwrap.bind(this)\n\t\t})\n\t}\n\n\tprivate immediateOrChained() {\n\t\tconst immediateAssertion = (...args: [expected: unknown]) => {\n\t\t\tlet expected\n\t\t\tif (args.length) expected = args[0]\n\t\t\telse {\n\t\t\t\tif (\"defaultExpected\" in this.ctx) expected = this.ctx.defaultExpected\n\t\t\t\telse {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Assertion call requires an arg representing the expected value.`\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this.ctx.allowRegex)\n\t\t\t\tassertEqualOrMatching(expected, this.versionableActual, this.ctx)\n\t\t\telse assertEquals(expected, this.versionableActual, this.ctx)\n\n\t\t\treturn this\n\t\t}\n\t\treturn new Proxy(immediateAssertion, {\n\t\t\tget: (target, prop) => (this as any)[prop]\n\t\t})\n\t}\n\n\tget throws(): unknown {\n\t\tconst result = callAssertedFunction(this.unversionedActual as Function)\n\t\tthis.ctx.versionableActual = getThrownMessage(result, this.ctx)\n\t\tthis.ctx.allowRegex = true\n\t\tthis.ctx.defaultExpected = \"\"\n\t\treturn this.immediateOrChained()\n\t}\n\n\tthrowsAndHasTypeError(matchValue: string | RegExp): void {\n\t\tassertEqualOrMatching(\n\t\t\tmatchValue,\n\t\t\tgetThrownMessage(\n\t\t\t\tcallAssertedFunction(this.unversionedActual as Function),\n\t\t\t\tthis.ctx\n\t\t\t),\n\t\t\tthis.ctx\n\t\t)\n\t\tif (!this.ctx.cfg.skipTypes) {\n\t\t\tassertEqualOrMatching(\n\t\t\t\tmatchValue,\n\t\t\t\tnew TypeAssertionMapping(data => ({\n\t\t\t\t\tactual: data.errors.join(\"\\n\")\n\t\t\t\t})),\n\t\t\t\tthis.ctx\n\t\t\t)\n\t\t}\n\t}\n\n\tget completions(): any {\n\t\tif (this.ctx.cfg.skipTypes) return chainableNoOpProxy\n\n\t\tthis.ctx.versionableActual = new TypeAssertionMapping(data => {\n\t\t\tif (typeof data.completions === \"string\") {\n\t\t\t\t// if the completions were ambiguously defined, e.g. two string\n\t\t\t\t// literals with the same value, they are writen as an error\n\t\t\t\t// message to the JSON. Throw it immediately.\n\t\t\t\tthrow new Error(data.completions)\n\t\t\t}\n\t\t\treturn { actual: data.completions }\n\t\t})\n\t\tthis.ctx.lastSnapName = \"completions\"\n\t\treturn this.snap\n\t}\n\n\tget jsdoc(): any {\n\t\tif (this.ctx.cfg.skipTypes) return chainableNoOpProxy\n\n\t\tthis.ctx.versionableActual = new TypeAssertionMapping(data => ({\n\t\t\tactual: formatTypeString(data.jsdoc ?? \"\")\n\t\t}))\n\t\tthis.ctx.allowRegex = true\n\t\treturn this.immediateOrChained()\n\t}\n\n\tget type(): any {\n\t\tif (this.ctx.cfg.skipTypes) return chainableNoOpProxy\n\n\t\t// We need to bind this to return an object with getters\n\t\tconst self = this\n\t\treturn {\n\t\t\tget toString() {\n\t\t\t\tself.ctx.versionableActual = new TypeAssertionMapping(data => ({\n\t\t\t\t\tactual: formatTypeString(data.args[0].type)\n\t\t\t\t}))\n\t\t\t\tself.ctx.allowRegex = true\n\t\t\t\treturn self.immediateOrChained()\n\t\t\t},\n\t\t\tget errors() {\n\t\t\t\tself.ctx.versionableActual = new TypeAssertionMapping(data => ({\n\t\t\t\t\tactual: data.errors.join(\"\\n\")\n\t\t\t\t}))\n\t\t\t\tself.ctx.allowRegex = true\n\t\t\t\treturn self.immediateOrChained()\n\t\t\t},\n\t\t\tget completions() {\n\t\t\t\treturn self.completions\n\t\t\t}\n\t\t}\n\t}\n}\n\nconst declarationPrefix = \"type T = \"\n\nconst formatTypeString = (typeString: string) =>\n\tprettier\n\t\t.format(`${declarationPrefix}${typeString}`, {\n\t\t\tsemi: false,\n\t\t\tprintWidth: 60,\n\t\t\ttrailingComma: \"none\",\n\t\t\tparser: \"typescript\",\n\t\t\t...getConfig().typeToStringFormat\n\t\t})\n\t\t.slice(declarationPrefix.length)\n\t\t.trimEnd()\n\nexport type AssertionKind = \"value\" | \"type\"\n\nexport type rootAssertions<t, kind extends AssertionKind> = valueAssertions<\n\tt,\n\tkind\n> &\n\tTypeAssertionsRoot\n\nexport type valueAssertions<\n\tt,\n\tkind extends AssertionKind\n> = comparableValueAssertion<t, kind> &\n\t([t] extends [() => unknown] ? functionAssertions<kind> : {})\n\nexport type nextAssertions<kind extends AssertionKind> =\n\t\"type\" extends kind ? TypeAssertionsRoot : {}\n\nexport type inferredAssertions<\n\targsType extends [value: any, ...rest: any[]],\n\tkind extends AssertionKind,\n\tchained = argsType[0]\n> = rootAssertions<chained, kind> &\n\t(<Args extends argsType | [] = []>(...args: Args) => nextAssertions<kind>)\n\nexport type ChainContext = {\n\tallowRegex?: boolean\n\tdefaultExpected?: unknown\n}\n\nexport type functionAssertions<kind extends AssertionKind> = {\n\tthrows: inferredAssertions<[message: string | RegExp], kind, string>\n} & (\"type\" extends kind ?\n\t{\n\t\tthrowsAndHasTypeError: (message: string | RegExp) => undefined\n\t}\n:\t{})\n\nexport type valueFromTypeAssertion<\n\texpected,\n\tchained = expected\n> = inferredAssertions<[expected: expected], \"value\", chained>\n\ntype snapProperty<expected, kind extends AssertionKind> = {\n\t(expected?: snapshot<expected>): nextAssertions<kind>\n\ttoFile: (\n\t\tid: string,\n\t\toptions?: ExternalSnapshotOptions\n\t) => nextAssertions<kind>\n\tunwrap: Unwrapper<expected>\n}\n\nexport type Unwrapper<expected = unknown> = (opts?: UnwrapOptions) => expected\n\nexport const nonOverlappingSatisfiesMessage =\n\t\"This type has no overlap with your satisfies constraint\"\n\nexport type nonOverlappingSatisfiesMessage =\n\ttypeof nonOverlappingSatisfiesMessage\n\ntype validateExpectedOverlaps<expected, satisfies> =\n\tisDisjoint<expected, satisfies> extends true ?\n\t\tErrorType<nonOverlappingSatisfiesMessage>\n\t:\tunknown\n\nexport type comparableValueAssertion<expected, kind extends AssertionKind> = {\n\tsnap: snapProperty<expected, kind>\n\tequals: (value: expected) => nextAssertions<kind>\n\tinstanceOf: (constructor: Constructor) => nextAssertions<kind>\n\tis: (value: expected) => nextAssertions<kind>\n\tcompletions: CompletionsSnap\n\tjsdoc: comparableValueAssertion<string, kind>\n\tsatisfies: <const def>(\n\t\tdef: type.validate<def> &\n\t\t\tvalidateExpectedOverlaps<expected, type.infer.In<def>>\n\t) => nextAssertions<kind>\n\t// This can be used to assert values without type constraints\n\tunknown: Omit<comparableValueAssertion<unknown, kind>, \"unknown\">\n\tunwrap: Unwrapper<expected>\n}\n\nexport interface CompletionsSnap {\n\t(value?: Completions): void\n\tunwrap: Unwrapper<Completions>\n}\n\nexport type TypeAssertionsRoot = {\n\ttype: TypeAssertionProps\n}\n\nexport type TypeAssertionProps = {\n\ttoString: valueFromTypeAssertion<string | RegExp>\n\terrors: valueFromTypeAssertion<string | RegExp, string>\n\tcompletions: CompletionsSnap\n}\n\nexport type ExternalSnapshotOptions = {\n\tpath?: string\n}\n"
  },
  {
    "path": "ark/attest/bench/await1k.ts",
    "content": "export const await1K = async (fn: () => Promise<void>): Promise<void> => {\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n\tawait fn()\n}\n"
  },
  {
    "path": "ark/attest/bench/baseline.ts",
    "content": "import { snapshot, throwInternalError } from \"@ark/util\"\nimport process from \"node:process\"\nimport { throwAssertionError } from \"../assert/assertions.ts\"\nimport {\n\tqueueSnapshotUpdate,\n\twriteSnapshotUpdatesOnExit\n} from \"../cache/snapshots.ts\"\nimport type { BenchContext } from \"./bench.ts\"\nimport {\n\tstringifyMeasure,\n\ttype MarkMeasure,\n\ttype Measure,\n\ttype MeasureComparison\n} from \"./measure.ts\"\n\nexport const queueBaselineUpdateIfNeeded = (\n\tupdated: Measure | MarkMeasure,\n\tbaseline: Measure | MarkMeasure | undefined,\n\tctx: BenchContext\n): void => {\n\t// If we already have a baseline and the user didn't pass an update flag, do nothing\n\tif (baseline && !ctx.cfg.updateSnapshots) return\n\n\tconst serializedValue = snapshot(updated)\n\tif (!ctx.lastSnapCallPosition) {\n\t\tthrowInternalError(\n\t\t\t`Unable to update baseline for ${ctx.qualifiedName} ('lastSnapCallPosition' was unset)`\n\t\t)\n\t}\n\tif (!ctx.lastSnapFunctionName) {\n\t\tthrowInternalError(\n\t\t\t`Unable to update baseline for ${ctx.qualifiedName} ('lastSnapFunctionName' was unset)`\n\t\t)\n\t}\n\tqueueSnapshotUpdate({\n\t\tposition: ctx.lastSnapCallPosition,\n\t\tserializedValue,\n\t\tsnapFunctionName: ctx.lastSnapFunctionName,\n\t\tbaselinePath: ctx.qualifiedPath\n\t})\n\n\tif (ctx.benchCallPosition) writeSnapshotUpdatesOnExit()\n}\n\n/** Pretty print comparison and set the process.exitCode to 1 if delta threshold is exceeded */\nexport const compareToBaseline = (\n\tresult: MeasureComparison,\n\tctx: BenchContext\n): void => {\n\tconsole.log(`⛳ Result: ${stringifyMeasure(result.updated)}`)\n\tif (result.baseline && !ctx.cfg.updateSnapshots) {\n\t\tconsole.log(`🎯 Baseline: ${stringifyMeasure(result.baseline)}`)\n\t\tconst delta =\n\t\t\t((result.updated[0] - result.baseline[0]) / result.baseline[0]) * 100\n\t\tconst formattedDelta = `${delta.toFixed(2)}%`\n\t\tif (delta > ctx.cfg.benchPercentThreshold)\n\t\t\thandlePositiveDelta(formattedDelta, ctx)\n\t\telse if (delta < -ctx.cfg.benchPercentThreshold)\n\t\t\thandleNegativeDelta(formattedDelta, ctx)\n\t\telse console.log(`📊 Delta: ${delta > 0 ? \"+\" : \"\"}${formattedDelta}`)\n\t\t// add an extra newline\n\t\tconsole.log()\n\t}\n}\n\nconst handlePositiveDelta = (formattedDelta: string, ctx: BenchContext) => {\n\tconst message = `'${ctx.qualifiedName}' exceeded baseline by ${formattedDelta} (threshold is ${ctx.cfg.benchPercentThreshold}%).`\n\tconsole.error(`📈 ${message}`)\n\tconst benchErrorConfig = ctx.cfg.benchErrorOnThresholdExceeded\n\tconst isTypeBench = ctx.lastSnapFunctionName === \"instantiations\"\n\tconst shouldError =\n\t\tbenchErrorConfig === true ||\n\t\t(isTypeBench ?\n\t\t\tbenchErrorConfig === \"types\"\n\t\t:\tbenchErrorConfig === \"runtime\")\n\tif (shouldError) {\n\t\tconst errorSummary = `❌ ${message}`\n\t\tif (ctx.lastSnapFunctionName === \"instantiations\")\n\t\t\tthrowAssertionError({ stack: ctx.assertionStack, message: errorSummary })\n\t\telse {\n\t\t\tprocess.exitCode = 1\n\t\t\t// Summarize failures at the end of output\n\t\t\tprocess.on(\"exit\", () => {\n\t\t\t\tconsole.error(errorSummary)\n\t\t\t})\n\t\t}\n\t}\n}\n\nconst handleNegativeDelta = (formattedDelta: string, ctx: BenchContext) => {\n\tconsole.log(\n\t\t// Remove the leading negative when formatting our delta\n\t\t`📉 ${ctx.qualifiedName} was under baseline by ${formattedDelta.slice(\n\t\t\t1\n\t\t)}! Consider setting a new baseline.`\n\t)\n}\n"
  },
  {
    "path": "ark/attest/bench/bench.ts",
    "content": "import { caller, getCallStack, rmRf, type SourcePosition } from \"@ark/fs\"\nimport { performance } from \"node:perf_hooks\"\nimport {\n\tensureCacheDirs,\n\tgetConfig,\n\ttype ParsedAttestConfig\n} from \"../config.ts\"\nimport { chainableNoOpProxy } from \"../utils.ts\"\nimport { await1K } from \"./await1k.ts\"\nimport { compareToBaseline, queueBaselineUpdateIfNeeded } from \"./baseline.ts\"\nimport { call1K } from \"./call1k.ts\"\nimport {\n\tcreateTimeComparison,\n\tcreateTimeMeasure,\n\ttype MarkMeasure,\n\ttype Measure,\n\ttype TimeUnit\n} from \"./measure.ts\"\nimport { createBenchTypeAssertion, type BenchTypeAssertions } from \"./type.ts\"\n\nexport type StatName = keyof typeof stats\n\nexport type TimeAssertionName = StatName | \"mark\"\n\nlet benchHasRun = false\n\ntype BenchFn = <fn extends BenchableFunction>(\n\tname: string,\n\tfn: fn,\n\toptions?: BenchOptions\n) => InitialBenchAssertions<fn>\n\nexport interface Bench extends BenchFn {\n\tbaseline: <T>(baselineExpressions: () => T) => void\n}\n\nconst benchFn: BenchFn = (name, fn, options) => {\n\tconst qualifiedPath = [...currentSuitePath, name]\n\tconsole.log(`🏌️  ${qualifiedPath.join(\"/\")}`)\n\tconst ctx = getBenchCtx(\n\t\tqualifiedPath,\n\t\tfn.constructor.name === \"AsyncFunction\",\n\t\toptions\n\t)\n\n\tif (!benchHasRun) {\n\t\trmRf(ctx.cfg.cacheDir)\n\t\tensureCacheDirs()\n\t\tbenchHasRun = true\n\t}\n\n\tctx.benchCallPosition = caller()\n\n\tif (\n\t\ttypeof ctx.cfg.filter === \"string\" &&\n\t\t!qualifiedPath.includes(ctx.cfg.filter)\n\t)\n\t\treturn chainableNoOpProxy\n\telse if (\n\t\tArray.isArray(ctx.cfg.filter) &&\n\t\tctx.cfg.filter.some((segment, i) => segment !== qualifiedPath[i])\n\t)\n\t\treturn chainableNoOpProxy\n\n\tconst assertions = new BenchAssertions(fn, ctx)\n\tObject.assign(assertions, createBenchTypeAssertion(ctx))\n\treturn assertions as never\n}\n\nexport const bench: Bench = Object.assign(benchFn, {\n\tbaseline: () => {}\n})\n\nexport const stats = {\n\tmean: (callTimes: number[]): number => {\n\t\tconst totalCallMs = callTimes.reduce((sum, duration) => sum + duration, 0)\n\t\treturn totalCallMs / callTimes.length\n\t},\n\tmedian: (callTimes: number[]): number => {\n\t\tconst middleIndex = Math.floor(callTimes.length / 2)\n\t\tconst ms =\n\t\t\tcallTimes.length % 2 === 0 ?\n\t\t\t\t(callTimes[middleIndex - 1] + callTimes[middleIndex]) / 2\n\t\t\t:\tcallTimes[middleIndex]\n\t\treturn ms\n\t}\n}\n\nclass ResultCollector {\n\tresults: number[] = []\n\tprivate benchStart = performance.now()\n\tprivate bounds: Required<UntilOptions>\n\tprivate lastInvocationStart: number\n\tprivate ctx: BenchContext\n\n\tconstructor(ctx: BenchContext) {\n\t\tthis.ctx = ctx\n\t\t// By default, will run for either 5 seconds or 100_000 call sets (of 1000 calls), whichever comes first\n\t\tthis.bounds = {\n\t\t\tms: 5000,\n\t\t\tcount: 100_000,\n\t\t\t...ctx.options.until\n\t\t}\n\t\tthis.lastInvocationStart = -1\n\t}\n\n\tstart() {\n\t\tthis.ctx.options.hooks?.beforeCall?.()\n\t\tthis.lastInvocationStart = performance.now()\n\t}\n\n\tstop() {\n\t\tthis.results.push((performance.now() - this.lastInvocationStart) / 1000)\n\t\tthis.ctx.options.hooks?.afterCall?.()\n\t}\n\n\tdone() {\n\t\tconst metMsTarget = performance.now() - this.benchStart >= this.bounds.ms\n\t\tconst metCountTarget = this.results.length >= this.bounds.count\n\t\treturn metMsTarget || metCountTarget\n\t}\n}\n\nconst loopCalls = (fn: () => void, ctx: BenchContext) => {\n\tconst collector = new ResultCollector(ctx)\n\twhile (!collector.done()) {\n\t\tcollector.start()\n\t\t// we use a function like this to make 1k explicit calls to the function\n\t\t// to avoid certain optimizations V8 makes when looping\n\t\tcall1K(fn)\n\t\tcollector.stop()\n\t}\n\treturn collector.results\n}\n\nconst loopAsyncCalls = async (fn: () => Promise<void>, ctx: BenchContext) => {\n\tconst collector = new ResultCollector(ctx)\n\twhile (!collector.done()) {\n\t\tcollector.start()\n\t\tawait await1K(fn)\n\t\tcollector.stop()\n\t}\n\treturn collector.results\n}\n\nexport class BenchAssertions<\n\tFn extends BenchableFunction,\n\tNextAssertions = BenchTypeAssertions,\n\tReturnedAssertions = Fn extends () => Promise<void> ? Promise<NextAssertions>\n\t:\tNextAssertions\n> {\n\tprivate label: string\n\tprivate lastCallTimes: number[] | undefined\n\tprivate fn: Fn\n\tprivate ctx: BenchContext\n\n\tconstructor(fn: Fn, ctx: BenchContext) {\n\t\tthis.fn = fn\n\t\tthis.ctx = ctx\n\t\tthis.label = `Call: ${ctx.qualifiedName}`\n\t}\n\n\tprivate applyCallTimeHooks() {\n\t\tif (this.ctx.options.fakeCallMs !== undefined) {\n\t\t\tconst fakeMs =\n\t\t\t\tthis.ctx.options.fakeCallMs === \"count\" ?\n\t\t\t\t\tthis.lastCallTimes!.length\n\t\t\t\t:\tthis.ctx.options.fakeCallMs\n\t\t\tthis.lastCallTimes = this.lastCallTimes!.map(() => fakeMs)\n\t\t}\n\t}\n\n\tprivate callTimesSync() {\n\t\tif (!this.lastCallTimes) {\n\t\t\tthis.lastCallTimes = loopCalls(this.fn as never, this.ctx)\n\t\t\tthis.lastCallTimes.sort()\n\t\t}\n\t\tthis.applyCallTimeHooks()\n\t\treturn this.lastCallTimes\n\t}\n\n\tprivate async callTimesAsync() {\n\t\tif (!this.lastCallTimes) {\n\t\t\tthis.lastCallTimes = await loopAsyncCalls(this.fn as never, this.ctx)\n\t\t\tthis.lastCallTimes.sort()\n\t\t}\n\t\tthis.applyCallTimeHooks()\n\t\treturn this.lastCallTimes\n\t}\n\n\tprivate createAssertion<Name extends TimeAssertionName>(\n\t\tname: Name,\n\t\tbaseline: Name extends \"mark\" ?\n\t\t\tRecord<StatName, Measure<TimeUnit>> | undefined\n\t\t:\tMeasure<TimeUnit> | undefined,\n\t\tcallTimes: number[]\n\t) {\n\t\tif (name === \"mark\") return this.markAssertion(baseline as never, callTimes)\n\n\t\tconst ms: number = stats[name as StatName](callTimes)\n\t\tconst comparison = createTimeComparison(ms, baseline as Measure<TimeUnit>)\n\t\tconsole.group(`${this.label} (${name}):`)\n\t\tcompareToBaseline(comparison, this.ctx)\n\t\tconsole.groupEnd()\n\t\tqueueBaselineUpdateIfNeeded(createTimeMeasure(ms), baseline, {\n\t\t\t...this.ctx,\n\t\t\tlastSnapFunctionName: name\n\t\t})\n\t\treturn this.getNextAssertions()\n\t}\n\n\tprivate markAssertion(\n\t\tbaseline: MarkMeasure | undefined,\n\t\tcallTimes: number[]\n\t) {\n\t\tconsole.group(`${this.label}:`)\n\t\tconst markEntries: [StatName, Measure<TimeUnit> | undefined][] = (\n\t\t\tbaseline ?\n\t\t\t\tObject.entries(baseline)\n\t\t\t\t// If nothing was passed, gather all available baselines by setting their values to undefined.\n\t\t\t:\tObject.entries(stats).map(([kind]) => [kind, undefined])) as never\n\t\tconst markResults = Object.fromEntries(\n\t\t\tmarkEntries.map(([kind, kindBaseline]) => {\n\t\t\t\tconsole.group(kind)\n\t\t\t\tconst ms = stats[kind](callTimes)\n\t\t\t\tconst comparison = createTimeComparison(ms, kindBaseline)\n\t\t\t\tcompareToBaseline(comparison, this.ctx)\n\t\t\t\tconsole.groupEnd()\n\t\t\t\treturn [kind, comparison.updated]\n\t\t\t})\n\t\t)\n\t\tconsole.groupEnd()\n\t\tqueueBaselineUpdateIfNeeded(markResults, baseline, {\n\t\t\t...this.ctx,\n\t\t\tlastSnapFunctionName: \"mark\"\n\t\t})\n\t\treturn this.getNextAssertions()\n\t}\n\n\tprivate getNextAssertions(): NextAssertions {\n\t\treturn createBenchTypeAssertion(this.ctx) as never\n\t}\n\n\tprivate createStatMethod<Name extends TimeAssertionName>(\n\t\tname: Name,\n\t\tbaseline: Name extends \"mark\" ?\n\t\t\tRecord<StatName, Measure<TimeUnit>> | undefined\n\t\t:\tMeasure<TimeUnit> | undefined\n\t) {\n\t\tif (this.ctx.isAsync) {\n\t\t\treturn new Promise(resolve => {\n\t\t\t\tthis.callTimesAsync().then(\n\t\t\t\t\tcallTimes => {\n\t\t\t\t\t\tresolve(this.createAssertion(name, baseline, callTimes))\n\t\t\t\t\t},\n\t\t\t\t\te => {\n\t\t\t\t\t\tthis.addUnhandledBenchException(e)\n\t\t\t\t\t\tresolve(chainableNoOpProxy)\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t})\n\t\t}\n\t\tlet assertions = chainableNoOpProxy\n\t\ttry {\n\t\t\tassertions = this.createAssertion(name, baseline, this.callTimesSync())\n\t\t} catch (e) {\n\t\t\tthis.addUnhandledBenchException(e)\n\t\t}\n\t\treturn assertions\n\t}\n\n\tprivate addUnhandledBenchException(reason: unknown) {\n\t\tconst message = `Bench ${\n\t\t\tthis.ctx.qualifiedName\n\t\t} threw during execution:\\n${String(reason)}`\n\t\tconsole.error(message)\n\t\tunhandledExceptionMessages.push(message)\n\t}\n\n\tmedian(baseline?: Measure<TimeUnit>): ReturnedAssertions {\n\t\tthis.ctx.lastSnapCallPosition = caller()\n\t\tconst assertions = this.createStatMethod(\"median\", baseline)\n\t\treturn assertions\n\t}\n\n\tmean(baseline?: Measure<TimeUnit>): ReturnedAssertions {\n\t\tthis.ctx.lastSnapCallPosition = caller()\n\t\treturn this.createStatMethod(\"mean\", baseline)\n\t}\n\n\tmark(baseline?: MarkMeasure): ReturnedAssertions {\n\t\tthis.ctx.lastSnapCallPosition = caller()\n\t\treturn this.createStatMethod(\"mark\", baseline as never)\n\t}\n}\n\nconst unhandledExceptionMessages: string[] = []\n\nexport type UntilOptions = {\n\tms?: number\n\tcount?: number\n}\n\nexport type BaseBenchOptions = {\n\tuntil?: UntilOptions\n}\n\nexport type BenchOptions = BaseBenchOptions & {\n\thooks?: {\n\t\tbeforeCall?: () => void\n\t\tafterCall?: () => void\n\t}\n}\n\nexport type InternalBenchOptions = BenchOptions & {\n\tfakeCallMs?: number | \"count\"\n}\n\nexport type BenchContext = {\n\tqualifiedPath: string[]\n\tqualifiedName: string\n\toptions: InternalBenchOptions\n\tcfg: ParsedAttestConfig\n\tassertionStack: string\n\tbenchCallPosition: SourcePosition\n\tlastSnapCallPosition: SourcePosition | undefined\n\tlastSnapFunctionName: string | undefined\n\tisAsync: boolean\n}\n\nexport type BenchableFunction = () => unknown | Promise<unknown>\n\nexport type InitialBenchAssertions<Fn extends BenchableFunction> =\n\tBenchAssertions<Fn> & BenchTypeAssertions\n\nconst currentSuitePath: string[] = []\n\nprocess.on(\"beforeExit\", () => {\n\tif (unhandledExceptionMessages.length) {\n\t\tconsole.error(\n\t\t\t`${unhandledExceptionMessages.length} unhandled exception(s) occurred during your benches (see details above).`\n\t\t)\n\t\tprocess.exit(1)\n\t}\n})\n\nexport const getBenchCtx = (\n\tqualifiedPath: string[],\n\tisAsync: boolean = false,\n\toptions: BenchOptions = {}\n): BenchContext => ({\n\tqualifiedPath,\n\tqualifiedName: qualifiedPath.join(\"/\"),\n\toptions,\n\tcfg: getConfig(),\n\tbenchCallPosition: caller(),\n\tlastSnapCallPosition: undefined,\n\tlastSnapFunctionName: undefined,\n\tisAsync,\n\tassertionStack: getCallStack({ offset: 1 }).join(\"\\n\")\n})\n"
  },
  {
    "path": "ark/attest/bench/call1k.ts",
    "content": "export const call1K = (fn: () => void): void => {\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n\tfn()\n}\n"
  },
  {
    "path": "ark/attest/bench/measure.ts",
    "content": "import type { StatName } from \"./bench.ts\"\n\ntype MeasureUnit = TimeUnit | TypeUnit\n\nexport type Measure<Unit extends MeasureUnit = MeasureUnit> = [\n\tvalue: number,\n\tunit: Unit\n]\n\nexport type MeasureComparison<Unit extends MeasureUnit = MeasureUnit> = {\n\tupdated: Measure<Unit>\n\tbaseline: Measure<Unit> | undefined\n}\n\nexport type MarkMeasure = Partial<Record<StatName, Measure>>\n\nexport const stringifyMeasure = ([value, units]: Measure): string =>\n\tunits in timeUnitRatios ?\n\t\tstringifyTimeMeasure([value, units as TimeUnit])\n\t:\t`${value} ${units}`\n\nexport const TYPE_UNITS = [\"instantiations\"] as const\n\nexport type TypeUnit = (typeof TYPE_UNITS)[number]\n\nexport const createTypeComparison = (\n\tvalue: number,\n\tbaseline: Measure<TypeUnit> | undefined\n): MeasureComparison<TypeUnit> => ({\n\tupdated: [value, \"instantiations\"],\n\tbaseline\n})\n\nexport const timeUnitRatios = {\n\tns: 0.000_001,\n\tus: 0.001,\n\tms: 1,\n\ts: 1000\n}\n\nexport type TimeUnit = keyof typeof timeUnitRatios\n\nexport const stringifyTimeMeasure = ([\n\tvalue,\n\tunit\n]: Measure<TimeUnit>): string => `${value.toFixed(2)}${unit}`\n\nconst convertTimeUnit = (n: number, from: TimeUnit, to: TimeUnit) =>\n\tround((n * timeUnitRatios[from]) / timeUnitRatios[to], 2)\n\n/**\n * Establish a new baseline using the most appropriate time unit\n */\nexport const createTimeMeasure = (ms: number): Measure<TimeUnit> => {\n\tlet bestMatch: Measure<TimeUnit> | undefined\n\tfor (const u in timeUnitRatios) {\n\t\tconst candidateMeasure = createTimeMeasureForUnit(ms, u as TimeUnit)\n\t\tif (!bestMatch) bestMatch = candidateMeasure\n\t\telse if (bestMatch[0] >= 1) {\n\t\t\tif (candidateMeasure[0] >= 1 && candidateMeasure[0] < bestMatch[0])\n\t\t\t\tbestMatch = candidateMeasure\n\t\t} else if (candidateMeasure[0] >= bestMatch[0]) bestMatch = candidateMeasure\n\t}\n\treturn bestMatch!\n}\n\nconst createTimeMeasureForUnit = (\n\tms: number,\n\tunit: TimeUnit\n): Measure<TimeUnit> => [convertTimeUnit(ms, \"ms\", unit), unit]\n\nconst round = (value: number, decimalPlaces: number) =>\n\tMath.round(value * 10 ** decimalPlaces) / 10 ** decimalPlaces\n\nexport const createTimeComparison = (\n\tms: number,\n\tbaseline: Measure<TimeUnit> | undefined\n): MeasureComparison<TimeUnit> => {\n\tif (baseline) {\n\t\treturn {\n\t\t\tupdated: [convertTimeUnit(ms, \"ms\", baseline[1]), baseline[1]],\n\t\t\tbaseline\n\t\t}\n\t}\n\treturn {\n\t\tupdated: createTimeMeasure(ms),\n\t\tbaseline: undefined\n\t}\n}\n"
  },
  {
    "path": "ark/attest/bench/type.ts",
    "content": "import { caller } from \"@ark/fs\"\nimport { throwInternalError } from \"@ark/util\"\nimport ts from \"typescript\"\nimport { getBenchAssertionsAtPosition } from \"../cache/getCachedAssertions.ts\"\nimport {\n\tTsServer,\n\tgetAbsolutePosition,\n\tgetAncestors,\n\tgetDescendants,\n\tnearestCallExpressionChild\n} from \"../cache/ts.ts\"\nimport {\n\tgetCallExpressionsByName,\n\tgetInstantiationsContributedByNode\n} from \"../cache/utils.ts\"\nimport { getConfig } from \"../config.ts\"\nimport { compareToBaseline, queueBaselineUpdateIfNeeded } from \"./baseline.ts\"\nimport type { BenchContext } from \"./bench.ts\"\nimport {\n\tcreateTypeComparison,\n\ttype Measure,\n\ttype MeasureComparison,\n\ttype TypeUnit\n} from \"./measure.ts\"\n\nexport type BenchTypeAssertions = {\n\ttypes: (instantiations?: Measure<TypeUnit>) => void\n}\n\nexport const createBenchTypeAssertion = (\n\tctx: BenchContext\n): BenchTypeAssertions => ({\n\ttypes: (...args: [instantiations?: Measure<TypeUnit> | undefined]) => {\n\t\tctx.lastSnapCallPosition = caller()\n\t\tinstantiationDataHandler({ ...ctx, lastSnapFunctionName: \"types\" }, args[0])\n\t}\n})\n\nexport const getContributedInstantiations = (ctx: BenchContext): number => {\n\tconst testDeclarationAliases = getConfig().testDeclarationAliases\n\tconst instance = TsServer.instance\n\tconst file = instance.getSourceFileOrThrow(ctx.benchCallPosition.file)\n\n\tconst node = nearestCallExpressionChild(\n\t\tfile,\n\t\tgetAbsolutePosition(file, ctx.benchCallPosition)\n\t)\n\n\tconst firstMatchingNamedCall = getAncestors(node).find(\n\t\tcall => getCallExpressionsByName(call, testDeclarationAliases).length\n\t)\n\n\tif (!firstMatchingNamedCall) {\n\t\tthrow new Error(\n\t\t\t`No call expressions matching the name(s) '${testDeclarationAliases.join()}' were found`\n\t\t)\n\t}\n\n\tconst body = getDescendants(firstMatchingNamedCall).find(\n\t\tnode => ts.isArrowFunction(node) || ts.isFunctionExpression(node)\n\t) as ts.ArrowFunction | ts.FunctionExpression | undefined\n\n\tif (!body)\n\t\tthrowInternalError(\"Unable to retrieve contents of the call expression\")\n\n\treturn getInstantiationsContributedByNode(file, body)\n}\n\nexport const instantiationDataHandler = (\n\tctx: BenchContext,\n\targs?: Measure<TypeUnit>,\n\tisBenchFunction = true\n): void => {\n\tconst instantiationsContributed =\n\t\tisBenchFunction ?\n\t\t\tgetContributedInstantiations(ctx)\n\t\t:\tgetBenchAssertionsAtPosition(ctx.benchCallPosition)[0][1].count\n\n\tconst comparison: MeasureComparison<TypeUnit> = createTypeComparison(\n\t\tinstantiationsContributed,\n\t\targs\n\t)\n\tcompareToBaseline(comparison, ctx)\n\tqueueBaselineUpdateIfNeeded(comparison.updated, args, ctx)\n}\n"
  },
  {
    "path": "ark/attest/cache/getCachedAssertions.ts",
    "content": "import { readJson, type LinePosition, type SourcePosition } from \"@ark/fs\"\nimport { existsSync, readdirSync } from \"node:fs\"\nimport { join } from \"node:path\"\nimport { getConfig } from \"../config.ts\"\nimport { getFileKey } from \"../utils.ts\"\nimport type {\n\tAssertionsByFile,\n\tLinePositionRange,\n\tTypeAssertionData,\n\tTypeAssertionKind\n} from \"./writeAssertionCache.ts\"\n\nexport type VersionedAssertionsByFile = [\n\ttsVersion: string,\n\trelationshipAssertions: AssertionsByFile,\n\tbenchAssertions: AssertionsByFile\n]\n\nlet assertionEntries: VersionedAssertionsByFile[] | undefined\nexport const getCachedAssertionEntries = (): VersionedAssertionsByFile[] => {\n\tif (!assertionEntries) {\n\t\tconst config = getConfig()\n\t\tif (!existsSync(config.assertionCacheDir))\n\t\t\tthrowMissingAssertionDataError(config.assertionCacheDir)\n\n\t\tconst assertionFiles = readdirSync(config.assertionCacheDir)\n\t\tconst relationshipAssertions: AssertionsByFile = {}\n\t\tconst benchAssertions: AssertionsByFile = {}\n\n\t\tassertionEntries = assertionFiles.map(file => {\n\t\t\tconst data = readJson(join(config.assertionCacheDir, file)) as Record<\n\t\t\t\tstring,\n\t\t\t\tTypeAssertionData[]\n\t\t\t>\n\t\t\tfor (const fileName of Object.keys(data)) {\n\t\t\t\tconst relationshipAssertionData = data[fileName].filter(\n\t\t\t\t\t(entry: TypeAssertionData) => \"args\" in entry\n\t\t\t\t)\n\t\t\t\tconst benchAssertionData = data[fileName].filter(\n\t\t\t\t\t(entry: TypeAssertionData) => \"count\" in entry\n\t\t\t\t)\n\t\t\t\trelationshipAssertions[fileName] = relationshipAssertionData\n\t\t\t\tbenchAssertions[fileName] = benchAssertionData\n\t\t\t}\n\t\t\treturn [\n\t\t\t\t// remove .json extension\n\t\t\t\tfile.slice(0, -5),\n\t\t\t\trelationshipAssertions,\n\t\t\t\tbenchAssertions\n\t\t\t]\n\t\t})\n\t}\n\treturn assertionEntries!\n}\n\nconst throwMissingAssertionDataError = (location: string) => {\n\tthrow new Error(\n\t\t`Unable to find precached assertion data at '${location}'. ` +\n\t\t\t`Ensure the 'setup' function from @ark/attest has been called before running your tests.`\n\t)\n}\n\nconst isPositionWithinRange = (\n\t{ line, char }: LinePosition,\n\t{ start, end }: LinePositionRange\n) => {\n\tif (line < start.line || line > end.line) return false\n\n\tif (line === start.line) return char >= start.char\n\n\tif (line === end.line) return char <= end.char\n\n\treturn true\n}\n\nexport type VersionedTypeAssertion<\n\tkind extends TypeAssertionKind = TypeAssertionKind\n> = [tsVersion: string, assertionData: TypeAssertionData<kind>]\n\nconst getAssertionsOfKindAtPosition = <kind extends TypeAssertionKind>(\n\tposition: SourcePosition,\n\tkind: kind\n): VersionedTypeAssertion<kind>[] => {\n\tconst fileKey = getFileKey(position.file)\n\treturn getCachedAssertionEntries().map(\n\t\t([version, typeRelationshipAssertions, BenchAssertionAssertions]) => {\n\t\t\tconst assertions =\n\t\t\t\tkind === \"type\" ? typeRelationshipAssertions : BenchAssertionAssertions\n\t\t\tif (!assertions[fileKey]) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Found no assertion data for '${fileKey}' for TypeScript version ${version}.`\n\t\t\t\t)\n\t\t\t}\n\t\t\tconst matchingAssertion = assertions[fileKey].find(assertion =>\n\t\t\t\t/**\n\t\t\t\t * Depending on the environment, a trace can refer to any of these points\n\t\t\t\t * attest(...)\n\t\t\t\t * ^     ^   ^\n\t\t\t\t * Because of this, it's safest to check if the call came from anywhere in the expected range.\n\t\t\t\t *\n\t\t\t\t */\n\t\t\t\tisPositionWithinRange(position, assertion.location)\n\t\t\t)\n\t\t\tif (!matchingAssertion) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Found no assertion for TypeScript version ${version} at line ${position.line} char ${position.char} in '${fileKey}'.\n\tAre sourcemaps enabled and working properly?`\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn [version, matchingAssertion] as VersionedTypeAssertion<kind>\n\t\t}\n\t)\n}\n\nexport const getTypeAssertionsAtPosition = (\n\tposition: SourcePosition\n): VersionedTypeAssertion<\"type\">[] =>\n\tgetAssertionsOfKindAtPosition(position, \"type\")\n\nexport const getBenchAssertionsAtPosition = (\n\tposition: SourcePosition\n): VersionedTypeAssertion<\"bench\">[] =>\n\tgetAssertionsOfKindAtPosition(position, \"bench\")\n"
  },
  {
    "path": "ark/attest/cache/snapshots.ts",
    "content": "import {\n\tfilePath,\n\tpositionToString,\n\treadFile,\n\treadJson,\n\tshell,\n\twriteFile,\n\twriteJson,\n\ttype SourcePosition\n} from \"@ark/fs\"\nimport { throwInternalError } from \"@ark/util\"\nimport { existsSync } from \"node:fs\"\nimport { basename, dirname, isAbsolute, join } from \"node:path\"\nimport type ts from \"typescript\"\nimport { getConfig } from \"../config.ts\"\nimport { getFileKey } from \"../utils.ts\"\nimport {\n\tTsServer,\n\tgetAbsolutePosition,\n\tnearestCallExpressionChild\n} from \"./ts.ts\"\nimport { getCallExpressionsByName } from \"./utils.ts\"\n\nexport type SnapshotArgs = {\n\tposition: SourcePosition\n\tserializedValue: unknown\n\tsnapFunctionName?: string\n\tbaselinePath?: string[]\n}\n\nexport const resolveSnapshotPath = (\n\ttestFile: string,\n\tcustomPath: string | undefined\n): string => {\n\tif (customPath && isAbsolute(customPath)) return customPath\n\n\treturn join(dirname(testFile), customPath ?? \"assert.snapshots.json\")\n}\n\nexport const getSnapshotByName = (\n\tfile: string,\n\tname: string,\n\tcustomPath: string | undefined\n): object => {\n\tconst snapshotPath = resolveSnapshotPath(file, customPath)\n\treturn (readJson(snapshotPath)?.[basename(file)] as any)?.[name]\n}\n\n/**\n * Writes the update and position to cacheDir, which will eventually be read and copied to the source\n * file by a cleanup process after all tests have completed.\n */\nexport const queueSnapshotUpdate = (args: SnapshotArgs): void => {\n\tconst config = getConfig()\n\tconst path = config.defaultAssertionCachePath\n\tif (existsSync(path)) {\n\t\tconst existing = readJson(path)\n\t\twriteJson(path, {\n\t\t\t...existing,\n\t\t\tupdates:\n\t\t\t\tArray.isArray(existing.updates) ? [...existing.updates, args] : [args]\n\t\t})\n\t} else writeJson(path, { updates: [args] })\n}\n\nexport type QueuedUpdate = {\n\tposition: SourcePosition\n\tsnapCall: ts.CallExpression\n\tsnapFunctionName: string\n\tnewArgText: string\n\tbaselinePath: string[] | undefined\n}\n\nexport type ExternalSnapshotArgs = SnapshotArgs & {\n\tname: string\n\tcustomPath: string | undefined\n}\n\nconst findCallExpressionAncestor = (\n\tposition: SourcePosition,\n\tfunctionName: string\n): ts.CallExpression => {\n\tconst server = TsServer.instance\n\tconst file = server.getSourceFileOrThrow(position.file)\n\tconst absolutePosition = getAbsolutePosition(file, position)\n\tconst startNode = nearestCallExpressionChild(file, absolutePosition)\n\tconst calls = getCallExpressionsByName(startNode, [functionName], true)\n\tif (calls.length) return startNode\n\n\tthrowInternalError(\n\t\t`Unable to locate expected inline ${functionName} call from assertion at ${positionToString(\n\t\t\tposition\n\t\t)}.`\n\t)\n}\n\nexport const updateExternalSnapshot = ({\n\tserializedValue: value,\n\tposition,\n\tname,\n\tcustomPath\n}: ExternalSnapshotArgs): void => {\n\tconst snapshotPath = resolveSnapshotPath(position.file, customPath)\n\tconst snapshotData = readJson(snapshotPath) ?? {}\n\tconst fileKey = basename(position.file)\n\tsnapshotData[fileKey] = {\n\t\t...(snapshotData[fileKey] as object),\n\t\t[name]: value\n\t}\n\twriteJson(snapshotPath, snapshotData)\n}\n\nlet snapshotsWillBeWritten = false\nexport const writeSnapshotUpdatesOnExit = (): void => {\n\tif (snapshotsWillBeWritten) return\n\n\tprocess.on(\"exit\", writeCachedInlineSnapshotUpdates)\n\tsnapshotsWillBeWritten = true\n}\n\nconst writeCachedInlineSnapshotUpdates = () => {\n\tconst config = getConfig()\n\n\tlet snapshotData: SnapshotArgs[] | undefined\n\n\tif (!existsSync(config.defaultAssertionCachePath)) return\n\n\ttry {\n\t\tsnapshotData = readJson(config.defaultAssertionCachePath).updates as never\n\t} catch {\n\t\t// If we can't read the snapshot, log an error and move onto the next update\n\t\tconsole.error(\n\t\t\t`Unable to read snapshot data from expected location ${config.defaultAssertionCachePath}.`\n\t\t)\n\t}\n\tif (snapshotData) {\n\t\ttry {\n\t\t\twriteUpdates(\n\t\t\t\tsnapshotData.map(snapshot => snapshotArgsToQueuedUpdate(snapshot))\n\t\t\t)\n\t\t} catch (error) {\n\t\t\t// If writeInlineSnapshotToFile throws an error, log it and move on to the next update\n\t\t\tconsole.error(String(error))\n\t\t}\n\t}\n}\n\nconst snapshotArgsToQueuedUpdate = ({\n\tposition,\n\tserializedValue,\n\tsnapFunctionName = \"snap\",\n\tbaselinePath\n}: SnapshotArgs): QueuedUpdate => {\n\tconst snapCall = findCallExpressionAncestor(position, snapFunctionName)\n\tlet newArgText =\n\t\ttypeof serializedValue === \"string\" && serializedValue.includes(\"\\n\") ?\n\t\t\t\"`\" + serializedValue.replace(/`/g, \"\\\\`\").replace(/\\${/g, \"\\\\${\") + \"`\"\n\t\t:\tJSON.stringify(serializedValue)\n\n\tnewArgText = newArgText\n\t\t.replace(/\"\\$ark.bigint-(-?\\d+)\"/g, \"$1n\")\n\t\t.replace(/\"\\$ark.undefined\"/g, \"undefined\")\n\n\treturn {\n\t\tposition,\n\t\tsnapCall,\n\t\tsnapFunctionName,\n\t\tnewArgText,\n\t\tbaselinePath\n\t}\n}\n\n// Waiting until process exit to write snapshots avoids invalidating existing source positions\nexport const writeUpdates = (queuedUpdates: QueuedUpdate[]): void => {\n\tif (!queuedUpdates.length) return\n\n\tconst updatesByFile: Record<string, QueuedUpdate[]> = {}\n\tfor (const update of queuedUpdates) {\n\t\tupdatesByFile[update.position.file] ??= []\n\t\tupdatesByFile[update.position.file].push(update)\n\t}\n\tfor (const k in updatesByFile) {\n\t\twriteFileUpdates(\n\t\t\tk,\n\t\t\tupdatesByFile[k].sort((l, r) =>\n\t\t\t\tl.position.line > r.position.line ? 1\n\t\t\t\t: r.position.line > l.position.line ? -1\n\t\t\t\t: l.position.char - r.position.char\n\t\t\t)\n\t\t)\n\t}\n\trunFormatterIfAvailable(queuedUpdates)\n}\n\nconst runFormatterIfAvailable = (queuedUpdates: QueuedUpdate[]) => {\n\tconst { formatCmd: formatter, shouldFormat } = getConfig()\n\tif (!shouldFormat) return\n\n\ttry {\n\t\tconst updatedPaths = [\n\t\t\t...new Set(\n\t\t\t\tqueuedUpdates.map(update =>\n\t\t\t\t\tfilePath(update.snapCall.getSourceFile().fileName)\n\t\t\t\t)\n\t\t\t)\n\t\t]\n\t\tshell(`${formatter} ${updatedPaths.join(\" \")}`)\n\t} catch {\n\t\t// If formatter is unavailable or skipped, do nothing.\n\t}\n}\n\nconst writeFileUpdates = (path: string, updates: QueuedUpdate[]) => {\n\tlet fileText = readFile(path)\n\tlet offSet = 0\n\tfor (const update of updates) {\n\t\tconst previousArgTextLength =\n\t\t\tupdate.snapCall.arguments.end - update.snapCall.arguments.pos\n\t\tfileText =\n\t\t\tfileText.slice(0, update.snapCall.arguments.pos + offSet) +\n\t\t\tupdate.newArgText +\n\t\t\tfileText.slice(update.snapCall.arguments.end + offSet)\n\t\toffSet += update.newArgText.length - previousArgTextLength\n\t\tsummarizeSnapUpdate(update.snapCall.arguments, update)\n\t}\n\twriteFile(path, fileText)\n}\n\nconst summarizeSnapUpdate = (\n\toriginalArgs: ts.NodeArray<ts.Expression>,\n\tupdate: QueuedUpdate\n) => {\n\tlet updateSummary = `${\n\t\toriginalArgs.length ? \"🆙  Updated\" : \"📸  Established\"\n\t} `\n\tupdateSummary +=\n\t\tupdate.baselinePath ?\n\t\t\t`baseline '${update.baselinePath.join(\"/\")}' `\n\t\t:\t`snap at ${getFileKey(update.position.file)}:${update.position.line} `\n\tconst previousValue = update.snapCall.arguments[0]?.getText()\n\tupdateSummary +=\n\t\tpreviousValue ?\n\t\t\t`from ${previousValue} to `\n\t\t:\t`${update.baselinePath ? \"at\" : \"as\"} `\n\n\tupdateSummary += update.newArgText\n\tconsole.log(updateSummary)\n}\n"
  },
  {
    "path": "ark/attest/cache/ts.ts",
    "content": "import { fromCwd, readFile, type SourcePosition } from \"@ark/fs\"\nimport { printable, throwError, throwInternalError, type dict } from \"@ark/util\"\nimport * as tsvfs from \"@typescript/vfs\"\nimport { readFileSync } from \"node:fs\"\nimport { resolve, dirname, join } from \"node:path\"\nimport ts from \"typescript\"\nimport { getConfig } from \"../config.ts\"\n\nexport class TsServer {\n\trootFiles!: string[]\n\tvirtualEnv!: tsvfs.VirtualTypeScriptEnvironment\n\tprogram!: ts.Program\n\n\tprivate static _instance: TsServer | null = null\n\tstatic get instance(): TsServer {\n\t\treturn new TsServer()\n\t}\n\n\tprivate tsConfigInfo!: TsconfigInfo\n\n\tconstructor(tsConfigInfo?: TsconfigInfo) {\n\t\tif (TsServer._instance) return TsServer._instance\n\n\t\tthis.tsConfigInfo = tsConfigInfo ?? getTsConfigInfoOrThrow()\n\n\t\tconst tsLibPaths = getTsLibFiles(this.tsConfigInfo.parsed.options)\n\n\t\t// TS represents windows paths as `C:/Users/ssalb/...`\n\t\tconst normalizedCwd = fromCwd().replace(/\\\\/g, \"/\")\n\n\t\tthis.rootFiles = this.tsConfigInfo.parsed.fileNames.filter(path => {\n\t\t\tif (!path.startsWith(normalizedCwd)) return\n\n\t\t\t// exclude empty files as they lead to a crash\n\t\t\t// when createVirtualTypeScriptEnvironment is called\n\t\t\tconst contents = readFile(path).trim()\n\n\t\t\treturn contents !== \"\"\n\t\t})\n\n\t\tconst system = tsvfs.createFSBackedSystem(\n\t\t\ttsLibPaths.defaultMapFromNodeModules,\n\t\t\tthis.tsConfigInfo.path ? dirname(this.tsConfigInfo.path) : fromCwd(),\n\t\t\tts\n\t\t)\n\n\t\tthis.virtualEnv = tsvfs.createVirtualTypeScriptEnvironment(\n\t\t\tsystem,\n\t\t\tthis.rootFiles,\n\t\t\tts,\n\t\t\tthis.tsConfigInfo.parsed.options\n\t\t)\n\n\t\tthis.program = this.virtualEnv.languageService.getProgram()!\n\n\t\tTsServer._instance = this\n\t}\n\n\tgetSourceFileOrThrow(path: string): ts.SourceFile {\n\t\tconst tsPath = path.replace(/\\\\/g, \"/\")\n\t\tconst existingFile = this.virtualEnv.getSourceFile(tsPath)\n\t\tif (existingFile) return existingFile\n\n\t\tif (!this.virtualEnv.sys.fileExists(tsPath)) {\n\t\t\tthrowInternalError(\n\t\t\t\t`@ark/attest: TypeScript was unable to resolve expected file at ${tsPath}.\\n`\n\t\t\t)\n\t\t}\n\n\t\tconst contents = this.virtualEnv.sys.readFile(tsPath)\n\n\t\tif (!contents) {\n\t\t\tthrowInternalError(\n\t\t\t\t`@ark/attest: TypeScript says a file exists at ${tsPath}, but was unable to read its contents.\\n`\n\t\t\t)\n\t\t}\n\n\t\tthis.virtualEnv.createFile(tsPath, contents)\n\n\t\tconst createdFile = this.virtualEnv.getSourceFile(tsPath)\n\n\t\tif (!createdFile) {\n\t\t\tthrowInternalError(\n\t\t\t\t`@ark/attest: TypeScript tried to create a file at ${tsPath} but was unable to access it.`\n\t\t\t)\n\t\t}\n\n\t\treturn createdFile\n\t}\n}\n\nexport const nearestCallExpressionChild = (\n\tnode: ts.Node,\n\tposition: number\n): ts.CallExpression => {\n\tconst result = nearestBoundingCallExpression(node, position)\n\tif (!result) {\n\t\tthrowInternalError(\n\t\t\t`Unable to find bounding call expression at position ${position} in ${\n\t\t\t\tnode.getSourceFile().fileName\n\t\t\t}`\n\t\t)\n\t}\n\treturn result\n}\n\nexport const nearestBoundingCallExpression = (\n\tnode: ts.Node,\n\tposition: number\n): ts.CallExpression | undefined =>\n\tnode.pos <= position && node.end >= position ?\n\t\t(node\n\t\t\t.getChildren()\n\t\t\t.flatMap(\n\t\t\t\tchild => nearestBoundingCallExpression(child, position) ?? []\n\t\t\t)[0] ?? (ts.isCallExpression(node) ? node : undefined))\n\t:\tundefined\n\nexport const getAbsolutePosition = (\n\tfile: ts.SourceFile,\n\tposition: SourcePosition\n): number => {\n\tconst pos = ts.getPositionOfLineAndCharacter(\n\t\tfile,\n\t\t// TS uses 0-based line and char #s\n\t\tposition.line - 1,\n\t\tposition.char - 1\n\t)\n\tif (!pos) {\n\t\tthrowInternalError(\n\t\t\t`Absolute position ${printable(position)} does not exist in ${file.fileName}`\n\t\t)\n\t}\n\treturn pos\n}\n\nexport type TsconfigInfo = {\n\tpath: string | undefined\n\tparsed: ts.ParsedCommandLine\n}\n\nexport const getTsConfigInfoOrThrow = (): TsconfigInfo => {\n\tconst config = getConfig()\n\tconst tsconfig = config.tsconfig\n\n\tlet instantiatedConfig: ts.ParsedCommandLine | undefined\n\tlet configFilePath: string | undefined\n\n\tif (tsconfig !== null) {\n\t\tconfigFilePath =\n\t\t\ttsconfig ??\n\t\t\tts.findConfigFile(fromCwd(), ts.sys.fileExists, \"tsconfig.json\")\n\t\tif (configFilePath)\n\t\t\tinstantiatedConfig = instantiateTsconfigFromPath(configFilePath)\n\t}\n\n\tinstantiatedConfig ??= instantiateNoFileConfig()\n\n\treturn {\n\t\tpath: configFilePath,\n\t\tparsed: instantiatedConfig\n\t}\n}\n\ntype RawTsConfigJson = dict & { compilerOptions: ts.CompilerOptions }\n\ntype InstantiatedTsConfigJson = ts.ParsedCommandLine\n\nconst instantiateNoFileConfig = (): InstantiatedTsConfigJson => {\n\tconst arkConfig = getConfig()\n\n\tconst instantiatedConfig = ts.parseJsonConfigFileContent(\n\t\t{\n\t\t\tcompilerOptions: arkConfig.compilerOptions\n\t\t},\n\t\tts.sys,\n\t\tfromCwd()\n\t)\n\n\tif (instantiatedConfig.errors.length > 0)\n\t\tthrowConfigInstantiationError(instantiatedConfig)\n\n\treturn instantiatedConfig\n}\n\nconst instantiateTsconfigFromPath = (\n\tpath: string\n): InstantiatedTsConfigJson => {\n\tconst arkConfig = getConfig()\n\tconst configFileText = readFileSync(path).toString()\n\tconst result = ts.parseConfigFileTextToJson(path, configFileText)\n\tif (result.error) throwConfigParseError(result.error)\n\n\tconst rawConfig: RawTsConfigJson = result.config\n\n\trawConfig.compilerOptions = Object.assign(\n\t\trawConfig.compilerOptions ?? {},\n\t\tarkConfig.compilerOptions\n\t)\n\n\tconst configPath = resolve(path)\n\n\tconst instantiatedConfig = ts.parseJsonConfigFileContent(\n\t\trawConfig,\n\t\tts.sys,\n\t\tdirname(configPath),\n\t\t{},\n\t\tconfigPath\n\t)\n\n\tif (instantiatedConfig.errors.length > 0)\n\t\tthrowConfigInstantiationError(instantiatedConfig)\n\n\treturn instantiatedConfig\n}\n\nconst defaultDiagnosticHost: ts.FormatDiagnosticsHost = {\n\tgetCanonicalFileName: fileName => fileName,\n\tgetCurrentDirectory: process.cwd,\n\tgetNewLine: () => ts.sys.newLine\n}\n\nconst throwConfigParseError = (error: ts.Diagnostic) =>\n\tthrowError(ts.formatDiagnostics([error], defaultDiagnosticHost))\n\nconst throwConfigInstantiationError = (\n\tinstantiatedConfig: InstantiatedTsConfigJson\n): never =>\n\tthrowError(\n\t\tts.formatDiagnostics(instantiatedConfig.errors, defaultDiagnosticHost)\n\t)\n\ntype TsLibFiles = {\n\tdefaultMapFromNodeModules: Map<string, string>\n\tresolvedPaths: string[]\n}\n\nexport const getTsLibFiles = (\n\ttsconfigOptions: ts.CompilerOptions\n): TsLibFiles => {\n\tconst defaultMapFromNodeModules =\n\t\ttsvfs.createDefaultMapFromNodeModules(tsconfigOptions)\n\tconst libPath = dirname(ts.getDefaultLibFilePath(tsconfigOptions))\n\treturn {\n\t\tdefaultMapFromNodeModules,\n\t\tresolvedPaths: [...defaultMapFromNodeModules.keys()].map(path =>\n\t\t\tjoin(libPath, path)\n\t\t)\n\t}\n}\n\nexport const getProgram = (\n\tenv?: tsvfs.VirtualTypeScriptEnvironment\n): ts.Program =>\n\tenv?.languageService.getProgram() ??\n\tTsServer.instance.virtualEnv.languageService.getProgram()!\n\nexport interface InternalTypeChecker extends ts.TypeChecker {\n\t// These APIs are not publicly exposed\n\tgetInstantiationCount: () => number\n\tisTypeAssignableTo: (source: ts.Type, target: ts.Type) => boolean\n\tgetDiagnostics: () => ts.Diagnostic[]\n}\n\nexport const getInternalTypeChecker = (\n\tenv?: tsvfs.VirtualTypeScriptEnvironment\n): InternalTypeChecker =>\n\tgetProgram(env).getTypeChecker() as InternalTypeChecker\n\nexport interface StringifiableType extends ts.Type {\n\ttoString(): string\n\tisUnresolvable: boolean\n}\n\nexport const getStringifiableType = (node: ts.Node): StringifiableType => {\n\tconst typeChecker = getInternalTypeChecker()\n\tconst nodeType = typeChecker.getTypeAtLocation(node)\n\n\tlet stringified = typeChecker.typeToString(nodeType)\n\n\tif (stringified.includes(\"...\")) {\n\t\tconst nonTruncated = typeChecker.typeToString(\n\t\t\tnodeType,\n\t\t\tundefined,\n\t\t\tts.TypeFormatFlags.NoTruncation\n\t\t)\n\n\t\tstringified =\n\t\t\tnonTruncated.includes(\" any\") && !stringified.includes(\" any\") ?\n\t\t\t\tnonTruncated.replace(/ any/g, \" cyclic\")\n\t\t\t:\tnonTruncated\n\t}\n\n\treturn Object.assign(nodeType, {\n\t\ttoString: () => stringified,\n\t\tisUnresolvable: (nodeType as any).intrinsicName === \"error\"\n\t})\n}\n\nexport type ArgumentTypes = {\n\targs: StringifiableType[]\n\ttypeArgs: StringifiableType[]\n}\n\nexport const extractArgumentTypesFromCall = (\n\tcall: ts.CallExpression\n): ArgumentTypes => ({\n\targs: call.arguments.map(arg => getStringifiableType(arg)),\n\ttypeArgs:\n\t\tcall.typeArguments?.map(typeArg => getStringifiableType(typeArg)) ?? []\n})\n\nexport const getDescendants = (node: ts.Node): ts.Node[] =>\n\tgetDescendantsRecurse(node)\n\nconst getDescendantsRecurse = (node: ts.Node): ts.Node[] => [\n\tnode,\n\t...node.getChildren().flatMap(child => getDescendantsRecurse(child))\n]\n\nexport const getAncestors = (node: ts.Node): ts.Node[] => {\n\tconst ancestors: ts.Node[] = []\n\tlet baseNode = node.parent\n\twhile (baseNode.parent !== undefined) {\n\t\tancestors.push(baseNode)\n\t\tbaseNode = baseNode.parent\n\t}\n\treturn ancestors\n}\n\nexport const getFirstAncestorByKindOrThrow = (\n\tnode: ts.Node,\n\tkind: ts.SyntaxKind\n): ts.Node =>\n\tgetAncestors(node).find(ancestor => ancestor.kind === kind) ??\n\tthrowInternalError(\n\t\t`Could not find an ancestor of kind ${ts.SyntaxKind[kind]}`\n\t)\n"
  },
  {
    "path": "ark/attest/cache/utils.ts",
    "content": "import { filePath } from \"@ark/fs\"\nimport { throwInternalError } from \"@ark/util\"\nimport * as tsvfs from \"@typescript/vfs\"\nimport ts from \"typescript\"\nimport { getConfig } from \"../config.ts\"\nimport { getFileKey } from \"../utils.ts\"\nimport {\n\tgetDescendants,\n\tgetFirstAncestorByKindOrThrow,\n\tgetProgram,\n\tgetTsConfigInfoOrThrow,\n\tgetTsLibFiles\n} from \"./ts.ts\"\nimport type { LinePositionRange } from \"./writeAssertionCache.ts\"\n\nexport const getCallLocationFromCallExpression = (\n\tcallExpression: ts.CallExpression\n): LinePositionRange => {\n\tconst start = ts.getLineAndCharacterOfPosition(\n\t\tcallExpression.getSourceFile(),\n\t\tcallExpression.getStart()\n\t)\n\tconst end = ts.getLineAndCharacterOfPosition(\n\t\tcallExpression.getSourceFile(),\n\t\tcallExpression.getEnd()\n\t)\n\t// Add 1 to everything, since trace positions are 1-based and TS positions are 0-based.\n\tconst location: LinePositionRange = {\n\t\tstart: {\n\t\t\tline: start.line + 1,\n\t\t\tchar: start.character + 1\n\t\t},\n\t\tend: {\n\t\t\tline: end.line + 1,\n\t\t\tchar: end.character + 1\n\t\t}\n\t}\n\treturn location\n}\n\n/**\n * Processes inline instantiations from an attest call\n * Preserves any JSDoc comments that are associated with the original expression\n */\nexport const gatherInlineInstantiationData = (\n\tfile: ts.SourceFile,\n\tassertionsByFile: Record<string, any[]>,\n\tinstantiationMethodCalls: string[]\n): void => {\n\tconst expressions = getCallExpressionsByName(file, instantiationMethodCalls)\n\tif (!expressions.length) return\n\n\tconst enclosingFunctions = expressions.map(expression => {\n\t\tconst attestInstantiationsExpression = getFirstAncestorByKindOrThrow(\n\t\t\texpression,\n\t\t\tts.SyntaxKind.ExpressionStatement\n\t\t)\n\t\treturn {\n\t\t\tancestor: getFirstAncestorByKindOrThrow(\n\t\t\t\tattestInstantiationsExpression,\n\t\t\t\tts.SyntaxKind.ExpressionStatement\n\t\t\t),\n\t\t\tposition: getCallLocationFromCallExpression(expression)\n\t\t}\n\t})\n\tconst instantiationInfo = enclosingFunctions.map(enclosingFunction => {\n\t\tconst body = getDescendants(enclosingFunction.ancestor).find(\n\t\t\tnode => ts.isArrowFunction(node) || ts.isFunctionExpression(node)\n\t\t) as ts.ArrowFunction | ts.FunctionExpression | undefined\n\t\tif (!body) {\n\t\t\tthrowInternalError(\n\t\t\t\t`Unable to resolve source associated with TS Node:\n${enclosingFunction.ancestor.getText()}`\n\t\t\t)\n\t\t}\n\n\t\treturn {\n\t\t\tlocation: enclosingFunction.position,\n\t\t\tcount: getInstantiationsContributedByNode(file, body)\n\t\t}\n\t})\n\tconst assertions = assertionsByFile[getFileKey(file.fileName)] ?? []\n\tassertionsByFile[getFileKey(file.fileName)] = [\n\t\t...assertions,\n\t\t...instantiationInfo\n\t]\n}\n\nexport const getCallExpressionsByName = (\n\tstartNode: ts.Node,\n\tnames: string[],\n\tisSnapCall = false\n): ts.CallExpression[] => {\n\tconst calls: ts.CallExpression[] = []\n\tfor (const descendant of getDescendants(startNode)) {\n\t\tif (ts.isCallExpression(descendant)) {\n\t\t\tif (names.includes(descendant.expression.getText()) || !names.length)\n\t\t\t\tcalls.push(descendant)\n\t\t} else if (isSnapCall) {\n\t\t\tif (ts.isIdentifier(descendant)) {\n\t\t\t\tif (names.includes(descendant.getText()) || !names.length)\n\t\t\t\t\tcalls.push(descendant as any as ts.CallExpression)\n\t\t\t}\n\t\t}\n\t}\n\treturn calls\n}\n\nconst instantiationsByPath: { [path: string]: number } = {}\n\nexport const getInstantiationsContributedByNode = (\n\tfile: ts.SourceFile,\n\tbenchBlock: ts.FunctionExpression | ts.ArrowFunction\n): number => {\n\tconst originalPath = filePath(file.fileName)\n\tconst fakePath = originalPath + \".nonexistent.ts\"\n\n\tconst baselineFile = getBaselineSourceFile(file)\n\n\tconst baselineFileWithBenchBlock =\n\t\tbaselineFile + `\\nconst $attestIsolatedBench = ${benchBlock.getFullText()}`\n\n\tif (!instantiationsByPath[fakePath]) {\n\t\tconst instantiationsWithoutNode = getInstantiationsWithFile(\n\t\t\tbaselineFile,\n\t\t\tfakePath\n\t\t)\n\n\t\tinstantiationsByPath[fakePath] = instantiationsWithoutNode\n\t}\n\n\tconst instantiationsWithNode = getInstantiationsWithFile(\n\t\tbaselineFileWithBenchBlock,\n\t\tfakePath\n\t)\n\n\treturn instantiationsWithNode - instantiationsByPath[fakePath]\n}\n\nexport const createOrUpdateFile = (\n\tenv: tsvfs.VirtualTypeScriptEnvironment,\n\tfileName: string,\n\tfileText: string\n): ts.SourceFile | undefined => {\n\tif (env.sys.fileExists(fileName)) env.updateFile(fileName, fileText)\n\telse env.createFile(fileName, fileText)\n\treturn env.getSourceFile(fileName)\n}\n\ndeclare module \"typescript\" {\n\tinterface SourceFile {\n\t\timports: ts.StringLiteral[]\n\t}\n\n\tinterface Program {\n\t\tgetResolvedModuleFromModuleSpecifier(\n\t\t\tmoduleSpecifier: ts.StringLiteralLike,\n\t\t\tsourceFile?: ts.SourceFile\n\t\t): ts.ResolvedModuleWithFailedLookupLocations\n\t}\n}\n\nconst getInstantiationsWithFile = (fileText: string, fileName: string) => {\n\tconst env = getIsolatedEnv()\n\tconst file = createOrUpdateFile(env, fileName, fileText)\n\tconst program = getProgram(env)\n\n\t// trigger type checking to generate instantiations\n\t// (was previously program.emit(file), but that as of TS 5.6 that doesn't\n\t// work, so this may need to change if instantiations is reported as 0 after\n\t// a future TypeScript update)\n\tprogram.getSemanticDiagnostics(file)\n\t// this may lead to additional type checking per Jake Bailey from the TS\n\t// team, although it doesn't currently affect any of our internal benchmarks\n\tprogram.getDeclarationDiagnostics(file)\n\tconst count = program.getInstantiationCount()\n\treturn count\n}\n\nlet virtualEnv: tsvfs.VirtualTypeScriptEnvironment | undefined = undefined\n\nexport const getIsolatedEnv = (): tsvfs.VirtualTypeScriptEnvironment => {\n\tif (virtualEnv !== undefined) return virtualEnv\n\n\tconst tsconfigInfo = getTsConfigInfoOrThrow()\n\tconst libFiles = getTsLibFiles(tsconfigInfo.parsed.options)\n\tconst projectRoot = process.cwd()\n\tconst system = tsvfs.createFSBackedSystem(\n\t\tlibFiles.defaultMapFromNodeModules,\n\t\tprojectRoot,\n\t\tts\n\t)\n\tvirtualEnv = tsvfs.createVirtualTypeScriptEnvironment(\n\t\tsystem,\n\t\t[],\n\t\tts,\n\t\ttsconfigInfo.parsed.options\n\t)\n\treturn virtualEnv\n}\n\nconst getBaselineSourceFile = (originalFile: ts.SourceFile): string => {\n\tconst functionNames = getConfig().testDeclarationAliases\n\n\tconst calls = getCallExpressionsByName(originalFile, functionNames)\n\n\tlet baselineSourceFileText = originalFile.getFullText()\n\n\t// for each test function like `it` or `bench`, walk up the AST to find the complete expression\n\tfor (const call of calls) {\n\t\tlet currentNode: ts.Node = call\n\n\t\t// ensure we capture the entire chain like bench(...).types(...)\n\t\twhile (currentNode.parent && !ts.isExpressionStatement(currentNode))\n\t\t\tcurrentNode = currentNode.parent\n\n\t\tconst fullExpressionText = currentNode.getFullText()\n\n\t\tbaselineSourceFileText = baselineSourceFileText.replace(\n\t\t\tfullExpressionText,\n\t\t\t\"\"\n\t\t)\n\t}\n\n\treturn baselineSourceFileText\n}\n"
  },
  {
    "path": "ark/attest/cache/writeAssertionCache.ts",
    "content": "import type { LinePosition } from \"@ark/fs\"\nimport { flatMorph } from \"@ark/util\"\nimport ts from \"typescript\"\n\nimport { getConfig } from \"../config.ts\"\nimport { getFileKey } from \"../utils.ts\"\nimport {\n\tTsServer,\n\textractArgumentTypesFromCall,\n\tgetDescendants,\n\tgetInternalTypeChecker,\n\ttype ArgumentTypes,\n\ttype StringifiableType\n} from \"./ts.ts\"\nimport {\n\tgatherInlineInstantiationData,\n\tgetCallExpressionsByName,\n\tgetCallLocationFromCallExpression\n} from \"./utils.ts\"\n\nexport type AssertionsByFile = Record<string, TypeAssertionData[]>\n\nexport const analyzeProjectAssertions = (): AssertionsByFile => {\n\tconst config = getConfig()\n\tconst instance = TsServer.instance\n\tconst filePaths = instance.rootFiles\n\tconst diagnosticsByFile = getDiagnosticsByFile()\n\tconst assertionsByFile: AssertionsByFile = {}\n\tconst attestAliasInstantiationMethodCalls = config.attestAliases.map(\n\t\talias => `${alias}.instantiations`\n\t)\n\tfor (const path of filePaths) {\n\t\tconst file = instance.getSourceFileOrThrow(path)\n\t\tconst assertionsInFile = getAssertionsInFile(\n\t\t\tfile,\n\t\t\tdiagnosticsByFile,\n\t\t\tconfig.attestAliases\n\t\t)\n\t\tif (assertionsInFile.length)\n\t\t\tassertionsByFile[getFileKey(file.fileName)] = assertionsInFile\n\t\tif (!config.skipInlineInstantiations) {\n\t\t\tgatherInlineInstantiationData(\n\t\t\t\tfile,\n\t\t\t\tassertionsByFile,\n\t\t\t\tattestAliasInstantiationMethodCalls\n\t\t\t)\n\t\t}\n\t}\n\treturn assertionsByFile\n}\n\nexport const getAssertionsInFile = (\n\tfile: ts.SourceFile,\n\tdiagnosticsByFile: DiagnosticsByFile,\n\tattestAliases: string[]\n): TypeAssertionData[] => {\n\tconst assertCalls = getCallExpressionsByName(file, attestAliases)\n\treturn assertCalls.map(call => analyzeAssertCall(call, diagnosticsByFile))\n}\n\nexport const analyzeAssertCall = (\n\tassertCall: ts.CallExpression,\n\tdiagnosticsByFile: DiagnosticsByFile\n): TypeAssertionData => {\n\tconst types = extractArgumentTypesFromCall(assertCall)\n\tconst location = getCallLocationFromCallExpression(assertCall)\n\tconst args = types.args.map(arg => serializeArg(arg, types))\n\tconst typeArgs = types.typeArgs.map(typeArg => serializeArg(typeArg, types))\n\tconst errors = checkDiagnosticMessages(assertCall, diagnosticsByFile)\n\tconst completions = getCompletions(assertCall)\n\n\t// Extract JSDoc comment for first argument if available\n\tconst jsdoc = extractJSDocFromArgument(assertCall)\n\n\tconst result: TypeAssertionData = {\n\t\tlocation,\n\t\targs,\n\t\ttypeArgs,\n\t\terrors,\n\t\tcompletions\n\t}\n\n\tif (jsdoc) result.jsdoc = jsdoc\n\n\treturn result\n}\n\n/**\n * Extract JSDoc comments associated with the first argument of a call expression\n */\nconst extractJSDocFromArgument = (\n\tcallExpr: ts.CallExpression\n): string | undefined => {\n\t// We're only interested in the first argument\n\tconst firstArg = callExpr.arguments[0]\n\tif (!firstArg) return undefined\n\n\tconst checker = getInternalTypeChecker()\n\n\t// If the argument is a property access expression (e.g., out.foo)\n\tif (ts.isPropertyAccessExpression(firstArg)) {\n\t\t// Try to find the symbol for the property\n\t\tconst propSymbol = checker.getSymbolAtLocation(firstArg)\n\t\tif (propSymbol) {\n\t\t\t// Get JSDoc from property declarations\n\t\t\treturn getJSDocFromSymbol(propSymbol)\n\t\t}\n\t}\n\t// If argument is an identifier, try to find its declaration's JSDoc\n\telse if (ts.isIdentifier(firstArg)) {\n\t\tconst symbol = checker.getSymbolAtLocation(firstArg)\n\t\tif (symbol) return getJSDocFromSymbol(symbol)\n\t}\n\n\treturn undefined\n}\n\n/**\n * Extract JSDoc comments from a symbol's declarations\n */\nconst getJSDocFromSymbol = (symbol: ts.Symbol): string | undefined => {\n\t// Get JSDoc directly from the symbol if possible\n\tconst symbolDocumentation = ts.displayPartsToString(\n\t\tsymbol.getDocumentationComment(getInternalTypeChecker())\n\t)\n\tif (symbolDocumentation) return symbolDocumentation.trim()\n\n\t// If no symbol documentation, try to get JSDoc from declarations\n\tconst declarations = symbol.getDeclarations() || []\n\tfor (const declaration of declarations) {\n\t\t// For property declarations in object literals, get the JSDoc comment\n\t\tif (\n\t\t\tts.isPropertyAssignment(declaration) ||\n\t\t\tts.isShorthandPropertyAssignment(declaration) ||\n\t\t\tts.isPropertyDeclaration(declaration)\n\t\t) {\n\t\t\tconst jsDocTags = ts.getJSDocTags(declaration)\n\t\t\tif (jsDocTags.length > 0) {\n\t\t\t\treturn jsDocTags\n\t\t\t\t\t.map(tag => {\n\t\t\t\t\t\tconst comment = tag.comment?.toString() || \"\"\n\t\t\t\t\t\treturn tag.tagName.text + (comment ? ` ${comment}` : \"\")\n\t\t\t\t\t})\n\t\t\t\t\t.join(\"\\n\")\n\t\t\t}\n\n\t\t\t// Try to get JSDoc comment before the property\n\t\t\tconst jsDocComments = ts.getJSDocCommentsAndTags(declaration)\n\t\t\tif (jsDocComments && jsDocComments.length > 0) {\n\t\t\t\treturn jsDocComments\n\t\t\t\t\t.map(doc => {\n\t\t\t\t\t\tif (ts.isJSDoc(doc)) return doc.comment || \"\"\n\n\t\t\t\t\t\treturn \"\"\n\t\t\t\t\t})\n\t\t\t\t\t.filter(Boolean)\n\t\t\t\t\t.join(\"\\n\")\n\t\t\t\t\t.trim()\n\t\t\t}\n\t\t}\n\t}\n\n\treturn undefined\n}\n\nconst serializeArg = (\n\targ: StringifiableType,\n\tcontext: ArgumentTypes\n): ArgAssertionData => ({\n\ttype: arg.toString(),\n\trelationships: {\n\t\targs: context.args.map(other => compareTsTypes(arg, other)),\n\t\ttypeArgs: context.typeArgs.map(other => compareTsTypes(arg, other))\n\t}\n})\n\nexport type Completions = Record<string, string[]> | string\n\nconst getCompletions = (attestCall: ts.CallExpression) => {\n\tconst arg = attestCall.arguments[0]\n\tif (arg === undefined) return {}\n\n\tconst descendants = getDescendants(arg)\n\tconst file = attestCall.getSourceFile()\n\tconst text = file.getFullText()\n\tconst completions: Completions | string = {}\n\n\tfor (const descendant of descendants) {\n\t\tif (ts.isStringLiteral(descendant) || ts.isTemplateLiteral(descendant)) {\n\t\t\t// descendant.pos tends to be an open quote while d.end tends to be right after the closing quote.\n\t\t\t// It seems to be more consistent using this to get the pos for the completion over descendant.pos\n\t\t\tconst lastPositionOfInnerString =\n\t\t\t\tdescendant.end - (/[\"'`]/.test(text[descendant.end - 1]) ? 1 : 2)\n\t\t\tconst completionData =\n\t\t\t\tTsServer.instance.virtualEnv.languageService.getCompletionsAtPosition(\n\t\t\t\t\tfile.fileName,\n\t\t\t\t\tlastPositionOfInnerString,\n\t\t\t\t\tundefined\n\t\t\t\t)\n\t\t\tconst prefix =\n\t\t\t\t\"text\" in descendant ? descendant.text : descendant.getText()\n\n\t\t\tconst entries = completionData?.entries ?? []\n\n\t\t\tif (prefix in completions)\n\t\t\t\treturn `Encountered multiple completion candidates for string(s) '${prefix}'. Assertions on the same prefix must be split into multiple attest calls so the results can be distinguished.`\n\n\t\t\tcompletions[prefix] = []\n\t\t\tfor (const entry of entries) {\n\t\t\t\tif (entry.name.startsWith(prefix) && entry.name.length > prefix.length)\n\t\t\t\t\tcompletions[prefix].push(entry.name)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn flatMorph(completions, (prefix, entries) =>\n\t\tentries.length >= 1 ? [prefix, entries.sort()] : []\n\t)\n}\n\nexport type DiagnosticData = {\n\tstart: number\n\tend: number\n\tmessage: string\n}\n\nexport type DiagnosticsByFile = Record<string, DiagnosticData[]>\n\nexport const getDiagnosticsByFile = (): DiagnosticsByFile => {\n\tconst diagnosticsByFile: DiagnosticsByFile = {}\n\tconst diagnostics: ts.Diagnostic[] = getInternalTypeChecker().getDiagnostics()\n\tfor (const diagnostic of diagnostics)\n\t\taddDiagnosticDataFrom(diagnostic, diagnosticsByFile)\n\n\treturn diagnosticsByFile\n}\n\nconst addDiagnosticDataFrom = (\n\tdiagnostic: ts.Diagnostic,\n\tdiagnosticsByFile: DiagnosticsByFile\n) => {\n\tconst filePath = diagnostic.file?.fileName\n\tif (!filePath) return\n\n\tconst fileKey = getFileKey(filePath)\n\tconst start = diagnostic.start ?? -1\n\tconst end = start + (diagnostic.length ?? 0)\n\tlet message = diagnostic.messageText\n\tif (typeof message === \"object\") message = concatenateChainedErrors([message])\n\n\tconst data: DiagnosticData = {\n\t\tstart,\n\t\tend,\n\t\tmessage\n\t}\n\tif (diagnosticsByFile[fileKey]) diagnosticsByFile[fileKey].push(data)\n\telse diagnosticsByFile[fileKey] = [data]\n}\n\nconst concatenateChainedErrors = (\n\tdiagnostics: ts.DiagnosticMessageChain[]\n): string =>\n\tdiagnostics\n\t\t.map(\n\t\t\tmsg =>\n\t\t\t\t`${msg.messageText}${\n\t\t\t\t\tmsg.next ? concatenateChainedErrors(msg.next) : \"\"\n\t\t\t\t}`\n\t\t)\n\t\t.join(\"\\n\")\n\nexport type ArgAssertionData = {\n\ttype: string\n\trelationships: {\n\t\targs: TypeRelationship[]\n\t\ttypeArgs: TypeRelationship[]\n\t}\n}\n\nexport type TypeRelationshipAssertionData = {\n\tlocation: LinePositionRange\n\targs: ArgAssertionData[]\n\ttypeArgs: ArgAssertionData[]\n\terrors: string[]\n\tcompletions: Completions\n\t/** JSDoc comment for the first argument, if any */\n\tjsdoc?: string\n}\n\nexport type TypeBenchmarkingAssertionData = {\n\tlocation: LinePositionRange\n\tcount: number\n}\n\nexport type TypeAssertionKind = \"bench\" | \"type\"\n\nexport type TypeAssertionData<\n\tkind extends TypeAssertionKind = TypeAssertionKind\n> =\n\tkind extends \"bench\" ? TypeBenchmarkingAssertionData\n\t:\tTypeRelationshipAssertionData\n\nexport type LinePositionRange = {\n\tstart: LinePosition\n\tend: LinePosition\n}\n\nexport type TypeRelationship = \"subtype\" | \"supertype\" | \"equality\" | \"none\"\n\nexport const compareTsTypes = (\n\tl: StringifiableType,\n\tr: StringifiableType\n): TypeRelationship => {\n\tconst lString = l.toString()\n\tconst rString = r.toString()\n\t// Ensure two unresolvable types are not treated as equivalent\n\tif (l.isUnresolvable || r.isUnresolvable) return \"none\"\n\t// Treat `any` as a supertype of every other type\n\tif (lString === \"any\") return rString === \"any\" ? \"equality\" : \"supertype\"\n\tif (rString === \"any\") return \"subtype\"\n\t// Otherwise, determine if the types are equivalent by checking mutual assignability\n\tconst checker = getInternalTypeChecker()\n\tconst isSubtype = checker.isTypeAssignableTo(l, r)\n\tconst isSupertype = checker.isTypeAssignableTo(r, l)\n\treturn (\n\t\tisSubtype ?\n\t\t\tisSupertype ? \"equality\"\n\t\t\t:\t\"subtype\"\n\t\t: isSupertype ? \"supertype\"\n\t\t: \"none\"\n\t)\n}\n\nexport const checkDiagnosticMessages = (\n\tattestCall: ts.CallExpression,\n\tdiagnosticsByFile: DiagnosticsByFile\n): string[] => {\n\tconst fileKey = getFileKey(attestCall.getSourceFile().fileName)\n\tconst fileDiagnostics = diagnosticsByFile[fileKey]\n\tif (!fileDiagnostics) return []\n\n\tconst diagnosticMessagesInArgRange: string[] = []\n\tfor (const diagnostic of fileDiagnostics) {\n\t\tif (\n\t\t\tdiagnostic.start >= attestCall.getStart() &&\n\t\t\tdiagnostic.end <= attestCall.getEnd()\n\t\t)\n\t\t\tdiagnosticMessagesInArgRange.push(diagnostic.message)\n\t}\n\treturn diagnosticMessagesInArgRange\n}\n"
  },
  {
    "path": "ark/attest/cli/cli.ts",
    "content": "#!/usr/bin/env node\nimport { fileName } from \"@ark/fs\"\nimport { basename } from \"node:path\"\nimport { precache } from \"./precache.ts\"\nimport { stats } from \"./stats.ts\"\nimport { trace } from \"./trace.ts\"\n\nconst subcommands = {\n\tprecache,\n\ttrace,\n\tstats\n}\n\ntype Subcommand = keyof typeof subcommands\n\nconst baseFileName = basename(fileName())\n\nconst thisFileIndex = process.argv.findIndex(\n\t// if running from build output in npm, will be a file called `attest`\n\t// if running from build output in pnpm, will be `cli.js` in build output\n\ts => s.endsWith(baseFileName) || s.endsWith(\"attest\")\n)\n\nif (thisFileIndex === -1)\n\tthrow new Error(`Expected to find an argument ending with \"${baseFileName}\"`)\n\nconst subcommand = process.argv[thisFileIndex + 1]\n\nif (!(subcommand in subcommands)) {\n\tconsole.error(\n\t\t`Expected a command like 'attest <subcommand>', where <subcommand> is one of:\\n${Object.keys(\n\t\t\tsubcommands\n\t\t)}`\n\t)\n\tprocess.exit(1)\n}\n\nconst args = process.argv.slice(thisFileIndex + 2)\n\nsubcommands[subcommand as Subcommand](args)\n"
  },
  {
    "path": "ark/attest/cli/precache.ts",
    "content": "import { ensureDir } from \"@ark/fs\"\nimport { join } from \"node:path\"\nimport { writeAssertionData } from \"../fixtures.ts\"\n\nexport const precache = (args: string[]): void => {\n\tconst cacheFileToWrite =\n\t\targs[0] ?? join(ensureDir(\".attest\"), \"typescript.json\")\n\n\twriteAssertionData(cacheFileToWrite)\n}\n"
  },
  {
    "path": "ark/attest/cli/shared.ts",
    "content": "export const baseDiagnosticTscCmd =\n\t\"npm exec -- tsc --noEmit --extendedDiagnostics --incremental false --tsBuildInfoFile null\"\n"
  },
  {
    "path": "ark/attest/cli/stats.ts",
    "content": "import { execSync } from \"node:child_process\"\nimport { baseDiagnosticTscCmd } from \"./shared.ts\"\n\nexport const stats = (args: string[]): void => {\n\tconst packageDirs = args.length ? args : [process.cwd()]\n\tconst listedStats = packageDirs.map((packageDir): TypePerfStats => {\n\t\tconsole.log(`⏳ Gathering type perf data for ${packageDir}...`)\n\t\tlet output: string\n\t\ttry {\n\t\t\toutput = execSync(baseDiagnosticTscCmd, {\n\t\t\t\tcwd: packageDir,\n\t\t\t\tstdio: \"pipe\"\n\t\t\t}).toString()\n\t\t} catch (e: any) {\n\t\t\toutput = e.stdout?.toString() ?? \"\"\n\t\t\toutput += e.stderr?.toString() ?? \"\"\n\t\t\tconsole.error(\n\t\t\t\t`❗Encountered one or more errors checking types for ${packageDir}- results may be inaccurate❗`\n\t\t\t)\n\t\t}\n\t\tconst stats = parseTsDiagnosticsOutput(output)\n\t\tlogTypePerfStats(stats)\n\t\treturn stats\n\t})\n\n\tconst aggregatedStats = listedStats.reduce<TypePerfStats>(\n\t\t(aggregatedStats, packageStats) => ({\n\t\t\tcheckTime: aggregatedStats.checkTime + packageStats.checkTime,\n\t\t\ttypes: aggregatedStats.types + packageStats.types,\n\t\t\tinstantiations:\n\t\t\t\taggregatedStats.instantiations + packageStats.instantiations\n\t\t}),\n\t\t{\n\t\t\tcheckTime: 0,\n\t\t\ttypes: 0,\n\t\t\tinstantiations: 0\n\t\t}\n\t)\n\n\tconsole.log(\"📊 aggregated type performance:\")\n\tlogTypePerfStats(aggregatedStats)\n}\n\ntype TypePerfStats = {\n\tcheckTime: number\n\ttypes: number\n\tinstantiations: number\n}\n\nconst parseTsDiagnosticsOutput = (output: string): TypePerfStats => {\n\tconst lines = output.split(\"\\n\")\n\tconst results: TypePerfStats = {\n\t\tcheckTime: 0,\n\t\ttypes: 0,\n\t\tinstantiations: 0\n\t}\n\n\tfor (const line of lines) {\n\t\tif (line.startsWith(\"Check time:\"))\n\t\t\tresults.checkTime = parseFloat(line.split(\":\")[1].trim())\n\t\telse if (line.startsWith(\"Types:\"))\n\t\t\tresults.types = parseInt(line.split(\":\")[1].trim(), 10)\n\t\telse if (line.startsWith(\"Instantiations:\"))\n\t\t\tresults.instantiations = parseInt(line.split(\":\")[1].trim(), 10)\n\t}\n\treturn results\n}\n\nconst logTypePerfStats = (stats: TypePerfStats) => {\n\tconsole.log(JSON.stringify(stats, null, 4))\n}\n"
  },
  {
    "path": "ark/attest/cli/trace.ts",
    "content": "import { ensureDir, getShellOutput, readJson, writeFile } from \"@ark/fs\"\nimport type { ExecException } from \"node:child_process\"\nimport { existsSync } from \"node:fs\"\nimport { basename, join, relative, resolve } from \"node:path\"\nimport ts from \"typescript\"\nimport {\n\tTsServer,\n\tgetDescendants,\n\tgetStringifiableType,\n\tnearestBoundingCallExpression\n} from \"../cache/ts.ts\"\nimport { getConfig } from \"../config.ts\"\nimport { baseDiagnosticTscCmd } from \"./shared.ts\"\n\ninterface TraceEntry {\n\tpid: number\n\ttid: number\n\tph: string // Phase (e.g., \"X\" for Complete Event)\n\tcat: string // Category\n\tts: number // Timestamp (microseconds)\n\tname: string // Name of the event\n\tdur?: number // Duration (microseconds)\n\targs: {\n\t\tkind?: number\n\t\tpos?: number\n\t\tend?: number\n\t\tpath?: string\n\t\tsourceId?: number\n\t\ttargetId?: number\n\t\t[key: string]: any\n\t}\n}\n\ninterface CallRange {\n\tid: string\n\ttypeId: string\n\tfunctionName: string\n\tcallSite: string\n\tstartTime: number // microseconds\n\tendTime: number // microseconds\n\tduration: number // microseconds\n\tchildren: CallRange[]\n\tselfTime: number // microseconds\n}\n\ninterface CallSiteDetail {\n\tpath: string\n\tpos: number\n\tend: number\n\tselfTime: number // microseconds\n}\n\ninterface FunctionStats {\n\ttypeId: string\n\tfunctionName: string\n\ttotalTime: number // microseconds\n\tselfTime: number // microseconds\n\tcount: number\n\tfirstLocation?: string\n\tdetailedCallSites: CallSiteDetail[]\n}\n\ninterface AnalysisContext {\n\ttraceDir: string\n\ttsServer: TsServer\n\ttraceEntries: TraceEntry[]\n\tdurationEntries: TraceEntry[] // Filtered entries with duration\n\tcallRanges: CallRange[]\n\trootCalls: CallRange[]\n\tfunctionStats: Record<string, FunctionStats>\n\tallFunctions: FunctionStats[]\n}\n\ninterface UngroupedCallStats {\n\ttypeId: string\n\tfunctionName: string\n\tcallSite: string\n\tduration: number // microseconds\n\tselfTime: number // microseconds\n}\n\n/**\n * Helper to write output to both console and collect for file output\n */\nconst outputCapture = (() => {\n\tlet buffer: string[] = []\n\n\treturn {\n\t\twrite: (text: string) => {\n\t\t\tconsole.log(text)\n\t\t\tbuffer.push(text)\n\t\t},\n\t\tgetBuffer: () => buffer.join(\"\\n\"),\n\t\tgetLines: () => [...buffer],\n\t\tclear: () => {\n\t\t\tbuffer = []\n\t\t}\n\t}\n})()\n\n/**\n * Formats microseconds to a string of milliseconds.\n */\nconst formatMillis = (ms: number, fractionDigits = 2): string =>\n\t(ms / 1000).toFixed(fractionDigits)\n\n/**\n * Formats microseconds to a padded string of milliseconds.\n */\nconst formatPaddedMillis = (\n\tms: number,\n\tpad: number,\n\tfractionDigits = 2\n): string => formatMillis(ms, fractionDigits).padStart(pad)\n\n// Helper to format duration in seconds to a human-readable string\nconst formatSeconds = (totalSeconds: number): string => {\n\tif (totalSeconds < 0) totalSeconds = 0\n\tconst hours = Math.floor(totalSeconds / 3600)\n\tconst minutes = Math.floor((totalSeconds % 3600) / 60)\n\tconst seconds = Math.floor(totalSeconds % 60)\n\n\tif (hours > 0) return `about ${hours} hour(s)`\n\tif (minutes > 0) return `about ${minutes} minute(s)`\n\treturn `${seconds}s`\n}\n\nclass ProgressDisplay {\n\tprivate totalItems: number\n\tprivate processedItems: number = 0\n\tprivate startTime: number = 0\n\tprivate timerId?: NodeJS.Timeout\n\tprivate barWidth: number = 30 // Width of the progress bar itself\n\n\tconstructor(totalItems: number) {\n\t\tthis.totalItems = totalItems\n\t\tif (this.totalItems <= 0) this.totalItems = 0\n\t}\n\n\tstart(): void {\n\t\tif (this.totalItems === 0) return\n\n\t\tthis.startTime = Date.now()\n\t\tthis.processedItems = 0\n\t\tthis.render() // Initial render\n\t\t// Update every second for elapsed time and ETA\n\t\tthis.timerId = setInterval(() => this.render(), 1000)\n\t}\n\n\tupdate(processedCount: number): void {\n\t\tif (this.totalItems === 0) return\n\n\t\tthis.processedItems = Math.min(processedCount, this.totalItems)\n\t\tthis.render() // Re-render on each item processed for immediate feedback\n\n\t\tif (this.processedItems >= this.totalItems) this.stop() // Automatically stop if all items are processed\n\t}\n\n\tprivate render(): void {\n\t\tif (this.totalItems === 0 && this.processedItems === 0 && !this.startTime)\n\t\t\treturn // Avoid rendering if not started for 0 items\n\n\t\tconst percent =\n\t\t\tthis.totalItems > 0 ?\n\t\t\t\tMath.min(100, (this.processedItems / this.totalItems) * 100)\n\t\t\t:\t100\n\t\tconst filledLength = Math.floor((this.barWidth * percent) / 100)\n\t\tconst emptyLength = this.barWidth - filledLength\n\n\t\tconst bar = `[${\"=\".repeat(filledLength)}${\" \".repeat(emptyLength)}]`\n\n\t\tconst elapsedMs = Date.now() - this.startTime\n\t\tconst elapsedSec = elapsedMs / 1000\n\t\tconst formattedElapsed = formatSeconds(elapsedSec)\n\n\t\tlet etaStr = \"\"\n\t\tif (this.processedItems > 0 && this.processedItems < this.totalItems) {\n\t\t\tconst avgTimePerItemMs = elapsedMs / this.processedItems\n\t\t\tconst remainingItems = this.totalItems - this.processedItems\n\t\t\tconst etaMs = remainingItems * avgTimePerItemMs\n\t\t\tetaStr = ` (ETA: ${formatSeconds(etaMs / 1000)})`\n\t\t} else if (this.processedItems >= this.totalItems && this.totalItems > 0)\n\t\t\tetaStr = \" (Done)\"\n\n\t\tconst summary = `${this.processedItems}/${this.totalItems} entries (${percent.toFixed(0)}%)`\n\t\tconst timeInfo = `${formattedElapsed} elapsed${etaStr}`\n\n\t\tprocess.stdout.clearLine(0) // Clear the current line\n\t\tprocess.stdout.cursorTo(0) // Move cursor to the beginning of the line\n\t\tprocess.stdout.write(`Processing: ${bar} ${summary} | ${timeInfo}`)\n\t}\n\n\tstop(): void {\n\t\tif (this.timerId) {\n\t\t\tclearInterval(this.timerId)\n\t\t\tthis.timerId = undefined as never\n\t\t}\n\t\tif (this.totalItems > 0) {\n\t\t\tthis.processedItems = this.totalItems // Ensure final state is 100%\n\t\t\tthis.render() // Final render\n\t\t\tprocess.stdout.write(\"\\n\") // Move to the next line\n\t\t}\n\t}\n}\n\nexport const trace = async (args: string[]): Promise<void> => {\n\tconst packageDir = resolve(args[0] ?? process.cwd())\n\tconst config = getConfig()\n\n\tif (!config.tsconfig) {\n\t\t// This message should go to console.error and also be captured if needed,\n\t\t// but since it exits, direct console.error is fine.\n\t\tconsole.error(\n\t\t\t`attest trace must be run from a directory with a tsconfig.json file`\n\t\t)\n\t\tprocess.exit(1)\n\t}\n\n\tconst traceDir = resolve(config.cacheDir, \"trace\")\n\tensureDir(traceDir)\n\n\toutputCapture.clear()\n\tconst initialMessages: string[] = []\n\n\tinitialMessages.push(`⏳ Gathering type trace data for ${packageDir}...`)\n\toutputCapture.write(initialMessages[0]) // This goes to console and buffer\n\n\tconst tracingOutput = generateTraceData(traceDir, config.tsconfig, packageDir)\n\n\tconst traceFile = join(traceDir, \"trace.json\")\n\n\tif (!existsSync(traceFile)) {\n\t\toutputCapture.write(\n\t\t\t`❌ No trace data found (expected a file at ${traceFile}). TSC output:\\n${tracingOutput}`\n\t\t)\n\t\tconst summaryPath = join(traceDir, \"summary.txt\")\n\t\twriteFile(summaryPath, outputCapture.getBuffer())\n\t\treturn\n\t}\n\n\t// This message will be followed by the progress bar on the next line\n\toutputCapture.write(`⏳ Analyzing type trace data for ${packageDir}...`)\n\tanalyzeTypeInstantiations(traceDir) // This function now handles its own progress display\n\n\t// Collect all messages for the summary file\n\t// The progress bar output is not part of outputCapture.getLines()\n\tconst analysisMessages = outputCapture\n\t\t.getLines()\n\t\t.slice(initialMessages.length + 1) // +1 for the \"Analyzing...\" message\n\n\tconst summaryContent = [\n\t\t...initialMessages,\n\t\ttracingOutput,\n\t\toutputCapture.getLines()[initialMessages.length], // The \"Analyzing...\" message\n\t\t...analysisMessages\n\t].join(\"\\n\")\n\n\tconst summaryPath = join(traceDir, \"summary.txt\")\n\twriteFile(summaryPath, summaryContent)\n}\n\nconst generateTraceData = (\n\ttraceDir: string,\n\ttsconfigPath: string,\n\tpackageDir: string\n): string => {\n\ttry {\n\t\tconst output = getShellOutput(\n\t\t\t`${baseDiagnosticTscCmd} --project ${tsconfigPath} --generateTrace ${traceDir}`,\n\t\t\t{ cwd: packageDir }\n\t\t)\n\t\tprocess.stdout.write(output) // Display tsc output directly\n\t\treturn output\n\t} catch (error: any) {\n\t\tconst e: ExecException = error\n\t\tconst output = e.stdout ?? \"\"\n\t\tconst errorOutput = e.stderr ?? \"\"\n\n\t\tprocess.stdout.write(output)\n\t\tprocess.stderr.write(errorOutput)\n\n\t\treturn `${output}\\n${errorOutput}`\n\t}\n}\n\nconst initializeAnalysisContext = (traceDir: string): AnalysisContext => {\n\tconst tsServer = TsServer.instance\n\tconst tracePath = join(traceDir, \"trace.json\")\n\n\tif (!existsSync(tracePath)) {\n\t\tthrow new Error(\n\t\t\t`Critical: Expected a trace file at ${tracePath}, but it was not found during context initialization.`\n\t\t)\n\t}\n\n\tconst traceEntries: TraceEntry[] = readJson(tracePath) as never\n\n\treturn {\n\t\ttraceDir,\n\t\ttsServer,\n\t\ttraceEntries,\n\t\tdurationEntries: [],\n\t\tcallRanges: [],\n\t\trootCalls: [],\n\t\tfunctionStats: {},\n\t\tallFunctions: []\n\t}\n}\n\nconst filterDurationEntries = (ctx: AnalysisContext): void => {\n\tctx.durationEntries = ctx.traceEntries.filter(entry => {\n\t\tconst { args, dur, ph } = entry\n\t\treturn (\n\t\t\tph === \"X\" &&\n\t\t\ttypeof dur === \"number\" &&\n\t\t\targs &&\n\t\t\ttypeof args.path === \"string\" &&\n\t\t\ttypeof args.pos === \"number\" &&\n\t\t\ttypeof args.end === \"number\"\n\t\t)\n\t})\n\t// This message goes to outputCapture for the summary file\n\toutputCapture.write(\n\t\t`Found ${ctx.durationEntries.length} complete event traces with duration, path, and position.`\n\t)\n}\n\nconst processDurationEntry = (\n\tentry: TraceEntry,\n\tctx: AnalysisContext\n): void => {\n\tconst entryPath = entry.args.path as string\n\tconst entryPos = entry.args.pos as number\n\tconst entryEnd = entry.args.end as number\n\tconst entryDur = entry.dur as number\n\n\tconst sourceFile = ctx.tsServer.getSourceFileOrThrow(entryPath)\n\tlet callRangeData: { typeId: string; functionName: string } | undefined\n\n\tconst callExpr = findCallExpressionInRange(sourceFile, entryPos, entryEnd)\n\tif (callExpr) {\n\t\tconst functionName = extractFunctionName(callExpr)\n\t\tcallRangeData = {\n\t\t\ttypeId: `function-${functionName}`,\n\t\t\tfunctionName\n\t\t}\n\t} else {\n\t\tconst relevantNode = findMostSpecificNodeInRange(\n\t\t\tsourceFile,\n\t\t\tentryPos,\n\t\t\tentryEnd\n\t\t)\n\t\tif (relevantNode) {\n\t\t\tconst nodeType = getStringifiableType(relevantNode)\n\t\t\tconst nodeKind = ts.SyntaxKind[relevantNode.kind]\n\t\t\tconst typeName = `${nodeKind}: ${nodeType.toString().substring(0, 25)}`\n\t\t\tconst typeNodeIdPart =\n\t\t\t\t(nodeType as any).id ?? nodeType.toString().substring(0, 20)\n\t\t\tcallRangeData = {\n\t\t\t\ttypeId: `node-${relevantNode.kind}-${typeNodeIdPart}`,\n\t\t\t\tfunctionName: typeName\n\t\t\t}\n\t\t}\n\t}\n\n\tif (callRangeData) {\n\t\tctx.callRanges.push({\n\t\t\tid: `${entry.ts}-${entryPos}-${entryEnd}`,\n\t\t\ttypeId: callRangeData.typeId,\n\t\t\tfunctionName: callRangeData.functionName,\n\t\t\tcallSite: `${entryPath}:${entryPos}-${entryEnd}`,\n\t\t\tstartTime: entry.ts,\n\t\t\tendTime: entry.ts + entryDur,\n\t\t\tduration: entryDur,\n\t\t\tchildren: [],\n\t\t\tselfTime: entryDur\n\t\t})\n\t} else {\n\t\tthrow new Error(\n\t\t\t`Failed to identify a processable AST node for duration entry (name: ${entry.name}, path: ${entryPath}, pos: ${entryPos}-${entryEnd}).`\n\t\t)\n\t}\n}\n\nconst findCallExpressionInRange = (\n\tfile: ts.SourceFile,\n\tstart: number,\n\tend: number\n): ts.CallExpression | undefined => {\n\tconst boundingCall = nearestBoundingCallExpression(file, start)\n\tif (boundingCall && boundingCall.pos >= start && boundingCall.end <= end)\n\t\treturn boundingCall\n\n\tconst allNodes = getDescendants(file)\n\tconst nodesInRange = allNodes.filter(\n\t\tnode => node.pos >= start && node.end <= end\n\t)\n\n\tconst callExpressions = nodesInRange.filter(node =>\n\t\tts.isCallExpression(node)\n\t) as ts.CallExpression[]\n\n\tif (callExpressions.length === 0) return undefined\n\n\tconst methodCalls = callExpressions.filter(call =>\n\t\tts.isPropertyAccessExpression(call.expression)\n\t)\n\treturn methodCalls.length > 0 ? methodCalls[0] : callExpressions[0]\n}\n\nconst extractFunctionName = (callExpr: ts.CallExpression): string => {\n\tif (ts.isPropertyAccessExpression(callExpr.expression))\n\t\treturn callExpr.expression.name.getText()\n\tif (ts.isIdentifier(callExpr.expression)) return callExpr.expression.getText()\n\treturn \"anonymousFunction\"\n}\n\nconst buildCallTree = (ctx: AnalysisContext): void => {\n\t// This message goes to outputCapture for the summary file\n\toutputCapture.write(\n\t\t`Building call tree from ${ctx.callRanges.length} ranges...`\n\t)\n\tctx.callRanges.sort((a, b) => a.startTime - b.startTime)\n\tconst activeCallStack: CallRange[] = []\n\n\tfor (const call of ctx.callRanges) {\n\t\twhile (\n\t\t\tactiveCallStack.length > 0 &&\n\t\t\tactiveCallStack[activeCallStack.length - 1].endTime < call.startTime\n\t\t)\n\t\t\tactiveCallStack.pop()\n\n\t\tif (activeCallStack.length === 0) ctx.rootCalls.push(call)\n\t\telse {\n\t\t\tconst parent = activeCallStack[activeCallStack.length - 1]\n\t\t\tparent.children.push(call)\n\t\t}\n\t\tactiveCallStack.push(call)\n\t}\n\toutputCapture.write(\n\t\t`Call tree built with ${ctx.rootCalls.length} root calls.`\n\t)\n}\n\nconst calculateSelfTimes = (call: CallRange): number => {\n\tlet childrenTime = 0\n\tfor (const child of call.children) childrenTime += calculateSelfTimes(child)\n\tcall.selfTime = call.duration - childrenTime\n\tif (call.selfTime < 0) call.selfTime = 0\n\treturn call.duration\n}\n\nconst collectFunctionStats = (call: CallRange, ctx: AnalysisContext): void => {\n\tif (!ctx.functionStats[call.typeId]) {\n\t\tctx.functionStats[call.typeId] = {\n\t\t\ttypeId: call.typeId,\n\t\t\tfunctionName: call.functionName,\n\t\t\ttotalTime: 0,\n\t\t\tselfTime: 0,\n\t\t\tcount: 0,\n\t\t\tfirstLocation: call.callSite,\n\t\t\tdetailedCallSites: []\n\t\t}\n\t}\n\n\tconst stats = ctx.functionStats[call.typeId]\n\tconst [filePath, positionRange] = call.callSite.split(\":\")\n\tif (!filePath || !positionRange)\n\t\tthrow new Error(`Invalid callSite format: ${call.callSite}`)\n\tconst [posStr, endStr] = positionRange.split(\"-\")\n\tconst pos = parseInt(posStr, 10)\n\tconst end = parseInt(endStr, 10)\n\tif (isNaN(pos) || isNaN(end)) {\n\t\tthrow new Error(\n\t\t\t`Invalid position in callSite: ${call.callSite}. Pos: ${posStr}, End: ${endStr}`\n\t\t)\n\t}\n\n\tstats.detailedCallSites.push({\n\t\tpath: filePath,\n\t\tpos,\n\t\tend,\n\t\tselfTime: call.selfTime\n\t})\n\tstats.totalTime += call.duration\n\tstats.selfTime += call.selfTime\n\tstats.count++\n\tfor (const child of call.children) collectFunctionStats(child, ctx)\n}\n\nconst sortAndRankFunctions = (ctx: AnalysisContext): void => {\n\toutputCapture.write(\"Sorting and ranking functions...\")\n\tfor (const stats of Object.values(ctx.functionStats))\n\t\tstats.detailedCallSites.sort((a, b) => b.selfTime - a.selfTime)\n\tctx.allFunctions = Object.values(ctx.functionStats).sort(\n\t\t(a, b) => b.selfTime - a.selfTime\n\t)\n}\n\nconst analyzeTypeInstantiations = (traceDir: string): void => {\n\tconst ctx = initializeAnalysisContext(traceDir)\n\tfilterDurationEntries(ctx) // Uses outputCapture\n\n\tconst totalEntries = ctx.durationEntries.length\n\tif (totalEntries === 0) {\n\t\toutputCapture.write(\"No duration entries with path/pos to process.\")\n\t\toutputCapture.write(\n\t\t\t`\\n✅ Analysis complete! No data to export. Summary written to:\\n` +\n\t\t\t\t`   - ${join(traceDir, \"summary.txt\")}`\n\t\t)\n\t\treturn\n\t}\n\n\tconst progressDisplay = new ProgressDisplay(totalEntries)\n\tprogressDisplay.start()\n\n\tfor (const [index, entry] of ctx.durationEntries.entries()) {\n\t\ttry {\n\t\t\tprocessDurationEntry(entry, ctx)\n\t\t} catch (e: any) {\n\t\t\tprogressDisplay.stop() // Stop progress before printing error via outputCapture\n\t\t\toutputCapture.write(\n\t\t\t\t`\\n❌ Error processing entry ${index + 1}/${totalEntries} (Path: ${entry.args.path ?? \"N/A\"}, Pos: ${entry.args.pos ?? \"N/A\"}): ${e.message}`\n\t\t\t)\n\t\t\toutputCapture.write(\"Aborting analysis due to error.\")\n\t\t\t// Early exit, summary will be written by the main trace function\n\t\t\treturn\n\t\t}\n\t\tprogressDisplay.update(index + 1)\n\t}\n\tprogressDisplay.stop() // Ensure it's stopped if loop finished\n\n\t// Subsequent messages use outputCapture and will appear after the progress bar\n\tbuildCallTree(ctx) // Uses outputCapture\n\n\toutputCapture.write(\"Calculating self-times for call tree nodes...\")\n\tfor (const root of ctx.rootCalls) calculateSelfTimes(root)\n\n\toutputCapture.write(\"Collecting statistics...\")\n\tconst ungroupedStats = collectUngroupedStats(ctx) // Uses outputCapture\n\tfor (const root of ctx.rootCalls) collectFunctionStats(root, ctx)\n\n\tsortAndRankFunctions(ctx) // Uses outputCapture\n\n\toutputCapture.write(\"\\n📊 Performance Analysis - Top Individual Calls:\\n\")\n\tdisplayIndividualSummary(ungroupedStats) // Uses outputCapture\n\n\toutputCapture.write(\"\\n📊 Performance Analysis - Functions by Self Time:\\n\")\n\tdisplayGroupedSummary(ctx.allFunctions) // Uses outputCapture\n\n\tconst rangesCsvPath = join(traceDir, \"ranges.csv\")\n\tconst namesCsvPath = join(traceDir, \"names.csv\")\n\tconst summaryFilePath = join(traceDir, \"summary.txt\") // Path already defined in trace()\n\n\tif (ctx.callRanges.length > 0) {\n\t\toutputCapture.write(\"Exporting CSV reports...\")\n\t\twriteToCsv(\n\t\t\trangesCsvPath,\n\t\t\t[\"Function Name\", \"Self (ms)\", \"Duration (ms)\", \"Location\"],\n\t\t\tungroupedStats.map(stat => [\n\t\t\t\tstat.functionName,\n\t\t\t\tformatMillis(stat.selfTime, 3),\n\t\t\t\tformatMillis(stat.duration, 3),\n\t\t\t\tformatLocation(stat.callSite)\n\t\t\t])\n\t\t)\n\n\t\twriteToCsv(\n\t\t\tnamesCsvPath,\n\t\t\t[\n\t\t\t\t\"Function Name\",\n\t\t\t\t\"Total Self (ms)\",\n\t\t\t\t\"Avg Self (ms)\",\n\t\t\t\t\"Call Count\",\n\t\t\t\t\"Top Location\",\n\t\t\t\t\"Top Self (ms)\"\n\t\t\t],\n\t\t\tctx.allFunctions.map(stats => {\n\t\t\t\tconst topUsage = stats.detailedCallSites[0] ?? {\n\t\t\t\t\tpath: \"unknown\",\n\t\t\t\t\tpos: 0,\n\t\t\t\t\tend: 0,\n\t\t\t\t\tselfTime: 0\n\t\t\t\t}\n\t\t\t\treturn [\n\t\t\t\t\tstats.functionName,\n\t\t\t\t\tformatMillis(stats.selfTime, 3),\n\t\t\t\t\tformatMillis(stats.selfTime / Math.max(1, stats.count), 3),\n\t\t\t\t\tstats.count.toString(),\n\t\t\t\t\tformatLocation(`${topUsage.path}:${topUsage.pos}-${topUsage.end}`),\n\t\t\t\t\tformatMillis(topUsage.selfTime, 3)\n\t\t\t\t]\n\t\t\t})\n\t\t)\n\t\toutputCapture.write(\n\t\t\t`\\n✅ Analysis complete! Results exported to:\\n` +\n\t\t\t\t`   - ${rangesCsvPath} (individual calls)\\n` +\n\t\t\t\t`   - ${namesCsvPath} (grouped by function name)\\n` +\n\t\t\t\t`   - ${summaryFilePath} (complete analysis report)`\n\t\t)\n\t} else {\n\t\toutputCapture.write(\n\t\t\t`\\n✅ Analysis complete! No call ranges processed to export to CSV. Summary written to:\\n` +\n\t\t\t\t`   - ${summaryFilePath}`\n\t\t)\n\t}\n}\n\nconst collectUngroupedStats = (ctx: AnalysisContext): UngroupedCallStats[] => {\n\toutputCapture.write(\"Collecting and sorting ungrouped call statistics...\")\n\tconst ungroupedStats: UngroupedCallStats[] = []\n\tconst flattenCallTree = (call: CallRange): void => {\n\t\tungroupedStats.push({\n\t\t\ttypeId: call.typeId,\n\t\t\tfunctionName: call.functionName,\n\t\t\tcallSite: call.callSite,\n\t\t\tduration: call.duration,\n\t\t\tselfTime: call.selfTime\n\t\t})\n\t\tfor (const child of call.children) flattenCallTree(child)\n\t}\n\tfor (const root of ctx.rootCalls) flattenCallTree(root)\n\treturn ungroupedStats.sort((a, b) => b.selfTime - a.selfTime)\n}\n\nconst displayIndividualSummary = (stats: UngroupedCallStats[]): void => {\n\tdisplayTableHeader([\"Rank\", \"Function Name\", \"Self (ms)\", \"Location\"])\n\tconst topN = Math.min(stats.length, 20)\n\tfor (let i = 0; i < topN; i++) {\n\t\tconst stat = stats[i]\n\t\tconst typeNameFormatted = formatTypeName(stat.functionName, 20)\n\t\tconst selfTimeMs = formatPaddedMillis(stat.selfTime, 15, 2)\n\t\tconst location = formatLocation(stat.callSite)\n\t\toutputCapture.write(\n\t\t\t`${(i + 1).toString().padStart(4)} | ${typeNameFormatted} | ${selfTimeMs} | ${location}`\n\t\t)\n\t}\n}\n\nconst displayTableHeader = (columns: string[]): void => {\n\tconst headerRow = [\n\t\tcolumns[0].padEnd(4),\n\t\tcolumns[1].padEnd(20),\n\t\tcolumns[2].padEnd(15),\n\t\t...columns.slice(3)\n\t].join(\" | \")\n\tconst separatorRow = [\n\t\t\"-\".repeat(4),\n\t\t\"-\".repeat(20),\n\t\t\"-\".repeat(15),\n\t\t...columns.slice(3).map(col => \"-\".repeat(col.length))\n\t].join(\"-|-\")\n\toutputCapture.write(headerRow)\n\toutputCapture.write(separatorRow)\n}\n\nconst displayGroupedSummary = (functions: FunctionStats[]): void => {\n\tdisplayTableHeader([\n\t\t\"Rank\",\n\t\t\"Function Name\",\n\t\t\"Total Self (ms)\",\n\t\t\"Avg Self (ms)\",\n\t\t\"Calls\",\n\t\t\"Top Usage\"\n\t])\n\tconst topN = Math.min(functions.length, 20)\n\tfor (let i = 0; i < topN; i++) {\n\t\tconst stats = functions[i]\n\t\tconst typeNameFormatted = formatTypeName(stats.functionName, 20)\n\t\tconst totalTimeMs = formatPaddedMillis(stats.selfTime, 15, 2)\n\t\tconst avgTimeMs = formatPaddedMillis(\n\t\t\tstats.selfTime / Math.max(1, stats.count),\n\t\t\t13,\n\t\t\t2\n\t\t)\n\t\tconst calls = stats.count.toString().padStart(5)\n\t\tconst topUsage = stats.detailedCallSites[0] ?? {\n\t\t\tpath: \"unknown\",\n\t\t\tpos: 0,\n\t\t\tend: 0,\n\t\t\tselfTime: 0\n\t\t}\n\t\tconst topUsageTime = formatMillis(topUsage.selfTime, 2) + \"ms\"\n\t\tconst topUsageLocation = formatLocation(\n\t\t\t`${topUsage.path}:${topUsage.pos}-${topUsage.end}`\n\t\t)\n\t\toutputCapture.write(\n\t\t\t`${(i + 1).toString().padStart(4)} | ${typeNameFormatted} | ${totalTimeMs} | ${avgTimeMs} | ${calls} | ${topUsageLocation} (${topUsageTime})`\n\t\t)\n\t}\n}\n\nconst formatTypeName = (typeName: string, maxLength: number): string => {\n\ttypeName = typeName.replace(/\\(\\)$/, \"\")\n\tif (typeName.length <= maxLength) return typeName.padEnd(maxLength)\n\tconst charsToKeep = maxLength - 3\n\tconst firstPart = Math.ceil(charsToKeep * 0.7)\n\tconst lastPart = charsToKeep - firstPart\n\treturn (\n\t\ttypeName.substring(0, firstPart) +\n\t\t\"...\" +\n\t\t(lastPart > 0 ? typeName.substring(typeName.length - lastPart) : \"\")\n\t).padEnd(maxLength)\n}\n\nconst formatLocation = (location: string): string => {\n\tif (!location || location === \"unknown\" || !location.includes(\":\"))\n\t\treturn location || \"unknown\"\n\tconst parts = location.split(\":\")\n\tif (parts.length < 2) return basename(location)\n\tconst filePath = parts.slice(0, -1).join(\":\")\n\tconst positionRange = parts[parts.length - 1]\n\tconst relativePath = relative(process.cwd(), filePath)\n\tconst [posStr] = positionRange.split(\"-\")\n\tconst pos = parseInt(posStr, 10)\n\tif (isNaN(pos)) return `${relativePath}:${positionRange}`\n\tconst sourceFile = TsServer.instance.getSourceFileOrThrow(filePath)\n\tconst lineAndChar = sourceFile.getLineAndCharacterOfPosition(pos)\n\treturn `${relativePath}:${lineAndChar.line + 1}:${lineAndChar.character + 1}`\n}\n\nconst findMostSpecificNodeInRange = (\n\tfile: ts.SourceFile,\n\tstart: number,\n\tend: number\n): ts.Node | undefined => {\n\tconst allNodes = getDescendants(file)\n\tconst nodesInRange = allNodes.filter(\n\t\tnode => node.pos >= start && node.end <= end\n\t)\n\tif (nodesInRange.length === 0) return undefined\n\tconst leafNodes = nodesInRange.filter(\n\t\tnode =>\n\t\t\t!nodesInRange.some(\n\t\t\t\tother =>\n\t\t\t\t\tother !== node && other.pos >= node.pos && other.end <= node.end\n\t\t\t)\n\t)\n\treturn findNodeByPreference(leafNodes.length > 0 ? leafNodes : nodesInRange)\n}\n\nconst findNodeByPreference = (nodes: ts.Node[]): ts.Node | undefined => {\n\tif (nodes.length === 0) return undefined\n\tconst typeReference = nodes.find(\n\t\tnode => ts.isTypeReferenceNode(node) || ts.isTypeQueryNode(node)\n\t)\n\tif (typeReference) return typeReference\n\tconst declaration = nodes.find(\n\t\tnode =>\n\t\t\tts.isVariableDeclaration(node) ||\n\t\t\tts.isFunctionDeclaration(node) ||\n\t\t\tts.isClassDeclaration(node) ||\n\t\t\tts.isInterfaceDeclaration(node)\n\t)\n\tif (declaration) return declaration\n\tconst propertyAccess = nodes.find(node => ts.isPropertyAccessExpression(node))\n\tif (propertyAccess) return propertyAccess\n\tconst assignment = nodes.find(\n\t\tnode =>\n\t\t\tts.isBinaryExpression(node) &&\n\t\t\tnode.operatorToken.kind === ts.SyntaxKind.EqualsToken\n\t)\n\tif (assignment) return assignment\n\tconst expression = nodes.find(\n\t\tnode => ts.isExpressionStatement(node) || ts.isExpression(node)\n\t)\n\tif (expression) return expression\n\treturn nodes.sort((a, b) => a.end - a.pos - (b.end - b.pos))[0]\n}\n\nconst writeToCsv = (\n\tfilePath: string,\n\theaders: string[],\n\trows: string[][]\n): void => {\n\tconst content = [\n\t\theaders.join(\",\"),\n\t\t...rows.map(row => row.map(escapeForCsv).join(\",\"))\n\t].join(\"\\n\")\n\twriteFile(filePath, content)\n}\n\nconst escapeForCsv = (value: string): string => {\n\tif (value.includes(\",\") || value.includes('\"') || value.includes(\"\\n\"))\n\t\treturn `\"${value.replace(/\"/g, '\"\"')}\"`\n\treturn value\n}\n"
  },
  {
    "path": "ark/attest/config.ts",
    "content": "import { ensureDir, fromCwd } from \"@ark/fs\"\nimport {\n\tisArray,\n\tliftArray,\n\ttryParseNumber,\n\ttype autocomplete\n} from \"@ark/util\"\nimport { existsSync } from \"node:fs\"\nimport { join, resolve } from \"node:path\"\nimport type * as prettier from \"prettier\"\nimport type ts from \"typescript\"\nimport {\n\tfindAttestTypeScriptVersions,\n\ttype TsVersionData\n} from \"./tsVersioning.ts\"\n\nexport type TsVersionAliases = autocomplete<\"*\"> | string[]\n\nexport type BenchErrorConfig = \"runtime\" | \"types\" | boolean\n\ntype BaseAttestConfig = {\n\ttsconfig: string | null | undefined\n\tcompilerOptions: ts.CompilerOptions\n\tupdateSnapshots: boolean\n\tfailOnMissingSnapshots: boolean\n\t/** A string or list of strings representing the TypeScript version aliases to run.\n\t *\n\t * Aliases must be specified as a package.json dependency or devDependency beginning with \"typescript\".\n\t * Alternate aliases can be specified using the \"npm:\" prefix:\n\t * ```json\n\t * \t\t\"typescript\": \"latest\",\n\t * \t\t\"typescript-next: \"npm:typescript@next\",\n\t * \t\t\"typescript-1\": \"npm:typescript@5.2\"\n\t * \t\t\"typescript-2\": \"npm:typescript@5.1\"\n\t * ```\n\t *\n\t * \"*\" can be pased to run all discovered versions beginning with \"typescript\".\n\t */\n\ttsVersions: TsVersionAliases | TsVersionData[]\n\tskipTypes: boolean\n\tskipInlineInstantiations: boolean\n\tattestAliases: string[]\n\tbenchPercentThreshold: number\n\tbenchErrorOnThresholdExceeded: BenchErrorConfig\n\tfilter: string | undefined\n\ttestDeclarationAliases: string[]\n\tformatCmd: string\n\tshouldFormat: boolean\n\t/**\n\t *  Provided options will override the following defaults.\n\t *  Any options not listed will fallback to Prettier's default value.\n\t *\n\t * {\n\t *\t semi: false,\n\t *\t printWidth: 60,\n\t *\t trailingComma: \"none\",\n\t * }\n\t */\n\ttypeToStringFormat: prettier.Options\n}\n\nexport type AttestConfig = Partial<BaseAttestConfig>\n\nexport const getDefaultAttestConfig = (): BaseAttestConfig => ({\n\ttsconfig:\n\t\texistsSync(fromCwd(\"tsconfig.json\")) ? fromCwd(\"tsconfig.json\") : undefined,\n\tcompilerOptions: {},\n\tattestAliases: [\"attest\", \"attestInternal\"],\n\tfailOnMissingSnapshots: \"CI\" in process.env,\n\tupdateSnapshots: false,\n\tskipTypes: false,\n\tskipInlineInstantiations: false,\n\ttsVersions: \"default\",\n\tbenchPercentThreshold: 20,\n\tbenchErrorOnThresholdExceeded: true,\n\tfilter: undefined,\n\ttestDeclarationAliases: [\"bench\", \"it\", \"test\"],\n\tformatCmd: `npm exec --no -- prettier --write`,\n\tshouldFormat: true,\n\ttypeToStringFormat: {}\n})\n\nconst flagAliases: { [k in keyof AttestConfig]?: string[] } = {\n\tupdateSnapshots: [\"u\", \"update\"]\n}\n\nconst findParamIndex = (flagOrAlias: string) =>\n\tprocess.argv.findIndex(\n\t\targ => arg === `-${flagOrAlias}` || arg === `--${flagOrAlias}`\n\t)\n\nconst hasFlag = (flag: keyof AttestConfig) =>\n\tfindParamIndex(flag) !== -1 ||\n\tflagAliases[flag]?.some(alias => findParamIndex(alias) !== -1)\n\nconst getParamValue = (param: keyof AttestConfig) => {\n\tlet paramIndex = findParamIndex(param)\n\tif (paramIndex === -1) {\n\t\tif (!flagAliases[param]) return\n\n\t\tfor (let i = 0; i < flagAliases[param].length && paramIndex === -1; i++)\n\t\t\tparamIndex = findParamIndex(flagAliases[param][i])\n\n\t\tif (paramIndex === -1) return\n\t}\n\n\tconst raw = process.argv[paramIndex + 1]\n\tif (raw === \"true\") return true\n\n\tif (raw === \"false\") return false\n\n\tif (raw === \"null\") return null\n\n\tif (param === \"benchPercentThreshold\")\n\t\treturn tryParseNumber(raw, { errorOnFail: true })\n\n\tif (param === \"tsVersions\" || param === \"attestAliases\") return raw.split(\",\")\n\n\tif (param === \"typeToStringFormat\" || param === \"compilerOptions\")\n\t\treturn JSON.parse(raw)\n\n\treturn raw\n}\n\nexport const attestEnvPrefix = \"ATTEST_\"\n\nconst addEnvConfig = (config: BaseAttestConfig) => {\n\tfor (const [k, v] of Object.entries(process.env as Record<string, string>)) {\n\t\tif (k.startsWith(attestEnvPrefix)) {\n\t\t\tconst optionName = k.slice(attestEnvPrefix.length)\n\t\t\tif (optionName === \"CONFIG\") Object.assign(config, JSON.parse(v))\n\t\t\telse (config as any)[optionName] = JSON.parse(v)\n\t\t}\n\t}\n\tlet k: keyof BaseAttestConfig\n\tfor (k in config) {\n\t\tif (config[k] === false) config[k] = hasFlag(k) as never\n\t\telse {\n\t\t\tconst value = getParamValue(k)\n\t\t\tif (value !== undefined) config[k] = value as never\n\t\t}\n\t}\n\treturn config\n}\n\nexport interface ParsedAttestConfig extends Readonly<BaseAttestConfig> {\n\tcacheDir: string\n\tassertionCacheDir: string\n\tdefaultAssertionCachePath: string\n\ttsVersions: TsVersionData[]\n}\n\nconst parseConfig = (): ParsedAttestConfig => {\n\tconst baseConfig = addEnvConfig(getDefaultAttestConfig())\n\tconst cacheDir = resolve(\".attest\")\n\tconst assertionCacheDir = join(cacheDir, \"assertions\")\n\tconst defaultAssertionCachePath = join(assertionCacheDir, \"typescript.json\")\n\n\treturn Object.assign(baseConfig, {\n\t\tcacheDir,\n\t\tassertionCacheDir,\n\t\tdefaultAssertionCachePath,\n\t\ttsVersions:\n\t\t\tbaseConfig.skipTypes ? []\n\t\t\t: isTsVersionAliases(baseConfig.tsVersions) ?\n\t\t\t\tparseTsVersions(baseConfig.tsVersions)\n\t\t\t:\tbaseConfig.tsVersions\n\t})\n}\n\nconst isTsVersionAliases = (\n\tv: AttestConfig[\"tsVersions\"]\n): v is TsVersionAliases =>\n\ttypeof v === \"string\" || (isArray(v) && typeof v[0] === \"string\")\n\nconst parseTsVersions = (aliases: TsVersionAliases): TsVersionData[] => {\n\tconst versions = findAttestTypeScriptVersions()\n\tif (aliases === \"*\" || (isArray(aliases) && aliases[0] === \"*\"))\n\t\treturn versions\n\n\treturn liftArray(aliases).map(alias => {\n\t\tconst matching = versions.find(v => v.alias === alias)\n\t\tif (!matching) {\n\t\t\tthrow new Error(\n\t\t\t\t`Specified TypeScript version ${alias} does not exist.` +\n\t\t\t\t\t` It should probably be specified in package.json like:\n\"@ark/attest-ts-${alias}\": \"npm:typescript@latest\"`\n\t\t\t)\n\t\t}\n\t\treturn matching\n\t})\n}\n\nlet cachedConfig: ParsedAttestConfig | undefined\n\nexport const getConfig = (): ParsedAttestConfig => parseConfig()\n\n// workaround for a bug in Node 25 that creates localStorage as an empty proxy,\n// leading to @typescript/vfs eventually throwing when it sees that it is not\n// undefined and tries to call `getItem`:\n\n// https://github.com/nodejs/node/issues/60303\n\n// this can be removed once the bug is addressed in Node\nif (!globalThis.localStorage?.getItem)\n\tglobalThis.localStorage = undefined as never\n\nexport const ensureCacheDirs = (): void => {\n\tcachedConfig ??= getConfig()\n\tensureDir(cachedConfig.cacheDir)\n\tensureDir(cachedConfig.assertionCacheDir)\n}\n"
  },
  {
    "path": "ark/attest/fixtures.ts",
    "content": "import { fileName, shell, writeJson } from \"@ark/fs\"\nimport { rmSync } from \"node:fs\"\nimport { join } from \"node:path\"\nimport { writeSnapshotUpdatesOnExit } from \"./cache/snapshots.ts\"\nimport { analyzeProjectAssertions } from \"./cache/writeAssertionCache.ts\"\nimport { ensureCacheDirs, getConfig, type AttestConfig } from \"./config.ts\"\nimport { forTypeScriptVersions } from \"./tsVersioning.ts\"\n\nexport const setup = (options?: Partial<AttestConfig>): typeof teardown => {\n\tconst { ...config } = getConfig()\n\tif (options) Object.assign(config, options)\n\tprocess.env.ATTEST_CONFIG = JSON.stringify(config)\n\trmSync(config.cacheDir, { recursive: true, force: true })\n\tensureCacheDirs()\n\tif (config.skipTypes) return teardown\n\n\tif (\n\t\tconfig.tsVersions.length === 1 &&\n\t\tconfig.tsVersions[0].alias === \"default\"\n\t)\n\t\twriteAssertionData(config.defaultAssertionCachePath)\n\telse {\n\t\tforTypeScriptVersions(config.tsVersions, version => {\n\t\t\tconst precachePath = join(\n\t\t\t\tconfig.assertionCacheDir,\n\t\t\t\tversion.alias + \".json\"\n\t\t\t)\n\t\t\t// if we're in our own repo, we need to pnpm to use the root script to execute ts directly\n\t\t\tif (fileName().endsWith(\"ts\"))\n\t\t\t\tshell(`pnpm attest precache ${precachePath}`)\n\t\t\t// otherwise, just use npm to run the CLI command from build output\n\t\t\telse shell(`npm exec -c \"attest precache ${precachePath}\"`)\n\t\t})\n\t}\n\treturn teardown\n}\n\nexport const writeAssertionData = (toPath: string): void => {\n\tconsole.log(\n\t\t\"⏳ Waiting for TypeScript to check your project (this may take a while)...\"\n\t)\n\twriteJson(toPath, analyzeProjectAssertions())\n}\n\nexport const cleanup = (): void => writeSnapshotUpdatesOnExit()\n\n/** alias for cleanup to align with vitest and others */\nexport const teardown: () => void = cleanup\n"
  },
  {
    "path": "ark/attest/index.ts",
    "content": "export { cleanup, setup, teardown, writeAssertionData } from \"./fixtures.ts\"\n// ensure fixtures are exported before config so additional settings can load\nexport { caller, type CallerOfOptions } from \"@ark/fs\"\nexport { attest } from \"./assert/attest.ts\"\nexport { bench } from \"./bench/bench.ts\"\nexport {\n\tgetBenchAssertionsAtPosition,\n\tgetTypeAssertionsAtPosition\n} from \"./cache/getCachedAssertions.ts\"\nexport type {\n\tArgAssertionData,\n\tLinePositionRange,\n\tTypeAssertionData,\n\tTypeRelationship\n} from \"./cache/writeAssertionCache.ts\"\nexport { getDefaultAttestConfig, type AttestConfig } from \"./config.ts\"\nexport {\n\tfindAttestTypeScriptVersions,\n\tgetPrimaryTsVersionUnderTest\n} from \"./tsVersioning.ts\"\nexport { contextualize } from \"./utils.ts\"\n"
  },
  {
    "path": "ark/attest/package.json",
    "content": "{\n\t\"name\": \"@ark/attest\",\n\t\"version\": \"0.56.0\",\n\t\"license\": \"MIT\",\n\t\"author\": {\n\t\t\"name\": \"David Blass\",\n\t\t\"email\": \"david@arktype.io\",\n\t\t\"url\": \"https://arktype.io\"\n\t},\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"https://github.com/arktypeio/arktype.git\",\n\t\t\"directory\": \"ark/attest\"\n\t},\n\t\"type\": \"module\",\n\t\"main\": \"./out/index.js\",\n\t\"types\": \"./out/index.d.ts\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"ark-ts\": \"./index.ts\",\n\t\t\t\"default\": \"./out/index.js\"\n\t\t},\n\t\t\"./internal/*.ts\": {\n\t\t\t\"ark-ts\": \"./*.ts\",\n\t\t\t\"default\": \"./out/*.js\"\n\t\t},\n\t\t\"./internal/*.js\": {\n\t\t\t\"ark-ts\": \"./*.ts\",\n\t\t\t\"default\": \"./out/*.js\"\n\t\t}\n\t},\n\t\"files\": [\n\t\t\"out\"\n\t],\n\t\"bin\": {\n\t\t\"attest\": \"out/cli/cli.js\"\n\t},\n\t\"scripts\": {\n\t\t\"build\": \"ts ../repo/build.ts\",\n\t\t\"test\": \"ts ../repo/testPackage.ts\"\n\t},\n\t\"dependencies\": {\n\t\t\"@ark/fs\": \"workspace:*\",\n\t\t\"@ark/util\": \"workspace:*\",\n\t\t\"@prettier/sync\": \"0.6.1\",\n\t\t\"@typescript/analyze-trace\": \"0.10.1\",\n\t\t\"@typescript/vfs\": \"1.6.1\",\n\t\t\"arktype\": \"workspace:*\",\n\t\t\"@ark/schema\": \"workspace:*\",\n\t\t\"prettier\": \"3.6.2\"\n\t},\n\t\"devDependencies\": {\n\t\t\"typescript\": \"catalog:\"\n\t},\n\t\"peerDependencies\": {\n\t\t\"typescript\": \"*\"\n\t},\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t}\n}\n"
  },
  {
    "path": "ark/attest/tsVersioning.ts",
    "content": "import { assertPackageRoot, findPackageAncestors, readJson } from \"@ark/fs\"\nimport type { Digit } from \"@ark/util\"\nimport {\n\texistsSync,\n\treaddirSync,\n\trenameSync,\n\tstatSync,\n\tsymlinkSync,\n\tunlinkSync\n} from \"node:fs\"\nimport { join } from \"node:path\"\nimport ts from \"typescript\"\n\n/**\n * Executes a provided function for an installed set of TypeScript versions.\n *\n * Your primary TypeScript version at node_modules/typescript will be\n * temporarily renamed to node_modules/typescript-temp, and reset after each\n * version has been executed, regardless of failures.\n *\n * Throws an error if any version fails when the associated function is executed.\n *\n * fn should spawn a new process so the new symlinked version can be loaded.\n */\nexport const forTypeScriptVersions = (\n\tversions: TsVersionData[],\n\tfn: (version: TsVersionData) => void\n): void => {\n\tconst passedVersions: TsVersionData[] = []\n\tconst failedVersions: TsVersionData[] = []\n\tconst nodeModules = join(assertPackageRoot(process.cwd()), \"node_modules\")\n\tconst tsPrimaryPath = join(nodeModules, \"typescript\")\n\tconst tsTemporaryPath = join(nodeModules, \"typescript-temp\")\n\n\tif (existsSync(tsTemporaryPath)) unlinkSync(tsTemporaryPath)\n\tif (existsSync(tsPrimaryPath)) renameSync(tsPrimaryPath, tsTemporaryPath)\n\n\ttry {\n\t\tfor (const version of versions) {\n\t\t\tconst targetPath =\n\t\t\t\tversion.path === tsPrimaryPath ? tsTemporaryPath : version.path\n\t\t\tconsole.log(\n\t\t\t\t`⛵ Switching to TypeScript version ${version.alias} (${version.version})...`\n\t\t\t)\n\t\t\ttry {\n\t\t\t\tif (existsSync(tsPrimaryPath)) unlinkSync(tsPrimaryPath)\n\t\t\t\tsymlinkSync(targetPath, tsPrimaryPath, \"junction\")\n\t\t\t\tfn(version)\n\t\t\t\tpassedVersions.push(version)\n\t\t\t} catch (e) {\n\t\t\t\tconsole.error(e)\n\t\t\t\tfailedVersions.push(version)\n\t\t\t}\n\t\t}\n\t\tif (failedVersions.length !== 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`❌ The following TypeScript versions threw: ${failedVersions\n\t\t\t\t\t.map(v => `${v.alias} (${v.version})`)\n\t\t\t\t\t.join(\", \")}`\n\t\t\t)\n\t\t}\n\t\tconsole.log(\n\t\t\t`✅ Successfully ran TypeScript versions ${passedVersions\n\t\t\t\t.map(v => `${v.alias} (${v.version})`)\n\t\t\t\t.join(\", \")}`\n\t\t)\n\t} finally {\n\t\tif (existsSync(tsTemporaryPath)) {\n\t\t\tconsole.log(`⏮️ Restoring your original TypeScript version...`)\n\t\t\tunlinkSync(tsPrimaryPath)\n\t\t\trenameSync(tsTemporaryPath, tsPrimaryPath)\n\t\t}\n\t}\n}\n\nexport type TsVersionData = {\n\talias: string\n\tversion: string\n\tpath: string\n}\n\nconst possibleTsVersionPrefix = \"typescript-\"\nconst strictTsVersionPrefix = \"attest-ts-\"\n\n/**\n * Determine the alias from the directory name\n */\nconst getDirAlias = (dirName: string): string | null => {\n\tif (dirName === \"typescript\") return \"default\"\n\tif (dirName.startsWith(possibleTsVersionPrefix))\n\t\treturn dirName.slice(possibleTsVersionPrefix.length)\n\tif (dirName.startsWith(strictTsVersionPrefix))\n\t\treturn dirName.slice(strictTsVersionPrefix.length)\n\treturn null\n}\n\n/**\n * Try to get the TypeScript version from a directory\n */\nconst getTsVersion = (fullPath: string): string | null => {\n\ttry {\n\t\t// Try to read package.json for version\n\t\tconst packageJsonPath = join(fullPath, \"package.json\")\n\t\tif (existsSync(packageJsonPath)) {\n\t\t\tconst packageJson = readJson(packageJsonPath)\n\t\t\tif (\n\t\t\t\tpackageJson &&\n\t\t\t\tpackageJson.name === \"typescript\" &&\n\t\t\t\ttypeof packageJson.version === \"string\"\n\t\t\t)\n\t\t\t\treturn packageJson.version\n\t\t}\n\n\t\t// As a fallback, check for the lib/typescript.js file which should exist in all TS installations\n\t\tif (existsSync(join(fullPath, \"lib\", \"typescript.js\"))) return \"unknown\"\n\n\t\treturn null\n\t} catch {\n\t\treturn null\n\t}\n}\n\n/**\n * Find and return the paths of all installed TypeScript versions by directly scanning\n * node_modules directories in the current package and all parent packages.\n *\n * This function only looks at directories, bypassing package.json entirely.\n *\n * @returns {TsVersionData[]} Information about each TypeScript version found\n */\nexport const findAttestTypeScriptVersions = (): TsVersionData[] => {\n\tconst packagePaths = findPackageAncestors(process.cwd())\n\tconst versions: TsVersionData[] = []\n\tconst foundVersionAliases = new Set<string>()\n\n\t// Check each package's node_modules directory\n\tfor (const packagePath of packagePaths) {\n\t\tconst nodeModulesPath = join(packagePath, \"node_modules\")\n\t\tif (\n\t\t\t!existsSync(nodeModulesPath) ||\n\t\t\t!statSync(nodeModulesPath).isDirectory()\n\t\t)\n\t\t\tcontinue\n\n\t\t// Check for regular typescript or typescript-* directories\n\t\tconst dirNames = readdirSync(nodeModulesPath)\n\t\tfor (const dirName of dirNames) {\n\t\t\t// Skip node_modules/@* directories - we'll handle them below\n\t\t\tif (dirName.startsWith(\"@\")) continue\n\n\t\t\tconst fullPath = join(nodeModulesPath, dirName)\n\t\t\tif (!statSync(fullPath).isDirectory()) continue\n\n\t\t\tconst alias = getDirAlias(dirName)\n\t\t\tif (!alias) continue\n\n\t\t\t// Skip if we already found this alias in a closer package\n\t\t\tif (foundVersionAliases.has(alias)) continue\n\n\t\t\tconst version = getTsVersion(fullPath)\n\t\t\tif (version) {\n\t\t\t\tfoundVersionAliases.add(alias)\n\t\t\t\tversions.push({\n\t\t\t\t\talias,\n\t\t\t\t\tversion,\n\t\t\t\t\tpath: fullPath\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\t// Check for @ark/attest-ts-* directories\n\t\tconst arkDir = join(nodeModulesPath, \"@ark\")\n\t\tif (existsSync(arkDir) && statSync(arkDir).isDirectory()) {\n\t\t\tconst arkDirs = readdirSync(arkDir)\n\t\t\tfor (const dirName of arkDirs) {\n\t\t\t\tif (!dirName.startsWith(\"attest-ts-\")) continue\n\n\t\t\t\tconst fullPath = join(arkDir, dirName)\n\t\t\t\tif (!statSync(fullPath).isDirectory()) continue\n\n\t\t\t\tconst alias = getDirAlias(dirName)\n\t\t\t\tif (!alias) continue\n\n\t\t\t\t// Skip if we already found this alias in a closer package\n\t\t\t\tif (foundVersionAliases.has(alias)) continue\n\n\t\t\t\tconst version = getTsVersion(fullPath)\n\t\t\t\tif (version) {\n\t\t\t\t\tfoundVersionAliases.add(alias)\n\t\t\t\t\tversions.push({\n\t\t\t\t\t\talias,\n\t\t\t\t\t\tversion,\n\t\t\t\t\t\tpath: fullPath\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn versions\n}\n\n/** Get the TypeScript version being used by attest as as string like \"5.0\"\n *  Does not include alternate versions that may be referenced by cache files\n */\nexport const getPrimaryTsVersionUnderTest = (): `${Digit}.${Digit}` =>\n\tts.versionMajorMinor\n"
  },
  {
    "path": "ark/attest/utils.ts",
    "content": "import { caller } from \"@ark/fs\"\nimport { throwError } from \"@ark/util\"\nimport { basename, relative } from \"node:path\"\n\nexport const getFileKey = (path: string): string => relative(\".\", path)\n\n/**\n *  Can be used to allow arbitrarily chained property access and function calls.\n */\nexport const chainableNoOpProxy: any = new Proxy(() => chainableNoOpProxy, {\n\tget: () => chainableNoOpProxy\n})\n\nexport type ContextualTests<ctx = unknown> = (\n\tit: (name: string, test: (ctx: ctx) => void) => void\n) => void\n\nexport type ContextualizeRoot = {\n\t// if this unused ctx type is removed, TS can no longer infer the overloads\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t<ctx>(tests: () => void, createCtx?: never): void\n\t<ctx>(createCtx: () => ctx, tests: ContextualTests<ctx>): void\n}\n\nexport type ContextualizeEach = <ctx>(\n\tname: string,\n\tcreateCtx: () => ctx,\n\ttests: ContextualTests<ctx>\n) => void\n\nexport interface Contextualize extends ContextualizeRoot {\n\teach: ContextualizeEach\n}\n\nconst testDirName = \"__tests__\"\nconst testSuffix = \".test.ts\"\n\nconst contextualizeRoot: ContextualizeRoot = (first, contextualTests) => {\n\tconst describe = globalThis.describe\n\tif (!describe) {\n\t\tthrow new Error(\n\t\t\t`contextualize cannot be used without a global 'describe' function.`\n\t\t)\n\t}\n\tconst filePath = caller().file\n\tconst testsDirChar = filePath.search(testDirName)\n\tconst suiteNamePath =\n\t\ttestsDirChar === -1 ?\n\t\t\tbasename(filePath)\n\t\t:\tfilePath.slice(testsDirChar + testDirName.length + 1)\n\tconst suiteName = suiteNamePath.slice(0, -testSuffix.length)\n\tif (contextualTests) {\n\t\tdescribe(suiteName, () =>\n\t\t\tcontextualTests((name, test) => {\n\t\t\t\tit(name, () => test(first() as never))\n\t\t\t})\n\t\t)\n\t} else describe(suiteName, first)\n}\n\nconst contextualizeEach: ContextualizeEach = (name, createCtx, tests) => {\n\tconst describe = globalThis.describe\n\tif (!describe) throwNoDescribeError()\n\n\tdescribe(name, () =>\n\t\ttests((name, test) => {\n\t\t\tit(name, () => test(createCtx()))\n\t\t})\n\t)\n}\n\nexport const contextualize: Contextualize = Object.assign(contextualizeRoot, {\n\teach: contextualizeEach\n})\n\nconst throwNoDescribeError = () =>\n\tthrowError(\n\t\t\"contextualize cannot be used without a global 'describe' function.\"\n\t)\n"
  },
  {
    "path": "ark/docs/.turbo/daemon/a6661884d53fb864-turbo.log.2025-10-05",
    "content": ""
  },
  {
    "path": "ark/docs/README.md",
    "content": "# my-app\n\nThis is a Next.js application generated with\n[Create Fumadocs](https://github.com/fuma-nama/fumadocs).\n\nRun development server:\n\n```bash\nnpm run dev\n# or\npnpm dev\n# or\nyarn dev\n```\n\nOpen http://localhost:3000 with your browser to see the result.\n\n## Learn More\n\nTo learn more about Next.js and Fumadocs, take a look at the following\nresources:\n\n- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js\n  features and API.\n- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.\n- [Fumadocs](https://fumadocs.vercel.app) - learn about Fumadocs\n"
  },
  {
    "path": "ark/docs/app/(home)/layout.tsx",
    "content": "import { HomeLayout } from \"fumadocs-ui/layouts/home\"\nimport type { ReactNode } from \"react\"\nimport { FloatYourBoat } from \"../../components/FloatYourBoat.tsx\"\nimport { baseOptions } from \"../layout.config.tsx\"\n\nexport type LayoutProps = {\n\tchildren: ReactNode\n}\n\nexport default ({ children }: LayoutProps): React.ReactElement => (\n\t<HomeLayout\n\t\t{...baseOptions}\n\t\tnav={{\n\t\t\t...baseOptions.nav,\n\t\t\tchildren: <FloatYourBoat />\n\t\t}}\n\t>\n\t\t{children}\n\t</HomeLayout>\n)\n"
  },
  {
    "path": "ark/docs/app/(home)/page.tsx",
    "content": "import {\n\tFunnelIcon,\n\tLightbulbIcon,\n\tMessageCircleWarning,\n\tRocketIcon,\n\tSearchIcon\n} from \"lucide-react\"\nimport { ArkCard, ArkCards } from \"../../components/ArkCard.tsx\"\nimport { CodeBlock } from \"../../components/CodeBlock.tsx\"\nimport { Hero } from \"../../components/Hero.tsx\"\nimport { TsIcon } from \"../../components/icons/ts.tsx\"\nimport { LinkCard } from \"../../components/LinkCard.tsx\"\nimport { RuntimeBenchmarksGraph } from \"../../components/RuntimeBenchmarksGraph.tsx\"\n\nexport default () => (\n\t<div className=\"flex-1 pt-40 container relative pb-20\">\n\t\t<Hero />\n\n\t\t<ArkCards>\n\t\t\t<ArkCard title=\"Unparalleled DX\" icon={<TsIcon height={20} />}>\n\t\t\t\tType syntax you already know with safety and completions unlike anything\n\t\t\t\tyou've ever seen\n\t\t\t\t<CodeBlock\n\t\t\t\t\tstyle={{ marginTop: \"1rem\" }}\n\t\t\t\t\tfromFile=\"unparalleledDx\"\n\t\t\t\t\tincludesCompletions\n\t\t\t\t/>\n\t\t\t</ArkCard>\n\t\t\t<ArkCard title=\"Better Errors\" icon={<MessageCircleWarning />}>\n\t\t\t\tDeeply customizable messages with great defaults\n\t\t\t\t<CodeBlock style={{ marginTop: \"1rem\" }} fromFile=\"betterErrors\" />\n\t\t\t</ArkCard>\n\t\t\t<ArkCard title=\"Clarity and Concision\" icon={<FunnelIcon />}>\n\t\t\t\tDefinitions are half as long, type errors are twice as readable, and\n\t\t\t\thovers tell you just what really matters\n\t\t\t\t<CodeBlock\n\t\t\t\t\tstyle={{ marginTop: \"1rem\" }}\n\t\t\t\t\tfromFile=\"clarityAndConcision\"\n\t\t\t\t/>\n\t\t\t</ArkCard>\n\t\t\t<ArkCard title=\"Faster... everything\" icon={<RocketIcon />}>\n\t\t\t\t20x faster than Zod4 and 2,000x faster than Yup at runtime, with editor\n\t\t\t\tperformance that will remind you how autocomplete is supposed to feel\n\t\t\t\t<RuntimeBenchmarksGraph className=\"pt-4\" />\n\t\t\t</ArkCard>\n\t\t\t<ArkCard title=\"Deep Introspectability\" icon={<SearchIcon />}>\n\t\t\t\tArkType uses set theory to understand and expose the relationships\n\t\t\t\tbetween your types at runtime the way TypeScript does at compile time\n\t\t\t\t<CodeBlock\n\t\t\t\t\tstyle={{ marginTop: \"1rem\" }}\n\t\t\t\t\tfromFile=\"deepIntrospectability\"\n\t\t\t\t/>\n\t\t\t</ArkCard>\n\t\t\t<ArkCard title=\"Intrinsic Optimization\" icon={<LightbulbIcon />}>\n\t\t\t\tEvery schema is internally normalized and reduced to its purest and\n\t\t\t\tfastest representation\n\t\t\t\t<CodeBlock\n\t\t\t\t\tstyle={{ marginTop: \"1rem\" }}\n\t\t\t\t\tfromFile=\"intrinsicOptimization\"\n\t\t\t\t/>\n\t\t\t</ArkCard>\n\t\t\t{/* <Card title=\"Portable\" icon=\"seti:json\">\n        <p>\n\t\tMost definitions are just objects and strings- take them across the stack or\n\t\teven outside JS altogether\n    </p>\n\t</Card> */}\n\t\t</ArkCards>\n\n\t\t<LinkCard\n\t\t\ttitle=\"Doc up\"\n\t\t\tdescription=\"Everything you need to know from installation to integration\"\n\t\t\thref=\"/docs/intro/setup\"\n\t\t\tclassName=\"sm:mt-16 mt-4\"\n\t\t/>\n\t</div>\n)\n"
  },
  {
    "path": "ark/docs/app/api/search/route.ts",
    "content": "import {\n\tcreateSearchAPI,\n\ttype AdvancedIndex\n} from \"fumadocs-core/search/server\"\nimport { source } from \"../../../lib/source.tsx\"\n\n// it should be cached forever\nexport const revalidate = false\nexport const { staticGET: GET } = createSearchAPI(\"advanced\", {\n\tindexes: await Promise.all(\n\t\tsource.getPages().map(\n\t\t\tasync page =>\n\t\t\t\t({\n\t\t\t\t\tid: page.url,\n\t\t\t\t\ttitle: page.data.title,\n\t\t\t\t\tdescription: page.data.description,\n\t\t\t\t\turl: page.url,\n\t\t\t\t\tstructuredData: (await page.data.load()).structuredData\n\t\t\t\t}) as AdvancedIndex\n\t\t)\n\t)\n})\n"
  },
  {
    "path": "ark/docs/app/discord/page.tsx",
    "content": "import { redirect } from \"next/navigation\"\nimport { defineMetadata } from \"../metadata.ts\"\n\nexport const metadata = defineMetadata({\n\ttitle: \"ArkType Discord\",\n\togImage: \"ogDiscord.png\"\n})\n\nexport default function DiscordPage() {\n\tredirect(\"https://discord.com/invite/xEzdc3fJQC\")\n}\n"
  },
  {
    "path": "ark/docs/app/docs/[[...slug]]/page.tsx",
    "content": "import { Popup, PopupContent, PopupTrigger } from \"fumadocs-twoslash/ui\"\nimport { CodeBlock, Pre } from \"fumadocs-ui/components/codeblock\"\nimport { Tab, Tabs } from \"fumadocs-ui/components/tabs\"\nimport defaultMdxComponents from \"fumadocs-ui/mdx\"\nimport {\n\tDocsBody,\n\tDocsDescription,\n\tDocsPage,\n\tDocsTitle\n} from \"fumadocs-ui/page\"\nimport { notFound, redirect } from \"next/navigation\"\nimport { AnchorAliases } from \"../../../components/AnchorAliases.tsx\"\nimport { SyntaxTab, SyntaxTabs } from \"../../../components/SyntaxTabs.tsx\"\nimport { source } from \"../../../lib/source.tsx\"\n\nexport default async (props: { params: Promise<{ slug?: string[] }> }) => {\n\tconst params = await props.params\n\n\tif (\n\t\t!params.slug?.length ||\n\t\t(params.slug?.length === 1 && params.slug[0] === \"intro\")\n\t)\n\t\tredirect(\"/docs/intro/setup\")\n\n\tconst page = source.getPage(params.slug)\n\n\tif (!page) notFound()\n\n\tconst { body: MDX, toc } = await page.data.load()\n\n\tconst isApiPage =\n\t\tpage.data.title.endsWith(\"API\") || page.data.title.endsWith(\"Configuration\")\n\n\treturn (\n\t\t<DocsPage\n\t\t\ttoc={isApiPage ? [] : toc}\n\t\t\t// \"clerk\" causes left border to wind in and out to mirror header structure\n\t\t\ttableOfContent={{ style: \"clerk\" }}\n\t\t\tfull={page.data.full ?? false}\n\t\t>\n\t\t\t<DocsTitle>\n\t\t\t\t{page.data.title}\n\t\t\t\t<DocsDescription>{page.data.description}</DocsDescription>\n\t\t\t</DocsTitle>\n\n\t\t\t<DocsBody className=\"docs-body\">\n\t\t\t\t<MDX\n\t\t\t\t\tcomponents={{\n\t\t\t\t\t\t...defaultMdxComponents,\n\t\t\t\t\t\tPopup,\n\t\t\t\t\t\tPopupContent,\n\t\t\t\t\t\tPopupTrigger,\n\t\t\t\t\t\tTabs,\n\t\t\t\t\t\tTab,\n\t\t\t\t\t\tSyntaxTabs,\n\t\t\t\t\t\tSyntaxTab,\n\t\t\t\t\t\tAnchorAliases,\n\t\t\t\t\t\t...(await import(\"../../../components/AutoplayDemo.tsx\")),\n\t\t\t\t\t\t...(await import(\"../../../components/CodeBlock.tsx\")),\n\t\t\t\t\t\t...(await import(\"../../../components/InstallationTabs.tsx\")),\n\t\t\t\t\t\t...(await import(\"../../../components/KeywordTable.tsx\")),\n\t\t\t\t\t\t...(await import(\"../../../components/ApiTable.tsx\")),\n\t\t\t\t\t\t...(await import(\"../../../components/LinkCard.tsx\")),\n\t\t\t\t\t\t...(await import(\"../../../components/AutoplayDemo.tsx\")),\n\t\t\t\t\t\t...(await import(\"../../../components/RuntimeBenchmarksGraph.tsx\")),\n\t\t\t\t\t\tpre: ({ ref: _, ...props }) => (\n\t\t\t\t\t\t\t<CodeBlock {...props}>\n\t\t\t\t\t\t\t\t<Pre>{props.children}</Pre>\n\t\t\t\t\t\t\t</CodeBlock>\n\t\t\t\t\t\t)\n\t\t\t\t\t}}\n\t\t\t\t/>\n\t\t\t</DocsBody>\n\t\t</DocsPage>\n\t)\n}\n\nexport const generateStaticParams = async () => [\n\t...source.generateParams(),\n\t{ slug: [] },\n\t{ slug: [\"intro\"] }\n]\n\nexport const generateMetadata = async (props: {\n\tparams: Promise<{ slug?: string[] }>\n}) => {\n\tconst params = await props.params\n\tconst page = source.getPage(params.slug)\n\tif (!page) notFound()\n\n\treturn {\n\t\ttitle: page.data.title,\n\t\tdescription: page.data.description\n\t}\n}\n"
  },
  {
    "path": "ark/docs/app/docs/layout.tsx",
    "content": "import { DocsLayout } from \"fumadocs-ui/layouts/docs\"\nimport type { ReactNode } from \"react\"\nimport { source } from \"../../lib/source.tsx\"\nimport { baseOptions } from \"../layout.config.tsx\"\nimport { defineMetadata } from \"../metadata.ts\"\n\nexport const metadata = defineMetadata({\n\ttitle: \"ArkType Docs\",\n\togImage: \"ogDocs.png\"\n})\n\nexport default ({ children }: { children: ReactNode }) => (\n\t<DocsLayout tree={source.pageTree} {...baseOptions}>\n\t\t{children}\n\t</DocsLayout>\n)\n"
  },
  {
    "path": "ark/docs/app/global-error.tsx",
    "content": "\"use client\"\n\nimport { useEffect } from \"react\"\n\nexport type GlobalErrorProps = {\n\terror: Error & { digest?: string }\n\treset: () => void\n}\n\nexport default function GlobalError() {\n\tuseEffect(() => {\n\t\tconst THRESHOLD = 2 * 60 * 1000\n\t\tconst now = Date.now()\n\t\tconst lastReloadStr = localStorage.getItem(\"globalErrorLastReload\")\n\t\tconst lastReload = lastReloadStr ? parseInt(lastReloadStr, 10) : 0\n\n\t\tif (!lastReloadStr || now - lastReload > THRESHOLD) {\n\t\t\tlocalStorage.setItem(\"globalErrorLastReload\", now.toString())\n\t\t\twindow.location.reload()\n\t\t}\n\t})\n\n\tconst containerStyle: React.CSSProperties = {\n\t\tminHeight: \"100vh\",\n\t\tmargin: \"0\",\n\t\tdisplay: \"flex\",\n\t\talignItems: \"center\",\n\t\tjustifyContent: \"center\",\n\t\tbackground: \"hsl(207 100% 9%)\",\n\t\tfontFamily: \"system-ui, sans-serif\",\n\t\tcolor: \"#E5E7EB\"\n\t}\n\n\tconst cardStyle: React.CSSProperties = {\n\t\tbackgroundColor: \"rgba(30, 41, 59, 0.5)\",\n\t\tbackdropFilter: \"blur(10px)\",\n\t\tpadding: \"2.5rem\",\n\t\tborderRadius: \"0.75rem\",\n\t\tboxShadow: \"0 4px 20px rgba(0, 0, 0, 0.3)\",\n\t\ttextAlign: \"center\",\n\t\tmaxWidth: \"400px\",\n\t\tborder: \"1px solid rgba(255, 255, 255, 0.1)\"\n\t}\n\n\tconst headingStyle: React.CSSProperties = {\n\t\tfontSize: \"2.25rem\",\n\t\tfontWeight: 600,\n\t\tmarginBottom: \"1.5rem\",\n\t\tbackground: \"linear-gradient(135deg, #E5E7EB 0%, #94A3B8 100%)\",\n\t\tWebkitBackgroundClip: \"text\",\n\t\tWebkitTextFillColor: \"transparent\",\n\t\tletterSpacing: \"-0.025em\"\n\t}\n\n\tconst paraStyle: React.CSSProperties = {\n\t\tfontSize: \"1.1rem\",\n\t\tmarginBottom: \"2rem\",\n\t\tcolor: \"#94A3B8\",\n\t\tlineHeight: 1.6\n\t}\n\n\tconst buttonStyle: React.CSSProperties = {\n\t\tpadding: \"0.75rem 1.5rem\",\n\t\tborder: \"1px solid rgba(255, 255, 255, 0.1)\",\n\t\tborderRadius: \"0.5rem\",\n\t\tcolor: \"#E5E7EB\",\n\t\tcursor: \"pointer\",\n\t\tfontSize: \"0.95rem\",\n\t\tfontWeight: 500,\n\t\ttransition: \"all 0.2s ease\",\n\t\tbackground: \"rgba(255, 255, 255, 0.05)\"\n\t}\n\n\tconst buttonHoverStyle = {\n\t\t...buttonStyle,\n\t\tbackground: \"rgba(255, 255, 255, 0.1)\"\n\t}\n\n\treturn (\n\t\t<html lang=\"en\">\n\t\t\t<head>\n\t\t\t\t<meta charSet=\"utf-8\" />\n\t\t\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t\t\t<title>Shipwrecked!</title>\n\t\t\t</head>\n\t\t\t<body style={containerStyle}>\n\t\t\t\t<div style={cardStyle}>\n\t\t\t\t\t<h2 style={headingStyle}>Shipwrecked!</h2>\n\t\t\t\t\t<p style={paraStyle}>Something unexpected went wrong.</p>\n\t\t\t\t\t<div\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tdisplay: \"flex\",\n\t\t\t\t\t\t\tgap: \"1rem\",\n\t\t\t\t\t\t\tjustifyContent: \"center\"\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\tonClick={() => window.location.reload()}\n\t\t\t\t\t\t\tstyle={buttonStyle}\n\t\t\t\t\t\t\tonMouseOver={e =>\n\t\t\t\t\t\t\t\tObject.assign(e.currentTarget.style, buttonHoverStyle)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonMouseOut={e =>\n\t\t\t\t\t\t\t\tObject.assign(e.currentTarget.style, buttonStyle)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\tReload\n\t\t\t\t\t\t</button>\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\tonClick={() => window.location.replace(window.location.origin)}\n\t\t\t\t\t\t\tstyle={buttonStyle}\n\t\t\t\t\t\t\tonMouseOver={e =>\n\t\t\t\t\t\t\t\tObject.assign(e.currentTarget.style, buttonHoverStyle)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonMouseOut={e =>\n\t\t\t\t\t\t\t\tObject.assign(e.currentTarget.style, buttonStyle)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\tGo Home\n\t\t\t\t\t\t</button>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</body>\n\t\t</html>\n\t)\n}\n"
  },
  {
    "path": "ark/docs/app/global.css",
    "content": "@import \"tailwindcss\";\n@import \"fumadocs-ui/css/ocean.css\";\n@import \"fumadocs-ui/css/preset.css\";\n\n@source '../node_modules/fumadocs-ui/dist/**/*.js';\n\n@font-face {\n\tfont-family: \"Cascadia Mono\";\n\tsrc:\n\t\tlocal(\"Cascadia Mono\"),\n\t\turl(\"https://fonts.cdnfonts.com/s/37910/CascadiaMono.woff\") format(\"woff\");\n}\n\n@theme {\n\t--color-background: var(--color-fd-background);\n\t--color-foreground: var(--color-fd-foreground);\n\t--color-muted: var(--color-fd-muted);\n\t--color-muted-foreground: var(--color-fd-muted-foreground);\n\t--color-popover: var(--color-fd-popover);\n\t--color-popover-foreground: var(--color-fd-popover-foreground);\n\t--color-card: var(--color-fd-card);\n\t--color-card-foreground: var(--color-fd-card-foreground);\n\t--color-border: var(--color-fd-border);\n\t--color-primary: var(--color-fd-primary);\n\t--color-primary-foreground: var(--color-fd-primary-foreground);\n\t--color-secondary: var(--color-fd-secondary);\n\t--color-secondary-foreground: var(--color-fd-secondary-foreground);\n\t--color-accent: var(--color-fd-accent);\n\t--color-accent-foreground: var(--color-fd-accent-foreground);\n\t--color-ring: var(--color-fd-ring);\n\t--color-highlight: #f5cf8f;\n}\n\n/** the * ensures this overrides the variable definitions from shiki*/\n:root * {\n\t--background: 207 100% 9%;\n\t--hover-glow: 0.5rem 0.5rem 2rem 0 rgba(31, 38, 135, 0.37);\n\n\t/* Based on ArkDark ErrorLens */\n\t--ark-green: #40decc;\n\t--ark-error: #9558f8;\n\t--ark-success: #40decca0;\n\t--ark-runtime-error: #f85858;\n\n\t/** @shikijs/twoslash/style-rich.css overrides */\n\t--twoslash-border-color: #ba7e4127;\n\t--twoslash-underline-color: currentColor;\n\t--twoslash-highlighted-border: #c37d0d50;\n\t--twoslash-highlighted-bg: #c37d0d20;\n\t--twoslash-popup-bg: transparent;\n\t--twoslash-popup-color: inherit;\n\t--twoslash-popup-shadow: var(--shadow);\n\t--twoslash-docs-color: #888;\n\t--twoslash-docs-font: sans-serif;\n\t--twoslash-code-font: inherit;\n\t--twoslash-code-font-size: 1em;\n\t--twoslash-matched-color: inherit;\n\t--twoslash-unmatched-color: #888;\n\t--twoslash-cursor-color: #888;\n\t--twoslash-error-color: var(--ark-error);\n\t--twoslash-error-bg: #9558f818;\n\t--twoslash-warn-color: #c37d0d;\n\t--twoslash-warn-bg: #c37d0d20;\n\t--twoslash-tag-color: #3772cf;\n\t--twoslash-tag-bg: #3772cf20;\n\t--twoslash-tag-warn-color: var(--twoslash-warn-color);\n\t--twoslash-tag-warn-bg: var(--twoslash-warn-bg);\n\t--twoslash-tag-annotate-color: #1ba673;\n\t--twoslash-tag-annotate-bg: #1ba67320;\n}\n\n@media (prefers-reduced-motion: no-preference) {\n\t* {\n\t\tscroll-behavior: smooth;\n\t}\n}\n\npre,\ncode {\n\tfont-family: \"Cascadia Mono\", monospace;\n}\n\n/* hack to avoid max-height on fuma codeblocks */\n@layer utilities {\n\t.max-h-\\[600px\\] {\n\t\tmax-height: unset;\n\t}\n}\n\n.fd-codeblock.twoslash {\n\tborder-radius: 1.5rem !important;\n}\n\npre.shiki,\n.twoslash-popup-container {\n\tborder-radius: 1rem;\n\tborder-color: #ba7e4127;\n\tborder-width: 1px;\n\toverflow-x: visible !important;\n}\n\n/** should match arkDarkTheme.colors[\"editor.background\"] */\n.bg-fd-secondary\\/50 {\n\tbackground-color: #0006;\n}\n\n/** avoid border on hover: \n    https://github.com/arktypeio/arktype/issues/1217 */\n.twoslash-popup-container pre.shiki,\nfigure.shiki {\n\tbackground-color: unset !important;\n}\n\ndiv.twoslash-popup-container {\n\tborder-radius: 1rem;\n\tbackground: #001323aa;\n\tbackdrop-filter: blur(8px);\n\tbox-shadow: var(--hover-glow);\n}\n\n/** .error.highlighted matches error lines explicitly added in the snippet\n    source via [!code error] */\n\n.error.highlighted {\n\tposition: relative;\n\tpadding: 4px;\n\tbackground-color: var(--twoslash-error-bg);\n\tborder-left: 3px solid var(--ark-error);\n\tpadding-right: 16px;\n\tmargin: 0.2em 0;\n\tmin-width: 100%;\n\twidth: max-content;\n}\n\n.error.highlighted > span {\n\tcolor: var(--twoslash-error-color) !important;\n}\n\n.error.highlighted.runtime-error {\n\tbackground-color: #f8585822;\n\tborder-left: 3px solid var(--ark-runtime-error);\n}\n\n.error.highlighted.runtime-error > span {\n\tcolor: var(--ark-runtime-error) !important;\n}\n\n/** .twoslash-error matches errors added by twoslash itself, e.g. type errors */\n.twoslash .twoslash-error {\n\t/* Override the built-in error squiggle to match our theme */\n\tbackground: url(\"/image/errorSquiggle.svg\") repeat-x bottom left;\n}\n\n.twoslash .twoslash-popup-code {\n\twhite-space: pre;\n}\n\n/* avoid double padding + border */\n/* matches popups rendered from react (on the home page) */\n.shiki .shiki,\n/* matches popups rendered from mdx (on most docs pages) */ \n.twoslash-popup-container pre.p-4 {\n\tpadding: 0px;\n\tborder-width: 0px;\n}\n\n/** display runtime errors on hover */\n.twoslash .twoslash-popup-docs {\n\tcolor: var(--ark-runtime-error);\n\tfont-size: small;\n\twhite-space: pre;\n}\n\n/** avoid empty lines being rendered with 0 height */\n.twoslash .line {\n\tmin-height: 20px;\n}\n\n.completions-block code {\n\tpadding-bottom: 2rem;\n}\n\n/** avoid a janky white outline on hovers: \n    https://github.com/arktypeio/arktype/issues/1217 */\n:focus-visible {\n\toutline: none;\n}\n\n/* Firefox specific rules */\n@-moz-document url-prefix() {\n\t/* The backdrop-filter above doesn't work by default yet on Firefox so we do this instead  */\n\t.twoslash .twoslash-hover:hover .twoslash-popup-container {\n\t\tbackground: #001323ee;\n\t}\n}\n\n/* allow us to inject a badge at order 1 */\n#nd-sidebar .lucide-chevron-down {\n\torder: 2;\n}\n\n#nd-home-layout,\n#nd-nav {\n\toverflow: hidden;\n\ttransition: margin-top 0.3s ease;\n}\n\n/* if release banner is visible, add top offset to home navbar and layout equal to its height */\n:root:has(.release-banner:not([hidden]):not(.hidden)) #nd-home-layout,\n:root:has(.release-banner:not([hidden]):not(.hidden)) #nd-nav {\n\tmargin-top: 3.5rem;\n}\n\n.glass-container,\n.monaco-editor {\n\tbox-shadow:\n\t\t0 10px 15px 0 rgba(0, 0, 0, 0.3),\n\t\t0 15px 30px 0 rgba(0, 0, 0, 0.22);\n\tbackdrop-filter: blur(16px);\n\t/* without this Monaco ends up adding a 1px outline at the top of the editor for some reason */\n\toutline-width: 0px !important;\n}\n\n.monaco-editor,\n.overflow-guard {\n\tborder-radius: 16px;\n}\n\n/* Chrome/Safari/Edge scrollbar styling */\n::-webkit-scrollbar {\n\twidth: 8px;\n\theight: 8px;\n\tbackground-color: transparent;\n}\n\n::-webkit-scrollbar-thumb {\n\tbackground-color: rgba(255, 255, 255, 0.1);\n\tborder-radius: 4px;\n}\n\n::-webkit-scrollbar-thumb:hover {\n\tbackground-color: rgba(255, 255, 255, 0.2);\n}\n\n::-webkit-scrollbar-track {\n\tbackground: transparent;\n}\n\n/* Firefox scrollbar styling */\n* {\n\tscrollbar-width: thin;\n\tscrollbar-color: rgba(255, 255, 255, 0.1) transparent;\n}\n\n.wiggle-animation {\n\tanimation: wiggle 4s ease-in-out infinite;\n\ttransform-origin: center center;\n}\n\n@keyframes wiggle {\n\t0%,\n\t87.5%,\n\t100% {\n\t\ttransform: rotate(0deg);\n\t}\n\t88.5% {\n\t\ttransform: rotate(1.5deg);\n\t}\n\t89.5% {\n\t\ttransform: rotate(-0.5deg);\n\t}\n\t90.5% {\n\t\ttransform: rotate(-1.5deg);\n\t}\n\t91.5% {\n\t\ttransform: rotate(1deg);\n\t}\n\t92.5% {\n\t\ttransform: rotate(1.5deg);\n\t}\n\t93.5% {\n\t\ttransform: rotate(-1deg);\n\t}\n\t94.5% {\n\t\ttransform: rotate(-0.5deg);\n\t}\n\t96% {\n\t\ttransform: rotate(0.25deg);\n\t}\n\t98% {\n\t\ttransform: rotate(0deg);\n\t}\n}\n\nh1,\nh2,\nh3,\nh4,\nh5,\nh6,\n.hero-tagline {\n\tfont-family: var(--font-raleway);\n}\n\nbody {\n\tfont-family: var(--font-atkinson);\n}\n\n#nd-docs-layout h1 {\n\tmargin-bottom: 0.5rem !important;\n\tfont-size: 2.75rem !important;\n}\n\n.docs-body h2 {\n\tmargin-top: 0.3rem;\n\tmargin-bottom: 0.3rem;\n\tfont-size: 2.25rem !important;\n}\n\n.docs-body h3 {\n\tmargin-top: 0.2rem;\n\tmargin-bottom: 0.2rem;\n\tfont-size: 1.75rem !important;\n}\n\n.docs-body h4 {\n\tfont-size: 1.5rem !important;\n\tcolor: #ffffffbf;\n}\n\n.docs-body h5 {\n\tfont-size: 1.25rem !important;\n\tcolor: #ffffffcf;\n}\n\n.docs-body h6 {\n\tfont-size: 1rem !important;\n\tcolor: #ffffffdf;\n}\n"
  },
  {
    "path": "ark/docs/app/layout.config.tsx",
    "content": "import {\n\tSiBluesky,\n\tSiDiscord,\n\tSiTwitch,\n\tSiX\n} from \"@icons-pack/react-simple-icons\"\nimport type { BaseLayoutProps } from \"fumadocs-ui/layouts/shared\"\nimport { ArkTypeLogo } from \"../components/icons/arktype-logo.tsx\"\n\nexport const baseOptions: BaseLayoutProps = {\n\tnav: {\n\t\ttitle: <ArkTypeLogo />\n\t},\n\tthemeSwitch: {\n\t\tenabled: false\n\t},\n\tgithubUrl: \"https://github.com/arktypeio/arktype\",\n\tlinks: [\n\t\t{\n\t\t\ttext: \"Twitch\",\n\t\t\ttype: \"icon\",\n\t\t\ticon: <SiTwitch />,\n\t\t\turl: \"https://twitch.tv/arktypeio\"\n\t\t},\n\t\t{\n\t\t\ttext: \"Bluesky\",\n\t\t\ttype: \"icon\",\n\t\t\ticon: <SiBluesky />,\n\t\t\turl: \"https://bsky.app/profile/arktype.io\"\n\t\t},\n\t\t{\n\t\t\ttext: \"X\",\n\t\t\ttype: \"icon\",\n\t\t\ticon: <SiX />,\n\t\t\turl: \"https://x.com/arktypeio\"\n\t\t},\n\t\t{\n\t\t\ttext: \"Discord\",\n\t\t\ttype: \"icon\",\n\t\t\ticon: <SiDiscord />,\n\t\t\turl: \"https://arktype.io/discord\"\n\t\t}\n\t]\n}\n"
  },
  {
    "path": "ark/docs/app/layout.tsx",
    "content": "import \"fumadocs-twoslash/twoslash.css\"\nimport { RootProvider } from \"fumadocs-ui/provider\"\nimport { Atkinson_Hyperlegible, Raleway } from \"next/font/google\"\nimport type { ReactNode } from \"react\"\nimport { ReleaseBanner } from \"../components/ReleaseBanner.tsx\"\nimport \"./global.css\"\nimport { defineMetadata } from \"./metadata.ts\"\nimport { CSPostHogProvider } from \"./providers.tsx\"\n\nconst raleway = Raleway({\n\tsubsets: [\"latin\"],\n\tdisplay: \"swap\",\n\tvariable: \"--font-raleway\"\n})\n\nconst atkinson = Atkinson_Hyperlegible({\n\tweight: [\"400\", \"700\"],\n\tsubsets: [\"latin\"],\n\tdisplay: \"swap\",\n\tvariable: \"--font-atkinson\"\n})\n\nexport const metadata = defineMetadata({})\n\nexport default function RootLayout({ children }: { children: ReactNode }) {\n\treturn (\n\t\t<html\n\t\t\tlang=\"en\"\n\t\t\tclassName={`dark ${raleway.variable} ${atkinson.variable}`}\n\t\t\tsuppressHydrationWarning\n\t\t>\n\t\t\t<body className=\"flex flex-col min-h-screen\">\n\t\t\t\t<RootProvider\n\t\t\t\t\tsearch={{\n\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\ttype: \"static\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}}\n\t\t\t\t\ttheme={{\n\t\t\t\t\t\tenabled: false,\n\t\t\t\t\t\tenableSystem: false\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<CSPostHogProvider>\n\t\t\t\t\t\t<ReleaseBanner />\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</CSPostHogProvider>\n\t\t\t\t</RootProvider>\n\t\t\t</body>\n\t\t</html>\n\t)\n}\n"
  },
  {
    "path": "ark/docs/app/metadata.ts",
    "content": "import type { Metadata } from \"next\"\n\nexport type MetadataOptions = {\n\ttitle?: string\n\togImage?: string\n}\n\nexport const defineMetadata = ({\n\ttitle = \"ArkType\",\n\togImage = \"og.png\"\n}: MetadataOptions): Metadata => ({\n\ttitle: `${title}: TypeScript's 1:1 validator, optimized from editor to runtime`,\n\tdescription: \"TypeScript's 1:1 validator, optimized from editor to runtime\",\n\tkeywords: [\n\t\t\"ArkType\",\n\t\t\"TypeScript\",\n\t\t\"JavaScript\",\n\t\t\"runtime validation\",\n\t\t\"schema\",\n\t\t\"type-safe\",\n\t\t\"validator\",\n\t\t\"syntax\"\n\t],\n\topenGraph: {\n\t\ttitle,\n\t\tdescription: \"TypeScript's 1:1 validator, optimized from editor to runtime\",\n\t\turl: \"https://arktype.io/\",\n\t\tsiteName: \"ArkType\",\n\t\timages: [\n\t\t\t{\n\t\t\t\turl: `https://arktype.io/image/${ogImage}`,\n\t\t\t\twidth: 1200,\n\t\t\t\theight: 600\n\t\t\t}\n\t\t],\n\t\ttype: \"website\"\n\t},\n\ttwitter: {\n\t\tcard: \"summary_large_image\"\n\t},\n\ticons: {\n\t\ticon: \"/image/favicon.svg\"\n\t}\n})\n"
  },
  {
    "path": "ark/docs/app/playground/page.tsx",
    "content": "import { HomeLayout } from \"fumadocs-ui/layouts/home\"\nimport type { ReactNode } from \"react\"\nimport { FloatYourBoat } from \"../../components/FloatYourBoat.tsx\"\nimport { Playground } from \"../../components/playground/Playground.tsx\"\nimport { baseOptions } from \"../layout.config.tsx\"\nimport { defineMetadata } from \"../metadata.ts\"\n\nexport const metadata = defineMetadata({\n\ttitle: \"ArkType Playground\",\n\togImage: \"ogPlayground.png\"\n})\n\nexport type LayoutProps = {\n\tchildren: ReactNode\n}\n\nexport default function PlaygroundPage() {\n\treturn (\n\t\t<HomeLayout\n\t\t\t{...baseOptions}\n\t\t\tstyle={{\n\t\t\t\tpaddingLeft: \"1rem\",\n\t\t\t\tpaddingRight: \"1rem\",\n\t\t\t\tdisplay: \"flex\",\n\t\t\t\tflexDirection: \"column\",\n\t\t\t\theight: \"100vh\"\n\t\t\t}}\n\t\t\tnav={{\n\t\t\t\t...baseOptions.nav,\n\t\t\t\tchildren: <FloatYourBoat />\n\t\t\t}}\n\t\t>\n\t\t\t<div className=\"flex-1 flex flex-col items-center justify-center py-8\">\n\t\t\t\t<div className=\"w-[90vw] h-[80vh]\">\n\t\t\t\t\t<Playground withResults={true} />\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</HomeLayout>\n\t)\n}\n"
  },
  {
    "path": "ark/docs/app/providers.tsx",
    "content": "\"use client\"\n\nimport posthog from \"posthog-js\"\nimport { PostHogProvider } from \"posthog-js/react\"\n\nif (\n\tglobalThis.window !== undefined &&\n\tprocess.env.NEXT_PUBLIC_POSTHOG_KEY &&\n\tprocess.env.NEXT_PUBLIC_POSTHOG_HOST\n) {\n\tposthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY, {\n\t\tapi_host: process.env.NEXT_PUBLIC_POSTHOG_HOST,\n\t\tperson_profiles: \"always\"\n\t})\n}\n\nexport const CSPostHogProvider = ({\n\tchildren\n}: {\n\tchildren: React.ReactNode\n}) => <PostHogProvider client={posthog}>{children}</PostHogProvider>\n"
  },
  {
    "path": "ark/docs/components/AnchorAliases.tsx",
    "content": "import React from \"react\"\n\nexport declare namespace AnchorAliases {\n\texport type Props = Record<string, true | undefined>\n}\n\n/**\n * create multiple anchor aliases for Markdown headers\n *\n * @example\n * <AnchorAliases old-id legacy-id alternate-name />\n */\nexport const AnchorAliases = (aliases: AnchorAliases.Props) => (\n\t<>\n\t\t{Object.keys(aliases).map(id => (\n\t\t\t<a key={id} id={id} />\n\t\t))}\n\t</>\n)\n"
  },
  {
    "path": "ark/docs/components/ApiTable.tsx",
    "content": "import type { ApiGroup, ParsedJsDocPart } from \"../../repo/jsdocGen.ts\"\nimport { apiDocsByGroup } from \"./apiData.ts\"\nimport { CodeBlock } from \"./CodeBlock.tsx\"\nimport { LocalFriendlyUrl } from \"./LocalFriendlyUrl.tsx\"\n\nexport type ApiTableProps = {\n\tgroup: ApiGroup\n}\n\nexport const ApiTable = ({ group }: ApiTableProps) => (\n\t<div className=\"w-full overflow-x-auto\">\n\t\t<table className=\"w-full table-fixed border-collapse\">\n\t\t\t<colgroup>\n\t\t\t\t<col className=\"w-28\" />\n\t\t\t\t<col className=\"w-1/4\" />\n\t\t\t\t<col className=\"w-full\" />\n\t\t\t</colgroup>\n\t\t\t<ApiTableHeader />\n\t\t\t<tbody>\n\t\t\t\t{apiDocsByGroup[group].map(props => (\n\t\t\t\t\t<ApiTableRow key={props.name} {...props} />\n\t\t\t\t))}\n\t\t\t</tbody>\n\t\t</table>\n\t</div>\n)\n\nconst ApiTableHeader = () => (\n\t<thead>\n\t\t<tr>\n\t\t\t<th className=\"p-2 text-left align-top whitespace-nowrap w-auto min-w-[100px]\">\n\t\t\t\tName\n\t\t\t</th>\n\t\t\t<th className=\"p-2 text-left align-top min-w-[200px]\">Summary</th>\n\t\t\t<th className=\"p-2 text-left align-top\">Notes & Examples</th>\n\t\t</tr>\n\t</thead>\n)\n\ninterface ApiTableRowProps {\n\tname: string\n\tsummary: ParsedJsDocPart[]\n\texample?: string\n\texperimental?: ParsedJsDocPart[]\n\tnotes: ParsedJsDocPart[][]\n}\n\nconst ApiTableRow = ({\n\tname,\n\tsummary,\n\texample,\n\texperimental,\n\tnotes\n}: ApiTableRowProps) => (\n\t<tr key={name}>\n\t\t<td\n\t\t\tstyle={{\n\t\t\t\tfontSize:\n\t\t\t\t\tname.length < 12 ? \"1rem\"\n\t\t\t\t\t: name.length < 16 ? \"0.7rem\"\n\t\t\t\t\t: \"0.6rem\"\n\t\t\t}}\n\t\t\tclassName=\"p-2 align-top whitespace-nowrap w-auto\"\n\t\t>\n\t\t\t{name}\n\t\t</td>\n\t\t<td className=\"p-2 align-top\">{JsDocParts(summary)}</td>\n\t\t<td className=\"p-2 align-top\">\n\t\t\t{notes.map((note, i) => (\n\t\t\t\t<div key={i}>{JsDocParts(note)} </div>\n\t\t\t))}\n\t\t\t{experimental ? JsDocParts(experimental) : null}\n\t\t\t<ApiExample>{example}</ApiExample>\n\t\t</td>\n\t</tr>\n)\n\nconst JsDocParts = (parts: readonly ParsedJsDocPart[]) =>\n\tparts.map((part, i) => (\n\t\t<span key={i} style={{ marginRight: \"0.25em\" }}>\n\t\t\t{part.kind === \"link\" ?\n\t\t\t\t<LocalFriendlyUrl url={part.url} key={i}>\n\t\t\t\t\t{part.value}\n\t\t\t\t</LocalFriendlyUrl>\n\t\t\t: part.kind === \"reference\" ?\n\t\t\t\t<a style={{ display: \"inline-block\" }} href={`#${part.value}`} key={i}>\n\t\t\t\t\t{part.value}\n\t\t\t\t</a>\n\t\t\t:\t<p\n\t\t\t\t\tstyle={{ display: \"inline\" }}\n\t\t\t\t\tkey={i}\n\t\t\t\t\tdangerouslySetInnerHTML={{\n\t\t\t\t\t\t__html: part.value\n\t\t\t\t\t\t\t.replace(/(\\*\\*|__)([^*_]+)\\1/g, \"<strong>$2</strong>\")\n\t\t\t\t\t\t\t.replace(/(\\*|_)([^*_]+)\\1/g, \"<em>$2</em>\")\n\t\t\t\t\t\t\t.replace(/`([^`]+)`/g, \"<code>$1</code>\")\n\t\t\t\t\t\t\t.replace(/^-(.*)/g, \"• $1\")\n\t\t\t\t\t}}\n\t\t\t\t/>\n\t\t\t}\n\t\t</span>\n\t))\n\ninterface ApiExampleProps {\n\tchildren: string | undefined\n}\n\nconst ApiExample = ({ children }: ApiExampleProps) =>\n\tchildren && (\n\t\t<CodeBlock style={{ margin: 0 }} decorators={[\"@noErrors\"]}>\n\t\t\t{children}\n\t\t</CodeBlock>\n\t)\n"
  },
  {
    "path": "ark/docs/components/ArkCard.tsx",
    "content": "import { cx } from \"class-variance-authority\"\nimport { Card, type CardProps, Cards } from \"fumadocs-ui/components/card\"\n\nexport const ArkCards: React.FC<{ children: React.ReactNode }> = ({\n\tchildren\n}) => <Cards>{children}</Cards>\n\nexport const ArkCard: React.FC<CardProps> = ({\n\tchildren,\n\tclassName,\n\t...props\n}) => (\n\t<Card\n\t\t{...props}\n\t\tclassName={cx(\n\t\t\t\"sm:even:translate-y-10 [&>h3]:text-2xl [&>h3]:font-semibold [&_.prose-no-margin]:text-lg\",\n\t\t\t\"[&>.prose-no-margin]:flex [&>.prose-no-margin]:flex-col [&>.prose-no-margin]:flex-grow\",\n\t\t\t\"flex flex-col\",\n\t\t\t\"rounded-3xl\",\n\t\t\tclassName\n\t\t)}\n\t\tstyle={{\n\t\t\tborderWidth: 2\n\t\t}}\n\t>\n\t\t{children}\n\t</Card>\n)\n"
  },
  {
    "path": "ark/docs/components/AutoplayDemo.tsx",
    "content": "\"use client\"\n\nimport { ArrowRightLeftIcon, ExpandIcon } from \"lucide-react\"\nimport { useEffect, useRef, useState } from \"react\"\nimport { Button } from \"./Button.tsx\"\nimport { Playground } from \"./playground/Playground.tsx\"\nimport { defaultPlaygroundCode } from \"./playground/utils.ts\"\n\nexport type AutoplayDemoProps = React.DetailedHTMLProps<\n\tReact.VideoHTMLAttributes<HTMLVideoElement>,\n\tHTMLVideoElement\n> & { src: string }\n\nexport const MainAutoplayDemo = () => (\n\t<AutoplayDemo src=\"https://github.com/arktypeio/arktype/releases/download/arktype%402.0.0/ArkType2Demo3To1.webm\" />\n)\n\nexport const AutoplayDemo = (props: AutoplayDemoProps) => {\n\tconst [showPlayground, setShowPlayground] = useState(false)\n\tconst [dimensions, setDimensions] = useState({\n\t\twidth: \"100%\",\n\t\theight: \"30vh\"\n\t})\n\tconst videoRef = useRef<HTMLVideoElement>(null)\n\n\tuseEffect(() => {\n\t\tconst updateDimensions = () => {\n\t\t\tif (videoRef.current) {\n\t\t\t\tconst { offsetWidth, offsetHeight } = videoRef.current\n\t\t\t\tsetDimensions({\n\t\t\t\t\twidth: `${offsetWidth}px`,\n\t\t\t\t\theight: `${offsetHeight}px`\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\tif (videoRef.current && videoRef.current.readyState >= 1) updateDimensions()\n\n\t\tconst video = videoRef.current\n\t\tif (video) {\n\t\t\tvideo.addEventListener(\"loadedmetadata\", updateDimensions)\n\t\t\tvideo.addEventListener(\"loadeddata\", updateDimensions)\n\t\t\twindow.addEventListener(\"resize\", updateDimensions)\n\t\t}\n\n\t\treturn () => {\n\t\t\tif (video) {\n\t\t\t\tvideo.removeEventListener(\"loadedmetadata\", updateDimensions)\n\t\t\t\tvideo.removeEventListener(\"loadeddata\", updateDimensions)\n\t\t\t}\n\t\t\twindow.removeEventListener(\"resize\", updateDimensions)\n\t\t}\n\t}, [videoRef.current])\n\n\treturn (\n\t\t<div style={{ position: \"relative\", width: \"100%\" }}>\n\t\t\t<div\n\t\t\t\tstyle={{\n\t\t\t\t\tdisplay: !showPlayground ? \"block\" : \"none\",\n\t\t\t\t\twidth: \"100%\"\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<video\n\t\t\t\t\tref={videoRef}\n\t\t\t\t\tautoPlay\n\t\t\t\t\tloop\n\t\t\t\t\tcontrols\n\t\t\t\t\tplaysInline\n\t\t\t\t\tmuted\n\t\t\t\t\tdisablePictureInPicture\n\t\t\t\t\tstyle={{ width: \"100%\", display: \"block\", margin: \"0 auto\" }}\n\t\t\t\t\t{...props}\n\t\t\t\t/>\n\t\t\t</div>\n\n\t\t\t<div\n\t\t\t\tstyle={{\n\t\t\t\t\tdisplay: showPlayground ? \"block\" : \"none\",\n\t\t\t\t\theight: dimensions.height,\n\t\t\t\t\twidth: dimensions.width,\n\t\t\t\t\tmargin: \"0 auto\"\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<Playground initialValue={defaultPlaygroundCode} />\n\t\t\t</div>\n\t\t\t<div className=\"absolute top-2.5 right-5 flex gap-2 z-60\">\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"outline\"\n\t\t\t\t\twiggle={!showPlayground}\n\t\t\t\t\tclassName=\"hidden md:flex\"\n\t\t\t\t\tonClick={() => setShowPlayground(!showPlayground)}\n\t\t\t\t\taria-label={\n\t\t\t\t\t\tshowPlayground ? \"Switch to Demo\" : \"Switch to Playground\"\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{showPlayground ?\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ArrowRightLeftIcon size={16} />\n\t\t\t\t\t\t\t<span>Demo Mode</span>\n\t\t\t\t\t\t</>\n\t\t\t\t\t:\t<>\n\t\t\t\t\t\t\t<ArrowRightLeftIcon size={16} />\n\t\t\t\t\t\t\t<span>Playground Mode</span>\n\t\t\t\t\t\t</>\n\t\t\t\t\t}\n\t\t\t\t</Button>\n\n\t\t\t\t{showPlayground && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"outline\"\n\t\t\t\t\t\tsize=\"sm\"\n\t\t\t\t\t\thref=\"/playground\"\n\t\t\t\t\t\taria-label=\"Open Full Playground\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<ExpandIcon size={24} />\n\t\t\t\t\t</Button>\n\t\t\t\t)}\n\t\t\t</div>\n\n\t\t\t<p className=\"caption\">\n\t\t\t\tType-level feedback with each keystroke-{\" \"}\n\t\t\t\t<b>no plugins or build steps required</b>.\n\t\t\t</p>\n\t\t</div>\n\t)\n}\n"
  },
  {
    "path": "ark/docs/components/Badge.tsx",
    "content": "import { cva, cx, type VariantProps } from \"class-variance-authority\"\nimport * as React from \"react\"\n\nexport const badgeVariants = cva(\n\t\"inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2\",\n\t{\n\t\tvariants: {\n\t\t\tvariant: {\n\t\t\t\tdefault:\n\t\t\t\t\t\"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80\",\n\t\t\t\tsecondary:\n\t\t\t\t\t\"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80\",\n\t\t\t\tdestructive:\n\t\t\t\t\t\"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80\",\n\t\t\t\toutline: \"text-foreground\"\n\t\t\t}\n\t\t},\n\t\tdefaultVariants: {\n\t\t\tvariant: \"default\"\n\t\t}\n\t}\n)\n\nexport interface BadgeProps\n\textends React.HTMLAttributes<HTMLDivElement>,\n\t\tVariantProps<typeof badgeVariants> {}\n\nexport const Badge = ({ className, variant, ...props }: BadgeProps) => (\n\t<div className={cx(badgeVariants({ variant }), className)} {...props} />\n)\n"
  },
  {
    "path": "ark/docs/components/Banner.tsx",
    "content": "\"use client\"\nimport { cx } from \"class-variance-authority\"\nimport { buttonVariants } from \"fumadocs-ui/components/ui/button\"\nimport { X } from \"lucide-react\"\nimport Link from \"next/link.js\"\nimport {\n\ttype HTMLAttributes,\n\ttype MouseEvent,\n\tuseCallback,\n\tuseEffect,\n\tuseState\n} from \"react\"\nimport { FloatYourBoat } from \"./FloatYourBoat.tsx\"\n\n// Based on:\n// https://github.com/fuma-nama/fumadocs/blob/1e6ece043987c8bf607249b66a8945632b229982/packages/ui/src/components/banner.tsx#L65\n\nexport declare namespace Banner {\n\texport interface Props extends HTMLAttributes<HTMLDivElement> {\n\t\thref: string\n\t\tboat?: boolean\n\t\tchangeLayout?: boolean\n\t}\n}\n\nexport const Banner = ({\n\tid = \"banner\",\n\tchangeLayout = true,\n\tboat,\n\thref,\n\tchildren,\n\t...props\n}: Banner.Props): React.ReactElement => {\n\tconst [open, setOpen] = useState(false)\n\tconst globalKey = id ? `nd-banner-${id}` : undefined\n\n\tuseEffect(() => {\n\t\tif (globalKey) setOpen(localStorage.getItem(globalKey) !== \"true\")\n\t}, [globalKey])\n\n\tconst handleCloseClick = useCallback(\n\t\t(e: MouseEvent<HTMLButtonElement>) => {\n\t\t\t// prevent the close button click from also triggering the link on\n\t\t\t// the rest the rest of the branner\n\t\t\te.stopPropagation()\n\t\t\tsetOpen(false)\n\t\t\tif (globalKey) localStorage.setItem(globalKey, \"true\")\n\t\t},\n\t\t[globalKey]\n\t)\n\n\tconst BannerContent = (\n\t\t<>\n\t\t\t<div style={{ width: 100 }}>\n\t\t\t\t{boat ?\n\t\t\t\t\t<FloatYourBoat />\n\t\t\t\t:\tnull}\n\t\t\t</div>\n\t\t\t<div>{children}</div>\n\t\t\t<div style={{ width: 100 }} />\n\t\t</>\n\t)\n\n\treturn (\n\t\t<div\n\t\t\tid={id}\n\t\t\t{...props}\n\t\t\tclassName={cx(\n\t\t\t\t\"release-banner\",\n\t\t\t\t\"sticky top-0 z-40 flex h-12 flex-row items-center justify-around bg-fd-secondary px-4 text-center text-sm font-medium\",\n\t\t\t\t\"bg-fd-background\",\n\t\t\t\t// fix offset scrolling on Chromium-based browsers:\n\t\t\t\t// https://github.com/arktypeio/arktype/issues/1290\n\t\t\t\t\"!overflow-hidden\",\n\t\t\t\t!open && \"hidden\",\n\t\t\t\tprops.className\n\t\t\t)}\n\t\t>\n\t\t\t{changeLayout && open ?\n\t\t\t\t<style>{`\n        :root:not(.${globalKey ?? \"nd-banner-never\"}) { --fd-banner-height: 3rem; }\n        `}</style>\n\t\t\t:\tnull}\n\t\t\t{globalKey ?\n\t\t\t\t<style>{`.${globalKey} #${id} { display: none; }`}</style>\n\t\t\t:\tnull}\n\t\t\t{id ?\n\t\t\t\t<script\n\t\t\t\t\tdangerouslySetInnerHTML={{\n\t\t\t\t\t\t__html: `if (localStorage.getItem('${globalKey}') === 'true') document.documentElement.classList.add('${globalKey}');`\n\t\t\t\t\t}}\n\t\t\t\t/>\n\t\t\t:\tnull}\n\t\t\t{background}\n\t\t\t{href ?\n\t\t\t\t<Link\n\t\t\t\t\thref={href}\n\t\t\t\t\tclassName=\"flex flex-grow items-center justify-around\"\n\t\t\t\t\tstyle={{ zIndex: 0 }}\n\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t// remove the banner when someone navigates to the announcement\n\t\t\t\t\t\tif (globalKey) localStorage.setItem(globalKey, \"true\")\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t{BannerContent}\n\t\t\t\t</Link>\n\t\t\t:\t<div className=\"flex flex-grow items-center justify-around\">\n\t\t\t\t\t{BannerContent}\n\t\t\t\t</div>\n\t\t\t}\n\t\t\t{id ?\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\taria-label=\"Close Banner\"\n\t\t\t\t\tonClick={handleCloseClick}\n\t\t\t\t\tclassName={cx(\n\t\t\t\t\t\tbuttonVariants({\n\t\t\t\t\t\t\tcolor: \"ghost\",\n\t\t\t\t\t\t\tclassName:\n\t\t\t\t\t\t\t\t\"absolute end-2 top-1/2 -translate-y-1/2 text-fd-muted-foreground z-10\",\n\t\t\t\t\t\t\tsize: \"icon\"\n\t\t\t\t\t\t})\n\t\t\t\t\t)}\n\t\t\t\t>\n\t\t\t\t\t<X />\n\t\t\t\t</button>\n\t\t\t:\tnull}\n\t\t</div>\n\t)\n}\n\nconst maskImage =\n\t\"linear-gradient(to bottom,white,transparent), radial-gradient(circle at top center, white, transparent)\"\n\nconst palette = {\n\t\"--start\": \"hsla(207, 100%, 9%, 0.35)\",\n\t\"--mid\": \"hsla(207, 100%, 36%, 0.35)\",\n\t\"--end\": \"hsla(207, 100%, 63%, 0.35)\",\n\t\"--via\": \"hsla(207, 100%, 46%, 0.35)\"\n}\n\nconst background = (\n\t<>\n\t\t<div\n\t\t\tclassName=\"absolute inset-0 z-[-1]\"\n\t\t\tstyle={{\n\t\t\t\tmaskImage,\n\t\t\t\tmaskComposite: \"intersect\",\n\t\t\t\tanimation: \"fd-moving-banner 16s linear infinite alternate-reverse\",\n\t\t\t\t...palette,\n\t\t\t\tbackgroundImage:\n\t\t\t\t\t\"repeating-linear-gradient(60deg, var(--start), var(--start) 5%, var(--via) 12%, var(--mid) 20%, var(--end) 28%, transparent 40%)\",\n\t\t\t\tbackgroundSize: \"200% 100%\",\n\t\t\t\tmixBlendMode: \"normal\",\n\t\t\t\tleft: \"-25%\"\n\t\t\t}}\n\t\t/>\n\t\t<div\n\t\t\tclassName=\"absolute inset-0 z-[-1]\"\n\t\t\tstyle={{\n\t\t\t\tmaskImage,\n\t\t\t\tmaskComposite: \"intersect\",\n\t\t\t\tanimation: \"fd-moving-banner 20s linear infinite alternate\",\n\t\t\t\t...palette,\n\t\t\t\tbackgroundImage:\n\t\t\t\t\t\"repeating-linear-gradient(45deg, var(--start), var(--start) 5%, var(--via) 12%, var(--mid) 20%, var(--end) 28%, transparent 40%)\",\n\t\t\t\tbackgroundSize: \"200% 100%\",\n\t\t\t\tmixBlendMode: \"normal\",\n\t\t\t\tleft: \"-25%\"\n\t\t\t}}\n\t\t/>\n\t\t<style>\n\t\t\t{`\n@keyframes fd-moving-banner {\n  from {\n    transform: translateX(0%);\n  }\n  to {\n    transform: translateX(25%);\n  }\n}`}\n\t\t</style>\n\t</>\n)\n"
  },
  {
    "path": "ark/docs/components/Button.tsx",
    "content": "import { cx } from \"class-variance-authority\"\nimport Link from \"next/link\"\nimport { type ComponentPropsWithoutRef, forwardRef } from \"react\"\n\ntype ButtonSize = \"sm\" | \"md\" | \"lg\"\ntype ButtonVariant = \"outline\" | \"filled\"\n\nexport interface ButtonProps extends ComponentPropsWithoutRef<\"button\"> {\n\tvariant?: ButtonVariant\n\tsize?: ButtonSize\n\twiggle?: boolean\n\thref?: string\n\tlinkTarget?: string\n}\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(\n\t(\n\t\t{\n\t\t\tvariant = \"outline\",\n\t\t\tsize = \"md\",\n\t\t\twiggle,\n\t\t\thref,\n\t\t\tclassName,\n\t\t\tlinkTarget,\n\t\t\t...otherProps\n\t\t},\n\t\tref\n\t) => {\n\t\tconst sizeClasses = {\n\t\t\tsm: \"py-1.5 px-2.5 text-xs\",\n\t\t\tmd: \"py-2 px-3 text-sm\",\n\t\t\tlg: \"py-4 px-6 text-base\"\n\t\t}\n\n\t\tconst baseClasses = cx(\n\t\t\t\"rounded-[1.5rem] flex items-center gap-[6px] transition-all duration-150 ease-linear cursor-pointer\",\n\t\t\t\"focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white\"\n\t\t)\n\n\t\tconst variantClasses = {\n\t\t\toutline: cx(\n\t\t\t\t\"bg-transparent text-white border-2 border-white/60 backdrop-blur-[5px]\",\n\t\t\t\t\"shadow-[0_0_7px_rgba(255,255,255,0.5),_0_0_14px_rgba(149,88,248,0.3),_inset_0_0_6px_rgba(255,255,255,0.15)]\",\n\t\t\t\t\"[text-shadow:0_0_6px_rgba(255,255,255,0.6)]\",\n\t\t\t\t\"hover:border-white hover:shadow-[0_0_12px_rgba(255,255,255,0.7),_0_0_22px_rgba(149,88,248,0.45)] hover:text-white/95 hover:-translate-y-[1px]\",\n\t\t\t\t\"active:scale-[0.98] active:brightness-95 active:translate-y-0\"\n\t\t\t),\n\t\t\tfilled: cx(\n\t\t\t\t\"bg-[#f5cf8f] text-black border-2 border-transparent\",\n\t\t\t\t\"shadow-[0_4px_10px_rgba(0,0,0,0.2),_0_0_10px_#f5cf8f]\",\n\t\t\t\t\"hover:bg-[#f7e1b1] hover:shadow-[0_4px_15px_rgba(0,0,0,0.15),_0_0_15px_#f7e1b1] hover:-translate-y-[1px]\",\n\t\t\t\t\"active:scale-[0.98] active:bg-[#f5cf8f] active:translate-y-0\"\n\t\t\t)\n\t\t}\n\n\t\tconst wiggleClasses = wiggle ? \"wiggle-animation\" : \"\"\n\n\t\tconst combinedClasses = cx(\n\t\t\tbaseClasses,\n\t\t\tsizeClasses[size],\n\t\t\tvariantClasses[variant],\n\t\t\twiggleClasses,\n\t\t\tclassName\n\t\t)\n\n\t\tconst commonProps = {\n\t\t\tclassName: combinedClasses,\n\t\t\t...otherProps\n\t\t}\n\n\t\tif (href) {\n\t\t\treturn (\n\t\t\t\t<Link href={href} target={linkTarget} {...(commonProps as any)}>\n\t\t\t\t\t{otherProps.children}\n\t\t\t\t</Link>\n\t\t\t)\n\t\t}\n\n\t\treturn <button ref={ref} {...commonProps} />\n\t}\n)\n"
  },
  {
    "path": "ark/docs/components/CodeBlock.tsx",
    "content": "import { throwInternalError, type propwiseXor } from \"@ark/util\"\nimport { cx } from \"class-variance-authority\"\nimport type { HighlightOptions } from \"fumadocs-core/highlight\"\nimport { Popup, PopupContent, PopupTrigger } from \"fumadocs-twoslash/ui\"\nimport {\n\tCodeBlock as FumaCodeBlock,\n\tPre\n} from \"fumadocs-ui/components/codeblock\"\nimport { toJsxRuntime } from \"hast-util-to-jsx-runtime\"\nimport { Fragment, jsx, jsxs } from \"react/jsx-runtime\"\nimport { getSingletonHighlighter } from \"shiki\"\nimport { shikiConfig, type BuiltinLang } from \"../lib/shiki.ts\"\nimport type { SnippetId } from \"../lib/writeSnippetsEntrypoint.ts\"\nimport snippetContentsById from \"./snippets/contentsById.ts\"\n\nexport type CodeBlockProps = {\n\t/** @default \"ts\" */\n\tlang?: BuiltinLang\n\tstyle?: React.CSSProperties\n\tclassName?: string\n\tincludesCompletions?: boolean\n\tdecorators?: CodeBlockDecorator[]\n} & propwiseXor<{ children: string }, { fromFile: SnippetId }>\n\nexport type CodeBlockDecorator = \"@noErrors\"\n\n// preload languages for shiki\n// https://github.com/fuma-nama/fumadocs/issues/1095\nconst highlighter = await getSingletonHighlighter({\n\tlangs: shikiConfig.langs,\n\tthemes: [shikiConfig.themes.dark]\n})\n\nexport const CodeBlock: React.FC<CodeBlockProps> = ({\n\tlang = \"ts\",\n\tchildren,\n\tfromFile,\n\tstyle,\n\tclassName,\n\tincludesCompletions,\n\tdecorators\n}) => {\n\tlet src = children ?? snippetContentsById[fromFile!]\n\n\tif (!src) {\n\t\tthrowInternalError(\n\t\t\tfromFile ?\n\t\t\t\t`Specified snippet '${fromFile}' does not have a corresponding file`\n\t\t\t:\t`CodeBlock requires either a fromFile prop or a string child representing its text contents`\n\t\t)\n\t}\n\n\tif (decorators)\n\t\tfor (const d of decorators) if (!src.includes(d)) src = `// ${d}\\n${src}`\n\n\tconst highlighted = highlight(lang, src)\n\n\treturn (\n\t\t<FumaCodeBlock\n\t\t\tclassName={cx(\n\t\t\t\tclassName,\n\t\t\t\tincludesCompletions ? \"completions-block\" : undefined\n\t\t\t)}\n\t\t\tkeepBackground\n\t\t\tstyle={style}\n\t\t>\n\t\t\t{highlighted}\n\t\t</FumaCodeBlock>\n\t)\n}\n\nconst components: HighlightOptions[\"components\"] = {\n\t// rounded none is for syntax tabs\n\tpre: ({ className, children, ...props }) => (\n\t\t<Pre className={cx(className, \"!rounded-none\")} {...props}>\n\t\t\t{children}\n\t\t</Pre>\n\t),\n\tCodeBlock\n}\n\n// overriding these custom components allows hovers to render\n// correctly in code blocks outside markdown (e.g. on the home page)\nObject.assign(components, {\n\tPopup,\n\tPopupContent,\n\tPopupTrigger\n})\n\nconst highlight = (lang: BuiltinLang, contents: string) => {\n\ttry {\n\t\tconst hast = highlighter.codeToHast(contents, {\n\t\t\t...shikiConfig,\n\t\t\tlang\n\t\t})\n\n\t\treturn toJsxRuntime(hast, {\n\t\t\tFragment,\n\t\t\tjsx,\n\t\t\tjsxs,\n\t\t\tcomponents\n\t\t})\n\t} catch (e) {\n\t\tconsole.error(`Failed to transform the following code:\\n${contents}`)\n\t\tthrow e\n\t}\n}\n"
  },
  {
    "path": "ark/docs/components/FloatYourBoat.tsx",
    "content": "\"use client\"\n\nimport { BoatIcon } from \"./icons/boat.tsx\"\nimport { cx } from \"class-variance-authority\"\n\nexport const FloatYourBoat = () => (\n\t<>\n\t\t<div\n\t\t\tclassName={cx(\"pointer-events-none\", \"motion-reduce:hidden\")}\n\t\t\tstyle={{\n\t\t\t\tposition: \"absolute\",\n\t\t\t\tzIndex: -10,\n\t\t\t\tanimation: \"float 150s linear infinite,\t\tbob 2s ease-in-out infinite\",\n\t\t\t\topacity: 0,\n\t\t\t\ttransform: \"translateZ(0)\",\n\t\t\t\tbottom: \"-30%\"\n\t\t\t}}\n\t\t>\n\t\t\t<BoatIcon height={100} />\n\t\t</div>\n\t\t<style>\n\t\t\t{`\n@keyframes float {\n\t0% {\n\t\tleft: 0;\n\t\topacity: 0;\n\t}\n\t2% {\n\t\topacity: 1;\n\t}\n\t98% {\n\t\topacity: 1;\n\t}\n\t100% {\n\t\topacity: 0;\n\t\tleft: calc(100% - 100px);\n\t}\n}\n@keyframes bob {\n\t0% {\n\t\ttransform: translateY(0px);\n\t}\n\t50% {\n\t\ttransform: translateY(2px);\n\t}\n\t100% {\n\t\ttransform: translateY(0px);\n\t}\n}\n`}\n\t\t</style>\n\t</>\n)\n"
  },
  {
    "path": "ark/docs/components/GhStarButton.tsx",
    "content": "\"use client\"\n\nimport { cx } from \"class-variance-authority\"\nimport { Star } from \"lucide-react\"\nimport React, { useEffect, useState } from \"react\"\nimport { Button } from \"./Button.tsx\"\n\nexport declare namespace GhStarButton {\n\texport type Props = {\n\t\tclassName?: string\n\t}\n}\n\nexport const formatStarCount = (count: number): string => {\n\tif (count < 1000) return count.toString()\n\n\tconst roundedCount = Math.floor(count / 100) / 10\n\tconst roundUpCount = Math.ceil(count / 100) / 10\n\tconst finalCount = count % 100 >= 50 ? roundUpCount : roundedCount\n\n\treturn `${finalCount}k`\n}\n\nconst defaultStars = \"6.5k\"\n\nexport const fetchStars = async () => {\n\tconst res = await fetch(\"https://api.github.com/repos/arktypeio/arktype\")\n\tconst data = (await res.json()) as { stargazers_count: number }\n\tif (typeof data?.stargazers_count === \"number\")\n\t\treturn formatStarCount(data.stargazers_count)\n\treturn defaultStars\n}\n\n// based on the trpc component:\n// https://github.com/trpc/trpc/blob/7d10d7b028f1d85f6523e995ee7deb17dc886874/www/src/components/GithubStarsButton.tsx#L15\nexport const GhStarButton = ({ className }: GhStarButton.Props) => {\n\tconst [starCount, setStarCount] = useState<string>(defaultStars)\n\n\tuseEffect(() => {\n\t\tfetchStars().then(setStarCount).catch(console.error)\n\t}, [])\n\n\treturn (\n\t\t<Button\n\t\t\tvariant=\"outline\"\n\t\t\thref=\"https://github.com/arktypeio/arktype\"\n\t\t\tlinkTarget=\"_blank\"\n\t\t\tsize=\"lg\"\n\t\t\tclassName={cx(className)}\n\t\t>\n\t\t\t{starCount}\n\t\t\t<Star size={16} />\n\t\t</Button>\n\t)\n}\n"
  },
  {
    "path": "ark/docs/components/Head.tsx",
    "content": ""
  },
  {
    "path": "ark/docs/components/Hero.tsx",
    "content": "import { ArrowRightIcon, PlayIcon } from \"lucide-react\"\nimport { MainAutoplayDemo } from \"./AutoplayDemo.tsx\"\nimport { Button } from \"./Button.tsx\"\nimport { GhStarButton } from \"./GhStarButton.tsx\"\nimport { PlatformCloud } from \"./PlatformCloud.tsx\"\n\nexport const Hero = () => (\n\t<div>\n\t\t<div className=\"flex flex-col md:flex-row justify-between\">\n\t\t\t<div className=\"absolute top-2 left-0 right-0\">\n\t\t\t\t<div className=\"flex justify-between\">\n\t\t\t\t\t<PlatformCloud\n\t\t\t\t\t\tmain=\"ts\"\n\t\t\t\t\t\tright=\"vscode\"\n\t\t\t\t\t\ttop=\"neovim\"\n\t\t\t\t\t\tleft=\"intellij\"\n\t\t\t\t\t/>\n\t\t\t\t\t<PlatformCloud main=\"js\" right=\"chromium\" top=\"node\" left=\"bun\" />\n\t\t\t\t</div>\n\t\t\t</div>\n\n\t\t\t<div className=\"relative w-full flex flex-col md:items-start text-center md:text-left\">\n\t\t\t\t<h1 className=\"mb-4 text-3xl md:text-8xl\">ArkType</h1>\n\t\t\t\t<p className=\"text-fd-muted-foreground text-3xl leading-relaxed hero-tagline\">\n\t\t\t\t\tTypeScript's 1:1 validator, optimized from editor to runtime\n\t\t\t\t</p>\n\t\t\t\t<div className=\"w-full flex-1 flex items-start justify-around mt-6 md:justify-start md:gap-x-4\">\n\t\t\t\t\t<GhStarButton />\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"outline\"\n\t\t\t\t\t\thref=\"/playground\"\n\t\t\t\t\t\tsize=\"lg\"\n\t\t\t\t\t\tclassName=\"hidden md:flex\"\n\t\t\t\t\t>\n\t\t\t\t\t\tPlayground\n\t\t\t\t\t\t<PlayIcon />\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button variant=\"filled\" href=\"/docs/intro/setup\" size=\"lg\">\n\t\t\t\t\t\tIntro\n\t\t\t\t\t\t<ArrowRightIcon />\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t</div>\n\n\t\t\t<div style={{ padding: \"2rem\", position: \"relative\" }}>\n\t\t\t\t<MainAutoplayDemo />\n\t\t\t</div>\n\t\t</div>\n\t</div>\n)\n"
  },
  {
    "path": "ark/docs/components/InstallationTabs.tsx",
    "content": "import { Tab, Tabs } from \"fumadocs-ui/components/tabs\"\nimport { CodeBlock } from \"./CodeBlock.tsx\"\n\nconst installers = [\"pnpm\", \"npm\", \"yarn\", \"bun\"] as const satisfies string[]\n\nexport type Installer = (typeof installers)[number]\n\ntype InstallationTabProps = {\n\tname: Installer\n}\n\nconst InstallerTab = ({ name }: InstallationTabProps) => (\n\t<Tab value={name} className=\"installer-tab\">\n\t\t<CodeBlock lang=\"bash\">{`${name} ${name === \"yarn\" ? \"add\" : \"install\"} arktype`}</CodeBlock>\n\t</Tab>\n)\n\nexport const InstallationTabs = () => (\n\t<Tabs items={installers}>\n\t\t<InstallerTab name=\"pnpm\" />\n\t\t<InstallerTab name=\"npm\" />\n\t\t<InstallerTab name=\"yarn\" />\n\t\t<InstallerTab name=\"bun\" />\n\t</Tabs>\n)\n"
  },
  {
    "path": "ark/docs/components/KeywordTable.tsx",
    "content": "import { append, entriesOf, flatMorph } from \"@ark/util\"\nimport { ark, Generic } from \"arktype\"\nimport { arkPrototypes } from \"arktype/internal/keywords/constructors.ts\"\nimport type { JSX } from \"react\"\n\nconst tableNames = [\n\t\"string\",\n\t\"number\",\n\t\"other\",\n\t\"object\",\n\t\"array\",\n\t\"FormData\",\n\t\"TypedArray\",\n\t\"instanceof\",\n\t\"generic\"\n] as const\n\nconst tableRowsByName = flatMorph(tableNames, (i, name) => [\n\tname,\n\t[] as JSX.Element[]\n])\n\nconst formatDescription = (description: string): JSX.Element => {\n\tif (!description.includes(\"`\")) return <>{description}</>\n\n\tconst segments = description.split(/(`[^`]+`)/)\n\treturn (\n\t\t<>\n\t\t\t{segments.map((segment, i) => {\n\t\t\t\tif (segment.startsWith(\"`\") && segment.endsWith(\"`\")) {\n\t\t\t\t\tconst code = segment.substring(1, segment.length - 1)\n\t\t\t\t\treturn <code key={i}>{code}</code>\n\t\t\t\t}\n\t\t\t\treturn <span key={i}>{segment}</span>\n\t\t\t})}\n\t\t</>\n\t)\n}\n\nfor (const [alias, v] of entriesOf(ark.internal.resolutions)\n\t.map(\n\t\t([alias, v]) =>\n\t\t\t[alias.endsWith(\".root\") ? alias.slice(0, -5) : alias, v] as const\n\t)\n\t.sort((l, r) => (l[0] < r[0] ? -1 : 1))) {\n\t// should not occur, only for temporary resolutions of cyclic definition\n\tif (typeof v === \"string\") continue\n\n\tconst name =\n\t\talias.startsWith(\"string\") ? \"string\"\n\t\t: alias.startsWith(\"number\") ? \"number\"\n\t\t: alias.startsWith(\"FormData\") ? \"FormData\"\n\t\t: alias.startsWith(\"Array\") ? \"array\"\n\t\t: alias.startsWith(\"object\") ? \"object\"\n\t\t: alias.startsWith(\"TypedArray\") ? \"TypedArray\"\n\t\t: v instanceof Generic ? \"generic\"\n\t\t: alias in arkPrototypes ? \"instanceof\"\n\t\t: \"other\"\n\n\ttableRowsByName[name] = append(\n\t\ttableRowsByName[name],\n\t\t<tr key={alias}>\n\t\t\t<td>{alias}</td>\n\t\t\t<td>{formatDescription(v.description)}</td>\n\t\t</tr>\n\t)\n}\n\ntype KeywordTableProps = {\n\trows: JSX.Element[]\n}\n\nconst KeywordTable = ({ rows }: KeywordTableProps) => (\n\t<table>\n\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t<th className=\"font-bold\">Alias</th>\n\t\t\t\t<th className=\"font-bold\">Description</th>\n\t\t\t</tr>\n\t\t</thead>\n\t\t<tbody>{...rows}</tbody>\n\t</table>\n)\n\nconst KeywordTables = flatMorph(tableNames, (i, name) => [\n\tname,\n\t() => <KeywordTable rows={tableRowsByName[name]} />\n])\n\nexport const StringKeywordTable = KeywordTables.string\n\nexport const NumberKeywordTable = KeywordTables.number\n\nexport const GenericKeywordTable = KeywordTables.generic\n\nexport const AllKeywordTables = () =>\n\ttableNames.map(name => (\n\t\t<>\n\t\t\t<h2>{name}</h2> <KeywordTable rows={tableRowsByName[name]} />\n\t\t</>\n\t))\n"
  },
  {
    "path": "ark/docs/components/LinkCard.tsx",
    "content": "import { cx } from \"class-variance-authority\"\nimport { Card } from \"fumadocs-ui/components/card\"\nimport { ArrowRight } from \"lucide-react\"\nimport Link from \"next/link.js\"\n\nexport const LinkCard: React.FC<{\n\thref: string\n\tdescription: string\n\ttitle: string\n\tclassName?: string\n\tdate?: string\n}> = ({ href, description, title, className, date }) => (\n\t<Link href={href} className={cx(\"block relative\", className)}>\n\t\t<Card\n\t\t\ttitle={title}\n\t\t\tclassName=\"border-[#003b62] hover:border-white [&>h3]:text-xl [&>h3]:font-semibold hover:bg-blue-500/10 group\"\n\t\t>\n\t\t\t<ArrowRight className=\"right-4 absolute top-3 group-hover:text-white\" />\n\t\t\t<p className=\"text-lg\">{description}</p>\n\t\t\t{date && (\n\t\t\t\t<span className=\"absolute right-4 bottom-3 text-sm text-gray-500\">\n\t\t\t\t\t{date}\n\t\t\t\t</span>\n\t\t\t)}\n\t\t</Card>\n\t</Link>\n)\n"
  },
  {
    "path": "ark/docs/components/LocalFriendlyUrl.tsx",
    "content": "\"use client\"\nimport { useEffect, useState } from \"react\"\n\nexport interface LocalFriendlyUrlProps {\n\tchildren: string\n\turl: string\n\tkey?: string | number | undefined\n}\n\nexport const LocalFriendlyUrl = (props: LocalFriendlyUrlProps) => {\n\tconst [locallyAccessibleUrl, setLocallyAccessibleUrl] = useState(props.url)\n\n\tif (process.env.NODE_ENV === \"development\") {\n\t\tuseEffect(() => {\n\t\t\tconst devFriendlyUrl = new URL(props.url)\n\t\t\tdevFriendlyUrl.protocol = \"http:\"\n\t\t\tdevFriendlyUrl.host = window.location.host\n\t\t\tsetLocallyAccessibleUrl(devFriendlyUrl.toString())\n\t\t}, [props.url])\n\t}\n\n\treturn (\n\t\t<a\n\t\t\tstyle={{ display: \"inline-block\" }}\n\t\t\thref={locallyAccessibleUrl}\n\t\t\tkey={props.key}\n\t\t>\n\t\t\t{props.children}\n\t\t</a>\n\t)\n}\n"
  },
  {
    "path": "ark/docs/components/PlatformCloud.tsx",
    "content": "\"use client\"\n\nimport { BunIcon } from \"./icons/bun.tsx\"\nimport { ChromiumIcon } from \"./icons/chromium.tsx\"\nimport { DenoIcon } from \"./icons/deno.tsx\"\nimport { IntellijIcon } from \"./icons/intellij.tsx\"\nimport { JsIcon } from \"./icons/js.tsx\"\nimport { NeovimIcon } from \"./icons/neovim.tsx\"\nimport { NodeIcon } from \"./icons/node.tsx\"\nimport { TsIcon } from \"./icons/ts.tsx\"\nimport { VscodeIcon } from \"./icons/vscode.tsx\"\n\nexport type SvgLogoProps = {\n\tname: PlatformName\n}\n\ntype PlatformName = keyof typeof platforms\n\nconst platforms = {\n\tjs: JsIcon,\n\tchromium: ChromiumIcon,\n\tnode: NodeIcon,\n\tdeno: DenoIcon,\n\tts: TsIcon,\n\tneovim: NeovimIcon,\n\tvscode: VscodeIcon,\n\tintellij: IntellijIcon,\n\tbun: BunIcon\n}\n\ntype PlatformCloudProps = {\n\tmain: PlatformName\n\tright: PlatformName\n\ttop: PlatformName\n\tleft: PlatformName\n}\n\nexport const PlatformCloud = ({\n\tmain,\n\tright,\n\ttop,\n\tleft\n}: PlatformCloudProps) => {\n\tconst Main = platforms[main]\n\tconst Right = platforms[right]\n\tconst Top = platforms[top]\n\tconst Left = platforms[left]\n\treturn (\n\t\t<div className=\"relative h-full w-[200px]\">\n\t\t\t<div\n\t\t\t\tstyle={{\n\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\theight: 70,\n\t\t\t\t\topacity: 0.1,\n\t\t\t\t\ttop: 55,\n\t\t\t\t\tleft: 70\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<Main height={70} aria-label={main} />\n\t\t\t</div>\n\t\t\t<div\n\t\t\t\tstyle={{\n\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\theight: 60,\n\t\t\t\t\topacity: 0.25,\n\t\t\t\t\ttop: 50,\n\t\t\t\t\tleft: 130\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<Right height={60} aria-label={right} />\n\t\t\t</div>\n\t\t\t<div\n\t\t\t\tstyle={{\n\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\theight: 50,\n\t\t\t\t\topacity: 0.25,\n\t\t\t\t\ttop: 100,\n\t\t\t\t\tleft: 30\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<Left height={50} aria-label={left} />\n\t\t\t</div>\n\t\t\t<div\n\t\t\t\tstyle={{\n\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\theight: 45,\n\t\t\t\t\topacity: 0.25,\n\t\t\t\t\ttop: 50,\n\t\t\t\t\tleft: 50\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<Top height={45} aria-label={top} />\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n"
  },
  {
    "path": "ark/docs/components/ReleaseBanner.tsx",
    "content": "\"use client\"\n\nimport { usePathname } from \"next/navigation.js\"\nimport { Banner } from \"./Banner.tsx\"\n\nconst text = \"🎉 Introducing ArkRegex 🎉\"\n\nexport const ReleaseBanner = () => (\n\t<Banner\n\t\tid=\"arkregex\"\n\t\thref=\"/docs/blog/arkregex\"\n\t\tstyle={{ fontSize: 16 }}\n\t\tboat={usePathname().includes(\"docs\")}\n\t>\n\t\t{text}\n\t</Banner>\n)\n"
  },
  {
    "path": "ark/docs/components/RuntimeBenchmarksGraph.tsx",
    "content": "import { cx } from \"class-variance-authority\"\nimport React from \"react\"\n\nconst barStyles: React.CSSProperties = {\n\theight: \"30px\",\n\tborderRadius: \"8px\",\n\tdisplay: \"flex\",\n\talignItems: \"baseline\",\n\tmarginRight: \"0.5rem\",\n\tmarginBottom: \"0.5rem\",\n\tcolor: \"black\"\n}\n\nconst arkBarStyles = {\n\t...barStyles,\n\tbackground:\n\t\t\"repeating-linear-gradient(135deg, #00ffd5, #00ffd5 12px, #00e6bf 12px, #00e6bf 24px)\"\n}\nconst zodBarStyles = {\n\t...barStyles,\n\tbackground:\n\t\t\"repeating-linear-gradient(135deg, rgba(140, 205, 255, 0.6), rgba(140, 205, 255, 0.6) 12px, rgba(124, 189, 237, 0.6) 12px, rgba(124, 189, 237, 0.6) 24px)\"\n}\n\nconst yupBarStyles = {\n\t...barStyles,\n\tbackground:\n\t\t\"repeating-linear-gradient(135deg, rgba(144, 175, 224, 0.7), rgba(144, 175, 224, 0.7) 12px, rgba(133, 157, 199, 0.7) 12px, rgba(133, 157, 199, 0.7) 24px)\"\n}\n\nexport const RuntimeBenchmarksGraph: React.FC<{ className?: string }> = ({\n\tclassName\n}) => (\n\t<div\n\t\tstyle={{\n\t\t\tfontSize: 16.8,\n\t\t\tfontWeight: 500,\n\t\t\tdisplay: \"flex\",\n\t\t\tflexDirection: \"column\",\n\t\t\tflexGrow: 1\n\t\t}}\n\t\tclassName={cx(\"font-semibold text-white\", className)}\n\t>\n\t\t<div style={{ display: \"flex\", flexDirection: \"row\" }}>\n\t\t\t<h6 className=\"text-xl mb-2\">Object Validation, Node v23.6.1</h6>{\" \"}\n\t\t\t<a\n\t\t\t\tclassName=\"underline ml-2\"\n\t\t\t\ttarget=\"_blank\"\n\t\t\t\thref=\"https://moltar.github.io/typescript-runtime-type-benchmarks/\"\n\t\t\t\tstyle={{ textDecoration: \"underline\", color: \"#1e90ff\" }}\n\t\t\t>\n\t\t\t\t(source)\n\t\t\t</a>\n\t\t</div>\n\t\t<div style={{ display: \"flex\", flexDirection: \"column\", flexGrow: 1 }}>\n\t\t\t<div style={{ display: \"flex\", alignItems: \"center\" }}>\n\t\t\t\t<div style={{ ...arkBarStyles, width: \"2%\" }}></div>\n\t\t\t\tArkType ⚡ 14 nanoseconds\n\t\t\t</div>\n\t\t\t<div style={{ ...zodBarStyles, width: \"40%\" }}>\n\t\t\t\t&nbsp;&nbsp;&nbsp;Zod 👍 281 nanoseconds\n\t\t\t</div>\n\t\t\t<div style={{ ...yupBarStyles, width: \"100%\" }}>\n\t\t\t\t&nbsp;&nbsp;&nbsp;Yup 🐌 40755 nanoseconds*\n\t\t\t</div>\n\t\t\t<div className=\"text-xs mt-auto self-end\">\n\t\t\t\t*scaling generously logarithmized\n\t\t\t</div>\n\t\t</div>\n\t</div>\n)\n"
  },
  {
    "path": "ark/docs/components/SyntaxTabs.tsx",
    "content": "import type { omit, unionToPropwiseXor } from \"@ark/util\"\nimport { Tab, Tabs, type TabsProps } from \"fumadocs-ui/components/tabs\"\nimport { Children, isValidElement, type FC } from \"react\"\n\nexport const syntaxKinds = [\n\t\"string\",\n\t\"fluent\",\n\t\"tuple\",\n\t\"args\",\n\t\"generic\"\n\t// don't infer as readonly since Fumadocs (incorrectly) doesn't support that\n] as const satisfies string[]\n\nexport type SyntaxKind = (typeof syntaxKinds)[number]\n\nexport const SyntaxTabs: React.FC<omit<TabsProps, \"items\">> = ({\n\tchildren,\n\t...rest\n}) => {\n\tconst usedKinds = Children.toArray(children as never).flatMap(child => {\n\t\tif (!isValidElement(child)) return []\n\t\tif (!child.props) return []\n\n\t\tconst props = child.props as SyntaxTabProps\n\n\t\tconst matchingKind = syntaxKinds.find(k => props[k])\n\t\tif (!matchingKind) return []\n\n\t\treturn matchingKind\n\t})\n\n\treturn (\n\t\t<Tabs {...rest} items={usedKinds}>\n\t\t\t{children}\n\t\t</Tabs>\n\t)\n}\n\ntype DiscriminatedSyntaxKindProps = unionToPropwiseXor<\n\t{\n\t\t[kind in SyntaxKind]: { [k in kind]: true }\n\t}[SyntaxKind]\n>\n\ntype SyntaxTabProps = DiscriminatedSyntaxKindProps & {\n\tchildren: React.ReactNode\n}\n\nexport const SyntaxTab: FC<SyntaxTabProps> = props => (\n\t<Tab value={syntaxKinds.find(k => props[k])!}>{props.children}</Tab>\n)\n"
  },
  {
    "path": "ark/docs/components/apiData.ts",
    "content": "import type { ApiDocsByGroup } from \"../../repo/jsdocGen.ts\"\n\n/** THIS FILE IS AUTOGENERATED FROM ark/repo/jsdocGen.ts **/\n// prettier-ignore\nexport const apiDocsByGroup: ApiDocsByGroup = {\n    \"Type\": [\n        {\n            \"group\": \"Type\",\n            \"name\": \"$\",\n            \"summary\": [\n                {\n                    \"kind\": \"reference\",\n                    \"value\": \"Scope\"\n                },\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"in which chained methods are parsed\"\n                }\n            ],\n            \"notes\": []\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"infer\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"type of output this returns\"\n                }\n            ],\n            \"notes\": [\n                [],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"🥸 inference-only property that will be `undefined` at runtime\"\n                    }\n                ]\n            ],\n            \"example\": \"const parseNumber = type(\\\"string\\\").pipe(s => Number.parseInt(s))\\ntype ParsedNumber = typeof parseNumber.infer // number\"\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"inferIn\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"type of input this allows\"\n                }\n            ],\n            \"notes\": [\n                [],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"🥸 inference-only property that will be `undefined` at runtime\"\n                    }\n                ]\n            ],\n            \"example\": \"const parseNumber = type(\\\"string\\\").pipe(s => Number.parseInt(s))\\ntype UnparsedNumber = typeof parseNumber.inferIn // string\"\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"json\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"internal JSON representation\"\n                }\n            ],\n            \"notes\": []\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"toJsonSchema\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"generate a JSON Schema\"\n                }\n            ],\n            \"notes\": []\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"meta\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"metadata like custom descriptions and error messages\"\n                }\n            ],\n            \"notes\": [\n                [],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"✅ type\"\n                    },\n                    {\n                        \"kind\": \"link\",\n                        \"url\": \"https://arktype.io/docs/configuration#custom\",\n                        \"value\": \"can be customized\"\n                    },\n                    {\n                        \"kind\": \"text\",\n                        \"value\": \"for your project\"\n                    }\n                ]\n            ]\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"description\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"human-readable English description\"\n                }\n            ],\n            \"notes\": [\n                [],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"✅ works best for primitive values\"\n                    }\n                ]\n            ],\n            \"example\": \"const N = type(\\\"0 < number <= 100\\\")\\nconsole.log(N.description) // positive and at most 100\"\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"expression\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"syntax string similar to native TypeScript\"\n                }\n            ],\n            \"notes\": [\n                [],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"✅ works well for both primitives and structures\"\n                    }\n                ]\n            ],\n            \"example\": \"const Loc = type({ coords: [\\\"number\\\", \\\"number\\\"] })\\nconsole.log(Loc.expression) // { coords: [number, number] }\"\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"assert\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"validate and return transformed data or throw\"\n                }\n            ],\n            \"notes\": [\n                [],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"✅ sugar to avoid checking for\"\n                    },\n                    {\n                        \"kind\": \"reference\",\n                        \"value\": \"type.errors\"\n                    },\n                    {\n                        \"kind\": \"text\",\n                        \"value\": \"if they are unrecoverable\"\n                    }\n                ]\n            ],\n            \"example\": \"const CriticalPayload = type({\\n    superImportantValue: \\\"string\\\"\\n})\\n// throws TraversalError: superImportantValue must be a string (was missing)\\nconst data = CriticalPayload.assert({ irrelevantValue: \\\"whoops\\\" })\\nconsole.log(data.superImportantValue) // valid output can be accessed directly\"\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"allows\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"check input without applying morphs\"\n                }\n            ],\n            \"notes\": [\n                [],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"✅ good for stuff like filtering that doesn't benefit from detailed errors\"\n                    }\n                ]\n            ],\n            \"example\": \"const Numeric = type(\\\"number | bigint\\\")\\n// [0, 2n]\\nconst numerics = [0, \\\"one\\\", 2n].filter(Numeric.allows)\"\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"configure\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"add metadata to shallow references\"\n                }\n            ],\n            \"notes\": [\n                [],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"⚠️ does not affect error messages within properties of an object\"\n                    }\n                ]\n            ],\n            \"example\": \"const NotOdd = type(\\\"number % 2\\\").configure({ description: \\\"not odd\\\" })\\n// all constraints at the root are affected\\nconst odd = NotOdd(3) // must be not odd (was 3)\\nconst nonNumber = NotOdd(\\\"two\\\") // must be not odd (was \\\"two\\\")\\n\\nconst NotOddBox = type({\\n   // we should have referenced notOdd or added meta here\\n   notOdd: \\\"number % 2\\\",\\n// but instead chained from the root object\\n}).configure({ description: \\\"not odd\\\" })\\n// error message at path notOdd is not affected\\nconst oddProp = NotOddBox({ notOdd: 3 }) // notOdd must be even (was 3)\\n// error message at root is affected, leading to a misleading description\\nconst nonObject = NotOddBox(null) // must be not odd (was null)\"\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"describe\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"add description to shallow references\"\n                }\n            ],\n            \"notes\": [\n                [],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"🔗 equivalent to `.configure({ description })` (see\"\n                    },\n                    {\n                        \"kind\": \"reference\",\n                        \"value\": \"configure\"\n                    },\n                    {\n                        \"kind\": \"text\",\n                        \"value\": \")\"\n                    }\n                ],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"⚠️ does not affect error messages within properties of an object\"\n                    }\n                ]\n            ],\n            \"example\": \"const AToZ = type(/^a.*z$/).describe(\\\"a string like 'a...z'\\\")\\nconst good = AToZ(\\\"alcatraz\\\") // \\\"alcatraz\\\"\\n// ArkErrors: must be a string like 'a...z' (was \\\"albatross\\\")\\nconst badPattern = AToZ(\\\"albatross\\\")\"\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"onUndeclaredKey\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"apply undeclared key behavior\"\n                }\n            ],\n            \"notes\": [\n                [],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"- `\\\"ignore\\\"` (default) - allow and preserve extra properties\"\n                    }\n                ],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"- `\\\"reject\\\"` - disallow extra properties\"\n                    }\n                ],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"- `\\\"delete\\\"` - clone and remove extra properties from output\"\n                    }\n                ]\n            ]\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"onDeepUndeclaredKey\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"deeply apply undeclared key behavior\"\n                }\n            ],\n            \"notes\": [\n                [],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"- `\\\"ignore\\\"` (default) - allow and preserve extra properties\"\n                    }\n                ],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"- `\\\"reject\\\"` - disallow extra properties\"\n                    }\n                ],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"- `\\\"delete\\\"` - clone and remove extra properties from output\"\n                    }\n                ]\n            ]\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"from\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"alias for\"\n                },\n                {\n                    \"kind\": \"reference\",\n                    \"value\": \"assert\"\n                },\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"with typed input\"\n                }\n            ],\n            \"notes\": [],\n            \"example\": \"const T = type({ foo: \\\"string\\\" });\\n// TypeScript: foo must be a string (was 5)\\nconst data = T.from({ foo: 5 });\"\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"brand\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"add a compile-time brand to output\"\n                }\n            ],\n            \"notes\": [\n                [],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"🥸 inference-only function that does nothing runtime\"\n                    }\n                ]\n            ],\n            \"example\": \"const Palindrome = type(\\\"string\\\")\\n    .narrow(s => s === [...s].reverse().join(\\\"\\\"))\\n    .brand(\\\"palindrome\\\")\\n// Brand<string, \\\"palindrome\\\">\\nconst out = Palindrome.assert(\\\"racecar\\\")\"\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"array\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"an array of this\"\n                }\n            ],\n            \"notes\": [],\n            \"example\": \"// Type<{ rebmun: number }[]>\\nconst T = type({ rebmun: \\\"number\\\" }).array();\"\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"optional\",\n            \"summary\": [\n                {\n                    \"kind\": \"link\",\n                    \"url\": \"https://arktype.io/docs/objects#properties-optional\",\n                    \"value\": \"optional definition\"\n                }\n            ],\n            \"notes\": [\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"⚠️ unlike most other methods, this creates a definition rather than a Type (read why)\"\n                    }\n                ]\n            ],\n            \"example\": \"const Prop = type({ foo: \\\"number\\\" })\\n// Type<{ bar?: { foo: number } }>\\nconst Obj = type({ bar: Prop.optional() })\"\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"default\",\n            \"summary\": [\n                {\n                    \"kind\": \"link\",\n                    \"url\": \"https://arktype.io/docs/objects#properties-defaultable\",\n                    \"value\": \"defaultable definition\"\n                }\n            ],\n            \"notes\": [\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"✅ object defaults can be returned from a function\"\n                    }\n                ],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"⚠️ throws if the default value is not allowed\"\n                    }\n                ],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"⚠️ unlike most other methods, this creates a definition rather than a Type (read why)\"\n                    }\n                ]\n            ],\n            \"example\": \"// Type<{ count: Default<number, 0> }>\\nconst State = type({ count: type.number.default(0) })\\nconst Prop = type({ nested: \\\"boolean\\\" })\\nconst ForObj = type({\\n    key: Prop.default(() => ({ nested: false }))\\n})\"\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"filter\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"apply a predicate function to input\"\n                }\n            ],\n            \"notes\": [\n                [],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"⚠️ the behavior of\"\n                    },\n                    {\n                        \"kind\": \"reference\",\n                        \"value\": \"narrow\"\n                    },\n                    {\n                        \"kind\": \"text\",\n                        \"value\": \", this method's output counterpart, is usually more desirable\"\n                    }\n                ],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"✅ most useful for morphs with input types that are re-used externally\"\n                    }\n                ],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"🥸\"\n                    },\n                    {\n                        \"kind\": \"link\",\n                        \"url\": \"https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates\",\n                        \"value\": \"Type predicates\"\n                    },\n                    {\n                        \"kind\": \"text\",\n                        \"value\": \"can be used as casts\"\n                    }\n                ]\n            ],\n            \"example\": \"const stringifyUser = type({ name: \\\"string\\\" }).pipe(user => JSON.stringify(user))\\nconst stringifySafe = stringifyUser.filter(user => user.name !== \\\"Bobby Tables\\\")\\n// Type<(In: `${string}Z`) => To<Date>>\\nconst WithPredicate = type(\\\"string.date.parse\\\").filter((s): s is `${string}Z` =>\\n    s.endsWith(\\\"Z\\\")\\n)\"\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"narrow\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"apply a predicate function to output\"\n                }\n            ],\n            \"notes\": [\n                [],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"✅ go-to fallback for validation not composable via built-in types and operators\"\n                    }\n                ],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"✅ runs after all other validators and morphs, if present\"\n                    }\n                ],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"🥸\"\n                    },\n                    {\n                        \"kind\": \"link\",\n                        \"url\": \"https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates\",\n                        \"value\": \"Type predicates\"\n                    },\n                    {\n                        \"kind\": \"text\",\n                        \"value\": \"can be used as casts\"\n                    }\n                ]\n            ],\n            \"example\": \"const Palindrome = type(\\\"string\\\").narrow(s => s === [...s].reverse().join(\\\"\\\"))\\n\\nconst PalindromicEmail = type(\\\"string.date.parse\\\").narrow((date, ctx) =>\\n\\t\\tdate.getFullYear() === 2025 || ctx.mustBe(\\\"the current year\\\")\\n)\\n// Type<`${string}.tsx`>\\nconst WithPredicate = type(\\\"string\\\").narrow((s): s is `${string}.tsx` => /\\\\.tsx?$/.test(s))\"\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"pipe\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"pipe output through arbitrary transformations or other Types\"\n                }\n            ],\n            \"notes\": [],\n            \"example\": \"const User = type({ name: \\\"string\\\" })\\n\\n// parse a string and validate that the result as a user\\nconst parseUser = type(\\\"string\\\").pipe(s => JSON.parse(s), user)\"\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"to\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"parse a definition as an output validator\"\n                }\n            ],\n            \"notes\": [\n                [],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"🔗 `to({ name: \\\"string\\\" })` is equivalent to `.pipe(type({ name: \\\"string\\\" }))`\"\n                    }\n                ]\n            ],\n            \"example\": \"// parse a string and validate that the result as a user\\nconst parseUser = type(\\\"string\\\").pipe(s => JSON.parse(s)).to({ name: \\\"string\\\" })\"\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"select\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"query internal node references\"\n                }\n            ],\n            \"notes\": [],\n            \"example\": \"// [\\\"blue\\\", \\\"red\\\"]\\nconst values = type(\\\"'red' | 'blue'\\\").select(\\\"unit\\\").map(u => u.unit)\",\n            \"experimental\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"filters and returns the Type's internal representation from `@ark/schema`\"\n                }\n            ]\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"as\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"cast the way this is inferred\"\n                }\n            ],\n            \"notes\": [\n                [],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"🥸 inference-only function that does nothing runtime\"\n                    }\n                ]\n            ],\n            \"example\": \"// Type<`LEEEEEEEE${string}ROY`>\\nconst Leeroy = type(/^LE{8,}ROY$/).as<`LEEEEEEEE${string}ROY`>()\"\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"and\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"intersect the parsed Type, throwing if the result is unsatisfiable\"\n                }\n            ],\n            \"notes\": [],\n            \"example\": \"// Type<{ foo: number; bar: string }>\\nconst T = type({ foo: \\\"number\\\" }).and({ bar: \\\"string\\\" })\\n// ParseError: Intersection at foo of number and string results in an unsatisfiable type\\nconst Bad = type({ foo: \\\"number\\\" }).and({ foo: \\\"string\\\" })\"\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"or\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"union with the parsed Type\"\n                }\n            ],\n            \"notes\": [\n                [],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"⚠️ a union that could apply different morphs to the same data is a ParseError (\"\n                    },\n                    {\n                        \"kind\": \"link\",\n                        \"url\": \"https://arktype.io/docs/expressions#union-morphs\",\n                        \"value\": \"docs\"\n                    },\n                    {\n                        \"kind\": \"text\",\n                        \"value\": \")\"\n                    }\n                ]\n            ],\n            \"example\": \"// Type<string | { box: string }>\\nconst T = type(\\\"string\\\").or({ box: \\\"string\\\" })\"\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"intersect\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"intersect the parsed Type, returning an introspectable\"\n                },\n                {\n                    \"kind\": \"reference\",\n                    \"value\": \"Disjoint\"\n                },\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"if the result is unsatisfiable\"\n                }\n            ],\n            \"notes\": [],\n            \"example\": \"// Type<{ foo: number; bar: string }>\\nconst T = type({ foo: \\\"number\\\" }).intersect({ bar: \\\"string\\\" })\\nconst Bad = type(\\\"number > 10\\\").intersect(\\\"number < 5\\\")\\n// logs \\\"Intersection of > 10 and < 5 results in an unsatisfiable type\\\"\\nif (Bad instanceof Disjoint) console.log(`${bad.summary}`)\"\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"equals\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"check if the parsed Type's constraints are identical\"\n                }\n            ],\n            \"notes\": [\n                [],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"✅ equal types have identical input and output constraints and transforms\"\n                    }\n                ],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"✅ ignores associated\"\n                    },\n                    {\n                        \"kind\": \"reference\",\n                        \"value\": \"meta\"\n                    },\n                    {\n                        \"kind\": \"text\",\n                        \"value\": \", which does not affect the set of allowed values\"\n                    }\n                ]\n            ],\n            \"example\": \"const DivisibleBy6 = type.number.divisibleBy(6).moreThan(0)\\n// false (left side must also be positive)\\nDivisibleBy6.equals(\\\"number % 6\\\")\\n// false (right side has an additional <100 constraint)\\nconsole.log(DivisibleBy6.equals(\\\"0 < (number % 6) < 100\\\"))\\nconst ThirdTry = type(\\\"(number % 2) > 0\\\").divisibleBy(3)\\n// true (types are normalized and reduced)\\nconsole.log(DivisibleBy6.equals(ThirdTry))\"\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"ifEquals\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"narrow this based on an\"\n                },\n                {\n                    \"kind\": \"reference\",\n                    \"value\": \"equals\"\n                },\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"check\"\n                }\n            ],\n            \"notes\": [\n                [],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"✅ ignores associated\"\n                    },\n                    {\n                        \"kind\": \"reference\",\n                        \"value\": \"meta\"\n                    },\n                    {\n                        \"kind\": \"text\",\n                        \"value\": \", which does not affect the set of allowed values\"\n                    }\n                ]\n            ],\n            \"example\": \"const N = type.raw(`${Math.random()}`)\\n// Type<0.5> | undefined\\nconst Ez = N.ifEquals(\\\"0.5\\\")\"\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"extends\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"check if this is a subtype of the parsed Type\"\n                }\n            ],\n            \"notes\": [\n                [],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"✅ a subtype must include all constraints from the base type\"\n                    }\n                ],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"✅ unlike\"\n                    },\n                    {\n                        \"kind\": \"reference\",\n                        \"value\": \"equals\"\n                    },\n                    {\n                        \"kind\": \"text\",\n                        \"value\": \", additional constraints may be present\"\n                    }\n                ],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"✅ ignores associated\"\n                    },\n                    {\n                        \"kind\": \"reference\",\n                        \"value\": \"meta\"\n                    },\n                    {\n                        \"kind\": \"text\",\n                        \"value\": \", which does not affect the set of allowed values\"\n                    }\n                ]\n            ],\n            \"example\": \"type.string.extends(\\\"unknown\\\") // true\\ntype.string.extends(/^a.*z$/) // false\"\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"ifExtends\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"narrow this based on an\"\n                },\n                {\n                    \"kind\": \"reference\",\n                    \"value\": \"extends\"\n                },\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"check\"\n                }\n            ],\n            \"notes\": [\n                [],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"✅ ignores associated\"\n                    },\n                    {\n                        \"kind\": \"reference\",\n                        \"value\": \"meta\"\n                    },\n                    {\n                        \"kind\": \"text\",\n                        \"value\": \", which does not affect the set of allowed values\"\n                    }\n                ]\n            ],\n            \"example\": \"const N = type(Math.random() > 0.5 ? \\\"true\\\" : \\\"0\\\") // Type<0 | true>\\nconst Ez = N.ifExtends(\\\"boolean\\\") // Type<true> | undefined\"\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"overlaps\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"check if a value could satisfy this and the parsed Type\"\n                }\n            ],\n            \"notes\": [\n                [],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"⚠️ will return true unless a\"\n                    },\n                    {\n                        \"kind\": \"reference\",\n                        \"value\": \"Disjoint\"\n                    },\n                    {\n                        \"kind\": \"text\",\n                        \"value\": \"can be proven\"\n                    }\n                ]\n            ],\n            \"example\": \"type.string.overlaps(\\\"string | number\\\") // true (e.g. \\\"foo\\\")\\ntype(\\\"string | number\\\").overlaps(\\\"1\\\") // true (1)\\ntype(\\\"number > 0\\\").overlaps(\\\"number < 0\\\") // false (no values exist)\\n\\nconst NoAt = type(\\\"string\\\").narrow(s => !s.includes(\\\"@\\\"))\\nNoAt.overlaps(\\\"string.email\\\") // true (no values exist, but not provable)\"\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"extract\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"extract branches\"\n                },\n                {\n                    \"kind\": \"reference\",\n                    \"value\": \"extend\"\n                },\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"ing the parsed Type\"\n                }\n            ],\n            \"notes\": [],\n            \"example\": \"// Type<true | 0 | 2>\\nconst T = type(\\\"boolean | 0 | 'one' | 2 | bigint\\\").extract(\\\"number | 0n | true\\\")\"\n        },\n        {\n            \"group\": \"Type\",\n            \"name\": \"exclude\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"exclude branches\"\n                },\n                {\n                    \"kind\": \"reference\",\n                    \"value\": \"extend\"\n                },\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"ing the parsed Type\"\n                }\n            ],\n            \"notes\": [],\n            \"example\": \"// Type<false | 'one' | bigint>\\nconst T = type(\\\"boolean | 0 | 'one' | 2 | bigint\\\").exclude(\\\"number | 0n | true\\\")\"\n        }\n    ],\n    \"Traversal\": [\n        {\n            \"group\": \"Traversal\",\n            \"name\": \"path\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"the path being validated or morphed\"\n                }\n            ],\n            \"notes\": [\n                [],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"✅ array indices represented as numbers\"\n                    }\n                ],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"⚠️ mutated during traversal - use `path.slice(0)` to snapshot\"\n                    }\n                ],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"🔗 use\"\n                    },\n                    {\n                        \"kind\": \"reference\",\n                        \"value\": \"propString\"\n                    },\n                    {\n                        \"kind\": \"text\",\n                        \"value\": \"for a stringified version\"\n                    }\n                ]\n            ]\n        },\n        {\n            \"group\": \"Traversal\",\n            \"name\": \"errors\",\n            \"summary\": [\n                {\n                    \"kind\": \"reference\",\n                    \"value\": \"ArkErrors\"\n                },\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"that will be part of this traversal's finalized result\"\n                }\n            ],\n            \"notes\": [\n                [],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"✅ will always be an empty array for a valid traversal\"\n                    }\n                ]\n            ]\n        },\n        {\n            \"group\": \"Traversal\",\n            \"name\": \"root\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"the original value being traversed\"\n                }\n            ],\n            \"notes\": []\n        },\n        {\n            \"group\": \"Traversal\",\n            \"name\": \"config\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"configuration for this traversal\"\n                }\n            ],\n            \"notes\": [\n                [],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"✅ options can affect traversal results and error messages\"\n                    }\n                ],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"✅ defaults < global config < scope config\"\n                    }\n                ],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"✅ does not include options configured on individual types\"\n                    }\n                ]\n            ]\n        },\n        {\n            \"group\": \"Traversal\",\n            \"name\": \"reject\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"add an\"\n                },\n                {\n                    \"kind\": \"reference\",\n                    \"value\": \"ArkError\"\n                },\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"and return `false`\"\n                }\n            ],\n            \"notes\": [\n                [],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"✅ useful for predicates like `.narrow`\"\n                    }\n                ]\n            ]\n        },\n        {\n            \"group\": \"Traversal\",\n            \"name\": \"mustBe\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"add an\"\n                },\n                {\n                    \"kind\": \"reference\",\n                    \"value\": \"ArkError\"\n                },\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"from a description and return `false`\"\n                }\n            ],\n            \"notes\": [\n                [],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"✅ useful for predicates like `.narrow`\"\n                    }\n                ],\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"🔗 equivalent to\"\n                    },\n                    {\n                        \"kind\": \"reference\",\n                        \"value\": \"reject\"\n                    },\n                    {\n                        \"kind\": \"text\",\n                        \"value\": \"({ expected })\"\n                    }\n                ]\n            ]\n        },\n        {\n            \"group\": \"Traversal\",\n            \"name\": \"error\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"add and return an\"\n                },\n                {\n                    \"kind\": \"reference\",\n                    \"value\": \"ArkError\"\n                }\n            ],\n            \"notes\": [\n                [\n                    {\n                        \"kind\": \"noteStart\",\n                        \"value\": \"✅ useful for morphs like `.pipe`\"\n                    }\n                ]\n            ]\n        },\n        {\n            \"group\": \"Traversal\",\n            \"name\": \"hasError\",\n            \"summary\": [\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"whether\"\n                },\n                {\n                    \"kind\": \"reference\",\n                    \"value\": \"currentBranch\"\n                },\n                {\n                    \"kind\": \"text\",\n                    \"value\": \"(or the traversal root, outside a union) has one or more errors\"\n                }\n            ],\n            \"notes\": []\n        }\n    ]\n}\n"
  },
  {
    "path": "ark/docs/components/dts/regex.ts",
    "content": "/** THIS FILE IS AUTOGENERATED FROM ark/repo/dtsGen.ts **/\n// prettier-ignore\nexport const regexDts = \"declare module \\\"arkregex\\\" {\\n    import { DynamicBase, Scanner, parseNonNegativeInteger, ErrorMessage, NumberLiteral, noSuggest, setIndex, ZeroWidthSpace, unionKeyOf, contains, WhitespaceChar, Backslash, writeUnclosedGroupMessage, inferred } from '@ark/util';\\n\\ninterface RegexExecArray<patternAndCaptures extends IndexedCaptures, namedCaptures extends NamedCaptures, flags extends Flags> extends DynamicBase<patternAndCaptures> {\\n    /**\\n     * The index of the search at which the result was found.\\n     */\\n    index: number;\\n    /**\\n     * A copy of the search string.\\n     */\\n    input: patternAndCaptures[0];\\n    indices: flags extends `${string}d${string}` ? RegexIndicesArray<patternAndCaptures, namedCaptures> : undefined;\\n    groups: keyof namedCaptures extends never ? undefined : namedCaptures;\\n}\\ntype RegexIndexRange = [start: number, end: number];\\ninterface RegexIndicesArray<patternAndCaptures extends IndexedCaptures, namedCaptures extends NamedCaptures> extends DynamicBase<{\\n    [i in keyof patternAndCaptures]: RegexIndexRange;\\n}> {\\n    groups: keyof namedCaptures extends never ? undefined : {\\n        [k in keyof namedCaptures]: RegexIndexRange;\\n    };\\n}\\n\\ntype parseBuiltinQuantifier<s extends State, quantifier extends QuantifyingChar, unscanned extends string> = s[\\\"root\\\"] extends \\\"\\\" ? s.error<writeUnmatchedQuantifierError<quantifier>> : quantifyBuiltin<s, quantifier, unscanned extends Scanner.shift<\\\"?\\\", infer lazyUnscanned> ? lazyUnscanned : unscanned>;\\ntype quantifyBuiltin<s extends State, quantifier extends QuantifyingChar, unscanned extends string> = quantifier extends \\\"?\\\" ? s.pushQuantifier<s, 0, 1, unscanned> : quantifier extends \\\"+\\\" ? s.pushQuantifier<s, 1, null, unscanned> : quantifier extends \\\"*\\\" ? s.pushQuantifier<s, 0, null, unscanned> : never;\\ntype ParsedRange = {\\n    min: number;\\n    max: number | null;\\n    unscanned: string;\\n};\\ndeclare namespace ParsedRange {\\n    type from<r extends ParsedRange> = r;\\n}\\ntype skipPossibleQuestionMark<unscanned extends string> = unscanned extends `?${infer next}` ? next : unscanned;\\ntype parsePossibleRangeString<unscanned extends string> = unscanned extends (`${infer l extends `${number}`},${infer r extends `${number}`}}${infer next}`) ? ParsedRange.from<{\\n    min: parseNonNegativeInteger<l>;\\n    max: parseNonNegativeInteger<r>;\\n    unscanned: skipPossibleQuestionMark<next>;\\n}> : unscanned extends `${infer l extends `${number}`},}${infer next}` ? ParsedRange.from<{\\n    min: parseNonNegativeInteger<l>;\\n    max: null;\\n    unscanned: skipPossibleQuestionMark<next>;\\n}> : unscanned extends `${infer l extends `${number}`}}${infer next}` ? ParsedRange.from<{\\n    min: parseNonNegativeInteger<l>;\\n    max: parseNonNegativeInteger<l>;\\n    unscanned: skipPossibleQuestionMark<next>;\\n}> : null;\\ntype parseQuantifier<unscanned extends string, parsed extends ParsedRange> = unscanned extends `${infer range}${parsed[\\\"unscanned\\\"]}` ? `{${range}` : never;\\ntype parsePossibleRange<s extends State, unscanned extends string, parsed extends ParsedRange | null = parsePossibleRangeString<unscanned>> = parsed extends ParsedRange ? s[\\\"root\\\"] extends \\\"\\\" ? s.error<writeUnmatchedQuantifierError<parseQuantifier<unscanned, parsed>>> : [parsed[\\\"min\\\"], parsed[\\\"max\\\"]] extends ([\\n    never,\\n    unknown\\n] | [unknown, never]) ? s.error<writeUnnaturalNumberQuantifierError<parseQuantifier<unscanned, parsed>>> : s.pushQuantifier<s, parsed[\\\"min\\\"], parsed[\\\"max\\\"], parsed[\\\"unscanned\\\"] extends Scanner.shift<\\\"?\\\", infer lazyUnscanned> ? lazyUnscanned : parsed[\\\"unscanned\\\"]> : s.shiftQuantifiable<s, \\\"{\\\", unscanned>;\\ntype quantify<pattern extends string, min extends number, max extends number | null> = tryFastPath<pattern, min, max>;\\ntype tryFastPath<pattern extends string, min extends number, max extends number | null> = max extends 0 ? \\\"\\\" : string extends pattern ? string : `${number}` extends pattern ? `${number}` : min extends 0 ? max extends 1 ? \\\"\\\" | pattern : max extends number ? loopFromZero<pattern, max, \\\"\\\", []> : // max is null, all we can do is append ${string}\\n\\\"\\\" | `${pattern}${string}` : loopUntilMin<pattern, min, max, \\\"\\\", []>;\\ntype loopFromZero<base extends string, max extends number, acc extends string, repetitions extends 1[]> = repetitions[\\\"length\\\"] extends max ? acc : loopFromZero<base, max, acc | `${acc}${base}`, [...repetitions, 1]>;\\ntype loopUntilMin<base extends string, min extends number, max extends number | null, acc extends string, repetitions extends 1[]> = repetitions[\\\"length\\\"] extends min ? max extends number ? loopUntilMax<base, min, max, acc, repetitions> : repetitions[\\\"length\\\"] extends 0 ? acc | `${acc}${base}${string}` : `${acc}${string}` : loopUntilMin<base, min, max, `${acc}${base}`, [...repetitions, 1]>;\\ntype loopUntilMax<base extends string, min extends number, max extends number, acc extends string, repetitions extends 1[]> = repetitions[\\\"length\\\"] extends max ? acc : loopUntilMax<base, min, max, acc | `${acc}${base}`, [...repetitions, 1]>;\\ntype QuantifyingChar = \\\"*\\\" | \\\"+\\\" | \\\"?\\\";\\ndeclare const writeUnmatchedQuantifierError: <quantifier extends string>(quantifier: quantifier) => writeUnmatchedQuantifierError<quantifier>;\\ntype writeUnmatchedQuantifierError<quantifier extends string> = `Quantifier ${quantifier} requires a preceding token`;\\ndeclare const writeUnnaturalNumberQuantifierError: <quantifier extends string>(quantifier: quantifier) => writeUnnaturalNumberQuantifierError<quantifier>;\\ntype writeUnnaturalNumberQuantifierError<quantifier extends string> = `Quantifier ${quantifier} must use natural numbers`;\\n\\ninterface State extends State.Group {\\n    unscanned: string;\\n    groups: State.Group[];\\n    /** the initial flags passed to the root of the expression */\\n    flags: Flags;\\n}\\ndeclare namespace State {\\n    type from<s extends State> = s;\\n    type initialize<source extends string, flags extends Flags> = from<{\\n        unscanned: source;\\n        groups: [];\\n        capture: never;\\n        branches: [];\\n        sequence: SequenceTree.Empty;\\n        root: \\\"\\\";\\n        caseInsensitive: contains<flags, \\\"i\\\">;\\n        flags: flags;\\n    }>;\\n    enum UnnamedCaptureKind {\\n        indexed,\\n        lookaround,\\n        noncapturing\\n    }\\n    type CaptureKind = string | UnnamedCaptureKind;\\n    type Group = {\\n        /** the name of the group or its kind */\\n        capture: CaptureKind;\\n        branches: RegexAst[];\\n        sequence: RegexAst;\\n        root: RegexAst;\\n        caseInsensitive: boolean;\\n    };\\n    namespace Group {\\n        type from<g extends Group> = g;\\n        type pop<init extends Group, last extends Group[]> = [...last, init];\\n        type finalize<g extends Group> = g[\\\"branches\\\"] extends [] ? pushQuantifiable<g[\\\"sequence\\\"], g[\\\"root\\\"]> : [...g[\\\"branches\\\"], pushQuantifiable<g[\\\"sequence\\\"], g[\\\"root\\\"]>] extends (infer branches extends RegexAst[]) ? finalizeUnion<branches, []> : never;\\n        type finalizeUnion<remaining extends RegexAst[], flattened extends RegexAst[]> = remaining extends ([\\n            infer head extends RegexAst,\\n            ...infer tail extends RegexAst[]\\n        ]) ? head extends UnionTree<infer headBranches> ? finalizeUnion<tail, [...flattened, ...headBranches]> : finalizeUnion<tail, [...flattened, head]> : UnionTree<flattened>;\\n    }\\n}\\ntype Boundary = Anchor | \\\"(\\\" | \\\")\\\" | \\\"[\\\" | \\\"]\\\";\\ntype Anchor = \\\"^\\\" | \\\"$\\\";\\ntype Control = QuantifyingChar | Boundary | \\\"|\\\" | \\\".\\\" | \\\"{\\\" | \\\"-\\\" | \\\"\\\\\\\\\\\";\\ntype AnchorMarker<inner extends Anchor = Anchor> = `<${ZeroWidthSpace}${inner}${ZeroWidthSpace}>`;\\ntype StartAnchorMarker = AnchorMarker<\\\"^\\\">;\\ntype EndAnchorMarker = AnchorMarker<\\\"$\\\">;\\ntype RegexAst = string | ReferenceNode | UnionTree | SequenceTree | GroupTree | QuantifierTree;\\ninterface ReferenceNode<to extends string = string> {\\n    kind: \\\"reference\\\";\\n    to: to;\\n}\\ndeclare namespace ReferenceNode {\\n    type finalize<self extends ReferenceNode, ctx extends FinalizationContext, to extends string = self[\\\"to\\\"]> = to extends NumberLiteral & keyof ctx[\\\"captures\\\"] ? ctx[\\\"captures\\\"][to] extends IncompleteCaptureGroup ? FinalizationResult.error<ctx, writeIncompleteReferenceError<to>> : FinalizationResult.from<{\\n        pattern: inferReference<ctx[\\\"captures\\\"][to]>;\\n        ctx: ctx;\\n    }> : to extends keyof ctx[\\\"names\\\"] ? ctx[\\\"names\\\"][to] extends IncompleteCaptureGroup ? FinalizationResult.error<ctx, writeIncompleteReferenceError<to>> : FinalizationResult.from<{\\n        pattern: inferReference<ctx[\\\"names\\\"][to]>;\\n        ctx: ctx;\\n    }> : FinalizationResult.error<ctx, writeUnresolvableBackreferenceMessage<to>>;\\n    type inferReference<to extends string | undefined> = to extends string ? to : \\\"\\\";\\n}\\ndeclare const writeIncompleteReferenceError: <ref extends string>(ref: ref) => writeIncompleteReferenceError<ref>;\\ntype writeIncompleteReferenceError<ref extends string> = `Reference to incomplete group '${ref}' has no effect`;\\ninterface SequenceTree<ast extends RegexAst[] = RegexAst[]> {\\n    kind: \\\"sequence\\\";\\n    ast: ast;\\n}\\ndeclare namespace SequenceTree {\\n    type Empty = SequenceTree<[]>;\\n    type finalize<self extends SequenceTree, ctx extends FinalizationContext> = _finalize<self[\\\"ast\\\"], \\\"\\\", ctx>;\\n    type _finalize<tree extends unknown[], pattern extends string, ctx extends FinalizationContext> = tree extends [infer head, ...infer tail] ? finalizeTree<head, ctx> extends infer r ? r extends FinalizationResult ? _finalize<tail, appendNonRedundant<pattern, r[\\\"pattern\\\"]>, r[\\\"ctx\\\"]> : never : never : FinalizationResult.from<{\\n        pattern: pattern;\\n        ctx: ctx;\\n    }>;\\n}\\ninterface UnionTree<ast extends RegexAst[] = RegexAst[]> {\\n    kind: \\\"union\\\";\\n    ast: ast;\\n}\\ndeclare namespace UnionTree {\\n    type finalize<self extends UnionTree, ctx extends FinalizationContext> = _finalize<self[\\\"ast\\\"], [], ctx>;\\n    type FinalizedBranch = {\\n        pattern: string;\\n        captures: IndexedCaptures;\\n        names: NamedCaptures;\\n    };\\n    namespace FinalizedBranch {\\n        type from<b extends FinalizedBranch> = b;\\n    }\\n    type _finalize<astBranches extends unknown[], acc extends FinalizedBranch[], ctx extends FinalizationContext> = astBranches extends [infer head, ...infer tail] ? finalizeTree<head, ctx> extends infer r ? r extends FinalizationResult ? _finalize<tail, finalizeBranch<acc, ctx, r>, ctx> : never : never : finalizeBranches<keyof acc, acc, ctx>;\\n    type finalizeBranch<acc extends FinalizedBranch[], ctx extends FinalizationContext, r extends FinalizationResult> = [\\n        ...acc,\\n        FinalizedBranch.from<{\\n            pattern: r[\\\"pattern\\\"];\\n            captures: finalizeBranchCaptures<acc, ctx, r>;\\n            names: r[\\\"ctx\\\"][\\\"names\\\"];\\n        }>\\n    ];\\n    type finalizeBranchCaptures<acc extends FinalizedBranch[], ctx extends FinalizationContext, r extends FinalizationResult, branchCaptures extends IndexedCaptures = extractNewCaptures<ctx[\\\"captures\\\"], r[\\\"ctx\\\"][\\\"captures\\\"]>> = acc extends [] ? branchCaptures : acc[0][\\\"captures\\\"] extends (infer firstCaptureBranch extends IndexedCaptures) ? branchCaptures extends [] ? {\\n        [i in keyof firstCaptureBranch]: undefined;\\n    } : [...{\\n        [i in keyof firstCaptureBranch]: undefined;\\n    }, ...branchCaptures] : never;\\n    type finalizeBranches<i, acc extends FinalizedBranch[], ctx extends FinalizationContext> = i extends keyof acc & NumberLiteral ? FinalizationResult.from<{\\n        pattern: acc[i][\\\"pattern\\\"];\\n        ctx: {\\n            flags: ctx[\\\"flags\\\"];\\n            captures: [...ctx[\\\"captures\\\"], ...acc[i][\\\"captures\\\"]];\\n            names: {\\n                [k in unionKeyOf<acc[number][\\\"names\\\"]>]: k extends (keyof acc[i][\\\"names\\\"]) ? acc[i][\\\"names\\\"][k] : undefined;\\n            };\\n            errors: ctx[\\\"errors\\\"];\\n        };\\n    }> : never;\\n}\\ntype CapturedGroupKind = string | State.UnnamedCaptureKind.indexed;\\ntype IncompleteCaptureGroup = noSuggest<\\\"incompleteCaptureGroup\\\">;\\ninterface GroupTree<ast extends RegexAst = RegexAst, capture extends CapturedGroupKind = CapturedGroupKind> {\\n    kind: \\\"group\\\";\\n    capture: capture;\\n    ast: ast;\\n}\\ndeclare namespace GroupTree {\\n    type finalize<self extends GroupTree, ctx extends FinalizationContext> = finalizeGroupAst<self, ctx> extends infer r ? r extends FinalizationResult ? finalizeGroupResult<self, ctx, r> : never : never;\\n    type finalizeGroupAst<self extends GroupTree, ctx extends FinalizationContext> = finalizeTree<self[\\\"ast\\\"], self[\\\"capture\\\"] extends string ? {\\n        captures: [...ctx[\\\"captures\\\"], IncompleteCaptureGroup];\\n        names: ctx[\\\"names\\\"] & {\\n            [_ in self[\\\"capture\\\"]]: IncompleteCaptureGroup;\\n        };\\n        flags: ctx[\\\"flags\\\"];\\n        errors: ctx[\\\"errors\\\"];\\n    } : self[\\\"capture\\\"] extends State.UnnamedCaptureKind.indexed ? {\\n        captures: [...ctx[\\\"captures\\\"], IncompleteCaptureGroup];\\n        names: ctx[\\\"names\\\"];\\n        flags: ctx[\\\"flags\\\"];\\n        errors: ctx[\\\"errors\\\"];\\n    } : ctx>;\\n    type finalizeGroupResult<self extends GroupTree, ctx extends FinalizationContext, r extends FinalizationResult> = FinalizationResult.from<{\\n        pattern: r[\\\"pattern\\\"];\\n        ctx: self[\\\"capture\\\"] extends string ? finalizeNamedCapture<self[\\\"capture\\\"], ctx[\\\"captures\\\"][\\\"length\\\"], r[\\\"pattern\\\"], r[\\\"ctx\\\"]> : self[\\\"capture\\\"] extends State.UnnamedCaptureKind.indexed ? finalizeUnnamedCapture<ctx[\\\"captures\\\"][\\\"length\\\"], r[\\\"pattern\\\"], r[\\\"ctx\\\"]> : r[\\\"ctx\\\"];\\n    }>;\\n    type finalizeNamedCapture<name extends string, index extends number, pattern extends string, ctx extends FinalizationContext> = FinalizationContext.from<{\\n        captures: setIndex<ctx[\\\"captures\\\"], index, anchorsAway<pattern>>;\\n        names: {\\n            [k in keyof ctx[\\\"names\\\"]]: k extends name ? anchorsAway<pattern> : ctx[\\\"names\\\"][k];\\n        };\\n        flags: ctx[\\\"flags\\\"];\\n        errors: ctx[\\\"errors\\\"];\\n    }>;\\n    type finalizeUnnamedCapture<index extends number, pattern extends string, ctx extends FinalizationContext> = FinalizationContext.from<{\\n        captures: setIndex<ctx[\\\"captures\\\"], index, anchorsAway<pattern>>;\\n        names: ctx[\\\"names\\\"];\\n        flags: ctx[\\\"flags\\\"];\\n        errors: ctx[\\\"errors\\\"];\\n    }>;\\n}\\ninterface QuantifierTree<ast extends RegexAst = RegexAst> {\\n    kind: \\\"quantifier\\\";\\n    ast: ast;\\n    min: number;\\n    max: number | null;\\n}\\ndeclare namespace QuantifierTree {\\n    type finalize<self extends QuantifierTree, ctx extends FinalizationContext> = finalizeTree<self[\\\"ast\\\"], ctx> extends infer r extends FinalizationResult ? finalizeQuantifierResult<self, ctx, r> : never;\\n    type finalizeQuantifierResult<self extends QuantifierTree, ctx extends FinalizationContext, r extends FinalizationResult, quantifiedCaptures extends IndexedCaptures = extractNewCaptures<ctx[\\\"captures\\\"], r[\\\"ctx\\\"][\\\"captures\\\"]>> = self[\\\"min\\\"] extends 0 ? quantifiedCaptures extends [] ? finalizeNonZeroMinQuantified<self, r> : finalizeZeroMinQuantifiedWithCaptures<self, ctx, r, quantifiedCaptures> : finalizeNonZeroMinQuantified<self, r>;\\n    type finalizeNonZeroMinQuantified<self extends QuantifierTree, r extends FinalizationResult> = FinalizationResult.from<{\\n        pattern: quantify<r[\\\"pattern\\\"], self[\\\"min\\\"], self[\\\"max\\\"]>;\\n        ctx: r[\\\"ctx\\\"];\\n    }>;\\n    type finalizeZeroMinQuantifiedWithCaptures<self extends QuantifierTree, ctx extends FinalizationContext, r extends FinalizationResult, quantifiedCaptures extends IndexedCaptures> = finalizeZeroQuantified<ctx, r, quantifiedCaptures> | finalizeOnePlusQuantified<self[\\\"max\\\"], r>;\\n    type finalizeZeroQuantified<ctx extends FinalizationContext, r extends FinalizationResult, quantifiedCaptures extends IndexedCaptures> = FinalizationResult.from<{\\n        pattern: \\\"\\\";\\n        ctx: {\\n            captures: [\\n                ...ctx[\\\"captures\\\"],\\n                ...{\\n                    [i in keyof quantifiedCaptures]: undefined;\\n                }\\n            ];\\n            flags: r[\\\"ctx\\\"][\\\"flags\\\"];\\n            names: zeroQuantifiedNames<ctx[\\\"names\\\"], r[\\\"ctx\\\"][\\\"names\\\"]>;\\n            errors: r[\\\"ctx\\\"][\\\"errors\\\"];\\n        };\\n    }>;\\n    type zeroQuantifiedNames<base extends NamedCaptures, result extends NamedCaptures> = {\\n        [k in keyof result]: k extends keyof base ? result[k] : undefined;\\n    } & unknown;\\n    type finalizeOnePlusQuantified<max extends number | null, r extends FinalizationResult> = max extends 1 ? r : FinalizationResult.from<{\\n        pattern: quantify<r[\\\"pattern\\\"], 1, max>;\\n        ctx: r[\\\"ctx\\\"];\\n    }>;\\n}\\ntype pushQuantifiable<sequence extends RegexAst, root extends RegexAst> = root extends \\\"\\\" ? sequence : sequence extends string ? sequence extends \\\"\\\" ? root : root extends string ? appendNonRedundant<sequence, root> : SequenceTree<[sequence, root]> : sequence extends SequenceTree ? pushToSequence<sequence, root> : SequenceTree<[sequence, root]>;\\ntype pushToSequence<sequence extends SequenceTree, root extends RegexAst> = sequence extends SequenceTree.Empty ? root : root extends SequenceTree ? SequenceTree<[...sequence[\\\"ast\\\"], ...root[\\\"ast\\\"]]> : SequenceTree<[...sequence[\\\"ast\\\"], root]>;\\ntype extractNewCaptures<base extends IndexedCaptures, result extends IndexedCaptures> = result extends readonly [...base, ...infer elements extends IndexedCaptures] ? elements : [];\\ninterface FinalizationContext extends Required<RegexContext> {\\n    errors: ErrorMessage[];\\n}\\ndeclare namespace FinalizationContext {\\n    type from<ctx extends FinalizationContext> = ctx;\\n}\\ntype FinalizationResult = {\\n    pattern: string;\\n    ctx: FinalizationContext;\\n};\\ndeclare namespace FinalizationResult {\\n    type from<r extends FinalizationResult> = r;\\n    type error<ctx extends FinalizationContext, message extends string> = from<{\\n        pattern: string;\\n        ctx: {\\n            captures: ctx[\\\"captures\\\"];\\n            names: ctx[\\\"names\\\"];\\n            flags: ctx[\\\"flags\\\"];\\n            errors: [...ctx[\\\"errors\\\"], ErrorMessage<message>];\\n        };\\n    }>;\\n}\\ntype finalizeTree<tree, ctx extends FinalizationContext> = tree extends string ? FinalizationResult.from<{\\n    pattern: tree;\\n    ctx: ctx;\\n}> : tree extends SequenceTree ? SequenceTree.finalize<tree, ctx> : tree extends UnionTree ? UnionTree.finalize<tree, ctx> : tree extends GroupTree ? GroupTree.finalize<tree, ctx> : tree extends QuantifierTree ? QuantifierTree.finalize<tree, ctx> : tree extends ReferenceNode ? ReferenceNode.finalize<tree, ctx> : never;\\ntype anchorsAway<pattern extends string> = pattern extends `${StartAnchorMarker}${infer startStripped}` ? startStripped extends `${infer bothStripped}${EndAnchorMarker}` ? bothStripped : startStripped : pattern extends `${infer endStripped}${EndAnchorMarker}` ? endStripped : pattern;\\ntype appendNonRedundant<base extends string, suffix extends string> = string extends base ? string extends suffix ? string : `${base}${suffix}` : `${number}` extends base ? `${number}` extends suffix ? `${number}` : `${base}${suffix}` : `${base}${suffix}`;\\n\\ntype parseEscape<s extends State, unscanned extends string> = unscanned extends Scanner.shift<infer char, infer nextUnscanned> ? char extends NonZeroDigit ? parseNumericBackreference<s, unscanned> : char extends \\\"k\\\" ? parseNamedBackreference<s, nextUnscanned> : char extends UnicodePropertyChar ? parseUnicodeProperty<s, char, nextUnscanned> : parseSingleEscapedCharacter<s, char, nextUnscanned> : s.error<trailingBackslashMessage>;\\ntype parseNumericBackreference<s extends State, fullUnscanned extends string> = Scanner.shiftUntilNot<fullUnscanned, StringDigit> extends (Scanner.shiftResult<infer ref, infer remaining>) ? s.shiftQuantifiable<s, ReferenceNode<ref>, remaining> : never;\\ntype parseNamedBackreference<s extends State, unscanned extends string> = unscanned extends `<${infer ref}>${infer following}` ? s.shiftQuantifiable<s, ReferenceNode<ref>, following> : s.error<missingBackreferenceNameMessage>;\\ntype parseUnicodeProperty<s extends State, char extends UnicodePropertyChar, unscanned extends string> = unscanned extends `{${string}}${infer following}` ? s.shiftQuantifiable<s, string, following> : s.error<writeInvalidUnicodePropertyMessage<char>>;\\ntype parseSingleEscapedCharacter<s extends State, char extends string, remaining extends string> = parseEscapedChar<char> extends infer result extends string ? result extends ErrorMessage ? s.error<result> : s.shiftQuantifiable<s, result, remaining> : never;\\ntype parseEscapedChar<char extends string> = char extends RegexClassChar ? string : char extends \\\"d\\\" ? `${number}` : char extends \\\"s\\\" ? WhitespaceChar : char extends BoundaryChar ? \\\"\\\" : char extends Control ? char : char extends \\\"c\\\" ? ErrorMessage<caretNotationMessage> : char extends StringEscapableChar ? ErrorMessage<writeStringEscapableMessage<char>> : ErrorMessage<writeUnnecessaryEscapeMessage<char>>;\\ndeclare const trailingBackslashMessage = \\\"A regex cannot end with \\\\\\\\\\\";\\ntype trailingBackslashMessage = typeof trailingBackslashMessage;\\ndeclare const writeUnresolvableBackreferenceMessage: <ref extends string | number>(ref: ref) => writeUnresolvableBackreferenceMessage<ref>;\\ntype writeUnresolvableBackreferenceMessage<ref extends string | number> = `Group ${ref} does not exist`;\\ndeclare const missingBackreferenceNameMessage = \\\"\\\\\\\\k must be followed by a named reference like <name>\\\";\\ntype missingBackreferenceNameMessage = typeof missingBackreferenceNameMessage;\\ndeclare const writeInvalidUnicodePropertyMessage: <char extends UnicodePropertyChar>(char: char) => writeInvalidUnicodePropertyMessage<char>;\\ntype writeInvalidUnicodePropertyMessage<char extends UnicodePropertyChar> = `\\\\\\\\${char} must be followed by a property like \\\\\\\\${char}{Emoji_Presentation}`;\\ndeclare const writeUnnecessaryEscapeMessage: <char extends string>(char: char) => writeUnnecessaryEscapeMessage<char>;\\ntype writeUnnecessaryEscapeMessage<char extends string> = `Escape preceding ${char} is unnecessary and should be removed.`;\\ndeclare const writeStringEscapableMessage: (char: StringEscapableChar) => \\\"\\\\\\\\f should be specified with a single backslash like regex('\\\\\\\\n')\\\" | \\\"\\\\\\\\n should be specified with a single backslash like regex('\\\\\\\\n')\\\" | \\\"\\\\\\\\r should be specified with a single backslash like regex('\\\\\\\\n')\\\" | \\\"\\\\\\\\t should be specified with a single backslash like regex('\\\\\\\\n')\\\" | \\\"\\\\\\\\u should be specified with a single backslash like regex('\\\\\\\\n')\\\" | \\\"\\\\\\\\v should be specified with a single backslash like regex('\\\\\\\\n')\\\" | \\\"\\\\\\\\x should be specified with a single backslash like regex('\\\\\\\\n')\\\" | \\\"\\\\\\\\0 should be specified with a single backslash like regex('\\\\\\\\n')\\\";\\ntype writeStringEscapableMessage<char extends StringEscapableChar> = `\\\\\\\\${char} should be specified with a single backslash like regex('\\\\n')`;\\ndeclare const caretNotationMessage = \\\"\\\\\\\\\\\\\\\\cX notation is not supported. Use hex (\\\\\\\\\\\\\\\\x) or unicode (\\\\\\\\\\\\\\\\u) instead.\\\";\\ntype caretNotationMessage = \\\"\\\\\\\\cX notation is not supported. Use hex (\\\\\\\\x) or unicode (\\\\\\\\u) instead.\\\";\\ntype StringEscapableChar = \\\"t\\\" | \\\"n\\\" | \\\"r\\\" | \\\"f\\\" | \\\"v\\\" | \\\"0\\\" | \\\"x\\\" | \\\"u\\\";\\ntype RegexClassChar = \\\"w\\\" | \\\"W\\\" | \\\"D\\\" | \\\"S\\\";\\ntype BoundaryChar = \\\"b\\\" | \\\"B\\\";\\ntype UnicodePropertyChar = \\\"p\\\" | \\\"P\\\";\\ntype NonZeroDigit = \\\"1\\\" | \\\"2\\\" | \\\"3\\\" | \\\"4\\\" | \\\"5\\\" | \\\"6\\\" | \\\"7\\\" | \\\"8\\\" | \\\"9\\\";\\ntype StringDigit = \\\"0\\\" | NonZeroDigit;\\n\\ntype parseCharset<s extends State, unscanned extends string> = Scanner.shiftUntilEscapable<unscanned, \\\"]\\\", Backslash> extends (Scanner.shiftResult<infer scanned, infer nextUnscanned>) ? nextUnscanned extends `]${infer remaining}` ? scanned extends Scanner.shift<\\\"^\\\", string> ? s.shiftQuantifiable<s, string, remaining> : parseNonNegatedCharset<scanned, never, null> extends (infer result extends string) ? [\\n    result\\n] extends [never] ? s.error<emptyCharacterSetMessage> : s.shiftQuantifiable<s, result, remaining> : never : s.error<writeUnclosedGroupMessage<\\\"]\\\">> : never;\\ntype parseNonNegatedCharset<chars extends string, set extends string, lastChar extends string | null> = parseChar<chars> extends Scanner.shiftResult<infer result, infer unscanned> ? result extends UnescapedDashMarker ? parseDash<unscanned, set, lastChar> : result extends ErrorMessage ? result : parseNonNegatedCharset<unscanned, set | result, result> : set;\\ntype parseDash<unscanned extends string, set extends string, lastChar extends string | null> = lastChar extends string ? parseChar<unscanned> extends (Scanner.shiftResult<infer rangeEnd, infer next>) ? parseNonNegatedCharset<next, set | inferRange<lastChar, rangeEnd>, null> : // trailing -, treat as literal\\nset | \\\"-\\\" : parseNonNegatedCharset<unscanned, set | \\\"-\\\", \\\"-\\\">;\\ntype inferRange<start extends string, end extends string> = start | end extends StringDigit ? `${number}` : string;\\ntype UnescapedDashMarker = noSuggest<\\\"dash\\\">;\\ntype parseChar<unscanned extends string> = unscanned extends Scanner.shift<infer lookahead, infer next> ? lookahead extends Backslash ? next extends Scanner.shift<infer escaped, infer postEscaped> ? Scanner.shiftResult<parseEscapedChar<escaped>, postEscaped> : never : Scanner.shiftResult<lookahead extends \\\"-\\\" ? UnescapedDashMarker : lookahead, next> : null;\\ndeclare const emptyCharacterSetMessage = \\\"Empty character set [] is unsatisfiable\\\";\\ntype emptyCharacterSetMessage = typeof emptyCharacterSetMessage;\\n\\ntype LookaroundChar = \\\"=\\\" | \\\"!\\\";\\ntype ModifiableFlag = \\\"i\\\" | \\\"m\\\" | \\\"s\\\";\\ntype parseGroup<s extends State, unscanned extends string> = unscanned extends Scanner.shift<infer lookahead, infer next> ? lookahead extends \\\"?\\\" ? parseNonCapturingGroup<s, next> : s.pushGroup<s, State.UnnamedCaptureKind.indexed, unscanned, undefined> : s.error<writeUnclosedGroupMessage<\\\")\\\">>;\\ntype parseNonCapturingGroup<s extends State, unscanned extends string> = unscanned extends Scanner.shift<infer lookahead, infer next> ? lookahead extends \\\":\\\" ? s.pushGroup<s, State.UnnamedCaptureKind.noncapturing, next, undefined> : lookahead extends LookaroundChar ? s.pushGroup<s, State.UnnamedCaptureKind.lookaround, next, undefined> : lookahead extends \\\"<\\\" ? parseNamedGroupOrLookbehind<s, next> : shiftModifiers<unscanned> extends (ShiftedModifiers<infer flags, infer negated, infer following>) ? following extends ErrorMessage<infer message> ? s.error<message> : s.pushGroup<s, State.UnnamedCaptureKind.noncapturing, following, \\\"i\\\" extends flags ? true : \\\"i\\\" extends negated ? false : undefined> : never : s.error<writeUnclosedGroupMessage<\\\")\\\">>;\\ntype ShiftedModifiers<flags extends ModifiableFlag = ModifiableFlag, negated extends ModifiableFlag = ModifiableFlag, unscanned extends string = string> = [ParsedModifiers<flags, negated>, unscanned];\\ntype ParsedModifiers<flags extends ModifiableFlag = ModifiableFlag, negated extends ModifiableFlag = ModifiableFlag> = {\\n    flags: flags;\\n    negated: negated;\\n};\\ntype shiftModifiers<unscanned extends string> = Scanner.shiftUntil<unscanned, \\\":\\\" | \\\")\\\"> extends (Scanner.shiftResult<infer scanned, infer next>) ? next extends Scanner.shift<infer terminator, infer following> ? terminator extends \\\":\\\" ? parseModifiers<scanned> extends (ParsedModifiers<infer flags, infer negated>) ? ShiftedModifiers<flags, negated, following> : ShiftedModifiers<never, never, ErrorMessage<parseModifiers<scanned> & string>> : ShiftedModifiers<never, never, ErrorMessage<unescapedLiteralQuestionMarkMessage>> : ShiftedModifiers<never, never, ErrorMessage<writeUnclosedGroupMessage<\\\")\\\">>> : never;\\ntype parseModifiers<unscanned extends string> = _parseModifiers<unscanned, never, never>;\\ntype _parseModifiers<unscanned extends string, flags extends ModifiableFlag, negated extends ModifiableFlag> = unscanned extends Scanner.shift<infer lookahead, infer next> ? lookahead extends \\\"-\\\" ? [\\n    negated\\n] extends [never] ? next extends Scanner.shift<infer modifier, infer next> ? modifier extends ModifiableFlag ? modifier extends flags | negated ? writeDuplicateModifierMessage<modifier> : _parseModifiers<next, flags, negated | modifier> : writeInvalidModifierMessage<modifier> : missingNegatedModifierMessage : multipleModifierDashesMessage : lookahead extends ModifiableFlag ? lookahead extends flags | negated ? writeDuplicateModifierMessage<lookahead> : [\\n    negated\\n] extends [never] ? _parseModifiers<next, flags | lookahead, negated> : _parseModifiers<next, flags, negated | lookahead> : writeInvalidModifierMessage<lookahead> : ParsedModifiers<flags, negated>;\\ndeclare const writeDuplicateModifierMessage: <modifier extends ModifiableFlag>(modifier: modifier) => writeDuplicateModifierMessage<modifier>;\\ntype writeDuplicateModifierMessage<modifier extends ModifiableFlag> = `Modifier ${modifier} cannot appear multiple times in a single group`;\\ndeclare const multipleModifierDashesMessage = \\\"Modifiers can include at most one '-' to negate subsequent flags\\\";\\ntype multipleModifierDashesMessage = typeof multipleModifierDashesMessage;\\ndeclare const missingNegatedModifierMessage = \\\"- must be followed by the modifier flag to negate ('i', 'm' or 's')\\\";\\ntype missingNegatedModifierMessage = typeof missingNegatedModifierMessage;\\ndeclare const writeInvalidModifierMessage: <char extends string>(char: char) => writeInvalidModifierMessage<char>;\\ntype writeInvalidModifierMessage<char extends string> = `Modifier flag ${char} must be 'i', 'm' or 's'`;\\ntype parseNamedGroupOrLookbehind<s extends State, unscanned extends string> = unscanned extends Scanner.shift<LookaroundChar, infer next> ? s.pushGroup<s, State.UnnamedCaptureKind.lookaround, next, undefined> : shiftNamedGroup<unscanned> extends (Scanner.shiftResult<infer name, infer following>) ? s.pushGroup<s, name, following, undefined> : s.error<writeUnclosedGroupMessage<\\\")\\\">>;\\ntype shiftNamedGroup<unscanned extends string> = unscanned extends `${infer name}>${infer next}` ? name extends \\\"\\\" ? Scanner.shiftResult<\\\"\\\", ErrorMessage<unnamedCaptureGroupMessage>> : Scanner.shiftResult<name, next> : Scanner.shiftResult<\\\"\\\", ErrorMessage<writeUnclosedGroupMessage<\\\">\\\">>>;\\ndeclare const unnamedCaptureGroupMessage = \\\"Capture group <> requires a name\\\";\\ntype unnamedCaptureGroupMessage = typeof unnamedCaptureGroupMessage;\\ndeclare const unescapedLiteralQuestionMarkMessage = \\\"literal ? must be escaped at the start of a group\\\";\\ntype unescapedLiteralQuestionMarkMessage = typeof unescapedLiteralQuestionMarkMessage;\\n\\ntype parseState<s extends State> = s[\\\"unscanned\\\"] extends ErrorMessage ? s[\\\"unscanned\\\"] : s[\\\"unscanned\\\"] extends \\\"\\\" ? s.finalize<s> : parseState<next<s>>;\\ntype next<s extends State> = s[\\\"unscanned\\\"] extends Scanner.shift<infer lookahead, infer unscanned> ? lookahead extends \\\".\\\" ? s.shiftQuantifiable<s, string, unscanned> : lookahead extends Backslash ? parseEscape<s, unscanned> : lookahead extends \\\"|\\\" ? s.finalizeBranch<s, unscanned> : lookahead extends Anchor ? s.anchor<s, AnchorMarker<lookahead>, unscanned> : lookahead extends \\\"(\\\" ? parseGroup<s, unscanned> : lookahead extends \\\")\\\" ? s.popGroup<s, unscanned> : lookahead extends QuantifyingChar ? parseBuiltinQuantifier<s, lookahead, unscanned> : lookahead extends \\\"{\\\" ? parsePossibleRange<s, unscanned> : lookahead extends \\\"[\\\" ? parseCharset<s, unscanned> : s.shiftQuantifiable<s, maybeSplitCasing<s[\\\"caseInsensitive\\\"], lookahead>, unscanned> : never;\\ntype maybeSplitCasing<caseInsensitive extends boolean, char extends string> = caseInsensitive extends false ? char : Lowercase<char> extends Uppercase<char> ? char : UnionTree<[Lowercase<char>, Capitalize<char>]>;\\n\\ntype IndexedCaptures = Array<string | undefined>;\\ntype NamedCaptures = Record<string, string | undefined>;\\ntype UnicodeFlag = \\\"v\\\" | \\\"u\\\";\\ntype Flags = `${\\\"d\\\" | \\\"\\\"}${\\\"g\\\" | \\\"\\\"}${\\\"i\\\" | \\\"\\\"}${\\\"m\\\" | \\\"\\\"}${\\\"s\\\" | \\\"\\\"}${UnicodeFlag | \\\"\\\"}${\\\"y\\\" | \\\"\\\"}`;\\ntype RegexContext = {\\n    flags?: Flags;\\n    captures?: IndexedCaptures;\\n    names?: NamedCaptures;\\n};\\ninterface Regex<out pattern extends string = string, out ctx extends RegexContext = RegexContext> extends RegExp {\\n    [inferred]: pattern;\\n    infer: pattern;\\n    inferCaptures: ctx[\\\"captures\\\"] extends IndexedCaptures ? ctx[\\\"captures\\\"] : [];\\n    inferNamedCaptures: ctx[\\\"names\\\"] extends NamedCaptures ? ctx[\\\"names\\\"] : {};\\n    inferExecArray: RegexExecArray<[\\n        pattern,\\n        ...this[\\\"inferCaptures\\\"]\\n    ], this[\\\"inferNamedCaptures\\\"], this[\\\"flags\\\"]>;\\n    flags: ctx[\\\"flags\\\"] extends Flags ? ctx[\\\"flags\\\"] : \\\"\\\";\\n    test(s: string): s is pattern;\\n    exec(s: string): this[\\\"inferExecArray\\\"] | null;\\n    exec(s: string): never;\\n}\\ninterface RegexParser {\\n    <src extends string, flags extends Flags = \\\"\\\">(src: regex.validate<src, flags>, flags?: flags): regex.parse<src, flags>;\\n    as: <pattern extends string = string, ctx extends RegexContext = {}>(src: string, flags?: Flags) => Regex<pattern, ctx>;\\n}\\ndeclare const regex: RegexParser;\\ntype regex<pattern extends string = string, ctx extends RegexContext = RegexContext> = Regex<pattern, ctx>;\\ndeclare namespace regex {\\n    type infer<src extends string, flags extends Flags = \\\"\\\"> = parse<src, flags> extends Regex<infer pattern> ? pattern : never;\\n    type validate<src extends string, flags extends Flags = \\\"\\\"> = parse<src, flags> extends infer e extends ErrorMessage ? e : src;\\n    type parse<src extends string, flags extends Flags = \\\"\\\"> = parseState<State.initialize<src, flags>>;\\n}\\n\\nexport { type Regex, regex };\\n\\n}\"\n"
  },
  {
    "path": "ark/docs/components/dts/schema.ts",
    "content": "/** THIS FILE IS AUTOGENERATED FROM ark/repo/dtsGen.ts **/\n// prettier-ignore\nexport const schemaDts = \"declare module \\\"@ark/schema\\\" {\\n    import { autocomplete, listable, array, JsonObject, JsonArray, satisfy, propValueOf, Domain as Domain$1, Constructor, Json, requireKeys, DynamicBase, anyOrNever, ReadonlyArray as ReadonlyArray$1, propwiseXor, merge, show, CastableBase, ReadonlyPath, mutable, Thunk, Callable, Hkt, JsonStructure, NonNegativeIntegerLiteral, flattenListable, noSuggest, intersectUnion, conform, ParseError, Key, describe, JsonPrimitive, SerializedPrimitive, inferred, Entry, KeySet, keySetOf, arrayIndexOf, Fn, BuiltinObjectKind, GuardablePredicate, Brand, dict, ArkRegistry } from '@ark/util';\\nexport { ParseError } from '@ark/util';\\n\\ndeclare const intrinsic: {\\n    emptyStructure: StructureNode;\\n    jsonPrimitive: BaseRoot<InternalRootDeclaration>;\\n    jsonObject: BaseRoot<InternalRootDeclaration>;\\n    jsonData: BaseRoot<InternalRootDeclaration>;\\n    integer: BaseRoot<InternalRootDeclaration>;\\n    key: BaseRoot<InternalRootDeclaration>;\\n    lengthBoundable: BaseRoot<InternalRootDeclaration>;\\n    nonNegativeIntegerString: BaseRoot<InternalRootDeclaration>;\\n    string: BaseRoot<InternalRootDeclaration>;\\n    number: BaseRoot<InternalRootDeclaration>;\\n    bigint: BaseRoot<InternalRootDeclaration>;\\n    boolean: BaseRoot<InternalRootDeclaration>;\\n    symbol: BaseRoot<InternalRootDeclaration>;\\n    undefined: BaseRoot<InternalRootDeclaration>;\\n    object: BaseRoot<InternalRootDeclaration>;\\n    null: BaseRoot<InternalRootDeclaration>;\\n    Array: BaseRoot<InternalRootDeclaration>;\\n    Date: BaseRoot<InternalRootDeclaration>;\\n    never: BaseRoot<InternalRootDeclaration>;\\n    unknown: BaseRoot<InternalRootDeclaration>;\\n    true: BaseRoot<InternalRootDeclaration>;\\n    false: BaseRoot<InternalRootDeclaration>;\\n};\\n\\ntype ListableJsonSchema = listable<JsonSchema>;\\ntype JsonSchemaOrBoolean = listable<JsonSchema.Branch>;\\ntype JsonSchema = JsonSchema.NonBooleanBranch;\\ndeclare namespace JsonSchema {\\n    type TypeName = \\\"string\\\" | \\\"integer\\\" | \\\"number\\\" | \\\"object\\\" | \\\"array\\\" | \\\"boolean\\\" | \\\"null\\\";\\n    /**\\n     *  a subset of JSON Schema's annotations, see:\\n     *  https://json-schema.org/understanding-json-schema/reference/annotations\\n     **/\\n    interface Meta<t = unknown> extends UniversalMeta<t> {\\n        $schema?: string;\\n        $defs?: Record<string, JsonSchema>;\\n    }\\n    type Format = autocomplete<\\\"date-time\\\" | \\\"date\\\" | \\\"time\\\" | \\\"email\\\" | \\\"ipv4\\\" | \\\"ipv6\\\" | \\\"uri\\\" | \\\"uuid\\\" | \\\"regex\\\">;\\n    /**\\n     * doesn't include root-only keys like $schema\\n     */\\n    interface UniversalMeta<t = unknown> {\\n        title?: string;\\n        description?: string;\\n        format?: Format;\\n        deprecated?: true;\\n        default?: t;\\n        examples?: readonly t[];\\n    }\\n    type Composition = Union | OneOf | Intersection | Not;\\n    type NonBooleanBranch = Constrainable | Const | Composition | Enum | String | Numeric | Object | Array | Ref;\\n    type Branch = boolean | JsonSchema;\\n    type RefString = `#/$defs/${string}`;\\n    interface Ref extends Meta {\\n        $ref: RefString;\\n        type?: never;\\n    }\\n    interface Constrainable extends Meta {\\n        type?: listable<TypeName>;\\n    }\\n    interface Intersection extends Meta {\\n        allOf: readonly JsonSchema[];\\n    }\\n    interface Not extends Meta {\\n        not: JsonSchema;\\n    }\\n    interface OneOf extends Meta {\\n        oneOf: readonly JsonSchema[];\\n    }\\n    interface Union extends Meta {\\n        anyOf: readonly JsonSchema[];\\n    }\\n    interface Const extends Meta {\\n        const: unknown;\\n    }\\n    interface Enum extends Meta {\\n        enum: array;\\n    }\\n    interface String extends Meta<string> {\\n        type: \\\"string\\\";\\n        minLength?: number;\\n        maxLength?: number;\\n        pattern?: string;\\n        format?: string;\\n    }\\n    interface Numeric extends Meta<number> {\\n        type: \\\"number\\\" | \\\"integer\\\";\\n        multipleOf?: number;\\n        minimum?: number;\\n        exclusiveMinimum?: number;\\n        maximum?: number;\\n        exclusiveMaximum?: number;\\n    }\\n    interface Object extends Meta<JsonObject> {\\n        type: \\\"object\\\";\\n        properties?: Record<string, JsonSchema>;\\n        required?: string[];\\n        patternProperties?: Record<string, JsonSchema>;\\n        additionalProperties?: JsonSchemaOrBoolean;\\n        maxProperties?: number;\\n        minProperties?: number;\\n        propertyNames?: String;\\n    }\\n    interface Array extends Meta<JsonArray> {\\n        type: \\\"array\\\";\\n        additionalItems?: JsonSchemaOrBoolean;\\n        contains?: JsonSchemaOrBoolean;\\n        uniqueItems?: boolean;\\n        minItems?: number;\\n        maxItems?: number;\\n        items?: JsonSchemaOrBoolean;\\n        prefixItems?: readonly Branch[];\\n    }\\n    type LengthBoundable = String | Array;\\n    type Structure = Object | Array;\\n}\\n\\ndeclare class DivisorNode extends InternalPrimitiveConstraint<Divisor.Declaration> {\\n    traverseAllows: TraverseAllows<number>;\\n    readonly compiledCondition: string;\\n    readonly compiledNegation: string;\\n    readonly impliedBasis: BaseRoot;\\n    readonly expression: string;\\n    reduceJsonSchema(schema: JsonSchema.Numeric): JsonSchema.Numeric;\\n}\\ndeclare namespace Divisor {\\n    interface Inner {\\n        readonly rule: number;\\n    }\\n    interface NormalizedSchema extends BaseNormalizedSchema {\\n        readonly rule: number;\\n    }\\n    type Schema = NormalizedSchema | number;\\n    interface ErrorContext extends BaseErrorContext<\\\"divisor\\\">, Inner {\\n    }\\n    interface Declaration extends declareNode<{\\n        kind: \\\"divisor\\\";\\n        schema: Schema;\\n        normalizedSchema: NormalizedSchema;\\n        inner: Inner;\\n        prerequisite: number;\\n        errorContext: ErrorContext;\\n    }> {\\n    }\\n    type Node = DivisorNode;\\n}\\ndeclare const Divisor: {\\n    implementation: nodeImplementationOf<Divisor.Declaration>;\\n    Node: typeof DivisorNode;\\n};\\ndeclare const writeIndivisibleMessage: (t: BaseRoot) => string;\\ntype writeIndivisibleMessage<actual> = writeInvalidOperandMessage<\\\"divisor\\\", actual>;\\ndeclare const writeNonIntegerDivisorMessage: <divisor extends number>(divisor: divisor) => writeNonIntegerDivisorMessage<divisor>;\\ntype writeNonIntegerDivisorMessage<divisor extends number> = `divisor must be an integer (was ${divisor})`;\\n\\ninterface BaseRangeDeclaration extends BaseNodeDeclaration {\\n    kind: RangeKind;\\n    inner: BaseRangeInner;\\n    normalizedSchema: UnknownExpandedRangeSchema;\\n}\\ndeclare abstract class BaseRange<d extends BaseRangeDeclaration> extends InternalPrimitiveConstraint<d> {\\n    readonly exclusive?: true;\\n    readonly boundOperandKind: OperandKindsByBoundKind[d[\\\"kind\\\"]];\\n    readonly compiledActual: string;\\n    readonly comparator: RelativeComparator;\\n    readonly numericLimit: number;\\n    readonly expression: string;\\n    readonly compiledCondition: string;\\n    readonly compiledNegation: string;\\n    readonly stringLimit: string;\\n    readonly limitKind: LimitKind;\\n    isStricterThan(r: nodeOfKind<d[\\\"kind\\\"] | pairedRangeKind<d[\\\"kind\\\"]>>): boolean;\\n    overlapsRange(r: nodeOfKind<pairedRangeKind<d[\\\"kind\\\"]>>): boolean;\\n    overlapIsUnit(r: nodeOfKind<pairedRangeKind<d[\\\"kind\\\"]>>): boolean;\\n}\\ninterface BaseRangeInner {\\n    readonly rule: LimitValue;\\n}\\ntype LimitValue = Date | number;\\ntype LimitSchemaValue = Date | number | string;\\ntype LimitInnerValue<kind extends RangeKind = RangeKind> = kind extends \\\"before\\\" | \\\"after\\\" ? Date : number;\\ninterface UnknownExpandedRangeSchema extends BaseNormalizedSchema {\\n    readonly rule: LimitSchemaValue;\\n    readonly exclusive?: boolean;\\n}\\ninterface UnknownNormalizedRangeSchema extends BaseNormalizedSchema {\\n    readonly rule: LimitSchemaValue;\\n}\\ntype UnknownRangeSchema = LimitSchemaValue | UnknownExpandedRangeSchema;\\ninterface ExclusiveExpandedDateRangeSchema extends BaseNormalizedSchema {\\n    rule: LimitSchemaValue;\\n    exclusive?: true;\\n}\\ntype ExclusiveDateRangeSchema = LimitSchemaValue | ExclusiveExpandedDateRangeSchema;\\ninterface InclusiveExpandedDateRangeSchema extends BaseNormalizedSchema {\\n    rule: LimitSchemaValue;\\n    exclusive?: false;\\n}\\ntype InclusiveDateRangeSchema = LimitSchemaValue | InclusiveExpandedDateRangeSchema;\\ninterface ExclusiveNormalizedNumericRangeSchema extends BaseNormalizedSchema {\\n    rule: number;\\n    exclusive?: true;\\n}\\ntype ExclusiveNumericRangeSchema = number | ExclusiveNormalizedNumericRangeSchema;\\ninterface InclusiveNormalizedNumericRangeSchema extends BaseNormalizedSchema {\\n    rule: number;\\n    exclusive?: false;\\n}\\ntype InclusiveNumericRangeSchema = number | InclusiveNormalizedNumericRangeSchema;\\ntype LimitKind = \\\"lower\\\" | \\\"upper\\\";\\ntype RelativeComparator<kind extends LimitKind = LimitKind> = {\\n    lower: \\\">\\\" | \\\">=\\\";\\n    upper: \\\"<\\\" | \\\"<=\\\";\\n}[kind];\\ndeclare const boundKindPairsByLower: BoundKindPairsByLower;\\ntype BoundKindPairsByLower = {\\n    min: \\\"max\\\";\\n    minLength: \\\"maxLength\\\";\\n    after: \\\"before\\\";\\n};\\ntype BoundKindPairsByUpper = {\\n    max: \\\"min\\\";\\n    maxLength: \\\"minLength\\\";\\n    before: \\\"after\\\";\\n};\\ntype pairedRangeKind<kind extends RangeKind> = kind extends LowerBoundKind ? BoundKindPairsByLower[kind] : BoundKindPairsByUpper[kind & UpperBoundKind];\\ntype LowerBoundKind = keyof typeof boundKindPairsByLower;\\ntype LowerNode = nodeOfKind<LowerBoundKind>;\\ntype UpperBoundKind = propValueOf<typeof boundKindPairsByLower>;\\ntype UpperNode = nodeOfKind<UpperBoundKind>;\\ntype NumericallyBoundable = string | number | array;\\ntype Boundable = NumericallyBoundable | Date;\\ndeclare const parseExclusiveKey: keySchemaDefinitions<Declaration<\\\"min\\\" | \\\"max\\\">>[\\\"exclusive\\\"];\\ndeclare const createLengthSchemaNormalizer: <kind extends \\\"minLength\\\" | \\\"maxLength\\\">(kind: kind) => (schema: NodeSchema<kind>) => NormalizedSchema<kind>;\\ndeclare const createDateSchemaNormalizer: <kind extends DateRangeKind>(kind: kind) => (schema: NodeSchema<kind>) => NormalizedSchema<kind>;\\ndeclare const parseDateLimit: (limit: LimitSchemaValue) => Date;\\ntype LengthBoundKind = \\\"minLength\\\" | \\\"maxLength\\\" | \\\"exactLength\\\";\\ndeclare const writeInvalidLengthBoundMessage: (kind: LengthBoundKind, limit: number) => string;\\ndeclare const createLengthRuleParser: (kind: LengthBoundKind) => (limit: number) => number | undefined;\\ntype OperandKindsByBoundKind = satisfy<Record<RangeKind, BoundOperandKind>, {\\n    min: \\\"value\\\";\\n    max: \\\"value\\\";\\n    minLength: \\\"length\\\";\\n    maxLength: \\\"length\\\";\\n    after: \\\"date\\\";\\n    before: \\\"date\\\";\\n}>;\\ndeclare const compileComparator: (kind: RangeKind, exclusive: boolean | undefined) => RelativeComparator;\\ntype BoundOperandKind = \\\"value\\\" | \\\"length\\\" | \\\"date\\\";\\ntype LengthBoundableData = string | array;\\ntype DateRangeKind = \\\"before\\\" | \\\"after\\\";\\ndeclare const dateLimitToString: (limit: LimitSchemaValue) => string;\\ndeclare const writeUnboundableMessage: <root extends string>(root: root) => writeUnboundableMessage<root>;\\ntype writeUnboundableMessage<root extends string> = `Bounded expression ${root} must be exactly one of number, string, Array, or Date`;\\n\\ndeclare class ExactLengthNode extends InternalPrimitiveConstraint<ExactLength.Declaration> {\\n    traverseAllows: TraverseAllows<LengthBoundableData>;\\n    readonly compiledCondition: string;\\n    readonly compiledNegation: string;\\n    readonly impliedBasis: BaseRoot;\\n    readonly expression: string;\\n    reduceJsonSchema(schema: JsonSchema.LengthBoundable): JsonSchema.LengthBoundable;\\n}\\ndeclare namespace ExactLength {\\n    interface Inner {\\n        readonly rule: number;\\n    }\\n    interface NormalizedSchema extends BaseNormalizedSchema {\\n        readonly rule: number;\\n    }\\n    type Schema = NormalizedSchema | number;\\n    interface ErrorContext extends BaseErrorContext<\\\"exactLength\\\">, Inner {\\n    }\\n    type Declaration = declareNode<{\\n        kind: \\\"exactLength\\\";\\n        schema: Schema;\\n        normalizedSchema: NormalizedSchema;\\n        inner: Inner;\\n        prerequisite: LengthBoundableData;\\n        errorContext: ErrorContext;\\n    }>;\\n    type Node = ExactLengthNode;\\n}\\ndeclare const ExactLength: {\\n    implementation: nodeImplementationOf<{\\n        intersectionIsOpen: false;\\n        childKind: never;\\n        reducibleTo: \\\"exactLength\\\";\\n        kind: \\\"exactLength\\\";\\n        schema: ExactLength.Schema;\\n        normalizedSchema: ExactLength.NormalizedSchema;\\n        inner: ExactLength.Inner;\\n        prerequisite: LengthBoundableData;\\n        errorContext: ExactLength.ErrorContext;\\n    }>;\\n    Node: typeof ExactLengthNode;\\n};\\n\\n/** From https://github.com/standard-schema/standard-schema */\\n/** The Standard Typed interface. This is a base type extended by other specs. */\\ninterface StandardTypedV1<Input = unknown, Output = Input> {\\n    /** The Standard properties. */\\n    readonly \\\"~standard\\\": StandardTypedV1.Props<Input, Output>;\\n}\\ndeclare namespace StandardTypedV1 {\\n    /** The Standard Typed properties interface. */\\n    interface Props<Input = unknown, Output = Input> {\\n        /** The version number of the standard. */\\n        readonly version: 1;\\n        /** The vendor name of the schema library. */\\n        readonly vendor: string;\\n        /** Inferred types associated with the schema. */\\n        readonly types?: Types<Input, Output> | undefined;\\n    }\\n    /** The Standard Typed types interface. */\\n    interface Types<Input = unknown, Output = Input> {\\n        /** The input type of the schema. */\\n        readonly input: Input;\\n        /** The output type of the schema. */\\n        readonly output: Output;\\n    }\\n    /** Infers the input type of a Standard Typed. */\\n    type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema[\\\"~standard\\\"][\\\"types\\\"]>[\\\"input\\\"];\\n    /** Infers the output type of a Standard Typed. */\\n    type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema[\\\"~standard\\\"][\\\"types\\\"]>[\\\"output\\\"];\\n}\\n/** The Standard Schema interface. */\\ninterface StandardSchemaV1<Input = unknown, Output = Input> {\\n    /** The Standard Schema properties. */\\n    readonly \\\"~standard\\\": StandardSchemaV1.Props<Input, Output>;\\n}\\ndeclare namespace StandardSchemaV1 {\\n    /** The Standard Schema properties interface. */\\n    interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {\\n        /** Validates unknown input values. */\\n        readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;\\n    }\\n    /** The result interface of the validate function. */\\n    type Result<Output> = SuccessResult<Output> | FailureResult;\\n    /** The result interface if validation succeeds. */\\n    interface SuccessResult<Output> {\\n        /** The typed output value. */\\n        readonly value: Output;\\n        /** A falsy value for `issues` indicates success. */\\n        readonly issues?: undefined;\\n    }\\n    interface Options {\\n        /** Explicit support for additional vendor-specific parameters, if needed. */\\n        readonly libraryOptions?: Record<string, unknown> | undefined;\\n    }\\n    /** The result interface if validation fails. */\\n    interface FailureResult {\\n        /** The issues of failed validation. */\\n        readonly issues: ReadonlyArray<Issue>;\\n    }\\n    /** The issue interface of the failure output. */\\n    interface Issue {\\n        /** The error message of the issue. */\\n        readonly message: string;\\n        /** The path of the issue, if any. */\\n        readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;\\n    }\\n    /** The path segment interface of the issue. */\\n    interface PathSegment {\\n        /** The key representing a path segment. */\\n        readonly key: PropertyKey;\\n    }\\n    /** The Standard types interface. */\\n    interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {\\n    }\\n    /** Infers the input type of a Standard. */\\n    type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;\\n    /** Infers the output type of a Standard. */\\n    type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;\\n    /** ArkType-specific properties that extend the standard schema with JSON Schema support. */\\n    interface ArkTypeProps<Input = unknown, Output = Input> extends Props<Input, Output>, StandardJSONSchemaV1.Props<Input, Output> {\\n        vendor: \\\"arktype\\\";\\n    }\\n}\\n/** The Standard JSON Schema interface. */\\ninterface StandardJSONSchemaV1<Input = unknown, Output = Input> {\\n    /** The Standard JSON Schema properties. */\\n    readonly \\\"~standard\\\": StandardJSONSchemaV1.Props<Input, Output>;\\n}\\ndeclare namespace StandardJSONSchemaV1 {\\n    /** The Standard JSON Schema properties interface. */\\n    interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {\\n        /** Methods for generating the input/output JSON Schema. */\\n        readonly jsonSchema: StandardJSONSchemaV1.Converter;\\n    }\\n    /** The Standard JSON Schema converter interface. */\\n    interface Converter {\\n        /** Converts the input type to JSON Schema. May throw if conversion is not supported. */\\n        readonly input: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;\\n        /** Converts the output type to JSON Schema. May throw if conversion is not supported. */\\n        readonly output: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;\\n    }\\n    /**\\n     * The target version of the generated JSON Schema.\\n     *\\n     * It is *strongly recommended* that implementers support `\\\"draft-2020-12\\\"` and `\\\"draft-07\\\"`, as they are both in wide use. All other targets can be implemented on a best-effort basis. Libraries should throw if they don't support a specified target.\\n     *\\n     * The `\\\"openapi-3.0\\\"` target is intended as a standardized specifier for OpenAPI 3.0 which is a superset of JSON Schema `\\\"draft-04\\\"`.\\n     */\\n    type Target = \\\"draft-2020-12\\\" | \\\"draft-07\\\" | \\\"openapi-3.0\\\" | ({} & string);\\n    /** The options for the input/output methods. */\\n    interface Options {\\n        /** Specifies the target version of the generated JSON Schema. Support for all versions is on a best-effort basis. If a given version is not supported, the library should throw. */\\n        readonly target: Target;\\n        /** Explicit support for additional vendor-specific parameters, if needed. */\\n        readonly libraryOptions?: Record<string, unknown> | undefined;\\n    }\\n    /** The Standard types interface. */\\n    interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {\\n    }\\n    /** Infers the input type of a Standard. */\\n    type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;\\n    /** Infers the output type of a Standard. */\\n    type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;\\n}\\n\\ndeclare class ToJsonSchemaError<code extends ToJsonSchema.Code = ToJsonSchema.Code> extends Error {\\n    readonly name = \\\"ToJsonSchemaError\\\";\\n    readonly code: code;\\n    readonly context: ToJsonSchema.ContextByCode[code];\\n    constructor(code: code, context: ToJsonSchema.ContextByCode[code]);\\n    hasCode<code extends ToJsonSchema.Code>(code: code): this is ToJsonSchemaError<code>;\\n}\\ndeclare const ToJsonSchema: {\\n    Error: typeof ToJsonSchemaError;\\n    throw: (code: keyof ToJsonSchema.ContextByCode, context: ToJsonSchema.DateContext | ToJsonSchema.MorphContext | ToJsonSchema.UnitContext | ToJsonSchema.ProtoContext | ToJsonSchema.DomainContext | ToJsonSchema.PredicateContext | ToJsonSchema.ArrayObjectContext | ToJsonSchema.ArrayPostfixContext | ToJsonSchema.DefaultValueContext | ToJsonSchema.PatternIntersectionContext | ToJsonSchema.SymbolKeyContext) => never;\\n    throwInternalOperandError: (kind: ConstraintKind, schema: JsonSchema) => never;\\n    defaultConfig: ToJsonSchema.Context;\\n};\\ndeclare namespace ToJsonSchema {\\n    type Unjsonifiable = object | symbol | bigint | undefined;\\n    type Error = InstanceType<typeof ToJsonSchema.Error>;\\n    interface BaseContext<code extends Code, base extends JsonSchema = JsonSchema> {\\n        code: code;\\n        base: base;\\n    }\\n    interface ArrayObjectContext extends BaseContext<\\\"arrayObject\\\", JsonSchema.Array> {\\n        object: JsonSchema.Object;\\n    }\\n    interface ArrayPostfixContext extends BaseContext<\\\"arrayPostfix\\\", VariadicArraySchema> {\\n        elements: readonly JsonSchema[];\\n    }\\n    interface DefaultValueContext extends BaseContext<\\\"defaultValue\\\", JsonSchema> {\\n        value: Unjsonifiable;\\n    }\\n    interface DomainContext extends BaseContext<\\\"domain\\\", JsonSchema> {\\n        domain: satisfy<Domain$1, \\\"symbol\\\" | \\\"bigint\\\" | \\\"undefined\\\">;\\n    }\\n    interface MorphContext extends BaseContext<\\\"morph\\\", JsonSchema> {\\n        out: JsonSchema | null;\\n    }\\n    interface PatternIntersectionContext extends BaseContext<\\\"patternIntersection\\\", StringSchemaWithPattern> {\\n        pattern: string;\\n    }\\n    interface PredicateContext extends BaseContext<\\\"predicate\\\", JsonSchema> {\\n        predicate: Predicate;\\n    }\\n    interface ProtoContext extends BaseContext<\\\"proto\\\", JsonSchema> {\\n        proto: Constructor;\\n    }\\n    type SymbolKeyContext = IndexSymbolKeyContext | RequiredSymbolKeyContext | OptionalSymbolKeyContext;\\n    interface IndexSymbolKeyContext extends BaseContext<\\\"symbolKey\\\", JsonSchema.Object> {\\n        key: null;\\n        value: JsonSchema;\\n        optional: false;\\n    }\\n    interface RequiredSymbolKeyContext extends BaseContext<\\\"symbolKey\\\", JsonSchema.Object> {\\n        key: symbol;\\n        value: JsonSchema;\\n        optional: false;\\n    }\\n    interface OptionalSymbolKeyContext extends BaseContext<\\\"symbolKey\\\", JsonSchema.Object> {\\n        key: symbol;\\n        value: JsonSchema;\\n        optional: true;\\n        default?: Json;\\n    }\\n    interface UnitContext extends BaseContext<\\\"unit\\\", JsonSchema> {\\n        unit: Unjsonifiable;\\n    }\\n    interface DateContext extends BaseContext<\\\"date\\\", JsonSchema> {\\n        before?: Date;\\n        after?: Date;\\n    }\\n    interface ContextByCode {\\n        arrayObject: ArrayObjectContext;\\n        arrayPostfix: ArrayPostfixContext;\\n        defaultValue: DefaultValueContext;\\n        domain: DomainContext;\\n        morph: MorphContext;\\n        patternIntersection: PatternIntersectionContext;\\n        predicate: PredicateContext;\\n        proto: ProtoContext;\\n        symbolKey: SymbolKeyContext;\\n        unit: UnitContext;\\n        date: DateContext;\\n    }\\n    type Code = keyof ContextByCode;\\n    type FallbackContext = ContextByCode[Code];\\n    type HandlerByCode = satisfy<{\\n        [code in Code]: (ctx: ContextByCode[code]) => unknown;\\n    }, {\\n        arrayObject: (ctx: ArrayObjectContext) => JsonSchema.Structure;\\n        arrayPostfix: (ctx: ArrayPostfixContext) => VariadicArraySchema;\\n        defaultValue: (ctx: DefaultValueContext) => JsonSchema;\\n        domain: (ctx: DomainContext) => JsonSchema;\\n        morph: (ctx: MorphContext) => JsonSchema;\\n        patternIntersection: (ctx: PatternIntersectionContext) => JsonSchema.String;\\n        predicate: (ctx: PredicateContext) => JsonSchema;\\n        proto: (ctx: ProtoContext) => JsonSchema;\\n        symbolKey: (ctx: SymbolKeyContext) => JsonSchema.Object;\\n        unit: (ctx: UnitContext) => JsonSchema;\\n        date: (ctx: DateContext) => JsonSchema;\\n    }>;\\n    type VariadicArraySchema = requireKeys<JsonSchema.Array, \\\"items\\\">;\\n    type StringSchemaWithPattern = requireKeys<JsonSchema.String, \\\"pattern\\\">;\\n    type UniversalFallback = (ctx: FallbackContext) => JsonSchema;\\n    interface FallbackObject extends Partial<HandlerByCode> {\\n        default?: UniversalFallback;\\n    }\\n    type FallbackOption = UniversalFallback | FallbackObject;\\n    type Target = satisfy<StandardJSONSchemaV1.Target, \\\"draft-2020-12\\\" | \\\"draft-07\\\">;\\n    interface Options {\\n        /** value to assign to the generated $schema key\\n         *\\n         *  - set to `null` to omit the `$schema` key\\n         *  - does not affect the contents of the generated schema\\n         *  - if `target` is also specified, `dialect` takes precedence\\n         *\\n         * @default \\\"https://json-schema.org/draft/2020-12/schema\\\"\\n         */\\n        dialect?: string | null;\\n        /**\\n         * Shorthand for specifying the target JSON Schema version.\\n         * Maps to the appropriate `dialect` URL.\\n         *\\n         *  - \\\"draft-2020-12\\\" -> \\\"https://json-schema.org/draft/2020-12/schema\\\"\\n         *  - \\\"draft-07\\\" -> \\\"http://json-schema.org/draft-07/schema#\\\"\\n         *\\n         * If `dialect` is also specified, `dialect` takes precedence.\\n         */\\n        target?: Target;\\n        useRefs?: boolean;\\n        fallback?: FallbackOption;\\n    }\\n    interface Context extends Required<Options> {\\n        fallback: HandlerByCode;\\n    }\\n}\\n\\ndeclare class PatternNode extends InternalPrimitiveConstraint<Pattern.Declaration> {\\n    readonly instance: RegExp;\\n    readonly expression: string;\\n    traverseAllows: (string: string) => boolean;\\n    readonly compiledCondition: string;\\n    readonly compiledNegation: string;\\n    readonly impliedBasis: BaseRoot;\\n    reduceJsonSchema(base: JsonSchema.String, ctx: ToJsonSchema.Context): JsonSchema.String;\\n}\\ndeclare namespace Pattern {\\n    interface NormalizedSchema extends BaseNormalizedSchema {\\n        readonly rule: string;\\n        readonly flags?: string;\\n    }\\n    interface Inner {\\n        readonly rule: string;\\n        readonly flags?: string;\\n    }\\n    type Schema = NormalizedSchema | string | RegExp;\\n    interface ErrorContext extends BaseErrorContext<\\\"pattern\\\">, Inner {\\n    }\\n    interface Declaration extends declareNode<{\\n        kind: \\\"pattern\\\";\\n        schema: Schema;\\n        normalizedSchema: NormalizedSchema;\\n        inner: Inner;\\n        intersectionIsOpen: true;\\n        prerequisite: string;\\n        errorContext: ErrorContext;\\n    }> {\\n    }\\n    type Node = PatternNode;\\n}\\ndeclare const Pattern: {\\n    implementation: nodeImplementationOf<Pattern.Declaration>;\\n    Node: typeof PatternNode;\\n};\\n\\ntype PreparsedNodeResolution = {\\n    [arkKind]: \\\"generic\\\" | \\\"module\\\";\\n};\\ndeclare class RootModule<exports extends {} = {}> extends DynamicBase<exports> {\\n    get [arkKind](): \\\"module\\\";\\n}\\ninterface InternalModule<exports extends InternalResolutions = InternalResolutions> extends RootModule<exports> {\\n    root?: BaseRoot;\\n}\\ndeclare const bindModule: (module: InternalModule, $: BaseScope) => InternalModule;\\ntype exportSchemaScope<$> = {\\n    [k in keyof $]: instantiateRoot<$[k]>;\\n};\\ntype instantiateRoot<t> = t extends InternalResolution ? [\\n    t\\n] extends [anyOrNever] ? BaseRoot : t : BaseRoot;\\ndeclare const SchemaModule: new <$ = {}>(types: exportSchemaScope<$>) => SchemaModule<$>;\\ninterface SchemaModule<$ = {}> extends RootModule<exportSchemaScope<$>> {\\n}\\n\\ntype ArkErrorResult = ArkError | ArkErrors;\\ndeclare class ArkError<code extends ArkErrorCode = ArkErrorCode> extends CastableBase<ArkErrorContextInput<code>> {\\n    readonly [arkKind] = \\\"error\\\";\\n    path: ReadonlyPath;\\n    data: Prerequisite<code>;\\n    private nodeConfig;\\n    protected input: ArkErrorContextInput<code>;\\n    protected ctx: Traversal;\\n    constructor(input: ArkErrorContextInput<code>, ctx: Traversal);\\n    transform(f: (input: ArkErrorContextInput<code>) => ArkErrorContextInput): ArkError;\\n    hasCode<code extends ArkErrorCode>(code: code): this is ArkError<code>;\\n    get propString(): string;\\n    get expected(): string;\\n    get actual(): string;\\n    get problem(): string;\\n    get message(): string;\\n    get flat(): ArkError[];\\n    toJSON(): JsonObject;\\n    toString(): string;\\n    throw(): never;\\n}\\ndeclare namespace ArkErrors {\\n    type Handler<returns = unknown> = (errors: ArkErrors) => returns;\\n}\\n/**\\n * A ReadonlyArray of `ArkError`s returned by a Type on invalid input.\\n *\\n * Subsequent errors added at an existing path are merged into an\\n * ArkError intersection.\\n */\\ndeclare class ArkErrors extends ReadonlyArray$1<ArkError> implements StandardSchemaV1.FailureResult {\\n    readonly [arkKind] = \\\"errors\\\";\\n    protected ctx: Traversal;\\n    constructor(ctx: Traversal);\\n    /**\\n     * Errors by a pathString representing their location.\\n     */\\n    byPath: Record<string, ArkError>;\\n    /**\\n     * {@link byPath} flattened so that each value is an array of ArkError instances at that path.\\n     *\\n     * ✅ Since \\\"intersection\\\" errors will be flattened to their constituent `.errors`,\\n     * they will never be directly present in this representation.\\n     */\\n    get flatByPath(): Record<string, ArkError[]>;\\n    /**\\n     * {@link byPath} flattened so that each value is an array of problem strings at that path.\\n     */\\n    get flatProblemsByPath(): Record<string, string[]>;\\n    /**\\n     * All pathStrings at which errors are present mapped to the errors occuring\\n     * at that path or any nested path within it.\\n     */\\n    byAncestorPath: Record<string, ArkError[]>;\\n    count: number;\\n    private mutable;\\n    /**\\n     * Throw a TraversalError based on these errors.\\n     */\\n    throw(): never;\\n    /**\\n     * Converts ArkErrors to TraversalError, a subclass of `Error` suitable for throwing with nice\\n     * formatting.\\n     */\\n    toTraversalError(): TraversalError;\\n    /**\\n     * Append an ArkError to this array, ignoring duplicates.\\n     */\\n    add(error: ArkError): void;\\n    transform(f: (e: ArkError) => ArkError): ArkErrors;\\n    /**\\n     * Add all errors from an ArkErrors instance, ignoring duplicates and\\n     * prefixing their paths with that of the current Traversal.\\n     */\\n    merge(errors: ArkErrors): void;\\n    /**\\n     * @internal\\n     */\\n    affectsPath(path: ReadonlyPath): boolean;\\n    /**\\n     * A human-readable summary of all errors.\\n     */\\n    get summary(): string;\\n    /**\\n     * Alias of this ArkErrors instance for StandardSchema compatibility.\\n     */\\n    get issues(): this;\\n    toJSON(): JsonArray;\\n    toString(): string;\\n    private addAncestorPaths;\\n}\\ndeclare class TraversalError extends Error {\\n    readonly name = \\\"TraversalError\\\";\\n    arkErrors: ArkErrors;\\n    constructor(errors: ArkErrors);\\n}\\ninterface DerivableErrorContext<code extends ArkErrorCode = ArkErrorCode> {\\n    expected: string;\\n    actual: string;\\n    problem: string;\\n    message: string;\\n    data: Prerequisite<code>;\\n    path: array<PropertyKey>;\\n    propString: string;\\n}\\ntype DerivableErrorContextInput<code extends ArkErrorCode = ArkErrorCode> = Partial<DerivableErrorContext<code>> & propwiseXor<{\\n    path?: array<PropertyKey>;\\n}, {\\n    relativePath?: array<PropertyKey>;\\n    prefixPath?: array<PropertyKey>;\\n}>;\\ntype ArkErrorCode = {\\n    [kind in NodeKind]: errorContext<kind> extends null ? never : kind;\\n}[NodeKind];\\ntype ArkErrorContextInputsByCode = {\\n    [code in ArkErrorCode]: errorContext<code> & DerivableErrorContextInput<code>;\\n};\\ntype ArkErrorContextInput<code extends ArkErrorCode = ArkErrorCode> = merge<ArkErrorContextInputsByCode[code], {\\n    meta?: ArkEnv.meta;\\n}>;\\ntype NodeErrorContextInput<code extends ArkErrorCode = ArkErrorCode> = ArkErrorContextInputsByCode[code] & {\\n    meta: ArkEnv.meta;\\n};\\ntype MessageContext<code extends ArkErrorCode = ArkErrorCode> = Omit<ArkError<code>, \\\"message\\\">;\\ntype ProblemContext<code extends ArkErrorCode = ArkErrorCode> = Omit<MessageContext<code>, \\\"problem\\\">;\\ntype CustomErrorInput = show<{\\n    code?: undefined;\\n} & DerivableErrorContextInput>;\\ntype ArkErrorInput = string | ArkErrorContextInput | CustomErrorInput;\\ntype ProblemConfig<code extends ArkErrorCode = ArkErrorCode> = string | ProblemWriter<code>;\\ntype ProblemWriter<code extends ArkErrorCode = ArkErrorCode> = (context: ProblemContext<code>) => string;\\ntype MessageConfig<code extends ArkErrorCode = ArkErrorCode> = string | MessageWriter<code>;\\ntype MessageWriter<code extends ArkErrorCode = ArkErrorCode> = (context: MessageContext<code>) => string;\\ntype getAssociatedDataForError<code extends ArkErrorCode> = code extends NodeKind ? Prerequisite<code> : unknown;\\ntype ExpectedConfig<code extends ArkErrorCode = ArkErrorCode> = string | ExpectedWriter<code>;\\ntype ExpectedWriter<code extends ArkErrorCode = ArkErrorCode> = (source: errorContext<code>) => string;\\ntype ActualConfig<code extends ArkErrorCode = ArkErrorCode> = string | ActualWriter<code>;\\ntype ActualWriter<code extends ArkErrorCode = ArkErrorCode> = (data: getAssociatedDataForError<code>) => string;\\n\\ndeclare const makeRootAndArrayPropertiesMutable: <o extends object>(o: o) => makeRootAndArrayPropertiesMutable<o>;\\ntype makeRootAndArrayPropertiesMutable<inner> = {\\n    -readonly [k in keyof inner]: inner[k] extends array | undefined ? mutable<inner[k]> : inner[k];\\n} & unknown;\\ntype internalImplementationOf<external, typeOnlyKey extends keyof external = never> = {\\n    [k in Exclude<keyof external, typeOnlyKey>]: external[k] extends ((...args: infer args) => unknown) ? (...args: {\\n        [i in keyof args]: never;\\n    }) => unknown : unknown;\\n};\\ntype arkKind = typeof arkKind;\\ndeclare const arkKind: \\\" arkKind\\\";\\ninterface ArkKinds {\\n    constraint: BaseConstraint;\\n    root: BaseRoot;\\n    scope: BaseScope;\\n    generic: GenericRoot;\\n    module: InternalModule;\\n    error: ArkError;\\n    errors: ArkErrors;\\n    context: BaseParseContext;\\n}\\ntype ArkKind = show<keyof ArkKinds>;\\ndeclare const hasArkKind: <kind extends ArkKind>(value: unknown, kind: kind) => value is ArkKinds[kind];\\ndeclare const isNode: (value: unknown) => value is BaseNode;\\ntype unwrapDefault<thunkableValue> = thunkableValue extends Thunk<infer returnValue> ? returnValue : thunkableValue;\\n\\ntype GenericParamAst<name extends string = string, constraint = unknown> = [name: name, constraint: constraint];\\ntype GenericParamDef<name extends string = string> = name | readonly [name, unknown];\\ndeclare const parseGeneric: (paramDefs: array<GenericParamDef>, bodyDef: unknown, $: BaseScope) => GenericRoot;\\ntype genericParamNames<params extends array<GenericParamAst>> = {\\n    [i in keyof params]: params[i][0];\\n};\\ntype genericParamConstraints<params extends array<GenericParamAst>> = {\\n    [i in keyof params]: params[i][1];\\n};\\ntype GenericArgResolutions<params extends array<GenericParamAst> = array<GenericParamAst>> = {\\n    [i in keyof params as params[i & `${number}`][0]]: BaseRoot;\\n};\\ndeclare class LazyGenericBody<argResolutions = {}, returns = unknown> extends Callable<(args: argResolutions) => returns> {\\n}\\ninterface GenericAst<params extends array<GenericParamAst> = array<GenericParamAst>, bodyDef = unknown, $ = unknown, arg$ = $> {\\n    [arkKind]: \\\"generic\\\";\\n    paramsAst: params;\\n    bodyDef: bodyDef;\\n    $: $;\\n    arg$: arg$;\\n    names: genericParamNames<params>;\\n    t: this;\\n}\\ndeclare class GenericRoot<params extends array<GenericParamAst> = array<GenericParamAst>, bodyDef = unknown> extends Callable<(...args: {\\n    [i in keyof params]: BaseRoot;\\n}) => BaseRoot> {\\n    readonly [arkKind] = \\\"generic\\\";\\n    readonly paramsAst: params;\\n    readonly t: GenericAst<params, bodyDef, {}, {}>;\\n    paramDefs: array<GenericParamDef>;\\n    bodyDef: bodyDef;\\n    $: BaseScope;\\n    arg$: BaseScope;\\n    baseInstantiation: BaseRoot;\\n    hkt: Hkt.constructor | null;\\n    description: string;\\n    constructor(paramDefs: array<GenericParamDef>, bodyDef: bodyDef, $: BaseScope, arg$: BaseScope, hkt: Hkt.constructor | null);\\n    defIsLazy(): this is GenericRoot<params, LazyGenericBody>;\\n    protected cacheGetter<name extends keyof this>(name: name, value: this[name]): this[name];\\n    get json(): JsonStructure;\\n    get params(): {\\n        [i in keyof params]: [params[i][0], BaseRoot];\\n    };\\n    get names(): genericParamNames<params>;\\n    get constraints(): {\\n        [i in keyof params]: BaseRoot;\\n    };\\n    get internal(): this;\\n    get referencesById(): Record<string, BaseNode>;\\n    get references(): BaseNode[];\\n}\\ntype genericParamSchemasToAst<schemas extends readonly GenericParamDef[]> = {\\n    [i in keyof schemas]: schemas[i] extends GenericParamDef<infer name> ? [\\n        name,\\n        unknown\\n    ] : never;\\n};\\ntype genericHktToConstraints<hkt extends abstract new () => Hkt> = InstanceType<hkt>[\\\"constraints\\\"];\\ntype GenericRootParser = <const paramsDef extends readonly GenericParamDef[]>(...params: paramsDef) => GenericRootBodyParser<genericParamSchemasToAst<paramsDef>>;\\ntype GenericRootBodyParser<params extends array<GenericParamAst>> = {\\n    <const body>(body: RootSchema): GenericRoot<params, body>;\\n    <hkt extends Hkt.constructor>(instantiateDef: LazyGenericBody<GenericArgResolutions<params>>, hkt: hkt): GenericRoot<{\\n        [i in keyof params]: [params[i][0], genericHktToConstraints<hkt>[i]];\\n    }, InstanceType<hkt>>;\\n};\\ndeclare const writeUnsatisfiedParameterConstraintMessage: <name extends string, constraint extends string, arg extends string>(name: name, constraint: constraint, arg: arg) => writeUnsatisfiedParameterConstraintMessage<name, constraint, arg>;\\ntype writeUnsatisfiedParameterConstraintMessage<name extends string, constraint extends string, arg extends string> = `${name} must be assignable to ${constraint} (was ${arg})`;\\n\\ndeclare class AliasNode extends BaseRoot<Alias.Declaration> {\\n    readonly expression: string;\\n    readonly structure: undefined;\\n    get resolution(): BaseRoot;\\n    protected _resolve(): BaseRoot;\\n    get resolutionId(): NodeId;\\n    get defaultShortDescription(): string;\\n    protected innerToJsonSchema(ctx: ToJsonSchema.Context): JsonSchema;\\n    traverseAllows: TraverseAllows;\\n    traverseApply: TraverseApply;\\n    compile(js: NodeCompiler): void;\\n}\\ndeclare namespace Alias {\\n    type Schema<alias extends string = string> = `$${alias}` | NormalizedSchema<alias>;\\n    interface NormalizedSchema<alias extends string = string> extends BaseNormalizedSchema {\\n        readonly reference: alias;\\n        readonly resolve?: () => BaseRoot;\\n    }\\n    interface Inner<alias extends string = string> {\\n        readonly reference: alias;\\n        readonly resolve?: () => BaseRoot;\\n    }\\n    interface Declaration extends declareNode<{\\n        kind: \\\"alias\\\";\\n        schema: Schema;\\n        normalizedSchema: NormalizedSchema;\\n        inner: Inner;\\n    }> {\\n    }\\n    type Node = AliasNode;\\n}\\ndeclare const Alias: {\\n    implementation: nodeImplementationOf<Alias.Declaration>;\\n    Node: typeof AliasNode;\\n};\\n\\ndeclare const registryName: string;\\ndeclare const $ark: ArkSchemaRegistry;\\ndeclare const reference: (name: string) => RegisteredReference;\\ndeclare const registeredReference: (value: object | symbol) => RegisteredReference;\\ntype RegisteredReference<to extends string = string> = `$ark${\\\"\\\" | NonNegativeIntegerLiteral}.${to}`;\\n\\ntype InternalResolutions = Record<string, InternalResolution | undefined>;\\ntype exportedNameOf<$> = Exclude<keyof $ & string, PrivateDeclaration>;\\ntype resolvableReferenceIn<$> = {\\n    [k in keyof $]: k extends string ? k extends PrivateDeclaration<infer alias> ? alias : k extends noSuggest | \\\"root\\\" ? never : k : never;\\n}[keyof $];\\ntype resolveReference<reference extends resolvableReferenceIn<$>, $> = reference extends keyof $ ? $[reference] : $[`#${reference}` & keyof $];\\ntype flatResolutionsOf<$> = show<intersectUnion<resolvableReferenceIn<$> extends infer k ? k extends keyof $ & string ? resolutionsOfReference<k, $[k]> : unknown : unknown>>;\\ntype resolutionsOfReference<k extends string, v> = [\\n    v\\n] extends [{\\n    [arkKind]: \\\"module\\\";\\n}] ? [\\n    v\\n] extends [anyOrNever] ? {\\n    [_ in k]: v;\\n} : prefixKeys<flatResolutionsOf<v>, k> & {\\n    [innerKey in keyof v as innerKey extends \\\"root\\\" ? k : never]: v[innerKey];\\n} : {\\n    [_ in k]: v;\\n};\\ntype prefixKeys<o, prefix extends string> = {\\n    [k in keyof o & string as `${prefix}.${k}`]: o[k];\\n} & unknown;\\ntype PrivateDeclaration<key extends string = string> = `#${key}`;\\ntype InternalResolution = BaseRoot | GenericRoot | InternalModule;\\ntype toInternalScope<$> = BaseScope<{\\n    [k in keyof $]: $[k] extends {\\n        [arkKind]: infer kind;\\n    } ? [\\n        $[k]\\n    ] extends [anyOrNever] ? BaseRoot : kind extends \\\"generic\\\" ? GenericRoot : kind extends \\\"module\\\" ? InternalModule : never : BaseRoot;\\n}>;\\ntype CachedResolution = NodeId | BaseRoot | GenericRoot;\\ndeclare const writeDuplicateAliasError: <alias extends string>(alias: alias) => writeDuplicateAliasError<alias>;\\ntype writeDuplicateAliasError<alias extends string> = `#${alias} duplicates public alias ${alias}`;\\ntype AliasDefEntry = [name: string, defValue: unknown];\\ntype GlobalOnlyConfigOptionName = satisfy<keyof ArkSchemaConfig, \\\"dateAllowsInvalid\\\" | \\\"numberAllowsNaN\\\" | \\\"onUndeclaredKey\\\" | \\\"keywords\\\">;\\ninterface ScopeOnlyConfigOptions {\\n    name?: string;\\n    prereducedAliases?: boolean;\\n}\\ninterface ArkSchemaScopeConfig extends Omit<ArkSchemaConfig, GlobalOnlyConfigOptionName>, ScopeOnlyConfigOptions {\\n}\\ninterface ResolvedScopeConfig extends ResolvedConfig, ScopeOnlyConfigOptions {\\n}\\ntype PrecompiledReferences = {\\n    [k: `${string}Allows`]: TraverseAllows;\\n    [k: `${string}Apply`]: TraverseApply;\\n    [k: `${string}Optimistic`]: (data: unknown) => unknown;\\n};\\ndeclare abstract class BaseScope<$ extends {} = {}> {\\n    readonly config: ArkSchemaScopeConfig;\\n    readonly resolvedConfig: ResolvedScopeConfig;\\n    readonly name: string;\\n    get [arkKind](): \\\"scope\\\";\\n    readonly referencesById: {\\n        [id: string]: BaseNode;\\n    };\\n    references: readonly BaseNode[];\\n    readonly resolutions: {\\n        [alias: string]: CachedResolution | undefined;\\n    };\\n    exportedNames: string[];\\n    readonly aliases: Record<string, unknown>;\\n    protected resolved: boolean;\\n    readonly nodesByHash: Record<string, BaseNode>;\\n    readonly intrinsic: Omit<typeof $ark.intrinsic, `json${string}`>;\\n    constructor(\\n    /** The set of names defined at the root-level of the scope mapped to their\\n     * corresponding definitions.**/\\n    def: Record<string, unknown>, config?: ArkSchemaScopeConfig);\\n    protected cacheGetter<name extends keyof this>(name: name, value: this[name]): this[name];\\n    get internal(): this;\\n    private _json;\\n    get json(): JsonStructure;\\n    defineSchema<def extends RootSchema>(def: def): def;\\n    generic: GenericRootParser;\\n    units: (values: array, opts?: BaseParseOptions) => BaseRoot;\\n    protected lazyResolutions: Alias.Node[];\\n    lazilyResolve(resolve: () => BaseRoot, syntheticAlias?: string): Alias.Node;\\n    schema: InternalSchemaParser;\\n    parseSchema: InternalSchemaParser;\\n    protected preparseNode(kinds: NodeKind | listable<RootKind>, schema: unknown, opts: BaseParseOptions): BaseNode | NodeParseContextInput;\\n    bindReference<reference extends BaseNode | GenericRoot>(reference: reference): reference;\\n    resolveRoot(name: string): BaseRoot;\\n    maybeResolveRoot(name: string): BaseRoot | undefined;\\n    /** If name is a valid reference to a submodule alias, return its resolution  */\\n    protected maybeResolveSubalias(name: string): BaseRoot | GenericRoot | undefined;\\n    get ambient(): InternalModule;\\n    maybeResolve(name: string): Exclude<CachedResolution, string> | undefined;\\n    protected createParseContext<input extends BaseParseContextInput>(input: input): input & AttachedParseContext;\\n    traversal(root: unknown): Traversal;\\n    import(): SchemaModule<{\\n        [k in exportedNameOf<$> as PrivateDeclaration<k>]: $[k];\\n    }>;\\n    import<names extends exportedNameOf<$>[]>(...names: names): SchemaModule<{\\n        [k in names[number] as PrivateDeclaration<k>]: $[k];\\n    } & unknown>;\\n    precompilation: string | undefined;\\n    private _exportedResolutions;\\n    private _exports;\\n    export(): SchemaModule<{\\n        [k in exportedNameOf<$>]: $[k];\\n    }>;\\n    export<names extends exportedNameOf<$>[]>(...names: names): SchemaModule<{\\n        [k in names[number]]: $[k];\\n    } & unknown>;\\n    resolve<name extends exportedNameOf<$>>(name: name): instantiateRoot<$[name]>;\\n    node: <kinds extends NodeKind | array<RootKind>, prereduced extends boolean = false>(kinds: kinds, nodeSchema: NodeSchema<flattenListable<kinds>>, opts?: BaseParseOptions<prereduced>) => nodeOfKind<prereduced extends true ? flattenListable<kinds> : reducibleKindOf<flattenListable<kinds>>>;\\n    parse: (def: unknown, opts?: BaseParseOptions) => BaseRoot;\\n    parseDefinition(def: unknown, opts?: BaseParseOptions): BaseRoot;\\n    finalize<node extends BaseRoot>(node: node): node;\\n    protected abstract preparseOwnDefinitionFormat(def: unknown, opts: BaseParseOptions): BaseRoot | BaseParseContextInput;\\n    abstract parseOwnDefinitionFormat(def: unknown, ctx: BaseParseContext): BaseRoot;\\n    protected abstract preparseOwnAliasEntry(k: string, v: unknown): AliasDefEntry;\\n    protected abstract normalizeRootScopeValue(resolution: unknown): unknown;\\n}\\ndeclare class SchemaScope<$ extends {} = {}> extends BaseScope<$> {\\n    parseOwnDefinitionFormat(def: unknown, ctx: NodeParseContext): BaseRoot;\\n    protected preparseOwnDefinitionFormat(schema: RootSchema, opts: BaseParseOptions): BaseRoot | NodeParseContextInput;\\n    protected preparseOwnAliasEntry(k: string, v: unknown): AliasDefEntry;\\n    protected normalizeRootScopeValue(v: unknown): unknown;\\n}\\ntype instantiateAliases<aliases> = {\\n    [k in keyof aliases]: aliases[k] extends InternalResolution ? aliases[k] : BaseRoot;\\n} & unknown;\\ntype SchemaScopeParser = <const aliases>(aliases: {\\n    [k in keyof aliases]: conform<aliases[k], RootSchema | PreparsedNodeResolution>;\\n}, config?: ArkSchemaScopeConfig) => BaseScope<instantiateAliases<aliases>>;\\ndeclare const schemaScope: SchemaScopeParser;\\ntype InternalSchemaParser = (schema: RootSchema, opts?: BaseParseOptions) => BaseRoot;\\ndeclare const rootSchemaScope: SchemaScope;\\ndeclare const parseAsSchema: (def: unknown, opts?: BaseParseOptions) => BaseRoot | ParseError;\\ntype RootExportCache = Record<string, BaseRoot | GenericRoot | RootModule | undefined>;\\ndeclare const writeUnresolvableMessage: <token extends string>(token: token) => writeUnresolvableMessage<token>;\\ntype writeUnresolvableMessage<token extends string> = `'${token}' is unresolvable`;\\ndeclare const writeNonSubmoduleDotMessage: <name extends string>(name: name) => writeNonSubmoduleDotMessage<name>;\\ntype writeNonSubmoduleDotMessage<name extends string> = `'${name}' must reference a module to be accessed using dot syntax`;\\ndeclare const writeMissingSubmoduleAccessMessage: <name extends string>(name: name) => writeMissingSubmoduleAccessMessage<name>;\\ntype writeMissingSubmoduleAccessMessage<name extends string> = `Reference to submodule '${name}' must specify an alias`;\\ndeclare const rootSchema: BaseScope[\\\"schema\\\"];\\ndeclare const node: BaseScope[\\\"node\\\"];\\ndeclare const defineSchema: BaseScope[\\\"defineSchema\\\"];\\ndeclare const genericNode: BaseScope[\\\"generic\\\"];\\n\\ndeclare class OptionalNode extends BaseProp<\\\"optional\\\"> {\\n    constructor(...args: ConstructorParameters<typeof BaseProp>);\\n    get rawIn(): OptionalNode;\\n    get outProp(): Prop.Node;\\n    expression: string;\\n    defaultValueMorph: Morph | undefined;\\n    defaultValueMorphRef: string | undefined;\\n}\\ndeclare namespace Optional {\\n    interface Schema extends Prop.Schema {\\n        default?: unknown;\\n    }\\n    interface Inner extends Prop.Inner {\\n        default?: unknown;\\n    }\\n    type Declaration = declareNode<Prop.Declaration<\\\"optional\\\"> & {\\n        schema: Schema;\\n        normalizedSchema: Schema;\\n        inner: Inner;\\n    }>;\\n    type Node = OptionalNode;\\n    namespace Node {\\n        type withDefault = requireKeys<Node, \\\"default\\\" | \\\"defaultValueMorph\\\" | \\\"defaultValueMorphRef\\\">;\\n    }\\n}\\ndeclare const Optional: {\\n    implementation: nodeImplementationOf<{\\n        reducibleTo: \\\"optional\\\";\\n        errorContext: null;\\n        kind: \\\"optional\\\";\\n        prerequisite: object;\\n        intersectionIsOpen: true;\\n        childKind: RootKind;\\n        schema: Optional.Schema;\\n        normalizedSchema: Optional.Schema;\\n        inner: Optional.Inner;\\n    }>;\\n    Node: typeof OptionalNode;\\n};\\ndeclare const computeDefaultValueMorph: (key: PropertyKey, value: BaseRoot, defaultInput: unknown) => Morph<any>;\\ndeclare const assertDefaultValueAssignability: (node: BaseRoot, value: unknown, key: PropertyKey | null) => unknown;\\ntype writeUnassignableDefaultValueMessage<baseDef extends string, defaultValue extends string> = `Default value ${defaultValue} must be assignable to ${baseDef}`;\\ndeclare const writeNonPrimitiveNonFunctionDefaultValueMessage: (key: PropertyKey | null) => string;\\n\\ndeclare class RequiredNode extends BaseProp<\\\"required\\\"> {\\n    expression: string;\\n    errorContext: NodeErrorContextInput<\\\"required\\\">;\\n    compiledErrorContext: string;\\n}\\ndeclare namespace Required$1 {\\n    interface ErrorContext extends BaseErrorContext<\\\"required\\\"> {\\n        missingValueDescription: string;\\n    }\\n    interface Schema extends Prop.Schema {\\n    }\\n    interface Inner extends Prop.Inner {\\n    }\\n    type Declaration = declareNode<Prop.Declaration<\\\"required\\\"> & {\\n        schema: Schema;\\n        normalizedSchema: Schema;\\n        inner: Inner;\\n        errorContext: ErrorContext;\\n    }>;\\n    type Node = RequiredNode;\\n}\\ndeclare const Required$1: {\\n    implementation: nodeImplementationOf<{\\n        reducibleTo: \\\"required\\\";\\n        kind: \\\"required\\\";\\n        prerequisite: object;\\n        intersectionIsOpen: true;\\n        childKind: RootKind;\\n        schema: Required$1.Schema;\\n        normalizedSchema: Required$1.Schema;\\n        inner: Required$1.Inner;\\n        errorContext: Required$1.ErrorContext;\\n    }>;\\n    Node: typeof RequiredNode;\\n};\\n\\ndeclare namespace Prop {\\n    type Kind = \\\"required\\\" | \\\"optional\\\";\\n    type Node = nodeOfKind<Kind>;\\n    interface Schema extends BaseNormalizedSchema {\\n        readonly key: Key;\\n        readonly value: RootSchema;\\n    }\\n    interface Inner {\\n        readonly key: Key;\\n        readonly value: BaseRoot;\\n    }\\n    interface Declaration<kind extends Kind = Kind> {\\n        kind: kind;\\n        prerequisite: object;\\n        intersectionIsOpen: true;\\n        childKind: RootKind;\\n    }\\n}\\ndeclare const intersectProps: (l: nodeOfKind<Prop.Kind>, r: nodeOfKind<Prop.Kind>, ctx: IntersectionContext) => nodeOfKind<Prop.Kind> | Disjoint | null;\\ndeclare abstract class BaseProp<kind extends Prop.Kind = Prop.Kind> extends BaseConstraint<kind extends \\\"required\\\" ? Required$1.Declaration : Optional.Declaration> {\\n    required: boolean;\\n    optional: boolean;\\n    impliedBasis: BaseRoot;\\n    serializedKey: string;\\n    compiledKey: string;\\n    flatRefs: FlatRef[];\\n    protected _transform(mapper: DeepNodeTransformation, ctx: DeepNodeTransformContext): BaseNode | null;\\n    hasDefault(): this is Optional.Node.withDefault;\\n    traverseAllows: TraverseAllows<object>;\\n    traverseApply: TraverseApply<object>;\\n    compile(js: NodeCompiler): void;\\n}\\ndeclare const writeDefaultIntersectionMessage: (lValue: unknown, rValue: unknown) => string;\\n\\ndeclare class IndexNode extends BaseConstraint<Index.Declaration> {\\n    impliedBasis: BaseRoot;\\n    expression: string;\\n    flatRefs: FlatRef<BaseRoot<InternalRootDeclaration>>[];\\n    traverseAllows: TraverseAllows<object>;\\n    traverseApply: TraverseApply<object>;\\n    protected _transform(mapper: DeepNodeTransformation, ctx: DeepNodeTransformContext): BaseNode | null;\\n    compile(): void;\\n}\\ndeclare namespace Index {\\n    type KeyKind = Exclude<RootKind, \\\"unit\\\">;\\n    type KeyNode = nodeOfKind<KeyKind>;\\n    interface Schema extends BaseNormalizedSchema {\\n        readonly signature: RootSchema<KeyKind>;\\n        readonly value: RootSchema;\\n    }\\n    interface Inner {\\n        readonly signature: KeyNode;\\n        readonly value: BaseRoot;\\n    }\\n    interface Declaration extends declareNode<{\\n        kind: \\\"index\\\";\\n        schema: Schema;\\n        normalizedSchema: Schema;\\n        inner: Inner;\\n        prerequisite: object;\\n        intersectionIsOpen: true;\\n        childKind: RootKind;\\n    }> {\\n    }\\n    type Node = IndexNode;\\n}\\ndeclare const Index: {\\n    implementation: nodeImplementationOf<Index.Declaration>;\\n    Node: typeof IndexNode;\\n};\\ndeclare const writeEnumerableIndexBranches: (keys: string[]) => string;\\ndeclare const writeInvalidPropertyKeyMessage: <indexSchema extends string>(indexSchema: indexSchema) => writeInvalidPropertyKeyMessage<indexSchema>;\\ntype writeInvalidPropertyKeyMessage<indexSchema extends string> = `Indexed key definition '${indexSchema}' must be a string or symbol`;\\n\\ndeclare class MaxLengthNode extends BaseRange<MaxLength.Declaration> {\\n    readonly impliedBasis: BaseRoot;\\n    traverseAllows: TraverseAllows<LengthBoundableData>;\\n    reduceJsonSchema(schema: JsonSchema.LengthBoundable): JsonSchema.LengthBoundable;\\n}\\ndeclare namespace MaxLength {\\n    interface Inner extends BaseRangeInner {\\n        rule: number;\\n    }\\n    interface NormalizedSchema extends UnknownNormalizedRangeSchema {\\n        rule: number;\\n    }\\n    interface ExpandedSchema extends UnknownExpandedRangeSchema {\\n        rule: number;\\n    }\\n    type Schema = ExpandedSchema | number;\\n    interface ErrorContext extends BaseErrorContext<\\\"maxLength\\\">, Inner {\\n    }\\n    interface Declaration extends declareNode<{\\n        kind: \\\"maxLength\\\";\\n        schema: Schema;\\n        reducibleTo: \\\"exactLength\\\";\\n        normalizedSchema: NormalizedSchema;\\n        inner: Inner;\\n        prerequisite: LengthBoundableData;\\n        errorContext: ErrorContext;\\n    }> {\\n    }\\n    type Node = MaxLengthNode;\\n}\\ndeclare const MaxLength: {\\n    implementation: nodeImplementationOf<MaxLength.Declaration>;\\n    Node: typeof MaxLengthNode;\\n};\\n\\ndeclare class MinLengthNode extends BaseRange<MinLength.Declaration> {\\n    readonly impliedBasis: BaseRoot;\\n    traverseAllows: TraverseAllows<LengthBoundableData>;\\n    reduceJsonSchema(schema: JsonSchema.LengthBoundable): JsonSchema.LengthBoundable;\\n}\\ndeclare namespace MinLength {\\n    interface Inner extends BaseRangeInner {\\n        rule: number;\\n    }\\n    interface NormalizedSchema extends UnknownNormalizedRangeSchema {\\n        rule: number;\\n    }\\n    interface ExpandedSchema extends UnknownExpandedRangeSchema {\\n        rule: number;\\n    }\\n    type Schema = ExpandedSchema | number;\\n    interface ErrorContext extends BaseErrorContext<\\\"minLength\\\">, Inner {\\n    }\\n    interface Declaration extends declareNode<{\\n        kind: \\\"minLength\\\";\\n        schema: Schema;\\n        normalizedSchema: NormalizedSchema;\\n        inner: Inner;\\n        prerequisite: LengthBoundableData;\\n        reducibleTo: \\\"intersection\\\";\\n        errorContext: ErrorContext;\\n    }> {\\n    }\\n    type Node = MinLengthNode;\\n}\\ndeclare const MinLength: {\\n    implementation: nodeImplementationOf<MinLength.Declaration>;\\n    Node: typeof MinLengthNode;\\n};\\n\\ndeclare class SequenceNode extends BaseConstraint<Sequence.Declaration> {\\n    impliedBasis: BaseRoot;\\n    tuple: SequenceTuple;\\n    prefixLength: number;\\n    defaultablesLength: number;\\n    optionalsLength: number;\\n    postfixLength: number;\\n    defaultablesAndOptionals: BaseRoot[];\\n    prevariadic: array<PrevariadicSequenceElement>;\\n    variadicOrPostfix: array<BaseRoot>;\\n    flatRefs: FlatRef[];\\n    protected addFlatRefs(): FlatRef[];\\n    isVariadicOnly: boolean;\\n    minVariadicLength: number;\\n    minLength: number;\\n    minLengthNode: MinLengthNode | null;\\n    maxLength: number | null;\\n    maxLengthNode: MaxLengthNode | ExactLengthNode | null;\\n    impliedSiblings: array<MaxLengthNode | MinLengthNode | ExactLengthNode>;\\n    defaultValueMorphs: Morph[];\\n    defaultValueMorphsReference: `$ark.${string}` | `$ark0.${string}` | `$ark${`1${string}` & `${bigint}`}.${string}` | `$ark${`4${string}` & `${bigint}`}.${string}` | `$ark${`2${string}` & `${bigint}`}.${string}` | `$ark${`3${string}` & `${bigint}`}.${string}` | `$ark${`5${string}` & `${bigint}`}.${string}` | `$ark${`6${string}` & `${bigint}`}.${string}` | `$ark${`7${string}` & `${bigint}`}.${string}` | `$ark${`8${string}` & `${bigint}`}.${string}` | `$ark${`9${string}` & `${bigint}`}.${string}` | undefined;\\n    protected elementAtIndex(data: array, index: number): SequenceElement;\\n    traverseAllows: TraverseAllows<array>;\\n    traverseApply: TraverseApply<array>;\\n    get element(): BaseRoot;\\n    compile(js: NodeCompiler): void;\\n    protected _transform(mapper: DeepNodeTransformation, ctx: DeepNodeTransformContext): BaseNode | null;\\n    expression: string;\\n    reduceJsonSchema(schema: JsonSchema.Array, ctx: ToJsonSchema.Context): JsonSchema.Array;\\n}\\ndeclare namespace Sequence {\\n    interface NormalizedSchema extends BaseNormalizedSchema {\\n        readonly prefix?: array<RootSchema>;\\n        readonly defaultables?: array<DefaultableSchema>;\\n        readonly optionals?: array<RootSchema>;\\n        readonly variadic?: RootSchema;\\n        readonly minVariadicLength?: number;\\n        readonly postfix?: array<RootSchema>;\\n    }\\n    type Schema = NormalizedSchema | RootSchema;\\n    type DefaultableSchema = [schema: RootSchema, defaultValue: unknown];\\n    type DefaultableElement = [node: BaseRoot, defaultValue: unknown];\\n    interface Inner {\\n        readonly prefix?: array<BaseRoot>;\\n        readonly defaultables?: array<DefaultableElement>;\\n        readonly optionals?: array<BaseRoot>;\\n        readonly variadic?: BaseRoot;\\n        readonly minVariadicLength?: number;\\n        readonly postfix?: array<BaseRoot>;\\n    }\\n    interface Declaration extends declareNode<{\\n        kind: \\\"sequence\\\";\\n        schema: Schema;\\n        normalizedSchema: NormalizedSchema;\\n        inner: Inner;\\n        prerequisite: array;\\n        reducibleTo: \\\"sequence\\\";\\n        childKind: RootKind;\\n    }> {\\n    }\\n    type Node = SequenceNode;\\n}\\ndeclare const Sequence: {\\n    implementation: nodeImplementationOf<Sequence.Declaration>;\\n    Node: typeof SequenceNode;\\n};\\ndeclare const postfixAfterOptionalOrDefaultableMessage = \\\"A postfix required element cannot follow an optional or defaultable element\\\";\\ntype postfixAfterOptionalOrDefaultableMessage = typeof postfixAfterOptionalOrDefaultableMessage;\\ndeclare const postfixWithoutVariadicMessage = \\\"A postfix element requires a variadic element\\\";\\ntype postfixWithoutVariadicMessage = typeof postfixWithoutVariadicMessage;\\ntype SequenceElement = PrevariadicSequenceElement | VariadicSequenceElement | PostfixSequenceElement;\\ntype SequenceElementKind = satisfy<keyof Sequence.Inner, SequenceElement[\\\"kind\\\"]>;\\ntype PrevariadicSequenceElement = PrefixSequenceElement | DefaultableSequenceElement | OptionalSequenceElement;\\ntype PrefixSequenceElement = {\\n    kind: \\\"prefix\\\";\\n    node: BaseRoot;\\n};\\ntype OptionalSequenceElement = {\\n    kind: \\\"optionals\\\";\\n    node: BaseRoot;\\n};\\ntype PostfixSequenceElement = {\\n    kind: \\\"postfix\\\";\\n    node: BaseRoot;\\n};\\ntype VariadicSequenceElement = {\\n    kind: \\\"variadic\\\";\\n    node: BaseRoot;\\n};\\ntype DefaultableSequenceElement = {\\n    kind: \\\"defaultables\\\";\\n    node: BaseRoot;\\n    default: unknown;\\n};\\ntype SequenceTuple = array<SequenceElement>;\\n\\n/**\\n * - `\\\"ignore\\\"` (default) - allow and preserve extra properties\\n * - `\\\"reject\\\"` - disallow extra properties\\n * - `\\\"delete\\\"` - clone and remove extra properties from output\\n */\\ntype UndeclaredKeyBehavior = \\\"ignore\\\" | UndeclaredKeyHandling;\\ntype UndeclaredKeyHandling = \\\"reject\\\" | \\\"delete\\\";\\ndeclare class StructureNode extends BaseConstraint<Structure.Declaration> {\\n    impliedBasis: BaseRoot;\\n    impliedSiblings: BaseConstraint<Constraint.Declaration>[];\\n    props: array<Prop.Node>;\\n    propsByKey: Record<Key, Prop.Node | undefined>;\\n    propsByKeyReference: RegisteredReference;\\n    expression: string;\\n    requiredKeys: Key[];\\n    optionalKeys: Key[];\\n    literalKeys: Key[];\\n    _keyof: BaseRoot | undefined;\\n    keyof(): BaseRoot;\\n    map(flatMapProp: PropFlatMapper): StructureNode;\\n    assertHasKeys(keys: array<KeyOrKeyNode>): void;\\n    get(indexer: GettableKeyOrNode, ...path: array<GettableKeyOrNode>): BaseRoot;\\n    pick(...keys: KeyOrKeyNode[]): StructureNode;\\n    omit(...keys: KeyOrKeyNode[]): StructureNode;\\n    optionalize(): StructureNode;\\n    require(): StructureNode;\\n    merge(r: StructureNode): StructureNode;\\n    private filterKeys;\\n    traverseAllows: TraverseAllows<object>;\\n    traverseApply: TraverseApply<object>;\\n    protected _traverse: (traversalKind: TraversalKind, data: object, ctx: InternalTraversal) => boolean;\\n    get defaultable(): Optional.Node.withDefault[];\\n    declaresKey: (k: Key) => boolean;\\n    _compileDeclaresKey(js: NodeCompiler): string;\\n    get structuralMorph(): Morph | undefined;\\n    structuralMorphRef: RegisteredReference | undefined;\\n    compile(js: NodeCompiler): unknown;\\n    protected compileExhaustiveEntry(js: NodeCompiler): NodeCompiler;\\n    reduceJsonSchema(schema: JsonSchema.Structure, ctx: ToJsonSchema.Context): JsonSchema.Structure;\\n    reduceObjectJsonSchema(schema: JsonSchema.Object, ctx: ToJsonSchema.Context): JsonSchema.Object;\\n}\\ntype PropFlatMapper = (entry: Prop.Node) => listable<MappedPropInner>;\\ntype MappedPropInner = BaseMappedPropInner | OptionalMappedPropInner;\\ninterface BaseMappedPropInner extends Required$1.Schema {\\n    kind?: \\\"required\\\" | \\\"optional\\\";\\n}\\ninterface OptionalMappedPropInner extends Optional.Schema {\\n    kind: \\\"optional\\\";\\n}\\ndeclare namespace Structure {\\n    interface Schema extends BaseNormalizedSchema {\\n        readonly optional?: readonly Optional.Schema[];\\n        readonly required?: readonly Required$1.Schema[];\\n        readonly index?: readonly Index.Schema[];\\n        readonly sequence?: Sequence.Schema;\\n        readonly undeclared?: UndeclaredKeyBehavior;\\n    }\\n    interface Inner {\\n        readonly optional?: readonly Optional.Node[];\\n        readonly required?: readonly Required$1.Node[];\\n        readonly index?: readonly Index.Node[];\\n        readonly sequence?: Sequence.Node;\\n        readonly undeclared?: UndeclaredKeyHandling;\\n    }\\n    namespace Inner {\\n        type mutable = makeRootAndArrayPropertiesMutable<Inner>;\\n    }\\n    interface Declaration extends declareNode<{\\n        kind: \\\"structure\\\";\\n        schema: Schema;\\n        normalizedSchema: Schema;\\n        inner: Inner;\\n        prerequisite: object;\\n        childKind: StructuralKind;\\n    }> {\\n    }\\n    type Node = StructureNode;\\n}\\ndeclare const Structure: {\\n    implementation: nodeImplementationOf<Structure.Declaration>;\\n    Node: typeof StructureNode;\\n};\\ndeclare const writeNumberIndexMessage: (indexExpression: string, sequenceExpression: string) => string;\\ntype NormalizedIndex = {\\n    index?: Index.Node;\\n    required?: Required$1.Node[];\\n    optional?: Optional.Node[];\\n};\\n/** extract enumerable named props from an index signature */\\ndeclare const normalizeIndex: (signature: BaseRoot, value: BaseRoot, $: BaseScope) => NormalizedIndex;\\ndeclare const typeKeyToString: (k: KeyOrKeyNode) => string;\\ndeclare const writeInvalidKeysMessage: <o extends string, keys extends array<KeyOrKeyNode>>(o: o, keys: keys) => string;\\ndeclare const writeDuplicateKeyMessage: <key extends Key>(key: key) => writeDuplicateKeyMessage<key>;\\ntype writeDuplicateKeyMessage<key extends Key> = `Duplicate key '${describe<key>}'`;\\n\\ndeclare abstract class InternalBasis<d extends InternalRootDeclaration = InternalRootDeclaration> extends BaseRoot<d> {\\n    abstract compiledCondition: string;\\n    abstract compiledNegation: string;\\n    structure: undefined;\\n    traverseApply: TraverseApply<d[\\\"prerequisite\\\"]>;\\n    get errorContext(): d[\\\"errorContext\\\"];\\n    get compiledErrorContext(): string;\\n    compile(js: NodeCompiler): void;\\n}\\n\\ndeclare class UnitNode extends InternalBasis<Unit.Declaration> {\\n    compiledValue: JsonPrimitive;\\n    serializedValue: string;\\n    compiledCondition: string;\\n    compiledNegation: string;\\n    expression: string;\\n    domain: Domain$1;\\n    get defaultShortDescription(): string;\\n    protected innerToJsonSchema(ctx: ToJsonSchema.Context): JsonSchema;\\n    traverseAllows: TraverseAllows;\\n}\\ndeclare namespace Unit {\\n    interface Schema<value = unknown> extends BaseNormalizedSchema {\\n        readonly unit: value;\\n    }\\n    interface Inner<value = unknown> {\\n        readonly unit: value;\\n    }\\n    interface ErrorContext<value = unknown> extends BaseErrorContext<\\\"unit\\\">, Inner<value> {\\n    }\\n    interface Declaration extends declareNode<{\\n        kind: \\\"unit\\\";\\n        schema: Schema;\\n        normalizedSchema: Schema;\\n        inner: Inner;\\n        errorContext: ErrorContext;\\n    }> {\\n    }\\n    type Node = UnitNode;\\n}\\ndeclare const Unit: {\\n    implementation: nodeImplementationOf<Unit.Declaration>;\\n    Node: typeof UnitNode;\\n};\\n\\ndeclare class DomainNode extends InternalBasis<Domain.Declaration> {\\n    private readonly requiresNaNCheck;\\n    readonly traverseAllows: TraverseAllows;\\n    readonly compiledCondition: string;\\n    readonly compiledNegation: string;\\n    readonly expression: string;\\n    get nestableExpression(): string;\\n    get defaultShortDescription(): string;\\n    protected innerToJsonSchema(ctx: ToJsonSchema.Context): JsonSchema.Constrainable;\\n}\\ntype Domain = Domain$1;\\ndeclare namespace Domain {\\n    type Enumerable = \\\"undefined\\\" | \\\"null\\\" | \\\"boolean\\\";\\n    type NonEnumerable = Exclude<Domain, Enumerable>;\\n    interface Inner<domain extends NonEnumerable = NonEnumerable> {\\n        readonly domain: domain;\\n        readonly numberAllowsNaN?: boolean;\\n    }\\n    interface NormalizedSchema<domain extends NonEnumerable = NonEnumerable> extends BaseNormalizedSchema, Inner<domain> {\\n    }\\n    type Schema<domain extends NonEnumerable = NonEnumerable> = domain | NormalizedSchema<domain>;\\n    interface ErrorContext extends BaseErrorContext<\\\"domain\\\">, Inner {\\n    }\\n    interface Declaration extends declareNode<{\\n        kind: \\\"domain\\\";\\n        schema: Schema;\\n        normalizedSchema: NormalizedSchema;\\n        inner: Inner;\\n        errorContext: ErrorContext;\\n    }> {\\n    }\\n    type Node = DomainNode;\\n}\\ndeclare const Domain: {\\n    implementation: nodeImplementationOf<Domain.Declaration>;\\n    Node: typeof DomainNode;\\n    writeBadAllowNanMessage: (actual: Exclude<Domain.NonEnumerable, \\\"number\\\">) => string;\\n};\\n\\ndeclare class UnionNode extends BaseRoot<Union.Declaration> {\\n    isBoolean: boolean;\\n    get branchGroups(): BaseRoot[];\\n    unitBranches: (MorphNode | UnitNode)[];\\n    discriminant: Discriminant<DiscriminantKind> | null;\\n    discriminantJson: JsonStructure | null;\\n    expression: string;\\n    createBranchedOptimisticRootApply(): BaseNode[\\\"rootApply\\\"];\\n    get shallowMorphs(): array<Morph>;\\n    get defaultShortDescription(): string;\\n    protected innerToJsonSchema(ctx: ToJsonSchema.Context): JsonSchema;\\n    traverseAllows: TraverseAllows;\\n    traverseApply: TraverseApply;\\n    traverseOptimistic: (data: unknown) => unknown;\\n    compile(js: NodeCompiler): void;\\n    private compileIndiscriminable;\\n    get nestableExpression(): string;\\n    discriminate(): Discriminant | null;\\n}\\ndeclare namespace Union {\\n    type ChildKind = UnionChildKind;\\n    type ChildSchema = NodeSchema<ChildKind>;\\n    type ChildNode = nodeOfKind<ChildKind>;\\n    type Schema = NormalizedSchema | readonly RootSchema[];\\n    interface NormalizedSchema extends BaseNormalizedSchema {\\n        readonly branches: array<RootSchema>;\\n        readonly ordered?: true;\\n    }\\n    interface Inner {\\n        readonly branches: readonly ChildNode[];\\n        readonly ordered?: true;\\n    }\\n    interface ErrorContext extends BaseErrorContext<\\\"union\\\"> {\\n        errors: readonly ArkError[];\\n    }\\n    interface Declaration extends declareNode<{\\n        kind: \\\"union\\\";\\n        schema: Schema;\\n        normalizedSchema: NormalizedSchema;\\n        inner: Inner;\\n        errorContext: ErrorContext;\\n        reducibleTo: RootKind;\\n        childKind: UnionChildKind;\\n    }> {\\n    }\\n    type Node = UnionNode;\\n}\\ndeclare const Union: {\\n    implementation: nodeImplementationOf<Union.Declaration>;\\n    Node: typeof UnionNode;\\n};\\ntype DescribeBranchesOptions = {\\n    delimiter?: string;\\n    finalDelimiter?: string;\\n};\\ndeclare const describeBranches: (descriptions: string[], opts?: DescribeBranchesOptions) => string;\\ndeclare const intersectBranches: (l: readonly Union.ChildNode[], r: readonly Union.ChildNode[], ctx: IntersectionContext) => readonly Union.ChildNode[] | Disjoint;\\ndeclare const reduceBranches: ({ branches, ordered }: Union.Inner) => readonly Union.ChildNode[];\\ntype CaseKey<kind extends DiscriminantKind = DiscriminantKind> = DiscriminantKind extends kind ? string : DiscriminantKinds[kind] | \\\"default\\\";\\ntype DiscriminantLocation<kind extends DiscriminantKind = DiscriminantKind> = {\\n    path: PropertyKey[];\\n    optionallyChainedPropString: string;\\n    kind: kind;\\n};\\ninterface Discriminant<kind extends DiscriminantKind = DiscriminantKind> extends DiscriminantLocation<kind> {\\n    cases: DiscriminatedCases<kind>;\\n}\\ntype CaseContext = {\\n    branchIndices: number[];\\n    condition: nodeOfKind<DiscriminantKind> | Domain.Enumerable;\\n};\\ntype CaseDiscriminant = nodeOfKind<DiscriminantKind> | Domain.Enumerable;\\ntype DiscriminatedCases<kind extends DiscriminantKind = DiscriminantKind> = {\\n    [caseKey in CaseKey<kind>]: BaseRoot | true;\\n};\\ntype DiscriminantKinds = {\\n    domain: Domain;\\n    unit: SerializedPrimitive | RegisteredReference;\\n};\\ntype DiscriminantKind = show<keyof DiscriminantKinds>;\\ndeclare const pruneDiscriminant: (discriminantBranch: BaseRoot, discriminantCtx: DiscriminantLocation) => BaseRoot | null;\\ndeclare const writeIndiscriminableMorphMessage: (lDescription: string, rDescription: string) => string;\\ndeclare const writeOrderedIntersectionMessage: (lDescription: string, rDescription: string) => string;\\n\\ninterface InternalRootDeclaration extends BaseNodeDeclaration {\\n    kind: RootKind;\\n}\\ndeclare abstract class BaseRoot<\\n/** @ts-ignore cast variance */\\nout d extends InternalRootDeclaration = InternalRootDeclaration> extends BaseNode<d> implements StandardSchemaV1, StandardJSONSchemaV1 {\\n    readonly [arkKind]: \\\"root\\\";\\n    readonly [inferred]: unknown;\\n    constructor(attachments: UnknownAttachments, $: BaseScope);\\n    get rawIn(): BaseRoot;\\n    get rawOut(): BaseRoot;\\n    get internal(): this;\\n    get \\\"~standard\\\"(): StandardSchemaV1.ArkTypeProps;\\n    as(): this;\\n    brand(name: string): this;\\n    readonly(): this;\\n    readonly branches: readonly nodeOfKind<Union.ChildKind>[];\\n    distribute<mapOut, reduceOut = mapOut[]>(mapBranch: (branch: nodeOfKind<Union.ChildKind>, i: number, branches: array<nodeOfKind<Union.ChildKind>>) => mapOut, reduceMapped?: (mappedBranches: mapOut[]) => reduceOut): reduceOut;\\n    abstract get defaultShortDescription(): string;\\n    get shortDescription(): string;\\n    toJsonSchema(opts?: ToJsonSchema.Options): JsonSchema;\\n    toJsonSchemaRecurse(ctx: ToJsonSchema.Context): JsonSchema;\\n    get alwaysExpandJsonSchema(): boolean;\\n    protected toResolvedJsonSchema(ctx: ToJsonSchema.Context): JsonSchema;\\n    protected abstract innerToJsonSchema(ctx: ToJsonSchema.Context): JsonSchema;\\n    intersect(r: unknown): BaseRoot | Disjoint;\\n    rawIntersect(r: BaseRoot): BaseRoot;\\n    toNeverIfDisjoint(): BaseRoot;\\n    and(r: unknown): BaseRoot;\\n    rawAnd(r: BaseRoot): BaseRoot;\\n    or(r: unknown): BaseRoot;\\n    rawOr(r: BaseRoot): BaseRoot;\\n    map(flatMapEntry: PropFlatMapper): BaseRoot;\\n    pick(...keys: KeyOrKeyNode[]): BaseRoot;\\n    omit(...keys: KeyOrKeyNode[]): BaseRoot;\\n    required(): BaseRoot;\\n    partial(): BaseRoot;\\n    private _keyof?;\\n    keyof(): BaseRoot;\\n    get props(): Prop.Node[];\\n    merge(r: unknown): BaseRoot;\\n    private applyStructuralOperation;\\n    get(...path: GettableKeyOrNode[]): BaseRoot;\\n    extract(r: unknown): BaseRoot;\\n    exclude(r: unknown): BaseRoot;\\n    array(): BaseRoot;\\n    overlaps(r: unknown): boolean;\\n    extends(r: unknown): boolean;\\n    ifExtends(r: unknown): BaseRoot | undefined;\\n    subsumes(r: unknown): boolean;\\n    configure(meta: TypeMeta.MappableInput, selector?: NodeSelector): this;\\n    describe(description: string, selector?: NodeSelector): this;\\n    optional(): [this, \\\"?\\\"];\\n    default(thunkableValue: unknown): [this, \\\"=\\\", unknown];\\n    from(input: unknown): unknown;\\n    protected _pipe(...morphs: Morph[]): BaseRoot;\\n    protected tryPipe(...morphs: Morph[]): BaseRoot;\\n    pipe: ((...morphs: Morph[]) => BaseRoot) & {\\n        try: (...morphs: Morph[]) => BaseRoot;\\n    };\\n    to(def: unknown): BaseRoot;\\n    private toNode;\\n    rawPipeOnce(morph: Morph): BaseRoot;\\n    narrow(predicate: Predicate): BaseRoot;\\n    constrain<kind extends Constraint.PrimitiveKind>(kind: kind, schema: NodeSchema<kind>): BaseRoot;\\n    constrainIn<kind extends Constraint.PrimitiveKind>(kind: kind, schema: NodeSchema<kind>): BaseRoot;\\n    constrainOut<kind extends Constraint.PrimitiveKind>(kind: kind, schema: NodeSchema<kind>): BaseRoot;\\n    private _constrain;\\n    onUndeclaredKey(cfg: UndeclaredKeyBehavior | UndeclaredKeyConfig): BaseRoot;\\n    hasEqualMorphs(r: BaseRoot): boolean;\\n    onDeepUndeclaredKey(behavior: UndeclaredKeyBehavior): BaseRoot;\\n    filter(predicate: Predicate): BaseRoot;\\n    divisibleBy(schema: Divisor.Schema): BaseRoot;\\n    matching(schema: Pattern.Schema): BaseRoot;\\n    atLeast(schema: InclusiveNumericRangeSchema): BaseRoot;\\n    atMost(schema: InclusiveNumericRangeSchema): BaseRoot;\\n    moreThan(schema: ExclusiveNumericRangeSchema): BaseRoot;\\n    lessThan(schema: ExclusiveNumericRangeSchema): BaseRoot;\\n    atLeastLength(schema: InclusiveNumericRangeSchema): BaseRoot;\\n    atMostLength(schema: InclusiveNumericRangeSchema): BaseRoot;\\n    moreThanLength(schema: ExclusiveNumericRangeSchema): BaseRoot;\\n    lessThanLength(schema: ExclusiveNumericRangeSchema): BaseRoot;\\n    exactlyLength(schema: ExactLength.Schema): BaseRoot;\\n    atOrAfter(schema: InclusiveDateRangeSchema): BaseRoot;\\n    atOrBefore(schema: InclusiveDateRangeSchema): BaseRoot;\\n    laterThan(schema: ExclusiveDateRangeSchema): BaseRoot;\\n    earlierThan(schema: ExclusiveDateRangeSchema): BaseRoot;\\n}\\ntype UndeclaredKeyConfig = {\\n    rule: UndeclaredKeyBehavior;\\n    deep?: boolean;\\n};\\ndeclare const emptyBrandNameMessage = \\\"Expected a non-empty brand name after #\\\";\\ntype emptyBrandNameMessage = typeof emptyBrandNameMessage;\\ndeclare const writeInvalidJsonSchemaTargetMessage: (target: string) => string;\\ndeclare const exclusivizeRangeSchema: <schema extends UnknownRangeSchema>(schema: schema) => schema;\\ntype exclusivizeRangeSchema<schema extends UnknownRangeSchema> = schema extends LimitSchemaValue ? {\\n    rule: schema;\\n    exclusive: true;\\n} : schema;\\ndeclare const typeOrTermExtends: (t: unknown, base: unknown) => boolean;\\ntype intersectRoot<l extends RootKind, r extends NodeKind> = [\\n    l,\\n    r\\n] extends [r, l] ? l : asymmetricIntersectionOf<l, r> | asymmetricIntersectionOf<r, l>;\\ntype asymmetricIntersectionOf<l extends NodeKind, r extends NodeKind> = l extends unknown ? r extends kindRightOf<l> ? l | reducibleKindOf<l> : never : never;\\ntype schemaKindRightOf<kind extends RootKind> = Extract<kindRightOf<kind>, RootKind>;\\ntype schemaKindOrRightOf<kind extends RootKind> = kind | schemaKindRightOf<kind>;\\ntype StructuralOperationBranchResultByName = {\\n    keyof: Union.ChildNode;\\n    pick: Union.ChildNode;\\n    omit: Union.ChildNode;\\n    get: Union.ChildNode;\\n    map: Union.ChildNode;\\n    required: Union.ChildNode;\\n    partial: Union.ChildNode;\\n    merge: Union.ChildNode;\\n    props: array<Prop.Node>;\\n};\\ntype StructuralOperationName = keyof StructuralOperationBranchResultByName;\\ndeclare const writeLiteralUnionEntriesMessage: (expression: string) => string;\\ndeclare const writeNonStructuralOperandMessage: <operation extends StructuralOperationName, operand extends string>(operation: operation, operand: operand) => writeNonStructuralOperandMessage<operation, operand>;\\ntype writeNonStructuralOperandMessage<operation extends StructuralOperationName, operand extends string> = `${operation} operand must be an object (was ${operand})`;\\n\\ndeclare const basisKinds: readonly [\\\"unit\\\", \\\"proto\\\", \\\"domain\\\"];\\ntype BasisKind = (typeof basisKinds)[number];\\ndeclare const structuralKinds: readonly [\\\"required\\\", \\\"optional\\\", \\\"index\\\", \\\"sequence\\\"];\\ntype StructuralKind = (typeof structuralKinds)[number];\\ndeclare const prestructuralKinds: readonly [\\\"pattern\\\", \\\"divisor\\\", \\\"exactLength\\\", \\\"max\\\", \\\"min\\\", \\\"maxLength\\\", \\\"minLength\\\", \\\"before\\\", \\\"after\\\"];\\ntype PrestructuralKind = (typeof prestructuralKinds)[number];\\ndeclare const refinementKinds: readonly [\\\"pattern\\\", \\\"divisor\\\", \\\"exactLength\\\", \\\"max\\\", \\\"min\\\", \\\"maxLength\\\", \\\"minLength\\\", \\\"before\\\", \\\"after\\\", \\\"structure\\\", \\\"predicate\\\"];\\ntype RefinementKind = (typeof refinementKinds)[number];\\ndeclare const constraintKinds: readonly [\\\"pattern\\\", \\\"divisor\\\", \\\"exactLength\\\", \\\"max\\\", \\\"min\\\", \\\"maxLength\\\", \\\"minLength\\\", \\\"before\\\", \\\"after\\\", \\\"structure\\\", \\\"predicate\\\", \\\"required\\\", \\\"optional\\\", \\\"index\\\", \\\"sequence\\\"];\\ntype ConstraintKind = (typeof constraintKinds)[number];\\ndeclare const rootKinds: readonly [\\\"alias\\\", \\\"union\\\", \\\"morph\\\", \\\"unit\\\", \\\"intersection\\\", \\\"proto\\\", \\\"domain\\\"];\\ntype RootKind = (typeof rootKinds)[number];\\ntype NodeKind = RootKind | ConstraintKind;\\ntype orderedNodeKinds = [...typeof rootKinds, ...typeof constraintKinds];\\ndeclare const nodeKinds: orderedNodeKinds;\\ntype OpenNodeKind = {\\n    [k in NodeKind]: Declaration<k>[\\\"intersectionIsOpen\\\"] extends true ? k : never;\\n}[NodeKind];\\ntype ClosedNodeKind = Exclude<NodeKind, OpenNodeKind>;\\ntype PrimitiveKind = Exclude<RefinementKind | BasisKind, \\\"structure\\\">;\\ntype CompositeKind = Exclude<NodeKind, PrimitiveKind>;\\ntype OrderedNodeKinds = typeof nodeKinds;\\ndeclare const constraintKeys: KeySet<ConstraintKind>;\\ndeclare const structureKeys: keySetOf<Structure.Inner>;\\ntype RightsByKind = accumulateRightKinds<OrderedNodeKinds, {}>;\\ntype kindOrRightOf<kind extends NodeKind> = kind | kindRightOf<kind>;\\ntype kindLeftOf<kind extends NodeKind> = Exclude<NodeKind, kindOrRightOf<kind>>;\\ntype kindOrLeftOf<kind extends NodeKind> = kind | kindLeftOf<kind>;\\ntype accumulateRightKinds<remaining extends readonly NodeKind[], result> = remaining extends (readonly [infer head extends NodeKind, ...infer tail extends NodeKind[]]) ? accumulateRightKinds<tail, result & {\\n    [k in head]: tail[number];\\n}> : result;\\ninterface InternalIntersectionOptions {\\n    pipe: boolean;\\n}\\ninterface IntersectionContext extends InternalIntersectionOptions {\\n    $: BaseScope;\\n    invert: boolean;\\n}\\ntype ConstraintIntersection<lKind extends ConstraintKind, rKind extends kindOrRightOf<lKind>> = (l: nodeOfKind<lKind>, r: nodeOfKind<rKind>, ctx: IntersectionContext) => BaseNode | Disjoint | null;\\ntype ConstraintIntersectionMap<kind extends ConstraintKind> = show<{\\n    [_ in kind]: ConstraintIntersection<kind, kind>;\\n} & {\\n    [rKind in kindRightOf<kind>]?: ConstraintIntersection<kind, rKind>;\\n}>;\\ntype RootIntersection<lKind extends RootKind, rKind extends schemaKindOrRightOf<lKind>> = (l: nodeOfKind<lKind>, r: nodeOfKind<rKind>, ctx: IntersectionContext) => BaseRoot | Disjoint;\\ntype TypeIntersectionMap<kind extends RootKind> = {\\n    [rKind in schemaKindOrRightOf<kind>]: RootIntersection<kind, rKind>;\\n};\\ntype IntersectionMap<kind extends NodeKind> = kind extends RootKind ? TypeIntersectionMap<kind> : ConstraintIntersectionMap<kind & ConstraintKind>;\\ntype UnknownIntersectionMap = {\\n    [k in NodeKind]?: (l: BaseNode, r: BaseNode, ctx: IntersectionContext) => UnknownIntersectionResult;\\n};\\ntype UnknownIntersectionResult = BaseNode | Disjoint | null;\\ntype PrecedenceByKind = {\\n    [i in arrayIndexOf<OrderedNodeKinds> as OrderedNodeKinds[i]]: i;\\n};\\ndeclare const precedenceByKind: PrecedenceByKind;\\ndeclare const isNodeKind: (value: unknown) => value is NodeKind;\\ndeclare function assertNodeKind<kind extends NodeKind>(value: BaseNode, kind: kind): asserts value is nodeOfKind<kind>;\\ntype precedenceOfKind<kind extends NodeKind> = PrecedenceByKind[kind];\\ndeclare const precedenceOfKind: <kind extends NodeKind>(kind: kind) => precedenceOfKind<kind>;\\ntype kindRightOf<kind extends NodeKind> = RightsByKind[kind];\\ndeclare const schemaKindsRightOf: <kind extends RootKind>(kind: kind) => schemaKindRightOf<kind>[];\\ndeclare const unionChildKinds: readonly [...(\\\"intersection\\\" | \\\"morph\\\" | \\\"unit\\\" | \\\"proto\\\" | \\\"domain\\\")[], \\\"alias\\\"];\\ntype UnionChildKind = (typeof unionChildKinds)[number];\\ndeclare const morphChildKinds: readonly [...(\\\"intersection\\\" | \\\"unit\\\" | \\\"proto\\\" | \\\"domain\\\")[], \\\"alias\\\"];\\ntype MorphChildKind = (typeof morphChildKinds)[number];\\ntype keySchemaDefinitions<d extends BaseNodeDeclaration> = {\\n    [k in keyRequiringSchemaDefinition<d>]: NodeKeyImplementation<d, k>;\\n};\\ntype keyRequiringSchemaDefinition<d extends BaseNodeDeclaration> = Exclude<keyof d[\\\"normalizedSchema\\\"], keyof BaseNormalizedSchema>;\\ndeclare const defaultValueSerializer: (v: unknown) => Json;\\ntype NodeKeyImplementation<d extends BaseNodeDeclaration, k extends keyof d[\\\"normalizedSchema\\\"], instantiated = k extends keyof d[\\\"inner\\\"] ? Exclude<d[\\\"inner\\\"][k], undefined> : never> = requireKeys<{\\n    preserveUndefined?: true;\\n    child?: boolean | ((value: instantiated) => BaseNode[]);\\n    serialize?: (schema: instantiated) => Json;\\n    reduceIo?: (ioKind: \\\"in\\\" | \\\"out\\\", inner: makeRootAndArrayPropertiesMutable<d[\\\"inner\\\"]>, value: d[\\\"inner\\\"][k]) => void;\\n    parse?: (schema: Exclude<d[\\\"normalizedSchema\\\"][k], undefined>, ctx: NodeParseContext<d[\\\"kind\\\"]>) => instantiated | undefined;\\n}, (d[\\\"normalizedSchema\\\"][k] extends instantiated | undefined ? never : \\\"parse\\\") | ([instantiated] extends [listable<BaseNode>] ? \\\"child\\\" : never)>;\\ninterface CommonNodeImplementationInput<d extends BaseNodeDeclaration> {\\n    kind: d[\\\"kind\\\"];\\n    keys: keySchemaDefinitions<d>;\\n    normalize: (schema: d[\\\"schema\\\"], $: BaseScope) => d[\\\"normalizedSchema\\\"];\\n    applyConfig?: (schema: d[\\\"normalizedSchema\\\"], config: ResolvedScopeConfig) => d[\\\"normalizedSchema\\\"];\\n    hasAssociatedError: d[\\\"errorContext\\\"] extends null ? false : true;\\n    finalizeInnerJson?: (json: {\\n        [k in keyof d[\\\"inner\\\"]]: Json;\\n    }) => JsonStructure;\\n    collapsibleKey?: keyof d[\\\"inner\\\"];\\n    reduce?: (inner: d[\\\"inner\\\"], $: BaseScope) => nodeOfKind<d[\\\"reducibleTo\\\"]> | Disjoint | undefined;\\n    obviatesBasisDescription?: d[\\\"kind\\\"] extends RefinementKind ? true : never;\\n    obviatesBasisExpression?: d[\\\"kind\\\"] extends RefinementKind ? true : never;\\n}\\ninterface UnknownNodeImplementation extends CommonNodeImplementationInput<BaseNodeDeclaration> {\\n    defaults: ResolvedUnknownNodeConfig;\\n    intersectionIsOpen: boolean;\\n    intersections: UnknownIntersectionMap;\\n    keys: Record<string, NodeKeyImplementation<any, any>>;\\n}\\ndeclare const compileObjectLiteral: (ctx: object) => string;\\ntype nodeImplementationOf<d extends BaseNodeDeclaration> = nodeImplementationInputOf<d> & {\\n    intersections: IntersectionMap<d[\\\"kind\\\"]>;\\n    intersectionIsOpen: d[\\\"intersectionIsOpen\\\"];\\n    defaults: Required<NodeConfig<d[\\\"kind\\\"]>>;\\n};\\ntype nodeImplementationInputOf<d extends BaseNodeDeclaration> = CommonNodeImplementationInput<d> & {\\n    intersections: IntersectionMap<d[\\\"kind\\\"]>;\\n    defaults: nodeSchemaaultsImplementationInputFor<d[\\\"kind\\\"]>;\\n} & (d[\\\"intersectionIsOpen\\\"] extends true ? {\\n    intersectionIsOpen: true;\\n} : {}) & (d[\\\"reducibleTo\\\"] extends d[\\\"kind\\\"] ? {} : {\\n    reduce: {};\\n});\\ntype nodeSchemaaultsImplementationInputFor<kind extends NodeKind> = requireKeys<NodeConfig<kind>, \\\"description\\\" | (Inner<kind> extends (Omit<errorContext<kind>, keyof BaseErrorContext | \\\"description\\\">) ? never : \\\"expected\\\" & keyof NodeConfig<kind>)>;\\ntype DescriptionWriter<kind extends NodeKind = NodeKind> = (node: nodeOfKind<kind>) => string;\\ninterface UnknownAttachments {\\n    readonly kind: NodeKind;\\n    readonly impl: UnknownNodeImplementation;\\n    readonly id: NodeId;\\n    readonly inner: Record<string, any>;\\n    readonly innerEntries: readonly Entry<string>[];\\n    readonly innerJson: object;\\n    readonly innerHash: string;\\n    readonly meta: ArkEnv.meta;\\n    readonly metaJson: object;\\n    readonly json: object;\\n    readonly hash: string;\\n    readonly collapsibleJson: Json;\\n    readonly children: BaseNode[];\\n}\\ninterface NarrowedAttachments<d extends BaseNodeDeclaration> extends UnknownAttachments {\\n    kind: d[\\\"kind\\\"];\\n    inner: d[\\\"inner\\\"];\\n    json: JsonStructure;\\n    innerJson: JsonStructure;\\n    collapsibleJson: Json;\\n    children: nodeOfKind<d[\\\"childKind\\\"]>[];\\n}\\ndeclare const implementNode: <d extends BaseNodeDeclaration = never>(_: nodeImplementationInputOf<d>) => nodeImplementationOf<d>;\\n\\ndeclare class AfterNode extends BaseRange<After.Declaration> {\\n    impliedBasis: BaseRoot;\\n    collapsibleLimitString: string;\\n    traverseAllows: TraverseAllows<Date>;\\n    reduceJsonSchema(base: JsonSchema, ctx: ToJsonSchema.Context): JsonSchema;\\n}\\ndeclare namespace After {\\n    interface Inner extends BaseRangeInner {\\n        rule: Date;\\n    }\\n    interface NormalizedSchema extends UnknownNormalizedRangeSchema {\\n        rule: LimitSchemaValue;\\n    }\\n    interface ExpandedSchema extends UnknownExpandedRangeSchema {\\n        rule: LimitSchemaValue;\\n    }\\n    type Schema = ExpandedSchema | LimitSchemaValue;\\n    interface ErrorContext extends BaseErrorContext<\\\"after\\\">, Inner {\\n    }\\n    interface Declaration extends declareNode<{\\n        kind: \\\"after\\\";\\n        schema: Schema;\\n        normalizedSchema: NormalizedSchema;\\n        inner: Inner;\\n        prerequisite: Date;\\n        errorContext: ErrorContext;\\n    }> {\\n    }\\n    type Node = AfterNode;\\n}\\ndeclare const After: {\\n    implementation: nodeImplementationOf<After.Declaration>;\\n    Node: typeof AfterNode;\\n};\\n\\ndeclare class BeforeNode extends BaseRange<Before.Declaration> {\\n    collapsibleLimitString: string;\\n    traverseAllows: TraverseAllows<Date>;\\n    impliedBasis: BaseRoot;\\n    reduceJsonSchema(base: JsonSchema, ctx: ToJsonSchema.Context): JsonSchema;\\n}\\ndeclare namespace Before {\\n    interface Inner extends BaseRangeInner {\\n        rule: Date;\\n    }\\n    interface NormalizedSchema extends UnknownNormalizedRangeSchema {\\n        rule: LimitSchemaValue;\\n    }\\n    interface ExpandedSchema extends UnknownExpandedRangeSchema {\\n        rule: LimitSchemaValue;\\n    }\\n    type Schema = ExpandedSchema | LimitSchemaValue;\\n    interface ErrorContext extends BaseErrorContext<\\\"before\\\">, Inner {\\n    }\\n    interface Declaration extends declareNode<{\\n        kind: \\\"before\\\";\\n        schema: Schema;\\n        normalizedSchema: NormalizedSchema;\\n        inner: Inner;\\n        prerequisite: Date;\\n        errorContext: ErrorContext;\\n    }> {\\n    }\\n    type Node = BeforeNode;\\n}\\ndeclare const Before: {\\n    implementation: nodeImplementationOf<Before.Declaration>;\\n    Node: typeof BeforeNode;\\n};\\n\\ndeclare class MaxNode extends BaseRange<Max.Declaration> {\\n    impliedBasis: BaseRoot;\\n    traverseAllows: TraverseAllows<number>;\\n    reduceJsonSchema(schema: JsonSchema.Numeric): JsonSchema.Numeric;\\n}\\ndeclare namespace Max {\\n    interface Inner extends BaseRangeInner {\\n        rule: number;\\n        exclusive?: true;\\n    }\\n    interface NormalizedSchema extends UnknownExpandedRangeSchema {\\n        rule: number;\\n    }\\n    type Schema = NormalizedSchema | number;\\n    interface ErrorContext extends BaseErrorContext<\\\"max\\\">, Inner {\\n    }\\n    interface Declaration extends declareNode<{\\n        kind: \\\"max\\\";\\n        schema: Schema;\\n        normalizedSchema: NormalizedSchema;\\n        inner: Inner;\\n        prerequisite: number;\\n        errorContext: ErrorContext;\\n    }> {\\n    }\\n    type Node = MaxNode;\\n}\\ndeclare const Max: {\\n    implementation: nodeImplementationOf<Max.Declaration>;\\n    Node: typeof MaxNode;\\n};\\n\\ndeclare class MinNode extends BaseRange<Min.Declaration> {\\n    readonly impliedBasis: BaseRoot;\\n    traverseAllows: TraverseAllows<number>;\\n    reduceJsonSchema(schema: JsonSchema.Numeric): JsonSchema.Numeric;\\n}\\ndeclare namespace Min {\\n    interface Inner extends BaseRangeInner {\\n        rule: number;\\n        exclusive?: true;\\n    }\\n    interface NormalizedSchema extends UnknownExpandedRangeSchema {\\n        rule: number;\\n    }\\n    type Schema = NormalizedSchema | number;\\n    interface ErrorContext extends BaseErrorContext<\\\"min\\\">, Inner {\\n    }\\n    interface Declaration extends declareNode<{\\n        kind: \\\"min\\\";\\n        schema: Schema;\\n        normalizedSchema: NormalizedSchema;\\n        inner: Inner;\\n        prerequisite: number;\\n        errorContext: ErrorContext;\\n    }> {\\n    }\\n    type Node = MinNode;\\n}\\ndeclare const Min: {\\n    implementation: nodeImplementationOf<Min.Declaration>;\\n    Node: typeof MinNode;\\n};\\n\\ninterface BoundDeclarations {\\n    min: Min.Declaration;\\n    max: Max.Declaration;\\n    minLength: MinLength.Declaration;\\n    maxLength: MaxLength.Declaration;\\n    exactLength: ExactLength.Declaration;\\n    after: After.Declaration;\\n    before: Before.Declaration;\\n}\\ninterface BoundNodesByKind {\\n    min: Min.Node;\\n    max: Max.Node;\\n    minLength: MinLength.Node;\\n    maxLength: MaxLength.Node;\\n    exactLength: ExactLength.Node;\\n    after: After.Node;\\n    before: Before.Node;\\n}\\ntype BoundKind = keyof BoundDeclarations;\\ntype RangeKind = Exclude<BoundKind, \\\"exactLength\\\">;\\ntype boundImplementationsByKind = {\\n    [k in BoundKind]: nodeImplementationOf<BoundDeclarations[k]>;\\n};\\ndeclare const boundImplementationsByKind: boundImplementationsByKind;\\ndeclare const boundClassesByKind: Record<BoundKind, typeof BaseConstraint<any>>;\\n\\ninterface DisjointEntry<kind extends DisjointKind = DisjointKind> {\\n    kind: kind;\\n    l: OperandsByDisjointKind[kind];\\n    r: OperandsByDisjointKind[kind];\\n    path: Key[];\\n    optional: boolean;\\n}\\ntype OperandsByDisjointKind = {\\n    domain: nodeOfKind<\\\"domain\\\"> | Domain.Enumerable;\\n    unit: nodeOfKind<\\\"unit\\\">;\\n    proto: nodeOfKind<\\\"proto\\\">;\\n    presence: BaseRoot;\\n    range: nodeOfKind<BoundKind>;\\n    assignability: BaseNode;\\n    union: readonly BaseRoot[];\\n};\\ntype DisjointEntryContext = {\\n    path?: Key[];\\n    optional?: true;\\n};\\ndeclare class Disjoint extends Array<DisjointEntry> {\\n    static init<kind extends DisjointKind>(kind: kind, l: OperandsByDisjointKind[kind], r: OperandsByDisjointKind[kind], ctx?: DisjointEntryContext): Disjoint;\\n    add<kind extends DisjointKind>(kind: kind, l: OperandsByDisjointKind[kind], r: OperandsByDisjointKind[kind], ctx?: DisjointEntryContext): Disjoint;\\n    get summary(): string;\\n    describeReasons(): string;\\n    throw(): never;\\n    invert(): Disjoint;\\n    withPrefixKey(key: PropertyKey, kind: Prop.Kind): Disjoint;\\n    toNeverIfDisjoint(): BaseRoot;\\n}\\ntype DisjointKind = keyof OperandsByDisjointKind;\\ndeclare const writeUnsatisfiableExpressionError: <expression extends string>(expression: expression) => writeUnsatisfiableExpressionError<expression>;\\ntype writeUnsatisfiableExpressionError<expression extends string> = `${expression} results in an unsatisfiable type`;\\n\\ntype withMetaPrefixedKeys<o> = {\\n    [k in keyof o as k extends string ? `meta.${k}` : never]: o[k];\\n};\\ninterface DefaultArkEnv {\\n    meta(): {};\\n    onFail(errors: ArkErrors): ArkErrors;\\n}\\ninterface NodeMeta extends JsonSchema.UniversalMeta, UnknownErrorConfigs {\\n    alias?: string;\\n    onFail?: ArkErrors.Handler;\\n}\\ndeclare global {\\n    export interface ArkEnv extends DefaultArkEnv {\\n    }\\n    export namespace ArkEnv {\\n        type meta = show<NodeMeta & ReturnType<ArkEnv[\\\"meta\\\"]>>;\\n        type onFail = ReturnType<ArkEnv[\\\"onFail\\\"]>;\\n    }\\n}\\ntype TypeMeta = Omit<ArkEnv.meta, \\\"onFail\\\">;\\ndeclare namespace TypeMeta {\\n    type Collapsible<meta extends TypeMeta = TypeMeta> = meta | string;\\n    type Mapper<meta extends TypeMeta = TypeMeta> = (existing: Readonly<meta>) => meta;\\n    type MappableInput<meta extends TypeMeta = TypeMeta> = Collapsible<meta> | Mapper<meta>;\\n    namespace MappableInput {\\n        type Internal = MappableInput<ArkEnv.meta>;\\n    }\\n}\\ninterface BaseNormalizedSchema extends withMetaPrefixedKeys<TypeMeta> {\\n    readonly meta?: ArkEnv.meta | string;\\n}\\ninterface DeclarationInput {\\n    kind: NodeKind;\\n    schema: unknown;\\n    normalizedSchema: BaseNormalizedSchema;\\n    inner: object;\\n    errorContext?: BaseErrorContext;\\n    reducibleTo?: NodeKind;\\n    intersectionIsOpen?: true;\\n    prerequisite?: unknown;\\n    childKind?: NodeKind;\\n}\\ninterface BaseErrorContext<kind extends NodeKind = NodeKind> {\\n    readonly description?: string;\\n    readonly code: kind;\\n    readonly meta: ArkEnv.meta;\\n}\\ntype defaultErrorContext<d extends DeclarationInput> = show<BaseErrorContext<d[\\\"kind\\\"]> & d[\\\"inner\\\"]>;\\ntype declareNode<d extends {\\n    [k in keyof d]: k extends keyof DeclarationInput ? DeclarationInput[k] : never;\\n} & DeclarationInput> = merge<{\\n    intersectionIsOpen: false;\\n    prerequisite: prerequisiteOf<d>;\\n    childKind: never;\\n    reducibleTo: d[\\\"kind\\\"];\\n    errorContext: null;\\n}, d>;\\ntype prerequisiteOf<d extends DeclarationInput> = \\\"prerequisite\\\" extends keyof d ? d[\\\"prerequisite\\\"] : unknown;\\ntype attachmentsOf<d extends BaseNodeDeclaration> = NarrowedAttachments<d> & attachedInner<d>;\\ntype attachedInner<d extends BaseNodeDeclaration> = \\\"intersection\\\" & d[\\\"kind\\\"] extends never ? d[\\\"inner\\\"] : {};\\ninterface BaseNodeDeclaration {\\n    kind: NodeKind;\\n    schema: unknown;\\n    normalizedSchema: BaseNormalizedSchema;\\n    inner: {};\\n    reducibleTo: NodeKind;\\n    prerequisite: any;\\n    intersectionIsOpen: boolean;\\n    childKind: NodeKind;\\n    errorContext: BaseErrorContext | null;\\n}\\ntype ownIntersectionResult<d extends BaseNodeDeclaration> = nodeOfKind<reducibleKindOf<d[\\\"kind\\\"]>> | Disjoint;\\n\\ndeclare class MorphNode extends BaseRoot<Morph.Declaration> {\\n    serializedMorphs: string[];\\n    compiledMorphs: string;\\n    lastMorph: Morph | BaseRoot | undefined;\\n    lastMorphIfNode: BaseRoot | undefined;\\n    introspectableIn: BaseRoot | undefined;\\n    introspectableOut: BaseRoot | undefined;\\n    get shallowMorphs(): array<Morph>;\\n    get rawIn(): BaseRoot;\\n    get rawOut(): BaseRoot;\\n    declareIn(declaredIn: BaseRoot): MorphNode;\\n    declareOut(declaredOut: BaseRoot): MorphNode;\\n    expression: string;\\n    get defaultShortDescription(): string;\\n    protected innerToJsonSchema(ctx: ToJsonSchema.Context): JsonSchema;\\n    compile(js: NodeCompiler): void;\\n    traverseAllows: TraverseAllows;\\n    traverseApply: TraverseApply;\\n    /** Check if the morphs of r are equal to those of this node */\\n    hasEqualMorphs(r: MorphNode): boolean;\\n}\\ndeclare namespace Morph {\\n    interface Inner {\\n        readonly in?: BaseRoot;\\n        readonly morphs: array<Morph | BaseRoot>;\\n        readonly declaredIn?: BaseRoot;\\n        readonly declaredOut?: BaseRoot;\\n    }\\n    interface Schema extends BaseNormalizedSchema {\\n        readonly in?: RootSchema;\\n        readonly morphs: listable<Morph | BaseRoot>;\\n        readonly declaredIn?: BaseRoot;\\n        readonly declaredOut?: BaseRoot;\\n    }\\n    interface Declaration extends declareNode<{\\n        kind: \\\"morph\\\";\\n        schema: Schema;\\n        normalizedSchema: Schema;\\n        inner: Inner;\\n        childKind: RootKind;\\n    }> {\\n    }\\n    type Node = MorphNode;\\n    type In<morph extends Morph> = morph extends Morph<infer i> ? i : never;\\n    type Out<morph extends Morph> = morph extends Morph<never, infer o> ? o : never;\\n    type ContextFree<i = never, o = unknown> = (In: i) => o;\\n}\\ntype Morph<i = never, o = unknown> = (In: i, ctx: Traversal) => o;\\ndeclare const Morph: {\\n    implementation: nodeImplementationOf<Morph.Declaration>;\\n    Node: typeof MorphNode;\\n};\\ndeclare const writeMorphIntersectionMessage: (lDescription: string, rDescription: string) => string;\\n\\ntype MorphsAtPath = {\\n    path: ReadonlyPath;\\n    morphs: array<Morph>;\\n};\\ntype BranchTraversal = {\\n    error: ArkError | undefined;\\n    queuedMorphs: MorphsAtPath[];\\n};\\ntype InternalTraversal = Omit<Traversal, \\\"error\\\" | \\\"mustBe\\\" | \\\"reject\\\">;\\ndeclare class Traversal {\\n    /**\\n     * #### the path being validated or morphed\\n     *\\n     * ✅ array indices represented as numbers\\n     * ⚠️ mutated during traversal - use `path.slice(0)` to snapshot\\n     * 🔗 use {@link propString} for a stringified version\\n     */\\n    path: PropertyKey[];\\n    /**\\n     * #### {@link ArkErrors} that will be part of this traversal's finalized result\\n     *\\n     * ✅ will always be an empty array for a valid traversal\\n     */\\n    errors: ArkErrors;\\n    /**\\n     * #### the original value being traversed\\n     */\\n    root: unknown;\\n    /**\\n     * #### configuration for this traversal\\n     *\\n     * ✅ options can affect traversal results and error messages\\n     * ✅ defaults < global config < scope config\\n     * ✅ does not include options configured on individual types\\n     */\\n    config: ResolvedConfig;\\n    queuedMorphs: MorphsAtPath[];\\n    branches: BranchTraversal[];\\n    seen: {\\n        [id in string]?: unknown[];\\n    };\\n    constructor(root: unknown, config: ResolvedConfig);\\n    /**\\n     * #### the data being validated or morphed\\n     *\\n     * ✅ extracted from {@link root} at {@link path}\\n     */\\n    get data(): unknown;\\n    /**\\n     * #### a string representing {@link path}\\n     *\\n     * @propString\\n     */\\n    get propString(): string;\\n    /**\\n     * #### add an {@link ArkError} and return `false`\\n     *\\n     * ✅ useful for predicates like `.narrow`\\n     */\\n    reject(input: ArkErrorInput): false;\\n    /**\\n     * #### add an {@link ArkError} from a description and return `false`\\n     *\\n     * ✅ useful for predicates like `.narrow`\\n     * 🔗 equivalent to {@link reject}({ expected })\\n     */\\n    mustBe(expected: string): false;\\n    /**\\n     * #### add and return an {@link ArkError}\\n     *\\n     * ✅ useful for morphs like `.pipe`\\n     */\\n    error<input extends ArkErrorInput>(input: input): ArkError<input extends {\\n        code: ArkErrorCode;\\n    } ? input[\\\"code\\\"] : \\\"predicate\\\">;\\n    /**\\n     * #### whether {@link currentBranch} (or the traversal root, outside a union) has one or more errors\\n     */\\n    hasError(): boolean;\\n    get currentBranch(): BranchTraversal | undefined;\\n    queueMorphs(morphs: array<Morph>): void;\\n    finalize(onFail?: ArkErrors.Handler | null): unknown;\\n    get currentErrorCount(): number;\\n    get failFast(): boolean;\\n    pushBranch(): void;\\n    popBranch(): BranchTraversal | undefined;\\n    /**\\n     * @internal\\n     * Convenience for casting from InternalTraversal to Traversal\\n     * for cases where the extra methods on the external type are expected, e.g.\\n     * a morph or predicate.\\n     */\\n    get external(): this;\\n    /**\\n     * @internal\\n     */\\n    errorFromNodeContext<input extends NodeErrorContextInput>(input: input): ArkError<input[\\\"code\\\"]>;\\n    private errorFromContext;\\n    private applyQueuedMorphs;\\n    private applyMorphsAtPath;\\n}\\ndeclare const traverseKey: <result>(key: PropertyKey, fn: () => result, ctx: InternalTraversal | undefined) => result;\\ntype TraversalMethodsByKind<input = unknown> = {\\n    Allows: TraverseAllows<input>;\\n    Apply: TraverseApply<input>;\\n    Optimistic: TraverseApply<input>;\\n};\\ntype TraversalKind = keyof TraversalMethodsByKind & {};\\ntype TraverseAllows<data = unknown> = (data: data, ctx: InternalTraversal) => boolean;\\ntype TraverseApply<data = unknown> = (data: data, ctx: InternalTraversal) => void;\\n\\ntype CoercibleValue = string | number | boolean | null | undefined;\\ndeclare class CompiledFunction<compiledSignature = (...args: unknown[]) => unknown, args extends readonly string[] = readonly string[]> extends CastableBase<{\\n    [k in args[number]]: k;\\n}> {\\n    readonly argNames: args;\\n    readonly body = \\\"\\\";\\n    constructor(...args: args);\\n    indentation: number;\\n    indent(): this;\\n    dedent(): this;\\n    prop(key: PropertyKey, optional?: boolean): string;\\n    index(key: string | number, optional?: boolean): string;\\n    line(statement: string): this;\\n    const(identifier: string, expression: CoercibleValue): this;\\n    let(identifier: string, expression: CoercibleValue): this;\\n    set(identifier: string, expression: CoercibleValue): this;\\n    if(condition: string, then: (self: this) => this): this;\\n    elseIf(condition: string, then: (self: this) => this): this;\\n    else(then: (self: this) => this): this;\\n    /** Current index is \\\"i\\\" */\\n    for(until: string, body: (self: this) => this, initialValue?: CoercibleValue): this;\\n    /** Current key is \\\"k\\\" */\\n    forIn(object: string, body: (self: this) => this): this;\\n    block(prefix: string, contents: (self: this) => this, suffix?: string): this;\\n    return(expression?: CoercibleValue): this;\\n    write(name?: string, indent?: number): string;\\n    compile(): compiledSignature;\\n}\\ndeclare const compileSerializedValue: (value: unknown) => string;\\ndeclare const compileLiteralPropAccess: (key: PropertyKey, optional?: boolean) => string;\\ndeclare const serializeLiteralKey: (key: PropertyKey) => string;\\ndeclare const indexPropAccess: (key: string, optional?: boolean) => string;\\ninterface InvokeOptions extends ReferenceOptions {\\n    arg?: string;\\n}\\ninterface ReferenceOptions {\\n    kind?: TraversalKind;\\n    bind?: string;\\n}\\ndeclare namespace NodeCompiler {\\n    interface Context {\\n        kind: TraversalKind;\\n        optimistic?: true;\\n    }\\n}\\ndeclare class NodeCompiler extends CompiledFunction<Fn, [\\\"data\\\", \\\"ctx\\\"]> {\\n    traversalKind: TraversalKind;\\n    optimistic: boolean;\\n    constructor(ctx: NodeCompiler.Context);\\n    invoke(node: BaseNode | NodeId, opts?: InvokeOptions): string;\\n    referenceToId(id: NodeId, opts?: ReferenceOptions): string;\\n    requiresContextFor(node: BaseNode): boolean;\\n    initializeErrorCount(): this;\\n    returnIfFail(): this;\\n    returnIfFailFast(): this;\\n    traverseKey(keyExpression: string, accessExpression: string, node: BaseNode): this;\\n    check(node: BaseNode, opts?: InvokeOptions): this;\\n}\\n\\ndeclare class PredicateNode extends BaseConstraint<Predicate.Declaration> {\\n    serializedPredicate: RegisteredReference;\\n    compiledCondition: string;\\n    compiledNegation: string;\\n    impliedBasis: null;\\n    expression: string;\\n    traverseAllows: TraverseAllows;\\n    errorContext: Predicate.ErrorContext;\\n    compiledErrorContext: string;\\n    traverseApply: TraverseApply;\\n    compile(js: NodeCompiler): void;\\n    reduceJsonSchema(base: JsonSchema.Constrainable, ctx: ToJsonSchema.Context): JsonSchema;\\n}\\ndeclare namespace Predicate {\\n    type Schema<predicate extends Predicate = Predicate> = NormalizedSchema<predicate> | predicate;\\n    interface NormalizedSchema<predicate extends Predicate = Predicate> extends BaseNormalizedSchema {\\n        readonly predicate: predicate;\\n    }\\n    interface Inner<predicate extends Predicate = Predicate> {\\n        readonly predicate: predicate;\\n    }\\n    interface ErrorContext extends BaseErrorContext<\\\"predicate\\\"> {\\n        readonly predicate?: Predicate;\\n    }\\n    interface Declaration extends declareNode<{\\n        kind: \\\"predicate\\\";\\n        schema: Schema;\\n        normalizedSchema: NormalizedSchema;\\n        inner: Inner;\\n        intersectionIsOpen: true;\\n        errorContext: ErrorContext;\\n    }> {\\n    }\\n    type Node = PredicateNode;\\n}\\ndeclare const Predicate: {\\n    implementation: nodeImplementationOf<Predicate.Declaration>;\\n    Node: typeof PredicateNode;\\n};\\ntype Predicate<data = any> = (data: data, ctx: Traversal) => boolean;\\ndeclare namespace Predicate {\\n    type Casted<input = never, narrowed extends input = input> = (input: input, ctx: Traversal) => input is narrowed;\\n    type Castable<input = never, narrowed extends input = input> = Predicate<input> | Casted<input, narrowed>;\\n}\\n\\ndeclare class ProtoNode extends InternalBasis<Proto.Declaration> {\\n    builtinName: BuiltinObjectKind | null;\\n    serializedConstructor: string;\\n    private readonly requiresInvalidDateCheck;\\n    traverseAllows: TraverseAllows;\\n    compiledCondition: string;\\n    compiledNegation: string;\\n    protected innerToJsonSchema(ctx: ToJsonSchema.Context): JsonSchema;\\n    expression: string;\\n    get nestableExpression(): string;\\n    readonly domain = \\\"object\\\";\\n    get defaultShortDescription(): string;\\n}\\ndeclare namespace Proto {\\n    type Reference = Constructor | BuiltinObjectKind;\\n    type Schema<proto extends Reference = Reference> = proto | ExpandedSchema<proto>;\\n    interface NormalizedSchema<proto extends Constructor = Constructor> extends BaseNormalizedSchema {\\n        readonly proto: proto;\\n        readonly dateAllowsInvalid?: boolean;\\n    }\\n    interface ExpandedSchema<proto extends Reference = Reference> {\\n        readonly proto: proto;\\n        readonly dateAllowsInvalid?: boolean;\\n    }\\n    interface Inner<proto extends Constructor = Constructor> {\\n        readonly proto: proto;\\n        readonly dateAllowsInvalid?: boolean;\\n    }\\n    interface ErrorContext extends BaseErrorContext<\\\"proto\\\">, Inner {\\n    }\\n    interface Declaration extends declareNode<{\\n        kind: \\\"proto\\\";\\n        schema: Schema;\\n        normalizedSchema: NormalizedSchema;\\n        inner: Inner;\\n        errorContext: ErrorContext;\\n    }> {\\n    }\\n    type Node = ProtoNode;\\n}\\ndeclare const Proto: {\\n    implementation: nodeImplementationOf<Proto.Declaration>;\\n    Node: typeof ProtoNode;\\n    writeBadInvalidDateMessage: (actual: Constructor) => string;\\n    writeInvalidSchemaMessage: (actual: unknown) => string;\\n};\\n\\ndeclare class IntersectionNode extends BaseRoot<Intersection.Declaration> {\\n    basis: nodeOfKind<Intersection.BasisKind> | null;\\n    prestructurals: array<nodeOfKind<PrestructuralKind>>;\\n    refinements: array<nodeOfKind<RefinementKind>>;\\n    structure: Structure.Node | undefined;\\n    expression: string;\\n    get shallowMorphs(): array<Morph>;\\n    get defaultShortDescription(): string;\\n    protected innerToJsonSchema(ctx: ToJsonSchema.Context): JsonSchema;\\n    traverseAllows: TraverseAllows;\\n    traverseApply: TraverseApply;\\n    compile(js: NodeCompiler): void;\\n}\\ndeclare namespace Intersection {\\n    type BasisKind = \\\"domain\\\" | \\\"proto\\\";\\n    type ChildKind = BasisKind | RefinementKind;\\n    type FlattenedChildKind = ChildKind | StructuralKind;\\n    type RefinementsInner = {\\n        [k in RefinementKind]?: intersectionChildInnerValueOf<k>;\\n    };\\n    interface Inner extends RefinementsInner {\\n        domain?: Domain.Node;\\n        proto?: Proto.Node;\\n        structure?: Structure.Node;\\n        predicate?: array<PredicateNode>;\\n    }\\n    namespace Inner {\\n        type mutable = makeRootAndArrayPropertiesMutable<Inner>;\\n    }\\n    type ConstraintsSchema<inferredBasis = any> = show<BaseNormalizedSchema & {\\n        domain?: Domain.Schema;\\n        proto?: Proto.Schema;\\n    } & conditionalRootOf<inferredBasis>>;\\n    type NormalizedSchema = Omit<ConstraintsSchema, StructuralKind | \\\"undeclared\\\">;\\n    type Schema<inferredBasis = any> = ConstraintsSchema<inferredBasis>;\\n    interface AstSchema extends BaseNormalizedSchema {\\n        intersection: readonly RootSchema[];\\n    }\\n    interface ErrorContext extends BaseErrorContext<\\\"intersection\\\">, Inner {\\n        errors: readonly ArkError[];\\n    }\\n    type Declaration = declareNode<{\\n        kind: \\\"intersection\\\";\\n        schema: Schema;\\n        normalizedSchema: NormalizedSchema;\\n        inner: Inner;\\n        reducibleTo: \\\"intersection\\\" | BasisKind;\\n        errorContext: ErrorContext;\\n        childKind: ChildKind;\\n    }>;\\n    type Node = IntersectionNode;\\n}\\ndeclare const Intersection: {\\n    implementation: nodeImplementationOf<{\\n        intersectionIsOpen: false;\\n        prerequisite: unknown;\\n        kind: \\\"intersection\\\";\\n        schema: Intersection.Schema;\\n        normalizedSchema: Intersection.NormalizedSchema;\\n        inner: Intersection.Inner;\\n        reducibleTo: \\\"intersection\\\" | Intersection.BasisKind;\\n        errorContext: Intersection.ErrorContext;\\n        childKind: Intersection.ChildKind;\\n    }>;\\n    Node: typeof IntersectionNode;\\n};\\ntype ConditionalTerminalIntersectionRoot = {\\n    undeclared?: UndeclaredKeyBehavior;\\n};\\ntype ConditionalTerminalIntersectionKey = keyof ConditionalTerminalIntersectionRoot;\\ntype ConditionalIntersectionKey = ConstraintKind | ConditionalTerminalIntersectionKey;\\ntype constraintKindOf<t> = {\\n    [k in ConstraintKind]: t extends Prerequisite<k> ? k : never;\\n}[ConstraintKind];\\ntype conditionalIntersectionKeyOf<t> = constraintKindOf<t> | (t extends object ? \\\"undeclared\\\" : never);\\ntype intersectionChildSchemaValueOf<k extends Intersection.FlattenedChildKind> = k extends OpenNodeKind ? listable<NodeSchema<k>> : NodeSchema<k>;\\ntype conditionalSchemaValueOfKey<k extends ConditionalIntersectionKey> = k extends Intersection.FlattenedChildKind ? intersectionChildSchemaValueOf<k> : ConditionalTerminalIntersectionRoot[k & ConditionalTerminalIntersectionKey];\\ntype intersectionChildInnerValueOf<k extends Intersection.FlattenedChildKind> = k extends OpenNodeKind ? readonly nodeOfKind<k>[] : nodeOfKind<k>;\\ntype conditionalRootOf<t> = {\\n    [k in conditionalIntersectionKeyOf<t>]?: conditionalSchemaValueOfKey<k>;\\n};\\n\\ndeclare namespace Constraint {\\n    interface Declaration extends BaseNodeDeclaration {\\n        kind: ConstraintKind;\\n    }\\n    type ReductionResult = BaseRoot | Disjoint | Intersection.Inner.mutable;\\n    interface Attachments {\\n        impliedBasis: BaseRoot | null;\\n        impliedSiblings?: array<BaseConstraint> | null;\\n    }\\n    type PrimitiveKind = Exclude<ConstraintKind, StructuralKind>;\\n}\\ndeclare abstract class BaseConstraint<\\n/** @ts-ignore allow instantiation assignment to the base type */\\nout d extends Constraint.Declaration = Constraint.Declaration> extends BaseNode<d> {\\n    readonly [arkKind]: \\\"constraint\\\";\\n    constructor(attachments: UnknownAttachments, $: BaseScope);\\n    abstract readonly impliedBasis: BaseRoot | null;\\n    readonly impliedSiblings?: array<BaseConstraint>;\\n    intersect<r extends BaseConstraint>(r: r): intersectConstraintKinds<d[\\\"kind\\\"], r[\\\"kind\\\"]>;\\n}\\ndeclare abstract class InternalPrimitiveConstraint<d extends Constraint.Declaration> extends BaseConstraint<d> {\\n    abstract traverseAllows: TraverseAllows<d[\\\"prerequisite\\\"]>;\\n    abstract readonly compiledCondition: string;\\n    abstract readonly compiledNegation: string;\\n    abstract reduceJsonSchema(base: JsonSchema.Constrainable, ctx: ToJsonSchema.Context): JsonSchema.Constrainable;\\n    traverseApply: TraverseApply<d[\\\"prerequisite\\\"]>;\\n    compile(js: NodeCompiler): void;\\n    get errorContext(): d[\\\"errorContext\\\"];\\n    get compiledErrorContext(): string;\\n}\\ndeclare const constraintKeyParser: <kind extends ConstraintKind>(kind: kind) => (schema: listable<NodeSchema<kind>>, ctx: NodeParseContext) => innerAttachedAs<kind> | undefined;\\ntype ConstraintGroupKind = satisfy<NodeKind, \\\"intersection\\\" | \\\"structure\\\">;\\ninterface ConstraintIntersectionState<kind extends ConstraintGroupKind = ConstraintGroupKind> {\\n    kind: kind;\\n    baseInner: Record<string, unknown>;\\n    l: BaseConstraint[];\\n    r: BaseConstraint[];\\n    roots: BaseRoot[];\\n    ctx: IntersectionContext;\\n}\\ndeclare const intersectConstraints: <kind extends ConstraintGroupKind>(s: ConstraintIntersectionState<kind>) => nodeOfKind<RootKind | Extract<kind, \\\"structure\\\">> | Disjoint;\\ndeclare const flattenConstraints: (inner: object) => BaseConstraint[];\\ntype FlatIntersectionInner = Intersection.Inner & Structure.Inner;\\ndeclare const unflattenConstraints: (constraints: array<BaseConstraint>) => FlatIntersectionInner;\\ntype constraintKindLeftOf<kind extends ConstraintKind> = ConstraintKind & kindLeftOf<kind>;\\ntype constraintKindOrLeftOf<kind extends ConstraintKind> = kind | constraintKindLeftOf<kind>;\\ntype intersectConstraintKinds<l extends ConstraintKind, r extends ConstraintKind> = nodeOfKind<l | r | \\\"unit\\\" | \\\"union\\\"> | Disjoint | null;\\ndeclare const throwInvalidOperandError: (...args: Parameters<typeof writeInvalidOperandMessage>) => never;\\ndeclare const writeInvalidOperandMessage: <kind extends ConstraintKind, expected extends BaseRoot, actual extends BaseRoot>(kind: kind, expected: expected, actual: actual) => string;\\ntype writeInvalidOperandMessage<kind extends ConstraintKind, actual> = `${Capitalize<kind>} operand must be ${describe<Prerequisite<kind>>} (was ${describe<Exclude<actual, Prerequisite<kind>>>})`;\\n\\ndeclare abstract class BaseNode<\\n/** @ts-ignore allow instantiation assignment to the base type */\\nout d extends BaseNodeDeclaration = BaseNodeDeclaration> extends Callable<(data: d[\\\"prerequisite\\\"], ctx?: Traversal, onFail?: ArkErrors.Handler | null) => unknown, attachmentsOf<d>> {\\n    attachments: UnknownAttachments;\\n    $: BaseScope;\\n    onFail: ArkErrors.Handler | null;\\n    includesTransform: boolean;\\n    includesContextualPredicate: boolean;\\n    isCyclic: boolean;\\n    allowsRequiresContext: boolean;\\n    rootApplyStrategy: \\\"allows\\\" | \\\"contextual\\\" | \\\"optimistic\\\" | \\\"branchedOptimistic\\\";\\n    contextFreeMorph: ((data: unknown) => unknown) | undefined;\\n    rootApply: (data: unknown, onFail: ArkErrors.Handler | null) => unknown;\\n    referencesById: Record<string, BaseNode>;\\n    shallowReferences: BaseNode[];\\n    flatRefs: FlatRef[];\\n    flatMorphs: FlatRef<Morph.Node | Intersection.Node>[];\\n    allows: (data: d[\\\"prerequisite\\\"]) => boolean;\\n    get shallowMorphs(): array<Morph>;\\n    constructor(attachments: UnknownAttachments, $: BaseScope);\\n    protected createRootApply(): this[\\\"rootApply\\\"];\\n    abstract traverseAllows: TraverseAllows<d[\\\"prerequisite\\\"]>;\\n    abstract traverseApply: TraverseApply<d[\\\"prerequisite\\\"]>;\\n    abstract expression: string;\\n    abstract compile(js: NodeCompiler): void;\\n    readonly compiledMeta: string;\\n    protected cacheGetter<name extends keyof this>(name: name, value: this[name]): this[name];\\n    get description(): string;\\n    get references(): BaseNode[];\\n    readonly precedence: number;\\n    precompilation: string | undefined;\\n    assert: (data: d[\\\"prerequisite\\\"], pipedFromCtx?: Traversal) => unknown;\\n    traverse(data: d[\\\"prerequisite\\\"], pipedFromCtx?: Traversal): ArkErrors | {} | null | undefined;\\n    /** rawIn should be used internally instead */\\n    get in(): unknown;\\n    get rawIn(): BaseNode;\\n    /** rawOut should be used internally instead */\\n    get out(): unknown;\\n    get rawOut(): BaseNode;\\n    getIo(ioKind: \\\"in\\\" | \\\"out\\\"): BaseNode;\\n    toJSON(): JsonStructure;\\n    toString(): string;\\n    equals(r: unknown): boolean;\\n    ifEquals(r: unknown): BaseNode | undefined;\\n    hasKind<kind extends NodeKind>(kind: kind): this is nodeOfKind<kind>;\\n    assertHasKind<kind extends NodeKind>(kind: kind): nodeOfKind<kind>;\\n    hasKindIn<kinds extends NodeKind[]>(...kinds: kinds): this is nodeOfKind<kinds[number]>;\\n    assertHasKindIn<kinds extends NodeKind[]>(...kinds: kinds): nodeOfKind<kinds[number]>;\\n    isBasis(): this is nodeOfKind<BasisKind>;\\n    isConstraint(): this is BaseConstraint;\\n    isStructural(): this is nodeOfKind<StructuralKind>;\\n    isRefinement(): this is nodeOfKind<RefinementKind>;\\n    isRoot(): this is BaseRoot;\\n    isUnknown(): boolean;\\n    isNever(): boolean;\\n    hasUnit<value>(value: unknown): this is Unit.Node & {\\n        unit: value;\\n    };\\n    hasOpenIntersection(): this is nodeOfKind<OpenNodeKind>;\\n    get nestableExpression(): string;\\n    select<const selector extends NodeSelector.CompositeInput, predicate extends GuardablePredicate<NodeSelector.inferSelectKind<d[\\\"kind\\\"], selector>>>(selector: NodeSelector.validateComposite<selector, predicate>): NodeSelector.infer<d[\\\"kind\\\"], selector>;\\n    select<const selector extends NodeSelector.Single>(selector: selector): NodeSelector.infer<d[\\\"kind\\\"], selector>;\\n    private _select;\\n    transform<mapper extends DeepNodeTransformation>(mapper: mapper, opts?: DeepNodeTransformOptions): nodeOfKind<reducibleKindOf<this[\\\"kind\\\"]>> | Extract<ReturnType<mapper>, null>;\\n    protected _createTransformContext(opts: DeepNodeTransformOptions | undefined): DeepNodeTransformContext;\\n    protected _transform(mapper: DeepNodeTransformation, ctx: DeepNodeTransformContext): BaseNode | null;\\n    configureReferences(meta: TypeMeta.MappableInput.Internal, selector?: NodeSelector): this;\\n}\\n/** a literal key (named property) or a node (index signatures) representing part of a type structure */\\ntype KeyOrKeyNode = Key | BaseRoot;\\ntype GettableKeyOrNode = KeyOrKeyNode | number;\\ntype FlatRef<root extends BaseRoot = BaseRoot> = {\\n    path: array<KeyOrKeyNode>;\\n    node: root;\\n    propString: string;\\n};\\ntype NodeSelector = NodeSelector.Single | NodeSelector.Composite;\\ndeclare namespace NodeSelector {\\n    type SelectableFn<input, returns, kind extends NodeKind = NodeKind> = {\\n        <const selector extends NodeSelector.CompositeInput, predicate extends GuardablePredicate<NodeSelector.inferSelectKind<kind, selector>>>(input: input, selector?: NodeSelector.validateComposite<selector, predicate>): returns;\\n        <const selector extends NodeSelector.Single>(input: input, selector?: selector): returns;\\n    };\\n    type Single = NodeSelector.Boundary | NodeSelector.Kind | GuardablePredicate<BaseNode>;\\n    type Boundary = \\\"self\\\" | \\\"child\\\" | \\\"shallow\\\" | \\\"references\\\";\\n    type Kind = NodeKind;\\n    type Method = \\\"filter\\\" | \\\"assertFilter\\\" | \\\"find\\\" | \\\"assertFind\\\";\\n    interface Composite {\\n        method?: Method;\\n        boundary?: Boundary;\\n        kind?: Kind;\\n        where?: GuardablePredicate<BaseNode>;\\n    }\\n    type Normalized = requireKeys<Composite, \\\"method\\\" | \\\"boundary\\\">;\\n    type CompositeInput = Omit<Composite, \\\"where\\\">;\\n    type BaseResult = BaseNode | BaseNode[] | undefined;\\n    type validateComposite<selector, predicate> = {\\n        [k in keyof selector]: k extends \\\"where\\\" ? predicate : conform<selector[k], CompositeInput[k & keyof CompositeInput]>;\\n    };\\n    type infer<selfKind extends NodeKind, selector> = applyMethod<selector extends NodeSelector.WhereCastInput<any, infer narrowed> ? narrowed : NodeSelector.inferSelectKind<selfKind, selector>, selector>;\\n    type BoundaryInput<b extends Boundary> = b | {\\n        boundary: b;\\n    };\\n    type KindInput<k extends Kind> = k | {\\n        kind: k;\\n    };\\n    type WhereCastInput<kindNode extends BaseNode, narrowed extends kindNode> = ((In: kindNode) => In is narrowed) | {\\n        where: (In: kindNode) => In is narrowed;\\n    };\\n    type inferSelectKind<selfKind extends NodeKind, selector> = selectKind<selfKind, selector> extends infer kind extends NodeKind ? NodeKind extends kind ? BaseNode : nodeOfKind<kind> : never;\\n    type selectKind<selfKind extends NodeKind, selector> = selector extends BoundaryInput<\\\"self\\\"> ? selfKind : selector extends KindInput<infer kind> ? kind : selector extends BoundaryInput<\\\"child\\\"> ? selfKind | childKindOf<selfKind> : NodeKind;\\n    type applyMethod<t, selector> = selector extends {\\n        method: infer method extends Method;\\n    } ? method extends \\\"filter\\\" ? t[] : method extends \\\"assertFilter\\\" ? [t, ...t[]] : method extends \\\"find\\\" ? t | undefined : method extends \\\"assertFind\\\" ? t : never : t[];\\n}\\ndeclare const typePathToPropString: (path: array<KeyOrKeyNode>) => string;\\ndeclare const flatRef: <node extends BaseRoot>(path: array<KeyOrKeyNode>, node: node) => FlatRef<node>;\\ndeclare const flatRefsAreEqual: (l: FlatRef, r: FlatRef) => boolean;\\ndeclare const appendUniqueFlatRefs: <node extends BaseRoot>(existing: FlatRef<node>[] | undefined, refs: listable<FlatRef<node>>) => FlatRef<node>[];\\ndeclare const appendUniqueNodes: <node extends BaseNode>(existing: node[] | undefined, refs: listable<node>) => node[];\\ntype DeepNodeTransformOptions = {\\n    shouldTransform?: ShouldTransformFn;\\n    bindScope?: BaseScope;\\n    prereduced?: boolean;\\n    selected?: readonly BaseNode[] | undefined;\\n};\\ntype ShouldTransformFn = (node: BaseNode, ctx: DeepNodeTransformContext) => boolean;\\ninterface DeepNodeTransformContext extends DeepNodeTransformOptions {\\n    root: BaseNode;\\n    selected: readonly BaseNode[] | undefined;\\n    path: mutable<array<KeyOrKeyNode>>;\\n    seen: {\\n        [originalId: string]: (() => BaseNode | undefined) | undefined;\\n    };\\n    parseOptions: BaseParseOptions;\\n    undeclaredKeyHandling: UndeclaredKeyHandling | undefined;\\n}\\ntype DeepNodeTransformation = <kind extends NodeKind>(kind: kind, innerWithMeta: Inner<kind> & {\\n    meta: ArkEnv.meta;\\n}, ctx: DeepNodeTransformContext) => NormalizedSchema<kind> | null;\\n\\ninterface NodeDeclarationsByKind extends BoundDeclarations {\\n    alias: Alias.Declaration;\\n    domain: Domain.Declaration;\\n    unit: Unit.Declaration;\\n    proto: Proto.Declaration;\\n    union: Union.Declaration;\\n    morph: Morph.Declaration;\\n    intersection: Intersection.Declaration;\\n    sequence: Sequence.Declaration;\\n    divisor: Divisor.Declaration;\\n    required: Required$1.Declaration;\\n    optional: Optional.Declaration;\\n    index: Index.Declaration;\\n    pattern: Pattern.Declaration;\\n    predicate: Predicate.Declaration;\\n    structure: Structure.Declaration;\\n}\\ndeclare const nodeImplementationsByKind: Record<NodeKind, UnknownNodeImplementation>;\\ndeclare const nodeClassesByKind: Record<NodeKind, new (attachments: UnknownAttachments, $: BaseScope) => BaseNode>;\\ninterface NodesByKind extends BoundNodesByKind {\\n    alias: Alias.Node;\\n    union: Union.Node;\\n    morph: Morph.Node;\\n    intersection: Intersection.Node;\\n    unit: Unit.Node;\\n    proto: Proto.Node;\\n    domain: Domain.Node;\\n    divisor: Divisor.Node;\\n    pattern: Pattern.Node;\\n    predicate: Predicate.Node;\\n    required: Required$1.Node;\\n    optional: Optional.Node;\\n    index: Index.Node;\\n    sequence: Sequence.Node;\\n    structure: Structure.Node;\\n}\\ntype nodeOfKind<kind extends NodeKind> = NodesByKind[kind];\\ntype Declaration<kind extends NodeKind> = NodeDeclarationsByKind[kind];\\ntype NodeSchema<kind extends NodeKind> = Declaration<kind>[\\\"schema\\\"];\\ntype RootSchema<kind extends RootKind = RootKind> = NodeSchema<kind>;\\ntype NormalizedSchema<kind extends NodeKind> = Declaration<kind>[\\\"normalizedSchema\\\"];\\ntype childKindOf<kind extends NodeKind> = Declaration<kind>[\\\"childKind\\\"];\\ntype Prerequisite<kind extends NodeKind> = Declaration<kind>[\\\"prerequisite\\\"];\\ntype reducibleKindOf<kind extends NodeKind> = Declaration<kind>[\\\"reducibleTo\\\"] extends NodeKind ? Declaration<kind>[\\\"reducibleTo\\\"] : kind;\\ntype Inner<kind extends NodeKind> = Declaration<kind>[\\\"inner\\\"];\\ntype defAttachedAs<kind extends ConstraintKind> = kind extends OpenNodeKind ? listable<NodeSchema<kind>> : NodeSchema<kind>;\\ntype innerAttachedAs<kind extends ConstraintKind> = kind extends OpenNodeKind ? array<nodeOfKind<kind>> : nodeOfKind<kind>;\\n/** make nested arrays mutable while keeping nested nodes immutable */\\ntype mutableInnerOfKind<kind extends NodeKind> = makeRootAndArrayPropertiesMutable<Inner<kind>>;\\ntype mutableNormalizedRootOfKind<kind extends NodeKind> = makeRootAndArrayPropertiesMutable<NormalizedSchema<kind>>;\\ntype errorContext<kind extends NodeKind> = Declaration<kind>[\\\"errorContext\\\"];\\n\\ntype ContextualArgs = Record<string, BaseRoot | NodeId>;\\ntype BaseParseOptions<prereduced extends boolean = boolean> = {\\n    alias?: string;\\n    prereduced?: prereduced;\\n    args?: ContextualArgs;\\n    id?: NodeId;\\n};\\ninterface BaseParseContextInput extends BaseParseOptions {\\n    prefix: string;\\n    def: unknown;\\n}\\ninterface AttachedParseContext {\\n    [arkKind]: \\\"context\\\";\\n    $: BaseScope;\\n    id: NodeId;\\n    phase: \\\"unresolved\\\" | \\\"resolving\\\" | \\\"resolved\\\";\\n}\\ninterface BaseParseContext extends BaseParseContextInput, AttachedParseContext {\\n    id: NodeId;\\n}\\ninterface NodeParseContextInput<kind extends NodeKind = NodeKind> extends BaseParseContextInput {\\n    kind: kind;\\n    def: NormalizedSchema<kind>;\\n}\\ninterface NodeParseContext<kind extends NodeKind = NodeKind> extends NodeParseContextInput<kind>, AttachedParseContext {\\n    id: NodeId;\\n}\\ndeclare const schemaKindOf: <kind extends RootKind = RootKind>(schema: unknown, allowedKinds?: readonly kind[]) => kind;\\ndeclare const writeInvalidSchemaMessage: (schema: unknown) => string;\\ntype NodeId = Brand<string, \\\"NodeId\\\">;\\ntype NodeResolver = (id: NodeId) => BaseNode;\\ndeclare const nodesByRegisteredId: Record<NodeId, BaseNode | BaseParseContext | undefined>;\\ndeclare const registerNodeId: (prefix: string) => NodeId;\\ndeclare const parseNode: (ctx: NodeParseContext) => BaseNode;\\ntype CreateNodeInput = {\\n    id: NodeId;\\n    kind: NodeKind;\\n    inner: dict;\\n    meta: ArkEnv.meta;\\n    $: BaseScope;\\n    ignoreCache?: true;\\n};\\ndeclare const createNode: ({ id, kind, inner, meta, $, ignoreCache }: CreateNodeInput) => BaseNode;\\ndeclare const withId: <node extends BaseNode>(node: node, id: NodeId) => node;\\ndeclare const withMeta: <node extends BaseNode>(node: node, meta: ArkEnv.meta, id?: NodeId) => node;\\n\\ninterface ArkSchemaRegistry extends ArkRegistry {\\n    intrinsic: typeof intrinsic;\\n    config: ArkSchemaConfig;\\n    defaultConfig: ResolvedConfig;\\n    resolvedConfig: ResolvedConfig;\\n    nodesByRegisteredId: typeof nodesByRegisteredId;\\n}\\ntype nodeConfigForKind<kind extends NodeKind> = Readonly<show<{\\n    description?: DescriptionWriter<kind>;\\n} & (kind extends ArkErrorCode ? {\\n    expected?: ExpectedConfig<kind>;\\n    actual?: ActualConfig<kind>;\\n    problem?: ProblemConfig<kind>;\\n    message?: MessageConfig<kind>;\\n} : {})>>;\\ntype NodeConfigsByKind = {\\n    [kind in NodeKind]: nodeConfigForKind<kind>;\\n};\\ntype NodeConfig<kind extends NodeKind = NodeKind> = NodeConfigsByKind[kind];\\ninterface UnknownErrorConfigs {\\n    expected?: ExpectedConfig;\\n    actual?: ActualConfig;\\n    problem?: ProblemConfig;\\n    message?: MessageConfig;\\n}\\ninterface UnknownNodeConfig extends UnknownErrorConfigs {\\n    description?: DescriptionWriter;\\n}\\ntype ResolvedUnknownNodeConfig = requireKeys<UnknownNodeConfig, \\\"description\\\">;\\ndeclare const configureSchema: (config: ArkSchemaConfig) => ArkSchemaConfig;\\ndeclare const mergeConfigs: <base extends ArkSchemaConfig>(base: base, merged: ArkSchemaConfig | undefined) => base;\\ntype MergeToJsonSchemaConfigs = <base extends ToJsonSchema.Options | undefined>(baseConfig: base, mergedConfig: ToJsonSchema.Options | undefined) => base extends ToJsonSchema.Context ? ToJsonSchema.Context : ToJsonSchema.Options;\\ndeclare const mergeToJsonSchemaConfigs: MergeToJsonSchemaConfigs;\\ntype CloneImplementation = <original extends object>(original: original) => original;\\ninterface ArkSchemaConfig extends Partial<Readonly<NodeConfigsByKind>> {\\n    readonly jitless?: boolean;\\n    readonly clone?: boolean | CloneImplementation;\\n    readonly onUndeclaredKey?: UndeclaredKeyBehavior;\\n    readonly numberAllowsNaN?: boolean;\\n    readonly dateAllowsInvalid?: boolean;\\n    readonly exactOptionalPropertyTypes?: boolean;\\n    readonly onFail?: ArkErrors.Handler | null;\\n    readonly keywords?: Record<string, TypeMeta.Collapsible | undefined>;\\n    readonly toJsonSchema?: ToJsonSchema.Options;\\n}\\ntype resolveConfig<config extends ArkSchemaConfig> = show<{\\n    [k in keyof ArkSchemaConfig]-?: k extends NodeKind ? Required<config[k]> : k extends \\\"clone\\\" ? CloneImplementation | false : k extends \\\"keywords\\\" ? Record<string, TypeMeta | undefined> : k extends \\\"toJsonSchema\\\" ? ToJsonSchema.Context : config[k];\\n} & Omit<config, keyof ArkSchemaConfig>>;\\ntype ResolvedConfig = resolveConfig<ArkSchemaConfig>;\\n\\ntype InternalNodeIntersection<ctx> = <l extends BaseNode, r extends BaseNode>(l: l, r: r, ctx: ctx) => l[\\\"kind\\\"] | r[\\\"kind\\\"] extends RootKind ? BaseRoot | Disjoint : BaseNode | Disjoint | null;\\ndeclare const intersectNodesRoot: InternalNodeIntersection<BaseScope>;\\ndeclare const pipeNodesRoot: InternalNodeIntersection<BaseScope>;\\ndeclare const intersectOrPipeNodes: InternalNodeIntersection<IntersectionContext>;\\n\\nexport { $ark, type ActualConfig, type ActualWriter, After, AfterNode, type AliasDefEntry, ArkError, type ArkErrorCode, type ArkErrorContextInput, type ArkErrorInput, type ArkErrorResult, ArkErrors, type ArkKind, type ArkKinds, type ArkSchemaConfig, type ArkSchemaRegistry, type ArkSchemaScopeConfig, type AttachedParseContext, BaseConstraint, type BaseErrorContext, type BaseMappedPropInner, BaseNode, type BaseNodeDeclaration, type BaseNormalizedSchema, type BaseParseContext, type BaseParseContextInput, type BaseParseOptions, BaseProp, BaseRange, type BaseRangeDeclaration, type BaseRangeInner, BaseRoot, BaseScope, type BasisKind, Before, BeforeNode, type BoundDeclarations, type BoundKind, type BoundNodesByKind, type BoundOperandKind, type Boundable, type BranchTraversal, type CaseContext, type CaseDiscriminant, type CaseKey, type CloneImplementation, type ClosedNodeKind, type CoercibleValue, CompiledFunction, type CompositeKind, type ConditionalTerminalIntersectionRoot, Constraint, type ConstraintIntersection, type ConstraintIntersectionMap, type ConstraintKind, type ContextualArgs, type CreateNodeInput, type CustomErrorInput, type DateRangeKind, type Declaration, type DeepNodeTransformContext, type DeepNodeTransformOptions, type DeepNodeTransformation, type DefaultArkEnv, type DefaultableSequenceElement, type DerivableErrorContext, type DerivableErrorContextInput, type DescriptionWriter, type Discriminant, type DiscriminantKind, type DiscriminantKinds, type DiscriminatedCases, Disjoint, type DisjointEntry, type DisjointEntryContext, type DisjointKind, Divisor, DivisorNode, Domain, DomainNode, ExactLength, ExactLengthNode, type ExclusiveDateRangeSchema, type ExclusiveExpandedDateRangeSchema, type ExclusiveNormalizedNumericRangeSchema, type ExclusiveNumericRangeSchema, type ExpectedConfig, type ExpectedWriter, type FlatRef, type GenericArgResolutions, type GenericAst, type GenericParamAst, type GenericParamDef, GenericRoot, type GenericRootBodyParser, type GenericRootParser, type GettableKeyOrNode, type GlobalOnlyConfigOptionName, type InclusiveDateRangeSchema, type InclusiveExpandedDateRangeSchema, type InclusiveNormalizedNumericRangeSchema, type InclusiveNumericRangeSchema, Index, IndexNode, Inner, type InternalIntersectionOptions, type InternalModule, InternalPrimitiveConstraint, type InternalResolution, type InternalResolutions, type InternalRootDeclaration, type InternalSchemaParser, type InternalTraversal, Intersection, type IntersectionContext, type IntersectionMap, IntersectionNode, type InvokeOptions, JsonSchema, type JsonSchemaOrBoolean, type KeyOrKeyNode, LazyGenericBody, type LengthBoundKind, type LengthBoundableData, type LimitInnerValue, type LimitKind, type LimitSchemaValue, type LimitValue, type ListableJsonSchema, type LowerBoundKind, type LowerNode, type MappedPropInner, Max, MaxLength, MaxLengthNode, MaxNode, type MessageConfig, type MessageContext, type MessageWriter, Min, MinLength, MinLengthNode, MinNode, Morph, type MorphChildKind, MorphNode, type MorphsAtPath, type NarrowedAttachments, NodeCompiler, type NodeConfig, type NodeDeclarationsByKind, type NodeErrorContextInput, type NodeId, type NodeKeyImplementation, type NodeKind, type NodeParseContext, type NodeParseContextInput, type NodeResolver, type NodeSchema, NodeSelector, type NormalizedIndex, type NormalizedSchema, type NumericallyBoundable, type OpenNodeKind, Optional, type OptionalMappedPropInner, OptionalNode, type OptionalSequenceElement, type OrderedNodeKinds, Pattern, PatternNode, type PostfixSequenceElement, type PrecompiledReferences, Predicate, PredicateNode, type PrefixSequenceElement, type PreparsedNodeResolution, type Prerequisite, type PrestructuralKind, type PrevariadicSequenceElement, type PrimitiveKind, type PrivateDeclaration, type ProblemConfig, type ProblemContext, type ProblemWriter, Prop, type PropFlatMapper, Proto, ProtoNode, type RangeKind, type ReferenceOptions, type RefinementKind, type RegisteredReference, type RelativeComparator, Required$1 as Required, RequiredNode, type ResolvedConfig, type ResolvedScopeConfig, type ResolvedUnknownNodeConfig, type RootExportCache, type RootIntersection, type RootKind, RootModule, type RootSchema, SchemaModule, SchemaScope, type SchemaScopeParser, type ScopeOnlyConfigOptions, Sequence, type SequenceElement, type SequenceElementKind, SequenceNode, type SequenceTuple, type ShouldTransformFn, StandardJSONSchemaV1, StandardSchemaV1, StandardTypedV1, type StructuralKind, type StructuralOperationBranchResultByName, type StructuralOperationName, Structure, StructureNode, ToJsonSchema, Traversal, TraversalError, type TraversalKind, type TraversalMethodsByKind, type TraverseAllows, type TraverseApply, type TypeIntersectionMap, TypeMeta, type UndeclaredKeyBehavior, type UndeclaredKeyConfig, type UndeclaredKeyHandling, Union, type UnionChildKind, UnionNode, Unit, UnitNode, type UnknownAttachments, type UnknownErrorConfigs, type UnknownExpandedRangeSchema, type UnknownIntersectionMap, type UnknownIntersectionResult, type UnknownNodeImplementation, type UnknownNormalizedRangeSchema, type UnknownRangeSchema, type UpperBoundKind, type UpperNode, type VariadicSequenceElement, appendUniqueFlatRefs, appendUniqueNodes, arkKind, assertDefaultValueAssignability, assertNodeKind, type attachmentsOf, basisKinds, bindModule, boundClassesByKind, boundImplementationsByKind, boundKindPairsByLower, type childKindOf, compileComparator, compileLiteralPropAccess, compileObjectLiteral, compileSerializedValue, computeDefaultValueMorph, type conditionalRootOf, configureSchema, constraintKeyParser, constraintKeys, type constraintKindLeftOf, type constraintKindOf, type constraintKindOrLeftOf, constraintKinds, createDateSchemaNormalizer, createLengthRuleParser, createLengthSchemaNormalizer, createNode, dateLimitToString, type declareNode, type defAttachedAs, type defaultErrorContext, defaultValueSerializer, defineSchema, describeBranches, emptyBrandNameMessage, type errorContext, exclusivizeRangeSchema, type exportedNameOf, flatRef, flatRefsAreEqual, type flatResolutionsOf, flattenConstraints, type genericHktToConstraints, genericNode, type genericParamConstraints, type genericParamNames, type genericParamSchemasToAst, type getAssociatedDataForError, hasArkKind, implementNode, indexPropAccess, type innerAttachedAs, type instantiateRoot, type internalImplementationOf, intersectBranches, type intersectConstraintKinds, intersectConstraints, intersectNodesRoot, intersectOrPipeNodes, intersectProps, type intersectRoot, intrinsic, isNode, isNodeKind, type keySchemaDefinitions, type kindLeftOf, type kindOrLeftOf, type kindOrRightOf, type kindRightOf, makeRootAndArrayPropertiesMutable, mergeConfigs, mergeToJsonSchemaConfigs, morphChildKinds, type mutableInnerOfKind, type mutableNormalizedRootOfKind, node, nodeClassesByKind, type nodeImplementationInputOf, type nodeImplementationOf, nodeImplementationsByKind, nodeKinds, type nodeOfKind, nodesByRegisteredId, normalizeIndex, type ownIntersectionResult, type pairedRangeKind, parseAsSchema, parseDateLimit, parseExclusiveKey, parseGeneric, parseNode, pipeNodesRoot, postfixAfterOptionalOrDefaultableMessage, postfixWithoutVariadicMessage, precedenceByKind, precedenceOfKind, prestructuralKinds, pruneDiscriminant, reduceBranches, type reducibleKindOf, reference, refinementKinds, registerNodeId, registeredReference, registryName, type resolvableReferenceIn, type resolveConfig, type resolveReference, rootKinds, rootSchema, rootSchemaScope, schemaKindOf, type schemaKindOrRightOf, type schemaKindRightOf, schemaKindsRightOf, schemaScope, serializeLiteralKey, structuralKinds, structureKeys, throwInvalidOperandError, type toInternalScope, traverseKey, typeKeyToString, typeOrTermExtends, typePathToPropString, unflattenConstraints, unionChildKinds, type unwrapDefault, withId, withMeta, writeDefaultIntersectionMessage, writeDuplicateAliasError, writeDuplicateKeyMessage, writeEnumerableIndexBranches, writeIndiscriminableMorphMessage, writeIndivisibleMessage, writeInvalidJsonSchemaTargetMessage, writeInvalidKeysMessage, writeInvalidLengthBoundMessage, writeInvalidOperandMessage, writeInvalidPropertyKeyMessage, writeInvalidSchemaMessage, writeLiteralUnionEntriesMessage, writeMissingSubmoduleAccessMessage, writeMorphIntersectionMessage, writeNonIntegerDivisorMessage, writeNonPrimitiveNonFunctionDefaultValueMessage, writeNonStructuralOperandMessage, writeNonSubmoduleDotMessage, writeNumberIndexMessage, writeOrderedIntersectionMessage, type writeUnassignableDefaultValueMessage, writeUnboundableMessage, writeUnresolvableMessage, writeUnsatisfiableExpressionError, writeUnsatisfiedParameterConstraintMessage };\\n\\n}\"\n"
  },
  {
    "path": "ark/docs/components/dts/type.ts",
    "content": "/** THIS FILE IS AUTOGENERATED FROM ark/repo/dtsGen.ts **/\n// prettier-ignore\nexport const typeDts = \"declare module \\\"arktype\\\" {\\n    import * as _ark_schema from '@ark/schema';\\nimport { BaseRoot, BaseParseContext, TypeMeta, arkKind, GenericAst, GenericParamAst, writeUnsatisfiedParameterConstraintMessage, GenericRoot, genericParamNames, resolvableReferenceIn, writeUnresolvableMessage, writeNonSubmoduleDotMessage, emptyBrandNameMessage, writeUnboundableMessage, writeUnassignableDefaultValueMessage, writeIndivisibleMessage, writeNonStructuralOperandMessage, PrivateDeclaration, writeMissingSubmoduleAccessMessage, writeInvalidPropertyKeyMessage, UndeclaredKeyBehavior, Sequence, postfixAfterOptionalOrDefaultableMessage, BaseMappedPropInner, OptionalMappedPropInner, Prop, InclusiveNumericRangeSchema, ExclusiveNumericRangeSchema, ExactLength, InclusiveDateRangeSchema, ExclusiveDateRangeSchema, Divisor, Pattern, Morph, ToJsonSchema, JsonSchema, NodeSelector, Predicate, BaseNode, Disjoint, StandardSchemaV1, ArkErrors, unwrapDefault, RootSchema, BaseParseOptions, ArkSchemaScopeConfig, exportedNameOf, toInternalScope, NodeKind, RootKind, NodeSchema, nodeOfKind, reducibleKindOf, PreparsedNodeResolution, writeDuplicateAliasError, BaseScope, AliasDefEntry, GenericParamDef, BaseParseContextInput, flatResolutionsOf, LazyGenericBody, RootModule, ArkError } from '@ark/schema';\\nexport { ArkError, ArkErrors, ArkSchemaConfig, ArkSchemaScopeConfig, JsonSchema, Traversal, TraversalError } from '@ark/schema';\\nimport * as util from '@ark/util';\\nimport { Scanner, requireKeys, ErrorMessage, Completion, writeUnmatchedGroupCloseMessage, writeUnclosedGroupMessage, defined, anyOrNever, Stringifiable, Hkt, array, typeToString, arkKeyOf, NumberLiteral, join, lastOf, BigintLiteral, WhitespaceChar, trim as trim$1, writeMalformedNumericLiteralMessage, show, merge, Key, Backslash, ErrorType, satisfy, conform, arkIndexableOf, arkGet, toArkKey, listable, intersectUnion, inferred, optionalKeyOf, JsonStructure, Callable, unset, numericStringKeyOf, isDisjoint, unionToTuple, propValueOf, Constructor, get, Fn, applyElementLabels, flattenListable, Brand, noSuggest, ifEmptyObjectLiteral, Primitive, objectKindOrDomainOf, requiredKeyOf, equals, Json, omit, pick, Digit, liftArray, EcmascriptObjects, PlatformObjects, isSafelyMappable, intersectArrays, unionKeyOf } from '@ark/util';\\nexport { Hkt, ParseError, inferred } from '@ark/util';\\nimport { regex, Regex } from 'arkregex';\\nexport { regex } from 'arkregex';\\nimport { ArkSchemaConfig } from '@ark/schema/config';\\n\\ntype StringifiablePrefixOperator = \\\"keyof\\\";\\ndeclare const minComparators: {\\n    readonly \\\">\\\": true;\\n    readonly \\\">=\\\": true;\\n};\\ntype MinComparator = keyof typeof minComparators;\\ndeclare const maxComparators: {\\n    readonly \\\"<\\\": true;\\n    readonly \\\"<=\\\": true;\\n};\\ntype MaxComparator = keyof typeof maxComparators;\\ndeclare const comparators: {\\n    \\\">\\\": boolean;\\n    \\\">=\\\": boolean;\\n    \\\"<\\\": boolean;\\n    \\\"<=\\\": boolean;\\n    \\\"==\\\": boolean;\\n};\\ntype Comparator = keyof typeof comparators;\\ntype InvertedComparators = {\\n    \\\"<\\\": \\\">\\\";\\n    \\\">\\\": \\\"<\\\";\\n    \\\"<=\\\": \\\">=\\\";\\n    \\\">=\\\": \\\"<=\\\";\\n    \\\"==\\\": \\\"==\\\";\\n};\\ntype BranchOperator = \\\"&\\\" | \\\"|\\\" | \\\"|>\\\";\\ntype OpenLeftBound = {\\n    limit: LimitLiteral;\\n    comparator: MinComparator;\\n};\\ndeclare const writeOpenRangeMessage: <min extends LimitLiteral, comparator extends MinComparator>(min: min, comparator: comparator) => writeOpenRangeMessage<min, comparator>;\\ntype writeOpenRangeMessage<min extends LimitLiteral, comparator extends MinComparator> = `Left bounds are only valid when paired with right bounds (try ...${comparator}${min})`;\\ntype writeUnpairableComparatorMessage<comparator extends Comparator> = `Left-bounded expressions must specify their limits using < or <= (was ${comparator})`;\\ndeclare const writeUnpairableComparatorMessage: <comparator extends Comparator>(comparator: comparator) => writeUnpairableComparatorMessage<comparator>;\\ndeclare const writeMultipleLeftBoundsMessage: <openLimit extends LimitLiteral, openComparator extends MinComparator, limit extends LimitLiteral, comparator extends MinComparator>(openLimit: openLimit, openComparator: openComparator, limit: limit, comparator: comparator) => writeMultipleLeftBoundsMessage<openLimit, openComparator, limit, comparator>;\\ntype writeMultipleLeftBoundsMessage<openLimit extends LimitLiteral, openComparator extends MinComparator, limit extends LimitLiteral, comparator extends MinComparator> = `An expression may have at most one left bound (parsed ${openLimit}${InvertedComparators[openComparator]}, ${limit}${InvertedComparators[comparator]})`;\\n\\ndeclare const terminatingChars: {\\n    readonly \\\" \\\": 1;\\n    readonly \\\"\\\\n\\\": 1;\\n    readonly \\\"\\\\t\\\": 1;\\n    readonly \\\"<\\\": 1;\\n    readonly \\\">\\\": 1;\\n    readonly \\\"=\\\": 1;\\n    readonly \\\"|\\\": 1;\\n    readonly \\\"&\\\": 1;\\n    readonly \\\")\\\": 1;\\n    readonly \\\"[\\\": 1;\\n    readonly \\\"%\\\": 1;\\n    readonly \\\",\\\": 1;\\n    readonly \\\":\\\": 1;\\n    readonly \\\"?\\\": 1;\\n    readonly \\\"#\\\": 1;\\n};\\ntype TerminatingChar = keyof typeof terminatingChars;\\ndeclare const finalizingLookaheads: {\\n    readonly \\\">\\\": 1;\\n    readonly \\\",\\\": 1;\\n    readonly \\\"\\\": 1;\\n    readonly \\\"=\\\": 1;\\n    readonly \\\"?\\\": 1;\\n};\\ntype FinalizingLookahead = keyof typeof finalizingLookaheads;\\ndeclare const lookaheadIsFinalizing: (lookahead: string, unscanned: string) => lookahead is \\\">\\\" | \\\",\\\" | \\\"=\\\" | \\\"?\\\";\\ntype lookaheadIsFinalizing<lookahead extends string, unscanned extends string> = lookahead extends \\\">\\\" ? unscanned extends `=${infer nextUnscanned}` ? nextUnscanned extends `=${string}` ? true : false : Scanner.skipWhitespace<unscanned> extends (\\\"\\\" | `${TerminatingChar}${string}`) ? true : false : lookahead extends \\\"=\\\" ? unscanned extends `=${string}` ? false : true : lookahead extends \\\",\\\" | \\\"?\\\" ? true : false;\\ntype InfixToken = Comparator | \\\"|\\\" | \\\"&\\\" | \\\"%\\\" | \\\":\\\" | \\\"=>\\\" | \\\"|>\\\" | \\\"#\\\" | \\\"@\\\" | \\\"=\\\";\\ntype PostfixToken = \\\"[]\\\" | \\\"?\\\";\\n\\ntype BranchState$1 = {\\n    prefixes: StringifiablePrefixOperator[];\\n    leftBound: OpenLeftBound | null;\\n    intersection: BaseRoot | null;\\n    union: BaseRoot | null;\\n    pipe: BaseRoot | null;\\n};\\ntype RootedRuntimeState = requireKeys<RuntimeState, \\\"root\\\">;\\ndeclare class RuntimeState {\\n    root: BaseRoot | undefined;\\n    branches: BranchState$1;\\n    finalizer: FinalizingLookahead | undefined;\\n    groups: BranchState$1[];\\n    scanner: Scanner;\\n    ctx: BaseParseContext;\\n    constructor(scanner: Scanner, ctx: BaseParseContext);\\n    error(message: string): never;\\n    hasRoot(): this is RootedRuntimeState;\\n    setRoot(root: BaseRoot): void;\\n    unsetRoot(): this[\\\"root\\\"];\\n    constrainRoot(...args: Parameters<BaseRoot<any>[\\\"constrain\\\"]>): void;\\n    finalize(finalizer: FinalizingLookahead): void;\\n    reduceLeftBound(limit: LimitLiteral, comparator: Comparator): void;\\n    finalizeBranches(): void;\\n    finalizeGroup(): void;\\n    addPrefix(prefix: StringifiablePrefixOperator): void;\\n    applyPrefixes(): void;\\n    pushRootToBranch(token: BranchOperator): void;\\n    parseUntilFinalizer(): RootedRuntimeState;\\n    parseOperator(this: RootedRuntimeState): void;\\n    parseOperand(): void;\\n    private assertRangeUnset;\\n    reduceGroupOpen(): void;\\n    previousOperator(): MinComparator | StringifiablePrefixOperator | InfixToken | undefined;\\n    shiftedBy(count: number): this;\\n}\\n\\ntype StaticState = {\\n    root: unknown;\\n    branches: BranchState;\\n    groups: BranchState[];\\n    finalizer: FinalizingLookahead | ErrorMessage | undefined;\\n    scanned: string;\\n    unscanned: string;\\n};\\ntype BranchState = {\\n    prefixes: StringifiablePrefixOperator[];\\n    leftBound: OpenLeftBound | undefined;\\n    intersection: unknown;\\n    pipe: unknown;\\n    union: unknown;\\n};\\ndeclare namespace s {\\n    type initialize<def extends string> = from<{\\n        root: undefined;\\n        branches: initialBranches;\\n        groups: [];\\n        finalizer: undefined;\\n        scanned: \\\"\\\";\\n        unscanned: def;\\n    }>;\\n    type error<message extends string> = from<{\\n        root: ErrorMessage<message>;\\n        branches: initialBranches;\\n        groups: [];\\n        finalizer: ErrorMessage<message>;\\n        scanned: \\\"\\\";\\n        unscanned: \\\"\\\";\\n    }>;\\n    type completion<text extends string> = from<{\\n        root: Completion<text>;\\n        branches: initialBranches;\\n        groups: [];\\n        finalizer: Completion<text>;\\n        scanned: \\\"\\\";\\n        unscanned: \\\"\\\";\\n    }>;\\n    type initialBranches = branchesFrom<{\\n        prefixes: [];\\n        leftBound: undefined;\\n        intersection: undefined;\\n        pipe: undefined;\\n        union: undefined;\\n    }>;\\n    type updateScanned<previousScanned extends string, previousUnscanned extends string, updatedUnscanned extends string> = previousUnscanned extends `${infer justScanned}${updatedUnscanned}` ? `${previousScanned}${justScanned}` : previousScanned;\\n    type setRoot<s extends StaticState, root, unscanned extends string = s[\\\"unscanned\\\"]> = from<{\\n        root: root;\\n        branches: s[\\\"branches\\\"];\\n        groups: s[\\\"groups\\\"];\\n        finalizer: s[\\\"finalizer\\\"];\\n        scanned: updateScanned<s[\\\"scanned\\\"], s[\\\"unscanned\\\"], unscanned>;\\n        unscanned: unscanned;\\n    }>;\\n    type addPrefix<s extends StaticState, prefix extends StringifiablePrefixOperator, unscanned extends string = s[\\\"unscanned\\\"]> = from<{\\n        root: s[\\\"root\\\"];\\n        branches: {\\n            prefixes: [...s[\\\"branches\\\"][\\\"prefixes\\\"], prefix];\\n            leftBound: s[\\\"branches\\\"][\\\"leftBound\\\"];\\n            intersection: s[\\\"branches\\\"][\\\"intersection\\\"];\\n            pipe: s[\\\"branches\\\"][\\\"pipe\\\"];\\n            union: s[\\\"branches\\\"][\\\"union\\\"];\\n        };\\n        groups: s[\\\"groups\\\"];\\n        finalizer: s[\\\"finalizer\\\"];\\n        scanned: updateScanned<s[\\\"scanned\\\"], s[\\\"unscanned\\\"], unscanned>;\\n        unscanned: unscanned;\\n    }>;\\n    type reduceBranch<s extends StaticState, token extends BranchOperator, unscanned extends string> = s[\\\"branches\\\"][\\\"leftBound\\\"] extends {} ? openRangeError<s[\\\"branches\\\"][\\\"leftBound\\\"]> : from<{\\n        root: undefined;\\n        branches: {\\n            prefixes: [];\\n            leftBound: undefined;\\n            intersection: token extends \\\"&\\\" ? mergeToIntersection<s> : undefined;\\n            union: token extends \\\"|\\\" ? mergeToUnion<s> : token extends \\\"|>\\\" ? undefined : s[\\\"branches\\\"][\\\"union\\\"];\\n            pipe: token extends \\\"|>\\\" ? mergeToPipe<s> : s[\\\"branches\\\"][\\\"pipe\\\"];\\n        };\\n        groups: s[\\\"groups\\\"];\\n        finalizer: s[\\\"finalizer\\\"];\\n        scanned: updateScanned<s[\\\"scanned\\\"], s[\\\"unscanned\\\"], unscanned>;\\n        unscanned: unscanned;\\n    }>;\\n    type reduceLeftBound<s extends StaticState, limit extends LimitLiteral, comparator extends Comparator, unscanned extends string> = comparator extends \\\"<\\\" | \\\"<=\\\" ? s[\\\"branches\\\"][\\\"leftBound\\\"] extends {} ? s.error<writeMultipleLeftBoundsMessage<s[\\\"branches\\\"][\\\"leftBound\\\"][\\\"limit\\\"], s[\\\"branches\\\"][\\\"leftBound\\\"][\\\"comparator\\\"], limit, InvertedComparators[comparator]>> : from<{\\n        root: undefined;\\n        branches: {\\n            prefixes: s[\\\"branches\\\"][\\\"prefixes\\\"];\\n            leftBound: {\\n                limit: limit;\\n                comparator: InvertedComparators[comparator];\\n            };\\n            intersection: s[\\\"branches\\\"][\\\"intersection\\\"];\\n            pipe: s[\\\"branches\\\"][\\\"pipe\\\"];\\n            union: s[\\\"branches\\\"][\\\"union\\\"];\\n        };\\n        groups: s[\\\"groups\\\"];\\n        finalizer: s[\\\"finalizer\\\"];\\n        scanned: updateScanned<s[\\\"scanned\\\"], s[\\\"unscanned\\\"], unscanned>;\\n        unscanned: unscanned;\\n    }> : s.error<writeUnpairableComparatorMessage<comparator>>;\\n    type reduceRange<s extends StaticState, minLimit extends LimitLiteral, minComparator extends MinComparator, maxComparator extends MaxComparator, maxLimit extends LimitLiteral, unscanned extends string> = s.from<{\\n        root: [minLimit, minComparator, [s[\\\"root\\\"], maxComparator, maxLimit]];\\n        branches: {\\n            prefixes: s[\\\"branches\\\"][\\\"prefixes\\\"];\\n            leftBound: undefined;\\n            intersection: s[\\\"branches\\\"][\\\"intersection\\\"];\\n            pipe: s[\\\"branches\\\"][\\\"pipe\\\"];\\n            union: s[\\\"branches\\\"][\\\"union\\\"];\\n        };\\n        groups: s[\\\"groups\\\"];\\n        finalizer: s[\\\"finalizer\\\"];\\n        scanned: updateScanned<s[\\\"scanned\\\"], s[\\\"unscanned\\\"], unscanned>;\\n        unscanned: unscanned;\\n    }>;\\n    type reduceSingleBound<s extends StaticState, comparator extends Comparator, limit extends number | string, unscanned extends string> = s.from<{\\n        root: [s[\\\"root\\\"], comparator, limit];\\n        branches: {\\n            prefixes: s[\\\"branches\\\"][\\\"prefixes\\\"];\\n            leftBound: undefined;\\n            intersection: s[\\\"branches\\\"][\\\"intersection\\\"];\\n            pipe: s[\\\"branches\\\"][\\\"pipe\\\"];\\n            union: s[\\\"branches\\\"][\\\"union\\\"];\\n        };\\n        groups: s[\\\"groups\\\"];\\n        finalizer: s[\\\"finalizer\\\"];\\n        scanned: updateScanned<s[\\\"scanned\\\"], s[\\\"unscanned\\\"], unscanned>;\\n        unscanned: unscanned;\\n    }>;\\n    type mergeToIntersection<s extends StaticState> = s[\\\"branches\\\"][\\\"intersection\\\"] extends undefined ? mergePrefixes<s> : [s[\\\"branches\\\"][\\\"intersection\\\"], \\\"&\\\", mergePrefixes<s>];\\n    type mergeToUnion<s extends StaticState> = s[\\\"branches\\\"][\\\"union\\\"] extends undefined ? mergeToIntersection<s> : [s[\\\"branches\\\"][\\\"union\\\"], \\\"|\\\", mergeToIntersection<s>];\\n    type mergeToPipe<s extends StaticState> = s[\\\"branches\\\"][\\\"pipe\\\"] extends undefined ? mergeToUnion<s> : [s[\\\"branches\\\"][\\\"pipe\\\"], \\\"|>\\\", mergeToUnion<s>];\\n    type mergePrefixes<s extends StaticState, remaining extends unknown[] = s[\\\"branches\\\"][\\\"prefixes\\\"]> = remaining extends [infer head, ...infer tail] ? [\\n        head,\\n        mergePrefixes<s, tail>\\n    ] : s[\\\"root\\\"];\\n    type popGroup<stack extends BranchState[], top extends BranchState> = [\\n        ...stack,\\n        top\\n    ];\\n    type finalizeGroup<s extends StaticState, unscanned extends string> = s[\\\"branches\\\"][\\\"leftBound\\\"] extends {} ? openRangeError<s[\\\"branches\\\"][\\\"leftBound\\\"]> : s[\\\"groups\\\"] extends popGroup<infer stack, infer top> ? from<{\\n        groups: stack;\\n        branches: top;\\n        root: mergeToPipe<s>;\\n        finalizer: s[\\\"finalizer\\\"];\\n        scanned: updateScanned<s[\\\"scanned\\\"], s[\\\"unscanned\\\"], unscanned>;\\n        unscanned: unscanned;\\n    }> : s.error<writeUnmatchedGroupCloseMessage<\\\")\\\", unscanned>>;\\n    type reduceGroupOpen<s extends StaticState, unscanned extends string> = from<{\\n        groups: [...s[\\\"groups\\\"], s[\\\"branches\\\"]];\\n        branches: initialBranches;\\n        root: undefined;\\n        finalizer: s[\\\"finalizer\\\"];\\n        scanned: updateScanned<s[\\\"scanned\\\"], s[\\\"unscanned\\\"], unscanned>;\\n        unscanned: unscanned;\\n    }>;\\n    type finalize<s extends StaticState, finalizer extends FinalizingLookahead> = s[\\\"groups\\\"] extends [] ? s[\\\"branches\\\"][\\\"leftBound\\\"] extends {} ? openRangeError<s[\\\"branches\\\"][\\\"leftBound\\\"]> : from<{\\n        root: mergeToPipe<s>;\\n        groups: s[\\\"groups\\\"];\\n        branches: initialBranches;\\n        finalizer: finalizer;\\n        scanned: s[\\\"scanned\\\"];\\n        unscanned: s[\\\"unscanned\\\"];\\n    }> : s.error<writeUnclosedGroupMessage<\\\")\\\">>;\\n    type openRangeError<range extends defined<BranchState[\\\"leftBound\\\"]>> = s.error<writeOpenRangeMessage<range[\\\"limit\\\"], range[\\\"comparator\\\"]>>;\\n    type previousOperator<s extends StaticState> = s[\\\"branches\\\"][\\\"leftBound\\\"] extends {} ? s[\\\"branches\\\"][\\\"leftBound\\\"][\\\"comparator\\\"] : s[\\\"branches\\\"][\\\"prefixes\\\"] extends ([\\n        ...unknown[],\\n        infer tail extends string\\n    ]) ? tail : s[\\\"branches\\\"][\\\"intersection\\\"] extends {} ? \\\"&\\\" : s[\\\"branches\\\"][\\\"union\\\"] extends {} ? \\\"|\\\" : undefined;\\n    type scanTo<s extends StaticState, unscanned extends string> = from<{\\n        root: s[\\\"root\\\"];\\n        branches: s[\\\"branches\\\"];\\n        groups: s[\\\"groups\\\"];\\n        finalizer: s[\\\"finalizer\\\"];\\n        scanned: updateScanned<s[\\\"scanned\\\"], s[\\\"unscanned\\\"], unscanned>;\\n        unscanned: unscanned;\\n    }>;\\n    type from<s extends StaticState> = s;\\n    type branchesFrom<b extends BranchState> = b;\\n}\\n\\ntype KeywordConfig = {\\n    [k in keyof Ark.flat as parseConfigurableFlatAlias<k, Ark.flat[k]>]?: TypeMeta.Collapsible;\\n};\\ntype parseConfigurableFlatAlias<k extends string, v> = [\\n    v\\n] extends [anyOrNever] ? k : v extends {\\n    [arkKind]: \\\"generic\\\" | \\\"module\\\";\\n} ? never : k extends `${infer prefix}.root` ? prefix : k;\\ninterface ArkConfig extends ArkSchemaConfig {\\n    keywords?: KeywordConfig;\\n}\\ndeclare const configure: <config extends ArkConfig>(config: config) => config;\\ndeclare global {\\n    export interface ArkEnv {\\n        $(): Ark;\\n    }\\n}\\n/**\\n * This mirrors the global ArkEnv namespace as a local export. We use it instead\\n * of the global internally due to a bug in twoslash that prevents `ark/docs`\\n * from building if we refer to the global directly.\\n *\\n * If, in the future, docs can build while arktype refers to `ArkEnv.$` directly,\\n * this can be removed.\\n */\\ndeclare namespace ArkAmbient {\\n    type $ = ReturnType<ArkEnv[\\\"$\\\"]>;\\n    type meta = ArkEnv.meta;\\n    type prototypes = ArkEnv.prototypes;\\n}\\n\\ntype astToString<ast> = ast extends InferredAst | DefAst ? ast[2] : ast extends PostfixExpression<infer operator, infer operand> ? operator extends \\\"[]\\\" ? `${astToString<operand>}[]` : never : ast extends InfixExpression<infer operator, infer l, infer r> ? operator extends \\\"&\\\" | \\\"|\\\" | \\\"%\\\" | Comparator ? `${astToString<l>} ${operator} ${astToString<r>}` : never : ast extends Stringifiable ? `${ast extends bigint ? `${ast}n` : ast}` : \\\"...\\\";\\ntype writeConstrainedMorphMessage<constrainedAst> = `To constrain the output of ${astToString<constrainedAst>}, pipe like myMorph.to('number > 0').\\nTo constrain the input, intersect like myMorph.and('number > 0').`;\\n\\ntype GenericInstantiationAst<generic extends GenericAst = GenericAst, argAsts extends unknown[] = unknown[]> = [generic, \\\"<>\\\", argAsts];\\ntype inferGenericInstantiation<g extends GenericAst, argAsts extends unknown[], $, args> = g[\\\"bodyDef\\\"] extends Hkt ? Hkt.apply<g[\\\"bodyDef\\\"], {\\n    [i in keyof argAsts]: inferExpression<argAsts[i], $, args>;\\n}> : inferDefinition<g[\\\"bodyDef\\\"], resolveScope<g[\\\"$\\\"], $>, {\\n    [i in keyof g[\\\"names\\\"] & `${number}` as g[\\\"names\\\"][i]]: inferExpression<argAsts[i & keyof argAsts], resolveScope<g[\\\"arg$\\\"], $>, args>;\\n}>;\\ntype validateGenericInstantiation<g extends GenericAst, argAsts extends unknown[], $, args> = validateGenericArgs<g[\\\"paramsAst\\\"], argAsts, $, args, []>;\\ntype validateGenericArgs<params extends array<GenericParamAst>, argAsts extends array, $, args, indices extends 1[]> = argAsts extends readonly [infer arg, ...infer argsTail] ? validateAst<arg, $, args> extends infer e extends ErrorMessage ? e : inferAstRoot<arg, $, args> extends params[indices[\\\"length\\\"]][1] ? validateGenericArgs<params, argsTail, $, args, [...indices, 1]> : ErrorMessage<writeUnsatisfiedParameterConstraintMessage<params[indices[\\\"length\\\"]][0], typeToString<params[indices[\\\"length\\\"]][1]>, astToString<arg>>> : undefined;\\ntype resolveScope<g$, $> = g$ extends UnparsedScope ? $ : g$;\\n\\ntype inferAstRoot<ast, $, args> = ast extends array ? inferExpression<ast, $, args> : never;\\ntype inferAstIn<ast, $, args> = distill.In<inferAstRoot<ast, $, args>>;\\ntype DefAst<def = unknown, alias extends string = string> = [\\n    def,\\n    \\\"def\\\",\\n    alias\\n];\\ntype InferredAst<t = unknown, def extends string = string> = [\\n    t,\\n    \\\"inferred\\\",\\n    def\\n];\\ntype inferExpression<ast, $, args> = ast extends array ? ast extends InferredAst<infer resolution> ? resolution : ast extends DefAst<infer def> ? inferDefinition<def, $, args> : ast extends GenericInstantiationAst<infer g, infer argAsts> ? inferGenericInstantiation<g, argAsts, $, args> : ast[1] extends \\\"[]\\\" ? inferExpression<ast[0], $, args>[] : ast[1] extends \\\"|\\\" ? inferExpression<ast[0], $, args> | inferExpression<ast[2], $, args> : ast[1] extends \\\"&\\\" ? inferIntersection<inferExpression<ast[0], $, args>, inferExpression<ast[2], $, args>> : ast[1] extends \\\"|>\\\" ? inferPipe<inferExpression<ast[0], $, args>, inferExpression<ast[2], $, args>> : ast[1] extends \\\"=\\\" ? type.infer<ast[2]> extends infer defaultValue ? withDefault<inferExpression<ast[0], $, args>, defaultValue> : never : ast[1] extends \\\"#\\\" ? type.brand<inferExpression<ast[0], $, args>, ast[2]> : ast[1] extends Comparator ? ast[0] extends LimitLiteral ? inferExpression<ast[2], $, args> : inferExpression<ast[0], $, args> : ast[1] extends \\\"%\\\" ? inferExpression<ast[0], $, args> : ast[1] extends \\\"?\\\" ? inferExpression<ast[0], $, args> : ast[0] extends \\\"keyof\\\" ? arkKeyOf<inferExpression<ast[1], $, args>> : never : never;\\ntype PostfixExpression<operator extends PostfixToken = PostfixToken, operand = unknown> = readonly [operand, operator];\\ntype InfixExpression<operator extends InfixToken = InfixToken, l = unknown, r = unknown> = [l, operator, r];\\n\\ntype StringLiteral<contents extends string = string> = DoubleQuotedStringLiteral<contents> | SingleQuotedStringLiteral<contents>;\\ntype DoubleQuotedStringLiteral<contents extends string = string> = `\\\"${contents}\\\"`;\\ntype SingleQuotedStringLiteral<contents extends string = string> = `'${contents}'`;\\ndeclare const parseEnclosed: (s: RuntimeState, enclosing: EnclosingStartToken) => void;\\ntype parseEnclosed<s extends StaticState, enclosingStart extends EnclosingStartToken, unscanned extends string> = Scanner.shiftUntilEscapable<unscanned, EnclosingTokens[enclosingStart], \\\"\\\"> extends Scanner.shiftResult<infer scanned, infer nextUnscanned> ? _parseEnclosed<s, enclosingStart, scanned, nextUnscanned> : never;\\ntype _parseEnclosed<s extends StaticState, enclosingStart extends EnclosingStartToken, scanned extends string, nextUnscanned extends string, def extends string = `${enclosingStart}${scanned}${EnclosingTokens[enclosingStart]}`> = nextUnscanned extends \\\"\\\" ? s.error<writeUnterminatedEnclosedMessage<scanned, enclosingStart>> : enclosingStart extends EnclosingQuote ? s.setRoot<s, InferredAst<scanned, def>, nextUnscanned extends Scanner.shift<string, infer unscanned> ? unscanned : \\\"\\\"> : enclosingStart extends EnclosingRegexToken ? regex.parse<scanned> extends infer r ? r extends Regex ? s.setRoot<s, InferredAst<enclosingStart extends \\\"/\\\" ? r[\\\"infer\\\"] : (In: r[\\\"infer\\\"]) => Out<r[\\\"inferExecArray\\\"]>, def>, nextUnscanned extends Scanner.shift<string, infer unscanned> ? unscanned : \\\"\\\"> : r extends ErrorMessage<infer e> ? s.error<e> : never : never : s.setRoot<s, InferredAst<Date, def>, nextUnscanned extends Scanner.shift<string, infer unscanned> ? unscanned : \\\"\\\">;\\ndeclare const enclosingQuote: {\\n    readonly \\\"'\\\": 1;\\n    readonly '\\\"': 1;\\n};\\ntype EnclosingQuote = keyof typeof enclosingQuote;\\ndeclare const enclosingLiteralTokens: {\\n    readonly \\\"d'\\\": \\\"'\\\";\\n    readonly 'd\\\"': \\\"\\\\\\\"\\\";\\n    readonly \\\"'\\\": \\\"'\\\";\\n    readonly '\\\"': \\\"\\\\\\\"\\\";\\n};\\ntype EnclosingLiteralTokens = typeof enclosingLiteralTokens;\\ntype EnclosingLiteralStartToken = keyof EnclosingLiteralTokens;\\ndeclare const enclosingRegexTokens: {\\n    readonly \\\"/\\\": \\\"/\\\";\\n    readonly \\\"x/\\\": \\\"/\\\";\\n};\\ntype EnclosingRegexTokens = typeof enclosingRegexTokens;\\ntype EnclosingRegexToken = keyof EnclosingRegexTokens;\\ndeclare const enclosingTokens: {\\n    readonly \\\"/\\\": \\\"/\\\";\\n    readonly \\\"x/\\\": \\\"/\\\";\\n    readonly \\\"d'\\\": \\\"'\\\";\\n    readonly 'd\\\"': \\\"\\\\\\\"\\\";\\n    readonly \\\"'\\\": \\\"'\\\";\\n    readonly '\\\"': \\\"\\\\\\\"\\\";\\n};\\ntype EnclosingTokens = typeof enclosingTokens;\\ntype EnclosingStartToken = keyof EnclosingTokens;\\ndeclare const enclosingCharDescriptions: {\\n    readonly '\\\"': \\\"double-quote\\\";\\n    readonly \\\"'\\\": \\\"single-quote\\\";\\n    readonly \\\"/\\\": \\\"forward slash\\\";\\n};\\ntype enclosingCharDescriptions = typeof enclosingCharDescriptions;\\ndeclare const writeUnterminatedEnclosedMessage: <fragment extends string, enclosingStart extends EnclosingStartToken>(fragment: fragment, enclosingStart: enclosingStart) => writeUnterminatedEnclosedMessage<fragment, enclosingStart>;\\ntype writeUnterminatedEnclosedMessage<fragment extends string, enclosingStart extends EnclosingStartToken> = `${enclosingStart}${fragment} requires a closing ${enclosingCharDescriptions[EnclosingTokens[enclosingStart]]}`;\\n\\ndeclare const parseUnenclosed: (s: RuntimeState) => void;\\ntype parseUnenclosed<s extends StaticState, $, args> = Scanner.shiftUntil<s[\\\"unscanned\\\"], TerminatingChar> extends (Scanner.shiftResult<infer token, infer unscanned>) ? tryResolve<s, unscanned, token, $, args> extends s.from<infer s> ? s : never : never;\\ntype parseResolution<s extends StaticState, unscanned extends string, alias extends string, resolution, $, args> = resolutionToAst<alias, resolution> extends infer ast ? ast extends GenericAst ? parseGenericInstantiation<alias, ast, s.scanTo<s, unscanned>, $, args> : s.setRoot<s, ast, unscanned> : never;\\ndeclare const parseGenericInstantiation: (name: string, g: GenericRoot, s: RuntimeState) => BaseRoot;\\ntype parseGenericInstantiation<name extends string, g extends GenericAst, s extends StaticState, $, args> = Scanner.skipWhitespace<s[\\\"unscanned\\\"]> extends `<${infer unscanned}` ? parseGenericArgs<name, g, unscanned, $, args> extends infer result ? result extends ParsedArgs<infer argAsts, infer nextUnscanned> ? s.setRoot<s, GenericInstantiationAst<g, argAsts>, nextUnscanned> : result : never : s.error<writeInvalidGenericArgCountMessage<name, genericParamNames<g[\\\"paramsAst\\\"]>, [\\n]>>;\\ntype tryResolve<s extends StaticState, unscanned extends string, token extends string, $, args> = token extends keyof args ? parseResolution<s, unscanned, token, args[token], $, args> : token extends keyof $ ? parseResolution<s, unscanned, token, $[token], $, args> : token extends keyof ArkAmbient.$ ? parseResolution<s, unscanned, token, ArkAmbient.$[token], $, args> : `#${token}` extends keyof $ ? parseResolution<s, unscanned, token, $[`#${token}`], $, args> : token extends NumberLiteral<infer n> ? s.setRoot<s, InferredAst<n, token>, unscanned> : token extends (`${infer submodule extends keyof $ & string}.${infer reference}`) ? tryResolveSubmodule<token, $[submodule], reference, s, unscanned, $, args, [\\n    submodule\\n]> : token extends (`${infer submodule extends keyof ArkAmbient.$ & string}.${infer reference}`) ? tryResolveSubmodule<token, ArkAmbient.$[submodule], reference, s, unscanned, $, args, [\\n    submodule\\n]> : token extends BigintLiteral<infer b> ? s.setRoot<s, InferredAst<b, token>, unscanned> : token extends \\\"keyof\\\" ? s.addPrefix<s, \\\"keyof\\\", unscanned> : unresolvableState<s, token, $, args, []>;\\ntype tryResolveSubmodule<token extends string, resolution, reference extends string, s extends StaticState, unscanned extends string, $, args, submodulePath extends string[]> = resolution extends {\\n    [arkKind]: \\\"module\\\";\\n} ? reference extends keyof resolution ? parseResolution<s, unscanned, token, resolution[reference], $, args> : reference extends (`${infer nestedSubmodule extends keyof resolution & string}.${infer nestedReference}`) ? tryResolveSubmodule<token, resolution[nestedSubmodule], nestedReference, s, unscanned, $, args, [\\n    ...submodulePath,\\n    nestedSubmodule\\n]> : unresolvableState<s, reference, resolution, {}, submodulePath> : s.error<writeNonSubmoduleDotMessage<lastOf<submodulePath>>>;\\n/** Provide valid completions for the current token, or fallback to an\\n * unresolvable error if there are none */\\ntype unresolvableState<s extends StaticState, token extends string, resolutions, args, submodulePath extends string[]> = [\\n    token,\\n    s[\\\"unscanned\\\"]\\n] extends [\\\"\\\", Scanner.shift<\\\"#\\\", infer unscanned>] ? Scanner.shiftUntil<unscanned, TerminatingChar> extends (Scanner.shiftResult<infer name, string>) ? s.error<writePrefixedPrivateReferenceMessage<name>> : never : validReferenceFromToken<token, resolutions, args, submodulePath> extends (never) ? s.error<writeUnresolvableMessage<qualifiedReference<token, submodulePath>>> : s.completion<`${s[\\\"scanned\\\"]}${qualifiedReference<validReferenceFromToken<token, resolutions, args, submodulePath>, submodulePath>}`>;\\ntype qualifiedReference<reference extends string, submodulePath extends string[]> = join<[...submodulePath, reference], \\\".\\\">;\\ntype validReferenceFromToken<token extends string, $, args, submodulePath extends string[]> = Extract<submodulePath[\\\"length\\\"] extends 0 ? BaseCompletions<$, args> : resolvableReferenceIn<$>, `${token}${string}`>;\\ntype writeMissingRightOperandMessage<token extends string, unscanned extends string = \\\"\\\"> = `Token '${token}' requires a right operand${unscanned extends \\\"\\\" ? \\\"\\\" : ` before '${unscanned}'`}`;\\ndeclare const writeMissingRightOperandMessage: <token extends string, unscanned extends string>(token: token, unscanned?: unscanned) => writeMissingRightOperandMessage<token, unscanned>;\\n\\ndeclare const parseOperand: (s: RuntimeState) => void;\\ntype parseOperand<s extends StaticState, $, args> = s[\\\"unscanned\\\"] extends Scanner.shift<infer lookahead, infer unscanned> ? lookahead extends \\\"(\\\" ? s.reduceGroupOpen<s, unscanned> : lookahead extends EnclosingStartToken ? parseEnclosed<s, lookahead, unscanned> : lookahead extends WhitespaceChar ? parseOperand<s.scanTo<s, unscanned>, $, args> : lookahead extends \\\"d\\\" ? unscanned extends (Scanner.shift<infer enclosing extends EnclosingQuote, infer nextUnscanned>) ? parseEnclosed<s, `d${enclosing}`, nextUnscanned> : parseUnenclosed<s, $, args> : lookahead extends \\\"x\\\" ? unscanned extends Scanner.shift<\\\"/\\\", infer nextUnscanned> ? parseEnclosed<s, \\\"x/\\\", nextUnscanned> : parseUnenclosed<s, $, args> : parseUnenclosed<s, $, args> : s.completion<`${s[\\\"scanned\\\"]}${BaseCompletions<$, args>}`>;\\n\\ntype UnitLiteralKeyword = \\\"null\\\" | \\\"undefined\\\" | \\\"true\\\" | \\\"false\\\";\\ntype UnitLiteral = UnenclosedUnitLiteral | EnclosedUnitLiteral;\\ntype UnenclosedUnitLiteral = BigintLiteral | NumberLiteral | UnitLiteralKeyword;\\ntype EnclosedUnitLiteral = StringLiteral | DateLiteral;\\ntype ParsedDefaultableProperty = readonly [BaseRoot, \\\"=\\\", unknown];\\ndeclare const parseDefault: (s: RootedRuntimeState) => ParsedDefaultableProperty;\\ntype parseDefault<root, unscanned extends string> = trim$1<unscanned> extends infer defaultExpression extends string ? defaultExpression extends UnenclosedUnitLiteral ? [\\n    root,\\n    \\\"=\\\",\\n    defaultExpression\\n] : defaultExpression extends (`${infer start extends EnclosingLiteralStartToken}${string}`) ? defaultExpression extends `${start}${infer nextUnscanned}` ? isValidEnclosedLiteral<start, nextUnscanned> extends true ? [\\n    root,\\n    \\\"=\\\",\\n    defaultExpression\\n] : ErrorMessage<writeNonLiteralDefaultMessage<defaultExpression>> : never : ErrorMessage<writeNonLiteralDefaultMessage<defaultExpression>> : never;\\ntype isValidEnclosedLiteral<start extends EnclosingLiteralStartToken, unscanned extends string> = Scanner.shiftUntilEscapable<unscanned, EnclosingLiteralTokens[start], \\\"\\\"> extends Scanner.shiftResult<string, infer nextUnscanned> ? nextUnscanned extends EnclosingLiteralTokens[start] ? true : false : false;\\ndeclare const writeNonLiteralDefaultMessage: <defaultDef extends string>(defaultDef: defaultDef) => writeNonLiteralDefaultMessage<defaultDef>;\\ntype writeNonLiteralDefaultMessage<defaultDef extends string> = `Default value '${defaultDef}' must be a literal value`;\\n\\ndeclare const parseBound: (s: RootedRuntimeState, start: ComparatorStartChar) => void;\\ntype parseBound<s extends StaticState, start extends ComparatorStartChar, unscanned extends string, $, args> = shiftComparator<start, unscanned> extends infer shiftResultOrError ? shiftResultOrError extends (Scanner.shiftResult<infer comparator extends Comparator, infer nextUnscanned>) ? s[\\\"root\\\"] extends (InferredAst<Date | number, `${infer limit extends number | DateLiteral}`>) ? s.reduceLeftBound<s, limit, comparator, nextUnscanned> : parseRightBound<s.scanTo<s, nextUnscanned>, comparator, $, args> : shiftResultOrError : never;\\ntype OneCharComparator = \\\">\\\" | \\\"<\\\";\\ntype ComparatorStartChar = Comparator extends `${infer char}${string}` ? char : never;\\ndeclare const shiftComparator: (s: RuntimeState, start: ComparatorStartChar) => Comparator;\\ntype shiftComparator<start extends ComparatorStartChar, unscanned extends string> = unscanned extends `=${infer nextUnscanned}` ? [`${start}=`, nextUnscanned] : [start & OneCharComparator, unscanned];\\ndeclare const parseRightBound: (s: RootedRuntimeState, comparator: Comparator) => void;\\ntype parseRightBound<s extends StaticState, comparator extends Comparator, $, args> = parseOperand<s, $, args> extends infer nextState extends StaticState ? nextState[\\\"root\\\"] extends (InferredAst<unknown, `${infer limit extends number | DateLiteral}`>) ? s[\\\"branches\\\"][\\\"leftBound\\\"] extends {} ? comparator extends MaxComparator ? s.reduceRange<s, s[\\\"branches\\\"][\\\"leftBound\\\"][\\\"limit\\\"], s[\\\"branches\\\"][\\\"leftBound\\\"][\\\"comparator\\\"], comparator, limit, nextState[\\\"unscanned\\\"]> : s.error<writeUnpairableComparatorMessage<comparator>> : s.reduceSingleBound<s, comparator, limit, nextState[\\\"unscanned\\\"]> : s.error<writeInvalidLimitMessage<comparator, astToString<nextState[\\\"root\\\"]>, \\\"right\\\">> : never;\\ndeclare const writeInvalidLimitMessage: <comparator extends Comparator, limit extends string | number, boundKind extends BoundExpressionKind>(comparator: comparator, limit: limit, boundKind: boundKind) => writeInvalidLimitMessage<comparator, limit, boundKind>;\\ntype writeInvalidLimitMessage<comparator extends Comparator, limit extends string | number, boundKind extends BoundExpressionKind> = `Comparator ${boundKind extends \\\"left\\\" ? InvertedComparators[comparator] : comparator} must be ${boundKind extends \\\"left\\\" ? \\\"preceded\\\" : \\\"followed\\\"} by a corresponding literal (was ${limit})`;\\ntype BoundExpressionKind = \\\"left\\\" | \\\"right\\\";\\n\\ndeclare const parseBrand: (s: RootedRuntimeState) => void;\\ntype parseBrand<s extends StaticState, unscanned extends string> = Scanner.shiftUntil<Scanner.skipWhitespace<unscanned>, TerminatingChar> extends Scanner.shiftResult<`${infer brandName}`, infer nextUnscanned> ? brandName extends \\\"\\\" ? s.error<emptyBrandNameMessage> : s.setRoot<s, [s[\\\"root\\\"], \\\"#\\\", brandName], nextUnscanned> : never;\\n\\ndeclare const parseDivisor: (s: RootedRuntimeState) => void;\\ntype parseDivisor<s extends StaticState, unscanned extends string> = Scanner.shiftUntil<Scanner.skipWhitespace<unscanned>, TerminatingChar> extends Scanner.shiftResult<infer scanned, infer nextUnscanned> ? scanned extends `${infer divisor extends number}` ? divisor extends 0 ? s.error<writeInvalidDivisorMessage<0>> : s.setRoot<s, [s[\\\"root\\\"], \\\"%\\\", divisor], nextUnscanned> : s.error<writeInvalidDivisorMessage<scanned>> : never;\\ndeclare const writeInvalidDivisorMessage: <divisor extends string | number>(divisor: divisor) => writeInvalidDivisorMessage<divisor>;\\ntype writeInvalidDivisorMessage<divisor extends string | number> = `% operator must be followed by a non-zero integer literal (was ${divisor})`;\\n\\ndeclare const parseOperator: (s: RootedRuntimeState) => void;\\ntype parseOperator<s extends StaticState, $, args> = s[\\\"unscanned\\\"] extends Scanner.shift<infer lookahead, infer unscanned> ? lookahead extends \\\"[\\\" ? unscanned extends Scanner.shift<\\\"]\\\", infer nextUnscanned> ? s.setRoot<s, [s[\\\"root\\\"], \\\"[]\\\"], nextUnscanned> : s.error<incompleteArrayTokenMessage> : lookahead extends \\\"|\\\" ? unscanned extends Scanner.shift<\\\">\\\", infer nextUnscanned> ? s.reduceBranch<s, \\\"|>\\\", nextUnscanned> : s.reduceBranch<s, lookahead, unscanned> : lookahead extends \\\"&\\\" ? s.reduceBranch<s, lookahead, unscanned> : lookahead extends \\\")\\\" ? s.finalizeGroup<s, unscanned> : lookaheadIsFinalizing<lookahead, unscanned> extends true ? s.finalize<s.scanTo<s, unscanned>, lookahead & FinalizingLookahead> : lookahead extends ComparatorStartChar ? parseBound<s, lookahead, unscanned, $, args> : lookahead extends \\\"%\\\" ? parseDivisor<s, unscanned> : lookahead extends \\\"#\\\" ? parseBrand<s, unscanned> : lookahead extends WhitespaceChar ? parseOperator<s.scanTo<s, unscanned>, $, args> : s.error<writeUnexpectedCharacterMessage<lookahead>> : s.finalize<s, \\\"\\\">;\\ndeclare const writeUnexpectedCharacterMessage: <char extends string, shouldBe extends string>(char: char, shouldBe?: shouldBe) => writeUnexpectedCharacterMessage<char, shouldBe>;\\ntype writeUnexpectedCharacterMessage<char extends string, shouldBe extends string = \\\"\\\"> = `'${char}' is not allowed here${shouldBe extends \\\"\\\" ? \\\"\\\" : ` (should be ${shouldBe})`}`;\\ndeclare const incompleteArrayTokenMessage = \\\"Missing expected ']'\\\";\\ntype incompleteArrayTokenMessage = typeof incompleteArrayTokenMessage;\\n\\ndeclare const parseString: (def: string, ctx: BaseParseContext) => InnerParseResult;\\n/**\\n * Try to parse the definition from right to left using the most common syntax.\\n * This can be much more efficient for simple definitions.\\n */\\ntype parseString<def extends string, $, args> = def extends keyof $ ? resolutionToAst<def, $[def]> : def extends `${infer child}[]` ? child extends keyof $ ? [\\n    resolutionToAst<child, $[child]>,\\n    \\\"[]\\\"\\n] : fullStringParse<s.initialize<def>, $, args> : fullStringParse<s.initialize<def>, $, args>;\\ntype inferString<def extends string, $, args> = inferAstRoot<parseString<def, $, args>, $, args>;\\ntype BaseCompletions<$, args, otherSuggestions extends string = never> = resolvableReferenceIn<$> | resolvableReferenceIn<ArkAmbient.$> | (keyof args & string) | StringifiablePrefixOperator | otherSuggestions;\\ndeclare const fullStringParse: (s: RuntimeState) => InnerParseResult;\\ntype fullStringParse<s extends StaticState, $, args> = extractFinalizedResult<parseUntilFinalizer<s, $, args>>;\\ndeclare const parseUntilFinalizer: (s: RuntimeState) => RootedRuntimeState;\\ntype parseUntilFinalizer<s extends StaticState, $, args> = s[\\\"finalizer\\\"] extends undefined ? parseUntilFinalizer<next<s, $, args>, $, args> : s;\\ndeclare const next: (s: RuntimeState) => void;\\ntype next<s extends StaticState, $, args> = s[\\\"root\\\"] extends undefined ? parseOperand<s, $, args> : parseOperator<s, $, args>;\\ntype extractFinalizedResult<s extends StaticState> = s[\\\"finalizer\\\"] extends \\\"\\\" ? s[\\\"root\\\"] : s[\\\"finalizer\\\"] extends ErrorMessage ? s[\\\"finalizer\\\"] : s[\\\"finalizer\\\"] extends \\\"?\\\" ? [s[\\\"root\\\"], \\\"?\\\"] : s[\\\"finalizer\\\"] extends \\\"=\\\" ? parseDefault<s[\\\"root\\\"], s[\\\"unscanned\\\"]> : ErrorMessage<writeUnexpectedCharacterMessage<s[\\\"finalizer\\\"] & string>>;\\n\\ndeclare const parseGenericArgs: (name: string, g: GenericRoot, s: RuntimeState) => BaseRoot[];\\ntype parseGenericArgs<name extends string, g extends GenericAst, unscanned extends string, $, args> = _parseGenericArgs<name, g, unscanned, $, args, [], []>;\\ntype ParsedArgs<result extends unknown[] = unknown[], unscanned extends string = string> = {\\n    result: result;\\n    unscanned: unscanned;\\n};\\ndeclare const _parseGenericArgs: (name: string, g: GenericRoot, s: RuntimeState, argNodes: BaseRoot[]) => BaseRoot[];\\ntype _parseGenericArgs<name extends string, g extends GenericAst, unscanned extends string, $, args, argDefs extends string[], argAsts extends unknown[]> = parseUntilFinalizer<s.initialize<unscanned>, $, args> extends (infer finalArgState extends StaticState) ? {\\n    defs: [\\n        ...argDefs,\\n        finalArgState[\\\"scanned\\\"] extends `${infer def}${\\\",\\\" | \\\">\\\"}` ? def : finalArgState[\\\"scanned\\\"]\\n    ];\\n    asts: [...argAsts, finalArgState[\\\"root\\\"]];\\n    unscanned: finalArgState[\\\"unscanned\\\"];\\n} extends ({\\n    defs: infer nextDefs extends string[];\\n    asts: infer nextAsts extends unknown[];\\n    unscanned: infer nextUnscanned extends string;\\n}) ? finalArgState[\\\"finalizer\\\"] extends \\\">\\\" ? nextAsts[\\\"length\\\"] extends g[\\\"paramsAst\\\"][\\\"length\\\"] ? ParsedArgs<nextAsts, nextUnscanned> : s.error<writeInvalidGenericArgCountMessage<name, genericParamNames<g[\\\"paramsAst\\\"]>, nextDefs>> : finalArgState[\\\"finalizer\\\"] extends \\\",\\\" ? _parseGenericArgs<name, g, nextUnscanned, $, args, nextDefs, nextAsts> : finalArgState[\\\"finalizer\\\"] extends ErrorMessage ? finalArgState : s.error<writeUnclosedGroupMessage<\\\">\\\">> : never : never;\\ndeclare const writeInvalidGenericArgCountMessage: <name extends string, params extends array<string>, argDefs extends array<string>>(name: name, params: params, argDefs: argDefs) => writeInvalidGenericArgCountMessage<name, params, argDefs>;\\ntype writeInvalidGenericArgCountMessage<name extends string, params extends array<string>, argDefs extends array<string>> = `${name}<${join<params, \\\", \\\">}> requires exactly ${params[\\\"length\\\"]} args (got ${argDefs[\\\"length\\\"]}${argDefs[\\\"length\\\"] extends (0) ? \\\"\\\" : `: ${join<argDefs, \\\",\\\">}`})`;\\n\\ntype validateRange<l, comparator extends Comparator, r, $, args> = [\\n    l\\n] extends [LimitLiteral] ? validateBound<r, comparator, l, \\\"left\\\", $, args> : [l] extends [[infer leftAst, Comparator, unknown]] ? ErrorMessage<writeDoubleRightBoundMessage<astToString<leftAst>>> : validateBound<l, comparator, r & LimitLiteral, \\\"right\\\", $, args>;\\ntype validateBound<boundedAst, comparator extends Comparator, limit extends LimitLiteral, boundKind extends BoundExpressionKind, $, args> = inferAstRoot<boundedAst, $, args> extends infer bounded ? isNumericallyBoundable<bounded> extends true ? limit extends number ? validateAst<boundedAst, $, args> : ErrorMessage<writeInvalidLimitMessage<comparator, limit, boundKind>> : [bounded] extends [Date] ? validateAst<boundedAst, $, args> : [bounded] extends [InferredMorph] ? ErrorMessage<writeConstrainedMorphMessage<boundedAst>> : ErrorMessage<writeUnboundableMessage<typeToString<bounded>>> : never;\\ntype isNumericallyBoundable<bounded> = [\\n    bounded\\n] extends [number] ? true : [bounded] extends [string] ? true : [bounded] extends [array] ? true : false;\\ndeclare const writeDoubleRightBoundMessage: <root extends string>(root: root) => writeDoubleRightBoundMessage<root>;\\ntype writeDoubleRightBoundMessage<root extends string> = `Expression ${root} must have at most one right bound`;\\n\\ntype validateDefault<baseAst, unitLiteral extends UnitLiteral, $, args> = validateAst<baseAst, $, args> extends infer e extends ErrorMessage ? e : type.infer<unitLiteral> extends inferAstIn<baseAst, $, args> ? undefined : ErrorMessage<writeUnassignableDefaultValueMessage<astToString<baseAst>, unitLiteral>>;\\n\\ntype validateDivisor<l, $, args> = inferAstRoot<l, $, args> extends infer data ? [\\n    data\\n] extends [number] ? validateAst<l, $, args> : [data] extends [InferredMorph] ? ErrorMessage<writeConstrainedMorphMessage<l>> : ErrorMessage<writeIndivisibleMessage<data>> : never;\\n\\ntype validateKeyof<operandAst, $, args> = inferAstRoot<operandAst, $, args> extends infer data ? [\\n    data\\n] extends [object] ? validateAst<operandAst, $, args> : ErrorMessage<writeNonStructuralOperandMessage<\\\"keyof\\\", typeToString<data>>> : never;\\n\\ntype validateAst<ast, $, args> = ast extends ErrorMessage ? ast : ast extends InferredAst ? validateInferredAst<ast[0], ast[2]> : ast extends DefAst ? ast[2] extends PrivateDeclaration<infer name> ? ErrorMessage<writePrefixedPrivateReferenceMessage<name>> : undefined : ast extends PostfixExpression<\\\"[]\\\" | \\\"?\\\", infer operand> ? validateAst<operand, $, args> : ast extends InfixExpression<infer operator, infer l, infer r> ? operator extends BranchOperator ? validateInfix<ast, $, args> : operator extends Comparator ? validateRange<l, operator, r, $, args> : operator extends \\\"%\\\" ? validateDivisor<l, $, args> : operator extends \\\"=\\\" ? validateDefault<l, r & UnitLiteral, $, args> : operator extends \\\"#\\\" ? validateAst<l, $, args> : ErrorMessage<writeUnexpectedExpressionMessage<astToString<ast>>> : ast extends [\\\"keyof\\\", infer operand] ? validateKeyof<operand, $, args> : ast extends GenericInstantiationAst<infer g, infer argAsts> ? validateGenericInstantiation<g, argAsts, $, args> : ErrorMessage<writeUnexpectedExpressionMessage<astToString<ast>>> & {\\n    ast: ast;\\n};\\ntype writeUnexpectedExpressionMessage<expression extends string> = `Failed to parse the expression resulting from ${expression}`;\\ndeclare const writePrefixedPrivateReferenceMessage: <name extends string>(name: name) => writePrefixedPrivateReferenceMessage<name>;\\ntype writePrefixedPrivateReferenceMessage<name extends string> = `Private type references should not include '#'. Use '${name}' instead.`;\\ntype validateInferredAst<inferred, def extends string> = def extends NumberLiteral ? number extends inferred ? ErrorMessage<writeMalformedNumericLiteralMessage<def, \\\"number\\\">> : undefined : def extends BigintLiteral ? bigint extends inferred ? ErrorMessage<writeMalformedNumericLiteralMessage<def, \\\"bigint\\\">> : undefined : [inferred] extends [anyOrNever] ? undefined : def extends PrivateDeclaration<infer name> ? ErrorMessage<writePrefixedPrivateReferenceMessage<name>> : inferred extends Generic ? ErrorMessage<writeInvalidGenericArgCountMessage<def, inferred[\\\"names\\\"], []>> : inferred extends {\\n    [arkKind]: \\\"module\\\";\\n} ? \\\"root\\\" extends keyof inferred ? undefined : ErrorMessage<writeMissingSubmoduleAccessMessage<def>> : def extends ErrorMessage ? def : undefined;\\ntype validateString<def extends string, $, args> = parseString<def, $, args> extends infer ast ? validateAst<ast, $, args> extends infer result extends ErrorMessage ? result extends Completion<infer text> ? text : result : def : never;\\ntype validateInfix<ast extends InfixExpression, $, args> = validateAst<ast[0], $, args> extends infer e extends ErrorMessage ? e : validateAst<ast[2], $, args> extends infer e extends ErrorMessage ? e : undefined;\\ndeclare const shallowOptionalMessage = \\\"Optional definitions like 'string?' are only valid as properties in an object or tuple\\\";\\ntype shallowOptionalMessage = typeof shallowOptionalMessage;\\ndeclare const shallowDefaultableMessage = \\\"Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple\\\";\\ntype shallowDefaultableMessage = typeof shallowDefaultableMessage;\\n\\ntype inferObjectLiteral<def extends object, $, args> = show<\\\"...\\\" extends keyof def ? merge<inferDefinition<def[\\\"...\\\"], $, args>, _inferObjectLiteral<def, $, args>> : _inferObjectLiteral<def, $, args>>;\\n/**\\n * Infers the contents of an object literal, ignoring a spread definition\\n */\\ntype _inferObjectLiteral<def extends object, $, args> = {\\n    -readonly [k in keyof def as nonOptionalKeyFromEntry<k, def[k], $, args>]: inferDefinition<def[k], $, args>;\\n} & {\\n    -readonly [k in keyof def as optionalKeyFromEntry<k, def[k]>]?: def[k] extends OptionalPropertyDefinition<infer baseDef> ? inferDefinition<baseDef, $, args> : inferDefinition<def[k], $, args>;\\n};\\ntype validateObjectLiteral<def, $, args> = {\\n    [k in keyof def]: preparseKey<k> extends (infer parsedKey extends PreparsedKey) ? parsedKey extends PreparsedEntryKey<\\\"index\\\"> ? validateString<parsedKey[\\\"normalized\\\"], $, args> extends (ErrorMessage<infer message>) ? ErrorType<message> : inferDefinition<parsedKey[\\\"normalized\\\"], $, args> extends Key ? validateProperty<def[k], parsedKey[\\\"kind\\\"], $, args> : ErrorMessage<writeInvalidPropertyKeyMessage<parsedKey[\\\"normalized\\\"]>> : validateProperty<def[k], parsedKey[\\\"kind\\\"], $, args> : never;\\n};\\ntype nonOptionalKeyFromEntry<k extends PropertyKey, v, $, args> = preparseKey<k> extends infer parsedKey ? parsedKey extends PreparsedEntryKey<\\\"required\\\"> ? [\\n    v\\n] extends [OptionalPropertyDefinition] ? [\\n    v\\n] extends [anyOrNever] ? parsedKey[\\\"normalized\\\"] : never : parsedKey[\\\"normalized\\\"] : parsedKey extends PreparsedEntryKey<\\\"index\\\"> ? inferDefinition<parsedKey[\\\"normalized\\\"], $, args> & Key : never : never;\\ntype optionalKeyFromEntry<k extends PropertyKey, v> = preparseKey<k> extends infer parsedKey ? parsedKey extends PreparsedEntryKey<\\\"optional\\\"> ? parsedKey[\\\"normalized\\\"] : v extends OptionalPropertyDefinition ? k : never : never;\\ntype normalizedKeyKind<kind extends EntryKeyKind> = kind extends \\\"index\\\" ? string : Key;\\ntype PreparsedEntryKey<kind extends EntryKeyKind = EntryKeyKind, normalized extends normalizedKeyKind<kind> = normalizedKeyKind<kind>> = {\\n    kind: kind;\\n    normalized: normalized;\\n};\\ntype PreparsedSpecialKey<kind extends SpecialKeyKind = SpecialKeyKind> = {\\n    kind: kind;\\n};\\ntype PreparsedKey = PreparsedEntryKey | PreparsedSpecialKey;\\ndeclare namespace PreparsedKey {\\n    type from<t extends PreparsedKey> = t;\\n}\\ntype ParsedKeyKind = EntryKeyKind | SpecialKeyKind;\\ntype EntryKeyKind = \\\"required\\\" | \\\"optional\\\" | \\\"index\\\";\\ntype SpecialKeyKind = \\\"spread\\\" | \\\"undeclared\\\";\\ntype MetaKey = \\\"...\\\" | \\\"+\\\";\\ntype IndexKey<def extends string = string> = `[${def}]`;\\ndeclare const preparseKey: (key: Key) => PreparsedKey;\\ntype preparseKey<k> = k extends symbol ? PreparsedKey.from<{\\n    kind: \\\"required\\\";\\n    normalized: k;\\n}> : k extends `${infer inner}?` ? inner extends `${infer baseName}${Backslash}` ? PreparsedKey.from<{\\n    kind: \\\"required\\\";\\n    normalized: `${baseName}?`;\\n}> : PreparsedKey.from<{\\n    kind: \\\"optional\\\";\\n    normalized: inner;\\n}> : k extends \\\"+\\\" ? {\\n    kind: \\\"undeclared\\\";\\n} : k extends \\\"...\\\" ? {\\n    kind: \\\"spread\\\";\\n} : k extends `${Backslash}${infer escapedMeta extends MetaKey}` ? PreparsedKey.from<{\\n    kind: \\\"required\\\";\\n    normalized: escapedMeta;\\n}> : k extends IndexKey<infer def> ? PreparsedKey.from<{\\n    kind: \\\"index\\\";\\n    normalized: def;\\n}> : PreparsedKey.from<{\\n    kind: \\\"required\\\";\\n    normalized: k extends (`${Backslash}${infer escapedIndexKey extends IndexKey}`) ? escapedIndexKey : k extends Key ? k : `${k & number}`;\\n}>;\\ndeclare const writeInvalidSpreadTypeMessage: <def extends string>(def: def) => writeInvalidSpreadTypeMessage<def>;\\ntype writeInvalidSpreadTypeMessage<def extends string> = `Spread operand must resolve to an object literal type (was ${def})`;\\n\\ntype ParsedOptionalProperty = readonly [BaseRoot, \\\"?\\\"];\\ntype validateProperty<def, keyKind extends ParsedKeyKind, $, args> = [\\n    def\\n] extends [anyOrNever] ? \\n/** this extra [anyOrNever] check is required to ensure that nested `type` invocations\\n * like the following are not prematurely validated by the outer call:\\n *\\n * ```ts\\n * type({\\n * \\t\\\"test?\\\": type(\\\"string\\\").pipe(x => x === \\\"true\\\")\\n * })\\n * ```\\n */\\ndef : keyKind extends \\\"spread\\\" ? def extends validateInnerDefinition<def, $, args> ? inferDefinition<def, $, args> extends object ? def : ErrorType<writeInvalidSpreadTypeMessage<typeToString<inferDefinition<def, $, args>>>> : validateInnerDefinition<def, $, args> : keyKind extends \\\"undeclared\\\" ? UndeclaredKeyBehavior : keyKind extends \\\"required\\\" ? validateInnerDefinition<def, $, args> : def extends OptionalPropertyDefinition ? ErrorMessage<invalidOptionalKeyKindMessage> : isDefaultable<def, $, args> extends true ? ErrorMessage<invalidDefaultableKeyKindMessage> : validateInnerDefinition<def, $, args>;\\ntype isDefaultable<def, $, args> = def extends DefaultablePropertyTuple ? true : def extends PossibleDefaultableStringDefinition ? parseString<def, $, args> extends DefaultablePropertyTuple ? true : false : false;\\ntype OptionalPropertyDefinition<baseDef = unknown> = OptionalPropertyTuple<baseDef> | OptionalPropertyString<baseDef & string>;\\ntype OptionalPropertyString<baseDef extends string = string> = `${baseDef}?`;\\ntype OptionalPropertyTuple<baseDef = unknown> = readonly [baseDef, \\\"?\\\"];\\ntype PossibleDefaultableStringDefinition = `${string}=${string}`;\\ntype DefaultablePropertyTuple<baseDef = unknown, thunkableProperty = unknown> = readonly [baseDef, \\\"=\\\", thunkableProperty];\\ndeclare const invalidOptionalKeyKindMessage = \\\"Only required keys may make their values optional, e.g. { [mySymbol]: ['number', '?'] }\\\";\\ntype invalidOptionalKeyKindMessage = typeof invalidOptionalKeyKindMessage;\\ndeclare const invalidDefaultableKeyKindMessage = \\\"Only required keys may specify default values, e.g. { value: 'number = 0' }\\\";\\ntype invalidDefaultableKeyKindMessage = typeof invalidDefaultableKeyKindMessage;\\n\\ntype validateTupleLiteral<def extends array, $, args> = parseSequence<def, $, args> extends infer s extends SequenceParseState ? Readonly<s[\\\"validated\\\"]> : never;\\ntype inferTupleLiteral<def extends array, $, args> = parseSequence<def, $, args> extends infer s extends SequenceParseState ? s[\\\"inferred\\\"] : never;\\ntype SequencePhase = satisfy<keyof Sequence.Inner, SequencePhase.prefix | SequencePhase.optionals | SequencePhase.defaultables | SequencePhase.postfix>;\\ndeclare namespace SequencePhase {\\n    type prefix = \\\"prefix\\\";\\n    type optionals = \\\"optionals\\\";\\n    type defaultables = \\\"defaultables\\\";\\n    type postfix = \\\"postfix\\\";\\n}\\ntype SequenceParseState = {\\n    unscanned: array;\\n    inferred: array;\\n    validated: array;\\n    phase: SequencePhase;\\n};\\ntype parseSequence<def extends array, $, args> = parseNextElement<{\\n    unscanned: def;\\n    inferred: [];\\n    validated: [];\\n    phase: SequencePhase.prefix;\\n}, $, args>;\\ntype PreparsedElementKind = \\\"required\\\" | SequencePhase.optionals | SequencePhase.defaultables;\\ntype PreparsedElement = {\\n    head: unknown;\\n    tail: array;\\n    inferred: unknown;\\n    validated: unknown;\\n    kind: PreparsedElementKind;\\n    spread: boolean;\\n};\\ndeclare namespace PreparsedElement {\\n    type from<result extends PreparsedElement> = result;\\n    type required = \\\"required\\\";\\n    type optionals = \\\"optionals\\\";\\n    type defaultables = \\\"defaultables\\\";\\n}\\ntype preparseNextState<s extends SequenceParseState, $, args> = s[\\\"unscanned\\\"] extends readonly [\\\"...\\\", infer head, ...infer tail] ? preparseNextElement<head, tail, true, $, args> : s[\\\"unscanned\\\"] extends readonly [infer head, ...infer tail] ? preparseNextElement<head, tail, false, $, args> : null;\\ntype preparseNextElement<head, tail extends array, spread extends boolean, $, args> = PreparsedElement.from<{\\n    head: head;\\n    tail: tail;\\n    inferred: inferDefinition<head, $, args>;\\n    validated: validateInnerDefinition<head, $, args>;\\n    kind: head extends OptionalPropertyDefinition ? PreparsedElement.optionals : head extends DefaultablePropertyTuple ? PreparsedElement.defaultables : isDefaultable<head, $, args> extends true ? PreparsedElement.defaultables : PreparsedElement.required;\\n    spread: spread;\\n}>;\\ntype parseNextElement<s extends SequenceParseState, $, args> = preparseNextState<s, $, args> extends infer next extends PreparsedElement ? parseNextElement<{\\n    unscanned: next[\\\"tail\\\"];\\n    inferred: nextInferred<s, next>;\\n    validated: nextValidated<s, next>;\\n    phase: next[\\\"kind\\\"] extends (SequencePhase.optionals | SequencePhase.defaultables) ? next[\\\"kind\\\"] : number extends nextInferred<s, next>[\\\"length\\\"] ? s[\\\"phase\\\"] : SequencePhase.prefix;\\n}, $, args> : s;\\ntype nextInferred<s extends SequenceParseState, next extends PreparsedElement> = next[\\\"spread\\\"] extends true ? [\\n    ...s[\\\"inferred\\\"],\\n    ...conform<next[\\\"inferred\\\"], array>\\n] : next[\\\"kind\\\"] extends SequencePhase.optionals ? [\\n    ...s[\\\"inferred\\\"],\\n    next[\\\"inferred\\\"]?\\n] : [...s[\\\"inferred\\\"], next[\\\"inferred\\\"]];\\ntype nextValidated<s extends SequenceParseState, next extends PreparsedElement> = [\\n    ...s[\\\"validated\\\"],\\n    ...nextValidatedSpreadOperatorIfPresent<s, next>,\\n    nextValidatedElement<s, next>\\n];\\ntype nextValidatedSpreadOperatorIfPresent<s extends SequenceParseState, next extends PreparsedElement> = next[\\\"spread\\\"] extends true ? [\\n    next[\\\"inferred\\\"] extends infer spreadOperand extends array ? [\\n        number,\\n        number\\n    ] extends ([\\n        s[\\\"inferred\\\"][\\\"length\\\"],\\n        spreadOperand[\\\"length\\\"]\\n    ]) ? ErrorMessage<multipleVariadicMessage> : \\\"...\\\" : ErrorMessage<writeNonArraySpreadMessage<next[\\\"head\\\"]>>\\n] : [];\\ntype nextValidatedElement<s extends SequenceParseState, next extends PreparsedElement> = next[\\\"kind\\\"] extends SequencePhase.optionals ? next[\\\"spread\\\"] extends true ? ErrorMessage<spreadOptionalMessage> : s[\\\"phase\\\"] extends SequencePhase.postfix ? ErrorMessage<optionalOrDefaultableAfterVariadicMessage> : next[\\\"validated\\\"] : next[\\\"kind\\\"] extends SequencePhase.defaultables ? next[\\\"spread\\\"] extends true ? ErrorMessage<spreadDefaultableMessage> : s[\\\"phase\\\"] extends SequencePhase.optionals ? ErrorMessage<defaultablePostOptionalMessage> : s[\\\"phase\\\"] extends SequencePhase.postfix ? ErrorMessage<optionalOrDefaultableAfterVariadicMessage> : next[\\\"validated\\\"] : [s[\\\"phase\\\"], next[\\\"spread\\\"]] extends ([\\n    SequencePhase.optionals | SequencePhase.defaultables,\\n    false\\n]) ? ErrorMessage<postfixAfterOptionalOrDefaultableMessage> : next[\\\"validated\\\"];\\ndeclare const writeNonArraySpreadMessage: <operand extends string>(operand: operand) => writeNonArraySpreadMessage<operand>;\\ntype writeNonArraySpreadMessage<operand> = `Spread element must be an array${operand extends string ? ` (was ${operand})` : \\\"\\\"}`;\\ndeclare const multipleVariadicMesage = \\\"A tuple may have at most one variadic element\\\";\\ntype multipleVariadicMessage = typeof multipleVariadicMesage;\\ndeclare const optionalOrDefaultableAfterVariadicMessage = \\\"An optional element may not follow a variadic element\\\";\\ntype optionalOrDefaultableAfterVariadicMessage = typeof optionalOrDefaultableAfterVariadicMessage;\\ndeclare const spreadOptionalMessage = \\\"A spread element cannot be optional\\\";\\ntype spreadOptionalMessage = typeof spreadOptionalMessage;\\ndeclare const spreadDefaultableMessage = \\\"A spread element cannot have a default\\\";\\ntype spreadDefaultableMessage = typeof spreadDefaultableMessage;\\ndeclare const defaultablePostOptionalMessage = \\\"A defaultable element may not follow an optional element without a default\\\";\\ntype defaultablePostOptionalMessage = typeof defaultablePostOptionalMessage;\\n\\n/** @ts-ignore cast variance */\\ninterface Type$6<out t extends object = object, $ = {}> extends Type$1<t, $> {\\n    readonly(): t extends array ? Type$5<{\\n        readonly [i in keyof t]: t[i];\\n    }, $> : Type$6<{\\n        readonly [k in keyof t]: t[k];\\n    }, $>;\\n    keyof(): instantiateType<arkKeyOf<t>, $>;\\n    /**\\n     * Get the `Type` of a property of this `Type<object>`.\\n     * @example type({ foo: \\\"string\\\" }).get(\\\"foo\\\") // Type<string>\\n     */\\n    get<const k1 extends arkIndexableOf<t>, r = instantiateType<arkGet<t, k1>, $>>(k1: k1 | type.cast<k1>): r extends infer _ ? _ : never;\\n    get<const k1 extends arkIndexableOf<t>, const k2 extends arkIndexableOf<arkGet<t, k1>>, r = instantiateType<arkGet<arkGet<t, k1>, k2>, $>>(k1: k1 | type.cast<k1>, k2: k2 | type.cast<k2>): r extends infer _ ? _ : never;\\n    get<const k1 extends arkIndexableOf<t>, const k2 extends arkIndexableOf<arkGet<t, k1>>, const k3 extends arkIndexableOf<arkGet<arkGet<t, k1>, k2>>, r = instantiateType<arkGet<arkGet<arkGet<t, k1>, k2>, k3>, $>>(k1: k1 | type.cast<k1>, k2: k2 | type.cast<k2>, k3: k3 | type.cast<k3>): r extends infer _ ? _ : never;\\n    /**\\n     * Create a copy of this `Type` with only the specified properties.\\n     * @example type({ foo: \\\"string\\\", bar: \\\"number\\\" }).pick(\\\"foo\\\") // Type<{ foo: string }>\\n     */\\n    pick<const key extends arkKeyOf<t> = never>(...keys: (key | type.cast<key>)[]): Type$6<{\\n        [k in keyof t as Extract<toArkKey<t, k>, key>]: t[k];\\n    }, $>;\\n    /**\\n     * Create a copy of this `Type` with all properties except the specified ones.\\n     * @example type({ foo: \\\"string\\\", bar: \\\"number\\\" }).omit(\\\"foo\\\") // Type<{ bar: number }>\\n     */\\n    omit<const key extends arkKeyOf<t> = never>(...keys: (key | type.cast<key>)[]): Type$6<{\\n        [k in keyof t as Exclude<toArkKey<t, k>, key>]: t[k];\\n    }, $>;\\n    /**\\n     * Merge another `Type` definition, overriding properties of this `Type` with the duplicate keys.\\n     * @example type({ a: \\\"1\\\", b: \\\"2\\\" }).merge({ b: \\\"3\\\", c: \\\"4\\\" }) // Type<{ a: 1, b: 3, c: 4 }>\\n     */\\n    merge<const def, inferredDef = type.infer<def, $>, r = Type$6<merge<t, inferredDef>, $>>(def: type.validate<def, $> & (inferredDef extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredDef]>)): r extends infer _ ? _ : never;\\n    /**\\n     * Create a copy of this `Type` with all properties required.\\n     * @example const T = type({ \\\"foo?\\\"\\\": \\\"string\\\" }).required() // Type<{ foo: string }>\\n     */\\n    required(): Type$6<{\\n        [k in keyof t]-?: t[k];\\n    }, $>;\\n    /**\\n     * Create a copy of this `Type` with all properties optional.\\n     * @example: const T = type({ foo: \\\"string\\\" }).optional() // Type<{ foo?: string }>\\n     */\\n    partial(): Type$6<{\\n        [k in keyof t]?: t[k];\\n    }, $>;\\n    map<transformed extends listable<MappedTypeProp>, r = Type$6<constructMapped<t, transformed>, $>>(flatMapEntry: (entry: typePropOf<t, $>) => transformed): r extends infer _ ? _ : never;\\n    /**\\n     * List of property info of this `Type<object>`.\\n     * @example type({ foo: \\\"string = \\\"\\\" }).props // [{ kind: \\\"required\\\", key: \\\"foo\\\", value: Type<string>, default: \\\"\\\" }]\\n     */\\n    props: array<typePropOf<t, $>>;\\n}\\ntype typePropOf<o, $> = keyof o extends infer k ? k extends keyof o ? typeProp<o, k, $> : never : never;\\ntype typeProp<o, k extends keyof o, $, t = o[k] & ({} | null)> = t extends Default<infer t, infer defaultValue> ? DefaultedTypeProp<k & Key, t, defaultValue, $> : BaseTypeProp<k extends optionalKeyOf<o> ? \\\"optional\\\" : \\\"required\\\", k & Key, t, $>;\\ninterface BaseTypeProp<kind extends Prop.Kind = Prop.Kind, k extends Key = Key, \\n/** @ts-ignore cast variance */\\nout v = unknown, $ = {}> {\\n    kind: kind;\\n    key: k;\\n    value: instantiateType<v, $>;\\n    meta: ArkEnv.meta;\\n    toJSON: () => JsonStructure;\\n}\\ninterface DefaultedTypeProp<k extends Key = Key, v = unknown, defaultValue = v, $ = {}> extends BaseTypeProp<\\\"optional\\\", k, v, $> {\\n    default: defaultValue;\\n}\\ntype MappedTypeProp<k extends Key = Key, v = unknown> = BaseMappedTypeProp<k, v> | OptionalMappedTypeProp<k, v>;\\ntype BaseMappedTypeProp<k extends Key, v> = merge<BaseMappedPropInner, {\\n    key: k;\\n    value: type.cast<v>;\\n}>;\\ntype OptionalMappedTypeProp<k extends Key, v> = merge<OptionalMappedPropInner, {\\n    key: k;\\n    value: type.cast<v>;\\n    default?: v;\\n}>;\\ntype constructMapped<t, transformed extends listable<MappedTypeProp>> = show<intersectUnion<fromTypeProps<t, transformed extends array ? transformed : [transformed]>>>;\\ntype fromTypeProps<t, props extends array<MappedTypeProp>> = show<{\\n    [prop in props[number] as Extract<applyHomomorphicOptionality<t, prop>, {\\n        kind: \\\"required\\\";\\n    }>[\\\"key\\\"]]: prop[\\\"value\\\"][inferred];\\n} & {\\n    [prop in props[number] as Extract<applyHomomorphicOptionality<t, prop>, {\\n        kind: \\\"optional\\\";\\n        default?: never;\\n    }>[\\\"key\\\"]]?: prop[\\\"value\\\"][inferred];\\n} & {\\n    [prop in props[number] as Extract<applyHomomorphicOptionality<t, prop>, {\\n        kind: \\\"optional\\\";\\n        default: unknown;\\n    }>[\\\"key\\\"]]: withDefault<prop[\\\"value\\\"][inferred], prop[\\\"default\\\" & keyof prop]>;\\n}>;\\ntype NonObjectMergeErrorMessage = \\\"Merged type must be an object\\\";\\ntype applyHomomorphicOptionality<t, prop extends MappedTypeProp> = prop[\\\"kind\\\"] extends string ? prop : prop & {\\n    kind: prop[\\\"key\\\"] extends optionalKeyOf<t> ? \\\"optional\\\" : \\\"required\\\";\\n};\\n\\ninterface Type$5<\\n/** @ts-ignore cast variance */\\nout t extends readonly unknown[] = readonly unknown[], $ = {}> extends Type$6<t, $> {\\n    atLeastLength(schema: InclusiveNumericRangeSchema): this;\\n    atMostLength(schema: InclusiveNumericRangeSchema): this;\\n    moreThanLength(schema: ExclusiveNumericRangeSchema): this;\\n    lessThanLength(schema: ExclusiveNumericRangeSchema): this;\\n    exactlyLength(schema: ExactLength.Schema): this;\\n}\\n\\n/** @ts-ignore cast variance */\\ninterface Type$4<out t extends globalThis.Date = globalThis.Date, $ = {}> extends Type$6<t, $> {\\n    atOrAfter(schema: InclusiveDateRangeSchema): this;\\n    atOrBefore(schema: InclusiveDateRangeSchema): this;\\n    laterThan(schema: ExclusiveDateRangeSchema): this;\\n    earlierThan(schema: ExclusiveDateRangeSchema): this;\\n}\\n\\n/** @ts-ignore cast variance */\\ninterface Type$3<out t extends number = number, $ = {}> extends Type$1<t, $> {\\n    divisibleBy(schema: Divisor.Schema): this;\\n    atLeast(schema: InclusiveNumericRangeSchema): this;\\n    atMost(schema: InclusiveNumericRangeSchema): this;\\n    moreThan(schema: ExclusiveNumericRangeSchema): this;\\n    lessThan(schema: ExclusiveNumericRangeSchema): this;\\n}\\n\\n/** @ts-ignore cast variance */\\ninterface Type$2<out t extends string = string, $ = {}> extends Type$1<t, $> {\\n    matching<const schema extends Pattern.Schema>(schema: schema): schema extends string ? Type$2<regex.infer<schema>, $> : schema extends {\\n        rule: infer pattern extends string;\\n    } ? Type$2<regex.infer<pattern>, $> : this;\\n    atLeastLength(schema: InclusiveNumericRangeSchema): this;\\n    atMostLength(schema: InclusiveNumericRangeSchema): this;\\n    moreThanLength(schema: ExclusiveNumericRangeSchema): this;\\n    lessThanLength(schema: ExclusiveNumericRangeSchema): this;\\n    exactlyLength(schema: ExactLength.Schema): this;\\n}\\n\\ntype instantiateType<t, $> = [\\n    t\\n] extends [anyOrNever] ? Type$1<t, $> : [t] extends [object] ? [\\n    t\\n] extends [array] ? Type$5<t, $> : [t] extends [Date] ? Type$4<t, $> : Type$6<t, $> : [t] extends [string] ? Type$2<t, $> : [t] extends [number] ? Type$3<t, $> : Type$1<t, $>;\\n\\ntype NaryUnionParser<$> = {\\n    (): Type<never, $>;\\n    <const a, r = Type<type.infer<a, $>, $>>(a: type.validate<a, $>): r extends infer _ ? _ : never;\\n    <const a, const b, r = Type<type.infer<a, $> | type.infer<b, $>, $>>(a: type.validate<a, $>, b: type.validate<b, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, r = Type<type.infer<a, $> | type.infer<b, $> | type.infer<c, $>, $>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, r = Type<type.infer<a, $> | type.infer<b, $> | type.infer<c, $> | type.infer<d, $>, $>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>, d: type.validate<d, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, r = Type<type.infer<a, $> | type.infer<b, $> | type.infer<c, $> | type.infer<d, $> | type.infer<e, $>, $>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>, d: type.validate<d, $>, e: type.validate<e, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, r = Type<type.infer<a, $> | type.infer<b, $> | type.infer<c, $> | type.infer<d, $> | type.infer<e, $> | type.infer<f, $>, $>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>, d: type.validate<d, $>, e: type.validate<e, $>, f: type.validate<f, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, r = Type<type.infer<a, $> | type.infer<b, $> | type.infer<c, $> | type.infer<d, $> | type.infer<e, $> | type.infer<f, $> | type.infer<g, $>, $>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>, d: type.validate<d, $>, e: type.validate<e, $>, f: type.validate<f, $>, g: type.validate<g, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, r = Type<type.infer<a, $> | type.infer<b, $> | type.infer<c, $> | type.infer<d, $> | type.infer<e, $> | type.infer<f, $> | type.infer<g, $> | type.infer<h, $>, $>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>, d: type.validate<d, $>, e: type.validate<e, $>, f: type.validate<f, $>, g: type.validate<g, $>, h: type.validate<h, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, const i, r = Type<type.infer<a, $> | type.infer<b, $> | type.infer<c, $> | type.infer<d, $> | type.infer<e, $> | type.infer<f, $> | type.infer<g, $> | type.infer<h, $> | type.infer<i, $>, $>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>, d: type.validate<d, $>, e: type.validate<e, $>, f: type.validate<f, $>, g: type.validate<g, $>, h: type.validate<h, $>, i: type.validate<i, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, const i, const j, r = Type<type.infer<a, $> | type.infer<b, $> | type.infer<c, $> | type.infer<d, $> | type.infer<e, $> | type.infer<f, $> | type.infer<g, $> | type.infer<h, $> | type.infer<i, $> | type.infer<j, $>>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>, d: type.validate<d, $>, e: type.validate<e, $>, f: type.validate<f, $>, g: type.validate<g, $>, h: type.validate<h, $>, i: type.validate<i, $>, j: type.validate<j, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, const i, const j, const k, r = Type<type.infer<a, $> | type.infer<b, $> | type.infer<c, $> | type.infer<d, $> | type.infer<e, $> | type.infer<f, $> | type.infer<g, $> | type.infer<h, $> | type.infer<i, $> | type.infer<j, $> | type.infer<k, $>>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>, d: type.validate<d, $>, e: type.validate<e, $>, f: type.validate<f, $>, g: type.validate<g, $>, h: type.validate<h, $>, i: type.validate<i, $>, j: type.validate<j, $>, k: type.validate<k, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, const i, const j, const k, const l, r = Type<type.infer<a, $> | type.infer<b, $> | type.infer<c, $> | type.infer<d, $> | type.infer<e, $> | type.infer<f, $> | type.infer<g, $> | type.infer<h, $> | type.infer<i, $> | type.infer<j, $> | type.infer<k, $> | type.infer<l, $>, $>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>, d: type.validate<d, $>, e: type.validate<e, $>, f: type.validate<f, $>, g: type.validate<g, $>, h: type.validate<h, $>, i: type.validate<i, $>, j: type.validate<j, $>, k: type.validate<k, $>, l: type.validate<l, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, const i, const j, const k, const l, const m, r = Type<type.infer<a, $> | type.infer<b, $> | type.infer<c, $> | type.infer<d, $> | type.infer<e, $> | type.infer<f, $> | type.infer<g, $> | type.infer<h, $> | type.infer<i, $> | type.infer<j, $> | type.infer<k, $> | type.infer<l, $> | type.infer<m, $>, $>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>, d: type.validate<d, $>, e: type.validate<e, $>, f: type.validate<f, $>, g: type.validate<g, $>, h: type.validate<h, $>, i: type.validate<i, $>, j: type.validate<j, $>, k: type.validate<k, $>, l: type.validate<l, $>, m: type.validate<m, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, const i, const j, const k, const l, const m, const n, r = Type<type.infer<a, $> | type.infer<b, $> | type.infer<c, $> | type.infer<d, $> | type.infer<e, $> | type.infer<f, $> | type.infer<g, $> | type.infer<h, $> | type.infer<i, $> | type.infer<j, $> | type.infer<k, $> | type.infer<l, $> | type.infer<m, $> | type.infer<n, $>, $>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>, d: type.validate<d, $>, e: type.validate<e, $>, f: type.validate<f, $>, g: type.validate<g, $>, h: type.validate<h, $>, i: type.validate<i, $>, j: type.validate<j, $>, k: type.validate<k, $>, l: type.validate<l, $>, m: type.validate<m, $>, n: type.validate<n, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, const i, const j, const k, const l, const m, const n, const o, r = Type<type.infer<a, $> | type.infer<b, $> | type.infer<c, $> | type.infer<d, $> | type.infer<e, $> | type.infer<f, $> | type.infer<g, $> | type.infer<h, $> | type.infer<i, $> | type.infer<j, $> | type.infer<k, $> | type.infer<l, $> | type.infer<m, $> | type.infer<n, $> | type.infer<o, $>, $>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>, d: type.validate<d, $>, e: type.validate<e, $>, f: type.validate<f, $>, g: type.validate<g, $>, h: type.validate<h, $>, i: type.validate<i, $>, j: type.validate<j, $>, k: type.validate<k, $>, l: type.validate<l, $>, m: type.validate<m, $>, n: type.validate<n, $>, o: type.validate<o, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, const i, const j, const k, const l, const m, const n, const o, const p, r = Type<type.infer<a, $> | type.infer<b, $> | type.infer<c, $> | type.infer<d, $> | type.infer<e, $> | type.infer<f, $> | type.infer<g, $> | type.infer<h, $> | type.infer<i, $> | type.infer<j, $> | type.infer<k, $> | type.infer<l, $> | type.infer<m, $> | type.infer<n, $> | type.infer<o, $> | type.infer<p, $>, $>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>, d: type.validate<d, $>, e: type.validate<e, $>, f: type.validate<f, $>, g: type.validate<g, $>, h: type.validate<h, $>, i: type.validate<i, $>, j: type.validate<j, $>, k: type.validate<k, $>, l: type.validate<l, $>, m: type.validate<m, $>, n: type.validate<n, $>, o: type.validate<o, $>, p: type.validate<p, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, const i, const j, const k, const l, const m, const n, const o, const p, const q, r = Type<type.infer<a, $> | type.infer<b, $> | type.infer<c, $> | type.infer<d, $> | type.infer<e, $> | type.infer<f, $> | type.infer<g, $> | type.infer<h, $> | type.infer<i, $> | type.infer<j, $> | type.infer<k, $> | type.infer<l, $> | type.infer<m, $> | type.infer<n, $> | type.infer<o, $> | type.infer<p, $> | type.infer<q, $>, $>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>, d: type.validate<d, $>, e: type.validate<e, $>, f: type.validate<f, $>, g: type.validate<g, $>, h: type.validate<h, $>, i: type.validate<i, $>, j: type.validate<j, $>, k: type.validate<k, $>, l: type.validate<l, $>, m: type.validate<m, $>, n: type.validate<n, $>, o: type.validate<o, $>, p: type.validate<p, $>, q: type.validate<q, $>): r extends infer _ ? _ : never;\\n    <const defs extends readonly unknown[], r = Type<type.infer<defs[number], $>, $>>(...defs: {\\n        [i in keyof defs]: type.validate<defs[i], $>;\\n    }): r extends infer _ ? _ : never;\\n};\\ntype NaryIntersectionParser<$> = {\\n    (): Type<unknown, $>;\\n    <const a, r = Type<type.infer<a, $>, $>>(a: type.validate<a, $>): r extends infer _ ? _ : never;\\n    <const a, const b, r = Type<inferIntersection<type.infer<a, $>, type.infer<b, $>>, $>>(a: type.validate<a, $>, b: type.validate<b, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, r = Type<inferNaryIntersection<[\\n        type.infer<a, $>,\\n        type.infer<b, $>,\\n        type.infer<c, $>\\n    ]>, $>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, r = Type<inferNaryIntersection<[\\n        type.infer<a, $>,\\n        type.infer<b, $>,\\n        type.infer<c, $>,\\n        type.infer<d, $>\\n    ]>, $>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>, d: type.validate<d, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, r = Type<inferNaryIntersection<[\\n        type.infer<a, $>,\\n        type.infer<b, $>,\\n        type.infer<c, $>,\\n        type.infer<d, $>,\\n        type.infer<e, $>\\n    ]>, $>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>, d: type.validate<d, $>, e: type.validate<e, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, r = Type<inferNaryIntersection<[\\n        type.infer<a, $>,\\n        type.infer<b, $>,\\n        type.infer<c, $>,\\n        type.infer<d, $>,\\n        type.infer<e, $>,\\n        type.infer<f, $>\\n    ]>, $>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>, d: type.validate<d, $>, e: type.validate<e, $>, f: type.validate<f, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, r = Type<inferNaryIntersection<[\\n        type.infer<a, $>,\\n        type.infer<b, $>,\\n        type.infer<c, $>,\\n        type.infer<d, $>,\\n        type.infer<e, $>,\\n        type.infer<f, $>,\\n        type.infer<g, $>\\n    ]>, $>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>, d: type.validate<d, $>, e: type.validate<e, $>, f: type.validate<f, $>, g: type.validate<g, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, r = Type<inferNaryIntersection<[\\n        type.infer<a, $>,\\n        type.infer<b, $>,\\n        type.infer<c, $>,\\n        type.infer<d, $>,\\n        type.infer<e, $>,\\n        type.infer<f, $>,\\n        type.infer<g, $>,\\n        type.infer<h, $>\\n    ]>, $>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>, d: type.validate<d, $>, e: type.validate<e, $>, f: type.validate<f, $>, g: type.validate<g, $>, h: type.validate<h, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, const i, r = Type<inferNaryIntersection<[\\n        type.infer<a, $>,\\n        type.infer<b, $>,\\n        type.infer<c, $>,\\n        type.infer<d, $>,\\n        type.infer<e, $>,\\n        type.infer<f, $>,\\n        type.infer<g, $>,\\n        type.infer<h, $>,\\n        type.infer<i, $>\\n    ]>, $>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>, d: type.validate<d, $>, e: type.validate<e, $>, f: type.validate<f, $>, g: type.validate<g, $>, h: type.validate<h, $>, i: type.validate<i, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, const i, const j, r = Type<inferNaryIntersection<[\\n        type.infer<a, $>,\\n        type.infer<b, $>,\\n        type.infer<c, $>,\\n        type.infer<d, $>,\\n        type.infer<e, $>,\\n        type.infer<f, $>,\\n        type.infer<g, $>,\\n        type.infer<h, $>,\\n        type.infer<i, $>,\\n        type.infer<j, $>\\n    ]>, $>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>, d: type.validate<d, $>, e: type.validate<e, $>, f: type.validate<f, $>, g: type.validate<g, $>, h: type.validate<h, $>, i: type.validate<i, $>, j: type.validate<j, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, const i, const j, const k, r = Type<inferNaryIntersection<[\\n        type.infer<a, $>,\\n        type.infer<b, $>,\\n        type.infer<c, $>,\\n        type.infer<d, $>,\\n        type.infer<e, $>,\\n        type.infer<f, $>,\\n        type.infer<g, $>,\\n        type.infer<h, $>,\\n        type.infer<i, $>,\\n        type.infer<j, $>,\\n        type.infer<k, $>\\n    ]>, $>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>, d: type.validate<d, $>, e: type.validate<e, $>, f: type.validate<f, $>, g: type.validate<g, $>, h: type.validate<h, $>, i: type.validate<i, $>, j: type.validate<j, $>, k: type.validate<k, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, const i, const j, const k, const l, r = Type<inferNaryIntersection<[\\n        type.infer<a, $>,\\n        type.infer<b, $>,\\n        type.infer<c, $>,\\n        type.infer<d, $>,\\n        type.infer<e, $>,\\n        type.infer<f, $>,\\n        type.infer<g, $>,\\n        type.infer<h, $>,\\n        type.infer<i, $>,\\n        type.infer<j, $>,\\n        type.infer<k, $>,\\n        type.infer<l, $>\\n    ]>, $>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>, d: type.validate<d, $>, e: type.validate<e, $>, f: type.validate<f, $>, g: type.validate<g, $>, h: type.validate<h, $>, i: type.validate<i, $>, j: type.validate<j, $>, k: type.validate<k, $>, l: type.validate<l, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, const i, const j, const k, const l, const m, r = Type<inferNaryIntersection<[\\n        type.infer<a, $>,\\n        type.infer<b, $>,\\n        type.infer<c, $>,\\n        type.infer<d, $>,\\n        type.infer<e, $>,\\n        type.infer<f, $>,\\n        type.infer<g, $>,\\n        type.infer<h, $>,\\n        type.infer<i, $>,\\n        type.infer<j, $>,\\n        type.infer<k, $>,\\n        type.infer<l, $>,\\n        type.infer<m, $>\\n    ]>, $>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>, d: type.validate<d, $>, e: type.validate<e, $>, f: type.validate<f, $>, g: type.validate<g, $>, h: type.validate<h, $>, i: type.validate<i, $>, j: type.validate<j, $>, k: type.validate<k, $>, l: type.validate<l, $>, m: type.validate<m, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, const i, const j, const k, const l, const m, const n, r = Type<inferNaryIntersection<[\\n        type.infer<a, $>,\\n        type.infer<b, $>,\\n        type.infer<c, $>,\\n        type.infer<d, $>,\\n        type.infer<e, $>,\\n        type.infer<f, $>,\\n        type.infer<g, $>,\\n        type.infer<h, $>,\\n        type.infer<i, $>,\\n        type.infer<j, $>,\\n        type.infer<k, $>,\\n        type.infer<l, $>,\\n        type.infer<m, $>,\\n        type.infer<n, $>\\n    ]>, $>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>, d: type.validate<d, $>, e: type.validate<e, $>, f: type.validate<f, $>, g: type.validate<g, $>, h: type.validate<h, $>, i: type.validate<i, $>, j: type.validate<j, $>, k: type.validate<k, $>, l: type.validate<l, $>, m: type.validate<m, $>, n: type.validate<n, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, const i, const j, const k, const l, const m, const n, const o, r = Type<inferNaryIntersection<[\\n        type.infer<a, $>,\\n        type.infer<b, $>,\\n        type.infer<c, $>,\\n        type.infer<d, $>,\\n        type.infer<e, $>,\\n        type.infer<f, $>,\\n        type.infer<g, $>,\\n        type.infer<h, $>,\\n        type.infer<i, $>,\\n        type.infer<j, $>,\\n        type.infer<k, $>,\\n        type.infer<l, $>,\\n        type.infer<m, $>,\\n        type.infer<n, $>,\\n        type.infer<o, $>\\n    ]>, $>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>, d: type.validate<d, $>, e: type.validate<e, $>, f: type.validate<f, $>, g: type.validate<g, $>, h: type.validate<h, $>, i: type.validate<i, $>, j: type.validate<j, $>, k: type.validate<k, $>, l: type.validate<l, $>, m: type.validate<m, $>, n: type.validate<n, $>, o: type.validate<o, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, const i, const j, const k, const l, const m, const n, const o, const p, r = Type<inferNaryIntersection<[\\n        type.infer<a, $>,\\n        type.infer<b, $>,\\n        type.infer<c, $>,\\n        type.infer<d, $>,\\n        type.infer<e, $>,\\n        type.infer<f, $>,\\n        type.infer<g, $>,\\n        type.infer<h, $>,\\n        type.infer<i, $>,\\n        type.infer<j, $>,\\n        type.infer<k, $>,\\n        type.infer<l, $>,\\n        type.infer<m, $>,\\n        type.infer<n, $>,\\n        type.infer<o, $>,\\n        type.infer<p, $>\\n    ]>, $>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>, d: type.validate<d, $>, e: type.validate<e, $>, f: type.validate<f, $>, g: type.validate<g, $>, h: type.validate<h, $>, i: type.validate<i, $>, j: type.validate<j, $>, k: type.validate<k, $>, l: type.validate<l, $>, m: type.validate<m, $>, n: type.validate<n, $>, o: type.validate<o, $>, p: type.validate<p, $>): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, const i, const j, const k, const l, const m, const n, const o, const p, const q, r = Type<inferNaryIntersection<[\\n        type.infer<a, $>,\\n        type.infer<b, $>,\\n        type.infer<c, $>,\\n        type.infer<d, $>,\\n        type.infer<e, $>,\\n        type.infer<f, $>,\\n        type.infer<g, $>,\\n        type.infer<h, $>,\\n        type.infer<i, $>,\\n        type.infer<j, $>,\\n        type.infer<k, $>,\\n        type.infer<l, $>,\\n        type.infer<m, $>,\\n        type.infer<n, $>,\\n        type.infer<o, $>,\\n        type.infer<p, $>,\\n        type.infer<q, $>\\n    ]>, $>>(a: type.validate<a, $>, b: type.validate<b, $>, c: type.validate<c, $>, d: type.validate<d, $>, e: type.validate<e, $>, f: type.validate<f, $>, g: type.validate<g, $>, h: type.validate<h, $>, i: type.validate<i, $>, j: type.validate<j, $>, k: type.validate<k, $>, l: type.validate<l, $>, m: type.validate<m, $>, n: type.validate<n, $>, o: type.validate<o, $>, p: type.validate<p, $>, q: type.validate<q, $>): r extends infer _ ? _ : never;\\n    <const defs extends readonly unknown[], r = Type<inferNaryIntersection<{\\n        [i in keyof defs]: type.infer<defs[i], $>;\\n    }>, $>>(...defs: {\\n        [i in keyof defs]: type.validate<defs[i], $>;\\n    }): r extends infer _ ? _ : never;\\n};\\ntype NaryMergeParser<$> = {\\n    (): Type<object, $>;\\n    <const a, inferredA = type.infer<a, $>, r = Type<inferredA, $>>(a: type.validate<a, $> & (inferredA extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>)): r extends infer _ ? _ : never;\\n    <const a, const b, inferredA = type.infer<a, $>, inferredB = type.infer<b, $>, r = Type<merge<inferredA, inferredB>, $>>(a: type.validate<a, $> & (inferredA extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>), b: type.validate<b, $> & (inferredB extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>)): r extends infer _ ? _ : never;\\n    <const a, const b, const c, inferredA = type.infer<a, $>, inferredB = type.infer<b, $>, inferredC = type.infer<c, $>, r = Type<inferNaryMerge<[inferredA, inferredB, inferredC]>, $>>(a: type.validate<a, $> & (inferredA extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>), b: type.validate<b, $> & (inferredB extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>), c: type.validate<c, $> & (inferredC extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>)): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, inferredA = type.infer<a, $>, inferredB = type.infer<b, $>, inferredC = type.infer<c, $>, inferredD = type.infer<d, $>, r = Type<inferNaryMerge<[inferredA, inferredB, inferredC, inferredD]>, $>>(a: type.validate<a, $> & (inferredA extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>), b: type.validate<b, $> & (inferredB extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>), c: type.validate<c, $> & (inferredC extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>), d: type.validate<d, $> & (inferredD extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredD]>)): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, inferredA = type.infer<a, $>, inferredB = type.infer<b, $>, inferredC = type.infer<c, $>, inferredD = type.infer<d, $>, inferredE = type.infer<e, $>, r = Type<inferNaryMerge<[inferredA, inferredB, inferredC, inferredD, inferredE]>, $>>(a: type.validate<a, $> & (inferredA extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>), b: type.validate<b, $> & (inferredB extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>), c: type.validate<c, $> & (inferredC extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>), d: type.validate<d, $> & (inferredD extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredD]>), e: type.validate<e, $> & (inferredE extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredE]>)): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, inferredA = type.infer<a, $>, inferredB = type.infer<b, $>, inferredC = type.infer<c, $>, inferredD = type.infer<d, $>, inferredE = type.infer<e, $>, inferredF = type.infer<f, $>, r = Type<inferNaryMerge<[\\n        inferredA,\\n        inferredB,\\n        inferredC,\\n        inferredD,\\n        inferredE,\\n        inferredF\\n    ]>, $>>(a: type.validate<a, $> & (inferredA extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>), b: type.validate<b, $> & (inferredB extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>), c: type.validate<c, $> & (inferredC extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>), d: type.validate<d, $> & (inferredD extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredD]>), e: type.validate<e, $> & (inferredE extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredE]>), f: type.validate<f, $> & (inferredF extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredF]>)): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, inferredA = type.infer<a, $>, inferredB = type.infer<b, $>, inferredC = type.infer<c, $>, inferredD = type.infer<d, $>, inferredE = type.infer<e, $>, inferredF = type.infer<f, $>, inferredG = type.infer<g, $>, r = Type<inferNaryMerge<[\\n        inferredA,\\n        inferredB,\\n        inferredC,\\n        inferredD,\\n        inferredE,\\n        inferredF,\\n        inferredG\\n    ]>, $>>(a: type.validate<a, $> & (inferredA extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>), b: type.validate<b, $> & (inferredB extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>), c: type.validate<c, $> & (inferredC extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>), d: type.validate<d, $> & (inferredD extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredD]>), e: type.validate<e, $> & (inferredE extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredE]>), f: type.validate<f, $> & (inferredF extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredF]>), g: type.validate<g, $> & (inferredG extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredG]>)): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, inferredA = type.infer<a, $>, inferredB = type.infer<b, $>, inferredC = type.infer<c, $>, inferredD = type.infer<d, $>, inferredE = type.infer<e, $>, inferredF = type.infer<f, $>, inferredG = type.infer<g, $>, inferredH = type.infer<h, $>, r = Type<inferNaryMerge<[\\n        inferredA,\\n        inferredB,\\n        inferredC,\\n        inferredD,\\n        inferredE,\\n        inferredF,\\n        inferredG,\\n        inferredH\\n    ]>, $>>(a: type.validate<a, $> & (inferredA extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>), b: type.validate<b, $> & (inferredB extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>), c: type.validate<c, $> & (inferredC extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>), d: type.validate<d, $> & (inferredD extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredD]>), e: type.validate<e, $> & (inferredE extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredE]>), f: type.validate<f, $> & (inferredF extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredF]>), g: type.validate<g, $> & (inferredG extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredG]>), h: type.validate<h, $> & (inferredH extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredH]>)): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, const i, inferredA = type.infer<a, $>, inferredB = type.infer<b, $>, inferredC = type.infer<c, $>, inferredD = type.infer<d, $>, inferredE = type.infer<e, $>, inferredF = type.infer<f, $>, inferredG = type.infer<g, $>, inferredH = type.infer<h, $>, inferredI = type.infer<i, $>, r = Type<inferNaryMerge<[\\n        inferredA,\\n        inferredB,\\n        inferredC,\\n        inferredD,\\n        inferredE,\\n        inferredF,\\n        inferredG,\\n        inferredH,\\n        inferredI\\n    ]>, $>>(a: type.validate<a, $> & (inferredA extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>), b: type.validate<b, $> & (inferredB extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>), c: type.validate<c, $> & (inferredC extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>), d: type.validate<d, $> & (inferredD extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredD]>), e: type.validate<e, $> & (inferredE extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredE]>), f: type.validate<f, $> & (inferredF extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredF]>), g: type.validate<g, $> & (inferredG extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredG]>), h: type.validate<h, $> & (inferredH extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredH]>), i: type.validate<i, $> & (inferredI extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredI]>)): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, const i, const j, inferredA = type.infer<a, $>, inferredB = type.infer<b, $>, inferredC = type.infer<c, $>, inferredD = type.infer<d, $>, inferredE = type.infer<e, $>, inferredF = type.infer<f, $>, inferredG = type.infer<g, $>, inferredH = type.infer<h, $>, inferredI = type.infer<i, $>, inferredJ = type.infer<j, $>, r = Type<inferNaryMerge<[\\n        inferredA,\\n        inferredB,\\n        inferredC,\\n        inferredD,\\n        inferredE,\\n        inferredF,\\n        inferredG,\\n        inferredH,\\n        inferredI,\\n        inferredJ\\n    ]>, $>>(a: type.validate<a, $> & (inferredA extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>), b: type.validate<b, $> & (inferredB extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>), c: type.validate<c, $> & (inferredC extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>), d: type.validate<d, $> & (inferredD extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredD]>), e: type.validate<e, $> & (inferredE extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredE]>), f: type.validate<f, $> & (inferredF extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredF]>), g: type.validate<g, $> & (inferredG extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredG]>), h: type.validate<h, $> & (inferredH extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredH]>), i: type.validate<i, $> & (inferredI extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredI]>), j: type.validate<j, $> & (inferredJ extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredJ]>)): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, const i, const j, const k, inferredA = type.infer<a, $>, inferredB = type.infer<b, $>, inferredC = type.infer<c, $>, inferredD = type.infer<d, $>, inferredE = type.infer<e, $>, inferredF = type.infer<f, $>, inferredG = type.infer<g, $>, inferredH = type.infer<h, $>, inferredI = type.infer<i, $>, inferredJ = type.infer<j, $>, inferredK = type.infer<k, $>, r = Type<inferNaryMerge<[\\n        inferredA,\\n        inferredB,\\n        inferredC,\\n        inferredD,\\n        inferredE,\\n        inferredF,\\n        inferredG,\\n        inferredH,\\n        inferredI,\\n        inferredJ,\\n        inferredK\\n    ]>, $>>(a: type.validate<a, $> & (inferredA extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>), b: type.validate<b, $> & (inferredB extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>), c: type.validate<c, $> & (inferredC extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>), d: type.validate<d, $> & (inferredD extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredD]>), e: type.validate<e, $> & (inferredE extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredE]>), f: type.validate<f, $> & (inferredF extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredF]>), g: type.validate<g, $> & (inferredG extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredG]>), h: type.validate<h, $> & (inferredH extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredH]>), i: type.validate<i, $> & (inferredI extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredI]>), j: type.validate<j, $> & (inferredJ extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredJ]>), k: type.validate<k, $> & (inferredK extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredK]>)): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, const i, const j, const k, const l, inferredA = type.infer<a, $>, inferredB = type.infer<b, $>, inferredC = type.infer<c, $>, inferredD = type.infer<d, $>, inferredE = type.infer<e, $>, inferredF = type.infer<f, $>, inferredG = type.infer<g, $>, inferredH = type.infer<h, $>, inferredI = type.infer<i, $>, inferredJ = type.infer<j, $>, inferredK = type.infer<k, $>, inferredL = type.infer<l, $>, r = Type<inferNaryMerge<[\\n        inferredA,\\n        inferredB,\\n        inferredC,\\n        inferredD,\\n        inferredE,\\n        inferredF,\\n        inferredG,\\n        inferredH,\\n        inferredI,\\n        inferredJ,\\n        inferredK,\\n        inferredL\\n    ]>, $>>(a: type.validate<a, $> & (inferredA extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>), b: type.validate<b, $> & (inferredB extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>), c: type.validate<c, $> & (inferredC extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>), d: type.validate<d, $> & (inferredD extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredD]>), e: type.validate<e, $> & (inferredE extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredE]>), f: type.validate<f, $> & (inferredF extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredF]>), g: type.validate<g, $> & (inferredG extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredG]>), h: type.validate<h, $> & (inferredH extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredH]>), i: type.validate<i, $> & (inferredI extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredI]>), j: type.validate<j, $> & (inferredJ extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredJ]>), k: type.validate<k, $> & (inferredK extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredK]>), l: type.validate<l, $> & (inferredL extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredL]>)): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, const i, const j, const k, const l, const m, inferredA = type.infer<a, $>, inferredB = type.infer<b, $>, inferredC = type.infer<c, $>, inferredD = type.infer<d, $>, inferredE = type.infer<e, $>, inferredF = type.infer<f, $>, inferredG = type.infer<g, $>, inferredH = type.infer<h, $>, inferredI = type.infer<i, $>, inferredJ = type.infer<j, $>, inferredK = type.infer<k, $>, inferredL = type.infer<l, $>, inferredM = type.infer<m, $>, r = Type<inferNaryMerge<[\\n        inferredA,\\n        inferredB,\\n        inferredC,\\n        inferredD,\\n        inferredE,\\n        inferredF,\\n        inferredG,\\n        inferredH,\\n        inferredI,\\n        inferredJ,\\n        inferredK,\\n        inferredL,\\n        inferredM\\n    ]>, $>>(a: type.validate<a, $> & (inferredA extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>), b: type.validate<b, $> & (inferredB extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>), c: type.validate<c, $> & (inferredC extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>), d: type.validate<d, $> & (inferredD extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredD]>), e: type.validate<e, $> & (inferredE extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredE]>), f: type.validate<f, $> & (inferredF extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredF]>), g: type.validate<g, $> & (inferredG extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredG]>), h: type.validate<h, $> & (inferredH extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredH]>), i: type.validate<i, $> & (inferredI extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredI]>), j: type.validate<j, $> & (inferredJ extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredJ]>), k: type.validate<k, $> & (inferredK extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredK]>), l: type.validate<l, $> & (inferredL extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredL]>), m: type.validate<m, $> & (inferredM extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredM]>)): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, const i, const j, const k, const l, const m, const n, inferredA = type.infer<a, $>, inferredB = type.infer<b, $>, inferredC = type.infer<c, $>, inferredD = type.infer<d, $>, inferredE = type.infer<e, $>, inferredF = type.infer<f, $>, inferredG = type.infer<g, $>, inferredH = type.infer<h, $>, inferredI = type.infer<i, $>, inferredJ = type.infer<j, $>, inferredK = type.infer<k, $>, inferredL = type.infer<l, $>, inferredM = type.infer<m, $>, inferredN = type.infer<n, $>, r = Type<inferNaryMerge<[\\n        inferredA,\\n        inferredB,\\n        inferredC,\\n        inferredD,\\n        inferredE,\\n        inferredF,\\n        inferredG,\\n        inferredH,\\n        inferredI,\\n        inferredJ,\\n        inferredK,\\n        inferredL,\\n        inferredM,\\n        inferredN\\n    ]>, $>>(a: type.validate<a, $> & (inferredA extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>), b: type.validate<b, $> & (inferredB extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>), c: type.validate<c, $> & (inferredC extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>), d: type.validate<d, $> & (inferredD extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredD]>), e: type.validate<e, $> & (inferredE extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredE]>), f: type.validate<f, $> & (inferredF extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredF]>), g: type.validate<g, $> & (inferredG extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredG]>), h: type.validate<h, $> & (inferredH extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredH]>), i: type.validate<i, $> & (inferredI extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredI]>), j: type.validate<j, $> & (inferredJ extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredJ]>), k: type.validate<k, $> & (inferredK extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredK]>), l: type.validate<l, $> & (inferredL extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredL]>), m: type.validate<m, $> & (inferredM extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredM]>), n: type.validate<n, $> & (inferredN extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredN]>)): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, const i, const j, const k, const l, const m, const n, const o, inferredA = type.infer<a, $>, inferredB = type.infer<b, $>, inferredC = type.infer<c, $>, inferredD = type.infer<d, $>, inferredE = type.infer<e, $>, inferredF = type.infer<f, $>, inferredG = type.infer<g, $>, inferredH = type.infer<h, $>, inferredI = type.infer<i, $>, inferredJ = type.infer<j, $>, inferredK = type.infer<k, $>, inferredL = type.infer<l, $>, inferredM = type.infer<m, $>, inferredN = type.infer<n, $>, inferredO = type.infer<o, $>, r = Type<inferNaryMerge<[\\n        inferredA,\\n        inferredB,\\n        inferredC,\\n        inferredD,\\n        inferredE,\\n        inferredF,\\n        inferredG,\\n        inferredH,\\n        inferredI,\\n        inferredJ,\\n        inferredK,\\n        inferredL,\\n        inferredM,\\n        inferredN,\\n        inferredO\\n    ]>, $>>(a: type.validate<a, $> & (inferredA extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>), b: type.validate<b, $> & (inferredB extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>), c: type.validate<c, $> & (inferredC extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>), d: type.validate<d, $> & (inferredD extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredD]>), e: type.validate<e, $> & (inferredE extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredE]>), f: type.validate<f, $> & (inferredF extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredF]>), g: type.validate<g, $> & (inferredG extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredG]>), h: type.validate<h, $> & (inferredH extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredH]>), i: type.validate<i, $> & (inferredI extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredI]>), j: type.validate<j, $> & (inferredJ extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredJ]>), k: type.validate<k, $> & (inferredK extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredK]>), l: type.validate<l, $> & (inferredL extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredL]>), m: type.validate<m, $> & (inferredM extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredM]>), n: type.validate<n, $> & (inferredN extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredN]>), o: type.validate<o, $> & (inferredO extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredO]>)): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, const i, const j, const k, const l, const m, const n, const o, const p, inferredA = type.infer<a, $>, inferredB = type.infer<b, $>, inferredC = type.infer<c, $>, inferredD = type.infer<d, $>, inferredE = type.infer<e, $>, inferredF = type.infer<f, $>, inferredG = type.infer<g, $>, inferredH = type.infer<h, $>, inferredI = type.infer<i, $>, inferredJ = type.infer<j, $>, inferredK = type.infer<k, $>, inferredL = type.infer<l, $>, inferredM = type.infer<m, $>, inferredN = type.infer<n, $>, inferredO = type.infer<o, $>, inferredP = type.infer<p, $>, r = Type<inferNaryMerge<[\\n        inferredA,\\n        inferredB,\\n        inferredC,\\n        inferredD,\\n        inferredE,\\n        inferredF,\\n        inferredG,\\n        inferredH,\\n        inferredI,\\n        inferredJ,\\n        inferredK,\\n        inferredL,\\n        inferredM,\\n        inferredN,\\n        inferredO,\\n        inferredP\\n    ]>, $>>(a: type.validate<a, $> & (inferredA extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>), b: type.validate<b, $> & (inferredB extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>), c: type.validate<c, $> & (inferredC extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>), d: type.validate<d, $> & (inferredD extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredD]>), e: type.validate<e, $> & (inferredE extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredE]>), f: type.validate<f, $> & (inferredF extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredF]>), g: type.validate<g, $> & (inferredG extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredG]>), h: type.validate<h, $> & (inferredH extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredH]>), i: type.validate<i, $> & (inferredI extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredI]>), j: type.validate<j, $> & (inferredJ extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredJ]>), k: type.validate<k, $> & (inferredK extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredK]>), l: type.validate<l, $> & (inferredL extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredL]>), m: type.validate<m, $> & (inferredM extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredM]>), n: type.validate<n, $> & (inferredN extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredN]>), o: type.validate<o, $> & (inferredO extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredO]>), p: type.validate<p, $> & (inferredP extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredP]>)): r extends infer _ ? _ : never;\\n    <const a, const b, const c, const d, const e, const f, const g, const h, const i, const j, const k, const l, const m, const n, const o, const p, const q, inferredA = type.infer<a, $>, inferredB = type.infer<b, $>, inferredC = type.infer<c, $>, inferredD = type.infer<d, $>, inferredE = type.infer<e, $>, inferredF = type.infer<f, $>, inferredG = type.infer<g, $>, inferredH = type.infer<h, $>, inferredI = type.infer<i, $>, inferredJ = type.infer<j, $>, inferredK = type.infer<k, $>, inferredL = type.infer<l, $>, inferredM = type.infer<m, $>, inferredN = type.infer<n, $>, inferredO = type.infer<o, $>, inferredP = type.infer<p, $>, inferredQ = type.infer<q, $>, r = Type<inferNaryMerge<[\\n        inferredA,\\n        inferredB,\\n        inferredC,\\n        inferredD,\\n        inferredE,\\n        inferredF,\\n        inferredG,\\n        inferredH,\\n        inferredI,\\n        inferredJ,\\n        inferredK,\\n        inferredL,\\n        inferredM,\\n        inferredN,\\n        inferredO,\\n        inferredP,\\n        inferredQ\\n    ]>, $>>(a: type.validate<a, $> & (inferredA extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>), b: type.validate<b, $> & (inferredB extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>), c: type.validate<c, $> & (inferredC extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>), d: type.validate<d, $> & (inferredD extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredD]>), e: type.validate<e, $> & (inferredE extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredE]>), f: type.validate<f, $> & (inferredF extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredF]>), g: type.validate<g, $> & (inferredG extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredG]>), h: type.validate<h, $> & (inferredH extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredH]>), i: type.validate<i, $> & (inferredI extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredI]>), j: type.validate<j, $> & (inferredJ extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredJ]>), k: type.validate<k, $> & (inferredK extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredK]>), l: type.validate<l, $> & (inferredL extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredL]>), m: type.validate<m, $> & (inferredM extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredM]>), n: type.validate<n, $> & (inferredN extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredN]>), o: type.validate<o, $> & (inferredO extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredO]>), p: type.validate<p, $> & (inferredP extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredP]>), q: type.validate<q, $> & (inferredQ extends object ? unknown : ErrorType<[NonObjectMergeErrorMessage, actual: inferredQ]>)): r extends infer _ ? _ : never;\\n    <const defs extends readonly unknown[], r = Type<inferNaryMerge<{\\n        [i in keyof defs]: type.infer<defs[i], $>;\\n    }>, $>>(...defs: {\\n        [i in keyof defs]: type.validate<defs[i], $> & (type.infer<defs[i], $> extends object ? unknown : ErrorType<[\\n            NonObjectMergeErrorMessage,\\n            actual: type.infer<defs[i], $>\\n        ]>);\\n    }): r extends infer _ ? _ : never;\\n};\\ntype NaryPipeParser<$, initial = unknown> = {\\n    (): Type<initial, $>;\\n    <a extends Morph<distill.Out<initial>>, r = instantiateType<inferMorph<initial, a>, $>>(a: a): r extends infer _ ? _ : never;\\n    <a extends Morph<distill.Out<initial>>, b extends Morph<inferMorphOut<a>>, r = instantiateType<inferNaryPipe<[Type<initial>, a, b]>, $>>(a: a, b: b): r extends infer _ ? _ : never;\\n    <a extends Morph<distill.Out<initial>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, r = instantiateType<inferNaryPipe<[Type<initial>, a, b, c]>, $>>(a: a, b: b, c: c): r extends infer _ ? _ : never;\\n    <a extends Morph<distill.Out<initial>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, r = instantiateType<inferNaryPipe<[Type<initial>, a, b, c, d]>, $>>(a: a, b: b, c: c, d: d): r extends infer _ ? _ : never;\\n    <a extends Morph<distill.Out<initial>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, r = instantiateType<inferNaryPipe<[Type<initial>, a, b, c, d, e]>, $>>(a: a, b: b, c: c, d: d, e: e): r extends infer _ ? _ : never;\\n    <a extends Morph<distill.Out<initial>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, f extends Morph<inferMorphOut<e>>, r = instantiateType<inferNaryPipe<[Type<initial>, a, b, c, d, e, f]>, $>>(a: a, b: b, c: c, d: d, e: e, f: f): r extends infer _ ? _ : never;\\n    <a extends Morph<distill.Out<initial>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, f extends Morph<inferMorphOut<e>>, g extends Morph<inferMorphOut<f>>, r = instantiateType<inferNaryPipe<[Type<initial>, a, b, c, d, e, f, g]>, $>>(a: a, b: b, c: c, d: d, e: e, f: f, g: g): r extends infer _ ? _ : never;\\n    <a extends Morph<distill.Out<initial>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, f extends Morph<inferMorphOut<e>>, g extends Morph<inferMorphOut<f>>, h extends Morph<inferMorphOut<g>>, r = instantiateType<inferNaryPipe<[Type<initial>, a, b, c, d, e, f, g, h]>, $>>(a: a, b: b, c: c, d: d, e: e, f: f, g: g, h: h): r extends infer _ ? _ : never;\\n    <a extends Morph<distill.Out<initial>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, f extends Morph<inferMorphOut<e>>, g extends Morph<inferMorphOut<f>>, h extends Morph<inferMorphOut<g>>, i extends Morph<inferMorphOut<h>>, r = instantiateType<inferNaryPipe<[Type<initial>, a, b, c, d, e, f, g, h, i]>, $>>(a: a, b: b, c: c, d: d, e: e, f: f, g: g, h: h, i: i): r extends infer _ ? _ : never;\\n    <a extends Morph<distill.Out<initial>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, f extends Morph<inferMorphOut<e>>, g extends Morph<inferMorphOut<f>>, h extends Morph<inferMorphOut<g>>, i extends Morph<inferMorphOut<h>>, j extends Morph<inferMorphOut<i>>, r = instantiateType<inferNaryPipe<[Type<initial>, a, b, c, d, e, f, g, h, i, j]>, $>>(a: a, b: b, c: c, d: d, e: e, f: f, g: g, h: h, i: i, j: j): r extends infer _ ? _ : never;\\n    <a extends Morph<distill.Out<initial>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, f extends Morph<inferMorphOut<e>>, g extends Morph<inferMorphOut<f>>, h extends Morph<inferMorphOut<g>>, i extends Morph<inferMorphOut<h>>, j extends Morph<inferMorphOut<i>>, k extends Morph<inferMorphOut<j>>, r = instantiateType<inferNaryPipe<[Type<initial>, a, b, c, d, e, f, g, h, i, j, k]>, $>>(a: a, b: b, c: c, d: d, e: e, f: f, g: g, h: h, i: i, j: j, k: k): r extends infer _ ? _ : never;\\n    <a extends Morph<distill.Out<initial>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, f extends Morph<inferMorphOut<e>>, g extends Morph<inferMorphOut<f>>, h extends Morph<inferMorphOut<g>>, i extends Morph<inferMorphOut<h>>, j extends Morph<inferMorphOut<i>>, k extends Morph<inferMorphOut<j>>, l extends Morph<inferMorphOut<k>>, r = instantiateType<inferNaryPipe<[Type<initial>, a, b, c, d, e, f, g, h, i, j, k, l]>, $>>(a: a, b: b, c: c, d: d, e: e, f: f, g: g, h: h, i: i, j: j, k: k, l: l): r extends infer _ ? _ : never;\\n    <a extends Morph<distill.Out<initial>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, f extends Morph<inferMorphOut<e>>, g extends Morph<inferMorphOut<f>>, h extends Morph<inferMorphOut<g>>, i extends Morph<inferMorphOut<h>>, j extends Morph<inferMorphOut<i>>, k extends Morph<inferMorphOut<j>>, l extends Morph<inferMorphOut<k>>, m extends Morph<inferMorphOut<l>>, r = instantiateType<inferNaryPipe<[Type<initial>, a, b, c, d, e, f, g, h, i, j, k, l, m]>, $>>(a: a, b: b, c: c, d: d, e: e, f: f, g: g, h: h, i: i, j: j, k: k, l: l, m: m): r extends infer _ ? _ : never;\\n    <a extends Morph<distill.Out<initial>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, f extends Morph<inferMorphOut<e>>, g extends Morph<inferMorphOut<f>>, h extends Morph<inferMorphOut<g>>, i extends Morph<inferMorphOut<h>>, j extends Morph<inferMorphOut<i>>, k extends Morph<inferMorphOut<j>>, l extends Morph<inferMorphOut<k>>, m extends Morph<inferMorphOut<l>>, n extends Morph<inferMorphOut<m>>, r = instantiateType<inferNaryPipe<[Type<initial>, a, b, c, d, e, f, g, h, i, j, k, l, m, n]>, $>>(a: a, b: b, c: c, d: d, e: e, f: f, g: g, h: h, i: i, j: j, k: k, l: l, m: m, n: n): r extends infer _ ? _ : never;\\n    <a extends Morph<distill.Out<initial>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, f extends Morph<inferMorphOut<e>>, g extends Morph<inferMorphOut<f>>, h extends Morph<inferMorphOut<g>>, i extends Morph<inferMorphOut<h>>, j extends Morph<inferMorphOut<i>>, k extends Morph<inferMorphOut<j>>, l extends Morph<inferMorphOut<k>>, m extends Morph<inferMorphOut<l>>, n extends Morph<inferMorphOut<m>>, o extends Morph<inferMorphOut<n>>, r = instantiateType<inferNaryPipe<[\\n        Type<initial>,\\n        a,\\n        b,\\n        c,\\n        d,\\n        e,\\n        f,\\n        g,\\n        h,\\n        i,\\n        j,\\n        k,\\n        l,\\n        m,\\n        n,\\n        o\\n    ]>, $>>(a: a, b: b, c: c, d: d, e: e, f: f, g: g, h: h, i: i, j: j, k: k, l: l, m: m, n: n, o: o): r extends infer _ ? _ : never;\\n    <a extends Morph<distill.Out<initial>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, f extends Morph<inferMorphOut<e>>, g extends Morph<inferMorphOut<f>>, h extends Morph<inferMorphOut<g>>, i extends Morph<inferMorphOut<h>>, j extends Morph<inferMorphOut<i>>, k extends Morph<inferMorphOut<j>>, l extends Morph<inferMorphOut<k>>, m extends Morph<inferMorphOut<l>>, n extends Morph<inferMorphOut<m>>, o extends Morph<inferMorphOut<n>>, p extends Morph<inferMorphOut<o>>, r = instantiateType<inferNaryPipe<[\\n        Type<initial>,\\n        a,\\n        b,\\n        c,\\n        d,\\n        e,\\n        f,\\n        g,\\n        h,\\n        i,\\n        j,\\n        k,\\n        l,\\n        m,\\n        n,\\n        o,\\n        p\\n    ]>, $>>(a: a, b: b, c: c, d: d, e: e, f: f, g: g, h: h, i: i, j: j, k: k, l: l, m: m, n: n, o: o, p: p): r extends infer _ ? _ : never;\\n    <a extends Morph<distill.Out<initial>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, f extends Morph<inferMorphOut<e>>, g extends Morph<inferMorphOut<f>>, h extends Morph<inferMorphOut<g>>, i extends Morph<inferMorphOut<h>>, j extends Morph<inferMorphOut<i>>, k extends Morph<inferMorphOut<j>>, l extends Morph<inferMorphOut<k>>, m extends Morph<inferMorphOut<l>>, n extends Morph<inferMorphOut<m>>, o extends Morph<inferMorphOut<n>>, p extends Morph<inferMorphOut<o>>, q extends Morph<inferMorphOut<p>>, r = instantiateType<inferNaryPipe<[\\n        Type<initial>,\\n        a,\\n        b,\\n        c,\\n        d,\\n        e,\\n        f,\\n        g,\\n        h,\\n        i,\\n        j,\\n        k,\\n        l,\\n        m,\\n        n,\\n        o,\\n        p,\\n        q\\n    ]>, $>>(a: a, b: b, c: c, d: d, e: e, f: f, g: g, h: h, i: i, j: j, k: k, l: l, m: m, n: n, o: o, p: p, q: q): r extends infer _ ? _ : never;\\n    <const morphs extends readonly Morph[], r = Type<inferNaryPipe<morphs>, $>>(...defs: morphs): r extends infer _ ? _ : never;\\n};\\n\\n/** @ts-ignore cast variance */\\ninterface Inferred<out t = unknown, $ = {}> {\\n    internal: BaseRoot;\\n    [inferred]: t;\\n    /**\\n     * precompiled JS used to optimize validation\\n     *\\n     * ⚠️ will be `undefined` in [jitless](https://arktype.io/docs/configuration#jitless) mode\\n     */\\n    precompilation: string | undefined;\\n    /**\\n     * generic parameter representing this Type\\n     *\\n     * @typeonly\\n     *\\n     * ⚠️ May contain types representing morphs or default values that would\\n     * be inaccurate if used directly for runtime values. In those cases,\\n     * you should use {@link infer} or {@link inferIn} on this object instead.\\n     */\\n    t: t;\\n    /**\\n     * #### {@link Scope} in which chained methods are parsed\\n     */\\n    $: Scope<$>;\\n    /**\\n     * #### type of output this returns\\n     *\\n     * @typeonly\\n     *\\n     * @example\\n     * const parseNumber = type(\\\"string\\\").pipe(s => Number.parseInt(s))\\n     * type ParsedNumber = typeof parseNumber.infer // number\\n     */\\n    infer: this[\\\"inferOut\\\"];\\n    /**\\n     * type of output this returns\\n     *\\n     * 🔗 alias of {@link infer}\\n     * @typeonly\\n     *\\n     *\\n     * @example\\n     * const parseNumber = type(\\\"string\\\").pipe(s => Number.parseInt(s))\\n     * type ParsedNumber = typeof parseNumber.infer // number\\n     */\\n    inferOut: distill.Out<t>;\\n    /**\\n     * type of output that can be introspected at runtime (e.g. via {@link out})\\n     *\\n     * ⚠️ If your Type contains morphs, they will be inferred as `unknown` unless\\n     * they are an ArkType keyword or have an explicitly defined output validator.\\n     *\\n     * @typeonly\\n     *\\n     * @example\\n     * const Unmorphed = type(\\\"string\\\")\\n     * // with no morphs, we can introspect the input and output as a single Type\\n     * type UnmorphedOut = typeof Unmorphed.inferIntrospectableOut // string\\n     *\\n     * const Morphed = type(\\\"string\\\").pipe(s => s.length)\\n     * // with a standard user-defined morph, TypeScript can infer a\\n     * // return type from your function, but we have no way to\\n     * // know the shape at runtime\\n     * type MorphOut = typeof Morphed.inferIntrospectableOut  // unknown\\n     *\\n     * const Validated = type(\\\"string\\\").pipe(s => s.length).to(\\\"number\\\")\\n     * // morphs with validated output, including all morph keywords, are introspectable\\n     * type ValidatedMorphOut = typeof Validated.inferIntrospectableOut\\n     */\\n    inferIntrospectableOut: distill.introspectable.Out<t>;\\n    /**\\n     * #### type of input this allows\\n     *\\n     * @typeonly\\n     *\\n     * @example\\n     * const parseNumber = type(\\\"string\\\").pipe(s => Number.parseInt(s))\\n     * type UnparsedNumber = typeof parseNumber.inferIn // string\\n     */\\n    inferIn: distill.In<t>;\\n    /**\\n     * #### internal JSON representation\\n     */\\n    json: JsonStructure;\\n    /**\\n     * alias of {@link json} for `JSON.stringify` compatibility\\n     */\\n    toJSON(): JsonStructure;\\n    /**\\n     * #### generate a JSON Schema\\n     *\\n     * @throws {ToJsonSchema.Error} if this cannot be converted to JSON Schema\\n     */\\n    toJsonSchema(options?: ToJsonSchema.Options): JsonSchema;\\n    /**\\n     * #### metadata like custom descriptions and error messages\\n     *\\n     * ✅ type {@link https://arktype.io/docs/configuration#custom | can be customized} for your project\\n     */\\n    meta: ArkAmbient.meta;\\n    /**\\n     * #### human-readable English description\\n     *\\n     * ✅ works best for primitive values\\n     *\\n     * @example\\n     * const N = type(\\\"0 < number <= 100\\\")\\n     * console.log(N.description) // positive and at most 100\\n     */\\n    description: string;\\n    /**\\n     * #### syntax string similar to native TypeScript\\n     *\\n     * ✅ works well for both primitives and structures\\n     *\\n     * @example\\n     * const Loc = type({ coords: [\\\"number\\\", \\\"number\\\"] })\\n     * console.log(Loc.expression) // { coords: [number, number] }\\n     */\\n    expression: string;\\n    /**\\n     * #### validate and return transformed data or throw\\n     *\\n     * ✅ sugar to avoid checking for {@link type.errors} if they are unrecoverable\\n     *\\n     * @example\\n     * const CriticalPayload = type({\\n     *     superImportantValue: \\\"string\\\"\\n     * })\\n     * // throws TraversalError: superImportantValue must be a string (was missing)\\n     * const data = CriticalPayload.assert({ irrelevantValue: \\\"whoops\\\" })\\n     * console.log(data.superImportantValue) // valid output can be accessed directly\\n     *\\n     * @throws {TraversalError}\\n     */\\n    assert: (data: unknown) => this[\\\"infer\\\"];\\n    /**\\n     * #### check input without applying morphs\\n     *\\n     * ✅ good for stuff like filtering that doesn't benefit from detailed errors\\n     *\\n     * @example\\n     * const Numeric = type(\\\"number | bigint\\\")\\n     * // [0, 2n]\\n     * const numerics = [0, \\\"one\\\", 2n].filter(Numeric.allows)\\n     */\\n    allows: (data: unknown) => data is this[\\\"inferIn\\\"];\\n    /**\\n     * #### add metadata to shallow references\\n     *\\n     * ⚠️ does not affect error messages within properties of an object\\n     *\\n     * @example\\n     * const NotOdd = type(\\\"number % 2\\\").configure({ description: \\\"not odd\\\" })\\n     * // all constraints at the root are affected\\n     * const odd = NotOdd(3) // must be not odd (was 3)\\n     * const nonNumber = NotOdd(\\\"two\\\") // must be not odd (was \\\"two\\\")\\n     *\\n     * const NotOddBox = type({\\n     *    // we should have referenced notOdd or added meta here\\n     *    notOdd: \\\"number % 2\\\",\\n     * // but instead chained from the root object\\n     * }).configure({ description: \\\"not odd\\\" })\\n     * // error message at path notOdd is not affected\\n     * const oddProp = NotOddBox({ notOdd: 3 }) // notOdd must be even (was 3)\\n     * // error message at root is affected, leading to a misleading description\\n     * const nonObject = NotOddBox(null) // must be not odd (was null)\\n     */\\n    configure: NodeSelector.SelectableFn<TypeMeta.MappableInput, this>;\\n    /**\\n     * #### add description to shallow references\\n     *\\n     * 🔗 equivalent to `.configure({ description })` (see {@link configure})\\n     * ⚠️ does not affect error messages within properties of an object\\n     *\\n     * @example\\n     * const AToZ = type(/^a.*z$/).describe(\\\"a string like 'a...z'\\\")\\n     * const good = AToZ(\\\"alcatraz\\\") // \\\"alcatraz\\\"\\n     * // ArkErrors: must be a string like 'a...z' (was \\\"albatross\\\")\\n     * const badPattern = AToZ(\\\"albatross\\\")\\n     */\\n    describe: NodeSelector.SelectableFn<string, this>;\\n    /**\\n     * #### apply undeclared key behavior\\n     *\\n     * {@inheritDoc UndeclaredKeyBehavior}\\n     */\\n    onUndeclaredKey(behavior: UndeclaredKeyBehavior): this;\\n    /**\\n     * #### deeply apply undeclared key behavior\\n     *\\n     * {@inheritDoc UndeclaredKeyBehavior}\\n     **/\\n    onDeepUndeclaredKey(behavior: UndeclaredKeyBehavior): this;\\n    /**\\n     * #### alias for {@link assert} with typed input\\n     *\\n     * @example\\n     * const T = type({ foo: \\\"string\\\" });\\n     * // TypeScript: foo must be a string (was 5)\\n     * const data = T.from({ foo: 5 });\\n     */\\n    from(literal: this[\\\"inferIn\\\"]): this[\\\"infer\\\"];\\n    /**\\n     * #### deeply extract inputs\\n     *\\n     * ✅ will never include morphs\\n     * ✅ good for generating JSON Schema or other non-transforming formats\\n     *\\n     * @example\\n     * const User = type({\\n     *    age: \\\"string.numeric.parse\\\"\\n     * })\\n     * // { age: 25 } (age parsed to a number)\\n     * const out = User({ age: \\\"25\\\" })\\n     * // { age: \\\"25\\\" } (age is still a string)\\n     * const inOut = User.in({ age: \\\"25\\\" })\\n     */\\n    get in(): instantiateType<this[\\\"inferIn\\\"], $>;\\n    /**\\n     * #### deeply extract outputs\\n     *\\n     * ✅ will never include morphs\\n     * ⚠️ if your type includes morphs, their output will likely be unknown unless they\\n     * were defined with an explicit output validator via `.to(outputDef)` or `.pipe(morph, outputType)`\\n     *\\n     * @example\\n     * const join = type(\\\"string[]\\\").pipe(a => a.join(\\\",\\\"))\\n     *\\n     * const T = type({\\n     *    // all keywords have introspectable output\\n     *    keyword: \\\"string.numeric.parse\\\",\\n     *    // TypeScript knows this returns a string, but we can't introspect that at runtime\\n     *    unvalidated: join,\\n     *    // if needed, it can be made introspectable with an output validator\\n     *    validated: join.to(\\\"string\\\")\\n     * })\\n     *\\n     * // Type<{ keyword: number; unvalidated: unknown; validated: string }>\\n     * const baseOut = base.out\\n     */\\n    get out(): instantiateType<this[\\\"inferIntrospectableOut\\\"], $>;\\n    /**\\n     * #### add a compile-time brand to output\\n     *\\n     * @typenoop\\n     *\\n     * @example\\n     * const Palindrome = type(\\\"string\\\")\\n     *     .narrow(s => s === [...s].reverse().join(\\\"\\\"))\\n     *     .brand(\\\"palindrome\\\")\\n     * // Brand<string, \\\"palindrome\\\">\\n     * const out = Palindrome.assert(\\\"racecar\\\")\\n     */\\n    brand<const name extends string, r = instantiateType<type.brand<t, name>, $>>(name: name): r extends infer _ ? _ : never;\\n    /**\\n     * #### an array of this\\n     *\\n     * @example\\n     * // Type<{ rebmun: number }[]>\\n     * const T = type({ rebmun: \\\"number\\\" }).array();\\n     */\\n    array(): Type$5<t[], $>;\\n    /**\\n     * #### {@link https://arktype.io/docs/objects#properties-optional | optional definition}\\n     *\\n     * @chainedDefinition\\n     *\\n     * @example\\n     * const Prop = type({ foo: \\\"number\\\" })\\n     * // Type<{ bar?: { foo: number } }>\\n     * const Obj = type({ bar: Prop.optional() })\\n     */\\n    optional(): [this, \\\"?\\\"];\\n    /**\\n     * #### {@link https://arktype.io/docs/objects#properties-defaultable | defaultable definition}\\n     *\\n     * ✅ object defaults can be returned from a function\\n     * ⚠️ throws if the default value is not allowed\\n     * @chainedDefinition\\n     *\\n     * @example\\n     * // Type<{ count: Default<number, 0> }>\\n     * const State = type({ count: type.number.default(0) })\\n     * const Prop = type({ nested: \\\"boolean\\\" })\\n     * const ForObj = type({\\n     *     key: Prop.default(() => ({ nested: false }))\\n     * })\\n     */\\n    default<const value extends defaultFor<this[\\\"inferIn\\\"]>>(value: value): [this, \\\"=\\\", value];\\n    /**\\n     * #### apply a predicate function to input\\n     *\\n     * ⚠️ the behavior of {@link narrow}, this method's output counterpart, is usually more desirable\\n     * ✅ most useful for morphs with input types that are re-used externally\\n     * @predicateCast\\n     *\\n     * @example\\n     * const stringifyUser = type({ name: \\\"string\\\" }).pipe(user => JSON.stringify(user))\\n     * const stringifySafe = stringifyUser.filter(user => user.name !== \\\"Bobby Tables\\\")\\n     * // Type<(In: `${string}Z`) => To<Date>>\\n     * const WithPredicate = type(\\\"string.date.parse\\\").filter((s): s is `${string}Z` =>\\n     *     s.endsWith(\\\"Z\\\")\\n     * )\\n     */\\n    filter<narrowed extends this[\\\"inferIn\\\"] = never, r = instantiateType<[\\n        narrowed\\n    ] extends [never] ? t : t extends InferredMorph<never, infer o> ? (In: narrowed) => o : narrowed, $>>(predicate: Predicate.Castable<this[\\\"inferIn\\\"], narrowed>): r extends infer _ ? _ : never;\\n    /**\\n     * #### apply a predicate function to output\\n     *\\n     * ✅ go-to fallback for validation not composable via built-in types and operators\\n     * ✅ runs after all other validators and morphs, if present\\n     * @predicateCast\\n     *\\n     * @example\\n     * const Palindrome = type(\\\"string\\\").narrow(s => s === [...s].reverse().join(\\\"\\\"))\\n     *\\n     * const PalindromicEmail = type(\\\"string.date.parse\\\").narrow((date, ctx) =>\\n     *\\t\\tdate.getFullYear() === 2025 || ctx.mustBe(\\\"the current year\\\")\\n     * )\\n     * // Type<`${string}.tsx`>\\n     * const WithPredicate = type(\\\"string\\\").narrow((s): s is `${string}.tsx` => /\\\\.tsx?$/.test(s))\\n     */\\n    narrow<narrowed extends this[\\\"infer\\\"] = never, r = instantiateType<[\\n        narrowed\\n    ] extends [never] ? t : t extends InferredMorph<infer i, infer o> ? o extends To ? (In: i) => To<narrowed> : (In: i) => Out<narrowed> : narrowed, $>>(predicate: Predicate.Castable<this[\\\"infer\\\"], narrowed>): r extends infer _ ? _ : never;\\n    /**\\n     * #### pipe output through arbitrary transformations or other Types\\n     *\\n     * @example\\n     * const User = type({ name: \\\"string\\\" })\\n     *\\n     * // parse a string and validate that the result as a user\\n     * const parseUser = type(\\\"string\\\").pipe(s => JSON.parse(s), user)\\n     */\\n    pipe: ChainedPipeParser<$, t>;\\n    /**\\n     * #### parse a definition as an output validator\\n     *\\n     * 🔗 `to({ name: \\\"string\\\" })` is equivalent to `.pipe(type({ name: \\\"string\\\" }))`\\n     *\\n     * @example\\n     * // parse a string and validate that the result as a user\\n     * const parseUser = type(\\\"string\\\").pipe(s => JSON.parse(s)).to({ name: \\\"string\\\" })\\n     */\\n    to<const def, r = instantiateType<inferPipe<t, type.infer<def, $>>, $>>(def: type.validate<def, $>): r extends infer _ ? _ : never;\\n    /**\\n     * #### query internal node references\\n     *\\n     * @experimental filters and returns the Type's internal representation from `@ark/schema`\\n     *\\n     * @example\\n     * // [\\\"blue\\\", \\\"red\\\"]\\n     * const values = type(\\\"'red' | 'blue'\\\").select(\\\"unit\\\").map(u => u.unit)\\n     */\\n    select: BaseNode[\\\"select\\\"];\\n}\\n/** @ts-ignore cast variance */\\ninterface Type$1<out t = unknown, $ = {}> extends Callable<(data: unknown) => distill.Out<t> | ArkEnv.onFail>, Inferred<t, $> {\\n    /**\\n     * #### cast the way this is inferred\\n     *\\n     * @typenoop\\n     *\\n     * @example\\n     * // Type<`LEEEEEEEE${string}ROY`>\\n     * const Leeroy = type(/^LE{8,}ROY$/).as<`LEEEEEEEE${string}ROY`>()\\n     */\\n    as<castTo = unset>(...args: validateChainedAsArgs<castTo>): instantiateType<castTo, $>;\\n    /**\\n     * #### intersect the parsed Type, throwing if the result is unsatisfiable\\n     *\\n     * @example\\n     * // Type<{ foo: number; bar: string }>\\n     * const T = type({ foo: \\\"number\\\" }).and({ bar: \\\"string\\\" })\\n     * // ParseError: Intersection at foo of number and string results in an unsatisfiable type\\n     * const Bad = type({ foo: \\\"number\\\" }).and({ foo: \\\"string\\\" })\\n     */\\n    and<const def, r = instantiateType<inferIntersection<t, type.infer<def, $>>, $>>(def: type.validate<def, $>): r extends infer _ ? _ : never;\\n    /**\\n     * #### union with the parsed Type\\n     *\\n     * ⚠️ a union that could apply different morphs to the same data is a ParseError ({@link https://arktype.io/docs/expressions#union-morphs | docs})\\n     *\\n     * @example\\n     * // Type<string | { box: string }>\\n     * const T = type(\\\"string\\\").or({ box: \\\"string\\\" })\\n     */\\n    or<const def, r = instantiateType<t | type.infer<def, $>, $>>(def: type.validate<def, $>): r extends infer _ ? _ : never;\\n    /**\\n     * #### intersect the parsed Type, returning an introspectable {@link Disjoint} if the result is unsatisfiable\\n     *\\n     * @example\\n     * // Type<{ foo: number; bar: string }>\\n     * const T = type({ foo: \\\"number\\\" }).intersect({ bar: \\\"string\\\" })\\n     * const Bad = type(\\\"number > 10\\\").intersect(\\\"number < 5\\\")\\n     * // logs \\\"Intersection of > 10 and < 5 results in an unsatisfiable type\\\"\\n     * if (Bad instanceof Disjoint) console.log(`${bad.summary}`)\\n     */\\n    intersect<const def, r = instantiateType<inferIntersection<t, type.infer<def, $>>, $>>(def: type.validate<def, $>): r extends infer _ ? _ | Disjoint : never;\\n    /**\\n     * #### check if the parsed Type's constraints are identical\\n     *\\n     * ✅ equal types have identical input and output constraints and transforms\\n     * @ignoresMeta\\n     *\\n     * @example\\n     * const DivisibleBy6 = type.number.divisibleBy(6).moreThan(0)\\n     * // false (left side must also be positive)\\n     * DivisibleBy6.equals(\\\"number % 6\\\")\\n     * // false (right side has an additional <100 constraint)\\n     * console.log(DivisibleBy6.equals(\\\"0 < (number % 6) < 100\\\"))\\n     * const ThirdTry = type(\\\"(number % 2) > 0\\\").divisibleBy(3)\\n     * // true (types are normalized and reduced)\\n     * console.log(DivisibleBy6.equals(ThirdTry))\\n     */\\n    equals<const def>(def: type.validate<def, $>): boolean;\\n    /**\\n     * #### narrow this based on an {@link equals} check\\n     *\\n     * @ignoresMeta\\n     *\\n     * @example\\n     * const N = type.raw(`${Math.random()}`)\\n     * // Type<0.5> | undefined\\n     * const Ez = N.ifEquals(\\\"0.5\\\")\\n     */\\n    ifEquals<const def, r = type.instantiate<def, $>>(def: type.validate<def, $>): r extends infer _ ? _ | undefined : never;\\n    /**\\n     * #### check if this is a subtype of the parsed Type\\n     *\\n     * ✅ a subtype must include all constraints from the base type\\n     * ✅ unlike {@link equals}, additional constraints may be present\\n     * @ignoresMeta\\n     *\\n     * @example\\n     * type.string.extends(\\\"unknown\\\") // true\\n     * type.string.extends(/^a.*z$/) // false\\n     */\\n    extends<const def>(other: type.validate<def, $>): boolean;\\n    /**\\n     * #### narrow this based on an {@link extends} check\\n     *\\n     * @ignoresMeta\\n     *\\n     * @example\\n     * const N = type(Math.random() > 0.5 ? \\\"true\\\" : \\\"0\\\") // Type<0 | true>\\n     * const Ez = N.ifExtends(\\\"boolean\\\") // Type<true> | undefined\\n     */\\n    ifExtends<const def, r = type.instantiate<def, $>>(other: type.validate<def, $>): r extends infer _ ? _ | undefined : never;\\n    /**\\n     * #### check if a value could satisfy this and the parsed Type\\n     *\\n     * ⚠️ will return true unless a {@link Disjoint} can be proven\\n     *\\n     * @example\\n     * type.string.overlaps(\\\"string | number\\\") // true (e.g. \\\"foo\\\")\\n     * type(\\\"string | number\\\").overlaps(\\\"1\\\") // true (1)\\n     * type(\\\"number > 0\\\").overlaps(\\\"number < 0\\\") // false (no values exist)\\n     *\\n     * const NoAt = type(\\\"string\\\").narrow(s => !s.includes(\\\"@\\\"))\\n     * NoAt.overlaps(\\\"string.email\\\") // true (no values exist, but not provable)\\n     */\\n    overlaps<const def>(r: type.validate<def, $>): boolean;\\n    /**\\n     * #### extract branches {@link extend}ing the parsed Type\\n     *\\n     * @example\\n     * // Type<true | 0 | 2>\\n     * const T = type(\\\"boolean | 0 | 'one' | 2 | bigint\\\").extract(\\\"number | 0n | true\\\")\\n     */\\n    extract<const def, r = instantiateType<t extends type.infer<def, $> ? t : never, $>>(r: type.validate<def, $>): r extends infer _ extends r ? _ : never;\\n    /**\\n     * #### exclude branches {@link extend}ing the parsed Type\\n     *\\n     * @example\\n     *\\n     * // Type<false | 'one' | bigint>\\n     * const T = type(\\\"boolean | 0 | 'one' | 2 | bigint\\\").exclude(\\\"number | 0n | true\\\")\\n     */\\n    exclude<const def, r = instantiateType<t extends type.infer<def, $> ? never : t, $>>(r: type.validate<def, $>): r extends infer _ ? _ : never;\\n    /**\\n     * @experimental\\n     * Map and optionally reduce branches of a union. Types that are not unions\\n     * are treated as a single branch.\\n     *\\n     * @param mapBranch - the mapping function, accepting a branch Type\\n     *     Returning another `Type` is common, but any value can be returned and\\n     *     inferred as part of the output.\\n     *\\n     * @param [reduceMapped] - an operation to perform on the mapped branches\\n     *     Can be used to e.g. merge an array of returned Types representing\\n     *     branches back to a single union.\\n     */\\n    distribute<mapOut, reduceOut = mapOut[]>(mapBranch: (branch: Type$1, i: number, branches: array<Type$1>) => mapOut, reduceMapped?: (mappedBranches: mapOut[]) => reduceOut): reduceOut;\\n    /** The Type's [StandardSchema](https://github.com/standard-schema/standard-schema) properties */\\n    \\\"~standard\\\": StandardSchemaV1.ArkTypeProps<this[\\\"inferIn\\\"] extends infer _ ? _ : never, this[\\\"inferOut\\\"] extends infer _ ? _ : never>;\\n    /** @deprecated */\\n    apply: Function[\\\"apply\\\"];\\n    /** @deprecated */\\n    bind: Function[\\\"bind\\\"];\\n    /** @deprecated */\\n    call: Function[\\\"call\\\"];\\n    /** @deprecated */\\n    caller: Function;\\n    /** @deprecated */\\n    length: number;\\n    /** @deprecated */\\n    name: string;\\n    /** @deprecated */\\n    prototype: Function[\\\"prototype\\\"];\\n    /** @deprecated */\\n    arguments: Function[\\\"arguments\\\"];\\n    /** @deprecated */\\n    Symbol: never;\\n}\\ninterface ChainedPipeParser<$, t> extends NaryPipeParser<$, t> {\\n    try: NaryPipeParser<$, t>;\\n}\\ntype validateChainedAsArgs<t> = [\\n    t\\n] extends [unset] ? [\\n    t\\n] extends [anyOrNever] ? [\\n] : [\\n    ErrorMessage<\\\"as requires an explicit type parameter like myType.as<t>()\\\">\\n] : [];\\n\\ntype MatchParserContext<input = unknown> = {\\n    cases: Morph[];\\n    $: unknown;\\n    input: input;\\n    checked: boolean;\\n    key: PropertyKey | null;\\n};\\ndeclare namespace ctx {\\n    type from<ctx extends MatchParserContext> = ctx;\\n    type init<$, input = unknown, checked extends boolean = false> = from<{\\n        cases: [];\\n        $: $;\\n        input: input;\\n        checked: checked;\\n        key: null;\\n    }>;\\n    type atKey<ctx extends MatchParserContext, key extends string> = from<{\\n        cases: ctx[\\\"cases\\\"];\\n        $: ctx[\\\"$\\\"];\\n        input: ctx[\\\"input\\\"];\\n        checked: ctx[\\\"checked\\\"];\\n        key: key;\\n    }>;\\n}\\ninterface MatchParser<$> extends CaseMatchParser<ctx.init<$>> {\\n    in<const def>(def: type.validate<def, $>): ChainableMatchParser<ctx.init<$, type.infer<def, $>, true>>;\\n    in<const typedInput = never>(...args: [typedInput] extends [never] ? [\\n        ErrorMessage<\\\"in requires a definition or type argument (in('string') or in<string>())\\\">\\n    ] : []): ChainableMatchParser<ctx.init<$, typedInput>>;\\n    in<const def>(def: type.validate<def, $>): ChainableMatchParser<ctx.init<$, type.infer<def, $>, true>>;\\n    case: CaseParser<ctx.init<$>>;\\n    at: AtParser<ctx.init<$>>;\\n}\\ntype addCasesToContext<ctx extends MatchParserContext, cases extends unknown[]> = cases extends Morph[] ? ctx.from<{\\n    $: ctx[\\\"$\\\"];\\n    input: ctx[\\\"input\\\"];\\n    cases: [...ctx[\\\"cases\\\"], ...cases];\\n    checked: ctx[\\\"checked\\\"];\\n    key: ctx[\\\"key\\\"];\\n}> : never;\\ntype addDefaultToContext<ctx extends MatchParserContext, defaultCase extends DefaultCase<ctx>> = ctx.from<{\\n    $: ctx[\\\"$\\\"];\\n    input: defaultCase extends \\\"never\\\" ? Morph.In<ctx[\\\"cases\\\"][number]> : ctx[\\\"input\\\"];\\n    cases: defaultCase extends \\\"never\\\" | \\\"assert\\\" ? ctx[\\\"cases\\\"] : defaultCase extends Morph ? ctx[\\\"checked\\\"] extends true ? [\\n        (In: unknown) => ArkErrors,\\n        ...ctx[\\\"cases\\\"],\\n        defaultCase\\n    ] : [...ctx[\\\"cases\\\"], defaultCase] : [\\n        ...ctx[\\\"cases\\\"],\\n        (In: ctx[\\\"input\\\"]) => ArkErrors\\n    ];\\n    checked: ctx[\\\"checked\\\"];\\n    key: ctx[\\\"key\\\"];\\n}>;\\ntype CaseKeyKind = \\\"def\\\" | \\\"string\\\";\\ntype casesToMorphTuple<cases, ctx extends MatchParserContext, kind extends CaseKeyKind> = unionToTuple<propValueOf<{\\n    [def in Exclude<keyof cases, \\\"default\\\">]: cases[def] extends (Morph<never, infer o>) ? kind extends \\\"def\\\" ? (In: inferCaseArg<def extends number ? `${number}` : def, ctx, \\\"in\\\">) => o : (In: maybeLiftToKey<def, ctx>) => o : never;\\n}>>;\\ntype addCasesToParser<cases, ctx extends MatchParserContext, kind extends CaseKeyKind> = cases extends {\\n    default: infer defaultDef extends DefaultCase<ctx>;\\n} ? finalizeMatchParser<addCasesToContext<ctx, casesToMorphTuple<cases, ctx, kind>>, defaultDef> : ChainableMatchParser<addCasesToContext<ctx, casesToMorphTuple<cases, ctx, kind>>>;\\ntype inferCaseArg<def, ctx extends MatchParserContext, endpoint extends \\\"in\\\" | \\\"out\\\"> = _finalizeCaseArg<maybeLiftToKey<type.infer<def, ctx[\\\"$\\\"]>, ctx>, ctx, endpoint>;\\ntype maybeLiftToKey<t, ctx extends MatchParserContext> = ctx[\\\"key\\\"] extends PropertyKey ? {\\n    [k in ctx[\\\"key\\\"]]: t;\\n} : t;\\ntype _finalizeCaseArg<t, ctx extends MatchParserContext, endpoint extends \\\"in\\\" | \\\"out\\\", ctxInput = ctx[\\\"input\\\"]> = ctxInput extends unknown ? t extends unknown ? distill<t, endpoint> extends infer result ? ctxInput extends result ? ctxInput : show<ctxInput & result> : never : never : never;\\ntype CaseParser<ctx extends MatchParserContext> = <const def, ret>(def: type.validate<def, ctx[\\\"$\\\"]>, resolve: (In: inferCaseArg<def, ctx, \\\"out\\\">) => ret) => ChainableMatchParser<addCasesToContext<ctx, [(In: inferCaseArg<def, ctx, \\\"in\\\">) => ret]>>;\\ntype validateKey<key extends Key, ctx extends MatchParserContext> = ctx[\\\"key\\\"] extends Key ? ErrorMessage<doubleAtMessage> : ctx[\\\"cases\\\"][\\\"length\\\"] extends 0 ? keyof ctx[\\\"input\\\"] extends never ? key : conform<key, keyof ctx[\\\"input\\\"]> : ErrorMessage<chainedAtMessage>;\\ninterface StringsParser<ctx extends MatchParserContext> {\\n    <const cases>(def: cases extends validateStringCases<cases, ctx> ? cases : validateStringCases<cases, ctx>): addCasesToParser<cases, ctx, \\\"string\\\">;\\n}\\ntype validateStringCases<cases, ctx extends MatchParserContext> = unknown extends ctx[\\\"input\\\"] ? {\\n    [k in keyof cases]?: k extends \\\"default\\\" ? DefaultCase<ctx> : (In: _finalizeCaseArg<maybeLiftToKey<k, ctx>, ctx, \\\"out\\\">) => unknown;\\n} & {\\n    default?: DefaultCase<ctx>;\\n} : {\\n    [k in keyof cases]?: k extends \\\"default\\\" ? DefaultCase<ctx> : k extends stringValue<ctx> ? (In: _finalizeCaseArg<maybeLiftToKey<k, ctx>, ctx, \\\"out\\\">) => unknown : ErrorType<`${k & string} must be a possible string value`>;\\n} & {\\n    [k in stringValue<ctx>]?: unknown;\\n} & {\\n    default?: DefaultCase<ctx>;\\n};\\ntype stringValue<ctx extends MatchParserContext> = ctx[\\\"input\\\"] extends string ? ctx[\\\"input\\\"] : ctx[\\\"key\\\"] extends keyof ctx[\\\"input\\\"] ? ctx[\\\"input\\\"][ctx[\\\"key\\\"]] extends infer s extends string ? s : never : never;\\ninterface AtParser<ctx extends MatchParserContext> {\\n    <const key extends string>(key: validateKey<key, ctx>): ChainableMatchParser<ctx.atKey<ctx, key>>;\\n    <const key extends string, const cases, ctxAtKey extends MatchParserContext = ctx.atKey<ctx, key>>(key: validateKey<key, ctx>, cases: cases extends validateCases<cases, ctxAtKey> ? cases : errorCases<cases, ctxAtKey>): addCasesToParser<cases, ctxAtKey, \\\"def\\\">;\\n}\\ninterface ChainableMatchParser<ctx extends MatchParserContext> {\\n    case: CaseParser<ctx>;\\n    match: CaseMatchParser<ctx>;\\n    default: DefaultMethod<ctx>;\\n    at: AtParser<ctx>;\\n    /** @experimental */\\n    strings: StringsParser<ctx>;\\n}\\ntype DefaultCaseKeyword = \\\"never\\\" | \\\"assert\\\" | \\\"reject\\\";\\ntype DefaultCase<ctx extends MatchParserContext = MatchParserContext<any>> = DefaultCaseKeyword | Morph<ctx[\\\"input\\\"]>;\\ntype DefaultMethod<ctx extends MatchParserContext> = <const def extends DefaultCase<ctx>>(def: def) => finalizeMatchParser<ctx, def>;\\ntype validateCases<cases, ctx extends MatchParserContext> = {\\n    [def in keyof cases | BaseCompletions<ctx[\\\"$\\\"], {}, \\\"default\\\">]?: def extends \\\"default\\\" ? DefaultCase<ctx> : def extends number ? (In: inferCaseArg<`${def}`, ctx, \\\"out\\\">) => unknown : def extends type.validate<def, ctx[\\\"$\\\"]> ? (In: inferCaseArg<def, ctx, \\\"out\\\">) => unknown : type.validate<def, ctx[\\\"$\\\"]>;\\n};\\ntype errorCases<cases, ctx extends MatchParserContext> = {\\n    [def in keyof cases]?: def extends \\\"default\\\" ? DefaultCase<ctx> : def extends number ? (In: inferCaseArg<`${def}`, ctx, \\\"out\\\">) => unknown : def extends type.validate<def, ctx[\\\"$\\\"]> ? (In: inferCaseArg<def, ctx, \\\"out\\\">) => unknown : ErrorType<type.validate<def, ctx[\\\"$\\\"]>>;\\n} & {\\n    [k in BaseCompletions<ctx[\\\"$\\\"], {}>]?: (In: inferCaseArg<k, ctx, \\\"out\\\">) => unknown;\\n} & {\\n    default?: DefaultCase<ctx>;\\n};\\ntype CaseMatchParser<ctx extends MatchParserContext> = <const cases>(def: cases extends validateCases<cases, ctx> ? cases : errorCases<cases, ctx>) => addCasesToParser<cases, ctx, \\\"def\\\">;\\ntype finalizeMatchParser<ctx extends MatchParserContext, defaultCase extends DefaultCase<ctx>> = addDefaultToContext<ctx, defaultCase> extends (infer ctx extends MatchParserContext) ? Match<ctx[\\\"input\\\"], ctx[\\\"cases\\\"]> : never;\\ninterface Match<In = any, cases extends Morph[] = Morph[]> extends Inferred<(In: Morph.In<cases[number]>) => Out<ReturnType<cases[number]>>> {\\n    <const data extends In>(data: data): {\\n        [i in numericStringKeyOf<cases>]: isDisjoint<data, Morph.In<cases[i]>> extends true ? never : Morph.Out<cases[i]>;\\n    }[numericStringKeyOf<cases>];\\n}\\ndeclare class InternalMatchParser extends Callable<InternalCaseParserFn> {\\n    $: InternalScope;\\n    constructor($: InternalScope);\\n    in(def?: unknown): InternalChainedMatchParser;\\n    at(key: Key, cases?: InternalCases): InternalChainedMatchParser | Match;\\n    case(when: unknown, then: Morph): InternalChainedMatchParser;\\n}\\ntype InternalCases = Record<string, Morph | DefaultCase>;\\ntype InternalCaseParserFn = (cases: InternalCases) => InternalChainedMatchParser | Match;\\ntype CaseEntry = [BaseRoot, Morph] | [\\\"default\\\", DefaultCase];\\ndeclare class InternalChainedMatchParser extends Callable<InternalCaseParserFn> {\\n    $: InternalScope;\\n    in: BaseRoot | undefined;\\n    protected key: Key | undefined;\\n    protected branches: BaseRoot[];\\n    constructor($: InternalScope, In?: BaseRoot);\\n    at(key: Key, cases?: InternalCases): InternalChainedMatchParser | Match;\\n    case(def: unknown, resolver: Morph): InternalChainedMatchParser;\\n    protected caseEntry(node: BaseRoot, resolver: Morph): InternalChainedMatchParser;\\n    match(cases: InternalCases): InternalChainedMatchParser | Match;\\n    strings(cases: InternalCases): InternalChainedMatchParser | Match;\\n    protected caseEntries(entries: CaseEntry[]): InternalChainedMatchParser | Match;\\n    default(defaultCase: DefaultCase): Match;\\n}\\ndeclare const chainedAtMessage = \\\"A key matcher must be specified before the first case i.e. match.at('foo') or match.in<object>().at('bar')\\\";\\ntype chainedAtMessage = typeof chainedAtMessage;\\ndeclare const doubleAtMessage = \\\"At most one key matcher may be specified per expression\\\";\\ntype doubleAtMessage = typeof doubleAtMessage;\\n\\ntype maybeValidateTupleExpression<def extends array, $, args> = def extends IndexZeroExpression ? validatePrefixExpression<def, $, args> : def extends IndexOneExpression ? validateIndexOneExpression<def, $, args> : def extends (readonly [\\\"\\\", ...unknown[]] | readonly [unknown, \\\"\\\", ...unknown[]]) ? readonly [\\n    def[0] extends \\\"\\\" ? BaseCompletions<$, args, IndexZeroOperator | \\\"...\\\"> : def[0],\\n    def[1] extends \\\"\\\" ? BaseCompletions<$, args, IndexOneOperator | \\\"...\\\"> : def[1]\\n] : null;\\ntype inferTupleExpression<def extends TupleExpression, $, args> = def[1] extends \\\"[]\\\" ? inferDefinition<def[0], $, args>[] : def[1] extends \\\"?\\\" ? inferDefinition<def[0], $, args> : def[1] extends \\\"&\\\" ? inferIntersection<inferDefinition<def[0], $, args>, inferDefinition<def[2], $, args>> : def[1] extends \\\"|\\\" ? inferDefinition<def[0], $, args> | inferDefinition<def[2], $, args> : def[1] extends \\\":\\\" ? inferPredicate<inferDefinition<def[0], $, args>, def[2]> : def[1] extends \\\"=>\\\" ? parseMorph<def[0], def[2], $, args> : def[1] extends \\\"|>\\\" ? parseTo<def[0], def[2], $, args> : def[1] extends \\\"=\\\" ? withDefault<inferDefinition<def[0], $, args>, unwrapDefault<def[2]>> : def[1] extends \\\"@\\\" ? inferDefinition<def[0], $, args> : def extends readonly [\\\"===\\\", ...infer values] ? values[number] : def extends (readonly [\\\"instanceof\\\", ...infer constructors extends Constructor[]]) ? InstanceType<constructors[number]> : def[0] extends \\\"keyof\\\" ? inferKeyOfExpression<def[1], $, args> : never;\\ntype validatePrefixExpression<def extends IndexZeroExpression, $, args> = def[\\\"length\\\"] extends 1 ? readonly [writeMissingRightOperandMessage<def[0]>] : def[0] extends \\\"keyof\\\" ? readonly [def[0], validateDefinition<def[1], $, args>] : def[0] extends \\\"===\\\" ? readonly [def[0], ...unknown[]] : def[0] extends \\\"instanceof\\\" ? readonly [def[0], ...Constructor[]] : never;\\ntype validateIndexOneExpression<def extends IndexOneExpression, $, args> = def[1] extends TuplePostfixOperator ? readonly [validateDefinition<def[0], $, args>, def[1]] : readonly [\\n    validateDefinition<def[0], $, args>,\\n    def[\\\"length\\\"] extends 2 ? writeMissingRightOperandMessage<def[1]> : def[1],\\n    def[1] extends \\\"|\\\" ? validateDefinition<def[2], $, args> : def[1] extends \\\"&\\\" ? validateDefinition<def[2], $, args> : def[1] extends \\\":\\\" ? Predicate<type.infer.Out<def[0], $, args>> : def[1] extends \\\"=>\\\" ? Morph<type.infer.Out<def[0], $, args>> : def[1] extends \\\"|>\\\" ? validateDefinition<def[2], $, args> : def[1] extends \\\"=\\\" ? defaultFor<type.infer.In<def[0], $, args>> : def[1] extends \\\"@\\\" ? TypeMeta.MappableInput : validateDefinition<def[2], $, args>,\\n    ...(def[1] extends \\\"@\\\" ? [NodeSelector?] : [])\\n];\\ntype inferKeyOfExpression<operandDef, $, args> = show<keyof inferDefinition<operandDef, $, args>>;\\ntype TupleExpression = IndexZeroExpression | IndexOneExpression;\\ntype ArgTwoOperator = Exclude<IndexOneOperator, \\\"?\\\" | \\\"=\\\">;\\ntype parseTo<inDef, outDef, $, args> = inferPipe<inferDefinition<inDef, $, args>, inferDefinition<outDef, $, args>>;\\ntype parseMorph<inDef, morph, $, args> = morph extends Morph ? inferMorphOut<morph> extends infer out ? (In: distill.In<inferDefinition<inDef, $, args>>) => Out<out> : never : never;\\ntype IndexOneExpression<token extends string = IndexOneOperator> = readonly [unknown, token, ...unknown[]];\\ntype IndexOneParser<token extends string> = (def: IndexOneExpression<token>, ctx: BaseParseContext) => BaseRoot;\\ndeclare const postfixParsers: {\\n    \\\"?\\\": IndexOneParser<\\\"?\\\">;\\n    \\\"[]\\\": IndexOneParser<\\\"[]\\\">;\\n};\\ntype TuplePostfixOperator = keyof typeof postfixParsers;\\ndeclare const infixParsers: {\\n    \\\"|\\\": IndexOneParser<\\\"|\\\">;\\n    \\\"=\\\": IndexOneParser<\\\"=\\\">;\\n    \\\"|>\\\": IndexOneParser<\\\"|>\\\">;\\n    \\\"&\\\": IndexOneParser<\\\"&\\\">;\\n    \\\"=>\\\": IndexOneParser<\\\"=>\\\">;\\n    \\\":\\\": IndexOneParser<\\\":\\\">;\\n    \\\"@\\\": IndexOneParser<\\\"@\\\">;\\n};\\ntype TupleInfixOperator = keyof typeof infixParsers;\\ndeclare const indexOneParsers: {\\n    \\\"|\\\": IndexOneParser<\\\"|\\\">;\\n    \\\"=\\\": IndexOneParser<\\\"=\\\">;\\n    \\\"|>\\\": IndexOneParser<\\\"|>\\\">;\\n    \\\"&\\\": IndexOneParser<\\\"&\\\">;\\n    \\\"=>\\\": IndexOneParser<\\\"=>\\\">;\\n    \\\":\\\": IndexOneParser<\\\":\\\">;\\n    \\\"@\\\": IndexOneParser<\\\"@\\\">;\\n    \\\"?\\\": IndexOneParser<\\\"?\\\">;\\n    \\\"[]\\\": IndexOneParser<\\\"[]\\\">;\\n};\\ntype IndexOneOperator = keyof typeof indexOneParsers;\\ntype IndexZeroParser<token extends string> = (def: IndexZeroExpression<token>, ctx: BaseParseContext) => BaseRoot;\\ntype IndexZeroExpression<token extends string = IndexZeroOperator> = readonly [\\n    token,\\n    ...unknown[]\\n];\\ndeclare const indexZeroParsers: {\\n    keyof: IndexZeroParser<\\\"keyof\\\">;\\n    instanceof: IndexZeroParser<\\\"instanceof\\\">;\\n    \\\"===\\\": IndexZeroParser<\\\"===\\\">;\\n};\\ntype IndexZeroOperator = keyof typeof indexZeroParsers;\\n\\n/** The convenience properties attached to `type` */\\ntype TypeParserAttachments = Omit<TypeParser, never>;\\ninterface TypeParser<$ = {}> extends Ark.boundTypeAttachments<$> {\\n    /**\\n     * Create a {@link Type} from your definition.\\n     *\\n     * @example const Person = type({ name: \\\"string\\\" })\\n     */\\n    <const def, r = type.instantiate<def, $>>(def: type.validate<def, $>): r extends infer _ ? _ : never;\\n    /**\\n     * Create a {@link Generic} from a parameter string and body definition.\\n     *\\n     * @param params A string like \\\"<t, n extends number>\\\" specifying the\\n     * {@link Generic}'s parameters and any associated constraints via `extends`.\\n     *\\n     * @param def The definition for the body of the {@link Generic}. Can reference the\\n     * parameter names specified in the previous argument in addition to aliases\\n     * from its {@link Scope}.\\n     *\\n     * @example const BoxOf = type(\\\"<t extends string | number>\\\", { contents: \\\"t\\\" })\\n     */\\n    <const params extends ParameterString, const def, r = Generic<parseValidGenericParams<params, $>, def, $>>(params: validateParameterString<params, $>, def: type.validate<def, $, baseGenericConstraints<parseValidGenericParams<params, $>>>): r extends infer _ ? _ : never;\\n    /**\\n     * Create a {@link Type} from a [tuple expression](http://localhost:3000/docs/expressions)\\n     * spread as this function's arguments.\\n     *\\n     * @example type(\\\"string\\\", \\\"|\\\", { foo: \\\"number\\\" })\\n     */\\n    <const zero, const one, const rest extends array, r = type.instantiate<[zero, one, ...rest], $>>(_0: zero extends IndexZeroOperator ? zero : type.validate<zero, $>, _1: zero extends \\\"keyof\\\" ? type.validate<one, $> : zero extends \\\"instanceof\\\" ? conform<one, Constructor> : zero extends \\\"===\\\" ? conform<one, unknown> : conform<one, ArgTwoOperator>, ..._2: zero extends \\\"===\\\" ? rest : zero extends \\\"instanceof\\\" ? conform<rest, readonly Constructor[]> : one extends TupleInfixOperator ? one extends \\\":\\\" ? [Predicate<distill.In<type.infer<zero, $>>>] : one extends \\\"=>\\\" ? [Morph<distill.Out<type.infer<zero, $>>, unknown>] : one extends \\\"|>\\\" ? [type.validate<rest[0], $>] : one extends \\\"@\\\" ? [TypeMeta.MappableInput, NodeSelector?] : [type.validate<rest[0], $>] : []): r extends infer _ ? _ : never;\\n    /**\\n     * An alias of the {@link ArkErrors} class, an instance of which is returned when a {@link Type}\\n     * is invoked with invalid input.\\n     *\\n     * @example\\n     * const out = myType(data)\\n     *\\n     * if(out instanceof type.errors) console.log(out.summary)\\n     */\\n    errors: typeof ArkErrors;\\n    hkt: typeof Hkt;\\n    keywords: typeof keywords;\\n    /**\\n     * The {@link Scope} in which definitions passed to this function will be parsed.\\n     */\\n    $: Scope<$>;\\n    /**\\n     * An alias of `type` with no type-level validation or inference.\\n     *\\n     * Useful when wrapping `type` or using it to parse a dynamic definition.\\n     */\\n    raw(def: unknown): Type$1<any, $>;\\n    module: ModuleParser;\\n    scope: ScopeParser;\\n    define: DefinitionParser<$>;\\n    declare: DeclarationParser<$>;\\n    generic: GenericParser<$>;\\n    match: MatchParser<$>;\\n    schema: SchemaParser<$>;\\n    /**\\n     * Create a {@link Type} that is satisfied only by a value strictly equal (`===`) to the argument passed to this function.\\n     * @example const foo = type.unit('foo') // {@link Type}<'foo'>\\n     * @example const sym: unique symbol = Symbol(); type.unit(sym) // {@link Type}<typeof sym>\\n     */\\n    unit: UnitTypeParser<$>;\\n    /**\\n     * Create a {@link Type} that is satisfied only by a value strictly equal (`===`) to one of the arguments passed to this function.\\n     * @example const enum = type.enumerated('foo', 'bar', obj) // obj is a by-reference object\\n     * @example const TupleForm = type(['===', 'foo', 'bar', obj])\\n     * @example const ArgsForm = type('===', 'foo', 'bar', obj)\\n     */\\n    enumerated: EnumeratedTypeParser<$>;\\n    /**\\n     * Create a {@link Type} that is satisfied only by one of the Object.values() of the argument passed to this function.\\n     *\\n     * ⚠️ For TypeScript enum compatibility, values at numeric keys with corresponding numeric values will not be included.\\n     * @example const myEnum = type.valueOf(myTsEnum)\\n     */\\n    valueOf: ValueOfTypeParser<$>;\\n    /**\\n     * Create a {@link Type} that is satisfied only by a value of a specific class.\\n     * @example const array = type.instanceOf(Array)\\n     */\\n    instanceOf: InstanceOfTypeParser<$>;\\n    /**\\n     * Create a {@link Type} from a union of definitions\\n     * @example const T = type.or(\\\"string\\\", \\\"number\\\")\\n     */\\n    or: NaryUnionParser<$>;\\n    /**\\n     * Create a {@link Type} from an intersection of definitions\\n     * @example const T = type.and({ a: \\\"1\\\" }, { b: \\\"2\\\" })\\n     */\\n    and: NaryIntersectionParser<$>;\\n    /**\\n     * Create a {@link Type} by merging object definitions, with later\\n     * definitions having precedence for overlapping keys\\n     * @example\\n     * // Type<{ a: \\\"3\\\", b: \\\"2\\\", c: \\\"4\\\" }>\\n     * const T = type.merge({ a: \\\"1\\\", b: \\\"2\\\" }, { a: \\\"3\\\", c: \\\"4\\\" })\\n     */\\n    merge: NaryMergeParser<$>;\\n    /**\\n     * Create a {@link Type} from a set of morphs (including Types)\\n     * @example\\n     * // Type<(In: string) => To<object>>\\n     * const T = type.pipe(type.string, s => JSON.parse(s), type.object)\\n     */\\n    pipe: NaryPipeParser<$>;\\n    /**\\n     * Define a validated function\\n     * @example\\n     * const len = type.fn(\\\"string | unknown[]\\\", \\\":\\\", \\\"number\\\")(s => s.length)\\n     * len(\\\"foo\\\") // 3\\n     * // TypeScript: boolean is not assignable to string | unknown[]\\n     * // Runtime (throws): must be a string or an object (was boolean)\\n     * len(true)\\n     */\\n    fn: FnParser<$>;\\n}\\ndeclare class InternalTypeParser extends Callable<(...args: unknown[]) => BaseRoot | Generic, TypeParserAttachments> {\\n    constructor($: InternalScope);\\n}\\ntype UnitTypeParser<$> = <const t>(value: t) => Type<t, $>;\\ntype InstanceOfTypeParser<$> = <const t extends object>(ctor: Constructor<t>) => Type<t, $>;\\ntype EnumeratedTypeParser<$> = <const values extends readonly unknown[]>(...values: values) => Type<values[number], $>;\\ntype ValueOfTypeParser<$> = <const o extends object>(o: o) => Type<o[keyof o], $>;\\ntype DefinitionParser<$> = <const def>(def: type.validate<def, $>) => def;\\ntype SchemaParser<$> = (schema: RootSchema, opts?: BaseParseOptions) => Type<unknown, $>;\\ntype TypeConstructor<t = unknown, $ = {}> = new (def: unknown, $: Scope<$>) => Type<t, $>;\\ntype Type<t = unknown, $ = {}> = instantiateType<t, $>;\\ndeclare const Type: TypeConstructor;\\n\\ntype BaseFnParser<$ = {}> = <const args extends readonly unknown[], paramsT extends readonly unknown[] = inferTupleLiteral<args extends readonly [...infer params, \\\":\\\", unknown] ? params : args, $, {}>, returnT = args extends readonly [...unknown[], \\\":\\\", infer returnDef] ? type.infer<returnDef, $> : unknown>(...args: {\\n    [i in keyof args]: conform<args[i], get<validateFnArgs<args, $>, i>>;\\n}) => <internalSignature extends (...args: distill.Out<paramsT>) => distill.In<returnT>, externalSignature extends Fn = (...args: applyElementLabels<distill.In<paramsT>, Parameters<internalSignature>>) => args extends readonly [...unknown[], \\\":\\\", unknown] ? distill.Out<returnT> : ReturnType<internalSignature>>(implementation: internalSignature) => TypedFn<externalSignature, $, args extends readonly [...unknown[], \\\":\\\", unknown] ? Return.introspectable : {}>;\\ninterface FnParser<$ = {}> extends BaseFnParser<$> {\\n    /**\\n     * The {@link Scope} in which definitions passed to this function will be parsed.\\n     */\\n    $: Scope<$>;\\n    /**\\n     * An alias of `fn` with no type-level validation or inference.\\n     *\\n     * Useful when wrapping `fn` or using it to parse a dynamic definition.\\n     */\\n    raw: RawFnParser;\\n}\\ntype RawFnParser = (...args: unknown[]) => (...args: unknown[]) => unknown;\\ndeclare class InternalFnParser extends Callable<(...args: unknown[]) => Fn> {\\n    constructor($: InternalScope);\\n}\\ndeclare namespace TypedFn {\\n    type meta = {\\n        introspectableReturn?: true;\\n    };\\n}\\ninterface TypedFn<signature extends Fn = Fn, $ = {}, meta extends TypedFn.meta = {}> extends Callable<signature> {\\n    expression: string;\\n    params: signature extends Fn<infer params> ? Type<params, $> : never;\\n    returns: Type<meta extends Return.introspectable ? ReturnType<signature> : unknown, $>;\\n}\\ndeclare namespace Return {\\n    interface introspectable {\\n        introspectableReturn: true;\\n    }\\n}\\ntype validateFnArgs<args, $> = args extends readonly unknown[] ? args extends readonly [...infer paramDefs, \\\":\\\", infer returnDef] ? readonly [\\n    ...validateFnParamDefs<paramDefs, $>,\\n    \\\":\\\",\\n    type.validate<returnDef, $>\\n] : validateFnParamDefs<args, $> : never;\\ntype validateFnParamDefs<paramDefs extends readonly unknown[], $> = paramDefs extends validateTupleLiteral<paramDefs, $, {}> ? paramDefs : paramDefs extends {\\n    [i in keyof paramDefs]: paramDefs[i] extends \\\"...\\\" ? paramDefs[i] : validateInnerDefinition<paramDefs[i], $, {}>;\\n} ? validateTupleLiteral<paramDefs, $, {}> : {\\n    [i in keyof paramDefs]: validateInnerDefinition<paramDefs[i], $, {}>;\\n};\\n\\ninterface ArkScopeConfig extends ArkSchemaScopeConfig {\\n}\\ninterface ScopeParser {\\n    <const def>(def: scope.validate<def>, config?: ArkScopeConfig): Scope<scope.infer<def>>;\\n    define: <const def>(def: scope.validate<def>) => def;\\n}\\ntype ModuleParser = <const def>(def: scope.validate<def>, config?: ArkScopeConfig) => scope.infer<def> extends infer $ ? Module<{\\n    [k in exportedNameOf<$>]: $[k];\\n}> : never;\\ntype bindThis<def> = {\\n    this: Def<def>;\\n};\\n/** nominal type for an unparsed definition used during scope bootstrapping */\\ntype Def<def = {}> = Brand<def, \\\"unparsed\\\">;\\n/** sentinel indicating a scope that will be associated with a generic has not yet been parsed */\\ntype UnparsedScope = \\\"$\\\";\\n/** These are legal as values of a scope but not as definitions in other contexts */\\ntype PreparsedResolution = PreparsedNodeResolution;\\ntype bootstrapAliases<def> = {\\n    [k in Exclude<keyof def, GenericDeclaration>]: def[k] extends (PreparsedResolution) ? def[k] extends {\\n        t: infer g extends GenericAst;\\n    } ? g : def[k] extends Module<infer $> | BoundModule<infer $, any> ? Submodule<$> : def[k] : def[k] extends (() => infer thunkReturn extends PreparsedResolution) ? thunkReturn extends {\\n        t: infer g extends GenericAst;\\n    } ? g : thunkReturn extends Module<infer $> | BoundModule<infer $, any> ? Submodule<$> : thunkReturn : Def<def[k]>;\\n} & {\\n    [k in keyof def & GenericDeclaration as extractGenericName<k>]: GenericAst<parseValidGenericParams<extractGenericParameters<k>, bootstrapAliases<def>>, def[k], UnparsedScope>;\\n};\\ntype inferBootstrapped<$> = {\\n    [name in keyof $]: $[name] extends Def<infer def> ? inferDefinition<def, $, {}> : $[name] extends {\\n        t: infer g extends GenericAst;\\n    } ? bindGenericToScope<g, $> : $[name];\\n} & unknown;\\ntype bindGenericToScope<g extends GenericAst, $> = GenericAst<g[\\\"paramsAst\\\"], g[\\\"bodyDef\\\"], g[\\\"$\\\"] extends UnparsedScope ? $ : g[\\\"$\\\"], $>;\\ntype extractGenericName<k> = k extends GenericDeclaration<infer name> ? name : never;\\ntype extractGenericParameters<k> = k extends `${string}<${infer params}>` ? ParameterString<params> : never;\\ntype resolutionToAst<alias extends string, resolution> = [\\n    resolution\\n] extends [anyOrNever] ? InferredAst<resolution, alias> : resolution extends Def<infer def> ? DefAst<def, alias> : resolution extends {\\n    [arkKind]: \\\"module\\\";\\n    root: infer root;\\n} ? InferredAst<root, alias> : resolution extends GenericAst ? resolution : InferredAst<resolution, alias>;\\ninterface InternalScope {\\n    constructor: typeof InternalScope;\\n}\\ndeclare class InternalScope<$ extends {} = {}> extends BaseScope<$> {\\n    get ambientAttachments(): Ark.boundTypeAttachments<$> | undefined;\\n    protected preparseOwnAliasEntry(alias: string, def: unknown): AliasDefEntry;\\n    parseGenericParams(def: string, opts: BaseParseOptions): array<GenericParamDef>;\\n    protected normalizeRootScopeValue(resolution: unknown): unknown;\\n    protected preparseOwnDefinitionFormat(def: unknown, opts: BaseParseOptions): BaseRoot | BaseParseContextInput;\\n    parseOwnDefinitionFormat(def: unknown, ctx: BaseParseContext): BaseRoot;\\n    unit: UnitTypeParser<$>;\\n    valueOf: ValueOfTypeParser<$>;\\n    enumerated: EnumeratedTypeParser<$>;\\n    instanceOf: InstanceOfTypeParser<$>;\\n    or: NaryUnionParser<$>;\\n    and: NaryIntersectionParser<$>;\\n    merge: NaryMergeParser<$>;\\n    pipe: NaryPipeParser<$>;\\n    fn: InternalFnParser;\\n    match: InternalMatchParser;\\n    declare: () => {\\n        type: InternalTypeParser;\\n    };\\n    define<def>(def: def): def;\\n    type: InternalTypeParser;\\n    static scope: ScopeParser;\\n    static module: ModuleParser;\\n}\\ndeclare const scope: ScopeParser;\\ndeclare namespace scope {\\n    type validate<def> = {\\n        [k in keyof def]: k extends noSuggest ? unknown : parseScopeKey<k, def>[\\\"params\\\"] extends infer params ? params extends array<GenericParamAst> ? params[\\\"length\\\"] extends 0 ? def[k] extends type.Any | PreparsedResolution ? def[k] : k extends (PrivateDeclaration<infer name extends keyof def & string>) ? ErrorType<writeDuplicateAliasError<name>> : type.validate<def[k], bootstrapAliases<def>, {}> : type.validate<def[k], bootstrapAliases<def>, baseGenericConstraints<params>> : params : never;\\n    };\\n    type infer<def> = inferBootstrapped<bootstrapAliases<def>>;\\n}\\ninterface ScopeConstructor {\\n    new <$ = {}>(...args: ConstructorParameters<typeof InternalScope>): Scope<$>;\\n    scope: ScopeParser;\\n    module: ModuleParser;\\n}\\ninterface Scope<$ = {}> {\\n    t: $;\\n    [arkKind]: \\\"scope\\\";\\n    config: ArkScopeConfig;\\n    references: readonly BaseNode[];\\n    json: JsonStructure;\\n    exportedNames: array<exportedNameOf<$>>;\\n    /** The set of names defined at the root-level of the scope mapped to their\\n     * corresponding definitions.**/\\n    aliases: Record<string, unknown>;\\n    internal: toInternalScope<$>;\\n    defineSchema<const def extends RootSchema>(schema: def): def;\\n    node<kinds extends NodeKind | array<RootKind>>(kinds: kinds, schema: NodeSchema<flattenListable<kinds>>, opts?: BaseParseOptions): nodeOfKind<reducibleKindOf<flattenListable<kinds>>>;\\n    unit: UnitTypeParser<$>;\\n    enumerated: EnumeratedTypeParser<$>;\\n    valueOf: ValueOfTypeParser<$>;\\n    instanceOf: InstanceOfTypeParser<$>;\\n    type: TypeParser<$>;\\n    match: MatchParser<$>;\\n    fn: FnParser<$>;\\n    declare: DeclarationParser<$>;\\n    define: DefinitionParser<$>;\\n    generic: GenericParser<$>;\\n    schema: SchemaParser<$>;\\n    import(): Module<{\\n        [k in exportedNameOf<$> as PrivateDeclaration<k>]: $[k];\\n    }>;\\n    import<names extends exportedNameOf<$>[]>(...names: names): BoundModule<{\\n        [k in names[number] as PrivateDeclaration<k>]: $[k];\\n    } & unknown, $>;\\n    export(): Module<{\\n        [k in exportedNameOf<$>]: $[k];\\n    }>;\\n    export<names extends exportedNameOf<$>[]>(...names: names): BoundModule<{\\n        [k in names[number]]: $[k];\\n    } & unknown, $>;\\n    resolve<name extends exportedNameOf<$>>(name: name): instantiateExport<$[name], $>;\\n}\\ndeclare const Scope: ScopeConstructor;\\ntype parseScopeKey<k, def> = k extends `${infer name}<${infer params}>` ? parseGenericScopeKey<name, params, def> : {\\n    name: k;\\n    params: [];\\n};\\ntype parseGenericScopeKey<name extends string, params extends string, def> = {\\n    name: name;\\n    params: parseGenericParams<params, bootstrapAliases<def>>;\\n};\\ntype InnerParseResult = BaseRoot | ParsedOptionalProperty | ParsedDefaultableProperty;\\n\\ntype inferDefinition<def, $, args> = [\\n    def\\n] extends [anyOrNever] ? def : def extends type.cast<infer t> ? ifEmptyObjectLiteral<def, object, t> : def extends ThunkCast<infer t> ? t : def extends string ? inferString<def, $, args> : def extends array ? inferTuple<def, $, args> : def extends RegExp ? string : def extends StandardSchemaV1 ? inferStandardSchema<def> : def extends object ? inferObjectLiteral<def, $, args> : never;\\ntype inferStandardSchema<schema extends StandardSchemaV1, i = StandardSchemaV1.InferInput<schema>, o = StandardSchemaV1.InferOutput<schema>> = [i, o] extends [o, i] ? i : (In: i) => Out<o>;\\ntype validateDefinition<def, $, args> = null extends undefined ? ErrorMessage<`'strict' or 'strictNullChecks' must be set to true in your tsconfig's 'compilerOptions'`> : [def] extends [anyOrNever] ? def : def extends OptionalPropertyDefinition ? ErrorMessage<shallowOptionalMessage> : isDefaultable<def, $, args> extends true ? ErrorMessage<shallowDefaultableMessage> : validateInnerDefinition<def, $, args>;\\ntype validateInnerDefinition<def, $, args> = [\\n    def\\n] extends [TerminalObjectDefinition] ? def : def extends string ? validateString<def, $, args> : unknown extends def ? BaseCompletions<$, args> | {} : def extends readonly unknown[] ? validateTuple<def, $, args> : def extends BadDefinitionType ? ErrorMessage<writeBadDefinitionTypeMessage<objectKindOrDomainOf<def>>> : validateObjectLiteral<def, $, args>;\\ntype validateTuple<def extends array, $, args> = maybeValidateTupleExpression<def, $, args> extends infer result ? result extends null ? validateTupleLiteral<def, $, args> : result : never;\\ntype inferTuple<def extends array, $, args> = def extends TupleExpression ? inferTupleExpression<def, $, args> : inferTupleLiteral<def, $, args>;\\ntype TerminalObjectDefinition = type.cast<unknown> | Fn | RegExp | StandardSchemaV1;\\ntype ThunkCast<t = unknown> = () => type.cast<t>;\\ntype BadDefinitionType = Exclude<Primitive, string>;\\ndeclare const writeBadDefinitionTypeMessage: <actual extends string>(actual: actual) => writeBadDefinitionTypeMessage<actual>;\\ntype writeBadDefinitionTypeMessage<actual extends string> = `Type definitions must be strings or objects (was ${actual})`;\\n\\ntype DeclarationParser<$> = <preinferred = unset, ctx extends DeclareContext = {}>() => {\\n    type: <const def>(def: [preinferred] extends [unset] ? [\\n        preinferred\\n    ] extends [anyOrNever] ? validateDeclared<preinferred, def, $, ctx> : ErrorMessage<`declare<ExternalType>() requires a generic argument`> : validateDeclared<preinferred, def, $, ctx>) => Type<finalizePreinferred<preinferred, def, $, ctx>, $>;\\n};\\ntype finalizePreinferred<preinferred, def, $, ctx extends DeclareContext> = ctx[\\\"side\\\"] extends distill.Side ? ctx[\\\"side\\\"] extends \\\"in\\\" ? (In: preinferred) => type.infer.Out<def, $> : (In: type.infer.In<def, $>) => preinferred : preinferred;\\ntype DeclareContext = {\\n    side?: \\\"in\\\" | \\\"out\\\";\\n};\\ntype validateDeclared<declared, def, $, ctx extends DeclareContext> = def extends type.validate<def, $> ? validateInference<def, declared, $, bindThis<def>, ctx> : type.validate<def, $>;\\ntype validateInference<def, declared, $, args, ctx extends DeclareContext> = def extends TerminalObjectDefinition | ThunkCast | TupleExpression ? keyof def extends never ? validateObjectInference<def, declared, $, args, ctx> : validateShallowInference<inferDefinition<def, $, args>, declared, ctx> : def extends array ? validateArrayInference<def, declared, $, args, ctx> : def extends object ? validateObjectInference<def, declared, $, args, ctx> : validateShallowInference<inferDefinition<def, $, args>, declared, ctx>;\\ntype validateArrayInference<def extends array, declared, $, args, ctx extends DeclareContext> = declared extends array ? {\\n    [i in keyof declared]: i extends keyof def ? validateInference<def[i], declared[i], $, args, ctx> : declared[i];\\n} : show<declarationMismatch<inferDefinition<def, $, args>, declared>>;\\ntype validateObjectInference<def extends object, declared, $, args, ctx extends DeclareContext> = show<{\\n    [k in requiredKeyOf<declared>]: k extends keyof def ? validateInference<def[k], declared[k], $, args, ctx> : declared[k];\\n} & {\\n    [k in optionalKeyOf<declared> & string as declaredOptionalKeySuggestion<k, def>]: declaredOptionalValueSuggestion<def, k, declared, $, args, ctx>;\\n}>;\\ntype declaredOptionalKeySuggestion<k extends string, def> = k extends keyof def ? def[k] extends OptionalPropertyDefinition ? k : `${k}?` : `${k}?`;\\ntype declaredOptionalValueSuggestion<def, k extends keyof declared & string, declared, $, args, ctx extends DeclareContext> = k extends keyof def ? def[k] extends OptionalPropertyDefinition ? validateInference<def[k], Required<declared>[k], $, args, ctx> : declared[k] : `${k}?` extends keyof def ? validateInference<def[`${k}?`], Required<declared>[k], $, args, ctx> : declared[k];\\ntype validateShallowInference<t, declared, ctx extends DeclareContext, inferred = ctx[\\\"side\\\"] extends distill.Side ? distill<t, ctx[\\\"side\\\"]> : t> = equals<inferred, declared> extends true ? unknown : show<declarationMismatch<inferred, declared>>;\\ntype declarationMismatch<inferred, declared> = ErrorType<{\\n    declared: declared;\\n    inferred: inferred;\\n}>;\\n\\ndeclare class MergeHkt extends Hkt<[base: object, props: object]> {\\n    body: util.merge<this[0], this[1]>;\\n    description: string;\\n}\\ndeclare const Merge: _ark_schema.GenericRoot<readonly [[\\\"base\\\", object], [\\\"props\\\", object]], MergeHkt>;\\ndeclare const arkBuiltins: arkBuiltins;\\ntype arkBuiltins = Module<arkBuiltins.$>;\\ndeclare namespace arkBuiltins {\\n    type submodule = Submodule<$>;\\n    type $ = {\\n        Key: Key;\\n        Merge: typeof Merge.t;\\n    };\\n}\\n\\ndeclare const number: number.module;\\ndeclare namespace number {\\n    type module = Module<submodule>;\\n    type submodule = Submodule<$>;\\n    type $ = {\\n        root: number;\\n        epoch: number;\\n        integer: number;\\n        safe: number;\\n        NaN: number;\\n        Infinity: number;\\n        NegativeInfinity: number;\\n    };\\n}\\n\\ndeclare const stringInteger: stringInteger.module;\\ndeclare namespace stringInteger {\\n    type module = Module<submodule>;\\n    type submodule = Submodule<$>;\\n    type $ = {\\n        root: string;\\n        parse: (In: string) => To<number>;\\n    };\\n}\\ndeclare const base64: Module<{\\n    root: unknown;\\n    url: unknown;\\n}>;\\ndeclare namespace base64 {\\n    type module = Module<submodule>;\\n    type submodule = Submodule<$>;\\n    type $ = {\\n        root: string;\\n        url: string;\\n    };\\n}\\ndeclare const capitalize: capitalize.module;\\ndeclare namespace capitalize {\\n    type module = Module<submodule>;\\n    type submodule = Submodule<$>;\\n    type $ = {\\n        root: (In: string) => To<string>;\\n        preformatted: string;\\n    };\\n}\\ndeclare const stringDate: stringDate.module;\\ndeclare namespace stringDate {\\n    type module = Module<stringDate.submodule>;\\n    type submodule = Submodule<$>;\\n    type $ = {\\n        root: string;\\n        parse: (In: string) => To<Date>;\\n        iso: iso.submodule;\\n        epoch: epoch.submodule;\\n    };\\n    namespace iso {\\n        type submodule = Submodule<$>;\\n        type $ = {\\n            root: string;\\n            parse: (In: string) => To<Date>;\\n        };\\n    }\\n    namespace epoch {\\n        type submodule = Submodule<$>;\\n        type $ = {\\n            root: string;\\n            parse: (In: string) => To<Date>;\\n        };\\n    }\\n}\\ndeclare const ip: ip.module;\\ndeclare namespace ip {\\n    type module = Module<submodule>;\\n    type submodule = Submodule<$>;\\n    type $ = {\\n        root: string;\\n        v4: string;\\n        v6: string;\\n    };\\n}\\ndeclare namespace stringJson {\\n    type module = Module<submodule>;\\n    type submodule = Submodule<$>;\\n    type $ = {\\n        root: string;\\n        parse: (In: string) => To<Json>;\\n    };\\n}\\ndeclare namespace lower {\\n    type module = Module<submodule>;\\n    type submodule = Submodule<$>;\\n    type $ = {\\n        root: (In: string) => To<string>;\\n        preformatted: string;\\n    };\\n}\\ndeclare const normalize: Module<{\\n    root: unknown;\\n    NFC: Submodule<{\\n        root: unknown;\\n        preformatted: unknown;\\n    }>;\\n    NFD: Submodule<{\\n        root: unknown;\\n        preformatted: unknown;\\n    }>;\\n    NFKC: Submodule<{\\n        root: unknown;\\n        preformatted: unknown;\\n    }>;\\n    NFKD: Submodule<{\\n        root: unknown;\\n        preformatted: unknown;\\n    }>;\\n}>;\\ndeclare namespace normalize {\\n    type module = Module<submodule>;\\n    type submodule = Submodule<$>;\\n    type $ = {\\n        root: (In: string) => To<string>;\\n        NFC: NFC.submodule;\\n        NFD: NFD.submodule;\\n        NFKC: NFKC.submodule;\\n        NFKD: NFKD.submodule;\\n    };\\n    namespace NFC {\\n        type submodule = Submodule<$>;\\n        type $ = {\\n            root: (In: string) => To<string>;\\n            preformatted: string;\\n        };\\n    }\\n    namespace NFD {\\n        type submodule = Submodule<$>;\\n        type $ = {\\n            root: (In: string) => To<string>;\\n            preformatted: string;\\n        };\\n    }\\n    namespace NFKC {\\n        type submodule = Submodule<$>;\\n        type $ = {\\n            root: (In: string) => To<string>;\\n            preformatted: string;\\n        };\\n    }\\n    namespace NFKD {\\n        type submodule = Submodule<$>;\\n        type $ = {\\n            root: (In: string) => To<string>;\\n            preformatted: string;\\n        };\\n    }\\n}\\ndeclare const stringNumeric: stringNumeric.module;\\ndeclare namespace stringNumeric {\\n    type module = Module<submodule>;\\n    type submodule = Submodule<$>;\\n    type $ = {\\n        root: string;\\n        parse: (In: string) => To<number>;\\n    };\\n}\\ndeclare namespace trim {\\n    type module = Module<submodule>;\\n    type submodule = Submodule<$>;\\n    type $ = {\\n        root: (In: string) => To<string>;\\n        preformatted: string;\\n    };\\n}\\ndeclare const upper: upper.module;\\ndeclare namespace upper {\\n    type module = Module<submodule>;\\n    type submodule = Submodule<$>;\\n    type $ = {\\n        root: (In: string) => To<string>;\\n        preformatted: string;\\n    };\\n}\\ndeclare const url: url.module;\\ndeclare namespace url {\\n    type module = Module<submodule>;\\n    type submodule = Submodule<$>;\\n    type $ = {\\n        root: string;\\n        parse: (In: string) => To<URL>;\\n    };\\n}\\ndeclare const uuid: Module<{\\n    root: string;\\n    v1: unknown;\\n    v2: unknown;\\n    v3: unknown;\\n    v4: unknown;\\n    v5: unknown;\\n    v6: unknown;\\n    v7: unknown;\\n    v8: unknown;\\n}>;\\ndeclare namespace uuid {\\n    type module = Module<submodule>;\\n    type submodule = Submodule<$>;\\n    type $ = {\\n        root: string;\\n        v1: string;\\n        v2: string;\\n        v3: string;\\n        v4: string;\\n        v5: string;\\n        v6: string;\\n        v7: string;\\n        v8: string;\\n    };\\n    namespace $ {\\n        type flat = {};\\n    }\\n}\\ndeclare const string: Module<{\\n    integer: Submodule<stringInteger.submodule>;\\n    trim: Submodule<trim.submodule>;\\n    normalize: Submodule<{\\n        root: unknown;\\n        NFC: Submodule<{\\n            root: unknown;\\n            preformatted: unknown;\\n        }>;\\n        NFD: Submodule<{\\n            root: unknown;\\n            preformatted: unknown;\\n        }>;\\n        NFKC: Submodule<{\\n            root: unknown;\\n            preformatted: unknown;\\n        }>;\\n        NFKD: Submodule<{\\n            root: unknown;\\n            preformatted: unknown;\\n        }>;\\n    }>;\\n    date: Submodule<stringDate.submodule>;\\n    root: unknown;\\n    email: unknown;\\n    uuid: Submodule<{\\n        root: string;\\n        v1: unknown;\\n        v2: unknown;\\n        v3: unknown;\\n        v4: unknown;\\n        v5: unknown;\\n        v6: unknown;\\n        v7: unknown;\\n        v8: unknown;\\n    }>;\\n    regex: unknown;\\n    json: Submodule<stringJson.submodule>;\\n    lower: Submodule<lower.submodule>;\\n    upper: Submodule<upper.submodule>;\\n    alpha: unknown;\\n    alphanumeric: unknown;\\n    hex: unknown;\\n    base64: Submodule<{\\n        root: unknown;\\n        url: unknown;\\n    }>;\\n    capitalize: Submodule<capitalize.submodule>;\\n    creditCard: unknown;\\n    digits: unknown;\\n    ip: Submodule<ip.submodule>;\\n    numeric: Submodule<stringNumeric.submodule>;\\n    semver: unknown;\\n    url: Submodule<url.submodule>;\\n}>;\\ndeclare namespace string {\\n    type module = Module<string.submodule>;\\n    type submodule = Submodule<$>;\\n    type $ = {\\n        root: string;\\n        alpha: string;\\n        alphanumeric: string;\\n        hex: string;\\n        base64: base64.submodule;\\n        capitalize: capitalize.submodule;\\n        creditCard: string;\\n        date: stringDate.submodule;\\n        digits: string;\\n        email: string;\\n        integer: stringInteger.submodule;\\n        ip: ip.submodule;\\n        json: stringJson.submodule;\\n        lower: lower.submodule;\\n        normalize: normalize.submodule;\\n        numeric: stringNumeric.submodule;\\n        regex: string;\\n        semver: string;\\n        trim: trim.submodule;\\n        upper: upper.submodule;\\n        url: url.submodule;\\n        uuid: uuid.submodule;\\n    };\\n}\\n\\ndeclare const arkTsKeywords: arkTsKeywords;\\ntype arkTsKeywords = Module<arkTsKeywords.$>;\\ndeclare namespace arkTsKeywords {\\n    type submodule = Submodule<$>;\\n    type $ = {\\n        bigint: bigint;\\n        boolean: boolean;\\n        false: false;\\n        never: never;\\n        null: null;\\n        number: number;\\n        object: object;\\n        string: string;\\n        symbol: symbol;\\n        true: true;\\n        unknown: unknown;\\n        undefined: undefined;\\n    };\\n}\\ndeclare const unknown: Module<{\\n    any: unknown;\\n    root: unknown;\\n}>;\\ndeclare namespace unknown {\\n    type submodule = Submodule<$>;\\n    type $ = {\\n        root: unknown;\\n        any: any;\\n    };\\n}\\ndeclare const json: Module<{\\n    stringify: unknown;\\n    root: unknown;\\n}>;\\ndeclare namespace json {\\n    type submodule = Submodule<$>;\\n    type $ = {\\n        root: Json;\\n        stringify: (In: Json) => To<string>;\\n    };\\n}\\ndeclare const object: Module<{\\n    root: unknown;\\n    json: Submodule<{\\n        stringify: unknown;\\n        root: unknown;\\n    }>;\\n}>;\\ndeclare namespace object {\\n    type submodule = Submodule<$>;\\n    type $ = {\\n        root: object;\\n        json: json.submodule;\\n    };\\n}\\ndeclare class RecordHkt extends Hkt<[Key, unknown]> {\\n    body: Record<this[0], this[1]>;\\n    description: string;\\n}\\ndeclare const Record: _ark_schema.GenericRoot<readonly [[\\\"K\\\", Key], [\\\"V\\\", unknown]], RecordHkt>;\\ndeclare class PickHkt extends Hkt<[object, Key]> {\\n    body: pick<this[0], this[1] & keyof this[0]>;\\n    description: string;\\n}\\ndeclare const Pick: _ark_schema.GenericRoot<readonly [[\\\"T\\\", object], [\\\"K\\\", Key]], PickHkt>;\\ndeclare class OmitHkt extends Hkt<[object, Key]> {\\n    body: omit<this[0], this[1] & keyof this[0]>;\\n    description: string;\\n}\\ndeclare const Omit: _ark_schema.GenericRoot<readonly [[\\\"T\\\", object], [\\\"K\\\", Key]], OmitHkt>;\\ndeclare class PartialHkt extends Hkt<[object]> {\\n    body: show<Partial<this[0]>>;\\n    description: string;\\n}\\ndeclare const Partial: _ark_schema.GenericRoot<readonly [[\\\"T\\\", object]], PartialHkt>;\\ndeclare class RequiredHkt extends Hkt<[object]> {\\n    body: show<Required$1<this[0]>>;\\n    description: string;\\n}\\ndeclare const Required$1: _ark_schema.GenericRoot<readonly [[\\\"T\\\", object]], RequiredHkt>;\\ndeclare class ExcludeHkt extends Hkt<[unknown, unknown]> {\\n    body: Exclude<this[0], this[1]>;\\n    description: string;\\n}\\ndeclare const Exclude: _ark_schema.GenericRoot<readonly [[\\\"T\\\", unknown], [\\\"U\\\", unknown]], ExcludeHkt>;\\ndeclare class ExtractHkt extends Hkt<[unknown, unknown]> {\\n    body: Extract<this[0], this[1]>;\\n    description: string;\\n}\\ndeclare const Extract: _ark_schema.GenericRoot<readonly [[\\\"T\\\", unknown], [\\\"U\\\", unknown]], ExtractHkt>;\\ndeclare const arkTsGenerics: arkTsGenerics.module;\\ndeclare namespace arkTsGenerics {\\n    type module = Module<arkTsGenerics.$>;\\n    type submodule = Submodule<$>;\\n    type $ = {\\n        Exclude: typeof Exclude.t;\\n        Extract: typeof Extract.t;\\n        Omit: typeof Omit.t;\\n        Partial: typeof Partial.t;\\n        Pick: typeof Pick.t;\\n        Record: typeof Record.t;\\n        Required: typeof Required$1.t;\\n    };\\n}\\n\\ninterface Ark extends Omit<Ark.keywords, keyof Ark.wrapped>, Ark.wrapped {\\n}\\ndeclare namespace Ark {\\n    interface keywords extends arkTsKeywords.$, arkTsGenerics.$, arkPrototypes.keywords, arkBuiltins.$ {\\n    }\\n    interface wrapped extends arkPrototypes.wrapped {\\n        string: string.submodule;\\n        number: number.submodule;\\n        object: object.submodule;\\n        unknown: unknown.submodule;\\n    }\\n    type flat = flatResolutionsOf<Ark>;\\n    interface typeAttachments extends arkTsKeywords.$ {\\n        arrayIndex: arkPrototypes.$[\\\"Array\\\"][\\\"index\\\"];\\n        Key: arkBuiltins.$[\\\"Key\\\"];\\n        Record: arkTsGenerics.$[\\\"Record\\\"];\\n        Date: arkPrototypes.$[\\\"Date\\\"];\\n        Array: arkPrototypes.$[\\\"Array\\\"][\\\"root\\\"];\\n    }\\n    interface boundTypeAttachments<$> extends Omit<BoundModule<typeAttachments, $>, arkKind> {\\n    }\\n}\\ndeclare const ark: Scope<Ark>;\\ndeclare const keywords: Module<Ark>;\\ndeclare const type: TypeParser<{}>;\\ndeclare namespace type {\\n    interface cast<to> {\\n        [inferred]?: to;\\n    }\\n    type errors = ArkErrors;\\n    type validate<def, $ = {}, args = bindThis<def>> = validateDefinition<def, $, args>;\\n    type instantiate<def, $ = {}, args = bindThis<def>> = instantiateType<inferDefinition<def, $, args>, $>;\\n    type infer<def, $ = {}, args = bindThis<def>> = inferDefinition<def, $, args>;\\n    namespace infer {\\n        type In<def, $ = {}, args = {}> = distill.In<inferDefinition<def, $, args>>;\\n        type Out<def, $ = {}, args = {}> = distill.Out<inferDefinition<def, $, args>>;\\n        namespace introspectable {\\n            type Out<def, $ = {}, args = {}> = distill.introspectable.Out<inferDefinition<def, $, args>>;\\n        }\\n    }\\n    type brand<t, id> = t extends InferredMorph<infer i, infer o> ? o[\\\"introspectable\\\"] extends true ? (In: i) => To<Brand<o[\\\"t\\\"], id>> : (In: i) => Out<Brand<o[\\\"t\\\"], id>> : Brand<t, id>;\\n    /** @ts-ignore cast variance */\\n    interface Any<out t = any, $ = any> extends Type$1<t, $> {\\n    }\\n}\\ntype type<t = unknown, $ = {}> = Type<t, $>;\\ndeclare const match: MatchParser<{}>;\\ndeclare const fn: FnParser<{}>;\\ndeclare const generic: GenericParser<{}>;\\ndeclare const define: DefinitionParser<{}>;\\ndeclare const declare: DeclarationParser<{}>;\\n\\ntype ParameterString<params extends string = string> = `<${params}>`;\\ntype extractParams<s extends ParameterString> = s extends ParameterString<infer params> ? params : never;\\ntype validateParameterString<s extends ParameterString, $> = parseGenericParams<extractParams<s>, $> extends infer e extends ErrorMessage ? e : s;\\ntype validateGenericArg<arg, param extends GenericParamAst, $> = type.infer<arg, $> extends param[1] ? unknown : ErrorType<[`Invalid argument for ${param[0]}`, expected: param[1]]>;\\ntype GenericInstantiator<params extends array<GenericParamAst>, def, $, args$> = params[\\\"length\\\"] extends 1 ? {\\n    <const a, r = instantiateGeneric<def, params, [a], $, args$>>(a: type.validate<a, args$> & validateGenericArg<a, params[0], args$>): r extends infer _ ? _ : never;\\n} : params[\\\"length\\\"] extends 2 ? {\\n    <const a, const b, r = instantiateGeneric<def, params, [a, b], $, args$>>(...args: [\\n        type.validate<a, args$> & validateGenericArg<a, params[0], args$>,\\n        type.validate<b, args$> & validateGenericArg<b, params[1], args$>\\n    ]): r extends infer _ ? _ : never;\\n} : params[\\\"length\\\"] extends 3 ? {\\n    <const a, const b, const c, r = instantiateGeneric<def, params, [a, b, c], $, args$>>(...args: [\\n        type.validate<a, args$> & validateGenericArg<a, params[0], args$>,\\n        type.validate<b, args$> & validateGenericArg<b, params[1], args$>,\\n        type.validate<c, args$> & validateGenericArg<c, params[2], args$>\\n    ]): r extends infer _ ? _ : never;\\n} : params[\\\"length\\\"] extends 4 ? {\\n    <const a, const b, const c, const d, r = instantiateGeneric<def, params, [a, b, c, d], $, args$>>(...args: [\\n        type.validate<a, args$> & validateGenericArg<a, params[0], args$>,\\n        type.validate<b, args$> & validateGenericArg<b, params[1], args$>,\\n        type.validate<c, args$> & validateGenericArg<c, params[2], args$>,\\n        type.validate<d, args$> & validateGenericArg<d, params[3], args$>\\n    ]): r extends infer _ ? _ : never;\\n} : params[\\\"length\\\"] extends 5 ? {\\n    <const a, const b, const c, const d, const e, r = instantiateGeneric<def, params, [a, b, c, d, e], $, args$>>(...args: [\\n        type.validate<a, args$> & validateGenericArg<a, params[0], args$>,\\n        type.validate<b, args$> & validateGenericArg<b, params[1], args$>,\\n        type.validate<c, args$> & validateGenericArg<c, params[2], args$>,\\n        type.validate<d, args$> & validateGenericArg<d, params[3], args$>,\\n        type.validate<e, args$> & validateGenericArg<e, params[4], args$>\\n    ]): r extends infer _ ? _ : never;\\n} : params[\\\"length\\\"] extends 6 ? {\\n    <const a, const b, const c, const d, const e, const f, r = instantiateGeneric<def, params, [a, b, c, d, e, f], $, args$>>(...args: [\\n        type.validate<a, args$> & validateGenericArg<a, params[0], args$>,\\n        type.validate<b, args$> & validateGenericArg<b, params[1], args$>,\\n        type.validate<c, args$> & validateGenericArg<c, params[2], args$>,\\n        type.validate<d, args$> & validateGenericArg<d, params[3], args$>,\\n        type.validate<e, args$> & validateGenericArg<e, params[4], args$>,\\n        type.validate<f, args$> & validateGenericArg<f, params[5], args$>\\n    ]): r extends infer _ ? _ : never;\\n} : (error: ErrorMessage<`You may not define more than 6 positional generic parameters`>) => never;\\ntype instantiateGeneric<def, params extends array<GenericParamAst>, args, $, args$> = Type<[\\n    def\\n] extends [Hkt] ? Hkt.apply<def, {\\n    [i in keyof args]: type.infer<args[i], args$>;\\n}> : inferDefinition<def, $, bindGenericArgs<params, args$, args>>, args$>;\\ntype bindGenericArgs<params extends array<GenericParamAst>, $, args> = {\\n    [i in keyof params & `${number}` as params[i][0]]: type.infer<args[i & keyof args], $>;\\n};\\ntype baseGenericResolutions<params extends array<GenericParamAst>, $> = baseGenericConstraints<params> extends infer baseConstraints ? {\\n    [k in keyof baseConstraints]: Type<baseConstraints[k], $>;\\n} : never;\\ntype baseGenericConstraints<params extends array<GenericParamAst>> = {\\n    [i in keyof params & `${number}` as params[i][0]]: params[i][1];\\n};\\ntype GenericConstructor<params extends array<GenericParamAst> = array<GenericParamAst>, bodyDef = unknown, $ = {}, arg$ = {}> = new () => Generic<params, bodyDef, $, arg$>;\\ninterface Generic<params extends array<GenericParamAst> = array<GenericParamAst>, bodyDef = unknown, $ = {}, arg$ = $> extends Callable<GenericInstantiator<params, bodyDef, $, arg$>> {\\n    [arkKind]: \\\"generic\\\";\\n    t: GenericAst<params, bodyDef, $, arg$>;\\n    bodyDef: bodyDef;\\n    params: {\\n        [i in keyof params]: [params[i][0], Type<params[i][1], $>];\\n    };\\n    names: genericParamNames<params>;\\n    constraints: {\\n        [i in keyof params]: Type<params[i][1], $>;\\n    };\\n    $: Scope<$>;\\n    arg$: Scope<arg$>;\\n    internal: GenericRoot;\\n    json: JsonStructure;\\n}\\ndeclare const Generic: GenericConstructor;\\ntype GenericDeclaration<name extends string = string, params extends ParameterString = ParameterString> = `${name}${params}`;\\ntype parseValidGenericParams<def extends ParameterString, $> = conform<parseGenericParams<extractParams<def>, $>, array<GenericParamAst>>;\\ndeclare const emptyGenericParameterMessage = \\\"An empty string is not a valid generic parameter name\\\";\\ntype emptyGenericParameterMessage = typeof emptyGenericParameterMessage;\\ntype parseGenericParams<def extends string, $> = parseNextNameChar<Scanner.skipWhitespace<def>, \\\"\\\", [\\n], $>;\\ntype ParamsTerminator = WhitespaceChar | \\\",\\\";\\ntype parseName<unscanned extends string, result extends array<GenericParamAst>, $> = parseNextNameChar<Scanner.skipWhitespace<unscanned>, \\\"\\\", result, $>;\\ntype parseNextNameChar<unscanned extends string, name extends string, result extends array<GenericParamAst>, $> = unscanned extends `${infer lookahead}${infer nextUnscanned}` ? lookahead extends ParamsTerminator ? name extends \\\"\\\" ? ErrorMessage<emptyGenericParameterMessage> : lookahead extends \\\",\\\" ? parseName<nextUnscanned, [...result, [name, unknown]], $> : lookahead extends WhitespaceChar ? _parseOptionalConstraint<nextUnscanned, name, result, $> : never : parseNextNameChar<nextUnscanned, `${name}${lookahead}`, result, $> : name extends \\\"\\\" ? result : [...result, [name, unknown]];\\ndeclare const extendsToken = \\\"extends \\\";\\ntype extendsToken = typeof extendsToken;\\ndeclare const _parseOptionalConstraint: (scanner: Scanner, name: string, result: GenericParamDef[], ctx: BaseParseContext) => GenericParamDef[];\\ntype _parseOptionalConstraint<unscanned extends string, name extends string, result extends array<GenericParamAst>, $> = Scanner.skipWhitespace<unscanned> extends (`${extendsToken}${infer nextUnscanned}`) ? parseUntilFinalizer<s.initialize<nextUnscanned>, $, {}> extends (infer finalArgState extends StaticState) ? validateAst<finalArgState[\\\"root\\\"], $, {}> extends (infer e extends ErrorMessage) ? e : parseName<finalArgState[\\\"unscanned\\\"], [\\n    ...result,\\n    [name, inferAstRoot<finalArgState[\\\"root\\\"], $, {}>]\\n], $> : never : parseName<Scanner.skipWhitespace<unscanned> extends `,${infer nextUnscanned}` ? nextUnscanned : unscanned, [\\n    ...result,\\n    [name, unknown]\\n], $>;\\ntype genericParamDefToAst<schema extends GenericParamDef, $> = schema extends string ? [schema, unknown] : schema extends readonly [infer name, infer def] ? [name, type.infer<def, $>] : never;\\ntype genericParamDefsToAst<defs extends array<GenericParamDef>, $> = [\\n    ...{\\n        [i in keyof defs]: genericParamDefToAst<defs[i], $>;\\n    }\\n];\\ntype GenericParser<$ = {}> = <const paramsDef extends array<GenericParamDef>>(...params: {\\n    [i in keyof paramsDef]: paramsDef[i] extends (readonly [infer name, infer def]) ? readonly [name, type.validate<def, $>] : paramsDef[i];\\n}) => GenericBodyParser<genericParamDefsToAst<paramsDef, $>, $>;\\ninterface GenericBodyParser<params extends array<GenericParamAst>, $> {\\n    <const body>(body: type.validate<body, $, baseGenericConstraints<params>>): Generic<params, body, $, $>;\\n    <hkt extends Hkt.constructor>(instantiateDef: LazyGenericBody<baseGenericResolutions<params, $>>, hkt: hkt): Generic<params, InstanceType<hkt>, $, $>;\\n}\\n\\ndeclare const Module: new <$ extends {}>(exports: exportScope<$>) => Module<$>;\\ninterface Module<$ extends {} = {}> extends RootModule<exportScope<$>> {\\n}\\ntype exportScope<$> = bindExportsToScope<$, $>;\\ndeclare const BoundModule: new <exports extends {}, $ extends {}>(exports: bindExportsToScope<exports, $>, $: $) => BoundModule<exports, $>;\\ninterface BoundModule<exports extends {}, $> extends RootModule<bindExportsToScope<exports, $>> {\\n}\\ntype bindExportsToScope<exports, $> = {\\n    [k in keyof exports]: instantiateExport<exports[k], $>;\\n} & unknown;\\ntype Submodule<exports extends {}> = RootModule<exports & (\\\"root\\\" extends keyof exports ? {\\n    [inferred]: exports[\\\"root\\\"];\\n} : {})>;\\ntype instantiateExport<t, $> = [\\n    t\\n] extends [PreparsedNodeResolution] ? [\\n    t\\n] extends [anyOrNever] ? Type<t, $> : t extends GenericAst<infer params, infer body, infer body$> ? Generic<params, body, body$, $> : t extends Submodule<infer exports> ? BoundModule<exports, $> : never : Type<t, $>;\\n\\ndeclare class liftFromHkt extends Hkt<[element: unknown]> {\\n    body: liftArray<this[0]> extends infer lifted ? (In: this[0] | lifted) => To<lifted> : never;\\n}\\ndeclare const liftFrom: _ark_schema.GenericRoot<readonly [[\\\"element\\\", unknown]], liftFromHkt>;\\ndeclare const arkArray: arkArray.module;\\ndeclare namespace arkArray {\\n    type module = Module<submodule>;\\n    type submodule = Submodule<$>;\\n    type $ = {\\n        root: unknown[];\\n        readonly: readonly unknown[];\\n        index: NonNegativeIntegerString;\\n        liftFrom: typeof liftFrom.t;\\n    };\\n}\\ntype NonNegativeIntegerString = `${Digit}` | (`${Exclude<Digit, 0>}${string}` & `${bigint}`);\\n\\ntype FormDataValue = string | File;\\ntype ParsedFormData = Record<string, FormDataValue | FormDataValue[]>;\\ndeclare const arkFormData: arkFormData.module;\\ndeclare namespace arkFormData {\\n    type module = Module<submodule>;\\n    type submodule = Submodule<$>;\\n    type $ = {\\n        root: FormData;\\n        value: FormDataValue;\\n        parse: (In: FormData) => To<ParsedFormData>;\\n        parsed: ParsedFormData;\\n    };\\n}\\n\\ndeclare const TypedArray: TypedArray.module;\\ndeclare namespace TypedArray {\\n    type module = Module<TypedArray.$>;\\n    type submodule = Submodule<$>;\\n    type $ = {\\n        Int8: Int8Array;\\n        Uint8: Uint8Array;\\n        Uint8Clamped: Uint8ClampedArray;\\n        Int16: Int16Array;\\n        Uint16: Uint16Array;\\n        Int32: Int32Array;\\n        Uint32: Uint32Array;\\n        Float32: Float32Array;\\n        Float64: Float64Array;\\n        BigInt64: BigInt64Array;\\n        BigUint64: BigUint64Array;\\n    };\\n}\\n\\ndeclare const omittedPrototypes: {\\n    Boolean: 1;\\n    Number: 1;\\n    String: 1;\\n};\\ndeclare const arkPrototypes: arkPrototypes.module;\\ndeclare namespace arkPrototypes {\\n    type module = Module<submodule>;\\n    type submodule = Submodule<$>;\\n    interface keywords extends ecmascript, platform {\\n    }\\n    interface $ extends Omit<keywords, keyof wrapped>, wrapped {\\n    }\\n    interface wrapped {\\n        Array: arkArray.submodule;\\n        TypedArray: TypedArray.submodule;\\n        FormData: arkFormData.submodule;\\n    }\\n    type ecmascript = Omit<EcmascriptObjects, keyof typeof omittedPrototypes>;\\n    type platform = PlatformObjects;\\n    interface instances extends ecmascript, platform {\\n    }\\n    type NonDegenerateName = keyof instances extends infer k ? k extends keyof instances ? {} extends instances[k] ? never : k : never : never;\\n    type instanceOf<name extends NonDegenerateName = NonDegenerateName> = instances[name];\\n}\\n\\ntype DateLiteral<source extends string = string> = `d\\\"${source}\\\"` | `d'${source}'`;\\ntype LimitLiteral = number | DateLiteral;\\ntype distill<t, side extends distill.Side> = finalizeDistillation<t, _distill<t, side>>;\\ndeclare namespace distill {\\n    type Side = \\\"in\\\" | \\\"out\\\" | \\\"introspectableOut\\\";\\n    type In<t> = distill<t, \\\"in\\\">;\\n    type Out<t> = distill<t, \\\"out\\\">;\\n    namespace introspectable {\\n        type Out<t> = distill<t, \\\"introspectableOut\\\">;\\n    }\\n}\\ntype finalizeDistillation<t, distilled> = equals<t, distilled> extends true ? t : distilled;\\ntype _distill<t, side extends distill.Side> = t extends undefined ? t : [t] extends [anyOrNever] ? t : unknown extends t ? unknown : t extends Brand<infer base> ? side extends \\\"in\\\" ? base : t : t extends TerminallyInferredObject | Primitive ? t : t extends Function ? t extends (...args: never) => anyOrNever ? t : t extends InferredMorph<infer i, infer o> ? distillIo<i, o, side> : t : t extends Default<infer constraint> ? _distill<constraint, side> : t extends array ? distillArray<t, side> : isSafelyMappable<t> extends true ? distillMappable<t, side> : t;\\ntype distillMappable<o, side extends distill.Side> = side extends \\\"in\\\" ? show<{\\n    [k in keyof o as k extends inferredDefaultKeyOf<o> ? never : k]: _distill<o[k], side>;\\n} & {\\n    [k in inferredDefaultKeyOf<o>]?: _distill<o[k], side>;\\n}> : {\\n    [k in keyof o]: _distill<o[k], side>;\\n};\\ntype distillIo<i, o extends Out, side extends distill.Side> = side extends \\\"out\\\" ? _distill<o[\\\"t\\\"], side> : side extends \\\"in\\\" ? _distill<i, side> : o extends To<infer validatedOut> ? _distill<validatedOut, side> : unknown;\\ntype unwrapInput<t> = t extends InferredMorph<infer i> ? t extends anyOrNever ? t : i : t;\\ntype inferredDefaultKeyOf<o> = keyof o extends infer k ? k extends keyof o ? unwrapInput<o[k]> extends Default<infer t> ? [\\n    t\\n] extends [anyOrNever] ? never : k : never : never : never;\\ntype distillArray<t extends array, side extends distill.Side> = t[number][] extends t ? alignReadonly<_distill<t[number], side>[], t> : distillNonArraykeys<t, alignReadonly<distillArrayFromPrefix<[...t], side, []>, t>, side>;\\ntype alignReadonly<result extends unknown[], original extends array> = original extends unknown[] ? result : Readonly<result>;\\ntype distillNonArraykeys<originalArray extends array, distilledArray, side extends distill.Side> = keyof originalArray extends keyof distilledArray ? distilledArray : distilledArray & _distill<{\\n    [k in keyof originalArray as k extends keyof distilledArray ? never : k]: originalArray[k];\\n}, side>;\\ntype distillArrayFromPrefix<t extends array, side extends distill.Side, prefix extends array> = t extends readonly [infer head, ...infer tail] ? distillArrayFromPrefix<tail, side, [\\n    side,\\n    head\\n] extends [\\\"in\\\", Default] ? [...prefix, _distill<head, side>?] : [...prefix, _distill<head, side>]> : [...prefix, ...distillArrayFromPostfix<t, side, []>];\\ntype distillArrayFromPostfix<t extends array, side extends distill.Side, postfix extends array> = t extends readonly [...infer init, infer last] ? distillArrayFromPostfix<init, side, [_distill<last, side>, ...postfix]> : [...{\\n    [i in keyof t]: _distill<t[i], side>;\\n}, ...postfix];\\ntype BuiltinTerminalObjectKind = Exclude<arkPrototypes.NonDegenerateName, \\\"Array\\\" | \\\"Function\\\">;\\n/** Objects we don't want to expand during inference like Date or Promise */\\ntype TerminallyInferredObject = arkPrototypes.instanceOf<BuiltinTerminalObjectKind> | ArkEnv.prototypes;\\ntype inferPredicate<t, predicate> = predicate extends (data: any, ...args: any[]) => data is infer narrowed ? narrowed : t;\\ntype inferNaryPipe<morphs extends readonly Morph[]> = _inferNaryPipe<morphs, unknown>;\\ntype _inferNaryPipe<remaining extends readonly unknown[], result> = remaining extends (readonly [infer head extends Morph, ...infer tail extends Morph[]]) ? _inferNaryPipe<tail, inferMorph<result, head>> : result;\\ntype inferNaryIntersection<types extends readonly unknown[]> = number extends types[\\\"length\\\"] ? _inferNaryIntersection<unionToTuple<types[number]>, unknown> : _inferNaryIntersection<types, unknown>;\\ntype _inferNaryIntersection<remaining extends readonly unknown[], result> = remaining extends readonly [infer head, ...infer tail] ? _inferNaryIntersection<tail, inferIntersection<result, head>> : result;\\ntype inferNaryMerge<types extends readonly unknown[]> = number extends types[\\\"length\\\"] ? _inferUnorderedMerge<types> : _inferNaryMerge<types, {}>;\\ntype _inferUnorderedMerge<types extends readonly unknown[], optionalKey extends PropertyKey = optionalAtLeastOnceUnionKeyOf<types[number]>, requiredKey extends PropertyKey = Exclude<unionKeyOf<types[number]>, optionalKey>> = show<{\\n    [k in requiredKey]: types[number] extends infer v ? v extends unknown ? k extends keyof v ? v[k] : never : never : never;\\n} & {\\n    [k in optionalKey]?: types[number] extends infer v ? v extends unknown ? k extends keyof v ? v[k] : never : never : never;\\n}>;\\n/** Coalesce keys that exist and are optional on one or more branches of a union */\\ntype optionalAtLeastOnceUnionKeyOf<t> = t extends unknown ? optionalKeyOf<t> : never;\\ntype _inferNaryMerge<remaining extends readonly unknown[], result> = remaining extends (readonly [infer head, ...infer tail extends readonly unknown[]]) ? _inferNaryMerge<tail, merge<result, head>> : result;\\ntype inferMorphOut<morph extends Morph> = Exclude<ReturnType<morph>, ArkError | ArkErrors>;\\ndeclare const isMorphOutKey: \\\" isMorphOut\\\";\\ninterface Out<o = any> {\\n    [isMorphOutKey]: true;\\n    t: o;\\n    introspectable: boolean;\\n}\\ninterface To<o = any> extends Out<o> {\\n    introspectable: true;\\n}\\ntype InferredMorph<i = never, o extends Out = Out> = (In: i) => o;\\ndeclare const defaultsToKey: \\\" defaultsTo\\\";\\ntype Default<t = unknown, v = unknown> = {\\n    [defaultsToKey]: [t, v];\\n};\\ntype withDefault<t, v, undistributed = t> = t extends InferredMorph ? addDefaultToMorph<t, v> : Default<Exclude<undistributed, InferredMorph>, v>;\\ntype addDefaultToMorph<t extends InferredMorph, v> = [\\n    normalizeMorphDistribution<t>\\n] extends [InferredMorph<infer i, infer o>] ? (In: Default<i, v>) => o : never;\\ntype normalizeMorphDistribution<t, undistributedIn = t extends InferredMorph<infer i> ? i : never, undistributedOut extends Out = t extends InferredMorph<never, infer o> ? [\\n    o\\n] extends [To<infer unwrappedOut>] ? To<unwrappedOut> : o : never> = (Extract<t, InferredMorph> extends anyOrNever ? never : Extract<t, InferredMorph> extends InferredMorph<infer i, infer o> ? [\\n    undistributedOut\\n] extends [o] ? (In: undistributedIn) => undistributedOut : [undistributedIn] extends [i] ? (In: undistributedIn) => undistributedOut : t : never) | Exclude<t, InferredMorph> extends infer _ ? _ : never;\\ntype defaultFor<t = unknown> = (Primitive extends t ? Primitive : t extends Primitive ? t : never) | (() => t);\\ntype inferIntersection<l, r> = normalizeMorphDistribution<_inferIntersection<l, r, false>>;\\ntype inferMorph<t, morph extends Morph> = morph extends type.cast<infer tMorph> ? inferPipe<t, tMorph> : inferMorphOut<morph> extends infer out ? (In: distill.In<t>) => Out<out> : never;\\ntype inferPipe<l, r> = normalizeMorphDistribution<_inferIntersection<l, r, true>>;\\ntype _inferIntersection<l, r, piped extends boolean> = [\\n    l & r\\n] extends [infer t extends anyOrNever] ? t : l extends InferredMorph<infer lIn, infer lOut> ? r extends InferredMorph<never, infer rOut> ? piped extends true ? (In: lIn) => rOut : never : piped extends true ? (In: lIn) => To<r> : (In: _inferIntersection<lIn, r, false>) => lOut : r extends InferredMorph<infer rIn, infer rOut> ? (In: _inferIntersection<rIn, l, false>) => rOut : [l, r] extends [object, object] ? intersectObjects<l, r, piped> extends infer result ? result : never : l & r;\\ninterface MorphableIntersection<piped extends boolean> extends Hkt<[unknown, unknown]> {\\n    body: _inferIntersection<this[0], this[1], piped>;\\n}\\ntype intersectObjects<l, r, piped extends boolean> = l extends array ? r extends array ? intersectArrays<l, r, MorphableIntersection<piped>> : // for an intersection with exactly one array operand like { name: string } & string[],\\nl & r : r extends array ? l & r : keyof l & keyof r extends never ? show<l & r> : show<{\\n    [k in keyof l]: k extends keyof r ? _inferIntersection<l[k], r[k], piped> : l[k];\\n} & {\\n    [k in keyof r]: k extends keyof l ? _inferIntersection<l[k], r[k], piped> : r[k];\\n}>;\\n\\nexport { Ark, ArkAmbient, type ArkConfig, type Type$1 as BaseType, BoundModule, Generic, type KeywordConfig, Module, type Out, Scope, type Submodule, Type, ark, type bindThis, configure, declare, define, distill, fn, generic, type inferDefinition, keywords, match, scope, type, type validateDefinition };\\n\\n}\"\n"
  },
  {
    "path": "ark/docs/components/dts/util.ts",
    "content": "/** THIS FILE IS AUTOGENERATED FROM ark/repo/dtsGen.ts **/\n// prettier-ignore\nexport const utilDts = \"declare module \\\"@ark/util\\\" {\\n    import * as buffer from 'buffer';\\n\\ntype Fn<args extends readonly any[] = readonly any[], returns = unknown> = (...args: args) => returns;\\ndeclare const cached: <t>(thunk: () => t) => (() => t);\\ndeclare const isThunk: <value>(value: value) => value is Extract<value, Thunk> extends never ? value & Thunk : Extract<value, Thunk>;\\ntype Thunk<ret = unknown> = () => ret;\\ntype thunkable<t> = t | Thunk<t>;\\ndeclare const tryCatch: <returns, onError = never>(fn: () => returns, onError?: (e: unknown) => onError) => returns | onError;\\ndeclare const DynamicFunction: DynamicFunction;\\ntype DynamicFunction = new <fn extends Fn>(...args: ConstructorParameters<typeof Function>) => fn & {\\n    apply(thisArg: null, args: Parameters<fn>): ReturnType<fn>;\\n    call(thisArg: null, ...args: Parameters<fn>): ReturnType<fn>;\\n};\\ntype CallableOptions<attachments extends object> = {\\n    attach?: attachments;\\n    bind?: object;\\n};\\n/** @ts-ignore required to cast function type */\\ninterface Callable<fn extends Fn, attachments extends object> extends fn, attachments {\\n}\\ndeclare class Callable<fn extends Fn, attachments extends object = {}> {\\n    constructor(fn: fn, ...[opts]: {} extends attachments ? [opts?: CallableOptions<attachments>] : [opts: CallableOptions<attachments>]);\\n}\\ntype GuardablePredicate<input = unknown, narrowed extends input = input> = ((In: input) => In is narrowed) | ((In: input) => boolean);\\ntype TypeGuard<input = unknown, narrowed extends input = input> = (In: input) => In is narrowed;\\n/**\\n * Checks if the environment has Content Security Policy (CSP) enabled,\\n * preventing JIT-optimized code from being compiled via new Function().\\n *\\n * @returns `true` if a function created using new Function() can be\\n * successfully invoked in the environment, `false` otherwise.\\n *\\n * The result is cached for subsequent invocations.\\n */\\ndeclare const envHasCsp: () => boolean;\\n\\ndeclare const ecmascriptConstructors: {\\n    Array: ArrayConstructor;\\n    Boolean: BooleanConstructor;\\n    Date: DateConstructor;\\n    Error: ErrorConstructor;\\n    Function: FunctionConstructor;\\n    Map: MapConstructor;\\n    Number: NumberConstructor;\\n    Promise: PromiseConstructor;\\n    RegExp: RegExpConstructor;\\n    Set: SetConstructor;\\n    String: StringConstructor;\\n    WeakMap: WeakMapConstructor;\\n    WeakSet: WeakSetConstructor;\\n};\\ntype ecmascriptConstructors = typeof ecmascriptConstructors;\\ntype EcmascriptObjects = satisfy<instantiateConstructors<keyof ecmascriptConstructors>, {\\n    Array: Array<unknown>;\\n    Boolean: Boolean;\\n    Date: Date;\\n    Error: Error;\\n    Function: Function;\\n    Map: Map<unknown, unknown>;\\n    Number: Number;\\n    RegExp: RegExp;\\n    Set: Set<unknown>;\\n    String: String;\\n    WeakMap: WeakMap<object, unknown>;\\n    WeakSet: WeakSet<object>;\\n    Promise: Promise<unknown>;\\n}>;\\n/** Node18 */\\ndeclare const FileConstructor: typeof buffer.File;\\ntype platformConstructors = {\\n    ArrayBuffer: ArrayBufferConstructor;\\n    Blob: typeof Blob;\\n    File: typeof File;\\n    FormData: typeof FormData;\\n    Headers: typeof Headers;\\n    Request: typeof Request;\\n    Response: typeof Response;\\n    URL: typeof URL;\\n};\\ndeclare const platformConstructors: platformConstructors;\\ntype PlatformObjects = instantiateConstructors<keyof platformConstructors>;\\ndeclare const typedArrayConstructors: {\\n    Int8Array: Int8ArrayConstructor;\\n    Uint8Array: Uint8ArrayConstructor;\\n    Uint8ClampedArray: Uint8ClampedArrayConstructor;\\n    Int16Array: Int16ArrayConstructor;\\n    Uint16Array: Uint16ArrayConstructor;\\n    Int32Array: Int32ArrayConstructor;\\n    Uint32Array: Uint32ArrayConstructor;\\n    Float32Array: Float32ArrayConstructor;\\n    Float64Array: Float64ArrayConstructor;\\n    BigInt64Array: BigInt64ArrayConstructor;\\n    BigUint64Array: BigUint64ArrayConstructor;\\n};\\ntype typedArrayConstructors = typeof typedArrayConstructors;\\ntype TypedArrayObjects = instantiateConstructors<keyof typedArrayConstructors>;\\ndeclare const builtinConstructors: {\\n    String: StringConstructor;\\n    Number: NumberConstructor;\\n    Boolean: BooleanConstructor;\\n    Int8Array: Int8ArrayConstructor;\\n    Uint8Array: Uint8ArrayConstructor;\\n    Uint8ClampedArray: Uint8ClampedArrayConstructor;\\n    Int16Array: Int16ArrayConstructor;\\n    Uint16Array: Uint16ArrayConstructor;\\n    Int32Array: Int32ArrayConstructor;\\n    Uint32Array: Uint32ArrayConstructor;\\n    Float32Array: Float32ArrayConstructor;\\n    Float64Array: Float64ArrayConstructor;\\n    BigInt64Array: BigInt64ArrayConstructor;\\n    BigUint64Array: BigUint64ArrayConstructor;\\n    ArrayBuffer: ArrayBufferConstructor;\\n    Blob: typeof Blob;\\n    File: typeof File;\\n    FormData: typeof FormData;\\n    Headers: typeof Headers;\\n    Request: typeof Request;\\n    Response: typeof Response;\\n    URL: typeof URL;\\n    Array: ArrayConstructor;\\n    Date: DateConstructor;\\n    Error: ErrorConstructor;\\n    Function: FunctionConstructor;\\n    Map: MapConstructor;\\n    Promise: PromiseConstructor;\\n    RegExp: RegExpConstructor;\\n    Set: SetConstructor;\\n    WeakMap: WeakMapConstructor;\\n    WeakSet: WeakSetConstructor;\\n};\\ntype builtinConstructors = typeof builtinConstructors;\\ntype BuiltinObjectKind = keyof builtinConstructors;\\ntype GlobalName = keyof typeof globalThis;\\ntype instantiateConstructors<kind extends BuiltinObjectKind> = {\\n    [k in kind]: k extends GlobalName ? InstanceType<(typeof globalThis)[k]> : `${k}Constructor` extends GlobalName ? InstanceType<(typeof globalThis)[`${k}Constructor`]> : never;\\n};\\ntype BuiltinObjects = instantiateConstructors<BuiltinObjectKind>;\\ntype describeObject<o extends object, opts extends DescribeOptions = {}> = objectKindOf<o> extends string ? [\\n    opts[\\\"includeArticles\\\"]\\n] extends [true] ? objectKindDescriptions[objectKindOf<o>] : objectKindOf<o> : [opts[\\\"includeArticles\\\"]] extends [true] ? domainDescriptions[\\\"object\\\"] : \\\"object\\\";\\ntype instantiableObjectKind<data extends object> = {\\n    [kind in keyof builtinConstructors]: data extends (InstanceType<builtinConstructors[kind]>) ? kind : never;\\n}[keyof builtinConstructors];\\ntype objectKindOf<data extends object> = object extends data ? keyof builtinConstructors | undefined : data extends Fn ? \\\"Function\\\" : instantiableObjectKind<data> extends never ? undefined : instantiableObjectKind<data>;\\ndeclare const objectKindOf: <data extends object>(data: data) => objectKindOf<data> | undefined;\\ndeclare const objectKindOrDomainOf: <data>(data: data) => (objectKindOf<data & object> & {}) | domainOf<data>;\\ntype objectKindOrDomainOf<data> = data extends object ? objectKindOf<data> extends undefined ? \\\"object\\\" : objectKindOf<data> : domainOf<data>;\\ndeclare const hasObjectKind: <kind extends keyof builtinConstructors>(data: object, kind: kind) => data is InstanceType<builtinConstructors[kind]>;\\ndeclare const isArray: (data: unknown) => data is readonly unknown[];\\ndeclare const ecmascriptDescriptions: {\\n    readonly Array: \\\"an array\\\";\\n    readonly Function: \\\"a function\\\";\\n    readonly Date: \\\"a Date\\\";\\n    readonly RegExp: \\\"a RegExp\\\";\\n    readonly Error: \\\"an Error\\\";\\n    readonly Map: \\\"a Map\\\";\\n    readonly Set: \\\"a Set\\\";\\n    readonly String: \\\"a String object\\\";\\n    readonly Number: \\\"a Number object\\\";\\n    readonly Boolean: \\\"a Boolean object\\\";\\n    readonly Promise: \\\"a Promise\\\";\\n    readonly WeakMap: \\\"a WeakMap\\\";\\n    readonly WeakSet: \\\"a WeakSet\\\";\\n};\\ndeclare const platformDescriptions: {\\n    ArrayBuffer: string;\\n    Blob: string;\\n    File: string;\\n    FormData: string;\\n    Headers: string;\\n    Request: string;\\n    Response: string;\\n    URL: string;\\n};\\ndeclare const typedArrayDescriptions: {\\n    readonly Int8Array: \\\"an Int8Array\\\";\\n    readonly Uint8Array: \\\"a Uint8Array\\\";\\n    readonly Uint8ClampedArray: \\\"a Uint8ClampedArray\\\";\\n    readonly Int16Array: \\\"an Int16Array\\\";\\n    readonly Uint16Array: \\\"a Uint16Array\\\";\\n    readonly Int32Array: \\\"an Int32Array\\\";\\n    readonly Uint32Array: \\\"a Uint32Array\\\";\\n    readonly Float32Array: \\\"a Float32Array\\\";\\n    readonly Float64Array: \\\"a Float64Array\\\";\\n    readonly BigInt64Array: \\\"a BigInt64Array\\\";\\n    readonly BigUint64Array: \\\"a BigUint64Array\\\";\\n};\\n/** Each defaultObjectKind's completion for the phrase \\\"must be _____\\\" */\\ndeclare const objectKindDescriptions: {\\n    readonly Int8Array: \\\"an Int8Array\\\";\\n    readonly Uint8Array: \\\"a Uint8Array\\\";\\n    readonly Uint8ClampedArray: \\\"a Uint8ClampedArray\\\";\\n    readonly Int16Array: \\\"an Int16Array\\\";\\n    readonly Uint16Array: \\\"a Uint16Array\\\";\\n    readonly Int32Array: \\\"an Int32Array\\\";\\n    readonly Uint32Array: \\\"a Uint32Array\\\";\\n    readonly Float32Array: \\\"a Float32Array\\\";\\n    readonly Float64Array: \\\"a Float64Array\\\";\\n    readonly BigInt64Array: \\\"a BigInt64Array\\\";\\n    readonly BigUint64Array: \\\"a BigUint64Array\\\";\\n    readonly ArrayBuffer: string;\\n    readonly Blob: string;\\n    readonly File: string;\\n    readonly FormData: string;\\n    readonly Headers: string;\\n    readonly Request: string;\\n    readonly Response: string;\\n    readonly URL: string;\\n    readonly Array: \\\"an array\\\";\\n    readonly Function: \\\"a function\\\";\\n    readonly Date: \\\"a Date\\\";\\n    readonly RegExp: \\\"a RegExp\\\";\\n    readonly Error: \\\"an Error\\\";\\n    readonly Map: \\\"a Map\\\";\\n    readonly Set: \\\"a Set\\\";\\n    readonly String: \\\"a String object\\\";\\n    readonly Number: \\\"a Number object\\\";\\n    readonly Boolean: \\\"a Boolean object\\\";\\n    readonly Promise: \\\"a Promise\\\";\\n    readonly WeakMap: \\\"a WeakMap\\\";\\n    readonly WeakSet: \\\"a WeakSet\\\";\\n};\\ntype objectKindDescriptions = typeof objectKindDescriptions;\\n/**\\n * this will only return an object kind if it's the root constructor\\n * example TypeError would return null not 'Error'\\n **/\\ndeclare const getBuiltinNameOfConstructor: (ctor: Function) => BuiltinObjectKind | null;\\ntype Constructor<instance = {}> = abstract new (...args: never[]) => instance;\\ntype instanceOf<constructor> = constructor extends Constructor<infer instance> ? instance : never;\\n/**\\n * Returns an array of constructors for all ancestors (i.e., prototypes) of a given object.\\n */\\ndeclare const ancestorsOf: (o: object) => Function[];\\ntype normalizedKeyOf<t> = keyof t extends infer k ? k extends number ? `${k}` : k : never;\\ndeclare const constructorExtends: (ctor: Constructor, base: Constructor) => boolean;\\n\\ntype stringifyUnion<t extends string, delimiter extends string = \\\", \\\"> = join<unionToTuple<t>, delimiter>;\\ntype unionToTuple<t> = _unionToTuple<t, []> extends infer result ? conform<result, t[]> : never;\\ntype _unionToTuple<t, result extends unknown[]> = getLastBranch<t> extends infer current ? [\\n    t\\n] extends [never] ? result : _unionToTuple<Exclude<t, current>, [current, ...result]> : never;\\ntype getLastBranch<t> = intersectUnion<t extends unknown ? (x: t) => void : never> extends ((x: infer branch) => void) ? branch : never;\\ntype intersectUnion<t> = (t extends unknown ? (_: t) => void : never) extends ((_: infer intersection) => void) ? intersection : never;\\ntype intersectOverloadReturns<fn extends Fn> = intersectUnion<ReturnType<overloadOf<fn>>>;\\ntype overloadOf<fn extends Fn, givenArgs extends array = array> = Exclude<collectSignatures<(() => never) & fn, givenArgs, unknown>, fn extends () => never ? never : () => never>;\\ntype collectSignatures<fn, givenArgs extends array, result> = result & fn extends (...args: infer args) => infer returns ? result extends fn ? never : collectSignatures<fn, givenArgs, Pick<fn, keyof fn> & result & ((...args: args) => returns)> | (args extends givenArgs ? (...args: args) => returns : never) : never;\\n\\ntype DescribeOptions = {\\n    includeArticles?: boolean;\\n    branchDelimiter?: string;\\n};\\ntype typeToString<t, opts extends DescribeOptions = {}> = stringifyUnion<[\\n    t\\n] extends [anyOrNever] ? unknown extends t ? \\\"any\\\" : \\\"never\\\" : unknown extends t ? \\\"unknown\\\" : boolean extends t ? \\\"boolean\\\" | ([t] extends [boolean] ? never : typeToString<Exclude<t, boolean>, opts>) : t extends array ? arrayTypeToString<t, opts> : t extends object ? describeObject<t, opts> : t extends Stringifiable ? stringifiableToString<t, opts> : describeDomainOf<t, opts>, opts[\\\"branchDelimiter\\\"] extends string ? opts[\\\"branchDelimiter\\\"] : describeDefaults[\\\"branchDelimiter\\\"]>;\\ntype stringifiableToString<t extends Stringifiable, opts extends DescribeOptions> = inferDomain<domainOf<t>> extends t ? describeDomainOf<t, opts> : `${t}`;\\ntype describe<t> = typeToString<t, {\\n    includeArticles: true;\\n    branchDelimiter: \\\" or \\\";\\n}>;\\ntype arrayTypeToString<t extends array, opts extends DescribeOptions> = typeToString<t[number], opts> extends infer element extends string ? opts[\\\"includeArticles\\\"] extends true ? describeArrayOf<element> : includesDelimiter<element, opts> extends true ? `(${element})[]` : `${element}[]` : never;\\ntype describeArrayOf<element extends string> = element extends \\\"unknown\\\" ? \\\"an array\\\" : `an array of ${element}`;\\ntype includesDelimiter<s extends string, opts extends DescribeOptions> = s extends (`${string}${opts[\\\"branchDelimiter\\\"] extends string ? opts[\\\"branchDelimiter\\\"] : describeDefaults[\\\"branchDelimiter\\\"]}${string}`) ? true : false;\\ntype describeDefaults = satisfy<Required<DescribeOptions>, {\\n    includeArticles: false;\\n    branchDelimiter: \\\" | \\\";\\n}>;\\n\\ntype JsTypeOf = \\\"object\\\" | \\\"function\\\" | \\\"number\\\" | \\\"bigint\\\" | \\\"boolean\\\" | \\\"string\\\" | \\\"symbol\\\" | \\\"undefined\\\" | \\\"null\\\";\\ndeclare const hasDomain: <data, domain extends Domain>(data: data, kind: domain) => data is data & inferDomain<domain>;\\ntype TypesByDomain = {\\n    bigint: bigint;\\n    boolean: boolean;\\n    number: number;\\n    object: object;\\n    string: string;\\n    symbol: symbol;\\n    undefined: undefined;\\n    null: null;\\n};\\ntype inferDomain<kind extends Domain> = Domain extends kind ? unknown : TypesByDomain[kind];\\ntype Domain = show<keyof TypesByDomain>;\\ntype NullishDomain = \\\"undefined\\\" | \\\"null\\\";\\ntype NonNullishDomain = Exclude<Domain, NullishDomain>;\\ntype PrimitiveDomain = Exclude<Domain, \\\"object\\\">;\\ntype Primitive = inferDomain<PrimitiveDomain>;\\ntype domainOf<data> = unknown extends data ? Domain : data extends object ? \\\"object\\\" : data extends string ? \\\"string\\\" : data extends number ? \\\"number\\\" : data extends boolean ? \\\"boolean\\\" : data extends undefined ? \\\"undefined\\\" : data extends null ? \\\"null\\\" : data extends bigint ? \\\"bigint\\\" : data extends symbol ? \\\"symbol\\\" : never;\\ndeclare const domainOf: <data>(data: data) => domainOf<data>;\\ndeclare const jsTypeOfDescriptions: {\\n    readonly function: \\\"a function\\\";\\n    readonly boolean: \\\"boolean\\\";\\n    readonly null: \\\"null\\\";\\n    readonly undefined: \\\"undefined\\\";\\n    readonly bigint: \\\"a bigint\\\";\\n    readonly number: \\\"a number\\\";\\n    readonly object: \\\"an object\\\";\\n    readonly string: \\\"a string\\\";\\n    readonly symbol: \\\"a symbol\\\";\\n};\\n/** Each domain's completion for the phrase \\\"must be _____\\\" */\\ndeclare const domainDescriptions: {\\n    readonly boolean: \\\"boolean\\\";\\n    readonly null: \\\"null\\\";\\n    readonly undefined: \\\"undefined\\\";\\n    readonly bigint: \\\"a bigint\\\";\\n    readonly number: \\\"a number\\\";\\n    readonly object: \\\"an object\\\";\\n    readonly string: \\\"a string\\\";\\n    readonly symbol: \\\"a symbol\\\";\\n};\\ntype domainDescriptions = typeof domainDescriptions;\\ntype describeDomainOf<t, opts extends DescribeOptions = {}> = stringifyUnion<opts[\\\"includeArticles\\\"] extends true ? domainDescriptions[domainOf<t>] : domainOf<t>, opts[\\\"branchDelimiter\\\"] extends string ? opts[\\\"branchDelimiter\\\"] : describeDefaults[\\\"branchDelimiter\\\"]>;\\n\\ntype Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;\\ntype NumberLiteral<n extends number = number> = `${n}`;\\ntype BigintLiteral<n extends bigint = bigint> = `${n}n`;\\ntype IntegerLiteral<n extends bigint = bigint> = `${n}`;\\ntype NonNegativeIntegerLiteral<n extends bigint = bigint> = `${Digit}` | (`${Exclude<Digit, 0>}${string}` & `${n}`);\\n/**\\n *  Matches a well-formatted numeric expression according to the following rules:\\n *    1. Must include an integer portion (i.e. '.321' must be written as '0.321')\\n *    2. The first digit of the value must not be 0, unless the entire integer portion is 0\\n *    3. If the value includes a decimal, its last digit may not be 0\\n *    4. The value may not be \\\"-0\\\"\\n */\\ndeclare const wellFormedNumberMatcher: RegExp;\\ndeclare const isWellFormedNumber: RegExp[\\\"test\\\"];\\n/**\\n * Similar to wellFormedNumber but more permissive in the following ways:\\n *\\n *  - Allows numbers without an integer portion like \\\".5\\\" (well-formed equivalent is \\\"0.5\\\")\\n *  - Allows decimals with trailing zeroes like \\\"0.10\\\" (well-formed equivalent is \\\"0.1\\\")\\n */\\ndeclare const numericStringMatcher: RegExp;\\ndeclare const isNumericString: (string: string) => boolean;\\ndeclare const numberLikeMatcher: RegExp;\\n/**\\n *  Matches a well-formatted integer according to the following rules:\\n *    1. must begin with an integer, the first digit of which cannot be 0 unless the entire value is 0\\n *    2. The value may not be \\\"-0\\\"\\n */\\ndeclare const wellFormedIntegerMatcher: RegExp;\\ndeclare const isWellFormedInteger: RegExp[\\\"test\\\"];\\ndeclare const integerLikeMatcher: RegExp;\\ntype NumericLiteralKind = \\\"number\\\" | \\\"bigint\\\" | \\\"integer\\\";\\ndeclare const numericLiteralDescriptions: {\\n    readonly number: \\\"a number\\\";\\n    readonly bigint: \\\"a bigint\\\";\\n    readonly integer: \\\"an integer\\\";\\n};\\ntype numericLiteralDescriptions = typeof numericLiteralDescriptions;\\ntype writeMalformedNumericLiteralMessage<def extends string, kind extends NumericLiteralKind> = `'${def}' was parsed as ${numericLiteralDescriptions[kind]} but could not be narrowed to a literal value. Avoid unnecessary leading or trailing zeros and other abnormal notation`;\\ndeclare const writeMalformedNumericLiteralMessage: <def extends string, kind extends NumericLiteralKind>(def: def, kind: kind) => writeMalformedNumericLiteralMessage<def, kind>;\\ndeclare const tryParseWellFormedNumber: typeof tryParseNumber;\\ndeclare const tryParseNumber: <errorOnFail extends boolean | string>(token: string, options?: NumericParseOptions<errorOnFail>) => errorOnFail extends true | string ? number : number | undefined;\\ntype tryParseNumber<token extends string, messageOnFail extends string> = token extends `${infer n extends number}` ? number extends n ? writeMalformedNumericLiteralMessage<token, \\\"number\\\"> : n : messageOnFail;\\ntype parseNumber<token extends string> = token extends `${infer n extends number}` ? n : never;\\ndeclare const tryParseInteger: <errorOnFail extends boolean | string>(token: string, options?: NumericParseOptions<errorOnFail>) => errorOnFail extends true | string ? number : number | undefined;\\ntype tryParseInteger<token extends string, messageOnFail extends string> = token extends `${infer b extends bigint}` ? bigint extends b ? writeMalformedNumericLiteralMessage<token, \\\"integer\\\"> : token extends `${infer n extends number}` ? n : never : messageOnFail;\\ntype parseInteger<token extends string> = token extends `${bigint}` ? token extends `${infer n extends number}` ? n : never : never;\\ntype parseNonNegativeInteger<token extends string> = token extends `-${string}` ? never : parseInteger<token>;\\ntype NumericParseOptions<errorOnFail extends boolean | string> = {\\n    errorOnFail?: errorOnFail;\\n    strict?: boolean;\\n};\\ndeclare const tryParseWellFormedBigint: (def: string) => bigint | undefined;\\n/**\\n * Returns the next or previous representable floating-point number after the given input.\\n *\\n * @param {\\\"+\\\" | \\\"-\\\"} [direction=\\\"+\\\"] - The direction to find the nearest float. \\\"+\\\" for the next float, \\\"-\\\" for the previous float.\\n * @throws {Error} If the input is not a finite number.\\n *\\n * @example\\n * console.log(nearestFloat(0)); // Smallest positive number\\n * console.log(nearestFloat(2)); // 2.0000000000000004\\n * console.log(nearestFloat(2.1)); // 2.1000000000000005\\n * console.log(nearestFloat(2, \\\"-\\\")); // 1.9999999999999998\\n * console.log(nearestFloat(2.1, \\\"-\\\")); // 2.0999999999999996\\n * // as size of input increases, the increments become larger to stay within what\\n * // JS can represent in a numeric value\\n * console.log(nearestFloat(5555555555555555)); // 5555555555555556\\n * console.log(nearestFloat(5555555555555555, \\\"-\\\")); // 5555555555555554\\n */\\ndeclare const nearestFloat: (n: number, direction?: \\\"+\\\" | \\\"-\\\") => number;\\n\\ntype Key = string | symbol;\\ntype toArkKey<o, k extends keyof o> = k extends number ? [\\n    o,\\n    number\\n] extends [array, k] ? NonNegativeIntegerLiteral : `${k}` : k;\\ntype arkIndexableOf<o> = arkKeyOf<o> extends infer k ? k extends `${infer index extends number}` ? index | k : k : never;\\ntype arkKeyOf<o> = [\\n    o\\n] extends [object] ? [\\n    o\\n] extends [array] ? arkArrayKeyOf<o> : arkObjectLiteralKeyOf<o> : never;\\ntype arkArrayKeyOf<a extends array> = number extends a[\\\"length\\\"] ? NonNegativeIntegerLiteral : keyof a extends infer i ? i extends `${number}` ? i : never : never;\\ntype arkObjectLiteralKeyOf<o extends object> = keyof o extends infer k ? k extends number ? `${k}` : k : never;\\ntype arkGet<o, k extends arkIndexableOf<o>> = o[k extends keyof o ? k : NonNegativeIntegerLiteral extends k ? number & keyof o : k extends number ? `${k}` & keyof o : never];\\ntype writeInvalidKeysMessage<o extends string, keys extends array<string>> = `Key${keys[\\\"length\\\"] extends 1 ? \\\"\\\" : \\\"s\\\"} ${join<keys, \\\", \\\">} ${keys[\\\"length\\\"] extends 1 ? \\\"does\\\" : \\\"do\\\"} not exist on ${o}`;\\n\\ntype Dict<k extends string = string, v = unknown> = {\\n    readonly [_ in k]: v;\\n};\\ntype dict<v = unknown, k extends string = string> = {\\n    [_ in k]: v;\\n};\\n/** Either:\\n * A, with all properties of B undefined\\n * OR\\n * B, with all properties of A undefined\\n **/\\ntype propwiseXor<a, b> = show<a & {\\n    [k in keyof b]?: undefined;\\n}> | show<b & {\\n    [k in keyof a]?: undefined;\\n}>;\\ntype unionToPropwiseXor<props extends object, branchKey extends PropertyKey = keyof intersectUnion<props>> = props extends infer distributed ? show<distributed & {\\n    [k in branchKey]?: k extends keyof distributed ? unknown : undefined;\\n}> : never;\\ntype requireKeys<o, key extends keyof o> = o & {\\n    [requiredKey in key]-?: defined<o[requiredKey]>;\\n};\\ntype require<o, maxDepth extends number = 1> = _require<o, [], maxDepth>;\\ntype _require<o, depth extends 1[], maxDepth extends number> = depth[\\\"length\\\"] extends maxDepth ? o : o extends object ? o extends Fn ? o : {\\n    [k in keyof o]-?: _require<o[k], [...depth, 1], maxDepth>;\\n} : o;\\ntype PartialRecord<k extends PropertyKey = PropertyKey, v = unknown> = {\\n    [_ in k]?: v;\\n};\\n/** Returns true if a type can be homomorphically mapped without losing information.\\n * Useful for avoiding e.g. classes with private properties while mapping.\\n */\\ntype isSafelyMappable<t> = {\\n    [k in keyof t]: t[k];\\n} extends t ? true : false;\\ntype KeySet<key extends string = string> = {\\n    readonly [_ in key]?: 1;\\n};\\ntype keySetOf<o extends object> = KeySet<Extract<keyof o, string>>;\\ntype mutable<o, maxDepth extends number = 1> = _mutable<o, [], maxDepth>;\\ntype _mutable<o, depth extends 1[], maxDepth extends number> = depth[\\\"length\\\"] extends maxDepth ? o : o extends Primitive ? o : o extends Fn ? o : {\\n    -readonly [k in keyof o]: _mutable<o[k], [...depth, 1], maxDepth>;\\n};\\n/**\\n * extracts entries mimicking Object.entries, accounting for whether the\\n * object is an array\\n **/\\ntype entryOf<o> = {\\n    [k in keyof o]-?: [k, o[k] & ({} | null)];\\n}[o extends readonly unknown[] ? keyof o & number : keyof o] & unknown;\\ntype entriesOf<o extends object> = entryOf<o>[];\\n/**\\n * Object.entries wrapper providing narrowed types for objects with known sets\\n * of keys, e.g. those defined internally as configs\\n */\\ndeclare const entriesOf: <o extends object>(o: o) => entryOf<o>[];\\ntype Entry<key extends PropertyKey = PropertyKey, value = unknown> = readonly [key: key, value: value];\\ntype fromEntries<entries extends readonly Entry[]> = show<{\\n    [entry in entries[number] as entry[0]]: entry[1];\\n}>;\\ndeclare const fromEntries: <const entries extends readonly Entry[]>(entries: entries) => fromEntries<entries>;\\n/** Mimics the result of Object.keys(...) */\\ntype keyOf<o> = o extends array ? number extends o[\\\"length\\\"] ? `${number}` : keyof o & `${number}` : keyof o extends infer k ? k extends string ? k : k extends number ? `${k}` : never : never;\\ndeclare const keysOf: <o extends object>(o: o) => keyOf<o>[];\\ndeclare const isKeyOf: <k extends string | number | symbol, o extends object>(k: k, o: o) => k is Extract<keyof o, k>;\\n/** Coalesce keys that exist on one or more branches of a union */\\ntype unionKeyOf<t> = t extends unknown ? keyof t : never;\\ntype extractKeyed<o extends object, k extends unionKeyOf<o>> = Extract<o, {\\n    [_ in k]?: unknown;\\n}>;\\ndeclare const hasKey: <o extends object, k extends unionKeyOf<o>>(o: o, k: k) => o is extractKeyed<o, k>;\\ntype extractDefinedKey<o extends object, k extends unionKeyOf<o>> = show<extractKeyed<o, k> & {\\n    [_ in k]: {} | null;\\n}>;\\ndeclare const hasDefinedKey: <o extends object, k extends unionKeyOf<o>>(o: o, k: k) => o is extractDefinedKey<o, k>;\\ntype requiredKeyOf<o> = keyof o extends infer k ? k extends keyof o ? o extends {\\n    [_ in k]-?: o[k];\\n} ? k : never : never : never;\\ntype optionalKeyOf<o> = Exclude<keyof o, requiredKeyOf<o>>;\\ntype merge<base, props> = base extends unknown ? props extends unknown ? keyof base & keyof props extends never ? show<base & props> : show<omit<base, keyof props & keyof base> & props> : never : never;\\ntype override<base, merged extends {\\n    [k in keyof base]?: unknown;\\n}> = merge<base, merged>;\\ntype propValueOf<o> = o[keyof o];\\ndeclare const InnerDynamicBase: new <t extends object>(base: t) => t;\\ndeclare class Covariant<t> {\\n    /**\\n     * Patterns of the form `interface Example<T> extends T {}` don't count as using `T`.\\n     * From tsc's point of view when calculating variance it may as well look like `interface Example<T> {}`.\\n     * Fundamentally this ordinarily means `Example<T>` will always be assignable to `Example<U>` and\\n     * vice versa.\\n     *\\n     * Obviously this is a problem, so `Covariant` exists to add an unobtrusive covariant usage of the type\\n     * parameter, making `Example<T>` assignable to `Example<U>` only if `T` is a subtype of `U`.\\n     */\\n    private \\\" covariant\\\"?;\\n}\\n/** @ts-ignore (needed to extend `t`) **/\\ninterface DynamicBase<t extends object> extends t, Covariant<t> {\\n}\\ndeclare class DynamicBase<t extends object> {\\n    constructor(properties: t);\\n}\\ndeclare const NoopBase: new <t extends object>() => t;\\n/** @ts-ignore (needed to extend `t`) **/\\ndeclare class CastableBase<t extends object> extends NoopBase<t> {\\n    private \\\" covariant\\\"?;\\n}\\ndeclare const splitByKeys: <o extends object, leftKeys extends keySetOf<o>>(o: o, leftKeys: leftKeys) => [show<Pick<o, keyof leftKeys & keyof o>>, show<Omit<o, keyof leftKeys & keyof o>>];\\n/** Homomorphic implementation of the builtin Pick.\\n *\\n * Gives different results for certain union expressions like the following:\\n *\\n * @example\\n * // flattens result to { a?: 1 | 2; b?: 1 | 2 }\\n * type PickResult = Pick<{ a: 1; b?: 1 } | { a?: 2; b: 2 }, \\\"a\\\" | \\\"b\\\">\\n *\\n * @example\\n * // preserves original type w/ modifier groupings\\n * type pickResult = pick<{ a: 1; b?: 1 } | { a?: 2; b: 2 }, \\\"a\\\" | \\\"b\\\">\\n */\\ntype pick<o, key extends keyof o> = o extends unknown ? {\\n    [k in keyof o as k extends key ? k : never]: o[k];\\n} : never;\\ndeclare const pick: <o extends object, keys extends keySetOf<o>>(o: o, keys: keys) => pick<o, keyof keys & keyof o>;\\n/** Homomorphic implementation of the builtin Omit.\\n *\\n * Gives different results for many union expressions like the following:\\n *\\n * @example\\n * // {}\\n * type OmitResult = Omit<{ a: 1 } | { b: 2 }, never>\\n *\\n * @example\\n * // preserves original type w/ modifier groupings\\n * type omitResult = omit<{ a: 1 } | { b: 2 }, never>\\n */\\ntype omit<o, key extends keyof o> = {\\n    [k in keyof o as k extends key ? never : k]: o[k];\\n};\\ndeclare const omit: <o extends object, keys extends keySetOf<o>>(o: o, keys: keys) => omit<o, keyof keys & keyof o>;\\n/** Returns onTrue if the type is exactly `{}` and onFalse otherwise*/\\ntype ifEmptyObjectLiteral<t, onTrue = true, onFalse = false> = [\\n    unknown,\\n    t & (null | undefined)\\n] extends [t | null | undefined, never] ? onTrue : onFalse;\\ntype EmptyObject = Record<PropertyKey, never>;\\ndeclare const isEmptyObject: (o: object) => o is EmptyObject;\\ndeclare const stringAndSymbolicEntriesOf: (o: object) => Entry<Key>[];\\n/** Like Object.assign, but it will preserve getters instead of evaluating them. */\\ndeclare const defineProperties: <base extends object, merged extends object>(base: base, merged: merged) => merge<base, merged>;\\n/** Copies enumerable keys of o to a new object in alphabetical order */\\ndeclare const withAlphabetizedKeys: <o extends object>(o: o) => o;\\ntype invert<t extends Record<PropertyKey, PropertyKey>> = {\\n    [k in t[keyof t]]: {\\n        [k2 in keyof t]: t[k2] extends k ? k2 : never;\\n    }[keyof t];\\n} & unknown;\\ndeclare const invert: <t extends Record<PropertyKey, PropertyKey>>(t: t) => invert<t>;\\ndeclare const unset: \\\" unset​\\\";\\ntype unset = typeof unset;\\n/**\\n *  For each keyof o that also exists on jsDocSource, add associated JsDoc annotations to o.\\n *  Does not preserve modifiers on o like optionality.\\n */\\ntype withJsDoc<o, jsDocSource> = show<keyof o extends keyof jsDocSource ? keyof jsDocSource extends keyof o ? _withJsDoc<o, jsDocSource> : Pick<_withJsDoc<o, jsDocSource>, keyof o & keyof jsDocSource> : Pick<_withJsDoc<o, jsDocSource>, keyof o & keyof jsDocSource> & {\\n    [k in Exclude<keyof o, keyof jsDocSource>]: o[k];\\n}>;\\ntype _withJsDoc<o, jsDocSource> = {\\n    [k in keyof jsDocSource]-?: o[k & keyof o];\\n};\\ntype propertyDescriptorsOf<o extends object> = {\\n    [k in keyof o]: TypedPropertyDescriptor<o[k]>;\\n};\\ntype keyWithValue<t, constraint> = keyof t extends infer k ? k extends keyof t ? t[k] extends constraint ? k : never : never : never;\\ndeclare const enumValues: <tsEnum extends object>(tsEnum: tsEnum) => tsEnum[keyof tsEnum][];\\n\\ndeclare class InternalArktypeError extends Error {\\n}\\ndeclare const throwInternalError: (message: string) => never;\\ndeclare const throwError: (message: string, ctor?: new (message: string) => Error) => never;\\ndeclare class ParseError extends Error {\\n    readonly name = \\\"ParseError\\\";\\n}\\ndeclare const throwParseError: (message: string) => never;\\n/**\\n *  TypeScript won't suggest strings beginning with a space as properties.\\n *  Useful for symbol-like string properties.\\n */\\ndeclare const noSuggest: <s extends string>(s: s) => noSuggest<s>;\\n/**\\n *  TypeScript won't suggest strings beginning with a space as properties.\\n *  Useful for symbol-like string properties.\\n */\\ntype noSuggest<s extends string = string> = ` ${s}`;\\n/** Unrendered character (U+200B) used to mark a string type */\\ndeclare const ZeroWidthSpace = \\\"\\\\u200B\\\";\\n/** Unrendered character (U+200B) used to mark a string type */\\ntype ZeroWidthSpace = typeof ZeroWidthSpace;\\ntype ErrorMessage<message extends string = string> = `${message}${ZeroWidthSpace}`;\\ninterface ErrorType<ctx extends {} = {}> extends CastableBase<ctx> {\\n    [brand]: \\\"ErrorType\\\";\\n}\\ntype Completion<text extends string = string> = `${text}${ZeroWidthSpace}${ZeroWidthSpace}`;\\n\\ntype Stringifiable = string | boolean | number | bigint | null | undefined;\\n/** Force an operation like `{ a: 0 } & { b: 1 }` to be computed so that it displays `{ a: 0; b: 1 }`. */\\ntype show<t> = {\\n    [k in keyof t]: t[k];\\n} & unknown;\\n/** @deprecated use \\\"show\\\" instead */\\ntype evaluate<t> = {\\n    [k in keyof t]: t[k];\\n} & unknown;\\ntype get<t, k extends PropertyKey> = t[k & keyof t];\\ntype exact<t extends object, u extends object> = {\\n    [k in keyof t]: k extends keyof u ? conform<t[k], u[k]> : never;\\n};\\ntype exactMessageOnError<t extends object, u extends object> = {\\n    [k in keyof t]: k extends keyof u ? conform<t[k], u[k]> : ErrorMessage<`'${k & string}' is not a valid key`>;\\n} & u;\\ntype promisable<t> = t | Promise<t>;\\ntype leftIfEqual<l, r> = [l, r] extends [r, l] ? l : r;\\ntype UnknownUnion = string | number | symbol | bigint | boolean | object | null | undefined;\\n/**\\n * Interesection (`&`) that avoids evaluating `unknown` to `{}`\\n */\\ntype andPreserveUnknown<l, r> = unknown extends l & r ? unknown : show<l & r>;\\n/** Can be used to test for the universal subtypes, `any` and `never`, e.g.:\\n *\\n * ```ts\\n * type isAnyOrNever<t> = [t] extends [anyOrNever] ? true : false\\n * ```\\n *\\n *  The actual value is a string literal, but the only realistic subtypes\\n *  of that literal are `any` and `never`.\\n */\\ntype anyOrNever = \\\" anyOrNever\\\";\\ntype conform<t, base> = t extends base ? t : base;\\ntype equals<l, r> = [l, r] extends [r, l] ? true : false;\\ntype exactEquals<l, r> = (<_>() => _ extends l ? 1 : 2) extends <_>() => _ extends r ? 1 : 2 ? true : false;\\ndeclare const brand: \\\" brand\\\";\\ntype Brand<t = unknown, id = unknown> = t & {\\n    readonly [brand]: [t, id];\\n};\\ntype unbrand<t> = t extends Brand<infer base, string> ? base : never;\\ntype satisfy<base, t extends base> = t;\\ntype defined<t> = t & ({} | null);\\ntype autocomplete<suggestions extends string> = suggestions | (string & {});\\ntype widen<t, supertypes> = collectWidenedType<t, unionToTuple<supertypes>>;\\ntype collectWidenedType<t, remaining extends unknown[], result = never> = remaining extends [infer head, ...infer tail] ? collectWidenedType<t, tail, t extends head ? result | head : result> : result;\\ntype narrowTuple<t extends readonly unknown[]> = t extends readonly [infer head, ...infer tail] ? readonly [head, ...narrowTuple<tail>] : [];\\ntype narrow<t> = t extends Primitive ? t : t extends readonly unknown[] ? narrowTuple<t> : {\\n    [k in keyof t]: narrow<t[k]>;\\n};\\ndeclare const narrow: <t>(t: narrow<t>) => t;\\n/** primitive key used to represent an inferred type at compile-time */\\ndeclare const inferred: \\\" arkInferred\\\";\\n/** primitive key used to represent an inferred type at compile-time */\\ntype inferred = typeof inferred;\\n\\ndeclare const args: \\\" args\\\";\\ntype args = typeof args;\\ndeclare abstract class Hkt<constraints extends unknown[] = any> {\\n    [args]: unknown[];\\n    constraints: constraints;\\n    args: this[args] extends infer args extends unknown[] ? args : never;\\n    0: this[args] extends [infer arg, ...any] ? arg : never;\\n    1: this[args] extends [any, infer arg, ...any] ? arg : never;\\n    2: this[args] extends [any, any, infer arg, ...any] ? arg : never;\\n    3: this[args] extends [any, any, any, infer arg, ...any] ? arg : never;\\n    abstract body: unknown;\\n    description?: string;\\n    constructor();\\n}\\n/** A small set of HKT utility types based on https://github.com/gvergnaud/hotscript\\n *  See https://github.com/gvergnaud/hotscript/blob/main/src/internals/core/Core.ts\\n */\\ndeclare namespace Hkt {\\n    type constructor<constraints extends unknown[] = any> = new () => Hkt<constraints>;\\n    type args = typeof args;\\n    type apply<hkt extends Hkt, args extends {\\n        [i in keyof args]: hkt[\\\"constraints\\\"][i];\\n    }> = (hkt & {\\n        [args]: args;\\n    })[\\\"body\\\"];\\n}\\n\\ninterface AndPreserveUnknown extends Hkt<[unknown, unknown]> {\\n    body: andPreserveUnknown<this[0], this[1]>;\\n}\\ntype SequenceIntersectionKind = \\\"array\\\" | \\\"parameters\\\";\\ntype intersectArrays<l extends array, r extends array, operator extends Hkt = AndPreserveUnknown> = intersectSequences<l, r, [], [], operator, \\\"array\\\">;\\ntype intersectParameters<l extends array, r extends array, operator extends Hkt = AndPreserveUnknown> = intersectSequences<l, r, [], [], operator, \\\"parameters\\\">;\\ntype intersectSequences<l extends array, r extends array, acc extends array, postfix extends array, operation extends Hkt, kind extends SequenceIntersectionKind> = l extends readonly [] ? kind extends \\\"array\\\" ? [\\n] extends r ? [\\n    ...acc,\\n    ...postfix\\n] : never : [...acc, ...r, ...postfix] : r extends readonly [] ? kind extends \\\"array\\\" ? [\\n] extends l ? [\\n    ...acc,\\n    ...postfix\\n] : never : [...acc, ...l, ...postfix] : [\\n    l,\\n    r\\n] extends ([\\n    readonly [(infer lHead)?, ...infer lTail],\\n    readonly [(infer rHead)?, ...infer rTail]\\n]) ? [\\n    \\\"0\\\",\\n    lHead,\\n    rHead\\n] extends [keyof l | keyof r, l[0], r[0]] ? intersectSequences<lTail, rTail, [\\n    [],\\n    []\\n] extends [l, r] ? [\\n    ...acc,\\n    Hkt.apply<operation, [lHead, rHead]>?\\n] : [...acc, Hkt.apply<operation, [lHead, rHead]>], postfix, operation, kind> : l extends readonly [...infer lInit, infer lLast] ? r extends readonly [...infer rInit, infer rLast] ? intersectSequences<lInit, rInit, acc, [\\n    Hkt.apply<operation, [lLast, rLast]>,\\n    ...postfix\\n], operation, kind> : intersectSequences<lInit, r, acc, [\\n    Hkt.apply<operation, [lLast, r[number]]>,\\n    ...postfix\\n], operation, kind> : r extends readonly [...infer rInit, infer rLast] ? intersectSequences<l, rInit, acc, [\\n    Hkt.apply<operation, [l[number], rLast]>,\\n    ...postfix\\n], operation, kind> : [...acc, ...Hkt.apply<operation, [lHead, rHead]>[], ...postfix] : never;\\ntype isDisjoint<l, r> = overlaps<l, r> extends true ? false : true;\\ntype overlaps<l, r> = l & r extends never ? false : domainOf<l> & domainOf<r> extends never ? false : [l, r] extends [object, object] ? false extends (propValueOf<{\\n    [k in Extract<keyof l & keyof r, requiredKeyOf<l> | requiredKeyOf<r>>]: overlaps<l[k], r[k]>;\\n}>) ? false : true : true;\\n\\ntype DuplicateData<val = unknown> = {\\n    element: val;\\n    indices: number[];\\n};\\n/**\\n * Extracts duplicated elements and their indices from an array, returning them.\\n *\\n * Note that given `a === b && b === c`, then `c === a` must be `true` for this to give accurate results.\\n *\\n * @param arr The array to extract duplicate elements from.\\n */ declare const getDuplicatesOf: <const arr extends array>(arr: arr, opts?: ComparisonOptions<arr[number]>) => DuplicateData<arr[number]>[];\\ntype pathToString<segments extends string[], delimiter extends string = \\\"/\\\"> = segments extends [] ? \\\"/\\\" : join<segments, delimiter>;\\ndeclare const join: <segments extends array<string>, delimiter extends string>(segments: segments, delimiter: delimiter) => join<segments, delimiter>;\\ntype join<segments extends array<string>, delimiter extends string, result extends string = \\\"\\\"> = segments extends (readonly [infer head extends string, ...infer tail extends string[]]) ? join<tail, delimiter, result extends \\\"\\\" ? head : `${result}${delimiter}${head}`> : result;\\ndeclare const getPath: (root: unknown, path: string[]) => unknown;\\ndeclare const intersectUniqueLists: <item>(l: readonly item[], r: readonly item[]) => item[];\\ntype filter<t extends array, constraint, result extends unknown[] = []> = t extends readonly [infer head, ...infer tail] ? filter<tail, constraint, head extends constraint ? [...result, head] : result> : result;\\ntype array<t = unknown> = readonly t[];\\ndeclare namespace array {\\n    type multiply<t extends array, count extends number> = _multiply<t, [\\n    ], count, [\\n    ]>;\\n    type _multiply<base extends array, result extends array, count extends number, i extends 1[]> = i[\\\"length\\\"] extends count ? result : _multiply<base, [...result, ...base], count, [...i, 1]>;\\n    type repeat<element, count extends number> = buildFromSegments<element, [\\n    ], exponentials.max<count>, count>;\\n    type buildFromSegments<element, result extends 1[], segments extends 1[][], count extends number, next extends 1[] = [...result, ...segments[0]]> = next[\\\"length\\\"] extends count ? {\\n        [i in keyof next]: element;\\n    } : `${count}` extends keyof next ? buildFromSegments<element, result, nextSegments<segments>, count> : buildFromSegments<element, next, nextSegments<segments>, count>;\\n    type nextSegments<segments extends 1[][]> = segments extends [unknown, ...infer nextSegments extends 1[][]] ? nextSegments : never;\\n    type minLength<element, minLength extends number> = readonly [\\n        ...multiply<[element], minLength>,\\n        ...element[]\\n    ];\\n}\\ntype listable<t> = t | readonly t[];\\ntype flattenListable<t> = t extends array<infer element> ? element : t;\\ntype longerThan<t extends array, n extends number> = `${n}` extends keyof t ? true : false;\\ntype CollapsingList<t = unknown> = readonly [] | t | readonly [t, t, ...t[]];\\ntype headOf<t extends array> = t[0];\\ntype tailOf<t extends array> = t extends readonly [unknown, ...infer tail] ? tail : never;\\ntype lastIndexOf<t extends array> = tailOf<t>[\\\"length\\\"];\\ntype lastOf<t extends array> = t[lastIndexOf<t>];\\ntype initOf<t extends array> = t extends readonly [...infer init, unknown] ? init : never;\\ntype numericStringKeyOf<t extends array> = Extract<keyof t, `${number}`>;\\ntype arrayIndexOf<a extends array> = keyof a extends infer k ? parseNonNegativeInteger<k & string> : never;\\ntype liftArray<t> = t extends array ? [\\n    t\\n] extends [anyOrNever] ? t[] : t : t[];\\ndeclare const liftArray: <t>(data: t) => liftArray<t>;\\n/**\\n * Splits an array into two arrays based on the result of a predicate\\n *\\n * @param predicate - The guard function used to determine which items to include.\\n * @returns A tuple containing two arrays:\\n * \\t\\t\\t\\t- the first includes items for which `predicate` returns true\\n * \\t\\t\\t\\t- the second includes items for which `predicate` returns false\\n *\\n * @example\\n * const list = [1, \\\"2\\\", \\\"3\\\", 4, 5];\\n * const [numbers, strings] = spliterate(list, (x) => typeof x === \\\"number\\\");\\n * // Type: number[]\\n * // Output: [1, 4, 5]\\n * console.log(evens);\\n * // Type: string[]\\n * // Output: [\\\"2\\\", \\\"3\\\"]\\n * console.log(odds);\\n */\\ndeclare const spliterate: <item, included extends item>(arr: readonly item[], predicate: GuardablePredicate<item, included>) => [included: included[], excluded: [item] extends [included] ? item[] : Exclude<item, included>[]];\\ndeclare const ReadonlyArray: new <T>(...args: ConstructorParameters<typeof Array<T>>) => ReadonlyArray<T>;\\ndeclare const includes: <a extends array>(array: a, element: unknown) => element is a[number];\\ndeclare const range: (length: number, offset?: number) => number[];\\ntype AppendOptions = {\\n    /** If true, adds the element to the beginning of the array instead of the end */\\n    prepend?: boolean;\\n};\\n/**\\n * Adds a value or array to an array, returning the concatenated result\\n */\\ndeclare const append: <to extends unknown[] | undefined, value extends appendableValue<to>>(to: to, value: value, opts?: AppendOptions) => to & {};\\ntype appendableValue<to extends array | undefined> = to extends array<infer element> ? element extends array ? array<element> : listable<element> : never;\\n/**\\n * Concatenates an element or list with a readonly list\\n */\\ndeclare const conflatenate: <element>(to: readonly element[] | undefined | null, elementOrList: appendableValue<readonly element[]> | undefined | null) => readonly element[];\\n/**\\n * Concatenates a variadic list of elements or lists with a readonly list\\n */\\ndeclare const conflatenateAll: <element>(...elementsOrLists: (listable<element> | undefined | null)[]) => readonly element[];\\ninterface ComparisonOptions<t = unknown> {\\n    isEqual?: (l: t, r: t) => boolean;\\n}\\n/**\\n * Appends a value or concatenates an array to an array if it is not already included, returning the array\\n */\\ndeclare const appendUnique: <to extends unknown[]>(to: to | undefined, value: NoInfer<Readonly<to> | to[number]>, opts?: ComparisonOptions<to[number]>) => to;\\ntype groupableKeyOf<o> = keyof o extends infer k ? k extends keyof o ? o[k] extends PropertyKey ? k : never : never : never;\\ntype groupBy<element, discriminant extends groupableKeyOf<element>> = {\\n    [k in element[discriminant] & PropertyKey]?: (element extends unknown ? isDisjoint<element[discriminant], k> extends true ? never : element : never)[];\\n} & unknown;\\ndeclare const groupBy: <element, discriminant extends groupableKeyOf<element>>(array: readonly element[], discriminant: discriminant) => groupBy<element, discriminant>;\\ndeclare const arrayEquals: <element>(l: array<element>, r: array<element>, opts?: ComparisonOptions<element>) => boolean;\\ntype validateExhaustiveKeys<keys extends readonly PropertyKey[], expectedKey extends PropertyKey> = keys extends readonly [infer head, ...infer tail extends PropertyKey[]] ? readonly [\\n    conform<head, expectedKey>,\\n    ...validateExhaustiveKeys<tail, Exclude<expectedKey, head>>\\n] : [expectedKey] extends [never] ? [] : [expectedKey];\\ntype applyElementLabels<t extends readonly unknown[], labels extends readonly unknown[]> = labels extends [unknown, ...infer labelsTail] ? t extends readonly [infer head, ...infer tail] ? readonly [\\n    ...labelElement<head, labels>,\\n    ...applyElementLabels<tail, labelsTail>\\n] : applyOptionalElementLabels<Required<t>, labels> : t;\\ntype applyOptionalElementLabels<t extends readonly unknown[], labels extends readonly unknown[]> = labels extends readonly [unknown, ...infer labelsTail] ? t extends readonly [infer head, ...infer tail] ? [\\n    ...labelOptionalElement<head, labels>,\\n    ...applyOptionalElementLabels<tail, labelsTail>\\n] : applyRestElementLabels<t, labels> : t;\\ntype applyRestElementLabels<t extends readonly unknown[], labels extends readonly unknown[]> = t extends readonly [] ? [] : labels extends readonly [unknown, ...infer tail] ? [\\n    ...labelOptionalElement<t[0], labels>,\\n    ...applyRestElementLabels<t, tail>\\n] : t;\\ntype labelElement<element, labels extends readonly unknown[]> = labels extends readonly [unknown] ? {\\n    [K in keyof labels]: element;\\n} : labels extends readonly [...infer head, unknown] ? labelElement<element, head> : [_: element];\\ntype labelOptionalElement<element, label extends readonly unknown[]> = label extends readonly [unknown] ? {\\n    [K in keyof label]?: element;\\n} : label extends readonly [...infer head, unknown] ? labelOptionalElement<element, head> : [_?: element];\\ntype setIndex<arr extends readonly unknown[], i extends number, to extends arr[number]> = arr extends arr[number][] ? _setIndex<arr, i, to, []> : Readonly<_setIndex<arr, i, to, []>>;\\ntype _setIndex<arr extends readonly unknown[], i extends number, to extends arr[number], result extends arr[number][]> = arr extends readonly [infer head, ...infer tail] ? _setIndex<tail, i, to, [...result, result[\\\"length\\\"] extends i ? to : head]> : result;\\ntype zero = [];\\ntype one = [1];\\ntype two = [1, 1];\\ntype three = [...two, ...two];\\ntype four = [...three, ...three];\\ntype five = [...four, ...four];\\ntype six = [...five, ...five];\\ntype seven = [...six, ...six];\\ntype eight = [...seven, ...seven];\\ntype nine = [...eight, ...eight];\\ntype ten = [...nine, ...nine];\\ntype eleven = [...ten, ...ten];\\ntype twelve = [...eleven, ...eleven];\\ntype thirteen = [...twelve, ...twelve];\\ntype fourteen = [...thirteen, ...thirteen];\\ntype exponentials = [\\n    fourteen,\\n    thirteen,\\n    twelve,\\n    eleven,\\n    ten,\\n    nine,\\n    eight,\\n    seven,\\n    six,\\n    five,\\n    four,\\n    three,\\n    two,\\n    one,\\n    zero\\n];\\ndeclare namespace exponentials {\\n    type max<n extends number> = _max<n, exponentials>;\\n    type _max<n extends number, filtered extends unknown[]> = `${n}` extends keyof filtered[0] ? _max<n, tailOf<filtered>> : filtered;\\n}\\n\\n/** Shallowly copy the properties of the object. */\\ndeclare const shallowClone: <input extends object>(input: input) => input;\\n/** Deeply copy the properties of the a non-subclassed Object, Array or Date.*/\\ndeclare const deepClone: <input extends object>(input: input) => input;\\n\\ntype objectFromListableEntries<transformed extends readonly GroupableEntry[]> = show<intersectUnion<fromGroupableEntries<transformed>>>;\\ntype fromGroupableEntries<entries extends readonly GroupableEntry[]> = {\\n    [entry in entries[number] as entry extends GroupedEntry ? entry[0][\\\"group\\\"] : conform<entry[0], PropertyKey>]: entry extends GroupedEntry ? entry[1][] : entry[1];\\n};\\ntype arrayFromListableEntries<transformed extends Entry> = Entry<number, never> extends transformed ? transformed[1][] : _arrayFromListableEntries<transformed, []>;\\ntype _arrayFromListableEntries<transformed extends Entry, result extends unknown[]> = [\\n    transformed\\n] extends [never] ? result : Extract<transformed, Entry<result[\\\"length\\\"]>> extends (infer next extends Entry) ? Exclude<transformed, next> extends infer remaining extends Entry ? [\\n    transformed\\n] extends [remaining] ? [\\n    ...result,\\n    ...transformed[1][]\\n] : _arrayFromListableEntries<remaining, [...result, next[1]]> : never : [...result, ...transformed[1][]];\\ntype extractEntrySets<e extends listable<GroupableEntry>> = e extends readonly GroupableEntry[] ? e : [e];\\ntype extractEntries<e extends listable<Entry>> = e extends readonly Entry[] ? e[number] : e;\\ntype entryArgsWithIndex<o> = {\\n    [k in keyof o]-?: [k: k, v: Exclude<o[k], undefined>, i: number];\\n}[keyof o];\\ntype numericArrayEntry<a extends array> = number extends a[\\\"length\\\"] ? [number, a[number]] : {\\n    [i in keyof a]: i extends `${infer n extends number}` ? [n, a[i]] : never;\\n}[number];\\ntype GroupedEntry = readonly [key: {\\n    group: Key;\\n}, value: unknown];\\ntype GroupableEntry = Entry<Key> | Entry<number> | GroupedEntry;\\ntype ListableEntry = listable<GroupableEntry>;\\ntype fromMappedEntries<transformed extends ListableEntry> = [\\n    transformed\\n] extends [listable<Entry<number>>] ? arrayFromListableEntries<extractEntries<transformed>> : objectFromListableEntries<extractEntrySets<transformed>>;\\ntype FlatMorph = {\\n    <const o extends array, transformed extends ListableEntry>(o: o, flatMapEntry: (...args: numericArrayEntry<o>) => transformed): fromMappedEntries<transformed>;\\n    <const o extends object, transformed extends ListableEntry>(o: o, flatMapEntry: (...args: entryOf<o>) => transformed): fromMappedEntries<transformed>;\\n    <const o extends object, transformed extends ListableEntry>(o: o, flatMapEntry: (...args: entryArgsWithIndex<o>) => transformed): fromMappedEntries<transformed>;\\n};\\ndeclare const flatMorph: FlatMorph;\\n\\ndeclare const isomorphic: {\\n    fileName: () => string;\\n    env: Record<autocomplete<\\\"ARK_DEBUG\\\">, string | undefined>;\\n};\\n\\ndeclare const lazily: <t extends object>(thunk: () => t) => t;\\n\\ntype SerializationOptions = {\\n    onCycle?: (value: object) => string;\\n    onSymbol?: (value: symbol) => string;\\n    onFunction?: (value: Function) => string;\\n    onUndefined?: string;\\n    onBigInt?: (value: bigint) => string;\\n};\\ntype JsonStructure = JsonObject | JsonArray;\\ninterface JsonObject {\\n    [k: string]: Json;\\n}\\ntype JsonArray = Json[];\\ntype JsonPrimitive = string | boolean | number | null;\\ntype Json = JsonStructure | JsonPrimitive;\\ndeclare const snapshot: <t>(data: t, opts?: SerializationOptions) => snapshot<t>;\\ntype snapshot<t, depth extends 1[] = []> = unknown extends t ? unknown : t extends Primitive ? snapshotPrimitive<t> : t extends {\\n    toJSON: () => infer serialized;\\n} ? serialized : t extends Function ? `Function(${string})` : t extends Date ? string : depth[\\\"length\\\"] extends 10 ? unknown : t extends array<infer item> ? array<snapshot<item, [...depth, 1]>> : {\\n    [k in keyof t as snapshotPrimitive<k>]: snapshot<t[k], [...depth, 1]>;\\n};\\ntype snapshotPrimitive<t> = t extends symbol ? `Symbol(${string})` : t;\\ntype PrintableOptions = {\\n    indent?: number;\\n    quoteKeys?: boolean;\\n};\\ndeclare const print: (data: unknown, opts?: PrintableOptions) => void;\\ndeclare const printable: (data: unknown, opts?: PrintableOptions) => string;\\n/**\\n * Converts a Date instance to a human-readable description relative to its precision\\n */\\ndeclare const describeCollapsibleDate: (date: Date) => string;\\n\\ntype StringifyPathOptions<stringifiable = PropertyKey> = requireKeys<{\\n    stringifySymbol?: (s: symbol) => string;\\n    stringifyNonKey?: (o: Exclude<stringifiable, PropertyKey>) => string;\\n}, stringifiable extends PropertyKey ? never : \\\"stringifyNonKey\\\">;\\ntype StringifyPathFn = <stringifiable>(path: array<stringifiable>, ...[opts]: [stringifiable] extends [PropertyKey] ? [\\n    opts?: StringifyPathOptions\\n] : NoInfer<[opts: StringifyPathOptions<stringifiable>]>) => string;\\ntype AppendStringifiedKeyFn = <stringifiable>(path: string, prop: stringifiable, ...[opts]: [stringifiable] extends [PropertyKey] ? [\\n    opts?: StringifyPathOptions\\n] : NoInfer<[opts: StringifyPathOptions<stringifiable>]>) => string;\\ndeclare const appendStringifiedKey: AppendStringifiedKeyFn;\\ndeclare const stringifyPath: StringifyPathFn;\\ndeclare class ReadonlyPath extends ReadonlyArray<PropertyKey> {\\n    private cache;\\n    constructor(...items: array<PropertyKey>);\\n    toJSON(): JsonArray;\\n    stringify(): string;\\n    stringifyAncestors(): readonly string[];\\n}\\n\\ntype SerializedString<value extends string = string> = `\\\"${value}\\\"`;\\ntype SerializedPrimitives = {\\n    string: SerializedString;\\n    number: `${number}`;\\n    bigint: BigintLiteral;\\n    boolean: \\\"true\\\" | \\\"false\\\";\\n    null: \\\"null\\\";\\n    undefined: \\\"undefined\\\";\\n};\\ntype SerializedPrimitive = SerializedPrimitives[keyof SerializedPrimitives];\\ntype SerializablePrimitive = inferDomain<keyof SerializedPrimitives>;\\ndeclare const serializePrimitive: <value extends SerializablePrimitive>(value: value) => serializePrimitive<value>;\\ntype serializePrimitive<value extends SerializablePrimitive> = value extends string ? `\\\"${value}\\\"` : value extends bigint ? `${value}n` : `${value}`;\\n\\ndeclare const arkUtilVersion = \\\"0.56.0\\\";\\ndeclare const initialRegistryContents: {\\n    version: string;\\n    filename: string;\\n    FileConstructor: typeof buffer.File;\\n};\\ntype InitialRegistryContents = typeof initialRegistryContents;\\ninterface ArkRegistry extends InitialRegistryContents {\\n    [k: string]: unknown;\\n}\\ndeclare const registry: ArkRegistry;\\ndeclare global {\\n    export interface ArkEnv {\\n        prototypes(): never;\\n    }\\n    export namespace ArkEnv {\\n        type prototypes = ReturnType<ArkEnv[\\\"prototypes\\\"]>;\\n    }\\n}\\ndeclare const register: (value: object | symbol) => string;\\ndeclare const isDotAccessible: (keyName: string) => boolean;\\n\\ndeclare const capitalize: <s extends string>(s: s) => Capitalize<s>;\\ndeclare const uncapitalize: <s extends string>(s: s) => Uncapitalize<s>;\\ntype firstChar<s extends string> = s extends `${infer head}${string}` ? head : \\\"\\\";\\ntype charsAfterFirst<s extends string> = s extends `${string}${infer tail}` ? tail : \\\"\\\";\\ntype lastChar<s extends string> = s extends `${infer head}${infer tail}` ? tail extends \\\"\\\" ? head : lastChar<tail> : s;\\ntype charsBeforeLast<s extends string> = s extends `${infer head}${infer tail}` ? tail extends \\\"\\\" ? \\\"\\\" : `${head}${charsBeforeLast<tail>}` : \\\"\\\";\\ntype contains<s extends string, sub extends string> = s extends `${string}${sub}${string}` ? true : false;\\ndeclare const anchoredRegex: (regex: RegExp | string) => RegExp;\\ndeclare const deanchoredRegex: (regex: RegExp | string) => RegExp;\\ndeclare const anchoredSource: (regex: RegExp | string) => string;\\ndeclare const deanchoredSource: (regex: RegExp | string) => string;\\ndeclare const RegexPatterns: {\\n    negativeLookahead: (pattern: string) => `(?!${string})`;\\n    nonCapturingGroup: (pattern: string) => `(?:${string})`;\\n};\\ndeclare const Backslash = \\\"\\\\\\\\\\\";\\ntype Backslash = typeof Backslash;\\ndeclare const whitespaceChars: {\\n    readonly \\\" \\\": 1;\\n    readonly \\\"\\\\n\\\": 1;\\n    readonly \\\"\\\\t\\\": 1;\\n};\\ntype WhitespaceChar = keyof typeof whitespaceChars;\\ntype trim<s extends string> = trimEnd<trimStart<s>>;\\ntype trimStart<s extends string> = s extends `${WhitespaceChar}${infer tail}` ? trimEnd<tail> : s;\\ntype trimEnd<s extends string> = s extends `${infer init}${WhitespaceChar}` ? trimEnd<init> : s;\\ntype isStringLiteral<t> = [\\n    t\\n] extends [string] ? [\\n    string\\n] extends [t] ? false : Uppercase<t> extends Uppercase<Lowercase<t>> ? Lowercase<t> extends Lowercase<Uppercase<t>> ? true : false : false : false;\\ndeclare const emojiToUnicode: (emoji: string) => string;\\ndeclare const alphabet: readonly [\\\"a\\\", \\\"b\\\", \\\"c\\\", \\\"d\\\", \\\"e\\\", \\\"f\\\", \\\"g\\\", \\\"h\\\", \\\"i\\\", \\\"j\\\", \\\"k\\\", \\\"l\\\", \\\"m\\\", \\\"n\\\", \\\"o\\\", \\\"p\\\", \\\"q\\\", \\\"r\\\", \\\"s\\\", \\\"t\\\", \\\"u\\\", \\\"v\\\", \\\"w\\\", \\\"x\\\", \\\"y\\\", \\\"z\\\"];\\n\\ndeclare class Scanner<lookahead extends string = string> {\\n    chars: string[];\\n    i: number;\\n    def: string;\\n    constructor(def: string);\\n    /** Get lookahead and advance scanner by one */\\n    shift(): this[\\\"lookahead\\\"];\\n    get lookahead(): lookahead;\\n    get nextLookahead(): string;\\n    get length(): number;\\n    shiftUntil(condition: Scanner.UntilCondition): string;\\n    shiftUntilEscapable(condition: Scanner.UntilCondition): string;\\n    shiftUntilLookahead(charOrSet: string | KeySet): string;\\n    shiftUntilNonWhitespace(): string;\\n    jumpToIndex(i: number): void;\\n    jumpForward(count: number): void;\\n    get location(): number;\\n    get unscanned(): string;\\n    get scanned(): string;\\n    sliceChars(start: number, end?: number): string;\\n    lookaheadIs<char extends lookahead>(char: char): this is Scanner<char>;\\n    lookaheadIsIn<keySet extends KeySet>(tokens: keySet): this is Scanner<Extract<keyof keySet, string>>;\\n}\\ndeclare namespace Scanner {\\n    type UntilCondition = (scanner: Scanner, shifted: string) => boolean;\\n    type shift<lookahead extends string, unscanned extends string> = `${lookahead}${unscanned}`;\\n    type shiftUntil<unscanned extends string, terminator extends string, appendTo extends string = \\\"\\\"> = unscanned extends shift<infer lookahead, infer nextUnscanned> ? lookahead extends terminator ? [\\n        appendTo,\\n        unscanned\\n    ] : shiftUntil<nextUnscanned, terminator, `${appendTo}${lookahead}`> : [appendTo, \\\"\\\"];\\n    type shiftUntilEscapable<unscanned extends string, terminator extends string, escapeEscape extends Backslash | \\\"\\\", appendTo extends string = \\\"\\\"> = unscanned extends shift<infer lookahead, infer nextUnscanned> ? lookahead extends terminator ? [appendTo, unscanned] : lookahead extends Backslash ? nextUnscanned extends (shift<infer nextLookahead, infer postEscapedUnscanned>) ? shiftUntilEscapable<postEscapedUnscanned, terminator, escapeEscape, `${appendTo}${nextLookahead extends terminator ? \\\"\\\" : nextLookahead extends Backslash ? escapeEscape : Backslash}${nextLookahead}`> : [`${appendTo}${Backslash}`, \\\"\\\"] : shiftUntilEscapable<nextUnscanned, terminator, escapeEscape, `${appendTo}${lookahead}`> : [appendTo, \\\"\\\"];\\n    type shiftUntilNot<unscanned extends string, nonTerminator extends string, appendTo extends string = \\\"\\\"> = unscanned extends shift<infer lookahead, infer nextUnscanned> ? lookahead extends nonTerminator ? shiftUntilNot<nextUnscanned, nonTerminator, `${appendTo}${lookahead}`> : [appendTo, unscanned] : [appendTo, \\\"\\\"];\\n    type skipWhitespace<unscanned extends string> = shiftUntilNot<unscanned, WhitespaceChar>[1];\\n    type shiftResult<scanned extends string, unscanned extends string> = [\\n        scanned,\\n        unscanned\\n    ];\\n}\\ndeclare const writeUnmatchedGroupCloseMessage: <char extends string, unscanned extends string>(char: char, unscanned: unscanned) => writeUnmatchedGroupCloseMessage<char, unscanned>;\\ntype writeUnmatchedGroupCloseMessage<char extends string, unscanned extends string> = `Unmatched ${char}${unscanned extends \\\"\\\" ? \\\"\\\" : ` before ${unscanned}`}`;\\ndeclare const writeUnclosedGroupMessage: <missingChar extends string>(missingChar: missingChar) => writeUnclosedGroupMessage<missingChar>;\\ntype writeUnclosedGroupMessage<missingChar extends string> = `Missing ${missingChar}`;\\n\\ntype TraitImplementation = <traits extends TraitConstructor[], implementation extends implementationOf<s>, s extends CompositionState = composeTraits<[\\n    ...traits,\\n    implementation\\n], \\\"implementation\\\">, cls extends TraitConstructor = TraitConstructor<s[\\\"params\\\"], s[\\\"implemented\\\"], s[\\\"statics\\\"], s[\\\"abstractMethods\\\"], s[\\\"abstractProps\\\"], s[\\\"abstractStatics\\\"]>>(...args: [...traits, implementation & ThisType<InstanceType<cls>>]) => cls;\\ntype TraitComposition = <traits extends TraitConstructor[], s extends CompositionState = composeTraits<traits, \\\"abstract\\\">>(...traits: conform<traits, s[\\\"validated\\\"]>) => TraitConstructor<s[\\\"params\\\"], s[\\\"implemented\\\"], s[\\\"statics\\\"], s[\\\"abstractMethods\\\"], s[\\\"abstractProps\\\"], s[\\\"abstractStatics\\\"]>;\\ndeclare const hasTrait: (traitClass: Constructor) => (o: unknown) => boolean;\\ntype TraitDeclaration = {\\n    abstractMethods?: object;\\n    abstractProps?: object;\\n    abstractStatics?: object;\\n    dynamicBase?: object;\\n};\\n/** @ts-ignore required to extend NoopBase */\\ndeclare abstract class Trait<d extends TraitDeclaration = {}, abstractMethods extends object = d[\\\"abstractMethods\\\"] & {}, abstractProps extends object = d[\\\"abstractProps\\\"] & {}, abstractStatics extends object = d[\\\"abstractStatics\\\"] & {}, dynamicBase extends object = d[\\\"dynamicBase\\\"] & {}> extends NoopBase<abstractMethods & abstractProps & dynamicBase> {\\n    abstractMethods: abstractMethods;\\n    abstractProps: abstractProps;\\n    abstractStatic: abstractStatics;\\n    static get [Symbol.hasInstance](): (o: unknown) => boolean;\\n    traitsOf(): readonly TraitConstructor[];\\n}\\ndeclare const compose: TraitComposition;\\ndeclare const implement: TraitImplementation;\\ntype TraitConstructor<params extends array = any[], instance extends object = {}, statics = {}, abstractMethods extends object = {}, abstractProps extends object = {}, abstractStatics extends object = {}> = statics & (new (...args: params) => Trait<{\\n    abstractMethods: abstractMethods;\\n    abstractProps: abstractProps;\\n    abstractStatics: abstractStatics;\\n}> & instance);\\ntype CompositionState = {\\n    validated: array;\\n    remaining: array;\\n    params: array;\\n    kind: TraitCompositionKind;\\n    implemented: object;\\n    abstractMethods: object;\\n    abstractProps: object;\\n    abstractStatics: object;\\n    statics: object;\\n};\\ntype TraitCompositionKind = \\\"abstract\\\" | \\\"implementation\\\";\\ntype composeTraits<traits extends array, kind extends TraitCompositionKind> = _compose<{\\n    validated: [];\\n    remaining: traits;\\n    kind: kind;\\n    params: [];\\n    implemented: {};\\n    abstractMethods: {};\\n    abstractProps: {};\\n    abstractStatics: {};\\n    statics: {};\\n}>;\\ntype intersectImplementations<l, r> = {\\n    [k in keyof l]: k extends keyof r ? l[k] extends (...args: infer lArgs) => infer lReturn ? r[k] extends (...args: infer rArgs) => infer rReturn ? (...args: intersectParameters<lArgs, rArgs>) => lReturn & rReturn : l[k] & r[k] : l[k] & r[k] : l[k];\\n} & Omit<r, keyof l>;\\ntype _compose<s extends CompositionState> = s[\\\"remaining\\\"] extends (readonly [\\n    TraitConstructor<infer params, infer instance, infer statics, infer abstractMethods, infer abstractProps, infer abstractStatics>,\\n    ...infer tail\\n]) ? _compose<{\\n    validated: [...s[\\\"validated\\\"], s[\\\"remaining\\\"][0]];\\n    remaining: tail;\\n    kind: s[\\\"kind\\\"];\\n    params: intersectParameters<s[\\\"params\\\"], params>;\\n    implemented: intersectImplementations<s[\\\"implemented\\\"], Omit<instance, keyof abstractMethods | keyof abstractProps>>;\\n    statics: intersectImplementations<s[\\\"statics\\\"], Omit<statics, keyof abstractStatics>>;\\n    abstractMethods: intersectImplementations<s[\\\"abstractMethods\\\"], abstractMethods>;\\n    abstractProps: intersectImplementations<s[\\\"abstractProps\\\"], abstractProps>;\\n    abstractStatics: intersectImplementations<s[\\\"abstractStatics\\\"], abstractStatics>;\\n}> : finalizeState<s>;\\ntype finalizeState<s extends CompositionState> = satisfy<CompositionState, {\\n    params: s[\\\"params\\\"];\\n    validated: s[\\\"validated\\\"];\\n    remaining: s[\\\"remaining\\\"];\\n    kind: s[\\\"kind\\\"];\\n    implemented: show<s[\\\"implemented\\\"]>;\\n    statics: show<Omit<s[\\\"statics\\\"], keyof typeof Trait>>;\\n    abstractMethods: show<Omit<s[\\\"abstractMethods\\\"], keyof s[\\\"implemented\\\"]>>;\\n    abstractProps: show<Omit<s[\\\"abstractProps\\\"], keyof s[\\\"implemented\\\"]>>;\\n    abstractStatics: show<Omit<s[\\\"abstractStatics\\\"], keyof s[\\\"statics\\\"]>>;\\n}>;\\ntype implementationOf<s extends CompositionState> = s[\\\"abstractMethods\\\"] & ({} extends s[\\\"abstractProps\\\"] ? {} : {\\n    construct: (...args: s[\\\"params\\\"]) => s[\\\"abstractProps\\\"];\\n}) & ({} extends s[\\\"abstractStatics\\\"] ? {} : {\\n    statics: s[\\\"abstractStatics\\\"];\\n});\\n\\nexport { type AndPreserveUnknown, type AppendOptions, type AppendStringifiedKeyFn, type ArkRegistry, Backslash, type BigintLiteral, type Brand, type BuiltinObjectKind, type BuiltinObjects, Callable, type CallableOptions, CastableBase, type CollapsingList, type ComparisonOptions, type Completion, type Constructor, Covariant, type DescribeOptions, type Dict, type Digit, type Domain, DynamicBase, DynamicFunction, type EcmascriptObjects, type EmptyObject, type Entry, type ErrorMessage, type ErrorType, FileConstructor, type FlatMorph, type Fn, type GlobalName, type GroupableEntry, type GroupedEntry, type GuardablePredicate, Hkt, type InitialRegistryContents, InnerDynamicBase, type IntegerLiteral, InternalArktypeError, type JsTypeOf, type Json, type JsonArray, type JsonObject, type JsonPrimitive, type JsonStructure, type Key, type KeySet, type ListableEntry, type NonNegativeIntegerLiteral, type NonNullishDomain, NoopBase, type NullishDomain, type NumberLiteral, type NumericParseOptions, ParseError, type PartialRecord, type PlatformObjects, type Primitive, type PrimitiveDomain, type PrintableOptions, ReadonlyArray, ReadonlyPath, RegexPatterns, Scanner, type SerializablePrimitive, type SerializationOptions, type SerializedPrimitive, type SerializedPrimitives, type Stringifiable, type StringifyPathFn, type StringifyPathOptions, type Thunk, Trait, type TraitComposition, type TraitCompositionKind, type TraitConstructor, type TraitDeclaration, type TraitImplementation, type TypeGuard, type TypedArrayObjects, type UnknownUnion, type WhitespaceChar, ZeroWidthSpace, alphabet, ancestorsOf, anchoredRegex, anchoredSource, type andPreserveUnknown, type anyOrNever, append, appendStringifiedKey, appendUnique, type appendableValue, type applyElementLabels, type arkGet, type arkIndexableOf, type arkKeyOf, arkUtilVersion, array, arrayEquals, type arrayIndexOf, type autocomplete, brand, builtinConstructors, cached, capitalize, type charsAfterFirst, type charsBeforeLast, compose, type composeTraits, conflatenate, conflatenateAll, type conform, constructorExtends, type contains, deanchoredRegex, deanchoredSource, deepClone, defineProperties, type defined, type describe, describeCollapsibleDate, type describeDefaults, type describeDomainOf, type describeObject, type dict, domainDescriptions, domainOf, ecmascriptConstructors, ecmascriptDescriptions, emojiToUnicode, entriesOf, type entryOf, enumValues, envHasCsp, type equals, type evaluate, type exact, type exactEquals, type exactMessageOnError, type extractDefinedKey, type extractKeyed, type filter, type firstChar, flatMorph, type flattenListable, fromEntries, type fromMappedEntries, type get, getBuiltinNameOfConstructor, getDuplicatesOf, getPath, groupBy, type groupableKeyOf, hasDefinedKey, hasDomain, hasKey, hasObjectKind, hasTrait, type headOf, type ifEmptyObjectLiteral, implement, type implementationOf, includes, type inferDomain, inferred, type initOf, initialRegistryContents, type instanceOf, integerLikeMatcher, type intersectArrays, type intersectOverloadReturns, type intersectParameters, type intersectUnion, intersectUniqueLists, invert, isArray, type isDisjoint, isDotAccessible, isEmptyObject, isKeyOf, isNumericString, type isSafelyMappable, type isStringLiteral, isThunk, isWellFormedInteger, isWellFormedNumber, isomorphic, join, jsTypeOfDescriptions, type keyOf, type keySetOf, type keyWithValue, keysOf, type lastChar, type lastIndexOf, type lastOf, lazily, type leftIfEqual, liftArray, type listable, type longerThan, type merge, type mutable, narrow, nearestFloat, noSuggest, type normalizedKeyOf, numberLikeMatcher, type numericStringKeyOf, numericStringMatcher, objectKindDescriptions, objectKindOf, objectKindOrDomainOf, omit, type optionalKeyOf, type overlaps, type overloadOf, type override, type parseInteger, type parseNonNegativeInteger, type parseNumber, type pathToString, pick, platformConstructors, platformDescriptions, print, printable, type promisable, type propValueOf, type propertyDescriptorsOf, type propwiseXor, range, register, registry, type require, type requireKeys, type requiredKeyOf, type satisfy, serializePrimitive, type setIndex, shallowClone, type show, snapshot, splitByKeys, spliterate, stringAndSymbolicEntriesOf, stringifyPath, type stringifyUnion, type tailOf, throwError, throwInternalError, throwParseError, type thunkable, type toArkKey, type trim, type trimEnd, type trimStart, tryCatch, tryParseInteger, tryParseNumber, tryParseWellFormedBigint, tryParseWellFormedNumber, type typeToString, typedArrayConstructors, typedArrayDescriptions, type unbrand, uncapitalize, type unionKeyOf, type unionToPropwiseXor, type unionToTuple, unset, type validateExhaustiveKeys, wellFormedIntegerMatcher, wellFormedNumberMatcher, whitespaceChars, type widen, withAlphabetizedKeys, type withJsDoc, type writeInvalidKeysMessage, writeMalformedNumericLiteralMessage, writeUnclosedGroupMessage, writeUnmatchedGroupCloseMessage };\\n\\n}\"\n"
  },
  {
    "path": "ark/docs/components/icons/arktype-logo.tsx",
    "content": "export const ArkTypeLogo = ({ height = 40, width = 40 }) => (\n\t<svg\n\t\tviewBox=\"0 0 100 100\"\n\t\tversion=\"1.1\"\n\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\theight={height}\n\t\twidth={width}\n\t>\n\t\t<rect fill=\"#085b92\" width=\"100\" height=\"100\" rx=\"10\" />\n\t\t<g fill=\"#f5cf8f\">\n\t\t\t<path d=\"M 53.315857,82.644683 H 39.977324 L 36.75999,93.838326 H 28.582598 L 42.85952,46.918864 h 7.507114 l 14.343949,46.919462 h -8.177392 z m -2.14489,-7.507114 -4.55789,-15.885589 -4.490863,15.885589 z\" />\n\t\t\t<path d=\"M 73.35719,54.425978 H 62.096519 v -7.507114 h 30.698733 v 7.507114 H 81.534582 V 93.838326 H 73.35719 Z\" />\n\t\t</g>\n\t</svg>\n)\n\nexport const ArkTypeLogoTransparent = () => (\n\t<svg viewBox=\"0 0 100 100\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n\t\t<rect fill=\"#085b92\" width=\"100\" height=\"100\" rx=\"10\" />\n\t\t<g fill=\"#f5cf8f\">\n\t\t\t<path d=\"M 53.315857,82.644683 H 39.977324 L 36.75999,93.838326 H 28.582598 L 42.85952,46.918864 h 7.507114 l 14.343949,46.919462 h -8.177392 z m -2.14489,-7.507114 -4.55789,-15.885589 -4.490863,15.885589 z\" />\n\t\t\t<path d=\"M 73.35719,54.425978 H 62.096519 v -7.507114 h 30.698733 v 7.507114 H 81.534582 V 93.838326 H 73.35719 Z\" />\n\t\t</g>\n\t</svg>\n)\n"
  },
  {
    "path": "ark/docs/components/icons/boat.tsx",
    "content": "export const BoatIcon: React.FC<{ height: number }> = ({ height }) => (\n\t<svg\n\t\tversion=\"1.1\"\n\t\tviewBox=\"0 0 375 375\"\n\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\theight={height}\n\t>\n\t\t<path\n\t\t\tfill=\"#252827\"\n\t\t\td=\"M5.314 281.357h27.799l9.62-38.835a5.288 5.337 0 0 1 5.156-4.077h212.609a5.288 5.337 0 0 1 5.156 4.077l9.461 38.3 37.844-4.775c1.754-.268 3.508.43 4.678 1.824 1.169 1.34 1.542 3.218 1.063 4.935l-10.63 37.548a5.295 5.344 0 0 1-5.103 3.916H5.315c-2.923 0-5.316-2.414-5.316-5.364V286.72c0-2.95 2.391-5.364 5.315-5.364Zm127.566-32.184H52.035l-7.972 32.184h88.817zm31.89 0h-21.26v32.184h21.26zm91.582 0h-80.95v32.184h88.923zM10.63 313.542h288.35l7.283-25.855-34.55 4.344c-.212.054-.425.054-.637.054H10.629v21.457z\"\n\t\t/>\n\t\t<path\n\t\t\tfill=\"#252827\"\n\t\t\td=\"M106.994 267.84a5.281 5.33 0 0 0 4.624 2.789c.904 0 1.754-.215 2.604-.697a5.358 5.358 0 0 0 2.073-7.296c-1.435-2.574-4.624-3.54-7.229-2.092-2.55 1.449-3.507 4.72-2.072 7.296zm-43.212-2.575c0 2.95 2.338 5.364 5.262 5.364h.052c2.924 0 5.316-2.414 5.316-5.364 0-2.95-2.392-5.364-5.316-5.364-2.923 0-5.314 2.413-5.314 5.364zm127.671.805c.425 2.628 2.658 4.56 5.262 4.56.266 0 .531 0 .797-.054 2.87-.43 4.943-3.165 4.465-6.115-.426-2.95-3.083-4.989-6.006-4.506h-.053c-2.87.428-4.89 3.165-4.465 6.114zm21.155-.805c0 2.95 2.391 5.364 5.315 5.364 2.924 0 5.369-2.414 5.369-5.364 0-2.95-2.392-5.364-5.316-5.364h-.053c-2.923 0-5.315 2.413-5.315 5.364zm-127.566 0c0 2.95 2.339 5.364 5.262 5.364h.053c2.923 0 5.316-2.414 5.316-5.364 0-2.95-2.392-5.364-5.316-5.364s-5.315 2.413-5.315 5.364zm152.866 5.203a5.232 5.28 0 0 0 1.276.161 5.284 5.284 0 0 0 5.156-4.077c.744-2.843-.957-5.793-3.827-6.49h-.053c-2.87-.698-5.74 1.018-6.432 3.916a5.39 5.39 0 0 0 3.88 6.49z\"\n\t\t/>\n\t\t<path\n\t\t\tfill=\"#252827\"\n\t\t\td=\"M182.736 249.173h73.616l6.644 26.82h-80.26Zm55.172 21.295a5.232 5.28 0 0 0 1.276.161 5.284 5.284 0 0 0 5.156-4.077c.744-2.843-.957-5.793-3.827-6.49h-.053c-2.87-.698-5.74 1.018-6.432 3.916a5.39 5.39 0 0 0 3.88 6.49zm-19.985.161c2.923 0 5.369-2.414 5.369-5.364 0-2.95-2.392-5.364-5.316-5.364h-.053c-2.923 0-5.315 2.413-5.315 5.364 0 2.95 2.392 5.364 5.315 5.364zm-21.208 0c.266 0 .532 0 .798-.053 2.87-.43 4.943-3.165 4.464-6.115-.425-2.95-3.082-4.989-6.006-4.506h-.053c-2.87.43-4.89 3.165-4.464 6.115.424 2.627 2.657 4.56 5.262 4.56z\"\n\t\t/>\n\t\t<path\n\t\t\tfill=\"#252827\"\n\t\t\td=\"M182.736 249.173v26.82h80.26l1.329 5.364H175.4v-32.184zM164.77 249.173h-13.925v26.82h13.925z\"\n\t\t/>\n\t\t<path\n\t\t\tfill=\"#252827\"\n\t\t\td=\"M150.845 249.173v26.82h13.925v5.364h-21.26v-32.184zM58.04 249.173h74.84v26.82H51.397Zm48.954 18.667a5.281 5.33 0 0 0 4.624 2.789c.904 0 1.754-.215 2.604-.697a5.358 5.358 0 0 0 2.073-7.296c-1.435-2.574-4.624-3.54-7.229-2.092-2.55 1.449-3.507 4.72-2.072 7.296zm-16.69 2.79h.053c2.923 0 5.316-2.415 5.316-5.365s-2.392-5.364-5.316-5.364-5.315 2.413-5.315 5.364c0 2.95 2.34 5.364 5.262 5.364zm-21.26 0h.052c2.924 0 5.316-2.415 5.316-5.365s-2.392-5.364-5.316-5.364c-2.923 0-5.315 2.413-5.315 5.364 0 2.95 2.34 5.364 5.262 5.364z\"\n\t\t/>\n\t\t<path\n\t\t\tfill=\"#252827\"\n\t\t\td=\"M52.035 249.173h6.006l-6.644 26.82h81.483v5.364H44.062ZM17.964 292.085h253.111c.213 0 .426 0 .638-.053l34.55-4.345-5.773 20.49H17.964Z\"\n\t\t/>\n\t\t<path\n\t\t\tfill=\"#252827\"\n\t\t\td=\"m300.49 308.178-1.51 5.364zM17.964 292.085v16.093H300.49l-1.51 5.364H10.63v-21.457z\"\n\t\t/>\n\t\t<path\n\t\t\tfill=\"#252827\"\n\t\t\td=\"M10.934 302.813v-10.728l131.358.01 131.358.01 15.636-1.955c8.6-1.076 15.786-1.805 15.968-1.621.182.184-1.236 5.887-3.152 12.674l-3.485 12.34H10.934Z\"\n\t\t/>\n\t\t<path\n\t\t\tfill=\"#7b755f\"\n\t\t\td=\"M11.237 302.813v-10.728l132.573-.01 132.573-.01 12.453-1.519c14.274-1.741 15.793-1.814 15.794-.759 0 .422-1.407 5.939-3.128 12.26l-3.13 11.495H11.238Z\"\n\t\t/>\n\t\t<path\n\t\t\tfill=\"#252827\"\n\t\t\td=\"M44.664 280.591c.009-.253 1.734-7.356 3.834-15.785l3.817-15.326 40.205-.157 40.205-.158v31.886h-44.04c-24.221 0-44.031-.207-44.021-.46zm28.34-11.294c1.408-1.335 1.898-4.63 1.03-6.916-.493-1.295-3.389-2.786-5.41-2.786-2.105 0-5.147 3.07-5.147 5.194 0 1.889 1.463 4.981 2.569 5.43 2.048.832 5.606.36 6.959-.922zm21.261 0c1.407-1.335 1.898-4.63 1.029-6.916-.493-1.295-3.389-2.786-5.41-2.786-2.105 0-5.147 3.07-5.147 5.194 0 1.889 1.463 4.981 2.569 5.43 2.049.832 5.606.36 6.959-.922zm20.992.12c1.898-1.506 2.42-4.01 1.367-6.554-.942-2.274-2.512-3.268-5.167-3.268-2.42 0-5.46 2.891-5.46 5.194 0 1.889 1.463 4.981 2.57 5.43 1.852.752 5.245.346 6.69-.802zM143.658 265.112v-15.938h20.653V281.05h-20.653z\"\n\t\t/>\n\t\t<path\n\t\t\tfill=\"#7b755f\"\n\t\t\td=\"M175.852 265.112v-15.938H255.987l.6 2.299c.33 1.264 1.993 7.953 3.694 14.865 1.702 6.912 3.237 13.05 3.413 13.64.301 1.015-2.064 1.073-43.761 1.073h-44.08Zm24.73 4.138c1.832-2.02 2.163-3.777 1.165-6.189-1.626-3.926-5.907-4.728-8.933-1.674-1.989 2.007-2.257 4.073-.877 6.765 1.064 2.077 1.647 2.365 4.918 2.429 1.832.036 2.801-.31 3.727-1.33zm21.246 0c1.735-1.934 2.089-3.992 1.098-6.384-1.495-3.61-5.994-4.363-8.852-1.479-1.988 2.007-2.256 4.073-.877 6.765 1.064 2.077 1.647 2.365 4.918 2.429 1.836.036 2.796-.308 3.713-1.33zm21.259.047c1.038-.985 1.406-2.009 1.406-3.917 0-3.434-1.442-5.155-4.685-5.594-2.255-.305-2.757-.131-4.397 1.524-2.067 2.086-2.35 4.117-.954 6.842 1.06 2.067 1.651 2.365 4.833 2.429 1.666.034 2.817-.356 3.797-1.284zM143.658 265.112v-15.938h20.653V281.05h-20.653zM64.844 280.591c-10.775-.094-19.59-.408-19.59-.699 0-.797 7.103-29.51 7.366-29.774.125-.127 18.2-.322 40.166-.434l39.939-.204V281.051l-24.146-.145c-13.28-.079-32.961-.22-43.735-.315Zm7.764-10.585c1.609-.87 2.585-4.818 1.772-7.171-1.21-3.501-6.312-4.384-9.2-1.593-1.966 1.902-2.253 4.697-.776 7.579.84 1.64 1.212 1.808 3.988 1.808 1.684 0 3.58-.28 4.216-.623zm21.26 0c1.61-.87 2.585-4.818 1.772-7.171-1.21-3.501-6.312-4.384-9.2-1.593-1.966 1.902-2.253 4.697-.776 7.579.84 1.64 1.212 1.808 3.988 1.808 1.684 0 3.581-.28 4.216-.623zm21.833-.587c1.661-1.676 2.08-3.852 1.24-6.424-.847-2.588-2.125-3.4-5.354-3.4-4.654 0-7.006 4.654-4.663 9.226.855 1.668 1.184 1.808 4.252 1.808 2.501 0 3.623-.3 4.525-1.21z\"\n\t\t/>\n\t</svg>\n)\n"
  },
  {
    "path": "ark/docs/components/icons/bun.tsx",
    "content": "export const BunIcon: React.FC<{ height: number }> = ({ height }) => (\n\t<svg\n\t\tid=\"Bun\"\n\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\tviewBox=\"0 0 80 70\"\n\t\theight={height}\n\t>\n\t\t<title>Bun Logo</title>\n\t\t<path\n\t\t\tid=\"Shadow\"\n\t\t\td=\"M71.09,20.74c-.16-.17-.33-.34-.5-.5s-.33-.34-.5-.5-.33-.34-.5-.5-.33-.34-.5-.5-.33-.34-.5-.5-.33-.34-.5-.5-.33-.34-.5-.5A26.46,26.46,0,0,1,75.5,35.7c0,16.57-16.82,30.05-37.5,30.05-11.58,0-21.94-4.23-28.83-10.86l.5.5.5.5.5.5.5.5.5.5.5.5.5.5C19.55,65.3,30.14,69.75,42,69.75c20.68,0,37.5-13.48,37.5-30C79.5,32.69,76.46,26,71.09,20.74Z\"\n\t\t/>\n\t\t<g id=\"Body\">\n\t\t\t<path\n\t\t\t\tid=\"Background\"\n\t\t\t\td=\"M73,35.7c0,15.21-15.67,27.54-35,27.54S3,50.91,3,35.7C3,26.27,9,17.94,18.22,13S33.18,3,38,3s8.94,4.13,19.78,10C67,17.94,73,26.27,73,35.7Z\"\n\t\t\t\tfill=\"#fbf0df\"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tid=\"Bottom_Shadow\"\n\t\t\t\tdata-name=\"Bottom Shadow\"\n\t\t\t\td=\"M73,35.7a21.67,21.67,0,0,0-.8-5.78c-2.73,33.3-43.35,34.9-59.32,24.94A40,40,0,0,0,38,63.24C57.3,63.24,73,50.89,73,35.7Z\"\n\t\t\t\tfill=\"#f6dece\"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tid=\"Light_Shine\"\n\t\t\t\tdata-name=\"Light Shine\"\n\t\t\t\td=\"M24.53,11.17C29,8.49,34.94,3.46,40.78,3.45A9.29,9.29,0,0,0,38,3c-2.42,0-5,1.25-8.25,3.13-1.13.66-2.3,1.39-3.54,2.15-2.33,1.44-5,3.07-8,4.7C8.69,18.13,3,26.62,3,35.7c0,.4,0,.8,0,1.19C9.06,15.48,20.07,13.85,24.53,11.17Z\"\n\t\t\t\tfill=\"#fffefc\"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tid=\"Top\"\n\t\t\t\td=\"M35.12,5.53A16.41,16.41,0,0,1,29.49,18c-.28.25-.06.73.3.59,3.37-1.31,7.92-5.23,6-13.14C35.71,5,35.12,5.12,35.12,5.53Zm2.27,0A16.24,16.24,0,0,1,39,19c-.12.35.31.65.55.36C41.74,16.56,43.65,11,37.93,5,37.64,4.74,37.19,5.14,37.39,5.49Zm2.76-.17A16.42,16.42,0,0,1,47,17.12a.33.33,0,0,0,.65.11c.92-3.49.4-9.44-7.17-12.53C40.08,4.54,39.82,5.08,40.15,5.32ZM21.69,15.76a16.94,16.94,0,0,0,10.47-9c.18-.36.75-.22.66.18-1.73,8-7.52,9.67-11.12,9.45C21.32,16.4,21.33,15.87,21.69,15.76Z\"\n\t\t\t\tfill=\"#ccbea7\"\n\t\t\t\tfillRule=\"evenodd\"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tid=\"Outline\"\n\t\t\t\td=\"M38,65.75C17.32,65.75.5,52.27.5,35.7c0-10,6.18-19.33,16.53-24.92,3-1.6,5.57-3.21,7.86-4.62,1.26-.78,2.45-1.51,3.6-2.19C32,1.89,35,.5,38,.5s5.62,1.2,8.9,3.14c1,.57,2,1.19,3.07,1.87,2.49,1.54,5.3,3.28,9,5.27C69.32,16.37,75.5,25.69,75.5,35.7,75.5,52.27,58.68,65.75,38,65.75ZM38,3c-2.42,0-5,1.25-8.25,3.13-1.13.66-2.3,1.39-3.54,2.15-2.33,1.44-5,3.07-8,4.7C8.69,18.13,3,26.62,3,35.7,3,50.89,18.7,63.25,38,63.25S73,50.89,73,35.7C73,26.62,67.31,18.13,57.78,13,54,11,51.05,9.12,48.66,7.64c-1.09-.67-2.09-1.29-3-1.84C42.63,4,40.42,3,38,3Z\"\n\t\t\t/>\n\t\t</g>\n\t\t<g id=\"Mouth\">\n\t\t\t<g id=\"Background-2\" data-name=\"Background\">\n\t\t\t\t<path\n\t\t\t\t\td=\"M45.05,43a8.93,8.93,0,0,1-2.92,4.71,6.81,6.81,0,0,1-4,1.88A6.84,6.84,0,0,1,34,47.71,8.93,8.93,0,0,1,31.12,43a.72.72,0,0,1,.8-.81H44.26A.72.72,0,0,1,45.05,43Z\"\n\t\t\t\t\tfill=\"#b71422\"\n\t\t\t\t/>\n\t\t\t</g>\n\t\t\t<g id=\"Tongue\">\n\t\t\t\t<path\n\t\t\t\t\tid=\"Background-3\"\n\t\t\t\t\tdata-name=\"Background\"\n\t\t\t\t\td=\"M34,47.79a6.91,6.91,0,0,0,4.12,1.9,6.91,6.91,0,0,0,4.11-1.9,10.63,10.63,0,0,0,1-1.07,6.83,6.83,0,0,0-4.9-2.31,6.15,6.15,0,0,0-5,2.78C33.56,47.4,33.76,47.6,34,47.79Z\"\n\t\t\t\t\tfill=\"#ff6164\"\n\t\t\t\t/>\n\t\t\t\t<path\n\t\t\t\t\tid=\"Outline-2\"\n\t\t\t\t\tdata-name=\"Outline\"\n\t\t\t\t\td=\"M34.16,47a5.36,5.36,0,0,1,4.19-2.08,6,6,0,0,1,4,1.69c.23-.25.45-.51.66-.77a7,7,0,0,0-4.71-1.93,6.36,6.36,0,0,0-4.89,2.36A9.53,9.53,0,0,0,34.16,47Z\"\n\t\t\t\t/>\n\t\t\t</g>\n\t\t\t<path\n\t\t\t\tid=\"Outline-3\"\n\t\t\t\tdata-name=\"Outline\"\n\t\t\t\td=\"M38.09,50.19a7.42,7.42,0,0,1-4.45-2,9.52,9.52,0,0,1-3.11-5.05,1.2,1.2,0,0,1,.26-1,1.41,1.41,0,0,1,1.13-.51H44.26a1.44,1.44,0,0,1,1.13.51,1.19,1.19,0,0,1,.25,1h0a9.52,9.52,0,0,1-3.11,5.05A7.42,7.42,0,0,1,38.09,50.19Zm-6.17-7.4c-.16,0-.2.07-.21.09a8.29,8.29,0,0,0,2.73,4.37A6.23,6.23,0,0,0,38.09,49a6.28,6.28,0,0,0,3.65-1.73,8.3,8.3,0,0,0,2.72-4.37.21.21,0,0,0-.2-.09Z\"\n\t\t\t/>\n\t\t</g>\n\t\t<g id=\"Face\">\n\t\t\t<ellipse\n\t\t\t\tid=\"Right_Blush\"\n\t\t\t\tdata-name=\"Right Blush\"\n\t\t\t\tcx=\"53.22\"\n\t\t\t\tcy=\"40.18\"\n\t\t\t\trx=\"5.85\"\n\t\t\t\try=\"3.44\"\n\t\t\t\tfill=\"#febbd0\"\n\t\t\t/>\n\t\t\t<ellipse\n\t\t\t\tid=\"Left_Bluch\"\n\t\t\t\tdata-name=\"Left Bluch\"\n\t\t\t\tcx=\"22.95\"\n\t\t\t\tcy=\"40.18\"\n\t\t\t\trx=\"5.85\"\n\t\t\t\try=\"3.44\"\n\t\t\t\tfill=\"#febbd0\"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tid=\"Eyes\"\n\t\t\t\td=\"M25.7,38.8a5.51,5.51,0,1,0-5.5-5.51A5.51,5.51,0,0,0,25.7,38.8Zm24.77,0A5.51,5.51,0,1,0,45,33.29,5.5,5.5,0,0,0,50.47,38.8Z\"\n\t\t\t\tfillRule=\"evenodd\"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tid=\"Iris\"\n\t\t\t\td=\"M24,33.64a2.07,2.07,0,1,0-2.06-2.07A2.07,2.07,0,0,0,24,33.64Zm24.77,0a2.07,2.07,0,1,0-2.06-2.07A2.07,2.07,0,0,0,48.75,33.64Z\"\n\t\t\t\tfill=\"#fff\"\n\t\t\t\tfillRule=\"evenodd\"\n\t\t\t/>\n\t\t</g>\n\t</svg>\n)\n"
  },
  {
    "path": "ark/docs/components/icons/chromium.tsx",
    "content": "export const ChromiumIcon: React.FC<{ height: number }> = ({ height }) => (\n\t<svg\n\t\tversion=\"1.1\"\n\t\tviewBox=\"0 0 511.98 511.98\"\n\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\theight={height}\n\t>\n\t\t<defs>\n\t\t\t<linearGradient\n\t\t\t\tid=\"_c1\"\n\t\t\t\tx1=\".46521\"\n\t\t\t\tx2=\".55656\"\n\t\t\t\ty1=\"-.67391\"\n\t\t\t\ty2=\".8113\"\n\t\t\t\tgradientTransform=\"matrix(231.63 0 0 231.62 111.11 159.99)\"\n\t\t\t\tgradientUnits=\"userSpaceOnUse\"\n\t\t\t>\n\t\t\t\t<stop stopColor=\"#1972e7\" offset=\"0\" />\n\t\t\t\t<stop stopColor=\"#1969d5\" offset=\"1\" />\n\t\t\t</linearGradient>\n\t\t\t<linearGradient\n\t\t\t\tid=\"_c2\"\n\t\t\t\tx1=\"101.74\"\n\t\t\t\tx2=\"101.6\"\n\t\t\t\ty1=\"33.726\"\n\t\t\t\ty2=\"135.47\"\n\t\t\t\tgradientTransform=\"matrix(3.7794 0 0 3.7794 .0015156 .0037786)\"\n\t\t\t\tgradientUnits=\"userSpaceOnUse\"\n\t\t\t>\n\t\t\t\t<stop stopColor=\"#afccfb\" offset=\"0\" />\n\t\t\t\t<stop stopColor=\"#8bb5f8\" offset=\"1\" />\n\t\t\t</linearGradient>\n\t\t\t<linearGradient\n\t\t\t\tid=\"_c3\"\n\t\t\t\tx1=\".018203\"\n\t\t\t\tx2=\"1.7696\"\n\t\t\t\ty1=\"-.5117\"\n\t\t\t\ty2=\".49943\"\n\t\t\t\tgradientTransform=\"matrix(94.932 164.43 -164.43 94.931 97.556 173.61)\"\n\t\t\t\tgradientUnits=\"userSpaceOnUse\"\n\t\t\t>\n\t\t\t\t<stop stopColor=\"#659cf6\" offset=\"0\" />\n\t\t\t\t<stop stopColor=\"#4285f4\" offset=\"1\" />\n\t\t\t</linearGradient>\n\t\t\t<linearGradient\n\t\t\t\tid=\"_c4\"\n\t\t\t\tx1=\"67.452\"\n\t\t\t\tx2=\"67.733\"\n\t\t\t\ty1=\"40.321\"\n\t\t\t\ty2=\"95.25\"\n\t\t\t\tgradientTransform=\"matrix(3.7794 0 0 3.7794 .0015004 .0037786)\"\n\t\t\t\tgradientUnits=\"userSpaceOnUse\"\n\t\t\t>\n\t\t\t\t<stop stopColor=\"#3680f0\" offset=\"0\" />\n\t\t\t\t<stop stopColor=\"#2678ec\" offset=\"1\" />\n\t\t\t</linearGradient>\n\t\t</defs>\n\t\t<path\n\t\t\td=\"m255.99 255.99 110.85 63.997-110.85 191.99c141.38 0 255.99-114.61 255.99-255.99 0-46.642-12.536-90.332-34.331-128h-221.66z\"\n\t\t\tfill=\"url(#_c2)\"\n\t\t/>\n\t\t<path\n\t\t\td=\"m255.99 0c-94.75 0-177.41 51.513-221.68 128.03l110.83 191.96 110.85-63.997v-128h221.66c-44.272-76.495-126.92-128-221.66-128z\"\n\t\t\tfill=\"url(#_c1)\"\n\t\t/>\n\t\t<path\n\t\t\td=\"m0.0015118 255.99c0 141.38 114.61 255.99 255.99 255.99l110.85-191.99-110.85-63.997-110.85 63.997-110.83-191.96c-21.783 37.655-34.315 81.329-34.315 127.96\"\n\t\t\tfill=\"url(#_c3)\"\n\t\t/>\n\t\t<path\n\t\t\td=\"m383.99 255.99c0 70.69-57.307 128-128 128s-128-57.307-128-128c0-70.69 57.307-128 128-128s128 57.307 128 128\"\n\t\t\tfill=\"#fff\"\n\t\t/>\n\t\t<path\n\t\t\td=\"m359.99 255.99c0 57.436-46.562 104-104 104s-104-46.562-104-104c0-57.436 46.562-104 104-104s104 46.562 104 104\"\n\t\t\tfill=\"url(#_c4)\"\n\t\t/>\n\t</svg>\n)\n"
  },
  {
    "path": "ark/docs/components/icons/deno.tsx",
    "content": "export const DenoIcon: React.FC<{ height: number }> = ({ height }) => (\n\t<svg\n\t\tversion=\"1.0\"\n\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\tviewBox=\"0 0 1024.000000 1024.000000\"\n\t\tpreserveAspectRatio=\"xMidYMid meet\"\n\t\theight={height}\n\t>\n\t\t<g\n\t\t\ttransform=\"translate(0.000000,1024.000000) scale(0.100000,-0.100000)\"\n\t\t\tfill=\"#fff\"\n\t\t\tstroke=\"none\"\n\t\t>\n\t\t\t<path\n\t\t\t\td=\"M4720 9174 c-19 -2 -80 -9 -135 -14 -782 -82 -1552 -413 -2180 -939\n-116 -96 -380 -360 -476 -476 -520 -621 -824 -1318 -936 -2143 -25 -183 -25\n-801 0 -984 112 -825 416 -1522 936 -2143 96 -116 360 -380 476 -476 621 -520\n1318 -824 2143 -936 183 -25 801 -25 984 0 825 112 1522 416 2143 936 116 96\n380 360 476 476 520 621 824 1318 936 2143 25 183 25 801 0 984 -112 825 -416\n1522 -936 2143 -96 116 -360 380 -476 476 -619 518 -1323 826 -2137 935 -88\n12 -216 17 -453 19 -181 2 -346 1 -365 -1z m50 -432 c0 -117 8 -371 19 -612 6\n-118 13 -287 16 -375 11 -312 44 -1131 49 -1204 l5 -73 -45 5 c-25 2 -48 8\n-52 11 -3 4 -10 73 -14 154 -18 356 -77 1737 -83 1939 l-6 222 28 4 c15 2 40\n5 56 6 l27 1 0 -78z m957 24 c1 -1 4 -303 7 -671 4 -369 9 -700 12 -736 3 -37\n2 -69 -3 -71 -4 -3 -29 -3 -54 0 l-46 4 -7 291 c-4 161 -9 339 -11 397 -8 177\n-15 778 -9 793 4 11 15 12 57 5 29 -6 53 -11 54 -12z m-2313 -335 c6 -9 53\n-560 111 -1281 19 -245 38 -469 41 -497 5 -51 4 -53 -28 -73 -18 -11 -36 -20\n-40 -20 -3 0 -9 26 -12 58 -14 130 -68 758 -106 1212 -22 267 -42 506 -45 532\n-5 44 -4 48 22 62 32 17 50 20 57 7z m2753 -201 c28 -10 31 -15 37 -72 10\n-100 7 -578 -4 -578 -29 0 -89 34 -94 53 -3 12 -6 154 -6 315 0 325 -4 306 67\n282z m-1847 -47 c0 -27 7 -176 15 -333 8 -157 17 -356 21 -442 7 -174 9 -168\n-58 -172 -33 -1 -33 -1 -35 49 -2 28 -7 115 -13 195 -5 80 -17 253 -25 385 -8\n132 -18 263 -21 291 -6 50 -5 52 22 62 16 6 44 11 62 11 32 1 32 1 32 -46z\nm2774 -137 l34 -14 7 -134 c3 -73 5 -231 3 -350 l-3 -218 -42 21 -42 20 -3\n332 c-2 183 -1 338 1 345 4 15 4 15 45 -2z m-1826 -131 c6 -6 20 -491 21 -737\nl1 -148 -47 7 c-27 3 -49 6 -50 7 -3 2 -33 743 -33 815 l0 74 51 -6 c29 -4 54\n-9 57 -12z m2303 -71 c12 -14 14 -233 17 -1441 3 -1387 3 -1423 -15 -1423 -11\n0 -26 6 -35 13 -15 11 -17 132 -22 1317 -4 718 -9 1370 -12 1449 l-6 144 29\n-21 c17 -12 36 -29 44 -38z m-897 -205 c5 -4 10 -61 11 -126 5 -221 6 -1576 1\n-1580 -2 -2 -20 3 -40 11 l-36 15 0 851 0 850 28 -6 c15 -4 31 -10 36 -15z\nm-2760 -56 c3 -27 8 -88 11 -138 3 -49 10 -161 16 -248 12 -176 10 -187 -47\n-187 -30 0 -34 3 -38 33 -10 59 -45 551 -40 559 5 7 57 25 81 27 6 1 14 -20\n17 -46z m-1654 -255 c11 -106 33 -328 49 -493 17 -165 31 -305 31 -311 0 -12\n-77 -50 -85 -42 -5 5 -105 890 -105 930 0 24 77 125 87 114 3 -2 13 -91 23\n-198z m3921 -105 l29 -17 1 -216 c1 -118 3 -250 3 -293 2 -90 -9 -105 -63 -86\nl-31 11 0 86 c0 48 -3 187 -7 310 l-6 222 23 0 c12 0 35 -8 51 -17z m-3482\n-388 c18 -192 47 -516 66 -720 l34 -370 -39 -39 -38 -39 -7 79 c-4 44 -24 248\n-45 454 -21 206 -51 505 -66 664 l-28 288 39 36 c35 33 39 34 46 16 4 -10 21\n-176 38 -369z m-749 -121 c22 -197 80 -721 130 -1164 50 -443 97 -870 106\n-950 8 -80 22 -201 30 -270 14 -117 14 -125 -2 -137 -24 -18 -34 -16 -34 5 0\n9 -9 85 -20 167 -18 137 -48 369 -115 890 -14 105 -41 314 -60 465 -20 151\n-49 376 -65 500 -16 124 -43 336 -60 473 -18 136 -29 257 -26 270 7 27 66 121\n72 115 2 -3 22 -166 44 -364z m-306 -431 c15 -120 43 -339 62 -488 19 -148 43\n-333 54 -410 l19 -140 -21 -18 c-12 -10 -24 -14 -28 -10 -4 4 -12 44 -18 88\n-6 44 -43 301 -83 570 l-71 490 23 68 c12 37 25 67 28 67 4 0 19 -98 35 -217z\nm5490 131 c14 -14 16 -76 16 -535 l0 -519 -28 0 c-61 0 -60 -15 -64 553 l-3\n517 32 0 c17 0 39 -7 47 -16z m-2189 -179 c226 -34 423 -97 618 -197 126 -65\n186 -110 326 -244 208 -199 336 -373 456 -619 175 -358 243 -675 329 -1525 39\n-381 90 -1072 101 -1355 3 -82 10 -217 16 -300 11 -176 24 -152 -131 -227\n-215 -104 -422 -176 -695 -243 -334 -82 -550 -108 -880 -109 l-240 -1 2 115\nc0 63 6 210 12 325 30 557 24 1260 -15 1650 -22 224 -65 496 -89 556 -5 13 18\n24 117 58 181 63 338 142 362 181 43 74 -34 180 -132 180 -17 0 -68 -18 -115\n-39 -224 -103 -673 -224 -932 -251 -179 -19 -457 -8 -650 27 -105 19 -293 90\n-450 171 -181 94 -292 219 -325 367 -18 80 -13 240 10 330 25 99 95 243 159\n327 285 375 873 700 1476 814 192 36 464 40 670 9z m3085 -31 c36 -15 40 -19\n40 -53 2 -273 -4 -897 -9 -923 -1 -9 -53 -10 -75 -2 -14 5 -16 59 -16 500 0\n316 4 494 10 494 5 0 28 -7 50 -16z m437 -549 l36 -15 -7 -828 c-8 -1055 -9\n-1086 -47 -1177 -62 -149 -59 -179 -53 475 2 327 7 658 9 735 2 77 4 294 5\n483 0 228 3 342 10 342 6 0 27 -7 47 -15z m-6014 -249 c6 -81 4 -89 -25 -153\nl-32 -68 -12 100 c-19 160 -19 167 19 191 17 12 35 20 38 18 3 -2 9 -42 12\n-88z m-618 -603 c9 -82 79 -626 115 -893 54 -413 58 -472 34 -447 -3 3 -26\n142 -50 309 -156 1078 -155 1071 -142 1079 27 18 36 8 43 -48z m720 -458 c6\n-25 35 -296 35 -329 0 -28 -36 -54 -52 -38 -5 5 -18 90 -28 188 -11 99 -22\n202 -25 229 l-6 50 35 -40 c20 -22 38 -49 41 -60z m807 -377 c11 -10 18 -50\n27 -158 15 -195 17 -180 -24 -180 -42 0 -41 -3 -55 173 -14 179 -14 177 13\n177 13 0 30 -6 39 -12z m792 -15 c2 -10 7 -70 11 -133 3 -63 12 -205 20 -315\n28 -404 29 -455 12 -455 -19 0 -21 15 -43 300 -8 118 -23 304 -33 413 -9 109\n-15 200 -12 202 11 12 40 3 45 -12z m-1880 -192 c6 -9 44 -329 91 -766 14\n-132 28 -259 31 -283 l5 -43 -25 16 c-19 13 -26 26 -26 49 0 63 -43 478 -76\n732 -19 144 -34 271 -34 283 0 21 24 29 34 12z m5771 -418 l-7 -418 -25 -37\nc-57 -84 -54 -100 -51 368 l2 429 37 38 c20 20 40 37 44 37 3 0 3 -188 0 -417z\nm-925 -663 c5 -581 4 -626 -12 -644 -10 -11 -19 -18 -22 -15 -7 8 -17 1275 -9\n1282 4 4 14 6 23 5 13 -3 16 -74 20 -628z m-3266 398 c7 -62 32 -359 42 -499\n6 -94 6 -97 -16 -104 -12 -4 -26 -3 -30 2 -7 7 -29 229 -56 571 l-7 82 31 0\nc29 0 31 -2 36 -52z m-786 -350 c7 -7 12 -32 12 -57 0 -26 12 -161 25 -301 38\n-383 41 -435 24 -425 -26 15 -49 38 -44 44 2 4 -2 54 -10 111 -7 58 -16 152\n-20 210 -4 58 -13 164 -21 235 -19 175 -18 195 4 195 10 0 23 -5 30 -12z m473\n-673 c3 -22 9 -104 13 -182 7 -150 4 -161 -37 -130 -12 9 -20 47 -32 161 -21\n206 -22 198 17 194 29 -3 33 -7 39 -43z\"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\td=\"M3184 5756 c-104 -45 -112 -186 -14 -236 71 -36 143 -19 180 43 70\n114 -44 246 -166 193z\"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\td=\"M3862 5660 c-96 -59 -96 -201 0 -260 95 -57 218 18 218 132 0 110\n-126 184 -218 128z\"\n\t\t\t/>\n\t\t</g>\n\t</svg>\n)\n"
  },
  {
    "path": "ark/docs/components/icons/intellij.tsx",
    "content": "export const IntellijIcon: React.FC<{ height: number }> = ({ height }) => (\n\t<svg height={height} viewBox=\"0 0 105 105\" xmlns=\"http://www.w3.org/2000/svg\">\n\t\t<linearGradient\n\t\t\tid=\"a\"\n\t\t\tgradientUnits=\"userSpaceOnUse\"\n\t\t\tx1=\"11.16\"\n\t\t\tx2=\"58.94\"\n\t\t\ty1=\"59.21\"\n\t\t\ty2=\"56.78\"\n\t\t>\n\t\t\t<stop offset=\".09\" stopColor=\"#fc801d\" />\n\t\t\t<stop offset=\".23\" stopColor=\"#b07f61\" />\n\t\t\t<stop offset=\".41\" stopColor=\"#577db3\" />\n\t\t\t<stop offset=\".53\" stopColor=\"#1e7ce6\" />\n\t\t\t<stop offset=\".59\" stopColor=\"#087cfa\" />\n\t\t</linearGradient>\n\t\t<linearGradient\n\t\t\tid=\"b\"\n\t\t\tgradientUnits=\"userSpaceOnUse\"\n\t\t\tx1=\"89.05\"\n\t\t\tx2=\"73.12\"\n\t\t\ty1=\"54.12\"\n\t\t\ty2=\"6.52\"\n\t\t>\n\t\t\t<stop offset=\"0\" stopColor=\"#fe2857\" />\n\t\t\t<stop offset=\".08\" stopColor=\"#cb3979\" />\n\t\t\t<stop offset=\".16\" stopColor=\"#9e4997\" />\n\t\t\t<stop offset=\".25\" stopColor=\"#7557b2\" />\n\t\t\t<stop offset=\".34\" stopColor=\"#5362c8\" />\n\t\t\t<stop offset=\".44\" stopColor=\"#386cda\" />\n\t\t\t<stop offset=\".54\" stopColor=\"#2373e8\" />\n\t\t\t<stop offset=\".66\" stopColor=\"#1478f2\" />\n\t\t\t<stop offset=\".79\" stopColor=\"#0b7bf8\" />\n\t\t\t<stop offset=\"1\" stopColor=\"#087cfa\" />\n\t\t</linearGradient>\n\t\t<linearGradient\n\t\t\tid=\"c\"\n\t\t\tgradientUnits=\"userSpaceOnUse\"\n\t\t\tx1=\"18.72\"\n\t\t\tx2=\"78.8\"\n\t\t\ty1=\"26.61\"\n\t\t\ty2=\"125.99\"\n\t\t>\n\t\t\t<stop offset=\"0\" stopColor=\"#fe2857\" />\n\t\t\t<stop offset=\".08\" stopColor=\"#fe295f\" />\n\t\t\t<stop offset=\".21\" stopColor=\"#ff2d76\" />\n\t\t\t<stop offset=\".3\" stopColor=\"#ff318c\" />\n\t\t\t<stop offset=\".38\" stopColor=\"#ea3896\" />\n\t\t\t<stop offset=\".55\" stopColor=\"#b248ae\" />\n\t\t\t<stop offset=\".79\" stopColor=\"#5a63d6\" />\n\t\t\t<stop offset=\"1\" stopColor=\"#087cfa\" />\n\t\t</linearGradient>\n\t\t<path d=\"m19.27 72.21-14.12-11.15 8.31-15.39 12.49 4.18z\" fill=\"url(#a)\" />\n\t\t<path d=\"m100.07 30.09-1.73 55.6-36.98 14.81-20.14-13z\" fill=\"#087cfa\" />\n\t\t<path d=\"m100.07 30.09-18.3 17.85-23.5-28.83 11.6-13.04z\" fill=\"url(#b)\" />\n\t\t<path\n\t\t\td=\"m41.22 87.5-29.41 10.63 6.16-21.57 7.98-26.71-21.88-7.32 13.9-38.03 31.42 3.71 32.38 39.73z\"\n\t\t\tfill=\"url(#c)\"\n\t\t/>\n\t\t<path d=\"m22.5 22.5h60v60h-60z\" />\n\t\t<g fill=\"#fff\">\n\t\t\t<path d=\"m29.98 71.16h22.5v3.75h-22.5z\" />\n\t\t\t<path d=\"m41.21 34.12v-4.1h-11.19v4.1h3.14v14.16h-3.14v4.1h11.19v-4.1h-3.13v-14.16z\" />\n\t\t\t<path d=\"m51.94 52.7a8.88 8.88 0 0 1 -4.39-1 10.16 10.16 0 0 1 -2.92-2.36l3.09-3.45a8.86 8.86 0 0 0 1.94 1.64 4 4 0 0 0 2.15.6 2.85 2.85 0 0 0 2.19-.87 4.16 4.16 0 0 0 .8-2.83v-14.43h5v14.65a10.14 10.14 0 0 1 -.55 3.49 6.49 6.49 0 0 1 -4.07 4 9.87 9.87 0 0 1 -3.31.52\" />\n\t\t</g>\n\t</svg>\n)\n"
  },
  {
    "path": "ark/docs/components/icons/js.tsx",
    "content": "export const JsIcon: React.FC<{ height: number }> = ({ height }) => (\n\t<svg viewBox=\"0 0 255 255\" xmlns=\"http://www.w3.org/2000/svg\" height={height}>\n\t\t<g>\n\t\t\t<path fill=\"#fff\" d=\"M0 0h256v256H0V0z\" />\n\t\t\t<path\n\t\t\t\tfill=\"#000\"\n\t\t\t\td=\"m67.312 213.932 19.59-11.856c3.78 6.701 7.218 12.371 15.465 12.371 7.905 0 12.89-3.092 12.89-15.12v-81.798h24.057v82.138c0 24.917-14.606 36.259-35.916 36.259-19.245 0-30.416-9.967-36.087-21.996m85.07-2.576 19.588-11.341c5.157 8.421 11.859 14.607 23.715 14.607 9.969 0 16.325-4.984 16.325-11.858 0-8.248-6.53-11.17-17.528-15.98l-6.013-2.58c-17.357-7.387-28.87-16.667-28.87-36.257 0-18.044 13.747-31.792 35.228-31.792 15.294 0 26.292 5.328 34.196 19.247l-18.732 12.03c-4.125-7.389-8.591-10.31-15.465-10.31-7.046 0-11.514 4.468-11.514 10.31 0 7.217 4.468 10.14 14.778 14.608l6.014 2.577c20.45 8.765 31.963 17.7 31.963 37.804 0 21.654-17.012 33.51-39.867 33.51-22.339 0-36.774-10.654-43.819-24.574\"\n\t\t\t/>\n\t\t</g>\n\t</svg>\n)\n"
  },
  {
    "path": "ark/docs/components/icons/neovim.tsx",
    "content": "export const NeovimIcon: React.FC<{ height: number }> = ({ height }) => (\n\t<svg\n\t\theight={height}\n\t\tviewBox=\"0 0 602 734\"\n\t\tversion=\"1.1\"\n\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t// xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n\t\t// xmlns:sketch=\"http://www.bohemiancoding.com/sketch/ns\"\n\t>\n\t\t<title>neovim-mark@2x</title>\n\t\t<defs>\n\t\t\t<linearGradient x1=\"50%\" y1=\"0%\" x2=\"50%\" y2=\"100%\" id=\"linearGradient-1\">\n\t\t\t\t<stop stopColor=\"#16B0ED\" stopOpacity=\"0.800235524\" offset=\"0%\"></stop>\n\t\t\t\t<stop stopColor=\"#0F59B2\" stopOpacity=\"0.83700023\" offset=\"100%\"></stop>\n\t\t\t</linearGradient>\n\t\t\t<linearGradient x1=\"50%\" y1=\"0%\" x2=\"50%\" y2=\"100%\" id=\"linearGradient-2\">\n\t\t\t\t<stop stopColor=\"#7DB643\" offset=\"0%\"></stop>\n\t\t\t\t<stop stopColor=\"#367533\" offset=\"100%\"></stop>\n\t\t\t</linearGradient>\n\t\t\t<linearGradient x1=\"50%\" y1=\"0%\" x2=\"50%\" y2=\"100%\" id=\"linearGradient-3\">\n\t\t\t\t<stop stopColor=\"#88C649\" stopOpacity=\"0.8\" offset=\"0%\"></stop>\n\t\t\t\t<stop stopColor=\"#439240\" stopOpacity=\"0.84\" offset=\"100%\"></stop>\n\t\t\t</linearGradient>\n\t\t</defs>\n\t\t<g\n\t\t\tid=\"Page-1\"\n\t\t\tstroke=\"none\"\n\t\t\tstrokeWidth=\"1\"\n\t\t\tfill=\"none\"\n\t\t\tfillRule=\"evenodd\"\n\t\t\t// sketch:type=\"MSPage\"\n\t\t>\n\t\t\t<g\n\t\t\t\tid=\"mark-copy\"\n\t\t\t\t// sketch:type=\"MSLayerGroup\"\n\t\t\t\ttransform=\"translate(2.000000, 3.000000)\"\n\t\t\t>\n\t\t\t\t<path\n\t\t\t\t\td=\"M0,155.5704 L155,-1 L154.999997,727 L0,572.237919 L0,155.5704 Z\"\n\t\t\t\t\tid=\"Left---green\"\n\t\t\t\t\tfill=\"url(#linearGradient-1)\"\n\t\t\t\t\t// sketch:type=\"MSShapeGroup\"\n\t\t\t\t></path>\n\t\t\t\t<path\n\t\t\t\t\td=\"M443.060403,156.982405 L600,-1 L596.818792,727 L442,572.219941 L443.060403,156.982405 Z\"\n\t\t\t\t\tid=\"Right---blue\"\n\t\t\t\t\tfill=\"url(#linearGradient-2)\"\n\t\t\t\t\t// sketch:type=\"MSShapeGroup\"\n\t\t\t\t\ttransform=\"translate(521.000000, 363.500000) scale(-1, 1) translate(-521.000000, -363.500000) \"\n\t\t\t\t></path>\n\t\t\t\t<path\n\t\t\t\t\td=\"M154.986294,0 L558,615.189696 L445.224605,728 L42,114.172017 L154.986294,0 Z\"\n\t\t\t\t\tid=\"Cross---blue\"\n\t\t\t\t\tfill=\"url(#linearGradient-3)\"\n\t\t\t\t\t// sketch:type=\"MSShapeGroup\"\n\t\t\t\t></path>\n\t\t\t\t<path\n\t\t\t\t\td=\"M155,283.83232 L154.786754,308 L31,124.710606 L42.4619486,113 L155,283.83232 Z\"\n\t\t\t\t\tid=\"Shadow\"\n\t\t\t\t\tfillOpacity=\"0.13\"\n\t\t\t\t\tfill=\"#000000\"\n\t\t\t\t\t// sketch:type=\"MSShapeGroup\"\n\t\t\t\t></path>\n\t\t\t</g>\n\t\t</g>\n\t</svg>\n)\n"
  },
  {
    "path": "ark/docs/components/icons/node.tsx",
    "content": "export const NodeIcon: React.FC<{ height: number }> = ({ height }) => (\n\t<svg\n\t\tviewBox=\"0 0 256 292\"\n\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\txmlnsXlink=\"http://www.w3.org/1999/xlink\"\n\t\theight={height}\n\t>\n\t\t<defs>\n\t\t\t<linearGradient\n\t\t\t\tid=\"node-a\"\n\t\t\t\tx1=\"68.188%\"\n\t\t\t\tx2=\"27.823%\"\n\t\t\t\ty1=\"17.487%\"\n\t\t\t\ty2=\"89.755%\"\n\t\t\t>\n\t\t\t\t<stop offset=\"0%\" stopColor=\"#41873F\" />\n\t\t\t\t<stop offset=\"32.88%\" stopColor=\"#418B3D\" />\n\t\t\t\t<stop offset=\"63.52%\" stopColor=\"#419637\" />\n\t\t\t\t<stop offset=\"93.19%\" stopColor=\"#3FA92D\" />\n\t\t\t\t<stop offset=\"100%\" stopColor=\"#3FAE2A\" />\n\t\t\t</linearGradient>\n\t\t\t<linearGradient\n\t\t\t\tid=\"node-c\"\n\t\t\t\tx1=\"43.277%\"\n\t\t\t\tx2=\"159.245%\"\n\t\t\t\ty1=\"55.169%\"\n\t\t\t\ty2=\"-18.306%\"\n\t\t\t>\n\t\t\t\t<stop offset=\"13.76%\" stopColor=\"#41873F\" />\n\t\t\t\t<stop offset=\"40.32%\" stopColor=\"#54A044\" />\n\t\t\t\t<stop offset=\"71.36%\" stopColor=\"#66B848\" />\n\t\t\t\t<stop offset=\"90.81%\" stopColor=\"#6CC04A\" />\n\t\t\t</linearGradient>\n\t\t\t<linearGradient\n\t\t\t\tid=\"node-f\"\n\t\t\t\tx1=\"-4.389%\"\n\t\t\t\tx2=\"101.499%\"\n\t\t\t\ty1=\"49.997%\"\n\t\t\t\ty2=\"49.997%\"\n\t\t\t>\n\t\t\t\t<stop offset=\"9.192%\" stopColor=\"#6CC04A\" />\n\t\t\t\t<stop offset=\"28.64%\" stopColor=\"#66B848\" />\n\t\t\t\t<stop offset=\"59.68%\" stopColor=\"#54A044\" />\n\t\t\t\t<stop offset=\"86.24%\" stopColor=\"#41873F\" />\n\t\t\t</linearGradient>\n\t\t\t<path\n\t\t\t\tid=\"node-b\"\n\t\t\t\td=\"M134.923 1.832c-4.344-2.443-9.502-2.443-13.846 0L6.787 67.801C2.443 70.244 0 74.859 0 79.745v132.208c0 4.887 2.715 9.502 6.787 11.945l114.29 65.968c4.344 2.444 9.502 2.444 13.846 0l114.29-65.968c4.344-2.443 6.787-7.058 6.787-11.945V79.745c0-4.886-2.715-9.501-6.787-11.944L134.923 1.832Z\"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tid=\"node-e\"\n\t\t\t\td=\"M134.923 1.832c-4.344-2.443-9.502-2.443-13.846 0L6.787 67.801C2.443 70.244 0 74.859 0 79.745v132.208c0 4.887 2.715 9.502 6.787 11.945l114.29 65.968c4.344 2.444 9.502 2.444 13.846 0l114.29-65.968c4.344-2.443 6.787-7.058 6.787-11.945V79.745c0-4.886-2.715-9.501-6.787-11.944L134.923 1.832Z\"\n\t\t\t/>\n\t\t</defs>\n\t\t<path\n\t\t\tfill=\"url(#node-a)\"\n\t\t\td=\"M134.923 1.832c-4.344-2.443-9.502-2.443-13.846 0L6.787 67.801C2.443 70.244 0 74.859 0 79.745v132.208c0 4.887 2.715 9.502 6.787 11.945l114.29 65.968c4.344 2.444 9.502 2.444 13.846 0l114.29-65.968c4.344-2.443 6.787-7.058 6.787-11.945V79.745c0-4.886-2.715-9.501-6.787-11.944L134.923 1.832Z\"\n\t\t/>\n\t\t<mask id=\"d\" fill=\"#fff\">\n\t\t\t<use xlinkHref=\"#node-b\" />\n\t\t</mask>\n\t\t<path\n\t\t\tfill=\"url(#node-c)\"\n\t\t\td=\"M249.485 67.8 134.65 1.833c-1.086-.542-2.443-1.085-3.529-1.357L2.443 220.912c1.086 1.357 2.444 2.443 3.8 3.258l114.834 65.968c3.258 1.9 7.059 2.443 10.588 1.357L252.47 70.515c-.815-1.086-1.9-1.9-2.986-2.714Z\"\n\t\t\tmask=\"url(#node-d)\"\n\t\t/>\n\t\t<mask id=\"g\" fill=\"#fff\">\n\t\t\t<use xlinkHref=\"#node-e\" />\n\t\t</mask>\n\t\t<path\n\t\t\tfill=\"url(#node-f)\"\n\t\t\td=\"M249.756 223.898c3.258-1.9 5.701-5.158 6.787-8.687L130.579.204c-3.258-.543-6.787-.272-9.773 1.628L6.786 67.53l122.979 224.238c1.628-.272 3.529-.815 5.158-1.63l114.833-66.239Z\"\n\t\t\tmask=\"url(#node-g)\"\n\t\t/>\n\t</svg>\n)\n"
  },
  {
    "path": "ark/docs/components/icons/npm.tsx",
    "content": "export const NPMIcon = () => (\n\t<svg\n\t\twidth=\"18\"\n\t\theight=\"18\"\n\t\tviewBox=\"0 0 18 18\"\n\t\tversion=\"1.1\"\n\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t>\n\t\t<rect fill=\"#cb3837\" width=\"18\" height=\"18\" />\n\t\t<g fill=\"#ffffff\" transform=\"translate(0,5.5)\">\n\t\t\t<polygon points=\"1,1 1,5 3,5 3,2 4,2 4,5 5,5 5,1 \" />\n\t\t\t<path d=\"M 6,1 V 6 H 8 V 5 h 2 V 1 Z M 9,4 H 8 V 2 h 1 z\" />\n\t\t\t<polygon points=\"15,2 16,2 16,5 17,5 17,1 11,1 11,5 13,5 13,2 14,2 14,5 15,5 \" />\n\t\t</g>\n\t</svg>\n)\n"
  },
  {
    "path": "ark/docs/components/icons/ts.tsx",
    "content": "export const TsIcon: React.FC<{ height: number; className?: string }> = ({\n\theight,\n\tclassName\n}) => (\n\t<svg\n\t\tviewBox=\"0 0 124 124\"\n\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\theight={height}\n\t\tclassName={className}\n\t>\n\t\t<g>\n\t\t\t<rect width=\"128\" height=\"128\" fill=\"#fff\" rx=\"2\" />\n\t\t\t<path\n\t\t\t\tfill=\"#000\"\n\t\t\t\tfillRule=\"evenodd\"\n\t\t\t\td=\"M74.262 99.468v14.026c2.273 1.168 4.96 2.045 8.063 2.629 3.102.585 6.373.877 9.81.877 3.35 0 6.533-.321 9.548-.964 3.016-.643 5.659-1.702 7.932-3.178a16.179 16.179 0 0 0 5.397-5.786c1.325-2.381 1.988-5.325 1.988-8.831 0-2.542-.379-4.77-1.136-6.684a15.632 15.632 0 0 0-3.278-5.107c-1.427-1.49-3.139-2.827-5.134-4.01-1.996-1.183-4.246-2.301-6.752-3.353a84.756 84.756 0 0 1-4.938-2.213c-1.456-.716-2.695-1.447-3.714-2.192-1.02-.745-1.806-1.534-2.36-2.367-.553-.832-.83-1.775-.83-2.827 0-.964.247-1.833.743-2.608s1.194-1.439 2.097-1.994c.903-.555 2.01-.986 3.321-1.293 1.311-.307 2.768-.46 4.37-.46 1.166 0 2.396.088 3.693.263 1.296.175 2.6.445 3.911.81 1.311.366 2.585.826 3.824 1.381a21.071 21.071 0 0 1 3.43 1.929V54.41c-2.127-.818-4.45-1.425-6.97-1.82S101.866 52 98.603 52c-3.321 0-6.468.358-9.44 1.074-2.97.716-5.586 1.833-7.843 3.353a16.732 16.732 0 0 0-5.353 5.807C74.656 64.587 74 67.4 74 70.672c0 4.178 1.202 7.743 3.605 10.694 2.404 2.951 6.053 5.45 10.947 7.495 1.923.789 3.714 1.563 5.375 2.323 1.66.76 3.095 1.549 4.304 2.367s2.163 1.71 2.862 2.674c.7.964 1.049 2.06 1.049 3.287 0 .906-.218 1.746-.655 2.52s-1.1 1.446-1.988 2.016c-.89.57-1.996 1.016-3.322 1.337-1.325.321-2.876.482-4.654.482-3.03 0-6.03-.533-9.002-1.6-2.971-1.066-5.724-2.666-8.259-4.799zm-23.56-34.914H69V53H18v11.554h18.208V116h14.495z\"\n\t\t\t\tclipRule=\"evenodd\"\n\t\t\t/>\n\t\t</g>\n\t</svg>\n)\n"
  },
  {
    "path": "ark/docs/components/icons/vscode.tsx",
    "content": "export const VscodeIcon: React.FC<{\n\theight: number\n}> = ({ height }) => (\n\t<svg\n\t\tviewBox=\"0 0 256 254\"\n\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\txmlnsXlink=\"http://www.w3.org/1999/xlink\"\n\t\theight={height}\n\t\tpreserveAspectRatio=\"xMidYMid\"\n\t>\n\t\t<defs>\n\t\t\t<linearGradient id=\"code-c\" x1=\"50%\" x2=\"50%\" y1=\"0%\" y2=\"100%\">\n\t\t\t\t<stop offset=\"0%\" stopColor=\"#FFF\" />\n\t\t\t\t<stop offset=\"100%\" stopColor=\"#FFF\" stopOpacity=\"0\" />\n\t\t\t</linearGradient>\n\t\t\t<path\n\t\t\t\tid=\"code-a\"\n\t\t\t\td=\"M180.828 252.605a15.872 15.872 0 0 0 12.65-.486l52.501-25.262a15.94 15.94 0 0 0 9.025-14.364V41.197a15.939 15.939 0 0 0-9.025-14.363l-52.5-25.263a15.877 15.877 0 0 0-18.115 3.084L74.857 96.35l-43.78-33.232a10.614 10.614 0 0 0-13.56.603L3.476 76.494c-4.63 4.211-4.635 11.495-.012 15.713l37.967 34.638-37.967 34.637c-4.623 4.219-4.618 11.502.012 15.714l14.041 12.772a10.614 10.614 0 0 0 13.56.604l43.78-33.233 100.507 91.695a15.853 15.853 0 0 0 5.464 3.571Zm10.464-183.649-76.262 57.889 76.262 57.888V68.956Z\"\n\t\t\t/>\n\t\t</defs>\n\t\t<mask id=\"code-b\" fill=\"#fff\">\n\t\t\t<use xlinkHref=\"#code-a\" />\n\t\t</mask>\n\t\t<path\n\t\t\tfill=\"#0065A9\"\n\t\t\td=\"M246.135 26.873 193.593 1.575a15.885 15.885 0 0 0-18.123 3.08L3.466 161.482c-4.626 4.219-4.62 11.502.012 15.714l14.05 12.772a10.625 10.625 0 0 0 13.569.604L238.229 33.436c6.949-5.271 16.93-.315 16.93 8.407v-.61a15.938 15.938 0 0 0-9.024-14.36Z\"\n\t\t/>\n\t\t<path\n\t\t\tfill=\"#007ACC\"\n\t\t\td=\"m246.135 226.816-52.542 25.298a15.887 15.887 0 0 1-18.123-3.08L3.466 92.207c-4.626-4.218-4.62-11.502.012-15.713l14.05-12.773a10.625 10.625 0 0 1 13.569-.603l207.132 157.135c6.949 5.271 16.93.315 16.93-8.408v.611a15.939 15.939 0 0 1-9.024 14.36Z\"\n\t\t/>\n\t\t<path\n\t\t\tfill=\"#1F9CF0\"\n\t\t\td=\"M193.428 252.134a15.892 15.892 0 0 1-18.125-3.083c5.881 5.88 15.938 1.715 15.938-6.603V11.273c0-8.318-10.057-12.483-15.938-6.602a15.892 15.892 0 0 1 18.125-3.084l52.533 25.263a15.937 15.937 0 0 1 9.03 14.363V212.51c0 6.125-3.51 11.709-9.03 14.363l-52.533 25.262Z\"\n\t\t/>\n\t\t<path\n\t\t\tfill=\"url(#code-c)\"\n\t\t\tfillOpacity=\".25\"\n\t\t\td=\"M180.828 252.605a15.874 15.874 0 0 0 12.65-.486l52.5-25.263a15.938 15.938 0 0 0 9.026-14.363V41.197a15.939 15.939 0 0 0-9.025-14.363L193.477 1.57a15.877 15.877 0 0 0-18.114 3.084L74.857 96.35l-43.78-33.232a10.614 10.614 0 0 0-13.56.603L3.476 76.494c-4.63 4.211-4.635 11.495-.012 15.713l37.967 34.638-37.967 34.637c-4.623 4.219-4.618 11.502.012 15.714l14.041 12.772a10.614 10.614 0 0 0 13.56.604l43.78-33.233 100.506 91.695a15.857 15.857 0 0 0 5.465 3.571Zm10.464-183.65-76.262 57.89 76.262 57.888V68.956Z\"\n\t\t/>\n\t</svg>\n)\n"
  },
  {
    "path": "ark/docs/components/playground/ParseResult.tsx",
    "content": "import { tryCatch } from \"@ark/util\"\nimport type { Type, type } from \"arktype\"\nimport { DynamicCodeBlock } from \"fumadocs-ui/components/dynamic-codeblock\"\nimport React from \"react\"\nimport { Tab, Tabs } from \"./PlaygroundTabs.tsx\"\nimport { RestoreDefault } from \"./RestoreDefault.tsx\"\nimport {\n\tbackgroundsByResultKind,\n\tplaygroundOutVariableName,\n\tplaygroundTypeVariableName\n} from \"./utils.ts\"\n\nexport type ParseResult = type | Error\n\nexport declare namespace ParseResult {\n\texport type Props = {\n\t\tparsed: ParseResult\n\t\trestoreDefault: () => void\n\t}\n}\n\nexport const ParseResult = ({ parsed, restoreDefault }: ParseResult.Props) => {\n\tconst title = parsed instanceof Error ? parsed.name : \"Type\"\n\n\tconst contents =\n\t\tparsed instanceof Error ?\n\t\t\tcreateErrorResult(parsed, restoreDefault)\n\t\t:\tcreateTypeResult(parsed)\n\n\treturn (\n\t\t<div\n\t\t\tstyle={{\n\t\t\t\tbackgroundColor:\n\t\t\t\t\tparsed instanceof Error ?\n\t\t\t\t\t\tbackgroundsByResultKind.failure\n\t\t\t\t\t:\tbackgroundsByResultKind.none\n\t\t\t}}\n\t\t\tclassName=\"glass-container editor-bg h-full p-4 rounded-2xl\"\n\t\t>\n\t\t\t<h3 className=\"text-3xl text-fd-foreground font-semibold mb-2\">\n\t\t\t\t{title}\n\t\t\t</h3>\n\t\t\t{contents}\n\t\t</div>\n\t)\n}\n\nconst createErrorResult = (e: Error, restoreDefault: () => void) =>\n\te instanceof ReferenceError ?\n\t\te.message.startsWith(playgroundTypeVariableName) ?\n\t\t\t<>\n\t\t\t\tDefine a <code>Type</code> called{\" \"}\n\t\t\t\t<code>\"{playgroundTypeVariableName}\"</code> to enable introspection.\n\t\t\t\t<RestoreDefault onClick={restoreDefault} />\n\t\t\t</>\n\t\t: e.message.startsWith(playgroundOutVariableName) ?\n\t\t\t<>\n\t\t\t\tAssign the result of <code>{\"Thing({})\"}</code> to a variable called{\" \"}\n\t\t\t\t<code>\"{playgroundOutVariableName}\"</code> to see it.\n\t\t\t\t<RestoreDefault onClick={restoreDefault} />\n\t\t\t</>\n\t\t:\te.message\n\t:\te.message\n\nconst TabDescription = ({ children }: { children: React.ReactNode }) => (\n\t<p className=\"mb-2 text-sm\">{children}</p>\n)\n\nconst createTypeResult = (t: Type) => (\n\t<Tabs\n\t\titems={[\n\t\t\t\".expression\",\n\t\t\t\".description\",\n\t\t\t\".toJsonSchema()\",\n\t\t\t\".json\",\n\t\t\t\".precompilation\"\n\t\t]}\n\t\tstyle={{\n\t\t\tmaxHeight: \"400px\",\n\t\t\toverflow: \"auto\"\n\t\t}}\n\t>\n\t\t<Tab value=\".expression\">\n\t\t\t<TabDescription>\n\t\t\t\tSyntactic string similar to native TypeScript\n\t\t\t</TabDescription>\n\t\t\t<DynamicCodeBlock lang=\"ts\" code={t.expression} />\n\t\t</Tab>\n\t\t<Tab value=\".description\">\n\t\t\t<TabDescription>\n\t\t\t\tHuman-readable descriptions used for error messages\n\t\t\t</TabDescription>\n\t\t\t<DynamicCodeBlock lang=\"ts\" code={t.description} />\n\t\t</Tab>\n\t\t<Tab value=\".toJsonSchema()\">\n\t\t\t<TabDescription>JSON Schema this generates</TabDescription>\n\t\t\t<DynamicCodeBlock\n\t\t\t\tlang=\"json\"\n\t\t\t\tcode={tryCatch(\n\t\t\t\t\t() => JSON.stringify(t.toJsonSchema(), null, 4),\n\t\t\t\t\te => String(e)\n\t\t\t\t)}\n\t\t\t/>\n\t\t</Tab>\n\t\t<Tab value=\".json\">\n\t\t\t<TabDescription>\n\t\t\t\tSerialized representation of the Type's internal structure\n\t\t\t</TabDescription>\n\t\t\t<DynamicCodeBlock lang=\"json\" code={JSON.stringify(t.json, null, 4)} />\n\t\t</Tab>\n\t\t<Tab value=\".precompilation\">\n\t\t\t<TabDescription>JIT-optimized validation code</TabDescription>\n\t\t\t<DynamicCodeBlock lang=\"js\" code={t.precompilation!} />\n\t\t</Tab>\n\t</Tabs>\n)\n"
  },
  {
    "path": "ark/docs/components/playground/Playground.tsx",
    "content": "\"use client\"\n\nimport { unset } from \"@ark/util\"\nimport Editor, { useMonaco } from \"@monaco-editor/react\"\nimport { type } from \"arktype\"\nimport type * as Monaco from \"monaco-editor\"\nimport { loadWASM } from \"onigasm\"\nimport React, {\n\tuseCallback,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n\ttype RefObject\n} from \"react\"\nimport { setupCompletionProvider } from \"./completions.ts\"\nimport { setupErrorLens } from \"./errorLens.ts\"\nimport { executeCode, type ExecutionResult } from \"./execute.ts\"\nimport { formatEditor } from \"./format.ts\"\nimport { setupTextmateGrammar, theme } from \"./highlights.ts\"\nimport { setupHoverProvider } from \"./hovers.ts\"\nimport { ParseResult } from \"./ParseResult.tsx\"\nimport { RestoreDefault } from \"./RestoreDefault.tsx\"\nimport { ShareLink } from \"./ShareLink.tsx\"\nimport { TraverseResult } from \"./TraverseResult.tsx\"\nimport { getInitializedTypeScriptService } from \"./tsserver.ts\"\nimport {\n\tdecodePlaygroundCode,\n\tdefaultPlaygroundCode,\n\teditorFileUri,\n\tupdatePlaygroundUrl\n} from \"./utils.ts\"\n\nlet monacoInitialized = false\nlet tsLanguageServiceInstance: Monaco.languages.typescript.TypeScriptWorker | null =\n\tnull\n\nconst onigasmLoaded =\n\tglobalThis.window &&\n\tloadWASM(\"/onigasm.wasm\").catch(e => {\n\t\tif (!String(e).includes(\"subsequent calls are not allowed\")) throw e\n\t})\n\nconst setupMonaco = async (\n\tmonaco: typeof Monaco,\n\tinitialValue: string\n): Promise<Monaco.languages.typescript.TypeScriptWorker> => {\n\tif (!monacoInitialized) {\n\t\tawait onigasmLoaded\n\t\tmonaco.editor.defineTheme(\"arkdark\", theme)\n\t\tif (!tsLanguageServiceInstance) {\n\t\t\tconst ts = await getInitializedTypeScriptService(\n\t\t\t\tmonaco,\n\t\t\t\teditorFileUri,\n\t\t\t\tinitialValue\n\t\t\t)\n\t\t\tsetupHoverProvider(monaco, ts)\n\t\t\tsetupCompletionProvider(monaco, ts)\n\t\t\tawait setupTextmateGrammar(monaco)\n\t\t\ttsLanguageServiceInstance = ts\n\t\t\tmonacoInitialized = true\n\t\t}\n\t}\n\treturn tsLanguageServiceInstance!\n}\n\nconst stripTypes = async (): Promise<string | undefined> => {\n\tif (!tsLanguageServiceInstance) return\n\n\ttry {\n\t\tconst emitOutput =\n\t\t\tawait tsLanguageServiceInstance.getEmitOutput(editorFileUri)\n\t\tif (emitOutput.outputFiles.length) return emitOutput.outputFiles[0].text\n\t} catch (e) {\n\t\tconsole.error(\"Error transforming .ts to .js:\", e)\n\t}\n}\n\ntype LoadingState = \"unloaded\" | \"loading\" | \"loaded\"\n\nexport interface PlaygroundProps {\n\tinitialValue?: string\n\tstyle?: React.CSSProperties\n\tclassName?: string\n\twithResults?: boolean\n}\n\nexport const Playground = ({\n\tinitialValue,\n\tstyle,\n\tclassName,\n\twithResults\n}: PlaygroundProps) => {\n\tlet value: string\n\n\tif (initialValue) value = initialValue\n\telse if (globalThis.window?.location.search) {\n\t\t// decode initial contents from URL\n\t\tconst params = new URLSearchParams(window.location.search)\n\t\tconst encodedCode = params.get(\"code\")\n\t\tif (encodedCode) value = decodePlaygroundCode(encodedCode)\n\t}\n\n\tvalue ??= defaultPlaygroundCode\n\n\tconst [loadingState, setLoaded] = useState<LoadingState>(\n\t\tmonacoInitialized ? \"loaded\" : \"unloaded\"\n\t)\n\tconst [validationResult, setValidationResult] = useState<ExecutionResult>({\n\t\tparsed: type.unknown,\n\t\ttraversed: unset\n\t})\n\n\tconst monaco = useMonaco()\n\tconst editorRef = useRef<Monaco.editor.IStandaloneCodeEditor | null>(null)\n\tconst [currentCode, setCurrentCode] = useState<string>(value)\n\n\t// ts + monaco initialization\n\tuseEffect(() => {\n\t\tif (monaco && monacoInitialized && tsLanguageServiceInstance) {\n\t\t\tsetLoaded(\"loaded\")\n\t\t\treturn\n\t\t}\n\t\tif (monaco && loadingState !== \"loaded\") {\n\t\t\tif (loadingState === \"unloaded\") setLoaded(\"loading\")\n\t\t\telse {\n\t\t\t\tsetupMonaco(monaco, value)\n\t\t\t\t\t.then(() => setLoaded(\"loaded\"))\n\t\t\t\t\t.catch(err => {\n\t\t\t\t\t\tconsole.error(\"Failed to setup Monaco:\", err)\n\t\t\t\t\t\tsetLoaded(\"unloaded\")\n\t\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}, [monaco, loadingState, initialValue])\n\n\tconst validateNow = useCallback(\n\t\tasync (code: string) => {\n\t\t\tif (!tsLanguageServiceInstance) return\n\n\t\t\tsetCurrentCode(code)\n\t\t\tconst stripped = await stripTypes()\n\n\t\t\tif (!stripped) return\n\n\t\t\tconst result = executeCode(stripped)\n\t\t\tsetValidationResult(result)\n\t\t},\n\t\t[tsLanguageServiceInstance]\n\t)\n\n\tconst shareCode = useCallback(() => {\n\t\tif (editorRef.current) {\n\t\t\tconst code = editorRef.current.getValue()\n\t\t\tconst url = updatePlaygroundUrl(code)\n\t\t\treturn url\n\t\t}\n\t\treturn \"\"\n\t}, [editorRef])\n\n\t// handle external changes to initialValue (e.g., URL change)\n\tuseEffect(() => {\n\t\tif (editorRef.current) {\n\t\t\tconst currentEditorValue = editorRef.current.getValue()\n\t\t\tif (value !== currentEditorValue) editorRef.current.setValue(value)\n\t\t}\n\t\tsetCurrentCode(value)\n\t\tvalidateNow(value)\n\t}, [initialValue, validateNow])\n\n\tconst restoreDefault = () => {\n\t\teditorRef.current?.setValue(defaultPlaygroundCode)\n\t\tupdatePlaygroundUrl(defaultPlaygroundCode)\n\t\tvalidateNow(defaultPlaygroundCode)\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tclassName={className}\n\t\t\tstyle={{\n\t\t\t\tdisplay: \"grid\",\n\t\t\t\tgridTemplateColumns: withResults ? \"minmax(400px, 1fr) 600px\" : \"1fr\",\n\t\t\t\tgap: \"1rem\",\n\t\t\t\twidth: \"100%\",\n\t\t\t\theight: \"100%\",\n\t\t\t\talignItems: \"stretch\",\n\t\t\t\t...style\n\t\t\t}}\n\t\t>\n\t\t\t{loadingState === \"loaded\" && monaco ?\n\t\t\t\t<>\n\t\t\t\t\t<PlaygroundEditor\n\t\t\t\t\t\tdefaultValue={currentCode}\n\t\t\t\t\t\tvalidateNow={validateNow}\n\t\t\t\t\t\teditorRef={editorRef}\n\t\t\t\t\t\trestoreDefault={restoreDefault}\n\t\t\t\t\t\tshareCode={shareCode}\n\t\t\t\t\t\twithResults={withResults}\n\t\t\t\t\t/>\n\t\t\t\t\t{withResults && (\n\t\t\t\t\t\t<PlaygroundResults\n\t\t\t\t\t\t\t{...validationResult}\n\t\t\t\t\t\t\trestoreDefault={restoreDefault}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t</>\n\t\t\t:\t<PlaygroundLoader />}\n\t\t</div>\n\t)\n}\n\ntype PlaygroundEditorProps = {\n\tdefaultValue: string\n\teditorRef: RefObject<Monaco.editor.IStandaloneCodeEditor | null>\n\tvalidateNow: (code: string) => void\n\trestoreDefault: () => void\n\tshareCode: () => string\n\twithResults: boolean | undefined\n}\n\nconst PlaygroundEditor = React.memo(\n\t({\n\t\tdefaultValue,\n\t\teditorRef,\n\t\tvalidateNow,\n\t\trestoreDefault,\n\t\tshareCode,\n\t\twithResults\n\t}: PlaygroundEditorProps) => {\n\t\tconst handleChange = useCallback(\n\t\t\t(code: string | undefined) => {\n\t\t\t\tif (code !== undefined) validateNow(code)\n\t\t\t},\n\t\t\t[validateNow]\n\t\t)\n\n\t\tconst handleMount = useCallback(\n\t\t\t(\n\t\t\t\teditor: Monaco.editor.IStandaloneCodeEditor,\n\t\t\t\tmonacoInstance: typeof Monaco\n\t\t\t) => {\n\t\t\t\teditorRef.current = editor\n\t\t\t\tif (tsLanguageServiceInstance)\n\t\t\t\t\tsetupErrorLens(monacoInstance, editor, tsLanguageServiceInstance)\n\n\t\t\t\t// on-save (ctrl+s) formatting + validation, update URL\n\t\t\t\teditor.onKeyDown(e => {\n\t\t\t\t\tconst monaco = (window as any).monaco\n\t\t\t\t\tif (!monaco) return\n\t\t\t\t\tif (e.keyCode === monaco.KeyCode.KeyS && (e.ctrlKey || e.metaKey)) {\n\t\t\t\t\t\te.preventDefault()\n\t\t\t\t\t\tformatEditor(editor).then(formattedCode => {\n\t\t\t\t\t\t\tconst codeToSave = formattedCode ?? editor.getValue()\n\t\t\t\t\t\t\tif (formattedCode) editor.setValue(formattedCode)\n\t\t\t\t\t\t\tvalidateNow(codeToSave)\n\t\t\t\t\t\t\tshareCode()\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t},\n\t\t\t[editorRef, shareCode, validateNow]\n\t\t)\n\n\t\treturn (\n\t\t\t// add z-index to ensure hovers are displayed above navbar\n\t\t\t<div className=\"relative z-50\">\n\t\t\t\t<Editor\n\t\t\t\t\twidth=\"100%\"\n\t\t\t\t\tdefaultLanguage=\"typescript\"\n\t\t\t\t\tdefaultValue={defaultValue}\n\t\t\t\t\tpath={editorFileUri}\n\t\t\t\t\ttheme=\"arkdark\"\n\t\t\t\t\toptions={{\n\t\t\t\t\t\tminimap: { enabled: false },\n\t\t\t\t\t\tscrollBeyondLastLine: false,\n\t\t\t\t\t\tquickSuggestions: { strings: \"on\" },\n\t\t\t\t\t\tquickSuggestionsDelay: 0,\n\t\t\t\t\t\tsmoothScrolling: true,\n\t\t\t\t\t\tautomaticLayout: true,\n\t\t\t\t\t\tcursorBlinking: \"smooth\",\n\t\t\t\t\t\tcursorSmoothCaretAnimation: \"on\",\n\t\t\t\t\t\tfontFamily: \"'Cascadia Code',Consolas,'Courier New',monospace\",\n\t\t\t\t\t\tpadding: {\n\t\t\t\t\t\t\ttop: 16\n\t\t\t\t\t\t}\n\t\t\t\t\t}}\n\t\t\t\t\tonMount={handleMount}\n\t\t\t\t\tonChange={handleChange}\n\t\t\t\t/>\n\t\t\t\t{\n\t\t\t\t\t// only include these buttons in expanded mode\n\t\t\t\t\twithResults ?\n\t\t\t\t\t\t<div className=\"absolute top-2 right-2 flex gap-2\">\n\t\t\t\t\t\t\t<ShareLink onShare={shareCode} />\n\t\t\t\t\t\t\t<RestoreDefault variant=\"icon\" onClick={restoreDefault} />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t:\tnull\n\t\t\t\t}\n\t\t\t</div>\n\t\t)\n\t}\n)\n\ninterface PlaygroundResultsProps extends ExecutionResult {\n\trestoreDefault: () => void\n}\n\nconst PlaygroundLoader = () => (\n\t<div className=\"flex items-center justify-center h-full gap-4\">\n\t\t<div className=\"animate-spin rounded-full h-16 w-16 border-t-2 border-b-2 border-blue-500\"></div>\n\t\t<p className=\"ml-4 text-lg text-gray-600\">Loading playground...</p>\n\t</div>\n)\n\nconst PlaygroundResults = (result: PlaygroundResultsProps) => (\n\t<div className=\"flex flex-col h-full gap-4\">\n\t\t<div className=\"flex-[2] min-h-0\">\n\t\t\t<ParseResult {...result} />\n\t\t</div>\n\t\t<div className=\"flex-[1] min-h-0\">\n\t\t\t<TraverseResult {...result} />\n\t\t</div>\n\t</div>\n)\n"
  },
  {
    "path": "ark/docs/components/playground/PlaygroundTabs.tsx",
    "content": "\"use client\"\n\nimport { hasDomain, type dict } from \"@ark/util\"\nimport { cx } from \"class-variance-authority\"\nimport React, { Children, isValidElement, useMemo, useState } from \"react\"\n\ninterface TabProps {\n\tvalue: string\n\tchildren: React.ReactNode\n}\n\nexport const Tab = (_: TabProps) => null\n\ninterface TabsProps {\n\titems: string[]\n\tchildren: React.ReactNode\n\tdefaultTab?: string\n\tclassName?: string\n\tstyle?: React.CSSProperties\n\ttabListClassName?: string\n\ttabButtonClassName?: string\n\tactiveTabButtonClassName?: string\n\ttabContentClassName?: string\n}\n\nexport const Tabs = ({\n\titems,\n\tchildren,\n\tdefaultTab,\n\tclassName,\n\tstyle,\n\ttabListClassName,\n\ttabButtonClassName,\n\tactiveTabButtonClassName,\n\ttabContentClassName\n}: TabsProps) => {\n\tconst validChildren = useMemo(\n\t\t() =>\n\t\t\tChildren.toArray(children).filter(\n\t\t\t\t(child): child is React.ReactElement<TabProps> =>\n\t\t\t\t\tisValidElement(child) &&\n\t\t\t\t\thasDomain(child.props, \"object\") &&\n\t\t\t\t\ttypeof (child.props as dict).value === \"string\"\n\t\t\t),\n\t\t[children]\n\t)\n\n\tconst initialTab =\n\t\tdefaultTab && items.includes(defaultTab) ? defaultTab : items[0]\n\tconst [activeTab, setActiveTab] = useState<string>(initialTab)\n\n\tconst activeTabContent = useMemo(() => {\n\t\tconst activeChild = validChildren.find(\n\t\t\tchild => child.props.value === activeTab\n\t\t)\n\t\treturn activeChild ? activeChild.props.children : null\n\t}, [activeTab, validChildren])\n\n\treturn (\n\t\t<div className={cx(\"flex flex-col\", className)} style={style}>\n\t\t\t<div\n\t\t\t\tclassName={cx(\n\t\t\t\t\t\"flex border-b border-border mb-4 flex-shrink-0\",\n\t\t\t\t\ttabListClassName\n\t\t\t\t)}\n\t\t\t\trole=\"tablist\"\n\t\t\t>\n\t\t\t\t{items.map(value => {\n\t\t\t\t\tconst isActive = activeTab === value\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\tkey={value}\n\t\t\t\t\t\t\trole=\"tab\"\n\t\t\t\t\t\t\taria-selected={isActive}\n\t\t\t\t\t\t\taria-controls={`tabpanel-${value}`}\n\t\t\t\t\t\t\tid={`tab-${value}`}\n\t\t\t\t\t\t\tonClick={() => setActiveTab(value)}\n\t\t\t\t\t\t\tclassName={cx(\n\t\t\t\t\t\t\t\t\"px-4 py-2 -mb-px border-b-2 text-sm font-medium transition-colors duration-150 ease-in-out\",\n\t\t\t\t\t\t\t\t\"focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2\", // Focus styles\n\t\t\t\t\t\t\t\tisActive ?\n\t\t\t\t\t\t\t\t\t\"border-primary text-primary\"\n\t\t\t\t\t\t\t\t:\t\"border-transparent text-muted-foreground hover:border-border hover:text-foreground\",\n\t\t\t\t\t\t\t\ttabButtonClassName,\n\t\t\t\t\t\t\t\tisActive && activeTabButtonClassName\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{value}\n\t\t\t\t\t\t</button>\n\t\t\t\t\t)\n\t\t\t\t})}\n\t\t\t</div>\n\t\t\t<div\n\t\t\t\trole=\"tabpanel\"\n\t\t\t\tid={`tabpanel-${activeTab}`}\n\t\t\t\taria-labelledby={`tab-${activeTab}`}\n\t\t\t\tclassName={cx(\"flex-grow min-h-0 overflow-y-auto\", tabContentClassName)}\n\t\t\t>\n\t\t\t\t{activeTabContent}\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n"
  },
  {
    "path": "ark/docs/components/playground/RestoreDefault.tsx",
    "content": "import { cx } from \"class-variance-authority\"\nimport { RotateCcwIcon } from \"lucide-react\"\n\nexport interface RestoreDefaultProps {\n\tonClick: () => void\n\tvariant?: \"full\" | \"icon\"\n\tclassName?: string\n}\n\nexport const RestoreDefault = ({\n\tonClick,\n\tvariant = \"full\",\n\tclassName\n}: RestoreDefaultProps) => {\n\tif (variant === \"icon\") {\n\t\treturn (\n\t\t\t<button\n\t\t\t\tclassName={cx(\n\t\t\t\t\t\"absolute top-4 right-16 p-2 rounded-lg cursor-pointer\",\n\t\t\t\t\t\"bg-blue-900/50 hover:bg-blue-900 transition-colors\",\n\t\t\t\t\t\"text-white/70 hover:text-white\",\n\t\t\t\t\t\"backdrop-blur-sm\",\n\t\t\t\t\tclassName\n\t\t\t\t)}\n\t\t\t\tonClick={onClick}\n\t\t\t\ttitle=\"Restore Default Code\"\n\t\t\t>\n\t\t\t\t<RotateCcwIcon size={16} />\n\t\t\t</button>\n\t\t)\n\t}\n\n\treturn (\n\t\t<button\n\t\t\tclassName={cx(\n\t\t\t\t\"mt-4 px-4 py-2 bg-blue-900 text-white rounded cursor-pointer\",\n\t\t\t\t\"hover:bg-blue-950 transition-colors\",\n\t\t\t\t\"flex items-center gap-2\",\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\tonClick={onClick}\n\t\t>\n\t\t\t<RotateCcwIcon size={16} />\n\t\t\tRestore Default Code\n\t\t</button>\n\t)\n}\n"
  },
  {
    "path": "ark/docs/components/playground/ShareLink.tsx",
    "content": "import { cx } from \"class-variance-authority\"\nimport { CheckIcon, LinkIcon } from \"lucide-react\"\nimport { useState } from \"react\"\nimport { copyToClipboard } from \"./utils.ts\"\n\nexport interface ShareLinkProps {\n\tonShare: () => string\n\tclassName?: string\n}\n\nexport const ShareLink = ({ onShare, className }: ShareLinkProps) => {\n\tconst [copied, setCopied] = useState(false)\n\n\tconst handleClick = async () => {\n\t\tconst url = onShare()\n\t\tconst success = await copyToClipboard(url)\n\n\t\tif (success) {\n\t\t\tsetCopied(true)\n\t\t\tsetTimeout(() => setCopied(false), 2000)\n\t\t}\n\t}\n\n\treturn (\n\t\t<button\n\t\t\tclassName={cx(\n\t\t\t\t\"absolute top-4 right-4 p-2 rounded-lg cursor-pointer\",\n\t\t\t\t\"bg-blue-900/50 hover:bg-blue-900 transition-colors\",\n\t\t\t\t\"text-white/70 hover:text-white\",\n\t\t\t\t\"backdrop-blur-sm\",\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\tonClick={handleClick}\n\t\t\ttitle=\"Copy shareable link\"\n\t\t>\n\t\t\t{copied ?\n\t\t\t\t<CheckIcon size={16} />\n\t\t\t:\t<LinkIcon size={16} />}\n\t\t</button>\n\t)\n}\n"
  },
  {
    "path": "ark/docs/components/playground/TraverseResult.tsx",
    "content": "import { hasArkKind } from \"@ark/schema\"\nimport { printable, unset } from \"@ark/util\"\nimport type { type } from \"arktype\"\nimport { type ResultKind, backgroundsByResultKind } from \"./utils.ts\"\n\nexport type TraverseResult = type.errors | unset | {} | null | undefined\n\nexport declare namespace TraverseResult {\n\texport type Props = {\n\t\ttraversed: TraverseResult\n\t}\n}\n\nexport const TraverseResult = ({ traversed }: TraverseResult.Props) => {\n\tconst resultKind: ResultKind =\n\t\thasArkKind(traversed, \"errors\") ? \"failure\"\n\t\t: traversed === unset ? \"none\"\n\t\t: \"success\"\n\n\treturn (\n\t\t<div\n\t\t\tstyle={{\n\t\t\t\tbackgroundColor: backgroundsByResultKind[resultKind]\n\t\t\t}}\n\t\t\tclassName=\"glass-container h-full p-4 rounded-2xl overflow-auto\"\n\t\t>\n\t\t\t<h3 className=\"text-3xl text-fd-foreground font-semibold mb-2\">\n\t\t\t\t{resultKind === \"failure\" ? \"ArkErrors\" : \"Out\"}\n\t\t\t</h3>\n\t\t\t{\n\t\t\t\t<pre className=\"m-0 whitespace-pre-wrap\">\n\t\t\t\t\t<code>\n\t\t\t\t\t\t{resultKind === \"none\" ?\n\t\t\t\t\t\t\t\"(variable was never set)\"\n\t\t\t\t\t\t: resultKind === \"failure\" ?\n\t\t\t\t\t\t\t(traversed as type.errors).summary\n\t\t\t\t\t\t:\tprintable(traversed, { quoteKeys: false, indent: 4 })}\n\t\t\t\t\t</code>\n\t\t\t\t</pre>\n\t\t\t}\n\t\t</div>\n\t)\n}\n"
  },
  {
    "path": "ark/docs/components/playground/completions.ts",
    "content": "import type * as Monaco from \"monaco-editor\"\nimport type { CompletionInfo, ScriptElementKind } from \"typescript\"\nimport { createPositionHash, isDuplicateRequest } from \"./utils.ts\"\n\nexport const getCompletions = async (\n\ttsLanguageService: Monaco.languages.typescript.TypeScriptWorker,\n\tmodel: Monaco.editor.ITextModel,\n\tposition: Monaco.Position\n) => {\n\tconst uri = model.uri.toString()\n\tconst offset = model.getOffsetAt(position)\n\treturn await tsLanguageService.getCompletionsAtPosition(uri, offset)\n}\n\nexport const setupCompletionProvider = (\n\tmonaco: typeof Monaco,\n\ttsLanguageService: Monaco.languages.typescript.TypeScriptWorker\n) =>\n\tmonaco.languages.registerCompletionItemProvider(\"typescript\", {\n\t\ttriggerCharacters: [\".\", '\"', \"'\", \"`\", \"/\", \"@\", \"<\", \"#\", \" \"],\n\t\tprovideCompletionItems: async (model, position) => {\n\t\t\tconst positionHash = createPositionHash(model, position)\n\t\t\tif (isDuplicateRequest(positionHash)) return { suggestions: [] }\n\n\t\t\tconst completions = await getCompletions(\n\t\t\t\ttsLanguageService,\n\t\t\t\tmodel,\n\t\t\t\tposition\n\t\t\t)\n\t\t\tif (!completions) return { suggestions: [] }\n\n\t\t\treturn formatCompletions(completions, model, position)\n\t\t}\n\t})\n\nconst formatCompletions = (\n\tcompletions: CompletionInfo,\n\tmodel: Monaco.editor.ITextModel,\n\tposition: Monaco.Position\n) => {\n\tconst suggestions = completions.entries.map(entry => {\n\t\tconst start =\n\t\t\tentry.replacementSpan ?\n\t\t\t\tmodel.getPositionAt(entry.replacementSpan.start)\n\t\t\t:\tposition\n\n\t\tconst end =\n\t\t\tentry.replacementSpan ?\n\t\t\t\tmodel.getPositionAt(\n\t\t\t\t\tentry.replacementSpan.start + entry.replacementSpan.length\n\t\t\t\t)\n\t\t\t:\tposition\n\n\t\tconst range = {\n\t\t\tstartLineNumber: start.lineNumber,\n\t\t\tstartColumn: start.column,\n\t\t\tendLineNumber: end.lineNumber,\n\t\t\tendColumn: end.column\n\t\t}\n\n\t\treturn {\n\t\t\tlabel: entry.name,\n\t\t\tkind: tsToMonacoCompletionKinds[entry.kind],\n\t\t\tinsertText: entry.name,\n\t\t\trange,\n\t\t\tsortText: entry.sortText,\n\t\t\tdetail: entry.kind\n\t\t}\n\t})\n\n\treturn { suggestions }\n}\n\n// Mirror Monaco.languages.CompletionItemKind\n// since importing Monaco directly at runtime causes issues\nconst MonacoCompletionKind = {\n\tMethod: 0,\n\tFunction: 1,\n\tConstructor: 2,\n\tField: 3,\n\tVariable: 4,\n\tClass: 5,\n\tStruct: 6,\n\tInterface: 7,\n\tModule: 8,\n\tProperty: 9,\n\tEvent: 10,\n\tOperator: 11,\n\tUnit: 12,\n\tValue: 13,\n\tConstant: 14,\n\tEnum: 15,\n\tEnumMember: 16,\n\tKeyword: 17,\n\tText: 18,\n\tColor: 19,\n\tFile: 20,\n\tReference: 21,\n\tCustomcolor: 22,\n\tFolder: 23,\n\tTypeParameter: 24,\n\tUser: 25,\n\tIssue: 26,\n\tSnippet: 27\n} as const\n\nconst tsToMonacoCompletionKinds: Record<\n\tScriptElementKind,\n\tMonaco.languages.CompletionItemKind\n> = {\n\t\"\": MonacoCompletionKind.Text,\n\n\t// Variable declarations\n\tconst: MonacoCompletionKind.Constant,\n\tlet: MonacoCompletionKind.Variable,\n\tvar: MonacoCompletionKind.Variable,\n\t\"local var\": MonacoCompletionKind.Variable,\n\n\t// Functions and methods\n\tfunction: MonacoCompletionKind.Function,\n\t\"local function\": MonacoCompletionKind.Function,\n\t\"local class\": MonacoCompletionKind.Class,\n\tmethod: MonacoCompletionKind.Method,\n\tgetter: MonacoCompletionKind.Method,\n\tsetter: MonacoCompletionKind.Method,\n\tconstructor: MonacoCompletionKind.Constructor,\n\n\t// Types, interfaces, and classes\n\tclass: MonacoCompletionKind.Class,\n\tinterface: MonacoCompletionKind.Interface,\n\tenum: MonacoCompletionKind.Enum,\n\ttype: MonacoCompletionKind.Reference,\n\t\"enum member\": MonacoCompletionKind.EnumMember,\n\t\"primitive type\": MonacoCompletionKind.Value,\n\t\"type parameter\": MonacoCompletionKind.TypeParameter,\n\talias: MonacoCompletionKind.Reference,\n\n\t// Properties and parameters\n\tproperty: MonacoCompletionKind.Property,\n\tparameter: MonacoCompletionKind.Variable,\n\n\t// Modules, scripts, and file system\n\tmodule: MonacoCompletionKind.Module,\n\tscript: MonacoCompletionKind.File,\n\tdirectory: MonacoCompletionKind.Folder,\n\n\t// Special types\n\tkeyword: MonacoCompletionKind.Keyword,\n\tcall: MonacoCompletionKind.Function,\n\tindex: MonacoCompletionKind.Value,\n\tconstruct: MonacoCompletionKind.Constructor,\n\t\"JSX attribute\": MonacoCompletionKind.Property,\n\tstring: MonacoCompletionKind.Constant,\n\tlink: MonacoCompletionKind.Reference,\n\t\"link name\": MonacoCompletionKind.Text,\n\t\"link text\": MonacoCompletionKind.Text,\n\tlabel: MonacoCompletionKind.Text,\n\twarning: MonacoCompletionKind.Issue,\n\tusing: MonacoCompletionKind.Keyword,\n\t\"await using\": MonacoCompletionKind.Keyword,\n\taccessor: MonacoCompletionKind.Keyword,\n\t\"external module name\": MonacoCompletionKind.Module\n}\n"
  },
  {
    "path": "ark/docs/components/playground/errorLens.ts",
    "content": "import extensionPackage from \"arkdark/package.json\" with { type: \"json\" }\nimport arkdarkColors from \"arkthemes/arkdark.json\" with { type: \"json\" }\nimport type * as Monaco from \"monaco-editor\"\n\nexport const setupErrorLens = (\n\tmonaco: typeof Monaco,\n\teditor: Monaco.editor.IStandaloneCodeEditor,\n\ttsLanguageService: Monaco.languages.typescript.TypeScriptWorker\n) => {\n\tconst styleElement = document.createElement(\"style\")\n\tstyleElement.textContent = styles\n\tdocument.head.appendChild(styleElement)\n\n\tlet decorationCollection: Monaco.editor.IEditorDecorationsCollection | null =\n\t\tnull\n\n\tconst updateDiagnostics = async () => {\n\t\tconst diagnostics = await getDiagnostics(\n\t\t\ttsLanguageService,\n\t\t\teditor.getModel()!\n\t\t)\n\n\t\tif (decorationCollection) decorationCollection.clear()\n\n\t\tconst model = editor.getModel()\n\t\tif (!model) return\n\n\t\t// group diagnostics by line to only show one error per line\n\t\tconst diagnosticsByLine = new Map<\n\t\t\tnumber,\n\t\t\tMonaco.languages.typescript.Diagnostic\n\t\t>()\n\n\t\tfor (const diag of diagnostics) {\n\t\t\tif (!diag.start) continue\n\t\t\tconst startPosition = model.getPositionAt(diag.start)\n\t\t\tconst lineNumber = startPosition.lineNumber\n\n\t\t\tif (!diagnosticsByLine.has(lineNumber))\n\t\t\t\tdiagnosticsByLine.set(lineNumber, diag)\n\t\t}\n\n\t\tconst decorations: Monaco.editor.IModelDeltaDecoration[] = Array.from(\n\t\t\tdiagnosticsByLine.entries()\n\t\t).map(([lineNumber, diag]) => {\n\t\t\tlet messageText =\n\t\t\t\ttypeof diag.messageText === \"object\" ?\n\t\t\t\t\tdiag.messageText.messageText\n\t\t\t\t:\tdiag.messageText\n\n\t\t\tmessageText = applyReplacements(messageText)\n\n\t\t\tconst lineContent = model.getLineContent(lineNumber)\n\t\t\tconst endOfLine = lineContent.length + 1\n\n\t\t\treturn {\n\t\t\t\trange: new monaco.Range(lineNumber, 1, lineNumber, endOfLine),\n\t\t\t\toptions: {\n\t\t\t\t\tisWholeLine: true,\n\t\t\t\t\tclassName: \"error-bg\",\n\t\t\t\t\tafter: {\n\t\t\t\t\t\tcontent: `    ${messageText}`,\n\t\t\t\t\t\tinlineClassName: \"error-text\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\n\t\tdecorationCollection = editor.createDecorationsCollection(decorations)\n\t}\n\n\tupdateDiagnostics()\n\n\teditor.onDidChangeModelContent(() => {\n\t\t// small delay to allow TS service to process changes\n\t\tsetTimeout(updateDiagnostics, 300)\n\t})\n}\n\ntype ErrorLensReplacement = {\n\tmatcher: RegExp\n\tmessage: string\n}\n\nconst errorLensReplacements: ErrorLensReplacement[] =\n\textensionPackage.contributes.configurationDefaults[\"errorLens.replace\"].map(\n\t\tsrc => ({ matcher: new RegExp(src.matcher, \"iu\"), message: src.message })\n\t)\n\n// apply errorLens.replace config to diagnostic message,\n// extracting arktype errors for inline display based on:\n// https://github.com/usernamehw/vscode-error-lens/blob/019d29b010f85ebb6e25c5f7f8ffda83479bfda0/src/utils/extUtils.ts#L184\nconst applyReplacements = (message: string): string => {\n\tfor (const transformation of errorLensReplacements) {\n\t\tconst matchResult = transformation.matcher.exec(message)\n\t\tif (matchResult) {\n\t\t\tmessage = transformation.message\n\t\t\t// replace groups like $0 and $1 with groups from the match\n\t\t\tfor (let groupIndex = 0; groupIndex < matchResult.length; groupIndex++) {\n\t\t\t\tmessage = message.replace(\n\t\t\t\t\tnew RegExp(`\\\\$${groupIndex}`, \"gu\"),\n\t\t\t\t\tmatchResult[Number(groupIndex)]\n\t\t\t\t)\n\t\t\t}\n\n\t\t\treturn message\n\t\t}\n\t}\n\n\treturn message\n}\n\nconst getDiagnostics = async (\n\ttsLanguageService: Monaco.languages.typescript.TypeScriptWorker,\n\tmodel: Monaco.editor.ITextModel\n): Promise<Monaco.languages.typescript.Diagnostic[]> => {\n\tconst uri = model.uri.toString()\n\tconst syntacticDiagnostics =\n\t\tawait tsLanguageService.getSyntacticDiagnostics(uri)\n\tconst semanticDiagnostics =\n\t\tawait tsLanguageService.getSemanticDiagnostics(uri)\n\n\treturn [...syntacticDiagnostics, ...semanticDiagnostics]\n}\n\nconst styles = `\n    .error-bg {\n        background-color: ${arkdarkColors.colors[\"errorLens.errorBackground\"]};\n    }\n    .error-text {\n        color:  ${arkdarkColors.colors[\"errorLens.errorForeground\"]};\n        font-style: italic;\n    }\n`\n"
  },
  {
    "path": "ark/docs/components/playground/execute.ts",
    "content": "import { unset } from \"@ark/util\"\nimport * as arktypeExports from \"arktype\"\nimport type { ParseResult } from \"./ParseResult.tsx\"\nimport type { TraverseResult } from \"./TraverseResult.tsx\"\nimport {\n\tplaygroundOutVariableName,\n\tplaygroundTypeVariableName\n} from \"./utils.ts\"\n\nexport interface ExecutionResult {\n\tparsed: ParseResult\n\ttraversed: TraverseResult\n}\n\nif (!(\"type\" in globalThis)) Object.assign(globalThis, arktypeExports)\n\nexport const executeCode = (code: string): ExecutionResult => {\n\tconst isolatedUserCode = code\n\t\t.replace(/^\\s*import .*\\n/g, \"\")\n\t\t.replace(/^\\s*export\\s+const/gm, \"const\")\n\n\ttry {\n\t\tconst wrappedCode = `${isolatedUserCode}\n        return { ${playgroundTypeVariableName}, ${playgroundOutVariableName} }`\n\n\t\tconst result = new Function(wrappedCode)()\n\t\tconst {\n\t\t\t[playgroundTypeVariableName]: parsed,\n\t\t\t[playgroundOutVariableName]: traversed\n\t\t} = result\n\n\t\treturn {\n\t\t\tparsed,\n\t\t\ttraversed\n\t\t}\n\t} catch (e) {\n\t\treturn {\n\t\t\tparsed:\n\t\t\t\te instanceof Error ? e : new ReferenceError(playgroundTypeVariableName),\n\t\t\ttraversed: unset\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "ark/docs/components/playground/format.ts",
    "content": "import type * as Monaco from \"monaco-editor\"\nimport prettierPluginEstree from \"prettier/plugins/estree\"\nimport prettierPluginTypeScript from \"prettier/plugins/typescript\"\nimport prettier from \"prettier/standalone\"\n\nexport const formatEditor = async (\n\teditor: Monaco.editor.IStandaloneCodeEditor\n): Promise<string | undefined> => {\n\tconst model = editor.getModel()\n\tif (!model) return\n\n\ttry {\n\t\tconst currentCode = editor.getValue()\n\t\tconst cursorPosition = editor.getPosition()\n\t\tconst cursorOffset = model.getOffsetAt(cursorPosition!)!\n\n\t\tconst result = await prettier.formatWithCursor(currentCode, {\n\t\t\tparser: \"typescript\",\n\t\t\tcursorOffset,\n\t\t\tplugins: [prettierPluginEstree, prettierPluginTypeScript],\n\t\t\tsemi: false,\n\t\t\tuseTabs: true,\n\t\t\ttrailingComma: \"none\",\n\t\t\texperimentalTernaries: true\n\t\t})\n\t\tmodel.setValue(result.formatted)\n\t\teditor.setPosition(model.getPositionAt(result.cursorOffset))\n\t} catch {\n\t\t// could have invalid syntax etc., fail silently\n\t}\n}\n"
  },
  {
    "path": "ark/docs/components/playground/highlights.ts",
    "content": "import arktypeTextmate from \"arkdark/tsWithArkType.tmLanguage.json\" with { type: \"json\" }\nimport arkdarkColors from \"arkthemes/arkdark.json\" with { type: \"json\" }\nimport type * as Monaco from \"monaco-editor\"\nimport { wireTmGrammars } from \"monaco-editor-textmate\"\nimport { Registry } from \"monaco-textmate\"\n\ninterface VSCodeTheme {\n\tcolors: {\n\t\t[name: string]: string\n\t}\n\ttokenColors: TokenColor[]\n}\n\ninterface TokenColor {\n\tscope: string | string[]\n\tsettings: {\n\t\tforeground?: string\n\t\tbackground?: string\n\t\tfontStyle?: string\n\t}\n}\n\nconst vsCodeThemeToMonaco = (\n\ttheme: VSCodeTheme\n): Monaco.editor.IStandaloneThemeData => ({\n\tbase: \"vs-dark\",\n\tinherit: false,\n\tcolors: theme.colors,\n\trules: arkdarkColors.tokenColors.flatMap(c =>\n\t\tArray.isArray(c.scope) ?\n\t\t\tc.scope.map(token => ({ token, ...c.settings }))\n\t\t:\t[{ token: c.scope, ...c.settings }]\n\t)\n})\n\nexport const theme = vsCodeThemeToMonaco(arkdarkColors)\n\nexport const setupTextmateGrammar = async (monaco: typeof Monaco) =>\n\tawait wireTmGrammars(\n\t\tmonaco,\n\t\tnew Registry({\n\t\t\tgetGrammarDefinition: async () => ({\n\t\t\t\tformat: \"json\",\n\t\t\t\tcontent: arktypeTextmate\n\t\t\t})\n\t\t}),\n\t\tnew Map().set(\"typescript\", \"source.ts\")\n\t)\n"
  },
  {
    "path": "ark/docs/components/playground/hovers.ts",
    "content": "import type * as Monaco from \"monaco-editor\"\nimport { createPositionHash, isDuplicateRequest } from \"./utils.ts\"\n\ntype DisplayPart = {\n\ttext: string\n}\n\nconst formatHoverInfo = (\n\thoverInfo: any,\n\tmodel: Monaco.editor.ITextModel\n): Monaco.languages.ProviderResult<Monaco.languages.Hover> => {\n\tif (!hoverInfo.displayParts) return\n\n\tconst displayText = hoverInfo.displayParts\n\t\t.map((part: DisplayPart) => part.text)\n\t\t.join(\"\")\n\t\t// when bundling .d.ts, tsup creates synthetic aliases like Type$6\n\t\t// for name collisions. remove them to reflect the actual editor experience\n\t\t.replace(/Type\\$\\d+/g, \"Type\")\n\n\tconst contents = [{ value: \"```typescript\\n\" + displayText + \"\\n```\" }]\n\n\tif (hoverInfo.documentation) {\n\t\tconst docs = hoverInfo.documentation\n\t\t\t.map((part: DisplayPart) => part.text)\n\t\t\t.join(\"\\n\\n\")\n\n\t\tif (docs.trim()) contents.push({ value: docs })\n\t}\n\n\treturn {\n\t\tcontents,\n\t\trange: getHoverRange(model, hoverInfo.textSpan)\n\t}\n}\n\nconst getHoverRange = (\n\tmodel: Monaco.editor.ITextModel,\n\ttextSpan: { start: number; length: number }\n): Monaco.IRange => {\n\tconst start = model.getPositionAt(textSpan.start)\n\tconst end = model.getPositionAt(textSpan.start + textSpan.length)\n\n\treturn {\n\t\tstartLineNumber: start.lineNumber,\n\t\tstartColumn: start.column,\n\t\tendLineNumber: end.lineNumber,\n\t\tendColumn: end.column\n\t}\n}\n\nexport const setupHoverProvider = (\n\tmonaco: typeof Monaco,\n\ttsLanguageService: Monaco.languages.typescript.TypeScriptWorker\n): void => {\n\tmonaco.languages.registerHoverProvider(\"typescript\", {\n\t\tprovideHover: async (model, position) => {\n\t\t\tconst positionHash = createPositionHash(model, position)\n\t\t\tif (isDuplicateRequest(positionHash)) return null\n\n\t\t\tconst uri = model.uri.toString()\n\t\t\tconst offset = model.getOffsetAt(position)\n\t\t\tconst hoverInfo = await tsLanguageService.getQuickInfoAtPosition(\n\t\t\t\turi,\n\t\t\t\toffset\n\t\t\t)\n\n\t\t\tif (!hoverInfo) return null\n\t\t\treturn formatHoverInfo(hoverInfo, model)\n\t\t}\n\t})\n}\n"
  },
  {
    "path": "ark/docs/components/playground/tsserver.ts",
    "content": "import type * as Monaco from \"monaco-editor\"\nimport { regexDts } from \"../dts/regex.ts\"\nimport { schemaDts } from \"../dts/schema.ts\"\nimport { typeDts } from \"../dts/type.ts\"\nimport { utilDts } from \"../dts/util.ts\"\n\nconst configureTypeScript = (monaco: typeof Monaco): void => {\n\tconst tsDefaultModeConfig = (\n\t\tmonaco.languages.typescript.typescriptDefaults as any\n\t)._modeConfiguration\n\ttsDefaultModeConfig.hovers = false\n\ttsDefaultModeConfig.completionItems = false\n\n\tmonaco.languages.typescript.typescriptDefaults.setCompilerOptions({\n\t\tstrict: true,\n\t\texactOptionalPropertyTypes: true,\n\t\ttarget: monaco.languages.typescript.ScriptTarget.ESNext,\n\t\tmoduleResolution: monaco.languages.typescript.ModuleResolutionKind.NodeJs,\n\t\tallowNonTsExtensions: true\n\t})\n\n\tmonaco.languages.typescript.typescriptDefaults.addExtraLib(utilDts)\n\tmonaco.languages.typescript.typescriptDefaults.addExtraLib(schemaDts)\n\tmonaco.languages.typescript.typescriptDefaults.addExtraLib(typeDts)\n\tmonaco.languages.typescript.typescriptDefaults.addExtraLib(regexDts)\n}\n\nexport const getInitializedTypeScriptService = async (\n\tmonaco: typeof Monaco,\n\teditorFileUri: string,\n\tcontents: string\n): Promise<Monaco.languages.typescript.TypeScriptWorker> => {\n\tconst targetUri = monaco.Uri.parse(editorFileUri)\n\tconfigureTypeScript(monaco)\n\n\tif (!monaco.editor.getModel(targetUri))\n\t\tmonaco.editor.createModel(contents, \"typescript\", targetUri)\n\n\tconst worker = await monaco.languages.typescript.getTypeScriptWorker()\n\treturn await worker(targetUri)\n}\n"
  },
  {
    "path": "ark/docs/components/playground/utils.ts",
    "content": "import type * as Monaco from \"monaco-editor\"\n\nexport const playgroundTypeVariableName = \"Thing\"\n\nexport const playgroundOutVariableName = \"out\"\n\nexport const defaultPlaygroundCode = `import { type } from \"arktype\"\n\nconst ${playgroundTypeVariableName} = type({\n\tname: \"string\",\n\t\"versions?\": \"(number | string)[]\"\n})\n\nconst ${playgroundOutVariableName} = ${playgroundTypeVariableName}({\n    name: \"TypeScript\",\n    versions: [\"5.8.2\", 6, 7n]\n})\n`\n\nexport const editorFileUri = \"file:///main.ts\"\n\nexport type ResultKind = \"failure\" | \"success\" | \"none\"\n\nexport const backgroundsByResultKind: Record<ResultKind, string> = {\n\tfailure: \"#17080888\",\n\tsuccess: \"#08161788\",\n\tnone: \"#080d17\"\n}\n\ntype RequestMap = Map<string, number>\n\nconst duplicateThresholdMs = 50\n\nconst recentRequests: RequestMap = new Map()\n\nexport const createPositionHash = (\n\tmodel: Monaco.editor.ITextModel,\n\tposition: Monaco.Position\n): string => `${model.uri}:${position.lineNumber}:${position.column}`\n\nexport const isDuplicateRequest = (positionHash: string): boolean => {\n\tconst now = Date.now()\n\tconst lastRequest = recentRequests.get(positionHash)\n\n\tif (lastRequest && now - lastRequest < duplicateThresholdMs) return true\n\n\trecentRequests.set(positionHash, now)\n\treturn false\n}\n\nexport const encodePlaygroundCode = (code: string): string =>\n\tencodeURIComponent(code)\n\nexport const decodePlaygroundCode = (encoded: string): string => {\n\ttry {\n\t\treturn decodeURIComponent(encoded)\n\t} catch (e) {\n\t\tconsole.error(\"Failed to decode playground code:\", e)\n\t\treturn defaultPlaygroundCode\n\t}\n}\n\nexport const updatePlaygroundUrl = (code: string): string => {\n\tif (typeof window === \"undefined\") return \"\"\n\tconst url = new URL(window.location.href)\n\turl.searchParams.set(\"code\", encodePlaygroundCode(code))\n\twindow.history.replaceState({}, \"\", url.toString())\n\treturn url.toString()\n}\n\nexport const copyToClipboard = async (text: string): Promise<unknown> =>\n\tnavigator.clipboard.writeText(text)\n"
  },
  {
    "path": "ark/docs/components/snippets/betterErrors.twoslash.ts",
    "content": "import { type, type ArkErrors } from \"arktype\"\n\nconst User = type({\n\tname: \"string\",\n\tplatform: \"'android' | 'ios'\",\n\t\"versions?\": \"(number | string)[]\"\n})\n\ninterface RuntimeErrors extends ArkErrors {\n\t/**platform must be \"android\" or \"ios\" (was \"enigma\")\nversions[2] must be a number or a string (was bigint)*/\n\tsummary: string\n}\n\nconst narrowMessage = (e: ArkErrors): e is RuntimeErrors => true\n\n// ---cut---\nconst out = User({\n\tname: \"Alan Turing\",\n\tplatform: \"enigma\",\n\tversions: [0, \"1\", 0n]\n})\n\nif (out instanceof type.errors) {\n\t// ---cut-start---\n\tif (!narrowMessage(out)) throw new Error()\n\t// ---cut-end---\n\t// hover summary to see validation errors\n\tconsole.error(out.summary)\n}\n"
  },
  {
    "path": "ark/docs/components/snippets/clarityAndConcision.twoslash.js",
    "content": "// @errors: 2322\nimport { type } from \"arktype\"\n// this file is written in JS so that it can include a syntax error\n// without creating a type error while still displaying the error in twoslash\n// ---cut---\n// hover me\nconst User = type({\n\tname: \"string\",\n\tplatform: \"'android' | 'ios'\",\n\t\"versions?\": \"number | string)[]\"\n})\n"
  },
  {
    "path": "ark/docs/components/snippets/contentsById.ts",
    "content": "// prettier-ignore\nexport default {\n    \"betterErrors\": \"import { type, type ArkErrors } from \\\"arktype\\\"\\n\\nconst User = type({\\n\\tname: \\\"string\\\",\\n\\tplatform: \\\"'android' | 'ios'\\\",\\n\\t\\\"versions?\\\": \\\"(number | string)[]\\\"\\n})\\n\\ninterface RuntimeErrors extends ArkErrors {\\n\\t/**platform must be \\\"android\\\" or \\\"ios\\\" (was \\\"enigma\\\")\\nversions[2] must be a number or a string (was bigint)*/\\n\\tsummary: string\\n}\\n\\nconst narrowMessage = (e: ArkErrors): e is RuntimeErrors => true\\n\\n// ---cut---\\nconst out = User({\\n\\tname: \\\"Alan Turing\\\",\\n\\tplatform: \\\"enigma\\\",\\n\\tversions: [0, \\\"1\\\", 0n]\\n})\\n\\nif (out instanceof type.errors) {\\n\\t// ---cut-start---\\n\\tif (!narrowMessage(out)) throw new Error()\\n\\t// ---cut-end---\\n\\t// hover summary to see validation errors\\n\\tconsole.error(out.summary)\\n}\",\n    \"clarityAndConcision\": \"// @errors: 2322\\nimport { type } from \\\"arktype\\\"\\n// this file is written in JS so that it can include a syntax error\\n// without creating a type error while still displaying the error in twoslash\\n// ---cut---\\n// hover me\\nconst User = type({\\n\\tname: \\\"string\\\",\\n\\tplatform: \\\"'android' | 'ios'\\\",\\n\\t\\\"versions?\\\": \\\"number | string)[]\\\"\\n})\",\n    \"deepIntrospectability\": \"import { type } from \\\"arktype\\\"\\n\\nconst User = type({\\n\\tname: \\\"string\\\",\\n\\tdevice: {\\n\\t\\tplatform: \\\"'android' | 'ios'\\\",\\n\\t\\t\\\"version?\\\": \\\"number | string\\\"\\n\\t}\\n})\\n\\n// ---cut---\\nUser.extends(\\\"object\\\") // true\\nUser.extends(\\\"string\\\") // false\\n// true (string is narrower than unknown)\\nUser.extends({\\n\\tname: \\\"unknown\\\"\\n})\\n// false (string is wider than \\\"Alan\\\")\\nUser.extends({\\n\\tname: \\\"'Alan'\\\"\\n})\",\n    \"intrinsicOptimization\": \"import { type } from \\\"arktype\\\"\\n// prettier-ignore\\n// ---cut---\\n// all unions are optimally discriminated\\n// even if multiple/nested paths are needed\\nconst Account = type({\\n\\tkind: \\\"'admin'\\\",\\n\\t\\\"powers?\\\": \\\"string[]\\\"\\n}).or({\\n\\tkind: \\\"'superadmin'\\\",\\n\\t\\\"superpowers?\\\": \\\"string[]\\\"\\n}).or({\\n\\tkind: \\\"'pleb'\\\"\\n})\",\n    \"unparalleledDx\": \"// @noErrors\\nimport { type } from \\\"arktype\\\"\\n// prettier-ignore\\n// ---cut---\\nconst User = type({\\n\\tname: \\\"string\\\",\\n\\tplatform: \\\"'android' | 'ios'\\\",\\n\\t\\\"version?\\\": \\\"number | s\\\"\\n\\t//                     ^|\\n})\",\n    \"nestedTypeInScopeError\": \"// @errors: 2322\\nimport { scope } from \\\"arktype\\\"\\n// ---cut---\\nconst myScope = scope({\\n\\tid: \\\"string#id\\\",\\n\\tuser: type({\\n\\t\\tname: \\\"string\\\",\\n\\t\\tid: \\\"id\\\"\\n\\t})\\n})\"\n}\n"
  },
  {
    "path": "ark/docs/components/snippets/deepIntrospectability.twoslash.js",
    "content": "import { type } from \"arktype\"\n\nconst User = type({\n\tname: \"string\",\n\tdevice: {\n\t\tplatform: \"'android' | 'ios'\",\n\t\t\"version?\": \"number | string\"\n\t}\n})\n\n// ---cut---\nUser.extends(\"object\") // true\nUser.extends(\"string\") // false\n// true (string is narrower than unknown)\nUser.extends({\n\tname: \"unknown\"\n})\n// false (string is wider than \"Alan\")\nUser.extends({\n\tname: \"'Alan'\"\n})\n"
  },
  {
    "path": "ark/docs/components/snippets/intrinsicOptimization.twoslash.js",
    "content": "import { type } from \"arktype\"\n// prettier-ignore\n// ---cut---\n// all unions are optimally discriminated\n// even if multiple/nested paths are needed\nconst Account = type({\n\tkind: \"'admin'\",\n\t\"powers?\": \"string[]\"\n}).or({\n\tkind: \"'superadmin'\",\n\t\"superpowers?\": \"string[]\"\n}).or({\n\tkind: \"'pleb'\"\n})\n"
  },
  {
    "path": "ark/docs/components/snippets/nestedTypeInScopeError.twoslash.js",
    "content": "// @errors: 2322\nimport { scope } from \"arktype\"\n// ---cut---\nconst myScope = scope({\n\tid: \"string#id\",\n\tuser: type({\n\t\tname: \"string\",\n\t\tid: \"id\"\n\t})\n})\n"
  },
  {
    "path": "ark/docs/components/snippets/unparalleledDx.twoslash.js",
    "content": "// @noErrors\nimport { type } from \"arktype\"\n// prettier-ignore\n// ---cut---\nconst User = type({\n\tname: \"string\",\n\tplatform: \"'android' | 'ios'\",\n\t\"version?\": \"number | s\"\n\t//                     ^|\n})\n"
  },
  {
    "path": "ark/docs/content/docs/blog/2.0.mdx",
    "content": "---\ntitle: Announcing ArkType 2.0\ndescription: 100x faster validation with DX that will blow your mind\n---\n\nAs of today, `arktype@2.0.0` is generally available and fully stable.\n\nArkType 2.0 brings types to runtime JS in a way that, until today, has been a pipedream.\n\nWhether you're a first-time TypeScript dev trying to validate a form or a library author introspecting relationships, ArkType offers fundamentally better tools for navigating the perils of JavaScript.\n\n<MainAutoplayDemo />\n\n### Unparalleled DX\n\nType syntax you already know with safety and completions unlike anything\nyou&apos;ve ever seen\n\n<CodeBlock fromFile=\"unparalleledDx\" includesCompletions />\n\n### Faster... everything\n\n100x faster than Zod at runtime with editor performance that will remind you\nhow autocomplete is supposed to feel\n\n<RuntimeBenchmarksGraph className=\"mt-2\" />\n\n### Clarity and Concision\n\nDefinitions are half as long, type errors are twice as readable, and hovers\ntell you just what really matters\n\n<CodeBlock fromFile=\"clarityAndConcision\" />\n\n### Better Errors\n\nDeeply customizable messages with great defaults\n\n<CodeBlock fromFile=\"betterErrors\" />\n\n### Deep Introspectability\n\nArkType uses set theory to understand and expose the relationships between\nyour types at runtime the way TypeScript does at compile time\n\n<CodeBlock fromFile=\"deepIntrospectability\" />\n\n### Intrinsic Optimization\n\nEvery schema is internally normalized and reduced to its purest and fastest\nrepresentation\n\n<CodeBlock fromFile=\"intrinsicOptimization\" />\n\n### What next?\n\nArkType doesn't require a special environment or build step to work- [our intro](/docs/intro/setup) will have you up and running in seconds.\n\nWe have [big plans](https://github.com/orgs/arktypeio/projects/4) to ArkType 2.0 even further, but we're even more excited to see what you do with it!\n\n⚡ [Starting coding](/docs/intro/setup)\n\n⭐ [Check out the project on GitHub](https://github.com/arktypeio/arktype)\n\n👋 [Join our Discord to lurk or ask questions](https://arktype.io/discord)\n\n- Follow any of these accounts for updates:\n  - [@arktype.io](https://bsky.app/profile/arktype.io), [@ssalbdivad.dev](https://bsky.app/profile/ssalbdivad.dev) on BlueSky\n  - [@arktypeio](https://x.com/arktypeio), [@ssalbdivad](https://x.com/arktypeio) on X/Twitter\n\n- Consider supporting my full-time work on ArkType...\n  - via [GitHub Sponsors](https://github.com/sponsors/arktypeio)\n  - by convincing your team to let me optimize your types and fix editor lag (reach out directly to one of the accounts listed or `david@arktype.io`)\n"
  },
  {
    "path": "ark/docs/content/docs/blog/2.1.mdx",
    "content": "---\ntitle: Announcing ArkType 2.1\ndescription: Optimized pattern matching from type syntax\n---\n\nAs of today, 2.1.0 is generally available 🎉\n\nThe biggest feature is `match`, a pattern matching API that allows you to define cases using expressive type syntax. The result is a highly optimized matcher that uses set theory to automatically skip unmatched branches.\n\nWe could not be more excited to share this not just as the first syntactic matcher in JS, but as the first ArkType feature to showcase the potential of runtime types to do more than just validation.\n\nLanguages with introspectable types offer incredibly powerful features that have always felt out of reach in JS- until now.\n\n```ts\n// @noErrors\nconst toJsonArkType = match({\n\t\"string | number | boolean | null\": v => v,\n\tbigint: b => `${b}n`,\n\tobject: o => {\n\t\tfor (const k in o) {\n\t\t\to[k] = toJsonArkType(o[k])\n\t\t}\n\t\treturn o\n\t},\n\tdefault: \"assert\"\n})\n\nconst toJsonTsPattern = (value: unknown) =>\n\ttsPatternMatch(value)\n\t\t.with(P.union(P.string, P.number, P.boolean, null), v => v)\n\t\t.with(P.bigint, v => `${v}n`)\n\t\t.with({}, o => {\n\t\t\tfor (const k in o) {\n\t\t\t\to[k] = toJsonTsPattern(o[k])\n\t\t\t}\n\t\t\treturn o\n\t\t})\n\t\t.otherwise(() => {\n\t\t\tthrow new Error(\"value is not valid JSON\")\n\t\t})\n\n// \"foo\" (9 nanoseconds)\ntoJsonArkType(\"foo\")\n// \"foo\" (765 nanoseconds)\ntoJsonTsPattern(\"foo\")\n\n// \"5n\" (33 nanoseconds)\ntoJsonArkType(5n)\n// \"5n\" (924 nanoseconds)\ntoJsonTsPattern(5n)\n\n// { nestedValue: \"5n\" } (44 nanoseconds)\ntoJsonArkType({ nestedValue: 5n })\n// { nestedValue: \"5n\" } (2080 nanoseconds)\ntoJsonTsPattern({ nestedValue: 5n })\n```\n\nWe're actually huge fans of [Gabriel Vergnaud](https://github.com/gvergnaud) and [ts-pattern](https://github.com/gvergnaud/ts-pattern), which has a great API and totally reasonable performance. We've referenced it for comparison to showcase the unique expressiveness and optimization runtime types unlock.\n\nBelow are the full notes for the 2.1.0 release. We can't wait to hear what you think! 🚀\n\n### `match`\n\nThe `match` function provides a powerful way to handle different types of input and return corresponding outputs based on the input type, like a type-safe `switch` statement.\n\n#### Case Record API\n\nThe simplest way to define a matcher is with ArkType definition strings as keys with corresponding handlers as values:\n\n```ts\nimport { match } from \"arktype\"\n\nconst sizeOf = match({\n\t\"string | Array\": v => v.length,\n\tnumber: v => v,\n\tbigint: v => v,\n\tdefault: \"assert\"\n})\n\n// a match definition is complete once a `default` has been specified,\n// either as a case or via the .default() method\n\nsizeOf(\"abc\") // 3\nsizeOf([1, 2, 3, 4]) // 4\nsizeOf(5n) // 5n\n// ArkErrors: must be an object, a string, a number or a bigint (was boolean)\nsizeOf(true)\n```\n\nIn this example, `sizeOf` is a matcher that takes a string, array, number, or bigint as input. It returns the length of strings and arrays, and the value of numbers and bigints.\n\n`default` accepts one of 4 values:\n\n- `\"assert\"`: accept `unknown`, throw if none of the cases match\n- `\"never\"`: accept an input based on inferred cases, throw if none match\n- `\"reject\"`: accept `unknown`, return `ArkErrors` if none of the cases match\n- `(data: In) => unknown`: handle data not matching other cases directly\n\nCases will be checked in the order they are specified, either as object literal keys or via chained methods.\n\n#### Fluent API\n\nThe `match` function also provides a fluent API. This can be convenient for non-string-embeddable definitions:\n\n```ts\n// the Case Record and Fluent APIs can be easily combined\nconst sizeOf = match({\n\tstring: v => v.length,\n\tnumber: v => v,\n\tbigint: v => v\n})\n\t// match any object with a numeric length property and extract it\n\t.case({ length: \"number\" }, o => o.length)\n\t// return 0 for all other data\n\t.default(() => 0)\n\nsizeOf(\"abc\") // 3\nsizeOf({ name: \"David\", length: 5 }) // 5\nsizeOf(null) // 0\n```\n\n#### Narrowing input with `in`, property matching with `at`\n\n```ts\n// @errors: 2345\ntype Data =\n\t| {\n\t\t\tid: 1\n\t\t\toneValue: number\n\t  }\n\t| {\n\t\t\tid: 2\n\t\t\ttwoValue: string\n\t  }\n\nconst discriminateValue = match\n\t// .in allows you to specify the input TypeScript allows for your matcher\n\t.in<Data>()\n\t// .at allows you to specify a key at which your input will be matched\n\t.at(\"id\")\n\t.match({\n\t\t1: o => `${o.oneValue}!`,\n\t\t2: o => o.twoValue.length,\n\t\tdefault: \"assert\"\n\t})\n\ndiscriminateValue({ id: 1, oneValue: 1 }) // \"1!\"\ndiscriminateValue({ id: 2, twoValue: \"two\" }) // 3\ndiscriminateValue({ oneValue: 3 })\n```\n\nSpecial thanks to [@thetayloredman](https://github.com/thetayloredman) who did a mind-blowingly good job helping us iterate toward the current type-level pattern-matching implementation🙇\n\n### Built-in keywords can now be globally configured\n\nThis can be very helpful for customizing error messages without needing to create your own aliases or wrappers.\n\n```ts title=\"config.ts\"\nimport { configure } from \"arktype/config\"\n\nconfigure({\n\tkeywords: {\n\t\tstring: \"shorthand description\",\n\t\t\"string.email\": {\n\t\t\tactual: () => \"definitely fake\"\n\t\t}\n\t}\n})\n```\n\n```ts title=\"app.ts\"\nimport \"./config.ts\"\nimport { type } from \"arktype\"\n\nconst User = type({\n\tname: \"string\",\n\temail: \"string.email\"\n})\n\nconst out = User({\n\t// ArkErrors: name must be shorthand description (was a number)\n\tname: 5,\n\t// ArkErrors: email must be an email address (was definitely fake)\n\temail: \"449 Canal St\"\n})\n```\n\nThe options you can provide here are identical to those used to [configure a Type directly](https://arktype.io/docs/expressions#meta), and can also be [extended at a type-level to include custom metadata](https://arktype.io/docs/configuration#metadata).\n\n### Tuple and args expressions for `.to`\n\nIf a morph returns an `ArkErrors` instance, validation will fail with that result instead of it being treated as a value. This is especially useful for using other Types as morphs to validate output or chain transformations.\n\nTo make this easier, there's a special `to` operator that can pipe to a parsed definition without having to wrap it in `type` to make it a function.\n\nThis was added before 2.0, but now it comes with a corresponding operator (`|>`) so that it can be expressed via a tuple or args like most other expressions:\n\n```ts\nconst FluentStillWorks = type(\"string.numeric.parse\").to(\"number % 2\")\n\nconst NowSoDoesTuple = type({\n\tsomeKey: [\"string.numeric.parse\", \"|>\", \"number % 2\"]\n})\n\nconst AndSpreadArgs = type(\"string.numeric.parse\", \"|>\", \"number % 2\")\n```\n\n### Error configurations now accept a string directly\n\n```ts\nconst CustomOne = type(\"1\", \"@\", {\n\t// previously only a function returning a string was allowed here\n\tmessage: \"Yikes.\"\n})\n\n// ArkErrors: Yikes.\nCustomOne(2)\n```\n\nKeep in mind, [as mentioned in the docs](https://arktype.io/docs/configuration#errors), error configs like `message` can clobber more granular config options like `expected` and `actual` and cannot be included in composite errors e.g. for a union.\n\nThough generally, returning a string based on context is the best option, in situations where you always want the same static message, it's now easier to get that!\n\n### Type.toString() now wraps its syntactic representation in `Type<..>`\n\nPreviously, `Type.toString()` just returned `Type.expression`. However, in contexts where the source of a message isn't always a `Type`, it could be confusing:\n\n```ts\n// < 2.1.0:  \"(was string)\"\n// >= 2.1.0: \"(was Type<string>)\"\nconsole.log(`(was ${type.string})`)\n```\n\nHopefully if you interpolate a Type, you'll be less confused by the result from now on!\n\n### Improve how Type instances are inferred when wrapped in external generics\n\nPreviously, we used `NoInfer` in some Type method returns. After migrating those to inlined conditionals, we get the same benefit and external inference for cases like this is more reliable:\n\n```ts\n// @noErrors\nfunction fn<\n\tT extends {\n\t\tschema: StandardSchemaV1\n\t}\n>(_: T) {\n\treturn {} as StandardSchemaV1.InferOutput<T[\"schema\"]>\n}\n\n// was inferred as unknown (now correctly { name: string })\nconst arkRes = fn({\n\tschema: type({\n\t\tname: \"string\"\n\t})\n})\n```\n\n### Fix an issue causing some discriminated unions to incorrectly reject default cases\n\n```ts\nconst Discriminated = type({\n\tid: \"0\",\n\tk1: \"number\"\n})\n\t.or({ id: \"1\", k1: \"number\" })\n\t.or({\n\t\tname: \"string\"\n\t})\n\n// previously, this was rejected as requiring a \"k1\" key\n// will now hit the case discriminated for id: 1,\n// but still correctly be allowed via the { name: string } branch\nDiscriminated({ name: \"foo\", id: 1 })\n```\n"
  },
  {
    "path": "ark/docs/content/docs/blog/2.2.mdx",
    "content": "---\ntitle: Announcing ArkType 2.2\ndescription: Type-safe regex, validated functions, and native Standard Schema definitions\n---\n\nAs of today, 2.2.0 is generally available 🎉\n\n2.2 brings `type.fn` for runtime-validated functions, type-safe regex via `arkregex`, bidirectional JSON Schema with the new `@ark/json-schema` package, and universal schema interop- embed Zod, Valibot, or any Standard Schema validator directly in your definitions.\n\nFor the first time, the type safety ArkType brings to data can extend to your entire function boundary- parameters in, return value out, validated and introspectable. Regex literals now carry full type inference including capture groups. And with configurable `toJsonSchema` and `@ark/json-schema`, ArkType speaks JSON Schema in both directions.\n\n```ts\n// @noErrors\nimport { type } from \"arktype\"\n\n// runtime-validated functions\nconst len = type.fn(\"string | unknown[]\", \":\", \"number\")(s => s.length)\n\nlen(\"foo\") // 3\nlen([1, 2, 3]) // 3\n\n// type-safe regex with inferred captures\nconst Birthday = type({\n\tbirthday: \"x/^(?<month>\\\\d{2})-(?<day>\\\\d{2})-(?<year>\\\\d{4})$/\"\n})\nBirthday.assert({ birthday: \"05-21-1993\" }).birthday.groups.month // \"05\"\n\n// embed any Standard Schema validator\nconst v = { number: () => \"number\" as const }\nconst User = type({ name: \"string\", age: v.number() })\n```\n\nBelow are the full notes for the 2.2.0 release. We can't wait to hear what you think! 🚀\n\n### `type.fn` - Validated functions\n\nDefine functions with runtime-validated parameters and return types, all using the same syntax you already know. The result is a callable with `.expression`, `.params`, and `.returns` for introspection.\n\n```ts\n// @errors: 2345\nconst len = type.fn(\"string | unknown[]\", \":\", \"number\")(s => s.length)\n\nlen(\"foo\") // 3\nlen([1, 2]) // 2\n\nlen.expression // \"(string | Array) => number\"\n\nlen(true) // TraversalError: value at [0] must be a string or an object (was boolean)\n```\n\nSince the types are defined as values rather than annotations, `type.fn` also works in plain `.js` files- no JSDoc or TypeScript required to get fully typed, validated function signatures.\n\nSupports all the tuple features you'd expect- defaults, optionals, variadics:\n\n```ts\n// \"string = 'world'\" means the second param defaults to \"world\" if omitted\nconst greet = type.fn(\n\t\"string\",\n\t\"string = 'world'\"\n)((greeting, name) => `${greeting}, ${name}!`)\n\ngreet(\"Hello\") // \"Hello, world!\"\ngreet(\"Hey\", \"David\") // \"Hey, David!\"\n\n// \"...\" spreads a variadic array parameter, just like in tuple definitions\nconst join = type.fn(\n\t\"...\",\n\t\"string[]\",\n\t\":\",\n\t\"string\"\n)((...parts) => parts.join(\",\"))\n\njoin.expression // \"(...string[]) => string\"\n```\n\n### Type-safe regex\n\nArkType 2.2 integrates [arkregex](/docs/blog/arkregex), a type-safe wrapper for `new RegExp()`. Regex literals in your definitions now carry full type inference:\n\n```ts\nconst Hex = type(\"/^[0-9a-fA-F]+$/\")\n//    Type<string>\n\nconst Semver = type(\"/^(\\\\d+)\\\\.(\\\\d+)\\\\.(\\\\d+)$/\")\n//    Type<`${number}.${number}.${number}`>\n```\n\n#### e(x)ec mode\n\nPrefix a regex literal with `x` to parse capture groups at runtime, fully typed via arkregex:\n\n```ts\nconst User = type({\n\tbirthday: \"x/^(?<month>\\\\d{2})-(?<day>\\\\d{2})-(?<year>\\\\d{4})$/\"\n})\n\nconst data = User.assert({ birthday: \"05-21-1993\" })\n\n// fully type-safe\ndata.birthday.groups.month // \"05\"\ndata.birthday.groups.day // \"21\"\ndata.birthday.groups.year // \"1993\"\n```\n\nFor the standalone package (no ArkType required), see the full [arkregex announcement](/docs/blog/arkregex).\n\n### `@ark/json-schema` - Bidirectional JSON Schema\n\nThe new `@ark/json-schema` package allows you to parse JSON Schema directly into ArkType Types, complementing the existing `toJsonSchema()` method on every Type. Together, they provide full bidirectional conversion.\n\nSpecial thanks to [@TizzySaurus](https://github.com/TizzySaurus) for the incredible work on this package 🙌\n\n```ts\ndeclare const jsonSchemaToType: (schema: unknown) => unknown\n\nconst User = jsonSchemaToType({\n\ttype: \"object\",\n\tproperties: {\n\t\tname: { type: \"string\" },\n\t\tage: { type: \"integer\", minimum: 0 }\n\t},\n\trequired: [\"name\"]\n})\n\n// Type<{ name: string; age?: number }>\n```\n\n### Configurable `toJsonSchema`\n\nSome ArkType features don't have JSON Schema equivalents. By default, `toJsonSchema()` throws in these cases. The new fallback config lets you handle incompatibilities granularly:\n\n```ts\nconst T = type({\n\t\"[symbol]\": \"string\",\n\tbirthday: \"Date\"\n})\n\nconst schema = T.toJsonSchema({\n\tfallback: {\n\t\tdate: ctx => ({\n\t\t\t...ctx.base,\n\t\t\ttype: \"string\",\n\t\t\tformat: \"date-time\",\n\t\t\tdescription: ctx.after ? `after ${ctx.after}` : \"anytime\"\n\t\t}),\n\t\tdefault: ctx => ctx.base\n\t}\n})\n```\n\n`toJsonSchema()` now also accepts a `target` option and can generate `draft-07` in addition to the default `draft-2020-12`. Cyclic types are fully supported and generate `$ref`-based schemas.\n\nArkType also implements the [Standard JSON Schema](https://standardschema.dev) interface, so libraries that consume Standard Schema can access JSON Schema directly via the `~standard` property.\n\nFull documentation including the complete table of fallback codes is available in the [configuration docs](/docs/configuration#tojsonschema).\n\n### Standard Schema as definitions\n\nAny [Standard Schema](https://standardschema.dev) compliant validator can now be passed directly to `type`, either at the top level or nested inside a structural definition, and will be fully inferred and validated.\n\n```ts\nimport { type } from \"arktype\"\nconst v = { number: () => \"number\" as const }\nconst z = {\n\tstring: () => \"string\" as const,\n\tobject: <shape extends Record<string, unknown>>(shape: shape) => shape\n}\n\nconst ZodAddress = z.object({\n\tstreet: z.string(),\n\tcity: z.string()\n})\n\nconst User = type({\n\tname: \"string\",\n\tage: v.number(),\n\taddress: ZodAddress\n})\n```\n\nThis makes ArkType a universal composition layer- mix and match validators from any ecosystem in a single definition.\n\n### `select` - Deep reference introspection\n\nThe new `select` method lets you query the internal structure of a type. Every Type is built from a tree of nodes (domains, constraints, morphs, etc.), and `select` extracts references by kind and predicate:\n\n```ts\nconst T = type(\"1 < number < 10\")\n\n// \"min\" is the node kind for lower bounds, \"exclusive\" means > (not >=)\nconst minNodes = T.select(\"min\")\nconst exclusiveMins = minNodes.filter(node => node.exclusive)\n```\n\nThese selectors can also be used to [target specific references for configuration](/docs/expressions#meta), avoiding the need to transform the entire type:\n\n```ts\nconst User = type({ name: \"string\", age: \"number\" })\n\n// add the description to all domain nodes\nconst configured = User.configure({ description: \"a special string\" }, \"domain\")\n\nconfigured.get(\"name\").description // \"a special string\"\nconfigured.get(\"age\").description // \"a special string\"\n```\n\n### Improved `type.declare`\n\n`type.declare` now supports morph-aware declarations via a `side` context, and optionality can be expressed via property values in addition to keys:\n\n```ts\ntype Expected = { a: string; b?: number }\n\nconst T = type.declare<Expected>().type({\n\ta: \"string\",\n\t// previously failed with `\"b?\" is missing`\n\tb: \"number?\"\n})\n```\n\nIf your type includes morphs like `string.numeric.parse`, you can declare just the input side or the output side. This is useful when your external type represents one half of a transformation:\n\n```ts\ntype Input = { name: string }\n\n// { side: \"in\" } means we're declaring only the input shape\nconst T = type.declare<Input, { side: \"in\" }>().type({\n\tname: \"string.numeric.parse\"\n})\n// (In: Input) => { name: number }\n```\n\nWhen there's a mismatch, you get a clear error showing exactly what went wrong:\n\n```ts\n// type.declare<{ a: string }>().type({ a: \"1\" })\n// TypeScript: declared: string; inferred: 1\n```\n\n### Serializable `ArkErrors`\n\n`ArkErrors` are now JSON stringifiable, making it easy to send validation errors as API responses or store them in logs. Two new properties provide structured access:\n\n```ts\nconst NEvenAtLeast2 = type({ n: \"number % 2 >= 2\" })\n\nconst out = NEvenAtLeast2({ n: 1 })\n\nif (out instanceof type.errors) {\n\tout.flatByPath\n\t// { n: [{ code: \"divisor\", rule: 2, ... }, { code: \"min\", rule: 2, ... }] }\n\n\tout.flatProblemsByPath\n\t// { n: [\"must be even (was 1)\", \"must be at least 2 (was 1)\"] }\n}\n```\n\nUnhandled validation errors now throw a `TraversalError` (instead of `AggregateError`) with cleaner multi-error formatting (thanks @LukeAbby).\n\n### N-ary operators\n\n`type.or`, `type.and`, `type.merge`, and `type.pipe` are standalone functions that accept variadic definitions, avoiding the need to chain or compose binary expressions:\n\n```ts\nconst Union = type.or(type.string, \"number\", { key: \"unknown\" })\n\nconst Intersection = type.and(\n\t{ foo: \"string\" },\n\t{ bar: \"number\" },\n\t{ baz: \"string\" }\n)\n\nconst Merged = type.merge(\n\t{ \"[string]\": \"number\", foo: \"0\" },\n\t{ \"[string]\": \"bigint\", \"foo?\": \"1n\" }\n)\n\nconst TrimToNonEmpty = type.pipe(\n\ttype.string,\n\ts => s.trimStart(),\n\ttype.string.atLeastLength(1)\n)\n```\n\n### String-embeddable `|>` pipe operator\n\nThe `to` operator (`|>`) can now be used directly inside string definitions:\n\n```ts\nconst TrimToNonEmpty = type(\"string.trim |> string > 0\")\n\n// equivalent to\nconst Equivalent = type(\"string.trim\").to(\"string > 0\")\n```\n\n### `type.valueOf`\n\nCreate a Type from a TypeScript `enum` or enum-like object:\n\n```ts\nenum Color {\n\tRed,\n\tGreen,\n\tBlue\n}\n\n// Type<Color.Red | Color.Green | Color.Blue>\nconst ColorType = type.valueOf(Color)\n```\n\n### New keywords\n\nTwo new built-in string keywords:\n\n```ts\n// validates hexadecimal strings (thanks @HoaX7)\nconst Hex = type(\"string.hex\")\nHex.allows(\"deadbeef\") // true\n\n// validates that a string is a syntactically valid regex pattern\nconst Pattern = type(\"string.regex\")\nPattern.allows(\"^[a-z]+$\") // true\nPattern.allows(\"[invalid\") // false\n```\n\n### `exactOptionalPropertyTypes` config\n\nArkType now supports a global config for `exactOptionalPropertyTypes`, matching TypeScript's compiler option:\n\n```ts title=\"config.ts\"\nimport { configure } from \"arktype/config\"\n\n// since the default in ArkType is `true`, this only has an effect if set to `false`\nconfigure({ exactOptionalPropertyTypes: false })\n```\n\n```ts title=\"app.ts\"\nimport \"./config.ts\"\nimport { type } from \"arktype\"\n\nconst MyObj = type({ \"key?\": \"number\" })\n\n// now valid (would be an error by default)\nMyObj({ key: undefined })\n```\n\n### Additional improvements\n\n- **`Type#distribute`**: Map and optionally reduce over union branches e.g. `T.distribute(branch => branch.expression)`. See [Type API docs](/docs/type-api#distribute).\n- **ES2020 / Hermes compatibility**: Removed usages of newer prototype methods like `.at()` to support legacy browsers and React Native's Hermes engine\n- **In-docs playground**: Try ArkType directly from the docs at [arktype.io/playground](https://arktype.io/playground) with full type checking and formatting\n- **Cyclic unions can now discriminate on nested paths**, improving performance and error messages for complex recursive types\n- **Faster shallow completions**: Near-instant autocomplete for `type(\"\")`\n- **Better JSDoc and go-to-definition** for parsed object keys\n- **Improved `.expression` for regex constraints**: Now displays `/^pattern$/` instead of `string /^pattern$/`\n- **Generic descriptions** are now included for built-in generics like `Record`, `Pick`, `Omit`, `Partial`, `Required`, `Exclude`, `Extract`, and `Merge`\n- **`toJsonSchema()` format annotations**: Built-in string keywords like `string.email`, `string.ip.v4`, `string.ip.v6`, `string.url`, and `string.uuid` now emit proper JSON Schema `format` fields, improving OpenAPI compatibility\n- **Duplicate key detection**: Definitions with conflicting keys like `{ foo: \"string\", foo?: \"string\" }` now throw a descriptive error at parse time\n- **Unsatisfiable index signature intersections** now result in a `ParseError` instead of silently producing an unusable type\n- **Fixed predicate errors** after the first not being reported for multi-property constraints\n- **Fixed clone crash** when an object has a getter or setter as a non-prototype property\n- **Fixed custom `message` callbacks in JIT mode** that previously produced `\"$ark.message\"` instead of the expected string\n- **Fixed morph inference for environments** where global prototypes like `FormData` resolve to `{}` (e.g. `@types/bun`)\n- **Fixed metatype extraction from recursive definitions** where `Default` and `Out` were not properly inferred\n\n⚡ [Start coding](/docs/intro/setup)\n\n⭐ [Check out the project on GitHub](https://github.com/arktypeio/arktype)\n\n👋 [Join our Discord to lurk or ask questions](https://arktype.io/discord)\n\n- Follow any of these accounts for updates:\n  - [@arktype.io](https://bsky.app/profile/arktype.io), [@ssalbdivad.dev](https://bsky.app/profile/ssalbdivad.dev) on BlueSky\n  - [@arktypeio](https://x.com/arktypeio), [@ssalbdivad](https://x.com/ssalbdivad) on X/Twitter\n\n- Consider supporting my full-time work on ArkType...\n  - via [GitHub Sponsors](https://github.com/sponsors/arktypeio)\n  - by convincing your team to let me optimize your types and fix editor lag (reach out directly to one of the accounts listed or `david@arktype.io`)\n"
  },
  {
    "path": "ark/docs/content/docs/blog/arkregex.mdx",
    "content": "---\ntitle: Introducing ArkRegex\ndescription: A drop-in replacement for new RegExp() with types\n---\n\nRegular expressions are ubiquitous in modern code.\n\nA few characters sprinkled into your JavaScript can validate and parse strings that would require dozens of lines of imperative logic.\n\nHowever, that concision comes at a cost. Complex expressions can be hard to understand and type safety is a pipe dream- or at least, it was.\n\n**Introducing `arkregex`, a type-safe wrapper of `new RegExp()`.**\n\n<video\n\tautoPlay\n\tloop\n\tcontrols\n\tplaysInline\n\tmuted\n\tdisablePictureInPicture\n\tsrc=\"https://github.com/arktypeio/arktype/releases/download/arkregex%400.0.1/arkregexDemo.webm\"\n\tstyle={{ marginTop: \"-1rem\" }}\n/>\n\nThe `regex` function creates a `Regex` instance with types for `.test()`, `.exec()` and more, statically parsed from native JS syntax:\n\n```ts\nimport { regex } from \"arkregex\"\n\nconst ok = regex(\"^ok$\", \"i\")\n// Regex<\"ok\" | \"oK\" | \"Ok\" | \"OK\", { flags: \"i\" }>\n\nconst semver = regex(\"^(\\\\d*)\\\\.(\\\\d*)\\\\.(\\\\d*)$\")\n// Regex<`${bigint}.${bigint}.${bigint}`, { captures: [`${bigint}`, `${bigint}`, `${bigint}`] }>\n\nconst email = regex(\"^(?<name>\\\\w+)@(?<domain>\\\\w+\\\\.\\\\w+)$\")\n// Regex<`${string}@${string}.${string}`, { names: { name: string; domain: `${string}.${string}`; }; ...>\n```\n\nAll you need to get started is `pnpm install arkregex` (or the equivalent for your package manager of choice) 🎉\n\nPerforms best with TS 5.9+\n\n### Features\n\n- **Types**: Infers string types for your existing regular expressions, including positional and named captures\n- **Parity**: Supports 100% of [features](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions) allowed by `new RegExp()`\n- **Safety**: Syntax errors like referencing a group that doesn't exist are now type errors\n- **Zero Runtime**: Improves your type safety without impacting your bundle size\n\n### FAQ\n\n#### Why aren't some patterns like `[a-Z]` inferred more precisely?\n\nConstructing string literal types for these sorts of expressions is combinatorial and will explode very quickly if we infer character ranges like this as literal characters.\n\nWe've tried to strike a balance between performance and precision while guaranteeing that the inferred types are at worst imprecise and never incorrect.\n\n#### Why doesn't it work with my massive RegExp?\n\nIf your expression is especially long or complex, TypeScript won't be able to infer it.\n\nIf your types start to slow down or you see the dreaded `Type is excessively deep...`, you can manually type your expression using `regex.as`:\n\n```ts\nconst complexPattern = regex.as<`pattern-${string}`, { captures: [string] }>(\n\t\"very-long-complex-expression-here\"\n)\n```\n\n#### Is it robust?\n\n`arkregex` types are [extensively tested](https://github.com/arktypeio/arktype/tree/main/ark/regex/__tests__/regex.test.ts) and [benchmarked](https://github.com/arktypeio/arktype/tree/main/ark/regex/__tests__/regex.bench.ts) using [attest](https://github.com/arktypeio/arktype/tree/main/ark/attest#readme).\n\nIf anything not covered by the other FAQs is not behaving how you'd expect, please don't hesitate to [create an issue](https://github.com/arktypeio/arktype/issues/new).\n\n#### How can I get syntax highlighting for my expressions?\n\nThe [ArkType extension](https://marketplace.visualstudio.com/items?itemName=arktypeio.arkdark) can be installed to add syntax highlighting to `regex` calls.\n\n### Useful links\n\n⭐ [Check out the project on GitHub](https://github.com/arktypeio/arktype)\n\n👋 [Join our Discord to lurk or ask questions](https://arktype.io/discord)\n\n- Follow any of these accounts for updates:\n  - [@arktype.io](https://bsky.app/profile/arktype.io), [@ssalbdivad.dev](https://bsky.app/profile/ssalbdivad.dev) on BlueSky\n  - [@arktypeio](https://x.com/arktypeio), [@ssalbdivad](https://x.com/arktypeio) on X/Twitter\n"
  },
  {
    "path": "ark/docs/content/docs/blog/index.mdx",
    "content": "---\ntitle: Posts\n---\n\n<LinkCard\n\ttitle=\"Announcing ArkType 2.2\"\n\tdescription=\"Type-safe regex, validated functions, and native Standard Schema definitions\"\n\thref=\"/docs/blog/2.2\"\n\tdate=\"February 10, 2026\"\n/>\n\n<LinkCard\n\ttitle=\"Introducing ArkRegex\"\n\tdescription=\"A drop-in replacement for new RegExp() with types\"\n\thref=\"/docs/blog/arkregex\"\n\tdate=\"October 28, 2025\"\n/>\n\n<LinkCard\n\ttitle=\"Announcing ArkType 2.1\"\n\tdescription=\"Optimized pattern matching from type syntax\"\n\thref=\"/docs/blog/2.1\"\n\tdate=\"February 27, 2025\"\n/>\n\n<LinkCard\n\ttitle=\"Announcing ArkType 2.0\"\n\tdescription=\"100x faster validation with DX that will blow your mind\"\n\thref=\"/docs/blog/2.0\"\n\tdate=\"January 17, 2025\"\n/>\n"
  },
  {
    "path": "ark/docs/content/docs/blog/meta.json",
    "content": "{\n\t\"title\": \"Blog\",\n\t\"defaultOpen\": true,\n\t\"pages\": [\n\t\t\"[2.2 Announcement](/docs/blog/2.2)\",\n\t\t\"[ArkRegex Intro](/docs/blog/arkregex)\",\n\t\t\"[2.1 Announcement](/docs/blog/2.1)\",\n\t\t\"[2.0 Announcement](/docs/blog/2.0)\"\n\t]\n}\n"
  },
  {
    "path": "ark/docs/content/docs/comparisons.mdx",
    "content": "---\ntitle: Comparisons\n---\n"
  },
  {
    "path": "ark/docs/content/docs/configuration/index.mdx",
    "content": "---\ntitle: Configuration\n---\n\nA great out-of-the-box experience is a core goal of ArkType, including safe defaults and helpful messages for complex errors.\n\nHowever, it's equally important that when you need different behavior, you can easily configure it with the right granularity.\n\n### Levels\n\n<table>\n  <thead>\n    <tr>\n      <th>Level</th>\n      <th>Applies To</th>\n      <th>Example</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td>**default**</td>\n      <td>built-in defaults for all Types</td>\n      <td></td>\n    </tr>\n    <tr>\n      <td>**global**</td>\n      <td>all Types parsed after the config is applied</td>\n      <td>\n```ts title=\"config.ts\"\nimport { configure } from \"arktype/config\"\n// use the \"arktype/config\" entrypoint\nconfigure({ numberAllowsNaN: true })\n```\n\n```ts title=\"app.ts\"\nimport \"./config.ts\"\n// import your config file before arktype\nimport { type } from \"arktype\"\n\ntype.number.allows(Number.NaN) // true\n```\n\n     </td>\n    </tr>\n    <tr>\n      <td>**scope**</td>\n      <td>all Types parsed in the configured Scope</td>\n      <td>\n\n```ts\nconst myScope = scope(\n\t{ User: { age: \"number < 100\" } },\n\t{\n\t\tmax: {\n\t\t\tactual: () => \"unacceptably large\"\n\t\t}\n\t}\n)\nconst types = myScope.export()\n// ArkErrors: age must be less than 100 (was unacceptably large)\ntypes.User({ name: \"Alice\", age: 101 })\nconst parsedAfter = myScope.type({\n\tage: \"number <= 100\"\n})\n// ArkErrors: age must be at most 100 (was unacceptably large)\nparsedAfter({ age: 101 })\n```\n\n      </td>\n    </tr>\n    <tr>\n      <td>**type**</td>\n      <td>all Types shallowly referenced by the configured Type</td>\n      <td>\n\n```ts\n// avoid logging \"was xxx\" for password\nconst Password = type(\"string >= 8\").configure({ actual: () => \"\" })\nconst User = type({\n\temail: \"string.email\",\n\tpassword: Password\n})\n// ArkErrors: password must be at least length 8\nconst out = User({\n\temail: \"david@arktype.io\",\n\tpassword: \"ez123\"\n})\n```\n\n      </td>\n    </tr>\n\n  </tbody>\n</table>\n\nSome options only apply at specific levels, as reflected in the corresponding input types.\n\n<Callout\n\ttype=\"warn\"\n\ttitle='Use the `\"arktype/config\"` entrypoint in a separate file for global config!'\n>\n\tIf you need your config to apply to built-in keywords (important for options\n\tlike `jitless`, `numberAllowsNaN`, `dateAllowsInvalid`), you should import and\n\t`configure` from `\"arktype/config\"` before importing anything from\n\t`\"arktype\"`.\n\nOtherwise, keywords will have already been parsed by the time your config applies!\n\n</Callout>\n\n### Errors\n\nTo allow custom errors to be integrated seamlessly with built-in logic for composite errors (i.e. `union` and `intersection`), ArkType supports a set of composable options:\n\n<table>\n<thead>\n<tr>\n<th>optional</th>\n<th>description</th>\n<th>example</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>**description**</td>\n<td>\n✅ a summary of the constraint that could complete the phrase \"must be ___\"\n\n🥇 reused by other metadata and should be your first go-to for customizing a message\n\n</td>\n<td>\n```ts\nconst Password = type.string.atLeastLength(8).describe(\"a valid password\")\n// ArkErrors: must be a valid password\nconst out = Password(\"ez123\")\n```\n</td>\n</tr>\n<tr>\n<td>**expected**</td>\n<td>\n✅ a function accepting the error context and returning a string of the format \"must be ___\"\n\n✅ specific to errors and takes precedence over `description` in those cases\n\n</td>\n    <td>\n```ts\nconst Password = type.string.atLeastLength(8).configure({\n\texpected: ctx =>\n\t\tctx.code === \"minLength\" ? `${ctx.rule} characters or better` : \"way better\"\n})\n// ArkErrors: must be 8 characters or better (was 5)\nconst out1 = Password(\"ez123\").toString()\n// ArkErrors: must be way better (was a number)\nconst out2 = Password(12345678).toString()\n```\n</td>\n</tr>\n<tr>\n<td>**actual**</td>\n<td>\n✅ a function accepting the data that caused the error and returning a string of the format \"(was ___)\"\n\n✅ if an empty string is returned, the actual portion of the message will be omitted\n\n</td>\n    <td>\n```ts\nconst Password = type(\"string >= 8\").configure({ actual: () => \"\" })\n// ArkErrors: must be at least length 8\nconst out = Password(\"ez123\")\n```\n</td>\n</tr>\n<tr>\n<td>**problem**</td>\n<td>\n✅ a function accepting the results of `expected` and `actual` in addition to other context and returning a complete description of the problem like \"must be a string (was a number)\"\n\n❌ may not apply to composite errors like unions\n\n</td>\n<td>\n```ts\nconst Password = type(\"string >= 8\").configure({\n\tproblem: ctx => `${ctx.actual} isn't ${ctx.expected}`\n})\n// ArkErrors: 5 isn't at least length 8\nconst out1 = Password(\"ez123\")\n// ArkErrors: a number isn't a string\nconst out2 = Password(12345678)\n```\n</td>\n</tr>\n<tr>\n<td>**message**</td>\n<td>\n✅ a function accepting the result of `problem` in addition to other context and returning a complete description of the problem including the path at which it occurred\n\n❌ may not apply to composite errors like unions\n\n</td>\n<td>\n```ts\nconst User = type({\n\tpassword: \"string >= 8\"\n}).configure({\n\tmessage: ctx =>\n\t\t`${ctx.propString || \"(root)\"}: ${ctx.actual} isn't ${ctx.expected}`\n})\n// ArkErrors: (root): a string isn't an object\nconst out1 = User(\"ez123\")\n// `.configure` only applies shallowly, so the nested error isn't changed!\n// ArkErrors: password must be at least length 8 (was 5)\nconst out2 = User({ password: \"ez123\" })\n```\n</td>\n</tr>\n</tbody>\n</table>\n\n#### By Code\n\nErrors can also be configured by their associated `code` property at a _scope_ or _global_ level.\n\nFor example:\n\n```ts\nconst mod = type.module(\n\t{ isEven: \"number%2\" },\n\t{\n\t\tdivisor: {\n\t\t\t// the available `ctx` types will include data specific to your errors\n\t\t\texpected: ctx => `% ${ctx.rule} !== 0`,\n\t\t\tproblem: ctx => `${ctx.actual} ${ctx.expected}`\n\t\t}\n\t}\n)\n// ArkErrors: 3 % 2 !== 0\nmod.isEven(3)\n```\n\n#### ArkErrors\n\nFor use cases like i18n that fall outside the scope of this composable message config, the `ArkErrors` array returned on validation failure contains `ArkError` instances that can be discriminated via calls like `.hasCode(\"divisor\")` and contain contextual data specific to that error type as well as getters for each composable error part.\n\nThese `ArkError` instances can be arbitrarily transformed and composed with an internationalization library. This is still a topic we're working on investigating and documenting, so please reach out with any questions or feedback!\n\n#### Serialization\n\n`ArkErrors` and `ArkError` are JSON stringifiable via `JSON.stringify()` or `.toJSON()`.\n\nTwo additional properties provide structured access to errors grouped by path:\n\n```ts\nconst T = type({ n: \"number % 2 >= 2\" })\n\nconst out = T({ n: 1 })\n\nif (out instanceof type.errors) {\n\tout.flatByPath\n\t// { n: [{ data: 1, path: [\"n\"], code: \"divisor\", ... }, { data: 1, path: [\"n\"], code: \"min\", ... }] }\n\n\tout.flatProblemsByPath\n\t// { n: [\"must be even (was 1)\", \"must be at least 2 (was 1)\"] }\n}\n```\n\n`flatByPath` maps each path string to an array of `ArkError` objects (decomposing union errors into their individual branches). `flatProblemsByPath` maps each path string to an array of human-readable problem strings.\n\nUnhandled validation errors (e.g. via `.assert()`) throw a `TraversalError`, which extends `Error` with cleaner multi-error formatting and a non-enumerable `arkErrors` property for programmatic access.\n\n### Keywords\n\nBuilt-in keywords like `string.email` can be globally configured.\n\nThis can be very helpful for customizing error messages without needing to create your own aliases or wrappers.\n\n```ts title=\"config.ts\"\nimport { configure } from \"arktype/config\"\n\nconfigure({\n\tkeywords: {\n\t\tstring: \"shorthand description\",\n\t\t\"string.email\": {\n\t\t\tactual: () => \"definitely fake\"\n\t\t}\n\t}\n})\n```\n\n```ts title=\"app.ts\"\nimport \"./config.ts\"\n// import your config file before arktype\nimport { type } from \"arktype\"\n\nconst User = type({\n\tname: \"string\",\n\temail: \"string.email\"\n})\n\nconst out = User({\n\t// ArkErrors: name must be shorthand description (was a number)\n\tname: 5,\n\t// ArkErrors: email must be an email address (was definitely fake)\n\temail: \"449 Canal St\"\n})\n```\n\nThe options you can provide here are identical to those used to [configure a Type directly](/docs/expressions#meta), and can also be [extended at a type-level to include custom metadata](/docs/configuration#metadata).\n\n### Clone\n\nBy default, before a [morph](/docs/intro/morphs-and-more) is applied, ArkType will deeply clone the original input value with a built-in `deepClone` function that tries to make reasonable assumptions about preserving prototypes etc. The implementation of `deepClone` can be found [here](https://github.com/arktypeio/arktype/blob/main/ark/util/clone.ts).\n\nYou can provide an alternate clone implementation to the `clone` config option.\n\n```ts title=\"config.ts\"\nimport { configure } from \"arktype/config\"\n\nconfigure({ clone: structuredClone })\n```\n\n```ts title=\"app.ts\"\nimport \"./config.ts\"\n// import your config file before arktype\nimport { type } from \"arktype\"\n\n// will now create a new object using structuredClone\nconst UserForm = type({\n\tage: \"string.numeric.parse\"\n})\n```\n\nTo mutate the input object directly, you can set the `clone` config option to `false`.\n\n```ts title=\"config.ts\"\nimport { configure } from \"arktype/config\"\n\nconfigure({ clone: false })\n```\n\n```ts title=\"app.ts\"\nimport \"./config.ts\"\n// import your config file before arktype\nimport { type } from \"arktype\"\n\nconst UserForm = type({\n\tage: \"string.numeric.parse\"\n})\n\nconst formData = {\n\tage: \"42\"\n}\n\nconst out = UserForm(formData)\n\n// the original object's age key is now a number\nconsole.log(formData.age)\n```\n\n### onUndeclaredKey\n\nLike TypeScript, ArkType defaults to ignoring undeclared keys during validation. However, it also supports two additional behaviors:\n\n- `\"ignore\"` (default): Allow undeclared keys on input, preserve them on output\n- `\"delete\"`: Allow undeclared keys on input, delete them before returning output\n- `\"reject\"`: Reject input with undeclared keys\n\nThese behaviors can be associated with individual Types via the built-in `\"+\"` syntax (see [those docs](/docs/objects#properties-undeclared) for more on how they work). You can also change the default globally:\n\n```ts title=\"config.ts\"\nimport { configure } from \"arktype/config\"\n\nconfigure({ onUndeclaredKey: \"delete\" })\n```\n\n```ts title=\"app.ts\"\nimport \"./config.ts\"\n// import your config file before arktype\nimport { type } from \"arktype\"\n\nconst UserForm = type({\n\tname: \"string\"\n})\n\n// out is now { name: \"Alice\" }\nconst out = UserForm({\n\tname: \"Alice\",\n\tage: \"42\"\n})\n```\n\n### exactOptionalPropertyTypes\n\nBy default, ArkType validates optional keys as if [TypeScript's `exactOptionalPropertyTypes` is set to `true`](https://www.typescriptlang.org/tsconfig/#exactOptionalPropertyTypes).\n\n<details>\n\t<summary>See an example</summary>\n\n```ts\nconst MyObj = type({\n\t\"key?\": \"number\"\n})\n\n// valid data\nconst validResult = MyObj({})\n\n// Error: key must be a number (was undefined)\nconst errorResult = MyObj({ key: undefined })\n```\n\n</details>\n\nThis approach allows the most granular control over optionality, as `| undefined` can be added to properties that should accept it.\n\nHowever, if you have not enabled TypeScript's `exactOptionalPropertyTypes` setting, you may globally configure ArkType's `exactOptionalPropertyTypes` to `false` to match TypeScript's behavior. If you do this, we'd recommend making a plan to enable `exactOptionalPropertyTypes` in the future.\n\n```ts title=\"config.ts\"\nimport { configure } from \"arktype/config\"\n\n// since the default in ArkType is `true`, this will only have an effect if set to `false`\nconfigure({ exactOptionalPropertyTypes: false })\n```\n\n```ts title=\"app.ts\"\nimport \"./config.ts\"\n// import your config file before arktype\nimport { type } from \"arktype\"\n\nconst MyObj = type({\n\t\"key?\": \"number\"\n})\n\n// valid data\nconst validResult = MyObj({})\n\n// now also valid data (would be an error by default)\nconst secondResult = MyObj({ key: undefined })\n```\n\n<Callout type=\"warn\" title=\"exactOptionalPropertyTypes does not yet affect default values!\">\n\n```ts\nconst MyObj = type({\n\tkey: \"number = 5\"\n})\n\n// { key: 5 }\nconst omittedResult = MyObj({})\n\n// { key: undefined }\nconst undefinedResult = MyObj({ key: undefined })\n```\n\nSupport for this is tracked as part of [this broader configurable defaultability issue](https://github.com/arktypeio/arktype/issues/1390).\n\n</Callout>\n\n### jitless\n\nBy default, when a `Type` is instantiated, ArkType will precompile optimized validation logic that will run when the type is invoked. This behavior is disabled by default in environments that don't support `new Function`, e.g. Cloudflare Workers.\n\nIf you'd like to opt out of it for another reason, you can set the `jitless` config option to `true`.\n\n```ts title=\"config.ts\"\nimport { configure } from \"arktype/config\"\n\nconfigure({ jitless: true })\n```\n\n```ts title=\"app.ts\"\nimport \"./config.ts\"\n// import your config file before arktype\nimport { type } from \"arktype\"\n\n// will not be precompiled\nconst MyObject = type({\n\tfoo: \"string\"\n})\n```\n\n### onFail\n\nIn some domains, you may always want to throw on failed validation or transform the result in some other way.\n\nBy specifying `onFail` in your global config, you can control what happens when you invoke a `Type` on invalid data:\n\n```ts title=\"config.ts\"\nimport { configure } from \"arktype/config\"\n\nconst config = configure({\n\tonFail: errors => errors.throw()\n})\n\n// be sure to specify both the runtime and static configs\n\ndeclare global {\n\tinterface ArkEnv {\n\t\tonFail: typeof config.onFail\n\t}\n}\n```\n\n```ts title=\"app.ts\"\nimport \"./config.ts\"\n// import your config file before arktype\nimport { type } from \"arktype\"\n\n// data is inferred as string- no need to discriminate!\nconst data = type.string(\"foo\")\n\n// now thrown instead of returned\n// ArkErrors: must be a string (was number)\nconst bad = type.string(5)\n```\n\n### metadata\n\nAdditional arbitrary metadata can also be associated with a Type.\n\nIt can even be made type-safe via an interface extension ArkType exposes for this purpose:\n\n```ts\n// add this anywhere in your project\ndeclare global {\n\tinterface ArkEnv {\n\t\tmeta(): {\n\t\t\t// meta properties should always be optional\n\t\t\tsecretIngredient?: string\n\t\t}\n\t}\n}\n\n// now types you define can specify and access your metadata\nconst MrPingsSecretIngredientSoup = type({\n\tbroth: \"'miso' | 'vegetable'\",\n\tingredients: \"string[]\"\n}).configure({ secretIngredient: \"nothing!\" })\n```\n\n### toJsonSchema\n\nSome ArkType features don't have JSON Schema equivalents. By default, `toJsonSchema()` will throw in these cases.\n\nThis behavior can be configured granularly to match your needs.\n\n```ts\nconst T = type({\n\t\"[symbol]\": \"string\",\n\tbirthday: \"Date\"\n})\n\nconst schema = T.toJsonSchema({\n\tfallback: {\n\t\t// ✅ the \"default\" key is a fallback for any non-explicitly handled code\n\t\t// ✅ ctx includes \"base\" (represents the schema being generated) and other code-specific props\n\t\t// ✅ returning `ctx.base` will effectively ignore the incompatible constraint\n\t\tdefault: ctx => ctx.base,\n\t\t// handle specific incompatibilities granularly\n\t\tdate: ctx => ({\n\t\t\t...ctx.base,\n\t\t\ttype: \"string\",\n\t\t\tformat: \"date-time\",\n\t\t\tdescription: ctx.after ? `after ${ctx.after}` : \"anytime\"\n\t\t})\n\t}\n})\n\nconst result = {\n\t$schema: \"https://json-schema.org/draft/2020-12/schema\",\n\ttype: \"object\",\n\tproperties: {\n\t\t// Date instance is now a date-time string as specified by the `date` handler\n\t\tbirthday: { type: \"string\", format: \"date-time\", description: \"anytime\" }\n\t},\n\trequired: [\"birthday\"]\n\t// symbolic index signature ignored as specified by the `default` handler\n}\n```\n\na `default` handler can also be specified at the root of a `fallback` config:\n\n```ts\nconst T = type({\n\t\"[symbol]\": \"string\",\n\tbirthday: \"Date\"\n})\n\n//--- cut ---\n\nconst schema = T.toJsonSchema({\n\t// \"just make it work\"\n\tfallback: ctx => ctx.base\n})\n```\n\nThese options can also be set at a [global or scope-level](/docs/configuration#levels).\n\n### Fallback Codes\n\nThis is the full list of configurable reasons `toJsonSchema()` can fail.\n\n| Code                  | Description                                                 |\n| --------------------- | ----------------------------------------------------------- |\n| `arrayObject`         | arrays with object properties                               |\n| `arrayPostfix`        | arrays with postfix elements                                |\n| `defaultValue`        | non-serializable default value                              |\n| `domain`              | non-serializable type keyword (always `bigint` or `symbol`) |\n| `morph`               | transformation                                              |\n| `patternIntersection` | multiple regex constraints                                  |\n| `predicate`           | custom narrow function                                      |\n| `proto`               | non-serializable `instanceof`                               |\n| `symbolKey`           | symbolic key on an object                                   |\n| `unit`                | non-serializable `===` reference (e.g. `undefined`)         |\n| `date`                | a Date instance (supersedes `proto` for Dates)              |\n\n### prototypes\n\nWhen you `.infer` your Types, ArkType traverses them and extracts special values like morphs, e.g. `(In: string) => Out<number>`.\n\nThough generally this is able to preserve the original type, it is inefficient and can accidentally expand certain object types.\n\nYou can use the type-level `prototypes` config to tell ArkType to treat those types as external:\n\n```ts\ndeclare global {\n\tinterface ArkEnv {\n\t\tprototypes(): MySpecialClass\n\t}\n}\n\nclass MySpecialClass {}\n\nconst T = type.instanceOf(MySpecialClass)\n//    ^? Type<MySpecialClass>\n```\n"
  },
  {
    "path": "ark/docs/content/docs/configuration/meta.json",
    "content": "{\n\t\"title\": \"Configuration\",\n\t\"pages\": [\n\t\t\"[levels](/docs/configuration#levels)\",\n\t\t\"[errors](/docs/configuration#errors)\",\n\t\t\"[keywords](/docs/configuration#keywords)\",\n\t\t\"[clone](/docs/configuration#clone)\",\n\t\t\"[onUndeclaredKey](/docs/configuration#onundeclaredkey)\",\n\t\t\"[jitless](/docs/configuration#jitless)\",\n\t\t\"[onFail](/docs/configuration#onfail)\",\n\t\t\"[metadata](/docs/configuration#metadata)\",\n\t\t\"[toJsonSchema](/docs/configuration#tojsonschema)\",\n\t\t\"[prototypes](/docs/configuration#prototypes)\"\n\t]\n}\n"
  },
  {
    "path": "ark/docs/content/docs/declare.mdx",
    "content": "---\ntitle: Declare\n---\n\nIf your ArkType definitions are your source of truth, it's easy to infer out the type with an expression like `type User = typeof User.infer`.\n\nBut what if you need to define a Type matching a pre-existing external type?\n\nThe `declare` API allows just that, with autocomplete for object keys and clear, type-level errors for mismatches:\n\n```ts\n// @errors: 2322\ntype Expected = { a: string; b?: number }\n\nconst T = type.declare<Expected>().type({\n\ta: \"string\",\n\t\"b?\": \"number\"\n})\n\nconst Bad = type.declare<Expected>().type({\n\ta: \"string\",\n\t// will error if the inferred type is too wide *or* too narrow\n\t\"b?\": \"1\"\n})\n```\n\nOptionality can also be expressed via the property value instead of the key:\n\n```ts\ntype Expected = { a: string; b?: number }\n\nconst T = type.declare<Expected>().type({\n\ta: \"string\",\n\t// equivalent to \"b?\": \"number\"\n\tb: \"number?\"\n})\n```\n\n### `side`\n\nIf your Type contains morphs or default values, its input and output will be inferred differently.\n\nYou can see this represented when you hover a Type like `string.numeric.parse` and see `(In: string) => To<number>`.\n\nBy default, `declare` does not allow the type you define to include morphs (unless you explicitly add them to the declared generic argument).\n\nPassing a `side` config to `declare` can change this behavior:\n\n```ts\n// @errors: 2322\ntype Expected = { a: number; b?: number }\n\nconst Bad = type.declare<Expected>().type({\n\ta: \"string.numeric.parse\",\n\t\"b?\": \"number\"\n})\n\n// passing a config object like { side: \"in\" | \"out\" } to validate that side\nconst T = type.declare<Expected, { side: \"out\" }>().type({\n\ta: \"string.numeric.parse\",\n\t\"b?\": \"number\"\n})\n```\n"
  },
  {
    "path": "ark/docs/content/docs/ecosystem/index.mdx",
    "content": "---\ntitle: Ecosystem\n---\n\n### ArkEnv\n\n[ArkEnv](https://arkenv.js.org) brings the power of ArkType to your environment variables.\n\nDefine an ArkType schema, pull values from your environment or config source, validate them, apply type conversions and transformations, and end up with a fully typesafe, ready-to-use `env` object.\n\nInspired by tools like [T3 Env](https://env.t3.gg) but tailored specifically for ArkType, ArkEnv also adds keywords like `string.host` and `number.port` for env-specific use cases.\n\n```ts\n// @noErrors\nimport arkenv from \"arkenv\"\n\nconst env = arkenv({\n\tHOST: \"string.host\",\n\tPORT: \"number.port\",\n\tNODE_ENV: \"'development' | 'production' | 'test' = 'development'\"\n})\n\n// Automatically validate and parse process.env\n// TypeScript knows the ✨exact✨ types!\nconsole.log(env.HOST) // (property) HOST: string\nconsole.log(env.PORT) // (property) PORT: number\nconsole.log(env.NODE_ENV) // (property) NODE_ENV: \"development\" | \"production\" | \"test\"\n```\n"
  },
  {
    "path": "ark/docs/content/docs/ecosystem/meta.json",
    "content": "{\n\t\"title\": \"Ecosystem\",\n\t\"icon\": \"New\",\n\t\"pages\": [\"[ArkEnv](/docs/ecosystem#arkenv)\"]\n}\n"
  },
  {
    "path": "ark/docs/content/docs/expressions/index.mdx",
    "content": "---\ntitle: Expressions\n---\n\n### Intersection\n\nLike its TypeScript counterpart, an intersection combines two existing `Type`s to create a new `Type` that enforces the constraints of both.\n\n<Callout\n\ttype=\"warn\"\n\ttitle=\"If you don't need to intersect overlapping props, spread instead!\"\n>\n\nComputing an intersection is more expensive than [merging props](/docs/objects#merge), both at runtime and in-editor.\n\nIf you can get away with the latter, doing so will make your Types faster and cleaner.\n\n</Callout>\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst MyObj = type({\n\t// an email address with the domain arktype.io\n\tintersected: \"string.email & /@arktype\\\\.io$/\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst FooObject = type({\n\tfoo: \"string\"\n})\n\n// an object requiring both foo and bar\nconst FoobarObject = FooObject.and({\n\tbar: \"number\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\n// an object requiring both foo and bar\nconst FoobarObject = type([\n\t{\n\t\tfoo: \"string\"\n\t},\n\t\"&\",\n\t{\n\t\tbar: \"number\"\n\t}\n])\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab args>\n\n```ts\n// an object requiring both foo and bar\nconst FoobarObject = type(\n\t{\n\t\tfoo: \"string\"\n\t},\n\t\"&\",\n\t{\n\t\tbar: \"number\"\n\t}\n)\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n<AnchorAliases intersection-n-ary />\n#### n-ary\n\nTo create an intersection of many objects directly, `type.and` will avoid the need to chain or compose many binary expressions:\n\n```ts\nconst FooObject = type({\n\tfoo: \"string\"\n})\n\n// accepts ...definitions\nconst FoobarObject = type.and(\n\tFooObject,\n\t{\n\t\tbar: \"number\"\n\t},\n\t{\n\t\tbaz: \"string\"\n\t}\n)\n```\n\n### Union\n\nAll unions are automatically discriminated to optimize check time and error message clarity.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst Unions = type({\n\tkey: \"string | number\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Unions = type({\n\tkey: type.string.or(type.number)\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\nconst Unions = type({\n\tkey: [\"string\", \"|\", { name: \"string\" }]\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab args>\n\n```ts\nconst Unions = type({\n\tkey: type(\"string\", \"|\", { name: \"string\" })\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n<AnchorAliases union-n-ary />\n#### n-ary\n\nTo create a union of many objects directly, `type.or` will avoid the need to chain or compose many binary expressions:\n\n```ts\n// accepts ...definitions\nconst Union = type.or(type.string, \"number\", { key: \"unknown\" })\n```\n\n<AnchorAliases union-morphs />\n\n<Callout\n\ttype=\"warn\"\n\ttitle=\"A union that could apply different morphs to the same data throws a ParseError!\"\n>\n```ts\n// operands overlap, but neither transforms data\nconst Okay = type(\"number > 0\").or(\"number < 10\")\n// operand transforms data, but there's no overlap between the inputs\nconst AlsoOkay = type(\"string.numeric.parse\").or({ box: \"string\" })\n// operands overlap and transform data, but in the same way\nconst StillOkay = type(\"string > 5\", \"=>\", Number.parseFloat).or([\n\t\"0 < string < 10\",\n\t\"=>\",\n\tNumber.parseFloat\n])\n// ParseError: An unordered union of a type including a morph and a type with overlapping input is indeterminate\nconst Bad = type({ box: \"string.numeric.parse\" }).or({ box: \"string\" })\nconst SameError = type({ a: \"string.numeric.parse\" }).or({ b: \"string.numeric.parse\" })\n```\n\n<details>\n\t<summary>Learn the set theory behind this restriction</summary>\n\nIf you're relatively new to set-based types, that error might be daunting, but if you take a second to think through the example, it becomes clear why this isn't allowed. The logic of `bad` is essentially:\n\n- If the input is an object where `box` is a `string`, parse and return it as a number\n- If the input is an object where `box` is a `string`, return it as a string\n\nThere is no way to deterministically return an output for this type without sacrificing the [commutativity](https://en.wikipedia.org/wiki/Commutative_property) of the union operator.\n\n`sameError` may look more innocuous, but has the same problem for an input like `{ a: \"1\", b: \"2\" }`.\n\n- Left branch would only parse `a`, resulting in `{ a: 1, b: \"2\" }`\n- Right branch would only parse `b`, resulting in `{ a: \"1\", b: 2 }`\n\n</details>\n\n</Callout>\n\n### Brand\n\nAdd a type-only symbol to an existing type so that the only values that satisfy it are those that have been directly validated.\n\n<SyntaxTabs>\n\n    <SyntaxTab string>\n\n```ts\n// @noErrors\nconst Even = type(\"(number % 2)#even\")\ntype Even = typeof Even.infer\n\nconst good: Even = Even.assert(2)\n// TypeScript: Type 'number' is not assignable to type 'Brand<number, \"even\">'\nconst bad: Even = 5\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\n// @noErrors\nconst Even = type.number.divisibleBy(2).brand(\"even\")\ntype Even = typeof Even.infer\n\nconst good: Even = Even.assert(2)\n// TypeScript: Type 'number' is not assignable to type 'Brand<number, \"even\">'\nconst bad: Even = 5\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\nBrands can be a great way to represent constraints that fall outside the scope TypeScript, but remember they don't change anything about what is enforced at runtime!\n\nFor more information on branding in general, check out [this excellent article](https://www.learningtypescript.com/articles/branded-types) from [Josh Goldberg](https://github.com/joshuakgoldberg).\n\n### Narrow\n\nNarrow expressions allow you to add custom validation logic and error messages. You can read more about them in [their intro section](/docs/intro/adding-constraints#narrow).\n\n<SyntaxTabs>\n    <SyntaxTab fluent>\n\n```ts\nconst Form = type({\n\tpassword: \"string\",\n\tconfirmPassword: \"string\"\n}).narrow((data, ctx) => {\n\tif (data.password === data.confirmPassword) {\n\t\treturn true\n\t}\n\treturn ctx.reject({\n\t\texpected: \"identical to password\",\n\t\t// don't display the password in the error message!\n\t\tactual: \"\",\n\t\tpath: [\"confirmPassword\"]\n\t})\n})\n\n// ArkErrors: confirmPassword must be identical to password\nconst out = Form({\n\tpassword: \"arktype\",\n\tconfirmPassword: \"artkype\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\nconst Form = type([\n\t{\n\t\tpassword: \"string\",\n\t\tconfirmPassword: \"string\"\n\t},\n\t\":\",\n\t(data, ctx) => {\n\t\tif (data.password === data.confirmPassword) {\n\t\t\treturn true\n\t\t}\n\t\treturn ctx.reject({\n\t\t\texpected: \"identical to password\",\n\t\t\t// don't display the password in the error message!\n\t\t\tactual: \"\",\n\t\t\tpath: [\"confirmPassword\"]\n\t\t})\n\t}\n])\n\n// ArkErrors: confirmPassword must be identical to password\nconst out = Form({\n\tpassword: \"arktype\",\n\tconfirmPassword: \"artkype\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab args>\n\n```ts\nconst Form = type(\n\t{\n\t\tpassword: \"string\",\n\t\tconfirmPassword: \"string\"\n\t},\n\t\":\",\n\t(data, ctx) => {\n\t\tif (data.password === data.confirmPassword) {\n\t\t\treturn true\n\t\t}\n\t\treturn ctx.reject({\n\t\t\texpected: \"identical to password\",\n\t\t\t// don't display the password in the error message!\n\t\t\tactual: \"\",\n\t\t\tpath: [\"confirmPassword\"]\n\t\t})\n\t}\n)\n\n// ArkErrors: confirmPassword must be identical to password\nconst out = Form({\n\tpassword: \"arktype\",\n\tconfirmPassword: \"artkype\"\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\nIf the return type of a narrow is a type predicate, that will be reflected in the inferred `Type`.\n\n<SyntaxTabs>\n    <SyntaxTab fluent>\n\n```ts\n// hover to see how the predicate is propagated to the outer `Type`\nconst ArkString = type(\"string\").narrow(\n\t(data, ctx): data is `ark${string}` =>\n\t\tdata.startsWith(\"ark\") ?? ctx.reject(\"a string starting with 'ark'\")\n)\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\n// hover to see how the predicate is propagated to the outer `Type`\nconst ArkString = type([\n\t\"string\",\n\t\":\",\n\t(data, ctx): data is `ark${string}` =>\n\t\tdata.startsWith(\"ark\") ?? ctx.reject(\"a string starting with 'ark'\")\n])\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab args>\n\n```ts\n// hover to see how the predicate is propagated to the outer `Type`\nconst ArkString = type(\n\t\"string\",\n\t\":\",\n\t(data, ctx): data is `ark${string}` =>\n\t\tdata.startsWith(\"ark\") ?? ctx.reject(\"a string starting with 'ark'\")\n)\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### Filter\n\n`filter` is similar to `narrow` but applies its predicate to the **input** of a type rather than the output. This distinction matters when your type includes morphs:\n\n- **`narrow`**: validates the **output** (after morphs have been applied)\n- **`filter`**: validates the **input** (before morphs run)\n\n```ts\nconst ShortNumeric = type(\"string.numeric.parse\").filter((s, ctx) => {\n\t// s is a string here (the input), not a number (the output)\n\tif (s.length > 10) return ctx.reject(\"at most 10 characters\")\n\treturn true\n})\n\n// the filter runs on the input (string) before the morph parses it\nShortNumeric(\"123\") // 123\nShortNumeric(\"12345678901\") // ArkErrors: must be at most 10 characters\n```\n\nIf the return type of a filter is a type predicate, that will be reflected in the inferred `Type`, just like with `narrow`.\n\n<AnchorAliases morph />\n### Pipe\n\nPiping allows you to transform your data after it is validated via one or more sequential **morphs**. You can read more about them in [their intro section](/docs/intro/morphs-and-more/).\n\n<SyntaxTabs>\n    <SyntaxTab fluent>\n\n```ts\n// hover to see how morphs are represented at a type-level\nconst trimStringStart = type(\"string\").pipe(str => str.trimStart())\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\n// hover to see how morphs are represented at a type-level\nconst trimStringStart = type([\"string\", \"=>\", str => str.trimStart()])\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab args>\n\n```ts\n// hover to see how morphs are represented at a type-level\nconst trimStringStart = type(\"string\", \"=>\", str => str.trimStart())\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n#### To\n\nIf a morph returns an `ArkErrors` instance, validation will fail with that result instead of it being treated as a value. This is especially useful for using other Types as morphs to validate output or chain transformations.\n\nTo make this easier, there's a special `to` operator that can pipe to a parsed definition without having to wrap it in `type` to make it a function:\n\n<SyntaxTabs>\n    <SyntaxTab string>\n\n```ts\nconst parseEvenTo = type(\"string.numeric.parse |> number % 2\")\n\nconst Even = type(\"number % 2\")\n// equivalent to parseEvenTo\nconst parseEvenPipe = type(\"string.numeric.parse\").pipe(Even)\n```\n\n    </SyntaxTab>\n    <SyntaxTab fluent>\n\n```ts\nconst parseEvenTo = type(\"string.numeric.parse\").to(\"number % 2\")\n\nconst Even = type(\"number % 2\")\n// equivalent to parseEvenTo\nconst parseEvenPipe = type(\"string.numeric.parse\").pipe(Even)\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\nconst parseEvenTo = type([\"string.numeric.parse\", \"|>\", \"number % 2\"])\n\nconst Even = type(\"number % 2\")\n// equivalent to parseEvenTo\nconst parseEvenPipe = type(\"string.numeric.parse\").pipe(Even)\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab args>\n\n```ts\nconst parseEvenTo = type(\"string.numeric.parse\", \"|>\", \"number % 2\")\n\nconst Even = type(\"number % 2\")\n// equivalent to parseEvenTo\nconst parseEvenPipe = type(\"string.numeric.parse\").pipe(Even)\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n<AnchorAliases pipe-n-ary />\n#### n-ary\n\nThough the fluent `.pipe(...morphsOrTypes)` method already accepts any number of arguments, `type.pipe()` allows you to define such an expression directly without having to explicitly instantiate the first input Type to chain from.\n\n```ts\n// directly accepts ...morphsOrTypes\nconst trimStartToNonEmpty = type.pipe(\n\ttype.string,\n\ts => s.trimStart(),\n\ttype.string.atLeastLength(1)\n)\n```\n\n### Unit\n\nWhile embedded [literal syntax](/docs/primitives#number-literals) is usually ideal for defining exact primitive values, `===` and `type.unit` can be helpful for referencing a non-serializable value like a `symbol` from your type.\n\n<SyntaxTabs>\n\n    <SyntaxTab fluent>\n\n```ts\nconst mySymbol = Symbol()\n\nconst ExactValue = type.unit(mySymbol)\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\nconst mySymbol = Symbol()\n\nconst ExactValue = type([\"===\", mySymbol])\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab args>\n\n```ts\nconst mySymbol = Symbol()\n\nconst ExactValue = type(\"===\", mySymbol)\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### Enumerated\n\n`type.enumerated` defines a Type based on a list of allowed values. It is semantically equivalent to `type.unit` if provided a single value.\n\n<SyntaxTabs>\n\n    <SyntaxTab fluent>\n\n```ts\nconst mySymbol = Symbol()\n\nconst ExactValueFromSet = type.enumerated(1337, true, mySymbol)\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\nconst mySymbol = Symbol()\n\nconst ExactValueFromSet = type([\"===\", 1337, true, mySymbol])\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab args>\n\n```ts\nconst mySymbol = Symbol()\n\nconst ExactValueFromSet = type(\"===\", 1337, true, mySymbol)\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### valueOf\n\n`type.valueOf` defines a Type from a TypeScript `enum` or enum-like object.\n\n<Callout\n\ttype=\"warn\"\n\ttitle=\"`enum` should be avoided in modern TypeScript\"\n>\n\nOver time, TS has shifted away from features that affect the `.js` it ultimately outputs, including `enum`.\n\nWith the introduction of the [`--erasableSyntaxOnly` option](https://www.typescriptlang.org/tsconfig/#erasableSyntaxOnly) to facilitate type-stripping, `enum` is no longer considered a best practice.\n\n`type.valueOf` exists primarily to facilitate integration with legacy code that relies on `enum`, but if you have the option, prefer transparently defining value sets via `[\"tupleLiterals\"] as const`, `{ objectLiterals: true } as const`, or directly via [`type.enumerated`](/docs/expressions#enumerated).\n\n</Callout>\n\n```ts\nenum TsEnum {\n\tnumeric = 1\n}\n\nconst EnumType = type.valueOf(TsEnum) // Type<1>\n```\n\nIt is _almost_ semantically identical to `type.enumerated(...Object.values(o))`. The only exception occurs when an object has an entry with a numeric value and entry with that value as a key mapping back to the original:\n\n```ts\n// this is the structure TsEnum compiles to in JS\nconst equivalentObject = {\n\tnumeric: 1,\n\t\"1\": \"numeric\"\n} as const\n\n// only allows the number 1 even though it is inferred\n// to also allow the string \"numeric\"\nconst EquivalentObject = type.valueOf(equivalentObject)\n```\n\nNotice `EquivalentObject` doesn't include `\"numeric\"` because it inverts a numeric value entry.\n\nWe recommend `type.enumerated` as the more transparent option for converting value references to a Type. However, if the described inverted entry pairs can't exist on your object, you can safely use `type.valueOf`.\n\n### fn\n\n`type.fn` defines a function with runtime-validated parameters and an optional return type. The result is a `TypedFn`- a callable with `.expression`, `.params`, and `.returns` for introspection.\n\nParameters are defined using the same syntax as tuple types. A return type can optionally be specified after a `\":\"` separator.\n\n```ts\n// @errors: 2345\nconst len = type.fn(\"string | unknown[]\", \":\", \"number\")(s => s.length)\n\nlen(\"foo\") // 3\nlen([1, 2]) // 2\n\nlen.expression // \"(string | Array) => number\"\n\nlen(true) // TraversalError: value at [0] must be a string or an object (was boolean)\n```\n\nSupports defaults, optionals, and variadic parameters:\n\n```ts\nconst greet = type.fn(\n\t\"string\",\n\t\"string = 'world'\"\n)((greeting, name) => `${greeting}, ${name}!`)\n\ngreet(\"Hello\") // \"Hello, world!\"\n\nconst maybeDouble = type.fn(\n\t\"number\",\n\t\"boolean?\"\n)((n, double) => (double ? n * 2 : n))\n\nmaybeDouble(5) // 5\nmaybeDouble(5, true) // 10\n\nconst join = type.fn(\n\t\"...\",\n\t\"string[]\",\n\t\":\",\n\t\"string\"\n)((...parts) => parts.join(\",\"))\n\njoin.expression // \"(...string[]) => string\"\n```\n\nIf no return type is specified, the return type is inferred from the implementation. If a return type is specified, it will be validated at runtime.\n\n### Meta\n\nMetadata allows you to associate arbitrary metadata with your types.\n\nSome metadata is consumed directly by ArkType, for example `description` is referenced by default when building an error message.\n\nOther properties are introspectable, but aren't used by default internally.\n\n<SyntaxTabs>\n    <SyntaxTab fluent>\n\n```ts\n// this validator's error message will now start with \"must be a special string\"\nconst SpecialString = type(\"string\").configure({\n\tdescription: \"a special string\"\n})\n\n// sugar for adding description metadata\nconst SpecialNumber = type(\"number\").describe(\"a special number\")\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\n// this validator's error message will now start with \"must be a special string\"\nconst SpecialString = type([\n\t\"string\",\n\t\"@\",\n\t{\n\t\tdescription: \"a special string\"\n\t}\n])\n\n// sugar for adding description metadata\nconst SpecialNumber = type([\"number\", \"@\", \"a special number\"])\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab args>\n\n```ts\n// this validator's error message will now start with \"must be a special string\"\nconst SpecialString = type(\"string\", \"@\", {\n\tdescription: \"a special string\"\n})\n\n// sugar for adding description metadata\nconst SpecialNumber = type(\"number\", \"@\", \"a special number\")\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\nFor more control over how to apply the config to the Type's internal structure, a `NodeSelector` can be specified following the config:\n\n<SyntaxTabs>\n    <SyntaxTab fluent>\n\n```ts\nconst SelectivelyConfigured = type({\n\tname: \"string\",\n\tage: \"number\"\n}).configure(\n\t{\n\t\tdescription: \"a special string\"\n\t},\n\t// add the description to all domain keywords\n\t\"domain\"\n)\n\nSelectivelyConfigured.get(\"name\").description // \"a special string\"\nSelectivelyConfigured.get(\"age\").description // \"a special string\"\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\nconst SelectivelyConfigured = type([\n\t{\n\t\tname: \"string\",\n\t\tage: \"number\"\n\t},\n\t\"@\",\n\t{\n\t\tdescription: \"a special string\"\n\t},\n\t// add the description to all domain keywords\n\t\"domain\"\n])\n\nSelectivelyConfigured.get(\"name\").description // \"a special string\"\nSelectivelyConfigured.get(\"age\").description // \"a special string\"\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab args>\n\n```ts\nconst SelectivelyConfigured = type(\n\t{\n\t\tname: \"string\",\n\t\tage: \"number\"\n\t},\n\t\"@\",\n\t{\n\t\tdescription: \"a special string\"\n\t},\n\t// add the description to all domain keywords\n\t\"domain\"\n)\n\nSelectivelyConfigured.get(\"name\").description // \"a special string\"\nSelectivelyConfigured.get(\"age\").description // \"a special string\"\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\nFor more details on the select API, [see the full docs](/docs/introspection#select).\n\n### Cast\n\nSometimes, you may want to directly specify how a `Type` should be inferred without affecting the runtime behavior. In these cases, you can use a cast expression.\n\n<SyntaxTabs>\n\n    <SyntaxTab string>\n\n```ts\n// allow any string, but suggest \"foo\" and \"bar\"\ntype AutocompletedString = \"foo\" | \"bar\" | (string & {})\n\nconst MyObj = type({\n\tautocompletedString: \"string\" as type.cast<AutocompletedString>\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\n// allow any string, but suggest \"foo\" and \"bar\"\ntype AutocompletedString = \"foo\" | \"bar\" | (string & {})\n\nconst MyObj = type({\n\tautocompletedString: type.string.as<AutocompletedString>()\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### Parenthetical\n\nBy default, ArkType's operators follow the same precedence as TypeScript's. Also like in TypeScript, this can be overridden by wrapping an expression in parentheses.\n\n```ts\n// hover to see the distinction!\nconst Groups = type({\n\tstringOrArrayOfNumbers: \"string | number[]\",\n\tarrayOfStringsOrNumbers: \"(string | number)[]\"\n})\n```\n\n### this\n\n`this` is a special keyword that can be used to create a recursive type referencing the root of the current definition.\n\n```ts\nconst DisappointingGift = type({\n\tlabel: \"string\",\n\t\"box?\": \"this\"\n})\n\nconst out = DisappointingGift({\n\tlabel: \"foo\",\n\tbox: { label: \"bar\", box: {} }\n})\n\nif (out instanceof type.errors) {\n\t// ArkErrors: box.box.label must be a string (was missing)\n\tconsole.error(out.summary)\n} else {\n\t// narrowed inference to arbitrary depth\n\tconsole.log(out.box?.box?.label)\n\t//                         ^?\n}\n```\n\nReferencing `this` from within a scope will result in a ParseError. For similar behavior within a scoped definition, just reference the alias by name:\n\n```ts\nconst types = scope({\n\tDisappointingGift: {\n\t\tlabel: \"string\",\n\t\t// Resolves correctly to the root of the current type\n\t\t\"box?\": \"DisappointingGift\"\n\t}\n}).export()\n```\n"
  },
  {
    "path": "ark/docs/content/docs/expressions/meta.json",
    "content": "{\n\t\"title\": \"Expressions\",\n\t\"pages\": [\n\t\t\"[intersection](/docs/expressions#intersection)\",\n\t\t\"[union](/docs/expressions#union)\",\n\t\t\"[brand](/docs/expressions#brand)\",\n\t\t\"[narrow](/docs/expressions#narrow)\",\n\t\t\"[filter](/docs/expressions#filter)\",\n\t\t\"[pipe](/docs/expressions#pipe)\",\n\t\t\"[unit](/docs/expressions#unit)\",\n\t\t\"[enumerated](/docs/expressions#enumerated)\",\n\t\t\"[valueOf](/docs/expressions#valueof)\",\n\t\t\"[fn](/docs/expressions#fn)\",\n\t\t\"[meta](/docs/expressions#meta)\",\n\t\t\"[cast](/docs/expressions#cast)\",\n\t\t\"[parenthetical](/docs/expressions#parenthetical)\",\n\t\t\"[this](/docs/expressions#this)\"\n\t]\n}\n"
  },
  {
    "path": "ark/docs/content/docs/faq.mdx",
    "content": "---\ntitle: FAQ\n---\n\n### Why do I see type errors in an ArkType package in `node_modules`?\n\nThis can occur due to incompatibilities between your `tsconfig.json` and ours. It is totally harmless as long as your types are correct in source.\n\nWe highly recommend enabling [`skipLibCheck`](https://www.typescriptlang.org/tsconfig/#skipLibCheck) in every TypeScript project to avoid false negatives like this and greatly improve editor performance.\n\n### Is there a way to create an async morph?\n\nOther than handling it as a promise on the output object, no.\n\nAs it stands, it doesn't seem worth the significant complexity it would add to morphs in the type system.\n\nIf you have a compelling use case, let us know on [this GitHub issue](https://github.com/arktypeio/arktype/issues/462).\n\n### What's up with your type/Type casing?\n\nYou might have noticed in our documentation we use PascalCase for some Types and camelCase for others:\n\n```ts\nconst User = type({\n\tname: \"string\",\n\tplatform: \"'android' | 'ios'\",\n\t\"version?\": \"number | string\"\n})\n\nconst parseJson = type(\"string.json.parse\").to({\n\tname: \"string\",\n\tversion: \"string.semver\"\n})\n```\n\nThis distinction actually evolved from the rules we use for casing our internal TypeScript types:\n\n- Use `PascalCase` for...\n  - Entities/non-generic types (e.g. `User`, `SomeData`)\n  - Generic types with noun names, like `Array<t>`. As a rule of thumb, your generic should be named this way if all its parameters have defaults (unfortunately TS's built-in `Array` type doesn't have a default parameter, but it probably should have been `unknown`!)\n\n- Use `camelCase` for...\n  - Generic types with verb names like `inferDomain<t>`. Types named this way should generally have at least one required parameter.\n  - Parameter names, e.g. `t` in `Array<t>`\n\nIf you don't like this, feel free to use whatever casing rules best suit your repo- it will not affect your Types or scope aliases in any way.\n\n### Why isn't my wrapper generic working?\n\nTypeScript generic inference is notoriously finicky. General patterns for wrapping Types and definitions are outlined [in the Generics docs](/docs/generics#external).\n\n<Callout\n\ttype=\"info\"\n\ttitle=\"If you want to write type-level logic, you need to cast.\"\n>\n\nWhen implementing a function with a generic return type, you will almost always need to cast in your implementation, either explicitly via `as` or by using an overload.\n\nThink of it as trading internal safety for external precision. As long as the function you're writing will be called many times externally, the overhead is justified. If not, it may not need to be generic at all- a broad return type like `string` as opposed to `${prefix}.${key}` may be sufficient.\n\n<details>\n\t<summary>See an example</summary>\n\n```ts\n// via explicit cast\nconst createBox = <const def>(\n\tof: type.validate<def>\n): type.instantiate<{ of: def }> =>\n\ttype.raw({\n\t\tbox: of\n\t\t// when implementing generics, never is your go-to\n\t\t// for allowing an arbitrary assignment with less risk than `any`\n\t}) as never\n\n// via overloads\n// only the external signatures are considered on invocation\nfunction createBox2<const def>(\n\tof: type.validate<def>\n): type.instantiate<{ of: def }>\n// the signature associated with the implementation is much looser and should\n// be thought of as equivalent to casting in terms of type safety\nfunction createBox2(of: unknown) {\n\treturn type.raw({\n\t\tbox: of\n\t})\n}\n```\n\nNotice in both cases, we've explicitly annotated the return type we want and used some method of casting internally to allow our implementation. This is a very common for implementing generic functions and, more generally, associating an implementation with typings TS can't infer on its own.\n\n</details>\n\n</Callout>\n\nFor anything more complex, you'll have to rely on your understanding of type manipulation to achieve the desired outcome. Tracing your way through ArkType's internal types may uncover helpful patterns, and you may even find friendly folks [in our Discord](https://arktype.io/discord) who may be willing to lend a hand.\n\nGenerally speaking however, **we cannot guarantee your generics will behave the way you expect**.\n\nWriting a good generic function can require understanding many complex details and edge cases- the kind of stuff our core API abstracts away.\n\nUnfortunately, when it comes to how ArkType integrates with external generics, that is not possible.\n\nGetting the results you want will take patience, but the DX ceiling for this kind of API is crazy high.\n\nIf we haven't scared you off by now, we're hyped to see what you build with it 🧗\n"
  },
  {
    "path": "ark/docs/content/docs/generics/index.mdx",
    "content": "---\ntitle: Generics\n---\n\n### Keywords\n\nThis table includes all generic keywords available in default `type` API.\n\n<GenericKeywordTable />\n\n### Syntax\n\nGenerics can be declared and instantiated in one of three ways.\n\n#### Definition\n\n```ts\nimport { type } from \"arktype\"\n\nconst boxOf = type(\"<t>\", { box: \"t\" })\n\n// hover me!\nconst schrodingersBox = boxOf({ cat: { isAlive: \"boolean\" } })\n```\n\n#### Constrained Parameters\n\nAll syntax in parameters definitions and all references to generic args are fully-type safe and autocompleted like any built-in keyword. Constraints can be used just like TS to limit what can be passed to a generic and allow that arg to be used with operators like `>`.\n\n```ts\nimport { type } from \"arktype\"\n\nconst nonEmpty = type(\"<arr extends unknown[]>\", \"arr > 0\")\n\nconst nonEmptyNumberArray = nonEmpty(\"number[]\")\n```\n\n#### Scoped\n\nThere is a special syntax for specifying generics in a scope:\n\n```ts\nimport { scope } from \"arktype\"\n\nconst types = scope({\n\t\"box<t, u>\": {\n\t\tbox: \"t | u\"\n\t},\n\tbitBox: \"box<0, 1>\"\n}).export()\n\nconst out = types.bitBox({ box: 0 })\n```\n\n#### Invocation\n\n```ts\nimport { type } from \"arktype\"\n\nconst One = type(\"Extract<0 | 1, 1>\")\n```\n\n##### Chained\n\n```ts\nimport { type } from \"arktype\"\n\nconst User = type({\n\tname: \"string\",\n\t\"age?\": \"number\",\n\tisAdmin: \"boolean\"\n})\n\n// hover me!\nconst BasicUser = User.pick(\"name\", \"age\")\n```\n\n#### Invoked\n\n```ts\nimport { type } from \"arktype\"\n\nconst Unfalse = type.keywords.Exclude(\"boolean\", \"false\")\n```\n\n### HKT\n\nOur new generics have been built using a new method for integrating arbitrary external types as native ArkType generics! This opens up tons of possibilities for external integrations that would otherwise not be possible. As a preview, here's what the implementation of `Partial` looks like internally:\n\n```ts\nimport { generic, Hkt } from \"arktype\"\n\nconst Partial = generic([\"T\", \"object\"])(\n\targs => args.T.partial(),\n\tclass PartialHkt extends Hkt<[object]> {\n\t\tdeclare body: Partial<this[0]>\n\t}\n)\n```\n\nRecursive and cyclic generics are also currently unavailable and will be added soon.\n\nFor more usage examples, check out the unit tests for generics [here](https://github.com/arktypeio/arktype/blob/main/ark/type/__tests__/generic.test.ts).\n\n### External\n\nThe most basic pattern for wrapping a Type looks something like this:\n\n```ts\nconst createBox = <t extends string>(of: type.Any<t>) =>\n\ttype({\n\t\tbox: of\n\t})\n\n// @ts-expect-error\ncreateBox(type(\"number\"))\n\n// Type<{ box: string }>\nconst BoxType = createBox(type(\"string\"))\n```\n\nFor a deeper integration, you may wish to parse a definition directly:\n\n```ts\nconst createBox = <const def>(\n\tof: type.validate<def>\n): type.instantiate<{ of: def }> =>\n\ttype.raw({\n\t\tbox: of\n\t}) as never\n\n// Type<{ box: string }>\nconst BoxType = createBox(\"string\")\n```\n\nThe sky's the limit when it comes to this sort of integration, but be warned- TypeScript generics are notoriously finicky and [you may find APIs like these difficult to write if you're not used to it](/docs/faq#why-isnt-my-wrapper-generic-working).\n"
  },
  {
    "path": "ark/docs/content/docs/generics/meta.json",
    "content": "{\n\t\"title\": \"Generics\",\n\t\"icon\": \"Advanced\",\n\t\"pages\": [\n\t\t\"[keywords](/docs/generics#keywords)\",\n\t\t\"[syntax](/docs/generics#syntax)\",\n\t\t\"[hkt](/docs/generics#hkt)\",\n\t\t\"[external](/docs/generics#external)\"\n\t]\n}\n"
  },
  {
    "path": "ark/docs/content/docs/integrations/index.mdx",
    "content": "---\ntitle: Integrations\n---\n\n### Standard Schema\n\nArkType is proud to support and co-author the new [Standard Schema](https://github.com/standard-schema/standard-schema) API with [Valibot](https://github.com/fabian-hiller/valibot) and [Zod](https://github.com/colinhacks/zod).\n\nStandard Schema allows you and your dependencies to integrate library-agnostic validation logic. If you're building or maintaining a library with a peer dependency on ArkType and/or other validation libraries, we'd recommend consuming it through Standard Schema's API if possible so that your users can choose the solution that best suits their needs!\n\n#### As definitions\n\nAny Standard Schema compliant validator can also be passed directly to `type`, either at the top level or nested inside a structural definition, and will be fully inferred and validated:\n\n```ts\n// @noErrors\nimport { type } from \"arktype\"\nconst v = { number: () => \"number\" as const }\nconst z = {\n\tstring: () => \"string\" as const,\n\tobject: <shape extends Record<string, unknown>>(shape: shape) => shape\n}\n\nconst ZodAddress = z.object({\n\tstreet: z.string(),\n\tcity: z.string()\n})\n\nconst User = type({\n\tname: \"string\",\n\tage: v.number(),\n\taddress: ZodAddress\n})\n```\n\nThis makes ArkType a universal composition layer- mix and match validators from any ecosystem in a single definition.\n\n### JSON Schema\n\nArkType supports bidirectional conversion with JSON Schema.\n\n#### Type to JSON Schema\n\nEvery Type instance has a [`toJsonSchema()` method](/docs/type-api#tojsonschema) that generates a corresponding JSON Schema. See the [configuration docs](/docs/configuration#tojsonschema) for options including draft targets, fallback handlers, and cyclic type support.\n\n#### JSON Schema to Type\n\nThe `@ark/json-schema` package converts JSON Schema directly into ArkType Types:\n\n```ts\n// @noErrors\ndeclare const jsonSchemaToType: (schema: unknown) => unknown\n\nconst User = jsonSchemaToType({\n\ttype: \"object\",\n\tproperties: {\n\t\tname: { type: \"string\" },\n\t\tage: { type: \"integer\", minimum: 0 }\n\t},\n\trequired: [\"name\"]\n})\n// Type<{ name: string; age?: number }>\n```\n\nSee the [`@ark/json-schema` README](https://github.com/arktypeio/arktype/tree/main/ark/json-schema) for more details and limitations.\n\n### tRPC\n\nArkType can easily be used with tRPC:\n\n```ts\n// @noErrors\n// trpc >= 11 accepts a Type directly\nt.procedure.input(\n\ttype({\n\t\tname: \"string\",\n\t\t\"age?\": \"number\"\n\t})\n)\n\n// tRPC < 11 accepts the `.assert` prop\nt.procedure.input(\n\ttype({\n\t\tname: \"string\",\n\t\t\"age?\": \"number\"\n\t}).assert\n)\n```\n\n### drizzle\n\nDrizzle maintains an official [`drizzle-arktype` package](https://orm.drizzle.team/docs/arktype) that can be used to create Types for your Drizzle schemas.\n\n```ts\n// @noErrors\nimport { pgTable, text, integer } from \"drizzle-orm/pg-core\"\nimport { createSelectSchema } from \"drizzle-arktype\"\n\nconst users = pgTable(\"users\", {\n\tid: integer().generatedAlwaysAsIdentity().primaryKey(),\n\tname: text().notNull(),\n\tage: integer().notNull()\n})\n\n// Type<{ id: number; name: string; age: number }>\nconst User = createSelectSchema(users)\n```\n\n### react-hook-form\n\nreact-hook-form has built-in support for ArkType via [`@hookform/resolvers`](https://github.com/react-hook-form/resolvers/tree/master):\n\n```ts\n// @noErrors\nimport { useForm } from \"react-hook-form\"\nimport { arktypeResolver } from \"@hookform/resolvers/arktype\"\nimport { type } from \"arktype\"\n\nconst User = type({\n\tfirstName: \"string\",\n\tage: \"number.integer > 0\"\n})\n\n// in your component\nconst {\n\tregister,\n\thandleSubmit,\n\tformState: { errors }\n} = useForm({\n\tresolver: arktypeResolver(User)\n})\n```\n\nFor a custom controlled input, you can pass the inferred type into the hook itself:\n\n```ts\n// @noErrors\nuseForm<typeof User.infer>(/*...*/)\n```\n\n### hono\n\nHono has built-in support for ArkType via [`@hono/arktype-validator`](https://github.com/honojs/middleware/tree/main/packages/arktype-validator):\n\n```ts\n// @noErrors\nconst User = type({\n\tname: \"string\",\n\tage: \"number\"\n})\n\napp.post(\"/author\", arktypeValidator(\"json\", User), c => {\n\tconst data = c.req.valid(\"json\")\n\treturn c.json({\n\t\tsuccess: true,\n\t\tmessage: `${data.name} is ${data.age}`\n\t})\n})\n```\n\n[`hono-openapi`](https://github.com/rhinobase/hono-openapi) also offers experimental support for OpenAPI docgen.\n\n### oRPC\n\n[oRPC](https://orpc.unnoq.com/) has built-in support for Standard Schema, so ArkType works seamlessly right out of the box:\n\n```ts\n// @noErrors\nos.input(\n\ttype({\n\t\tname: \"string\",\n\t\t\"age?\": \"number\"\n\t})\n)\n```\n"
  },
  {
    "path": "ark/docs/content/docs/integrations/meta.json",
    "content": "{\n\t\"title\": \"Integrations\",\n\t\"pages\": [\n\t\t\"[Standard Schema](/docs/integrations#standard-schema)\",\n\t\t\"[JSON Schema](/docs/integrations#json-schema)\",\n\t\t\"[tRPC](/docs/integrations#trpc)\",\n\t\t\"[drizzle](/docs/integrations#drizzle)\",\n\t\t\"[react-hook-form](/docs/integrations#react-hook-form)\",\n\t\t\"[hono](/docs/integrations#hono)\"\n\t]\n}\n"
  },
  {
    "path": "ark/docs/content/docs/internal/index.mdx",
    "content": "---\ntitle: Internal\n---\n\nTypes have an extremely powerful internal representation defined in `@ark/schema` that is primarily exposed through the `.internal` property on each Type.\n\nThough APIs under `.internal` are not officially frozen, they are stable enough that we want to start giving users more direct access to some of the introspection capabilities they provide.\n\n### Node kinds\n\nAll nodes have a `kind` property indicating their purpose, structure and special properties.\n\n#### Roots\n\nThe `kind` at the root of a Type will always be one of the following **root** kind.\n\n##### Bases\n\nThe simplest root nodes are defined by a single **basis** constraint.\n\nOnly a single basis can exist in an intersection. From widest to narrowest:\n\n<div className=\"overflow-auto\">\n\t<table className=\"w-full\">\n\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t<th>kind</th>\n\t\t\t\t<th>description</th>\n\t\t\t\t<th className=\"w-1/3\">example</th>\n\t\t\t</tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td>`domain`</td>\n\t\t\t\t<td>\n\t\t\t\t\tOne of 5 non-enumerable type sets (`string`, `number`, `object`, `bigint`, `symbol`)\n\t\t\t\t</td>\n\t\t\t\t<td>`{ domain: \"string\" }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`proto`</td>\n\t\t\t\t<td>\n\t\t\t\t\tA constructor checked by `instanceof` (implies domain `object`)\n\t\t\t\t</td>\n\t\t\t\t<td>`{ proto: Date }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`unit`</td>\n\t\t\t\t<td>\n\t\t\t\t\tAn exact value checked by `===` (can be intersected with any other constraint and reduced to itself or `never`)\n\t\t\t\t</td>\n\t\t\t\t<td>`{ unit: true }`</td>\n\t\t\t</tr>\n\t\t</tbody>\n\t</table>\n</div>\n\n##### Composites\n\nRoot kinds are built from references to other nodes.\n\nWill be normalized to appear in approximately the following hierarchical order:\n\n<div className=\"overflow-auto\">\n\t<table className=\"w-full\">\n\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t<th>kind</th>\n\t\t\t\t<th>description</th>\n\t\t\t\t<th className=\"w-1/3\">example</th>\n\t\t\t</tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td>`alias`</td>\n\t\t\t\t<td>Stores a cyclic reference to a node</td>\n\t\t\t\t<td>`{ reference: \"$name\" }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`union`</td>\n\t\t\t\t<td>\n\t\t\t\t\tA set of allowed nodes\n\t\t\t\t</td>\n\t\t\t\t<td>`{ branches: [\"string\", \"Array\"] }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`morph`</td>\n\t\t\t\t<td>\n\t\t\t\t\tOne or more transformations applied to valid data\n\t\t\t\t</td>\n\t\t\t\t<td>`{ in: \"string\", morphs: [(s) => s.trim()] }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`intersection`</td>\n\t\t\t\t<td>An intersection of constraints</td>\n\t\t\t\t<td>`{ domain: \"number\", divisor: 5 }`</td>\n\t\t\t</tr>\n\t\t</tbody>\n\t</table>\n</div>\n\n#### Constraints\n\nConstraint nodes exist on an `intersection` (or its `structure`) and narrow the set of values allowed by its [basis](#bases).\n\n##### Refinements\n\nPrimitive constraints that apply to the data shallowly.\n\n<div className=\"overflow-auto\">\n\t<table className=\"w-full\">\n\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t<th>kind</th>\n\t\t\t\t<th>impliedBasis</th>\n\t\t\t\t<th>description</th>\n\t\t\t\t<th className=\"w-1/3\">example</th>\n\t\t\t</tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td>`divisor`</td>\n\t\t\t\t<td>`number`</td>\n\t\t\t\t<td>Multiple of the specified integer</td>\n\t\t\t\t<td>`{ rule: 2 }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`pattern`</td>\n\t\t\t\t<td>`string`</td>\n\t\t\t\t<td>Matched by a regex</td>\n\t\t\t\t<td>`{ rule: \"^[a-z]+$\" }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`min`</td>\n\t\t\t\t<td>`number`</td>\n\t\t\t\t<td>Numeric minimum (inclusive by default)</td>\n\t\t\t\t<td>`{ rule: 0, exclusive: true }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`max`</td>\n\t\t\t\t<td>`number`</td>\n\t\t\t\t<td>Numeric maximum (inclusive by default)</td>\n\t\t\t\t<td>`{ rule: 100 }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`minLength`</td>\n\t\t\t\t<td>`string | Array`</td>\n\t\t\t\t<td>Inclusive minimum length</td>\n\t\t\t\t<td>`{ rule: 1 }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`maxLength`</td>\n\t\t\t\t<td>`string | Array`</td>\n\t\t\t\t<td>Inclusive maximum length</td>\n\t\t\t\t<td>`{ rule: 255 }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`exactLength`</td>\n\t\t\t\t<td>`string | Array`</td>\n\t\t\t\t<td>Exact length</td>\n\t\t\t\t<td>`{ rule: 10 }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`after`</td>\n\t\t\t\t<td>`Date`</td>\n\t\t\t\t<td>Minimum Date (inclusive by default)</td>\n\t\t\t\t<td>`{ rule: new Date(\"2000-01-01\") }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`before`</td>\n\t\t\t\t<td>`Date`</td>\n\t\t\t\t<td>Maximum Date (inclusive by default)</td>\n\t\t\t\t<td>`{ rule: new Date() }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`predicate`</td>\n\t\t\t\t<td>`unknown`</td>\n\t\t\t\t<td>Custom `narrow` function</td>\n\t\t\t\t<td>`{ predicate: (n) => n % 2 === 1 }`</td>\n\t\t\t</tr>\n\t\t</tbody>\n\t</table>\n</div>\n\n##### Structural\n\nThese constraints define the shape and properties of objects or arrays.\n\n<div className=\"overflow-auto\">\n\t<table className=\"w-full\">\n\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t<th>kind</th>\n\t\t\t\t<th>description</th>\n\t\t\t\t<th className=\"w-1/3\">example</th>\n\t\t\t</tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td>`sequence`</td>\n\t\t\t\t<td>\n\t\t\t\t\tDefines array patterns with tuples, rest elements, and variadic parts\n\t\t\t\t</td>\n\t\t\t\t<td>`{ sequence: { prefix: [\"string\", \"number\"] } }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`required`</td>\n\t\t\t\t<td>Defines a required property in an object structure</td>\n\t\t\t\t<td>`{ key: \"id\", value: \"number\" }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`optional`</td>\n\t\t\t\t<td>Defines an optional property in an object structure</td>\n\t\t\t\t<td>`{ key: \"name\", value: \"string\" }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`index`</td>\n\t\t\t\t<td>\n\t\t\t\t\tDefines index signatures for objects (\n\t\t\t\t\t`[key: string]: value`)\n\t\t\t\t</td>\n\t\t\t\t<td>`{ key: \"string\", value: \"boolean\" }`</td>\n\t\t\t</tr>\n\t\t</tbody>\n\t</table>\n</div>\n\nMore details on the type system to come!\n\n#### select\n\n<Callout type=\"warn\" title=\"select is not fully stable!\">\n\n`select` relies on the internal representation defined in `@ark/schema`, which although relatively mature, is not guaranteed semver-stable.\n\n</Callout>\n\n`select` is the top-level first method we're introducing for interacting with a Type based on its internal representation.\n\nIt can be used to filter a Type's references:\n\n```ts\nconst T = type({\n\tname: \"string > 5\",\n\tflag: \"0 | 1\"\n})\n\t.array()\n\t.atLeastLength(1)\n\n// get all references representing literal values\nconst literals = T.select(\"unit\") // [Type<0>, Type<1>]\n\n// get all references representing literal positive numbers\nconst positiveNumberLiterals = T.select({\n\tkind: \"unit\",\n\twhere: u => typeof u.unit === \"number\" && u.unit > 0\n}) // [Type<1>]\n\n// get all minLength constraints at the root of the Type\nconst minLengthConstraints = T.select({\n\tkind: \"minLength\",\n\t// the shallow filter excludes the constraint on `name`\n\tboundary: \"shallow\"\n}) // [MinLengthNode<1>]\n```\n"
  },
  {
    "path": "ark/docs/content/docs/internal/meta.json",
    "content": "{\n\t\"title\": \"Internal\",\n\t\"pages\": [\n\t\t\"[node kinds](/docs/internal#nodekinds)\",\n\t\t\"[select](/docs/internal#select)\"\n\t]\n}\n"
  },
  {
    "path": "ark/docs/content/docs/intro/adding-constraints.mdx",
    "content": "---\ntitle: Adding Constraints\n---\n\nTypeScript is extremely versatile for representing types like `string` or `number`, but what about `email` or `integer less than 100`?\n\nIn ArkType, conditions that narrow a type beyond its **basis** are called **constraints**.\n\nConstraints are a first-class citizen of ArkType. They are fully composable with TypeScript's built-in operators and governed by the same underlying principles of set-theory.\n\n## Define\n\nLet's create a new `contact` Type that enforces our example constraints.\n\n```ts\nconst Contact = type({\n\t// many common constraints are available as built-in keywords\n\temail: \"string.email\",\n\t// others can be written as type-safe expressions\n\tscore: \"number.integer < 100\"\n})\n\n// if you need the TS type, just infer it out as normal\ntype Contact = typeof Contact.infer\n```\n\n## Compose\n\nImagine we want to define a new Type representing a non-empty list of `Contact`.\n\nWhile the expression syntax we've been using is ideal for creating new types, chaining is a great way to refine or transform existing ones.\n\n```ts\nconst _Contact = type({\n\temail: \"string.email\",\n\tscore: \"number.integer < 100\"\n})\n\ntype _Contact = typeof _Contact.t\n\ninterface Contact extends _Contact {}\n\nexport const Contact: type<Contact> = _Contact\n// ---cut-start---\n// a non-empty list of Contact\n// ---cut-end---\nconst Contacts = Contact.array().atLeastLength(1)\n```\n\n## Narrow\n\nStructured constraints like divisors and ranges will only take us so far. Luckily, they integrate seamlessly with whatever custom validation logic you need.\n\n```ts\ninterface RuntimeErrors extends type.errors {\n\t/**even must be even (was 7)\nodd must be odd (was 8)*/\n\tsummary: string\n}\n\nconst narrowMessage = (e: type.errors): e is RuntimeErrors => true\n// ---cut---\n\n// there's no \"not divisible\" expression - need to narrow\nconst Odd = type(\"number\").narrow((n, ctx) =>\n\t// if even, add a customizable error and return false\n\tn % 2 === 0 ? ctx.mustBe(\"odd\") : true\n)\n\nconst FavoriteNumbers = type({\n\teven: \"number % 2\",\n\todd: Odd\n})\n\nconst out = FavoriteNumbers({\n\teven: 7,\n\todd: 8\n})\n\nif (out instanceof type.errors) {\n\t// ---cut-start---\n\tif (!narrowMessage(out)) throw new Error()\n\t// ---cut-end---\n\t// hover summary to see validation errors\n\tconsole.error(out.summary)\n} else {\n\tconsole.log(out.odd)\n}\n```\n\nYou now know how to refine your types to enforce additional constraints at runtime.\n\nBut what if once your input is fully validated, you still need to make some adjustments before it's ready to use?\n\nThe final section of intro will cover **morphs**, an extremely powerful tool for composing and transforming Types.\n"
  },
  {
    "path": "ark/docs/content/docs/intro/meta.json",
    "content": "{\n\t\"title\": \"Intro\",\n\t\"defaultOpen\": true,\n\t\"pages\": [\"setup\", \"your-first-type\", \"adding-constraints\", \"morphs-and-more\"]\n}\n"
  },
  {
    "path": "ark/docs/content/docs/intro/morphs-and-more.mdx",
    "content": "---\ntitle: Morphs & More\n---\n\nSometimes, data at the boundaries of your code requires more than validation before it's ready to use.\n\n**Morphs** allow you to arbitrarily transform the shape and format of your data.\n\nMorphs can be **piped** before, after or between validators and even chained to other morphs.\n\n```ts\n// Hover to see the type-level representation\nconst parseJson = type(\"string\").pipe((s): object => JSON.parse(s))\n\n// object: { ark: \"type\" }\nconst out = parseJson('{ \"ark\": \"type\" }')\n\n// ArkErrors: must be a string (was object)\nconst badOut = parseJson(out)\n```\n\nThis is a good start, but there are still a couple major issues with our morph.\n\nWhat happens if we pass a string that isn't valid JSON?\n\n```ts\nconst parseJson = type(\"string\").pipe((s): object => JSON.parse(s))\n// ---cut---\n\n// Uncaught SyntaxError: Expected property name ☠️ // [!code error]\nconst badOut = parseJson('{ unquoted: \"keys\" }')\n```\n\nDespite what `JSON.parse` might have you believe, throwing exceptions and returning `any` are not very good ways to parse a string. By default, ArkType assumes that if one of your morphs or narrows throws, you intend to crash.\n\nIf you do happen to find yourself at the mercy of an unsafe API, you might consider wrapping your function body in a `try...catch`.\n\nLuckily, there is a built-in API for wrapping `pipe`d functions you don't trust:\n\n```ts\nconst parseJson = type(\"string\").pipe.try((s): object => JSON.parse(s))\n\n// Now returns an introspectable error instead of crashing 🎉\nconst badOut = parseJson('{ unquoted: \"keys\" }')\n\nconst out = parseJson('{ \"ark\": \"type\" }')\n\nif (out instanceof type.errors) out.throw()\n// Unfortunately, a validated `object` still isn't very useful...\nelse console.log(out)\n```\n\nThe best part about `pipe` is that since any `Type` is root-invokable, `Type`s themselves _are_ already morphs! This means validating out parsed output is as easy as adding another pipe:\n\n```ts\nconst parseJson = type(\"string\").pipe.try(\n\t(s): object => JSON.parse(s),\n\ttype({\n\t\tname: \"string\",\n\t\tversion: \"string.semver\"\n\t})\n)\n\nconst out = parseJson('{ \"name\": \"arktype\", \"version\": \"2.0.0\" }')\n\nif (!(out instanceof type.errors)) {\n\t// Logs \"arktype:2.0.0\"\n\tconsole.log(`${out.name}:${out.version}`)\n}\n```\n\nAt this point, our implementation is starting to look pretty clean, but in many cases like this one, we can skip straight to the punch line with one of ArkType's many built-in aliases for validation and parsing, `string.json.parse`:\n\n```ts\ninterface RuntimeErrors extends type.errors {\n\t/**name must be a string (was true) \nversion must be a semantic version (see https://semver.org/) (was \"v2.0.0\")*/\n\tsummary: string\n}\n\nconst narrowMessage = (e: type.errors): e is RuntimeErrors => true\n\n// ---cut---\n// .to is a sugared .pipe for a single parsed output validator\nconst parseJson = type(\"string.json.parse\").to({\n\tname: \"string\",\n\tversion: \"string.semver\"\n})\n\nconst out = parseJson('{ \"name\": true, \"version\": \"v2.0.0\" }')\n\nif (out instanceof type.errors) {\n\t// ---cut-start---\n\tif (!narrowMessage(out)) throw new Error()\n\t// ---cut-end---\n\t// hover out.summary to see the default error message\n\tconsole.error(out.summary)\n}\n```\n\nIf you've made it this far, congratulations! You should have all the fundamental intuitions you need to bring your types to runtime ⛵\n\nOur remaining docs will help you understand the trade offs between ArkType's most important APIs so that no matter the application, you can find a solution that feels great to write, great to read, and great to run.\n"
  },
  {
    "path": "ark/docs/content/docs/intro/setup.mdx",
    "content": "---\ntitle: Setup\n---\n\n## Installation\n\n<InstallationTabs />\n\nYou'll also need...\n\n- TypeScript version `>=5.1`.\n- A `package.json` with `\"type\": \"module\"` (or an environment that supports ESM imports)\n- A `tsconfig.json` with...\n  - [`strict`](https://www.typescriptlang.org/tsconfig#strict) or [`strictNullChecks`](https://www.typescriptlang.org/tsconfig#strictNullChecks) (**required**)\n  - [`skipLibCheck`](https://www.typescriptlang.org/tsconfig#skipLibCheck) (strongly recommended, see [FAQ](/docs/faq#why-do-i-see-type-errors-in-an-arktype-package-in-node_modules))\n  - [`exactOptionalPropertyTypes`](https://www.typescriptlang.org/tsconfig#exactOptionalPropertyTypes) (recommended)\n\n## VSCode\n\n### Settings\n\nTo take advantage of all of ArkType's autocomplete capabilities, you'll need to add the following to your workspace settings at `.vscode/settings.json`:\n\n```json\n// allow autocomplete for ArkType expressions like \"string | num\"\n\"editor.quickSuggestions\": {\n\t\"strings\": \"on\"\n},\n// prioritize ArkType's \"type\" for autoimports\n\"typescript.preferences.autoImportSpecifierExcludeRegexes\": [\n\t\"^(node:)?os$\"\n],\n```\n\n### Extension (optional)\n\n[ArkDark](https://marketplace.visualstudio.com/items?itemName=arktypeio.arkdark) provides the embedded syntax highlighting you'll see throughout the docs.\n\nWithout it, your definitions can still feel like a natural extension of the language.\n\nWith it, you'll forget there was ever a boundary in the first place.\n\n## JetBrains IDEs\n\n### Extension (optional)\n\n[ArkType](https://plugins.jetbrains.com/plugin/27099-arktype) provides the embedded syntax highlighting you are familiar with for typescript types.\n\n## Other editors\n\nIf you're using a different editor, we'd love [help adding support](https://github.com/arktypeio/arktype/issues/989). In the meantime, don't worry- ArkType still offers best-in-class DX anywhere TypeScript is supported.\n"
  },
  {
    "path": "ark/docs/content/docs/intro/your-first-type.mdx",
    "content": "---\ntitle: Your First Type\n---\n\nIf you already know TypeScript, congratulations- you just learned most of ArkType's syntax 🎉\n\n## Define\n\n```ts\nimport { type } from \"arktype\"\n\nconst User = type({\n\tname: \"string\",\n\tplatform: \"'android' | 'ios'\",\n\t\"versions?\": \"(number | string)[]\"\n})\n\n// extract the type if needed\ntype User = typeof User.infer\n```\n\nIf you make a mistake, don't worry- every definition gets the autocomplete and validation you're used to from your editor, all within TypeScript's type system.\n\n<Callout title=\"Will ArkType crash my TypeScript server?\">\n\tThousands of hours of optimization have gone into making validating native\n\ttype syntax not just feasible, but often much faster than alternatives ⚡\n</Callout>\n\n## Compose\n\nSuppose we want to move `platform` and `versions` from our original type to a new `device` property.\n\n```ts\nconst User = type({\n\tname: \"string\",\n\t// nested definitions don't need to be wrapped\n\tdevice: {\n\t\tplatform: \"'android' | 'ios'\",\n\t\t\"versions?\": \"(number | string)[]\"\n\t}\n})\n```\n\nTo decouple `device` from `User`, just move it to its own type and reference it.\n\n```ts\nconst Device = type({\n\tplatform: \"'android' | 'ios'\",\n\t\"versions?\": \"(number | string)[]\"\n})\n\nconst User = type({\n\tname: \"string\",\n\tdevice: Device\n})\n```\n\n## Validate\n\nAt runtime, we can pass `unknown` data to our type and get back either a validated `User` or an array of clear, customizable errors with a root `summary`.\n\n```ts\nconst User = type({\n\tname: \"string\",\n\tdevice: {\n\t\tplatform: \"'android' | 'ios'\",\n\t\t\"versions?\": \"(number | string)[]\"\n\t}\n})\n\ninterface RuntimeErrors extends type.errors {\n\t/**device.platform must be \"android\" or \"ios\" (was \"enigma\")\ndevice.versions[2] must be a number or a string (was bigint)*/\n\tsummary: string\n}\n\nconst narrowMessage = (e: type.errors): e is RuntimeErrors => true\n\n// ---cut---\nconst out = User({\n\tname: \"Alan Turing\",\n\tdevice: {\n\t\tplatform: \"enigma\",\n\t\tversions: [0, \"1\", 0n]\n\t}\n})\n\nif (out instanceof type.errors) {\n\t// ---cut-start---\n\t// just a trick to display the runtime error\n\tif (!narrowMessage(out)) throw new Error()\n\t// ---cut-end---\n\t// hover out.summary to see validation errors\n\tconsole.error(out.summary)\n} else {\n\t// hover out to see your validated data\n\tconsole.log(`Hello, ${out.name}`)\n}\n```\n\nAnd that's it! You now know how to define a `Type` and use it to check your data at runtime.\n\nNext, we'll take a look at how ArkType extends TypeScript's type system to handle runtime constraints like `maxLength` and `pattern`.\n"
  },
  {
    "path": "ark/docs/content/docs/introspection/index.mdx",
    "content": "---\ntitle: Introspection\n---\n\nTypes have an extremely powerful internal representation defined in `@ark/schema` that is primarily exposed through the `.internal` property on each Type.\n\nThough APIs under `.internal` are not officially frozen, they are stable enough that we want to start giving users more direct access to some of the introspection capabilities they provide.\n\n### Node kinds\n\nAll nodes have a `kind` property indicating their purpose, structure and special properties.\n\n#### Roots\n\nThe `kind` at the root of a Type will always be one of the following **root** kind.\n\n##### Bases\n\nThe simplest root nodes are defined by a single **basis** constraint.\n\nOnly a single basis can exist in an intersection. From widest to narrowest:\n\n<div className=\"overflow-auto\">\n\t<table className=\"w-full\">\n\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t<th>kind</th>\n\t\t\t\t<th>description</th>\n\t\t\t\t<th className=\"w-1/3\">example</th>\n\t\t\t</tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td>`domain`</td>\n\t\t\t\t<td>\n\t\t\t\t\tOne of 5 non-enumerable type sets (`string`, `number`, `object`, `bigint`, `symbol`)\n\t\t\t\t</td>\n\t\t\t\t<td>`{ domain: \"string\" }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`proto`</td>\n\t\t\t\t<td>\n\t\t\t\t\tA constructor checked by `instanceof` (implies domain `object`)\n\t\t\t\t</td>\n\t\t\t\t<td>`{ proto: Date }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`unit`</td>\n\t\t\t\t<td>\n\t\t\t\t\tAn exact value checked by `===` (can be intersected with any other constraint and reduced to itself or `never`)\n\t\t\t\t</td>\n\t\t\t\t<td>`{ unit: true }`</td>\n\t\t\t</tr>\n\t\t</tbody>\n\t</table>\n</div>\n\n##### Composites\n\nRoot kinds are built from references to other nodes.\n\nWill be normalized to appear in approximately the following hierarchical order:\n\n<div className=\"overflow-auto\">\n\t<table className=\"w-full\">\n\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t<th>kind</th>\n\t\t\t\t<th>description</th>\n\t\t\t\t<th className=\"w-1/3\">example</th>\n\t\t\t</tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td>`alias`</td>\n\t\t\t\t<td>Stores a cyclic reference to a node</td>\n\t\t\t\t<td>`{ reference: \"$name\" }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`union`</td>\n\t\t\t\t<td>\n\t\t\t\t\tA set of allowed nodes\n\t\t\t\t</td>\n\t\t\t\t<td>`{ branches: [\"string\", \"Array\"] }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`morph`</td>\n\t\t\t\t<td>\n\t\t\t\t\tOne or more transformations applied to valid data\n\t\t\t\t</td>\n\t\t\t\t<td>`{ in: \"string\", morphs: [(s) => s.trim()] }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`intersection`</td>\n\t\t\t\t<td>An intersection of constraints</td>\n\t\t\t\t<td>`{ domain: \"number\", divisor: 5 }`</td>\n\t\t\t</tr>\n\t\t</tbody>\n\t</table>\n</div>\n\n#### Constraints\n\nConstraint nodes exist on an `intersection` (or its `structure`) and narrow the set of values allowed by its [basis](#bases).\n\n##### Refinements\n\nConstraints that apply directly to the root of an intersection (includes the base `structure` node but not [its children](#structural)).\n\n<div className=\"overflow-auto\">\n\t<table className=\"w-full\">\n\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t<th>kind</th>\n\t\t\t\t<th>impliedBasis</th>\n\t\t\t\t<th>description</th>\n\t\t\t\t<th className=\"w-1/3\">example</th>\n\t\t\t</tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td>`divisor`</td>\n\t\t\t\t<td>`number`</td>\n\t\t\t\t<td>Multiple of the specified integer</td>\n\t\t\t\t<td>`{ rule: 2 }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`pattern`</td>\n\t\t\t\t<td>`string`</td>\n\t\t\t\t<td>Matched by a regex</td>\n\t\t\t\t<td>`{ rule: \"^[a-z]+$\" }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`min`</td>\n\t\t\t\t<td>`number`</td>\n\t\t\t\t<td>Numeric minimum (inclusive by default)</td>\n\t\t\t\t<td>`{ rule: 0, exclusive: true }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`max`</td>\n\t\t\t\t<td>`number`</td>\n\t\t\t\t<td>Numeric maximum (inclusive by default)</td>\n\t\t\t\t<td>`{ rule: 100 }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`minLength`</td>\n\t\t\t\t<td>`string | Array`</td>\n\t\t\t\t<td>Inclusive minimum length</td>\n\t\t\t\t<td>`{ rule: 1 }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`maxLength`</td>\n\t\t\t\t<td>`string | Array`</td>\n\t\t\t\t<td>Inclusive maximum length</td>\n\t\t\t\t<td>`{ rule: 255 }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`exactLength`</td>\n\t\t\t\t<td>`string | Array`</td>\n\t\t\t\t<td>Exact length</td>\n\t\t\t\t<td>`{ rule: 10 }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`after`</td>\n\t\t\t\t<td>`Date`</td>\n\t\t\t\t<td>Minimum Date (inclusive by default)</td>\n\t\t\t\t<td>`{ rule: new Date(\"2000-01-01\") }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`before`</td>\n\t\t\t\t<td>`Date`</td>\n\t\t\t\t<td>Maximum Date (inclusive by default)</td>\n\t\t\t\t<td>`{ rule: new Date() }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`predicate`</td>\n\t\t\t\t<td>`unknown`</td>\n\t\t\t\t<td>Custom `narrow` function</td>\n\t\t\t\t<td>`{ predicate: (n) => n % 2 === 1 }`</td>\n\t\t\t</tr>\n\t\t</tbody>\n\t</table>\n</div>\n\n##### Structural\n\nThese constraints refine a `structure` node, defining the shape of properties and/or array elements.\n\n<div className=\"overflow-auto\">\n\t<table className=\"w-full\">\n\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t<th>kind</th>\n\t\t\t\t<th>description</th>\n\t\t\t\t<th className=\"w-1/3\">example</th>\n\t\t\t</tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td>`sequence`</td>\n\t\t\t\t<td>Array/tuple shape</td>\n\t\t\t\t<td>`{ prefix: [\"string\"], variadic: \"number\" }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`required`</td>\n\t\t\t\t<td>Required object property</td>\n\t\t\t\t<td>`{ key: \"id\", value: \"number\" }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`optional`</td>\n\t\t\t\t<td>Optional object property</td>\n\t\t\t\t<td>`{ key: \"name\", value: \"string\" }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`index`</td>\n\t\t\t\t<td>Properties allowed by `signature` must conform to `value`</td>\n\t\t\t\t<td>`{ signature: \"string\", value: \"boolean\" }`</td>\n\t\t\t</tr>\n\t\t</tbody>\n\t</table>\n</div>\n\nMore details on the type system to come!\n\n### select\n\n<Callout type=\"warn\" title=\"select is not fully stable!\">\n\n`select` relies on the internal representation defined in `@ark/schema`, which although relatively mature, is not guaranteed semver-stable.\n\n</Callout>\n\n`select` is the top-level first method we're introducing for interacting with a Type based on its internal representation.\n\nIt can be used to filter a Type's references:\n\n```ts\nconst T = type({\n\tname: \"string > 5\",\n\tflag: \"0 | 1\"\n})\n\t.array()\n\t.atLeastLength(1)\n\n// get all references representing literal values\nconst literals = T.select(\"unit\") // [Type<0>, Type<1>]\n\n// get all references representing literal positive numbers\nconst positiveNumberLiterals = T.select({\n\tkind: \"unit\",\n\twhere: u => typeof u.unit === \"number\" && u.unit > 0\n}) // [Type<1>]\n\n// get all minLength constraints at the root of the Type\nconst minLengthConstraints = T.select({\n\tkind: \"minLength\",\n\t// the shallow filter excludes the constraint on `name`\n\tboundary: \"shallow\"\n}) // [MinLengthNode<1>]\n```\n\nThis can be used directly or in combination with the [`configure` API](/docs/expressions#meta) for fine-grained control over which nodes to modify.\n"
  },
  {
    "path": "ark/docs/content/docs/introspection/meta.json",
    "content": "{\n\t\"title\": \"Introspection\",\n\t\"pages\": [\n\t\t\"[node kinds](/docs/introspection#nodekinds)\",\n\t\t\"[select](/docs/introspection#select)\"\n\t]\n}\n"
  },
  {
    "path": "ark/docs/content/docs/keywords.mdx",
    "content": "---\ntitle: Keywords\n---\n\n### TypeScript\n\n<div>All\\* built-in TypeScript keywords are directly available.</div>\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n```ts\nconst Keywords = type({\n\tstring: \"string\",\n\tdate: \"Date\"\n})\n```\n\t</SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Keywords = type({\n\tstring: type.string,\n\tdate: type.Date\n})\n```\n\nCommon keywords are exposed directly on `type`.\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n<sup>\n\t\\* `any` and `void` are misleading and unnecessary for runtime validation and\n\tso are not included as keywords by default.\n</sup>\n\n### Subtype\n\nSubtype keywords refine or transform their root type.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n```ts\nconst Keywords = type({\n\tdateFormattedString: \"string.date\",\n\ttransformStringToDate: \"string.date.parse\",\n\tisoFormattedString: \"string.date.iso\",\n\ttransformIsoFormattedStringToDate: \"string.date.iso.parse\"\n})\n```\n\nYou can easily explore available subtypes via autocomplete by with a partial definition like `\"string.\"`.\n\n</SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Keywords = type({\n\tdateFormattedString: type.keywords.string.date.root,\n\tisoFormattedString: type.keywords.string.date.iso.root,\n\ttransformStringToDate: type.keywords.string.date.parse,\n\ttransformIsoFormattedStringToDate: type.keywords.string.date.iso.parse\n})\n```\n\nAll built-in keywords and modules are available in `type.keywords`.\n\n`.root` gets the base type of a subtyped module so that it can be used as a `Type` directly.\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### All Keywords\n\nThis table includes all keywords available in default `type` API. To define your own string-embeddable keywords, see [scopes](/docs/scopes).\n\n<AllKeywordTables />\n"
  },
  {
    "path": "ark/docs/content/docs/match.mdx",
    "content": "---\ntitle: Match\n---\n\nThe `match` function provides a powerful way to handle different types of input and return corresponding outputs based on the input type, like a type-safe `switch` statement.\n\n## Case Record API\n\nThe simplest way to define a matcher is with ArkType definition strings as keys with corresponding handlers as values:\n\n```ts\nimport { match } from \"arktype\"\n\nconst sizeOf = match({\n\t\"string | Array\": v => v.length,\n\tnumber: v => v,\n\tbigint: v => v,\n\tdefault: \"assert\"\n})\n\n// a match definition is complete once a `default` has been specified,\n// either as a case or via the .default() method\n\nsizeOf(\"abc\") // 3\nsizeOf([1, 2, 3, 4]) // 4\nsizeOf(5n) // 5n\n// TraversalError: must be a string or an object (was boolean)\nsizeOf(true)\n```\n\nIn this example, `sizeOf` is a matcher that takes a string, array, number, or bigint as input. It returns the length of strings and arrays, and the value of numbers and bigints.\n\n`default` accepts one of 4 values:\n\n- `\"assert\"`: accept `unknown`, throw if none of the cases match\n- `\"never\"`: accept an input based on inferred cases, throw if none match\n- `\"reject\"`: accept `unknown`, return `ArkErrors` if none of the cases match\n- `(data: In) => unknown`: handle data not matching other cases directly\n\nCases will be checked in the order they are specified, either as object literal keys or via chained methods.\n\n## Fluent API\n\nThe `match` function also provides a fluent API. This can be convenient for non-string-embeddable definitions:\n\n```ts\nimport { match } from \"arktype\"\n\n// the Case Record and Fluent APIs can be easily combined\nconst sizeOf = match({\n\tstring: v => v.length,\n\tnumber: v => v,\n\tbigint: v => v\n})\n\t// match any object with a numeric length property and extract it\n\t.case({ length: \"number\" }, o => o.length)\n\t// return 0 for all other data\n\t.default(() => 0)\n\nsizeOf(\"abc\") // 3\nsizeOf({ name: \"David\", length: 5 }) // 5\nsizeOf(null) // 0\n```\n\n## Narrowing input with `in`, property matching with `at`\n\n```ts\n// @errors: 2345\nimport { match } from \"arktype\"\n\ntype Data =\n\t| {\n\t\t\tid: 1\n\t\t\toneValue: number\n\t  }\n\t| {\n\t\t\tid: 2\n\t\t\ttwoValue: string\n\t  }\n\nconst discriminateValue = match\n\t// .in allows you to specify the input TypeScript allows for your matcher\n\t.in<Data>()\n\t// .at allows you to specify a key at which your input will be matched\n\t.at(\"id\")\n\t.match({\n\t\t1: o => `${o.oneValue}!`,\n\t\t2: o => o.twoValue.length,\n\t\tdefault: \"assert\"\n\t})\n\ndiscriminateValue({ id: 1, oneValue: 1 }) // \"1!\"\ndiscriminateValue({ id: 2, twoValue: \"two\" }) // 3\ndiscriminateValue({ oneValue: 3 })\n```\n"
  },
  {
    "path": "ark/docs/content/docs/meta.json",
    "content": "{\n\t\"pages\": [\n\t\t\"intro\",\n\t\t\"primitives\",\n\t\t\"objects\",\n\t\t\"keywords\",\n\t\t\"expressions\",\n\t\t\"match\",\n\t\t\"configuration\",\n\t\t\"type-api\",\n\t\t\"traversal-api\",\n\t\t\"integrations\",\n\t\t\"ecosystem\",\n\t\t\"scopes\",\n\t\t\"generics\",\n\t\t\"declare\",\n\t\t\"blog\",\n\t\t\"faq\"\n\t]\n}\n"
  },
  {
    "path": "ark/docs/content/docs/objects/arrays/meta.json",
    "content": "{\n\t\"title\": \"arrays and tuples\",\n\t\"pages\": [\n\t\t\"[lengths](/docs/objects#arrays-lengths)\",\n\t\t\"[prefix](/docs/objects#tuples-prefix)\",\n\t\t\"[defaultable](/docs/objects#tuples-defaultable)\",\n\t\t\"[optional](/docs/objects#tuples-optional)\",\n\t\t\"[variadic](/docs/objects#tuples-variadic)\",\n\t\t\"[postfix](/docs/objects#tuples-postfix)\"\n\t]\n}\n"
  },
  {
    "path": "ark/docs/content/docs/objects/index.mdx",
    "content": "---\ntitle: Objects\n---\n\n## properties\n\nObjects definitions can include any combination of required, optional, defaultable named properties and index signatures.\n\n### required [#properties-required]\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst symbolicKey = Symbol()\n\nconst MyObj = type({\n\trequiredKey: \"string\",\n\t// Nested definitions don't require additional `type` calls!\n\t[symbolicKey]: {\n\t\tnested: \"unknown\"\n\t}\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst symbolicKey = Symbol()\n\nconst MyObj = type({\n\trequiredKey: type.string,\n\t// Nested definitions don't require additional `type` calls!\n\t[symbolicKey]: {\n\t\tnested: type.unknown\n\t}\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### optional [#properties-optional]\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst symbolicKey = Symbol()\n\nconst MyObj = type({\n\t\"optionalKey?\": \"number[]\",\n\t[symbolicKey]: \"string?\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst symbolicKey = Symbol()\n\nconst MyObj = type({\n\toptionalKey: type.number.array().optional(),\n\t[symbolicKey]: type.string.optional()\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\nconst symbolicKey = Symbol()\n\nconst MyObj = type({\n\toptionalKey: [{ type: \"'script'\" }, \"?\"],\n\t[symbolicKey]: [{ ark: \"'type'\" }, \"?\"]\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n<Callout type=\"info\" title=\"Should I use key or value syntax for optionality?\">\n\n    Optionality can either be expressed on the key or the corresponding value.\n\n    We recommend using the key syntax by default because...\n\n    - it mirrors TypeScript\n    - it better reflects a _key presence_ constraint that has no effect on allowed values\n\n    However, there are a few reasons you might want to use a value-embedded syntax:\n\n    1. The key is a symbol (makes key-embedded syntax impossible)\n    2. You want editor features like JSDoc and go-to-definition for the key (can't work if the key name changes)\n    3. You really hate having to quote key names\n\n</Callout>\n\n<Callout type=\"warn\" title=\"Optional properties cannot be present with the value undefined\">\n\n    In TypeScript, there is a setting called [`exactOptionalPropertyTypes`](https://www.typescriptlang.org/tsconfig#exactOptionalPropertyTypes) that can be set to `true` to enforce the distinction between properties that are missing and properties that are present with the value `undefined`.\n\n    ArkType mirrors this behavior by default, so if you want to allow `undefined`, you'll need to add it to your value's definition. Though not recommended as a long-term solution, you may also [globally configure `exactOptionalPropertyTypes`](/docs/configuration#exactoptionalpropertytypes) to `false`.\n\n    <details>\n    \t<summary>See an example</summary>\n\n    ```ts\n    const MyObj = type({\n    \t\"key?\": \"number\"\n    })\n\n    // valid data\n    const validResult = MyObj({})\n\n    // Error: key must be a number (was undefined)\n    const errorResult = MyObj({ key: undefined })\n    ```\n\n    </details>\n\n</Callout>\n\n### defaultable [#properties-defaultable]\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst MyObj = type({\n\tdefaultableKey: \"boolean = false\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst MyObj = type({\n\tdefaultableKey: type.boolean.default(false)\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\nconst MyObj = type({\n\tdefaultableKey: [\"boolean\", \"=\", false]\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n<Callout type=\"warn\" title=\"Optional and default only work within objects and tuples!\">\n    Unlike e.g. `number.array()`, `number.optional()` and `number.default(0)` don't return a new `Type`, but rather a tuple definition like `[Type<number>, \"?\"]` or `[Type<number>, \"=\", 0]`.\n\n    This reflects the fact that in ArkType's type system, optionality and defaultability are only meaningful in reference to a property. Attempting to create an optional or defaultable value outside an object like `type(\"string?\")` will result in a `ParseError`.\n\n    To create a `Type` accepting `string` or `undefined`, use a union like `type(\"string | undefined\")`.\n\n    To have it transform `undefined` to an empty string, use an explicit morph like:\n\n    ```ts\n    const FallbackString = type(\"string | undefined\").pipe(v => v ?? \"\")\n    ```\n\n</Callout>\n\n### index [#properties-index]\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst MyObj = type({\n\t// index signatures do not require a label\n\t\"[string]\": \"number.integer\",\n\t// arbitrary string or symbolic expressions are allowed\n\t\"[string | symbol]\": \"number\"\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### undeclared [#properties-undeclared]\n\nTypeScript's structural type system explicitly allows assigning objects with additional keys so long as all declared constraints are satisfied. ArkType mirrors this behavior by default because generally...\n\n- Existing objects can be reused more often.\n- Validation is much more efficient if you don't need to check for undeclared keys.\n- Extra properties don't usually matter as long as those you've declared are satisfied.\n\nHowever, sometimes the way you're using the object would make undeclared properties problematic. Even though they can't be reflected by TypeScript ([_yet_- please +1 the issue!](https://github.com/microsoft/TypeScript/issues/12936#issuecomment-1854411301)), ArkType _does_ support rejection or deletion of undeclared keys. This behavior can be defined for individual objects using the syntax below or [via configuration](/docs/configuration#onundeclaredkey) if you want to change the default across all objects.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\n// fail if any key other than \"onlyAllowedKey\" is present\nconst MyClosedObject = type({\n\t\"+\": \"reject\",\n\tonlyAllowedKey: \"string\"\n})\n\n// delete all non-symbolic keys other than \"onlyPreservedStringKey\"\nconst MyStrippedObject = type({\n\t\"+\": \"delete\",\n\t\"[symbol]\": \"unknown\",\n\tonlyPreservedStringKey: \"string\"\n})\n\n// allow and preserve undeclared keys (the default behavior)\nconst MyOpenObject = type({\n\t// only specify \"ignore\" if you explicitly configured the default elsewhere\n\t\"+\": \"ignore\",\n\tnonexclusiveKey: \"number\"\n})\n```\n\n    </SyntaxTab>\n\n    \t<SyntaxTab fluent>\n\n```ts\n// fail if any key other than \"onlyAllowedKey\" is present\nconst MyClosedObject = type({\n\tonlyAllowedKey: \"string\"\n}).onUndeclaredKey(\"reject\")\n\n// delete all non-symbolic keys other than \"onlyPreservedStringKey\"\nconst MyStrippedObject = type({\n\t\"[symbol]\": \"unknown\",\n\tonlyPreservedStringKey: \"string\"\n}).onUndeclaredKey(\"delete\")\n\n// allow and preserve undeclared keys (the default behavior)\nconst MyOpenObject = type({\n\tnonexclusiveKey: \"number\"\n\t// only specify \"ignore\" if you explicitly configured the default elsewhere\n}).onUndeclaredKey(\"ignore\")\n\n// there is also a method for altering nested objects recursively\nconst MyDeeplyStrippedObject = type({\n\tpreserved: \"string\",\n\tnested: {\n\t\tpreserved: \"string\"\n\t}\n}).onDeepUndeclaredKey(\"delete\")\n```\n\n<Callout type=\"info\" title=\"Prefer in-object syntax where possible\">\n\tCertain methods like `.onUndeclaredKey` or `.configure` require a full traversal and transformation of the node created by the initial `type` call.\n\n    <details>\n    \t<summary>**Learn to recognize when chaining creates unnecessary overhead**</summary>\n\nThough they can be convenient if you need both variants of the type, most of the time you incur a significant performance cost instantiating your Type compared to the embedded syntax.\n\nThough how a Type is defined will never affect validation performance, depending on your sensitivity to initialization, you may want to avoid chained methods that transform rather than compose their base type. Methods like `.or` and `.pipe` that create new `Types` that directly reference the original incur no such overhead, so feel free to use whichever syntax is more convenient for those operations.\n\n    </details>\n\n</Callout>\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n<AnchorAliases properties-merge spread properties-spread />\n### merge\n\n**merge** allows you to extend an object with new properties or replace existing ones like the `...` operator [in JS](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax).\n\nWhen applied to two distinct (i.e. non-overlapping) sets of properties, it is a more efficient equivalent of [intersection](/docs/expressions#intersection).\n\nHowever, if a key appears in both the base and merged objects, the base value will be discarded in favor of the merged rather than recursively intersected.\n\nSpreading bypasses a lot of the behavioral complexity and computational overhead of an intersection and should be the preferred method of combining property sets.\n\n<SyntaxTabs>\n    <SyntaxTab fluent>\n\n```ts\nconst zildjian = Symbol()\n\nconst Base = type({\n\t\"[string]\": \"number\",\n\tfoo: \"0\",\n\t[zildjian]: \"true\"\n})\n\n// hover to see the inferred result\nconst chainedResult = Base.merge({\n\t\"[string]\": \"bigint\",\n\t\"foo?\": \"1n\"\n})\n```\n\n    </SyntaxTab>\n    <SyntaxTab string>\n\n```ts\nconst User = type({ isAdmin: \"false\", name: \"string\" })\n\n// hover to see the newly merged object\nconst Admin = type({\n\t\"...\": User,\n\t// in an intersection, non-overlapping values at isAdmin would result in a ParseError\n\tisAdmin: \"true\",\n\tpermissions: \"string[]\"\n})\n```\n\n    </SyntaxTab>\n    <SyntaxTab generic>\n\n```ts\nconst types = type.module({\n\tbase: {\n\t\t\"foo?\": \"0\",\n\t\t\"bar?\": \"0\"\n\t},\n\tmerged: {\n\t\tbar: \"1\",\n\t\t\"baz?\": \"1\"\n\t},\n\tresult: \"Merge<base, merged>\"\n})\n\n// hover to see the inferred result\ntype Result = typeof types.result.infer\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n<AnchorAliases merge-n-ary />\n#### n-ary\n\nTo merge many objects directly, `type.merge` will avoid the need to chain or compose many binary expressions:\n\n```ts\nconst zildjian = Symbol()\n\nconst Base = type({\n\t\"[string]\": \"number\",\n\tfoo: \"0\",\n\t[zildjian]: \"true\"\n})\n\n// accepts ...objectDefinitions\nconst functionResult = type.merge(\n\tBase,\n\t{\n\t\t\"[string]\": \"bigint\",\n\t\t\"foo?\": \"1n\"\n\t},\n\t{\n\t\tincludeThisPropAlso: \"true\"\n\t}\n)\n```\n\n### keyof [#properties-keyof]\n\nLike in TypeScript, the `keyof` operator extracts the keys of an object as a union:\n\n<SyntaxTabs>\n    <SyntaxTab fluent>\n\n```ts\nconst UsedCar = type({\n\toriginallyPurchased: \"string.date\",\n\tremainingWheels: \"number\"\n})\n\nconst UsedCarKey = UsedCar.keyof()\n\ntype UsedCarKey = typeof UsedCarKey.infer\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab string>\n\n```ts\nconst types = type.module({\n\tUsedCar: {\n\t\toriginallyPurchased: \"string.date\",\n\t\tremainingWheels: \"number\"\n\t},\n\tUsedCarKey: \"keyof UsedCar\"\n})\n\ntype UsedCarKey = typeof types.UsedCarKey.infer\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\nconst UsedCar = type({\n\toriginallyPurchased: \"string.date\",\n\tremainingWheels: \"number\"\n})\n\nconst UsedCarKey = type([\"keyof\", UsedCar])\n\ntype UsedCarKey = typeof UsedCarKey.infer\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab args>\n\n```ts\nconst UsedCar = type({\n\toriginallyPurchased: \"string.date\",\n\tremainingWheels: \"number\"\n})\n\nconst UsedCarKey = type(\"keyof\", UsedCar)\n\ntype UsedCarKey = typeof UsedCarKey.infer\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\nAlso like in TypeScript, if an object includes an index signature like `[string]` alongside named properties, the union from `keyof` will reduce to `string`:\n\n```ts\nconst RecordWithSpecialKeys = type({\n\t\"[string]\": \"unknown\",\n\tverySpecialKey: \"0 < number <= 3.14159\",\n\tmoderatelySpecialKey: \"-9.51413 <= number < 0\"\n})\n\n// in a union with the `string` index signature, string literals\n// \"verySpecialKey\" and \"moderatelySpecialKey\" are redundant and will be pruned\nconst Key = RecordWithSpecialKeys.keyof()\n\n// key is identical to the base `string` Type\nconsole.log(Key.equals(\"string\"))\n```\n\n<Callout type=\"warn\" title=\"ArkType's `keyof` will never include `number`\">\n\tThough TypeScript's `keyof` operator can yield a `number`, the concept of\n\tnumeric keys does not exist in JavaScript at runtime. This leads to confusing\n\tand inconsistent behavior. In ArkType, `keyof` will always return a `string`\n\tor `symbol` in accordance with the construction of a JavaScript object.\n\n    <details>\n    \t<summary>Learn more about our motivation for diverging from TypeScript on this issue</summary>\n\nIn JavaScript, you can use a number literal to define a key, but the constructed value has no way to represent a numeric key, so it is coerced to a string.\n\n```ts\nconst numberLiteralObj = {\n\t4: true,\n\t5: true\n}\n\nconst stringLiteralObj = {\n\t\"4\": true,\n\t\"5\": true\n}\n\n// numberLiteralObj and stringLiteralObj are indistinguishable at this point\nObject.keys(numberLiteralObj) // [\"4\", \"5\"]\nObject.keys(stringLiteralObj) // [\"4\", \"5\"]\n```\n\nFor a set-based type system to be correct, any two types representing the same set of underlying values must share a single representation. TypeScript's decision to have distinct numeric and string representations for the same underlying key has led to some if its most confusing inference pitfalls:\n\n```ts\ntype Thing1 = {\n\t[x: string]: unknown\n}\n\n// Thing2 is apparently identical to Thing1\ntype Thing2 = Record<string, unknown>\n\n// and yet...\ntype Key1 = keyof Thing1\n//   ^?\n\ntype Key2 = keyof Thing2\n//   ^?\n```\n\nThis sort of inconsistency is inevitable for a type system that has to reconcile multiple representations\nfor identical sets of underlying values. Therefore, numeric keys are one of a handful of cases where ArkType intentionally diverges from TypeScript. ArkType will never return a `number` from `keyof`. Keys will always be normalized to a `string` or `symbol`, the two distinct property types that can be uniquely attached to a JavaScript object.\n\n    </details>\n\n</Callout>\n\n### get [#properties-get]\n\nLike an index access expression in TypeScript (e.g. `User[\"name\"]`), the `get` operator extracts the Type of a value based on a specified key definition from an object:\n\n```ts\nconst snorfUsage = type.enumerated(\"eating plants\", \"looking adorable\")\n\nconst Manatee = type({\n\tisFriendly: \"true\",\n\tsnorf: {\n\t\tuses: snorfUsage.array()\n\t}\n})\n\nconst True = Manatee.get(\"isFriendly\")\n\n// nested properties can be accessed directly by passing additional args\nconst SnorfUses = Manatee.get(\"snorf\", \"uses\")\n```\n\n<Callout\n\ttype=\"warn\"\n\ttitle=\"Expressions like `get` and `omit` that extract a portion of an existing Type can be an antipattern!\"\n>\n\tBefore using `get` to extract the type of a property you've defined, consider\n\twhether you may be able to define the property value directly as a standalone\n\tType that can be easily referenced and composed as needed.\n\n    Usually, composing Types from the bottom up is clearer and more efficient than trying to rip the part you need out of an existing Type.\n\n</Callout>\n\nThough cases like this are quite straightforward, there are a number of more nuanced behaviors to consider when accessing an arbitrary key that could be a union, literal, or index signature on an object Type that could also be a union including optional keys or index signatures.\n\nIf you're interested in a deeper dive into this (or anything else in ArkType), [our unit tests](https://github.com/arktypeio/arktype/blob/main/ark/type/__tests__/get.test.ts) are the closest thing we have to a comprehensive spec.\n\nNot your cup of tea? No worries- the inferred types and errors you'll see in editor will always be guiding you in the right direction 🧭\n\n<Callout\n\ttype=\"info\"\n\ttitle=\"Support for TypeScript's index access syntax is planned!\"\n>\n\tLeave a comment on [the\n\tissue](https://github.com/arktypeio/arktype/issues/831) letting us know if\n\tyou're interested in using- or even helping implement- type-level parsing for\n\tstring-embedded index access 🤓\n</Callout>\n\n### pick / omit [#properties-pick-omit]\n\nExtract or exclude specific properties from an object Type:\n\n```ts\nconst User = type({\n\tname: \"string\",\n\temail: \"string.email\",\n\t\"age?\": \"number\"\n})\n\n// Type<{ name: string; email: string }>\nconst NameAndEmail = User.pick(\"name\", \"email\")\n\n// Type<{ name: string; age?: number }>\nconst WithoutEmail = User.omit(\"email\")\n```\n\nThese are also available as [generic keywords](/docs/generics): `Pick(User, \"name | email\")`, `Omit(User, \"email\")`.\n\n### required / partial [#properties-required-partial]\n\nMake all named properties required or optional:\n\n```ts\nconst User = type({\n\tname: \"string\",\n\t\"email?\": \"string.email\",\n\t\"age?\": \"number\"\n})\n\n// Type<{ name: string; email: string; age: number }>\nconst RequiredUser = User.required()\n\nconst Config = type({\n\thost: \"string\",\n\tport: \"number\"\n})\n\n// Type<{ host?: string; port?: number }>\nconst PartialConfig = Config.partial()\n```\n\nThese are also available as [generic keywords](/docs/generics): `Required(User)`, `Partial(Config)`.\n\n### readonly [#properties-readonly]\n\nMark all properties as readonly (type-level only, no runtime effect):\n\n```ts\nconst Frozen = type({\n\tid: \"number\",\n\tname: \"string\"\n}).readonly()\n\n// Type<{ readonly id: number; readonly name: string }>\n```\n\n### map [#properties-map]\n\nTransform the properties of an object Type using a mapping function. The mapper receives a prop entry with `key`, `value`, and `kind` (`\"required\"` or `\"optional\"`). Return a `{ key, value }` object (optionally with `kind`) to transform, or an empty array `[]` to remove the property.\n\n```ts\n// @noErrors\nconst User = type({\n\tname: \"string\",\n\t\"age?\": \"number\"\n})\n\n// make all properties nullable by wrapping each value in a union with null\nconst NullableUser = User.map(prop => {\n\treturn { key: prop.key, value: prop.value.or(\"null\") }\n})\n// Type<{ name: string | null; age?: number | null }>\n```\n\n### props [#properties-props]\n\nThe `props` getter returns an array of property descriptors for introspection:\n\n```ts\nconst User = type({\n\tname: \"string\",\n\t\"age?\": \"number\",\n\trole: \"'admin' | 'user' = 'user'\"\n})\n\nfor (const prop of User.props) {\n\tconsole.log(prop.kind) // \"required\", \"optional\"\n\tconsole.log(prop.key) // \"name\", \"role\", \"age\"\n\tconsole.log(prop.value.expression) // \"string\", '\"admin\" | \"user\"', \"number\"\n\tconsole.log(prop.meta) // metadata object\n\tif (\"default\" in prop) console.log(prop.default) // \"user\" for role\n}\n```\n\n## arrays\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst Arrays = type({\n\tkey: \"string[]\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Arrays = type({\n\tkey: type.string.array()\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\nconst Arrays = type({\n\tkey: [{ name: \"string\" }, \"[]\"]\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab args>\n\n```ts\nconst Arrays = type({\n\tkey: type({ name: \"string\" }, \"[]\")\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### lengths [#arrays-lengths]\n\nConstrain an array with an inclusive or exclusive min or max length.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst Bounded = type({\n\tnonEmptyStringArray: \"string[] > 0\",\n\tatLeast3Integers: \"number.integer[] >= 3\",\n\tlessThan10Emails: \"string.email[] < 10\",\n\tatMost5Booleans: \"boolean[] <= 5\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Bounded = type({\n\tnonEmptyStringArray: type.string.array().moreThanLength(0),\n\tatLeast3Integers: type.keywords.number.integer.array().atLeastLength(3),\n\tlessThan10Emails: type.keywords.string.email.array().lessThanLength(10),\n\tatMost5Booleans: type.boolean.array().atMostLength(5)\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\nRange expressions allow you to specify both a min and max length and use the same syntax for exclusivity.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst Range = type({\n\tnonEmptyStringArrayAtMostLength10: \"0 < string[] <= 10\",\n\ttwoToFiveIntegers: \"2 <= number.integer[] < 6\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Range = type({\n\tnonEmptyStringArrayAtMostLength10: type.string\n\t\t.array()\n\t\t.moreThanLength(0)\n\t\t.atMostLength(10),\n\ttwoToFiveIntegers: type.keywords.number.integer\n\t\t.array()\n\t\t.atLeastLength(2)\n\t\t.lessThanLength(6)\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n## tuples\n\nLike objects, tuples are structures whose values are nested definitions. Like TypeScript, ArkType supports prefix, optional, variadic, and postfix elements, with the same restrictions about combining them.\n\n### prefix [#tuples-prefix]\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst MyTuple = type([\n\t\"string\",\n\t// Object definitions can be nested in tuples- and vice versa!\n\t{\n\t\tcoordinates: [\"number\", \"number\"]\n\t}\n])\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst MyTuple = type([\n\ttype.string,\n\t// Object definitions can be nested in tuples- and vice versa!\n\t{\n\t\tcoordinates: [type.number, type.number]\n\t}\n])\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### defaultable [#tuples-defaultable]\n\nDefaultable elements are optional elements that will be assigned their specified default if not present in the tuple's input.\n\nA tuple may include zero or more defaultable elements following its prefix elements and preceding its non-defaultable optional elements.\n\nLike optional elements, defaultable elements are mutually exclusive with postfix elements.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst MyTuple = type([\"string\", \"boolean = false\", \"number = 0\"])\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst MyTuple = type([\n\ttype.string,\n\ttype.boolean.default(false),\n\ttype.number.default(0)\n])\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\nconst MyTuple = type([\n\t\"string\",\n\t[\n\t\t{\n\t\t\tname: \"string\"\n\t\t},\n\t\t\"=\",\n\t\t() => ({ name: \"Anon Eemuss\" })\n\t]\n])\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### optional [#tuples-optional]\n\nOptional elements are tuple elements that may or may not be present in the input that do not have a default value.\n\nA tuple may include zero or more optional elements following its prefix and defaultable elements and preceding either a variadic element or the end of the tuple.\n\nLike in TypeScript, optional elements are mutually exclusive with postfix elements.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst MyTuple = type([\"string\", \"bigint = 999n\", \"boolean?\", \"number?\"])\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst MyTuple = type([\n\ttype.string,\n\ttype.bigint.default(999n),\n\ttype.boolean.optional(),\n\ttype.number.optional()\n])\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\nconst MyTuple = type([\n\t\"string\",\n\t[\n\t\t{\n\t\t\tname: \"string\"\n\t\t},\n\t\t\"?\"\n\t]\n])\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### variadic [#tuples-variadic]\n\nLike in TypeScript, variadic elements allow zero or more consecutive values of a given type and may occur at most once in a tuple.\n\nThey are specified with a `\"...\"` operator preceding an array element.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\n// allows a string followed by zero or more numbers\nconst MyTuple = type([\"string\", \"...\", \"number[]\"])\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\n// allows a string followed by zero or more numbers\nconst MyTuple = type([type.string, \"...\", type.number.array()])\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### postfix [#tuples-postfix]\n\nPostfix elements are required elements following a variadic element.\n\nThey are mutually exclusive with optional elements.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\n// allows zero or more numbers followed by a boolean, then a string\nconst MyTuple = type([\"...\", \"number[]\", \"boolean\", \"string\"])\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\n// allows zero or more numbers followed by a boolean, then a string\nconst MyTuple = type([\"...\", type.number.array(), type.boolean, type.string])\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n## dates\n\n### literals [#dates-literals]\n\nDate literals represent a Date instance with an exact value.\n\nThey're primarily useful in ranges.\n\n```ts\nconst Literals = type({\n\tsingleQuoted: \"d'01-01-1970'\",\n\tdoubleQuoted: 'd\"01-01-1970\"'\n})\n```\n\n### ranges [#dates-ranges]\n\nConstrain a Date with an inclusive or exclusive min or max.\n\nBounds can be expressed as either a [number](/docs/primitives#number-literals) representing its corresponding Unix epoch value or a [Date literal](/docs/objects#dates-literals).\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst Bounded = type({\n\tdateInThePast: `Date < ${Date.now()}`,\n\tdateAfter2000: \"Date > d'2000-01-01'\",\n\tdateAtOrAfter1970: \"Date >= 0\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Bounded = type({\n\tdateInThePast: type.Date.earlierThan(Date.now()),\n\tdateAfter2000: type.Date.laterThan(\"2000-01-01\"),\n\tdateAtOrAfter1970: type.Date.atOrAfter(0)\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\nRange expressions allow you to specify both a min and max and use the same syntax for exclusivity.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst tenYearsAgo = new Date()\n\t.setFullYear(new Date().getFullYear() - 10)\n\t.valueOf()\n\nconst Bounded = type({\n\tdateInTheLast10Years: `${tenYearsAgo} <= Date < ${Date.now()}`\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst tenYearsAgo = new Date()\n\t.setFullYear(new Date().getFullYear() - 10)\n\t.valueOf()\n\nconst Bounded = type({\n\tdateInTheLast10Years: type.Date.atOrAfter(tenYearsAgo).earlierThan(Date.now())\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n## instanceof\n\nMost built-in instance types like `Array` and `Date` are available directly as keywords, but `instanceof` can be useful for constraining a type to one of your own classes.\n\n<SyntaxTabs>\n    <SyntaxTab fluent>\n\n```ts\nclass MyClass {}\n\nconst Instances = type.instanceOf(MyClass)\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\nclass MyClass {}\n\nconst Instances = type({\n\tkey: [\"instanceof\", MyClass]\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab args>\n\n```ts\nclass MyClass {}\n\nconst Instances = type({\n\tkey: type(\"instanceof\", MyClass)\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### keywords [#instanceof-keywords]\n\nA list of instanceof keywords can be found [here](/docs/keywords#instanceof) alongside the base and subtype keywords for [Array](/docs/keywords#array) and [FormData](/docs/keywords#formdata).\n"
  },
  {
    "path": "ark/docs/content/docs/objects/meta.json",
    "content": "{\n\t\"title\": \"Objects\",\n\t\"defaultOpen\": true,\n\t\"pages\": [\n\t\t\"properties\",\n\t\t\"arrays\",\n\t\t\"[dates](/docs/objects#dates)\",\n\t\t\"[instanceof](/docs/objects#instanceof)\"\n\t]\n}\n"
  },
  {
    "path": "ark/docs/content/docs/objects/properties/meta.json",
    "content": "{\n\t\"title\": \"properties\",\n\t\"pages\": [\n\t\t\"[required](/docs/objects#properties-required)\",\n\t\t\"[optional](/docs/objects#properties-optional)\",\n\t\t\"[defaultable](/docs/objects#properties-defaultable)\",\n\t\t\"[index](/docs/objects#properties-index)\",\n\t\t\"[undeclared](/docs/objects#properties-undeclared)\",\n\t\t\"[spread](/docs/objects#properties-spread)\",\n\t\t\"[keyof](/docs/objects#properties-keyof)\",\n\t\t\"[get](/docs/objects#properties-get)\",\n\t\t\"[pick / omit](/docs/objects#properties-pick-omit)\",\n\t\t\"[required / partial](/docs/objects#properties-required-partial)\",\n\t\t\"[readonly](/docs/objects#properties-readonly)\",\n\t\t\"[map](/docs/objects#properties-map)\",\n\t\t\"[props](/docs/objects#properties-props)\"\n\t]\n}\n"
  },
  {
    "path": "ark/docs/content/docs/primitives/index.mdx",
    "content": "---\ntitle: Primitives\n---\n\n## string\n\n### keywords\n\nThe following keywords can be referenced in any definition, e.g.:\n\n```ts\nconst Email = type(\"string.email\")\n\nconst User = type({\n\tdata: \"string.json.parse\",\n\tids: \"string.uuid.v4[]\"\n})\n```\n\n<StringKeywordTable />\n\n### literals [#string-literals]\n\n```ts\nconst Literals = type({\n\tsingleQuoted: \"'typescript'\",\n\tdoubleQuoted: '\"arktype\"'\n})\n```\n\n### patterns [#string-patterns]\n\nRegex literals specify an unanchored regular expression that an input string must match.\n\nThey can either be string-embedded or refer directly to a `RegExp` instance.\n\n```ts\nconst Literals = type({\n\tstringEmbedded: \"/^a.*z$/\",\n\tregexLiteral: /^a.*z$/\n})\n```\n\nRegex literals now carry full type inference via [arkregex](/docs/blog/arkregex):\n\n```ts\nconst Hex = type(\"/^[0-9a-fA-F]+$/\")\n//    Type<string>\n\nconst Semver = type(\"/^(\\\\d+)\\\\.(\\\\d+)\\\\.(\\\\d+)$/\")\n//    Type<`${number}.${number}.${number}`>\n```\n\n#### e(x)ec mode\n\nPrefix a regex literal with `x` to parse capture groups at runtime, fully typed:\n\n```ts\nconst User = type({\n\tbirthday: \"x/^(?<month>\\\\d{2})-(?<day>\\\\d{2})-(?<year>\\\\d{4})$/\"\n})\n\nconst data = User.assert({ birthday: \"05-21-1993\" })\n\n// fully type-safe\ndata.birthday.groups.month // \"05\"\ndata.birthday.groups.day // \"21\"\ndata.birthday.groups.year // \"1993\"\n```\n\nFor the standalone package (no ArkType required), see the full [arkregex announcement](/docs/blog/arkregex).\n\n### lengths [#string-lengths]\n\nConstrain a string with an inclusive or exclusive min or max length.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst Bounded = type({\n\tnonEmpty: \"string > 0\",\n\tatLeastLength3: \"string.alphanumeric >= 3\",\n\tlessThanLength10: \"string < 10\",\n\tatMostLength5: \"string <= 5\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Bounded = type({\n\tnonEmpty: type.string.moreThanLength(0),\n\tatLeastLength3: type.keywords.string.alphanumeric.atLeastLength(3),\n\tlessThanLength10: type.string.lessThanLength(10),\n\tatMostLength5: type.string.atMostLength(5)\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\nRange expressions allow you to specify both a min and max length and use the same syntax for exclusivity.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst Range = type({\n\tnonEmptyAtMostLength10: \"0 < string <= 10\",\n\tintegerStringWith2To5Digits: \"2 <= string.integer < 6\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Range = type({\n\tnonEmptyAtMostLength10: type.string.moreThanLength(0).atMostLength(10),\n\tintegerStringWith2To5Digits: type.keywords.string.integer.root\n\t\t.atLeastLength(2)\n\t\t.lessThanLength(6)\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n## number\n\n### keywords [#number-keywords]\n\nThe following keywords can be referenced in any definition, e.g.:\n\n```ts\nconst User = type({\n\tcreatedAt: \"number.epoch\",\n\tage: \"number.integer >= 0\"\n})\n```\n\n<NumberKeywordTable />\n\n### literals [#number-literals]\n\n```ts\nconst Literals = type({\n\tnumber: \"1337\"\n})\n```\n\n### ranges [#number-ranges]\n\nConstrain a number with an inclusive or exclusive min or max.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst Bounded = type({\n\tpositive: \"number > 0\",\n\tatLeast3: \"number.integer >= 3\",\n\tlessThanPi: \"number < 3.14159\",\n\tatMost5: \"number <= 5\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Bounded = type({\n\tpositive: type.number.moreThan(0),\n\tatLeast3: type.keywords.number.integer.atLeast(3),\n\tlessThanPi: type.number.lessThan(3.14159),\n\tatMost5: type.number.atMost(5)\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\nRange expressions allow you to specify both a min and max and use the same syntax for exclusivity.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst Range = type({\n\tpositiveAtMostE: \"0 < number <= 2.71828\",\n\tevenNumberAbsoluteValueLessThan50: \"-50 < (number % 2) < 50\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Range = type({\n\tpositiveAtMostE: type.number.moreThan(0).atMost(2.71828),\n\tevenNumberAbsoluteValueLessThan50: type.number\n\t\t.divisibleBy(2)\n\t\t.moreThan(-50)\n\t\t.lessThan(50)\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### divisors [#number-divisors]\n\nConstrain a `number` to a multiple of the specified integer.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst Evens = type({\n\tkey: \"number % 2\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Evens = type({\n\tkey: type.number.divisibleBy(2)\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n## bigint\n\nTo allow any `bigint` value, use the `\"bigint\"` keyword.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst Bigints = type({\n\tfoo: \"bigint\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Symbols = type({\n\tfoo: type.bigint\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### literals [#bigint-literals]\n\nTo require an exact `bigint` value in your type, you can use add the suffix `n` to a string-embedded [number literal](/docs/primitives#number-literals) to make it a `bigint`.\n\n```ts\nconst Literals = type({\n\tbigint: \"1337n\"\n})\n```\n\nYou may also use a [unit expression](/docs/expressions#unit) to define `bigint` literals.\n\n## symbol\n\nTo allow any `symbol` value, use the `\"symbol\"` keyword.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst Symbols = type({\n\tkey: \"symbol\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Symbols = type({\n\tkey: type.symbol\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\nTo reference a specific symbol in your definition, use a [unit expression](/docs/expressions#unit).\n\nNo special syntax is required to define symbolic properties like `{ [mySymbol]: \"string\" }`. For more information and examples of how to combine symbolic keys with other syntax like optionality, see [properties](/docs/objects#properties).\n\n## boolean\n\nTo allow `true` or `false`, use the `\"boolean\"` keyword.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst Booleans = type({\n\tkey: \"boolean\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Booleans = type({\n\tkey: type.boolean\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### literals [#boolean-literals]\n\nTo require a specific boolean value, use the corresponding literal.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst Booleans = type({\n\ta: \"true\",\n\tb: \"false\",\n\t// equivalent to the \"boolean\" keyword\n\tc: \"true | false\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Booleans = type({\n\ta: type.keywords.true,\n\tb: type.keywords.false,\n\t// equivalent to the \"boolean\" keyword\n\tc: type.keywords.true.or(type.keywords.false)\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n## null\n\nThe `\"null\"` keyword can be used to allow the exact value `null`, generally as part of a [union](/docs/expressions#union).\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst MyObj = type({\n\tfoo: \"number | null\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst MyObj = type({\n\tfoo: type.number.or(type.null)\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n## undefined\n\nThe `\"undefined\"` keyword can be used to allow the exact value `undefined`, generally as part of a [union](/docs/expressions#union).\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst MyObj = type({\n\trequiredKey: \"number | undefined\",\n\t\"optionalKey?\": \"number | undefined\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst MyObj = type({\n\trequiredKey: type.number.or(type.undefined),\n\toptionalKey: type.number.or(type.undefined).optional()\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n<Callout type=\"warn\" title=\"Allowing undefined as a value does not make the key optional!\">\n\n    In TypeScript, a required property that allows `undefined` must still be present for the type to be satisfied.\n\n    The same is true in ArkType.\n\n    <details>\n    \t<summary>See an example</summary>\n\n    ```ts\n    const MyObj = type({\n    \tkey: \"number | undefined\"\n    })\n\n    // valid data\n    const validResult = MyObj({ key: undefined })\n\n    // Error: name must be a number or undefined (was missing)\n    const errorResult = MyObj({})\n    ```\n\n    </details>\n\n</Callout>\n"
  },
  {
    "path": "ark/docs/content/docs/primitives/meta.json",
    "content": "{\n\t\"title\": \"Primitives\",\n\t\"defaultOpen\": true,\n\t\"pages\": [\n\t\t\"string\",\n\t\t\"number\",\n\t\t\"[bigint](/docs/primitives#bigint)\",\n\t\t\"[symbol](/docs/primitives#symbol)\",\n\t\t\"[boolean](/docs/primitives#boolean)\",\n\t\t\"[null](/docs/primitives#null)\",\n\t\t\"[undefined](/docs/primitives#undefined)\"\n\t]\n}\n"
  },
  {
    "path": "ark/docs/content/docs/primitives/number/meta.json",
    "content": "{\n\t\"title\": \"number\",\n\t\"pages\": [\n\t\t\"[keywords](/docs/primitives#number-keywords)\",\n\t\t\"[literals](/docs/primitives#number-literals)\",\n\t\t\"[ranges](/docs/primitives#number-ranges)\",\n\t\t\"[divisors](/docs/primitives#number-divisors)\"\n\t]\n}\n"
  },
  {
    "path": "ark/docs/content/docs/primitives/string/meta.json",
    "content": "{\n\t\"title\": \"string\",\n\t\"pages\": [\n\t\t\"[keywords](/docs/primitives#string-keywords)\",\n\t\t\"[literals](/docs/primitives#string-literals)\",\n\t\t\"[patterns](/docs/primitives#string-patterns)\",\n\t\t\"[lengths](/docs/primitives#string-lengths)\"\n\t]\n}\n"
  },
  {
    "path": "ark/docs/content/docs/scopes/index.mdx",
    "content": "---\ntitle: Scopes\n---\n\n<AnchorAliases intro />\n\nScopes are the foundation of ArkType, and one of the most powerful features for users wanting full control over configuration and to make their own keywords available fluidly within string definition syntax.\n\nA scope is just like a scope in code- a resolution space where you can define types, generics, or other scopes. The `type` export is a actually just a method on our default `Scope`!\n\n## Defining a Scope\n\nTo define a scope, you may either `import { scope } from \"arktype\"` or use `type.scope` on the default `type` export.\n\nA scope is specified as an object literal mapping names to definitions.\n\n```ts\nimport { scope } from \"arktype\"\n\nconst coolScope = scope({\n\t// keywords are still available in your scope\n\tId: \"string\",\n\t// but you can also reference your own aliases directly!\n\tUser: { id: \"Id\", friends: \"Id[]\" },\n\t// your aliases will be autocompleted and validated alongside ArkType's keywords\n\tUsersById: {\n\t\t\"[Id]\": \"User | undefined\"\n\t}\n})\n```\n\n`coolScope` is an object with reusable methods like `type` and `generic`. You can use it to create additional `Type`s that can reference your **aliases**- `id`, `user` and `usersById`.\n\n<Callout type=\"warn\" title=\"Don't wrap your scoped definitions in type!\">\n\nEven if you reference it as part of your scope definition, the global 'type' parser only knows about built-in keywords.\n\n```ts\n// @errors: 2322\nconst badScope = scope({\n\tId: \"string\",\n\t// ❌ wrapping this definition in `type` will fail\n\tBadEntity: type({\n\t\tid: \"Id\"\n\t}),\n\t// ✅ reference scoped definitions directly instead of wrapping them\n\tGoodEntity: {\n\t\tid: \"Id\"\n\t}\n})\n```\n\nIf you need access to fluent syntax from within a Scope, see [thunks](/docs/scopes#thunks).\n\n</Callout>\n\n```ts\nconst coolScope = scope({\n\tId: \"string\",\n\tUser: { id: \"Id\", friends: \"Id[]\" },\n\tUsersById: {\n\t\t\"[Id]\": \"User | undefined\"\n\t}\n})\n// ---cut---\n\nconst group = coolScope.type({\n\tname: \"string\",\n\tmembers: \"User[]\"\n})\n\n// chained definitions are parsed in the same scope as the original Type\nconst ownedGroup = group.and({\n\townerId: \"Id\"\n})\n```\n\nTo use the scoped types directly, you must `.export()` your `Scope` to a `Module`. A `Module` is just an object mapping aliases to `Type`s. They can be used for validation or in any other context a `Type` can be used.\n\n```ts\nconst coolScope = scope({\n\tId: \"string\",\n\tUser: { id: \"Id\", friends: \"Id[]\" },\n\tUsersById: {\n\t\t\"[Id]\": \"User | undefined\"\n\t}\n})\n\ninterface RuntimeErrors extends type.errors {\n\t/**friends[1] must be a string (was a number)*/\n\tsummary: string\n}\n\nconst narrowMessage = (e: type.errors): e is RuntimeErrors => true\n// ---cut---\n\nconst coolModule = coolScope.export()\n\nconst out = coolModule.User({\n\tid: \"99\",\n\tfriends: [\"7\", 8, \"9\"]\n})\n\nif (out instanceof type.errors) {\n\t// ---cut-start---\n\tif (!narrowMessage(out)) throw new Error()\n\t// ---cut-end---\n\t// hover summary to see validation errors\n\tconsole.error(out.summary)\n}\n```\n\n`.export()` is also useful in combination with the spread operator for extending your `Scope`s. Recall that a `Type` can be referenced as a definition. This means that spreading a `Module` into the definition you pass to `scope` includes all of that Module's aliases in your new `Scope`.\n\n```ts\nconst coolScope = scope({\n\tId: \"string\",\n\tUser: { id: \"Id\", friends: \"Id[]\" },\n\tUsersById: {\n\t\t\"[Id]\": \"User | undefined\"\n\t}\n})\n// ---cut---\n\nconst threeSixtyNoScope = scope({\n\tthree: \"3\",\n\tsixty: \"60\",\n\tno: \"'no'\"\n})\n\nconst superScope = scope({\n\t...coolScope.export(),\n\t// if you don't want to include the entire scope, you can pass a list of ...aliases\n\t...threeSixtyNoScope.export(\"three\", \"sixty\"),\n\tsaiyan: {\n\t\tpowerLevel: \"number > 9000\"\n\t}\n})\n```\n\nIf you don't plan to reuse your `Scope` to create additional types, it is common to export it inline:\n\n```ts\nconst ezModule = scope({\n\tEz: \"'moochi'\"\n}).export()\n```\n\n`type.module` is available as sugar for this pattern:\n\n```ts\nconst ezModule = type.module({\n\tEz: \"'moochi'\"\n})\n```\n\n### Cyclic Types\n\nScopes make it easy to create recursive `Type`s. Just reference the alias like you would any other:\n\n```ts\nexport const types = scope({\n\tPackage: {\n\t\tname: \"string\",\n\t\t\"dependencies?\": \"Package[]\",\n\t\t\"contributors?\": \"Contributor[]\"\n\t},\n\tContributor: {\n\t\temail: \"string.email\",\n\t\t\"packages?\": \"Package[]\"\n\t}\n}).export()\n```\n\nCyclic types are inferred to arbitrary depth. At runtime, they can safely validate cyclic data.\n\n```ts\nexport const types = scope({\n\tPackage: {\n\t\tname: \"string\",\n\t\t\"dependencies?\": \"Package[]\",\n\t\t\"contributors?\": \"Contributor[]\"\n\t},\n\tContributor: {\n\t\temail: \"string.email\",\n\t\t\"packages?\": \"Package[]\"\n\t}\n}).export()\n// ---cut---\n\nexport type Package = typeof types.Package.infer\n\nconst packageData: Package = {\n\tname: \"arktype\",\n\tdependencies: [{ name: \"typescript\" }],\n\tcontributors: [{ email: \"david@sharktypeio\" }]\n}\n\n// update arktype to depend on itself\npackageData.dependencies![0].dependencies = [packageData]\n\n// ArkErrors: contributors[0].email must be an email address (was \"david@sharktypeio\")\nconst out = types.Package(packageData)\n```\n\n<Callout type=\"warn\" title=\"Some `any`s are not what they seem!\">\n\nBy default, TypeScript represents anonymous cycles as `...`. However, if you have `noErrorTruncation` enabled, they are visually displayed as `any`😬\n\nLuckily, despite its appearance, the type otherwise behaves as you'd expect- TypeScript will provide completions and will complain as normal if you access a non-existent property.\n\n</Callout>\n\n### visibility\n\nIntermediate aliases can be useful for composing Scoped definitions from aliases. Sometimes, you may not want to expose those aliases externally as `Type`s when your `Scope` is `export`ed.\n\nThis can be done using _private_ aliases:\n\n```ts\nconst shapeScope = scope({\n\t// aliases with a \"#\" prefix are treated as private\n\t\"#BaseShapeProps\": {\n\t\tperimeter: \"number\",\n\t\tarea: \"number\"\n\t},\n\tEllipse: {\n\t\t// when referencing a private alias, the \"#\" should not be included\n\t\t\"...\": \"BaseShapeProps\",\n\t\tradii: [\"number\", \"number\"]\n\t},\n\tRectangle: {\n\t\t\"...\": \"BaseShapeProps\",\n\t\twidth: \"number\",\n\t\theight: \"number\"\n\t}\n})\n\n// private aliases can be referenced from any scoped definition,\n// even outside the original scope\nconst PartialShape = shapeScope.type(\"Partial<BaseShapeProps>\")\n\n// when the scope is exported to a Module, they will not be included\n// hover to see the Scope's exports\nconst shapeModule = shapeScope.export()\n```\n\n#### `import()`\n\nPrivate aliases are especially useful for building scopes without polluting them with every alias you might want to reference internally. To facilitate this, Scopes have an `import()` method that behaves identically to `export()` but converts all exported aliases to `private`.\n\n```ts\nconst utilityScope = scope({\n\t\"withId<o extends object>\": {\n\t\t\"...\": \"o\",\n\t\tid: \"string\"\n\t}\n})\n\nconst userModule = type.module({\n\t// because we use `import()` here, we can reference our utilities\n\t// internally, but they will not be included in `userModule`.\n\t// if we used `export()` instead, `withId` could be accessed on `userModule`.\n\t...utilityScope.import(),\n\tPayload: {\n\t\tname: \"string\",\n\t\tage: \"number\"\n\t},\n\tdb: \"withId<Payload>\"\n})\n```\n\n### submodules\n\nIf you've used keywords like `string.email` or `number.integer`, you may wonder if aliases can be grouped in your own Scopes. Recall from [the introduction to Scopes](#intro) that `type` is actually just a method on ArkType's default `Scope`, meaning all of its functionality is available externally, including alias groups called _Submodules_.\n\nSubmodules are groups of aliases with a shared prefix. To define one, just assign the value of the prefix to a `Module` with the names you want:\n\n```ts\nconst subAliases = type.module({ alias: \"number\" })\n\nconst rootScope = scope({\n\ta: \"string\",\n\tb: \"sub.alias\",\n\tsub: subAliases\n})\n\nconst myType = rootScope.type({\n\tsomeKey: \"sub.alias[]\"\n})\n```\n\nSubmodules are parsed bottom-up. This means subaliases can be referenced directly in the root scope,\nbut root aliases can't be referenced from the submodule, even if it's inlined.\n\n#### nested\n\nSubmodules can be nested to arbitrary depth:\n\n```ts\nconst subAliases = type.module({ alias: \"number\" })\n\nconst rootScope = scope({\n\ta: \"string\",\n\tb: \"sub.alias\",\n\tsub: subAliases\n})\n// ---cut---\n\nconst rootScopeSquared = scope({\n\t// reference rootScope from our previous example\n\tnewRoot: rootScope.export()\n})\n\nconst myNewType = rootScopeSquared.type({\n\tsomeOtherKey: \"newRoot.sub.alias | boolean\"\n})\n```\n\n#### rooted\n\nThe Submodules from our previous examples group `Type`s together, but cannot be referenced as `Type`s themselves the way `string` and `number` can. To define a _Rooted Submodule_, just use an alias called `root`:\n\n```ts\nconst userModule = type.module({\n\troot: {\n\t\tname: \"string\"\n\t},\n\t// subaliases can extend a base type by referencing 'root'\n\t// like any other alias\n\tAdmin: {\n\t\t\"...\": \"root\",\n\t\tisAdmin: \"true\"\n\t},\n\tSaiyan: {\n\t\t\"...\": \"root\",\n\t\tpowerLevel: \"number > 9000\"\n\t}\n})\n\nconst types = type.module({\n\tUser: userModule,\n\t// user can now be referenced directly in a definition\n\tGroup: \"User[]\",\n\t// or used as a prefix to access subaliases\n\tElevatedUser: \"User.Admin | User.Saiyan\"\n})\n```\n\n### thunks\n\nWhen users are first learning about Scopes, one of the most common mistakes is to reference an alias in a nested `type` call:\n\n<CodeBlock fromFile=\"nestedTypeInScopeError\" />\n\nThis error occurs because although the `id` alias would be resolvable in the current Scope directly, `type` only allows references to built-in keywords. In this case, the `type` wrapper is redundant and the fix is to simply remove it:\n\n```ts\nconst myScope = scope({\n\tId: \"string#id\",\n\tUser: {\n\t\tname: \"string\",\n\t\t// now resolves correctly\n\t\tid: \"Id\"\n\t}\n})\n```\n\nHowever, even if it is _possible_ to define your scope without invoking `type` by composing aliases and tuple expressions, the fluent methods available on `Type` can define complex types that can be cumbersome to express otherwise. In these situations, you can use a **thunk definition** to access the `type` method on the Scope you're currently defining:\n\n```ts\nconst $ = scope({\n\tId: \"string#id\",\n\texpandUserGroup: () =>\n\t\t$.type({\n\t\t\tname: \"string\",\n\t\t\tid: \"Id\"\n\t\t})\n\t\t\t.or(\"Id\")\n\t\t\t.pipe(user =>\n\t\t\t\ttypeof user === \"string\" ? { id: user, name: \"Anonymous\" } : user\n\t\t\t)\n\t\t\t.array()\n\t\t\t.atLeastLength(2)\n})\n\nconst types = $.export()\n\n// input is validated and transformed to:\n// [{ name: \"Magical Crawdad\", id: \"777\" }, { name: \"Anonymous\", id: \"778\" }]\nconst groups = types.expandUserGroup([\n\t{ name: \"Magical Crawdad\", id: \"777\" },\n\t\"778\"\n])\n```\n\nThough thunk definitions are really only useful when defining a Scope, they can be used anywhere a `Type` definition is expected:\n\n```ts\n// you *can* use them anywhere, but *should* you? (no)\nconst MyInelegantType = type(() =>\n\ttype({ inelegantKey: () => type(\"'inelegant value'\") })\n)\n```\n"
  },
  {
    "path": "ark/docs/content/docs/scopes/meta.json",
    "content": "{\n\t\"title\": \"Scopes\",\n\t\"icon\": \"Advanced\",\n\t\"pages\": [\n\t\t\"[modules](/docs/scopes#modules)\",\n\t\t\"[visibility](/docs/scopes#visibility)\",\n\t\t\"[submodules](/docs/scopes#submodules)\",\n\t\t\"[thunks](/docs/scopes#thunks)\"\n\t]\n}\n"
  },
  {
    "path": "ark/docs/content/docs/traversal-api.mdx",
    "content": "---\ntitle: Traversal API\n---\n\n<ApiTable group=\"Traversal\" />\n\n### assert\n\nValidate data, returning the output on success or throwing a `TraversalError` on failure:\n\n```ts\nconst User = type({ name: \"string\", \"age?\": \"number\" })\n\n// returns { name: \"David\" }\nconst valid = User.assert({ name: \"David\" })\n\n// throws TraversalError: name must be a string (was a number)\nUser.assert({ name: 42 })\n```\n\n### allows\n\nCheck if data satisfies the type's constraints without applying morphs or transformations. Returns a type guard:\n\n```ts\nconst User = type({ name: \"string\" })\n\nconst data: unknown = { name: \"David\" }\n\nif (User.allows(data)) {\n\t// data is narrowed to { name: string }\n\tconsole.log(data.name)\n}\n```\n\nThis is useful when you want a pure type check without triggering any side effects from morphs like `string.numeric.parse`.\n\n### Invoking a Type directly\n\nCalling a Type as a function validates and transforms the input, returning either the output or `ArkErrors`:\n\n```ts\nconst T = type(\"string.numeric.parse\")\n\nconst out = T(\"42\")\n\nif (out instanceof type.errors) {\n\tconsole.log(out.summary)\n} else {\n\t// out is number\n\tconsole.log(out + 1)\n}\n```\n\n### ArkErrors\n\nThe `ArkErrors` array returned on validation failure contains `ArkError` instances with structured data:\n\n```ts\nconst T = type({ n: \"number % 2\", m: \"number >= 2\" })\n\nconst out = T({ n: 1, m: 0 })\n\nif (out instanceof type.errors) {\n\t// discriminate by error code\n\tfor (const error of out) {\n\t\tif (error.hasCode(\"divisor\")) {\n\t\t\tconsole.log(error.rule) // 2\n\t\t}\n\t}\n\n\t// structured access by path\n\tout.flatByPath // { m: [ArkError], n: [ArkError] }\n\tout.flatProblemsByPath // { m: [\"must be at least 2 (was 0)\"], n: [\"must be even (was 1)\"] }\n\n\t// JSON serializable\n\tJSON.stringify(out) // [{ path: [\"m\"], code: \"min\", ... }, { path: [\"n\"], code: \"divisor\", ... }]\n}\n```\n\n### TraversalError\n\nWhen `.assert()` fails, it throws a `TraversalError` (extends `Error`) with:\n\n- A formatted `message` (single errors inline, multiple errors bulleted)\n- A non-enumerable `arkErrors` property for programmatic access\n\n```ts\nimport { type, TraversalError } from \"arktype\"\n\ntry {\n\ttype({ a: \"string\", b: \"number\" }).assert({ a: 1, b: \"x\" })\n} catch (e) {\n\tif (e instanceof TraversalError) {\n\t\tconsole.log(e.message)\n\t\t// • a must be a string (was a number)\n\t\t// • b must be a number (was a string)\n\n\t\t// access the underlying ArkErrors for structured data\n\t\tconsole.log(e.arkErrors.flatProblemsByPath)\n\t}\n}\n```\n"
  },
  {
    "path": "ark/docs/content/docs/type-api/index.mdx",
    "content": "---\ntitle: Type API\n---\n\n<ApiTable group=\"Type\" />\n\nThe methods below are available on every `Type` instance. For validation and traversal methods (`assert`, `allows`, direct invocation), see the [Traversal API](/docs/traversal-api). For composition methods (`pipe`, `to`, `narrow`, `filter`, `and`, `or`), see [Expressions](/docs/expressions). For object-specific methods (`pick`, `omit`, `required`, `partial`, `merge`, `keyof`, `get`, `readonly`, `map`, `props`), see [Objects](/docs/objects).\n\n### from\n\n`from` is a typed-input variant of `assert`. It accepts an input matching `inferIn` and returns `inferOut`, providing type safety on both sides. Like `assert`, it throws a `TraversalError` on invalid input:\n\n```ts\n// @errors: 2345\nconst StringToNumber = type(\"string.numeric.parse\")\n\n// TypeScript knows the input must be a string\nconst result = StringToNumber.from(\"42\") // 42\n\nStringToNumber.from(42)\n```\n\n### in / out\n\nThe `in` and `out` getters extract the input or output Type from a morphed Type, stripping transformations:\n\n```ts\nconst ParsedUser = type({\n\tname: \"string\",\n\tage: \"string.numeric.parse\"\n})\n\n// Type<{ name: string; age: string }>\nconst UserInput = ParsedUser.in\n\n// Type<{ name: string; age: number }>\nconst UserOutput = ParsedUser.out\n```\n\n### extends\n\nCheck if a Type is a subtype of another:\n\n```ts\nconst T = type(\"string\")\n\nT.extends(\"unknown\") // true\nT.extends(\"number\") // false\n\n// ifExtends returns the Type itself if true, undefined otherwise\nconst result = T.ifExtends(\"string | number\") // Type<string | number> | undefined\n```\n\n### equals\n\nCheck if two Types are structurally identical:\n\n```ts\nconst A = type({ name: \"string\" })\nconst B = type({ name: \"string\" })\nconst C = type({ name: \"number\" })\n\nA.equals(B) // true\nA.equals(C) // false\n\n// ifEquals returns the Type if equal, undefined otherwise\nconst result = A.ifEquals(B) // Type<{ name: string }> | undefined\n```\n\n### overlaps\n\nCheck if any value could satisfy both Types:\n\n```ts\nconst A = type(\"string | number\")\nconst B = type(\"number | boolean\")\nconst C = type(\"string\")\n\nA.overlaps(B) // true (number satisfies both)\nC.overlaps(type(\"number\")) // false\n```\n\n### extract / exclude\n\nExtract or exclude union branches based on a Type:\n\n```ts\nconst T = type(\"string | number | boolean\")\n\n// Type<string | boolean>\nconst Extracted = T.extract(\"string | boolean\")\n\n// Type<number>\nconst Excluded = T.exclude(\"string | boolean\")\n```\n\n### distribute\n\nMap and optionally reduce over union branches:\n\n```ts\nconst T = type(\"string | number | bigint\")\n\n// [\"bigint\", \"number\", \"string\"]\nconst expressions = T.distribute(branch => branch.expression)\n\n// with a reducer\nconst count = T.distribute(\n\tbranch => branch,\n\tbranches => branches.length\n) // 3\n```\n\n### toJsonSchema\n\nEach `Type` instance exposes a `toJsonSchema()` method that can be used to generate a corresponding JSON Schema.\n\n```ts\nconst User = type({\n\tname: \"string\",\n\temail: \"string.email\",\n\t\"age?\": \"number >= 18\"\n})\n\nconst schema = User.toJsonSchema()\n\nconst result = {\n\t$schema: \"https://json-schema.org/draft/2020-12/schema\",\n\ttype: \"object\",\n\tproperties: {\n\t\tname: { type: \"string\" },\n\t\temail: {\n\t\t\ttype: \"string\",\n\t\t\tformat: \"email\",\n\t\t\tpattern: \"^[\\w%+.-]+@[\\d.A-Za-z-]+\\.[A-Za-z]{2,}$\"\n\t\t},\n\t\tage: { type: \"number\", minimum: 18 }\n\t},\n\trequired: [\"email\", \"name\"]\n}\n```\n\nOptions can be passed to change the behavior including how incompatibilities are handled. See [the associated config docs](/docs/configuration#tojsonschema) for more details.\n"
  },
  {
    "path": "ark/docs/content/docs/type-api/meta.json",
    "content": "{\n\t\"title\": \"Type API\",\n\t\"pages\": [\n\t\t\"[from](/docs/type-api#from)\",\n\t\t\"[in / out](/docs/type-api#in--out)\",\n\t\t\"[extends](/docs/type-api#extends)\",\n\t\t\"[equals](/docs/type-api#equals)\",\n\t\t\"[overlaps](/docs/type-api#overlaps)\",\n\t\t\"[extract / exclude](/docs/type-api#extract--exclude)\",\n\t\t\"[distribute](/docs/type-api#distribute)\",\n\t\t\"[toJsonSchema](/docs/type-api#tojsonschema)\"\n\t]\n}\n"
  },
  {
    "path": "ark/docs/lib/ambient.d.ts",
    "content": "declare module \"*.css\" {}\n\ndeclare module \"*?raw\" {\n\tconst _: string\n\texport default _\n}\n"
  },
  {
    "path": "ark/docs/lib/metadata.ts",
    "content": "import { createMetadataImage } from \"fumadocs-core/server\"\nimport { source } from \"./source.tsx\"\n\nexport const metadataImage = createMetadataImage({\n\timageRoute: \"/docs-og\",\n\tsource\n})\n"
  },
  {
    "path": "ark/docs/lib/shiki.ts",
    "content": "import { transformerNotationErrorLevel } from \"@shikijs/transformers\"\nimport type { RehypeCodeOptions } from \"fumadocs-core/mdx-plugins\"\nimport { transformerTwoslash } from \"fumadocs-twoslash\"\nimport { createRequire } from \"node:module\"\nimport type { ShikiTransformer } from \"shiki\"\n\n/** for some reason a standard import with an attribute like:\n \n\timport arkDarkTheme from \"arkdark/arkdark.json\" with { type: \"json\" }\n    \nresults in an error like:\n\n\tModule \"file:///home/ssalb/arktype/ark/dark/arkdark.json\" needs an import attribute of \"type: json\"\n\ndespite it having the attribute. Using require as a workaround- convert to an import\nlike the one above if possible in the future without breaking the build.*/\n\nconst require = createRequire(import.meta.url)\n\nconst arkDarkTheme = require(\"arkthemes/arkdark.json\")\nconst arkTypePackageJson = require(\"arkdark/package.json\")\nconst arkTypeTmJson = require(\"arkdark/tsWithArkType.tmLanguage.json\")\n\n// Theme adjustments\n/** should match the css rule for .bg-fd-secondary\\/50 */\narkDarkTheme.colors[\"editor.background\"] = \"#060c18\"\n\narkDarkTheme.tokenColors.push({\n\t// this is covered by editorBracketHighlight.foreground1 etc. in VSCode,\n\t// but it's not available in Shiki so add a replacement\n\tscope: [\"meta.brace\"],\n\tsettings: {\n\t\tforeground: \"#f5cf8f\"\n\t}\n})\n\nconst twoslashPropertyPrefix = \"(property) \"\nconst twoslash = transformerTwoslash({\n\texplicitTrigger: false,\n\tlangs: [\"ts\", \"js\"],\n\ttwoslashOptions: {\n\t\tcompilerOptions: {\n\t\t\t// avoid ... in certain longer types on hover\n\t\t\tnoErrorTruncation: true\n\t\t},\n\t\textraFiles: {\n\t\t\t\"global.d.ts\": `import type * as a from \"arktype\"\nimport type * as r from \"arkregex\"\n\ndeclare global {\n\tconst regex: typeof r.regex\n\tconst type: typeof a.type\n\tnamespace type {\n\t\texport type cast<t> = {\n\t\t\t[a.inferred]?: t\n\t\t}\n\n\t\texport type errors = a.ArkErrors\n\n\t\texport type validate<def, $ = {}, args = a.bindThis<def>> = a.validateDefinition<\n\t\t\tdef,\n\t\t\t$,\n\t\t\targs\n\t\t>\n\t\n\t\texport type instantiate<def, $ = {}, args = a.bindThis<def>> = type<\n\t\t\ta.inferDefinition<def, $, args>,\n\t\t\t$\n\t\t>\n\t\n\t\texport type infer<def, $ = {}, args = a.bindThis<def>> = a.inferDefinition<\n\t\t\tdef,\n\t\t\t$,\n\t\t\targs\n\t\t>\n\n\t\t/** @ts-ignore cast variance */\n\t\texport interface Any<out t = any, $ = any> extends a.BaseType<t, $> {}\n\t}\n\n\ttype type<t = unknown, $ = {}> = a.Type<t, $>\n\tconst scope: typeof a.scope\n\tconst match: typeof a.match\n}`\n\t\t},\n\t\tfilterNode: node => {\n\t\t\tswitch (node.type) {\n\t\t\t\tcase \"hover\":\n\t\t\t\t\tif (node.text.endsWith(\", {}>\"))\n\t\t\t\t\t\t// omit default scope param from type display\n\t\t\t\t\t\tnode.text = node.text.slice(0, -5) + \">\"\n\t\t\t\t\tif (node.text.startsWith(\"type\")) return true\n\n\t\t\t\t\t// when `noErrorTruncation` is enabled, TS displays the type\n\t\t\t\t\t// of an anonymous cyclic type as `any` instead of using\n\t\t\t\t\t// `...`, so replace it to clarify the type is accurately inferred\n\t\t\t\t\tnode.text = node.text.replace(/ any/g, \" ...\")\n\t\t\t\t\tif (node.text.startsWith(\"const\")) {\n\t\t\t\t\t\t// show type with completions populated for known examples\n\t\t\t\t\t\tnode.text = node.text.replace(\n\t\t\t\t\t\t\t\"version?: undefined\",\n\t\t\t\t\t\t\t`version?: number | string`\n\t\t\t\t\t\t)\n\t\t\t\t\t\tnode.text = node.text.replace(\n\t\t\t\t\t\t\t\"versions?: undefined\",\n\t\t\t\t\t\t\t\"versions?: (number | string)[]\"\n\t\t\t\t\t\t)\n\t\t\t\t\t\t// filter out the type of Type's invocation\n\t\t\t\t\t\t// as opposed to the Type itself\n\t\t\t\t\t\treturn !node.text.includes(\"(data: unknown)\")\n\t\t\t\t\t}\n\t\t\t\t\tif (node.text.startsWith(twoslashPropertyPrefix)) {\n\t\t\t\t\t\tconst expression = node.text.slice(twoslashPropertyPrefix.length)\n\t\t\t\t\t\tif (expression.startsWith(\"RuntimeErrors.summary\") && node.docs) {\n\t\t\t\t\t\t\t// this shows error summary in JSDoc\n\t\t\t\t\t\t\t// re-add spaces stripped out during processing\n\t\t\t\t\t\t\tnode.docs = node.docs.replace(/•/g, \"    •\")\n\t\t\t\t\t\t\treturn true\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (expression === `platform: \"android\" | \"ios\"`) {\n\t\t\t\t\t\t\t// this helps demonstrate narrowing on discrimination\n\t\t\t\t\t\t\treturn true\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t\treturn false\n\t\t\t\tcase \"error\":\n\t\t\t\t\t// adapted from my ErrorLens implementation at\n\t\t\t\t\t// https://github.com/usernamehw/vscode-error-lens/blob/d1786ddeedee23d70f5f75b16415a6579b554b59/src/utils/extUtils.ts#L127\n\t\t\t\t\tfor (const transformation of arkTypePackageJson.contributes\n\t\t\t\t\t\t.configurationDefaults[\"errorLens.replace\"]) {\n\t\t\t\t\t\tconst regex = new RegExp(transformation.matcher)\n\t\t\t\t\t\tconst matchResult = regex.exec(node.text)\n\t\t\t\t\t\tif (matchResult) {\n\t\t\t\t\t\t\tnode.text = transformation.message\n\t\t\t\t\t\t\t// Replace groups like $0 and $1 with groups from the match\n\t\t\t\t\t\t\tfor (\n\t\t\t\t\t\t\t\tlet groupIndex = 0;\n\t\t\t\t\t\t\t\tgroupIndex < matchResult.length;\n\t\t\t\t\t\t\t\tgroupIndex++\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnode.text = node.text.replace(\n\t\t\t\t\t\t\t\t\tnew RegExp(`\\\\$${groupIndex}`, \"gu\"),\n\t\t\t\t\t\t\t\t\tmatchResult[Number(groupIndex)]\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tnode.text = `TypeScript: ${node.text}`\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn true\n\t\t\t\tdefault:\n\t\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n})\n\ntype HastElement = Parameters<ShikiTransformer[\"line\"] & {}>[0]\nconst descendantIncludesText = (\n\tnode: HastElement,\n\t...texts: string[]\n): boolean =>\n\tnode.children &&\n\tnode.children.some(\n\t\tc =>\n\t\t\t(c.type === \"text\" && texts.some(s => c.value.includes(s))) ||\n\t\t\tdescendantIncludesText(c as never, ...texts)\n\t)\n\nexport const shikiConfig = {\n\texperimentalJSEngine: true,\n\tthemes: {\n\t\tdark: arkDarkTheme,\n\t\tlight: arkDarkTheme\n\t},\n\tlangs: [\"json\", \"bash\", { ...arkTypeTmJson, name: \"ts\" }],\n\ttransformers: [\n\t\t{\n\t\t\tline(node) {\n\t\t\t\tif (descendantIncludesText(node, \"// ArkErrors:\", \"// ParseError:\")) {\n\t\t\t\t\tthis.addClassToHast(node, \"highlighted\")\n\t\t\t\t\tthis.addClassToHast(node, \"error\")\n\t\t\t\t\tthis.addClassToHast(node, \"runtime-error\")\n\t\t\t\t} else if (descendantIncludesText(node, \"// TypeScript:\")) {\n\t\t\t\t\tthis.addClassToHast(node, \"highlighted\")\n\t\t\t\t\tthis.addClassToHast(node, \"error\")\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\ttwoslash,\n\t\ttransformerNotationErrorLevel({ matchAlgorithm: \"v3\" })\n\t]\n} as const satisfies RehypeCodeOptions\n\nexport type shikiConfig = typeof shikiConfig\n\nexport type BuiltinLang = {\n\t[i in keyof shikiConfig[\"langs\"]]: extractName<shikiConfig[\"langs\"][i]>\n}[number]\n\ntype extractName<lang> = lang extends { name: infer name } ? name : lang\n"
  },
  {
    "path": "ark/docs/lib/source.tsx",
    "content": "import type { autocomplete } from \"@ark/util\"\nimport { loader } from \"fumadocs-core/source\"\nimport { icons } from \"lucide-react\"\nimport { createElement } from \"react\"\n// eslint-disable-next-line @typescript-eslint/no-restricted-imports\nimport { docs } from \"../.source/index.ts\"\nimport { Badge } from \"../components/Badge.tsx\"\n\nexport type IconName = keyof typeof icons | \"Advanced\" | \"New\"\n\nexport const source = loader({\n\tbaseUrl: \"/docs\",\n\tsource: docs.toFumadocsSource(),\n\ticon: (name?: autocomplete<IconName>) => {\n\t\tif (!name) return\n\t\tif (name in icons) return createElement(icons[name as never])\n\n\t\tif (name === \"Advanced\") {\n\t\t\treturn (\n\t\t\t\t<Badge\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\theight: \"1rem\",\n\t\t\t\t\t\tfontSize: 10,\n\t\t\t\t\t\tpadding: \"0 0.2rem\",\n\t\t\t\t\t\torder: 1\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\tadvanced\n\t\t\t\t</Badge>\n\t\t\t)\n\t\t}\n\t\tif (name === \"New\") {\n\t\t\treturn (\n\t\t\t\t<Badge\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\theight: \"1rem\",\n\t\t\t\t\t\tfontSize: 10,\n\t\t\t\t\t\tpadding: \"0 0.2rem\",\n\t\t\t\t\t\torder: 1\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\tnew\n\t\t\t\t</Badge>\n\t\t\t)\n\t\t}\n\n\t\tthrow new Error(`${name} is not a valid icon`)\n\t}\n})\n"
  },
  {
    "path": "ark/docs/lib/writeLlmsTxt.ts",
    "content": "import { readFile, walkPaths, writeFile } from \"@ark/fs\"\nimport { join } from \"node:path\"\nimport { repoDirs } from \"../../repo/shared.ts\"\n\nexport const writeLlmsTxt = () => {\n\tconst contentDir = join(repoDirs.docs, \"content\", \"docs\")\n\tconst paths = walkPaths(contentDir, {\n\t\texcludeDirs: true,\n\t\tinclude: path => path.endsWith(\".mdx\")\n\t})\n\n\tconst contents = paths.map(readFile).join(\"\\n\\n\")\n\n\twriteFile(join(repoDirs.docs, \"public\", \"llms.txt\"), contents)\n}\n"
  },
  {
    "path": "ark/docs/lib/writeSnippetsEntrypoint.ts",
    "content": "import { fromHere, readFile, writeFile } from \"@ark/fs\"\nimport { flatMorph, throwInternalError } from \"@ark/util\"\nimport { existsSync } from \"node:fs\"\n\n/**\n * Previously, we used raw-loader imports like:\n *\n * import unparalleledDx from \"./snippets/unparalleledDx.twoslash.js?raw\"\n *\n * so that we could write longer code blocks for use in .tsx\n * without losing syntax highlighting, type checking etc.\n * However, I was unable to get this working with Next's --turbo\n * flag, which seems very impactful in terms of performance.\n *\n * As a workaround, when this config is loaded, we regenerate\n * the contents.ts file and just import that directly. It is\n * then committed to git as normal.\n */\nexport const updateSnippetsEntrypoint = () => {\n\tconst snippetContentsById = flatMorph(snippetIds, (i, id) => {\n\t\tconst tsPath = snippetPath(`${id}.twoslash.ts`)\n\t\tconst jsPath = snippetPath(`${id}.twoslash.js`)\n\n\t\tconst path =\n\t\t\texistsSync(tsPath) ? tsPath\n\t\t\t: existsSync(jsPath) ? jsPath\n\t\t\t: throwInternalError(\n\t\t\t\t\t`Expected a snippet file at ${tsPath} or ${jsPath} (neither existed).`\n\t\t\t\t)\n\t\t// don't include trailing newline\n\t\treturn [id, readFile(path).trimEnd()]\n\t})\n\n\tconst toPath = snippetPath(\"contentsById.ts\")\n\n\tconst contents = `// prettier-ignore\\nexport default ${JSON.stringify(snippetContentsById, null, 4)}\\n`\n\n\tif (!existsSync(toPath) || readFile(toPath) !== contents)\n\t\twriteFile(toPath, contents)\n}\n\nconst snippetIds = [\n\t\"betterErrors\",\n\t\"clarityAndConcision\",\n\t\"deepIntrospectability\",\n\t\"intrinsicOptimization\",\n\t\"unparalleledDx\",\n\t\"nestedTypeInScopeError\"\n] as const\n\nexport type SnippetId = (typeof snippetIds)[number]\n\nconst snippetPath = (fileName: string) =>\n\tfromHere(\"..\", \"components\", \"snippets\", fileName)\n"
  },
  {
    "path": "ark/docs/next-env.d.ts",
    "content": "/// <reference types=\"next\" />\n/// <reference types=\"next/image-types/global\" />\n\n// NOTE: This file should not be edited\n// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.\n"
  },
  {
    "path": "ark/docs/next.config.ts",
    "content": "import { createMDX } from \"fumadocs-mdx/next\"\nimport type { NextConfig } from \"next\"\nimport { mkdtempSync } from \"node:fs\"\nimport { tmpdir } from \"node:os\"\nimport { join } from \"node:path\"\nimport { writeLlmsTxt } from \"./lib/writeLlmsTxt.ts\"\nimport { updateSnippetsEntrypoint } from \"./lib/writeSnippetsEntrypoint.ts\"\n\n// workaround for a bug in Node 25 that creates localStorage as an empty proxy,\n// leading to @typescript/vfs eventually throwing when it sees that it is not\n// undefined and tries to call `getItem`:\n\n// https://github.com/nodejs/node/issues/60303\n\n// this can be removed once the bug is addressed in Node\nif (!globalThis.localStorage?.getItem)\n\tglobalThis.localStorage = undefined as never\n\n// also set the --localstorage-file env var so subprocesses don't run into the same issue\nprocess.env.NODE_OPTIONS ??= \"\"\nconst tmpDir = mkdtempSync(join(tmpdir(), \"ark-localstorage-\"))\nprocess.env.NODE_OPTIONS = `${process.env.NODE_OPTIONS} --localstorage-file=${join(tmpDir, \"localstorage\")}`\n\nupdateSnippetsEntrypoint()\nwriteLlmsTxt()\n\nconst config = {\n\treactStrictMode: true,\n\tcleanDistDir: true,\n\tserverExternalPackages: [\"twoslash\", \"typescript\", \"ts-morph\"],\n\t// the following properties are required by nextjs-github-pages:\n\t// https://github.com/gregrickaby/nextjs-github-pages\n\toutput: \"export\",\n\timages: {\n\t\tunoptimized: true\n\t}\n} as const satisfies NextConfig\n\nconst mdxConfig = createMDX()(config)\n\nexport default mdxConfig\n"
  },
  {
    "path": "ark/docs/package.json",
    "content": "{\n\t\"name\": \"@ark/docs\",\n\t\"version\": \"0.0.1\",\n\t\"private\": true,\n\t\"type\": \"module\",\n\t\"scripts\": {\n\t\t\"build\": \"next build\",\n\t\t\"dev\": \"next dev --turbo\",\n\t\t\"buildAndStart\": \"pnpm build && pnpm start\",\n\t\t\"start\": \"pnpm serve out\",\n\t\t\"clean\": \"rm -rf .next .source out\",\n\t\t\"upDeps\": \"pnpm up --latest\",\n\t\t\"checkLinks\": \"linkinator https://arktype.io -r\"\n\t},\n\t\"dependencies\": {\n\t\t\"@ark/fs\": \"workspace:*\",\n\t\t\"@ark/repo\": \"workspace:*\",\n\t\t\"@ark/schema\": \"workspace:*\",\n\t\t\"@ark/util\": \"workspace:*\",\n\t\t\"@fumadocs/mdx-remote\": \"1.3.0\",\n\t\t\"@icons-pack/react-simple-icons\": \"12.7.0\",\n\t\t\"@monaco-editor/react\": \"4.7.0\",\n\t\t\"@oramacloud/client\": \"2.1.4\",\n\t\t\"@shikijs/transformers\": \"3.3.0\",\n\t\t\"arkdark\": \"workspace:*\",\n\t\t\"arkregex\": \"workspace:*\",\n\t\t\"arkthemes\": \"workspace:*\",\n\t\t\"arktype\": \"workspace:*\",\n\t\t\"class-variance-authority\": \"0.7.1\",\n\t\t\"fumadocs-core\": \"15.2.3\",\n\t\t\"fumadocs-mdx\": \"11.5.7\",\n\t\t\"fumadocs-twoslash\": \"3.1.0\",\n\t\t\"fumadocs-ui\": \"15.2.3\",\n\t\t\"hast-util-to-jsx-runtime\": \"2.3.6\",\n\t\t\"linkinator\": \"6.1.2\",\n\t\t\"lucide-react\": \"0.503.0\",\n\t\t\"monaco-editor\": \"0.52.2\",\n\t\t\"monaco-editor-textmate\": \"4.0.0\",\n\t\t\"monaco-textmate\": \"3.0.1\",\n\t\t\"next\": \"15.3.1\",\n\t\t\"onigasm\": \"2.2.5\",\n\t\t\"postcss\": \"8.5.3\",\n\t\t\"posthog-js\": \"1.237.0\",\n\t\t\"prettier\": \"3.5.3\",\n\t\t\"react\": \"19.1.0\",\n\t\t\"react-dom\": \"19.1.0\",\n\t\t\"serve\": \"14.2.4\",\n\t\t\"shiki\": \"3.3.0\",\n\t\t\"tailwind-merge\": \"3.2.0\",\n\t\t\"ts-morph\": \"25.0.1\",\n\t\t\"twoslash\": \"0.3.1\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@fumadocs/cli\": \"0.1.1\",\n\t\t\"@tailwindcss/postcss\": \"4.1.4\",\n\t\t\"@types/mdx\": \"2.0.13\",\n\t\t\"@types/react\": \"19.1.2\",\n\t\t\"@types/react-dom\": \"19.1.2\",\n\t\t\"prettier-plugin-tailwindcss\": \"0.6.11\",\n\t\t\"tailwindcss\": \"4.1.4\",\n\t\t\"typescript\": \"catalog:\"\n\t}\n}\n"
  },
  {
    "path": "ark/docs/postcss.config.cjs",
    "content": "module.exports = {\n\tplugins: {\n\t\t\"@tailwindcss/postcss\": {}\n\t}\n}\n"
  },
  {
    "path": "ark/docs/public/CNAME",
    "content": "arktype.io"
  },
  {
    "path": "ark/docs/public/llms.txt",
    "content": "---\ntitle: Announcing ArkType 2.0\ndescription: 100x faster validation with DX that will blow your mind\n---\n\nAs of today, `arktype@2.0.0` is generally available and fully stable.\n\nArkType 2.0 brings types to runtime JS in a way that, until today, has been a pipedream.\n\nWhether you're a first-time TypeScript dev trying to validate a form or a library author introspecting relationships, ArkType offers fundamentally better tools for navigating the perils of JavaScript.\n\n<MainAutoplayDemo />\n\n### Unparalleled DX\n\nType syntax you already know with safety and completions unlike anything\nyou&apos;ve ever seen\n\n<CodeBlock fromFile=\"unparalleledDx\" includesCompletions />\n\n### Faster... everything\n\n100x faster than Zod at runtime with editor performance that will remind you\nhow autocomplete is supposed to feel\n\n<RuntimeBenchmarksGraph className=\"mt-2\" />\n\n### Clarity and Concision\n\nDefinitions are half as long, type errors are twice as readable, and hovers\ntell you just what really matters\n\n<CodeBlock fromFile=\"clarityAndConcision\" />\n\n### Better Errors\n\nDeeply customizable messages with great defaults\n\n<CodeBlock fromFile=\"betterErrors\" />\n\n### Deep Introspectability\n\nArkType uses set theory to understand and expose the relationships between\nyour types at runtime the way TypeScript does at compile time\n\n<CodeBlock fromFile=\"deepIntrospectability\" />\n\n### Intrinsic Optimization\n\nEvery schema is internally normalized and reduced to its purest and fastest\nrepresentation\n\n<CodeBlock fromFile=\"intrinsicOptimization\" />\n\n### What next?\n\nArkType doesn't require a special environment or build step to work- [our intro](/docs/intro/setup) will have you up and running in seconds.\n\nWe have [big plans](https://github.com/orgs/arktypeio/projects/4) to ArkType 2.0 even further, but we're even more excited to see what you do with it!\n\n⚡ [Starting coding](/docs/intro/setup)\n\n⭐ [Check out the project on GitHub](https://github.com/arktypeio/arktype)\n\n👋 [Join our Discord to lurk or ask questions](https://arktype.io/discord)\n\n- Follow any of these accounts for updates:\n  - [@arktype.io](https://bsky.app/profile/arktype.io), [@ssalbdivad.dev](https://bsky.app/profile/ssalbdivad.dev) on BlueSky\n  - [@arktypeio](https://x.com/arktypeio), [@ssalbdivad](https://x.com/arktypeio) on X/Twitter\n\n- Consider supporting my full-time work on ArkType...\n  - via [GitHub Sponsors](https://github.com/sponsors/arktypeio)\n  - by convincing your team to let me optimize your types and fix editor lag (reach out directly to one of the accounts listed or `david@arktype.io`)\n\n\n---\ntitle: Announcing ArkType 2.1\ndescription: Optimized pattern matching from type syntax\n---\n\nAs of today, 2.1.0 is generally available 🎉\n\nThe biggest feature is `match`, a pattern matching API that allows you to define cases using expressive type syntax. The result is a highly optimized matcher that uses set theory to automatically skip unmatched branches.\n\nWe could not be more excited to share this not just as the first syntactic matcher in JS, but as the first ArkType feature to showcase the potential of runtime types to do more than just validation.\n\nLanguages with introspectable types offer incredibly powerful features that have always felt out of reach in JS- until now.\n\n```ts\n// @noErrors\nconst toJsonArkType = match({\n\t\"string | number | boolean | null\": v => v,\n\tbigint: b => `${b}n`,\n\tobject: o => {\n\t\tfor (const k in o) {\n\t\t\to[k] = toJsonArkType(o[k])\n\t\t}\n\t\treturn o\n\t},\n\tdefault: \"assert\"\n})\n\nconst toJsonTsPattern = (value: unknown) =>\n\ttsPatternMatch(value)\n\t\t.with(P.union(P.string, P.number, P.boolean, null), v => v)\n\t\t.with(P.bigint, v => `${v}n`)\n\t\t.with({}, o => {\n\t\t\tfor (const k in o) {\n\t\t\t\to[k] = toJsonTsPattern(o[k])\n\t\t\t}\n\t\t\treturn o\n\t\t})\n\t\t.otherwise(() => {\n\t\t\tthrow new Error(\"value is not valid JSON\")\n\t\t})\n\n// \"foo\" (9 nanoseconds)\ntoJsonArkType(\"foo\")\n// \"foo\" (765 nanoseconds)\ntoJsonTsPattern(\"foo\")\n\n// \"5n\" (33 nanoseconds)\ntoJsonArkType(5n)\n// \"5n\" (924 nanoseconds)\ntoJsonTsPattern(5n)\n\n// { nestedValue: \"5n\" } (44 nanoseconds)\ntoJsonArkType({ nestedValue: 5n })\n// { nestedValue: \"5n\" } (2080 nanoseconds)\ntoJsonTsPattern({ nestedValue: 5n })\n```\n\nWe're actually huge fans of [Gabriel Vergnaud](https://github.com/gvergnaud) and [ts-pattern](https://github.com/gvergnaud/ts-pattern), which has a great API and totally reasonable performance. We've referenced it for comparison to showcase the unique expressiveness and optimization runtime types unlock.\n\nBelow are the full notes for the 2.1.0 release. We can't wait to hear what you think! 🚀\n\n### `match`\n\nThe `match` function provides a powerful way to handle different types of input and return corresponding outputs based on the input type, like a type-safe `switch` statement.\n\n#### Case Record API\n\nThe simplest way to define a matcher is with ArkType definition strings as keys with corresponding handlers as values:\n\n```ts\nimport { match } from \"arktype\"\n\nconst sizeOf = match({\n\t\"string | Array\": v => v.length,\n\tnumber: v => v,\n\tbigint: v => v,\n\tdefault: \"assert\"\n})\n\n// a match definition is complete once a `default` has been specified,\n// either as a case or via the .default() method\n\nsizeOf(\"abc\") // 3\nsizeOf([1, 2, 3, 4]) // 4\nsizeOf(5n) // 5n\n// ArkErrors: must be an object, a string, a number or a bigint (was boolean)\nsizeOf(true)\n```\n\nIn this example, `sizeOf` is a matcher that takes a string, array, number, or bigint as input. It returns the length of strings and arrays, and the value of numbers and bigints.\n\n`default` accepts one of 4 values:\n\n- `\"assert\"`: accept `unknown`, throw if none of the cases match\n- `\"never\"`: accept an input based on inferred cases, throw if none match\n- `\"reject\"`: accept `unknown`, return `ArkErrors` if none of the cases match\n- `(data: In) => unknown`: handle data not matching other cases directly\n\nCases will be checked in the order they are specified, either as object literal keys or via chained methods.\n\n#### Fluent API\n\nThe `match` function also provides a fluent API. This can be convenient for non-string-embeddable definitions:\n\n```ts\n// the Case Record and Fluent APIs can be easily combined\nconst sizeOf = match({\n\tstring: v => v.length,\n\tnumber: v => v,\n\tbigint: v => v\n})\n\t// match any object with a numeric length property and extract it\n\t.case({ length: \"number\" }, o => o.length)\n\t// return 0 for all other data\n\t.default(() => 0)\n\nsizeOf(\"abc\") // 3\nsizeOf({ name: \"David\", length: 5 }) // 5\nsizeOf(null) // 0\n```\n\n#### Narrowing input with `in`, property matching with `at`\n\n```ts\n// @errors: 2345\ntype Data =\n\t| {\n\t\t\tid: 1\n\t\t\toneValue: number\n\t  }\n\t| {\n\t\t\tid: 2\n\t\t\ttwoValue: string\n\t  }\n\nconst discriminateValue = match\n\t// .in allows you to specify the input TypeScript allows for your matcher\n\t.in<Data>()\n\t// .at allows you to specify a key at which your input will be matched\n\t.at(\"id\")\n\t.match({\n\t\t1: o => `${o.oneValue}!`,\n\t\t2: o => o.twoValue.length,\n\t\tdefault: \"assert\"\n\t})\n\ndiscriminateValue({ id: 1, oneValue: 1 }) // \"1!\"\ndiscriminateValue({ id: 2, twoValue: \"two\" }) // 3\ndiscriminateValue({ oneValue: 3 })\n```\n\nSpecial thanks to [@thetayloredman](https://github.com/thetayloredman) who did a mind-blowingly good job helping us iterate toward the current type-level pattern-matching implementation🙇\n\n### Built-in keywords can now be globally configured\n\nThis can be very helpful for customizing error messages without needing to create your own aliases or wrappers.\n\n```ts title=\"config.ts\"\nimport { configure } from \"arktype/config\"\n\nconfigure({\n\tkeywords: {\n\t\tstring: \"shorthand description\",\n\t\t\"string.email\": {\n\t\t\tactual: () => \"definitely fake\"\n\t\t}\n\t}\n})\n```\n\n```ts title=\"app.ts\"\nimport \"./config.ts\"\nimport { type } from \"arktype\"\n\nconst User = type({\n\tname: \"string\",\n\temail: \"string.email\"\n})\n\nconst out = User({\n\t// ArkErrors: name must be shorthand description (was a number)\n\tname: 5,\n\t// ArkErrors: email must be an email address (was definitely fake)\n\temail: \"449 Canal St\"\n})\n```\n\nThe options you can provide here are identical to those used to [configure a Type directly](https://arktype.io/docs/expressions#meta), and can also be [extended at a type-level to include custom metadata](https://arktype.io/docs/configuration#metadata).\n\n### Tuple and args expressions for `.to`\n\nIf a morph returns an `ArkErrors` instance, validation will fail with that result instead of it being treated as a value. This is especially useful for using other Types as morphs to validate output or chain transformations.\n\nTo make this easier, there's a special `to` operator that can pipe to a parsed definition without having to wrap it in `type` to make it a function.\n\nThis was added before 2.0, but now it comes with a corresponding operator (`|>`) so that it can be expressed via a tuple or args like most other expressions:\n\n```ts\nconst FluentStillWorks = type(\"string.numeric.parse\").to(\"number % 2\")\n\nconst NowSoDoesTuple = type({\n\tsomeKey: [\"string.numeric.parse\", \"|>\", \"number % 2\"]\n})\n\nconst AndSpreadArgs = type(\"string.numeric.parse\", \"|>\", \"number % 2\")\n```\n\n### Error configurations now accept a string directly\n\n```ts\nconst CustomOne = type(\"1\", \"@\", {\n\t// previously only a function returning a string was allowed here\n\tmessage: \"Yikes.\"\n})\n\n// ArkErrors: Yikes.\nCustomOne(2)\n```\n\nKeep in mind, [as mentioned in the docs](https://arktype.io/docs/configuration#errors), error configs like `message` can clobber more granular config options like `expected` and `actual` and cannot be included in composite errors e.g. for a union.\n\nThough generally, returning a string based on context is the best option, in situations where you always want the same static message, it's now easier to get that!\n\n### Type.toString() now wraps its syntactic representation in `Type<..>`\n\nPreviously, `Type.toString()` just returned `Type.expression`. However, in contexts where the source of a message isn't always a `Type`, it could be confusing:\n\n```ts\n// < 2.1.0:  \"(was string)\"\n// >= 2.1.0: \"(was Type<string>)\"\nconsole.log(`(was ${type.string})`)\n```\n\nHopefully if you interpolate a Type, you'll be less confused by the result from now on!\n\n### Improve how Type instances are inferred when wrapped in external generics\n\nPreviously, we used `NoInfer` in some Type method returns. After migrating those to inlined conditionals, we get the same benefit and external inference for cases like this is more reliable:\n\n```ts\n// @noErrors\nfunction fn<\n\tT extends {\n\t\tschema: StandardSchemaV1\n\t}\n>(_: T) {\n\treturn {} as StandardSchemaV1.InferOutput<T[\"schema\"]>\n}\n\n// was inferred as unknown (now correctly { name: string })\nconst arkRes = fn({\n\tschema: type({\n\t\tname: \"string\"\n\t})\n})\n```\n\n### Fix an issue causing some discriminated unions to incorrectly reject default cases\n\n```ts\nconst Discriminated = type({\n\tid: \"0\",\n\tk1: \"number\"\n})\n\t.or({ id: \"1\", k1: \"number\" })\n\t.or({\n\t\tname: \"string\"\n\t})\n\n// previously, this was rejected as requiring a \"k1\" key\n// will now hit the case discriminated for id: 1,\n// but still correctly be allowed via the { name: string } branch\nDiscriminated({ name: \"foo\", id: 1 })\n```\n\n\n---\ntitle: Announcing ArkType 2.2\ndescription: Type-safe regex, validated functions, and native Standard Schema definitions\n---\n\nAs of today, 2.2.0 is generally available 🎉\n\n2.2 brings `type.fn` for runtime-validated functions, type-safe regex via `arkregex`, bidirectional JSON Schema with the new `@ark/json-schema` package, and universal schema interop- embed Zod, Valibot, or any Standard Schema validator directly in your definitions.\n\nFor the first time, the type safety ArkType brings to data can extend to your entire function boundary- parameters in, return value out, validated and introspectable. Regex literals now carry full type inference including capture groups. And with configurable `toJsonSchema` and `@ark/json-schema`, ArkType speaks JSON Schema in both directions.\n\n```ts\n// @noErrors\nimport { type } from \"arktype\"\n\n// runtime-validated functions\nconst len = type.fn(\"string | unknown[]\", \":\", \"number\")(s => s.length)\n\nlen(\"foo\") // 3\nlen([1, 2, 3]) // 3\n\n// type-safe regex with inferred captures\nconst Birthday = type({\n\tbirthday: \"x/^(?<month>\\\\d{2})-(?<day>\\\\d{2})-(?<year>\\\\d{4})$/\"\n})\nBirthday.assert({ birthday: \"05-21-1993\" }).birthday.groups.month // \"05\"\n\n// embed any Standard Schema validator\nconst v = { number: () => \"number\" as const }\nconst User = type({ name: \"string\", age: v.number() })\n```\n\nBelow are the full notes for the 2.2.0 release. We can't wait to hear what you think! 🚀\n\n### `type.fn` - Validated functions\n\nDefine functions with runtime-validated parameters and return types, all using the same syntax you already know. The result is a callable with `.expression`, `.params`, and `.returns` for introspection.\n\n```ts\n// @errors: 2345\nconst len = type.fn(\"string | unknown[]\", \":\", \"number\")(s => s.length)\n\nlen(\"foo\") // 3\nlen([1, 2]) // 2\n\nlen.expression // \"(string | Array) => number\"\n\nlen(true) // TraversalError: value at [0] must be a string or an object (was boolean)\n```\n\nSince the types are defined as values rather than annotations, `type.fn` also works in plain `.js` files- no JSDoc or TypeScript required to get fully typed, validated function signatures.\n\nSupports all the tuple features you'd expect- defaults, optionals, variadics:\n\n```ts\n// \"string = 'world'\" means the second param defaults to \"world\" if omitted\nconst greet = type.fn(\n\t\"string\",\n\t\"string = 'world'\"\n)((greeting, name) => `${greeting}, ${name}!`)\n\ngreet(\"Hello\") // \"Hello, world!\"\ngreet(\"Hey\", \"David\") // \"Hey, David!\"\n\n// \"...\" spreads a variadic array parameter, just like in tuple definitions\nconst join = type.fn(\n\t\"...\",\n\t\"string[]\",\n\t\":\",\n\t\"string\"\n)((...parts) => parts.join(\",\"))\n\njoin.expression // \"(...string[]) => string\"\n```\n\n### Type-safe regex\n\nArkType 2.2 integrates [arkregex](/docs/blog/arkregex), a type-safe wrapper for `new RegExp()`. Regex literals in your definitions now carry full type inference:\n\n```ts\nconst Hex = type(\"/^[0-9a-fA-F]+$/\")\n//    Type<string>\n\nconst Semver = type(\"/^(\\\\d+)\\\\.(\\\\d+)\\\\.(\\\\d+)$/\")\n//    Type<`${number}.${number}.${number}`>\n```\n\n#### e(x)ec mode\n\nPrefix a regex literal with `x` to parse capture groups at runtime, fully typed via arkregex:\n\n```ts\nconst User = type({\n\tbirthday: \"x/^(?<month>\\\\d{2})-(?<day>\\\\d{2})-(?<year>\\\\d{4})$/\"\n})\n\nconst data = User.assert({ birthday: \"05-21-1993\" })\n\n// fully type-safe\ndata.birthday.groups.month // \"05\"\ndata.birthday.groups.day // \"21\"\ndata.birthday.groups.year // \"1993\"\n```\n\nFor the standalone package (no ArkType required), see the full [arkregex announcement](/docs/blog/arkregex).\n\n### `@ark/json-schema` - Bidirectional JSON Schema\n\nThe new `@ark/json-schema` package allows you to parse JSON Schema directly into ArkType Types, complementing the existing `toJsonSchema()` method on every Type. Together, they provide full bidirectional conversion.\n\nSpecial thanks to [@TizzySaurus](https://github.com/TizzySaurus) for the incredible work on this package 🙌\n\n```ts\ndeclare const jsonSchemaToType: (schema: unknown) => unknown\n\nconst User = jsonSchemaToType({\n\ttype: \"object\",\n\tproperties: {\n\t\tname: { type: \"string\" },\n\t\tage: { type: \"integer\", minimum: 0 }\n\t},\n\trequired: [\"name\"]\n})\n\n// Type<{ name: string; age?: number }>\n```\n\n### Configurable `toJsonSchema`\n\nSome ArkType features don't have JSON Schema equivalents. By default, `toJsonSchema()` throws in these cases. The new fallback config lets you handle incompatibilities granularly:\n\n```ts\nconst T = type({\n\t\"[symbol]\": \"string\",\n\tbirthday: \"Date\"\n})\n\nconst schema = T.toJsonSchema({\n\tfallback: {\n\t\tdate: ctx => ({\n\t\t\t...ctx.base,\n\t\t\ttype: \"string\",\n\t\t\tformat: \"date-time\",\n\t\t\tdescription: ctx.after ? `after ${ctx.after}` : \"anytime\"\n\t\t}),\n\t\tdefault: ctx => ctx.base\n\t}\n})\n```\n\n`toJsonSchema()` now also accepts a `target` option and can generate `draft-07` in addition to the default `draft-2020-12`. Cyclic types are fully supported and generate `$ref`-based schemas.\n\nArkType also implements the [Standard JSON Schema](https://standardschema.dev) interface, so libraries that consume Standard Schema can access JSON Schema directly via the `~standard` property.\n\nFull documentation including the complete table of fallback codes is available in the [configuration docs](/docs/configuration#tojsonschema).\n\n### Standard Schema as definitions\n\nAny [Standard Schema](https://standardschema.dev) compliant validator can now be passed directly to `type`, either at the top level or nested inside a structural definition, and will be fully inferred and validated.\n\n```ts\nimport { type } from \"arktype\"\nconst v = { number: () => \"number\" as const }\nconst z = {\n\tstring: () => \"string\" as const,\n\tobject: <shape extends Record<string, unknown>>(shape: shape) => shape\n}\n\nconst ZodAddress = z.object({\n\tstreet: z.string(),\n\tcity: z.string()\n})\n\nconst User = type({\n\tname: \"string\",\n\tage: v.number(),\n\taddress: ZodAddress\n})\n```\n\nThis makes ArkType a universal composition layer- mix and match validators from any ecosystem in a single definition.\n\n### `select` - Deep reference introspection\n\nThe new `select` method lets you query the internal structure of a type. Every Type is built from a tree of nodes (domains, constraints, morphs, etc.), and `select` extracts references by kind and predicate:\n\n```ts\nconst T = type(\"1 < number < 10\")\n\n// \"min\" is the node kind for lower bounds, \"exclusive\" means > (not >=)\nconst minNodes = T.select(\"min\")\nconst exclusiveMins = minNodes.filter(node => node.exclusive)\n```\n\nThese selectors can also be used to [target specific references for configuration](/docs/expressions#meta), avoiding the need to transform the entire type:\n\n```ts\nconst User = type({ name: \"string\", age: \"number\" })\n\n// add the description to all domain nodes\nconst configured = User.configure(\n\t{ description: \"a special string\" },\n\t\"domain\"\n)\n\nconfigured.get(\"name\").description // \"a special string\"\nconfigured.get(\"age\").description // \"a special string\"\n```\n\n### Improved `type.declare`\n\n`type.declare` now supports morph-aware declarations via a `side` context, and optionality can be expressed via property values in addition to keys:\n\n```ts\ntype Expected = { a: string; b?: number }\n\nconst T = type.declare<Expected>().type({\n\ta: \"string\",\n\t// previously failed with `\"b?\" is missing`\n\tb: \"number?\"\n})\n```\n\nIf your type includes morphs like `string.numeric.parse`, you can declare just the input side or the output side. This is useful when your external type represents one half of a transformation:\n\n```ts\ntype Input = { name: string }\n\n// { side: \"in\" } means we're declaring only the input shape\nconst T = type.declare<Input, { side: \"in\" }>().type({\n\tname: \"string.numeric.parse\"\n})\n// (In: Input) => { name: number }\n```\n\nWhen there's a mismatch, you get a clear error showing exactly what went wrong:\n\n```ts\n// type.declare<{ a: string }>().type({ a: \"1\" })\n// TypeScript: declared: string; inferred: 1\n```\n\n### Serializable `ArkErrors`\n\n`ArkErrors` are now JSON stringifiable, making it easy to send validation errors as API responses or store them in logs. Two new properties provide structured access:\n\n```ts\nconst NEvenAtLeast2 = type({ n: \"number % 2 >= 2\" })\n\nconst out = NEvenAtLeast2({ n: 1 })\n\nif (out instanceof type.errors) {\n\tout.flatByPath\n\t// { n: [{ code: \"divisor\", rule: 2, ... }, { code: \"min\", rule: 2, ... }] }\n\n\tout.flatProblemsByPath\n\t// { n: [\"must be even (was 1)\", \"must be at least 2 (was 1)\"] }\n}\n```\n\nUnhandled validation errors now throw a `TraversalError` (instead of `AggregateError`) with cleaner multi-error formatting (thanks @LukeAbby).\n\n### N-ary operators\n\n`type.or`, `type.and`, `type.merge`, and `type.pipe` are standalone functions that accept variadic definitions, avoiding the need to chain or compose binary expressions:\n\n```ts\nconst Union = type.or(type.string, \"number\", { key: \"unknown\" })\n\nconst Intersection = type.and(\n\t{ foo: \"string\" },\n\t{ bar: \"number\" },\n\t{ baz: \"string\" }\n)\n\nconst Merged = type.merge(\n\t{ \"[string]\": \"number\", foo: \"0\" },\n\t{ \"[string]\": \"bigint\", \"foo?\": \"1n\" }\n)\n\nconst TrimToNonEmpty = type.pipe(\n\ttype.string,\n\ts => s.trimStart(),\n\ttype.string.atLeastLength(1)\n)\n```\n\n### String-embeddable `|>` pipe operator\n\nThe `to` operator (`|>`) can now be used directly inside string definitions:\n\n```ts\nconst TrimToNonEmpty = type(\"string.trim |> string > 0\")\n\n// equivalent to\nconst Equivalent = type(\"string.trim\").to(\"string > 0\")\n```\n\n### `type.valueOf`\n\nCreate a Type from a TypeScript `enum` or enum-like object:\n\n```ts\nenum Color {\n\tRed,\n\tGreen,\n\tBlue\n}\n\n// Type<Color.Red | Color.Green | Color.Blue>\nconst ColorType = type.valueOf(Color)\n```\n\n### New keywords\n\nTwo new built-in string keywords:\n\n```ts\n// validates hexadecimal strings (thanks @HoaX7)\nconst Hex = type(\"string.hex\")\nHex.allows(\"deadbeef\") // true\n\n// validates that a string is a syntactically valid regex pattern\nconst Pattern = type(\"string.regex\")\nPattern.allows(\"^[a-z]+$\") // true\nPattern.allows(\"[invalid\") // false\n```\n\n### `exactOptionalPropertyTypes` config\n\nArkType now supports a global config for `exactOptionalPropertyTypes`, matching TypeScript's compiler option:\n\n```ts title=\"config.ts\"\nimport { configure } from \"arktype/config\"\n\n// since the default in ArkType is `true`, this only has an effect if set to `false`\nconfigure({ exactOptionalPropertyTypes: false })\n```\n\n```ts title=\"app.ts\"\nimport \"./config.ts\"\nimport { type } from \"arktype\"\n\nconst MyObj = type({ \"key?\": \"number\" })\n\n// now valid (would be an error by default)\nMyObj({ key: undefined })\n```\n\n### Additional improvements\n\n- **`Type#distribute`**: Map and optionally reduce over union branches e.g. `T.distribute(branch => branch.expression)`. See [Type API docs](/docs/type-api#distribute).\n- **ES2020 / Hermes compatibility**: Removed usages of newer prototype methods like `.at()` to support legacy browsers and React Native's Hermes engine\n- **In-docs playground**: Try ArkType directly from the docs at [arktype.io/playground](https://arktype.io/playground) with full type checking and formatting\n- **Cyclic unions can now discriminate on nested paths**, improving performance and error messages for complex recursive types\n- **Faster shallow completions**: Near-instant autocomplete for `type(\"\")`\n- **Better JSDoc and go-to-definition** for parsed object keys\n- **Improved `.expression` for regex constraints**: Now displays `/^pattern$/` instead of `string /^pattern$/`\n- **Generic descriptions** are now included for built-in generics like `Record`, `Pick`, `Omit`, `Partial`, `Required`, `Exclude`, `Extract`, and `Merge`\n- **`toJsonSchema()` format annotations**: Built-in string keywords like `string.email`, `string.ip.v4`, `string.ip.v6`, `string.url`, and `string.uuid` now emit proper JSON Schema `format` fields, improving OpenAPI compatibility\n- **Duplicate key detection**: Definitions with conflicting keys like `{ foo: \"string\", foo?: \"string\" }` now throw a descriptive error at parse time\n- **Unsatisfiable index signature intersections** now result in a `ParseError` instead of silently producing an unusable type\n- **Fixed predicate errors** after the first not being reported for multi-property constraints\n- **Fixed clone crash** when an object has a getter or setter as a non-prototype property\n- **Fixed custom `message` callbacks in JIT mode** that previously produced `\"$ark.message\"` instead of the expected string\n- **Fixed morph inference for environments** where global prototypes like `FormData` resolve to `{}` (e.g. `@types/bun`)\n- **Fixed metatype extraction from recursive definitions** where `Default` and `Out` were not properly inferred\n\n⚡ [Start coding](/docs/intro/setup)\n\n⭐ [Check out the project on GitHub](https://github.com/arktypeio/arktype)\n\n👋 [Join our Discord to lurk or ask questions](https://arktype.io/discord)\n\n- Follow any of these accounts for updates:\n  - [@arktype.io](https://bsky.app/profile/arktype.io), [@ssalbdivad.dev](https://bsky.app/profile/ssalbdivad.dev) on BlueSky\n  - [@arktypeio](https://x.com/arktypeio), [@ssalbdivad](https://x.com/ssalbdivad) on X/Twitter\n\n- Consider supporting my full-time work on ArkType...\n  - via [GitHub Sponsors](https://github.com/sponsors/arktypeio)\n  - by convincing your team to let me optimize your types and fix editor lag (reach out directly to one of the accounts listed or `david@arktype.io`)\n\n\n---\ntitle: Introducing ArkRegex\ndescription: A drop-in replacement for new RegExp() with types\n---\n\nRegular expressions are ubiquitous in modern code.\n\nA few characters sprinkled into your JavaScript can validate and parse strings that would require dozens of lines of imperative logic.\n\nHowever, that concision comes at a cost. Complex expressions can be hard to understand and type safety is a pipe dream- or at least, it was.\n\n**Introducing `arkregex`, a type-safe wrapper of `new RegExp()`.**\n\n<video\n\tautoPlay\n\tloop\n\tcontrols\n\tplaysInline\n\tmuted\n\tdisablePictureInPicture\n\tsrc=\"https://github.com/arktypeio/arktype/releases/download/arkregex%400.0.1/arkregexDemo.webm\"\n\tstyle={{ marginTop: \"-1rem\" }}\n/>\n\nThe `regex` function creates a `Regex` instance with types for `.test()`, `.exec()` and more, statically parsed from native JS syntax:\n\n```ts\nimport { regex } from \"arkregex\"\n\nconst ok = regex(\"^ok$\", \"i\")\n// Regex<\"ok\" | \"oK\" | \"Ok\" | \"OK\", { flags: \"i\" }>\n\nconst semver = regex(\"^(\\\\d*)\\\\.(\\\\d*)\\\\.(\\\\d*)$\")\n// Regex<`${bigint}.${bigint}.${bigint}`, { captures: [`${bigint}`, `${bigint}`, `${bigint}`] }>\n\nconst email = regex(\"^(?<name>\\\\w+)@(?<domain>\\\\w+\\\\.\\\\w+)$\")\n// Regex<`${string}@${string}.${string}`, { names: { name: string; domain: `${string}.${string}`; }; ...>\n```\n\nAll you need to get started is `pnpm install arkregex` (or the equivalent for your package manager of choice) 🎉\n\nPerforms best with TS 5.9+\n\n### Features\n\n- **Types**: Infers string types for your existing regular expressions, including positional and named captures\n- **Parity**: Supports 100% of [features](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions) allowed by `new RegExp()`\n- **Safety**: Syntax errors like referencing a group that doesn't exist are now type errors\n- **Zero Runtime**: Improves your type safety without impacting your bundle size\n\n### FAQ\n\n#### Why aren't some patterns like `[a-Z]` inferred more precisely?\n\nConstructing string literal types for these sorts of expressions is combinatorial and will explode very quickly if we infer character ranges like this as literal characters.\n\nWe've tried to strike a balance between performance and precision while guaranteeing that the inferred types are at worst imprecise and never incorrect.\n\n#### Why doesn't it work with my massive RegExp?\n\nIf your expression is especially long or complex, TypeScript won't be able to infer it.\n\nIf your types start to slow down or you see the dreaded `Type is excessively deep...`, you can manually type your expression using `regex.as`:\n\n```ts\nconst complexPattern = regex.as<`pattern-${string}`, { captures: [string] }>(\n\t\"very-long-complex-expression-here\"\n)\n```\n\n#### Is it robust?\n\n`arkregex` types are [extensively tested](https://github.com/arktypeio/arktype/tree/main/ark/regex/__tests__/regex.test.ts) and [benchmarked](https://github.com/arktypeio/arktype/tree/main/ark/regex/__tests__/regex.bench.ts) using [attest](https://github.com/arktypeio/arktype/tree/main/ark/attest#readme).\n\nIf anything not covered by the other FAQs is not behaving how you'd expect, please don't hesitate to [create an issue](https://github.com/arktypeio/arktype/issues/new).\n\n#### How can I get syntax highlighting for my expressions?\n\nThe [ArkType extension](https://marketplace.visualstudio.com/items?itemName=arktypeio.arkdark) can be installed to add syntax highlighting to `regex` calls.\n\n### Useful links\n\n⭐ [Check out the project on GitHub](https://github.com/arktypeio/arktype)\n\n👋 [Join our Discord to lurk or ask questions](https://arktype.io/discord)\n\n- Follow any of these accounts for updates:\n  - [@arktype.io](https://bsky.app/profile/arktype.io), [@ssalbdivad.dev](https://bsky.app/profile/ssalbdivad.dev) on BlueSky\n  - [@arktypeio](https://x.com/arktypeio), [@ssalbdivad](https://x.com/arktypeio) on X/Twitter\n\n\n---\ntitle: Posts\n---\n\n<LinkCard\n\ttitle=\"Announcing ArkType 2.2\"\n\tdescription=\"Type-safe regex, validated functions, and native Standard Schema definitions\"\n\thref=\"/docs/blog/2.2\"\n\tdate=\"February 10, 2026\"\n/>\n\n<LinkCard\n\ttitle=\"Introducing ArkRegex\"\n\tdescription=\"A drop-in replacement for new RegExp() with types\"\n\thref=\"/docs/blog/arkregex\"\n\tdate=\"October 28, 2025\"\n/>\n\n<LinkCard\n\ttitle=\"Announcing ArkType 2.1\"\n\tdescription=\"Optimized pattern matching from type syntax\"\n\thref=\"/docs/blog/2.1\"\n\tdate=\"February 27, 2025\"\n/>\n\n<LinkCard\n\ttitle=\"Announcing ArkType 2.0\"\n\tdescription=\"100x faster validation with DX that will blow your mind\"\n\thref=\"/docs/blog/2.0\"\n\tdate=\"January 17, 2025\"\n/>\n\n\n---\ntitle: Comparisons\n---\n\n\n---\ntitle: Configuration\n---\n\nA great out-of-the-box experience is a core goal of ArkType, including safe defaults and helpful messages for complex errors.\n\nHowever, it's equally important that when you need different behavior, you can easily configure it with the right granularity.\n\n### Levels\n\n<table>\n  <thead>\n    <tr>\n      <th>Level</th>\n      <th>Applies To</th>\n      <th>Example</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td>**default**</td>\n      <td>built-in defaults for all Types</td>\n      <td></td>\n    </tr>\n    <tr>\n      <td>**global**</td>\n      <td>all Types parsed after the config is applied</td>\n      <td>\n```ts title=\"config.ts\"\nimport { configure } from \"arktype/config\"\n// use the \"arktype/config\" entrypoint\nconfigure({ numberAllowsNaN: true })\n```\n\n```ts title=\"app.ts\"\nimport \"./config.ts\"\n// import your config file before arktype\nimport { type } from \"arktype\"\n\ntype.number.allows(Number.NaN) // true\n```\n\n     </td>\n    </tr>\n    <tr>\n      <td>**scope**</td>\n      <td>all Types parsed in the configured Scope</td>\n      <td>\n\n```ts\nconst myScope = scope(\n\t{ User: { age: \"number < 100\" } },\n\t{\n\t\tmax: {\n\t\t\tactual: () => \"unacceptably large\"\n\t\t}\n\t}\n)\nconst types = myScope.export()\n// ArkErrors: age must be less than 100 (was unacceptably large)\ntypes.User({ name: \"Alice\", age: 101 })\nconst parsedAfter = myScope.type({\n\tage: \"number <= 100\"\n})\n// ArkErrors: age must be at most 100 (was unacceptably large)\nparsedAfter({ age: 101 })\n```\n\n      </td>\n    </tr>\n    <tr>\n      <td>**type**</td>\n      <td>all Types shallowly referenced by the configured Type</td>\n      <td>\n\n```ts\n// avoid logging \"was xxx\" for password\nconst Password = type(\"string >= 8\").configure({ actual: () => \"\" })\nconst User = type({\n\temail: \"string.email\",\n\tpassword: Password\n})\n// ArkErrors: password must be at least length 8\nconst out = User({\n\temail: \"david@arktype.io\",\n\tpassword: \"ez123\"\n})\n```\n\n      </td>\n    </tr>\n\n  </tbody>\n</table>\n\nSome options only apply at specific levels, as reflected in the corresponding input types.\n\n<Callout\n\ttype=\"warn\"\n\ttitle='Use the `\"arktype/config\"` entrypoint in a separate file for global config!'\n>\n\tIf you need your config to apply to built-in keywords (important for options\n\tlike `jitless`, `numberAllowsNaN`, `dateAllowsInvalid`), you should import and\n\t`configure` from `\"arktype/config\"` before importing anything from\n\t`\"arktype\"`.\n\nOtherwise, keywords will have already been parsed by the time your config applies!\n\n</Callout>\n\n### Errors\n\nTo allow custom errors to be integrated seamlessly with built-in logic for composite errors (i.e. `union` and `intersection`), ArkType supports a set of composable options:\n\n<table>\n<thead>\n<tr>\n<th>optional</th>\n<th>description</th>\n<th>example</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>**description**</td>\n<td>\n✅ a summary of the constraint that could complete the phrase \"must be ___\"\n\n🥇 reused by other metadata and should be your first go-to for customizing a message\n\n</td>\n<td>\n```ts\nconst Password = type.string.atLeastLength(8).describe(\"a valid password\")\n// ArkErrors: must be a valid password\nconst out = Password(\"ez123\")\n```\n</td>\n</tr>\n<tr>\n<td>**expected**</td>\n<td>\n✅ a function accepting the error context and returning a string of the format \"must be ___\"\n\n✅ specific to errors and takes precedence over `description` in those cases\n\n</td>\n    <td>\n```ts\nconst Password = type.string.atLeastLength(8).configure({\n\texpected: ctx =>\n\t\tctx.code === \"minLength\" ? `${ctx.rule} characters or better` : \"way better\"\n})\n// ArkErrors: must be 8 characters or better (was 5)\nconst out1 = Password(\"ez123\").toString()\n// ArkErrors: must be way better (was a number)\nconst out2 = Password(12345678).toString()\n```\n</td>\n</tr>\n<tr>\n<td>**actual**</td>\n<td>\n✅ a function accepting the data that caused the error and returning a string of the format \"(was ___)\"\n\n✅ if an empty string is returned, the actual portion of the message will be omitted\n\n</td>\n    <td>\n```ts\nconst Password = type(\"string >= 8\").configure({ actual: () => \"\" })\n// ArkErrors: must be at least length 8\nconst out = Password(\"ez123\")\n```\n</td>\n</tr>\n<tr>\n<td>**problem**</td>\n<td>\n✅ a function accepting the results of `expected` and `actual` in addition to other context and returning a complete description of the problem like \"must be a string (was a number)\"\n\n❌ may not apply to composite errors like unions\n\n</td>\n<td>\n```ts\nconst Password = type(\"string >= 8\").configure({\n\tproblem: ctx => `${ctx.actual} isn't ${ctx.expected}`\n})\n// ArkErrors: 5 isn't at least length 8\nconst out1 = Password(\"ez123\")\n// ArkErrors: a number isn't a string\nconst out2 = Password(12345678)\n```\n</td>\n</tr>\n<tr>\n<td>**message**</td>\n<td>\n✅ a function accepting the result of `problem` in addition to other context and returning a complete description of the problem including the path at which it occurred\n\n❌ may not apply to composite errors like unions\n\n</td>\n<td>\n```ts\nconst User = type({\n\tpassword: \"string >= 8\"\n}).configure({\n\tmessage: ctx =>\n\t\t`${ctx.propString || \"(root)\"}: ${ctx.actual} isn't ${ctx.expected}`\n})\n// ArkErrors: (root): a string isn't an object\nconst out1 = User(\"ez123\")\n// `.configure` only applies shallowly, so the nested error isn't changed!\n// ArkErrors: password must be at least length 8 (was 5)\nconst out2 = User({ password: \"ez123\" })\n```\n</td>\n</tr>\n</tbody>\n</table>\n\n#### By Code\n\nErrors can also be configured by their associated `code` property at a _scope_ or _global_ level.\n\nFor example:\n\n```ts\nconst mod = type.module(\n\t{ isEven: \"number%2\" },\n\t{\n\t\tdivisor: {\n\t\t\t// the available `ctx` types will include data specific to your errors\n\t\t\texpected: ctx => `% ${ctx.rule} !== 0`,\n\t\t\tproblem: ctx => `${ctx.actual} ${ctx.expected}`\n\t\t}\n\t}\n)\n// ArkErrors: 3 % 2 !== 0\nmod.isEven(3)\n```\n\n#### ArkErrors\n\nFor use cases like i18n that fall outside the scope of this composable message config, the `ArkErrors` array returned on validation failure contains `ArkError` instances that can be discriminated via calls like `.hasCode(\"divisor\")` and contain contextual data specific to that error type as well as getters for each composable error part.\n\nThese `ArkError` instances can be arbitrarily transformed and composed with an internationalization library. This is still a topic we're working on investigating and documenting, so please reach out with any questions or feedback!\n\n#### Serialization\n\n`ArkErrors` and `ArkError` are JSON stringifiable via `JSON.stringify()` or `.toJSON()`.\n\nTwo additional properties provide structured access to errors grouped by path:\n\n```ts\nconst T = type({ n: \"number % 2 >= 2\" })\n\nconst out = T({ n: 1 })\n\nif (out instanceof type.errors) {\n\tout.flatByPath\n\t// { n: [{ data: 1, path: [\"n\"], code: \"divisor\", ... }, { data: 1, path: [\"n\"], code: \"min\", ... }] }\n\n\tout.flatProblemsByPath\n\t// { n: [\"must be even (was 1)\", \"must be at least 2 (was 1)\"] }\n}\n```\n\n`flatByPath` maps each path string to an array of `ArkError` objects (decomposing union errors into their individual branches). `flatProblemsByPath` maps each path string to an array of human-readable problem strings.\n\nUnhandled validation errors (e.g. via `.assert()`) throw a `TraversalError`, which extends `Error` with cleaner multi-error formatting and a non-enumerable `arkErrors` property for programmatic access.\n\n### Keywords\n\nBuilt-in keywords like `string.email` can be globally configured.\n\nThis can be very helpful for customizing error messages without needing to create your own aliases or wrappers.\n\n```ts title=\"config.ts\"\nimport { configure } from \"arktype/config\"\n\nconfigure({\n\tkeywords: {\n\t\tstring: \"shorthand description\",\n\t\t\"string.email\": {\n\t\t\tactual: () => \"definitely fake\"\n\t\t}\n\t}\n})\n```\n\n```ts title=\"app.ts\"\nimport \"./config.ts\"\n// import your config file before arktype\nimport { type } from \"arktype\"\n\nconst User = type({\n\tname: \"string\",\n\temail: \"string.email\"\n})\n\nconst out = User({\n\t// ArkErrors: name must be shorthand description (was a number)\n\tname: 5,\n\t// ArkErrors: email must be an email address (was definitely fake)\n\temail: \"449 Canal St\"\n})\n```\n\nThe options you can provide here are identical to those used to [configure a Type directly](/docs/expressions#meta), and can also be [extended at a type-level to include custom metadata](/docs/configuration#metadata).\n\n### Clone\n\nBy default, before a [morph](/docs/intro/morphs-and-more) is applied, ArkType will deeply clone the original input value with a built-in `deepClone` function that tries to make reasonable assumptions about preserving prototypes etc. The implementation of `deepClone` can be found [here](https://github.com/arktypeio/arktype/blob/main/ark/util/clone.ts).\n\nYou can provide an alternate clone implementation to the `clone` config option.\n\n```ts title=\"config.ts\"\nimport { configure } from \"arktype/config\"\n\nconfigure({ clone: structuredClone })\n```\n\n```ts title=\"app.ts\"\nimport \"./config.ts\"\n// import your config file before arktype\nimport { type } from \"arktype\"\n\n// will now create a new object using structuredClone\nconst UserForm = type({\n\tage: \"string.numeric.parse\"\n})\n```\n\nTo mutate the input object directly, you can set the `clone` config option to `false`.\n\n```ts title=\"config.ts\"\nimport { configure } from \"arktype/config\"\n\nconfigure({ clone: false })\n```\n\n```ts title=\"app.ts\"\nimport \"./config.ts\"\n// import your config file before arktype\nimport { type } from \"arktype\"\n\nconst UserForm = type({\n\tage: \"string.numeric.parse\"\n})\n\nconst formData = {\n\tage: \"42\"\n}\n\nconst out = UserForm(formData)\n\n// the original object's age key is now a number\nconsole.log(formData.age)\n```\n\n### onUndeclaredKey\n\nLike TypeScript, ArkType defaults to ignoring undeclared keys during validation. However, it also supports two additional behaviors:\n\n- `\"ignore\"` (default): Allow undeclared keys on input, preserve them on output\n- `\"delete\"`: Allow undeclared keys on input, delete them before returning output\n- `\"reject\"`: Reject input with undeclared keys\n\nThese behaviors can be associated with individual Types via the built-in `\"+\"` syntax (see [those docs](/docs/objects#properties-undeclared) for more on how they work). You can also change the default globally:\n\n```ts title=\"config.ts\"\nimport { configure } from \"arktype/config\"\n\nconfigure({ onUndeclaredKey: \"delete\" })\n```\n\n```ts title=\"app.ts\"\nimport \"./config.ts\"\n// import your config file before arktype\nimport { type } from \"arktype\"\n\nconst UserForm = type({\n\tname: \"string\"\n})\n\n// out is now { name: \"Alice\" }\nconst out = UserForm({\n\tname: \"Alice\",\n\tage: \"42\"\n})\n```\n\n### exactOptionalPropertyTypes\n\nBy default, ArkType validates optional keys as if [TypeScript's `exactOptionalPropertyTypes` is set to `true`](https://www.typescriptlang.org/tsconfig/#exactOptionalPropertyTypes).\n\n<details>\n\t<summary>See an example</summary>\n\n```ts\nconst MyObj = type({\n\t\"key?\": \"number\"\n})\n\n// valid data\nconst validResult = MyObj({})\n\n// Error: key must be a number (was undefined)\nconst errorResult = MyObj({ key: undefined })\n```\n\n</details>\n\nThis approach allows the most granular control over optionality, as `| undefined` can be added to properties that should accept it.\n\nHowever, if you have not enabled TypeScript's `exactOptionalPropertyTypes` setting, you may globally configure ArkType's `exactOptionalPropertyTypes` to `false` to match TypeScript's behavior. If you do this, we'd recommend making a plan to enable `exactOptionalPropertyTypes` in the future.\n\n```ts title=\"config.ts\"\nimport { configure } from \"arktype/config\"\n\n// since the default in ArkType is `true`, this will only have an effect if set to `false`\nconfigure({ exactOptionalPropertyTypes: false })\n```\n\n```ts title=\"app.ts\"\nimport \"./config.ts\"\n// import your config file before arktype\nimport { type } from \"arktype\"\n\nconst MyObj = type({\n\t\"key?\": \"number\"\n})\n\n// valid data\nconst validResult = MyObj({})\n\n// now also valid data (would be an error by default)\nconst secondResult = MyObj({ key: undefined })\n```\n\n<Callout type=\"warn\" title=\"exactOptionalPropertyTypes does not yet affect default values!\">\n\n```ts\nconst MyObj = type({\n\tkey: \"number = 5\"\n})\n\n// { key: 5 }\nconst omittedResult = MyObj({})\n\n// { key: undefined }\nconst undefinedResult = MyObj({ key: undefined })\n```\n\nSupport for this is tracked as part of [this broader configurable defaultability issue](https://github.com/arktypeio/arktype/issues/1390).\n\n</Callout>\n\n### jitless\n\nBy default, when a `Type` is instantiated, ArkType will precompile optimized validation logic that will run when the type is invoked. This behavior is disabled by default in environments that don't support `new Function`, e.g. Cloudflare Workers.\n\nIf you'd like to opt out of it for another reason, you can set the `jitless` config option to `true`.\n\n```ts title=\"config.ts\"\nimport { configure } from \"arktype/config\"\n\nconfigure({ jitless: true })\n```\n\n```ts title=\"app.ts\"\nimport \"./config.ts\"\n// import your config file before arktype\nimport { type } from \"arktype\"\n\n// will not be precompiled\nconst MyObject = type({\n\tfoo: \"string\"\n})\n```\n\n### onFail\n\nIn some domains, you may always want to throw on failed validation or transform the result in some other way.\n\nBy specifying `onFail` in your global config, you can control what happens when you invoke a `Type` on invalid data:\n\n```ts title=\"config.ts\"\nimport { configure } from \"arktype/config\"\n\nconst config = configure({\n\tonFail: errors => errors.throw()\n})\n\n// be sure to specify both the runtime and static configs\n\ndeclare global {\n\tinterface ArkEnv {\n\t\tonFail: typeof config.onFail\n\t}\n}\n```\n\n```ts title=\"app.ts\"\nimport \"./config.ts\"\n// import your config file before arktype\nimport { type } from \"arktype\"\n\n// data is inferred as string- no need to discriminate!\nconst data = type.string(\"foo\")\n\n// now thrown instead of returned\n// ArkErrors: must be a string (was number)\nconst bad = type.string(5)\n```\n\n### metadata\n\nAdditional arbitrary metadata can also be associated with a Type.\n\nIt can even be made type-safe via an interface extension ArkType exposes for this purpose:\n\n```ts\n// add this anywhere in your project\ndeclare global {\n\tinterface ArkEnv {\n\t\tmeta(): {\n\t\t\t// meta properties should always be optional\n\t\t\tsecretIngredient?: string\n\t\t}\n\t}\n}\n\n// now types you define can specify and access your metadata\nconst MrPingsSecretIngredientSoup = type({\n\tbroth: \"'miso' | 'vegetable'\",\n\tingredients: \"string[]\"\n}).configure({ secretIngredient: \"nothing!\" })\n```\n\n### toJsonSchema\n\nSome ArkType features don't have JSON Schema equivalents. By default, `toJsonSchema()` will throw in these cases.\n\nThis behavior can be configured granularly to match your needs.\n\n```ts\nconst T = type({\n\t\"[symbol]\": \"string\",\n\tbirthday: \"Date\"\n})\n\nconst schema = T.toJsonSchema({\n\tfallback: {\n\t\t// ✅ the \"default\" key is a fallback for any non-explicitly handled code\n\t\t// ✅ ctx includes \"base\" (represents the schema being generated) and other code-specific props\n\t\t// ✅ returning `ctx.base` will effectively ignore the incompatible constraint\n\t\tdefault: ctx => ctx.base,\n\t\t// handle specific incompatibilities granularly\n\t\tdate: ctx => ({\n\t\t\t...ctx.base,\n\t\t\ttype: \"string\",\n\t\t\tformat: \"date-time\",\n\t\t\tdescription: ctx.after ? `after ${ctx.after}` : \"anytime\"\n\t\t})\n\t}\n})\n\nconst result = {\n\t$schema: \"https://json-schema.org/draft/2020-12/schema\",\n\ttype: \"object\",\n\tproperties: {\n\t\t// Date instance is now a date-time string as specified by the `date` handler\n\t\tbirthday: { type: \"string\", format: \"date-time\", description: \"anytime\" }\n\t},\n\trequired: [\"birthday\"]\n\t// symbolic index signature ignored as specified by the `default` handler\n}\n```\n\na `default` handler can also be specified at the root of a `fallback` config:\n\n```ts\nconst T = type({\n\t\"[symbol]\": \"string\",\n\tbirthday: \"Date\"\n})\n\n//--- cut ---\n\nconst schema = T.toJsonSchema({\n\t// \"just make it work\"\n\tfallback: ctx => ctx.base\n})\n```\n\nThese options can also be set at a [global or scope-level](/docs/configuration#levels).\n\n### Fallback Codes\n\nThis is the full list of configurable reasons `toJsonSchema()` can fail.\n\n| Code                  | Description                                                 |\n| --------------------- | ----------------------------------------------------------- |\n| `arrayObject`         | arrays with object properties                               |\n| `arrayPostfix`        | arrays with postfix elements                                |\n| `defaultValue`        | non-serializable default value                              |\n| `domain`              | non-serializable type keyword (always `bigint` or `symbol`) |\n| `morph`               | transformation                                              |\n| `patternIntersection` | multiple regex constraints                                  |\n| `predicate`           | custom narrow function                                      |\n| `proto`               | non-serializable `instanceof`                               |\n| `symbolKey`           | symbolic key on an object                                   |\n| `unit`                | non-serializable `===` reference (e.g. `undefined`)         |\n| `date`                | a Date instance (supersedes `proto` for Dates)              |\n\n### prototypes\n\nWhen you `.infer` your Types, ArkType traverses them and extracts special values like morphs, e.g. `(In: string) => Out<number>`.\n\nThough generally this is able to preserve the original type, it is inefficient and can accidentally expand certain object types.\n\nYou can use the type-level `prototypes` config to tell ArkType to treat those types as external:\n\n```ts\ndeclare global {\n\tinterface ArkEnv {\n\t\tprototypes(): MySpecialClass\n\t}\n}\n\nclass MySpecialClass {}\n\nconst T = type.instanceOf(MySpecialClass)\n//    ^? Type<MySpecialClass>\n```\n\n\n---\ntitle: Declare\n---\n\nIf your ArkType definitions are your source of truth, it's easy to infer out the type with an expression like `type User = typeof User.infer`.\n\nBut what if you need to define a Type matching a pre-existing external type?\n\nThe `declare` API allows just that, with autocomplete for object keys and clear, type-level errors for mismatches:\n\n```ts\n// @errors: 2322\ntype Expected = { a: string; b?: number }\n\nconst T = type.declare<Expected>().type({\n\ta: \"string\",\n\t\"b?\": \"number\"\n})\n\nconst Bad = type.declare<Expected>().type({\n\ta: \"string\",\n\t// will error if the inferred type is too wide *or* too narrow\n\t\"b?\": \"1\"\n})\n```\n\nOptionality can also be expressed via the property value instead of the key:\n\n```ts\ntype Expected = { a: string; b?: number }\n\nconst T = type.declare<Expected>().type({\n\ta: \"string\",\n\t// equivalent to \"b?\": \"number\"\n\tb: \"number?\"\n})\n```\n\n### `side`\n\nIf your Type contains morphs or default values, its input and output will be inferred differently.\n\nYou can see this represented when you hover a Type like `string.numeric.parse` and see `(In: string) => To<number>`.\n\nBy default, `declare` does not allow the type you define to include morphs (unless you explicitly add them to the declared generic argument).\n\nPassing a `side` config to `declare` can change this behavior:\n\n```ts\n// @errors: 2322\ntype Expected = { a: number; b?: number }\n\nconst Bad = type.declare<Expected>().type({\n\ta: \"string.numeric.parse\",\n\t\"b?\": \"number\"\n})\n\n// passing a config object like { side: \"in\" | \"out\" } to validate that side\nconst T = type.declare<Expected, { side: \"out\" }>().type({\n\ta: \"string.numeric.parse\",\n\t\"b?\": \"number\"\n})\n```\n\n\n---\ntitle: Ecosystem\n---\n\n### ArkEnv\n\n[ArkEnv](https://arkenv.js.org) brings the power of ArkType to your environment variables.\n\nDefine an ArkType schema, pull values from your environment or config source, validate them, apply type conversions and transformations, and end up with a fully typesafe, ready-to-use `env` object.\n\nInspired by tools like [T3 Env](https://env.t3.gg) but tailored specifically for ArkType, ArkEnv also adds keywords like `string.host` and `number.port` for env-specific use cases.\n\n```ts\n// @noErrors\nimport arkenv from \"arkenv\"\n\nconst env = arkenv({\n\tHOST: \"string.host\",\n\tPORT: \"number.port\",\n\tNODE_ENV: \"'development' | 'production' | 'test' = 'development'\"\n})\n\n// Automatically validate and parse process.env\n// TypeScript knows the ✨exact✨ types!\nconsole.log(env.HOST) // (property) HOST: string\nconsole.log(env.PORT) // (property) PORT: number\nconsole.log(env.NODE_ENV) // (property) NODE_ENV: \"development\" | \"production\" | \"test\"\n```\n\n\n---\ntitle: Expressions\n---\n\n### Intersection\n\nLike its TypeScript counterpart, an intersection combines two existing `Type`s to create a new `Type` that enforces the constraints of both.\n\n<Callout\n\ttype=\"warn\"\n\ttitle=\"If you don't need to intersect overlapping props, spread instead!\"\n>\n\nComputing an intersection is more expensive than [merging props](/docs/objects#merge), both at runtime and in-editor.\n\nIf you can get away with the latter, doing so will make your Types faster and cleaner.\n\n</Callout>\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst MyObj = type({\n\t// an email address with the domain arktype.io\n\tintersected: \"string.email & /@arktype\\\\.io$/\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst FooObject = type({\n\tfoo: \"string\"\n})\n\n// an object requiring both foo and bar\nconst FoobarObject = FooObject.and({\n\tbar: \"number\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\n// an object requiring both foo and bar\nconst FoobarObject = type([\n\t{\n\t\tfoo: \"string\"\n\t},\n\t\"&\",\n\t{\n\t\tbar: \"number\"\n\t}\n])\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab args>\n\n```ts\n// an object requiring both foo and bar\nconst FoobarObject = type(\n\t{\n\t\tfoo: \"string\"\n\t},\n\t\"&\",\n\t{\n\t\tbar: \"number\"\n\t}\n)\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n<AnchorAliases intersection-n-ary />\n#### n-ary\n\nTo create an intersection of many objects directly, `type.and` will avoid the need to chain or compose many binary expressions:\n\n```ts\nconst FooObject = type({\n\tfoo: \"string\"\n})\n\n// accepts ...definitions\nconst FoobarObject = type.and(\n\tFooObject,\n\t{\n\t\tbar: \"number\"\n\t},\n\t{\n\t\tbaz: \"string\"\n\t}\n)\n```\n\n### Union\n\nAll unions are automatically discriminated to optimize check time and error message clarity.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst Unions = type({\n\tkey: \"string | number\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Unions = type({\n\tkey: type.string.or(type.number)\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\nconst Unions = type({\n\tkey: [\"string\", \"|\", { name: \"string\" }]\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab args>\n\n```ts\nconst Unions = type({\n\tkey: type(\"string\", \"|\", { name: \"string\" })\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n<AnchorAliases union-n-ary />\n#### n-ary\n\nTo create a union of many objects directly, `type.or` will avoid the need to chain or compose many binary expressions:\n\n```ts\n// accepts ...definitions\nconst Union = type.or(type.string, \"number\", { key: \"unknown\" })\n```\n\n<AnchorAliases union-morphs />\n\n<Callout\n\ttype=\"warn\"\n\ttitle=\"A union that could apply different morphs to the same data throws a ParseError!\"\n>\n```ts\n// operands overlap, but neither transforms data\nconst Okay = type(\"number > 0\").or(\"number < 10\")\n// operand transforms data, but there's no overlap between the inputs\nconst AlsoOkay = type(\"string.numeric.parse\").or({ box: \"string\" })\n// operands overlap and transform data, but in the same way\nconst StillOkay = type(\"string > 5\", \"=>\", Number.parseFloat).or([\n\t\"0 < string < 10\",\n\t\"=>\",\n\tNumber.parseFloat\n])\n// ParseError: An unordered union of a type including a morph and a type with overlapping input is indeterminate\nconst Bad = type({ box: \"string.numeric.parse\" }).or({ box: \"string\" })\nconst SameError = type({ a: \"string.numeric.parse\" }).or({ b: \"string.numeric.parse\" })\n```\n\n<details>\n\t<summary>Learn the set theory behind this restriction</summary>\n\nIf you're relatively new to set-based types, that error might be daunting, but if you take a second to think through the example, it becomes clear why this isn't allowed. The logic of `bad` is essentially:\n\n- If the input is an object where `box` is a `string`, parse and return it as a number\n- If the input is an object where `box` is a `string`, return it as a string\n\nThere is no way to deterministically return an output for this type without sacrificing the [commutativity](https://en.wikipedia.org/wiki/Commutative_property) of the union operator.\n\n`sameError` may look more innocuous, but has the same problem for an input like `{ a: \"1\", b: \"2\" }`.\n\n- Left branch would only parse `a`, resulting in `{ a: 1, b: \"2\" }`\n- Right branch would only parse `b`, resulting in `{ a: \"1\", b: 2 }`\n\n</details>\n\n</Callout>\n\n### Brand\n\nAdd a type-only symbol to an existing type so that the only values that satisfy it are those that have been directly validated.\n\n<SyntaxTabs>\n\n    <SyntaxTab string>\n\n```ts\n// @noErrors\nconst Even = type(\"(number % 2)#even\")\ntype Even = typeof Even.infer\n\nconst good: Even = Even.assert(2)\n// TypeScript: Type 'number' is not assignable to type 'Brand<number, \"even\">'\nconst bad: Even = 5\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\n// @noErrors\nconst Even = type.number.divisibleBy(2).brand(\"even\")\ntype Even = typeof Even.infer\n\nconst good: Even = Even.assert(2)\n// TypeScript: Type 'number' is not assignable to type 'Brand<number, \"even\">'\nconst bad: Even = 5\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\nBrands can be a great way to represent constraints that fall outside the scope TypeScript, but remember they don't change anything about what is enforced at runtime!\n\nFor more information on branding in general, check out [this excellent article](https://www.learningtypescript.com/articles/branded-types) from [Josh Goldberg](https://github.com/joshuakgoldberg).\n\n### Narrow\n\nNarrow expressions allow you to add custom validation logic and error messages. You can read more about them in [their intro section](/docs/intro/adding-constraints#narrow).\n\n<SyntaxTabs>\n    <SyntaxTab fluent>\n\n```ts\nconst Form = type({\n\tpassword: \"string\",\n\tconfirmPassword: \"string\"\n}).narrow((data, ctx) => {\n\tif (data.password === data.confirmPassword) {\n\t\treturn true\n\t}\n\treturn ctx.reject({\n\t\texpected: \"identical to password\",\n\t\t// don't display the password in the error message!\n\t\tactual: \"\",\n\t\tpath: [\"confirmPassword\"]\n\t})\n})\n\n// ArkErrors: confirmPassword must be identical to password\nconst out = Form({\n\tpassword: \"arktype\",\n\tconfirmPassword: \"artkype\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\nconst Form = type([\n\t{\n\t\tpassword: \"string\",\n\t\tconfirmPassword: \"string\"\n\t},\n\t\":\",\n\t(data, ctx) => {\n\t\tif (data.password === data.confirmPassword) {\n\t\t\treturn true\n\t\t}\n\t\treturn ctx.reject({\n\t\t\texpected: \"identical to password\",\n\t\t\t// don't display the password in the error message!\n\t\t\tactual: \"\",\n\t\t\tpath: [\"confirmPassword\"]\n\t\t})\n\t}\n])\n\n// ArkErrors: confirmPassword must be identical to password\nconst out = Form({\n\tpassword: \"arktype\",\n\tconfirmPassword: \"artkype\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab args>\n\n```ts\nconst Form = type(\n\t{\n\t\tpassword: \"string\",\n\t\tconfirmPassword: \"string\"\n\t},\n\t\":\",\n\t(data, ctx) => {\n\t\tif (data.password === data.confirmPassword) {\n\t\t\treturn true\n\t\t}\n\t\treturn ctx.reject({\n\t\t\texpected: \"identical to password\",\n\t\t\t// don't display the password in the error message!\n\t\t\tactual: \"\",\n\t\t\tpath: [\"confirmPassword\"]\n\t\t})\n\t}\n)\n\n// ArkErrors: confirmPassword must be identical to password\nconst out = Form({\n\tpassword: \"arktype\",\n\tconfirmPassword: \"artkype\"\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\nIf the return type of a narrow is a type predicate, that will be reflected in the inferred `Type`.\n\n<SyntaxTabs>\n    <SyntaxTab fluent>\n\n```ts\n// hover to see how the predicate is propagated to the outer `Type`\nconst ArkString = type(\"string\").narrow(\n\t(data, ctx): data is `ark${string}` =>\n\t\tdata.startsWith(\"ark\") ?? ctx.reject(\"a string starting with 'ark'\")\n)\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\n// hover to see how the predicate is propagated to the outer `Type`\nconst ArkString = type([\n\t\"string\",\n\t\":\",\n\t(data, ctx): data is `ark${string}` =>\n\t\tdata.startsWith(\"ark\") ?? ctx.reject(\"a string starting with 'ark'\")\n])\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab args>\n\n```ts\n// hover to see how the predicate is propagated to the outer `Type`\nconst ArkString = type(\n\t\"string\",\n\t\":\",\n\t(data, ctx): data is `ark${string}` =>\n\t\tdata.startsWith(\"ark\") ?? ctx.reject(\"a string starting with 'ark'\")\n)\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### Filter\n\n`filter` is similar to `narrow` but applies its predicate to the **input** of a type rather than the output. This distinction matters when your type includes morphs:\n\n- **`narrow`**: validates the **output** (after morphs have been applied)\n- **`filter`**: validates the **input** (before morphs run)\n\n```ts\nconst ShortNumeric = type(\"string.numeric.parse\").filter((s, ctx) => {\n\t// s is a string here (the input), not a number (the output)\n\tif (s.length > 10) return ctx.reject(\"at most 10 characters\")\n\treturn true\n})\n\n// the filter runs on the input (string) before the morph parses it\nShortNumeric(\"123\") // 123\nShortNumeric(\"12345678901\") // ArkErrors: must be at most 10 characters\n```\n\nIf the return type of a filter is a type predicate, that will be reflected in the inferred `Type`, just like with `narrow`.\n\n<AnchorAliases morph />\n### Pipe\n\nPiping allows you to transform your data after it is validated via one or more sequential **morphs**. You can read more about them in [their intro section](/docs/intro/morphs-and-more/).\n\n<SyntaxTabs>\n    <SyntaxTab fluent>\n\n```ts\n// hover to see how morphs are represented at a type-level\nconst trimStringStart = type(\"string\").pipe(str => str.trimStart())\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\n// hover to see how morphs are represented at a type-level\nconst trimStringStart = type([\"string\", \"=>\", str => str.trimStart()])\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab args>\n\n```ts\n// hover to see how morphs are represented at a type-level\nconst trimStringStart = type(\"string\", \"=>\", str => str.trimStart())\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n#### To\n\nIf a morph returns an `ArkErrors` instance, validation will fail with that result instead of it being treated as a value. This is especially useful for using other Types as morphs to validate output or chain transformations.\n\nTo make this easier, there's a special `to` operator that can pipe to a parsed definition without having to wrap it in `type` to make it a function:\n\n<SyntaxTabs>\n    <SyntaxTab string>\n\n```ts\nconst parseEvenTo = type(\"string.numeric.parse |> number % 2\")\n\nconst Even = type(\"number % 2\")\n// equivalent to parseEvenTo\nconst parseEvenPipe = type(\"string.numeric.parse\").pipe(Even)\n```\n\n    </SyntaxTab>\n    <SyntaxTab fluent>\n\n```ts\nconst parseEvenTo = type(\"string.numeric.parse\").to(\"number % 2\")\n\nconst Even = type(\"number % 2\")\n// equivalent to parseEvenTo\nconst parseEvenPipe = type(\"string.numeric.parse\").pipe(Even)\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\nconst parseEvenTo = type([\"string.numeric.parse\", \"|>\", \"number % 2\"])\n\nconst Even = type(\"number % 2\")\n// equivalent to parseEvenTo\nconst parseEvenPipe = type(\"string.numeric.parse\").pipe(Even)\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab args>\n\n```ts\nconst parseEvenTo = type(\"string.numeric.parse\", \"|>\", \"number % 2\")\n\nconst Even = type(\"number % 2\")\n// equivalent to parseEvenTo\nconst parseEvenPipe = type(\"string.numeric.parse\").pipe(Even)\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n<AnchorAliases pipe-n-ary />\n#### n-ary\n\nThough the fluent `.pipe(...morphsOrTypes)` method already accepts any number of arguments, `type.pipe()` allows you to define such an expression directly without having to explicitly instantiate the first input Type to chain from.\n\n```ts\n// directly accepts ...morphsOrTypes\nconst trimStartToNonEmpty = type.pipe(\n\ttype.string,\n\ts => s.trimStart(),\n\ttype.string.atLeastLength(1)\n)\n```\n\n### Unit\n\nWhile embedded [literal syntax](/docs/primitives#number-literals) is usually ideal for defining exact primitive values, `===` and `type.unit` can be helpful for referencing a non-serializable value like a `symbol` from your type.\n\n<SyntaxTabs>\n\n    <SyntaxTab fluent>\n\n```ts\nconst mySymbol = Symbol()\n\nconst ExactValue = type.unit(mySymbol)\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\nconst mySymbol = Symbol()\n\nconst ExactValue = type([\"===\", mySymbol])\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab args>\n\n```ts\nconst mySymbol = Symbol()\n\nconst ExactValue = type(\"===\", mySymbol)\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### Enumerated\n\n`type.enumerated` defines a Type based on a list of allowed values. It is semantically equivalent to `type.unit` if provided a single value.\n\n<SyntaxTabs>\n\n    <SyntaxTab fluent>\n\n```ts\nconst mySymbol = Symbol()\n\nconst ExactValueFromSet = type.enumerated(1337, true, mySymbol)\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\nconst mySymbol = Symbol()\n\nconst ExactValueFromSet = type([\"===\", 1337, true, mySymbol])\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab args>\n\n```ts\nconst mySymbol = Symbol()\n\nconst ExactValueFromSet = type(\"===\", 1337, true, mySymbol)\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### valueOf\n\n`type.valueOf` defines a Type from a TypeScript `enum` or enum-like object.\n\n<Callout\n\ttype=\"warn\"\n\ttitle=\"`enum` should be avoided in modern TypeScript\"\n>\n\nOver time, TS has shifted away from features that affect the `.js` it ultimately outputs, including `enum`.\n\nWith the introduction of the [`--erasableSyntaxOnly` option](https://www.typescriptlang.org/tsconfig/#erasableSyntaxOnly) to facilitate type-stripping, `enum` is no longer considered a best practice.\n\n`type.valueOf` exists primarily to facilitate integration with legacy code that relies on `enum`, but if you have the option, prefer transparently defining value sets via `[\"tupleLiterals\"] as const`, `{ objectLiterals: true } as const`, or directly via [`type.enumerated`](/docs/expressions#enumerated).\n\n</Callout>\n\n```ts\nenum TsEnum {\n\tnumeric = 1\n}\n\nconst EnumType = type.valueOf(TsEnum) // Type<1>\n```\n\nIt is _almost_ semantically identical to `type.enumerated(...Object.values(o))`. The only exception occurs when an object has an entry with a numeric value and entry with that value as a key mapping back to the original:\n\n```ts\n// this is the structure TsEnum compiles to in JS\nconst equivalentObject = {\n\tnumeric: 1,\n\t\"1\": \"numeric\"\n} as const\n\n// only allows the number 1 even though it is inferred\n// to also allow the string \"numeric\"\nconst EquivalentObject = type.valueOf(equivalentObject)\n```\n\nNotice `EquivalentObject` doesn't include `\"numeric\"` because it inverts a numeric value entry.\n\nWe recommend `type.enumerated` as the more transparent option for converting value references to a Type. However, if the described inverted entry pairs can't exist on your object, you can safely use `type.valueOf`.\n\n### fn\n\n`type.fn` defines a function with runtime-validated parameters and an optional return type. The result is a `TypedFn`- a callable with `.expression`, `.params`, and `.returns` for introspection.\n\nParameters are defined using the same syntax as tuple types. A return type can optionally be specified after a `\":\"` separator.\n\n```ts\n// @errors: 2345\nconst len = type.fn(\"string | unknown[]\", \":\", \"number\")(s => s.length)\n\nlen(\"foo\") // 3\nlen([1, 2]) // 2\n\nlen.expression // \"(string | Array) => number\"\n\nlen(true) // TraversalError: value at [0] must be a string or an object (was boolean)\n```\n\nSupports defaults, optionals, and variadic parameters:\n\n```ts\nconst greet = type.fn(\n\t\"string\",\n\t\"string = 'world'\"\n)((greeting, name) => `${greeting}, ${name}!`)\n\ngreet(\"Hello\") // \"Hello, world!\"\n\nconst maybeDouble = type.fn(\n\t\"number\",\n\t\"boolean?\"\n)((n, double) => (double ? n * 2 : n))\n\nmaybeDouble(5) // 5\nmaybeDouble(5, true) // 10\n\nconst join = type.fn(\n\t\"...\",\n\t\"string[]\",\n\t\":\",\n\t\"string\"\n)((...parts) => parts.join(\",\"))\n\njoin.expression // \"(...string[]) => string\"\n```\n\nIf no return type is specified, the return type is inferred from the implementation. If a return type is specified, it will be validated at runtime.\n\n### Meta\n\nMetadata allows you to associate arbitrary metadata with your types.\n\nSome metadata is consumed directly by ArkType, for example `description` is referenced by default when building an error message.\n\nOther properties are introspectable, but aren't used by default internally.\n\n<SyntaxTabs>\n    <SyntaxTab fluent>\n\n```ts\n// this validator's error message will now start with \"must be a special string\"\nconst SpecialString = type(\"string\").configure({\n\tdescription: \"a special string\"\n})\n\n// sugar for adding description metadata\nconst SpecialNumber = type(\"number\").describe(\"a special number\")\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\n// this validator's error message will now start with \"must be a special string\"\nconst SpecialString = type([\n\t\"string\",\n\t\"@\",\n\t{\n\t\tdescription: \"a special string\"\n\t}\n])\n\n// sugar for adding description metadata\nconst SpecialNumber = type([\"number\", \"@\", \"a special number\"])\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab args>\n\n```ts\n// this validator's error message will now start with \"must be a special string\"\nconst SpecialString = type(\"string\", \"@\", {\n\tdescription: \"a special string\"\n})\n\n// sugar for adding description metadata\nconst SpecialNumber = type(\"number\", \"@\", \"a special number\")\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\nFor more control over how to apply the config to the Type's internal structure, a `NodeSelector` can be specified following the config:\n\n<SyntaxTabs>\n    <SyntaxTab fluent>\n\n```ts\nconst SelectivelyConfigured = type({\n\tname: \"string\",\n\tage: \"number\"\n}).configure(\n\t{\n\t\tdescription: \"a special string\"\n\t},\n\t// add the description to all domain keywords\n\t\"domain\"\n)\n\nSelectivelyConfigured.get(\"name\").description // \"a special string\"\nSelectivelyConfigured.get(\"age\").description // \"a special string\"\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\nconst SelectivelyConfigured = type([\n\t{\n\t\tname: \"string\",\n\t\tage: \"number\"\n\t},\n\t\"@\",\n\t{\n\t\tdescription: \"a special string\"\n\t},\n\t// add the description to all domain keywords\n\t\"domain\"\n])\n\nSelectivelyConfigured.get(\"name\").description // \"a special string\"\nSelectivelyConfigured.get(\"age\").description // \"a special string\"\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab args>\n\n```ts\nconst SelectivelyConfigured = type(\n\t{\n\t\tname: \"string\",\n\t\tage: \"number\"\n\t},\n\t\"@\",\n\t{\n\t\tdescription: \"a special string\"\n\t},\n\t// add the description to all domain keywords\n\t\"domain\"\n)\n\nSelectivelyConfigured.get(\"name\").description // \"a special string\"\nSelectivelyConfigured.get(\"age\").description // \"a special string\"\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\nFor more details on the select API, [see the full docs](/docs/introspection#select).\n\n### Cast\n\nSometimes, you may want to directly specify how a `Type` should be inferred without affecting the runtime behavior. In these cases, you can use a cast expression.\n\n<SyntaxTabs>\n\n    <SyntaxTab string>\n\n```ts\n// allow any string, but suggest \"foo\" and \"bar\"\ntype AutocompletedString = \"foo\" | \"bar\" | (string & {})\n\nconst MyObj = type({\n\tautocompletedString: \"string\" as type.cast<AutocompletedString>\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\n// allow any string, but suggest \"foo\" and \"bar\"\ntype AutocompletedString = \"foo\" | \"bar\" | (string & {})\n\nconst MyObj = type({\n\tautocompletedString: type.string.as<AutocompletedString>()\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### Parenthetical\n\nBy default, ArkType's operators follow the same precedence as TypeScript's. Also like in TypeScript, this can be overridden by wrapping an expression in parentheses.\n\n```ts\n// hover to see the distinction!\nconst Groups = type({\n\tstringOrArrayOfNumbers: \"string | number[]\",\n\tarrayOfStringsOrNumbers: \"(string | number)[]\"\n})\n```\n\n### this\n\n`this` is a special keyword that can be used to create a recursive type referencing the root of the current definition.\n\n```ts\nconst DisappointingGift = type({\n\tlabel: \"string\",\n\t\"box?\": \"this\"\n})\n\nconst out = DisappointingGift({\n\tlabel: \"foo\",\n\tbox: { label: \"bar\", box: {} }\n})\n\nif (out instanceof type.errors) {\n\t// ArkErrors: box.box.label must be a string (was missing)\n\tconsole.error(out.summary)\n} else {\n\t// narrowed inference to arbitrary depth\n\tconsole.log(out.box?.box?.label)\n\t//                         ^?\n}\n```\n\nReferencing `this` from within a scope will result in a ParseError. For similar behavior within a scoped definition, just reference the alias by name:\n\n```ts\nconst types = scope({\n\tDisappointingGift: {\n\t\tlabel: \"string\",\n\t\t// Resolves correctly to the root of the current type\n\t\t\"box?\": \"DisappointingGift\"\n\t}\n}).export()\n```\n\n\n---\ntitle: FAQ\n---\n\n### Why do I see type errors in an ArkType package in `node_modules`?\n\nThis can occur due to incompatibilities between your `tsconfig.json` and ours. It is totally harmless as long as your types are correct in source.\n\nWe highly recommend enabling [`skipLibCheck`](https://www.typescriptlang.org/tsconfig/#skipLibCheck) in every TypeScript project to avoid false negatives like this and greatly improve editor performance.\n\n### Is there a way to create an async morph?\n\nOther than handling it as a promise on the output object, no.\n\nAs it stands, it doesn't seem worth the significant complexity it would add to morphs in the type system.\n\nIf you have a compelling use case, let us know on [this GitHub issue](https://github.com/arktypeio/arktype/issues/462).\n\n### What's up with your type/Type casing?\n\nYou might have noticed in our documentation we use PascalCase for some Types and camelCase for others:\n\n```ts\nconst User = type({\n\tname: \"string\",\n\tplatform: \"'android' | 'ios'\",\n\t\"version?\": \"number | string\"\n})\n\nconst parseJson = type(\"string.json.parse\").to({\n\tname: \"string\",\n\tversion: \"string.semver\"\n})\n```\n\nThis distinction actually evolved from the rules we use for casing our internal TypeScript types:\n\n- Use `PascalCase` for...\n  - Entities/non-generic types (e.g. `User`, `SomeData`)\n  - Generic types with noun names, like `Array<t>`. As a rule of thumb, your generic should be named this way if all its parameters have defaults (unfortunately TS's built-in `Array` type doesn't have a default parameter, but it probably should have been `unknown`!)\n\n- Use `camelCase` for...\n  - Generic types with verb names like `inferDomain<t>`. Types named this way should generally have at least one required parameter.\n  - Parameter names, e.g. `t` in `Array<t>`\n\nIf you don't like this, feel free to use whatever casing rules best suit your repo- it will not affect your Types or scope aliases in any way.\n\n### Why isn't my wrapper generic working?\n\nTypeScript generic inference is notoriously finicky. General patterns for wrapping Types and definitions are outlined [in the Generics docs](/docs/generics#external).\n\n<Callout\n\ttype=\"info\"\n\ttitle=\"If you want to write type-level logic, you need to cast.\"\n>\n\nWhen implementing a function with a generic return type, you will almost always need to cast in your implementation, either explicitly via `as` or by using an overload.\n\nThink of it as trading internal safety for external precision. As long as the function you're writing will be called many times externally, the overhead is justified. If not, it may not need to be generic at all- a broad return type like `string` as opposed to `${prefix}.${key}` may be sufficient.\n\n<details>\n\t<summary>See an example</summary>\n\n```ts\n// via explicit cast\nconst createBox = <const def>(\n\tof: type.validate<def>\n): type.instantiate<{ of: def }> =>\n\ttype.raw({\n\t\tbox: of\n\t\t// when implementing generics, never is your go-to\n\t\t// for allowing an arbitrary assignment with less risk than `any`\n\t}) as never\n\n// via overloads\n// only the external signatures are considered on invocation\nfunction createBox2<const def>(\n\tof: type.validate<def>\n): type.instantiate<{ of: def }>\n// the signature associated with the implementation is much looser and should\n// be thought of as equivalent to casting in terms of type safety\nfunction createBox2(of: unknown) {\n\treturn type.raw({\n\t\tbox: of\n\t})\n}\n```\n\nNotice in both cases, we've explicitly annotated the return type we want and used some method of casting internally to allow our implementation. This is a very common for implementing generic functions and, more generally, associating an implementation with typings TS can't infer on its own.\n\n</details>\n\n</Callout>\n\nFor anything more complex, you'll have to rely on your understanding of type manipulation to achieve the desired outcome. Tracing your way through ArkType's internal types may uncover helpful patterns, and you may even find friendly folks [in our Discord](https://arktype.io/discord) who may be willing to lend a hand.\n\nGenerally speaking however, **we cannot guarantee your generics will behave the way you expect**.\n\nWriting a good generic function can require understanding many complex details and edge cases- the kind of stuff our core API abstracts away.\n\nUnfortunately, when it comes to how ArkType integrates with external generics, that is not possible.\n\nGetting the results you want will take patience, but the DX ceiling for this kind of API is crazy high.\n\nIf we haven't scared you off by now, we're hyped to see what you build with it 🧗\n\n\n---\ntitle: Generics\n---\n\n### Keywords\n\nThis table includes all generic keywords available in default `type` API.\n\n<GenericKeywordTable />\n\n### Syntax\n\nGenerics can be declared and instantiated in one of three ways.\n\n#### Definition\n\n```ts\nimport { type } from \"arktype\"\n\nconst boxOf = type(\"<t>\", { box: \"t\" })\n\n// hover me!\nconst schrodingersBox = boxOf({ cat: { isAlive: \"boolean\" } })\n```\n\n#### Constrained Parameters\n\nAll syntax in parameters definitions and all references to generic args are fully-type safe and autocompleted like any built-in keyword. Constraints can be used just like TS to limit what can be passed to a generic and allow that arg to be used with operators like `>`.\n\n```ts\nimport { type } from \"arktype\"\n\nconst nonEmpty = type(\"<arr extends unknown[]>\", \"arr > 0\")\n\nconst nonEmptyNumberArray = nonEmpty(\"number[]\")\n```\n\n#### Scoped\n\nThere is a special syntax for specifying generics in a scope:\n\n```ts\nimport { scope } from \"arktype\"\n\nconst types = scope({\n\t\"box<t, u>\": {\n\t\tbox: \"t | u\"\n\t},\n\tbitBox: \"box<0, 1>\"\n}).export()\n\nconst out = types.bitBox({ box: 0 })\n```\n\n#### Invocation\n\n```ts\nimport { type } from \"arktype\"\n\nconst One = type(\"Extract<0 | 1, 1>\")\n```\n\n##### Chained\n\n```ts\nimport { type } from \"arktype\"\n\nconst User = type({\n\tname: \"string\",\n\t\"age?\": \"number\",\n\tisAdmin: \"boolean\"\n})\n\n// hover me!\nconst BasicUser = User.pick(\"name\", \"age\")\n```\n\n#### Invoked\n\n```ts\nimport { type } from \"arktype\"\n\nconst Unfalse = type.keywords.Exclude(\"boolean\", \"false\")\n```\n\n### HKT\n\nOur new generics have been built using a new method for integrating arbitrary external types as native ArkType generics! This opens up tons of possibilities for external integrations that would otherwise not be possible. As a preview, here's what the implementation of `Partial` looks like internally:\n\n```ts\nimport { generic, Hkt } from \"arktype\"\n\nconst Partial = generic([\"T\", \"object\"])(\n\targs => args.T.partial(),\n\tclass PartialHkt extends Hkt<[object]> {\n\t\tdeclare body: Partial<this[0]>\n\t}\n)\n```\n\nRecursive and cyclic generics are also currently unavailable and will be added soon.\n\nFor more usage examples, check out the unit tests for generics [here](https://github.com/arktypeio/arktype/blob/main/ark/type/__tests__/generic.test.ts).\n\n### External\n\nThe most basic pattern for wrapping a Type looks something like this:\n\n```ts\nconst createBox = <t extends string>(of: type.Any<t>) =>\n\ttype({\n\t\tbox: of\n\t})\n\n// @ts-expect-error\ncreateBox(type(\"number\"))\n\n// Type<{ box: string }>\nconst BoxType = createBox(type(\"string\"))\n```\n\nFor a deeper integration, you may wish to parse a definition directly:\n\n```ts\nconst createBox = <const def>(\n\tof: type.validate<def>\n): type.instantiate<{ of: def }> =>\n\ttype.raw({\n\t\tbox: of\n\t}) as never\n\n// Type<{ box: string }>\nconst BoxType = createBox(\"string\")\n```\n\nThe sky's the limit when it comes to this sort of integration, but be warned- TypeScript generics are notoriously finicky and [you may find APIs like these difficult to write if you're not used to it](/docs/faq#why-isnt-my-wrapper-generic-working).\n\n\n---\ntitle: Integrations\n---\n\n### Standard Schema\n\nArkType is proud to support and co-author the new [Standard Schema](https://github.com/standard-schema/standard-schema) API with [Valibot](https://github.com/fabian-hiller/valibot) and [Zod](https://github.com/colinhacks/zod).\n\nStandard Schema allows you and your dependencies to integrate library-agnostic validation logic. If you're building or maintaining a library with a peer dependency on ArkType and/or other validation libraries, we'd recommend consuming it through Standard Schema's API if possible so that your users can choose the solution that best suits their needs!\n\n#### As definitions\n\nAny Standard Schema compliant validator can also be passed directly to `type`, either at the top level or nested inside a structural definition, and will be fully inferred and validated:\n\n```ts\n// @noErrors\nimport { type } from \"arktype\"\nconst v = { number: () => \"number\" as const }\nconst z = {\n\tstring: () => \"string\" as const,\n\tobject: <shape extends Record<string, unknown>>(shape: shape) => shape\n}\n\nconst ZodAddress = z.object({\n\tstreet: z.string(),\n\tcity: z.string()\n})\n\nconst User = type({\n\tname: \"string\",\n\tage: v.number(),\n\taddress: ZodAddress\n})\n```\n\nThis makes ArkType a universal composition layer- mix and match validators from any ecosystem in a single definition.\n\n### JSON Schema\n\nArkType supports bidirectional conversion with JSON Schema.\n\n#### Type to JSON Schema\n\nEvery Type instance has a [`toJsonSchema()` method](/docs/type-api#tojsonschema) that generates a corresponding JSON Schema. See the [configuration docs](/docs/configuration#tojsonschema) for options including draft targets, fallback handlers, and cyclic type support.\n\n#### JSON Schema to Type\n\nThe `@ark/json-schema` package converts JSON Schema directly into ArkType Types:\n\n```ts\n// @noErrors\ndeclare const jsonSchemaToType: (schema: unknown) => unknown\n\nconst User = jsonSchemaToType({\n\ttype: \"object\",\n\tproperties: {\n\t\tname: { type: \"string\" },\n\t\tage: { type: \"integer\", minimum: 0 }\n\t},\n\trequired: [\"name\"]\n})\n// Type<{ name: string; age?: number }>\n```\n\nSee the [`@ark/json-schema` README](https://github.com/arktypeio/arktype/tree/main/ark/json-schema) for more details and limitations.\n\n### tRPC\n\nArkType can easily be used with tRPC:\n\n```ts\n// @noErrors\n// trpc >= 11 accepts a Type directly\nt.procedure.input(\n\ttype({\n\t\tname: \"string\",\n\t\t\"age?\": \"number\"\n\t})\n)\n\n// tRPC < 11 accepts the `.assert` prop\nt.procedure.input(\n\ttype({\n\t\tname: \"string\",\n\t\t\"age?\": \"number\"\n\t}).assert\n)\n```\n\n### drizzle\n\nDrizzle maintains an official [`drizzle-arktype` package](https://orm.drizzle.team/docs/arktype) that can be used to create Types for your Drizzle schemas.\n\n```ts\n// @noErrors\nimport { pgTable, text, integer } from \"drizzle-orm/pg-core\"\nimport { createSelectSchema } from \"drizzle-arktype\"\n\nconst users = pgTable(\"users\", {\n\tid: integer().generatedAlwaysAsIdentity().primaryKey(),\n\tname: text().notNull(),\n\tage: integer().notNull()\n})\n\n// Type<{ id: number; name: string; age: number }>\nconst User = createSelectSchema(users)\n```\n\n### react-hook-form\n\nreact-hook-form has built-in support for ArkType via [`@hookform/resolvers`](https://github.com/react-hook-form/resolvers/tree/master):\n\n```ts\n// @noErrors\nimport { useForm } from \"react-hook-form\"\nimport { arktypeResolver } from \"@hookform/resolvers/arktype\"\nimport { type } from \"arktype\"\n\nconst User = type({\n\tfirstName: \"string\",\n\tage: \"number.integer > 0\"\n})\n\n// in your component\nconst {\n\tregister,\n\thandleSubmit,\n\tformState: { errors }\n} = useForm({\n\tresolver: arktypeResolver(User)\n})\n```\n\nFor a custom controlled input, you can pass the inferred type into the hook itself:\n\n```ts\n// @noErrors\nuseForm<typeof User.infer>(/*...*/)\n```\n\n### hono\n\nHono has built-in support for ArkType via [`@hono/arktype-validator`](https://github.com/honojs/middleware/tree/main/packages/arktype-validator):\n\n```ts\n// @noErrors\nconst User = type({\n\tname: \"string\",\n\tage: \"number\"\n})\n\napp.post(\"/author\", arktypeValidator(\"json\", User), c => {\n\tconst data = c.req.valid(\"json\")\n\treturn c.json({\n\t\tsuccess: true,\n\t\tmessage: `${data.name} is ${data.age}`\n\t})\n})\n```\n\n[`hono-openapi`](https://github.com/rhinobase/hono-openapi) also offers experimental support for OpenAPI docgen.\n\n### oRPC\n\n[oRPC](https://orpc.unnoq.com/) has built-in support for Standard Schema, so ArkType works seamlessly right out of the box:\n\n```ts\n// @noErrors\nos.input(\n\ttype({\n\t\tname: \"string\",\n\t\t\"age?\": \"number\"\n\t})\n)\n```\n\n\n---\ntitle: Internal\n---\n\nTypes have an extremely powerful internal representation defined in `@ark/schema` that is primarily exposed through the `.internal` property on each Type.\n\nThough APIs under `.internal` are not officially frozen, they are stable enough that we want to start giving users more direct access to some of the introspection capabilities they provide.\n\n### Node kinds\n\nAll nodes have a `kind` property indicating their purpose, structure and special properties.\n\n#### Roots\n\nThe `kind` at the root of a Type will always be one of the following **root** kind.\n\n##### Bases\n\nThe simplest root nodes are defined by a single **basis** constraint.\n\nOnly a single basis can exist in an intersection. From widest to narrowest:\n\n<div className=\"overflow-auto\">\n\t<table className=\"w-full\">\n\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t<th>kind</th>\n\t\t\t\t<th>description</th>\n\t\t\t\t<th className=\"w-1/3\">example</th>\n\t\t\t</tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td>`domain`</td>\n\t\t\t\t<td>\n\t\t\t\t\tOne of 5 non-enumerable type sets (`string`, `number`, `object`, `bigint`, `symbol`)\n\t\t\t\t</td>\n\t\t\t\t<td>`{ domain: \"string\" }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`proto`</td>\n\t\t\t\t<td>\n\t\t\t\t\tA constructor checked by `instanceof` (implies domain `object`)\n\t\t\t\t</td>\n\t\t\t\t<td>`{ proto: Date }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`unit`</td>\n\t\t\t\t<td>\n\t\t\t\t\tAn exact value checked by `===` (can be intersected with any other constraint and reduced to itself or `never`)\n\t\t\t\t</td>\n\t\t\t\t<td>`{ unit: true }`</td>\n\t\t\t</tr>\n\t\t</tbody>\n\t</table>\n</div>\n\n##### Composites\n\nRoot kinds are built from references to other nodes.\n\nWill be normalized to appear in approximately the following hierarchical order:\n\n<div className=\"overflow-auto\">\n\t<table className=\"w-full\">\n\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t<th>kind</th>\n\t\t\t\t<th>description</th>\n\t\t\t\t<th className=\"w-1/3\">example</th>\n\t\t\t</tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td>`alias`</td>\n\t\t\t\t<td>Stores a cyclic reference to a node</td>\n\t\t\t\t<td>`{ reference: \"$name\" }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`union`</td>\n\t\t\t\t<td>\n\t\t\t\t\tA set of allowed nodes\n\t\t\t\t</td>\n\t\t\t\t<td>`{ branches: [\"string\", \"Array\"] }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`morph`</td>\n\t\t\t\t<td>\n\t\t\t\t\tOne or more transformations applied to valid data\n\t\t\t\t</td>\n\t\t\t\t<td>`{ in: \"string\", morphs: [(s) => s.trim()] }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`intersection`</td>\n\t\t\t\t<td>An intersection of constraints</td>\n\t\t\t\t<td>`{ domain: \"number\", divisor: 5 }`</td>\n\t\t\t</tr>\n\t\t</tbody>\n\t</table>\n</div>\n\n#### Constraints\n\nConstraint nodes exist on an `intersection` (or its `structure`) and narrow the set of values allowed by its [basis](#bases).\n\n##### Refinements\n\nPrimitive constraints that apply to the data shallowly.\n\n<div className=\"overflow-auto\">\n\t<table className=\"w-full\">\n\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t<th>kind</th>\n\t\t\t\t<th>impliedBasis</th>\n\t\t\t\t<th>description</th>\n\t\t\t\t<th className=\"w-1/3\">example</th>\n\t\t\t</tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td>`divisor`</td>\n\t\t\t\t<td>`number`</td>\n\t\t\t\t<td>Multiple of the specified integer</td>\n\t\t\t\t<td>`{ rule: 2 }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`pattern`</td>\n\t\t\t\t<td>`string`</td>\n\t\t\t\t<td>Matched by a regex</td>\n\t\t\t\t<td>`{ rule: \"^[a-z]+$\" }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`min`</td>\n\t\t\t\t<td>`number`</td>\n\t\t\t\t<td>Numeric minimum (inclusive by default)</td>\n\t\t\t\t<td>`{ rule: 0, exclusive: true }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`max`</td>\n\t\t\t\t<td>`number`</td>\n\t\t\t\t<td>Numeric maximum (inclusive by default)</td>\n\t\t\t\t<td>`{ rule: 100 }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`minLength`</td>\n\t\t\t\t<td>`string | Array`</td>\n\t\t\t\t<td>Inclusive minimum length</td>\n\t\t\t\t<td>`{ rule: 1 }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`maxLength`</td>\n\t\t\t\t<td>`string | Array`</td>\n\t\t\t\t<td>Inclusive maximum length</td>\n\t\t\t\t<td>`{ rule: 255 }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`exactLength`</td>\n\t\t\t\t<td>`string | Array`</td>\n\t\t\t\t<td>Exact length</td>\n\t\t\t\t<td>`{ rule: 10 }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`after`</td>\n\t\t\t\t<td>`Date`</td>\n\t\t\t\t<td>Minimum Date (inclusive by default)</td>\n\t\t\t\t<td>`{ rule: new Date(\"2000-01-01\") }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`before`</td>\n\t\t\t\t<td>`Date`</td>\n\t\t\t\t<td>Maximum Date (inclusive by default)</td>\n\t\t\t\t<td>`{ rule: new Date() }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`predicate`</td>\n\t\t\t\t<td>`unknown`</td>\n\t\t\t\t<td>Custom `narrow` function</td>\n\t\t\t\t<td>`{ predicate: (n) => n % 2 === 1 }`</td>\n\t\t\t</tr>\n\t\t</tbody>\n\t</table>\n</div>\n\n##### Structural\n\nThese constraints define the shape and properties of objects or arrays.\n\n<div className=\"overflow-auto\">\n\t<table className=\"w-full\">\n\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t<th>kind</th>\n\t\t\t\t<th>description</th>\n\t\t\t\t<th className=\"w-1/3\">example</th>\n\t\t\t</tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td>`sequence`</td>\n\t\t\t\t<td>\n\t\t\t\t\tDefines array patterns with tuples, rest elements, and variadic parts\n\t\t\t\t</td>\n\t\t\t\t<td>`{ sequence: { prefix: [\"string\", \"number\"] } }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`required`</td>\n\t\t\t\t<td>Defines a required property in an object structure</td>\n\t\t\t\t<td>`{ key: \"id\", value: \"number\" }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`optional`</td>\n\t\t\t\t<td>Defines an optional property in an object structure</td>\n\t\t\t\t<td>`{ key: \"name\", value: \"string\" }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`index`</td>\n\t\t\t\t<td>\n\t\t\t\t\tDefines index signatures for objects (\n\t\t\t\t\t`[key: string]: value`)\n\t\t\t\t</td>\n\t\t\t\t<td>`{ key: \"string\", value: \"boolean\" }`</td>\n\t\t\t</tr>\n\t\t</tbody>\n\t</table>\n</div>\n\nMore details on the type system to come!\n\n#### select\n\n<Callout type=\"warn\" title=\"select is not fully stable!\">\n\n`select` relies on the internal representation defined in `@ark/schema`, which although relatively mature, is not guaranteed semver-stable.\n\n</Callout>\n\n`select` is the top-level first method we're introducing for interacting with a Type based on its internal representation.\n\nIt can be used to filter a Type's references:\n\n```ts\nconst T = type({\n\tname: \"string > 5\",\n\tflag: \"0 | 1\"\n})\n\t.array()\n\t.atLeastLength(1)\n\n// get all references representing literal values\nconst literals = T.select(\"unit\") // [Type<0>, Type<1>]\n\n// get all references representing literal positive numbers\nconst positiveNumberLiterals = T.select({\n\tkind: \"unit\",\n\twhere: u => typeof u.unit === \"number\" && u.unit > 0\n}) // [Type<1>]\n\n// get all minLength constraints at the root of the Type\nconst minLengthConstraints = T.select({\n\tkind: \"minLength\",\n\t// the shallow filter excludes the constraint on `name`\n\tboundary: \"shallow\"\n}) // [MinLengthNode<1>]\n```\n\n\n---\ntitle: Adding Constraints\n---\n\nTypeScript is extremely versatile for representing types like `string` or `number`, but what about `email` or `integer less than 100`?\n\nIn ArkType, conditions that narrow a type beyond its **basis** are called **constraints**.\n\nConstraints are a first-class citizen of ArkType. They are fully composable with TypeScript's built-in operators and governed by the same underlying principles of set-theory.\n\n## Define\n\nLet's create a new `contact` Type that enforces our example constraints.\n\n```ts\nconst Contact = type({\n\t// many common constraints are available as built-in keywords\n\temail: \"string.email\",\n\t// others can be written as type-safe expressions\n\tscore: \"number.integer < 100\"\n})\n\n// if you need the TS type, just infer it out as normal\ntype Contact = typeof Contact.infer\n```\n\n## Compose\n\nImagine we want to define a new Type representing a non-empty list of `Contact`.\n\nWhile the expression syntax we've been using is ideal for creating new types, chaining is a great way to refine or transform existing ones.\n\n```ts\nconst _Contact = type({\n\temail: \"string.email\",\n\tscore: \"number.integer < 100\"\n})\n\ntype _Contact = typeof _Contact.t\n\ninterface Contact extends _Contact {}\n\nexport const Contact: type<Contact> = _Contact\n// ---cut-start---\n// a non-empty list of Contact\n// ---cut-end---\nconst Contacts = Contact.array().atLeastLength(1)\n```\n\n## Narrow\n\nStructured constraints like divisors and ranges will only take us so far. Luckily, they integrate seamlessly with whatever custom validation logic you need.\n\n```ts\ninterface RuntimeErrors extends type.errors {\n\t/**even must be even (was 7)\nodd must be odd (was 8)*/\n\tsummary: string\n}\n\nconst narrowMessage = (e: type.errors): e is RuntimeErrors => true\n// ---cut---\n\n// there's no \"not divisible\" expression - need to narrow\nconst Odd = type(\"number\").narrow((n, ctx) =>\n\t// if even, add a customizable error and return false\n\tn % 2 === 0 ? ctx.mustBe(\"odd\") : true\n)\n\nconst FavoriteNumbers = type({\n\teven: \"number % 2\",\n\todd: Odd\n})\n\nconst out = FavoriteNumbers({\n\teven: 7,\n\todd: 8\n})\n\nif (out instanceof type.errors) {\n\t// ---cut-start---\n\tif (!narrowMessage(out)) throw new Error()\n\t// ---cut-end---\n\t// hover summary to see validation errors\n\tconsole.error(out.summary)\n} else {\n\tconsole.log(out.odd)\n}\n```\n\nYou now know how to refine your types to enforce additional constraints at runtime.\n\nBut what if once your input is fully validated, you still need to make some adjustments before it's ready to use?\n\nThe final section of intro will cover **morphs**, an extremely powerful tool for composing and transforming Types.\n\n\n---\ntitle: Morphs & More\n---\n\nSometimes, data at the boundaries of your code requires more than validation before it's ready to use.\n\n**Morphs** allow you to arbitrarily transform the shape and format of your data.\n\nMorphs can be **piped** before, after or between validators and even chained to other morphs.\n\n```ts\n// Hover to see the type-level representation\nconst parseJson = type(\"string\").pipe((s): object => JSON.parse(s))\n\n// object: { ark: \"type\" }\nconst out = parseJson('{ \"ark\": \"type\" }')\n\n// ArkErrors: must be a string (was object)\nconst badOut = parseJson(out)\n```\n\nThis is a good start, but there are still a couple major issues with our morph.\n\nWhat happens if we pass a string that isn't valid JSON?\n\n```ts\nconst parseJson = type(\"string\").pipe((s): object => JSON.parse(s))\n// ---cut---\n\n// Uncaught SyntaxError: Expected property name ☠️ // [!code error]\nconst badOut = parseJson('{ unquoted: \"keys\" }')\n```\n\nDespite what `JSON.parse` might have you believe, throwing exceptions and returning `any` are not very good ways to parse a string. By default, ArkType assumes that if one of your morphs or narrows throws, you intend to crash.\n\nIf you do happen to find yourself at the mercy of an unsafe API, you might consider wrapping your function body in a `try...catch`.\n\nLuckily, there is a built-in API for wrapping `pipe`d functions you don't trust:\n\n```ts\nconst parseJson = type(\"string\").pipe.try((s): object => JSON.parse(s))\n\n// Now returns an introspectable error instead of crashing 🎉\nconst badOut = parseJson('{ unquoted: \"keys\" }')\n\nconst out = parseJson('{ \"ark\": \"type\" }')\n\nif (out instanceof type.errors) out.throw()\n// Unfortunately, a validated `object` still isn't very useful...\nelse console.log(out)\n```\n\nThe best part about `pipe` is that since any `Type` is root-invokable, `Type`s themselves _are_ already morphs! This means validating out parsed output is as easy as adding another pipe:\n\n```ts\nconst parseJson = type(\"string\").pipe.try(\n\t(s): object => JSON.parse(s),\n\ttype({\n\t\tname: \"string\",\n\t\tversion: \"string.semver\"\n\t})\n)\n\nconst out = parseJson('{ \"name\": \"arktype\", \"version\": \"2.0.0\" }')\n\nif (!(out instanceof type.errors)) {\n\t// Logs \"arktype:2.0.0\"\n\tconsole.log(`${out.name}:${out.version}`)\n}\n```\n\nAt this point, our implementation is starting to look pretty clean, but in many cases like this one, we can skip straight to the punch line with one of ArkType's many built-in aliases for validation and parsing, `string.json.parse`:\n\n```ts\ninterface RuntimeErrors extends type.errors {\n\t/**name must be a string (was true) \nversion must be a semantic version (see https://semver.org/) (was \"v2.0.0\")*/\n\tsummary: string\n}\n\nconst narrowMessage = (e: type.errors): e is RuntimeErrors => true\n\n// ---cut---\n// .to is a sugared .pipe for a single parsed output validator\nconst parseJson = type(\"string.json.parse\").to({\n\tname: \"string\",\n\tversion: \"string.semver\"\n})\n\nconst out = parseJson('{ \"name\": true, \"version\": \"v2.0.0\" }')\n\nif (out instanceof type.errors) {\n\t// ---cut-start---\n\tif (!narrowMessage(out)) throw new Error()\n\t// ---cut-end---\n\t// hover out.summary to see the default error message\n\tconsole.error(out.summary)\n}\n```\n\nIf you've made it this far, congratulations! You should have all the fundamental intuitions you need to bring your types to runtime ⛵\n\nOur remaining docs will help you understand the trade offs between ArkType's most important APIs so that no matter the application, you can find a solution that feels great to write, great to read, and great to run.\n\n\n---\ntitle: Setup\n---\n\n## Installation\n\n<InstallationTabs />\n\nYou'll also need...\n\n- TypeScript version `>=5.1`.\n- A `package.json` with `\"type\": \"module\"` (or an environment that supports ESM imports)\n- A `tsconfig.json` with...\n  - [`strict`](https://www.typescriptlang.org/tsconfig#strict) or [`strictNullChecks`](https://www.typescriptlang.org/tsconfig#strictNullChecks) (**required**)\n  - [`skipLibCheck`](https://www.typescriptlang.org/tsconfig#skipLibCheck) (strongly recommended, see [FAQ](/docs/faq#why-do-i-see-type-errors-in-an-arktype-package-in-node_modules))\n  - [`exactOptionalPropertyTypes`](https://www.typescriptlang.org/tsconfig#exactOptionalPropertyTypes) (recommended)\n\n## VSCode\n\n### Settings\n\nTo take advantage of all of ArkType's autocomplete capabilities, you'll need to add the following to your workspace settings at `.vscode/settings.json`:\n\n```json\n// allow autocomplete for ArkType expressions like \"string | num\"\n\"editor.quickSuggestions\": {\n\t\"strings\": \"on\"\n},\n// prioritize ArkType's \"type\" for autoimports\n\"typescript.preferences.autoImportSpecifierExcludeRegexes\": [\n\t\"^(node:)?os$\"\n],\n```\n\n### Extension (optional)\n\n[ArkDark](https://marketplace.visualstudio.com/items?itemName=arktypeio.arkdark) provides the embedded syntax highlighting you'll see throughout the docs.\n\nWithout it, your definitions can still feel like a natural extension of the language.\n\nWith it, you'll forget there was ever a boundary in the first place.\n\n## JetBrains IDEs\n\n### Extension (optional)\n\n[ArkType](https://plugins.jetbrains.com/plugin/27099-arktype) provides the embedded syntax highlighting you are familiar with for typescript types.\n\n## Other editors\n\nIf you're using a different editor, we'd love [help adding support](https://github.com/arktypeio/arktype/issues/989). In the meantime, don't worry- ArkType still offers best-in-class DX anywhere TypeScript is supported.\n\n\n---\ntitle: Your First Type\n---\n\nIf you already know TypeScript, congratulations- you just learned most of ArkType's syntax 🎉\n\n## Define\n\n```ts\nimport { type } from \"arktype\"\n\nconst User = type({\n\tname: \"string\",\n\tplatform: \"'android' | 'ios'\",\n\t\"versions?\": \"(number | string)[]\"\n})\n\n// extract the type if needed\ntype User = typeof User.infer\n```\n\nIf you make a mistake, don't worry- every definition gets the autocomplete and validation you're used to from your editor, all within TypeScript's type system.\n\n<Callout title=\"Will ArkType crash my TypeScript server?\">\n\tThousands of hours of optimization have gone into making validating native\n\ttype syntax not just feasible, but often much faster than alternatives ⚡\n</Callout>\n\n## Compose\n\nSuppose we want to move `platform` and `versions` from our original type to a new `device` property.\n\n```ts\nconst User = type({\n\tname: \"string\",\n\t// nested definitions don't need to be wrapped\n\tdevice: {\n\t\tplatform: \"'android' | 'ios'\",\n\t\t\"versions?\": \"(number | string)[]\"\n\t}\n})\n```\n\nTo decouple `device` from `User`, just move it to its own type and reference it.\n\n```ts\nconst Device = type({\n\tplatform: \"'android' | 'ios'\",\n\t\"versions?\": \"(number | string)[]\"\n})\n\nconst User = type({\n\tname: \"string\",\n\tdevice: Device\n})\n```\n\n## Validate\n\nAt runtime, we can pass `unknown` data to our type and get back either a validated `User` or an array of clear, customizable errors with a root `summary`.\n\n```ts\nconst User = type({\n\tname: \"string\",\n\tdevice: {\n\t\tplatform: \"'android' | 'ios'\",\n\t\t\"versions?\": \"(number | string)[]\"\n\t}\n})\n\ninterface RuntimeErrors extends type.errors {\n\t/**device.platform must be \"android\" or \"ios\" (was \"enigma\")\ndevice.versions[2] must be a number or a string (was bigint)*/\n\tsummary: string\n}\n\nconst narrowMessage = (e: type.errors): e is RuntimeErrors => true\n\n// ---cut---\nconst out = User({\n\tname: \"Alan Turing\",\n\tdevice: {\n\t\tplatform: \"enigma\",\n\t\tversions: [0, \"1\", 0n]\n\t}\n})\n\nif (out instanceof type.errors) {\n\t// ---cut-start---\n\t// just a trick to display the runtime error\n\tif (!narrowMessage(out)) throw new Error()\n\t// ---cut-end---\n\t// hover out.summary to see validation errors\n\tconsole.error(out.summary)\n} else {\n\t// hover out to see your validated data\n\tconsole.log(`Hello, ${out.name}`)\n}\n```\n\nAnd that's it! You now know how to define a `Type` and use it to check your data at runtime.\n\nNext, we'll take a look at how ArkType extends TypeScript's type system to handle runtime constraints like `maxLength` and `pattern`.\n\n\n---\ntitle: Introspection\n---\n\nTypes have an extremely powerful internal representation defined in `@ark/schema` that is primarily exposed through the `.internal` property on each Type.\n\nThough APIs under `.internal` are not officially frozen, they are stable enough that we want to start giving users more direct access to some of the introspection capabilities they provide.\n\n### Node kinds\n\nAll nodes have a `kind` property indicating their purpose, structure and special properties.\n\n#### Roots\n\nThe `kind` at the root of a Type will always be one of the following **root** kind.\n\n##### Bases\n\nThe simplest root nodes are defined by a single **basis** constraint.\n\nOnly a single basis can exist in an intersection. From widest to narrowest:\n\n<div className=\"overflow-auto\">\n\t<table className=\"w-full\">\n\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t<th>kind</th>\n\t\t\t\t<th>description</th>\n\t\t\t\t<th className=\"w-1/3\">example</th>\n\t\t\t</tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td>`domain`</td>\n\t\t\t\t<td>\n\t\t\t\t\tOne of 5 non-enumerable type sets (`string`, `number`, `object`, `bigint`, `symbol`)\n\t\t\t\t</td>\n\t\t\t\t<td>`{ domain: \"string\" }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`proto`</td>\n\t\t\t\t<td>\n\t\t\t\t\tA constructor checked by `instanceof` (implies domain `object`)\n\t\t\t\t</td>\n\t\t\t\t<td>`{ proto: Date }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`unit`</td>\n\t\t\t\t<td>\n\t\t\t\t\tAn exact value checked by `===` (can be intersected with any other constraint and reduced to itself or `never`)\n\t\t\t\t</td>\n\t\t\t\t<td>`{ unit: true }`</td>\n\t\t\t</tr>\n\t\t</tbody>\n\t</table>\n</div>\n\n##### Composites\n\nRoot kinds are built from references to other nodes.\n\nWill be normalized to appear in approximately the following hierarchical order:\n\n<div className=\"overflow-auto\">\n\t<table className=\"w-full\">\n\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t<th>kind</th>\n\t\t\t\t<th>description</th>\n\t\t\t\t<th className=\"w-1/3\">example</th>\n\t\t\t</tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td>`alias`</td>\n\t\t\t\t<td>Stores a cyclic reference to a node</td>\n\t\t\t\t<td>`{ reference: \"$name\" }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`union`</td>\n\t\t\t\t<td>\n\t\t\t\t\tA set of allowed nodes\n\t\t\t\t</td>\n\t\t\t\t<td>`{ branches: [\"string\", \"Array\"] }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`morph`</td>\n\t\t\t\t<td>\n\t\t\t\t\tOne or more transformations applied to valid data\n\t\t\t\t</td>\n\t\t\t\t<td>`{ in: \"string\", morphs: [(s) => s.trim()] }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`intersection`</td>\n\t\t\t\t<td>An intersection of constraints</td>\n\t\t\t\t<td>`{ domain: \"number\", divisor: 5 }`</td>\n\t\t\t</tr>\n\t\t</tbody>\n\t</table>\n</div>\n\n#### Constraints\n\nConstraint nodes exist on an `intersection` (or its `structure`) and narrow the set of values allowed by its [basis](#bases).\n\n##### Refinements\n\nConstraints that apply directly to the root of an intersection (includes the base `structure` node but not [its children](#structural)).\n\n<div className=\"overflow-auto\">\n\t<table className=\"w-full\">\n\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t<th>kind</th>\n\t\t\t\t<th>impliedBasis</th>\n\t\t\t\t<th>description</th>\n\t\t\t\t<th className=\"w-1/3\">example</th>\n\t\t\t</tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td>`divisor`</td>\n\t\t\t\t<td>`number`</td>\n\t\t\t\t<td>Multiple of the specified integer</td>\n\t\t\t\t<td>`{ rule: 2 }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`pattern`</td>\n\t\t\t\t<td>`string`</td>\n\t\t\t\t<td>Matched by a regex</td>\n\t\t\t\t<td>`{ rule: \"^[a-z]+$\" }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`min`</td>\n\t\t\t\t<td>`number`</td>\n\t\t\t\t<td>Numeric minimum (inclusive by default)</td>\n\t\t\t\t<td>`{ rule: 0, exclusive: true }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`max`</td>\n\t\t\t\t<td>`number`</td>\n\t\t\t\t<td>Numeric maximum (inclusive by default)</td>\n\t\t\t\t<td>`{ rule: 100 }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`minLength`</td>\n\t\t\t\t<td>`string | Array`</td>\n\t\t\t\t<td>Inclusive minimum length</td>\n\t\t\t\t<td>`{ rule: 1 }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`maxLength`</td>\n\t\t\t\t<td>`string | Array`</td>\n\t\t\t\t<td>Inclusive maximum length</td>\n\t\t\t\t<td>`{ rule: 255 }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`exactLength`</td>\n\t\t\t\t<td>`string | Array`</td>\n\t\t\t\t<td>Exact length</td>\n\t\t\t\t<td>`{ rule: 10 }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`after`</td>\n\t\t\t\t<td>`Date`</td>\n\t\t\t\t<td>Minimum Date (inclusive by default)</td>\n\t\t\t\t<td>`{ rule: new Date(\"2000-01-01\") }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`before`</td>\n\t\t\t\t<td>`Date`</td>\n\t\t\t\t<td>Maximum Date (inclusive by default)</td>\n\t\t\t\t<td>`{ rule: new Date() }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`predicate`</td>\n\t\t\t\t<td>`unknown`</td>\n\t\t\t\t<td>Custom `narrow` function</td>\n\t\t\t\t<td>`{ predicate: (n) => n % 2 === 1 }`</td>\n\t\t\t</tr>\n\t\t</tbody>\n\t</table>\n</div>\n\n##### Structural\n\nThese constraints refine a `structure` node, defining the shape of properties and/or array elements.\n\n<div className=\"overflow-auto\">\n\t<table className=\"w-full\">\n\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t<th>kind</th>\n\t\t\t\t<th>description</th>\n\t\t\t\t<th className=\"w-1/3\">example</th>\n\t\t\t</tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td>`sequence`</td>\n\t\t\t\t<td>Array/tuple shape</td>\n\t\t\t\t<td>`{ prefix: [\"string\"], variadic: \"number\" }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`required`</td>\n\t\t\t\t<td>Required object property</td>\n\t\t\t\t<td>`{ key: \"id\", value: \"number\" }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`optional`</td>\n\t\t\t\t<td>Optional object property</td>\n\t\t\t\t<td>`{ key: \"name\", value: \"string\" }`</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>`index`</td>\n\t\t\t\t<td>Properties allowed by `signature` must conform to `value`</td>\n\t\t\t\t<td>`{ signature: \"string\", value: \"boolean\" }`</td>\n\t\t\t</tr>\n\t\t</tbody>\n\t</table>\n</div>\n\nMore details on the type system to come!\n\n### select\n\n<Callout type=\"warn\" title=\"select is not fully stable!\">\n\n`select` relies on the internal representation defined in `@ark/schema`, which although relatively mature, is not guaranteed semver-stable.\n\n</Callout>\n\n`select` is the top-level first method we're introducing for interacting with a Type based on its internal representation.\n\nIt can be used to filter a Type's references:\n\n```ts\nconst T = type({\n\tname: \"string > 5\",\n\tflag: \"0 | 1\"\n})\n\t.array()\n\t.atLeastLength(1)\n\n// get all references representing literal values\nconst literals = T.select(\"unit\") // [Type<0>, Type<1>]\n\n// get all references representing literal positive numbers\nconst positiveNumberLiterals = T.select({\n\tkind: \"unit\",\n\twhere: u => typeof u.unit === \"number\" && u.unit > 0\n}) // [Type<1>]\n\n// get all minLength constraints at the root of the Type\nconst minLengthConstraints = T.select({\n\tkind: \"minLength\",\n\t// the shallow filter excludes the constraint on `name`\n\tboundary: \"shallow\"\n}) // [MinLengthNode<1>]\n```\n\nThis can be used directly or in combination with the [`configure` API](/docs/expressions#meta) for fine-grained control over which nodes to modify.\n\n\n---\ntitle: Keywords\n---\n\n### TypeScript\n\n<div>All\\* built-in TypeScript keywords are directly available.</div>\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n```ts\nconst Keywords = type({\n\tstring: \"string\",\n\tdate: \"Date\"\n})\n```\n\t</SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Keywords = type({\n\tstring: type.string,\n\tdate: type.Date\n})\n```\n\nCommon keywords are exposed directly on `type`.\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n<sup>\n\t\\* `any` and `void` are misleading and unnecessary for runtime validation and\n\tso are not included as keywords by default.\n</sup>\n\n### Subtype\n\nSubtype keywords refine or transform their root type.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n```ts\nconst Keywords = type({\n\tdateFormattedString: \"string.date\",\n\ttransformStringToDate: \"string.date.parse\",\n\tisoFormattedString: \"string.date.iso\",\n\ttransformIsoFormattedStringToDate: \"string.date.iso.parse\"\n})\n```\n\nYou can easily explore available subtypes via autocomplete by with a partial definition like `\"string.\"`.\n\n</SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Keywords = type({\n\tdateFormattedString: type.keywords.string.date.root,\n\tisoFormattedString: type.keywords.string.date.iso.root,\n\ttransformStringToDate: type.keywords.string.date.parse,\n\ttransformIsoFormattedStringToDate: type.keywords.string.date.iso.parse\n})\n```\n\nAll built-in keywords and modules are available in `type.keywords`.\n\n`.root` gets the base type of a subtyped module so that it can be used as a `Type` directly.\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### All Keywords\n\nThis table includes all keywords available in default `type` API. To define your own string-embeddable keywords, see [scopes](/docs/scopes).\n\n<AllKeywordTables />\n\n\n---\ntitle: Match\n---\n\nThe `match` function provides a powerful way to handle different types of input and return corresponding outputs based on the input type, like a type-safe `switch` statement.\n\n## Case Record API\n\nThe simplest way to define a matcher is with ArkType definition strings as keys with corresponding handlers as values:\n\n```ts\nimport { match } from \"arktype\"\n\nconst sizeOf = match({\n\t\"string | Array\": v => v.length,\n\tnumber: v => v,\n\tbigint: v => v,\n\tdefault: \"assert\"\n})\n\n// a match definition is complete once a `default` has been specified,\n// either as a case or via the .default() method\n\nsizeOf(\"abc\") // 3\nsizeOf([1, 2, 3, 4]) // 4\nsizeOf(5n) // 5n\n// TraversalError: must be a string or an object (was boolean)\nsizeOf(true)\n```\n\nIn this example, `sizeOf` is a matcher that takes a string, array, number, or bigint as input. It returns the length of strings and arrays, and the value of numbers and bigints.\n\n`default` accepts one of 4 values:\n\n- `\"assert\"`: accept `unknown`, throw if none of the cases match\n- `\"never\"`: accept an input based on inferred cases, throw if none match\n- `\"reject\"`: accept `unknown`, return `ArkErrors` if none of the cases match\n- `(data: In) => unknown`: handle data not matching other cases directly\n\nCases will be checked in the order they are specified, either as object literal keys or via chained methods.\n\n## Fluent API\n\nThe `match` function also provides a fluent API. This can be convenient for non-string-embeddable definitions:\n\n```ts\nimport { match } from \"arktype\"\n\n// the Case Record and Fluent APIs can be easily combined\nconst sizeOf = match({\n\tstring: v => v.length,\n\tnumber: v => v,\n\tbigint: v => v\n})\n\t// match any object with a numeric length property and extract it\n\t.case({ length: \"number\" }, o => o.length)\n\t// return 0 for all other data\n\t.default(() => 0)\n\nsizeOf(\"abc\") // 3\nsizeOf({ name: \"David\", length: 5 }) // 5\nsizeOf(null) // 0\n```\n\n## Narrowing input with `in`, property matching with `at`\n\n```ts\n// @errors: 2345\nimport { match } from \"arktype\"\n\ntype Data =\n\t| {\n\t\t\tid: 1\n\t\t\toneValue: number\n\t  }\n\t| {\n\t\t\tid: 2\n\t\t\ttwoValue: string\n\t  }\n\nconst discriminateValue = match\n\t// .in allows you to specify the input TypeScript allows for your matcher\n\t.in<Data>()\n\t// .at allows you to specify a key at which your input will be matched\n\t.at(\"id\")\n\t.match({\n\t\t1: o => `${o.oneValue}!`,\n\t\t2: o => o.twoValue.length,\n\t\tdefault: \"assert\"\n\t})\n\ndiscriminateValue({ id: 1, oneValue: 1 }) // \"1!\"\ndiscriminateValue({ id: 2, twoValue: \"two\" }) // 3\ndiscriminateValue({ oneValue: 3 })\n```\n\n\n---\ntitle: Objects\n---\n\n## properties\n\nObjects definitions can include any combination of required, optional, defaultable named properties and index signatures.\n\n### required [#properties-required]\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst symbolicKey = Symbol()\n\nconst MyObj = type({\n\trequiredKey: \"string\",\n\t// Nested definitions don't require additional `type` calls!\n\t[symbolicKey]: {\n\t\tnested: \"unknown\"\n\t}\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst symbolicKey = Symbol()\n\nconst MyObj = type({\n\trequiredKey: type.string,\n\t// Nested definitions don't require additional `type` calls!\n\t[symbolicKey]: {\n\t\tnested: type.unknown\n\t}\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### optional [#properties-optional]\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst symbolicKey = Symbol()\n\nconst MyObj = type({\n\t\"optionalKey?\": \"number[]\",\n\t[symbolicKey]: \"string?\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst symbolicKey = Symbol()\n\nconst MyObj = type({\n\toptionalKey: type.number.array().optional(),\n\t[symbolicKey]: type.string.optional()\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\nconst symbolicKey = Symbol()\n\nconst MyObj = type({\n\toptionalKey: [{ type: \"'script'\" }, \"?\"],\n\t[symbolicKey]: [{ ark: \"'type'\" }, \"?\"]\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n<Callout type=\"info\" title=\"Should I use key or value syntax for optionality?\">\n\n    Optionality can either be expressed on the key or the corresponding value.\n\n    We recommend using the key syntax by default because...\n\n    - it mirrors TypeScript\n    - it better reflects a _key presence_ constraint that has no effect on allowed values\n\n    However, there are a few reasons you might want to use a value-embedded syntax:\n\n    1. The key is a symbol (makes key-embedded syntax impossible)\n    2. You want editor features like JSDoc and go-to-definition for the key (can't work if the key name changes)\n    3. You really hate having to quote key names\n\n</Callout>\n\n<Callout type=\"warn\" title=\"Optional properties cannot be present with the value undefined\">\n\n    In TypeScript, there is a setting called [`exactOptionalPropertyTypes`](https://www.typescriptlang.org/tsconfig#exactOptionalPropertyTypes) that can be set to `true` to enforce the distinction between properties that are missing and properties that are present with the value `undefined`.\n\n    ArkType mirrors this behavior by default, so if you want to allow `undefined`, you'll need to add it to your value's definition. Though not recommended as a long-term solution, you may also [globally configure `exactOptionalPropertyTypes`](/docs/configuration#exactoptionalpropertytypes) to `false`.\n\n    <details>\n    \t<summary>See an example</summary>\n\n    ```ts\n    const MyObj = type({\n    \t\"key?\": \"number\"\n    })\n\n    // valid data\n    const validResult = MyObj({})\n\n    // Error: key must be a number (was undefined)\n    const errorResult = MyObj({ key: undefined })\n    ```\n\n    </details>\n\n</Callout>\n\n### defaultable [#properties-defaultable]\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst MyObj = type({\n\tdefaultableKey: \"boolean = false\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst MyObj = type({\n\tdefaultableKey: type.boolean.default(false)\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\nconst MyObj = type({\n\tdefaultableKey: [\"boolean\", \"=\", false]\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n<Callout type=\"warn\" title=\"Optional and default only work within objects and tuples!\">\n    Unlike e.g. `number.array()`, `number.optional()` and `number.default(0)` don't return a new `Type`, but rather a tuple definition like `[Type<number>, \"?\"]` or `[Type<number>, \"=\", 0]`.\n\n    This reflects the fact that in ArkType's type system, optionality and defaultability are only meaningful in reference to a property. Attempting to create an optional or defaultable value outside an object like `type(\"string?\")` will result in a `ParseError`.\n\n    To create a `Type` accepting `string` or `undefined`, use a union like `type(\"string | undefined\")`.\n\n    To have it transform `undefined` to an empty string, use an explicit morph like:\n\n    ```ts\n    const FallbackString = type(\"string | undefined\").pipe(v => v ?? \"\")\n    ```\n\n</Callout>\n\n### index [#properties-index]\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst MyObj = type({\n\t// index signatures do not require a label\n\t\"[string]\": \"number.integer\",\n\t// arbitrary string or symbolic expressions are allowed\n\t\"[string | symbol]\": \"number\"\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### undeclared [#properties-undeclared]\n\nTypeScript's structural type system explicitly allows assigning objects with additional keys so long as all declared constraints are satisfied. ArkType mirrors this behavior by default because generally...\n\n- Existing objects can be reused more often.\n- Validation is much more efficient if you don't need to check for undeclared keys.\n- Extra properties don't usually matter as long as those you've declared are satisfied.\n\nHowever, sometimes the way you're using the object would make undeclared properties problematic. Even though they can't be reflected by TypeScript ([_yet_- please +1 the issue!](https://github.com/microsoft/TypeScript/issues/12936#issuecomment-1854411301)), ArkType _does_ support rejection or deletion of undeclared keys. This behavior can be defined for individual objects using the syntax below or [via configuration](/docs/configuration#onundeclaredkey) if you want to change the default across all objects.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\n// fail if any key other than \"onlyAllowedKey\" is present\nconst MyClosedObject = type({\n\t\"+\": \"reject\",\n\tonlyAllowedKey: \"string\"\n})\n\n// delete all non-symbolic keys other than \"onlyPreservedStringKey\"\nconst MyStrippedObject = type({\n\t\"+\": \"delete\",\n\t\"[symbol]\": \"unknown\",\n\tonlyPreservedStringKey: \"string\"\n})\n\n// allow and preserve undeclared keys (the default behavior)\nconst MyOpenObject = type({\n\t// only specify \"ignore\" if you explicitly configured the default elsewhere\n\t\"+\": \"ignore\",\n\tnonexclusiveKey: \"number\"\n})\n```\n\n    </SyntaxTab>\n\n    \t<SyntaxTab fluent>\n\n```ts\n// fail if any key other than \"onlyAllowedKey\" is present\nconst MyClosedObject = type({\n\tonlyAllowedKey: \"string\"\n}).onUndeclaredKey(\"reject\")\n\n// delete all non-symbolic keys other than \"onlyPreservedStringKey\"\nconst MyStrippedObject = type({\n\t\"[symbol]\": \"unknown\",\n\tonlyPreservedStringKey: \"string\"\n}).onUndeclaredKey(\"delete\")\n\n// allow and preserve undeclared keys (the default behavior)\nconst MyOpenObject = type({\n\tnonexclusiveKey: \"number\"\n\t// only specify \"ignore\" if you explicitly configured the default elsewhere\n}).onUndeclaredKey(\"ignore\")\n\n// there is also a method for altering nested objects recursively\nconst MyDeeplyStrippedObject = type({\n\tpreserved: \"string\",\n\tnested: {\n\t\tpreserved: \"string\"\n\t}\n}).onDeepUndeclaredKey(\"delete\")\n```\n\n<Callout type=\"info\" title=\"Prefer in-object syntax where possible\">\n\tCertain methods like `.onUndeclaredKey` or `.configure` require a full traversal and transformation of the node created by the initial `type` call.\n\n    <details>\n    \t<summary>**Learn to recognize when chaining creates unnecessary overhead**</summary>\n\nThough they can be convenient if you need both variants of the type, most of the time you incur a significant performance cost instantiating your Type compared to the embedded syntax.\n\nThough how a Type is defined will never affect validation performance, depending on your sensitivity to initialization, you may want to avoid chained methods that transform rather than compose their base type. Methods like `.or` and `.pipe` that create new `Types` that directly reference the original incur no such overhead, so feel free to use whichever syntax is more convenient for those operations.\n\n    </details>\n\n</Callout>\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n<AnchorAliases properties-merge spread properties-spread />\n### merge\n\n**merge** allows you to extend an object with new properties or replace existing ones like the `...` operator [in JS](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax).\n\nWhen applied to two distinct (i.e. non-overlapping) sets of properties, it is a more efficient equivalent of [intersection](/docs/expressions#intersection).\n\nHowever, if a key appears in both the base and merged objects, the base value will be discarded in favor of the merged rather than recursively intersected.\n\nSpreading bypasses a lot of the behavioral complexity and computational overhead of an intersection and should be the preferred method of combining property sets.\n\n<SyntaxTabs>\n    <SyntaxTab fluent>\n\n```ts\nconst zildjian = Symbol()\n\nconst Base = type({\n\t\"[string]\": \"number\",\n\tfoo: \"0\",\n\t[zildjian]: \"true\"\n})\n\n// hover to see the inferred result\nconst chainedResult = Base.merge({\n\t\"[string]\": \"bigint\",\n\t\"foo?\": \"1n\"\n})\n```\n\n    </SyntaxTab>\n    <SyntaxTab string>\n\n```ts\nconst User = type({ isAdmin: \"false\", name: \"string\" })\n\n// hover to see the newly merged object\nconst Admin = type({\n\t\"...\": User,\n\t// in an intersection, non-overlapping values at isAdmin would result in a ParseError\n\tisAdmin: \"true\",\n\tpermissions: \"string[]\"\n})\n```\n\n    </SyntaxTab>\n    <SyntaxTab generic>\n\n```ts\nconst types = type.module({\n\tbase: {\n\t\t\"foo?\": \"0\",\n\t\t\"bar?\": \"0\"\n\t},\n\tmerged: {\n\t\tbar: \"1\",\n\t\t\"baz?\": \"1\"\n\t},\n\tresult: \"Merge<base, merged>\"\n})\n\n// hover to see the inferred result\ntype Result = typeof types.result.infer\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n<AnchorAliases merge-n-ary />\n#### n-ary\n\nTo merge many objects directly, `type.merge` will avoid the need to chain or compose many binary expressions:\n\n```ts\nconst zildjian = Symbol()\n\nconst Base = type({\n\t\"[string]\": \"number\",\n\tfoo: \"0\",\n\t[zildjian]: \"true\"\n})\n\n// accepts ...objectDefinitions\nconst functionResult = type.merge(\n\tBase,\n\t{\n\t\t\"[string]\": \"bigint\",\n\t\t\"foo?\": \"1n\"\n\t},\n\t{\n\t\tincludeThisPropAlso: \"true\"\n\t}\n)\n```\n\n### keyof [#properties-keyof]\n\nLike in TypeScript, the `keyof` operator extracts the keys of an object as a union:\n\n<SyntaxTabs>\n    <SyntaxTab fluent>\n\n```ts\nconst UsedCar = type({\n\toriginallyPurchased: \"string.date\",\n\tremainingWheels: \"number\"\n})\n\nconst UsedCarKey = UsedCar.keyof()\n\ntype UsedCarKey = typeof UsedCarKey.infer\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab string>\n\n```ts\nconst types = type.module({\n\tUsedCar: {\n\t\toriginallyPurchased: \"string.date\",\n\t\tremainingWheels: \"number\"\n\t},\n\tUsedCarKey: \"keyof UsedCar\"\n})\n\ntype UsedCarKey = typeof types.UsedCarKey.infer\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\nconst UsedCar = type({\n\toriginallyPurchased: \"string.date\",\n\tremainingWheels: \"number\"\n})\n\nconst UsedCarKey = type([\"keyof\", UsedCar])\n\ntype UsedCarKey = typeof UsedCarKey.infer\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab args>\n\n```ts\nconst UsedCar = type({\n\toriginallyPurchased: \"string.date\",\n\tremainingWheels: \"number\"\n})\n\nconst UsedCarKey = type(\"keyof\", UsedCar)\n\ntype UsedCarKey = typeof UsedCarKey.infer\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\nAlso like in TypeScript, if an object includes an index signature like `[string]` alongside named properties, the union from `keyof` will reduce to `string`:\n\n```ts\nconst RecordWithSpecialKeys = type({\n\t\"[string]\": \"unknown\",\n\tverySpecialKey: \"0 < number <= 3.14159\",\n\tmoderatelySpecialKey: \"-9.51413 <= number < 0\"\n})\n\n// in a union with the `string` index signature, string literals\n// \"verySpecialKey\" and \"moderatelySpecialKey\" are redundant and will be pruned\nconst Key = RecordWithSpecialKeys.keyof()\n\n// key is identical to the base `string` Type\nconsole.log(Key.equals(\"string\"))\n```\n\n<Callout type=\"warn\" title=\"ArkType's `keyof` will never include `number`\">\n\tThough TypeScript's `keyof` operator can yield a `number`, the concept of\n\tnumeric keys does not exist in JavaScript at runtime. This leads to confusing\n\tand inconsistent behavior. In ArkType, `keyof` will always return a `string`\n\tor `symbol` in accordance with the construction of a JavaScript object.\n\n    <details>\n    \t<summary>Learn more about our motivation for diverging from TypeScript on this issue</summary>\n\nIn JavaScript, you can use a number literal to define a key, but the constructed value has no way to represent a numeric key, so it is coerced to a string.\n\n```ts\nconst numberLiteralObj = {\n\t4: true,\n\t5: true\n}\n\nconst stringLiteralObj = {\n\t\"4\": true,\n\t\"5\": true\n}\n\n// numberLiteralObj and stringLiteralObj are indistinguishable at this point\nObject.keys(numberLiteralObj) // [\"4\", \"5\"]\nObject.keys(stringLiteralObj) // [\"4\", \"5\"]\n```\n\nFor a set-based type system to be correct, any two types representing the same set of underlying values must share a single representation. TypeScript's decision to have distinct numeric and string representations for the same underlying key has led to some if its most confusing inference pitfalls:\n\n```ts\ntype Thing1 = {\n\t[x: string]: unknown\n}\n\n// Thing2 is apparently identical to Thing1\ntype Thing2 = Record<string, unknown>\n\n// and yet...\ntype Key1 = keyof Thing1\n//   ^?\n\ntype Key2 = keyof Thing2\n//   ^?\n```\n\nThis sort of inconsistency is inevitable for a type system that has to reconcile multiple representations\nfor identical sets of underlying values. Therefore, numeric keys are one of a handful of cases where ArkType intentionally diverges from TypeScript. ArkType will never return a `number` from `keyof`. Keys will always be normalized to a `string` or `symbol`, the two distinct property types that can be uniquely attached to a JavaScript object.\n\n    </details>\n\n</Callout>\n\n### get [#properties-get]\n\nLike an index access expression in TypeScript (e.g. `User[\"name\"]`), the `get` operator extracts the Type of a value based on a specified key definition from an object:\n\n```ts\nconst snorfUsage = type.enumerated(\"eating plants\", \"looking adorable\")\n\nconst Manatee = type({\n\tisFriendly: \"true\",\n\tsnorf: {\n\t\tuses: snorfUsage.array()\n\t}\n})\n\nconst True = Manatee.get(\"isFriendly\")\n\n// nested properties can be accessed directly by passing additional args\nconst SnorfUses = Manatee.get(\"snorf\", \"uses\")\n```\n\n<Callout\n\ttype=\"warn\"\n\ttitle=\"Expressions like `get` and `omit` that extract a portion of an existing Type can be an antipattern!\"\n>\n\tBefore using `get` to extract the type of a property you've defined, consider\n\twhether you may be able to define the property value directly as a standalone\n\tType that can be easily referenced and composed as needed.\n\n    Usually, composing Types from the bottom up is clearer and more efficient than trying to rip the part you need out of an existing Type.\n\n</Callout>\n\nThough cases like this are quite straightforward, there are a number of more nuanced behaviors to consider when accessing an arbitrary key that could be a union, literal, or index signature on an object Type that could also be a union including optional keys or index signatures.\n\nIf you're interested in a deeper dive into this (or anything else in ArkType), [our unit tests](https://github.com/arktypeio/arktype/blob/main/ark/type/__tests__/get.test.ts) are the closest thing we have to a comprehensive spec.\n\nNot your cup of tea? No worries- the inferred types and errors you'll see in editor will always be guiding you in the right direction 🧭\n\n<Callout\n\ttype=\"info\"\n\ttitle=\"Support for TypeScript's index access syntax is planned!\"\n>\n\tLeave a comment on [the\n\tissue](https://github.com/arktypeio/arktype/issues/831) letting us know if\n\tyou're interested in using- or even helping implement- type-level parsing for\n\tstring-embedded index access 🤓\n</Callout>\n\n### pick / omit [#properties-pick-omit]\n\nExtract or exclude specific properties from an object Type:\n\n```ts\nconst User = type({\n\tname: \"string\",\n\temail: \"string.email\",\n\t\"age?\": \"number\"\n})\n\n// Type<{ name: string; email: string }>\nconst NameAndEmail = User.pick(\"name\", \"email\")\n\n// Type<{ name: string; age?: number }>\nconst WithoutEmail = User.omit(\"email\")\n```\n\nThese are also available as [generic keywords](/docs/generics): `Pick(User, \"name | email\")`, `Omit(User, \"email\")`.\n\n### required / partial [#properties-required-partial]\n\nMake all named properties required or optional:\n\n```ts\nconst User = type({\n\tname: \"string\",\n\t\"email?\": \"string.email\",\n\t\"age?\": \"number\"\n})\n\n// Type<{ name: string; email: string; age: number }>\nconst RequiredUser = User.required()\n\nconst Config = type({\n\thost: \"string\",\n\tport: \"number\"\n})\n\n// Type<{ host?: string; port?: number }>\nconst PartialConfig = Config.partial()\n```\n\nThese are also available as [generic keywords](/docs/generics): `Required(User)`, `Partial(Config)`.\n\n### readonly [#properties-readonly]\n\nMark all properties as readonly (type-level only, no runtime effect):\n\n```ts\nconst Frozen = type({\n\tid: \"number\",\n\tname: \"string\"\n}).readonly()\n\n// Type<{ readonly id: number; readonly name: string }>\n```\n\n### map [#properties-map]\n\nTransform the properties of an object Type using a mapping function. The mapper receives a prop entry with `key`, `value`, and `kind` (`\"required\"` or `\"optional\"`). Return a `{ key, value }` object (optionally with `kind`) to transform, or an empty array `[]` to remove the property.\n\n```ts\n// @noErrors\nconst User = type({\n\tname: \"string\",\n\t\"age?\": \"number\"\n})\n\n// make all properties nullable by wrapping each value in a union with null\nconst NullableUser = User.map(prop => {\n\treturn { key: prop.key, value: prop.value.or(\"null\") }\n})\n// Type<{ name: string | null; age?: number | null }>\n```\n\n### props [#properties-props]\n\nThe `props` getter returns an array of property descriptors for introspection:\n\n```ts\nconst User = type({\n\tname: \"string\",\n\t\"age?\": \"number\",\n\t\"role\": \"'admin' | 'user' = 'user'\"\n})\n\nfor (const prop of User.props) {\n\tconsole.log(prop.kind) // \"required\", \"optional\"\n\tconsole.log(prop.key) // \"name\", \"role\", \"age\"\n\tconsole.log(prop.value.expression) // \"string\", '\"admin\" | \"user\"', \"number\"\n\tconsole.log(prop.meta) // metadata object\n\tif (\"default\" in prop) console.log(prop.default) // \"user\" for role\n}\n```\n\n## arrays\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst Arrays = type({\n\tkey: \"string[]\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Arrays = type({\n\tkey: type.string.array()\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\nconst Arrays = type({\n\tkey: [{ name: \"string\" }, \"[]\"]\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab args>\n\n```ts\nconst Arrays = type({\n\tkey: type({ name: \"string\" }, \"[]\")\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### lengths [#arrays-lengths]\n\nConstrain an array with an inclusive or exclusive min or max length.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst Bounded = type({\n\tnonEmptyStringArray: \"string[] > 0\",\n\tatLeast3Integers: \"number.integer[] >= 3\",\n\tlessThan10Emails: \"string.email[] < 10\",\n\tatMost5Booleans: \"boolean[] <= 5\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Bounded = type({\n\tnonEmptyStringArray: type.string.array().moreThanLength(0),\n\tatLeast3Integers: type.keywords.number.integer.array().atLeastLength(3),\n\tlessThan10Emails: type.keywords.string.email.array().lessThanLength(10),\n\tatMost5Booleans: type.boolean.array().atMostLength(5)\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\nRange expressions allow you to specify both a min and max length and use the same syntax for exclusivity.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst Range = type({\n\tnonEmptyStringArrayAtMostLength10: \"0 < string[] <= 10\",\n\ttwoToFiveIntegers: \"2 <= number.integer[] < 6\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Range = type({\n\tnonEmptyStringArrayAtMostLength10: type.string\n\t\t.array()\n\t\t.moreThanLength(0)\n\t\t.atMostLength(10),\n\ttwoToFiveIntegers: type.keywords.number.integer\n\t\t.array()\n\t\t.atLeastLength(2)\n\t\t.lessThanLength(6)\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n## tuples\n\nLike objects, tuples are structures whose values are nested definitions. Like TypeScript, ArkType supports prefix, optional, variadic, and postfix elements, with the same restrictions about combining them.\n\n### prefix [#tuples-prefix]\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst MyTuple = type([\n\t\"string\",\n\t// Object definitions can be nested in tuples- and vice versa!\n\t{\n\t\tcoordinates: [\"number\", \"number\"]\n\t}\n])\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst MyTuple = type([\n\ttype.string,\n\t// Object definitions can be nested in tuples- and vice versa!\n\t{\n\t\tcoordinates: [type.number, type.number]\n\t}\n])\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### defaultable [#tuples-defaultable]\n\nDefaultable elements are optional elements that will be assigned their specified default if not present in the tuple's input.\n\nA tuple may include zero or more defaultable elements following its prefix elements and preceding its non-defaultable optional elements.\n\nLike optional elements, defaultable elements are mutually exclusive with postfix elements.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst MyTuple = type([\"string\", \"boolean = false\", \"number = 0\"])\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst MyTuple = type([\n\ttype.string,\n\ttype.boolean.default(false),\n\ttype.number.default(0)\n])\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\nconst MyTuple = type([\n\t\"string\",\n\t[\n\t\t{\n\t\t\tname: \"string\"\n\t\t},\n\t\t\"=\",\n\t\t() => ({ name: \"Anon Eemuss\" })\n\t]\n])\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### optional [#tuples-optional]\n\nOptional elements are tuple elements that may or may not be present in the input that do not have a default value.\n\nA tuple may include zero or more optional elements following its prefix and defaultable elements and preceding either a variadic element or the end of the tuple.\n\nLike in TypeScript, optional elements are mutually exclusive with postfix elements.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst MyTuple = type([\"string\", \"bigint = 999n\", \"boolean?\", \"number?\"])\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst MyTuple = type([\n\ttype.string,\n\ttype.bigint.default(999n),\n\ttype.boolean.optional(),\n\ttype.number.optional()\n])\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\nconst MyTuple = type([\n\t\"string\",\n\t[\n\t\t{\n\t\t\tname: \"string\"\n\t\t},\n\t\t\"?\"\n\t]\n])\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### variadic [#tuples-variadic]\n\nLike in TypeScript, variadic elements allow zero or more consecutive values of a given type and may occur at most once in a tuple.\n\nThey are specified with a `\"...\"` operator preceding an array element.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\n// allows a string followed by zero or more numbers\nconst MyTuple = type([\"string\", \"...\", \"number[]\"])\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\n// allows a string followed by zero or more numbers\nconst MyTuple = type([type.string, \"...\", type.number.array()])\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### postfix [#tuples-postfix]\n\nPostfix elements are required elements following a variadic element.\n\nThey are mutually exclusive with optional elements.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\n// allows zero or more numbers followed by a boolean, then a string\nconst MyTuple = type([\"...\", \"number[]\", \"boolean\", \"string\"])\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\n// allows zero or more numbers followed by a boolean, then a string\nconst MyTuple = type([\"...\", type.number.array(), type.boolean, type.string])\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n## dates\n\n### literals [#dates-literals]\n\nDate literals represent a Date instance with an exact value.\n\nThey're primarily useful in ranges.\n\n```ts\nconst Literals = type({\n\tsingleQuoted: \"d'01-01-1970'\",\n\tdoubleQuoted: 'd\"01-01-1970\"'\n})\n```\n\n### ranges [#dates-ranges]\n\nConstrain a Date with an inclusive or exclusive min or max.\n\nBounds can be expressed as either a [number](/docs/primitives#number-literals) representing its corresponding Unix epoch value or a [Date literal](/docs/objects#dates-literals).\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst Bounded = type({\n\tdateInThePast: `Date < ${Date.now()}`,\n\tdateAfter2000: \"Date > d'2000-01-01'\",\n\tdateAtOrAfter1970: \"Date >= 0\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Bounded = type({\n\tdateInThePast: type.Date.earlierThan(Date.now()),\n\tdateAfter2000: type.Date.laterThan(\"2000-01-01\"),\n\tdateAtOrAfter1970: type.Date.atOrAfter(0)\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\nRange expressions allow you to specify both a min and max and use the same syntax for exclusivity.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst tenYearsAgo = new Date()\n\t.setFullYear(new Date().getFullYear() - 10)\n\t.valueOf()\n\nconst Bounded = type({\n\tdateInTheLast10Years: `${tenYearsAgo} <= Date < ${Date.now()}`\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst tenYearsAgo = new Date()\n\t.setFullYear(new Date().getFullYear() - 10)\n\t.valueOf()\n\nconst Bounded = type({\n\tdateInTheLast10Years: type.Date.atOrAfter(tenYearsAgo).earlierThan(Date.now())\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n## instanceof\n\nMost built-in instance types like `Array` and `Date` are available directly as keywords, but `instanceof` can be useful for constraining a type to one of your own classes.\n\n<SyntaxTabs>\n    <SyntaxTab fluent>\n\n```ts\nclass MyClass {}\n\nconst Instances = type.instanceOf(MyClass)\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab tuple>\n\n```ts\nclass MyClass {}\n\nconst Instances = type({\n\tkey: [\"instanceof\", MyClass]\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab args>\n\n```ts\nclass MyClass {}\n\nconst Instances = type({\n\tkey: type(\"instanceof\", MyClass)\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### keywords [#instanceof-keywords]\n\nA list of instanceof keywords can be found [here](/docs/keywords#instanceof) alongside the base and subtype keywords for [Array](/docs/keywords#array) and [FormData](/docs/keywords#formdata).\n\n\n---\ntitle: Primitives\n---\n\n## string\n\n### keywords\n\nThe following keywords can be referenced in any definition, e.g.:\n\n```ts\nconst Email = type(\"string.email\")\n\nconst User = type({\n\tdata: \"string.json.parse\",\n\tids: \"string.uuid.v4[]\"\n})\n```\n\n<StringKeywordTable />\n\n### literals [#string-literals]\n\n```ts\nconst Literals = type({\n\tsingleQuoted: \"'typescript'\",\n\tdoubleQuoted: '\"arktype\"'\n})\n```\n\n### patterns [#string-patterns]\n\nRegex literals specify an unanchored regular expression that an input string must match.\n\nThey can either be string-embedded or refer directly to a `RegExp` instance.\n\n```ts\nconst Literals = type({\n\tstringEmbedded: \"/^a.*z$/\",\n\tregexLiteral: /^a.*z$/\n})\n```\n\nRegex literals now carry full type inference via [arkregex](/docs/blog/arkregex):\n\n```ts\nconst Hex = type(\"/^[0-9a-fA-F]+$/\")\n//    Type<string>\n\nconst Semver = type(\"/^(\\\\d+)\\\\.(\\\\d+)\\\\.(\\\\d+)$/\")\n//    Type<`${number}.${number}.${number}`>\n```\n\n#### e(x)ec mode\n\nPrefix a regex literal with `x` to parse capture groups at runtime, fully typed:\n\n```ts\nconst User = type({\n\tbirthday: \"x/^(?<month>\\\\d{2})-(?<day>\\\\d{2})-(?<year>\\\\d{4})$/\"\n})\n\nconst data = User.assert({ birthday: \"05-21-1993\" })\n\n// fully type-safe\ndata.birthday.groups.month // \"05\"\ndata.birthday.groups.day // \"21\"\ndata.birthday.groups.year // \"1993\"\n```\n\nFor the standalone package (no ArkType required), see the full [arkregex announcement](/docs/blog/arkregex).\n\n### lengths [#string-lengths]\n\nConstrain a string with an inclusive or exclusive min or max length.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst Bounded = type({\n\tnonEmpty: \"string > 0\",\n\tatLeastLength3: \"string.alphanumeric >= 3\",\n\tlessThanLength10: \"string < 10\",\n\tatMostLength5: \"string <= 5\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Bounded = type({\n\tnonEmpty: type.string.moreThanLength(0),\n\tatLeastLength3: type.keywords.string.alphanumeric.atLeastLength(3),\n\tlessThanLength10: type.string.lessThanLength(10),\n\tatMostLength5: type.string.atMostLength(5)\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\nRange expressions allow you to specify both a min and max length and use the same syntax for exclusivity.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst Range = type({\n\tnonEmptyAtMostLength10: \"0 < string <= 10\",\n\tintegerStringWith2To5Digits: \"2 <= string.integer < 6\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Range = type({\n\tnonEmptyAtMostLength10: type.string.moreThanLength(0).atMostLength(10),\n\tintegerStringWith2To5Digits: type.keywords.string.integer.root\n\t\t.atLeastLength(2)\n\t\t.lessThanLength(6)\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n## number\n\n### keywords [#number-keywords]\n\nThe following keywords can be referenced in any definition, e.g.:\n\n```ts\nconst User = type({\n\tcreatedAt: \"number.epoch\",\n\tage: \"number.integer >= 0\"\n})\n```\n\n<NumberKeywordTable />\n\n### literals [#number-literals]\n\n```ts\nconst Literals = type({\n\tnumber: \"1337\"\n})\n```\n\n### ranges [#number-ranges]\n\nConstrain a number with an inclusive or exclusive min or max.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst Bounded = type({\n\tpositive: \"number > 0\",\n\tatLeast3: \"number.integer >= 3\",\n\tlessThanPi: \"number < 3.14159\",\n\tatMost5: \"number <= 5\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Bounded = type({\n\tpositive: type.number.moreThan(0),\n\tatLeast3: type.keywords.number.integer.atLeast(3),\n\tlessThanPi: type.number.lessThan(3.14159),\n\tatMost5: type.number.atMost(5)\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\nRange expressions allow you to specify both a min and max and use the same syntax for exclusivity.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst Range = type({\n\tpositiveAtMostE: \"0 < number <= 2.71828\",\n\tevenNumberAbsoluteValueLessThan50: \"-50 < (number % 2) < 50\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Range = type({\n\tpositiveAtMostE: type.number.moreThan(0).atMost(2.71828),\n\tevenNumberAbsoluteValueLessThan50: type.number\n\t\t.divisibleBy(2)\n\t\t.moreThan(-50)\n\t\t.lessThan(50)\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### divisors [#number-divisors]\n\nConstrain a `number` to a multiple of the specified integer.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst Evens = type({\n\tkey: \"number % 2\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Evens = type({\n\tkey: type.number.divisibleBy(2)\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n## bigint\n\nTo allow any `bigint` value, use the `\"bigint\"` keyword.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst Bigints = type({\n\tfoo: \"bigint\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Symbols = type({\n\tfoo: type.bigint\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### literals [#bigint-literals]\n\nTo require an exact `bigint` value in your type, you can use add the suffix `n` to a string-embedded [number literal](/docs/primitives#number-literals) to make it a `bigint`.\n\n```ts\nconst Literals = type({\n\tbigint: \"1337n\"\n})\n```\n\nYou may also use a [unit expression](/docs/expressions#unit) to define `bigint` literals.\n\n## symbol\n\nTo allow any `symbol` value, use the `\"symbol\"` keyword.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst Symbols = type({\n\tkey: \"symbol\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Symbols = type({\n\tkey: type.symbol\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\nTo reference a specific symbol in your definition, use a [unit expression](/docs/expressions#unit).\n\nNo special syntax is required to define symbolic properties like `{ [mySymbol]: \"string\" }`. For more information and examples of how to combine symbolic keys with other syntax like optionality, see [properties](/docs/objects#properties).\n\n## boolean\n\nTo allow `true` or `false`, use the `\"boolean\"` keyword.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst Booleans = type({\n\tkey: \"boolean\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Booleans = type({\n\tkey: type.boolean\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n### literals [#boolean-literals]\n\nTo require a specific boolean value, use the corresponding literal.\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst Booleans = type({\n\ta: \"true\",\n\tb: \"false\",\n\t// equivalent to the \"boolean\" keyword\n\tc: \"true | false\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst Booleans = type({\n\ta: type.keywords.true,\n\tb: type.keywords.false,\n\t// equivalent to the \"boolean\" keyword\n\tc: type.keywords.true.or(type.keywords.false)\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n## null\n\nThe `\"null\"` keyword can be used to allow the exact value `null`, generally as part of a [union](/docs/expressions#union).\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst MyObj = type({\n\tfoo: \"number | null\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst MyObj = type({\n\tfoo: type.number.or(type.null)\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n## undefined\n\nThe `\"undefined\"` keyword can be used to allow the exact value `undefined`, generally as part of a [union](/docs/expressions#union).\n\n<SyntaxTabs>\n\t<SyntaxTab string>\n\n```ts\nconst MyObj = type({\n\trequiredKey: \"number | undefined\",\n\t\"optionalKey?\": \"number | undefined\"\n})\n```\n\n    </SyntaxTab>\n\n    <SyntaxTab fluent>\n\n```ts\nconst MyObj = type({\n\trequiredKey: type.number.or(type.undefined),\n\toptionalKey: type.number.or(type.undefined).optional()\n})\n```\n\n    </SyntaxTab>\n\n</SyntaxTabs>\n\n<Callout type=\"warn\" title=\"Allowing undefined as a value does not make the key optional!\">\n\n    In TypeScript, a required property that allows `undefined` must still be present for the type to be satisfied.\n\n    The same is true in ArkType.\n\n    <details>\n    \t<summary>See an example</summary>\n\n    ```ts\n    const MyObj = type({\n    \tkey: \"number | undefined\"\n    })\n\n    // valid data\n    const validResult = MyObj({ key: undefined })\n\n    // Error: name must be a number or undefined (was missing)\n    const errorResult = MyObj({})\n    ```\n\n    </details>\n\n</Callout>\n\n\n---\ntitle: Scopes\n---\n\n<AnchorAliases intro />\n\nScopes are the foundation of ArkType, and one of the most powerful features for users wanting full control over configuration and to make their own keywords available fluidly within string definition syntax.\n\nA scope is just like a scope in code- a resolution space where you can define types, generics, or other scopes. The `type` export is a actually just a method on our default `Scope`!\n\n## Defining a Scope\n\nTo define a scope, you may either `import { scope } from \"arktype\"` or use `type.scope` on the default `type` export.\n\nA scope is specified as an object literal mapping names to definitions.\n\n```ts\nimport { scope } from \"arktype\"\n\nconst coolScope = scope({\n\t// keywords are still available in your scope\n\tId: \"string\",\n\t// but you can also reference your own aliases directly!\n\tUser: { id: \"Id\", friends: \"Id[]\" },\n\t// your aliases will be autocompleted and validated alongside ArkType's keywords\n\tUsersById: {\n\t\t\"[Id]\": \"User | undefined\"\n\t}\n})\n```\n\n`coolScope` is an object with reusable methods like `type` and `generic`. You can use it to create additional `Type`s that can reference your **aliases**- `id`, `user` and `usersById`.\n\n<Callout type=\"warn\" title=\"Don't wrap your scoped definitions in type!\">\n\nEven if you reference it as part of your scope definition, the global 'type' parser only knows about built-in keywords.\n\n```ts\n// @errors: 2322\nconst badScope = scope({\n\tId: \"string\",\n\t// ❌ wrapping this definition in `type` will fail\n\tBadEntity: type({\n\t\tid: \"Id\"\n\t}),\n\t// ✅ reference scoped definitions directly instead of wrapping them\n\tGoodEntity: {\n\t\tid: \"Id\"\n\t}\n})\n```\n\nIf you need access to fluent syntax from within a Scope, see [thunks](/docs/scopes#thunks).\n\n</Callout>\n\n```ts\nconst coolScope = scope({\n\tId: \"string\",\n\tUser: { id: \"Id\", friends: \"Id[]\" },\n\tUsersById: {\n\t\t\"[Id]\": \"User | undefined\"\n\t}\n})\n// ---cut---\n\nconst group = coolScope.type({\n\tname: \"string\",\n\tmembers: \"User[]\"\n})\n\n// chained definitions are parsed in the same scope as the original Type\nconst ownedGroup = group.and({\n\townerId: \"Id\"\n})\n```\n\nTo use the scoped types directly, you must `.export()` your `Scope` to a `Module`. A `Module` is just an object mapping aliases to `Type`s. They can be used for validation or in any other context a `Type` can be used.\n\n```ts\nconst coolScope = scope({\n\tId: \"string\",\n\tUser: { id: \"Id\", friends: \"Id[]\" },\n\tUsersById: {\n\t\t\"[Id]\": \"User | undefined\"\n\t}\n})\n\ninterface RuntimeErrors extends type.errors {\n\t/**friends[1] must be a string (was a number)*/\n\tsummary: string\n}\n\nconst narrowMessage = (e: type.errors): e is RuntimeErrors => true\n// ---cut---\n\nconst coolModule = coolScope.export()\n\nconst out = coolModule.User({\n\tid: \"99\",\n\tfriends: [\"7\", 8, \"9\"]\n})\n\nif (out instanceof type.errors) {\n\t// ---cut-start---\n\tif (!narrowMessage(out)) throw new Error()\n\t// ---cut-end---\n\t// hover summary to see validation errors\n\tconsole.error(out.summary)\n}\n```\n\n`.export()` is also useful in combination with the spread operator for extending your `Scope`s. Recall that a `Type` can be referenced as a definition. This means that spreading a `Module` into the definition you pass to `scope` includes all of that Module's aliases in your new `Scope`.\n\n```ts\nconst coolScope = scope({\n\tId: \"string\",\n\tUser: { id: \"Id\", friends: \"Id[]\" },\n\tUsersById: {\n\t\t\"[Id]\": \"User | undefined\"\n\t}\n})\n// ---cut---\n\nconst threeSixtyNoScope = scope({\n\tthree: \"3\",\n\tsixty: \"60\",\n\tno: \"'no'\"\n})\n\nconst superScope = scope({\n\t...coolScope.export(),\n\t// if you don't want to include the entire scope, you can pass a list of ...aliases\n\t...threeSixtyNoScope.export(\"three\", \"sixty\"),\n\tsaiyan: {\n\t\tpowerLevel: \"number > 9000\"\n\t}\n})\n```\n\nIf you don't plan to reuse your `Scope` to create additional types, it is common to export it inline:\n\n```ts\nconst ezModule = scope({\n\tEz: \"'moochi'\"\n}).export()\n```\n\n`type.module` is available as sugar for this pattern:\n\n```ts\nconst ezModule = type.module({\n\tEz: \"'moochi'\"\n})\n```\n\n### Cyclic Types\n\nScopes make it easy to create recursive `Type`s. Just reference the alias like you would any other:\n\n```ts\nexport const types = scope({\n\tPackage: {\n\t\tname: \"string\",\n\t\t\"dependencies?\": \"Package[]\",\n\t\t\"contributors?\": \"Contributor[]\"\n\t},\n\tContributor: {\n\t\temail: \"string.email\",\n\t\t\"packages?\": \"Package[]\"\n\t}\n}).export()\n```\n\nCyclic types are inferred to arbitrary depth. At runtime, they can safely validate cyclic data.\n\n```ts\nexport const types = scope({\n\tPackage: {\n\t\tname: \"string\",\n\t\t\"dependencies?\": \"Package[]\",\n\t\t\"contributors?\": \"Contributor[]\"\n\t},\n\tContributor: {\n\t\temail: \"string.email\",\n\t\t\"packages?\": \"Package[]\"\n\t}\n}).export()\n// ---cut---\n\nexport type Package = typeof types.Package.infer\n\nconst packageData: Package = {\n\tname: \"arktype\",\n\tdependencies: [{ name: \"typescript\" }],\n\tcontributors: [{ email: \"david@sharktypeio\" }]\n}\n\n// update arktype to depend on itself\npackageData.dependencies![0].dependencies = [packageData]\n\n// ArkErrors: contributors[0].email must be an email address (was \"david@sharktypeio\")\nconst out = types.Package(packageData)\n```\n\n<Callout type=\"warn\" title=\"Some `any`s are not what they seem!\">\n\nBy default, TypeScript represents anonymous cycles as `...`. However, if you have `noErrorTruncation` enabled, they are visually displayed as `any`😬\n\nLuckily, despite its appearance, the type otherwise behaves as you'd expect- TypeScript will provide completions and will complain as normal if you access a non-existent property.\n\n</Callout>\n\n### visibility\n\nIntermediate aliases can be useful for composing Scoped definitions from aliases. Sometimes, you may not want to expose those aliases externally as `Type`s when your `Scope` is `export`ed.\n\nThis can be done using _private_ aliases:\n\n```ts\nconst shapeScope = scope({\n\t// aliases with a \"#\" prefix are treated as private\n\t\"#BaseShapeProps\": {\n\t\tperimeter: \"number\",\n\t\tarea: \"number\"\n\t},\n\tEllipse: {\n\t\t// when referencing a private alias, the \"#\" should not be included\n\t\t\"...\": \"BaseShapeProps\",\n\t\tradii: [\"number\", \"number\"]\n\t},\n\tRectangle: {\n\t\t\"...\": \"BaseShapeProps\",\n\t\twidth: \"number\",\n\t\theight: \"number\"\n\t}\n})\n\n// private aliases can be referenced from any scoped definition,\n// even outside the original scope\nconst PartialShape = shapeScope.type(\"Partial<BaseShapeProps>\")\n\n// when the scope is exported to a Module, they will not be included\n// hover to see the Scope's exports\nconst shapeModule = shapeScope.export()\n```\n\n#### `import()`\n\nPrivate aliases are especially useful for building scopes without polluting them with every alias you might want to reference internally. To facilitate this, Scopes have an `import()` method that behaves identically to `export()` but converts all exported aliases to `private`.\n\n```ts\nconst utilityScope = scope({\n\t\"withId<o extends object>\": {\n\t\t\"...\": \"o\",\n\t\tid: \"string\"\n\t}\n})\n\nconst userModule = type.module({\n\t// because we use `import()` here, we can reference our utilities\n\t// internally, but they will not be included in `userModule`.\n\t// if we used `export()` instead, `withId` could be accessed on `userModule`.\n\t...utilityScope.import(),\n\tPayload: {\n\t\tname: \"string\",\n\t\tage: \"number\"\n\t},\n\tdb: \"withId<Payload>\"\n})\n```\n\n### submodules\n\nIf you've used keywords like `string.email` or `number.integer`, you may wonder if aliases can be grouped in your own Scopes. Recall from [the introduction to Scopes](#intro) that `type` is actually just a method on ArkType's default `Scope`, meaning all of its functionality is available externally, including alias groups called _Submodules_.\n\nSubmodules are groups of aliases with a shared prefix. To define one, just assign the value of the prefix to a `Module` with the names you want:\n\n```ts\nconst subAliases = type.module({ alias: \"number\" })\n\nconst rootScope = scope({\n\ta: \"string\",\n\tb: \"sub.alias\",\n\tsub: subAliases\n})\n\nconst myType = rootScope.type({\n\tsomeKey: \"sub.alias[]\"\n})\n```\n\nSubmodules are parsed bottom-up. This means subaliases can be referenced directly in the root scope,\nbut root aliases can't be referenced from the submodule, even if it's inlined.\n\n#### nested\n\nSubmodules can be nested to arbitrary depth:\n\n```ts\nconst subAliases = type.module({ alias: \"number\" })\n\nconst rootScope = scope({\n\ta: \"string\",\n\tb: \"sub.alias\",\n\tsub: subAliases\n})\n// ---cut---\n\nconst rootScopeSquared = scope({\n\t// reference rootScope from our previous example\n\tnewRoot: rootScope.export()\n})\n\nconst myNewType = rootScopeSquared.type({\n\tsomeOtherKey: \"newRoot.sub.alias | boolean\"\n})\n```\n\n#### rooted\n\nThe Submodules from our previous examples group `Type`s together, but cannot be referenced as `Type`s themselves the way `string` and `number` can. To define a _Rooted Submodule_, just use an alias called `root`:\n\n```ts\nconst userModule = type.module({\n\troot: {\n\t\tname: \"string\"\n\t},\n\t// subaliases can extend a base type by referencing 'root'\n\t// like any other alias\n\tAdmin: {\n\t\t\"...\": \"root\",\n\t\tisAdmin: \"true\"\n\t},\n\tSaiyan: {\n\t\t\"...\": \"root\",\n\t\tpowerLevel: \"number > 9000\"\n\t}\n})\n\nconst types = type.module({\n\tUser: userModule,\n\t// user can now be referenced directly in a definition\n\tGroup: \"User[]\",\n\t// or used as a prefix to access subaliases\n\tElevatedUser: \"User.Admin | User.Saiyan\"\n})\n```\n\n### thunks\n\nWhen users are first learning about Scopes, one of the most common mistakes is to reference an alias in a nested `type` call:\n\n<CodeBlock fromFile=\"nestedTypeInScopeError\" />\n\nThis error occurs because although the `id` alias would be resolvable in the current Scope directly, `type` only allows references to built-in keywords. In this case, the `type` wrapper is redundant and the fix is to simply remove it:\n\n```ts\nconst myScope = scope({\n\tId: \"string#id\",\n\tUser: {\n\t\tname: \"string\",\n\t\t// now resolves correctly\n\t\tid: \"Id\"\n\t}\n})\n```\n\nHowever, even if it is _possible_ to define your scope without invoking `type` by composing aliases and tuple expressions, the fluent methods available on `Type` can define complex types that can be cumbersome to express otherwise. In these situations, you can use a **thunk definition** to access the `type` method on the Scope you're currently defining:\n\n```ts\nconst $ = scope({\n\tId: \"string#id\",\n\texpandUserGroup: () =>\n\t\t$.type({\n\t\t\tname: \"string\",\n\t\t\tid: \"Id\"\n\t\t})\n\t\t\t.or(\"Id\")\n\t\t\t.pipe(user =>\n\t\t\t\ttypeof user === \"string\" ? { id: user, name: \"Anonymous\" } : user\n\t\t\t)\n\t\t\t.array()\n\t\t\t.atLeastLength(2)\n})\n\nconst types = $.export()\n\n// input is validated and transformed to:\n// [{ name: \"Magical Crawdad\", id: \"777\" }, { name: \"Anonymous\", id: \"778\" }]\nconst groups = types.expandUserGroup([\n\t{ name: \"Magical Crawdad\", id: \"777\" },\n\t\"778\"\n])\n```\n\nThough thunk definitions are really only useful when defining a Scope, they can be used anywhere a `Type` definition is expected:\n\n```ts\n// you *can* use them anywhere, but *should* you? (no)\nconst MyInelegantType = type(() =>\n\ttype({ inelegantKey: () => type(\"'inelegant value'\") })\n)\n```\n\n\n---\ntitle: Traversal API\n---\n\n<ApiTable group=\"Traversal\" />\n\n### assert\n\nValidate data, returning the output on success or throwing a `TraversalError` on failure:\n\n```ts\nconst User = type({ name: \"string\", \"age?\": \"number\" })\n\n// returns { name: \"David\" }\nconst valid = User.assert({ name: \"David\" })\n\n// throws TraversalError: name must be a string (was a number)\nUser.assert({ name: 42 })\n```\n\n### allows\n\nCheck if data satisfies the type's constraints without applying morphs or transformations. Returns a type guard:\n\n```ts\nconst User = type({ name: \"string\" })\n\nconst data: unknown = { name: \"David\" }\n\nif (User.allows(data)) {\n\t// data is narrowed to { name: string }\n\tconsole.log(data.name)\n}\n```\n\nThis is useful when you want a pure type check without triggering any side effects from morphs like `string.numeric.parse`.\n\n### Invoking a Type directly\n\nCalling a Type as a function validates and transforms the input, returning either the output or `ArkErrors`:\n\n```ts\nconst T = type(\"string.numeric.parse\")\n\nconst out = T(\"42\")\n\nif (out instanceof type.errors) {\n\tconsole.log(out.summary)\n} else {\n\t// out is number\n\tconsole.log(out + 1)\n}\n```\n\n### ArkErrors\n\nThe `ArkErrors` array returned on validation failure contains `ArkError` instances with structured data:\n\n```ts\nconst T = type({ n: \"number % 2\", m: \"number >= 2\" })\n\nconst out = T({ n: 1, m: 0 })\n\nif (out instanceof type.errors) {\n\t// discriminate by error code\n\tfor (const error of out) {\n\t\tif (error.hasCode(\"divisor\")) {\n\t\t\tconsole.log(error.rule) // 2\n\t\t}\n\t}\n\n\t// structured access by path\n\tout.flatByPath // { m: [ArkError], n: [ArkError] }\n\tout.flatProblemsByPath // { m: [\"must be at least 2 (was 0)\"], n: [\"must be even (was 1)\"] }\n\n\t// JSON serializable\n\tJSON.stringify(out) // [{ path: [\"m\"], code: \"min\", ... }, { path: [\"n\"], code: \"divisor\", ... }]\n}\n```\n\n### TraversalError\n\nWhen `.assert()` fails, it throws a `TraversalError` (extends `Error`) with:\n\n- A formatted `message` (single errors inline, multiple errors bulleted)\n- A non-enumerable `arkErrors` property for programmatic access\n\n```ts\nimport { type, TraversalError } from \"arktype\"\n\ntry {\n\ttype({ a: \"string\", b: \"number\" }).assert({ a: 1, b: \"x\" })\n} catch (e) {\n\tif (e instanceof TraversalError) {\n\t\tconsole.log(e.message)\n\t\t// • a must be a string (was a number)\n\t\t// • b must be a number (was a string)\n\n\t\t// access the underlying ArkErrors for structured data\n\t\tconsole.log(e.arkErrors.flatProblemsByPath)\n\t}\n}\n```\n\n\n---\ntitle: Type API\n---\n\n<ApiTable group=\"Type\" />\n\nThe methods below are available on every `Type` instance. For validation and traversal methods (`assert`, `allows`, direct invocation), see the [Traversal API](/docs/traversal-api). For composition methods (`pipe`, `to`, `narrow`, `filter`, `and`, `or`), see [Expressions](/docs/expressions). For object-specific methods (`pick`, `omit`, `required`, `partial`, `merge`, `keyof`, `get`, `readonly`, `map`, `props`), see [Objects](/docs/objects).\n\n### from\n\n`from` is a typed-input variant of `assert`. It accepts an input matching `inferIn` and returns `inferOut`, providing type safety on both sides. Like `assert`, it throws a `TraversalError` on invalid input:\n\n```ts\n// @errors: 2345\nconst StringToNumber = type(\"string.numeric.parse\")\n\n// TypeScript knows the input must be a string\nconst result = StringToNumber.from(\"42\") // 42\n\nStringToNumber.from(42)\n```\n\n### in / out\n\nThe `in` and `out` getters extract the input or output Type from a morphed Type, stripping transformations:\n\n```ts\nconst ParsedUser = type({\n\tname: \"string\",\n\tage: \"string.numeric.parse\"\n})\n\n// Type<{ name: string; age: string }>\nconst UserInput = ParsedUser.in\n\n// Type<{ name: string; age: number }>\nconst UserOutput = ParsedUser.out\n```\n\n### extends\n\nCheck if a Type is a subtype of another:\n\n```ts\nconst T = type(\"string\")\n\nT.extends(\"unknown\") // true\nT.extends(\"number\") // false\n\n// ifExtends returns the Type itself if true, undefined otherwise\nconst result = T.ifExtends(\"string | number\") // Type<string | number> | undefined\n```\n\n### equals\n\nCheck if two Types are structurally identical:\n\n```ts\nconst A = type({ name: \"string\" })\nconst B = type({ name: \"string\" })\nconst C = type({ name: \"number\" })\n\nA.equals(B) // true\nA.equals(C) // false\n\n// ifEquals returns the Type if equal, undefined otherwise\nconst result = A.ifEquals(B) // Type<{ name: string }> | undefined\n```\n\n### overlaps\n\nCheck if any value could satisfy both Types:\n\n```ts\nconst A = type(\"string | number\")\nconst B = type(\"number | boolean\")\nconst C = type(\"string\")\n\nA.overlaps(B) // true (number satisfies both)\nC.overlaps(type(\"number\")) // false\n```\n\n### extract / exclude\n\nExtract or exclude union branches based on a Type:\n\n```ts\nconst T = type(\"string | number | boolean\")\n\n// Type<string | boolean>\nconst Extracted = T.extract(\"string | boolean\")\n\n// Type<number>\nconst Excluded = T.exclude(\"string | boolean\")\n```\n\n### distribute\n\nMap and optionally reduce over union branches:\n\n```ts\nconst T = type(\"string | number | bigint\")\n\n// [\"bigint\", \"number\", \"string\"]\nconst expressions = T.distribute(branch => branch.expression)\n\n// with a reducer\nconst count = T.distribute(\n\tbranch => branch,\n\tbranches => branches.length\n) // 3\n```\n\n### toJsonSchema\n\nEach `Type` instance exposes a `toJsonSchema()` method that can be used to generate a corresponding JSON Schema.\n\n```ts\nconst User = type({\n\tname: \"string\",\n\temail: \"string.email\",\n\t\"age?\": \"number >= 18\"\n})\n\nconst schema = User.toJsonSchema()\n\nconst result = {\n\t$schema: \"https://json-schema.org/draft/2020-12/schema\",\n\ttype: \"object\",\n\tproperties: {\n\t\tname: { type: \"string\" },\n\t\temail: {\n\t\t\ttype: \"string\",\n\t\t\tformat: \"email\",\n\t\t\tpattern: \"^[\\w%+.-]+@[\\d.A-Za-z-]+\\.[A-Za-z]{2,}$\"\n\t\t},\n\t\tage: { type: \"number\", minimum: 18 }\n\t},\n\trequired: [\"email\", \"name\"]\n}\n```\n\nOptions can be passed to change the behavior including how incompatibilities are handled. See [the associated config docs](/docs/configuration#tojsonschema) for more details.\n"
  },
  {
    "path": "ark/docs/source.config.ts",
    "content": "import { defineConfig, defineDocs } from \"fumadocs-mdx/config\"\nimport { shikiConfig } from \"./lib/shiki.ts\"\n\nexport const docs = defineDocs({\n\tdir: \"content/docs\",\n\tdocs: {\n\t\tasync: true\n\t}\n})\n\nexport default defineConfig({\n\tmdxOptions: {\n\t\trehypeCodeOptions: shikiConfig\n\t}\n})\n"
  },
  {
    "path": "ark/docs/tsconfig.json",
    "content": "{\n\t\"extends\": \"../../tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t// unfortunately, twoslash doesn't seem to respect customConditions,\n\t\t// so .d.ts will need to be rebuilt to see its static compilation updated\n\t\t\"module\": \"ESNext\",\n\t\t\"moduleResolution\": \"bundler\",\n\t\t\"allowJs\": true,\n\t\t\"jsx\": \"preserve\",\n\t\t// we don't need declarations for docs, and enabling it causes\n\t\t// pnpm resolution errors\n\t\t\"declaration\": false,\n\t\t\"lib\": [\"ESNext\", \"DOM\"],\n\t\t\"plugins\": [\n\t\t\t{\n\t\t\t\t\"name\": \"next\"\n\t\t\t}\n\t\t],\n\t\t\"incremental\": true\n\t},\n\t\"mdx\": {\n\t\t\"checkMdx\": true\n\t},\n\t\"include\": [\n\t\t\"next.config.ts\",\n\t\t\"next-env.d.ts\",\n\t\t\"**/*.ts\",\n\t\t\"**/*.tsx\",\n\t\t\".next/types/**/*.ts\"\n\t],\n\t\"exclude\": [\"node_modules\"],\n\t\"customConditions\": [\"ark-ts\"]\n}\n"
  },
  {
    "path": "ark/extension/.vscode/launch.json",
    "content": "// A launch configuration that launches the extension inside a new window\n{\n\t\"version\": \"0.1.0\",\n\t\"configurations\": [\n\t\t{\n\t\t\t\"name\": \"Debug Extension\",\n\t\t\t\"type\": \"extensionHost\",\n\t\t\t\"request\": \"launch\",\n\t\t\t\"runtimeExecutable\": \"${execPath}\",\n\t\t\t\"args\": [\"--extensionDevelopmentPath=${workspaceRoot}\"]\n\t\t}\n\t]\n}\n"
  },
  {
    "path": "ark/extension/README.md",
    "content": "<div align=\"center\">\n  <img src=\"https://arktype.io/image/logo.png\" height=\"64px\" />\n  <h1>ArkType</h1>\n</div>\n<div align=\"center\">\n\n[ArkType](https://arktype.io) syntax highlighting and inline errors ⛵\n\n[Install the extension](https://marketplace.visualstudio.com/items?itemName=arktypeio.arkdark)\n\n</div>\n\nWe're building a 1:1 validator for TypeScript! Check out our core project [on GitHub](https://github.com/arktypeio/arktype)!\n\n## Features\n\n- syntax highlighting for strings that are part of an ArkType definition\n\n![syntax highlighting](https://raw.githubusercontent.com/arktypeio/arktype/refs/heads/main/ark/extension/highlighting.png)\n\n- inline type error summaries optimized for ArkType via [ErrorLens](https://github.com/usernamehw/vscode-error-lens)\n\n![errorLens](https://raw.githubusercontent.com/arktypeio/arktype/refs/heads/main/ark/extension/errorLens.png)\n\n## Contributing\n\n**Run > Debugger** (`F5` by default) will launch the extension in another window, allowing you to see the effects of your changes on whatever code you open in it.\n\n#### Update syntax highlighting rules\n\nSee [injected.tmLanguage.json](/ark/extension/injected.tmLanguage.json)\n\nTo determine which scopes need to be changed, you can view scopes applied to any file in VSCode by opening the Command Palette (Ctrl+Shift+P by default) and searching \"Developer: Inspect Editor Tokens and Scopes\".\n\nChanges to `injected.tmLanguage.json` should be mirrored to [tsWithArkType.tmLanguage.json](./tsWithArkType.tmLanguage.json).\n\n#### Testing tsWithArkType.tmLanguage.json\n\nTo test the standalone rules for TS w/ ArkType highlighting, replace `grammars` in `package.json` with the following:\n\n```json\n\"grammars\": {\n\t\"scopeName\": \"source.ts\",\n\t\"language\": \"typescript\",\n\t\"path\": \"tsWithArkType.tmLanguage.json\"\n}\n```\n\nBe sure to switch back before publishing!\n\n> [!IMPORTANT]  \n> You must reload the extension host window to see scope changes reflected\n"
  },
  {
    "path": "ark/extension/arktype.scratch.ts",
    "content": "// @ts-nocheck\nimport { scope, type } from \"arktype\"\nimport { hasArkKind } from \"../schema/out/shared/utils\"\n\ntype(\"(boolean | number | 'foo')[]\")\n\n// = should be highlighted as normal\nconst T = type(\"(boolean | number | 'foo')[]\")\n\ntype({\n\tfoo: \"string.normalize.NFC.preformatted\"\n})\n\nconst CreditCard = type(\n\t\"/^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35d{3})d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$/\"\n)\n\nenum Foo {\n\tBar\n}\n\n// Should be highlighted\nFoo.BAR\n\ntype({\n\ta: \"string|number[]\"\n})\n\nexport const tsGenerics = Scope.root({\n\t\"Record<K, V>\": node({ domain: \"object\" })\n})\n\ntype([\"string|numer\", \"[]\"])\n\nconst a = \"string\"\nconst b = \"boolean\"\nconst c = \"number\"\n\nconst T = type(a).and(b).and(c)\nconst z = {\n\ta: true\n}\n\nconst factor = (s: string) => s\n\n// not highlighted\nfactor(\"foo|bar\")\n// not highglighted\nor(\"foo|bar\")\n\n// THIS SHOULD NOT BE HIGHLIGHTED\n// \tconst T = type({\n// \t\t[optional(s)]: \"number\"\n// \t})\n\nconst lOrR = types.l.or(types.r)\n\n// THIS SHOULD NOT BE HIGHLIGHTED\n// attest(T.internal.indexableExpressions).snap()\n\n// THIS SHOULD NOT BE HIGHLIGHTED AS A TYPE\nhasArkKind(\"foo[]\")\n\nconst foo = {\n\tbar: blah.bloo()\n}\n\nconst aTypes = {\n\ta: type(\"string\").anythingNotAKnownChainedMethod(\"\")\n}\n\n// THIS SHOULD BE HIGHLIGHTED\nfor (const [name, schema] of Object.entries(aTypes)) {\n}\n\nconst Ff = type(\"string\").or(\"foobar|baz\")\n\nconst types = scope({ notASpace: { a: type(\"string\") } }).export()\nattest<Type<{ a: string }, Ark>>(types.notASpace)\n\ntest(\"type definition\", () => {\n\tconst types = scope({ a: type(\"string | number\") }).export()\n\tattest<string>(types.a.infer)\n\tattest(() =>\n\t\t// @ts-expect-error\n\t\tscope({ a: type(\"strong\") })\n\t).throwsAndHasTypeError(writeUnresolvableMessage(\"strong\"))\n})\n\nconst $ = scope({\n\tb: \"3.14\",\n\ta: () => $.type(\"number\").pipe(data => `${data}`),\n\taAndB: () => $.type(\"a&b\"),\n\tbAndA: () => $.type(\"b&a\")\n})\n\nscope({\n\t// nested highlighting\n\ta: \"string|number\",\n\tb: [\n\t\t{\n\t\t\tnested: \"a\"\n\t\t}\n\t]\n})\n\ntype({\n\tfoo: \"string[]\"\n})\n\n{\n\tconst type = (arg?: any) => {}\n\ttype({\n\t\tfoo: \"string|number\"\n\t})\n\tconst obj = {\n\t\ttype\n\t}\n\tobj.type({})\n\t// syntax should still be correctly highlighted\n\tconst foo = {}\n\n\tconst outer = (...args: any[]) => obj\n\n\touter(\"ark\", () => {\n\t\tconst ArkType = type({\n\t\t\tnumber: \"number\",\n\t\t\tnegNumber: \"number\",\n\t\t\tmaxNumber: \"number\",\n\t\t\tstring: \"string\",\n\t\t\tlongString: \"string\",\n\t\t\tboolean: \"boolean\",\n\t\t\tdeeplyNested: {\n\t\t\t\tfoo: \"string\",\n\t\t\t\tnum: \"number\",\n\t\t\t\tbool: \"boolean\"\n\t\t\t}\n\t\t})\n\t}).type()\n\tconst T = type(`${2}<Date<${4}`)\n\n\tconst $ = scope({ a: \"string\" })\n\tconst importer = $.scope({ b: \"a\" })\n\n\tconst func = (f: any) => f\n\tconst abc = func($.type(\"string\"))\n}\n\nclass F {\n\tstatic compile(rule: PropRule[]) {\n\t\tconst named = rule.filter(isNamed)\n\t\tif (named.length === rule.length) {\n\t\t\treturn this.compileNamed(named)\n\t\t}\n\t\tconst indexed = rule.filter(isIndexed)\n\t\treturn condition\n\t}\n}\n\n// This is used to generate highlighting.png\nconst Highlighted = type({\n\tliterals: \"'foo' | 'bar' | true\",\n\texpressions: \"boolean[] | 5 < number <= 10 | number % 2\",\n\tpattern: \"/^(?:4[0-9]{12}(?:[0-9]{3,6}))$/\",\n\tbar: \"(string | number)[]\"\n})\n\n// chained calls should be highlighted\nhighlighted.or(\"string[]\").or({ object: \"string[]\" })\n"
  },
  {
    "path": "ark/extension/injected.tmLanguage.json",
    "content": "{\n\t\"$schema\": \"https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json\",\n\t\"name\": \"InjectedArkTypeScript\",\n\t\"scopeName\": \"source.arktype.injection.ts\",\n\t\"injectionSelector\": \"L:source.ts - comment, L:source.tsx - comment, L:source.js - comment, L:source.jsx - comment, L:source.mdx - comment, L:meta.embedded.block.typescript - comment, L:meta.embedded.block.typescriptreact - comment, L:meta.embedded.block.javascript - comment\",\n\t\"patterns\": [\n\t\t{\n\t\t\t\"include\": \"#arkDefinition\"\n\t\t},\n\t\t{\n\t\t\t\"include\": \"#arkChained\"\n\t\t},\n\t\t{\n\t\t\t\"include\": \"#arkRegexFunction\"\n\t\t}\n\t],\n\t\"repository\": {\n\t\t\"arkDefinition\": {\n\t\t\t\"contentName\": \"meta.embedded.arktype.definition\",\n\t\t\t\"begin\": \"([^\\\\)\\\\(\\\\s]+)?(\\\\.)?\\\\b(type|generic|scope|define|match|fn|module|[aA]rk[a-zA-Z]*)(\\\\()\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"punctuation.accessor.ts\"\n\t\t\t\t},\n\t\t\t\t\"3\": {\n\t\t\t\t\t\"name\": \"entity.name.function.ts\"\n\t\t\t\t},\n\t\t\t\t\"4\": {\n\t\t\t\t\t\"name\": \"meta.brace.round.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"\\\\)\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"meta.brace.round.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#arkAll\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"arkChained\": {\n\t\t\t\"contentName\": \"meta.embedded.arktype.definition\",\n\t\t\t\"begin\": \"([^\\\\)\\\\(\\\\s]+)?(\\\\.)\\\\b(and|or|case|in|extends|ifExtends|intersect|merge|exclude|extract|overlaps|subsumes|to|satisfies)(\\\\()\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"punctuation.accessor.ts\"\n\t\t\t\t},\n\t\t\t\t\"3\": {\n\t\t\t\t\t\"name\": \"entity.name.function.ts\"\n\t\t\t\t},\n\t\t\t\t\"4\": {\n\t\t\t\t\t\"name\": \"meta.brace.round.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"\\\\)\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"meta.brace.round.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#arkAll\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"arkQuoted\": {\n\t\t\t\"match\": \"([\\\"'`])(.*?)(\\\\\\\\)*(\\\\1)\",\n\t\t\t\"captures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"string.quoted\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#arkOperator\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#arkRegex\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"name\": \"keyword.operator\",\n\t\t\t\t\t\t\t\"match\": \"[^ \\\\w]\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"source.ts#type\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t\"4\": {\n\t\t\t\t\t\"name\": \"string.quoted\"\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t\"arkRegex\": {\n\t\t\t\"match\": \"(\\\\/)(.*?)(\\\\\\\\)*(\\\\1)\",\n\t\t\t\"captures\": {\n\t\t\t\t\"1\": { \"name\": \"keyword.operator\" },\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"patterns\": [{ \"include\": \"#arkRegexSource\" }]\n\t\t\t\t},\n\t\t\t\t\"4\": { \"name\": \"keyword.operator\" }\n\t\t\t}\n\t\t},\n\t\t\"arkOperator\": {\n\t\t\t\"name\": \"keyword.operator\",\n\t\t\t\"match\": \"[<>=%`'&]|\\\"\"\n\t\t},\n\t\t\"arkObject\": {\n\t\t\t\"begin\": \"(\\\\s*)?\\\\{\",\n\t\t\t\"end\": \"\\\\}\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.block.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.block.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"\\\\w+\\\\:\",\n\t\t\t\t\t\"name\": \"meta.object-literal.key.ts\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#arkAll\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"arkTuple\": {\n\t\t\t\"begin\": \"(\\\\s*)?\\\\[\",\n\t\t\t\"end\": \"\\\\]\",\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#arkAll\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"arkRegexFunction\": {\n\t\t\t\"contentName\": \"meta.embedded.arktype.regex\",\n\t\t\t\"begin\": \"\\\\b(regex)(\\\\()(['\\\"`])\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"entity.name.function.ts\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"meta.brace.round.ts\"\n\t\t\t\t},\n\t\t\t\t\"3\": {\n\t\t\t\t\t\"name\": \"string.quoted.ts punctuation.definition.string.begin.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"(\\\\3)(?:(\\\\)|(,)))\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"string.quoted.ts punctuation.definition.string.end.ts\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"meta.brace.round.ts\"\n\t\t\t\t},\n\t\t\t\t\"3\": {\n\t\t\t\t\t\"name\": \"punctuation.separator.comma.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#arkRegexSource\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"arkRegexSource\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"entity.name.type.ts\",\n\t\t\t\t\t\"match\": \"[A-Za-z]\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"constant.numeric.decimal.ts\",\n\t\t\t\t\t\"match\": \"[0-9]\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.operator\",\n\t\t\t\t\t\"match\": \"[^ \\\\w]\"\n\t\t\t\t},\n\t\t\t\t{ \"include\": \"#arkOperator\" },\n\t\t\t\t{ \"include\": \"#arkQuoted\" }\n\t\t\t]\n\t\t},\n\t\t\"arkAll\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#arkObject\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#arkTuple\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#arkQuoted\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"source.ts#comment\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"source.ts\"\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "ark/extension/package.json",
    "content": "{\n\t\"name\": \"arkdark\",\n\t\"displayName\": \"ArkType\",\n\t\"description\": \"Syntax highlighting and inline errors for ArkType⛵\",\n\t\"version\": \"6.6.0\",\n\t\"publisher\": \"arktypeio\",\n\t\"type\": \"module\",\n\t\"license\": \"MIT\",\n\t\"scripts\": {\n\t\t\"publishExtension\": \"pnpm packageExtension && pnpm publishVsce && pnpm publishOvsx\",\n\t\t\"packageExtension\": \"vsce package --out arkdark.vsix\",\n\t\t\"publishVsce\": \"vsce publish -i arkdark.vsix\",\n\t\t\"publishOvsx\": \"ovsx publish -i arkdark.vsix\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@vscode/vsce\": \"3.6.2\",\n\t\t\"ovsx\": \"0.10.6\"\n\t},\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"https://github.com/arktypeio/arktype\"\n\t},\n\t\"engines\": {\n\t\t\"vscode\": \"^1.0.0\"\n\t},\n\t\"categories\": [\n\t\t\"Programming Languages\"\n\t],\n\t\"icon\": \"icon.png\",\n\t\"exports\": {\n\t\t\"./*.json\": \"./*.json\"\n\t},\n\t\"extensionDependencies\": [\n\t\t\"usernamehw.errorlens\"\n\t],\n\t\"contributes\": {\n\t\t\"grammars\": [\n\t\t\t{\n\t\t\t\t\"injectTo\": [\n\t\t\t\t\t\"source.ts\",\n\t\t\t\t\t\"source.tsx\",\n\t\t\t\t\t\"source.js\",\n\t\t\t\t\t\"source.jsx\",\n\t\t\t\t\t\"source.mdx\",\n\t\t\t\t\t\"source.svelte\",\n\t\t\t\t\t\"source.vue\",\n\t\t\t\t\t\"source.astro\",\n\t\t\t\t\t\"text.html.markdown\"\n\t\t\t\t],\n\t\t\t\t\"scopeName\": \"source.arktype.injection.ts\",\n\t\t\t\t\"path\": \"injected.tmLanguage.json\"\n\t\t\t}\n\t\t],\n\t\t\"configurationDefaults\": {\n\t\t\t\"editor.quickSuggestions\": {\n\t\t\t\t\"strings\": \"on\"\n\t\t\t},\n\t\t\t\"errorLens.followCursor\": \"closestProblem\",\n\t\t\t\"errorLens.delay\": 0,\n\t\t\t\"errorLens.editorHoverPartsEnabled\": {\n\t\t\t\t\"buttonsEnabled\": false\n\t\t\t},\n\t\t\t\"errorLens.replace\": [\n\t\t\t\t{\n\t\t\t\t\t\"matcher\": \".*'ErrorType<\\\"?(.*?)\\\"?>'.*$\",\n\t\t\t\t\t\"message\": \"$1\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"matcher\": \".*brand\\\": \\\"ErrorType\\\"; (.*) \\\\}'\\\\.$\",\n\t\t\t\t\t\"message\": \"$1\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"matcher\": \".*'\\\"(.*[\\\\u200A\\\\u200B])\\\"'\\\\.$\",\n\t\t\t\t\t\"message\": \"$1\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"matcher\": \"^(?:Type|Argument of type) '\\\"(.*)\\\"' is not assignable to (?:parameter of )?type '(\\\"\\\\1.*\\\")'\\\\.\",\n\t\t\t\t\t\"message\": \"$2\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"matcher\": \"[^]*\\n([^\\n]*)$\",\n\t\t\t\t\t\"message\": \"$1\"\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "ark/extension/tsWithArkType.tmLanguage.json",
    "content": "{\n\t\"name\": \"ArkTypeScript\",\n\t\"scopeName\": \"source.ts\",\n\t\"fileTypes\": [\"ts\", \"js\"],\n\t\"patterns\": [\n\t\t{\n\t\t\t\"include\": \"#directives\"\n\t\t},\n\t\t{\n\t\t\t\"include\": \"#statements\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"comment.line.shebang.ts\",\n\t\t\t\"match\": \"\\\\A(#!).*(?=$)\",\n\t\t\t\"captures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.comment.ts\"\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t],\n\t\"repository\": {\n\t\t\"arkDefinition\": {\n\t\t\t\"contentName\": \"meta.embedded.arktype.definition\",\n\t\t\t\"begin\": \"([^\\\\)\\\\(\\\\s]+)?(\\\\.)?\\\\b(type|generic|scope|define|match|fn|module|[aA]rk[a-zA-Z]*)(\\\\()\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"punctuation.accessor.ts\"\n\t\t\t\t},\n\t\t\t\t\"3\": {\n\t\t\t\t\t\"name\": \"entity.name.function.ts\"\n\t\t\t\t},\n\t\t\t\t\"4\": {\n\t\t\t\t\t\"name\": \"meta.brace.round.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"\\\\)\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"meta.brace.round.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#arkAll\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"arkChained\": {\n\t\t\t\"contentName\": \"meta.embedded.arktype.definition\",\n\t\t\t\"begin\": \"([^\\\\)\\\\(\\\\s]+)?(\\\\.)\\\\b(and|or|case|in|extends|ifExtends|intersect|merge|exclude|extract|overlaps|subsumes|to|satisfies)(\\\\()\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"punctuation.accessor.ts\"\n\t\t\t\t},\n\t\t\t\t\"3\": {\n\t\t\t\t\t\"name\": \"entity.name.function.ts\"\n\t\t\t\t},\n\t\t\t\t\"4\": {\n\t\t\t\t\t\"name\": \"meta.brace.round.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"\\\\)\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"meta.brace.round.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#arkAll\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"arkQuoted\": {\n\t\t\t\"match\": \"([\\\"'`])(.*?)(\\\\\\\\)*(\\\\1)\",\n\t\t\t\"captures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"string.quoted\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#arkOperator\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#arkRegex\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"name\": \"keyword.operator\",\n\t\t\t\t\t\t\t\"match\": \"[^ \\\\w]\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"source.ts#type\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t\"4\": {\n\t\t\t\t\t\"name\": \"string.quoted\"\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t\"arkRegex\": {\n\t\t\t\"match\": \"(\\\\/)(.*?)(\\\\\\\\)*(\\\\1)\",\n\t\t\t\"captures\": {\n\t\t\t\t\"1\": { \"name\": \"keyword.operator\" },\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"patterns\": [{ \"include\": \"#arkRegexSource\" }]\n\t\t\t\t},\n\t\t\t\t\"4\": { \"name\": \"keyword.operator\" }\n\t\t\t}\n\t\t},\n\t\t\"arkOperator\": {\n\t\t\t\"name\": \"keyword.operator\",\n\t\t\t\"match\": \"[<>=%`'&]|\\\"\"\n\t\t},\n\t\t\"arkObject\": {\n\t\t\t\"begin\": \"(\\\\s*)?\\\\{\",\n\t\t\t\"end\": \"\\\\}\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.block.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.block.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"\\\\w+\\\\:\",\n\t\t\t\t\t\"name\": \"meta.object-literal.key.ts\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#arkAll\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"arkTuple\": {\n\t\t\t\"begin\": \"(\\\\s*)?\\\\[\",\n\t\t\t\"end\": \"\\\\]\",\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#arkAll\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"arkRegexFunction\": {\n\t\t\t\"contentName\": \"meta.embedded.arktype.regex\",\n\t\t\t\"begin\": \"\\\\b(regex)(\\\\()(['\\\"`])\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"entity.name.function.ts\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"meta.brace.round.ts\"\n\t\t\t\t},\n\t\t\t\t\"3\": {\n\t\t\t\t\t\"name\": \"string.quoted.ts punctuation.definition.string.begin.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"(\\\\3)(?:(\\\\)|(,)))\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"string.quoted.ts punctuation.definition.string.end.ts\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"meta.brace.round.ts\"\n\t\t\t\t},\n\t\t\t\t\"3\": {\n\t\t\t\t\t\"name\": \"punctuation.separator.comma.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#arkRegexSource\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"arkRegexSource\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"entity.name.type.ts\",\n\t\t\t\t\t\"match\": \"[A-Za-z]\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"constant.numeric.decimal.ts\",\n\t\t\t\t\t\"match\": \"[0-9]\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.operator\",\n\t\t\t\t\t\"match\": \"[^ \\\\w]\"\n\t\t\t\t},\n\t\t\t\t{ \"include\": \"#arkOperator\" },\n\t\t\t\t{ \"include\": \"#arkQuoted\" }\n\t\t\t]\n\t\t},\n\t\t\"arkAll\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#arkObject\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#arkTuple\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#arkQuoted\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"source.ts#comment\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"source.ts\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"statements\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#string\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#template\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#literal\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#declaration\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#switch-statement\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#for-loop\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#after-operator-block\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#decl-block\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#control-statement\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#expression\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#punctuation-semicolon\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"var-expr\": {\n\t\t\t\"name\": \"meta.var.expr.ts\",\n\t\t\t\"begin\": \"(?<!\\\\.|\\\\$)(?:(\\\\bexport)\\\\s+)?\\\\b(var|let|const(?!\\\\s+enum\\\\b))\\\\b(?!\\\\$)\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"keyword.control.export.ts\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"storage.type.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"(?=$|;|}|(\\\\s+(of|in)\\\\s+))\",\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#destructuring-variable\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#var-single-variable\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#variable-initializer\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#punctuation-comma\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"var-single-variable\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.var-single-variable.expr.ts\",\n\t\t\t\t\t\"begin\": \"(?x)([_$[:alpha:]][_$[:alnum:]]*)(?=\\\\s* (=\\\\s*( (async\\\\s+) | (function\\\\s*[(<]) | (function\\\\s+) | ([_$[:alpha:]][_$[:alnum:]]*\\\\s*=>) | ((<([^<>]|\\\\<[^<>]+\\\\>)+>\\\\s*)?\\\\(([^()]|\\\\([^()]*\\\\))*\\\\)(\\\\s*:\\\\s*(.)*)?\\\\s*=>)) ) | (:\\\\s*( (<) | ([(]\\\\s*( ([)]) | (\\\\.\\\\.\\\\.) | ([_$[:alnum:]]+\\\\s*( ([:,?=])| ([)]\\\\s*=>) )) ))) ))\",\n\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"entity.name.function.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"end\": \"(?=$|[;,=}]|(\\\\s+(of|in)\\\\s+))\",\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#type-annotation\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#string\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.var-single-variable.expr.ts\",\n\t\t\t\t\t\"begin\": \"([_$[:alpha:]][_$[:alnum:]]*)\",\n\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"variable.other.readwrite.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"end\": \"(?=$|[;,=}]|(\\\\s+(of|in)\\\\s+))\",\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#type-annotation\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#string\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"destructuring-variable\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.object-binding-pattern-variable.ts\",\n\t\t\t\t\t\"begin\": \"(?<!=|:|of|in)\\\\s*(?=\\\\{)\",\n\t\t\t\t\t\"end\": \"(?=$|[;,=}]|(\\\\s+(of|in)\\\\s+))\",\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#object-binding-pattern\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#type-annotation\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.array-binding-pattern-variable.ts\",\n\t\t\t\t\t\"begin\": \"(?<!=|:|of|in)\\\\s*(?=\\\\[)\",\n\t\t\t\t\t\"end\": \"(?=$|[;,=}]|(\\\\s+(of|in)\\\\s+))\",\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#array-binding-pattern\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#type-annotation\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"object-binding-element\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"begin\": \"(?=(([_$[:alpha:]][_$[:alnum:]]*)|(\\\\'[^']*\\\\')|(\\\\\\\"[^\\\"]*\\\\\\\")|(\\\\[([^\\\\[\\\\]]|\\\\[[^\\\\[\\\\]]+\\\\])+\\\\]))\\\\s*(:))\",\n\t\t\t\t\t\"end\": \"(?=,|\\\\})\",\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#object-binding-element-propertyName\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#binding-element\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#object-binding-pattern\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#destructuring-variable-rest\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#variable-initializer\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#punctuation-comma\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"object-binding-element-propertyName\": {\n\t\t\t\"begin\": \"(?=(([_$[:alpha:]][_$[:alnum:]]*)|(\\\\'[^']*\\\\')|(\\\\\\\"[^\\\"]*\\\\\\\")|(\\\\[([^\\\\[\\\\]]|\\\\[[^\\\\[\\\\]]+\\\\])+\\\\]))\\\\s*(:))\",\n\t\t\t\"end\": \"(:)\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.destructuring.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#string\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#array-literal\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"variable.object.property.ts\",\n\t\t\t\t\t\"match\": \"([_$[:alpha:]][_$[:alnum:]]*)\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"binding-element\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#object-binding-pattern\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#array-binding-pattern\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#destructuring-variable-rest\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#variable-initializer\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"destructuring-variable-rest\": {\n\t\t\t\"match\": \"(?:(\\\\.\\\\.\\\\.)\\\\s*)?([_$[:alpha:]][_$[:alnum:]]*)\",\n\t\t\t\"captures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"keyword.operator.rest.ts\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"variable.other.readwrite.ts\"\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t\"object-binding-pattern\": {\n\t\t\t\"begin\": \"(?:(\\\\.\\\\.\\\\.)\\\\s*)?(\\\\{)\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"keyword.operator.rest.ts\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.binding-pattern.object.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"\\\\}\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.binding-pattern.object.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#object-binding-element\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"array-binding-pattern\": {\n\t\t\t\"begin\": \"(?:(\\\\.\\\\.\\\\.)\\\\s*)?(\\\\[)\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"keyword.operator.rest.ts\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.binding-pattern.array.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"\\\\]\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.binding-pattern.array.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#binding-element\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#punctuation-comma\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"ternary-expression\": {\n\t\t\t\"begin\": \"(?=\\\\?)\",\n\t\t\t\"end\": \"(?=$|[;,})\\\\]])\",\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#ternary-operator\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#expression\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"ternary-operator\": {\n\t\t\t\"begin\": \"(\\\\?)\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"keyword.operator.ternary.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"(:)\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"keyword.operator.ternary.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#expression\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"expression\": {\n\t\t\t\"name\": \"meta.expression.ts\",\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#arkDefinition\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#arkChained\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#string\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#regex\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#template\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#literal\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#function-declaration\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#class-or-interface-declaration\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#arrow-function\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#cast\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#ternary-expression\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#new-expr\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#object-literal\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#expression-operators\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#function-call\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#support-objects\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#identifiers\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#paren-expression\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#punctuation-comma\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#punctuation-accessor\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"control-statement\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.control.trycatch.ts\",\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\b(catch|finally|throw|try)\\\\b(?!\\\\$)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.control.loop.ts\",\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\b(break|continue|do|goto|while)\\\\b(?!\\\\$)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.control.flow.ts\",\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\b(return)\\\\b(?!\\\\$)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\b(yield)\\\\b(?!\\\\$)(?:\\\\s*(\\\\*))?\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.control.flow.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.generator.asterisk.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.control.switch.ts\",\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\b(case|default|switch)\\\\b(?!\\\\$)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.control.conditional.ts\",\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\b(else|if)\\\\b(?!\\\\$)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.control.with.ts\",\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\b(with)\\\\b(?!\\\\$)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.other.debugger.ts\",\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\b(debugger)\\\\b(?!\\\\$)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"storage.modifier.ts\",\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\b(declare)\\\\b(?!\\\\$)\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"declaration\": {\n\t\t\t\"name\": \"meta.declaration.ts\",\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#decorator\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#var-expr\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#function-declaration\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#class-or-interface-declaration\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type-declaration\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#enum-declaration\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#namespace-declaration\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#import-equals-declaration\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#import-declaration\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#export-declaration\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"decorator\": {\n\t\t\t\"name\": \"meta.decorator.ts\",\n\t\t\t\"begin\": \"(?<!\\\\.|\\\\$)\\\\@\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.decorator.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"(?=\\\\s)\",\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#expression\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"type-declaration\": {\n\t\t\t\"name\": \"meta.type.declaration.ts\",\n\t\t\t\"begin\": \"(?<!\\\\.|\\\\$)(?:(\\\\bexport)\\\\s+)?\\\\b(type)\\\\b\\\\s+([_$[:alpha:]][_$[:alnum:]]*)\\\\s*\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"keyword.control.export.ts\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"storage.type.type.ts\"\n\t\t\t\t},\n\t\t\t\t\"3\": {\n\t\t\t\t\t\"name\": \"entity.name.type.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"(?=[};]|\\\\bvar\\\\b|\\\\blet\\\\b|\\\\bconst\\\\b|\\\\btype\\\\b|\\\\bfunction\\\\b|\\\\bclass\\\\b|\\\\binterface\\\\b|\\\\bnamespace\\\\b|\\\\bmodule\\\\b|\\\\bimport\\\\b|\\\\benum\\\\b|\\\\bdeclare\\\\b|\\\\bexport\\\\b|\\\\babstract\\\\b|\\\\basync\\\\b)\",\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type-parameters\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"(=)\\\\s*\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.operator.assignment.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"enum-declaration\": {\n\t\t\t\"name\": \"meta.enum.declaration.ts\",\n\t\t\t\"begin\": \"(?<!\\\\.|\\\\$)(?:(\\\\bexport)\\\\s+)?(?:\\\\b(const)\\\\s+)?\\\\b(enum)\\\\s+([_$[:alpha:]][_$[:alnum:]]*)\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"keyword.control.export.ts\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"storage.modifier.ts\"\n\t\t\t\t},\n\t\t\t\t\"3\": {\n\t\t\t\t\t\"name\": \"storage.type.enum.ts\"\n\t\t\t\t},\n\t\t\t\t\"4\": {\n\t\t\t\t\t\"name\": \"entity.name.type.enum.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"(?<=\\\\})\",\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"begin\": \"\\\\{\",\n\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.block.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"end\": \"\\\\}\",\n\t\t\t\t\t\"endCaptures\": {\n\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.block.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"begin\": \"([_$[:alpha:]][_$[:alnum:]]*)\",\n\t\t\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\t\t\"name\": \"variable.other.enummember.ts\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"end\": \"(?=,|\\\\}|$)\",\n\t\t\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"include\": \"#variable-initializer\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"begin\": \"(?=((\\\\'[^']*\\\\')|(\\\\\\\"[^\\\"]*\\\\\\\")|(\\\\[([^\\\\[\\\\]]|\\\\[[^\\\\[\\\\]]+\\\\])+\\\\])))\",\n\t\t\t\t\t\t\t\"end\": \"(?=,|\\\\}|$)\",\n\t\t\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"include\": \"#string\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"include\": \"#array-literal\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"include\": \"#variable-initializer\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#punctuation-comma\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"namespace-declaration\": {\n\t\t\t\"name\": \"meta.namespace.declaration.ts\",\n\t\t\t\"begin\": \"(?<!\\\\.|\\\\$)(?:(\\\\bexport)\\\\s+)?\\\\b(namespace|module)\\\\s+\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"keyword.control.export.ts\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"storage.type.namespace.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"(?=$|\\\\{)\",\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#string\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"entity.name.type.module.ts\",\n\t\t\t\t\t\"match\": \"([_$[:alpha:]][_$[:alnum:]]*)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"punctuation.accessor.ts\",\n\t\t\t\t\t\"match\": \"\\\\.\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"import-equals-declaration\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.import-equals.external.ts\",\n\t\t\t\t\t\"begin\": \"(?<!\\\\.|\\\\$)(?:(\\\\bexport)\\\\s+)?\\\\b(import)\\\\s+([_$[:alpha:]][_$[:alnum:]]*)\\\\s*(=)\\\\s*(require)\\\\s*(\\\\()\",\n\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.control.export.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.control.import.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"3\": {\n\t\t\t\t\t\t\t\"name\": \"variable.other.readwrite.alias.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"4\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.operator.assignment.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"5\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.control.require.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"6\": {\n\t\t\t\t\t\t\t\"name\": \"meta.brace.round.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"end\": \"\\\\)\",\n\t\t\t\t\t\"endCaptures\": {\n\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\"name\": \"meta.brace.round.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#string\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.import-equals.internal.ts\",\n\t\t\t\t\t\"begin\": \"(?<!\\\\.|\\\\$)(?:(\\\\bexport)\\\\s+)?\\\\b(import)\\\\s+([_$[:alpha:]][_$[:alnum:]]*)\\\\s*(=)\\\\s*(?!require\\\\b)\",\n\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.control.export.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.control.import.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"3\": {\n\t\t\t\t\t\t\t\"name\": \"variable.other.readwrite.alias.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"4\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.operator.assignment.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"end\": \"(?=;|$)\",\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"match\": \"([_$[:alpha:]][_$[:alnum:]]*)\\\\s*(\\\\.)\",\n\t\t\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\t\t\"name\": \"entity.name.type.module.ts\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\t\t\"name\": \"punctuation.accessor.ts\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"name\": \"variable.other.readwrite.ts\",\n\t\t\t\t\t\t\t\"match\": \"([_$[:alpha:]][_$[:alnum:]]*)\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"import-declaration\": {\n\t\t\t\"name\": \"meta.import.ts\",\n\t\t\t\"begin\": \"(?<!\\\\.|\\\\$)(?:(\\\\bexport)\\\\s+)?\\\\b(import)(?!(\\\\s*:)|(\\\\$))\\\\b\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"keyword.control.export.ts\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"keyword.control.import.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"(?=;|$)\",\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#import-export-declaration\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"export-declaration\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\b(export)\\\\s+(as)\\\\s+(namespace)\\\\s+([_$[:alpha:]][_$[:alnum:]]*)\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.control.export.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.control.as.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"3\": {\n\t\t\t\t\t\t\t\"name\": \"storage.type.namespace.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"4\": {\n\t\t\t\t\t\t\t\"name\": \"entity.name.type.module.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.export.default.ts\",\n\t\t\t\t\t\"begin\": \"(?<!\\\\.|\\\\$)\\\\b(export)(?:(?:\\\\s*(=))|(?:\\\\s+(default)(?=\\\\s+)))\",\n\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.control.export.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.operator.assignment.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"3\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.control.default.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"end\": \"(?=;|\\\\bexport\\\\b|\\\\bfunction\\\\b|\\\\bclass\\\\b|\\\\binterface\\\\b|\\\\blet\\\\b|\\\\bvar\\\\b|\\\\bconst\\\\b|\\\\bimport\\\\b|\\\\benum\\\\b|\\\\bnamespace\\\\b|\\\\bmodule\\\\b|\\\\btype\\\\b|\\\\babstract\\\\b|\\\\bdeclare\\\\b|\\\\basync\\\\b|$)\",\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#expression\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.export.ts\",\n\t\t\t\t\t\"begin\": \"(?<!\\\\.|\\\\$)\\\\b(export)(?!(\\\\s*:)|(\\\\$))\\\\b\",\n\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.control.export.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"end\": \"(?=;|\\\\bexport\\\\b|\\\\bfunction\\\\b|\\\\bclass\\\\b|\\\\binterface\\\\b|\\\\blet\\\\b|\\\\bvar\\\\b|\\\\bconst\\\\b|\\\\bimport\\\\b|\\\\benum\\\\b|\\\\bnamespace\\\\b|\\\\bmodule\\\\b|\\\\btype\\\\b|\\\\babstract\\\\b|\\\\bdeclare\\\\b|\\\\basync\\\\b|$)\",\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#import-export-declaration\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"import-export-declaration\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#string\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#import-export-block\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.control.from.ts\",\n\t\t\t\t\t\"match\": \"\\\\bfrom\\\\b\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#import-export-clause\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"import-export-block\": {\n\t\t\t\"name\": \"meta.block.ts\",\n\t\t\t\"begin\": \"\\\\{\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.block.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"\\\\}\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.block.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#import-export-clause\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"import-export-clause\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"comment\": \"(default|*|name) as alias\",\n\t\t\t\t\t\"match\": \"(?x) (?: \\\\b(default)\\\\b | (\\\\*) | ([_$[:alpha:]][_$[:alnum:]]*)) \\\\s+  (as) \\\\s+ (?: (\\\\b default \\\\b | \\\\*) | ([_$[:alpha:]][_$[:alnum:]]*))\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.control.default.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"constant.language.import-export-all.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"3\": {\n\t\t\t\t\t\t\t\"name\": \"variable.other.readwrite.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"4\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.control.as.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"5\": {\n\t\t\t\t\t\t\t\"name\": \"invalid.illegal.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"6\": {\n\t\t\t\t\t\t\t\"name\": \"variable.other.readwrite.alias.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#punctuation-comma\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"constant.language.import-export-all.ts\",\n\t\t\t\t\t\"match\": \"\\\\*\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.control.default.ts\",\n\t\t\t\t\t\"match\": \"\\\\b(default)\\\\b\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"variable.other.readwrite.alias.ts\",\n\t\t\t\t\t\"match\": \"([_$[:alpha:]][_$[:alnum:]]*)\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"class-or-interface-declaration\": {\n\t\t\t\"name\": \"meta.class.ts\",\n\t\t\t\"begin\": \"(?<!\\\\.|\\\\$)\\\\b(?:(export)\\\\s+)?\\\\b(?:(abstract)\\\\s+)?\\\\b(?:(class)|(interface))\\\\b\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"keyword.control.export.ts\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"storage.modifier.ts\"\n\t\t\t\t},\n\t\t\t\t\"3\": {\n\t\t\t\t\t\"name\": \"storage.type.class.ts\"\n\t\t\t\t},\n\t\t\t\t\"4\": {\n\t\t\t\t\t\"name\": \"storage.type.interface.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"(?<=\\\\})\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.block.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#class-or-interface-heritage\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"[_$[:alpha:]][_$[:alnum:]]*\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\"name\": \"entity.name.type.class.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type-parameters\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#class-or-interface-body\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"class-or-interface-heritage\": {\n\t\t\t\"begin\": \"(?<!\\\\.|\\\\$)(?:\\\\b(extends|implements)\\\\b)(?!\\\\$)\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"storage.modifier.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"(?=\\\\{)\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.block.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#class-or-interface-heritage\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type-parameters\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"([_$[:alpha:]][_$[:alnum:]]*)\\\\s*(\\\\.)(?=\\\\s*[_$[:alpha:]][_$[:alnum:]]*(\\\\s*\\\\.\\\\s*[_$[:alpha:]][_$[:alnum:]]*)*\\\\s*([,<{]|extends|implements|//|/\\\\*))\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"entity.name.type.module.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.accessor.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"([_$[:alpha:]][_$[:alnum:]]*)(?=\\\\s*([,<{]|extends|implements|//|/\\\\*))\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"entity.other.inherited-class.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#expression\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"class-or-interface-body\": {\n\t\t\t\"begin\": \"\\\\{\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.block.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"\\\\}\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.block.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#string\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#decorator\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#method-declaration\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#indexer-declaration\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#field-declaration\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type-annotation\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#variable-initializer\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#access-modifier\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#property-accessor\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#expression\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#punctuation-comma\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#punctuation-semicolon\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"type-object\": {\n\t\t\t\"name\": \"meta.object.type.ts\",\n\t\t\t\"begin\": \"\\\\{\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.block.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"\\\\}\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.block.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type-object-members\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"type-object-members\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#method-declaration\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#indexer-declaration\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#field-declaration\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type-annotation\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"begin\": \"\\\\.\\\\.\\\\.\",\n\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.operator.spread.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"end\": \"(?=\\\\}|;|,|$)|(?<=\\\\})\",\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#type\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#punctuation-comma\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#punctuation-semicolon\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"field-declaration\": {\n\t\t\t\"name\": \"meta.field.declaration.ts\",\n\t\t\t\"begin\": \"(?<!\\\\()(?:(?<!\\\\.|\\\\$)\\\\b(readonly)\\\\s+)?(?=(([_$[:alpha:]][_$[:alnum:]]*)|(\\\\'[^']*\\\\')|(\\\\\\\"[^\\\"]*\\\\\\\")|(\\\\[([^\\\\[\\\\]]|\\\\[[^\\\\[\\\\]]+\\\\])+\\\\]))\\\\s*(\\\\?\\\\s*)?(=|:))\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"storage.modifier.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"(?=\\\\}|;|,|$)|(?<=\\\\})\",\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#variable-initializer\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"begin\": \"(?=((?:[_$[:alpha:]][_$[:alnum:]]*)|(?:\\\\'[^']*\\\\')|(?:\\\\\\\"[^\\\"]*\\\\\\\")|(\\\\[([^\\\\[\\\\]]|\\\\[[^\\\\[\\\\]]+\\\\])+\\\\]))\\\\s*(\\\\?\\\\s*)?(=|:))\",\n\t\t\t\t\t\"end\": \"(?=[};,=]|$)|(?<=\\\\})\",\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#type-annotation\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#string\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#array-literal\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"name\": \"entity.name.function.ts\",\n\t\t\t\t\t\t\t\"match\": \"(?x)([_$[:alpha:]][_$[:alnum:]]*)(?=(\\\\?\\\\s*)?\\\\s* (=\\\\s*( (async\\\\s+) | (function\\\\s*[(<]) | (function\\\\s+) | ([_$[:alpha:]][_$[:alnum:]]*\\\\s*=>) | ((<([^<>]|\\\\<[^<>]+\\\\>)+>\\\\s*)?\\\\(([^()]|\\\\([^()]*\\\\))*\\\\)(\\\\s*:\\\\s*(.)*)?\\\\s*=>)) ) | (:\\\\s*( (<) | ([(]\\\\s*( ([)]) | (\\\\.\\\\.\\\\.) | ([_$[:alnum:]]+\\\\s*( ([:,?=])| ([)]\\\\s*=>) )) ))) ))\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"name\": \"variable.object.property.ts\",\n\t\t\t\t\t\t\t\"match\": \"[_$[:alpha:]][_$[:alnum:]]*\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"name\": \"keyword.operator.optional.ts\",\n\t\t\t\t\t\t\t\"match\": \"\\\\?\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"method-declaration\": {\n\t\t\t\"name\": \"meta.method.declaration.ts\",\n\t\t\t\"begin\": \"(?<!\\\\.|\\\\$)(?:\\\\b(public|private|protected)\\\\s+)?(?:\\\\b(abstract)\\\\s+)?(?:\\\\b(async)\\\\s+)?(?:\\\\b(get|set)\\\\s+)?(?:(?:\\\\b(?:(new)|(constructor))\\\\b(?!\\\\$|:))|(?:(\\\\*)\\\\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\\\\'[^']*\\\\')|(\\\\\\\"[^\\\"]*\\\\\\\")|(\\\\[([^\\\\[\\\\]]|\\\\[[^\\\\[\\\\]]+\\\\])+\\\\]))\\\\s*(\\\\??))?\\\\s*[\\\\(\\\\<]))\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"storage.modifier.ts\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"storage.modifier.ts\"\n\t\t\t\t},\n\t\t\t\t\"3\": {\n\t\t\t\t\t\"name\": \"storage.modifier.async.ts\"\n\t\t\t\t},\n\t\t\t\t\"4\": {\n\t\t\t\t\t\"name\": \"storage.type.property.ts\"\n\t\t\t\t},\n\t\t\t\t\"5\": {\n\t\t\t\t\t\"name\": \"keyword.operator.new.ts\"\n\t\t\t\t},\n\t\t\t\t\"6\": {\n\t\t\t\t\t\"name\": \"storage.type.ts\"\n\t\t\t\t},\n\t\t\t\t\"7\": {\n\t\t\t\t\t\"name\": \"keyword.generator.asterisk.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"(?=\\\\}|;|,)|(?<=\\\\})\",\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#method-declaration-name\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type-parameters\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#function-parameters\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#return-type\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#method-overload-declaration\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#decl-block\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"method-overload-declaration\": {\n\t\t\t\"begin\": \"(?<!\\\\.|\\\\$)(?:\\\\b(public|private|protected)\\\\s+)?(?:\\\\b(abstract)\\\\s+)?(?:\\\\b(async)\\\\s+)?(?:\\\\b(get|set)\\\\s+)?(?:(?:\\\\b(?:(new)|(constructor))\\\\b(?!\\\\$|:))|(?:(\\\\*)\\\\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\\\\'[^']*\\\\')|(\\\\\\\"[^\\\"]*\\\\\\\")|(\\\\[([^\\\\[\\\\]]|\\\\[[^\\\\[\\\\]]+\\\\])+\\\\]))\\\\s*(\\\\??))?\\\\s*[\\\\(\\\\<]))\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"storage.modifier.ts\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"storage.modifier.ts\"\n\t\t\t\t},\n\t\t\t\t\"3\": {\n\t\t\t\t\t\"name\": \"storage.modifier.async.ts\"\n\t\t\t\t},\n\t\t\t\t\"4\": {\n\t\t\t\t\t\"name\": \"storage.type.property.ts\"\n\t\t\t\t},\n\t\t\t\t\"5\": {\n\t\t\t\t\t\"name\": \"keyword.operator.new.ts\"\n\t\t\t\t},\n\t\t\t\t\"6\": {\n\t\t\t\t\t\"name\": \"storage.type.ts\"\n\t\t\t\t},\n\t\t\t\t\"7\": {\n\t\t\t\t\t\"name\": \"keyword.generator.asterisk.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"(?=\\\\(|\\\\<)\",\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#method-declaration-name\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"method-declaration-name\": {\n\t\t\t\"begin\": \"(?=(([_$[:alpha:]][_$[:alnum:]]*)|(\\\\'[^']*\\\\')|(\\\\\\\"[^\\\"]*\\\\\\\")|(\\\\[([^\\\\[\\\\]]|\\\\[[^\\\\[\\\\]]+\\\\])+\\\\]))\\\\s*(\\\\??)\\\\s*[\\\\(\\\\<])\",\n\t\t\t\"end\": \"(?=\\\\(|\\\\<)\",\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#string\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#array-literal\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"entity.name.function.ts\",\n\t\t\t\t\t\"match\": \"[_$[:alpha:]][_$[:alnum:]]*\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.operator.optional.ts\",\n\t\t\t\t\t\"match\": \"\\\\?\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"indexer-declaration\": {\n\t\t\t\"name\": \"meta.indexer.declaration.ts\",\n\t\t\t\"begin\": \"(?:(?<!\\\\.|\\\\$)\\\\b(readonly)\\\\s*)?(\\\\[)\\\\s*([_$[:alpha:]][_$[:alnum:]]*)\\\\s*(?=:)\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"storage.modifier.ts\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"meta.brace.square.ts\"\n\t\t\t\t},\n\t\t\t\t\"3\": {\n\t\t\t\t\t\"name\": \"variable.parameter.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"(\\\\])\\\\s*(\\\\?\\\\s*)?|$\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"meta.brace.square.ts\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"keyword.operator.optional.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type-annotation\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"function-declaration\": {\n\t\t\t\"name\": \"meta.function.ts\",\n\t\t\t\"begin\": \"(?<!\\\\.|\\\\$)\\\\b(?:(export)\\\\s+)?(?:(async)\\\\s+)?(function\\\\b)(?:\\\\s*(\\\\*))?(?:(?:\\\\s+|(?<=\\\\*))([_$[:alpha:]][_$[:alnum:]]*))?\\\\s*\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"keyword.control.export.ts\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"storage.modifier.async.ts\"\n\t\t\t\t},\n\t\t\t\t\"3\": {\n\t\t\t\t\t\"name\": \"storage.type.function.ts\"\n\t\t\t\t},\n\t\t\t\t\"4\": {\n\t\t\t\t\t\"name\": \"keyword.generator.asterisk.ts\"\n\t\t\t\t},\n\t\t\t\t\"5\": {\n\t\t\t\t\t\"name\": \"entity.name.function.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"(?=;|\\\\})|(?<=\\\\})\",\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type-parameters\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#function-parameters\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#return-type\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#function-overload-declaration\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#decl-block\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"function-overload-declaration\": {\n\t\t\t\"name\": \"meta.function.overload.ts\",\n\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\b(?:(export)\\\\s+)?(?:(async)\\\\s+)?(function\\\\b)(?:\\\\s*(\\\\*))?(?:(?:\\\\s+|(?<=\\\\*))([_$[:alpha:]][_$[:alnum:]]*))?\\\\s*\",\n\t\t\t\"captures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"keyword.control.export.ts\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"storage.modifier.async.ts\"\n\t\t\t\t},\n\t\t\t\t\"3\": {\n\t\t\t\t\t\"name\": \"storage.type.function.ts\"\n\t\t\t\t},\n\t\t\t\t\"4\": {\n\t\t\t\t\t\"name\": \"keyword.generator.asterisk.ts\"\n\t\t\t\t},\n\t\t\t\t\"5\": {\n\t\t\t\t\t\"name\": \"entity.name.function.ts\"\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t\"object-literal\": {\n\t\t\t\"name\": \"meta.objectliteral.ts\",\n\t\t\t\"begin\": \"\\\\{\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.block.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"\\\\}\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.block.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#object-member\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"decl-block\": {\n\t\t\t\"name\": \"meta.block.ts\",\n\t\t\t\"begin\": \"\\\\{\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.block.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"\\\\}\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.block.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#statements\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"after-operator-block\": {\n\t\t\t\"name\": \"meta.objectliteral.ts\",\n\t\t\t\"begin\": \"(?<=[=(,\\\\[?+!]|await|return|yield|throw|in|of|typeof|&&|\\\\|\\\\||\\\\*)\\\\s*(\\\\{)\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.block.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"\\\\}\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.block.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#object-member\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"parameter-name\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"(?x)(?:\\\\s*\\\\b(readonly)\\\\s+)?(?:\\\\s*\\\\b(public|private|protected)\\\\s+)?(\\\\.\\\\.\\\\.)?\\\\s*(?<!=|:)([_$[:alpha:]][_$[:alnum:]]*)\\\\s*(\\\\??)(?=\\\\s* (=\\\\s*( (async\\\\s+) | (function\\\\s*[(<]) | (function\\\\s+) | ([_$[:alpha:]][_$[:alnum:]]*\\\\s*=>) | ((<([^<>]|\\\\<[^<>]+\\\\>)+>\\\\s*)?\\\\(([^()]|\\\\([^()]*\\\\))*\\\\)(\\\\s*:\\\\s*(.)*)?\\\\s*=>)) ) | (:\\\\s*( (<) | ([(]\\\\s*( ([)]) | (\\\\.\\\\.\\\\.) | ([_$[:alnum:]]+\\\\s*( ([:,?=])| ([)]\\\\s*=>) )) ))) ))\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"storage.modifier.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"storage.modifier.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"3\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.operator.rest.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"4\": {\n\t\t\t\t\t\t\t\"name\": \"entity.name.function.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"5\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.operator.optional.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"(?:\\\\s*\\\\b(readonly)\\\\s+)?(?:\\\\s*\\\\b(public|private|protected)\\\\s+)?(\\\\.\\\\.\\\\.)?\\\\s*(?<!=|:)([_$[:alpha:]][_$[:alnum:]]*)\\\\s*(\\\\??)\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"storage.modifier.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"storage.modifier.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"3\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.operator.rest.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"4\": {\n\t\t\t\t\t\t\t\"name\": \"variable.parameter.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"5\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.operator.optional.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"destructuring-parameter\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.parameter.object-binding-pattern.ts\",\n\t\t\t\t\t\"begin\": \"(?<!=|:)\\\\s*(\\\\{)\",\n\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.binding-pattern.object.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"end\": \"\\\\}\",\n\t\t\t\t\t\"endCaptures\": {\n\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.binding-pattern.object.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#parameter-object-binding-element\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.paramter.array-binding-pattern.ts\",\n\t\t\t\t\t\"begin\": \"(?<!=|:)\\\\s*(\\\\[)\",\n\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.binding-pattern.array.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"end\": \"\\\\]\",\n\t\t\t\t\t\"endCaptures\": {\n\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.binding-pattern.array.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#parameter-binding-element\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#punctuation-comma\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"parameter-object-binding-element\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"begin\": \"(?=(([_$[:alpha:]][_$[:alnum:]]*)|(\\\\'[^']*\\\\')|(\\\\\\\"[^\\\"]*\\\\\\\")|(\\\\[([^\\\\[\\\\]]|\\\\[[^\\\\[\\\\]]+\\\\])+\\\\]))\\\\s*(:))\",\n\t\t\t\t\t\"end\": \"(?=,|\\\\})\",\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#object-binding-element-propertyName\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#parameter-binding-element\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#parameter-object-binding-pattern\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#destructuring-parameter-rest\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#variable-initializer\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#punctuation-comma\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"parameter-binding-element\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#parameter-object-binding-pattern\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#parameter-array-binding-pattern\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#destructuring-parameter-rest\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#variable-initializer\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"destructuring-parameter-rest\": {\n\t\t\t\"match\": \"(?:(\\\\.\\\\.\\\\.)\\\\s*)?([_$[:alpha:]][_$[:alnum:]]*)\",\n\t\t\t\"captures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"keyword.operator.rest.ts\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"variable.parameter.ts\"\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t\"parameter-object-binding-pattern\": {\n\t\t\t\"begin\": \"(?:(\\\\.\\\\.\\\\.)\\\\s*)?(\\\\{)\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"keyword.operator.rest.ts\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.binding-pattern.object.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"\\\\}\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.binding-pattern.object.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#parameter-object-binding-element\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"parameter-array-binding-pattern\": {\n\t\t\t\"begin\": \"(?:(\\\\.\\\\.\\\\.)\\\\s*)?(\\\\[)\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"keyword.operator.rest.ts\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.binding-pattern.array.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"\\\\]\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.binding-pattern.array.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#parameter-binding-element\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#punctuation-comma\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"return-type\": {\n\t\t\t\"name\": \"meta.return.type.ts\",\n\t\t\t\"begin\": \"(?<=\\\\))\\\\s*(:)\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"keyword.operator.type.annotation.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"(?<!:)((?=$)|(?=\\\\{|;|//|\\\\}))\",\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.object.type.ts\",\n\t\t\t\t\t\"begin\": \"(?<=:)\\\\s*(\\\\{)\",\n\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.block.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"end\": \"\\\\}\",\n\t\t\t\t\t\"endCaptures\": {\n\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.block.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#type-object-members\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type-predicate-operator\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"type-predicate-operator\": {\n\t\t\t\"name\": \"keyword.operator.expression.is.ts\",\n\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\bis\\\\b(?!\\\\$)\"\n\t\t},\n\t\t\"type-annotation\": {\n\t\t\t\"name\": \"meta.type.annotation.ts\",\n\t\t\t\"begin\": \":\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"keyword.operator.type.annotation.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"(?=$|[,);\\\\}\\\\]]|//)|(?==[^>])|(?<=[\\\\}>\\\\]\\\\)]|[_$[:alpha:]])\\\\s*(?=\\\\{)\",\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"type\": {\n\t\t\t\"name\": \"meta.type.ts\",\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#string\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#numeric-literal\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type-primitive\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type-builtin-literals\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type-parameters\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type-tuple\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type-object\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type-operators\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type-fn-type-parameters\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type-paren-or-function-parameters\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type-function-return-type\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type-name\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"function-parameters\": {\n\t\t\t\"name\": \"meta.parameters.ts\",\n\t\t\t\"begin\": \"\\\\(\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.parameters.begin.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"\\\\)\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.parameters.end.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#decorator\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#destructuring-parameter\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#parameter-name\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type-annotation\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#variable-initializer\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"punctuation.separator.parameter.ts\",\n\t\t\t\t\t\"match\": \",\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"type-primitive\": {\n\t\t\t\"name\": \"support.type.primitive.ts\",\n\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\b(string|number|boolean|symbol|any|void|never)\\\\b(?!\\\\$)\"\n\t\t},\n\t\t\"type-builtin-literals\": {\n\t\t\t\"name\": \"support.type.builtin.ts\",\n\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\b(this|true|false|undefined|null)\\\\b(?!\\\\$)\"\n\t\t},\n\t\t\"type-paren-or-function-parameters\": {\n\t\t\t\"name\": \"meta.type.paren.cover.ts\",\n\t\t\t\"begin\": \"\\\\(\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"meta.brace.round.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"\\\\)\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"meta.brace.round.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#function-parameters\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"type-fn-type-parameters\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.type.constructor.ts\",\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\b(new)\\\\b(?=\\\\s*\\\\<)\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.control.new.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.type.constructor.ts\",\n\t\t\t\t\t\"begin\": \"(?<!\\\\.|\\\\$)\\\\b(new)\\\\b\\\\s*(?=\\\\()\",\n\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.control.new.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"end\": \"(?<=\\\\))\",\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#function-parameters\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.type.function.ts\",\n\t\t\t\t\t\"begin\": \"(?<=\\\\>)\\\\s*(?=\\\\()\",\n\t\t\t\t\t\"end\": \"(?<=\\\\))\",\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#function-parameters\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.type.function.ts\",\n\t\t\t\t\t\"begin\": \"(?x)( (?= [(]\\\\s*( ([)]) |  (\\\\.\\\\.\\\\.) | ([_$[:alnum:]]+\\\\s*( ([:,?=])| ([)]\\\\s*=>) )) ) ) )\",\n\t\t\t\t\t\"end\": \"(?<=\\\\))\",\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#function-parameters\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"type-operators\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#typeof-operator\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.operator.type.ts\",\n\t\t\t\t\t\"match\": \"[&|]\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.operator.expression.keyof.ts\",\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\bkeyof\\\\b(?!\\\\$)\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"type-function-return-type\": {\n\t\t\t\"name\": \"meta.type.function.return.ts\",\n\t\t\t\"begin\": \"=>\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"storage.type.function.arrow.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"(?<!=>)(?=[,\\\\]\\\\)\\\\{\\\\}=;>]|//|$)\",\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.object.type.ts\",\n\t\t\t\t\t\"begin\": \"(?<==>)\\\\s*(\\\\{)\",\n\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.block.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"end\": \"\\\\}\",\n\t\t\t\t\t\"endCaptures\": {\n\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.block.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#type-object-members\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type-predicate-operator\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"type-tuple\": {\n\t\t\t\"name\": \"meta.type.tuple.ts\",\n\t\t\t\"begin\": \"\\\\[\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"meta.brace.square.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"\\\\]\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"meta.brace.square.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#punctuation-comma\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"type-name\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"([_$[:alpha:]][_$[:alnum:]]*)\\\\s*(\\\\.)\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"entity.name.type.module.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.accessor.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"entity.name.type.ts\",\n\t\t\t\t\t\"match\": \"[_$[:alpha:]][_$[:alnum:]]*\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"type-parameters\": {\n\t\t\t\"name\": \"meta.type.parameters.ts\",\n\t\t\t\"begin\": \"(<)\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.typeparameters.begin.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"(?=$)|(>)\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.typeparameters.end.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"storage.modifier.ts\",\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\b(extends)\\\\b(?!\\\\$)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#punctuation-comma\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"variable-initializer\": {\n\t\t\t\"begin\": \"(?<!=|!)(=)(?!=)\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"keyword.operator.assignment.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"(?=$|[,);}\\\\]])\",\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#expression\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"for-loop\": {\n\t\t\t\"begin\": \"(?<!\\\\.|\\\\$)\\\\b(for)\\\\s*(\\\\()\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"keyword.control.loop.ts\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"meta.brace.round.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"\\\\)\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"meta.brace.round.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#var-expr\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#expression\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#punctuation-semicolon\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"switch-expression\": {\n\t\t\t\"name\": \"switch-expression.expr.ts\",\n\t\t\t\"begin\": \"(?<!\\\\.|\\\\$)\\\\b(switch)\\\\s*(\\\\()\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"keyword.control.switch.ts\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"meta.brace.round.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"\\\\)\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"meta.brace.round.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#expression\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"switch-block\": {\n\t\t\t\"name\": \"switch-block.expr.ts\",\n\t\t\t\"begin\": \"{\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.block.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"(?=\\\\})\",\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#case-clause\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#statements\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"case-clause\": {\n\t\t\t\"name\": \"case-clause.expr.ts\",\n\t\t\t\"begin\": \"(?<!\\\\.|\\\\$)\\\\b(case|default(?=:))\\\\b(?!\\\\$)\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"keyword.control.switch.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \":\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.section.case-statement.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#expression\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"switch-statement\": {\n\t\t\t\"name\": \"switch-statement.expr.ts\",\n\t\t\t\"begin\": \"(?<!\\\\.|\\\\$)(?=\\\\bswitch\\\\s*\\\\()\",\n\t\t\t\"end\": \"}\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.block.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#switch-expression\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#switch-block\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"support-objects\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"variable.language.arguments.ts\",\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\b(arguments)\\\\b(?!\\\\$)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"support.class.builtin.ts\",\n\t\t\t\t\t\"match\": \"(?x)(?<!\\\\.|\\\\$)\\\\b(Array|ArrayBuffer|Atomics|Boolean|DataView|Date|Float32Array|Float64Array|Function|Generator |GeneratorFunction|Int8Array|Int16Array|Int32Array|Intl|Map|Number|Object|Promise|Proxy |Reflect|RegExp|Set|SharedArrayBuffer|SIMD|String|Symbol|TypedArray |Uint8Array|Uint16Array|Uint32Array|Uint8ClampedArray|WeakMap|WeakSet)\\\\b(?!\\\\$)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"support.class.error.ts\",\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\b((Eval|Internal|Range|Reference|Syntax|Type|URI)?Error)\\\\b(?!\\\\$)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"support.function.ts\",\n\t\t\t\t\t\"match\": \"(?x)(?<!\\\\.|\\\\$)\\\\b(clear(Interval|Timeout)|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|escape|eval| isFinite|isNaN|parseFloat|parseInt|require|set(Interval|Timeout)|super|unescape|uneval)(?=\\\\s*\\\\()\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"(?x)(?<!\\\\.|\\\\$)\\\\b(Math)(?:\\\\s*(\\\\.)\\\\s*(?:\\n  (abs|acos|acosh|asin|asinh|atan|atan2|atanh|cbrt|ceil|clz32|cos|cosh|exp|\\n  expm1|floor|fround|hypot|imul|log|log10|log1p|log2|max|min|pow|random|\\n  round|sign|sin|sinh|sqrt|tan|tanh|trunc)\\n  |\\n  (E|LN10|LN2|LOG10E|LOG2E|PI|SQRT1_2|SQRT2)))?\\\\b(?!\\\\$)\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"support.constant.math.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.accessor.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"3\": {\n\t\t\t\t\t\t\t\"name\": \"support.function.math.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"4\": {\n\t\t\t\t\t\t\t\"name\": \"support.constant.property.math.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"(?x)(?<!\\\\.|\\\\$)\\\\b(console)(?:\\\\s*(\\\\.)\\\\s*(\\n  assert|clear|count|debug|dir|error|group|groupCollapsed|groupEnd|info|log\\n  |profile|profileEnd|table|time|timeEnd|timeStamp|trace|warn))?\\\\b(?!\\\\$)\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"support.class.console.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.accessor.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"3\": {\n\t\t\t\t\t\t\t\"name\": \"support.function.console.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\b(JSON)(?:\\\\s*(\\\\.)\\\\s*(parse|stringify))?\\\\b(?!\\\\$)\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"support.constant.json.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.accessor.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"3\": {\n\t\t\t\t\t\t\t\"name\": \"support.function.json.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"(?x) (\\\\.) \\\\s* (?:\\n  (constructor|length|prototype|__proto__) \\n  |\\n  (EPSILON|MAX_SAFE_INTEGER|MAX_VALUE|MIN_SAFE_INTEGER|MIN_VALUE|NEGATIVE_INFINITY|POSITIVE_INFINITY))\\\\b(?!\\\\$)\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.accessor.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"support.variable.property.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"3\": {\n\t\t\t\t\t\t\t\"name\": \"support.constant.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"(?x) (?<!\\\\.|\\\\$) \\\\b (?:\\n  (document|event|navigator|performance|screen|window) \\n  |\\n  (AnalyserNode|ArrayBufferView|Attr|AudioBuffer|AudioBufferSourceNode|AudioContext|AudioDestinationNode|AudioListener\\n  |AudioNode|AudioParam|BatteryManager|BeforeUnloadEvent|BiquadFilterNode|Blob|BufferSource|ByteString|CSS|CSSConditionRule\\n  |CSSCounterStyleRule|CSSGroupingRule|CSSMatrix|CSSMediaRule|CSSPageRule|CSSPrimitiveValue|CSSRule|CSSRuleList|CSSStyleDeclaration\\n  |CSSStyleRule|CSSStyleSheet|CSSSupportsRule|CSSValue|CSSValueList|CanvasGradient|CanvasImageSource|CanvasPattern\\n  |CanvasRenderingContext2D|ChannelMergerNode|ChannelSplitterNode|CharacterData|ChromeWorker|CloseEvent|Comment|CompositionEvent\\n  |Console|ConvolverNode|Coordinates|Credential|CredentialsContainer|Crypto|CryptoKey|CustomEvent|DOMError|DOMException\\n  |DOMHighResTimeStamp|DOMImplementation|DOMString|DOMStringList|DOMStringMap|DOMTimeStamp|DOMTokenList|DataTransfer\\n  |DataTransferItem|DataTransferItemList|DedicatedWorkerGlobalScope|DelayNode|DeviceProximityEvent|DirectoryEntry\\n  |DirectoryEntrySync|DirectoryReader|DirectoryReaderSync|Document|DocumentFragment|DocumentTouch|DocumentType|DragEvent\\n  |DynamicsCompressorNode|Element|Entry|EntrySync|ErrorEvent|Event|EventListener|EventSource|EventTarget|FederatedCredential\\n  |FetchEvent|File|FileEntry|FileEntrySync|FileException|FileList|FileReader|FileReaderSync|FileSystem|FileSystemSync\\n  |FontFace|FormData|GainNode|Gamepad|GamepadButton|GamepadEvent|Geolocation|GlobalEventHandlers|HTMLAnchorElement\\n  |HTMLAreaElement|HTMLAudioElement|HTMLBRElement|HTMLBaseElement|HTMLBodyElement|HTMLButtonElement|HTMLCanvasElement\\n  |HTMLCollection|HTMLContentElement|HTMLDListElement|HTMLDataElement|HTMLDataListElement|HTMLDialogElement|HTMLDivElement\\n  |HTMLDocument|HTMLElement|HTMLEmbedElement|HTMLFieldSetElement|HTMLFontElement|HTMLFormControlsCollection|HTMLFormElement\\n  |HTMLHRElement|HTMLHeadElement|HTMLHeadingElement|HTMLHtmlElement|HTMLIFrameElement|HTMLImageElement|HTMLInputElement\\n  |HTMLKeygenElement|HTMLLIElement|HTMLLabelElement|HTMLLegendElement|HTMLLinkElement|HTMLMapElement|HTMLMediaElement\\n  |HTMLMetaElement|HTMLMeterElement|HTMLModElement|HTMLOListElement|HTMLObjectElement|HTMLOptGroupElement|HTMLOptionElement\\n  |HTMLOptionsCollection|HTMLOutputElement|HTMLParagraphElement|HTMLParamElement|HTMLPreElement|HTMLProgressElement\\n  |HTMLQuoteElement|HTMLScriptElement|HTMLSelectElement|HTMLShadowElement|HTMLSourceElement|HTMLSpanElement|HTMLStyleElement\\n  |HTMLTableCaptionElement|HTMLTableCellElement|HTMLTableColElement|HTMLTableDataCellElement|HTMLTableElement|HTMLTableHeaderCellElement\\n  |HTMLTableRowElement|HTMLTableSectionElement|HTMLTextAreaElement|HTMLTimeElement|HTMLTitleElement|HTMLTrackElement\\n  |HTMLUListElement|HTMLUnknownElement|HTMLVideoElement|HashChangeEvent|History|IDBCursor|IDBCursorWithValue|IDBDatabase\\n  |IDBEnvironment|IDBFactory|IDBIndex|IDBKeyRange|IDBMutableFile|IDBObjectStore|IDBOpenDBRequest|IDBRequest|IDBTransaction\\n  |IDBVersionChangeEvent|IIRFilterNode|IdentityManager|ImageBitmap|ImageBitmapFactories|ImageData|Index|InputDeviceCapabilities\\n  |InputEvent|InstallEvent|InstallTrigger|KeyboardEvent|LinkStyle|LocalFileSystem|LocalFileSystemSync|Location|MIDIAccess\\n  |MIDIConnectionEvent|MIDIInput|MIDIInputMap|MIDIOutputMap|MediaElementAudioSourceNode|MediaError|MediaKeyMessageEvent\\n  |MediaKeySession|MediaKeyStatusMap|MediaKeySystemAccess|MediaKeySystemConfiguration|MediaKeys|MediaRecorder|MediaStream\\n  |MediaStreamAudioDestinationNode|MediaStreamAudioSourceNode|MessageChannel|MessageEvent|MessagePort|MouseEvent\\n  |MutationObserver|MutationRecord|NamedNodeMap|Navigator|NavigatorConcurrentHardware|NavigatorGeolocation|NavigatorID\\n  |NavigatorLanguage|NavigatorOnLine|Node|NodeFilter|NodeIterator|NodeList|NonDocumentTypeChildNode|Notification\\n  |OfflineAudioCompletionEvent|OfflineAudioContext|OscillatorNode|PageTransitionEvent|PannerNode|ParentNode|PasswordCredential\\n  |Path2D|PaymentAddress|PaymentRequest|PaymentResponse|Performance|PerformanceEntry|PerformanceFrameTiming|PerformanceMark\\n  |PerformanceMeasure|PerformanceNavigation|PerformanceNavigationTiming|PerformanceObserver|PerformanceObserverEntryList\\n  |PerformanceResourceTiming|PerformanceTiming|PeriodicSyncEvent|PeriodicWave|Plugin|Point|PointerEvent|PopStateEvent\\n  |PortCollection|Position|PositionError|PositionOptions|PresentationConnectionClosedEvent|PresentationConnectionList\\n  |PresentationReceiver|ProcessingInstruction|ProgressEvent|PromiseRejectionEvent|PushEvent|PushRegistrationManager\\n  |RTCCertificate|RTCConfiguration|RTCPeerConnection|RTCSessionDescriptionCallback|RTCStatsReport|RadioNodeList|RandomSource\\n  |Range|ReadableByteStream|RenderingContext|SVGAElement|SVGAngle|SVGAnimateColorElement|SVGAnimateElement|SVGAnimateMotionElement\\n  |SVGAnimateTransformElement|SVGAnimatedAngle|SVGAnimatedBoolean|SVGAnimatedEnumeration|SVGAnimatedInteger|SVGAnimatedLength\\n  |SVGAnimatedLengthList|SVGAnimatedNumber|SVGAnimatedNumberList|SVGAnimatedPoints|SVGAnimatedPreserveAspectRatio\\n  |SVGAnimatedRect|SVGAnimatedString|SVGAnimatedTransformList|SVGAnimationElement|SVGCircleElement|SVGClipPathElement\\n  |SVGCursorElement|SVGDefsElement|SVGDescElement|SVGElement|SVGEllipseElement|SVGEvent|SVGFilterElement|SVGFontElement\\n  |SVGFontFaceElement|SVGFontFaceFormatElement|SVGFontFaceNameElement|SVGFontFaceSrcElement|SVGFontFaceUriElement\\n  |SVGForeignObjectElement|SVGGElement|SVGGlyphElement|SVGGradientElement|SVGHKernElement|SVGImageElement|SVGLength\\n  |SVGLengthList|SVGLineElement|SVGLinearGradientElement|SVGMPathElement|SVGMaskElement|SVGMatrix|SVGMissingGlyphElement\\n  |SVGNumber|SVGNumberList|SVGPathElement|SVGPatternElement|SVGPoint|SVGPolygonElement|SVGPolylineElement|SVGPreserveAspectRatio\\n  |SVGRadialGradientElement|SVGRect|SVGRectElement|SVGSVGElement|SVGScriptElement|SVGSetElement|SVGStopElement|SVGStringList\\n  |SVGStylable|SVGStyleElement|SVGSwitchElement|SVGSymbolElement|SVGTRefElement|SVGTSpanElement|SVGTests|SVGTextElement\\n  |SVGTextPositioningElement|SVGTitleElement|SVGTransform|SVGTransformList|SVGTransformable|SVGUseElement|SVGVKernElement\\n  |SVGViewElement|ServiceWorker|ServiceWorkerContainer|ServiceWorkerGlobalScope|ServiceWorkerRegistration|ServiceWorkerState\\n  |ShadowRoot|SharedWorker|SharedWorkerGlobalScope|SourceBufferList|StereoPannerNode|Storage|StorageEvent|StyleSheet\\n  |StyleSheetList|SubtleCrypto|SyncEvent|Text|TextMetrics|TimeEvent|TimeRanges|Touch|TouchEvent|TouchList|Transferable\\n  |TreeWalker|UIEvent|USVString|VRDisplayCapabilities|ValidityState|WaveShaperNode|WebGL|WebGLActiveInfo|WebGLBuffer\\n  |WebGLContextEvent|WebGLFramebuffer|WebGLProgram|WebGLRenderbuffer|WebGLRenderingContext|WebGLShader|WebGLShaderPrecisionFormat\\n  |WebGLTexture|WebGLTimerQueryEXT|WebGLTransformFeedback|WebGLUniformLocation|WebGLVertexArrayObject|WebGLVertexArrayObjectOES\\n  |WebSocket|WebSockets|WebVTT|WheelEvent|Window|WindowBase64|WindowEventHandlers|WindowTimers|Worker|WorkerGlobalScope\\n  |WorkerLocation|WorkerNavigator|XMLHttpRequest|XMLHttpRequestEventTarget|XMLSerializer|XPathExpression|XPathResult\\n  |XSLTProcessor))\\\\b(?!\\\\$)\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"support.variable.dom.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"support.class.dom.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"(?x) (\\\\.) \\\\s* (?:\\n  (ATTRIBUTE_NODE|CDATA_SECTION_NODE|COMMENT_NODE|DOCUMENT_FRAGMENT_NODE|DOCUMENT_NODE|DOCUMENT_TYPE_NODE\\n  |DOMSTRING_SIZE_ERR|ELEMENT_NODE|ENTITY_NODE|ENTITY_REFERENCE_NODE|HIERARCHY_REQUEST_ERR|INDEX_SIZE_ERR\\n  |INUSE_ATTRIBUTE_ERR|INVALID_CHARACTER_ERR|NO_DATA_ALLOWED_ERR|NO_MODIFICATION_ALLOWED_ERR|NOT_FOUND_ERR\\n  |NOT_SUPPORTED_ERR|NOTATION_NODE|PROCESSING_INSTRUCTION_NODE|TEXT_NODE|WRONG_DOCUMENT_ERR)\\n  |\\n  (_content|[xyz]|abbr|above|accept|acceptCharset|accessKey|action|align|[av]Link(?:color)?|all|alt|anchors|appCodeName\\n  |appCore|applets|appMinorVersion|appName|appVersion|archive|areas|arguments|attributes|availHeight|availLeft|availTop\\n  |availWidth|axis|background|backgroundColor|backgroundImage|below|bgColor|body|border|borderBottomWidth|borderColor\\n  |borderLeftWidth|borderRightWidth|borderStyle|borderTopWidth|borderWidth|bottom|bufferDepth|callee|caller|caption\\n  |cellPadding|cells|cellSpacing|ch|characterSet|charset|checked|childNodes|chOff|cite|classes|className|clear\\n  |clientInformation|clip|clipBoardData|closed|code|codeBase|codeType|color|colorDepth|cols|colSpan|compact|complete\\n  |components|content|controllers|cookie|cookieEnabled|cords|cpuClass|crypto|current|data|dateTime|declare|defaultCharset\\n  |defaultChecked|defaultSelected|defaultStatus|defaultValue|defaultView|defer|description|dialogArguments|dialogHeight\\n  |dialogLeft|dialogTop|dialogWidth|dir|directories|disabled|display|docmain|doctype|documentElement|elements|embeds\\n  |enabledPlugin|encoding|enctype|entities|event|expando|external|face|fgColor|filename|firstChild|fontFamily|fontSize\\n  |fontWeight|form|formName|forms|frame|frameBorder|frameElement|frames|hasFocus|hash|headers|height|history|host\\n  |hostname|href|hreflang|hspace|htmlFor|httpEquiv|id|ids|ignoreCase|images|implementation|index|innerHeight|innerWidth\\n  |input|isMap|label|lang|language|lastChild|lastIndex|lastMatch|lastModified|lastParen|layer[sXY]|left|leftContext\\n  |lineHeight|link|linkColor|links|listStyleType|localName|location|locationbar|longDesc|lowsrc|lowSrc|marginBottom\\n  |marginHeight|marginLeft|marginRight|marginTop|marginWidth|maxLength|media|menubar|method|mimeTypes|multiline|multiple\\n  |name|nameProp|namespaces|namespaceURI|next|nextSibling|nodeName|nodeType|nodeValue|noHref|noResize|noShade|notationName\\n  |notations|noWrap|object|offscreenBuffering|onLine|onreadystatechange|opener|opsProfile|options|oscpu|outerHeight\\n  |outerWidth|ownerDocument|paddingBottom|paddingLeft|paddingRight|paddingTop|page[XY]|page[XY]Offset|parent|parentLayer\\n  |parentNode|parentWindow|pathname|personalbar|pixelDepth|pkcs11|platform|plugins|port|prefix|previous|previousDibling\\n  |product|productSub|profile|profileend|prompt|prompter|protocol|publicId|readOnly|readyState|referrer|rel|responseText\\n  |responseXML|rev|right|rightContext|rowIndex|rows|rowSpan|rules|scheme|scope|screen[XY]|screenLeft|screenTop|scripts\\n  |scrollbars|scrolling|sectionRowIndex|security|securityPolicy|selected|selectedIndex|selection|self|shape|siblingAbove\\n  |siblingBelow|size|source|specified|standby|start|status|statusbar|statusText|style|styleSheets|suffixes|summary\\n  |systemId|systemLanguage|tagName|tags|target|tBodies|text|textAlign|textDecoration|textIndent|textTransform|tFoot|tHead\\n  |title|toolbar|top|type|undefined|uniqueID|updateInterval|URL|URLUnencoded|useMap|userAgent|userLanguage|userProfile\\n  |vAlign|value|valueType|vendor|vendorSub|version|visibility|vspace|whiteSpace|width|X[MS]LDocument|zIndex))\\\\b(?!\\\\$|\\\\s*(<([^<>]|\\\\<[^<>]+\\\\>)+>\\\\s*)?\\\\()\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.accessor.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"support.constant.dom.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"3\": {\n\t\t\t\t\t\t\t\"name\": \"support.variable.property.dom.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"support.class.node.ts\",\n\t\t\t\t\t\"match\": \"(?x)(?<!\\\\.|\\\\$)\\\\b(Buffer|EventEmitter|Server|Pipe|Socket|REPLServer|ReadStream|WriteStream|Stream\\n  |Inflate|Deflate|InflateRaw|DeflateRaw|GZip|GUnzip|Unzip|Zip)\\\\b(?!\\\\$)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"support.module.node.ts\",\n\t\t\t\t\t\"match\": \"(?x)(?<!\\\\.|\\\\$)\\\\b(assert|buffer|child_process|cluster|constants|crypto|dgram|dns|domain|events|fs|http|https|net\\n  |os|path|punycode|querystring|readline|repl|stream|string_decoder|timers|tls|tty|url|util|vm|zlib)\\\\b(?!\\\\$)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"(?x)(?<!\\\\.|\\\\$)\\\\b(process)(?:(\\\\.)(?:\\n  (arch|argv|config|connected|env|execArgv|execPath|exitCode|mainModule|pid|platform|release|stderr|stdin|stdout|title|version|versions)\\n  |\\n  (abort|chdir|cwd|disconnect|exit|[sg]ete?[gu]id|send|[sg]etgroups|initgroups|kill|memoryUsage|nextTick|umask|uptime|hrtime)\\n))?\\\\b(?!\\\\$)\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"support.variable.object.process.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.accessor.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"3\": {\n\t\t\t\t\t\t\t\"name\": \"support.variable.property.process.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"4\": {\n\t\t\t\t\t\t\t\"name\": \"support.function.process.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\b(?:(exports)|(module)(?:(\\\\.)(exports|id|filename|loaded|parent|children))?)\\\\b(?!\\\\$)\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"support.type.object.module.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"support.type.object.module.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"3\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.accessor.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"4\": {\n\t\t\t\t\t\t\t\"name\": \"support.type.object.module.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"support.variable.object.node.ts\",\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\b(global|GLOBAL|root|__dirname|__filename)\\\\b(?!\\\\$)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"(?x) (\\\\.) \\\\s* \\n(?:\\n (on(?:Rowsinserted|Rowsdelete|Rowenter|Rowexit|Resize|Resizestart|Resizeend|Reset|\\n   Readystatechange|Mouseout|Mouseover|Mousedown|Mouseup|Mousemove|\\n   Before(?:cut|deactivate|unload|update|paste|print|editfocus|activate)|\\n   Blur|Scrolltop|Submit|Select|Selectstart|Selectionchange|Hover|Help|\\n   Change|Contextmenu|Controlselect|Cut|Cellchange|Clock|Close|Deactivate|\\n   Datasetchanged|Datasetcomplete|Dataavailable|Drop|Drag|Dragstart|Dragover|\\n   Dragdrop|Dragenter|Dragend|Dragleave|Dblclick|Unload|Paste|Propertychange|Error|\\n   Errorupdate|Keydown|Keyup|Keypress|Focus|Load|Activate|Afterupdate|Afterprint|Abort)\\n ) |\\n (shift|showModelessDialog|showModalDialog|showHelp|scroll|scrollX|scrollByPages|\\n   scrollByLines|scrollY|scrollTo|stop|strike|sizeToContent|sidebar|signText|sort|\\n   sup|sub|substr|substring|splice|split|send|set(?:Milliseconds|Seconds|Minutes|Hours|\\n   Month|Year|FullYear|Date|UTC(?:Milliseconds|Seconds|Minutes|Hours|Month|FullYear|Date)|\\n   Time|Hotkeys|Cursor|ZOptions|Active|Resizable|RequestHeader)|search|slice|\\n   savePreferences|small|home|handleEvent|navigate|char|charCodeAt|charAt|concat|\\n   contextual|confirm|compile|clear|captureEvents|call|createStyleSheet|createPopup|\\n   createEventObject|to(?:GMTString|UTCString|String|Source|UpperCase|LowerCase|LocaleString)|\\n   test|taint|taintEnabled|indexOf|italics|disableExternalCapture|dump|detachEvent|unshift|\\n   untaint|unwatch|updateCommands|join|javaEnabled|pop|push|plugins.refresh|paddings|parse|\\n   print|prompt|preference|enableExternalCapture|exec|execScript|valueOf|UTC|find|file|\\n   fileModifiedDate|fileSize|fileCreatedDate|fileUpdatedDate|fixed|fontsize|fontcolor|\\n   forward|fromCharCode|watch|link|load|lastIndexOf|anchor|attachEvent|atob|apply|alert|\\n   abort|routeEvents|resize|resizeBy|resizeTo|recalc|returnValue|replace|reverse|reload|\\n   releaseCapture|releaseEvents|go|get(?:Milliseconds|Seconds|Minutes|Hours|Month|Day|Year|FullYear|\\n   Time|Date|TimezoneOffset|UTC(?:Milliseconds|Seconds|Minutes|Hours|Day|Month|FullYear|Date)|\\n   Attention|Selection|ResponseHeader|AllResponseHeaders)|moveBy|moveBelow|moveTo|\\n   moveToAbsolute|moveAbove|mergeAttributes|match|margins|btoa|big|bold|borderWidths|blink|back\\n ) |\\n (acceptNode|add|addEventListener|addTextTrack|adoptNode|after|animate|append|\\n   appendChild|appendData|before|blur|canPlayType|captureStream|\\n   caretPositionFromPoint|caretRangeFromPoint|checkValidity|clear|click|\\n   cloneContents|cloneNode|cloneRange|close|closest|collapse|\\n   compareBoundaryPoints|compareDocumentPosition|comparePoint|contains|\\n   convertPointFromNode|convertQuadFromNode|convertRectFromNode|createAttribute|\\n   createAttributeNS|createCaption|createCDATASection|createComment|\\n   createContextualFragment|createDocument|createDocumentFragment|\\n   createDocumentType|createElement|createElementNS|createEntityReference|\\n   createEvent|createExpression|createHTMLDocument|createNodeIterator|\\n   createNSResolver|createProcessingInstruction|createRange|createShadowRoot|\\n   createTBody|createTextNode|createTFoot|createTHead|createTreeWalker|delete|\\n   deleteCaption|deleteCell|deleteContents|deleteData|deleteRow|deleteTFoot|\\n   deleteTHead|detach|disconnect|dispatchEvent|elementFromPoint|elementsFromPoint|\\n   enableStyleSheetsForSet|entries|evaluate|execCommand|exitFullscreen|\\n   exitPointerLock|expand|extractContents|fastSeek|firstChild|focus|forEach|get|\\n   getAll|getAnimations|getAttribute|getAttributeNames|getAttributeNode|\\n   getAttributeNodeNS|getAttributeNS|getBoundingClientRect|getBoxQuads|\\n   getClientRects|getContext|getDestinationInsertionPoints|getElementById|\\n   getElementsByClassName|getElementsByName|getElementsByTagName|\\n   getElementsByTagNameNS|getItem|getNamedItem|getSelection|getStartDate|\\n   getVideoPlaybackQuality|has|hasAttribute|hasAttributeNS|hasAttributes|\\n   hasChildNodes|hasFeature|hasFocus|importNode|initEvent|insertAdjacentElement|\\n   insertAdjacentHTML|insertAdjacentText|insertBefore|insertCell|insertData|\\n   insertNode|insertRow|intersectsNode|isDefaultNamespace|isEqualNode|\\n   isPointInRange|isSameNode|item|key|keys|lastChild|load|lookupNamespaceURI|\\n   lookupPrefix|matches|move|moveAttribute|moveAttributeNode|moveChild|\\n   moveNamedItem|namedItem|nextNode|nextSibling|normalize|observe|open|\\n   parentNode|pause|play|postMessage|prepend|preventDefault|previousNode|\\n   previousSibling|probablySupportsContext|queryCommandEnabled|\\n   queryCommandIndeterm|queryCommandState|queryCommandSupported|queryCommandValue|\\n   querySelector|querySelectorAll|registerContentHandler|registerElement|\\n   registerProtocolHandler|releaseCapture|releaseEvents|remove|removeAttribute|\\n   removeAttributeNode|removeAttributeNS|removeChild|removeEventListener|\\n   removeItem|replace|replaceChild|replaceData|replaceWith|reportValidity|\\n   requestFullscreen|requestPointerLock|reset|scroll|scrollBy|scrollIntoView|\\n   scrollTo|seekToNextFrame|select|selectNode|selectNodeContents|set|setAttribute|\\n   setAttributeNode|setAttributeNodeNS|setAttributeNS|setCapture|\\n   setCustomValidity|setEnd|setEndAfter|setEndBefore|setItem|setNamedItem|\\n   setRangeText|setSelectionRange|setSinkId|setStart|setStartAfter|setStartBefore|\\n   slice|splitText|stepDown|stepUp|stopImmediatePropagation|stopPropagation|\\n   submit|substringData|supports|surroundContents|takeRecords|terminate|toBlob|\\n   toDataURL|toggle|toString|values|write|writeln\\n )\\n)(?=\\\\s*\\\\()\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.accessor.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"support.function.event-handler.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"3\": {\n\t\t\t\t\t\t\t\"name\": \"support.function.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"4\": {\n\t\t\t\t\t\t\t\"name\": \"support.function.dom.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"function-call\": {\n\t\t\t\"begin\": \"(?=(\\\\.\\\\s*)?([_$[:alpha:]][_$[:alnum:]]*)\\\\s*(<([^<>]|\\\\<[^<>]+\\\\>)+>\\\\s*)?\\\\()\",\n\t\t\t\"end\": \"(?<=\\\\))(?!(\\\\.\\\\s*)?([_$[:alpha:]][_$[:alnum:]]*)\\\\s*(<([^<>]|\\\\<[^<>]+\\\\>)+>\\\\s*)?\\\\()\",\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#support-objects\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"punctuation.accessor.ts\",\n\t\t\t\t\t\"match\": \"\\\\.\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"entity.name.function.ts\",\n\t\t\t\t\t\"match\": \"([_$[:alpha:]][_$[:alnum:]]*)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.type.parameters.ts\",\n\t\t\t\t\t\"begin\": \"\\\\<\",\n\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.typeparameters.begin.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"end\": \"\\\\>\",\n\t\t\t\t\t\"endCaptures\": {\n\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.typeparameters.end.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#type\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#punctuation-comma\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#paren-expression\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"identifiers\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"support.class.ts\",\n\t\t\t\t\t\"match\": \"([_$[:alpha:]][_$[:alnum:]]*)(?=\\\\s*\\\\.\\\\s*prototype\\\\b(?!\\\\$))\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"(?x)(\\\\.)\\\\s*(?:\\n  ([[:upper:]][_$[:digit:][:upper:]]*) |\\n  ([_$[:alpha:]][_$[:alnum:]]*)\\n)(?=\\\\s*\\\\.\\\\s*[_$[:alpha:]][_$[:alnum:]]*)\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.accessor.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"constant.other.object.property.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"3\": {\n\t\t\t\t\t\t\t\"name\": \"variable.other.object.property.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"(?x)(?:(\\\\.)\\\\s*)?([_$[:alpha:]][_$[:alnum:]]*)(?=\\\\s*=\\\\s*( (async\\\\s+)|(function\\\\s*[(<])|(function\\\\s+)| ([_$[:alpha:]][_$[:alnum:]]*\\\\s*=>)| ((<([^<>]|\\\\<[^<>]+\\\\>)+>\\\\s*)?\\\\(([^()]|\\\\([^()]*\\\\))*\\\\)(\\\\s*:\\\\s*(.)*)?\\\\s*=>)))\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.accessor.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"entity.name.function.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"(\\\\.)\\\\s*([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.accessor.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"constant.other.property.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"(\\\\.)\\\\s*([_$[:alpha:]][_$[:alnum:]]*)\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.accessor.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"variable.other.property.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"(?x)(?:\\n  ([[:upper:]][_$[:digit:][:upper:]]*) |\\n  ([_$[:alpha:]][_$[:alnum:]]*)\\n)(?=\\\\s*\\\\.\\\\s*[_$[:alpha:]][_$[:alnum:]]*)\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"constant.other.object.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"variable.other.object.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"constant.other.ts\",\n\t\t\t\t\t\"match\": \"([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"variable.other.readwrite.ts\",\n\t\t\t\t\t\"match\": \"[_$[:alpha:]][_$[:alnum:]]*\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"cast\": {\n\t\t\t\"name\": \"cast.expr.ts\",\n\t\t\t\"begin\": \"(?:(?<=return|throw|yield|await|default|[=(,:>*]))\\\\s*(<)(?!<?\\\\=)\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"meta.brace.angle.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \">\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"meta.brace.angle.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"new-expr\": {\n\t\t\t\"name\": \"new.expr.ts\",\n\t\t\t\"begin\": \"(?<!\\\\.|\\\\$)\\\\b(new)\\\\b(?!\\\\$)\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"keyword.operator.new.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"(?<=\\\\))|(?=[;),]|$|((?<!\\\\.|\\\\$)\\\\bnew\\\\b(?!\\\\$)))\",\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#paren-expression\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#class-or-interface-declaration\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"object-member\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#method-declaration\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.object.member.ts\",\n\t\t\t\t\t\"begin\": \"(?=(?:(?:\\\\'[^']*\\\\')|(?:\\\\\\\"[^\\\"]*\\\\\\\")|(?:\\\\[([^\\\\[\\\\]]|\\\\[[^\\\\[\\\\]]+\\\\])+\\\\]))\\\\s*:)\",\n\t\t\t\t\t\"end\": \"(?=,|\\\\})\",\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"name\": \"meta.object-literal.key.ts\",\n\t\t\t\t\t\t\t\"begin\": \"(?=(?:(?:\\\\'[^']*\\\\')|(?:\\\\\\\"[^\\\"]*\\\\\\\")|(?:\\\\[([^\\\\[\\\\]]|\\\\[[^\\\\[\\\\]]+\\\\])+\\\\]))\\\\s*:)\",\n\t\t\t\t\t\t\t\"end\": \":\",\n\t\t\t\t\t\t\t\"endCaptures\": {\n\t\t\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\t\t\"name\": \"punctuation.separator.key-value.ts\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"include\": \"#string\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"include\": \"#array-literal\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#expression\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.object.member.ts\",\n\t\t\t\t\t\"begin\": \"(?x)(?:([_$[:alpha:]][_$[:alnum:]]*)\\\\s*(:)(?=\\\\s*( (async\\\\s+)|(function\\\\s*[(<])|(function\\\\s+)| ([_$[:alpha:]][_$[:alnum:]]*\\\\s*=>)| ((<([^<>]|\\\\<[^<>]+\\\\>)+>\\\\s*)?\\\\(([^()]|\\\\([^()]*\\\\))*\\\\)(\\\\s*:\\\\s*(.)*)?\\\\s*=>))))\",\n\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\"name\": \"meta.object-literal.key.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"entity.name.function.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.separator.key-value.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"end\": \"(?=,|\\\\})\",\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#expression\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.object.member.ts\",\n\t\t\t\t\t\"begin\": \"(?:[_$[:alpha:]][_$[:alnum:]]*)\\\\s*(:)\",\n\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\"name\": \"meta.object-literal.key.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.separator.key-value.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"end\": \"(?=,|\\\\})\",\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#expression\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.object.member.ts\",\n\t\t\t\t\t\"begin\": \"\\\\.\\\\.\\\\.\",\n\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.operator.spread.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"end\": \"(?=,|\\\\})\",\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#expression\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.object.member.ts\",\n\t\t\t\t\t\"match\": \"([_$[:alpha:]][_$[:alnum:]]*)\\\\s*(?=,|\\\\}|$)\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"variable.other.readwrite.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#punctuation-comma\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"expression-operators\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.control.flow.ts\",\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\b(await)\\\\b(?!\\\\$)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.operator.expression.delete.ts\",\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\bdelete\\\\b(?!\\\\$)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.operator.expression.in.ts\",\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\bin\\\\b(?!\\\\$)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.operator.expression.of.ts\",\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\bof\\\\b(?!\\\\$)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.operator.expression.instanceof.ts\",\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\binstanceof\\\\b(?!\\\\$)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.operator.new.ts\",\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\bnew\\\\b(?!\\\\$)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#typeof-operator\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.operator.expression.void.ts\",\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\bvoid\\\\b(?!\\\\$)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"begin\": \"(?<!\\\\.|\\\\$)\\\\bas\\\\b(?!\\\\$)\",\n\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.control.as.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"end\": \"(?=$|[;,:})\\\\]])\",\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#type\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.operator.spread.ts\",\n\t\t\t\t\t\"match\": \"\\\\.\\\\.\\\\.\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.operator.assignment.compound.ts\",\n\t\t\t\t\t\"match\": \"\\\\*=|(?<!\\\\()/=|%=|\\\\+=|\\\\-=\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.operator.assignment.compound.bitwise.ts\",\n\t\t\t\t\t\"match\": \"\\\\&=|\\\\^=|<<=|>>=|>>>=|\\\\|=\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.operator.bitwise.shift.ts\",\n\t\t\t\t\t\"match\": \"<<|>>>|>>\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.operator.comparison.ts\",\n\t\t\t\t\t\"match\": \"===|!==|==|!=\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.operator.relational.ts\",\n\t\t\t\t\t\"match\": \"<=|>=|<>|<|>\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.operator.logical.ts\",\n\t\t\t\t\t\"match\": \"\\\\!|&&|\\\\|\\\\|\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.operator.bitwise.ts\",\n\t\t\t\t\t\"match\": \"\\\\&|~|\\\\^|\\\\|\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.operator.assignment.ts\",\n\t\t\t\t\t\"match\": \"\\\\=\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.operator.decrement.ts\",\n\t\t\t\t\t\"match\": \"--\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.operator.increment.ts\",\n\t\t\t\t\t\"match\": \"\\\\+\\\\+\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.operator.arithmetic.ts\",\n\t\t\t\t\t\"match\": \"%|\\\\*|/|-|\\\\+\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"(?<=[_$[:alnum:]])\\\\s*(/)(?![/*])\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.operator.arithmetic.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"typeof-operator\": {\n\t\t\t\"name\": \"keyword.operator.expression.typeof.ts\",\n\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\btypeof\\\\b(?!\\\\$)\"\n\t\t},\n\t\t\"arrow-function\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.arrow.ts\",\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)(\\\\basync)(?=\\\\s*[<(])\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"storage.modifier.async.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.arrow.ts\",\n\t\t\t\t\t\"match\": \"(?:(?<!\\\\.|\\\\$)(\\\\basync)\\\\s*)?([_$[:alpha:]][_$[:alnum:]]*)\\\\s*(?==>)\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"storage.modifier.async.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"variable.parameter.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.arrow.ts\",\n\t\t\t\t\t\"begin\": \"(?x)\\\\s*(?=(<([^<>]|\\\\<[^<>]+\\\\>)+>\\\\s*)?\\\\(([^()]|\\\\([^()]*\\\\))*\\\\)(\\\\s*:\\\\s*(.)*)?\\\\s*=>)\",\n\t\t\t\t\t\"end\": \"(?==>)\",\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#comment\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#type-parameters\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#function-parameters\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#arrow-return-type\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.arrow.ts\",\n\t\t\t\t\t\"begin\": \"=>\",\n\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\"name\": \"storage.type.function.arrow.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"end\": \"(?<=\\\\})|((?!\\\\{)(?=\\\\S))\",\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#decl-block\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#expression\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"arrow-return-type\": {\n\t\t\t\"name\": \"meta.return.type.arrow.ts\",\n\t\t\t\"begin\": \"(?<=\\\\))\\\\s*(:)\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"keyword.operator.type.annotation.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"(?<!:)((?=$)|(?==>|;|//))\",\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type-predicate-operator\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#type\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"punctuation-comma\": {\n\t\t\t\"name\": \"punctuation.separator.comma.ts\",\n\t\t\t\"match\": \",\"\n\t\t},\n\t\t\"punctuation-semicolon\": {\n\t\t\t\"name\": \"punctuation.terminator.statement.ts\",\n\t\t\t\"match\": \";\"\n\t\t},\n\t\t\"punctuation-accessor\": {\n\t\t\t\"name\": \"punctuation.accessor.ts\",\n\t\t\t\"match\": \"\\\\.\"\n\t\t},\n\t\t\"paren-expression\": {\n\t\t\t\"begin\": \"\\\\(\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"meta.brace.round.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"\\\\)\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"meta.brace.round.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#expression\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#punctuation-comma\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"qstring-double\": {\n\t\t\t\"name\": \"string.quoted.double.ts\",\n\t\t\t\"begin\": \"\\\"\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.string.begin.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"(\\\")|((?:[^\\\\\\\\\\\\n])$)\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.string.end.ts\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"invalid.illegal.newline.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#string-character-escape\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"qstring-single\": {\n\t\t\t\"name\": \"string.quoted.single.ts\",\n\t\t\t\"begin\": \"'\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.string.begin.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"(\\\\')|((?:[^\\\\\\\\\\\\n])$)\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.string.end.ts\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"invalid.illegal.newline.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#string-character-escape\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"regex\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"string.regex.ts\",\n\t\t\t\t\t\"begin\": \"(?<=[=(:,\\\\[?+!]|return|case|=>|&&|\\\\|\\\\||\\\\*\\\\/)\\\\s*(/)(?![/*])(?=(?:[^/\\\\\\\\\\\\[]|\\\\\\\\.|\\\\[([^\\\\]\\\\\\\\]|\\\\\\\\.)+\\\\])+/(?![/*])[gimy]*(?!\\\\s*[a-zA-Z0-9_$]))\",\n\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.string.begin.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"end\": \"(/)([gimuy]*)\",\n\t\t\t\t\t\"endCaptures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.string.end.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.other.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#regexp\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"string.regex.ts\",\n\t\t\t\t\t\"begin\": \"/(?![/*])(?=(?:[^/\\\\\\\\\\\\[]|\\\\\\\\.|\\\\[([^\\\\]\\\\\\\\]|\\\\\\\\.)+\\\\])+/(?![/*])[gimy]*(?!\\\\s*[a-zA-Z0-9_$]))\",\n\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.string.begin.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"end\": \"(/)([gimuy]*)\",\n\t\t\t\t\t\"endCaptures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.string.end.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.other.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#regexp\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"regexp\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.control.anchor.regexp\",\n\t\t\t\t\t\"match\": \"\\\\\\\\[bB]|\\\\^|\\\\$\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.other.back-reference.regexp\",\n\t\t\t\t\t\"match\": \"\\\\\\\\[1-9]\\\\d*\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.operator.quantifier.regexp\",\n\t\t\t\t\t\"match\": \"[?+*]|\\\\{(\\\\d+,\\\\d+|\\\\d+,|,\\\\d+|\\\\d+)\\\\}\\\\??\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"keyword.operator.or.regexp\",\n\t\t\t\t\t\"match\": \"\\\\|\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.group.assertion.regexp\",\n\t\t\t\t\t\"begin\": \"(\\\\()((\\\\?=)|(\\\\?!))\",\n\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.group.regexp\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.group.assertion.regexp\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"3\": {\n\t\t\t\t\t\t\t\"name\": \"meta.assertion.look-ahead.regexp\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"4\": {\n\t\t\t\t\t\t\t\"name\": \"meta.assertion.negative-look-ahead.regexp\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"end\": \"(\\\\))\",\n\t\t\t\t\t\"endCaptures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.group.regexp\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#regexp\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.group.regexp\",\n\t\t\t\t\t\"begin\": \"\\\\((\\\\?:)?\",\n\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.group.regexp\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.group.capture.regexp\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"end\": \"\\\\)\",\n\t\t\t\t\t\"endCaptures\": {\n\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.group.regexp\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#regexp\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"constant.other.character-class.set.regexp\",\n\t\t\t\t\t\"begin\": \"(\\\\[)(\\\\^)?\",\n\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.character-class.regexp\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"keyword.operator.negation.regexp\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"end\": \"(\\\\])\",\n\t\t\t\t\t\"endCaptures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.character-class.regexp\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"name\": \"constant.other.character-class.range.regexp\",\n\t\t\t\t\t\t\t\"match\": \"(?:.|(\\\\\\\\(?:[0-7]{3}|x\\\\h\\\\h|u\\\\h\\\\h\\\\h\\\\h))|(\\\\\\\\c[A-Z])|(\\\\\\\\.))\\\\-(?:[^\\\\]\\\\\\\\]|(\\\\\\\\(?:[0-7]{3}|x\\\\h\\\\h|u\\\\h\\\\h\\\\h\\\\h))|(\\\\\\\\c[A-Z])|(\\\\\\\\.))\",\n\t\t\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\t\t\"name\": \"constant.character.numeric.regexp\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\t\t\"name\": \"constant.character.control.regexp\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\"3\": {\n\t\t\t\t\t\t\t\t\t\"name\": \"constant.character.escape.backslash.regexp\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\"4\": {\n\t\t\t\t\t\t\t\t\t\"name\": \"constant.character.numeric.regexp\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\"5\": {\n\t\t\t\t\t\t\t\t\t\"name\": \"constant.character.control.regexp\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\"6\": {\n\t\t\t\t\t\t\t\t\t\"name\": \"constant.character.escape.backslash.regexp\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#regex-character-class\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#regex-character-class\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"regex-character-class\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"constant.other.character-class.regexp\",\n\t\t\t\t\t\"match\": \"\\\\\\\\[wWsSdDtrnvf]|\\\\.\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"constant.character.numeric.regexp\",\n\t\t\t\t\t\"match\": \"\\\\\\\\([0-7]{3}|x\\\\h\\\\h|u\\\\h\\\\h\\\\h\\\\h)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"constant.character.control.regexp\",\n\t\t\t\t\t\"match\": \"\\\\\\\\c[A-Z]\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"constant.character.escape.backslash.regexp\",\n\t\t\t\t\t\"match\": \"\\\\\\\\.\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"string\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#qstring-single\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#qstring-double\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"template\": {\n\t\t\t\"name\": \"string.template.ts\",\n\t\t\t\"begin\": \"([_$[:alpha:]][_$[:alnum:]]*)?(`)\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"entity.name.function.tagged-template.ts\"\n\t\t\t\t},\n\t\t\t\t\"2\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.string.template.begin.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"`\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.string.template.end.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#template-substitution-element\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#string-character-escape\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"string-character-escape\": {\n\t\t\t\"name\": \"constant.character.escape.ts\",\n\t\t\t\"match\": \"\\\\\\\\(x\\\\h{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.|$)\"\n\t\t},\n\t\t\"template-substitution-element\": {\n\t\t\t\"name\": \"meta.template.expression.ts\",\n\t\t\t\"begin\": \"\\\\$\\\\{\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.template-expression.begin.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"\\\\}\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.template-expression.end.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#expression\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"literal\": {\n\t\t\t\"name\": \"literal.ts\",\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#numeric-literal\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#boolean-literal\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#null-literal\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#undefined-literal\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#numericConstant-literal\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#array-literal\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#this-literal\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#super-literal\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"array-literal\": {\n\t\t\t\"name\": \"meta.array.literal.ts\",\n\t\t\t\"begin\": \"\\\\[\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"meta.brace.square.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"\\\\]\",\n\t\t\t\"endCaptures\": {\n\t\t\t\t\"0\": {\n\t\t\t\t\t\"name\": \"meta.brace.square.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#expression\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"include\": \"#punctuation-comma\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"numeric-literal\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"constant.numeric.hex.ts\",\n\t\t\t\t\t\"match\": \"\\\\b(?<!\\\\$)0(x|X)[0-9a-fA-F]+\\\\b(?!\\\\$)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"constant.numeric.binary.ts\",\n\t\t\t\t\t\"match\": \"\\\\b(?<!\\\\$)0(b|B)[01]+\\\\b(?!\\\\$)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"constant.numeric.octal.ts\",\n\t\t\t\t\t\"match\": \"\\\\b(?<!\\\\$)0(o|O)?[0-7]+\\\\b(?!\\\\$)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"(?x)\\n(?<!\\\\$)(?:\\n  (?:\\\\b[0-9]+(\\\\.)[0-9]+[eE][+-]?[0-9]+\\\\b)| # 1.1E+3\\n  (?:\\\\b[0-9]+(\\\\.)[eE][+-]?[0-9]+\\\\b)|       # 1.E+3\\n  (?:\\\\B(\\\\.)[0-9]+[eE][+-]?[0-9]+\\\\b)|       # .1E+3\\n  (?:\\\\b[0-9]+[eE][+-]?[0-9]+\\\\b)|            # 1E+3\\n  (?:\\\\b[0-9]+(\\\\.)[0-9]+\\\\b)|                # 1.1\\n  (?:\\\\b[0-9]+(\\\\.)\\\\B)|                      # 1.\\n  (?:\\\\B(\\\\.)[0-9]+\\\\b)|                      # .1\\n  (?:\\\\b[0-9]+\\\\b(?!\\\\.))                     # 1\\n)(?!\\\\$)\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\"name\": \"constant.numeric.decimal.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"meta.delimiter.decimal.period.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"meta.delimiter.decimal.period.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"3\": {\n\t\t\t\t\t\t\t\"name\": \"meta.delimiter.decimal.period.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"4\": {\n\t\t\t\t\t\t\t\"name\": \"meta.delimiter.decimal.period.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"5\": {\n\t\t\t\t\t\t\t\"name\": \"meta.delimiter.decimal.period.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"6\": {\n\t\t\t\t\t\t\t\"name\": \"meta.delimiter.decimal.period.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"boolean-literal\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"constant.language.boolean.true.ts\",\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\btrue\\\\b(?!\\\\$)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"constant.language.boolean.false.ts\",\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\bfalse\\\\b(?!\\\\$)\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"null-literal\": {\n\t\t\t\"name\": \"constant.language.null.ts\",\n\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\bnull\\\\b(?!\\\\$)\"\n\t\t},\n\t\t\"this-literal\": {\n\t\t\t\"name\": \"variable.language.this.ts\",\n\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\bthis\\\\b(?!\\\\$)\"\n\t\t},\n\t\t\"super-literal\": {\n\t\t\t\"name\": \"variable.language.super.ts\",\n\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\bsuper\\\\b(?!\\\\$)\"\n\t\t},\n\t\t\"undefined-literal\": {\n\t\t\t\"name\": \"constant.language.undefined.ts\",\n\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\bundefined\\\\b(?!\\\\$)\"\n\t\t},\n\t\t\"numericConstant-literal\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"constant.language.nan.ts\",\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\bNaN\\\\b(?!\\\\$)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"constant.language.infinity.ts\",\n\t\t\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\bInfinity\\\\b(?!\\\\$)\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"access-modifier\": {\n\t\t\t\"name\": \"storage.modifier.ts\",\n\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\b(abstract|public|protected|private|readonly|static)\\\\b(?!\\\\$)\"\n\t\t},\n\t\t\"property-accessor\": {\n\t\t\t\"name\": \"storage.type.property.ts\",\n\t\t\t\"match\": \"(?<!\\\\.|\\\\$)\\\\b(get|set)\\\\b(?!\\\\$)\"\n\t\t},\n\t\t\"comment\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"comment.block.documentation.ts\",\n\t\t\t\t\t\"begin\": \"/\\\\*\\\\*(?!/)\",\n\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.comment.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"end\": \"\\\\*/\",\n\t\t\t\t\t\"endCaptures\": {\n\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.comment.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#docblock\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"comment.block.ts\",\n\t\t\t\t\t\"begin\": \"/\\\\*\",\n\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.comment.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"end\": \"\\\\*/\",\n\t\t\t\t\t\"endCaptures\": {\n\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.comment.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"begin\": \"(^[ \\\\t]+)?(?=//)\",\n\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.whitespace.comment.leading.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"end\": \"(?=$)\",\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"name\": \"comment.line.double-slash.ts\",\n\t\t\t\t\t\t\t\"begin\": \"//\",\n\t\t\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\t\t\"name\": \"punctuation.definition.comment.ts\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"end\": \"(?=$)\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"directives\": {\n\t\t\t\"name\": \"comment.line.triple-slash.directive.ts\",\n\t\t\t\"begin\": \"^(///)\\\\s*(?=<(reference|amd-dependency|amd-module)(\\\\s+(path|types|no-default-lib|name)\\\\s*=\\\\s*((\\\\'[^']*\\\\')|(\\\\\\\"[^\\\"]*\\\\\\\")))+\\\\s*/>\\\\s*$)\",\n\t\t\t\"beginCaptures\": {\n\t\t\t\t\"1\": {\n\t\t\t\t\t\"name\": \"punctuation.definition.comment.ts\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"end\": \"(?=$)\",\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"meta.tag.ts\",\n\t\t\t\t\t\"begin\": \"(<)(reference|amd-dependency|amd-module)\",\n\t\t\t\t\t\"beginCaptures\": {\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.tag.directive.ts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"entity.name.tag.directive.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"end\": \"/>\",\n\t\t\t\t\t\"endCaptures\": {\n\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\"name\": \"punctuation.definition.tag.directive.ts\"\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"patterns\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"name\": \"entity.other.attribute-name.directive.ts\",\n\t\t\t\t\t\t\t\"match\": \"path|types|no-default-lib|name\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"name\": \"keyword.operator.assignment.ts\",\n\t\t\t\t\t\t\t\"match\": \"=\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"include\": \"#string\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t\"docblock\": {\n\t\t\t\"patterns\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"storage.type.class.jsdoc\",\n\t\t\t\t\t\"match\": \"(?<!\\\\w)@(abstract|access|alias|arg|argument|async|attribute|augments|author|beta|borrows|bubbes|callback|chainable|class|classdesc|code|config|const|constant|constructor|constructs|copyright|default|defaultvalue|define|deprecated|desc|description|dict|emits|enum|event|example|exports?|extends|extension|extension_for|extensionfor|external|file|fileoverview|final|fires|for|function|global|host|ignore|implements|inherit[Dd]oc|inner|instance|interface|kind|lends|license|listens|main|member|memberof|method|mixex|mixins?|module|name|namespace|nocollapse|nosideeffects|override|overview|package|param|preserve|private|prop|property|protected|public|read[Oo]nly|record|require[ds]|returns?|see|since|static|struct|submodule|summary|template|this|throws|todo|tutorial|type|typedef|unrestricted|uses|var|variation|version|virtual|writeOnce)\\\\b\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"(?x)\\n(?:(?<=@param)|(?<=@arg)|(?<=@argument)|(?<=@type))\\n\\\\s+\\n({(?:\\n  \\\\* |                                        # {*} any type\\n  \\\\? |                                        # {?} unknown type\\n  (?:                                         # Check for a prefix\\n    \\\\? |                                      # {?string} nullable type\\n    !   |                                     # {!string} non-nullable type\\n    \\\\.{3}                                     # {...string} variable number of parameters\\n  )?\\n  (?:\\n    \\\\(                                        # Opening bracket of multiple types with parenthesis {(string|number)}\\n      [a-zA-Z_$]+\\n      (?:\\n        (?:\\n          [\\\\w$]*\\n          (?:\\\\[\\\\])?                           # {(string[]|number)} type application, an array of strings or a number\\n        ) |\\n        \\\\.?<[\\\\w$]+(?:,\\\\s+[\\\\w$]+)*>            # {Array<string>} or {Object<string, number>} type application (optional .)\\n      )\\n      (?:\\n        [\\\\.|~]                                # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback\\n        [a-zA-Z_$]+\\n        (?:\\n          (?:\\n            [\\\\w$]*\\n            (?:\\\\[\\\\])?                        # {(string|number[])} type application, a string or an array of numbers\\n          ) |\\n          \\\\.?<[\\\\w$]+(?:,\\\\s+[\\\\w$]+)*>         # {Array<string>} or {Object<string, number>} type application (optional .)\\n        )\\n      )*\\n    \\\\) |\\n    [a-zA-Z_$]+\\n    (?:\\n      (?:\\n        [\\\\w$]*\\n        (?:\\\\[\\\\])?                            # {string[]|number} type application, an array of strings or a number\\n      ) |\\n      \\\\.?<[\\\\w$]+(?:,\\\\s+[\\\\w$]+)*>             # {Array<string>} or {Object<string, number>} type application (optional .)\\n    )\\n    (?:\\n      [\\\\.|~]                                 # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback\\n      [a-zA-Z_$]+\\n      (?:\\n        [\\\\w$]* |\\n        \\\\.?<[\\\\w$]+(?:,\\\\s+[\\\\w$]+)*>           # {Array<string>} or {Object<string, number>} type application (optional .)\\n      )\\n    )*\\n  )\\n                                             # Check for suffix\\n  (?:\\\\[\\\\])?                                  # {string[]} type application, an array of strings\\n  =?                                         # {string=} optional parameter\\n)})\\n\\\\s+\\n(\\n  \\\\[                                         # [foo] optional parameter\\n    \\\\s*\\n    (?:\\n      [a-zA-Z_$][\\\\w$]*\\n      (?:\\n        (?:\\\\[\\\\])?                            # Foo[].bar properties within an array\\n        \\\\.                                   # Foo.Bar namespaced parameter\\n        [a-zA-Z_$][\\\\w$]*\\n      )*\\n      (?:\\n        \\\\s*\\n        =                                    # [foo=bar] Default parameter value\\n        \\\\s*\\n        [\\\\w$\\\\s]*\\n      )?\\n    )\\n    \\\\s*\\n  \\\\] |\\n  (?:\\n    [a-zA-Z_$][\\\\w$]*\\n    (?:\\n      (?:\\\\[\\\\])?                              # Foo[].bar properties within an array\\n      \\\\.                                     # Foo.Bar namespaced parameter\\n      [a-zA-Z_$][\\\\w$]*\\n    )*\\n  )?\\n)\\n\\\\s+\\n(?:-\\\\s+)?                                    # optional hyphen before the description\\n((?:(?!\\\\*\\\\/).)*)                             # The type description\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\"name\": \"other.meta.jsdoc\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"entity.name.type.instance.jsdoc\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"variable.other.jsdoc\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"3\": {\n\t\t\t\t\t\t\t\"name\": \"other.description.jsdoc\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"match\": \"(?x)\\n({(?:\\n  \\\\* |                                       # {*} any type\\n  \\\\? |                                       # {?} unknown type\\n\\n  (?:                                        # Check for a prefix\\n    \\\\? |                                     # {?string} nullable type\\n    !   |                                    # {!string} non-nullable type\\n    \\\\.{3}                                    # {...string} variable number of parameters\\n  )?\\n\\n  (?:\\n    \\\\(                                       # Opening bracket of multiple types with parenthesis {(string|number)}\\n      [a-zA-Z_$]+\\n      (?:\\n        [\\\\w$]* |\\n        \\\\.?<[\\\\w$]+(?:,\\\\s+[\\\\w$]+)*>           # {Array<string>} or {Object<string, number>} type application (optional .)\\n      )\\n      (?:\\n        [\\\\.|~]                               # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback\\n        [a-zA-Z_$]+\\n        (?:\\n          [\\\\w$]* |\\n          \\\\.?<[\\\\w$]+(?:,\\\\s+[\\\\w$]+)*>         # {Array<string>} or {Object<string, number>} type application (optional .)\\n        )\\n      )*\\n    \\\\) |\\n    [a-zA-Z_$]+\\n    (?:\\n      [\\\\w$]* |\\n      \\\\.?<[\\\\w$]+(?:,\\\\s+[\\\\w$]+)*>             # {Array<string>} or {Object<string, number>} type application (optional .)\\n    )\\n    (?:\\n      [\\\\.|~]                                 # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback\\n      [a-zA-Z_$]+\\n      (?:\\n        [\\\\w$]* |\\n        \\\\.?<[\\\\w$]+(?:,\\\\s+[\\\\w$]+)*>           # {Array<string>} or {Object<string, number>} type application (optional .)\\n      )\\n    )*\\n  )\\n                                             # Check for suffix\\n  (?:\\\\[\\\\])?                                  # {string[]} type application, an array of strings\\n  =?                                         # {string=} optional parameter\\n)})\\n\\\\s+\\n(?:-\\\\s+)?                                    # optional hyphen before the description\\n((?:(?!\\\\*\\\\/).)*)                             # The type description\",\n\t\t\t\t\t\"captures\": {\n\t\t\t\t\t\t\"0\": {\n\t\t\t\t\t\t\t\"name\": \"other.meta.jsdoc\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"1\": {\n\t\t\t\t\t\t\t\"name\": \"entity.name.type.instance.jsdoc\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"2\": {\n\t\t\t\t\t\t\t\"name\": \"other.description.jsdoc\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\t},\n\t\"version\": \"https://github.com/Microsoft/TypeScript-TmLanguage/commit/4d0bdebb93aadc25ecbb903ebc897e9cd5fab69c\"\n}\n"
  },
  {
    "path": "ark/fast-check/__tests__/arktypeFastCheck.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { arkToArbitrary } from \"@ark/fast-check/internal/arktypeFastCheck.ts\"\nimport { scope, type } from \"arktype\"\nimport { type Arbitrary, assert, property } from \"fast-check\"\nimport { describe } from \"mocha\"\n\ncontextualize(() => {\n\tdescribe(\"union\", () => {\n\t\tit(\"boolean\", () => {\n\t\t\tconst T = type(\"boolean\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\treturn assertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"number|string\", () => {\n\t\t\tconst T = type(\"number|string\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t})\n\n\tdescribe(\"number\", () => {\n\t\tit(\"number\", () => {\n\t\t\tconst T = type(\"number\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\treturn assertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"Tight Bound\", () => {\n\t\t\tconst T = type(\"4<number<5\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\treturn assertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"Integer\", () => {\n\t\t\tconst T = type(\"number.integer\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"Invalid Bound\", () => {\n\t\t\tconst T = type(\"4<number.integer<5\")\n\t\t\tattest(() => assertProperty(arkToArbitrary(T), T)).throws(\n\t\t\t\t\"No integer value satisfies >5 & <4\"\n\t\t\t)\n\t\t})\n\t\tit(\"equals\", () => {\n\t\t\tconst T = type(\"number==2\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"divisible\", () => {\n\t\t\tconst T = type(\"number%2\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"large divisor\", () => {\n\t\t\tconst T = type(\"number%7654321001>1\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"divisible within range\", () => {\n\t\t\tconst T = type(\"15<number%7<39\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"non-divisible within range\", () => {\n\t\t\tconst T = type(\"52<number%10<58\")\n\t\t\tattest(() => arkToArbitrary(T)).throws(\n\t\t\t\t\"No values within range 53 - 57 are divisible by 10.\"\n\t\t\t)\n\t\t})\n\t})\n\n\tdescribe(\"string\", () => {\n\t\tit(\"string\", () => {\n\t\t\tconst T = type(\"string\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"bounded string\", () => {\n\t\t\tconst T = type(\"string < 5\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"double bounded string\", () => {\n\t\t\tconst T = type(\"3<string <= 8\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"regex\", () => {\n\t\t\tconst T = type(\"string.email\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"multiple regexes\", () => {\n\t\t\tconst T = type(\"string.email\").and(\"string.alpha\")\n\t\t\tattest(() => arkToArbitrary(T)).throws(\n\t\t\t\t\"Multiple regexes on a single node is not supported.\"\n\t\t\t)\n\t\t})\n\t\tit(\"bounded regex\", () => {\n\t\t\tconst T = type(\"string.email<5\")\n\t\t\tattest(() => arkToArbitrary(T)).throws(\"Bounded regex is not supported.\")\n\t\t})\n\t})\n\n\tdescribe(\"misc\", () => {\n\t\tit(\"unknown\", () => {\n\t\t\tconst T = type(\"unknown\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\treturn assertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"unknown[]\", () => {\n\t\t\tconst T = type(\"unknown[]\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\treturn assertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"bigint\", () => {\n\t\t\tconst T = type(\"bigint\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\treturn assertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"symbol\", () => {\n\t\t\tconst T = type(\"symbol\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\treturn assertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"false\", () => {\n\t\t\tconst T = type(\"false\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"true\", () => {\n\t\t\tconst T = type(\"true\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"literal number\", () => {\n\t\t\tconst T = type(\"0.5\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"literal string\", () => {\n\t\t\tconst T = type(\"'hello'\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"morph\", () => {\n\t\t\tconst T = type([\"string<5\", \"=>\", val => `${val}`])\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t})\n\n\tdescribe(\"array\", () => {\n\t\tit(\"Array keyword\", () => {\n\t\t\tconst T = type(\"Array\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"constrained Array keyword\", () => {\n\t\t\tconst T = type(\"Array<2\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"string[]\", () => {\n\t\t\tconst T = type(\"string[]\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"number[][]\", () => {\n\t\t\tconst T = type(\"number[][]\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"bounded array\", () => {\n\t\t\tconst T = type(\"3<number[]<=5\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"union array\", () => {\n\t\t\tconst T = type(\"(string|number)[]\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t})\n\n\tdescribe(\"tuple\", () => {\n\t\tit(\"empty tuple\", () => {\n\t\t\tconst T = type([])\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"one element tuple\", () => {\n\t\t\tconst T = type([\"string\"])\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"two element tuple\", () => {\n\t\t\tconst T = type([\"string\", \"number\"])\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\n\t\tit(\"just variadic\", () => {\n\t\t\tconst T = type([\"...\", \"string[]\"])\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"variadic\", () => {\n\t\t\tconst T = type([\"number\", \"...\", \"string[]\"])\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"one element optional tuple\", () => {\n\t\t\tconst T = type([\"string?\"])\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"tuple with optional\", () => {\n\t\t\tconst T = type([\"number\", \"string>2?\"])\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t})\n\n\tdescribe(\"object\", () => {\n\t\tit(\"{}\", () => {\n\t\t\tconst T = type({})\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"object keyword\", () => {\n\t\t\tconst T = type(\"object\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"object with optional key\", () => {\n\t\t\tconst T = type({ a: \"string\", \"b?\": \"3<number<5\" })\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"nested object\", () => {\n\t\t\tconst T = type({\n\t\t\t\ta: {\n\t\t\t\t\tb: \"string >= 2\",\n\t\t\t\t\t\"c?\": \"string\"\n\t\t\t\t},\n\t\t\t\t\"d?\": \"number\"\n\t\t\t})\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"intersected object\", () => {\n\t\t\tconst T = type([{ a: \"string\" }, \"&\", { b: \"number\" }])\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"symbol key\", () => {\n\t\t\tconst s = Symbol()\n\t\t\tconst T = type({\n\t\t\t\t[s]: \"string\"\n\t\t\t})\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"index signature\", () => {\n\t\t\tconst T = type({ \"[string]\": \"number|string\" })\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"multiple index signatures\", () => {\n\t\t\tconst T = type({\n\t\t\t\t\"[string]\": \"number|string\",\n\t\t\t\t\"[symbol]\": \"string\"\n\t\t\t})\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"symbol index signature\", () => {\n\t\t\tconst T = type({ \"[symbol]\": \"number|string\" })\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"contains alias\", () => {\n\t\t\tconst example = {\n\t\t\t\tuser: {\n\t\t\t\t\tname: \"string\",\n\t\t\t\t\tfriends: \"user[]\"\n\t\t\t\t}\n\t\t\t} as const\n\t\t\tconst T = scope(example).type(\"user\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"cyclic\", () => {\n\t\t\tconst $ = scope({\n\t\t\t\tarf2: {\n\t\t\t\t\tb: \"bork2\"\n\t\t\t\t},\n\t\t\t\tbork2: {\n\t\t\t\t\tc: \"arf2&bork2\"\n\t\t\t\t}\n\t\t\t}).export()\n\t\t\tattest(() => arkToArbitrary($.arf2)).throws(\n\t\t\t\t\"Infinitely deep cycles are not supported.\"\n\t\t\t)\n\t\t})\n\t\tit(\"unknown array with additional props\", () => {\n\t\t\tconst T = type({ name: \"string\" }).and(\"unknown[]\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"array keyword with additional props\", () => {\n\t\t\tconst T = type({ name: \"string\" }).and(\"Array<4\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"array with additional props\", () => {\n\t\t\tconst T = type({ name: \"string\" }).and(\"string[]\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t})\n\n\tdescribe(\"proto\", () => {\n\t\tit(\"Set\", () => {\n\t\t\tconst T = type(\"Set\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"Date\", () => {\n\t\t\tconst T = type(\"Date\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t\tit(\"bounded date\", () => {\n\t\t\tconst T = type(\"d'2001/10/10'<Date<=d'2005/10/10'\")\n\t\t\tconst arbitrary = arkToArbitrary(T)\n\t\t\tassertProperty(arbitrary, T)\n\t\t})\n\t})\n})\n\nconst assertProperty = (arbitrary: Arbitrary<unknown>, schema: type.Any) =>\n\tassert(\n\t\tproperty(arbitrary, value => {\n\t\t\tschema.assert(value)\n\t\t\treturn true\n\t\t})\n\t)\n"
  },
  {
    "path": "ark/fast-check/arbitraries/array.ts",
    "content": "import type { nodeOfKind, SequenceTuple } from \"@ark/schema\"\nimport * as fc from \"fast-check\"\nimport type { Ctx } from \"../fastCheckContext.ts\"\n\nexport const getPossiblyWeightedArray = (\n\tarrArbitrary: fc.Arbitrary<unknown[]>,\n\tnode: nodeOfKind<\"sequence\">,\n\tctx: Ctx\n): fc.Arbitrary<unknown[]> =>\n\tctx.tieStack.length ?\n\t\tfc.oneof(\n\t\t\t{\n\t\t\t\tmaxDepth: 2,\n\t\t\t\tdepthIdentifier: `id:${node.id}`\n\t\t\t},\n\t\t\t{ arbitrary: fc.constant([]), weight: 1 },\n\t\t\t{\n\t\t\t\tarbitrary: arrArbitrary,\n\t\t\t\tweight: 2\n\t\t\t}\n\t\t)\n\t:\tarrArbitrary\n\nexport const spreadVariadicElements = (\n\ttupleArbitraries: fc.Arbitrary<unknown>[],\n\ttupleElements: SequenceTuple\n): fc.Arbitrary<unknown[]> =>\n\tfc.tuple(...tupleArbitraries).chain(arr => {\n\t\tconst arrayWithoutOptionals = []\n\t\tconst arrayWithOptionals = []\n\n\t\tfor (const i in arr) {\n\t\t\tif (tupleElements[i].kind === \"variadic\") {\n\t\t\t\tconst generatedValuesArray = (arr[i] as unknown[]).map(val =>\n\t\t\t\t\tfc.constant(val)\n\t\t\t\t)\n\t\t\t\tarrayWithoutOptionals.push(...generatedValuesArray)\n\t\t\t\tarrayWithOptionals.push(...generatedValuesArray)\n\t\t\t} else if (tupleElements[i].kind === \"optionals\")\n\t\t\t\tarrayWithOptionals.push(fc.constant(arr[i]))\n\t\t\telse {\n\t\t\t\tarrayWithoutOptionals.push(fc.constant(arr[i]))\n\t\t\t\tarrayWithOptionals.push(fc.constant(arr[i]))\n\t\t\t}\n\t\t}\n\t\tif (arrayWithOptionals.length !== arrayWithoutOptionals.length) {\n\t\t\treturn fc.oneof(\n\t\t\t\tfc.tuple(...arrayWithoutOptionals),\n\t\t\t\tfc.tuple(...arrayWithOptionals)\n\t\t\t)\n\t\t}\n\t\treturn fc.tuple(...arrayWithOptionals)\n\t})\n"
  },
  {
    "path": "ark/fast-check/arbitraries/date.ts",
    "content": "import * as fc from \"fast-check\"\nimport type { ProtoInputNode } from \"./proto.ts\"\n\nexport const buildDateArbitrary = (\n\tnode: ProtoInputNode\n): fc.Arbitrary<Date> => {\n\tif (node.hasKind(\"intersection\")) {\n\t\tconst fastCheckDateConstraints: fc.DateConstraints = {}\n\t\tif (node.inner.after) fastCheckDateConstraints.min = node.inner.after.rule\n\t\tif (node.inner.before) fastCheckDateConstraints.max = node.inner.before.rule\n\n\t\treturn fc.date(fastCheckDateConstraints)\n\t}\n\treturn fc.date()\n}\n"
  },
  {
    "path": "ark/fast-check/arbitraries/domain.ts",
    "content": "import type { nodeOfKind } from \"@ark/schema\"\nimport * as fc from \"fast-check\"\nimport { buildStructureArbitrary } from \"../arktypeFastCheck.ts\"\nimport type { Ctx } from \"../fastCheckContext.ts\"\nimport { buildNumberArbitrary } from \"./number.ts\"\nimport { buildStringArbitrary } from \"./string.ts\"\n\nexport const buildDomainArbitrary: BuildDomainArbitrary = {\n\tnumber: node => buildNumberArbitrary(node),\n\tstring: node => buildStringArbitrary(node),\n\tobject: (node, ctx) =>\n\t\tnode.hasKind(\"domain\") ? fc.object() : buildStructureArbitrary(node, ctx),\n\tsymbol: () => fc.constant(Symbol()),\n\tbigint: () => fc.bigInt()\n}\n\nexport type DomainArbitrary<t = unknown> = (\n\tnode: DomainInputNode,\n\tctx: Ctx\n) => fc.Arbitrary<t>\n\ntype BuildDomainArbitrary = {\n\tnumber: DomainArbitrary<number>\n\tstring: DomainArbitrary<string>\n\tsymbol: DomainArbitrary<symbol>\n\tbigint: DomainArbitrary<bigint>\n\tobject: DomainArbitrary\n}\n\nexport type DomainInputNode = nodeOfKind<\"intersection\"> | nodeOfKind<\"domain\">\n"
  },
  {
    "path": "ark/fast-check/arbitraries/number.ts",
    "content": "import type { IntersectionNode } from \"@ark/schema\"\nimport { hasKey, nearestFloat, throwInternalError } from \"@ark/util\"\nimport * as fc from \"fast-check\"\nimport type { DomainInputNode } from \"./domain.ts\"\n\nexport const buildNumberArbitrary = (\n\tnode: DomainInputNode\n): fc.Arbitrary<number> => {\n\tif (node.hasKind(\"domain\")) {\n\t\treturn fc.double({\n\t\t\tnoNaN: !node.numberAllowsNaN\n\t\t})\n\t}\n\tconst numberConstraints = getFastCheckNumberConstraints(node)\n\tconst hasMax = hasKey(numberConstraints, \"max\")\n\tconst hasMin = hasKey(numberConstraints, \"min\")\n\n\tif (!hasKey(numberConstraints, \"divisor\")) return fc.double(numberConstraints)\n\n\tconst divisor = numberConstraints.divisor\n\tif (divisor === undefined) throwInternalError(\"Expected a divisor.\")\n\n\tif (hasMin && hasMax) {\n\t\tif (\n\t\t\tnumberConstraints.min === undefined ||\n\t\t\tnumberConstraints.max === undefined\n\t\t) {\n\t\t\tthrowInternalError(\n\t\t\t\t`Expected min and max node refinements to not be undefined. (was min: ${numberConstraints.min} max: ${numberConstraints.max})`\n\t\t\t)\n\t\t}\n\t\tif (numberConstraints.min > numberConstraints.max) {\n\t\t\tthrow new Error(\n\t\t\t\t`No integer value satisfies >${numberConstraints.min} & <${numberConstraints.max}`\n\t\t\t)\n\t\t}\n\t}\n\n\tconst min = numberConstraints.min ?? Number.MIN_SAFE_INTEGER\n\tconst max = numberConstraints.max ?? Number.MAX_SAFE_INTEGER\n\n\tconst firstDivisibleInRange = Math.ceil(min / divisor) * divisor\n\n\tif (firstDivisibleInRange > max || firstDivisibleInRange < min) {\n\t\tthrow new Error(\n\t\t\t`No values within range ${numberConstraints.min} - ${numberConstraints.max} are divisible by ${numberConstraints.divisor}.`\n\t\t)\n\t}\n\n\tnumberConstraints.min = firstDivisibleInRange\n\t//fast-check defaults max to 0x7fffffff which prevents larger divisible numbers from being produced\n\tnumberConstraints.max = max\n\n\tconst integerArbitrary = fc.integer(numberConstraints)\n\n\tconst integersDivisibleByDivisor = integerArbitrary.map(value => {\n\t\tconst remainder = value % divisor\n\t\tif (remainder === 0) return value\n\n\t\tconst lowerPossibleValue = value - remainder\n\t\tif (\n\t\t\tlowerPossibleValue >= firstDivisibleInRange &&\n\t\t\tlowerPossibleValue % divisor === 0\n\t\t)\n\t\t\treturn lowerPossibleValue\n\t\treturn value + remainder\n\t})\n\treturn integersDivisibleByDivisor\n}\n\nconst getFastCheckNumberConstraints = (node: IntersectionNode) => {\n\tconst hasDivisor = node.prestructurals.find(refinement =>\n\t\trefinement.hasKind(\"divisor\")\n\t)\n\tconst numberConstraints: fc.DoubleConstraints & {\n\t\tdivisor?: number\n\t} = {\n\t\tnoNaN: !node.inner.domain?.numberAllowsNaN\n\t}\n\n\tfor (const refinement of node.prestructurals) {\n\t\tif (refinement.hasKindIn(\"min\", \"max\")) {\n\t\t\tlet rule = refinement.rule\n\t\t\tif (\"exclusive\" in refinement) {\n\t\t\t\trule = nearestFloat(\n\t\t\t\t\trefinement.rule,\n\t\t\t\t\trefinement.hasKind(\"min\") ? \"+\" : \"-\"\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (hasDivisor !== undefined)\n\t\t\t\trule = refinement.hasKind(\"min\") ? Math.ceil(rule) : Math.floor(rule)\n\t\t\tnumberConstraints[refinement.kind] = rule\n\t\t} else if (refinement.hasKind(\"divisor\"))\n\t\t\tnumberConstraints[\"divisor\"] = refinement.rule\n\t}\n\n\treturn numberConstraints\n}\n"
  },
  {
    "path": "ark/fast-check/arbitraries/object.ts",
    "content": "import type { nodeOfKind } from \"@ark/schema\"\nimport { letrec, type Arbitrary, type LetrecValue } from \"fast-check\"\nimport { buildObjectArbitrary } from \"../arktypeFastCheck.ts\"\nimport type { Ctx } from \"../fastCheckContext.ts\"\n\nexport const buildCyclicArbitrary = (\n\tnode: nodeOfKind<\"structure\">,\n\tctx: Ctx\n): Arbitrary<Record<string, unknown>> => {\n\tconst objectArbitrary: LetrecValue<unknown> = letrec(tie => {\n\t\tctx.tieStack.push(tie)\n\t\tconst arbitraries = {\n\t\t\troot: buildObjectArbitrary(node, ctx),\n\t\t\t...ctx.arbitrariesByIntersectionId\n\t\t}\n\t\tctx.tieStack.pop()\n\t\treturn arbitraries\n\t})\n\treturn (objectArbitrary as never)[\"root\"]\n}\n"
  },
  {
    "path": "ark/fast-check/arbitraries/proto.ts",
    "content": "import type { nodeOfKind } from \"@ark/schema\"\nimport * as fc from \"fast-check\"\nimport { buildStructureArbitrary } from \"../arktypeFastCheck.ts\"\nimport type { Ctx } from \"../fastCheckContext.ts\"\nimport { buildDateArbitrary } from \"./date.ts\"\nimport type { DomainInputNode } from \"./domain.ts\"\n\nexport const buildProtoArbitrary: BuildProtoArbitrary = {\n\tArray: (node, ctx) =>\n\t\tnode.hasKind(\"proto\") ?\n\t\t\tfc.array(fc.anything())\n\t\t:\tbuildStructureArbitrary(node as never, ctx),\n\tSet: () => fc.uniqueArray(fc.anything()).map(arr => new Set(arr)),\n\tDate: node => buildDateArbitrary(node)\n}\n\ntype BuildProtoArbitrary = {\n\tArray: ProtoArbitrary\n\tSet: ProtoArbitrary<Set<unknown>>\n\tDate: ProtoArbitrary<Date>\n\t[key: string]: ProtoArbitrary\n}\n\ntype ProtoArbitrary<t = unknown> = (\n\tnode: ProtoInputNode | DomainInputNode,\n\tctx: Ctx\n) => fc.Arbitrary<t>\n\nexport type ProtoInputNode = nodeOfKind<\"intersection\"> | nodeOfKind<\"domain\">\n"
  },
  {
    "path": "ark/fast-check/arbitraries/string.ts",
    "content": "import type { nodeOfKind, PrestructuralKind } from \"@ark/schema\"\nimport { throwInternalError, type array } from \"@ark/util\"\nimport * as fc from \"fast-check\"\nimport type { DomainInputNode } from \"./domain.ts\"\n\nexport const buildStringArbitrary = (\n\tnode: DomainInputNode\n): fc.Arbitrary<string> => {\n\tif (node.hasKind(\"domain\")) return fc.string()\n\tconst stringConstraints = getFastCheckStringConstraints(node.prestructurals)\n\tif (\"pattern\" in stringConstraints) {\n\t\tif (stringConstraints.minLength || stringConstraints.maxLength)\n\t\t\tthrowInternalError(\"Bounded regex is not supported.\")\n\t\treturn fc.stringMatching(new RegExp(stringConstraints.pattern))\n\t}\n\n\treturn fc.string(stringConstraints)\n}\n\nconst getFastCheckStringConstraints = (\n\trefinements: array<nodeOfKind<PrestructuralKind>>\n) => {\n\tconst stringConstraints: fc.StringConstraints & {\n\t\tpattern?: string\n\t} = {}\n\tfor (const refinement of refinements) {\n\t\tif (refinement.hasKind(\"pattern\")) {\n\t\t\tif (stringConstraints.pattern !== undefined) {\n\t\t\t\tthrowInternalError(\n\t\t\t\t\t\"Multiple regexes on a single node is not supported.\"\n\t\t\t\t)\n\t\t\t}\n\t\t\tstringConstraints[\"pattern\"] = refinement.rule\n\t\t} else if (refinement.hasKind(\"exactLength\")) {\n\t\t\tstringConstraints[\"minLength\"] = refinement.rule\n\t\t\tstringConstraints[\"maxLength\"] = refinement.rule\n\t\t} else\n\t\t\tstringConstraints[refinement.kind as never] = refinement.rule as never\n\t}\n\treturn stringConstraints\n}\n"
  },
  {
    "path": "ark/fast-check/arktypeFastCheck.ts",
    "content": "import type { NodeKind, nodeOfKind, SequenceTuple } from \"@ark/schema\"\nimport {\n\thasKey,\n\tstringAndSymbolicEntriesOf,\n\tthrowInternalError\n} from \"@ark/util\"\nimport type { type } from \"arktype\"\nimport * as fc from \"fast-check\"\nimport {\n\tgetPossiblyWeightedArray,\n\tspreadVariadicElements\n} from \"./arbitraries/array.ts\"\nimport { buildDomainArbitrary } from \"./arbitraries/domain.ts\"\nimport { buildCyclicArbitrary } from \"./arbitraries/object.ts\"\nimport { buildProtoArbitrary } from \"./arbitraries/proto.ts\"\nimport { initializeContext, type Ctx } from \"./fastCheckContext.ts\"\n\nexport const arkToArbitrary = (schema: type.Any): fc.Arbitrary<unknown> => {\n\tconst ctx = initializeContext()\n\n\treturn buildArbitrary(schema as never, ctx)\n}\n\nconst buildArbitrary = (node: nodeOfKind<NodeKind>, ctx: Ctx) => {\n\tswitch (node.kind) {\n\t\tcase \"intersection\":\n\t\t\tctx.seenIntersectionIds[node.id] = true\n\n\t\t\tctx.isCyclic = node.isCyclic\n\n\t\t\t//specifically in the case of unknown, it is represented as an empty intersection so we just return anything here.\n\t\t\tif (node.basis === null) return fc.anything()\n\n\t\t\tconst intersectionArbitrary =\n\t\t\t\tnode.basis?.kind === \"domain\" ?\n\t\t\t\t\tbuildDomainArbitrary[node.basis?.domain](node, ctx)\n\t\t\t\t:\tbuildProtoArbitrary[node.basis?.proto.name](node, ctx)\n\n\t\t\tctx.arbitrariesByIntersectionId[node.id] = intersectionArbitrary\n\n\t\t\treturn intersectionArbitrary\n\t\tcase \"domain\":\n\t\t\tif (node.domain in buildDomainArbitrary)\n\t\t\t\treturn buildDomainArbitrary[node.domain](node, ctx)\n\n\t\t\treturn throwInternalError(`${node.domain} is not supported`)\n\t\tcase \"union\":\n\t\t\tconst arbitraries: fc.Arbitrary<unknown>[] = node.children.map(node =>\n\t\t\t\tbuildArbitrary(node, ctx)\n\t\t\t)\n\n\t\t\treturn fc.oneof(...arbitraries)\n\t\tcase \"unit\":\n\t\t\treturn fc.constant(node.unit)\n\t\tcase \"proto\":\n\t\t\treturn buildProtoArbitrary[node.proto.name](node as never, ctx)\n\t\tcase \"structure\":\n\t\t\treturn buildStructureArbitrary(node as never, ctx)\n\t\tcase \"index\":\n\t\t\treturn buildIndexSignatureArbitrary([node], ctx)\n\t\tcase \"required\":\n\t\tcase \"optional\":\n\t\t\tif (node.value.hasKind(\"alias\") && node.required)\n\t\t\t\tthrowInternalError(\"Infinitely deep cycles are not supported.\")\n\n\t\t\treturn buildArbitrary(node.value as never, ctx)\n\t\tcase \"morph\":\n\t\t\tif (node.inner.in === undefined)\n\t\t\t\tthrowInternalError(`Expected the morph to have an 'In' value.`)\n\n\t\t\treturn buildArbitrary(node.inner.in as never, ctx)\n\t\tcase \"alias\":\n\t\t\tif (ctx.tieStack.length < 1)\n\t\t\t\tthrowInternalError(\"Tie has not been initialized\")\n\n\t\t\tconst tie = ctx.tieStack[ctx.tieStack.length - 1]\n\n\t\t\tconst id = node.resolutionId\n\n\t\t\t/**\n\t\t\t * Synthetic aliases cause the original structure to not contain the resolved alias node when\n\t\t\t * iterating through children so we explicitly build the resolved node\n\t\t\t */\n\t\t\tif (!(id in ctx.seenIntersectionIds)) {\n\t\t\t\tctx.seenIntersectionIds[id] = true\n\t\t\t\tctx.arbitrariesByIntersectionId[id] = buildArbitrary(\n\t\t\t\t\tnode.resolution as never,\n\t\t\t\t\tctx\n\t\t\t\t)\n\t\t\t}\n\n\t\t\treturn tie(id)\n\t}\n\tthrowInternalError(`${node.kind} is not supported`)\n}\n\nexport const buildStructureArbitrary = (\n\tnode: nodeOfKind<\"intersection\">,\n\tctx: Ctx\n): fc.Arbitrary<unknown> => {\n\tconst structure = node.structure\n\n\tif (node.basis?.hasKind(\"domain\")) {\n\t\tif (structure === undefined)\n\t\t\tthrowInternalError(\"Expected a structure node.\")\n\n\t\tif (hasKey(structure, \"index\") && structure.index)\n\t\t\treturn buildIndexSignatureArbitrary(structure.index, ctx)\n\n\t\treturn buildObjectArbitrary(structure, ctx)\n\t}\n\n\tif (node.inner.exactLength?.rule === 0) return fc.tuple()\n\n\tconst fcArrayConstraints: fc.ArrayConstraints = {}\n\tif (node.inner.minLength)\n\t\tfcArrayConstraints.minLength = node.inner.minLength.rule\n\tif (node.inner.maxLength)\n\t\tfcArrayConstraints.maxLength = node.inner.maxLength.rule\n\n\tconst arrArbitrary =\n\t\tstructure?.sequence ?\n\t\t\tbuildArrayArbitrary(structure.sequence, fcArrayConstraints, ctx)\n\t\t:\tfc.array(fc.anything(), fcArrayConstraints)\n\n\tif (structure?.required || structure?.optional) {\n\t\tconst objectArbitrary = buildObjectArbitrary(structure, ctx)\n\t\treturn fc\n\t\t\t.tuple(arrArbitrary, objectArbitrary)\n\t\t\t.map(([arr, record]) => Object.assign(arr, record))\n\t}\n\n\treturn arrArbitrary\n}\n\nexport const buildObjectArbitrary = (\n\tnode: nodeOfKind<\"structure\">,\n\tctx: Ctx\n): fc.Arbitrary<Record<string, unknown>> => {\n\tif (ctx.isCyclic && !ctx.tieStack.length)\n\t\treturn buildCyclicArbitrary(node, ctx)\n\n\tconst entries = stringAndSymbolicEntriesOf(node.propsByKey)\n\tconst requiredKeys = node.requiredKeys\n\tconst arbitrariesByKey: Record<PropertyKey, fc.Arbitrary<unknown>> = {}\n\n\tfor (const [key, value] of entries)\n\t\tarbitrariesByKey[key] = buildArbitrary(value as never, ctx)\n\n\treturn fc.record(arbitrariesByKey, { requiredKeys } as never)\n}\n\nconst buildIndexSignatureArbitrary = (\n\tindexNodes: readonly nodeOfKind<\"index\">[],\n\tctx: Ctx\n): fc.Arbitrary<Record<string, unknown>> => {\n\tif (indexNodes.length === 1) return getDictionaryArbitrary(indexNodes[0], ctx)\n\n\tconst dictionaryArbitraries = []\n\tfor (const indexNode of indexNodes)\n\t\tdictionaryArbitraries.push(getDictionaryArbitrary(indexNode, ctx))\n\n\treturn fc.tuple(...dictionaryArbitraries).map(arbs => {\n\t\tconst recordArb = {}\n\t\tfor (const arb of arbs) Object.assign(recordArb, arb)\n\t\treturn recordArb\n\t})\n}\n\nconst getDictionaryArbitrary = (node: nodeOfKind<\"index\">, ctx: Ctx) => {\n\tconst signatureArbitrary = buildArbitrary(node.signature, ctx)\n\tconst valueArbitrary = buildArbitrary(node.value as never, ctx)\n\n\t//signatureArbitrary can be a symbol or string arbitrary\n\treturn fc.dictionary(signatureArbitrary as never, valueArbitrary)\n}\n\nconst buildArrayArbitrary = (\n\tnode: nodeOfKind<\"sequence\">,\n\trefinements: fc.ArrayConstraints,\n\tctx: Ctx\n): fc.Arbitrary<unknown[]> => {\n\t//Arrays will always have a single element and the kind will be variadic\n\tif (node.tuple.length === 1 && node.tuple[0].kind === \"variadic\") {\n\t\tconst elementsArbitrary = buildArbitrary(node.tuple[0].node as never, ctx)\n\n\t\tconst arrArbitrary = fc.array(elementsArbitrary, refinements)\n\n\t\treturn getPossiblyWeightedArray(arrArbitrary, node, ctx)\n\t}\n\n\treturn getSpreadVariadicElementsTuple(node.tuple, ctx)\n}\n\nconst getSpreadVariadicElementsTuple = (\n\ttupleElements: SequenceTuple,\n\tctx: Ctx\n) => {\n\tconst tupleArbitraries = []\n\tfor (const element of tupleElements) {\n\t\tconst arbitrary = buildArbitrary(element.node as never, ctx)\n\n\t\tif (element.kind === \"variadic\") tupleArbitraries.push(fc.array(arbitrary))\n\t\telse tupleArbitraries.push(arbitrary)\n\t}\n\n\treturn spreadVariadicElements(tupleArbitraries, tupleElements)\n}\n"
  },
  {
    "path": "ark/fast-check/fastCheckContext.ts",
    "content": "import type { Arbitrary, LetrecLooselyTypedTie } from \"fast-check\"\n\nexport type Ctx = {\n\tseenIntersectionIds: Record<string, true>\n\tarbitrariesByIntersectionId: Record<string, Arbitrary<unknown>>\n\tisCyclic: boolean\n\ttieStack: LetrecLooselyTypedTie[]\n}\n\nexport const initializeContext = (): Ctx => ({\n\tseenIntersectionIds: {},\n\tarbitrariesByIntersectionId: {},\n\tisCyclic: false,\n\ttieStack: []\n})\n"
  },
  {
    "path": "ark/fast-check/package.json",
    "content": "{\n\t\"name\": \"@ark/fast-check\",\n\t\"version\": \"0.0.11\",\n\t\"license\": \"MIT\",\n\t\"author\": {\n\t\t\"name\": \"David Blass\",\n\t\t\"email\": \"david@arktype.io\",\n\t\t\"url\": \"https://arktype.io\"\n\t},\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"https://github.com/arktypeio/arktype.git\",\n\t\t\"directory\": \"ark/fast-check\"\n\t},\n\t\"type\": \"module\",\n\t\"main\": \"./out/arktypeFastCheck.js\",\n\t\"types\": \"./out/arktypeFastCheck.d.ts\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"ark-ts\": \"./arktypeFastCheck.ts\",\n\t\t\t\"default\": \"./out/arktypeFastCheck.js\"\n\t\t},\n\t\t\"./internal/*.ts\": {\n\t\t\t\"ark-ts\": \"./*.ts\",\n\t\t\t\"default\": \"./out/*.js\"\n\t\t},\n\t\t\"./internal/*.js\": {\n\t\t\t\"ark-ts\": \"./*.ts\",\n\t\t\t\"default\": \"./out/*.js\"\n\t\t}\n\t},\n\t\"files\": [\n\t\t\"out\"\n\t],\n\t\"scripts\": {\n\t\t\"build\": \"ts ../repo/build.ts\",\n\t\t\"test\": \"tsx ../repo/testPackage.ts\"\n\t},\n\t\"dependencies\": {\n\t\t\"arktype\": \"workspace:*\",\n\t\t\"@ark/schema\": \"workspace:*\",\n\t\t\"@ark/util\": \"workspace:*\"\n\t},\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t},\n\t\"peerDependencies\": {\n\t\t\"fast-check\": \"3\"\n\t}\n}\n"
  },
  {
    "path": "ark/fs/caller.ts",
    "content": "import path from \"node:path\"\nimport * as process from \"node:process\"\nimport { fileURLToPath } from \"node:url\"\nimport { isDeepStrictEqual } from \"node:util\"\nimport { getCurrentLine, getFramesFromError } from \"./getCurrentLine.ts\"\n\nexport type GetCallStackOptions = {\n\toffset?: number\n}\n\nexport const getCallStack = ({\n\toffset = 0\n}: GetCallStackOptions = {}): string[] => {\n\tconst frames = getFramesFromError(new Error())\n\tframes.splice(1, 1 + offset)\n\treturn frames\n}\n\nexport type LinePosition = {\n\tline: number\n\tchar: number\n}\n\nexport type SourcePosition = LinePosition & {\n\tfile: string\n\tmethod: string\n}\n\nexport type CallerOfOptions = {\n\tformatPath?: FormatFilePathOptions\n\tupStackBy?: number\n\tskip?: (position: SourcePosition) => boolean\n\tmethodName?: string\n}\n\nconst nonexistentCurrentLine = {\n\tline: -1,\n\tchar: -1,\n\tmethod: \"\",\n\tfile: \"\"\n}\n\nexport type FormatFilePathOptions = {\n\trelative?: string | boolean\n\tseparator?: string\n}\n\nexport const positionToString = (position: SourcePosition): string =>\n\t`line ${position.line}, character ${position.char} at path '${position.file}'`\n\nexport const formatFilePath = (\n\toriginal: string,\n\t{ relative, separator }: FormatFilePathOptions\n): string => {\n\tlet formatted = original\n\tif (original.startsWith(\"file:///\")) formatted = fileURLToPath(original)\n\n\tif (relative) {\n\t\tformatted = path.relative(\n\t\t\ttypeof relative === \"string\" ? relative : process.cwd(),\n\t\t\tformatted\n\t\t)\n\t}\n\tif (separator)\n\t\tformatted = formatted.replace(new RegExp(`\\\\${path.sep}`, \"g\"), separator)\n\n\treturn formatted\n}\n\nexport const caller = (options: CallerOfOptions = {}): SourcePosition => {\n\tlet upStackBy = options.upStackBy ?? 0\n\tif (!options.methodName && !options.upStackBy) upStackBy = 3\n\n\tlet match: SourcePosition | undefined\n\twhile (!match) {\n\t\tconst location = getCurrentLine({\n\t\t\tmethod: options.methodName!,\n\t\t\tframes: upStackBy\n\t\t})\n\t\tif (!location || isDeepStrictEqual(location, nonexistentCurrentLine)) {\n\t\t\tthrow new Error(\n\t\t\t\t`No caller of '${\n\t\t\t\t\toptions.methodName\n\t\t\t\t}' matches given options: ${JSON.stringify(options, null, 4)}.`\n\t\t\t)\n\t\t}\n\t\tconst candidate = {\n\t\t\t...location,\n\t\t\tfile: formatFilePath(location.file, options.formatPath ?? {})\n\t\t}\n\t\tif (options.skip?.(candidate)) upStackBy++\n\t\telse match = candidate\n\t}\n\tif (match.file.startsWith(\"file:///\")) match.file = fileURLToPath(match.file)\n\n\treturn match\n}\n\nexport const callsAgo = (\n\tnum: number,\n\toptions: Omit<CallerOfOptions, \"upStackBy\"> = {}\n): SourcePosition =>\n\tcaller({ methodName: \"callsAgo\", upStackBy: num, ...options })\n"
  },
  {
    "path": "ark/fs/fs.ts",
    "content": "import {\n\tcpSync,\n\texistsSync,\n\tlstatSync,\n\tmkdirSync,\n\treadFileSync,\n\treaddirSync,\n\trmSync,\n\tstatSync,\n\twriteFileSync\n} from \"node:fs\"\nimport { homedir } from \"node:os\"\nimport { dirname, join, parse } from \"node:path\"\nimport * as process from \"node:process\"\nimport { URL, fileURLToPath } from \"node:url\"\nimport { caller } from \"./caller.ts\"\nimport { getShellOutput } from \"./shell.ts\"\nexport { rmSync } from \"node:fs\"\n\nexport const ensureDir = (path: string): string => {\n\tif (existsSync(path)) {\n\t\tif (!statSync(path).isDirectory())\n\t\t\tthrow new Error(`${path} exists and is not a directory.`)\n\t} else mkdirSync(path, { recursive: true })\n\n\treturn path\n}\n\nexport const readFile = (path: string): string => readFileSync(path).toString()\n\nexport const writeFile = (path: string, contents: string): string => {\n\twriteFileSync(path, contents)\n\treturn contents\n}\n\nexport const rewriteFile = (\n\tpath: string,\n\ttransform: (contents: string) => string\n): string => writeFile(path, transform(readFile(path)))\n\nexport const readJson = (path: string): Record<string, unknown> =>\n\tJSON.parse(readFileSync(path, { encoding: \"utf8\" }))\n\nexport const writeJson = (path: string, data: object): void =>\n\twriteFileSync(path, `${JSON.stringify(data, null, 4)}\\n`)\n\nexport type JsonTransformer = (data: object) => object\n\nexport const rewriteJson = (\n\tpath: string,\n\ttransform: (data: object) => object\n): void => writeJson(path, transform(readJson(path)))\n\nexport const rmRf = (target: string): void =>\n\trmSync(target, { recursive: true, force: true })\n\nexport const cpR = (from: string, to: string): void =>\n\tcpSync(from, to, { recursive: true, force: true })\n\nexport type WalkOptions = {\n\tignoreDirsMatching?: RegExp\n\tignoreFilesMatching?: RegExp\n\texcludeFiles?: boolean\n\texcludeDirs?: boolean\n\texclude?: (path: string) => boolean\n\tinclude?: (path: string) => boolean\n}\n\nexport const walkPaths = (dir: string, options: WalkOptions = {}): string[] =>\n\treaddirSync(dir).reduce((paths: string[], item: string) => {\n\t\tconst path = join(dir, item)\n\t\tconst isDir = lstatSync(path).isDirectory()\n\t\tconst isFile = lstatSync(path).isFile()\n\t\tif (isDir && options.ignoreDirsMatching?.test(path)) return paths\n\n\t\tif (isFile && options.ignoreFilesMatching?.test(path)) return paths\n\n\t\tconst excludeCurrent =\n\t\t\t(options.excludeDirs && isDir) ||\n\t\t\t(options.excludeFiles && !isDir) ||\n\t\t\toptions.exclude?.(path) ||\n\t\t\t(options.include && !options.include(path))\n\t\tconst nestedPaths = isDir ? walkPaths(path, options) : []\n\t\tpaths.push(...(excludeCurrent ? [] : [path]), ...nestedPaths)\n\t\treturn paths\n\t}, [])\n\n/** Fetch the file and directory paths from a path, uri, or `import.meta.url` */\nexport const filePath = (path: string): string => {\n\tlet file: string\n\tif (path.includes(\"://\")) {\n\t\t// is a url, e.g. file://, or https://\n\t\tconst url = new URL(path)\n\t\tfile = url.protocol === \"file:\" ? fileURLToPath(url) : url.href\n\t} else {\n\t\t// is already a typical path\n\t\tfile = path\n\t}\n\treturn file\n}\n\nconst fileOfCaller = () =>\n\tfilePath(caller({ methodName: \"fileOfCaller\", upStackBy: 1 }).file)\n\nconst dirOfCaller = () =>\n\tdirname(filePath(caller({ methodName: \"dirOfCaller\", upStackBy: 1 }).file))\n\nexport const fileName = (): string => fileOfCaller()\n\nexport const dirName = (): string => dirOfCaller()\n\nexport const fromHere = (...joinWith: string[]): string =>\n\tjoin(dirOfCaller(), ...joinWith)\n\nexport const fromCwd = (...joinWith: string[]): string =>\n\tjoin(process.cwd(), ...joinWith)\n\nexport const fromHome = (...joinWith: string[]): string =>\n\tjoin(homedir()!, ...joinWith)\n\nexport const fsRoot: string = parse(process.cwd()).root\n\nexport const findPackageRoot = (fromDir?: string): string | null => {\n\tconst startDir = fromDir ?? dirOfCaller()\n\tlet dirToCheck = startDir\n\twhile (dirToCheck !== fsRoot) {\n\t\ttry {\n\t\t\tconst contents = readJson(join(dirToCheck, \"package.json\"))\n\t\t\t/*\n\t\t\t * If the file is just a stub with no package name, don't consider\n\t\t\t * it a package root\n\t\t\t */\n\t\t\tif (\"name\" in contents) return dirToCheck\n\t\t} catch {\n\t\t\t// If the file doesn't exist, go up another level\n\t\t}\n\t\tdirToCheck = join(dirToCheck, \"..\")\n\t}\n\treturn null\n}\n\nexport const assertPackageRoot = (fromDir?: string): string => {\n\tconst startDir = fromDir ?? dirOfCaller()\n\tconst result = findPackageRoot(fromDir)\n\tif (result) return result\n\n\tthrow new Error(`${startDir} is not part of a node package.`)\n}\n\nexport const findPackageAncestors = (fromDir?: string): string[] => {\n\tconst dirs: string[] = []\n\n\tlet dir: string | null = fromDir ?? dirOfCaller()\n\n\twhile (dir) {\n\t\tdir = findPackageRoot(dir)\n\t\tif (dir) {\n\t\t\tdirs.push(dir)\n\t\t\tdir = join(dir, \"..\")\n\t\t}\n\t}\n\n\treturn dirs\n}\n\nexport const readPackageJsonAncestors = (fromDir?: string): any[] =>\n\tfindPackageAncestors(fromDir).map(dir => readPackageJson(dir))\n\nexport const fromPackageRoot = (...joinWith: string[]): string =>\n\tjoin(assertPackageRoot(dirOfCaller()), ...joinWith)\n\nexport const readPackageJson = (startDir = dirOfCaller()): any =>\n\treadJson(join(assertPackageRoot(startDir), \"package.json\"))\n\nexport const getSourceControlPaths = (): string[] =>\n\t// include tracked and untracked files as long as they are not ignored\n\tgetShellOutput(\"git ls-files --exclude-standard --cached --others\")\n\t\t.split(\"\\n\")\n\t\t.filter(path => existsSync(path) && statSync(path).isFile())\n\nexport const tsFileMatcher: RegExp = /^.*\\.(c|m)?tsx?$/\n\nconst inFileFilter: WalkOptions = {\n\tinclude: path => tsFileMatcher.test(path),\n\tignoreDirsMatching: /node_modules|out|dist|docgen/\n}\n\nexport const getSourceFilePaths = (dir = \".\"): string[] =>\n\twalkPaths(dir, inFileFilter)\n\nexport type SourceFileEntry = [path: string, contents: string]\n\nexport const getSourceFileEntries = (dir = \".\"): SourceFileEntry[] =>\n\tgetSourceFilePaths(dir).map(path => [path, readFile(path)])\n\nexport type ReplacementDictionary = Record<\n\tstring,\n\t{ pattern: RegExp; replacement: `\"${string}\"` }\n>\nexport type Matchers = ReadonlyArray<Matcher>\nexport type Matcher = {\n\tpattern: RegExp\n\treplacement: string\n}\n\n/**\n * Given a set of {@link Matchers} and an input string,\n * replace all will replace\n */\nconst findReplace: (matchers: Matchers) => (input: string) => string =\n\tmatchers => input =>\n\t\tmatchers.reduce((acc, m) => acc.replace(m.pattern, m.replacement), input)\n\n/**\n * Applies a set of {@link Matchers} to a list of files and rewrites\n * each file's contents according to the provided `Matcher[\"find\"]`\n * and `Matcher[\"replace\"]`.\n */\nconst findReplaceMany =\n\t(matchers: Matchers) =>\n\t(files: readonly string[] = []) => {\n\t\tfor (const file of files)\n\t\t\twriteFile(file, findReplace(matchers)(readFile(file)))\n\t}\n\n/**\n * Given a directory and a set of {@link Matchers}, recursively walks\n * the directory and applies every set of changes in the dictionary\n * to all files except those matching `ignoreFilesMatching`.\n */\nexport const findReplaceAll =\n\t(matchDictionary: ReplacementDictionary, ignoreFilesMatching: RegExp) =>\n\t(dirPath: string): void => {\n\t\tconst files = walkPaths(dirPath, {\n\t\t\texcludeDirs: true,\n\t\t\tignoreFilesMatching\n\t\t})\n\n\t\tconst matchers: Matchers = Object.values(matchDictionary)\n\t\tfindReplaceMany(matchers)(files)\n\t}\n"
  },
  {
    "path": "ark/fs/getCurrentLine.ts",
    "content": "// Copied from unmaintained package https://github.com/bevry/get-current-line to fix imports\n\n/** The combination of location information about the line that was executing at the time */\nexport type Location = {\n\t/** the location of the line that was executing at the time */\n\tline: number\n\t/** the location of the character that was executing at the time */\n\tchar: number\n\t/** the method name that was executing at the time */\n\tmethod: string\n\t/** the file path that was executing at the time */\n\tfile: string\n}\n\n/**\n * If provided, continue skipping until:\n *\n * 1. The file or method is found\n * 2. Once found, will continue until neither the file nor method are found anymore\n * 3. Once exited, the frame offset will then apply\n *\n * If you wish to capture the found method or the file, combine them with `frames: -1` or `immediate: true`.\n *\n * If you wish for more customisation than this, create an issue requesting passing a custom skip handler function, as more variance to this interface is too much customisation complexity.\n */\ntype Offset = {\n\t/**\n\t * if provided, continue until a method containing or matching this string is exited\n\t * if provided alongside a file, will continue until neither the file nor method are found\n\t * this allows file and method to act as fallbacks for each other, such that if one is not found, it doesn't skip everything\n\t */\n\tmethod?: RegExp | string | null\n\t/**\n\t * if provided, continue until a file containing or matching this string is exited\n\t * if provided alongside a method, will continue until neither the file nor method are found\n\t * this allows file and method to act as fallbacks for each other, such that if one is not found, it doesn't skip everything\n\t */\n\tfile?: RegExp | string | null\n\t/**\n\t * once we have satisfied the found condition, if any, then apply this index offset to the frames\n\t * e.g. 1 would mean next frame, and -1 would mean the previous frame\n\t * Use -1 to go back to the found method or file\n\t */\n\tframes?: number\n\t/**\n\t * once we have satisfied the found condition, should we apply the frame offset immediately, or wait until the found condition has exited\n\t */\n\timmediate?: boolean\n}\n\n/**\n * For an error instance, return its stack frames as an array.\n */\nexport const getFramesFromError = (error: Error): string[] => {\n\t// Create an error\n\tlet stack: Error[\"stack\"] | null, frames: any[]\n\n\t// And attempt to retrieve it's stack\n\t// https://github.com/winstonjs/winston/issues/401#issuecomment-61913086\n\ttry {\n\t\tstack = error.stack\n\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t} catch (error1) {\n\t\ttry {\n\t\t\t// @ts-expect-error https://github.com/winstonjs/winston/issues/401#issuecomment-61913086\n\t\t\tconst previous = err.__previous__ || err.__previous\n\t\t\tstack = previous && previous.stack\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t} catch (error2) {\n\t\t\tstack = null\n\t\t}\n\t}\n\n\t// Handle different stack formats\n\tif (stack)\n\t\tframes = Array.isArray(stack) ? Array(stack) : stack.toString().split(\"\\n\")\n\telse frames = []\n\n\t// Parse our frames\n\treturn frames\n}\n\nconst lineRegex =\n\t/\\s+at\\s(?:(?<method>.+?)\\s\\()?(?<file>.+?):(?<line>\\d+):(?<char>\\d+)\\)?\\s*$/\n\n/**\n * Get the locations from a list of error stack frames.\n */\nconst getLocationsFromFrames = (frames: string[]): Location[] => {\n\t// Prepare\n\tconst locations: Location[] = []\n\n\t// Cycle through the lines\n\tfor (const frame of frames) {\n\t\t// ensure each line is a string\n\t\tconst line = (frame || \"\").toString()\n\n\t\t// skip empty lines\n\t\tif (line.length === 0) continue\n\n\t\t// Error\n\t\t// at file:///Users/balupton/Projects/active/get-current-line/asd.js:1:13\n\t\t// at ModuleJob.run (internal/modules/esm/module_job.js:140:23)\n\t\t// at async Loader.import (internal/modules/esm/loader.js:165:24)\n\t\t// at async Object.loadESM (internal/process/esm_loader.js:68:5)\n\t\tconst match = line.match(lineRegex)\n\t\tif (match && match.groups) {\n\t\t\tlocations.push({\n\t\t\t\tmethod: match.groups.method || \"\",\n\t\t\t\tfile: match.groups.file || \"\",\n\t\t\t\tline: Number(match.groups.line),\n\t\t\t\tchar: Number(match.groups.char)\n\t\t\t})\n\t\t}\n\t}\n\n\treturn locations\n}\n\n/**\n * If a location is not found, this is the result that is used.\n */\nconst failureLocation: Location = {\n\tline: -1,\n\tchar: -1,\n\tmethod: \"\",\n\tfile: \"\"\n}\n\n/**\n * From a list of locations, get the location that is determined by the offset.\n * If none are found, return the failure location\n */\nconst getLocationWithOffset = (locations: Array<Location>, offset: Offset) => {\n\t// Continue\n\tlet found: boolean = !offset.file && !offset.method\n\n\t// use while loop so we can skip ahead\n\tlet i = 0\n\twhile (i < locations.length) {\n\t\tconst location = locations[i]\n\n\t\t// the current location matches the offset\n\t\tif (\n\t\t\t(offset.file &&\n\t\t\t\t(typeof offset.file === \"string\" ?\n\t\t\t\t\tlocation.file.includes(offset.file)\n\t\t\t\t:\toffset.file.test(location.file))) ||\n\t\t\t(offset.method &&\n\t\t\t\t(typeof offset.method === \"string\" ?\n\t\t\t\t\tlocation.method.includes(offset.method)\n\t\t\t\t:\toffset.method.test(location.method)))\n\t\t) {\n\t\t\t// we are found, and we should exit immediatelyg, so return with the frame offset applied\n\t\t\tif (offset.immediate) {\n\t\t\t\t// apply frame offset\n\t\t\t\ti += offset.frames || 0\n\t\t\t\t// and return the result\n\t\t\t\treturn locations[i]\n\t\t\t}\n\t\t\t// otherwise, continue until the found condition has exited\n\t\t\telse {\n\t\t\t\tfound = true\n\t\t\t\t++i\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\t// has been found, and the found condition has exited, so return with the frame offset applied\n\t\telse if (found) {\n\t\t\t// apply frame offset\n\t\t\ti += offset.frames || 0\n\t\t\t// and return the result\n\t\t\treturn locations[i]\n\t\t}\n\t\t// nothing has been found yet, so continue until we find the offset\n\t\telse {\n\t\t\t++i\n\t\t\tcontinue\n\t\t}\n\t}\n\n\t// return failure\n\treturn failureLocation\n}\n\n/**\n * Get each error stack frame's location information.\n */\nconst getLocationsFromError = (error: Error): Location[] => {\n\tconst frames = getFramesFromError(error)\n\treturn getLocationsFromFrames(frames)\n}\n\n/**\n * Get first determined location information that appears in the stack of the error.\n * If no offset is provided, then the offset used will determine the first location information.\n */\nconst getLocationFromError = (\n\terror: Error,\n\toffset: Offset = {\n\t\timmediate: true\n\t}\n): Location => {\n\tconst locations = getLocationsFromError(error)\n\treturn getLocationWithOffset(locations, offset)\n}\n\n/**\n * Get the location information about the line that called this method.\n * If no offset is provided, then continue until the caller of the `getCurrentLine` is found.\n * @example Input\n * ``` javascript\n * console.log(getCurrentLine())\n * ```\n * @example Result\n * ``` json\n * {\n * \t\"line\": \"1\",\n * \t\"char\": \"12\",\n * \t\"method\": \"Object.<anonymous>\",\n * \t\"file\": \"/Users/balupton/some-project/calling-file.ts\"\n * }\n * ```\n */\nexport const getCurrentLine = (\n\toffset: Offset = {\n\t\tmethod: \"getCurrentLine\",\n\t\tframes: 0,\n\t\timmediate: false\n\t}\n): Location => getLocationFromError(new Error(), offset)\n"
  },
  {
    "path": "ark/fs/index.ts",
    "content": "export * from \"./caller.ts\"\nexport * from \"./fs.ts\"\nexport * from \"./shell.ts\"\n"
  },
  {
    "path": "ark/fs/package.json",
    "content": "{\n\t\"name\": \"@ark/fs\",\n\t\"version\": \"0.56.0\",\n\t\"license\": \"MIT\",\n\t\"author\": {\n\t\t\"name\": \"David Blass\",\n\t\t\"email\": \"david@arktype.io\",\n\t\t\"url\": \"https://arktype.io\"\n\t},\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"https://github.com/arktypeio/arktype.git\",\n\t\t\"directory\": \"ark/fs\"\n\t},\n\t\"type\": \"module\",\n\t\"main\": \"./out/index.js\",\n\t\"types\": \"./out/index.d.ts\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"ark-ts\": \"./index.ts\",\n\t\t\t\"default\": \"./out/index.js\"\n\t\t},\n\t\t\"./internal/*.ts\": {\n\t\t\t\"ark-ts\": \"./*.ts\",\n\t\t\t\"default\": \"./out/*.js\"\n\t\t},\n\t\t\"./internal/*.js\": {\n\t\t\t\"ark-ts\": \"./*.ts\",\n\t\t\t\"default\": \"./out/*.js\"\n\t\t}\n\t},\n\t\"scripts\": {\n\t\t\"build\": \"ts ../repo/build.ts\"\n\t},\n\t\"files\": [\n\t\t\"out\"\n\t],\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t}\n}\n"
  },
  {
    "path": "ark/fs/shell.ts",
    "content": "import { execSync, type ExecSyncOptions } from \"node:child_process\"\nimport * as process from \"node:process\"\n\nexport type ShellOptions = Omit<ExecSyncOptions, \"stdio\"> & {\n\tenv?: Record<string, string | undefined>\n}\n\n/** Run the cmd synchronously. Output goes to terminal. */\nexport const shell = (\n\tcmd: string,\n\t{ env, ...otherOptions }: ShellOptions = {}\n): void => {\n\texecSync(cmd, {\n\t\tenv: { ...process.env, ...env },\n\t\t...otherOptions,\n\t\tstdio: \"inherit\"\n\t})\n}\n\n/** Run the cmd synchronously, returning output as a string */\nexport const getShellOutput = (\n\tcmd: string,\n\t{ env, ...otherOptions }: ShellOptions = {}\n): string =>\n\texecSync(cmd, {\n\t\tenv: { ...process.env, ...env },\n\t\t...otherOptions,\n\t\tstdio: \"pipe\"\n\t})!.toString()\n"
  },
  {
    "path": "ark/json-schema/CHANGELOG.md",
    "content": "# @ark/json-schema\n\n## 0.0.1\n\n### Initial Release\n\nReleased the initial implementation of the package.\n"
  },
  {
    "path": "ark/json-schema/README.md",
    "content": "# @ark/json-schema\n\n## What is it?\n\n`@ark/json-schema` is a package that allows converting from a JSON Schema schema to an ArkType Type. For example:\n\n```js\nimport { jsonSchemaToType } from \"@ark/json-schema\"\n\nconst T = jsonSchemaToType({ type: \"string\", minLength: 5, maxLength: 10 })\n```\n\nis equivalent to:\n\n```js\nimport { type } from \"arktype\"\n\nconst T = type(\"5<=string<=10\")\n```\n\nThis enables easy adoption of ArkType for people who currently have JSON Schema based runtime validation in their codebase.\n\nIf you want to convert your existing ArkType `Type`s to JSON Schema, you don't need this library.\n\nInstead, use the built-in `toJsonSchema()` method that exists on every `Type`, e.g.:\n\n```ts\nimport { type } from \"arktype\"\n\n// { type: \"string\", minLength: 5, maxLength: 10 }\nconst schema = type(\"5<=string<=10\").toJsonSchema()\n```\n\n## Extra Type Safety\n\nIf you wish to ensure that your JSON Schema schemas are valid, you can do this too! Simply import the relevant `Schema` type from `@ark/json-schema` like so:\n\n```ts\nimport type { JsonSchema } from \"arktype\"\n\nconst integerSchema: JsonSchema.Numeric = {\n\ttype: \"integer\",\n\tmultipleOf: \"3\" // errors stating that 'multipleOf' must be a number\n}\n```\n\nNote that for string schemas exclusively, you must import the schema type from `@ark/json-schema` instead of `arktype`. This is because `@ark/json-schema` doesn't yet support the `format` keyword whilst `arktype` does.\n\n```ts\nimport type { StringSchema } from \"@ark/json-schema\"\nconst stringSchema: StringSchema = {\n\ttype: \"string\",\n\tminLength: \"3\" // errors stating that 'minLength' must be a number\n}\n```\n\n## Limitations\n\n- No `dependencies` support\n- No `if`/`else`/`then` support\n- `multipleOf` only supports integers\n"
  },
  {
    "path": "ark/json-schema/__tests__/array.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport {\n\tjsonSchemaToType,\n\twriteJsonSchemaArrayAdditionalItemsAndItemsAndPrefixItemsMessage,\n\twriteJsonSchemaArrayNonArrayItemsAndAdditionalItemsMessage\n} from \"@ark/json-schema\"\n\ncontextualize(() => {\n\tit(\"type array\", () => {\n\t\tconst t = jsonSchemaToType({ type: \"array\" })\n\t\tattest(t.expression).snap(\"Array\")\n\t})\n\n\tit(\"items\", () => {\n\t\tconst tItems = jsonSchemaToType({\n\t\t\ttype: \"array\",\n\t\t\titems: { type: \"string\" }\n\t\t})\n\t\tattest(tItems.expression).snap(\"string[]\")\n\n\t\tconst tItemsArr = jsonSchemaToType({\n\t\t\ttype: \"array\",\n\t\t\titems: [{ type: \"string\" }, { type: \"number\" }]\n\t\t})\n\t\tattest(tItemsArr.expression).snap(\"[string, number]\")\n\t})\n\n\tit(\"prefixItems\", () => {\n\t\tconst tPrefixItems = jsonSchemaToType({\n\t\t\ttype: \"array\",\n\t\t\tprefixItems: [{ type: \"string\" }, { type: \"number\" }]\n\t\t})\n\t\tattest(tPrefixItems.expression).snap(\"[string, number, ...unknown[]]\")\n\t})\n\n\tit(\"items & prefixItems\", () => {\n\t\tconst tItemsAndPrefixItems = jsonSchemaToType({\n\t\t\ttype: \"array\",\n\t\t\tprefixItems: [{ type: \"string\" }, { type: \"number\" }],\n\t\t\titems: { type: \"boolean\" }\n\t\t})\n\t\tattest(tItemsAndPrefixItems.expression).snap(\n\t\t\t\"[string, number, ...boolean[]]\"\n\t\t)\n\t})\n\n\tit(\"additionalItems\", () => {\n\t\tconst tAdditionalItems = jsonSchemaToType({\n\t\t\ttype: \"array\",\n\t\t\tadditionalItems: { type: \"string\" }\n\t\t})\n\t\tattest(tAdditionalItems.expression).snap(\"string[]\")\n\t})\n\n\tit(\"additionalItems & items\", () => {\n\t\tconst tItemsVariadic = jsonSchemaToType({\n\t\t\ttype: \"array\",\n\t\t\tadditionalItems: { type: \"boolean\" },\n\t\t\titems: [{ type: \"string\" }, { type: \"number\" }]\n\t\t})\n\t\tattest(tItemsVariadic.expression).snap(\"[string, number, ...boolean[]]\")\n\n\t\tconst tItemsFalseAdditional = jsonSchemaToType({\n\t\t\ttype: \"array\",\n\t\t\tadditionalItems: false,\n\t\t\titems: [{ type: \"string\" }]\n\t\t})\n\t\tattest(tItemsFalseAdditional.expression).snap(\"[string]\")\n\n\t\tattest(() =>\n\t\t\tjsonSchemaToType({\n\t\t\t\ttype: \"array\",\n\t\t\t\tadditionalItems: { type: \"string\" },\n\t\t\t\titems: { type: \"string\" }\n\t\t\t})\n\t\t).throws(writeJsonSchemaArrayNonArrayItemsAndAdditionalItemsMessage())\n\t})\n\n\tit(\"additionalItems & prefixItems\", () => {\n\t\tconst tPrefixItemsAndAdditional = jsonSchemaToType({\n\t\t\ttype: \"array\",\n\t\t\tadditionalItems: { type: \"boolean\" },\n\t\t\tprefixItems: [{ type: \"string\" }, { type: \"number\" }]\n\t\t})\n\t\tattest(tPrefixItemsAndAdditional.expression).snap(\n\t\t\t\"[string, number, ...boolean[]]\"\n\t\t)\n\t})\n\n\tit(\"additionalItems & items & prefixItems\", () => {\n\t\tattest(() =>\n\t\t\tjsonSchemaToType({\n\t\t\t\ttype: \"array\",\n\t\t\t\tadditionalItems: { type: \"boolean\" },\n\t\t\t\titems: { type: \"null\" },\n\t\t\t\tprefixItems: [{ type: \"string\" }, { type: \"number\" }]\n\t\t\t})\n\t\t).throws(writeJsonSchemaArrayAdditionalItemsAndItemsAndPrefixItemsMessage())\n\t})\n\n\tit(\"contains\", () => {\n\t\tconst tContains = jsonSchemaToType({\n\t\t\ttype: \"array\",\n\t\t\tcontains: { type: \"number\" }\n\t\t})\n\t\tattest(tContains.json).snap({\n\t\t\tproto: \"Array\",\n\t\t\tpredicate: [\"$ark.jsonSchemaArrayContainsValidator\"]\n\t\t})\n\t\tattest(tContains.allows([])).equals(false)\n\t\tattest(tContains.allows([1, 2, 3])).equals(true)\n\t\tattest(tContains.allows([\"foo\", 2, \"baz\"])).equals(true)\n\t})\n\n\tit(\"maxItems (positive)\", () => {\n\t\tconst tMaxItems = jsonSchemaToType({\n\t\t\ttype: \"array\",\n\t\t\tmaxItems: 5\n\t\t})\n\t\tattest(tMaxItems.expression).snap(\"Array <= 5\")\n\t})\n\n\tit(\"maxItems (negative)\", () => {\n\t\tattest(() => jsonSchemaToType({ type: \"array\", maxItems: -1 })).throws(\n\t\t\t\"TraversalError: maxItems must be non-negative\"\n\t\t)\n\t})\n\n\tit(\"minItems (positive)\", () => {\n\t\tconst tMinItems = jsonSchemaToType({\n\t\t\ttype: \"array\",\n\t\t\tminItems: 5\n\t\t})\n\t\tattest(tMinItems.expression).snap(\"Array >= 5\")\n\t})\n\n\tit(\"minItems (negative)\", () => {\n\t\tattest(() => jsonSchemaToType({ type: \"array\", minItems: -1 })).throws(\n\t\t\t\"TraversalError: minItems must be non-negative\"\n\t\t)\n\t})\n\n\tit(\"minItems (0)\", () => {\n\t\tconst tMinItems = jsonSchemaToType({\n\t\t\ttype: \"array\",\n\t\t\tminItems: 0,\n\t\t\titems: { type: \"string\" }\n\t\t})\n\n\t\tattest(tMinItems.expression).snap(\"string[]\")\n\t})\n\n\tit(\"uniqueItems\", () => {\n\t\tconst tUniqueItems = jsonSchemaToType({\n\t\t\ttype: \"array\",\n\t\t\tuniqueItems: true\n\t\t})\n\t\tattest(tUniqueItems.json).snap({\n\t\t\tproto: \"Array\",\n\t\t\tpredicate: [\"$ark.jsonSchemaArrayUniqueItemsValidator\"]\n\t\t})\n\t\tattest(tUniqueItems.allows([1, 2, 3])).equals(true)\n\t\tattest(tUniqueItems.allows([1, 1, 2])).equals(false)\n\t\tattest(\n\t\t\ttUniqueItems.allows([\n\t\t\t\t{ foo: { bar: [\"baz\", { qux: \"quux\" }] } },\n\t\t\t\t{ foo: { bar: [\"baz\", { qux: \"quux\" }] } }\n\t\t\t])\n\t\t).equals(false)\n\t\tattest(\n\t\t\t// JSON Schema specifies that arrays must be same order to be classified as equal\n\t\t\ttUniqueItems.allows([\n\t\t\t\t{ foo: { bar: [\"baz\", { qux: \"quux\" }] } },\n\t\t\t\t{ foo: { bar: [{ qux: \"quux\" }, \"baz\"] } }\n\t\t\t])\n\t\t).equals(true)\n\n\t\tattest(() =>\n\t\t\ttUniqueItems.assert([1, 1, 2, 3, 3, { foo: \"string\" }, { foo: \"string\" }])\n\t\t).throws(\n\t\t\t'TraversalError: must be an array of unique items (was an array with 3 duplicates: 1, 3, and {\"foo\":\"string\"})'\n\t\t)\n\t})\n})\n"
  },
  {
    "path": "ark/json-schema/__tests__/composition.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { jsonSchemaToType } from \"@ark/json-schema\"\n\ncontextualize(() => {\n\tit(\"allOf\", () => {\n\t\tconst tAllOf = jsonSchemaToType({\n\t\t\tallOf: [\n\t\t\t\t{ type: \"string\", minLength: 1 },\n\t\t\t\t{ type: \"string\", maxLength: 10 }\n\t\t\t]\n\t\t})\n\t\tattest(tAllOf.expression).snap(\"string <= 10 & >= 1\")\n\t})\n\n\tit(\"anyOf\", () => {\n\t\tconst tAnyOf = jsonSchemaToType({\n\t\t\tanyOf: [\n\t\t\t\t{ type: \"string\", minLength: 1 },\n\t\t\t\t{ type: \"string\", maxLength: 10 }\n\t\t\t]\n\t\t})\n\t\tattest(tAnyOf.expression).snap(\"string <= 10 | string >= 1\")\n\t})\n\n\tit(\"not\", () => {\n\t\tconst tNot = jsonSchemaToType({ not: { type: \"string\", maxLength: 3 } })\n\t\tattest(tNot.json).snap({\n\t\t\tpredicate: [\"$ark.jsonSchemaNotValidator\"]\n\t\t})\n\n\t\tattest(tNot.allows(123)).equals(true)\n\t\tattest(tNot.allows(\"1234\")).equals(true)\n\t\tattest(() => tNot.assert(\"123\")).throws(\n\t\t\t'TraversalError: must be not: a string and at most length 3 (was \"123\")'\n\t\t)\n\t})\n\n\tit(\"oneOf\", () => {\n\t\tconst tOneOf = jsonSchemaToType({\n\t\t\toneOf: [{ type: \"string\", minLength: 10 }, { const: \"foo\" }]\n\t\t})\n\t\tattest(tOneOf.json).snap({\n\t\t\tpredicate: [\"$ark.jsonSchemaOneOfValidator\"]\n\t\t})\n\n\t\tattest(tOneOf.allows(\"foo\")).equals(true)\n\t\tattest(tOneOf.allows(\"1234567890\")).equals(true)\n\t\tattest(() => tOneOf.assert(\"bar\")).throws(\n\t\t\t'TraversalError: must be valid according to jsonSchemaOneOfValidator (was \"bar\")'\n\t\t)\n\t})\n})\n"
  },
  {
    "path": "ark/json-schema/__tests__/number.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport {\n\tjsonSchemaToType,\n\twriteJsonSchemaNumberMaximumAndExclusiveMaximumMessage,\n\twriteJsonSchemaNumberMinimumAndExclusiveMinimumMessage\n} from \"@ark/json-schema\"\n\ncontextualize(() => {\n\tit(\"type number\", () => {\n\t\tconst jsonSchema = { type: \"number\" } as const\n\n\t\tconst parsedNumberValidator = jsonSchemaToType(jsonSchema)\n\t\tattest(parsedNumberValidator.expression).snap(\"number\")\n\t})\n\n\tit(\"type integer\", () => {\n\t\tconst t = jsonSchemaToType({ type: \"integer\" })\n\t\tattest(t.expression).snap(\"number % 1\")\n\t})\n\n\tit(\"maximum\", () => {\n\t\tconst tMax = jsonSchemaToType({\n\t\t\ttype: \"number\",\n\t\t\tmaximum: 5\n\t\t})\n\t\tattest(tMax.expression).snap(\"number <= 5\")\n\t})\n\n\tit(\"exclusiveMaximum\", () => {\n\t\tconst tExclMax = jsonSchemaToType({\n\t\t\ttype: \"number\",\n\t\t\texclusiveMaximum: 5\n\t\t})\n\t\tattest(tExclMax.expression).snap(\"number < 5\")\n\t})\n\n\tit(\"maximum & exclusiveMaximum\", () => {\n\t\tattest(() =>\n\t\t\tjsonSchemaToType({\n\t\t\t\ttype: \"number\",\n\t\t\t\tmaximum: 5,\n\t\t\t\texclusiveMaximum: 5\n\t\t\t})\n\t\t).throws(writeJsonSchemaNumberMaximumAndExclusiveMaximumMessage())\n\t})\n\n\tit(\"minimum\", () => {\n\t\tconst tMin = jsonSchemaToType({ type: \"number\", minimum: 5 })\n\t\tattest(tMin.expression).snap(\"number >= 5\")\n\t})\n\n\tit(\"exclusiveMinimum\", () => {\n\t\tconst tExclMin = jsonSchemaToType({\n\t\t\ttype: \"number\",\n\t\t\texclusiveMinimum: 5\n\t\t})\n\t\tattest(tExclMin.expression).snap(\"number > 5\")\n\t})\n\n\tit(\"minimum & exclusiveMinimum\", () => {\n\t\tattest(() =>\n\t\t\tjsonSchemaToType({\n\t\t\t\ttype: \"number\",\n\t\t\t\tminimum: 5,\n\t\t\t\texclusiveMinimum: 5\n\t\t\t})\n\t\t).throws(writeJsonSchemaNumberMinimumAndExclusiveMinimumMessage())\n\t})\n\n\tit(\"multipleOf\", () => {\n\t\tconst t = jsonSchemaToType({ type: \"number\", multipleOf: 5 })\n\t\tattest(t.expression).snap(\"number % 5\")\n\n\t\tconst tInt = jsonSchemaToType({\n\t\t\ttype: \"integer\",\n\t\t\tmultipleOf: 5\n\t\t})\n\t\tattest(tInt.expression).snap(\"number % 5\")\n\t})\n})\n"
  },
  {
    "path": "ark/json-schema/__tests__/object.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport {\n\tjsonSchemaToType,\n\twriteJsonSchemaObjectNonConformingKeyAndPropertyNamesMessage,\n\twriteJsonSchemaObjectNonConformingPatternAndPropertyNamesMessage\n} from \"@ark/json-schema\"\nimport { writeDuplicateKeyMessage } from \"@ark/schema\"\n\ncontextualize(() => {\n\tit(\"type object\", () => {\n\t\tconst t = jsonSchemaToType({ type: \"object\" })\n\t\tattest(t.expression).snap(\"{}\")\n\t\tattest(t.allows({ foo: 3 }))\n\t})\n\n\tit(\"maxProperties\", () => {\n\t\tconst tMaxProperties = jsonSchemaToType({\n\t\t\ttype: \"object\",\n\t\t\tmaxProperties: 1\n\t\t})\n\t\tattest(tMaxProperties.json).snap({\n\t\t\tdomain: \"object\",\n\t\t\tpredicate: [\"$ark.jsonSchemaObjectMaxPropertiesValidator\"]\n\t\t})\n\t\tattest(tMaxProperties.allows({})).equals(true)\n\t\tattest(tMaxProperties.allows({ foo: 1 })).equals(true)\n\t\tattest(tMaxProperties.allows({ foo: 1, bar: 2 })).equals(false)\n\t\tattest(tMaxProperties.allows({ foo: 1, bar: 2, baz: 3 })).equals(false)\n\t})\n\n\tit(\"minProperties\", () => {\n\t\tconst tMinProperties = jsonSchemaToType({\n\t\t\ttype: \"object\",\n\t\t\tminProperties: 2\n\t\t})\n\t\tattest(tMinProperties.json).snap({\n\t\t\tdomain: \"object\",\n\t\t\tpredicate: [\"$ark.jsonSchemaObjectMinPropertiesValidator\"]\n\t\t})\n\t\tattest(tMinProperties.allows({})).equals(false)\n\t\tattest(tMinProperties.allows({ foo: 1 })).equals(false)\n\t\tattest(tMinProperties.allows({ foo: 1, bar: 2 })).equals(true)\n\t\tattest(tMinProperties.allows({ foo: 1, bar: 2, baz: 3 })).equals(true)\n\t})\n\n\tit(\"properties & required\", () => {\n\t\tconst tRequired = jsonSchemaToType({\n\t\t\ttype: \"object\",\n\t\t\tproperties: {\n\t\t\t\tfoo: { type: \"string\" },\n\t\t\t\tbar: { type: \"number\" }\n\t\t\t},\n\t\t\trequired: [\"foo\"]\n\t\t})\n\t\tattest(tRequired.expression).snap(\"{ foo: string, bar?: number }\")\n\n\t\tattest(() =>\n\t\t\tjsonSchemaToType({ type: \"object\", required: [\"foo\"] })\n\t\t).throws(\n\t\t\t\"TraversalError: must be a valid object JSON Schema (was an object JSON Schema with 'required' array but no 'properties' object)\"\n\t\t)\n\t\tattest(() =>\n\t\t\tjsonSchemaToType({\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: { foo: { type: \"string\" } },\n\t\t\t\trequired: [\"bar\"]\n\t\t\t})\n\t\t).throws(\n\t\t\t`TraversalError: required must be a key from the 'properties' object, i.e. foo (was bar)`\n\t\t)\n\t\tattest(() =>\n\t\t\tjsonSchemaToType({\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: { foo: { type: \"string\" } },\n\t\t\t\trequired: [\"foo\", \"foo\"]\n\t\t\t})\n\t\t).throws(writeDuplicateKeyMessage(\"foo\"))\n\t})\n\n\tit(\"additionalProperties\", () => {\n\t\tconst tAdditionalProperties = jsonSchemaToType({\n\t\t\ttype: \"object\",\n\t\t\tadditionalProperties: { type: \"number\" },\n\t\t\tproperties: { bar: { type: \"string\" } }\n\t\t})\n\t\tattest(tAdditionalProperties.json).snap({\n\t\t\tdomain: \"object\",\n\t\t\toptional: [{ key: \"bar\", value: \"string\" }],\n\t\t\tpredicate: [\"$ark.jsonSchemaObjectAdditionalPropertiesValidator\"]\n\t\t})\n\t\tattest(tAdditionalProperties.allows({})).equals(true)\n\t\tattest(tAdditionalProperties.allows({ foo: 1 })).equals(true)\n\t\tattest(tAdditionalProperties.allows({ foo: 1, bar: \"2\" })).equals(true)\n\t\tattest(tAdditionalProperties.allows({ foo: 1, baz: \"2\" })).equals(false)\n\t})\n\n\tit(\"patternProperties\", () => {\n\t\tconst tPatternProperties = jsonSchemaToType({\n\t\t\ttype: \"object\",\n\t\t\tpatternProperties: {\n\t\t\t\t\"^[a-z]+$\": { type: \"string\" }\n\t\t\t}\n\t\t})\n\t\tattest(tPatternProperties.expression).snap(\"{ [/^[a-z]+$/]: string }\")\n\t\tattest(tPatternProperties.allows({})).equals(true)\n\t\tattest(tPatternProperties.allows({ foo: \"bar\" })).equals(true)\n\t\tattest(tPatternProperties.allows({ foo: 1 })).equals(false)\n\t\tattest(tPatternProperties.allows({ \"123\": \"bar\" })).equals(true) // true since by default JSON Schema allows additional properties\n\t})\n\n\tit(\"propertyNames\", () => {\n\t\tconst tPropertyNames = jsonSchemaToType({\n\t\t\ttype: \"object\",\n\t\t\tpropertyNames: { type: \"string\", minLength: 5 }\n\t\t})\n\t\tattest(tPropertyNames.expression).snap(\n\t\t\t\"{ [string >= 5]: unknown, + (undeclared): reject }\"\n\t\t)\n\n\t\tattest(() =>\n\t\t\t// @ts-expect-error\n\t\t\tjsonSchemaToType({\n\t\t\t\ttype: \"object\",\n\t\t\t\tpropertyNames: { type: \"number\" }\n\t\t\t})\n\t\t).type.errors.snap(\n\t\t\t`Argument of type '{ type: \"object\"; propertyNames: { type: \"number\"; }; }' is not assignable to parameter of type 'JsonSchemaOrBoolean'.` +\n\t\t\t\t`The types of 'propertyNames.type' are incompatible between these types.` +\n\t\t\t\t`Type '\"number\"' is not assignable to type '\"string\"'.`\n\t\t)\n\t})\n\n\tit(\"propertyNames & additionalProperties\", () => {\n\t\tconst tPropertyNamesAndAdditionalProperties = jsonSchemaToType({\n\t\t\ttype: \"object\",\n\t\t\tpropertyNames: { type: \"string\", minLength: 3 },\n\t\t\tadditionalProperties: true\n\t\t})\n\t\tattest(tPropertyNamesAndAdditionalProperties.expression).snap(\n\t\t\t\"{ [string >= 3]: unknown, + (undeclared): reject }\"\n\t\t)\n\t})\n\n\tit(\"propertyNames & patternProperties\", () => {\n\t\tconst tPropertyNamesAndPatternPropertiesValid = jsonSchemaToType({\n\t\t\ttype: \"object\",\n\t\t\tpatternProperties: { foo: { type: \"number\" } },\n\t\t\tpropertyNames: { type: \"string\", pattern: \"foo\" }\n\t\t})\n\t\tattest(tPropertyNamesAndPatternPropertiesValid.expression).snap(\n\t\t\t\"{ [/foo/]: number, [/foo/]: unknown, + (undeclared): reject }\"\n\t\t)\n\n\t\tattest(() => {\n\t\t\tjsonSchemaToType({\n\t\t\t\ttype: \"object\",\n\t\t\t\tpropertyNames: { type: \"string\", minLength: 3 },\n\t\t\t\tpatternProperties: { \"^abcd\": { type: \"number\" } }\n\t\t\t})\n\t\t}).throws(\n\t\t\twriteJsonSchemaObjectNonConformingPatternAndPropertyNamesMessage(\n\t\t\t\t\"/^abcd/\",\n\t\t\t\t\"string >= 3\"\n\t\t\t)\n\t\t)\n\t})\n\n\tit(\"propertyNames & properties\", () => {\n\t\tconst tPropertyNamesAndProperties = jsonSchemaToType({\n\t\t\ttype: \"object\",\n\t\t\tpropertyNames: { type: \"string\", minLength: 3 },\n\t\t\tproperties: {\n\t\t\t\ta: { type: \"boolean\" },\n\t\t\t\tabc: { type: \"number\" }\n\t\t\t}\n\t\t})\n\n\t\tattest(tPropertyNamesAndProperties.expression).snap(\n\t\t\t\"{ [string >= 3]: unknown, a?: never, abc?: number, + (undeclared): reject }\"\n\t\t)\n\t})\n\n\tit(\"propertyNames & properties & required\", () => {\n\t\tconst tPropertyNamesAndRequiredValid = jsonSchemaToType({\n\t\t\ttype: \"object\",\n\t\t\tpropertyNames: { type: \"string\", minLength: 3 },\n\t\t\tproperties: { abc: { type: \"number\" } },\n\t\t\trequired: [\"abc\"]\n\t\t})\n\t\tattest(tPropertyNamesAndRequiredValid.expression).snap(\n\t\t\t\"{ [string >= 3]: unknown, abc: number, + (undeclared): reject }\"\n\t\t)\n\n\t\tattest(() =>\n\t\t\tjsonSchemaToType({\n\t\t\t\ttype: \"object\",\n\t\t\t\tpropertyNames: { type: \"string\", minLength: 3 },\n\t\t\t\tproperties: { a: { type: \"boolean\" } },\n\t\t\t\trequired: [\"a\"]\n\t\t\t})\n\t\t).throws(\n\t\t\twriteJsonSchemaObjectNonConformingKeyAndPropertyNamesMessage(\n\t\t\t\t\"a\",\n\t\t\t\t\"string >= 3\"\n\t\t\t)\n\t\t)\n\t})\n})\n"
  },
  {
    "path": "ark/json-schema/__tests__/string.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { jsonSchemaToType } from \"@ark/json-schema\"\nimport type { JsonSchemaOrBoolean } from \"@ark/schema\"\n\ncontextualize(() => {\n\tit(\"type string\", () => {\n\t\tconst t = jsonSchemaToType({ type: \"string\" })\n\t\tattest(t.expression).snap(\"string\")\n\t})\n\n\tit(\"maxLength (positive)\", () => {\n\t\tconst tMaxLength = jsonSchemaToType({\n\t\t\ttype: \"string\",\n\t\t\tmaxLength: 5\n\t\t})\n\t\tattest(tMaxLength.expression).snap(\"string <= 5\")\n\t})\n\n\tit(\"maxLength (negative)\", () => {\n\t\tconst maxLength = -5\n\t\tattest(() =>\n\t\t\tjsonSchemaToType({\n\t\t\t\ttype: \"string\",\n\t\t\t\tmaxLength\n\t\t\t})\n\t\t).throws(\n\t\t\t`TraversalError: maxLength must be non-negative (was ${maxLength})`\n\t\t)\n\t})\n\n\tit(\"minLength (positive)\", () => {\n\t\tconst tMinLength = jsonSchemaToType({\n\t\t\ttype: \"string\",\n\t\t\tminLength: 5\n\t\t})\n\t\tattest(tMinLength.expression).snap(\"string >= 5\")\n\t})\n\n\tit(\"minLength (negative)\", () => {\n\t\tconst minLength = -1\n\t\tattest(() =>\n\t\t\tjsonSchemaToType({\n\t\t\t\ttype: \"string\",\n\t\t\t\tminLength\n\t\t\t})\n\t\t).throws(\n\t\t\t`TraversalError: minLength must be non-negative (was ${minLength})`\n\t\t)\n\t})\n\n\tit(\"pattern\", () => {\n\t\tconst tPatternString = jsonSchemaToType({\n\t\t\ttype: \"string\",\n\t\t\tpattern: \"es\"\n\t\t})\n\t\tattest(tPatternString.expression).snap(\"/es/\")\n\t\t// JSON Schema explicitly specifies that regexes MUST NOT be implicitly anchored\n\t\t// https://json-schema.org/draft-07/draft-handrews-json-schema-validation-01#rfc.section.4.3\n\t\tattest(tPatternString.allows(\"expression\")).equals(true)\n\t})\n\n\tit(\"string enums\", () => {\n\t\tconst enumKeys = [\"keyOne\", \"keyTwo\"]\n\n\t\tconst stringEnums = jsonSchemaToType({\n\t\t\ttype: \"string\",\n\t\t\tenum: enumKeys\n\t\t})\n\n\t\tattest(stringEnums.expression).snap('\"keyOne\" | \"keyTwo\"')\n\t})\n\n\tit(\"minLength (0)\", () => {\n\t\tconst schema = {\n\t\t\ttype: \"string\",\n\t\t\tminLength: 0\n\t\t} satisfies JsonSchemaOrBoolean\n\t\tconst pattern = jsonSchemaToType(schema)\n\n\t\tattest(() => jsonSchemaToType(schema))\n\t\tattest(pattern.expression).snap(\"string\")\n\t})\n})\n"
  },
  {
    "path": "ark/json-schema/array.ts",
    "content": "import {\n\tdescribeBranches,\n\trootSchema,\n\ttype Intersection,\n\ttype Predicate,\n\ttype Traversal\n} from \"@ark/schema\"\nimport { printable, throwParseError } from \"@ark/util\"\nimport { type, type JsonSchema, type Out, type Type } from \"arktype\"\nimport {\n\twriteJsonSchemaArrayAdditionalItemsAndItemsAndPrefixItemsMessage,\n\twriteJsonSchemaArrayNonArrayItemsAndAdditionalItemsMessage\n} from \"./errors.ts\"\nimport { jsonSchemaToType } from \"./json.ts\"\nimport { JsonSchemaScope } from \"./scope.ts\"\n\nconst deepNormalize = (data: unknown): unknown =>\n\ttypeof data === \"object\" ?\n\t\tdata === null ? null\n\t\t: Array.isArray(data) ? data.map(item => deepNormalize(item))\n\t\t: Object.fromEntries(\n\t\t\t\tObject.entries(data)\n\t\t\t\t\t.map(([k, v]) => [k, deepNormalize(v)] as const)\n\t\t\t\t\t.sort((l, r) => (l[0] > r[0] ? 1 : -1))\n\t\t\t)\n\t:\tdata\n\nconst jsonSchemaArrayUniqueItemsValidator = (\n\tarray: readonly unknown[],\n\tctx: Traversal\n) => {\n\tconst seen: Record<string, true> = {}\n\tconst duplicates: unknown[] = []\n\tfor (const item of array) {\n\t\tconst stringified = JSON.stringify(deepNormalize(item))\n\t\tif (stringified in seen) duplicates.push(item)\n\t\telse seen[stringified] = true\n\t}\n\treturn duplicates.length === 0 ?\n\t\t\ttrue\n\t\t:\tctx.reject({\n\t\t\t\texpected: \"an array of unique items\",\n\t\t\t\tactual: `an array with ${duplicates.length} duplicates: ${describeBranches(\n\t\t\t\t\tduplicates.map(duplicate => printable(duplicate)),\n\t\t\t\t\t{ finalDelimiter: \", and \" }\n\t\t\t\t)}`\n\t\t\t})\n}\n\nconst arrayContainsItemMatchingSchema = (schema: Type) => {\n\tconst jsonSchemaArrayContainsValidator = (\n\t\tarray: readonly unknown[],\n\t\tctx: Traversal\n\t) =>\n\t\tarray.some(item => schema.allows(item)) === true ?\n\t\t\ttrue\n\t\t:\tctx.reject({\n\t\t\t\texpected: `at least one item satisfying 'contains' schema of ${schema.description}`,\n\t\t\t\tactual: printable(array)\n\t\t\t})\n\n\treturn jsonSchemaArrayContainsValidator\n}\n\nexport const parseArrayJsonSchema: Type<\n\t(In: JsonSchema.Array) => Out<Type<unknown[], {}>>,\n\tany\n> = JsonSchemaScope.ArraySchema.pipe(jsonSchema => {\n\tconst arktypeArraySchema: Intersection.Schema<Array<unknown>> = {\n\t\tproto: \"Array\"\n\t}\n\n\tlet itemsIsPrefixItems = false\n\tif (\"prefixItems\" in jsonSchema) {\n\t\tif (\"items\" in jsonSchema) {\n\t\t\tif (\"additionalItems\" in jsonSchema) {\n\t\t\t\tthrowParseError(\n\t\t\t\t\twriteJsonSchemaArrayAdditionalItemsAndItemsAndPrefixItemsMessage()\n\t\t\t\t)\n\t\t\t} else jsonSchema.additionalItems = jsonSchema.items\n\t\t}\n\t\tjsonSchema.items = jsonSchema.prefixItems\n\t\titemsIsPrefixItems = true\n\t}\n\n\tif (\"items\" in jsonSchema) {\n\t\tif (Array.isArray(jsonSchema.items)) {\n\t\t\tarktypeArraySchema.sequence = {\n\t\t\t\tprefix: jsonSchema.items.map(item => jsonSchemaToType(item).internal)\n\t\t\t}\n\n\t\t\tif (\"additionalItems\" in jsonSchema) {\n\t\t\t\tif (jsonSchema.additionalItems !== false) {\n\t\t\t\t\tarktypeArraySchema.sequence = {\n\t\t\t\t\t\t...arktypeArraySchema.sequence,\n\t\t\t\t\t\tvariadic: jsonSchemaToType(jsonSchema.additionalItems).internal\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (itemsIsPrefixItems) {\n\t\t\t\tarktypeArraySchema.sequence = {\n\t\t\t\t\t...arktypeArraySchema.sequence,\n\t\t\t\t\tvariadic: type.unknown.internal\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (\"additionalItems\" in jsonSchema) {\n\t\t\t\tthrowParseError(\n\t\t\t\t\twriteJsonSchemaArrayNonArrayItemsAndAdditionalItemsMessage()\n\t\t\t\t)\n\t\t\t}\n\t\t\tarktypeArraySchema.sequence = {\n\t\t\t\tvariadic: jsonSchemaToType(jsonSchema.items).internal\n\t\t\t}\n\t\t}\n\t} else if (\"additionalItems\" in jsonSchema) {\n\t\tarktypeArraySchema.sequence = {\n\t\t\tvariadic: jsonSchemaToType(jsonSchema.additionalItems).internal\n\t\t}\n\t}\n\n\tif (\"maxItems\" in jsonSchema)\n\t\tarktypeArraySchema.maxLength = jsonSchema.maxItems\n\tif (\"minItems\" in jsonSchema)\n\t\tarktypeArraySchema.minLength = jsonSchema.minItems\n\n\tconst predicates: Predicate.Schema[] = []\n\tif (\"uniqueItems\" in jsonSchema && jsonSchema.uniqueItems === true)\n\t\tpredicates.push(jsonSchemaArrayUniqueItemsValidator)\n\n\tif (\"contains\" in jsonSchema) {\n\t\tconst parsedContainsJsonSchema = jsonSchemaToType(jsonSchema.contains)\n\t\tpredicates.push(arrayContainsItemMatchingSchema(parsedContainsJsonSchema))\n\t}\n\n\tif (predicates.length > 0) arktypeArraySchema.predicate = predicates\n\n\treturn rootSchema(arktypeArraySchema) as never\n})\n"
  },
  {
    "path": "ark/json-schema/common.ts",
    "content": "import { throwParseError } from \"@ark/util\"\nimport { type JsonSchema, type Type, type } from \"arktype\"\nimport { writeJsonSchemaCommonConstAndEnumMessage } from \"./errors.ts\"\n\nexport const parseCommonJsonSchema = (\n\tjsonSchema: JsonSchema\n): Type | undefined => {\n\tif (\"const\" in jsonSchema) {\n\t\tif (\"enum\" in jsonSchema)\n\t\t\tthrowParseError(writeJsonSchemaCommonConstAndEnumMessage())\n\n\t\treturn type.unit(jsonSchema.const)\n\t}\n\n\tif (\"enum\" in jsonSchema) return type.enumerated(...jsonSchema.enum)\n}\n"
  },
  {
    "path": "ark/json-schema/composition.ts",
    "content": "import type { Traversal } from \"@ark/schema\"\nimport { printable } from \"@ark/util\"\nimport { type, type JsonSchema, type Type } from \"arktype\"\nimport { jsonSchemaToType } from \"./json.ts\"\n\nconst parseAllOfJsonSchema = (jsonSchemas: readonly JsonSchema[]): Type =>\n\tjsonSchemas\n\t\t.map(jsonSchema => jsonSchemaToType(jsonSchema))\n\t\t.reduce((acc, validator) => acc.and(validator))\n\nexport const parseAnyOfJsonSchema = (\n\tjsonSchemas: readonly JsonSchema[]\n): Type =>\n\tjsonSchemas\n\t\t.map(jsonSchema => jsonSchemaToType(jsonSchema))\n\t\t.reduce((acc, validator) => acc.or(validator))\n\nconst parseNotJsonSchema = (jsonSchema: JsonSchema): Type => {\n\tconst inner = jsonSchemaToType(jsonSchema)\n\n\tconst jsonSchemaNotValidator = (data: unknown, ctx: Traversal) =>\n\t\tinner.allows(data) ?\n\t\t\tctx.reject({\n\t\t\t\texpected: `not: ${inner.description}`,\n\t\t\t\tactual: printable(data)\n\t\t\t})\n\t\t:\ttrue\n\treturn type.unknown.narrow(jsonSchemaNotValidator)\n}\n\nconst parseOneOfJsonSchema = (jsonSchemas: readonly JsonSchema[]): Type => {\n\tconst oneOfValidators = jsonSchemas.map(nestedSchema =>\n\t\tjsonSchemaToType(nestedSchema)\n\t)\n\tconst oneOfValidatorsDescriptions = oneOfValidators.map(\n\t\tvalidator => `○ ${validator.description}`\n\t)\n\tconst jsonSchemaOneOfValidator = (data: unknown, ctx: Traversal) => {\n\t\tlet matchedValidator: Type | undefined = undefined\n\n\t\tfor (const validator of oneOfValidators) {\n\t\t\tif (validator.allows(data)) {\n\t\t\t\tif (matchedValidator === undefined) {\n\t\t\t\t\tmatchedValidator = validator\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\treturn ctx.reject({\n\t\t\t\t\texpected: `exactly one of:\\n${oneOfValidatorsDescriptions.join(\"\\n\")}`,\n\t\t\t\t\tactual: `a value that matches against at least ${matchedValidator} and ${validator}`\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\treturn matchedValidator !== undefined\n\t}\n\treturn type.unknown.narrow(jsonSchemaOneOfValidator)\n}\n\nexport const parseCompositionJsonSchema = (\n\tjsonSchema: JsonSchema\n): Type | undefined => {\n\tif (\"allOf\" in jsonSchema) return parseAllOfJsonSchema(jsonSchema.allOf)\n\tif (\"anyOf\" in jsonSchema) return parseAnyOfJsonSchema(jsonSchema.anyOf)\n\tif (\"not\" in jsonSchema) return parseNotJsonSchema(jsonSchema.not)\n\tif (\"oneOf\" in jsonSchema) return parseOneOfJsonSchema(jsonSchema.oneOf)\n}\n"
  },
  {
    "path": "ark/json-schema/errors.ts",
    "content": "/* Common Schema Parsing Errors */\nexport type writeJsonSchemaCommonConstAndEnumMessage =\n\t\"Provided JSON Schema cannot have both 'const' and 'enum' keywords.\"\nexport const writeJsonSchemaCommonConstAndEnumMessage =\n\t(): writeJsonSchemaCommonConstAndEnumMessage =>\n\t\t\"Provided JSON Schema cannot have both 'const' and 'enum' keywords.\"\n\nexport type writeJsonSchemaInsufficientKeysMessage<\n\tdescribedExpectedKeys extends string,\n\tprintableJsonSchema extends string\n> = `Provided JSON Schema must have at least one of the keys ${describedExpectedKeys} (was ${printableJsonSchema})`\nexport const writeJsonSchemaInsufficientKeysMessage = <\n\tdescribedExpectedKeys extends string,\n\tprintableJsonSchema extends string\n>(\n\tdescribedExpectedKeys: describedExpectedKeys,\n\tprintableJsonSchema: printableJsonSchema\n): writeJsonSchemaInsufficientKeysMessage<\n\tdescribedExpectedKeys,\n\tprintableJsonSchema\n> =>\n\t`Provided JSON Schema must have at least one of the keys ${describedExpectedKeys} (was ${printableJsonSchema})`\n\nexport type writeJsonSchemaUnsupportedTypeMessage<\n\tprintableType extends string\n> =\n\t`Provided 'type' value must be a supported JSON Schema type (was '${printableType}')`\nexport const writeJsonSchemaUnsupportedTypeMessage = <\n\tprintableType extends string\n>(\n\tprintableType: printableType\n): writeJsonSchemaUnsupportedTypeMessage<printableType> =>\n\t`Provided 'type' value must be a supported JSON Schema type (was '${printableType}')`\n\n/* Array Schema Parsing Errors */\nexport type writeJsonSchemaArrayAdditionalItemsAndItemsAndPrefixItemsMessage =\n\t\"Provided array JSON Schema cannot have 'additionalItems' and 'items' and 'prefixItems'\"\nexport const writeJsonSchemaArrayAdditionalItemsAndItemsAndPrefixItemsMessage =\n\t(): writeJsonSchemaArrayAdditionalItemsAndItemsAndPrefixItemsMessage =>\n\t\t\"Provided array JSON Schema cannot have 'additionalItems' and 'items' and 'prefixItems'\"\n\nexport type writeJsonSchemaArrayNonArrayItemsAndAdditionalItemsMessage =\n\t\"Provided array JSON Schema cannot have non-array 'items' and 'additionalItems\"\nexport const writeJsonSchemaArrayNonArrayItemsAndAdditionalItemsMessage =\n\t(): writeJsonSchemaArrayNonArrayItemsAndAdditionalItemsMessage =>\n\t\t\"Provided array JSON Schema cannot have non-array 'items' and 'additionalItems\"\n\n/* Number Schema Parsing Errors */\nexport type writeJsonSchemaNumberMaximumAndExclusiveMaximumMessage =\n\t\"Provided number JSON Schema cannot have 'maximum' and 'exclusiveMaximum\"\nexport const writeJsonSchemaNumberMaximumAndExclusiveMaximumMessage =\n\t(): writeJsonSchemaNumberMaximumAndExclusiveMaximumMessage =>\n\t\t\"Provided number JSON Schema cannot have 'maximum' and 'exclusiveMaximum\"\n\nexport type writeJsonSchemaNumberMinimumAndExclusiveMinimumMessage =\n\t\"Provided number JSON Schema cannot have 'minimum' and 'exclusiveMinimum\"\nexport const writeJsonSchemaNumberMinimumAndExclusiveMinimumMessage =\n\t(): writeJsonSchemaNumberMinimumAndExclusiveMinimumMessage =>\n\t\t\"Provided number JSON Schema cannot have 'minimum' and 'exclusiveMinimum\"\n\n/* Object Schema Parsing Errors */\nexport type writeJsonSchemaObjectNonConformingKeyAndPropertyNamesMessage<\n\trequiredKey extends string,\n\tpropertyNamesExpression extends string\n> = `Required key ${requiredKey} doesn't conform to propertyNames schema of ${propertyNamesExpression}`\nexport const writeJsonSchemaObjectNonConformingKeyAndPropertyNamesMessage = <\n\trequiredKey extends string,\n\tpropertyNamesExpression extends string\n>(\n\trequiredKey: requiredKey,\n\tpropertyNamesExpression: propertyNamesExpression\n): writeJsonSchemaObjectNonConformingKeyAndPropertyNamesMessage<\n\trequiredKey,\n\tpropertyNamesExpression\n> =>\n\t`Required key ${requiredKey} doesn't conform to propertyNames schema of ${propertyNamesExpression}`\n\nexport type writeJsonSchemaObjectNonConformingPatternAndPropertyNamesMessage<\n\tpatternPropertySignatureExpression extends string,\n\tpropertyNamesExpression extends string\n> = `Pattern property ${patternPropertySignatureExpression} doesn't conform to propertyNames schema of ${propertyNamesExpression}`\nexport const writeJsonSchemaObjectNonConformingPatternAndPropertyNamesMessage =\n\t<\n\t\tpatternPropertySignatureExpression extends string,\n\t\tpropertyNamesExpression extends string\n\t>(\n\t\tpatternPropertySignatureExpression: patternPropertySignatureExpression,\n\t\tpropertyNamesExpression: propertyNamesExpression\n\t): writeJsonSchemaObjectNonConformingPatternAndPropertyNamesMessage<\n\t\tpatternPropertySignatureExpression,\n\t\tpropertyNamesExpression\n\t> =>\n\t\t`Pattern property ${patternPropertySignatureExpression} doesn't conform to propertyNames schema of ${propertyNamesExpression}`\n"
  },
  {
    "path": "ark/json-schema/index.ts",
    "content": "export * from \"./errors.ts\"\nexport { jsonSchemaToType } from \"./json.ts\"\nexport * from \"./scope.ts\"\n"
  },
  {
    "path": "ark/json-schema/json.ts",
    "content": "import { describeBranches, type JsonSchemaOrBoolean } from \"@ark/schema\"\nimport { printable, throwParseError } from \"@ark/util\"\nimport { type, type JsonSchema } from \"arktype\"\nimport { parseArrayJsonSchema } from \"./array.ts\"\nimport { parseCommonJsonSchema } from \"./common.ts\"\nimport {\n\tparseAnyOfJsonSchema,\n\tparseCompositionJsonSchema\n} from \"./composition.ts\"\nimport {\n\twriteJsonSchemaInsufficientKeysMessage,\n\twriteJsonSchemaUnsupportedTypeMessage\n} from \"./errors.ts\"\nimport { parseNumberJsonSchema } from \"./number.ts\"\nimport { parseObjectJsonSchema } from \"./object.ts\"\nimport { JsonSchemaScope } from \"./scope.ts\"\nimport { parseStringJsonSchema } from \"./string.ts\"\n\nconst jsonSchemaTypeMatcher = type.match\n\t.in<Extract<JsonSchema, { type?: unknown }>>()\n\t.at(\"type\")\n\t.match({\n\t\t\"unknown[]\": jsonSchema =>\n\t\t\tparseCompositionJsonSchema({\n\t\t\t\tanyOf: jsonSchema.type.map(t => ({ type: t as never }))\n\t\t\t}),\n\t\t\"'array'\": jsonSchema => parseArrayJsonSchema.assert(jsonSchema),\n\t\t\"'boolean'|'null'\": jsonSchema => type(jsonSchema.type),\n\t\t\"'integer'|'number'\": jsonSchema =>\n\t\t\tparseNumberJsonSchema.assert(jsonSchema),\n\t\t\"'object'\": jsonSchema => parseObjectJsonSchema.assert(jsonSchema),\n\t\t\"'string'\": jsonSchema => parseStringJsonSchema.assert(jsonSchema),\n\t\tdefault: () => undefined\n\t})\n\nexport const innerParseJsonSchema = JsonSchemaScope.Schema.pipe(\n\t(jsonSchema: JsonSchemaOrBoolean): type.Any => {\n\t\tif (typeof jsonSchema === \"boolean\")\n\t\t\t// no runtime value ever passes validation for JSON schema of 'false'\n\t\t\treturn jsonSchema ? JsonSchemaScope.Json : type.never\n\n\t\tif (Array.isArray(jsonSchema)) return parseAnyOfJsonSchema(jsonSchema)\n\n\t\tconst constAndOrEnumValidator = parseCommonJsonSchema(\n\t\t\tjsonSchema as JsonSchema\n\t\t)\n\t\tconst compositionValidator = parseCompositionJsonSchema(\n\t\t\tjsonSchema as JsonSchema\n\t\t)\n\n\t\tconst preTypeValidator =\n\t\t\tconstAndOrEnumValidator ?\n\t\t\t\tcompositionValidator ? compositionValidator.and(constAndOrEnumValidator)\n\t\t\t\t:\tconstAndOrEnumValidator\n\t\t\t:\tcompositionValidator\n\n\t\tif (\"type\" in jsonSchema) {\n\t\t\tconst typeValidator = jsonSchemaTypeMatcher(jsonSchema as never) as\n\t\t\t\t| type.Any\n\t\t\t\t| undefined\n\n\t\t\tif (typeValidator === undefined) {\n\t\t\t\tthrowParseError(\n\t\t\t\t\twriteJsonSchemaUnsupportedTypeMessage(printable(jsonSchema.type))\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tif (preTypeValidator === undefined) return typeValidator\n\t\t\treturn typeValidator.and(preTypeValidator)\n\t\t}\n\t\tif (preTypeValidator === undefined) {\n\t\t\tconst atLeastOneOf = [\n\t\t\t\t\"'type'\",\n\t\t\t\t\"'enum'\",\n\t\t\t\t\"'const'\",\n\t\t\t\t\"'allOf'\",\n\t\t\t\t\"'anyOf'\",\n\t\t\t\t\"'oneOf'\",\n\t\t\t\t\"'not'\"\n\t\t\t]\n\t\t\tthrowParseError(\n\t\t\t\twriteJsonSchemaInsufficientKeysMessage(\n\t\t\t\t\tdescribeBranches(atLeastOneOf, { finalDelimiter: \" and \" }),\n\t\t\t\t\tprintable(jsonSchema)\n\t\t\t\t)\n\t\t\t)\n\t\t}\n\t\treturn preTypeValidator\n\t}\n)\n\nexport const jsonSchemaToType = (\n\tjsonSchema: JsonSchemaOrBoolean\n): type<unknown> => innerParseJsonSchema.assert(jsonSchema) as never\n"
  },
  {
    "path": "ark/json-schema/number.ts",
    "content": "import { rootSchema, type Intersection } from \"@ark/schema\"\nimport { throwParseError } from \"@ark/util\"\nimport type { JsonSchema, Out, Type } from \"arktype\"\nimport {\n\twriteJsonSchemaNumberMaximumAndExclusiveMaximumMessage,\n\twriteJsonSchemaNumberMinimumAndExclusiveMinimumMessage\n} from \"./errors.ts\"\nimport { JsonSchemaScope } from \"./scope.ts\"\n\nexport const parseNumberJsonSchema: Type<\n\t(In: JsonSchema.Numeric) => Out<Type<number, any>>,\n\tany\n> = JsonSchemaScope.NumberSchema.pipe((jsonSchema): Type<number> => {\n\tconst arktypeNumberSchema: Intersection.Schema<number> = {\n\t\tdomain: \"number\"\n\t}\n\n\tif (\"maximum\" in jsonSchema) {\n\t\tif (\"exclusiveMaximum\" in jsonSchema)\n\t\t\tthrowParseError(writeJsonSchemaNumberMaximumAndExclusiveMaximumMessage())\n\n\t\tarktypeNumberSchema.max = jsonSchema.maximum\n\t} else if (\"exclusiveMaximum\" in jsonSchema) {\n\t\tarktypeNumberSchema.max = {\n\t\t\trule: jsonSchema.exclusiveMaximum,\n\t\t\texclusive: true\n\t\t}\n\t}\n\n\tif (\"minimum\" in jsonSchema) {\n\t\tif (\"exclusiveMinimum\" in jsonSchema)\n\t\t\tthrowParseError(writeJsonSchemaNumberMinimumAndExclusiveMinimumMessage())\n\n\t\tarktypeNumberSchema.min = jsonSchema.minimum\n\t} else if (\"exclusiveMinimum\" in jsonSchema) {\n\t\tarktypeNumberSchema.min = {\n\t\t\trule: jsonSchema.exclusiveMinimum,\n\t\t\texclusive: true\n\t\t}\n\t}\n\n\tif (\"multipleOf\" in jsonSchema)\n\t\tarktypeNumberSchema.divisor = jsonSchema.multipleOf\n\telse if (jsonSchema.type === \"integer\") arktypeNumberSchema.divisor = 1\n\n\treturn rootSchema(arktypeNumberSchema) as never\n})\n"
  },
  {
    "path": "ark/json-schema/object.ts",
    "content": "import {\n\tdescribeBranches,\n\tnode,\n\trootSchema,\n\ttype Index,\n\ttype Intersection,\n\ttype Predicate,\n\ttype Traversal\n} from \"@ark/schema\"\nimport { printable, throwParseError } from \"@ark/util\"\nimport { type, type JsonSchema, type Out, type Type } from \"arktype\"\n\nimport {\n\twriteJsonSchemaObjectNonConformingKeyAndPropertyNamesMessage,\n\twriteJsonSchemaObjectNonConformingPatternAndPropertyNamesMessage\n} from \"./errors.ts\"\nimport { jsonSchemaToType } from \"./json.ts\"\nimport { JsonSchemaScope } from \"./scope.ts\"\n\nconst parseMinMaxProperties = (\n\tjsonSchema: JsonSchema.Object,\n\tctx: Traversal\n) => {\n\tconst predicates: Predicate.Schema[] = []\n\tif (\"maxProperties\" in jsonSchema) {\n\t\tconst maxProperties = jsonSchema.maxProperties\n\n\t\tif ((jsonSchema.required?.length ?? 0) > maxProperties) {\n\t\t\tctx.reject({\n\t\t\t\texpected: `an object JSON Schema with at most ${jsonSchema.maxProperties} required properties`,\n\t\t\t\tactual: `an object JSON Schema with ${jsonSchema.required!.length} required properties`\n\t\t\t})\n\t\t}\n\n\t\tconst jsonSchemaObjectMaxPropertiesValidator = (\n\t\t\tdata: object,\n\t\t\tctx: Traversal\n\t\t) => {\n\t\t\tconst keys = Object.keys(data)\n\t\t\treturn keys.length <= maxProperties ?\n\t\t\t\t\ttrue\n\t\t\t\t:\tctx.reject({\n\t\t\t\t\t\texpected: `an object with at most ${maxProperties} propert${maxProperties === 1 ? \"y\" : \"ies\"}`,\n\t\t\t\t\t\tactual: `an object with ${keys.length.toString()} propert${maxProperties === 1 ? \"y\" : \"ies\"}`\n\t\t\t\t\t})\n\t\t}\n\t\tpredicates.push(jsonSchemaObjectMaxPropertiesValidator)\n\t}\n\tif (\"minProperties\" in jsonSchema) {\n\t\tconst minProperties = jsonSchema.minProperties\n\n\t\tconst jsonSchemaObjectMinPropertiesValidator = (\n\t\t\tdata: object,\n\t\t\tctx: Traversal\n\t\t) => {\n\t\t\tconst keys = Object.keys(data)\n\t\t\treturn keys.length >= minProperties ?\n\t\t\t\t\ttrue\n\t\t\t\t:\tctx.reject({\n\t\t\t\t\t\texpected: `an object with at least ${minProperties} propert${minProperties === 1 ? \"y\" : \"ies\"}`,\n\t\t\t\t\t\tactual: `an object with ${keys.length.toString()} propert${minProperties === 1 ? \"y\" : \"ies\"}`\n\t\t\t\t\t})\n\t\t}\n\t\tpredicates.push(jsonSchemaObjectMinPropertiesValidator)\n\t}\n\treturn predicates\n}\n\nconst parsePatternProperties = (jsonSchema: JsonSchema.Object) => {\n\tif (!(\"patternProperties\" in jsonSchema)) return\n\n\tconst patternProperties = Object.entries(jsonSchema.patternProperties).map(\n\t\t([key, value]) => [new RegExp(key), jsonSchemaToType(value)] as const\n\t)\n\n\t// NB: We don't validate compatibility of schemas for overlapping patternProperties\n\t// since getting the intersection of regexes is inherently non-trivial.\n\tconst indexSchemas = patternProperties.map(\n\t\t([pattern, parsedPatternPropertySchema]) => ({\n\t\t\tsignature: { domain: \"string\" as const, pattern: [pattern] },\n\t\t\tvalue: parsedPatternPropertySchema.internal\n\t\t})\n\t)\n\treturn indexSchemas\n}\n\nconst parsePropertyNames = (jsonSchema: JsonSchema.Object) => {\n\tif (!(\"propertyNames\" in jsonSchema)) return\n\tconst propertyNamesValidator = jsonSchemaToType(jsonSchema.propertyNames)\n\treturn propertyNamesValidator.internal\n}\n\nconst parseRequiredAndOptionalKeys = (\n\tjsonSchema: JsonSchema.Object,\n\tctx: Traversal\n) => {\n\tconst optionalKeys: string[] = []\n\tconst requiredKeys: string[] = []\n\tif (\"properties\" in jsonSchema) {\n\t\tif (\"required\" in jsonSchema) {\n\t\t\tfor (const key of jsonSchema.required) {\n\t\t\t\tif (key in jsonSchema.properties) requiredKeys.push(key)\n\t\t\t\telse {\n\t\t\t\t\tctx.reject({\n\t\t\t\t\t\tpath: [\"required\"],\n\t\t\t\t\t\texpected: `a key from the 'properties' object, i.e. ${describeBranches(Object.keys(jsonSchema.properties))}`,\n\t\t\t\t\t\tactual: key\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const key in jsonSchema.properties)\n\t\t\t\tif (!jsonSchema.required.includes(key)) optionalKeys.push(key)\n\t\t} else {\n\t\t\t// If 'required' is not present, all keys are optional\n\t\t\toptionalKeys.push(...Object.keys(jsonSchema.properties))\n\t\t}\n\t} else if (\"required\" in jsonSchema) {\n\t\tctx.reject({\n\t\t\texpected: \"a valid object JSON Schema\",\n\t\t\tactual:\n\t\t\t\t\"an object JSON Schema with 'required' array but no 'properties' object\"\n\t\t})\n\t}\n\n\treturn {\n\t\toptionalKeys: optionalKeys.map(key => ({\n\t\t\tkey,\n\t\t\tvalue: jsonSchemaToType(jsonSchema.properties![key]).internal\n\t\t})),\n\t\trequiredKeys: requiredKeys.map(key => ({\n\t\t\tkey,\n\t\t\tvalue: jsonSchemaToType(jsonSchema.properties![key]).internal\n\t\t}))\n\t}\n}\n\nconst parseAdditionalProperties = (jsonSchema: JsonSchema.Object) => {\n\tif (!(\"additionalProperties\" in jsonSchema)) return\n\n\tconst properties =\n\t\tjsonSchema.properties ? Object.keys(jsonSchema.properties) : []\n\tconst patternProperties = Object.keys(jsonSchema.patternProperties ?? {})\n\n\tconst additionalPropertiesSchema = jsonSchema.additionalProperties\n\tif (additionalPropertiesSchema === true) return true\n\tif (additionalPropertiesSchema === false) return false\n\n\tconst schemaDefinedKeys = rootSchema(\n\t\t[...properties]\n\t\t\t.map(key => ({ unit: key }))\n\t\t\t.concat(\n\t\t\t\t[...patternProperties].map(key => ({\n\t\t\t\t\tdomain: \"string\",\n\t\t\t\t\tpattern: key\n\t\t\t\t})) as never\n\t\t\t)\n\t)\n\n\tconst jsonSchemaObjectAdditionalPropertiesValidator = (\n\t\tdata: object,\n\t\tctx: Traversal\n\t) => {\n\t\tfor (const key of Object.keys(data)) {\n\t\t\tif (schemaDefinedKeys.allows(key))\n\t\t\t\t// not an additional property, so don't validate here\n\t\t\t\tcontinue\n\n\t\t\tconst additionalPropertyValidator = jsonSchemaToType(\n\t\t\t\tadditionalPropertiesSchema\n\t\t\t)\n\n\t\t\tconst value = data[key as keyof typeof data]\n\t\t\tif (!additionalPropertyValidator.allows(value)) {\n\t\t\t\tctx.reject({\n\t\t\t\t\tpath: [key],\n\t\t\t\t\texpected: `${additionalPropertyValidator.description}, since ${key} is an additional property.`,\n\t\t\t\t\tactual: printable(value)\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\treturn !ctx.hasError()\n\t}\n\treturn jsonSchemaObjectAdditionalPropertiesValidator\n}\n\nexport const parseObjectJsonSchema: Type<\n\t(In: JsonSchema.Object) => Out<Type<object, any>>,\n\tany\n> = JsonSchemaScope.ObjectSchema.pipe((jsonSchema, ctx): Type<object> => {\n\tconst arktypeObjectSchema: Intersection.Schema<object> = {\n\t\tdomain: \"object\"\n\t}\n\n\tconst { requiredKeys, optionalKeys } = parseRequiredAndOptionalKeys(\n\t\tjsonSchema,\n\t\tctx\n\t)\n\tconst patternPropertiesIndexes: Index.Schema[] =\n\t\tparsePatternProperties(jsonSchema) ?? []\n\n\tconst parsedPropertyNamesSchema = parsePropertyNames(jsonSchema)\n\tif (parsedPropertyNamesSchema === undefined) {\n\t\tarktypeObjectSchema.required = requiredKeys\n\t\tarktypeObjectSchema.optional = optionalKeys\n\t\tarktypeObjectSchema.index = patternPropertiesIndexes\n\t} else {\n\t\tconst propertyNamesIndex = {\n\t\t\tsignature: parsedPropertyNamesSchema,\n\t\t\tvalue: type.unknown.internal\n\t\t}\n\n\t\t// Ensure all 'patternProperties' adhere to the 'propertyNames' schema\n\t\tconst propertyNamesNode = node(\"index\", propertyNamesIndex)\n\t\tfor (const patternPropertyIndex of patternPropertiesIndexes) {\n\t\t\tconst patternPropertyNode = node(\"index\", patternPropertyIndex)\n\n\t\t\tif (!patternPropertyNode.signature.extends(propertyNamesNode.signature)) {\n\t\t\t\tthrowParseError(\n\t\t\t\t\twriteJsonSchemaObjectNonConformingPatternAndPropertyNamesMessage(\n\t\t\t\t\t\tpatternPropertyNode.signature.expression,\n\t\t\t\t\t\tparsedPropertyNamesSchema.expression\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\t// Ensure all required keys adhere to the 'propertyNames' schema\n\t\tfor (const requiredKey of requiredKeys) {\n\t\t\tif (!parsedPropertyNamesSchema.allows(requiredKey.key)) {\n\t\t\t\tthrowParseError(\n\t\t\t\t\twriteJsonSchemaObjectNonConformingKeyAndPropertyNamesMessage(\n\t\t\t\t\t\trequiredKey.key,\n\t\t\t\t\t\tparsedPropertyNamesSchema.expression\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t\tarktypeObjectSchema.required = requiredKeys\n\n\t\t// Update the value of optional keys that doen't adhere to the 'propertyNames' to be 'never'\n\t\tarktypeObjectSchema.optional = optionalKeys.map(optionalKey =>\n\t\t\tparsedPropertyNamesSchema.allows(optionalKey.key) ? optionalKey : (\n\t\t\t\t{ ...optionalKey, value: type.never.internal }\n\t\t\t)\n\t\t)\n\n\t\t// Set the 'propertyNames' constraints\n\t\tarktypeObjectSchema.index = [\n\t\t\t...patternPropertiesIndexes,\n\t\t\t{\n\t\t\t\tsignature: parsedPropertyNamesSchema,\n\t\t\t\tvalue: type.unknown.internal\n\t\t\t}\n\t\t]\n\t\tarktypeObjectSchema.undeclared = \"reject\"\n\t}\n\n\tconst potentialPredicates: (Predicate.Schema | undefined)[] =\n\t\tparseMinMaxProperties(jsonSchema, ctx)\n\n\tconst additionalProperties = parseAdditionalProperties(jsonSchema)\n\tif (typeof additionalProperties === \"boolean\") {\n\t\tarktypeObjectSchema.undeclared ??=\n\t\t\tadditionalProperties ? \"ignore\" : \"reject\"\n\t} else potentialPredicates.push(additionalProperties)\n\n\tconst predicates = potentialPredicates.filter(\n\t\tpotentialPredicate => potentialPredicate !== undefined\n\t)\n\n\tconst typeWithoutPredicates = rootSchema(arktypeObjectSchema)\n\tif (predicates.length === 0) return typeWithoutPredicates as never\n\treturn rootSchema({ ...arktypeObjectSchema, predicate: predicates }) as never\n})\n"
  },
  {
    "path": "ark/json-schema/package.json",
    "content": "{\n\t\"name\": \"@ark/json-schema\",\n\t\"version\": \"0.0.4\",\n\t\"license\": \"MIT\",\n\t\"authors\": [\n\t\t{\n\t\t\t\"name\": \"TizzySaurus\",\n\t\t\t\"email\": \"tizzysaurus@gmail.com\",\n\t\t\t\"url\": \"https://github.com/tizzysaurus\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"David Blass\",\n\t\t\t\"email\": \"david@arktype.io\",\n\t\t\t\"url\": \"https://arktype.io\"\n\t\t}\n\t],\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"https://github.com/arktypeio/arktype.git\",\n\t\t\"directory\": \"ark/json-schema\"\n\t},\n\t\"type\": \"module\",\n\t\"main\": \"./out/index.js\",\n\t\"types\": \"./out/index.d.ts\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"ark-ts\": \"./index.ts\",\n\t\t\t\"default\": \"./out/index.js\"\n\t\t},\n\t\t\"./internal/*.ts\": {\n\t\t\t\"ark-ts\": \"./*.ts\",\n\t\t\t\"default\": \"./out/*.js\"\n\t\t},\n\t\t\"./internal/*.js\": {\n\t\t\t\"ark-ts\": \"./*.ts\",\n\t\t\t\"default\": \"./out/*.js\"\n\t\t}\n\t},\n\t\"files\": [\n\t\t\"out\"\n\t],\n\t\"scripts\": {\n\t\t\"build\": \"ts ../repo/build.ts\",\n\t\t\"test\": \"ts ../repo/testPackage.ts\",\n\t\t\"tnt\": \"ts ../repo/testPackage.ts --skipTypes\"\n\t},\n\t\"dependencies\": {\n\t\t\"arktype\": \"workspace:*\",\n\t\t\"@ark/schema\": \"workspace:*\",\n\t\t\"@ark/util\": \"workspace:*\"\n\t},\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t}\n}\n"
  },
  {
    "path": "ark/json-schema/scope.ts",
    "content": "import type { JsonSchemaOrBoolean } from \"@ark/schema\"\nimport { type JsonSchema, scope, type Scope } from \"arktype\"\n\ntype AnyKeywords = Partial<JsonSchema.Const & JsonSchema.Enum>\n\ntype TypeWithNoKeywords = { type: \"boolean\" | \"null\" }\n\ntype TypeWithKeywords =\n\t| JsonSchema.Array\n\t| JsonSchema.Numeric\n\t| JsonSchema.Object\n\t| StringSchema\n\n// NB: For sake of simplicitly, at runtime it's assumed that\n// whatever we're parsing is valid JSON since it will be 99% of the time.\n// This decision may be changed later, e.g. when a built-in JSON type exists in AT.\ntype Json = unknown\n\ntype ArraySchema = JsonSchema.Array\n\ntype NumberSchema = JsonSchema.Numeric\n\ntype ObjectSchema = JsonSchema.Object\n\n// NB: @ark/json-schema doesn't support the \"format\" keyword, and the \"pattern\"\n// could be string|RegExp rather than only string, so we need a separate type\nexport type StringSchema = Omit<JsonSchema.String, \"format\" | \"pattern\"> & {\n\tpattern?: string | RegExp\n}\n\ntype JsonSchemaScope = Scope<{\n\tAnyKeywords: AnyKeywords\n\tCompositionKeywords: JsonSchema.Composition\n\tTypeWithNoKeywords: TypeWithNoKeywords\n\tTypeWithKeywords: TypeWithKeywords\n\tJson: Json\n\tSchema: JsonSchemaOrBoolean\n\tArraySchema: ArraySchema\n\tNumberSchema: NumberSchema\n\tObjectSchema: ObjectSchema\n\tStringSchema: StringSchema\n}>\n\nconst $: JsonSchemaScope = scope({\n\tAnyKeywords: {\n\t\t\"const?\": \"unknown\",\n\t\t\"enum?\": \"unknown[]\"\n\t},\n\tCompositionKeywords: {\n\t\t\"allOf?\": \"Schema[]\",\n\t\t\"anyOf?\": \"Schema[]\",\n\t\t\"oneOf?\": \"Schema[]\",\n\t\t\"not?\": \"Schema\"\n\t},\n\tTypeWithNoKeywords: { type: \"'boolean'|'null'\" },\n\tTypeWithKeywords: \"ArraySchema|NumberSchema|ObjectSchema|StringSchema\",\n\t// NB: For sake of simplicitly, at runtime it's assumed that\n\t// whatever we're parsing is valid JSON since it will be 99% of the time.\n\t// This decision may be changed later, e.g. when a built-in JSON type exists in AT.\n\tJson: \"unknown\",\n\t\"#BaseSchema\":\n\t\t// NB: `true` means \"accept an valid JSON\"; `false` means \"reject everything\".\n\t\t\"boolean|TypeWithNoKeywords|TypeWithKeywords|AnyKeywords|CompositionKeywords\",\n\tSchema: \"BaseSchema|BaseSchema[]\",\n\tArraySchema: {\n\t\t\"additionalItems?\": \"Schema\",\n\t\t\"contains?\": \"Schema\",\n\t\t// JSON Schema states that if 'items' is not present, then treat as an empty schema (i.e. accept any valid JSON)\n\t\t\"items?\": \"Schema|Schema[]\",\n\t\t\"maxItems?\": \"number.integer>=0\",\n\t\t\"minItems?\": \"number.integer>=0\",\n\t\t// NB: Technically `prefixItems` and `items` are mutually exclusive,\n\t\t// which is reflected at runtime but it's not worth the performance cost to validate this statically.\n\t\t\"prefixItems?\": \"Schema[]\",\n\t\ttype: \"'array'\",\n\t\t\"uniqueItems?\": \"boolean\"\n\t},\n\tNumberSchema: {\n\t\t// NB: Technically 'exclusiveMaximum' and 'exclusiveMinimum' are mutually exclusive with 'maximum' and 'minimum', respectively,\n\t\t// which is reflected at runtime but it's not worth the performance cost to validate this statically.\n\t\t\"exclusiveMaximum?\": \"number\",\n\t\t\"exclusiveMinimum?\": \"number\",\n\t\t\"maximum?\": \"number\",\n\t\t\"minimum?\": \"number\",\n\t\t\"multipleOf?\": \"number\",\n\t\ttype: \"'number'|'integer'\"\n\t},\n\tObjectSchema: {\n\t\t\"additionalProperties?\": \"Schema\",\n\t\t\"maxProperties?\": \"number.integer>=0\",\n\t\t\"minProperties?\": \"number.integer>=0\",\n\t\t\"patternProperties?\": { \"[string]\": \"Schema\" },\n\t\t// NB: Technically 'properties' is required when 'required' is present,\n\t\t// which is reflected at runtime but it's not worth the performance cost to validate this statically.\n\t\t\"properties?\": { \"[string]\": \"Schema\" },\n\t\t\"propertyNames?\": \"Schema\",\n\t\t\"required?\": \"string[]\",\n\t\ttype: \"'object'\"\n\t},\n\tStringSchema: {\n\t\t\"maxLength?\": \"number.integer>=0\",\n\t\t\"minLength?\": \"number.integer>=0\",\n\t\t\"pattern?\": \"RegExp | string\",\n\t\ttype: \"'string'\"\n\t}\n}) as never\n\nexport const JsonSchemaScope = $.export()\n"
  },
  {
    "path": "ark/json-schema/string.ts",
    "content": "import { rootSchema, type Intersection } from \"@ark/schema\"\nimport type { Out, Type } from \"arktype\"\nimport { JsonSchemaScope, type StringSchema } from \"./scope.ts\"\n\nexport const parseStringJsonSchema: Type<\n\t(In: StringSchema) => Out<Type<string, any>>,\n\tany\n> = JsonSchemaScope.StringSchema.pipe((jsonSchema): Type<string> => {\n\tconst arktypeStringSchema: Intersection.Schema<string> = {\n\t\tdomain: \"string\"\n\t}\n\n\tif (\"maxLength\" in jsonSchema)\n\t\tarktypeStringSchema.maxLength = jsonSchema.maxLength\n\tif (\"minLength\" in jsonSchema)\n\t\tarktypeStringSchema.minLength = jsonSchema.minLength\n\tif (\"pattern\" in jsonSchema)\n\t\tarktypeStringSchema.pattern = [jsonSchema.pattern]\n\n\treturn rootSchema(arktypeStringSchema) as never\n})\n"
  },
  {
    "path": "ark/regex/CHANGELOG.md",
    "content": "# arkregex\n\n## 0.0.5\n\n### represent \\d as `${number}` instead of `${bigint}`\n\nThough this slightly widens the scope of literal strings allowed by \\d, it will now behave consistently and can collapse when multiple `${number}`s appear in sequence, since `${number}` allows 0-prefixed strings like `\"00\"` that are rejected by `${bigint}`.\n\n```ts\n// was: Regex<`${bigint}${bigint}`>\n// now: Regex<`${number}`>\nregex(\"^\\\\d{2}$\")\n```\n\n## 0.0.4\n\n### consecutive `${bigint}`s are no longer collapsed\n\n```ts\n// was: Regex<`${bigint}`>\n// now: Regex<`${bigint}${bigint}`>\nregex(\"^\\\\d{2}$\")\n```\n\nThough the new representation will be longer for some expressions, it is required to correctly allow a zero-prefix like `\"01\"` in this case.\n\n## 0.0.3\n\n### fix quantifier behavior for non-natural numbers\n\n```ts\n// the following expressions now result in:\n// TypeScript: Quantifier {bad-quantifier} must use natural numbers\n\n// leading zeroes\nregex(\"^a{002}$\")\n// negative quantifier\nregex(\"^a{-1}$\")\n// non-integer quantifier\nregex(\"^a{1.5}$\")\n// with whitespace\nregex(\"^a{ 1}$\"))\n```\n\n🙌(thanks @codpro2005)\n\n## 0.0.1\n\ninitial release 🎉\n"
  },
  {
    "path": "ark/regex/README.md",
    "content": "# arkregex\n\nA drop-in replacement for `new RegExp()` with types\n\n## Usage\n\nThe `regex` function creates a `Regex` instance with types for `.test()`, `.exec()` and more, statically parsed from native JS syntax:\n\n```ts\nimport { regex } from \"arkregex\"\n\nconst ok = regex(\"^ok$\", \"i\")\n// Regex<\"ok\" | \"oK\" | \"Ok\" | \"OK\", { flags: \"i\" }>\n\nconst semver = regex(\"^(\\\\d*)\\\\.(\\\\d*)\\\\.(\\\\d*)$\")\n// Regex<`${number}.${number}.${number}`, { captures: [`${number}`, `${number}`, `${number}`] }>\n\nconst email = regex(\"^(?<name>\\\\w+)@(?<domain>\\\\w+\\\\.\\\\w+)$\")\n// Regex<`${string}@${string}.${string}`, { names: { name: string; domain: `${string}.${string}`; }; ...>\n```\n\nAll you need to get started is `pnpm install arkregex` (or the equivalent for your package manager of choice) 🎉\n\nPerforms best with TS 5.9+\n\n### Features\n\n- **Types**: Infers string types for your existing regular expressions, including positional and named captures\n- **Parity**: Supports 100% of [features](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions) allowed by `new RegExp()`\n- **Safety**: Syntax errors like referencing a group that doesn't exist are now type errors\n- **Zero Runtime**: Improves your type safety without impacting your bundle size\n\n### FAQ\n\n#### Why aren't some patterns like `[a-Z]` inferred more precisely?\n\nConstructing string literal types for these sorts of expressions is combinatorial and will explode very quickly if we infer character ranges like this as literal characters.\n\nWe've tried to strike a balance between performance and precision while guaranteeing that the inferred types are at worst imprecise and never incorrect.\n\n#### Why doesn't it work with my massive RegExp?\n\nIf your expression is especially long or complex, TypeScript won't be able to infer it.\n\nIf your types start to slow down or you see the dreaded `Type is excessively deep...`, you can manually type your expression using `regex.as`:\n\n```ts\nconst complexPattern = regex.as<`pattern-${string}`, { captures: [string] }>(\n\t\"very-long-complex-expression-here\"\n)\n```\n\n#### Is it robust?\n\n`arkregex` types are [extensively tested](https://github.com/arktypeio/arktype/tree/main/ark/regex/__tests__/regex.test.ts) and [benchmarked](https://github.com/arktypeio/arktype/tree/main/ark/regex/__tests__/regex.bench.ts) using [attest](https://github.com/arktypeio/arktype/tree/main/ark/attest#readme).\n\nIf anything not covered by the other FAQs is not behaving how you'd expect, please don't hesitate to [create an issue](https://github.com/arktypeio/arktype/issues/new).\n\n#### How can I get syntax highlighting for `regex`?\n\nThe [ArkType extension](https://marketplace.visualstudio.com/items?itemName=arktypeio.arkdark) can be installed to add syntax highlighting to `regex` calls.\n"
  },
  {
    "path": "ark/regex/__tests__/regex.bench.ts",
    "content": "import { bench } from \"@ark/attest\"\nimport type { array } from \"@ark/util\"\nimport { regex } from \"arkregex\"\n\nbench.baseline(() => {\n\tregex(\"foo|^bar$|baz{9,10}?\")\n})\n\nconst r = regex(\"a?(b|cd)\")\n\ntype Result = array.repeat<3, 50>\n\nbench(\"repeat(100)\", () => {\n\ttype Result = array.repeat<2, 100>\n}).types([666, \"instantiations\"])\n\nbench(\"repeat(500)\", () => {\n\ttype Result = array.repeat<2, 500>\n}).types([3528, \"instantiations\"])\n\nbench(\"repeat(512)\", () => {\n\ttype Result = array.repeat<2, 512>\n}).types([557, \"instantiations\"])\n\nbench(\"repeat(513)\", () => {\n\ttype Result = array.repeat<2, 513>\n}).types([5928, \"instantiations\"])\n\nbench(\"anchored union\", () => {\n\tconst r = regex(\"typescript|^go$|brrr$\")\n}).types([1702, \"instantiations\"])\n\nbench(\"?(1)\", () => {\n\tconst r = regex(\"^a?$\")\n}).types([480, \"instantiations\"])\n\nbench(\"?(4)\", () => {\n\tconst r = regex(\"^a?b?c?d?$\")\n}).types([1378, \"instantiations\"])\n\nbench(\"?(7)\", () => {\n\tconst r = regex(\"^a?b?c?d?e?f?g?$\")\n}).types([3964, \"instantiations\"])\n\nbench(\"?(15)\", () => {\n\tconst r = regex(\"^ab?c?d?e?f?g?h?i?j?k?l?m?n?o?$\")\n}).types([282048, \"instantiations\"])\n\nbench(\"escape(6)\", () => {\n\tconst r = regex(\"^\\t\\n\\r\\v\\f\\0$\")\n}).types([509, \"instantiations\"])\n\nbench(\"quantified char\", () => {\n\tconst r = regex(\"^a{5}$\")\n}).types([631, \"instantiations\"])\n\nbench(\"quantified char min max\", () => {\n\tconst r = regex(\"^a{5,10}$\")\n}).types([704, \"instantiations\"])\n\nbench(\"quantified string\", () => {\n\tconst r = regex(\"^.{5,10}$\")\n}).types([506, \"instantiations\"])\n\nbench(\"semver\", () => {\n\tconst r = regex(\"^(0|[1-9]\\\\d*)\\\\.(0|[1-9]\\\\d*)\\\\.(0|[1-9]\\\\d*)$\")\n}).types([35386, \"instantiations\"])\n\n// Literals\nbench(\"literal basic\", () => {\n\tconst r = regex(\"abcdef\")\n}).types([426, \"instantiations\"])\n\nbench(\"literal long\", () => {\n\tconst r = regex(\"abcdefghijklmnopqrstuvwxyz\")\n}).types([1580, \"instantiations\"])\n\n// Anchors\nbench(\"anchor start\", () => {\n\tconst r = regex(\"^abc\")\n}).types([294, \"instantiations\"])\n\nbench(\"anchor end\", () => {\n\tconst r = regex(\"abc$\")\n}).types([305, \"instantiations\"])\nbench(\"anchor both\", () => {\n\tconst r = regex(\"^abc$\")\n}).types([329, \"instantiations\"])\n\nbench(\"anchor union(2)\", () => {\n\tconst r = regex(\"^foo|bar$\")\n}).types([916, \"instantiations\"])\n\nbench(\"anchor union(5)\", () => {\n\tconst r = regex(\"^foo|^bar|baz$|qux|^end\")\n}).types([1929, \"instantiations\"])\n\n// Unions\nbench(\"union(2)\", () => {\n\tconst r = regex(\"a|b\")\n}).types([612, \"instantiations\"])\n\nbench(\"union(5)\", () => {\n\tconst r = regex(\"a|b|c|d|e\")\n}).types([1200, \"instantiations\"])\n\nbench(\"union(10)\", () => {\n\tconst r = regex(\"a|b|c|d|e|f|g|h|i|j\")\n}).types([2212, \"instantiations\"])\n\nbench(\"union nested\", () => {\n\tconst r = regex(\"(a|b)(c|d)(e|f)\")\n}).types([6384, \"instantiations\"])\n\n// Quantifiers - ranges\nbench(\"range {1,3}\", () => {\n\tconst r = regex(\"^a{1,3}$\")\n}).types([605, \"instantiations\"])\n\nbench(\"range {2,8}\", () => {\n\tconst r = regex(\"^a{2,8}$\")\n}).types([717, \"instantiations\"])\n\nbench(\"range {0,5}\", () => {\n\tconst r = regex(\"^a{0,5}$\")\n}).types([696, \"instantiations\"])\n\nbench(\"range complex\", () => {\n\tconst r = regex(\"^a{1,2}b{2,3}c{0,2}$\")\n}).types([1377, \"instantiations\"])\n\n// Character sets\nbench(\"charset simple\", () => {\n\tconst r = regex(\"[abc]\")\n}).types([674, \"instantiations\"])\n\nbench(\"charset range\", () => {\n\tconst r = regex(\"[a-z]\")\n}).types([620, \"instantiations\"])\n\nbench(\"charset mixed\", () => {\n\tconst r = regex(\"[a-zA-Z0-9]\")\n}).types([881, \"instantiations\"])\n\nbench(\"charset negated\", () => {\n\tconst r = regex(\"[^abc]\")\n}).types([307, \"instantiations\"])\n\n// Escapes\nbench(\"escape shorthand\", () => {\n\tconst r = regex(\"\\\\d\\\\w\\\\s\")\n}).types([529, \"instantiations\"])\n\nbench(\"escape builtin\", () => {\n\tconst r = regex(\"\\t\\n\\r\\v\\f\\0\")\n}).types([436, \"instantiations\"])\n\n// Groups - Captures\nbench(\"group single\", () => {\n\tconst r = regex(\"(abc)\")\n}).types([447, \"instantiations\"])\n\nbench(\"group nested(2)\", () => {\n\tconst r = regex(\"(a(b)c)\")\n}).types([874, \"instantiations\"])\n\nbench(\"group nested(3)\", () => {\n\tconst r = regex(\"(a(b(c)d)e)\")\n}).types([1544, \"instantiations\"])\n\nbench(\"group union\", () => {\n\tconst r = regex(\"(a|b|c)\")\n}).types([1158, \"instantiations\"])\n\nbench(\"group quantified\", () => {\n\tconst r = regex(\"(ab){1,3}\")\n}).types([759, \"instantiations\"])\n\n// Non-capturing groups\nbench(\"group non-capturing\", () => {\n\tconst r = regex(\"(?:abc)\")\n}).types([403, \"instantiations\"])\n\nbench(\"group mixed capturing\", () => {\n\tconst r = regex(\"(a)(?:b)(c)\")\n}).types([1092, \"instantiations\"])\n\n// Backreferences\nbench(\"backref simple\", () => {\n\tconst r = regex(\"(a)\\\\1\")\n}).types([749, \"instantiations\"])\n\nbench(\"backref union\", () => {\n\tconst r = regex(\"(a|b)\\\\1\")\n}).types([1440, \"instantiations\"])\n\nbench(\"backref multiple\", () => {\n\tconst r = regex(\"(a)(b)\\\\1\\\\2\")\n}).types([1336, \"instantiations\"])\n\n// Named captures\nbench(\"named capture\", () => {\n\tconst r = regex(\"(?<name>abc)\")\n}).types([619, \"instantiations\"])\n\nbench(\"named backref\", () => {\n\tconst r = regex(\"(?<name>a|b)\\\\k<name>\")\n}).types([1641, \"instantiations\"])\n\n// Complex patterns\nbench(\"email pattern\", () => {\n\tconst r = regex(\"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\\\.[a-zA-Z]{2,}$\")\n}).types([3035, \"instantiations\"])\n\nbench(\"phone pattern\", () => {\n\tconst r = regex(\"^\\\\(?([0-9]{3})\\\\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$\")\n}).types([9650, \"instantiations\"])\n\n// Scaling tests\nbench(\"wildcard sequence(5)\", () => {\n\tconst r = regex(\".....$\")\n}).types([322, \"instantiations\"])\n\nbench(\"wildcard sequence(10)\", () => {\n\tconst r = regex(\"..........$\")\n}).types([467, \"instantiations\"])\n\nbench(\"nested groups(4)\", () => {\n\tconst r = regex(\"((((a))))\")\n}).types([1409, \"instantiations\"])\n\nbench(\"mixed complexity\", () => {\n\tconst r = regex(\n\t\t\"^((?:https?://)?(?:www\\\\.)?([a-zA-Z0-9-]+)\\\\.(com|org|net))(/.*)?$\"\n\t)\n}).types([9686, \"instantiations\"])\n"
  },
  {
    "path": "ark/regex/__tests__/regex.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport {\n\twriteUnclosedGroupMessage,\n\twriteUnmatchedGroupCloseMessage,\n\ttype WhitespaceChar\n} from \"@ark/util\"\nimport { regex, type Regex } from \"arkregex\"\nimport { emptyCharacterSetMessage } from \"arkregex/internal/charset.ts\"\nimport {\n\tcaretNotationMessage,\n\tmissingBackreferenceNameMessage,\n\ttrailingBackslashMessage,\n\twriteStringEscapableMessage,\n\twriteUnnecessaryEscapeMessage,\n\twriteUnresolvableBackreferenceMessage\n} from \"arkregex/internal/escape.ts\"\nimport {\n\tmissingNegatedModifierMessage,\n\tmultipleModifierDashesMessage,\n\tunescapedLiteralQuestionMarkMessage,\n\tunnamedCaptureGroupMessage,\n\twriteDuplicateModifierMessage,\n\twriteInvalidModifierMessage\n} from \"arkregex/internal/group.ts\"\nimport type { next } from \"arkregex/internal/parse.ts\"\nimport {\n\twriteUnmatchedQuantifierError,\n\twriteUnnaturalNumberQuantifierError\n} from \"arkregex/internal/quantify.ts\"\nimport {\n\twriteIncompleteReferenceError,\n\twriteMidAnchorError,\n\ttype finalizeTree,\n\ttype GroupTree,\n\ttype IndexedCaptureOffset,\n\ttype s,\n\ttype SequenceTree,\n\ttype State,\n\ttype UnionTree\n} from \"arkregex/internal/state.ts\"\n\ntype iterate<s extends State, until extends number, counter extends 1[] = []> =\n\tcounter[\"length\"] extends until ? s : iterate<next<s>, until, [...counter, 1]>\n\ntype _ParseResult = iterate<State.initialize<\"^\\\\d\\\\d$\", \"\">, 4>\ntype _AstResult = State.Group.finalize<_ParseResult>\ntype _FinalizedResult = s.finalize<_ParseResult>\n\ntype _Tree = SequenceTree<\n\t[\n\t\t\"<​^​>\",\n\t\tGroupTree<\n\t\t\tUnionTree<\n\t\t\t\t[\n\t\t\t\t\t\"0\",\n\t\t\t\t\tSequenceTree<\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\tUnionTree<[\"1\", string]>,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkind: \"quantifier\"\n\t\t\t\t\t\t\t\tast: `${number}`\n\t\t\t\t\t\t\t\tmin: 0\n\t\t\t\t\t\t\t\tmax: null\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t]\n\t\t\t\t\t>\n\t\t\t\t]\n\t\t\t>,\n\t\t\tState.UnnamedCaptureKind.indexed\n\t\t>,\n\t\t\".\",\n\t\t\"<​$​>\"\n\t]\n>\n\ntype _Result = finalizeTree<\n\t_Tree,\n\t{ errors: []; flags: \"\"; captures: [IndexedCaptureOffset]; names: {} }\n>\n\ncontextualize(() => {\n\tdescribe(\"literals\", () => {\n\t\tit(\"base\", () => {\n\t\t\tconst S = regex(\"abc\")\n\t\t\tattest<Regex<`${string}abc${string}`, {}>>(S).type.toString.snap(\n\t\t\t\t\"Regex<`${string}abc${string}`, {}>\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"empty\", () => {\n\t\t\tconst S = regex(\"\")\n\t\t\tattest<Regex<string, {}>>(S).type.toString.snap(\"Regex<string, {}>\")\n\t\t})\n\t})\n\n\tdescribe(\"anchors\", () => {\n\t\tit(\"start\", () => {\n\t\t\tconst S = regex(\"^a\")\n\t\t\tattest<Regex<`a${string}`, {}>>(S).type.toString.snap(\n\t\t\t\t\"Regex<`a${string}`, {}>\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"end\", () => {\n\t\t\tconst S = regex(\"a$\")\n\t\t\tattest<Regex<`${string}a`, {}>>(S).type.toString.snap(\n\t\t\t\t\"Regex<`${string}a`, {}>\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"start and end\", () => {\n\t\t\tconst S = regex(\"^a$\")\n\t\t\tattest<Regex<`a`, {}>>(S).type.toString.snap('Regex<\"a\", {}>')\n\t\t})\n\n\t\tit(\"multiple start branches\", () => {\n\t\t\tconst S = regex(\"^foo|^bar\")\n\t\t\tattest<Regex<`foo${string}` | `bar${string}`, {}>>(S)\n\t\t})\n\n\t\tit(\"multiple end branches\", () => {\n\t\t\tconst S = regex(\"foo$|bar$\")\n\t\t\tattest<Regex<`${string}foo` | `${string}bar`, {}>>(S)\n\t\t})\n\n\t\tit(\"mixed anchor branches\", () => {\n\t\t\tconst S = regex(\"^foo|bar$\")\n\t\t\tattest<Regex<`foo${string}` | `${string}bar`, {}>>(S)\n\t\t})\n\n\t\tit(\"inner outer anchors\", () => {\n\t\t\tconst S = regex(\"(^bo(innerAnchored$|innerUnanchored))\")\n\t\t\tattest<\n\t\t\t\tRegex<\n\t\t\t\t\t\"boinnerAnchored\" | `boinnerUnanchored${string}`,\n\t\t\t\t\t{\n\t\t\t\t\t\tcaptures:\n\t\t\t\t\t\t\t| [\"boinnerAnchored\", \"innerAnchored\"]\n\t\t\t\t\t\t\t| [\"boinnerUnanchored\", \"innerUnanchored\"]\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>(S)\n\t\t})\n\n\t\tit(\"consecutive start\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"^^\")).type.errors(writeMidAnchorError(\"^\"))\n\t\t})\n\n\t\tit(\"consecutive end\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"$$\")).type.errors(writeMidAnchorError(\"$\"))\n\t\t})\n\n\t\tit(\"start after first char\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"a^\")).type.errors(writeMidAnchorError(\"^\"))\n\t\t})\n\n\t\tit(\"end before last char\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"$a\")).type.errors(writeMidAnchorError(\"$\"))\n\t\t})\n\n\t\tit(\"invalid start anchor union\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"^f^oo|^bar\")).type.errors(writeMidAnchorError(\"^\"))\n\t\t})\n\n\t\tit(\"invalid end anchor union\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"^foo|^b$ar\")).type.errors(writeMidAnchorError(\"$\"))\n\t\t})\n\n\t\tit(\"start after first char in group\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"f(^)\")).type.errors(writeMidAnchorError(\"^\"))\n\t\t})\n\n\t\tit(\"end before last char in group\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"($a)\")).type.errors(writeMidAnchorError(\"$\"))\n\t\t})\n\t})\n\n\tdescribe(\"simple quantifiers\", () => {\n\t\tit(\"?\", () => {\n\t\t\tconst S = regex(\"^ab?c$\")\n\t\t\tattest<Regex<`a${\"b\" | \"\"}c`, {}>>(S)\n\t\t})\n\n\t\tit(\"? sequence\", () => {\n\t\t\tconst S = regex(\"^a?b?$\")\n\t\t\tattest<Regex<\"\" | \"a\" | \"b\" | \"ab\", {}>>(S)\n\t\t})\n\n\t\tit(\"??\", () => {\n\t\t\tconst S = regex(\"^ab??c$\")\n\t\t\tattest<Regex<`a${\"b\" | \"\"}c`, {}>>(S)\n\t\t})\n\n\t\tit(\"+\", () => {\n\t\t\tconst S = regex(\"^ab+c$\")\n\t\t\tattest<Regex<`ab${string}c`, {}>>(S).type.toString.snap(\n\t\t\t\t\"Regex<`ab${string}c`, {}>\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"+?\", () => {\n\t\t\tconst S = regex(\"^ab+?c$\")\n\t\t\tattest<Regex<`ab${string}c`, {}>>(S).type.toString.snap(\n\t\t\t\t\"Regex<`ab${string}c`, {}>\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"*\", () => {\n\t\t\tconst S = regex(\"^ab*c$\")\n\t\t\tattest<Regex<\"ac\" | `ab${string}c`, {}>>(S)\n\t\t})\n\n\t\tit(\"*?\", () => {\n\t\t\tconst S = regex(\"^ab*?c$\")\n\t\t\tattest<Regex<\"ac\" | `ab${string}c`, {}>>(S)\n\t\t})\n\n\t\tit(\"unmatched ?\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"?\")).type.errors(writeUnmatchedQuantifierError(\"?\"))\n\t\t})\n\n\t\tit(\"unmatched +\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"+\")).type.errors(writeUnmatchedQuantifierError(\"+\"))\n\t\t})\n\n\t\tit(\"unmatched *\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"*\")).type.errors(writeUnmatchedQuantifierError(\"*\"))\n\t\t})\n\n\t\tit(\"unmatched ??\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"??\")).type.errors(writeUnmatchedQuantifierError(\"?\"))\n\t\t})\n\t})\n\n\tdescribe(\"ranges\", () => {\n\t\tit(\"exact\", () => {\n\t\t\tconst S = regex(\"^a{2}$\")\n\t\t\tattest<Regex<\"aa\", {}>>(S).type.toString.snap('Regex<\"aa\", {}>')\n\t\t})\n\n\t\tit(\"min\", () => {\n\t\t\tconst S = regex(\"^a{2,}$\")\n\t\t\tattest<Regex<`aa${string}`, {}>>(S).type.toString.snap(\n\t\t\t\t\"Regex<`aa${string}`, {}>\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"min max\", () => {\n\t\t\tconst S = regex(\"^a{2,4}$\")\n\t\t\tattest<Regex<\"aa\" | \"aaa\" | \"aaaa\", {}>>(S)\n\t\t})\n\n\t\tit(\"min max lazy\", () => {\n\t\t\tconst S = regex(\"^a{2,4}?$\")\n\t\t\tattest<Regex<\"aa\" | \"aaa\" | \"aaaa\", {}>>(S)\n\t\t})\n\n\t\tit(\"min max group\", () => {\n\t\t\tconst S = regex(\"^(ab){1,2}$\")\n\t\t\tattest<\n\t\t\t\tRegex<\n\t\t\t\t\t\"ab\" | \"abab\",\n\t\t\t\t\t{\n\t\t\t\t\t\tcaptures: [\"ab\"]\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>(S)\n\t\t})\n\n\t\tit(\"zero or more greedy\", () => {\n\t\t\tconst S = regex(\"^a{0,}$\")\n\t\t\tattest<Regex<\"\" | `a${string}`, {}>>(S)\n\t\t})\n\n\t\tit(\"zero or more lazy\", () => {\n\t\t\tconst S = regex(\"^a{0,}?$\")\n\t\t\tattest<Regex<\"\" | `a${string}`, {}>>(S)\n\t\t})\n\n\t\tit(\"zero or one\", () => {\n\t\t\tconst S = regex(\"^a{0,1}$\")\n\t\t\tattest<Regex<\"\" | \"a\", {}>>(S)\n\t\t})\n\n\t\tit(\"zero or one lazy\", () => {\n\t\t\tconst S = regex(\"^a{0,1}?$\")\n\t\t\tattest<Regex<\"\" | \"a\", {}>>(S)\n\t\t})\n\n\t\tit(\"falls back to literal for missing min\", () => {\n\t\t\tconst r = regex(\"^a{,2}$\")\n\t\t\tattest<Regex<\"a{,2}\", {}>>(r).type.toString.snap('Regex<\"a{,2}\", {}>')\n\t\t})\n\n\t\tit(\"fallsback to literal on empty\", () => {\n\t\t\tconst r = regex(\"^a{}$\")\n\t\t\tattest<Regex<\"a{}\", {}>>(r).type.toString.snap('Regex<\"a{}\", {}>')\n\t\t})\n\n\t\tit(\"falls back to literal for non-numeric\", () => {\n\t\t\tconst r = regex(\"^a{1,foo}$\")\n\t\t\tattest<Regex<\"a{1,foo}\", {}>>(r).type.toString.snap(\n\t\t\t\t'Regex<\"a{1,foo}\", {}>'\n\t\t\t)\n\t\t})\n\n\t\tit(\"${string} does not duplicate when quantified\", () => {\n\t\t\tconst r = regex(\"^.{5,10}$\")\n\t\t\tattest<Regex<string, {}>>(r).type.toString.snap(\"Regex<string, {}>\")\n\t\t})\n\n\t\tit(\"many ranges\", () => {\n\t\t\tconst S = regex(\"^x{0}a{1}b{2}c{3}d{3,}e{1,2}f{4}$\")\n\t\t\tattest<Regex<`abbcccddd${string}effff` | `abbcccddd${string}eeffff`, {}>>(\n\t\t\t\tS\n\t\t\t)\n\t\t})\n\n\t\tit(\"quantified charset\", () => {\n\t\t\tconst S = regex(\"^[ab]{2}$\")\n\t\t\tattest<Regex<\"aa\" | \"ab\" | \"ba\" | \"bb\">>(S)\n\t\t})\n\n\t\tit(\"quantified union group\", () => {\n\t\t\tconst S = regex(\"^(a|b){2}$\")\n\t\t\tattest<Regex<\"aa\" | \"ab\" | \"ba\" | \"bb\", { captures: [\"a\"] | [\"b\"] }>>(S)\n\t\t})\n\n\t\tit(\"unmatched\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"{2}\")).type.errors(\n\t\t\t\twriteUnmatchedQuantifierError(\"{2}\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"unmatched comma\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"{2,}\")).type.errors(\n\t\t\t\twriteUnmatchedQuantifierError(\"{2,}\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"unmatched min max\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"{2,3}\")).type.errors(\n\t\t\t\twriteUnmatchedQuantifierError(\"{2,3}\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"unmatched lazy\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"{2,3}?\")).type.errors(\n\t\t\t\twriteUnmatchedQuantifierError(\"{2,3}?\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"leading zeroes\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"^a{002}$\")).type.errors(\n\t\t\t\twriteUnnaturalNumberQuantifierError(\"{002}\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"negative number\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"^a{-1}$\")).type.errors(\n\t\t\t\twriteUnnaturalNumberQuantifierError(\"{-1}\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"decimal number\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"^a{1.5}$\")).type.errors(\n\t\t\t\twriteUnnaturalNumberQuantifierError(\"{1.5}\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"spaced number\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"^a{ 1}$\")).type.errors(\n\t\t\t\twriteUnnaturalNumberQuantifierError(\"{ 1}\")\n\t\t\t)\n\t\t})\n\t})\n\n\tdescribe(\"character sets\", () => {\n\t\tit(\"literals\", () => {\n\t\t\tconst S = regex(\"^a[abc]$\")\n\t\t\tattest<Regex<`a${\"a\" | \"b\" | \"c\"}`, {}>>(S)\n\t\t})\n\n\t\tit(\"ranges\", () => {\n\t\t\tconst S = regex(\"^a[x-z]$\")\n\t\t\tattest<Regex<`a${string}`, {}>>(S).type.toString.snap(\n\t\t\t\t\"Regex<`a${string}`, {}>\"\n\t\t\t) // ranges widen to string for now\n\t\t})\n\n\t\tit(\"range tree\", () => {\n\t\t\t// was previously incorrectly inferred as UnionTree<[\"1\", string]>\n\t\t\ttype Tree = State.Group.finalize<\n\t\t\t\titerate<State.initialize<\"[1-9]\", \"\">, 1>\n\t\t\t>\n\t\t\tattest<`${number}`, Tree>()\n\t\t})\n\n\t\tit(\"literal dash start\", () => {\n\t\t\tconst S = regex(\"^a[-abc]$\")\n\t\t\tattest<Regex<`a${\"-\" | \"a\" | \"b\" | \"c\"}`, {}>>(S)\n\t\t})\n\n\t\tit(\"literal dash end\", () => {\n\t\t\tconst S = regex(\"^a[abc-]$\")\n\t\t\tattest<Regex<`a${\"a\" | \"b\" | \"c\" | \"-\"}`, {}>>(S)\n\t\t})\n\n\t\tit(\"literal dash post range\", () => {\n\t\t\ttype Tree = State.Group.finalize<\n\t\t\t\titerate<State.initialize<\"[0-9-Z]\", \"\">, 1>\n\t\t\t>\n\t\t\tattest<\"-\" | \"Z\" | `${number}`, Tree>()\n\n\t\t\tconst S = regex(\"[a-z-Z]\")\n\t\t\tattest<Regex<string, {}>>(S)\n\t\t})\n\n\t\tit(\"escaped dash\", () => {\n\t\t\tconst S = regex(\"^a[a\\\\-c]$\")\n\t\t\tattest<Regex<`a${\"a\" | \"-\" | \"c\"}`, {}>>(S)\n\t\t})\n\n\t\tit(\"escaped caret\", () => {\n\t\t\tconst S = regex(\"^a[\\\\^bc]$\")\n\t\t\tattest<Regex<`a${\"^\" | \"b\" | \"c\"}`, {}>>(S)\n\t\t})\n\n\t\tit(\"escaped closing bracket\", () => {\n\t\t\tconst S = regex(\"^a[bc\\\\]]$\")\n\t\t\tattest<Regex<`a${\"b\" | \"c\" | \"]\"}`, {}>>(S)\n\t\t})\n\n\t\tit(\"escaped backslash\", () => {\n\t\t\tconst S = regex(\"^a[bc\\\\\\\\]$\")\n\t\t\tattest<Regex<`a${\"b\" | \"c\" | \"\\\\\"}`, {}>>(S)\n\t\t})\n\n\t\tit(\"negated\", () => {\n\t\t\tconst S = regex(\"^a[^abc]$\")\n\t\t\t// always widens to string, inner contents not parsed\n\t\t\tattest<Regex<`a${string}`, {}>>(S).type.toString.snap(\n\t\t\t\t\"Regex<`a${string}`, {}>\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"shorthand\", () => {\n\t\t\tconst S = regex(\"^a[\\\\d]$\")\n\t\t\tattest<Regex<`a${number}`, {}>>(S).type.toString.snap(\n\t\t\t\t\"Regex<`a${number}`, {}>\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"unclosed\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"[abc\")).type.errors(writeUnclosedGroupMessage(\"]\"))\n\t\t})\n\n\t\tit(\"unclosed negated\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"[^abc\")).type.errors(writeUnclosedGroupMessage(\"]\"))\n\t\t})\n\n\t\tit(\"empty\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"[]\")).type.errors(emptyCharacterSetMessage)\n\t\t})\n\t})\n\n\tdescribe(\"escapes\", () => {\n\t\tit(\"\\\\w\", () => {\n\t\t\tconst S = regex(\"^a\\\\wc$\")\n\t\t\tattest<Regex<`a${string}c`, {}>>(S).type.toString.snap(\n\t\t\t\t\"Regex<`a${string}c`, {}>\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"\\\\d\", () => {\n\t\t\tconst S = regex(\"^a\\\\dc$\")\n\t\t\tattest<Regex<`a${number}c`, {}>>(S).type.toString.snap(\n\t\t\t\t\"Regex<`a${number}c`, {}>\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"\\\\s\", () => {\n\t\t\tconst S = regex(\"^a\\\\sc$\")\n\t\t\tattest<Regex<`a${WhitespaceChar}c`, {}>>(S)\n\t\t})\n\n\t\tit(\"\\\\W\", () => {\n\t\t\tconst S = regex(\"^a\\\\Wc$\")\n\t\t\tattest<Regex<`a${string}c`, {}>>(S).type.toString.snap(\n\t\t\t\t\"Regex<`a${string}c`, {}>\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"\\\\D\", () => {\n\t\t\tconst S = regex(\"^a\\\\Dc$\")\n\t\t\tattest<Regex<`a${string}c`, {}>>(S).type.toString.snap(\n\t\t\t\t\"Regex<`a${string}c`, {}>\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"\\\\S\", () => {\n\t\t\tconst S = regex(\"^a\\\\Sc$\")\n\t\t\tattest<Regex<`a${string}c`, {}>>(S).type.toString.snap(\n\t\t\t\t\"Regex<`a${string}c`, {}>\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"escaped quantifier\", () => {\n\t\t\tconst S = regex(\"^a\\\\?c$\")\n\t\t\tattest<Regex<`a?c`, {}>>(S)\n\t\t})\n\n\t\tit(\"escaped anchor\", () => {\n\t\t\tconst S = regex(\"^a\\\\^c$\")\n\t\t\tattest<Regex<`a^c`, {}>>(S)\n\t\t})\n\n\t\tit(\"escaped group delimiter\", () => {\n\t\t\tconst S = regex(\"^a\\\\(c$\")\n\t\t\tattest<Regex<`a(c`, {}>>(S)\n\t\t})\n\n\t\tit(\"escaped charset delimiter\", () => {\n\t\t\tconst S = regex(\"^a\\\\[c$\")\n\t\t\tattest<Regex<`a[c`, {}>>(S)\n\t\t})\n\n\t\tit(\"escaped alternator\", () => {\n\t\t\tconst S = regex(\"^a\\\\|c$\")\n\t\t\tattest<Regex<`a|c`, {}>>(S)\n\t\t})\n\n\t\tit(\"escaped wildcard\", () => {\n\t\t\tconst S = regex(\"^a\\\\.c$\")\n\t\t\tattest<Regex<`a.c`, {}>>(S)\n\t\t})\n\n\t\tit(\"escaped backslash\", () => {\n\t\t\tconst S = regex(\"^a\\\\\\\\c$\")\n\t\t\tattest<Regex<`a\\\\c`, {}>>(S)\n\t\t})\n\n\t\tit(\"unnecessary escape\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"\\\\a\")).type.errors(writeUnnecessaryEscapeMessage(\"a\"))\n\t\t})\n\n\t\tit(\"trailing escape\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"abc\\\\\")).type.errors(trailingBackslashMessage)\n\t\t})\n\n\t\tit(\"\\\\b\", () => {\n\t\t\tconst S = regex(\"^word\\\\b$\")\n\t\t\tattest<Regex<`word`, {}>>(S)\n\t\t})\n\n\t\tit(\"\\\\B\", () => {\n\t\t\tconst S = regex(\"^word\\\\B$\")\n\t\t\tattest<Regex<`word`, {}>>(S)\n\t\t})\n\n\t\tit(\"builtin escapes\", () => {\n\t\t\tconst S = regex(\"^\\t\\n\\r\\v\\f\\0$\")\n\t\t\tattest<Regex<\"\\t\\n\\r\\v\\f\\0\", {}>>(S)\n\t\t})\n\n\t\tit(\"string escapable char\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"\\\\n\")).type.errors(writeStringEscapableMessage(\"n\"))\n\t\t})\n\n\t\tit(\"hex escape\", () => {\n\t\t\tconst S = regex(\"^a\\x62c$\")\n\t\t\tattest<Regex<\"abc\", {}>>(S).type.toString.snap('Regex<\"abc\", {}>')\n\t\t})\n\n\t\tit(\"string escapable hex\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"^a\\\\x62c$\")).type.errors(\n\t\t\t\twriteStringEscapableMessage(\"x\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"unicode escape (4 digit)\", () => {\n\t\t\tconst S = regex(\"^a\\u0062c$\")\n\t\t\tattest<Regex<\"abc\", {}>>(S).type.toString.snap('Regex<\"abc\", {}>')\n\t\t})\n\n\t\tit(\"string escapable unicode\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"^a\\\\u0062c$\")).type.errors(\n\t\t\t\twriteStringEscapableMessage(\"u\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"unicode escape (braced)\", () => {\n\t\t\tconst S = regex(\"^a\\u{62}c$\")\n\t\t\tattest<Regex<\"abc\", {}>>(S).type.toString.snap('Regex<\"abc\", {}>')\n\t\t})\n\n\t\tit(\"unicode escape (braced multi-digit)\", () => {\n\t\t\tconst S = regex(\"^a\\u{00000062}c$\")\n\t\t\tattest<Regex<\"abc\", {}>>(S).type.toString.snap('Regex<\"abc\", {}>')\n\t\t})\n\n\t\tit(\"caret notation error\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"\\\\cA\")).type.errors(caretNotationMessage)\n\t\t})\n\t})\n\n\tdescribe(\"groups\", () => {\n\t\tit(\"capturing\", () => {\n\t\t\tconst S = regex(\"^(a(b)c)$\")\n\t\t\tattest<\n\t\t\t\tRegex<\n\t\t\t\t\t`abc`,\n\t\t\t\t\t{\n\t\t\t\t\t\tcaptures: [\"abc\", \"b\"]\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>(S)\n\t\t})\n\n\t\tit(\"non-capturing\", () => {\n\t\t\tconst S = regex(\"^(a(?:b)c)$\")\n\t\t\tattest<\n\t\t\t\tRegex<\n\t\t\t\t\t`abc`,\n\t\t\t\t\t{\n\t\t\t\t\t\tcaptures: [\"abc\"]\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>(S).type.toString.snap('Regex<\"abc\", { captures: [\"abc\"] }>')\n\t\t})\n\n\t\tit(\"optional capture group includes undefined\", () => {\n\t\t\tconst S = regex(\"^(a)?$\")\n\t\t\tattest<\n\t\t\t\tRegex<\n\t\t\t\t\t\"\" | \"a\",\n\t\t\t\t\t{\n\t\t\t\t\t\tcaptures: [\"a\" | undefined]\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>(S)\n\t\t})\n\n\t\tit(\"inner optional capture group includes undefined\", () => {\n\t\t\tconst S = regex(\"^a(b(c)d)?e$\")\n\t\t\tattest<\n\t\t\t\tRegex<\n\t\t\t\t\t\"ae\" | \"abcde\",\n\t\t\t\t\t{\n\t\t\t\t\t\tcaptures: [\"bcd\", \"c\"] | [undefined, undefined]\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>(S)\n\t\t})\n\n\t\tit(\"quantified capture group including 0 includes undefined\", () => {\n\t\t\tconst S = regex(\"^(a){0,1}$\")\n\t\t\tattest<\n\t\t\t\tRegex<\n\t\t\t\t\t\"\" | \"a\",\n\t\t\t\t\t{\n\t\t\t\t\t\tcaptures: [\"a\" | undefined]\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>(S)\n\t\t})\n\n\t\tit(\"quantified\", () => {\n\t\t\tconst S = regex(\"^a(?:b)+c$\")\n\t\t\tattest<Regex<`ab${string}c`, {}>>(S).type.toString.snap(\n\t\t\t\t\"Regex<`ab${string}c`, {}>\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"nested\", () => {\n\t\t\tconst S = regex(\"^(a(b(c)))$\")\n\t\t\tattest<\n\t\t\t\tRegex<\n\t\t\t\t\t`abc`,\n\t\t\t\t\t{\n\t\t\t\t\t\tcaptures: [\"abc\", \"bc\", \"c\"]\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>(S)\n\t\t})\n\n\t\tit(\"unclosed\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"(abc\")).type.errors(writeUnclosedGroupMessage(\")\"))\n\t\t})\n\n\t\tit(\"unmatched\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"abc)\")).type.errors(\n\t\t\t\twriteUnmatchedGroupCloseMessage(\")\", \"\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"empty\", () => {\n\t\t\tconst S = regex(\"()\")\n\t\t\tattest<\n\t\t\t\tRegex<\n\t\t\t\t\t`${string}${string}`,\n\t\t\t\t\t{\n\t\t\t\t\t\tcaptures: [\"\"]\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>(S).type.toString.snap('Regex<string, { captures: [\"\"] }>')\n\t\t})\n\n\t\tit(\"unescaped literal question mark\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"(?ab)\")).type.errors(\n\t\t\t\tunescapedLiteralQuestionMarkMessage\n\t\t\t)\n\t\t})\n\t})\n\n\tdescribe(\"union\", () => {\n\t\tit(\"basic\", () => {\n\t\t\tconst S = regex(\"^a|b$\")\n\t\t\tattest<Regex<`a${string}` | `${string}b`, {}>>(S)\n\t\t})\n\n\t\tit(\"multiple\", () => {\n\t\t\tconst S = regex(\"^a|b|c$\")\n\t\t\tattest<Regex<`a${string}` | `${string}b${string}` | `${string}c`, {}>>(S)\n\t\t})\n\n\t\tit(\"within group\", () => {\n\t\t\tconst S = regex(\"^(a|b)c$\")\n\t\t\tattest<\n\t\t\t\tRegex<\n\t\t\t\t\t\"ac\" | \"bc\",\n\t\t\t\t\t{\n\t\t\t\t\t\tcaptures: [\"a\"] | [\"b\"]\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>(S)\n\t\t})\n\n\t\tit(\"empty start branch\", () => {\n\t\t\tconst S = regex(\"^|b$\")\n\t\t\tattest<Regex<string, {}>>(S).type.toString.snap(\"Regex<string, {}>\")\n\t\t})\n\n\t\tit(\"empty end branch\", () => {\n\t\t\tconst S = regex(\"^a|$\")\n\t\t\tattest<Regex<string, {}>>(S).type.toString.snap(\"Regex<string, {}>\")\n\t\t})\n\n\t\tit(\"empty middle branch\", () => {\n\t\t\tconst S = regex(\"^a||c$\")\n\t\t\tattest<Regex<string, {}>>(S).type.toString.snap(\"Regex<string, {}>\")\n\t\t})\n\t})\n\n\tit(\".\", () => {\n\t\tconst S = regex(\"^a.$\")\n\t\tattest<Regex<`a${string}`, {}>>(S)\n\t})\n\n\tit(\"consecutive .\", () => {\n\t\tconst S = regex(\"^a..c$\")\n\t\t// ideally this could be collapsed to a single {string} but seems\n\t\t// inefficient for perf based on current implementation\n\t\tattest<Regex<`a${string}${string}c`, {}>>(S).type.toString.snap(\n\t\t\t\"Regex<`a${string}${string}c`, {}>\"\n\t\t)\n\t})\n\n\tdescribe(\"index backreferences\", () => {\n\t\tit(\"basic\", () => {\n\t\t\tconst S = regex(\"^(a)b\\\\1$\")\n\t\t\tattest<\n\t\t\t\tRegex<\n\t\t\t\t\t`aba`,\n\t\t\t\t\t{\n\t\t\t\t\t\tcaptures: [\"a\"]\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>(S).type.toString.snap('Regex<\"aba\", { captures: [\"a\"] }>')\n\t\t})\n\n\t\tit(\"union\", () => {\n\t\t\tconst S = regex(\"^(a|b)\\\\1$\")\n\t\t\tattest<\n\t\t\t\tRegex<\n\t\t\t\t\t\"aa\" | \"bb\",\n\t\t\t\t\t{\n\t\t\t\t\t\tcaptures: [\"a\"] | [\"b\"]\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>(S).type.toString.snap('Regex<\"aa\" | \"bb\", { captures: [\"b\"] | [\"a\"] }>')\n\t\t})\n\n\t\tit(\"branching captures\", () => {\n\t\t\tconst S = regex(\"^((a)|b)$\")\n\t\t\tattest<\n\t\t\t\tRegex<\n\t\t\t\t\t\"a\" | \"b\",\n\t\t\t\t\t{\n\t\t\t\t\t\tcaptures: [\"a\", \"a\"] | [\"b\", undefined]\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>(S)\n\t\t})\n\n\t\tit(\"branching named captures\", () => {\n\t\t\tconst S = regex(\"^(?<foo>(?<bar>a)|b)$\")\n\t\t\tattest<\n\t\t\t\tRegex<\n\t\t\t\t\t\"a\" | \"b\",\n\t\t\t\t\t{\n\t\t\t\t\t\tcaptures: [\"a\", \"a\"] | [\"b\", undefined]\n\t\t\t\t\t\tnames:\n\t\t\t\t\t\t\t| {\n\t\t\t\t\t\t\t\t\tfoo: \"a\"\n\t\t\t\t\t\t\t\t\tbar: \"a\"\n\t\t\t\t\t\t\t  }\n\t\t\t\t\t\t\t| {\n\t\t\t\t\t\t\t\t\tfoo: \"b\"\n\t\t\t\t\t\t\t\t\tbar: undefined\n\t\t\t\t\t\t\t  }\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>(S)\n\t\t})\n\n\t\tit(\"anchored ref\", () => {\n\t\t\tconst S = regex(\"(^f)\")\n\t\t\tattest<\n\t\t\t\tRegex<\n\t\t\t\t\t`f${string}`,\n\t\t\t\t\t{\n\t\t\t\t\t\tcaptures: [\"f\"]\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>(S)\n\t\t})\n\n\t\tit(\"incomplete reference\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"^(a\\\\1b)c\\\\1$\")).type.errors(\n\t\t\t\twriteIncompleteReferenceError(\"1\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"inner quantified\", () => {\n\t\t\tconst S = regex(\"^(a+)\\\\1$\")\n\t\t\tattest<\n\t\t\t\tRegex<\n\t\t\t\t\t`a${string}a${string}`,\n\t\t\t\t\t{\n\t\t\t\t\t\tcaptures: [`a${string}`]\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>(S)\n\t\t})\n\n\t\tit(\"group quantified\", () => {\n\t\t\tconst S = regex(\"^(a)+\\\\1$\")\n\t\t\tattest<\n\t\t\t\tRegex<\n\t\t\t\t\t`a${string}a`,\n\t\t\t\t\t{\n\t\t\t\t\t\tcaptures: [\"a\"]\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>(S)\n\t\t})\n\n\t\tit(\"ref quantified\", () => {\n\t\t\tconst S = regex(\"^(a)\\\\1+$\")\n\t\t\tattest<\n\t\t\t\tRegex<\n\t\t\t\t\t`aa${string}`,\n\t\t\t\t\t{\n\t\t\t\t\t\tcaptures: [\"a\"]\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>(S)\n\t\t})\n\n\t\tit(\"multiple refs\", () => {\n\t\t\tconst S = regex(\"^a(?<foo>b(c)d)?e\\\\1\\\\2?$\")\n\n\t\t\tattest<\n\t\t\t\tRegex<\n\t\t\t\t\t\"abcdebcd\" | \"abcdebcdc\" | \"ae\",\n\t\t\t\t\t{\n\t\t\t\t\t\tcaptures: [\"bcd\", \"c\"] | [undefined, undefined]\n\t\t\t\t\t\tnames:\n\t\t\t\t\t\t\t| {\n\t\t\t\t\t\t\t\t\tfoo: \"bcd\"\n\t\t\t\t\t\t\t  }\n\t\t\t\t\t\t\t| {\n\t\t\t\t\t\t\t\t\tfoo: undefined\n\t\t\t\t\t\t\t  }\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>(S)\n\t\t})\n\n\t\tit(\"index out of range\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"(a)b\\\\2\")).type.errors(\n\t\t\t\twriteUnresolvableBackreferenceMessage(\"2\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"index 0 (invalid backreference)\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"abc\\\\0\")).type.errors(\n\t\t\t\twriteStringEscapableMessage(\"0\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"escaped octal error\", () => {\n\t\t\t// just gives based \\\\0 error message since it is not mentioned in\n\t\t\t// MDN docs even though it is technically valid JS.\n\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"\\\\07\")).type.errors(writeStringEscapableMessage(\"0\"))\n\t\t})\n\t})\n\n\tdescribe(\"named backreference\", () => {\n\t\tit(\"unreferenced\", () => {\n\t\t\tconst S = regex(\"^(?<foo>abc)$\")\n\t\t\tattest<\n\t\t\t\tRegex<\n\t\t\t\t\t`abc`,\n\t\t\t\t\t{\n\t\t\t\t\t\tcaptures: [\"abc\"]\n\t\t\t\t\t\tnames: {\n\t\t\t\t\t\t\tfoo: \"abc\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>(S)\n\t\t})\n\n\t\tit(\"anchored ref\", () => {\n\t\t\tconst S = regex(\"(?<anchored>^f)$\")\n\t\t\tattest<\n\t\t\t\tRegex<\n\t\t\t\t\t\"f\",\n\t\t\t\t\t{\n\t\t\t\t\t\tcaptures: [\"f\"]\n\t\t\t\t\t\tnames: {\n\t\t\t\t\t\t\tanchored: \"f\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>(S)\n\t\t})\n\n\t\tit(\"simple reference\", () => {\n\t\t\tconst S = regex(\"^(?<foo>a)b\\\\k<foo>$\")\n\t\t\tattest<\n\t\t\t\tRegex<\n\t\t\t\t\t`aba`,\n\t\t\t\t\t{\n\t\t\t\t\t\tcaptures: [\"a\"]\n\t\t\t\t\t\tnames: {\n\t\t\t\t\t\t\tfoo: \"a\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>(S)\n\t\t})\n\n\t\tit(\"nested\", () => {\n\t\t\tconst S = regex(\"^(?<outer>a(?<inner>b)c)\\\\k<outer>\\\\k<inner>$\")\n\t\t\tattest<\n\t\t\t\tRegex<\n\t\t\t\t\t\"abcabcb\",\n\t\t\t\t\t{\n\t\t\t\t\t\tcaptures: [\"abc\", \"b\"]\n\t\t\t\t\t\tnames: {\n\t\t\t\t\t\t\touter: \"abc\"\n\t\t\t\t\t\t\tinner: \"b\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>(S)\n\t\t})\n\n\t\tit(\"incomplete reference\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"^(?<foo>a\\\\k<foo>b)c\\\\k<foo>$\")).type.errors(\n\t\t\t\twriteIncompleteReferenceError(\"foo\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"inner quantified group\", () => {\n\t\t\tconst S = regex(\"^(?<foo>a+)\\\\k<foo>$\")\n\t\t\tattest<\n\t\t\t\tRegex<\n\t\t\t\t\t`a${string}a${string}`,\n\t\t\t\t\t{\n\t\t\t\t\t\tcaptures: [`a${string}`]\n\t\t\t\t\t\tnames: {\n\t\t\t\t\t\t\tfoo: `a${string}`\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>(S)\n\t\t})\n\n\t\tit(\"group quantified\", () => {\n\t\t\tconst S = regex(\"^(?<foo>a)+\\\\k<foo>$\")\n\t\t\tattest<\n\t\t\t\tRegex<\n\t\t\t\t\t`a${string}a`,\n\t\t\t\t\t{\n\t\t\t\t\t\tcaptures: [\"a\"]\n\t\t\t\t\t\tnames: {\n\t\t\t\t\t\t\tfoo: \"a\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>(S)\n\t\t})\n\n\t\tit(\"ref quantified\", () => {\n\t\t\tconst S = regex(\"^(?<foo>a)\\\\k<foo>+$\")\n\t\t\tattest<\n\t\t\t\tRegex<\n\t\t\t\t\t`aa${string}`,\n\t\t\t\t\t{\n\t\t\t\t\t\tcaptures: [\"a\"]\n\t\t\t\t\t\tnames: {\n\t\t\t\t\t\t\tfoo: \"a\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>(S)\n\t\t})\n\n\t\tit(\"named union group\", () => {\n\t\t\tconst S = regex(\"^(?<foo>a|b)\\\\k<foo>$\")\n\t\t\tattest<\n\t\t\t\tRegex<\n\t\t\t\t\t\"aa\" | \"bb\",\n\t\t\t\t\t{\n\t\t\t\t\t\tcaptures: [\"a\"] | [\"b\"]\n\t\t\t\t\t\tnames:\n\t\t\t\t\t\t\t| {\n\t\t\t\t\t\t\t\t\tfoo: \"b\"\n\t\t\t\t\t\t\t  }\n\t\t\t\t\t\t\t| {\n\t\t\t\t\t\t\t\t\tfoo: \"a\"\n\t\t\t\t\t\t\t  }\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>(S)\n\t\t})\n\n\t\tit(\"unclosed group\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"(?<foo>abc\")).type.errors(\n\t\t\t\twriteUnclosedGroupMessage(\")\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"unclosed name\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"(?<fooabc)\")).type.errors(\n\t\t\t\twriteUnclosedGroupMessage(\">\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"empty name\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"(?<>foo)\")).type.errors(unnamedCaptureGroupMessage)\n\t\t})\n\n\t\tit(\"unresolvable\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"(?<foo>a)b\\\\k<bar>\")).type.errors(\n\t\t\t\twriteUnresolvableBackreferenceMessage(\"bar\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"forward reference\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"\\\\k<foo>(?<foo>a)\")).type.errors(\n\t\t\t\twriteUnresolvableBackreferenceMessage(\"foo\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"missing reference\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"^(?<foo>a)b\\\\k$\")).type.errors(\n\t\t\t\tmissingBackreferenceNameMessage\n\t\t\t)\n\t\t})\n\n\t\tit(\"\\\\k< without name\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"\\\\k<>\")).type.errors(\n\t\t\t\twriteUnresolvableBackreferenceMessage(\"\")\n\t\t\t)\n\t\t})\n\t})\n\n\tdescribe(\"lookarounds\", () => {\n\t\tit(\"positive\", () => {\n\t\t\tconst S = regex(\"^a(?=b)b$\")\n\t\t\tattest<Regex<\"ab\", {}>>(S)\n\t\t})\n\n\t\tit(\"negative\", () => {\n\t\t\tconst S = regex(\"^a(?!c)b$\")\n\t\t\tattest<Regex<\"ab\", {}>>(S)\n\t\t})\n\n\t\tit(\"nested\", () => {\n\t\t\tconst S = regex(\"^a(?=b(?!d)c)bc$\")\n\t\t\tattest<Regex<\"abc\", {}>>(S)\n\t\t})\n\n\t\tit(\"quantified lookahead\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"^a(?=b)?b$\")).type.errors(\n\t\t\t\twriteUnmatchedQuantifierError(\"?\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"unclosed lookahead\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"a(?=b\")).type.errors(writeUnclosedGroupMessage(\")\"))\n\t\t})\n\n\t\tit(\"positive\", () => {\n\t\t\tconst S = regex(\"^a(?<=a)b$\")\n\t\t\tattest<Regex<\"ab\", {}>>(S).type.toString.snap('Regex<\"ab\", {}>')\n\t\t})\n\n\t\tit(\"negative\", () => {\n\t\t\tconst S = regex(\"^a(?<!b)c$\")\n\t\t\tattest<Regex<\"ac\", {}>>(S).type.toString.snap('Regex<\"ac\", {}>')\n\t\t})\n\n\t\tit(\"nested\", () => {\n\t\t\tconst S = regex(\"^abc(?<=b(?<!d)c)$\")\n\t\t\tattest<Regex<\"abc\", {}>>(S).type.toString.snap('Regex<\"abc\", {}>')\n\t\t})\n\n\t\tit(\"unclosed lookbehind\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => regex(\"(?<=ab\")).type.errors(writeUnclosedGroupMessage(\")\"))\n\t\t})\n\t})\n\n\tdescribe(\"flags\", () => {\n\t\tit(\"empty string\", () => {\n\t\t\tconst S = regex(\"^aB$\", \"\")\n\t\t\tattest<Regex<\"aB\", {}>>(S)\n\t\t})\n\n\t\tit(\"i\", () => {\n\t\t\tconst S = regex(\"^aB$\", \"i\")\n\t\t\tattest<Regex<\"aB\" | \"ab\" | \"Ab\" | \"AB\", { flags: \"i\" }>>(S)\n\t\t})\n\t})\n\n\tdescribe(\"modifiers\", () => {\n\t\tconst nodeMajor = parseInt(process.versions.node.split(\".\")[0], 10)\n\t\t// modifier support was added in node 24\n\t\tif (nodeMajor >= 24) {\n\t\t\tit(\"i enable\", () => {\n\t\t\t\tconst S = regex(\"^a(?i:bC)d$\")\n\t\t\t\tattest<Regex<\"abcd\" | \"abCd\" | \"aBcd\" | \"aBCd\", {}>>(S)\n\t\t\t})\n\n\t\t\tit(\"i disable\", () => {\n\t\t\t\tconst S = regex(\"^(?-i:aB)$\")\n\t\t\t\tattest<Regex<\"aB\", {}>>(S)\n\t\t\t})\n\n\t\t\tit(\"i enable overrides global i disable\", () => {\n\t\t\t\tconst S = regex(\"^(?i:aB)$\", \"\")\n\t\t\t\tattest<Regex<\"aB\" | \"ab\" | \"Ab\" | \"AB\", {}>>(S)\n\t\t\t})\n\n\t\t\tit(\"i disable overrides global i enable\", () => {\n\t\t\t\tconst S = regex(\"^(?-i:aB)$\", \"i\")\n\t\t\t\tattest<Regex<\"aB\", { flags: \"i\" }>>(S)\n\t\t\t})\n\n\t\t\tit(\"i enable with global i enable\", () => {\n\t\t\t\tconst S = regex(\"^(?i:aB)$\", \"i\")\n\t\t\t\tattest<Regex<\"aB\" | \"ab\" | \"Ab\" | \"AB\", { flags: \"i\" }>>(S)\n\t\t\t})\n\n\t\t\tit(\"i disable with global i disable\", () => {\n\t\t\t\tconst S = regex(\"^(?-i:aB)$\", \"\")\n\t\t\t\tattest<Regex<\"aB\", {}>>(S)\n\t\t\t})\n\n\t\t\tit(\"nested enable/disable\", () => {\n\t\t\t\tconst S = regex(\"^(?i:a(?-i:B)c)$\")\n\t\t\t\tattest<Regex<\"aBc\" | \"aBC\" | \"ABc\" | \"ABC\", {}>>(S)\n\t\t\t})\n\n\t\t\tit(\"nested disable/enable\", () => {\n\t\t\t\tconst S = regex(\"^(?-i:a(?i:B)c)$\")\n\t\t\t\tattest<Regex<\"aBc\" | \"abc\", {}>>(S)\n\t\t\t})\n\n\t\t\tit(\"multiple modifiers enable i\", () => {\n\t\t\t\tconst S = regex(\"^(?im:aB)$\")\n\t\t\t\tattest<Regex<\"aB\" | \"ab\" | \"Ab\" | \"AB\", {}>>(S)\n\t\t\t})\n\n\t\t\tit(\"multiple modifiers disable i\", () => {\n\t\t\t\tconst S = regex(\"^(?-im:aB)$\")\n\t\t\t\tattest<Regex<\"aB\", {}>>(S)\n\t\t\t})\n\n\t\t\tit(\"multiple modifiers enable/disable i\", () => {\n\t\t\t\tconst S = regex(\"^(?i-m:aB)$\")\n\t\t\t\tattest<Regex<\"aB\" | \"ab\" | \"Ab\" | \"AB\", {}>>(S)\n\t\t\t})\n\n\t\t\tit(\"duplicate conflicting modifier\", () => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tattest(() => regex(\"(?m-m:.*)\")).type.errors(\n\t\t\t\t\twriteDuplicateModifierMessage(\"m\")\n\t\t\t\t)\n\t\t\t})\n\n\t\t\tit(\"duplicate positive modifier\", () => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tattest(() => regex(\"(?mm:.*)\")).type.errors(\n\t\t\t\t\twriteDuplicateModifierMessage(\"m\")\n\t\t\t\t)\n\t\t\t})\n\n\t\t\tit(\"duplicate negated modifier\", () => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tattest(() => regex(\"(?-mm:.*)\")).type.errors(\n\t\t\t\t\twriteDuplicateModifierMessage(\"m\")\n\t\t\t\t)\n\t\t\t})\n\n\t\t\tit(\"multiple dashes\", () => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tattest(() => regex(\"^(?-i-m:aB)$\")).type.errors(\n\t\t\t\t\tmultipleModifierDashesMessage\n\t\t\t\t)\n\t\t\t})\n\n\t\t\tit(\"invalid modifier\", () => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tattest(() => regex(\"(?x:abc)\")).type.errors(\n\t\t\t\t\twriteInvalidModifierMessage(\"x\")\n\t\t\t\t)\n\t\t\t})\n\n\t\t\tit(\"invalid negated modifier\", () => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tattest(() => regex(\"(?-x:abc)\")).type.errors(\n\t\t\t\t\twriteInvalidModifierMessage(\"x\")\n\t\t\t\t)\n\t\t\t})\n\n\t\t\tit(\"missing negated modifier\", () => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tattest(() => regex(\"(?-:abc)\")).type.errors(\n\t\t\t\t\tmissingNegatedModifierMessage\n\t\t\t\t)\n\t\t\t})\n\n\t\t\tit(\"unclosed modifier group\", () => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tattest(() => regex(\"(?i\")).type.errors(writeUnclosedGroupMessage(\")\"))\n\t\t\t})\n\n\t\t\tit(\"modifier group without colon\", () => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tattest(() => regex(\"(?i)\")).type.errors(\n\t\t\t\t\tunescapedLiteralQuestionMarkMessage\n\t\t\t\t)\n\t\t\t})\n\n\t\t\tit(\"modifier group with colon but no content\", () => {\n\t\t\t\tconst S = regex(\"^(?i:)$\")\n\t\t\t\tattest<Regex<\"\", {}>>(S)\n\t\t\t})\n\t\t}\n\t})\n\n\tit(\"combinatorial\", () => {\n\t\tconst S = regex(\"^ab?c?d?e?f?g?h?i?j?k?l?m?n?o?$\")\n\t\ttype Expected =\n\t\t\t`a${\"b\" | \"\"}${\"c\" | \"\"}${\"d\" | \"\"}${\"e\" | \"\"}${\"f\" | \"\"}${\"g\" | \"\"}${\"h\" | \"\"}${\"i\" | \"\"}${\"j\" | \"\"}${\"k\" | \"\"}${\"l\" | \"\"}${\"m\" | \"\"}${\"n\" | \"\"}${\"o\" | \"\"}`\n\t\tattest<Regex<Expected, {}>>(S)\n\t})\n\n\tit(\"semver\", () => {\n\t\tconst S = regex(\"^(\\\\d+)\\\\.(\\\\d+)\\\\.(\\\\d+)$\")\n\n\t\tattest<\n\t\t\tRegex<\n\t\t\t\t`${number}.${number}.${number}`,\n\t\t\t\t{\n\t\t\t\t\tcaptures: [`${number}`, `${number}`, `${number}`]\n\t\t\t\t}\n\t\t\t>\n\t\t>(S)\n\t})\n\n\t// these tests will break if `${bigint}` is used instead of `${number}`\n\tit(\"repeated digits allow 0 prefix\", () => {\n\t\tconst S = regex(\"^\\\\d\\\\d$\")\n\t\t// we can't collapse this to a single `${number}` because of the performance cost\n\t\t// of treating the StartAnchorMarker as an empty string every time we appendNonRedundant\n\t\tattest<Regex<`${number}${number}`, {}>>(S)\n\t\tconst value: typeof S.infer = \"05\"\n\t})\n\n\tit(\"quantified bigints allow 0 prefix\", () => {\n\t\tconst S = regex(\"^\\\\d{2}$\")\n\t\tattest<Regex<`${number}`, {}>>(S)\n\t\tconst value: typeof S.infer = \"05\"\n\t})\n\n\tit(\"many repeated digit\", () => {\n\t\tconst S = regex(\"^\\\\d{64}$\")\n\t\tattest<Regex<`${number}`, {}>>(S)\n\t\tattest(S).type.toString.snap(\"Regex<`${number}`, {}>\")\n\t})\n\n\tdescribe(\"regex.as\", () => {\n\t\tit(\"0 type parameters\", () => {\n\t\t\tconst S = regex.as(\"^hello$\")\n\t\t\tattest<Regex<string, {}>>(S)\n\t\t\tattest(S.source).equals(\"^hello$\")\n\t\t\tattest(S.flags).equals(\"\")\n\t\t})\n\n\t\tit(\"1 type parameter\", () => {\n\t\t\tconst S = regex.as<\"hello\">(\"^hello$\")\n\t\t\tattest<Regex<\"hello\", {}>>(S)\n\t\t})\n\n\t\tit(\"2 type parameters\", () => {\n\t\t\tconst S = regex.as<\"hello\", { captures: [\"hello\"]; flags: \"gi\" }>(\n\t\t\t\t\"^(hello)$\",\n\t\t\t\t\"gi\"\n\t\t\t)\n\t\t\tattest<Regex<\"hello\", { captures: [\"hello\"]; flags: \"gi\" }>>(S)\n\t\t})\n\t})\n})\n"
  },
  {
    "path": "ark/regex/charset.ts",
    "content": "import type {\n\tBackslash,\n\tErrorMessage,\n\tnoSuggest,\n\tScanner,\n\twriteUnclosedGroupMessage\n} from \"@ark/util\"\nimport type { parseEscapedChar, StringDigit } from \"./escape.ts\"\nimport type { s, State } from \"./state.ts\"\n\nexport type parseCharset<s extends State, unscanned extends string> =\n\tScanner.shiftUntilEscapable<unscanned, \"]\", Backslash> extends (\n\t\tScanner.shiftResult<infer scanned, infer nextUnscanned>\n\t) ?\n\t\tnextUnscanned extends `]${infer remaining}` ?\n\t\t\t// we don't care about the contents of the negated char set because we can't infer it\n\t\t\tscanned extends Scanner.shift<\"^\", string> ?\n\t\t\t\ts.shiftQuantifiable<s, string, remaining>\n\t\t\t: parseNonNegatedCharset<scanned, never, null> extends (\n\t\t\t\tinfer result extends string\n\t\t\t) ?\n\t\t\t\t[result] extends [never] ?\n\t\t\t\t\ts.error<emptyCharacterSetMessage>\n\t\t\t\t:\ts.shiftQuantifiable<s, result, remaining>\n\t\t\t:\tnever\n\t\t:\ts.error<writeUnclosedGroupMessage<\"]\">>\n\t:\tnever\n\ntype parseNonNegatedCharset<\n\tchars extends string,\n\tset extends string,\n\tlastChar extends string | null\n> =\n\tparseChar<chars> extends Scanner.shiftResult<infer result, infer unscanned> ?\n\t\tresult extends UnescapedDashMarker ? parseDash<unscanned, set, lastChar>\n\t\t: result extends ErrorMessage ? result\n\t\t: parseNonNegatedCharset<unscanned, set | result, result>\n\t:\tset\n\ntype parseDash<\n\tunscanned extends string,\n\tset extends string,\n\tlastChar extends string | null\n> =\n\tlastChar extends string ?\n\t\t// we have a last character to use as range start\n\t\tparseChar<unscanned> extends (\n\t\t\tScanner.shiftResult<infer rangeEnd, infer next>\n\t\t) ?\n\t\t\tparseNonNegatedCharset<next, set | inferRange<lastChar, rangeEnd>, null>\n\t\t:\t// trailing -, treat as literal\n\t\t\tset | \"-\"\n\t:\t// leading -, treat as literal (lastChar is null)\n\t\tparseNonNegatedCharset<unscanned, set | \"-\", \"-\">\n\n// don't infer the full union of characters for ranges as it would blow up tsc\n// immediately, but handle cases like 0-9 better than just `string`\ntype inferRange<start extends string, end extends string> =\n\tstart | end extends StringDigit ? `${number}` : string\n\ntype UnescapedDashMarker = noSuggest<\"dash\">\n\ntype parseChar<unscanned extends string> =\n\tunscanned extends Scanner.shift<infer lookahead, infer next> ?\n\t\tlookahead extends Backslash ?\n\t\t\tnext extends Scanner.shift<infer escaped, infer postEscaped> ?\n\t\t\t\tScanner.shiftResult<parseEscapedChar<escaped>, postEscaped>\n\t\t\t:\tnever\n\t\t:\tScanner.shiftResult<\n\t\t\t\tlookahead extends \"-\" ? UnescapedDashMarker : lookahead,\n\t\t\t\tnext\n\t\t\t>\n\t:\t// return null if called on an empty string\n\t\tnull\n\nexport const emptyCharacterSetMessage =\n\t\"Empty character set [] is unsatisfiable\"\n\nexport type emptyCharacterSetMessage = typeof emptyCharacterSetMessage\n"
  },
  {
    "path": "ark/regex/escape.ts",
    "content": "import type { ErrorMessage, Scanner, WhitespaceChar } from \"@ark/util\"\nimport type { Control, ReferenceNode, s, State } from \"./state.ts\"\n\nexport type parseEscape<s extends State, unscanned extends string> =\n\tunscanned extends Scanner.shift<infer char, infer nextUnscanned> ?\n\t\tchar extends NonZeroDigit ? parseNumericBackreference<s, unscanned>\n\t\t: char extends \"k\" ? parseNamedBackreference<s, nextUnscanned>\n\t\t: char extends UnicodePropertyChar ?\n\t\t\tparseUnicodeProperty<s, char, nextUnscanned>\n\t\t:\tparseSingleEscapedCharacter<s, char, nextUnscanned>\n\t:\ts.error<trailingBackslashMessage>\n\ntype parseNumericBackreference<\n\ts extends State,\n\t// expects everything following the backslash, including the first digit\n\tfullUnscanned extends string\n> =\n\tScanner.shiftUntilNot<fullUnscanned, StringDigit> extends (\n\t\tScanner.shiftResult<infer ref, infer remaining>\n\t) ?\n\t\ts.shiftQuantifiable<s, ReferenceNode<ref>, remaining>\n\t:\tnever\n\ntype parseNamedBackreference<s extends State, unscanned extends string> =\n\tunscanned extends `<${infer ref}>${infer following}` ?\n\t\ts.shiftQuantifiable<s, ReferenceNode<ref>, following>\n\t:\ts.error<missingBackreferenceNameMessage>\n\ntype parseUnicodeProperty<\n\ts extends State,\n\tchar extends UnicodePropertyChar,\n\tunscanned extends string\n> =\n\tunscanned extends `{${string}}${infer following}` ?\n\t\ts.shiftQuantifiable<s, string, following>\n\t:\ts.error<writeInvalidUnicodePropertyMessage<char>>\n\ntype parseSingleEscapedCharacter<\n\ts extends State,\n\tchar extends string,\n\tremaining extends string\n> =\n\tparseEscapedChar<char> extends infer result extends string ?\n\t\tresult extends ErrorMessage ?\n\t\t\ts.error<result>\n\t\t:\ts.shiftQuantifiable<s, result, remaining>\n\t:\tnever\n\nexport type parseEscapedChar<char extends string> =\n\tchar extends RegexClassChar ? string\n\t: char extends \"d\" ? `${number}`\n\t: char extends \"s\" ? WhitespaceChar\n\t: // does not consume tokens\n\tchar extends BoundaryChar ? \"\"\n\t: char extends Control ? char\n\t: char extends \"c\" ? ErrorMessage<caretNotationMessage>\n\t: char extends StringEscapableChar ?\n\t\tErrorMessage<writeStringEscapableMessage<char>>\n\t:\tErrorMessage<writeUnnecessaryEscapeMessage<char>>\n\nexport const trailingBackslashMessage = \"A regex cannot end with \\\\\"\n\nexport type trailingBackslashMessage = typeof trailingBackslashMessage\n\nexport const writeUnresolvableBackreferenceMessage = <\n\tref extends string | number\n>(\n\tref: ref\n): writeUnresolvableBackreferenceMessage<ref> => `Group ${ref} does not exist`\n\nexport type writeUnresolvableBackreferenceMessage<ref extends string | number> =\n\t`Group ${ref} does not exist`\n\nexport const missingBackreferenceNameMessage =\n\t\"\\\\k must be followed by a named reference like <name>\"\n\nexport type missingBackreferenceNameMessage =\n\ttypeof missingBackreferenceNameMessage\n\nexport const writeInvalidUnicodePropertyMessage = <\n\tchar extends UnicodePropertyChar\n>(\n\tchar: char\n): writeInvalidUnicodePropertyMessage<char> =>\n\t`\\\\${char} must be followed by a property like \\\\${char}{Emoji_Presentation}`\n\nexport type writeInvalidUnicodePropertyMessage<\n\tchar extends UnicodePropertyChar\n> =\n\t`\\\\${char} must be followed by a property like \\\\${char}{Emoji_Presentation}`\n\nexport const writeUnnecessaryEscapeMessage = <char extends string>(\n\tchar: char\n): writeUnnecessaryEscapeMessage<char> =>\n\t`Escape preceding ${char} is unnecessary and should be removed.`\n\nexport type writeUnnecessaryEscapeMessage<char extends string> =\n\t`Escape preceding ${char} is unnecessary and should be removed.`\n\n// we have to add extra backslashes to the runtime variants of these\n// so that attest can compare them correctly to their type-level equivalents\n// the runtime variants are only used for the tests\n\nexport const writeStringEscapableMessage = (char: StringEscapableChar) =>\n\t`\\\\${char} should be specified with a single backslash like regex('\\\\n')` as const\n\nexport type writeStringEscapableMessage<char extends StringEscapableChar> =\n\t`\\\\${char} should be specified with a single backslash like regex('\\n')`\n\nexport const caretNotationMessage =\n\t\"\\\\\\\\cX notation is not supported. Use hex (\\\\\\\\x) or unicode (\\\\\\\\u) instead.\"\n\nexport type caretNotationMessage =\n\t\"\\\\cX notation is not supported. Use hex (\\\\x) or unicode (\\\\u) instead.\"\n\nexport type StringEscapableChar = \"t\" | \"n\" | \"r\" | \"f\" | \"v\" | \"0\" | \"x\" | \"u\"\n\nexport type RegexClassChar = \"w\" | \"W\" | \"D\" | \"S\"\n\nexport type BoundaryChar = \"b\" | \"B\"\n\nexport type UnicodePropertyChar = \"p\" | \"P\"\n\nexport type NonZeroDigit = \"1\" | \"2\" | \"3\" | \"4\" | \"5\" | \"6\" | \"7\" | \"8\" | \"9\"\n\nexport type StringDigit = \"0\" | NonZeroDigit\n"
  },
  {
    "path": "ark/regex/execArray.ts",
    "content": "import type { DynamicBase } from \"@ark/util\"\nimport type { Flags, IndexedCaptures, NamedCaptures } from \"./regex.ts\"\n\nexport interface RegexExecArray<\n\tpatternAndCaptures extends IndexedCaptures,\n\tnamedCaptures extends NamedCaptures,\n\tflags extends Flags\n> extends DynamicBase<patternAndCaptures> {\n\t/**\n\t * The index of the search at which the result was found.\n\t */\n\tindex: number\n\n\t/**\n\t * A copy of the search string.\n\t */\n\tinput: patternAndCaptures[0]\n\n\tindices: flags extends `${string}d${string}` ?\n\t\tRegexIndicesArray<patternAndCaptures, namedCaptures>\n\t:\tundefined\n\n\tgroups: keyof namedCaptures extends never ? undefined : namedCaptures\n}\n\nexport type RegexIndexRange = [start: number, end: number]\n\ninterface RegexIndicesArray<\n\tpatternAndCaptures extends IndexedCaptures,\n\tnamedCaptures extends NamedCaptures\n> extends DynamicBase<{ [i in keyof patternAndCaptures]: RegexIndexRange }> {\n\tgroups: keyof namedCaptures extends never ? undefined\n\t:\t{ [k in keyof namedCaptures]: RegexIndexRange }\n}\n"
  },
  {
    "path": "ark/regex/group.ts",
    "content": "import type {\n\tErrorMessage,\n\tScanner,\n\twriteUnclosedGroupMessage\n} from \"@ark/util\"\nimport type { State, s } from \"./state.ts\"\n\ntype LookaroundChar = \"=\" | \"!\"\n\nexport type ModifiableFlag = \"i\" | \"m\" | \"s\"\n\nexport type parseGroup<s extends State, unscanned extends string> =\n\tunscanned extends Scanner.shift<infer lookahead, infer next> ?\n\t\tlookahead extends \"?\" ?\n\t\t\tparseNonCapturingGroup<s, next>\n\t\t:\ts.pushGroup<s, State.UnnamedCaptureKind.indexed, unscanned, undefined>\n\t:\ts.error<writeUnclosedGroupMessage<\")\">>\n\ntype parseNonCapturingGroup<s extends State, unscanned extends string> =\n\tunscanned extends Scanner.shift<infer lookahead, infer next> ?\n\t\tlookahead extends \":\" ?\n\t\t\ts.pushGroup<s, State.UnnamedCaptureKind.noncapturing, next, undefined>\n\t\t: // for now, lookarounds don't affect inference\n\t\tlookahead extends LookaroundChar ?\n\t\t\ts.pushGroup<s, State.UnnamedCaptureKind.lookaround, next, undefined>\n\t\t: lookahead extends \"<\" ? parseNamedGroupOrLookbehind<s, next>\n\t\t: shiftModifiers<unscanned> extends (\n\t\t\tShiftedModifiers<infer flags, infer negated, infer following>\n\t\t) ?\n\t\t\tfollowing extends ErrorMessage<infer message> ?\n\t\t\t\ts.error<message>\n\t\t\t:\ts.pushGroup<\n\t\t\t\t\ts,\n\t\t\t\t\tState.UnnamedCaptureKind.noncapturing,\n\t\t\t\t\tfollowing,\n\t\t\t\t\t\"i\" extends flags ? true\n\t\t\t\t\t: \"i\" extends negated ? false\n\t\t\t\t\t: undefined\n\t\t\t\t>\n\t\t:\tnever\n\t:\ts.error<writeUnclosedGroupMessage<\")\">>\n\ntype ShiftedModifiers<\n\tflags extends ModifiableFlag = ModifiableFlag,\n\tnegated extends ModifiableFlag = ModifiableFlag,\n\tunscanned extends string = string\n> = [ParsedModifiers<flags, negated>, unscanned]\n\ntype ParsedModifiers<\n\tflags extends ModifiableFlag = ModifiableFlag,\n\tnegated extends ModifiableFlag = ModifiableFlag\n> = {\n\tflags: flags\n\tnegated: negated\n}\n\ntype shiftModifiers<unscanned extends string> =\n\tScanner.shiftUntil<unscanned, \":\" | \")\"> extends (\n\t\tScanner.shiftResult<infer scanned, infer next>\n\t) ?\n\t\tnext extends Scanner.shift<infer terminator, infer following> ?\n\t\t\tterminator extends \":\" ?\n\t\t\t\tparseModifiers<scanned> extends (\n\t\t\t\t\tParsedModifiers<infer flags, infer negated>\n\t\t\t\t) ?\n\t\t\t\t\tShiftedModifiers<flags, negated, following>\n\t\t\t\t:\t// set unscanned to the error string\n\t\t\t\t\tShiftedModifiers<\n\t\t\t\t\t\tnever,\n\t\t\t\t\t\tnever,\n\t\t\t\t\t\tErrorMessage<parseModifiers<scanned> & string>\n\t\t\t\t\t>\n\t\t\t:\tShiftedModifiers<\n\t\t\t\t\tnever,\n\t\t\t\t\tnever,\n\t\t\t\t\tErrorMessage<unescapedLiteralQuestionMarkMessage>\n\t\t\t\t>\n\t\t:\tShiftedModifiers<\n\t\t\t\tnever,\n\t\t\t\tnever,\n\t\t\t\tErrorMessage<writeUnclosedGroupMessage<\")\">>\n\t\t\t>\n\t:\tnever\n\ntype parseModifiers<unscanned extends string> = _parseModifiers<\n\tunscanned,\n\tnever,\n\tnever\n>\n\ntype _parseModifiers<\n\tunscanned extends string,\n\tflags extends ModifiableFlag,\n\tnegated extends ModifiableFlag\n> =\n\tunscanned extends Scanner.shift<infer lookahead, infer next> ?\n\t\tlookahead extends \"-\" ?\n\t\t\t[negated] extends [never] ?\n\t\t\t\tnext extends Scanner.shift<infer modifier, infer next> ?\n\t\t\t\t\tmodifier extends ModifiableFlag ?\n\t\t\t\t\t\tmodifier extends flags | negated ?\n\t\t\t\t\t\t\twriteDuplicateModifierMessage<modifier>\n\t\t\t\t\t\t:\t_parseModifiers<next, flags, negated | modifier>\n\t\t\t\t\t:\twriteInvalidModifierMessage<modifier>\n\t\t\t\t:\tmissingNegatedModifierMessage\n\t\t\t:\tmultipleModifierDashesMessage\n\t\t: lookahead extends ModifiableFlag ?\n\t\t\tlookahead extends flags | negated ?\n\t\t\t\twriteDuplicateModifierMessage<lookahead>\n\t\t\t: // once \"-\" has been seen, all subsequent modifiers are negated\n\t\t\t// check if we've already parsed a negation to see how to treat this\n\t\t\t[negated] extends [never] ?\n\t\t\t\t_parseModifiers<next, flags | lookahead, negated>\n\t\t\t:\t_parseModifiers<next, flags, negated | lookahead>\n\t\t:\twriteInvalidModifierMessage<lookahead>\n\t:\tParsedModifiers<flags, negated>\n\nexport const writeDuplicateModifierMessage = <modifier extends ModifiableFlag>(\n\tmodifier: modifier\n): writeDuplicateModifierMessage<modifier> =>\n\t`Modifier ${modifier} cannot appear multiple times in a single group`\n\ntype writeDuplicateModifierMessage<modifier extends ModifiableFlag> =\n\t`Modifier ${modifier} cannot appear multiple times in a single group`\n\nexport const multipleModifierDashesMessage =\n\t\"Modifiers can include at most one '-' to negate subsequent flags\"\n\ntype multipleModifierDashesMessage = typeof multipleModifierDashesMessage\n\nexport const missingNegatedModifierMessage = `- must be followed by the modifier flag to negate ('i', 'm' or 's')`\n\ntype missingNegatedModifierMessage = typeof missingNegatedModifierMessage\n\nexport const writeInvalidModifierMessage = <char extends string>(\n\tchar: char\n): writeInvalidModifierMessage<char> =>\n\t`Modifier flag ${char} must be 'i', 'm' or 's'`\n\ntype writeInvalidModifierMessage<char extends string> =\n\t`Modifier flag ${char} must be 'i', 'm' or 's'`\n\ntype parseNamedGroupOrLookbehind<s extends State, unscanned extends string> =\n\tunscanned extends Scanner.shift<LookaroundChar, infer next> ?\n\t\t// for now, lookarounds don't affect inference\n\t\ts.pushGroup<s, State.UnnamedCaptureKind.lookaround, next, undefined>\n\t: shiftNamedGroup<unscanned> extends (\n\t\tScanner.shiftResult<infer name, infer following>\n\t) ?\n\t\ts.pushGroup<s, name, following, undefined>\n\t:\ts.error<writeUnclosedGroupMessage<\")\">>\n\ntype shiftNamedGroup<unscanned extends string> =\n\tunscanned extends `${infer name}>${infer next}` ?\n\t\tname extends \"\" ?\n\t\t\tScanner.shiftResult<\"\", ErrorMessage<unnamedCaptureGroupMessage>>\n\t\t:\tScanner.shiftResult<name, next>\n\t:\tScanner.shiftResult<\"\", ErrorMessage<writeUnclosedGroupMessage<\">\">>>\n\nexport const unnamedCaptureGroupMessage = \"Capture group <> requires a name\"\n\nexport type unnamedCaptureGroupMessage = typeof unnamedCaptureGroupMessage\n\nexport const unescapedLiteralQuestionMarkMessage =\n\t\"literal ? must be escaped at the start of a group\"\n\nexport type unescapedLiteralQuestionMarkMessage =\n\ttypeof unescapedLiteralQuestionMarkMessage\n"
  },
  {
    "path": "ark/regex/index.ts",
    "content": "export { regex, type Regex } from \"./regex.ts\"\n"
  },
  {
    "path": "ark/regex/package.json",
    "content": "{\n\t\"name\": \"arkregex\",\n\t\"description\": \"A drop-in replacement for new RegExp() with types\",\n\t\"version\": \"0.0.5\",\n\t\"license\": \"MIT\",\n\t\"author\": {\n\t\t\"name\": \"David Blass\",\n\t\t\"email\": \"david@arktype.io\",\n\t\t\"url\": \"https://arktype.io\"\n\t},\n\t\"type\": \"module\",\n\t\"main\": \"./out/index.js\",\n\t\"types\": \"./out/index.d.ts\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"ark-ts\": \"./index.ts\",\n\t\t\t\"default\": \"./out/index.js\"\n\t\t},\n\t\t\"./internal/*.ts\": {\n\t\t\t\"ark-ts\": \"./*.ts\",\n\t\t\t\"default\": \"./out/*.js\"\n\t\t},\n\t\t\"./internal/*.js\": {\n\t\t\t\"ark-ts\": \"./*.ts\",\n\t\t\t\"default\": \"./out/*.js\"\n\t\t}\n\t},\n\t\"files\": [\n\t\t\"out\"\n\t],\n\t\"scripts\": {\n\t\t\"build\": \"ts ../repo/build.ts\",\n\t\t\"test\": \"ts ../repo/testPackage.ts\",\n\t\t\"bench\": \"ts ./__tests__/regex.bench.ts\"\n\t},\n\t\"dependencies\": {\n\t\t\"@ark/util\": \"workspace:*\"\n\t},\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t}\n}\n"
  },
  {
    "path": "ark/regex/parse.ts",
    "content": "import type { Backslash, ErrorMessage, Scanner } from \"@ark/util\"\nimport type { parseCharset } from \"./charset.ts\"\nimport type { parseEscape } from \"./escape.ts\"\nimport type { parseGroup } from \"./group.ts\"\nimport type {\n\tparseBuiltinQuantifier,\n\tparsePossibleRange,\n\tQuantifyingChar\n} from \"./quantify.ts\"\nimport type { Anchor, AnchorMarker, s, State, UnionTree } from \"./state.ts\"\n\nexport type parseState<s extends State> =\n\ts[\"unscanned\"] extends ErrorMessage ? s[\"unscanned\"]\n\t: s[\"unscanned\"] extends \"\" ? s.finalize<s>\n\t: parseState<next<s>>\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions/Cheatsheet\nexport type next<s extends State> =\n\ts[\"unscanned\"] extends Scanner.shift<infer lookahead, infer unscanned> ?\n\t\tlookahead extends \".\" ? s.shiftQuantifiable<s, string, unscanned>\n\t\t: lookahead extends Backslash ? parseEscape<s, unscanned>\n\t\t: lookahead extends \"|\" ? s.finalizeBranch<s, unscanned>\n\t\t: lookahead extends Anchor ? s.anchor<s, AnchorMarker<lookahead>, unscanned>\n\t\t: lookahead extends \"(\" ? parseGroup<s, unscanned>\n\t\t: lookahead extends \")\" ? s.popGroup<s, unscanned>\n\t\t: lookahead extends QuantifyingChar ?\n\t\t\tparseBuiltinQuantifier<s, lookahead, unscanned>\n\t\t: lookahead extends \"{\" ? parsePossibleRange<s, unscanned>\n\t\t: lookahead extends \"[\" ? parseCharset<s, unscanned>\n\t\t: s.shiftQuantifiable<\n\t\t\t\ts,\n\t\t\t\tmaybeSplitCasing<s[\"caseInsensitive\"], lookahead>,\n\t\t\t\tunscanned\n\t\t\t>\n\t:\tnever\n\ntype maybeSplitCasing<caseInsensitive extends boolean, char extends string> =\n\tcaseInsensitive extends false ? char\n\t: Lowercase<char> extends Uppercase<char> ? char\n\t: UnionTree<[Lowercase<char>, Capitalize<char>]>\n"
  },
  {
    "path": "ark/regex/quantify.ts",
    "content": "import type { parseNonNegativeInteger, Scanner } from \"@ark/util\"\nimport type { s, State } from \"./state.ts\"\n\nexport type parseBuiltinQuantifier<\n\ts extends State,\n\tquantifier extends QuantifyingChar,\n\tunscanned extends string\n> =\n\ts[\"root\"] extends \"\" ? s.error<writeUnmatchedQuantifierError<quantifier>>\n\t:\tquantifyBuiltin<\n\t\t\ts,\n\t\t\tquantifier,\n\t\t\tunscanned extends Scanner.shift<\"?\", infer lazyUnscanned> ? lazyUnscanned\n\t\t\t:\tunscanned\n\t\t>\n\ntype quantifyBuiltin<\n\ts extends State,\n\tquantifier extends QuantifyingChar,\n\tunscanned extends string\n> =\n\tquantifier extends \"?\" ? s.pushQuantifier<s, 0, 1, unscanned>\n\t: quantifier extends \"+\" ? s.pushQuantifier<s, 1, null, unscanned>\n\t: quantifier extends \"*\" ? s.pushQuantifier<s, 0, null, unscanned>\n\t: never\n\ntype ParsedRange = {\n\tmin: number\n\tmax: number | null\n\tunscanned: string\n}\n\ndeclare namespace ParsedRange {\n\texport type from<r extends ParsedRange> = r\n}\n\ntype skipPossibleQuestionMark<unscanned extends string> =\n\tunscanned extends `?${infer next}` ? next : unscanned\n\ntype parsePossibleRangeString<unscanned extends string> =\n\tunscanned extends (\n\t\t`${infer l extends `${number}`},${infer r extends `${number}`}}${infer next}`\n\t) ?\n\t\tParsedRange.from<{\n\t\t\tmin: parseNonNegativeInteger<l>\n\t\t\tmax: parseNonNegativeInteger<r>\n\t\t\tunscanned: skipPossibleQuestionMark<next>\n\t\t}>\n\t: unscanned extends `${infer l extends `${number}`},}${infer next}` ?\n\t\tParsedRange.from<{\n\t\t\tmin: parseNonNegativeInteger<l>\n\t\t\tmax: null\n\t\t\tunscanned: skipPossibleQuestionMark<next>\n\t\t}>\n\t: unscanned extends `${infer l extends `${number}`}}${infer next}` ?\n\t\tParsedRange.from<{\n\t\t\tmin: parseNonNegativeInteger<l>\n\t\t\tmax: parseNonNegativeInteger<l>\n\t\t\tunscanned: skipPossibleQuestionMark<next>\n\t\t}>\n\t:\tnull\n\ntype parseQuantifier<unscanned extends string, parsed extends ParsedRange> =\n\tunscanned extends `${infer range}${parsed[\"unscanned\"]}` ? `{${range}` : never\nexport type parsePossibleRange<\n\ts extends State,\n\tunscanned extends string,\n\tparsed extends ParsedRange | null = parsePossibleRangeString<unscanned>\n> =\n\tparsed extends ParsedRange ?\n\t\ts[\"root\"] extends \"\" ?\n\t\t\ts.error<writeUnmatchedQuantifierError<parseQuantifier<unscanned, parsed>>>\n\t\t: [parsed[\"min\"], parsed[\"max\"]] extends (\n\t\t\t[never, unknown] | [unknown, never]\n\t\t) ?\n\t\t\ts.error<\n\t\t\t\twriteUnnaturalNumberQuantifierError<parseQuantifier<unscanned, parsed>>\n\t\t\t>\n\t\t:\ts.pushQuantifier<\n\t\t\t\ts,\n\t\t\t\tparsed[\"min\"],\n\t\t\t\tparsed[\"max\"],\n\t\t\t\tparsed[\"unscanned\"] extends Scanner.shift<\"?\", infer lazyUnscanned> ?\n\t\t\t\t\tlazyUnscanned\n\t\t\t\t:\tparsed[\"unscanned\"]\n\t\t\t>\n\t:\ts.shiftQuantifiable<s, \"{\", unscanned>\n\nexport type quantify<\n\tpattern extends string,\n\tmin extends number,\n\tmax extends number | null\n> = tryFastPath<pattern, min, max>\n\ntype tryFastPath<\n\tpattern extends string,\n\tmin extends number,\n\tmax extends number | null\n> =\n\tmax extends 0 ? \"\"\n\t: // repeating string or `${number}` any number of times will not change the type\n\tstring extends pattern ? string\n\t: `${number}` extends pattern ? `${number}`\n\t: min extends 0 ?\n\t\tmax extends 1 ? \"\" | pattern\n\t\t: max extends number ? loopFromZero<pattern, max, \"\", []>\n\t\t: // max is null, all we can do is append ${string}\n\t\t\t\"\" | `${pattern}${string}`\n\t:\tloopUntilMin<pattern, min, max, \"\", []>\n\ntype loopFromZero<\n\tbase extends string,\n\tmax extends number,\n\tacc extends string,\n\trepetitions extends 1[]\n> =\n\trepetitions[\"length\"] extends max ? acc\n\t:\tloopFromZero<base, max, acc | `${acc}${base}`, [...repetitions, 1]>\n\ntype loopUntilMin<\n\tbase extends string,\n\tmin extends number,\n\tmax extends number | null,\n\tacc extends string,\n\trepetitions extends 1[]\n> =\n\trepetitions[\"length\"] extends min ?\n\t\tmax extends number ? loopUntilMax<base, min, max, acc, repetitions>\n\t\t: // don't need appendNonRedundant for these cases because if the pattern is\n\t\t// something collapsible like `string` or `bigint, the fast path has\n\t\t// already been taken\n\t\trepetitions[\"length\"] extends 0 ? acc | `${acc}${base}${string}`\n\t\t: `${acc}${string}`\n\t:\tloopUntilMin<base, min, max, `${acc}${base}`, [...repetitions, 1]>\n\ntype loopUntilMax<\n\tbase extends string,\n\tmin extends number,\n\tmax extends number,\n\tacc extends string,\n\trepetitions extends 1[]\n> =\n\trepetitions[\"length\"] extends max ? acc\n\t:\tloopUntilMax<base, min, max, acc | `${acc}${base}`, [...repetitions, 1]>\n\nexport type QuantifyingChar = \"*\" | \"+\" | \"?\"\n\nexport const writeUnmatchedQuantifierError = <quantifier extends string>(\n\tquantifier: quantifier\n): writeUnmatchedQuantifierError<quantifier> =>\n\t`Quantifier ${quantifier} requires a preceding token`\n\nexport type writeUnmatchedQuantifierError<quantifier extends string> =\n\t`Quantifier ${quantifier} requires a preceding token`\n\nexport const writeUnnaturalNumberQuantifierError = <quantifier extends string>(\n\tquantifier: quantifier\n): writeUnnaturalNumberQuantifierError<quantifier> =>\n\t`Quantifier ${quantifier} must use natural numbers`\n\nexport type writeUnnaturalNumberQuantifierError<quantifier extends string> =\n\t`Quantifier ${quantifier} must use natural numbers`\n"
  },
  {
    "path": "ark/regex/regex.ts",
    "content": "import type { ErrorMessage, inferred } from \"@ark/util\"\nimport type { RegexExecArray } from \"./execArray.ts\"\nimport type { parseState } from \"./parse.ts\"\nimport type { State } from \"./state.ts\"\n\nexport type IndexedCaptures = Array<string | undefined>\nexport type NamedCaptures = Record<string, string | undefined>\n\nexport type UnicodeFlag = \"v\" | \"u\"\nexport type Flags =\n\t`${\"d\" | \"\"}${\"g\" | \"\"}${\"i\" | \"\"}${\"m\" | \"\"}${\"s\" | \"\"}${UnicodeFlag | \"\"}${\"y\" | \"\"}`\n\nexport type RegexContext = {\n\tflags?: Flags\n\tcaptures?: IndexedCaptures\n\tnames?: NamedCaptures\n}\n\nexport interface Regex<\n\tout pattern extends string = string,\n\t// @ts-ignore (override variance)\n\tout ctx extends RegexContext = RegexContext\n> extends RegExp {\n\t[inferred]: pattern\n\tinfer: pattern\n\tinferCaptures: ctx[\"captures\"] extends IndexedCaptures ? ctx[\"captures\"] : []\n\tinferNamedCaptures: ctx[\"names\"] extends NamedCaptures ? ctx[\"names\"] : {}\n\tinferExecArray: RegexExecArray<\n\t\t[pattern, ...this[\"inferCaptures\"]],\n\t\tthis[\"inferNamedCaptures\"],\n\t\tthis[\"flags\"]\n\t>\n\n\tflags: ctx[\"flags\"] extends Flags ? ctx[\"flags\"] : \"\"\n\n\ttest(s: string): s is pattern\n\n\texec(s: string): this[\"inferExecArray\"] | null\n\t// allow extension of base RegExp with more accurate types\n\t// since parameters are identical, this overload will never be hit\n\texec(s: string): never\n}\n\nexport interface RegexParser {\n\t<src extends string, flags extends Flags = \"\">(\n\t\tsrc: regex.validate<src, flags>,\n\t\tflags?: flags\n\t): regex.parse<src, flags>\n\n\tas: <pattern extends string = string, ctx extends RegexContext = {}>(\n\t\tsrc: string,\n\t\tflags?: Flags\n\t) => Regex<pattern, ctx>\n}\n\nexport const regex: RegexParser = ((src, flags) =>\n\tnew RegExp(src, flags)) as RegexParser\n\nObject.assign(regex, { as: regex })\n\nexport type regex<\n\tpattern extends string = string,\n\tctx extends RegexContext = RegexContext\n> = Regex<pattern, ctx>\n\nexport declare namespace regex {\n\texport type infer<src extends string, flags extends Flags = \"\"> =\n\t\tparse<src, flags> extends Regex<infer pattern> ? pattern : never\n\n\texport type validate<src extends string, flags extends Flags = \"\"> =\n\t\tparse<src, flags> extends infer e extends ErrorMessage ? e : src\n\n\texport type parse<src extends string, flags extends Flags = \"\"> = parseState<\n\t\tState.initialize<src, flags>\n\t>\n}\n"
  },
  {
    "path": "ark/regex/state.ts",
    "content": "import type {\n\tcontains,\n\tErrorMessage,\n\tnoSuggest,\n\tNumberLiteral,\n\tsetIndex,\n\tunionKeyOf,\n\twriteUnclosedGroupMessage,\n\twriteUnmatchedGroupCloseMessage,\n\tZeroWidthSpace\n} from \"@ark/util\"\nimport type { writeUnresolvableBackreferenceMessage } from \"./escape.ts\"\nimport type { quantify, QuantifyingChar } from \"./quantify.ts\"\nimport type {\n\tFlags,\n\tIndexedCaptures,\n\tNamedCaptures,\n\tRegex,\n\tRegexContext\n} from \"./regex.ts\"\n\nexport interface State extends State.Group {\n\tunscanned: string\n\tgroups: State.Group[]\n\t/** the initial flags passed to the root of the expression */\n\tflags: Flags\n}\n\nexport declare namespace State {\n\texport type from<s extends State> = s\n\n\texport type initialize<source extends string, flags extends Flags> = from<{\n\t\tunscanned: source\n\t\tgroups: []\n\t\tcapture: never\n\t\tbranches: []\n\t\tsequence: SequenceTree.Empty\n\t\troot: \"\"\n\t\tcaseInsensitive: contains<flags, \"i\">\n\t\tflags: flags\n\t}>\n\n\tenum UnnamedCaptureKind {\n\t\tindexed,\n\t\tlookaround,\n\t\tnoncapturing\n\t}\n\n\texport type CaptureKind = string | UnnamedCaptureKind\n\n\texport type Group = {\n\t\t/** the name of the group or its kind */\n\t\tcapture: CaptureKind\n\t\tbranches: RegexAst[]\n\t\tsequence: RegexAst\n\t\troot: RegexAst\n\t\tcaseInsensitive: boolean\n\t}\n\n\texport namespace Group {\n\t\texport type from<g extends Group> = g\n\n\t\ttype pop<init extends Group, last extends Group[]> = [...last, init]\n\n\t\texport type finalize<g extends Group> =\n\t\t\tg[\"branches\"] extends [] ? pushQuantifiable<g[\"sequence\"], g[\"root\"]>\n\t\t\t: [...g[\"branches\"], pushQuantifiable<g[\"sequence\"], g[\"root\"]>] extends (\n\t\t\t\tinfer branches extends RegexAst[]\n\t\t\t) ?\n\t\t\t\tfinalizeUnion<branches, []>\n\t\t\t:\tnever\n\n\t\ttype finalizeUnion<\n\t\t\tremaining extends RegexAst[],\n\t\t\tflattened extends RegexAst[]\n\t\t> =\n\t\t\tremaining extends (\n\t\t\t\t[infer head extends RegexAst, ...infer tail extends RegexAst[]]\n\t\t\t) ?\n\t\t\t\thead extends UnionTree<infer headBranches> ?\n\t\t\t\t\tfinalizeUnion<tail, [...flattened, ...headBranches]>\n\t\t\t\t:\tfinalizeUnion<tail, [...flattened, head]>\n\t\t\t:\tUnionTree<flattened>\n\t}\n}\n\nexport type Boundary = Anchor | \"(\" | \")\" | \"[\" | \"]\"\nexport type Anchor = \"^\" | \"$\"\nexport type Control = QuantifyingChar | Boundary | \"|\" | \".\" | \"{\" | \"-\" | \"\\\\\"\n\nexport type AnchorMarker<inner extends Anchor = Anchor> =\n\t`<${ZeroWidthSpace}${inner}${ZeroWidthSpace}>`\n\nexport type StartAnchorMarker = AnchorMarker<\"^\">\nexport type EndAnchorMarker = AnchorMarker<\"$\">\n\nexport declare namespace s {\n\texport type error<message extends string> = State.from<{\n\t\tunscanned: ErrorMessage<message>\n\t\tgroups: []\n\t\tcapture: never\n\t\tbranches: []\n\t\tsequence: SequenceTree.Empty\n\t\troot: \"\"\n\t\tcaseInsensitive: false\n\t\tflags: \"\"\n\t}>\n\n\texport type shiftQuantifiable<\n\t\ts extends State,\n\t\troot extends RegexAst,\n\t\tunscanned extends string\n\t> = State.from<{\n\t\tunscanned: unscanned\n\t\tgroups: s[\"groups\"]\n\t\tcapture: s[\"capture\"]\n\t\tbranches: s[\"branches\"]\n\t\tsequence: pushQuantifiable<s[\"sequence\"], s[\"root\"]>\n\t\troot: root\n\t\tcaseInsensitive: s[\"caseInsensitive\"]\n\t\tflags: s[\"flags\"]\n\t}>\n\n\texport type pushQuantified<\n\t\ts extends State,\n\t\tquantified extends RegexAst,\n\t\tunscanned extends string\n\t> = State.from<{\n\t\tunscanned: unscanned\n\t\tgroups: s[\"groups\"]\n\t\tcapture: s[\"capture\"]\n\t\tbranches: s[\"branches\"]\n\t\tsequence: pushQuantifiable<s[\"sequence\"], quantified>\n\t\troot: \"\"\n\t\tcaseInsensitive: s[\"caseInsensitive\"]\n\t\tflags: s[\"flags\"]\n\t}>\n\n\texport type pushQuantifier<\n\t\ts extends State,\n\t\tmin extends number,\n\t\tmax extends number | null,\n\t\tunscanned extends string\n\t> = State.from<{\n\t\tunscanned: unscanned\n\t\tgroups: s[\"groups\"]\n\t\tcapture: s[\"capture\"]\n\t\tbranches: s[\"branches\"]\n\t\tsequence: pushQuantifiable<\n\t\t\ts[\"sequence\"],\n\t\t\t{\n\t\t\t\tkind: \"quantifier\"\n\t\t\t\tast: s[\"root\"]\n\t\t\t\tmin: min\n\t\t\t\tmax: max\n\t\t\t}\n\t\t>\n\t\troot: \"\"\n\t\tcaseInsensitive: s[\"caseInsensitive\"]\n\t\tflags: s[\"flags\"]\n\t}>\n\n\texport type finalizeBranch<\n\t\ts extends State,\n\t\tunscanned extends string\n\t> = State.from<{\n\t\tunscanned: unscanned\n\t\tgroups: s[\"groups\"]\n\t\tcapture: s[\"capture\"]\n\t\tbranches: [...s[\"branches\"], pushQuantifiable<s[\"sequence\"], s[\"root\"]>]\n\t\tsequence: SequenceTree.Empty\n\t\troot: \"\"\n\t\tcaseInsensitive: s[\"caseInsensitive\"]\n\t\tflags: s[\"flags\"]\n\t}>\n\n\texport type anchor<\n\t\ts extends State,\n\t\ta extends AnchorMarker,\n\t\tunscanned extends string\n\t> = State.from<{\n\t\tunscanned: unscanned\n\t\tgroups: s[\"groups\"]\n\t\tcapture: s[\"capture\"]\n\t\tbranches: s[\"branches\"]\n\t\tsequence: pushQuantifiable<s[\"sequence\"], pushQuantifiable<s[\"root\"], a>>\n\t\troot: \"\"\n\t\tcaseInsensitive: s[\"caseInsensitive\"]\n\t\tflags: s[\"flags\"]\n\t}>\n\n\texport type pushGroup<\n\t\ts extends State,\n\t\tcapture extends string | State.UnnamedCaptureKind,\n\t\tunscanned extends string,\n\t\tcaseInsensitive extends boolean | undefined\n\t> = State.from<{\n\t\tunscanned: unscanned\n\t\tgroups: [...s[\"groups\"], s]\n\t\tcapture: capture\n\t\tbranches: []\n\t\tsequence: SequenceTree.Empty\n\t\troot: \"\"\n\t\tcaseInsensitive: caseInsensitive extends boolean ? caseInsensitive\n\t\t:\ts[\"caseInsensitive\"]\n\t\tflags: s[\"flags\"]\n\t}>\n\n\texport type popGroup<s extends State, unscanned extends string> =\n\t\ts[\"groups\"] extends State.Group.pop<infer last, infer init> ?\n\t\t\tState.from<{\n\t\t\t\tunscanned: unscanned\n\t\t\t\tgroups: init\n\t\t\t\tcapture: last[\"capture\"]\n\t\t\t\tbranches: last[\"branches\"]\n\t\t\t\tsequence: pushQuantifiable<last[\"sequence\"], last[\"root\"]>\n\t\t\t\troot: s[\"capture\"] extends CapturedGroupKind ?\n\t\t\t\t\tGroupTree<State.Group.finalize<s>, s[\"capture\"]>\n\t\t\t\t: s[\"capture\"] extends State.UnnamedCaptureKind.lookaround ? \"\"\n\t\t\t\t: // non-capturing\n\t\t\t\t\tState.Group.finalize<s>\n\t\t\t\tcaseInsensitive: last[\"caseInsensitive\"]\n\t\t\t\tflags: s[\"flags\"]\n\t\t\t}>\n\t\t:\ts.error<writeUnmatchedGroupCloseMessage<\")\", unscanned>>\n\n\texport type finalize<s extends State> =\n\t\ts[\"groups\"] extends [unknown, ...unknown[]] ?\n\t\t\tErrorMessage<writeUnclosedGroupMessage<\")\">>\n\t\t:\tfinalizeRegexOrError<\n\t\t\t\tfinalizeTree<\n\t\t\t\t\tState.Group.finalize<s>,\n\t\t\t\t\t{\n\t\t\t\t\t\tcaptures: EmptyCaptures\n\t\t\t\t\t\tnames: {}\n\t\t\t\t\t\tflags: s[\"flags\"]\n\t\t\t\t\t\terrors: []\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>\n\n\ttype finalizeRegexOrError<r extends FinalizationResult> =\n\t\tr[\"ctx\"][\"errors\"] extends [] ?\n\t\t\tapplyAnchors<r[\"pattern\"]> extends infer pattern extends string ?\n\t\t\t\t// check the negation in case pattern is a union in which some\n\t\t\t\t// branches contain invalid anchors\n\t\t\t\tcontains<pattern, StartAnchorMarker> extends false ?\n\t\t\t\t\tcontains<pattern, EndAnchorMarker> extends false ?\n\t\t\t\t\t\tRegex<pattern, finalizeContext<r[\"ctx\"]>>\n\t\t\t\t\t:\tErrorMessage<writeMidAnchorError<\"$\">>\n\t\t\t\t:\tErrorMessage<writeMidAnchorError<\"^\">>\n\t\t\t:\tnever\n\t\t:\t// if there were errors, return the first one\n\t\t\tr[\"ctx\"][\"errors\"][0]\n\n\ttype finalizeContext<ctx extends FinalizationContext> =\n\t\tctx[\"captures\"] extends EmptyCaptures ? finalizeContextWithoutCaptures<ctx>\n\t\t:\tfinalizeContextWithCaptures<{\n\t\t\t\t// re-align 1-based indexing for capture groups to 0-based for\n\t\t\t\t// external display\n\t\t\t\tcaptures: ctx[\"captures\"] extends (\n\t\t\t\t\t[IndexedCaptureOffset, ...infer rest extends IndexedCaptures]\n\t\t\t\t) ?\n\t\t\t\t\trest\n\t\t\t\t:\tnever\n\t\t\t\tnames: ctx[\"names\"]\n\t\t\t\tflags: ctx[\"flags\"]\n\t\t\t\terrors: ctx[\"errors\"]\n\t\t\t}>\n\n\ttype finalizeContextWithoutCaptures<ctx extends FinalizationContext> =\n\t\tctx[\"flags\"] extends \"\" ? {}\n\t\t:\t{\n\t\t\t\tflags: ctx[\"flags\"]\n\t\t\t}\n\n\ttype finalizeContextWithCaptures<ctx extends FinalizationContext> =\n\t\tkeyof ctx[\"names\"] extends never ?\n\t\t\tctx[\"flags\"] extends \"\" ?\n\t\t\t\t{ captures: ctx[\"captures\"] }\n\t\t\t:\t{ captures: ctx[\"captures\"]; flags: ctx[\"flags\"] }\n\t\t: ctx[\"flags\"] extends \"\" ?\n\t\t\t{\n\t\t\t\tcaptures: ctx[\"captures\"]\n\t\t\t\tnames: ctx[\"names\"]\n\t\t\t}\n\t\t:\t{\n\t\t\t\tcaptures: ctx[\"captures\"]\n\t\t\t\tnames: ctx[\"names\"]\n\t\t\t\tflags: ctx[\"flags\"]\n\t\t\t}\n}\n\nexport type RegexAst =\n\t| string\n\t| ReferenceNode\n\t| UnionTree\n\t| SequenceTree\n\t| GroupTree\n\t| QuantifierTree\n\nexport interface ReferenceNode<to extends string = string> {\n\tkind: \"reference\"\n\tto: to\n}\n\nexport declare namespace ReferenceNode {\n\texport type finalize<\n\t\tself extends ReferenceNode,\n\t\tctx extends FinalizationContext,\n\t\t// ensure `to` distributes\n\t\tto extends string = self[\"to\"]\n\t> =\n\t\tto extends NumberLiteral & keyof ctx[\"captures\"] ?\n\t\t\tctx[\"captures\"][to] extends IncompleteCaptureGroup ?\n\t\t\t\t// referencing an unclosed group is a no-op, so error\n\t\t\t\t// to help users avoid it\n\t\t\t\tFinalizationResult.error<ctx, writeIncompleteReferenceError<to>>\n\t\t\t:\tFinalizationResult.from<{\n\t\t\t\t\tpattern: inferReference<ctx[\"captures\"][to]>\n\t\t\t\t\tctx: ctx\n\t\t\t\t}>\n\t\t: to extends keyof ctx[\"names\"] ?\n\t\t\tctx[\"names\"][to] extends IncompleteCaptureGroup ?\n\t\t\t\tFinalizationResult.error<ctx, writeIncompleteReferenceError<to>>\n\t\t\t:\tFinalizationResult.from<{\n\t\t\t\t\tpattern: inferReference<ctx[\"names\"][to]>\n\t\t\t\t\tctx: ctx\n\t\t\t\t}>\n\t\t:\tFinalizationResult.error<ctx, writeUnresolvableBackreferenceMessage<to>>\n\n\ttype inferReference<to extends string | undefined> =\n\t\tto extends string ? to : \"\"\n}\n\nexport const writeIncompleteReferenceError = <ref extends string>(\n\tref: ref\n): writeIncompleteReferenceError<ref> =>\n\t`Reference to incomplete group '${ref}' has no effect`\n\nexport type writeIncompleteReferenceError<ref extends string> =\n\t`Reference to incomplete group '${ref}' has no effect`\n\nexport interface SequenceTree<ast extends RegexAst[] = RegexAst[]> {\n\tkind: \"sequence\"\n\tast: ast\n}\n\nexport declare namespace SequenceTree {\n\texport type Empty = SequenceTree<[]>\n\n\texport type finalize<\n\t\tself extends SequenceTree,\n\t\tctx extends FinalizationContext\n\t> = _finalize<self[\"ast\"], \"\", ctx>\n\n\ttype _finalize<\n\t\ttree extends unknown[],\n\t\tpattern extends string,\n\t\tctx extends FinalizationContext\n\t> =\n\t\ttree extends [infer head, ...infer tail] ?\n\t\t\tfinalizeTree<head, ctx> extends infer r ?\n\t\t\t\tr extends FinalizationResult ?\n\t\t\t\t\t// preserve the distribution from Group.finalize\n\t\t\t\t\t_finalize<tail, appendNonRedundant<pattern, r[\"pattern\"]>, r[\"ctx\"]>\n\t\t\t\t:\tnever\n\t\t\t:\tnever\n\t\t:\tFinalizationResult.from<{\n\t\t\t\tpattern: pattern\n\t\t\t\tctx: ctx\n\t\t\t}>\n}\n\nexport interface UnionTree<ast extends RegexAst[] = RegexAst[]> {\n\tkind: \"union\"\n\tast: ast\n}\n\nexport declare namespace UnionTree {\n\texport type finalize<\n\t\tself extends UnionTree,\n\t\tctx extends FinalizationContext\n\t> = _finalize<self[\"ast\"], [], ctx>\n\n\ttype FinalizedBranch = {\n\t\tpattern: string\n\t\tcaptures: IndexedCaptures\n\t\tnames: NamedCaptures\n\t}\n\n\tnamespace FinalizedBranch {\n\t\texport type from<b extends FinalizedBranch> = b\n\t}\n\n\ttype _finalize<\n\t\tastBranches extends unknown[],\n\t\tacc extends FinalizedBranch[],\n\t\tctx extends FinalizationContext\n\t> =\n\t\tastBranches extends [infer head, ...infer tail] ?\n\t\t\tfinalizeTree<head, ctx> extends infer r ?\n\t\t\t\tr extends FinalizationResult ?\n\t\t\t\t\t_finalize<tail, finalizeBranch<acc, ctx, r>, ctx>\n\t\t\t\t:\tnever\n\t\t\t:\tnever\n\t\t:\tfinalizeBranches<keyof acc, acc, ctx>\n\n\ttype finalizeBranch<\n\t\tacc extends FinalizedBranch[],\n\t\tctx extends FinalizationContext,\n\t\tr extends FinalizationResult\n\t> = [\n\t\t...acc,\n\t\tFinalizedBranch.from<{\n\t\t\tpattern: r[\"pattern\"]\n\t\t\tcaptures: finalizeBranchCaptures<acc, ctx, r>\n\t\t\t// undefined will be added to named captures as needed\n\t\t\t// by finalizeBranches since it can be done in one step\n\t\t\tnames: r[\"ctx\"][\"names\"]\n\t\t}>\n\t]\n\n\ttype finalizeBranchCaptures<\n\t\tacc extends FinalizedBranch[],\n\t\tctx extends FinalizationContext,\n\t\tr extends FinalizationResult,\n\t\tbranchCaptures extends IndexedCaptures = extractNewCaptures<\n\t\t\tctx[\"captures\"],\n\t\t\tr[\"ctx\"][\"captures\"]\n\t\t>\n\t> =\n\t\tacc extends [] ? branchCaptures\n\t\t: acc[0][\"captures\"] extends (\n\t\t\tinfer firstCaptureBranch extends IndexedCaptures\n\t\t) ?\n\t\t\tbranchCaptures extends [] ?\n\t\t\t\t{ [i in keyof firstCaptureBranch]: undefined }\n\t\t\t:\t[...{ [i in keyof firstCaptureBranch]: undefined }, ...branchCaptures]\n\t\t:\tnever\n\n\ttype finalizeBranches<\n\t\ti,\n\t\tacc extends FinalizedBranch[],\n\t\tctx extends FinalizationContext\n\t> =\n\t\ti extends keyof acc & NumberLiteral ?\n\t\t\tFinalizationResult.from<{\n\t\t\t\tpattern: acc[i][\"pattern\"]\n\t\t\t\tctx: {\n\t\t\t\t\tflags: ctx[\"flags\"]\n\t\t\t\t\tcaptures: [...ctx[\"captures\"], ...acc[i][\"captures\"]]\n\t\t\t\t\tnames: {\n\t\t\t\t\t\t[k in unionKeyOf<acc[number][\"names\"]>]: k extends (\n\t\t\t\t\t\t\tkeyof acc[i][\"names\"]\n\t\t\t\t\t\t) ?\n\t\t\t\t\t\t\tacc[i][\"names\"][k]\n\t\t\t\t\t\t:\tundefined\n\t\t\t\t\t}\n\t\t\t\t\terrors: ctx[\"errors\"]\n\t\t\t\t}\n\t\t\t}>\n\t\t:\tnever\n}\n\nexport type CapturedGroupKind = string | State.UnnamedCaptureKind.indexed\n\nexport type IncompleteCaptureGroup = noSuggest<\"incompleteCaptureGroup\">\n\nexport type IndexedCaptureOffset = noSuggest<\"indexedCaptureOffset\">\n\n/**\n * Offset captures to match 1-based indexing for references\n * (i.e so that \\1 would match the first capture group)\n */\nexport type EmptyCaptures = [IndexedCaptureOffset]\n\nexport interface GroupTree<\n\tast extends RegexAst = RegexAst,\n\tcapture extends CapturedGroupKind = CapturedGroupKind\n> {\n\tkind: \"group\"\n\tcapture: capture\n\tast: ast\n}\n\nexport declare namespace GroupTree {\n\texport type finalize<\n\t\tself extends GroupTree,\n\t\tctx extends FinalizationContext\n\t> =\n\t\tfinalizeGroupAst<self, ctx> extends infer r ?\n\t\t\t// allow the result to distribute to a particular branch\n\t\t\t// to preserve associations between groups and references\n\t\t\t// so that e.g. \"(a|b)\\\\1\" is inferred as \"aa\" | \"bb\"\n\t\t\t// as opposed to \"aa\" | \"ab\" | \"ba\" | \"bb\"\n\t\t\tr extends FinalizationResult ?\n\t\t\t\tfinalizeGroupResult<self, ctx, r>\n\t\t\t:\tnever\n\t\t:\tnever\n\n\ttype finalizeGroupAst<\n\t\tself extends GroupTree,\n\t\tctx extends FinalizationContext\n\t> = finalizeTree<\n\t\tself[\"ast\"],\n\t\tself[\"capture\"] extends string ?\n\t\t\t{\n\t\t\t\t// IncompleteCaptureGroup represents a capture group that is still being parsed\n\t\t\t\t// error on trying to reference it (will always be empty)\n\t\t\t\tcaptures: [...ctx[\"captures\"], IncompleteCaptureGroup]\n\t\t\t\tnames: ctx[\"names\"] & { [_ in self[\"capture\"]]: IncompleteCaptureGroup }\n\t\t\t\tflags: ctx[\"flags\"]\n\t\t\t\terrors: ctx[\"errors\"]\n\t\t\t}\n\t\t: self[\"capture\"] extends State.UnnamedCaptureKind.indexed ?\n\t\t\t{\n\t\t\t\tcaptures: [...ctx[\"captures\"], IncompleteCaptureGroup]\n\t\t\t\tnames: ctx[\"names\"]\n\t\t\t\tflags: ctx[\"flags\"]\n\t\t\t\terrors: ctx[\"errors\"]\n\t\t\t}\n\t\t:\tctx\n\t>\n\n\ttype finalizeGroupResult<\n\t\tself extends GroupTree,\n\t\tctx extends FinalizationContext,\n\t\tr extends FinalizationResult\n\t> = FinalizationResult.from<{\n\t\tpattern: r[\"pattern\"]\n\t\tctx: self[\"capture\"] extends string ?\n\t\t\tfinalizeNamedCapture<\n\t\t\t\tself[\"capture\"],\n\t\t\t\tctx[\"captures\"][\"length\"],\n\t\t\t\tr[\"pattern\"],\n\t\t\t\tr[\"ctx\"]\n\t\t\t>\n\t\t: self[\"capture\"] extends State.UnnamedCaptureKind.indexed ?\n\t\t\tfinalizeUnnamedCapture<ctx[\"captures\"][\"length\"], r[\"pattern\"], r[\"ctx\"]>\n\t\t:\tr[\"ctx\"]\n\t}>\n\n\ttype finalizeNamedCapture<\n\t\tname extends string,\n\t\tindex extends number,\n\t\tpattern extends string,\n\t\tctx extends FinalizationContext\n\t> = FinalizationContext.from<{\n\t\t// replace undefined (representing a group being parsed)\n\t\t// with the inferred reference\n\t\tcaptures: setIndex<ctx[\"captures\"], index, anchorsAway<pattern>>\n\t\tnames: {\n\t\t\t[k in keyof ctx[\"names\"]]: k extends name ? anchorsAway<pattern>\n\t\t\t:\tctx[\"names\"][k]\n\t\t}\n\t\tflags: ctx[\"flags\"]\n\t\terrors: ctx[\"errors\"]\n\t}>\n\n\ttype finalizeUnnamedCapture<\n\t\tindex extends number,\n\t\tpattern extends string,\n\t\tctx extends FinalizationContext\n\t> = FinalizationContext.from<{\n\t\tcaptures: setIndex<ctx[\"captures\"], index, anchorsAway<pattern>>\n\t\tnames: ctx[\"names\"]\n\t\tflags: ctx[\"flags\"]\n\t\terrors: ctx[\"errors\"]\n\t}>\n}\n\nexport interface QuantifierTree<ast extends RegexAst = RegexAst> {\n\tkind: \"quantifier\"\n\tast: ast\n\tmin: number\n\tmax: number | null\n}\n\nexport declare namespace QuantifierTree {\n\texport type finalize<\n\t\tself extends QuantifierTree,\n\t\tctx extends FinalizationContext\n\t> =\n\t\tfinalizeTree<self[\"ast\"], ctx> extends infer r extends FinalizationResult ?\n\t\t\tfinalizeQuantifierResult<self, ctx, r>\n\t\t:\tnever\n\n\ttype finalizeQuantifierResult<\n\t\tself extends QuantifierTree,\n\t\tctx extends FinalizationContext,\n\t\tr extends FinalizationResult,\n\t\tquantifiedCaptures extends IndexedCaptures = extractNewCaptures<\n\t\t\tctx[\"captures\"],\n\t\t\tr[\"ctx\"][\"captures\"]\n\t\t>\n\t> =\n\t\tself[\"min\"] extends 0 ?\n\t\t\tquantifiedCaptures extends [] ?\n\t\t\t\tfinalizeNonZeroMinQuantified<self, r>\n\t\t\t:\tfinalizeZeroMinQuantifiedWithCaptures<self, ctx, r, quantifiedCaptures>\n\t\t:\tfinalizeNonZeroMinQuantified<self, r>\n\n\ttype finalizeNonZeroMinQuantified<\n\t\tself extends QuantifierTree,\n\t\tr extends FinalizationResult\n\t> = FinalizationResult.from<{\n\t\tpattern: quantify<r[\"pattern\"], self[\"min\"], self[\"max\"]>\n\t\tctx: r[\"ctx\"]\n\t}>\n\n\ttype finalizeZeroMinQuantifiedWithCaptures<\n\t\tself extends QuantifierTree,\n\t\tctx extends FinalizationContext,\n\t\tr extends FinalizationResult,\n\t\tquantifiedCaptures extends IndexedCaptures\n\t> =\n\t\t| finalizeZeroQuantified<ctx, r, quantifiedCaptures>\n\t\t| finalizeOnePlusQuantified<self[\"max\"], r>\n\n\t// add `| undefined` to any capture groups quantified by zero\n\ttype finalizeZeroQuantified<\n\t\tctx extends FinalizationContext,\n\t\tr extends FinalizationResult,\n\t\tquantifiedCaptures extends IndexedCaptures\n\t> = FinalizationResult.from<{\n\t\tpattern: \"\"\n\t\tctx: {\n\t\t\tcaptures: [\n\t\t\t\t...ctx[\"captures\"],\n\t\t\t\t...{\n\t\t\t\t\t[i in keyof quantifiedCaptures]: undefined\n\t\t\t\t}\n\t\t\t]\n\t\t\tflags: r[\"ctx\"][\"flags\"]\n\t\t\tnames: zeroQuantifiedNames<ctx[\"names\"], r[\"ctx\"][\"names\"]>\n\t\t\terrors: r[\"ctx\"][\"errors\"]\n\t\t}\n\t}>\n\n\ttype zeroQuantifiedNames<\n\t\tbase extends NamedCaptures,\n\t\tresult extends NamedCaptures\n\t> = {\n\t\t[k in keyof result]: k extends keyof base ? result[k] : undefined\n\t} & unknown\n\n\ttype finalizeOnePlusQuantified<\n\t\tmax extends number | null,\n\t\tr extends FinalizationResult\n\t> =\n\t\tmax extends 1 ? r\n\t\t:\tFinalizationResult.from<{\n\t\t\t\t// don't include 0 since it has been inferred separately\n\t\t\t\tpattern: quantify<r[\"pattern\"], 1, max>\n\t\t\t\tctx: r[\"ctx\"]\n\t\t\t}>\n}\n\nexport type pushQuantifiable<sequence extends RegexAst, root extends RegexAst> =\n\troot extends \"\" ? sequence\n\t: sequence extends string ?\n\t\tsequence extends \"\" ? root\n\t\t: root extends string ? appendNonRedundant<sequence, root>\n\t\t: SequenceTree<[sequence, root]>\n\t: sequence extends SequenceTree ? pushToSequence<sequence, root>\n\t: SequenceTree<[sequence, root]>\n\ntype pushToSequence<sequence extends SequenceTree, root extends RegexAst> =\n\tsequence extends SequenceTree.Empty ? root\n\t: root extends SequenceTree ?\n\t\tSequenceTree<[...sequence[\"ast\"], ...root[\"ast\"]]>\n\t:\tSequenceTree<[...sequence[\"ast\"], root]>\n\ntype extractNewCaptures<\n\tbase extends IndexedCaptures,\n\tresult extends IndexedCaptures\n> =\n\tresult extends readonly [...base, ...infer elements extends IndexedCaptures] ?\n\t\telements\n\t:\t[]\n\nexport interface FinalizationContext extends Required<RegexContext> {\n\terrors: ErrorMessage[]\n}\n\nexport declare namespace FinalizationContext {\n\texport type from<ctx extends FinalizationContext> = ctx\n}\n\nexport type FinalizationResult = {\n\tpattern: string\n\tctx: FinalizationContext\n}\n\nexport declare namespace FinalizationResult {\n\texport type from<r extends FinalizationResult> = r\n\n\texport type error<\n\t\tctx extends FinalizationContext,\n\t\tmessage extends string\n\t> = from<{\n\t\tpattern: string\n\t\tctx: {\n\t\t\tcaptures: ctx[\"captures\"]\n\t\t\tnames: ctx[\"names\"]\n\t\t\tflags: ctx[\"flags\"]\n\t\t\terrors: [...ctx[\"errors\"], ErrorMessage<message>]\n\t\t}\n\t}>\n}\n\nexport type finalizeTree<tree, ctx extends FinalizationContext> =\n\ttree extends string ?\n\t\tFinalizationResult.from<{\n\t\t\tpattern: tree\n\t\t\tctx: ctx\n\t\t}>\n\t: tree extends SequenceTree ? SequenceTree.finalize<tree, ctx>\n\t: tree extends UnionTree ? UnionTree.finalize<tree, ctx>\n\t: tree extends GroupTree ? GroupTree.finalize<tree, ctx>\n\t: tree extends QuantifierTree ? QuantifierTree.finalize<tree, ctx>\n\t: tree extends ReferenceNode ? ReferenceNode.finalize<tree, ctx>\n\t: never\n\ntype applyAnchors<pattern extends string> =\n\tpattern extends `${StartAnchorMarker}${infer startStripped}` ?\n\t\tstartStripped extends `${infer bothStripped}${EndAnchorMarker}` ?\n\t\t\tbothStripped\n\t\t:\tappendNonRedundant<startStripped, string>\n\t: pattern extends `${infer endStripped}${EndAnchorMarker}` ?\n\t\tprependNonRedundant<endStripped, string>\n\t:\tprependNonRedundant<appendNonRedundant<pattern, string>, string>\n\ntype anchorsAway<pattern extends string> =\n\tpattern extends `${StartAnchorMarker}${infer startStripped}` ?\n\t\tstartStripped extends `${infer bothStripped}${EndAnchorMarker}` ?\n\t\t\tbothStripped\n\t\t:\tstartStripped\n\t: pattern extends `${infer endStripped}${EndAnchorMarker}` ? endStripped\n\t: pattern\n\ntype appendNonRedundant<base extends string, suffix extends string> =\n\tstring extends base ?\n\t\tstring extends suffix ?\n\t\t\tstring\n\t\t:\t`${base}${suffix}`\n\t: // this is not generalizable, but arkregex uses `${number}`\n\t// to represent digits, so it is valid to merge them as `${number}`.\n\t`${number}` extends base ?\n\t\t`${number}` extends suffix ?\n\t\t\t`${number}`\n\t\t:\t`${base}${suffix}`\n\t:\t`${base}${suffix}`\n\ntype prependNonRedundant<base extends string, prefix extends string> =\n\tstring extends base ?\n\t\tstring extends prefix ?\n\t\t\tstring\n\t\t:\t`${prefix}${base}`\n\t: // this is not generalizable, but arkregex uses `${number}`\n\t// to represent digits, so it is valid to merge them as `${number}`.\n\t`${number}` extends base ?\n\t\t`${number}` extends prefix ?\n\t\t\t`${number}`\n\t\t:\t`${prefix}${base}`\n\t:\t`${prefix}${base}`\n\nexport const writeMidAnchorError = <anchor extends Anchor>(\n\tanchor: anchor\n): writeMidAnchorError<anchor> => `Anchor ${anchor} may not appear mid-pattern`\n\ntype writeMidAnchorError<anchor extends Anchor> =\n\t`Anchor ${anchor} may not appear mid-pattern`\n"
  },
  {
    "path": "ark/repo/.prettierignore",
    "content": "pnpm-lock.yaml\n"
  },
  {
    "path": "ark/repo/__tests__/standardSchema.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { type, type Out, type Type } from \"arktype\"\nimport z from \"zod\"\n\ncontextualize(() => {\n\tit(\"accepts standard schema at property\", () => {\n\t\tconst Address = z.object({\n\t\t\tstreetNumber: z.number(),\n\t\t\tstreetName: z.string()\n\t\t})\n\n\t\tconst TFromZod = type({\n\t\t\tname: \"string\",\n\t\t\tage: \"number\",\n\t\t\taddress: Address\n\t\t})\n\n\t\tattest<\n\t\t\tType<{\n\t\t\t\tname: string\n\t\t\t\tage: number\n\t\t\t\taddress: {\n\t\t\t\t\tstreetNumber: number\n\t\t\t\t\tstreetName: string\n\t\t\t\t}\n\t\t\t}>\n\t\t>(TFromZod)\n\n\t\tconst validInput = {\n\t\t\tname: \"David\",\n\t\t\tage: 32,\n\t\t\taddress: {\n\t\t\t\tstreetNumber: 449,\n\t\t\t\tstreetName: \"Canal\"\n\t\t\t}\n\t\t}\n\n\t\tconst valid = TFromZod(validInput)\n\n\t\tattest(valid).equals(validInput)\n\n\t\tconst invalid = TFromZod({\n\t\t\tname: 5,\n\t\t\tage: \"500\",\n\t\t\taddress: {\n\t\t\t\tstreetNumber: \"449\"\n\t\t\t}\n\t\t})\n\n\t\tattest(invalid).instanceOf(type.errors)\n\t\tattest(invalid.toString()).snap(`age must be a number (was a string)\nname must be a string (was a number)\naddress.streetNumber invalid input: expected number, received string\naddress.streetName invalid input: expected string, received undefined`)\n\t})\n\n\tit(\"accepts zod schema passed directly to type\", () => {\n\t\tconst UserSchema = z.object({\n\t\t\tid: z.number(),\n\t\t\tusername: z.string(),\n\t\t\temail: z.email(),\n\t\t\tisActive: z.boolean()\n\t\t})\n\n\t\tconst TFromZod = type(UserSchema)\n\n\t\tattest<\n\t\t\tType<{\n\t\t\t\tid: number\n\t\t\t\tusername: string\n\t\t\t\temail: string\n\t\t\t\tisActive: boolean\n\t\t\t}>\n\t\t>(TFromZod)\n\n\t\tconst validInput: typeof TFromZod.infer = {\n\t\t\tid: 123,\n\t\t\tusername: \"john_doe\",\n\t\t\temail: \"john@example.com\",\n\t\t\tisActive: true\n\t\t}\n\n\t\tconst valid = TFromZod(validInput)\n\n\t\tattest(valid).equals(validInput)\n\n\t\tconst invalid = TFromZod({\n\t\t\tid: \"123\",\n\t\t\tusername: 42,\n\t\t\temail: \"not-an-email\",\n\t\t\tisActive: \"yes\"\n\t\t})\n\n\t\tattest(invalid).instanceOf(type.errors)\n\t\tattest(invalid.toString())\n\t\t\t.snap(`id invalid input: expected number, received string\nusername invalid input: expected string, received number\nemail invalid email address\nisActive invalid input: expected boolean, received string`)\n\t})\n\n\tit(\"accepts zod schema with transformation\", () => {\n\t\tconst ProductSchema = z.object({\n\t\t\tname: z.string().trim().toLowerCase(),\n\t\t\tprice: z.string().transform(val => parseFloat(val)),\n\t\t\tcategory: z.enum([\"electronics\", \"books\", \"clothing\"]),\n\t\t\tinStock: z\n\t\t\t\t.union([z.boolean(), z.string()])\n\t\t\t\t.transform(val => (typeof val === \"string\" ? val === \"true\" : val))\n\t\t})\n\n\t\tconst TFromZod = type(ProductSchema)\n\n\t\tattest<\n\t\t\tType<\n\t\t\t\t(In: {\n\t\t\t\t\tname: string\n\t\t\t\t\tprice: string\n\t\t\t\t\tcategory: \"electronics\" | \"books\" | \"clothing\"\n\t\t\t\t\tinStock: string | boolean\n\t\t\t\t}) => Out<{\n\t\t\t\t\tname: string\n\t\t\t\t\tprice: number\n\t\t\t\t\tcategory: \"electronics\" | \"books\" | \"clothing\"\n\t\t\t\t\tinStock: boolean\n\t\t\t\t}>\n\t\t\t>\n\t\t>(TFromZod)\n\n\t\tconst validInput: typeof TFromZod.inferIn = {\n\t\t\tname: \"  iPhone 15  \",\n\t\t\tprice: \"999.99\",\n\t\t\tcategory: \"electronics\",\n\t\t\tinStock: \"true\"\n\t\t}\n\n\t\tconst valid = TFromZod(validInput)\n\n\t\tattest(valid).equals({\n\t\t\tname: \"iphone 15\",\n\t\t\tprice: 999.99,\n\t\t\tcategory: \"electronics\",\n\t\t\tinStock: true\n\t\t})\n\n\t\tconst invalid = TFromZod({\n\t\t\tname: 123,\n\t\t\tprice: \"not-a-number\",\n\t\t\tcategory: \"furniture\",\n\t\t\tinStock: \"maybe\"\n\t\t})\n\n\t\tattest(invalid).instanceOf(type.errors)\n\t\tattest(invalid.toString())\n\t\t\t.snap(`name invalid input: expected string, received number\ncategory invalid option: expected one of \"electronics\"|\"books\"|\"clothing\"`)\n\t})\n})\n"
  },
  {
    "path": "ark/repo/build.ts",
    "content": "import { copyFileSync } from \"node:fs\"\nimport { join } from \"node:path\"\n// eslint-disable-next-line @typescript-eslint/no-restricted-imports\nimport {\n\tfromCwd,\n\tfromHere,\n\treadPackageJson,\n\trmRf,\n\tshell,\n\twriteJson\n} from \"../fs/index.ts\"\nimport { dtsGen } from \"./dtsGen.ts\"\nimport { jsDocGen } from \"./jsdocGen.ts\"\nimport { packagesByScope } from \"./shared.ts\"\n\nconst buildKind =\n\tprocess.argv.includes(\"--cjs\") || process.env.ARKTYPE_CJS ? \"cjs\" : \"esm\"\nconst outDir = fromCwd(\"out\")\nconst packageName = readPackageJson(process.cwd()).name\n\nconst buildCurrentProject = () =>\n\tshell(\n\t\t`node ${fromHere(\"node_modules\", \"typescript\", \"lib\", \"tsc.js\")} --project tsconfig.build.json`\n\t)\n\ntry {\n\trmRf(outDir)\n\trmRf(\"tsconfig.build.json\")\n\tcopyFileSync(`../repo/tsconfig.${buildKind}.json`, \"tsconfig.build.json\")\n\tbuildCurrentProject()\n\trmRf(\"tsconfig.build.json\")\n\tcopyFileSync(`../repo/tsconfig.dts.json`, \"tsconfig.build.json\")\n\tbuildCurrentProject()\n\tif (buildKind === \"cjs\")\n\t\twriteJson(join(outDir, \"package.json\"), { type: \"commonjs\" })\n\tif (packageName === \"arktype\") {\n\t\tjsDocGen()\n\t\tdtsGen()\n\t} else if (packageName in packagesByScope.type.json.dependencies!) dtsGen()\n} finally {\n\trmRf(\"tsconfig.build.json\")\n}\n"
  },
  {
    "path": "ark/repo/config.ts",
    "content": "// eslint-disable-next-line @typescript-eslint/no-restricted-imports\nimport { configure } from \"arktype/config\"\n\nconfigure({})\n"
  },
  {
    "path": "ark/repo/dtsGen.ts",
    "content": "import { basename, join } from \"node:path\"\nimport {\n\tbootstrapFs,\n\tpackagesByScope,\n\trepoDirs,\n\ttype PackageScope\n} from \"./shared.ts\"\n\nconst { readFile, shell, rmSync, writeFile } = bootstrapFs\n\nexport const dtsGen = () => {\n\tconst pkgScope = basename(process.cwd()) as PackageScope\n\tconst pkg = packagesByScope[pkgScope]\n\n\tconsole.log(`✍️ Generating DTS bundle for ${pkg.name}...`)\n\n\tshell(\"pnpm tsup index.ts --dts-only --dts-resolve --format esm --out-dir .\")\n\n\tconst expectedDtsBundlePath = join(pkg.path, \"index.d.ts\")\n\n\tconst rawDts = readFile(expectedDtsBundlePath)\n\trmSync(expectedDtsBundlePath)\n\n\tconst bundleOutputPath = join(\n\t\trepoDirs.docs,\n\t\t\"components\",\n\t\t\"dts\",\n\t\t`${pkgScope}.ts`\n\t)\n\n\tconst rawDtsModule = `declare module \"${pkg.name}\" {\n    ${rawDts}\n}`\n\n\tconst rawFileContents = `/** THIS FILE IS AUTOGENERATED FROM ark/repo/dtsGen.ts **/\n// prettier-ignore\nexport const ${pkg.scope}Dts = ${JSON.stringify(rawDtsModule)}\\n`\n\n\t// fix some tsup confusion\n\tconst fileContents = rawFileContents.replace(\n\t\t/(Omit|Exclude|Extract|Record)\\$1/g,\n\t\t\"$1\"\n\t)\n\n\twriteFile(bundleOutputPath, fileContents)\n\n\tconsole.log(`📚 Successfully wrote DTS bundle for ${pkg.name}!`)\n}\n"
  },
  {
    "path": "ark/repo/jsdocGen.ts",
    "content": "import { existsSync } from \"node:fs\"\nimport { join } from \"node:path\"\nimport {\n\tProject,\n\tSyntaxKind,\n\ttype JSDoc,\n\ttype JSDocableNode,\n\ttype Node,\n\ttype SourceFile\n} from \"ts-morph\"\nimport ts from \"typescript\"\nimport { bootstrapFs, bootstrapUtil, repoDirs } from \"./shared.ts\"\n\nconst { flatMorph, throwInternalError, emojiToUnicode } = bootstrapUtil\nconst { writeFile } = bootstrapFs\n\nconst inheritDocToken = \"@inheritDoc\"\n\n// used to delimit notes in JSDoc.\n// add to the list if you need new ones!\nconst noteEmoji = [\"✅\", \"🥸\", \"⚠️\", \"🔗\"]\n\nconst noteEmojiUnicode = noteEmoji.map(emojiToUnicode)\nconst noteDelimiterRegex = new RegExp(`(?=\\\\n\\\\s*[-${noteEmojiUnicode}])`, \"u\")\n\nconst replacedDecorators = {\n\t\"@typeonly\": \"🥸 inference-only property that will be `undefined` at runtime\",\n\t\"@typenoop\": \"🥸 inference-only function that does nothing runtime\",\n\t\"@chainedDefinition\":\n\t\t\"⚠️ unlike most other methods, this creates a definition rather than a Type (read why)\",\n\t\"@predicateCast\":\n\t\t\"🥸 {@link https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates | Type predicates} can be used as casts\",\n\t\"@ignoresMeta\":\n\t\t\"✅ ignores associated {@link meta}, which does not affect the set of allowed values\",\n\t\"@propString\":\n\t\t\"✅ uses `.access` {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors#dot_notation | where allowed by JS}, falling back to `[indexAccess]`\\n\" +\n\t\t`@example\nconst path = [\"key1\", Symbol(\"key2\"), \"key3\", 4, \"~key5\"]\nconst propString = 'key1[Symbol(key2)].key3[4][\"~key5\"]'`\n} as const\n\nconst typeBuildDir = join(repoDirs.arkDir, \"type\", \"out\")\nconst typeBuildGlob = `${typeBuildDir}/**/*.d.ts`\nconst schemaBuildDir = join(repoDirs.arkDir, \"schema\", \"out\")\nconst schemaBuildGlob = `${schemaBuildDir}/**/*.d.ts`\nconst docsComponentsDir = join(repoDirs.docs, \"components\")\nconst apiDataPath = join(docsComponentsDir, \"apiData.ts\")\n\nlet updateCount = 0\nlet apiDocsByGroup: ApiDocsByGroup = {} as ApiDocsByGroup\n\nexport const jsDocGen = () => {\n\tconst project = createProject()\n\n\tconst sourceFiles = project.getSourceFiles()\n\n\tconsole.log(\n\t\t`✍️ Generating JSDoc for ${sourceFiles.length} files in ${typeBuildDir} and ${schemaBuildDir}...`\n\t)\n\n\tfor (const file of project.getSourceFiles()) docgenForFile(file)\n\n\tproject.saveSync()\n\n\tconst docs = getAllJsDoc(project)\n\n\tapiDocsByGroup = flatMorph(docs, (i, doc) => {\n\t\tconst block = parseBlock(doc)\n\n\t\tif (!block) return []\n\n\t\treturn [{ group: block.group }, block]\n\t})\n\n\twriteApiDataFile()\n\n\tconsole.log(\n\t\t`📚 Successfully updated ${updateCount} JSDoc comments on your build output.`\n\t)\n}\n\nexport const writeApiDataFile = () => {\n\twriteFile(\n\t\tapiDataPath,\n\t\t`import type { ApiDocsByGroup } from \"../../repo/jsdocGen.ts\"\n\n/** THIS FILE IS AUTOGENERATED FROM ark/repo/jsdocGen.ts **/\n// prettier-ignore\nexport const apiDocsByGroup: ApiDocsByGroup = ${JSON.stringify(apiDocsByGroup, null, 4)}\n`\n\t)\n}\n\nexport const getAllJsDoc = (project: Project) => {\n\tconst sourceFiles = project.getSourceFiles()\n\n\treturn sourceFiles.flatMap(file =>\n\t\tfile.getDescendantsOfKind(SyntaxKind.JSDoc)\n\t)\n}\n\nexport type ApiGroup = \"Type\" | \"Traversal\"\n\nexport type JsDocComment = ReturnType<JSDoc[\"getComment\"]>\n\nexport type RawJsDocPart = Extract<\n\tJsDocComment,\n\treadonly unknown[]\n>[number] & {}\n\nexport type ParsedJsDocPart =\n\t| { kind: \"text\"; value: string }\n\t| { kind: \"noteStart\"; value: string }\n\t| { kind: \"reference\"; value: string }\n\t| { kind: \"link\"; value: string; url: string }\n\nexport type ApiDocsByGroup = {\n\treadonly [k in ApiGroup]: readonly ParsedJsDocBlock[]\n}\n\nexport type ParsedJsDocBlock = {\n\tgroup: ApiGroup\n\tname: string\n\tsummary: ParsedJsDocPart[]\n\tnotes: ParsedJsDocPart[][]\n\texample?: string\n\texperimental?: ParsedJsDocPart[]\n}\n\nconst createProject = () => {\n\tconst project = new Project()\n\n\tassertBuildDirExists(typeBuildDir)\n\tassertBuildDirExists(schemaBuildDir)\n\n\tproject.addSourceFilesAtPaths(typeBuildGlob)\n\tproject.addSourceFilesAtPaths(schemaBuildGlob)\n\n\treturn project\n}\n\nconst assertBuildDirExists = (path: string) => {\n\tif (!existsSync(path)) {\n\t\tthrow new Error(\n\t\t\t`jsDocGen rewrites ${path} but that directory doesn't exist. Did you run \"pnpm build\" there first?`\n\t\t)\n\t}\n}\n\nconst extractNameAndGroup = (\n\tdoc: JSDoc\n): { name: string; group: ApiGroup } | undefined => {\n\tconst name = doc.getNextSiblingIfKind(SyntaxKind.Identifier)?.getText()\n\tif (!name) return undefined\n\n\tconst filePath = doc.getSourceFile().getFilePath()\n\tlet group: ApiGroup\n\tif (filePath.includes(\"variants\")) group = \"Type\"\n\telse if (filePath.endsWith(\"traversal.d.ts\")) group = \"Traversal\"\n\telse return undefined\n\n\treturn { name, group }\n}\n\nconst organizeDocParts = (\n\tallParts: ParsedJsDocPart[]\n): {\n\tsummary: ParsedJsDocPart[]\n\tnotes: ParsedJsDocPart[][]\n} => {\n\tconst summary: ParsedJsDocPart[] = []\n\tconst notes: ParsedJsDocPart[][] = []\n\n\tif (allParts[0]?.kind === \"text\") {\n\t\tallParts[0].value = allParts[0].value.replace(/^#+\\s*/, \"\")\n\t\tif (allParts[0].value === \"\") allParts.shift()\n\t}\n\n\tfor (const part of allParts) {\n\t\tif (part.kind === \"noteStart\") notes.push(part.value ? [part] : [])\n\t\telse if (part.value === \"\") continue\n\t\telse if (notes.length) notes[notes.length - 1]!.push(part)\n\t\telse summary.push(part)\n\t}\n\n\treturn { summary, notes }\n}\n\nconst parseBlock = (doc: JSDoc): ParsedJsDocBlock | undefined => {\n\tconst nameAndGroup = extractNameAndGroup(doc)\n\tif (!nameAndGroup) return undefined\n\n\tconst { name, group } = nameAndGroup\n\n\tif (!doc.getInnerText().trim().startsWith(\"#\")) return undefined\n\n\tconst tags = doc.getTags()\n\tconst rootComment = doc.getComment()\n\n\tif (!rootComment)\n\t\treturn throwInternalError(`Expected root comment for ${group}/${name}`)\n\n\tconst allParts: ParsedJsDocPart[] =\n\t\ttypeof rootComment === \"string\" ?\n\t\t\tparseJsDocText(rootComment)\n\t\t:\trootComment.filter(_ => !!_).flatMap(parseJsDocPart)\n\n\tconst { summary, notes } = organizeDocParts(allParts)\n\n\tconst result: ParsedJsDocBlock = {\n\t\tgroup,\n\t\tname,\n\t\tsummary,\n\t\tnotes\n\t}\n\n\tconst example = tags.find(t => t.getTagName() === \"example\")?.getCommentText()\n\tif (example) result.example = example\n\n\tconst experimentalTag = tags.find(t => t.getTagName() === \"experimental\")\n\tif (experimentalTag)\n\t\tresult.experimental = parseJsDocText(experimentalTag.getCommentText())\n\n\treturn result\n}\n\nconst parseJsDocPart = (part: RawJsDocPart): ParsedJsDocPart[] => {\n\tswitch (part.getKindName()) {\n\t\tcase \"JSDocText\":\n\t\t\treturn parseJsDocText(part.compilerNode.text)\n\t\tcase \"JSDocLink\":\n\t\t\treturn [parseJsDocLink(part)]\n\t\tdefault:\n\t\t\treturn throwInternalError(\n\t\t\t\t`Unsupported JSDoc part kind ${part.getKindName()} at position ${part.getPos()} in ${part.getSourceFile().getFilePath()}`\n\t\t\t)\n\t}\n}\n\nconst parseJsDocText = (text: string | undefined): ParsedJsDocPart[] => {\n\tif (!text) return []\n\tconst sections = text.split(noteDelimiterRegex)\n\treturn sections.map((sectionText, i) => ({\n\t\tkind: i === 0 ? \"text\" : \"noteStart\",\n\t\tvalue: sectionText.trim()\n\t}))\n}\n\nconst describedLinkRegex = /{@link\\s+(https?:\\/\\/[^\\s|}]+)(?:\\s*\\|\\s*([^}]*))?}/\n\nconst parseJsDocLink = (part: RawJsDocPart): ParsedJsDocPart => {\n\tconst linkText = part.getText()\n\tconst match = describedLinkRegex.exec(linkText)\n\tif (match) {\n\t\tconst url = match[1].trim()\n\t\tconst value = match[2]?.trim() || url\n\t\treturn { kind: \"link\", url, value }\n\t}\n\n\tconst referencedName = part\n\t\t.getChildren()\n\t\t.find(\n\t\t\tchild =>\n\t\t\t\tchild.isKind(SyntaxKind.Identifier) ||\n\t\t\t\tchild.isKind(SyntaxKind.QualifiedName)\n\t\t)\n\t\t?.getText()\n\n\tif (!referencedName) {\n\t\treturn throwInternalError(\n\t\t\t`Unable to parse referenced name from ${part.getText()}`\n\t\t)\n\t}\n\n\treturn {\n\t\tkind: \"reference\",\n\t\tvalue: referencedName\n\t}\n}\n\ntype MatchContext = {\n\tmatchedJsDoc: JSDoc\n\tupdateJsDoc: (text: string) => void\n\tinheritDocsSource: string | undefined\n}\n\nconst docgenForFile = (sourceFile: SourceFile) => {\n\tconst path = sourceFile.getFilePath()\n\n\tconst jsDocNodes = sourceFile.getDescendantsOfKind(SyntaxKind.JSDoc)\n\n\tconst matchContexts: MatchContext[] = jsDocNodes.flatMap(jsDoc => {\n\t\tconst text = jsDoc.getText()\n\n\t\tconst inheritDocsSource = extractInheritDocName(path, text)\n\n\t\tif (\n\t\t\t!inheritDocsSource &&\n\t\t\t!Object.keys(replacedDecorators).some(k => text.includes(k))\n\t\t)\n\t\t\treturn []\n\n\t\treturn {\n\t\t\tmatchedJsDoc: jsDoc,\n\t\t\tinheritDocsSource,\n\t\t\tupdateJsDoc: text => {\n\t\t\t\tconst parent = jsDoc.getParent() as JSDocableNode\n\n\t\t\t\t// replace the original JSDoc node in the AST with a new one\n\t\t\t\t// created from updatedContents\n\t\t\t\tjsDoc.remove()\n\t\t\t\tparent.addJsDoc(text)\n\n\t\t\t\tupdateCount++\n\t\t\t}\n\t\t}\n\t})\n\n\tfor (const ctx of matchContexts) {\n\t\tconst inheritedDocs = findInheritedDocs(sourceFile, ctx)\n\n\t\tlet updatedContents = ctx.matchedJsDoc.getInnerText()\n\n\t\tif (inheritedDocs)\n\t\t\tupdatedContents = `${inheritedDocs.originalSummary}\\n${inheritedDocs.inheritedDescription}`\n\n\t\tupdatedContents = Object.entries(replacedDecorators).reduce(\n\t\t\t(contents, [decorator, message]) => contents.replace(decorator, message),\n\t\t\tupdatedContents\n\t\t)\n\n\t\tctx.updateJsDoc(updatedContents)\n\t}\n}\n\nconst findInheritedDocs = (\n\tsourceFile: SourceFile,\n\t{ inheritDocsSource, matchedJsDoc }: MatchContext\n) => {\n\tif (!inheritDocsSource) return\n\n\tconst sourceDeclaration = sourceFile\n\t\t.getDescendantsOfKind(ts.SyntaxKind.Identifier as never)\n\t\t.find((i): i is any => i.getText() === inheritDocsSource)\n\t\t?.getDefinitions()[0]\n\t\t.getDeclarationNode()\n\n\tif (!sourceDeclaration || !canHaveJsDoc(sourceDeclaration)) return\n\n\tconst matchedDescription = matchedJsDoc.getDescription()\n\n\tconst inheritedDescription = sourceDeclaration.getJsDocs()[0].getDescription()\n\n\tconst originalSummary = matchedDescription\n\t\t.slice(0, matchedDescription.indexOf(\"{\"))\n\t\t.trim()\n\n\treturn {\n\t\toriginalSummary,\n\t\tinheritedDescription\n\t}\n}\n\nconst extractInheritDocName = (\n\tpath: string,\n\ttext: string\n): string | undefined => {\n\tconst inheritDocTokenIndex = text.indexOf(inheritDocToken)\n\n\tif (inheritDocTokenIndex === -1) return\n\n\tconst prefix = text.slice(0, inheritDocTokenIndex)\n\n\tconst openBraceIndex = prefix.trimEnd().length - 1\n\n\tif (text[openBraceIndex] !== \"{\") {\n\t\tthrowJsDocgenParseError(\n\t\t\tpath,\n\t\t\ttext,\n\t\t\t` Expected '{' before @inheritDoc but got '${text[openBraceIndex]}'`\n\t\t)\n\t}\n\n\tconst openTagEndIndex = inheritDocTokenIndex + inheritDocToken.length\n\n\tconst textFollowingOpenTag = text.slice(openTagEndIndex)\n\n\tconst innerTagLength = textFollowingOpenTag.indexOf(\"}\")\n\n\tif (innerTagLength === -1) {\n\t\tthrowJsDocgenParseError(\n\t\t\tpath,\n\t\t\ttext,\n\t\t\t`Expected '}' after @inheritDoc but got '${textFollowingOpenTag[0]}'`\n\t\t)\n\t}\n\n\tconst sourceName = textFollowingOpenTag.slice(0, innerTagLength).trim()\n\n\treturn sourceName\n}\n\nconst canHaveJsDoc = (node: Node): node is Node & JSDocableNode =>\n\t\"addJsDoc\" in node\n\nconst throwJsDocgenParseError = (\n\tpath: string,\n\tcommentText: string,\n\tmessage: string\n): never => {\n\tthrow new Error(\n\t\t`jsDocGen ParseError in ${path}: ${message}\\nComment text: ${commentText}`\n\t)\n}\n"
  },
  {
    "path": "ark/repo/mocha.globalSetup.ts",
    "content": "import { cleanup, setup } from \"@ark/attest\"\n\nprocess.env.TZ = \"America/New_York\"\n\nexport const mochaGlobalSetup = (): typeof cleanup =>\n\tsetup({\n\t\ttypeToStringFormat: {\n\t\t\tuseTabs: true\n\t\t}\n\t})\n\nexport const mochaGlobalTeardown = cleanup\n"
  },
  {
    "path": "ark/repo/mocha.package.jsonc",
    "content": "// This is the per-package config for running mocha tests without including\n// context from the entire workspace.\n\n// Other than require which has its relative path changed, it should be identical\n// to the repo root's mocha config from the root package.json\n\n// IF YOU UPDATE THE MOCHA CONFIG HERE, PLEASE ALSO UPDATE package.json/mocha AND .vscode/settings.json\n{\n\t\"spec\": [\"__tests__/*.test.*\"],\n\t\"ignore\": \"node_modules/**/*\",\n\t\"node-option\": [\"conditions=ark-ts\", \"import=tsx\"],\n\t\"require\": \"../repo/mocha.globalSetup.ts\"\n}\n"
  },
  {
    "path": "ark/repo/nodeOptions.js",
    "content": "// @ts-check\n\nconst [major, minor] = process.version.replace(\"v\", \"\").split(\".\").map(Number)\n\nconst versionedFlags =\n\tmajor > 22 || (major === 22 && minor >= 7) ?\n\t\t\"--experimental-transform-types --no-warnings\"\n\t:\t(console.log(\n\t\t\t\"--experimental-transform-types requires Node >= 22.7.0, falling back to tsx...\"\n\t\t),\n\t\t\"--import tsx\")\n\nexport const nodeDevOptions = `${process.env.NODE_OPTIONS ?? \"\"} --conditions ark-ts ${versionedFlags}`\n\nexport const addNodeDevOptions = extraOpts =>\n\t(process.env.NODE_OPTIONS = `${nodeDevOptions} ${extraOpts ?? \"\"}`)\n"
  },
  {
    "path": "ark/repo/package.json",
    "content": "{\n\t\"name\": \"@ark/repo\",\n\t\"private\": true,\n\t\"type\": \"module\",\n\t\"license\": \"MIT\",\n\t\"dependencies\": {\n\t\t\"@ark/attest\": \"link:../attest\",\n\t\t\"@ark/fs\": \"workspace:*\",\n\t\t\"arkenv\": \"0.7.3\",\n\t\t\"arktype\": \"workspace:*\",\n\t\t\"arkregex\": \"workspace:*\",\n\t\t\"ts-morph\": \"27.0.2\",\n\t\t\"ts-pattern\": \"5.8.0\",\n\t\t\"type-fest\": \"5.1.0\",\n\t\t\"typescript\": \"catalog:\",\n\t\t\"valibot\": \"1.1.0\",\n\t\t\"zod\": \"4.1.12\"\n\t},\n\t\"scripts\": {\n\t\t\"build\": \"echo No build required!\"\n\t},\n\t\"bin\": {\n\t\t\"ts\": \"./ts.js\"\n\t}\n}\n"
  },
  {
    "path": "ark/repo/patchC8.cjs",
    "content": "/* eslint-disable @typescript-eslint/no-var-requires */\n// Patch the c8 ignore comment parser to ignore internal errors\nconst c8Paths = require.resolve(\"c8\")\nconst covSourcePath = require.resolve(\"v8-to-istanbul/lib/source\", {\n\tpaths: [c8Paths]\n})\nconst CovSource = require(covSourcePath)\n\n// Wrap the function found here:\n// https://github.com/istanbuljs/v8-to-istanbul/blob/fca5e6a9e6ef38a9cdc3a178d5a6cf9ef82e6cab/lib/source.js#L53\nconst original = CovSource.prototype._parseIgnore\nif (!original) {\n\tthrow new Error(\n\t\t`Failed to patch c8: unable to find the _parseIgnore function.`\n\t)\n}\n\nlet inThrowInternalCall = false\nconst stack = []\nconst throwInternalRegex = /throwInternal.*\\(/\n\nCovSource.prototype._parseIgnore = lineStr => {\n\tif (throwInternalRegex.test(lineStr)) {\n\t\tinThrowInternalCall = true\n\t}\n\tif (inThrowInternalCall) {\n\t\tif (isBalanced(lineStr)) {\n\t\t\tinThrowInternalCall = false\n\t\t}\n\t\treturn { count: 1 }\n\t} else {\n\t\treturn original(lineStr)\n\t}\n}\n\nconst isBalanced = lineStr => {\n\tconst filteredMatchers = lineStr\n\t\t.split(\" \")\n\t\t.filter(\n\t\t\tsection =>\n\t\t\t\tthrowInternalRegex.test(section) |\n\t\t\t\tsection.includes(\"(\") |\n\t\t\t\tsection.includes(\")\") |\n\t\t\t\tfalse\n\t\t)\n\n\tfor (let match of filteredMatchers) {\n\t\tfor (let position = 0; position < match.length; position++) {\n\t\t\tconst section = match[position]\n\t\t\tfor (let char of section) {\n\t\t\t\tif (char === \"(\") {\n\t\t\t\t\tstack.push(char)\n\t\t\t\t} else if (char === \")\") {\n\t\t\t\t\tstack.pop()\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn !stack.length\n}\n"
  },
  {
    "path": "ark/repo/publish.ts",
    "content": "import { getShellOutput, rewriteJson, shell } from \"@ark/fs\"\nimport { packages, type ArkPackage } from \"./shared.ts\"\n\nconst tagsToPublish: string[] = []\n\nconst existingTags = getShellOutput(\"git tag\").split(\"\\n\")\n\nconst publishPackage = (pkg: ArkPackage, alias?: string) => {\n\tconst tagName = `${alias ?? pkg.name}@${pkg.version}`\n\n\tif (!existingTags.includes(tagName)) {\n\t\tif (alias) rewritePackageJsonName(pkg.packageJsonPath, alias)\n\n\t\tshell(`git tag ${tagName}`)\n\t\ttagsToPublish.push(tagName)\n\t\tshell(\"pnpm publish --no-git-checks\", { cwd: pkg.path })\n\n\t\tif (alias) rewritePackageJsonName(pkg.packageJsonPath, pkg.name)\n\t}\n}\n\nconst rewritePackageJsonName = (path: string, alias: string) =>\n\trewriteJson(path, data => ({ ...data, name: alias }))\n\nfor (const pkg of packages) {\n\t// primary name (either arktype, arkregex or @ark/*)\n\tpublishPackage(pkg)\n\n\t// scoped alias for primary entry point\n\tif (pkg.scope === \"type\") publishPackage(pkg, \"@ark/type\")\n\tif (pkg.scope === \"regex\") publishPackage(pkg, \"@ark/regex\")\n\n\t// alias for original @arktype/ scope\n\tpublishPackage(pkg, `@arktype/${pkg.scope}`)\n}\n\nshell(\"git push --tags\")\n\nfor (const tagName of tagsToPublish)\n\tshell(`gh release create ${tagName} --latest`)\n"
  },
  {
    "path": "ark/repo/scratch/fn.ts",
    "content": "// const LegacyZodSchema = z.object({\n// \tstreetNumber: z.number(),\n// \tstreetName: z.string(),\n// \tcity: z.string(),\n// \tstate: z.string()\n// })\n\n// const User = type({\n// \tname: \"string\",\n// \tage: v.number(),\n// \taddress: LegacyZodSchema\n// })\n\n// const valid = User({ foo: \"foo\" })\n// const invalid = User({ foo: 5 })\n\n// const getLength = fn(\n// \t\"string\",\n// \t\":\",\n// \t\"number\"\n// )(s => s.length).describe(\"get the length of a string\")\n\n// const getLength = fn(\n// \t\"string\",\n// \t\":\",\n// \t\"number\"\n// )(s => s.length).configure({\n// \tname: \"getLength\",\n// \tdescription: \"get the length of a string\"\n// })\n\n// const getLength = fn(\"string\", \":\", \"number\").describe(\n// \t\"get the length of a string\"\n// )(s => s.length)\n\n// const getLength = fn(\"string\", \":\", \"number\").configure({\n// \tname: \"getLength\",\n// \tdescription: \"get the length of a string\"\n// })(s => s.length)\n\n// const getLength = fn(\"string\", \":\", \"number\")(\"get the length of a string\")(\n// \ts => s.length\n// )\n\n// const getLength = fn(\n// \t\"string\",\n// \t\":\",\n// \t\"number\"\n// )({\n// \tname: \"getLength\",\n// \tdescription: \"get the length of a string\"\n// })(s => s.length)\n\n// const getLength = fn.getLength(\n// \t\"string\",\n// \t\":\",\n// \t\"number\"\n// )(\"get the length of a string\")(s => s.length)\n\n// const getLength = fn.getLength(\"string\", \":\", \"number\")(s => s.length)\n\n// const getLength = fn.getLength(\"get the length of the string\")(\n// \t\"string\",\n// \t\":\",\n// \t\"number\"\n// )(s => s.length)\n\n// const getLength = fn.getLength(\"get the length of the string\")(\n// \t\"string\",\n// \t\":\",\n// \t\"number\"\n// )(s => s.length)\n\n// const getLength = fn.getLength({\n// \tdescription: \"get the length of the string\",\n// \ttitle: \"Get Length\"\n// })(\n// \t\"string\",\n// \t\":\",\n// \t\"number\"\n// )(s => s.length)\n\n// const getLength = fn.named(\"getLength\", \"get length of the string\")(\n// \t\"string\",\n// \t\":\",\n// \t\"number\"\n// )(s => s.length)\n\n// const getLength = fn[\"\\\\apply\"](\"get the length of the string\")(\n// \t\"string\",\n// \t\":\",\n// \t\"number\"\n// )(s => s.length)\n"
  },
  {
    "path": "ark/repo/scratch/matchComparison.bench.ts",
    "content": "import { bench } from \"@ark/attest\"\nimport { match } from \"arktype\"\nimport { match as tsPatternMatch } from \"ts-pattern\"\n\nconst arkMatch3 = match\n\t.case(\"31\", n => `${n}` as const)\n\t.case(\"32\", n => `${n}` as const)\n\t.case(\"33\", n => `${n}` as const)\n\t.default(\"assert\")\n\nconst tsPatternMatch3 = (n: 31 | 32 | 33) =>\n\ttsPatternMatch(n)\n\t\t.with(31, n => `${n}`)\n\t\t.with(32, n => `${n}`)\n\t\t.with(33, n => `${n}`)\n\t\t.exhaustive()\n\nbench(\"case(3, invoke)\", () => {\n\tarkMatch3(31)\n\tarkMatch3(32)\n\tarkMatch3(33)\n}).mean([832.71, \"ns\"])\n\nbench(\"ts-pattern case(3, invoke)\", () => {\n\ttsPatternMatch3(31)\n\ttsPatternMatch3(32)\n\ttsPatternMatch3(33)\n}).mean([384.92, \"ns\"])\n\nconst arkMatch10 = match\n\t.case(\"0n\", n => `${n}` as const)\n\t.case(\"1n\", n => `${n}` as const)\n\t.case(\"2n\", n => `${n}` as const)\n\t.case(\"3n\", n => `${n}` as const)\n\t.case(\"4n\", n => `${n}` as const)\n\t.case(\"5n\", n => `${n}` as const)\n\t.case(\"6n\", n => `${n}` as const)\n\t.case(\"7n\", n => `${n}` as const)\n\t.case(\"8n\", n => `${n}` as const)\n\t.case(\"9n\", n => `${n}` as const)\n\t.default(\"never\")\n\nconst tsPatternMatch10 = (n: typeof arkMatch10.inferIn) =>\n\ttsPatternMatch(n)\n\t\t.with(0n, n => `${n}`)\n\t\t.with(1n, n => `${n}`)\n\t\t.with(2n, n => `${n}`)\n\t\t.with(3n, n => `${n}`)\n\t\t.with(4n, n => `${n}`)\n\t\t.with(5n, n => `${n}`)\n\t\t.with(6n, n => `${n}`)\n\t\t.with(7n, n => `${n}`)\n\t\t.with(8n, n => `${n}`)\n\t\t.with(9n, n => `${n}`)\n\t\t.exhaustive()\n\nbench(\"case(10, invoke first)\", () => {\n\tarkMatch10(0n)\n\tarkMatch10(1n)\n\tarkMatch10(2n)\n}).mean([892.59, \"ns\"])\n\nbench(\"ts-pattern case(10, invoke first)\", () => {\n\ttsPatternMatch10(0n)\n\ttsPatternMatch10(1n)\n\ttsPatternMatch10(2n)\n}).mean([796.69, \"ns\"])\n\nbench(\"case(10, invoke last)\", () => {\n\tarkMatch10(7n)\n\tarkMatch10(8n)\n\tarkMatch10(9n)\n}).mean([977.74, \"ns\"])\n\nbench(\"ts-pattern case(10, invoke last)\", () => {\n\ttsPatternMatch10(7n)\n\ttsPatternMatch10(8n)\n\ttsPatternMatch10(9n)\n}).mean([1.63, \"us\"])\n"
  },
  {
    "path": "ark/repo/scratch/realWorldComparison.ts",
    "content": "import { bench } from \"@ark/attest\"\nimport { scope, type } from \"arktype\"\nimport { z } from \"zod\"\n\nbench.baseline(() => {\n\ttype({ foo: \"string\" }).or({ bar: \"number\" }).array()\n\tz.array(\n\t\tz.union([z.object({ foo: z.string() }), z.object({ bar: z.number() })])\n\t)\n})\n\n// checkDeferredNode: 9ms\nbench(\"arktype\", () => {\n\tconst authenticatorTransportFutureSchema = type\n\t\t.enumerated(\"ble\", \"internal\", \"nfc\", \"usb\", \"cable\", \"hybrid\")\n\t\t.array()\n\n\tconst authenticatorAttachmentSchema = type.enumerated(\n\t\t\"cross-platform\",\n\t\t\"platform\"\n\t)\n\n\tconst AuthenticationResponseJSONSchema = type({\n\t\tid: \"string\",\n\t\trawId: \"string\",\n\t\tresponse: {\n\t\t\tclientDataJSON: \"string\",\n\t\t\tauthenticatorData: \"string\",\n\t\t\tsignature: \"string\",\n\t\t\t\"userHandle?\": \"string\"\n\t\t},\n\t\t\"authenticatorAttachment?\": authenticatorAttachmentSchema,\n\t\tclientExtensionResults: {\n\t\t\t\"appid?\": \"boolean\",\n\t\t\t\"credProps?\": {\n\t\t\t\t\"rk?\": \"boolean\"\n\t\t\t},\n\t\t\t\"hmacCreateSecret?\": \"boolean\"\n\t\t},\n\t\ttype: \"'public-key'\"\n\t})\n\n\tconst VerifyRegistrationResponseOptsSchema = type({\n\t\tid: \"string\",\n\t\trawId: \"string\",\n\t\tresponse: {\n\t\t\tclientDataJSON: \"string\",\n\t\t\tattestationObject: \"string\",\n\t\t\t\"transports?\": authenticatorTransportFutureSchema\n\t\t},\n\t\t\"authenticatorAttachment?\": authenticatorAttachmentSchema,\n\t\tclientExtensionResults: {\n\t\t\t\"appid?\": \"boolean\",\n\t\t\t\"credProps?\": {\n\t\t\t\t\"rk?\": \"boolean\"\n\t\t\t},\n\t\t\t\"hmacCreateSecret?\": \"boolean\"\n\t\t},\n\t\ttype: \"'public-key'\"\n\t})\n\n\tconst derived = VerifyRegistrationResponseOptsSchema.pick(\n\t\t\"id\",\n\t\t\"clientExtensionResults\",\n\t\t\"authenticatorAttachment\"\n\t).omit(\"clientExtensionResults\")\n}).types([5769, \"instantiations\"])\n\n// checkDeferredNode: 19ms\nbench(\"arktype scope\", () => {\n\tconst types = scope({\n\t\tauthenticatorTransportFutureSchema:\n\t\t\t\"('ble'|'internal'|'nfc'|'usb'|'cable'|'hybrid')[]\",\n\t\tauthenticatorAttachmentSchema: \"'cross-platform'|'platform'\",\n\t\tauthenticationResponseJSONSchema: {\n\t\t\tid: \"string\",\n\t\t\trawId: \"string\",\n\t\t\tresponse: {\n\t\t\t\tclientDataJSON: \"string\",\n\t\t\t\tauthenticatorData: \"string\",\n\t\t\t\tsignature: \"string\",\n\t\t\t\t\"userHandle?\": \"string\"\n\t\t\t},\n\t\t\t\"authenticatorAttachment?\": \"authenticatorAttachmentSchema\",\n\t\t\tclientExtensionResults: {\n\t\t\t\t\"appid?\": \"boolean\",\n\t\t\t\t\"credProps?\": {\n\t\t\t\t\t\"rk?\": \"boolean\"\n\t\t\t\t},\n\t\t\t\t\"hmacCreateSecret?\": \"boolean\"\n\t\t\t},\n\t\t\ttype: \"'public-key'\"\n\t\t},\n\t\tverifyRegistrationResponseOptsSchema: {\n\t\t\tid: \"string\",\n\t\t\trawId: \"string\",\n\t\t\tresponse: {\n\t\t\t\tclientDataJSON: \"string\",\n\t\t\t\tattestationObject: \"string\",\n\t\t\t\t\"transports?\": \"authenticatorTransportFutureSchema\"\n\t\t\t},\n\t\t\t\"authenticatorAttachment?\": \"authenticatorAttachmentSchema\",\n\t\t\tclientExtensionResults: {\n\t\t\t\t\"appid?\": \"boolean\",\n\t\t\t\t\"credProps?\": {\n\t\t\t\t\t\"rk?\": \"boolean\"\n\t\t\t\t},\n\t\t\t\t\"hmacCreateSecret?\": \"boolean\"\n\t\t\t},\n\t\t\ttype: \"'public-key'\"\n\t\t}\n\t}).export()\n\n\tconst derived = types.verifyRegistrationResponseOptsSchema\n\t\t.pick(\"id\", \"clientExtensionResults\", \"authenticatorAttachment\")\n\t\t.omit(\"clientExtensionResults\")\n}).types([11380, \"instantiations\"])\n\n// checkDeferredNode: 82ms\nbench(\"zod\", () => {\n\tconst authenticatorTransportFutureSchema = z.array(\n\t\tz.union([\n\t\t\tz.literal(\"ble\"),\n\t\t\tz.literal(\"internal\"),\n\t\t\tz.literal(\"nfc\"),\n\t\t\tz.literal(\"usb\"),\n\t\t\tz.literal(\"cable\"),\n\t\t\tz.literal(\"hybrid\")\n\t\t])\n\t)\n\tconst authenticatorAttachmentSchema = z.union([\n\t\tz.literal(\"cross-platform\"),\n\t\tz.literal(\"platform\")\n\t])\n\tconst authenticationResponseJSONSchema = z.object({\n\t\tid: z.string(),\n\t\trawId: z.string(),\n\t\tresponse: z.object({\n\t\t\tclientDataJSON: z.string(),\n\t\t\tauthenticatorData: z.string(),\n\t\t\tsignature: z.string(),\n\t\t\tuserHandle: z.string().optional()\n\t\t}),\n\t\tauthenticatorAttachment: authenticatorAttachmentSchema.optional(),\n\t\tclientExtensionResults: z.object({\n\t\t\tappid: z.boolean().optional(),\n\t\t\tcredProps: z\n\t\t\t\t.object({\n\t\t\t\t\trk: z.boolean().optional()\n\t\t\t\t})\n\t\t\t\t.optional(),\n\t\t\thmacCreateSecret: z.boolean().optional()\n\t\t}),\n\t\ttype: z.literal(\"public-key\")\n\t})\n\n\tconst verifyRegistrationResponseOptsSchema = z.object({\n\t\tid: z.string(),\n\t\trawId: z.string(),\n\t\tresponse: z.object({\n\t\t\tclientDataJSON: z.string(),\n\t\t\tattestationObject: z.string(),\n\t\t\ttransports: authenticatorTransportFutureSchema.optional()\n\t\t}),\n\t\tauthenticatorAttachment: authenticatorAttachmentSchema.optional(),\n\t\tclientExtensionResults: z.object({\n\t\t\tappid: z.boolean().optional(),\n\t\t\tcredProps: z\n\t\t\t\t.object({\n\t\t\t\t\trk: z.boolean().optional()\n\t\t\t\t})\n\t\t\t\t.optional(),\n\t\t\thmacCreateSecret: z.boolean().optional()\n\t\t}),\n\t\ttype: z.literal(\"public-key\")\n\t})\n\n\tconst derived = verifyRegistrationResponseOptsSchema\n\t\t.pick({\n\t\t\tid: true,\n\t\t\tresponse: true,\n\t\t\tclientExtensionResults: true\n\t\t})\n\t\t.omit({ clientExtensionResults: true })\n}).types([16922, \"instantiations\"])\n"
  },
  {
    "path": "ark/repo/scratch/typeClass.ts",
    "content": "import { DynamicBase } from \"@ark/util\"\nimport { type } from \"arktype\"\n\nconst Class = <const def>(def: type.validate<def>) => {\n\tconst Validator = type(def as never)\n\n\treturn class TypeConstructor<t = type.infer<def>> extends DynamicBase<\n\t\tt & object\n\t> {\n\t\tstatic infer: type.infer<def>\n\n\t\tconstructor(input: unknown) {\n\t\t\tconst out = Validator(input)\n\t\t\tif (out instanceof type.errors) {\n\t\t\t\treturn out.throw()\n\t\t\t}\n\t\t\tsuper(out as never)\n\t\t}\n\n\t\tstatic and<cls extends typeof TypeConstructor<any>, andDef>(\n\t\t\tthis: cls,\n\t\t\tdef: type.validate<andDef>\n\t\t) {\n\t\t\treturn class extends (this as typeof TypeConstructor<\n\t\t\t\tInstanceType<cls> & type.infer<andDef>\n\t\t\t>) {\n\t\t\t\tstatic infer: cls[\"infer\"] & type.infer<andDef>\n\t\t\t}\n\t\t}\n\t}\n}\n\nclass Foo extends Class({ a: \"string|number[]\" }) {\n\tgetA() {\n\t\treturn this.a\n\t}\n}\n\nconst data = new Foo({}) //=>\n\nconst a = data.a //=>\n\nclass Bar extends Foo.and({ b: \"boolean\" }) {\n\tgetB() {\n\t\treturn this.b\n\t}\n}\n\ntype Z = typeof Bar.infer //=>\n\nconst data2 = new Bar({}) //=>\n\nconst implemented = data2.getB() //=>\nconst inherited = data2.getA() //=>\n\nconst a2 = data2.a //=>\nconst b = data2.b //=>\n"
  },
  {
    "path": "ark/repo/scratch/unionComparison.ts",
    "content": "import { scope, type } from \"arktype\"\nimport { z } from \"zod\"\n\nconst zodUser = z.discriminatedUnion(\"kind\", [\n\tz.object({ kind: z.literal(\"admin\"), powers: z.string().array().optional() }),\n\tz.object({\n\t\tkind: z.literal(\"superadmin\"),\n\t\tsuperpowers: z.string().array().optional()\n\t}),\n\tz.object({ kind: z.literal(\"pleb\") })\n])\n\nexport const ArkUser = type({\n\tkind: \"'admin'\",\n\t\"powers?\": \"string[]\"\n})\n\t.or({\n\t\tkind: \"'superadmin'\",\n\t\t\"superpowers?\": \"string[]\"\n\t})\n\t.or({\n\t\tkind: \"'pleb'\"\n\t})\n"
  },
  {
    "path": "ark/repo/scratch.ts",
    "content": "import { join } from \"@ark/util\"\nimport { type } from \"arktype\"\n\nconst options = [\"red\", \"blue\"] as const\n\nconst color = type.enumerated(...options)\n\nconst darkColorLiteral = type.enumerated(\n\t...options.map(base => `${base}Dark` as const)\n)\n\nconst darkColorRegex = type(`/^(${join(options, \"|\")})Dark$/`)\n"
  },
  {
    "path": "ark/repo/shared.ts",
    "content": "import {\n\tfileName,\n\tfindPackageAncestors,\n\treadJson,\n\treadPackageJson\n} from \"@ark/fs\"\nimport { flatMorph, throwInternalError } from \"@ark/util\"\nimport { join } from \"node:path\"\nimport type { PackageJson } from \"type-fest\"\n\n// allow other utils invoked from build to bootstrap utils\n\n// eslint-disable-next-line @typescript-eslint/no-restricted-imports\nexport * as bootstrapFs from \"../fs/index.ts\"\n// eslint-disable-next-line @typescript-eslint/no-restricted-imports\nexport * as bootstrapUtil from \"../util/index.ts\"\n\nconst root = findPackageAncestors().find(\n\tdir => readPackageJson(dir).name === \"ark\"\n)\n\nif (!root) throwInternalError(`Can't find repo root from ${fileName()}!`)\n\nconst arkDir = join(root, \"ark\")\nconst docs = join(arkDir, \"docs\")\n\nexport const repoDirs = {\n\troot,\n\tarkDir,\n\tdocs,\n\trepo: join(arkDir, \"repo\")\n}\n\nexport const packageScopes = [\n\t\"attest\",\n\t\"fs\",\n\t\"json-schema\",\n\t\"regex\",\n\t\"schema\",\n\t\"type\",\n\t\"util\"\n] as const\n\nexport type PackageScope = (typeof packageScopes)[number]\n\nexport type ArkPackage = {\n\tscope: PackageScope\n\tpath: string\n\tpackageJsonPath: string\n\tname: string\n\tversion: string\n\tjson: PackageJson\n}\n\nexport const packagesByScope = flatMorph(\n\tpackageScopes,\n\t(i, scope): [PackageScope, ArkPackage] => {\n\t\tconst path = join(arkDir, scope)\n\t\tconst packageJsonPath = join(path, \"package.json\")\n\t\tconst json = readJson(packageJsonPath) as PackageJson\n\t\treturn [\n\t\t\tscope,\n\t\t\t{\n\t\t\t\tscope,\n\t\t\t\tpath,\n\t\t\t\tpackageJsonPath,\n\t\t\t\tjson,\n\t\t\t\tname: json.name!,\n\t\t\t\tversion: json.version!\n\t\t\t}\n\t\t]\n\t}\n)\n\nexport const packages = Object.values(packagesByScope)\n"
  },
  {
    "path": "ark/repo/testPackage.ts",
    "content": "import { fromHere, shell } from \"@ark/fs\"\n\nshell(\n\t`pnpm mocha --config ${fromHere(\"mocha.package.jsonc\")} ${process.argv\n\t\t.slice(2)\n\t\t.join(\" \")}`\n)\n"
  },
  {
    "path": "ark/repo/testV8.js",
    "content": "import { fromHere } from \"@ark/fs\"\nimport { type } from \"arktype\"\n\nconsole.log(\n\t\"⏱️  Checking for V8 fast properties (https://v8.dev/blog/fast-properties) on Type...\\n\"\n)\n\nconst T = type({\n\tname: \"string\",\n\tage: \"number\"\n})\n\nlet hasFastProperties\n\ntry {\n\thasFastProperties = eval(\"%HasFastProperties(T)\")\n} catch {\n\tthrow new Error(`This test must be run in a V8-based runtime with the --allow-natives-syntax flag, e.g.:\nnode --allow-natives-syntax ${fromHere()}`)\n}\n\nif (!hasFastProperties) {\n\tthrow new Error(\"⚠️  Type instance has been deoptimized.\")\n}\n\nconsole.log(\"🏎️  Type instance has fast properties!\")\n"
  },
  {
    "path": "ark/repo/ts.js",
    "content": "#!/usr/bin/env node\n\n// @ts-check\nimport { execSync } from \"node:child_process\"\nimport { addNodeDevOptions } from \"./nodeOptions.js\"\n\naddNodeDevOptions()\n\nexecSync(`node ${process.argv.slice(2).join(\" \")}`, { stdio: \"inherit\" })\n"
  },
  {
    "path": "ark/repo/tsconfig.cjs.json",
    "content": "{\n\t\"extends\": \"../../tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"module\": \"CommonJS\",\n\t\t\"moduleResolution\": \"Node\",\n\t\t\"verbatimModuleSyntax\": false,\n\t\t\"rootDir\": \".\",\n\t\t\"outDir\": \"out\",\n\t\t\"noEmit\": false,\n\t\t\"declaration\": false,\n\t\t\"customConditions\": []\n\t},\n\t\"exclude\": [\"out\", \"__tests__\"]\n}\n"
  },
  {
    "path": "ark/repo/tsconfig.dts.json",
    "content": "{\n\t\"extends\": \"../../tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"rootDir\": \".\",\n\t\t\"outDir\": \"out\",\n\t\t\"noEmit\": false,\n\t\t\"emitDeclarationOnly\": true,\n\t\t\"customConditions\": []\n\t},\n\t\"exclude\": [\"out\", \"__tests__\"]\n}\n"
  },
  {
    "path": "ark/repo/tsconfig.esm.json",
    "content": "{\n\t\"extends\": \"../../tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"rootDir\": \".\",\n\t\t\"outDir\": \"out\",\n\t\t\"noEmit\": false,\n\t\t\"declaration\": false,\n\t\t\"noCheck\": true,\n\t\t\"customConditions\": []\n\t},\n\t\"exclude\": [\"out\", \"__tests__\"]\n}\n"
  },
  {
    "path": "ark/schema/README.md",
    "content": "# @ark/schema\n\nUnderlying schema language parsed from arktype syntax.\n\nThe parts of ArkType's type system that exist in TS (i.e. not runtime-only constraints like bounds, divisors, custom predicates, morphs etc.) are structured like this:\n\n- Union: a set of intersections\n- Intersection: a set of a basis and constraints\n- Basis: this is the base type to which refinements like props are applied. It is one of three things, getting narrower as you move down the list:\n  - Domain: `\"string\" | \"number\" | \"bigint\" | \"object\" | \"symbol\"` parallels built-in TS keywords for non-enumerable value sets\n  - Proto: Must be an `instanceof` some class (implies domain `\"object\"`)\n  - Unit: Must `===` some value (can be intersected with any other constraint and reduced to itself or a disjoint)\n- Constraint: an individual condition that must be satisfied:\n  - Required: must have a specified literal string or symbol key and a value that conforms to a specified union or intersection\n  - Optional: Required conditions met or the specified key is not present\n  - Index: all keys that satisfy an index type must have values satisfying the corresponding value type\n\nIn this system, `L` extends/subtypes/is assignable to `R` if and only if the intersection `L & R` is equal to `L`.\n"
  },
  {
    "path": "ark/schema/__tests__/bounds.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport {\n\tDisjoint,\n\tboundKindPairsByLower,\n\trootSchema,\n\twriteInvalidLengthBoundMessage\n} from \"@ark/schema\"\nimport { entriesOf, flatMorph } from \"@ark/util\"\n\nconst numericCases = {\n\tlessThanMin: 4,\n\tequalToExclusiveMin: 5,\n\tbetween: 8,\n\tequalToInclusiveMax: 10,\n\tgreaterThanMax: 11\n}\n\nconst dateCases = flatMorph(numericCases, (name, v) => [name, new Date(v)])\n\nconst lengthCases = flatMorph(numericCases, (name, v) => [name, \"1\".repeat(v)])\n\ncontextualize(() => {\n\tit(\"numeric apply\", () => {\n\t\tconst T = rootSchema({\n\t\t\tdomain: \"number\",\n\t\t\tmin: { rule: 5, exclusive: true },\n\t\t\tmax: { rule: 10 }\n\t\t})\n\n\t\tattest(T.traverse(numericCases.lessThanMin)?.toString()).snap(\n\t\t\t\"must be more than 5 (was 4)\"\n\t\t)\n\t\tattest(T.traverse(numericCases.equalToExclusiveMin)?.toString()).snap(\n\t\t\t\"must be more than 5 (was 5)\"\n\t\t)\n\t\tattest(T.traverse(numericCases.between)).equals(numericCases.between)\n\t\tattest(T.traverse(numericCases.equalToInclusiveMax)).equals(\n\t\t\tnumericCases.equalToInclusiveMax\n\t\t)\n\t\tattest(T.traverse(numericCases.greaterThanMax)?.toString()).snap(\n\t\t\t\"must be at most 10 (was 11)\"\n\t\t)\n\t})\n\n\tit(\"length apply\", () => {\n\t\tconst T = rootSchema({\n\t\t\tdomain: \"string\",\n\t\t\tminLength: { rule: 5, exclusive: true },\n\t\t\tmaxLength: { rule: 10 }\n\t\t})\n\n\t\tattest(T.traverse(lengthCases.lessThanMin)?.toString()).snap(\n\t\t\t\"must be at least length 6 (was 4)\"\n\t\t)\n\t\tattest(T.traverse(lengthCases.equalToExclusiveMin)?.toString()).snap(\n\t\t\t\"must be at least length 6 (was 5)\"\n\t\t)\n\t\tattest(T.traverse(lengthCases.between)).equals(lengthCases.between)\n\t\tattest(T.traverse(lengthCases.equalToInclusiveMax)).equals(\n\t\t\tlengthCases.equalToInclusiveMax\n\t\t)\n\t\tattest(T.traverse(lengthCases.greaterThanMax)?.toString()).snap(\n\t\t\t\"must be at most length 10 (was 11)\"\n\t\t)\n\t})\n\n\tit(\"date apply\", () => {\n\t\tconst T = rootSchema({\n\t\t\tproto: Date,\n\t\t\tafter: { rule: 5, exclusive: true },\n\t\t\tbefore: { rule: 10 }\n\t\t})\n\n\t\tattest(T.traverse(dateCases.lessThanMin)?.toString()).snap(\n\t\t\t\"must be 7:00:00.006 PM, December 31, 1969 or later (was 7:00:00.004 PM, December 31, 1969)\"\n\t\t)\n\t\tattest(T.traverse(dateCases.equalToExclusiveMin)?.toString()).snap(\n\t\t\t\"must be 7:00:00.006 PM, December 31, 1969 or later (was 7:00:00.005 PM, December 31, 1969)\"\n\t\t)\n\t\tattest(T.traverse(dateCases.between)).equals(dateCases.between)\n\t\tattest(T.traverse(dateCases.equalToInclusiveMax)).equals(\n\t\t\tdateCases.equalToInclusiveMax\n\t\t)\n\t\tattest(T.traverse(dateCases.greaterThanMax)?.toString()).snap(\n\t\t\t\"must be 7:00:00.010 PM, December 31, 1969 or earlier (was 7:00:00.011 PM, December 31, 1969)\"\n\t\t)\n\t})\n\n\tit(\"errors on negative length bound\", () => {\n\t\tattest(() => rootSchema({ domain: \"string\", maxLength: -1 })).throws(\n\t\t\twriteInvalidLengthBoundMessage(\"maxLength\", -1)\n\t\t)\n\t})\n\n\tit(\"errors on non-integer length bound\", () => {\n\t\tattest(() => rootSchema({ domain: \"string\", exactLength: 1.5 })).throws(\n\t\t\twriteInvalidLengthBoundMessage(\"exactLength\", 1.5)\n\t\t)\n\t})\n\n\tit(\"minLength 0 reduces to unconstrained\", () => {\n\t\tconst T = rootSchema({ domain: \"string\", minLength: 0 })\n\t\tattest(T.expression).snap(\"string\")\n\t})\n\n\tfor (const [min, max] of entriesOf(boundKindPairsByLower)) {\n\t\tdescribe(`${min}/${max}`, () => {\n\t\t\tconst basis =\n\t\t\t\tmin === \"min\" ? { domain: \"number\" }\n\t\t\t\t: min === \"minLength\" ? { domain: \"string\" }\n\t\t\t\t: { proto: Date }\n\t\t\tconst cases =\n\t\t\t\tmin === \"min\" ? numericCases\n\t\t\t\t: min === \"minLength\" ? lengthCases\n\t\t\t\t: dateCases\n\n\t\t\tit(\"allows\", () => {\n\t\t\t\tconst T = rootSchema({\n\t\t\t\t\t...basis,\n\t\t\t\t\t[min]: { rule: 5, exclusive: true },\n\t\t\t\t\t[max]: { rule: 10 }\n\t\t\t\t} as never)\n\n\t\t\t\tattest(T.allows(cases.lessThanMin)).equals(false)\n\t\t\t\tattest(T.allows(cases.equalToExclusiveMin)).equals(false)\n\t\t\t\tattest(T.allows(cases.between)).equals(true)\n\t\t\t\tattest(T.allows(cases.equalToInclusiveMax)).equals(true)\n\t\t\t\tattest(T.allows(cases.greaterThanMax)).equals(false)\n\t\t\t})\n\n\t\t\tit(\"unit range reduces\", () => {\n\t\t\t\tconst L = rootSchema({\n\t\t\t\t\t...basis,\n\t\t\t\t\t[min]: {\n\t\t\t\t\t\trule: 6\n\t\t\t\t\t}\n\t\t\t\t} as never)\n\t\t\t\tconst R = rootSchema({\n\t\t\t\t\t...basis,\n\t\t\t\t\t[max]: {\n\t\t\t\t\t\trule: 6\n\t\t\t\t\t}\n\t\t\t\t} as never)\n\t\t\t\tconst Expected =\n\t\t\t\t\tmin === \"min\" ?\n\t\t\t\t\t\trootSchema({\n\t\t\t\t\t\t\tunit: 6\n\t\t\t\t\t\t})\n\t\t\t\t\t: min === \"minLength\" ?\n\t\t\t\t\t\trootSchema({\n\t\t\t\t\t\t\t...basis,\n\t\t\t\t\t\t\texactLength: 6\n\t\t\t\t\t\t} as never)\n\t\t\t\t\t:\trootSchema({\n\t\t\t\t\t\t\tunit: new Date(6)\n\t\t\t\t\t\t})\n\n\t\t\t\tattest(L.and(R).json).equals(Expected.json)\n\t\t\t\tattest(R.and(L).json).equals(Expected.json)\n\t\t\t})\n\n\t\t\tit(\"non-overlapping exclusive\", () => {\n\t\t\t\tconst L = rootSchema({\n\t\t\t\t\t...basis,\n\t\t\t\t\t[min]: {\n\t\t\t\t\t\trule: 3\n\t\t\t\t\t}\n\t\t\t\t} as never)\n\t\t\t\tconst R = rootSchema({\n\t\t\t\t\t...basis,\n\t\t\t\t\t[max]: {\n\t\t\t\t\t\trule: 3,\n\t\t\t\t\t\texclusive: true\n\t\t\t\t\t}\n\t\t\t\t} as never)\n\t\t\t\tattest(L.intersect(R)).instanceOf(Disjoint)\n\t\t\t\tattest(R.intersect(L)).instanceOf(Disjoint)\n\t\t\t})\n\n\t\t\tit(\"non-overlapping limits\", () => {\n\t\t\t\tconst L = rootSchema({ ...basis, [min]: 3 } as never)\n\t\t\t\tconst R = rootSchema({\n\t\t\t\t\t...basis,\n\t\t\t\t\t[max]: 1\n\t\t\t\t} as never)\n\t\t\t\tattest(L.intersect(R)).instanceOf(Disjoint)\n\t\t\t\tattest(R.intersect(L)).instanceOf(Disjoint)\n\t\t\t})\n\n\t\t\tit(\"greater min is stricter\", () => {\n\t\t\t\tconst lesser = rootSchema({\n\t\t\t\t\t...basis,\n\t\t\t\t\t[min]: 3\n\t\t\t\t} as never)\n\t\t\t\tconst greater = rootSchema({\n\t\t\t\t\t...basis,\n\t\t\t\t\t[min]: 4\n\t\t\t\t} as never)\n\t\t\t\tattest(lesser.and(greater).json).equals(greater.json)\n\t\t\t\tattest(greater.and(lesser).json).equals(greater.json)\n\t\t\t})\n\n\t\t\tit(\"lesser max is stricter\", () => {\n\t\t\t\tconst lesser = rootSchema({\n\t\t\t\t\t...basis,\n\t\t\t\t\t[max]: 3\n\t\t\t\t} as never)\n\t\t\t\tconst greater = rootSchema({\n\t\t\t\t\t...basis,\n\t\t\t\t\t[max]: { rule: 4, exclusive: true }\n\t\t\t\t} as never)\n\t\t\t\tattest(lesser.and(greater).json).equals(lesser.json)\n\t\t\t\tattest(greater.and(lesser).json).equals(lesser.json)\n\t\t\t})\n\n\t\t\tit(\"exclusive wins if limits equal\", () => {\n\t\t\t\tconst exclusive = rootSchema({\n\t\t\t\t\t...basis,\n\t\t\t\t\t[max]: { rule: 3, exclusive: true }\n\t\t\t\t} as never)\n\t\t\t\tconst inclusive = rootSchema({\n\t\t\t\t\t...basis,\n\t\t\t\t\t[max]: 3\n\t\t\t\t} as never)\n\t\t\t\tattest(exclusive.and(inclusive).json).equals(exclusive.json)\n\t\t\t\tattest(inclusive.and(exclusive).json).equals(exclusive.json)\n\t\t\t})\n\t\t})\n\t}\n})\n"
  },
  {
    "path": "ark/schema/__tests__/errors.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport {\n\t$ark,\n\ttype ArkErrors,\n\tconfigureSchema,\n\trootSchema,\n\tschemaScope\n} from \"@ark/schema\"\n\ncontextualize(() => {\n\tit(\"shallow\", () => {\n\t\tconst n = rootSchema({\n\t\t\tdomain: \"number\",\n\t\t\tdivisor: 3\n\t\t})\n\t\tattest(n.traverse(6)).snap(6)\n\t\tattest(n.traverse(7)?.toString()).snap(\"must be a multiple of 3 (was 7)\")\n\t})\n\n\tit(\"at path\", () => {\n\t\tconst o = rootSchema({\n\t\t\tdomain: \"object\",\n\t\t\trequired: {\n\t\t\t\tkey: \"foo\",\n\t\t\t\tvalue: {\n\t\t\t\t\tdomain: \"number\",\n\t\t\t\t\tdivisor: 3\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t\tattest(o.traverse({ foo: 6 })).snap({ foo: 6 })\n\t\tattest(o.traverse({ foo: 7 })?.toString()).snap(\n\t\t\t\"foo must be a multiple of 3 (was 7)\"\n\t\t)\n\t})\n\n\tit(\"array\", () => {\n\t\tconst T = rootSchema({\n\t\t\tproto: Array,\n\t\t\tsequence: \"number\"\n\t\t})\n\t\tattest(T.traverse([5])).snap([5])\n\t\tattest(T.traverse([5, \"five\"])?.toString()).snap(\n\t\t\t\"value at [1] must be a number (was a string)\"\n\t\t)\n\t})\n\n\tit(\"custom description integrated with error\", () => {\n\t\tconst superSpecialBigint = rootSchema({\n\t\t\tdomain: \"bigint\",\n\t\t\tmeta: \"my special bigint\"\n\t\t})\n\t\tattest(superSpecialBigint.description).snap(\"my special bigint\")\n\t\tattest(superSpecialBigint.traverse(5)?.toString()).snap(\n\t\t\t\"must be my special bigint (was a number)\"\n\t\t)\n\t})\n\n\tit(\"custom description on parent doesn't affect children\", () => {\n\t\tconst evenNumber = rootSchema({\n\t\t\tmeta: \"an even number\",\n\t\t\tdomain: \"number\",\n\t\t\tdivisor: 2\n\t\t})\n\t\tattest(evenNumber.description).snap(\"an even number\")\n\t\t// since the error is from the divisor constraint which didn't have a\n\t\t// description, it is unchanged\n\t\tattest(evenNumber.traverse(5)?.toString()).snap(\"must be even (was 5)\")\n\t})\n\n\tit(\"can configure error writers at a node level\", () => {\n\t\tconst customNumber = rootSchema({\n\t\t\tmeta: {\n\t\t\t\tdescription: \"custom description\",\n\t\t\t\tactual: data => `custom actual ${data}`,\n\t\t\t\tproblem: ctx => `custom problem ${ctx.expected} ${ctx.actual}`,\n\t\t\t\tmessage: ctx => `custom message ${ctx.problem}`\n\t\t\t},\n\t\t\tdomain: \"number\"\n\t\t})\n\n\t\tconst out = customNumber(\"foo\") as ArkErrors\n\n\t\tattest(out.summary).snap(\n\t\t\t\"custom message custom problem custom description custom actual foo\"\n\t\t)\n\t})\n\n\tit(\"can configure errors by kind at a scope level\", () => {\n\t\tconst types = schemaScope(\n\t\t\t{ superSpecialString: \"string\" },\n\t\t\t{\n\t\t\t\tdomain: {\n\t\t\t\t\texpected: inner => `custom expected ${inner.domain}`,\n\t\t\t\t\tactual: data => `custom actual ${data}`,\n\t\t\t\t\tproblem: ctx => `custom problem ${ctx.expected} ${ctx.actual}`,\n\t\t\t\t\tmessage: ctx => `custom message ${ctx.problem}`\n\t\t\t\t}\n\t\t\t}\n\t\t).export()\n\t\tconst superSpecialString = types.superSpecialString\n\t\tattest(superSpecialString(5)?.toString()).snap(\n\t\t\t\"custom message custom problem custom expected string custom actual 5\"\n\t\t)\n\t})\n\n\tit(\"can configure description by kind at scope level\", () => {\n\t\tconst types = schemaScope(\n\t\t\t{ superSpecialNumber: \"number\" },\n\t\t\t{\n\t\t\t\tdomain: {\n\t\t\t\t\tdescription: inner => `my special ${inner.domain}`\n\t\t\t\t}\n\t\t\t}\n\t\t).export()\n\t\tconst superSpecialNumber = types.superSpecialNumber\n\t\tattest(superSpecialNumber.description).snap(\"my special number\")\n\t\tattest(superSpecialNumber(\"five\")?.toString()).snap(\n\t\t\t\"must be my special number (was a string)\"\n\t\t)\n\t})\n\n\tit(\"can apply a global config\", () => {\n\t\tconfigureSchema({\n\t\t\tdomain: {\n\t\t\t\tdescription: inner => `my special ${inner.domain}`\n\t\t\t}\n\t\t})\n\t\tconst mySpecialSymbol = schemaScope({}).parseSchema(\"symbol\")\n\t\tattest(mySpecialSymbol.traverse(\"foo\")?.toString()).snap(\n\t\t\t\"must be my special symbol (was a string)\"\n\t\t)\n\t\tconfigureSchema({\n\t\t\tdomain: $ark.defaultConfig.domain\n\t\t})\n\t\tconst myBoringSymbol = schemaScope({}).parseSchema(\"symbol\")\n\t\tattest(myBoringSymbol.traverse(\"foo\")?.toString()).snap(\n\t\t\t\"must be a symbol (was a string)\"\n\t\t)\n\t})\n\n\tconst nEvenAtLeast2 = rootSchema({\n\t\tdomain: \"object\",\n\t\trequired: {\n\t\t\tkey: \"n\",\n\t\t\tvalue: { domain: \"number\", divisor: 2, min: 2 }\n\t\t}\n\t})\n\n\tconst errors = nEvenAtLeast2({ n: 1 }) as ArkErrors\n\n\tit(\"serialization\", () => {\n\t\tattest(errors.toJSON()).snap([\n\t\t\t{\n\t\t\t\tdata: 1,\n\t\t\t\tpath: [\"n\"],\n\t\t\t\tcode: \"intersection\",\n\t\t\t\terrors: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdata: 1,\n\t\t\t\t\t\tpath: [\"n\"],\n\t\t\t\t\t\tcode: \"divisor\",\n\t\t\t\t\t\tdescription: \"even\",\n\t\t\t\t\t\tmeta: {},\n\t\t\t\t\t\trule: 2,\n\t\t\t\t\t\texpected: \"even\",\n\t\t\t\t\t\tactual: \"1\",\n\t\t\t\t\t\tproblem: \"must be even (was 1)\",\n\t\t\t\t\t\tmessage: \"n must be even (was 1)\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdata: 1,\n\t\t\t\t\t\tpath: [\"n\"],\n\t\t\t\t\t\tcode: \"min\",\n\t\t\t\t\t\tdescription: \"at least 2\",\n\t\t\t\t\t\tmeta: {},\n\t\t\t\t\t\trule: 2,\n\t\t\t\t\t\texpected: \"at least 2\",\n\t\t\t\t\t\tactual: \"1\",\n\t\t\t\t\t\tproblem: \"must be at least 2 (was 1)\",\n\t\t\t\t\t\tmessage: \"n must be at least 2 (was 1)\"\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\texpected: \"  ◦ even\\n  ◦ at least 2\",\n\t\t\t\tactual: \"1\",\n\t\t\t\tproblem: \"(1) must be...\\n  ◦ even\\n  ◦ at least 2\",\n\t\t\t\tmessage: \"n (1) must be...\\n  ◦ even\\n  ◦ at least 2\"\n\t\t\t}\n\t\t])\n\t})\n\n\tit(\"flatByPath\", () => {\n\t\tattest(errors.flatByPath).snap({\n\t\t\tn: [\n\t\t\t\t{\n\t\t\t\t\tdata: 1,\n\t\t\t\t\tpath: [\"n\"],\n\t\t\t\t\tcode: \"divisor\",\n\t\t\t\t\tdescription: \"even\",\n\t\t\t\t\tmeta: {},\n\t\t\t\t\trule: 2,\n\t\t\t\t\texpected: \"even\",\n\t\t\t\t\tactual: \"1\",\n\t\t\t\t\tproblem: \"must be even (was 1)\",\n\t\t\t\t\tmessage: \"n must be even (was 1)\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdata: 1,\n\t\t\t\t\tpath: [\"n\"],\n\t\t\t\t\tcode: \"min\",\n\t\t\t\t\tdescription: \"at least 2\",\n\t\t\t\t\tmeta: {},\n\t\t\t\t\trule: 2,\n\t\t\t\t\texpected: \"at least 2\",\n\t\t\t\t\tactual: \"1\",\n\t\t\t\t\tproblem: \"must be at least 2 (was 1)\",\n\t\t\t\t\tmessage: \"n must be at least 2 (was 1)\"\n\t\t\t\t}\n\t\t\t]\n\t\t})\n\t})\n\n\tit(\"flatProblemsByPath\", () => {\n\t\tattest(errors.flatProblemsByPath).snap({\n\t\t\tn: [\"must be even (was 1)\", \"must be at least 2 (was 1)\"]\n\t\t})\n\t})\n})\n"
  },
  {
    "path": "ark/schema/__tests__/intersection.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { rootSchema } from \"@ark/schema\"\n\ncontextualize(() => {\n\tit(\"normalizes refinement order\", () => {\n\t\tconst L = rootSchema({\n\t\t\tdomain: \"number\",\n\t\t\tdivisor: 3,\n\t\t\tmin: 5\n\t\t})\n\t\tconst R = rootSchema({\n\t\t\tdomain: \"number\",\n\t\t\tmin: 5,\n\t\t\tdivisor: 3\n\t\t})\n\t\tattest(L.json).equals(R.json)\n\t})\n\n\tit(\"multiple constraints\", () => {\n\t\tconst n = rootSchema({\n\t\t\tdomain: \"number\",\n\t\t\tdivisor: 3,\n\t\t\tmin: 5\n\t\t})\n\t\tattest(n.allows(6)).snap(true)\n\t\tattest(n.allows(4)).snap(false)\n\t\tattest(n.allows(7)).snap(false)\n\t})\n})\n"
  },
  {
    "path": "ark/schema/__tests__/jsonSchema.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport {\n\t$ark,\n\tintrinsic,\n\trootSchema,\n\trootSchemaScope,\n\tschemaScope,\n\ttype BaseRoot,\n\ttype ToJsonSchema\n} from \"@ark/schema\"\nimport type { omit } from \"@ark/util\"\n\nconst toJsonSchema = (\n\tnode: BaseRoot,\n\toptions?: omit<ToJsonSchema.Options, \"dialect\">\n) => node.toJsonSchema({ dialect: null, ...options })\n\ncontextualize(() => {\n\tit(\"generates dialect by default\", () => {\n\t\tconst node = rootSchema(\"string\")\n\n\t\tattest(node.toJsonSchema()).snap({\n\t\t\ttype: \"string\",\n\t\t\t$schema: \"https://json-schema.org/draft/2020-12/schema\"\n\t\t})\n\t})\n\n\tit(\"base primitives\", () => {\n\t\tattest(toJsonSchema(intrinsic.jsonPrimitive)).snap({\n\t\t\tanyOf: [\n\t\t\t\t{ type: \"number\" },\n\t\t\t\t{ type: \"string\" },\n\t\t\t\t{ type: \"boolean\" },\n\t\t\t\t{ type: \"null\" }\n\t\t\t]\n\t\t})\n\t})\n\n\tit(\"boolean\", () => {\n\t\tattest(toJsonSchema($ark.intrinsic.boolean)).snap({\n\t\t\ttype: \"boolean\"\n\t\t})\n\t})\n\n\tit(\"string\", () => {\n\t\tconst node = rootSchema({\n\t\t\tdomain: \"string\",\n\t\t\tpattern: \".*\",\n\t\t\tminLength: 1,\n\t\t\tmaxLength: 2\n\t\t})\n\t\tattest(toJsonSchema(node)).snap({\n\t\t\ttype: \"string\",\n\t\t\tpattern: \".*\",\n\t\t\tmaxLength: 2,\n\t\t\tminLength: 1\n\t\t})\n\t})\n\n\tit(\"number\", () => {\n\t\tconst node = rootSchema({\n\t\t\tdomain: \"number\",\n\t\t\tdivisor: 2,\n\t\t\tmin: 1,\n\t\t\tmax: 2\n\t\t})\n\t\tattest(toJsonSchema(node)).snap({\n\t\t\ttype: \"integer\",\n\t\t\tmultipleOf: 2,\n\t\t\tmaximum: 2,\n\t\t\tminimum: 1\n\t\t})\n\t})\n\n\tit(\"exclusive range\", () => {\n\t\tconst node = rootSchema({\n\t\t\tdomain: \"number\",\n\t\t\tmin: { rule: 1, exclusive: true },\n\t\t\tmax: { rule: 2, exclusive: true }\n\t\t})\n\t\tattest(toJsonSchema(node)).snap({\n\t\t\ttype: \"number\",\n\t\t\texclusiveMaximum: 2,\n\t\t\texclusiveMinimum: 1\n\t\t})\n\t})\n\n\tit(\"object\", () => {\n\t\tconst node = rootSchema({\n\t\t\tdomain: \"object\",\n\t\t\trequired: [\n\t\t\t\t{\n\t\t\t\t\tkey: \"foo\",\n\t\t\t\t\tvalue: \"string\"\n\t\t\t\t},\n\t\t\t\t{ key: \"bar\", value: \"number\" }\n\t\t\t],\n\t\t\toptional: [\n\t\t\t\t{\n\t\t\t\t\tkey: \"baz\",\n\t\t\t\t\tvalue: { unit: 1 }\n\t\t\t\t}\n\t\t\t],\n\t\t\tindex: {\n\t\t\t\tsignature: \"string\",\n\t\t\t\tvalue: $ark.intrinsic.jsonPrimitive\n\t\t\t}\n\t\t})\n\t\tattest(toJsonSchema(node)).snap({\n\t\t\ttype: \"object\",\n\t\t\tproperties: {\n\t\t\t\tbar: { type: \"number\" },\n\t\t\t\tfoo: { type: \"string\" },\n\t\t\t\tbaz: { const: 1 }\n\t\t\t},\n\t\t\trequired: [\"bar\", \"foo\"],\n\t\t\tadditionalProperties: {\n\t\t\t\tanyOf: [\n\t\t\t\t\t{ type: \"number\" },\n\t\t\t\t\t{ type: \"string\" },\n\t\t\t\t\t{ type: \"boolean\" },\n\t\t\t\t\t{ type: \"null\" }\n\t\t\t\t]\n\t\t\t}\n\t\t})\n\t})\n\n\tit(\"pattern index\", () => {\n\t\tconst node = rootSchema({\n\t\t\tdomain: \"object\",\n\t\t\tindex: {\n\t\t\t\tsignature: {\n\t\t\t\t\tdomain: \"string\",\n\t\t\t\t\tpattern: \".*\"\n\t\t\t\t},\n\t\t\t\tvalue: \"number\"\n\t\t\t}\n\t\t})\n\t\tattest(toJsonSchema(node)).snap({\n\t\t\ttype: \"object\",\n\t\t\tpatternProperties: { \".*\": { type: \"number\" } }\n\t\t})\n\t})\n\n\tit(\"variadic array\", () => {\n\t\tconst node = rootSchema({\n\t\t\tproto: Array,\n\t\t\tsequence: { domain: \"string\" },\n\t\t\tminLength: 1,\n\t\t\tmaxLength: 5\n\t\t})\n\t\tconst jsonSchema = toJsonSchema(node)\n\t\tattest(jsonSchema).snap({\n\t\t\ttype: \"array\",\n\t\t\titems: { type: \"string\" },\n\t\t\tminItems: 1,\n\t\t\tmaxItems: 5\n\t\t})\n\t})\n\n\tit(\"fixed length tuple\", () => {\n\t\tconst node = rootSchema({\n\t\t\tproto: Array,\n\t\t\tsequence: {\n\t\t\t\tprefix: [{ domain: \"string\" }, { domain: \"number\" }]\n\t\t\t}\n\t\t})\n\t\tconst jsonSchema = toJsonSchema(node)\n\t\tattest(jsonSchema).snap({\n\t\t\ttype: \"array\",\n\t\t\tminItems: 2,\n\t\t\tprefixItems: [{ type: \"string\" }, { type: \"number\" }],\n\t\t\titems: false\n\t\t})\n\t})\n\n\tit(\"prefixed array\", () => {\n\t\tconst node = rootSchema({\n\t\t\tproto: Array,\n\t\t\tsequence: {\n\t\t\t\tprefix: [{ domain: \"string\" }, { domain: \"number\" }],\n\t\t\t\tvariadic: { unit: 1 }\n\t\t\t}\n\t\t})\n\t\tconst jsonSchema = toJsonSchema(node)\n\t\tattest(jsonSchema).snap({\n\t\t\ttype: \"array\",\n\t\t\tminItems: 2,\n\t\t\tprefixItems: [{ type: \"string\" }, { type: \"number\" }],\n\t\t\titems: { const: 1 }\n\t\t})\n\t})\n\n\tit(\"preserves meta\", () => {\n\t\tconst node = rootSchema({\n\t\t\tdomain: \"object\",\n\t\t\trequired: [\n\t\t\t\t{\n\t\t\t\t\tkey: \"foo\",\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\tdomain: \"string\",\n\t\t\t\t\t\tmeta: \"a foo\"\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tkey: \"bar\",\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\tdomain: \"number\",\n\t\t\t\t\t\tmeta: {\n\t\t\t\t\t\t\ttitle: \"bar\",\n\t\t\t\t\t\t\texamples: [1337, 7331]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t],\n\t\t\toptional: {\n\t\t\t\tkey: \"baz\",\n\t\t\t\tvalue: { \"meta.deprecated\": true, unit: 1 }\n\t\t\t}\n\t\t})\n\n\t\tconst jsonSchema = toJsonSchema(node)\n\n\t\tattest(jsonSchema).snap({\n\t\t\ttype: \"object\",\n\t\t\tproperties: {\n\t\t\t\tbar: { type: \"number\", title: \"bar\", examples: [1337, 7331] },\n\t\t\t\tfoo: { type: \"string\", description: \"a foo\" },\n\t\t\t\tbaz: { const: 1, deprecated: true }\n\t\t\t},\n\t\t\trequired: [\"bar\", \"foo\"]\n\t\t})\n\t})\n\n\tit(\"cyclic\", () => {\n\t\tconst schema = toJsonSchema($ark.intrinsic.jsonObject)\n\n\t\tattest(schema).snap({\n\t\t\t$ref: \"#/$defs/intersection11\",\n\t\t\t$defs: {\n\t\t\t\tintersection11: {\n\t\t\t\t\ttype: \"object\",\n\t\t\t\t\tadditionalProperties: { $ref: \"#/$defs/jsonData1\" }\n\t\t\t\t},\n\t\t\t\tjsonData1: {\n\t\t\t\t\tanyOf: [\n\t\t\t\t\t\t{ $ref: \"#/$defs/intersection11\" },\n\t\t\t\t\t\t{ type: \"number\" },\n\t\t\t\t\t\t{ type: \"string\" },\n\t\t\t\t\t\t{ type: \"boolean\" },\n\t\t\t\t\t\t{ type: \"null\" }\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\tunion7: {\n\t\t\t\t\tanyOf: [{ $ref: \"#/$defs/intersection11\" }, { type: \"boolean\" }]\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t})\n\n\tit(\"unions of literal values as enums\", () => {\n\t\tconst Bit = rootSchemaScope.units([0, 1])\n\n\t\tattest(toJsonSchema(Bit)).snap({ enum: [0, 1] })\n\t})\n\n\tit(\"unions of literal values with metadata not enums\", () => {\n\t\tconst Bit = rootSchema([\n\t\t\t{ unit: 0 },\n\t\t\t{ unit: 1, \"meta.description\": \"one\" }\n\t\t])\n\n\t\tattest(toJsonSchema(Bit)).snap({\n\t\t\tanyOf: [{ const: 0 }, { const: 1, description: \"one\" }]\n\t\t})\n\t})\n\n\tit(\"includes default for primitive prop\", () => {\n\t\tconst T = rootSchema({\n\t\t\tdomain: \"object\",\n\t\t\toptional: [{ key: \"foo\", value: \"number\", default: 0 }]\n\t\t})\n\t\tattest(toJsonSchema(T)).snap({\n\t\t\ttype: \"object\",\n\t\t\tproperties: { foo: { type: \"number\", default: 0 } }\n\t\t})\n\t})\n\n\tit(\"includes default for object prop\", () => {\n\t\tconst T = rootSchema({\n\t\t\tdomain: \"object\",\n\t\t\toptional: [{ key: \"foo\", value: \"Array\", default: () => [] }]\n\t\t})\n\t\tattest(toJsonSchema(T)).snap({\n\t\t\ttype: \"object\",\n\t\t\tproperties: { foo: { type: \"array\", default: [] } }\n\t\t})\n\t})\n\n\tit(\"it includes primitive default for tuple\", () => {\n\t\tconst T = rootSchema({\n\t\t\tproto: \"Array\",\n\t\t\tsequence: {\n\t\t\t\tprefix: [\"number\"],\n\t\t\t\tdefaultables: [[\"string\", \"\"]],\n\t\t\t\toptionals: [\"string\"]\n\t\t\t}\n\t\t})\n\n\t\tattest(toJsonSchema(T)).snap({\n\t\t\ttype: \"array\",\n\t\t\tminItems: 1,\n\t\t\tprefixItems: [\n\t\t\t\t{ type: \"number\" },\n\t\t\t\t{ type: \"string\", default: \"\" },\n\t\t\t\t{ type: \"string\" }\n\t\t\t],\n\t\t\titems: false\n\t\t})\n\t})\n\n\tit(\"it includes object default for tuple\", () => {\n\t\tconst T = rootSchema({\n\t\t\tproto: \"Array\",\n\t\t\tsequence: {\n\t\t\t\tdefaultables: [[\"Array\", () => []]]\n\t\t\t}\n\t\t})\n\n\t\tattest(toJsonSchema(T)).snap({\n\t\t\ttype: \"array\",\n\t\t\tprefixItems: [{ type: \"array\", default: [] }],\n\t\t\titems: false\n\t\t})\n\t})\n\n\tit(\"null generated as type instead of const\", () => {\n\t\tconst T = rootSchema({ unit: null })\n\n\t\tattest(toJsonSchema(T)).snap({ type: \"null\" })\n\t})\n\n\tdescribe(\"unjsonifiable\", () => {\n\t\tit(\"arrayObject\", () => {\n\t\t\tconst T = rootSchema({\n\t\t\t\tproto: \"Array\",\n\t\t\t\tsequence: {\n\t\t\t\t\tvariadic: \"number\"\n\t\t\t\t},\n\t\t\t\trequired: [{ key: \"extra\", value: \"string\" }]\n\t\t\t})\n\n\t\t\tattest(() => T.toJsonSchema()).throws.snap(`ToJsonSchemaError: {\n    code: \"arrayObject\",\n    base: {\n        type: \"array\",\n        items: {\n            type: \"number\"\n        }\n    },\n    object: {\n        type: \"object\",\n        properties: {\n            extra: {\n                type: \"string\"\n            }\n        },\n        required: [\n            \"extra\"\n        ]\n    }\n}`)\n\t\t})\n\n\t\tit(\"arrayPostfix\", () => {\n\t\t\tconst T = rootSchema({\n\t\t\t\tproto: \"Array\",\n\t\t\t\tsequence: {\n\t\t\t\t\tvariadic: \"number\",\n\t\t\t\t\tpostfix: [\"string\"]\n\t\t\t\t}\n\t\t\t})\n\n\t\t\tattest(() => T.toJsonSchema()).throws.snap(`ToJsonSchemaError: {\n    code: \"arrayPostfix\",\n    base: {\n        type: \"array\",\n        minItems: 1,\n        items: {\n            type: \"number\"\n        }\n    },\n    elements: [\n        {\n            type: \"string\"\n        }\n    ]\n}`)\n\t\t})\n\n\t\tit(\"default\", () => {\n\t\t\tconst T = rootSchema({\n\t\t\t\tdomain: \"object\",\n\t\t\t\toptional: [\n\t\t\t\t\t{\n\t\t\t\t\t\tkey: \"foo\",\n\t\t\t\t\t\tvalue: {},\n\t\t\t\t\t\tdefault: 0n\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t})\n\n\t\t\tattest(() => T.toJsonSchema()).throws.snap(`ToJsonSchemaError: {\n    code: \"defaultValue\",\n    base: {},\n    value: 0n\n}`)\n\t\t})\n\n\t\tit(\"functional default\", () => {\n\t\t\tconst T = rootSchema({\n\t\t\t\tdomain: \"object\",\n\t\t\t\toptional: [\n\t\t\t\t\t{\n\t\t\t\t\t\tkey: \"foo\",\n\t\t\t\t\t\tvalue: {},\n\t\t\t\t\t\tdefault: () => 0n\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t})\n\n\t\t\tattest(() => T.toJsonSchema()).throws.snap(`ToJsonSchemaError: {\n    code: \"defaultValue\",\n    base: {},\n    value: 0n\n}`)\n\t\t})\n\n\t\tit(\"domain\", () => {\n\t\t\tconst T = rootSchema(\"bigint\")\n\n\t\t\tattest(() => T.toJsonSchema()).throws.snap(`ToJsonSchemaError: {\n    code: \"domain\",\n    base: {},\n    domain: \"bigint\"\n}`)\n\t\t})\n\n\t\tit(\"morph\", () => {\n\t\t\tconst T = rootSchema({\n\t\t\t\tin: \"string\",\n\t\t\t\tmorphs: [(s: string) => Number.parseInt(s)]\n\t\t\t})\n\n\t\t\tattest(() => T.toJsonSchema()).throws.snap(`ToJsonSchemaError: {\n    code: \"morph\",\n    base: {\n        type: \"string\"\n    },\n    out: null\n}`)\n\t\t})\n\n\t\tit(\"patternIntersection\", () => {\n\t\t\tconst T = rootSchema({\n\t\t\t\tdomain: \"string\",\n\t\t\t\tpattern: [\"^a\", \"z$\"]\n\t\t\t})\n\n\t\t\tattest(() => T.toJsonSchema()).throws.snap(`ToJsonSchemaError: {\n    code: \"patternIntersection\",\n    base: {\n        type: \"string\",\n        pattern: \"^a\"\n    },\n    pattern: \"z$\"\n}`)\n\t\t})\n\n\t\tit(\"predicate\", () => {\n\t\t\tconst T = rootSchema({\n\t\t\t\tdomain: \"string\",\n\t\t\t\tpredicate: function _toJsonSchemaPredicate() {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t})\n\n\t\t\tattest(() => T.toJsonSchema()).throws.snap(`ToJsonSchemaError: {\n    code: \"predicate\",\n    base: {\n        type: \"string\"\n    },\n    predicate: Function(_toJsonSchemaPredicate)\n}`)\n\t\t})\n\n\t\tit(\"proto\", () => {\n\t\t\tconst T = rootSchema({\n\t\t\t\tproto: Map\n\t\t\t})\n\n\t\t\tattest(() => T.toJsonSchema()).throws.snap(`ToJsonSchemaError: {\n    code: \"proto\",\n    base: {},\n    proto: Function(Map)\n}`)\n\t\t})\n\n\t\tit(\"symbolKey\", () => {\n\t\t\tconst T = rootSchema({\n\t\t\t\tdomain: \"object\",\n\t\t\t\trequired: [{ key: Symbol(\"zildjian\"), value: \"string\" }]\n\t\t\t})\n\n\t\t\tattest(() => T.toJsonSchema()).throws.snap(\n\t\t\t\t\"TypeError: Cannot convert a Symbol value to a string\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"unit\", () => {\n\t\t\tconst T = rootSchema({ unit: undefined })\n\n\t\t\tattest(() => T.toJsonSchema()).throws.snap(`ToJsonSchemaError: {\n    code: \"unit\",\n    base: {},\n    unit: undefined\n}`)\n\t\t})\n\n\t\tit(\"after\", () => {\n\t\t\tconst T = rootSchema({\n\t\t\t\tproto: \"Date\",\n\t\t\t\tafter: new Date(\"01-01-2000\")\n\t\t\t})\n\n\t\t\tattest(() =>\n\t\t\t\tT.toJsonSchema({\n\t\t\t\t\tfallback: {\n\t\t\t\t\t\tproto: () => ({ type: \"object\" })\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t).throws.snap(`ToJsonSchemaError: {\n    code: \"date\",\n    base: {}\n}`)\n\t\t})\n\n\t\tit(\"before\", () => {\n\t\t\tconst T = rootSchema({\n\t\t\t\tproto: \"Date\",\n\t\t\t\tbefore: new Date(\"06-01-2000\")\n\t\t\t})\n\n\t\t\tattest(() =>\n\t\t\t\tT.toJsonSchema({\n\t\t\t\t\tfallback: {\n\t\t\t\t\t\tproto: () => ({ type: \"object\" })\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t).throws.snap(`ToJsonSchemaError: {\n    code: \"date\",\n    base: {}\n}`)\n\t\t})\n\t})\n\n\tdescribe(\"fallbacks\", () => {\n\t\tit(\"morph falls back to in\", () => {\n\t\t\tconst T = rootSchema({\n\t\t\t\tin: \"string\",\n\t\t\t\tmorphs: [(s: string) => Number.parseInt(s)]\n\t\t\t})\n\n\t\t\tconst schema = toJsonSchema(T, {\n\t\t\t\tfallback: {\n\t\t\t\t\tmorph: ctx => ({ ...ctx.base, _testOut: ctx.out })\n\t\t\t\t}\n\t\t\t})\n\n\t\t\tattest(schema).unknown.snap({ type: \"string\", _testOut: null })\n\t\t})\n\n\t\tit(\"introspectable out\", () => {\n\t\t\tconst T = rootSchema({\n\t\t\t\tin: \"string\",\n\t\t\t\tmorphs: [(s: string) => Number.parseInt(s), rootSchema(\"number\")]\n\t\t\t})\n\n\t\t\tconst schema = toJsonSchema(T, {\n\t\t\t\tfallback: {\n\t\t\t\t\tmorph: ctx => ({ ...ctx.out, _testIn: ctx.base }) as never\n\t\t\t\t}\n\t\t\t})\n\n\t\t\tattest(schema).unknown.snap({\n\t\t\t\ttype: \"number\",\n\t\t\t\t_testIn: { type: \"string\" }\n\t\t\t})\n\t\t})\n\n\t\tit(\"date supercedes proto\", () => {\n\t\t\tconst T = rootSchema({\n\t\t\t\tproto: \"Date\"\n\t\t\t})\n\n\t\t\tconst schema = toJsonSchema(T, {\n\t\t\t\tfallback: {\n\t\t\t\t\tproto: () => ({ type: \"object\" }),\n\t\t\t\t\tdate: () => ({\n\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\tformat: \"date-time\"\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t})\n\n\t\t\tattest(schema).snap({ type: \"string\", format: \"date-time\" })\n\t\t})\n\n\t\tit(\"date range with fallback\", () => {\n\t\t\tconst T = rootSchema({\n\t\t\t\tproto: \"Date\",\n\t\t\t\tbefore: new Date(\"06-01-2000\")\n\t\t\t})\n\n\t\t\tconst schema = toJsonSchema(T, {\n\t\t\t\tfallback: {\n\t\t\t\t\tproto: () => ({ type: \"object\" }),\n\t\t\t\t\tdate: ctx => ({\n\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\tformat: \"date-time\",\n\t\t\t\t\t\tdescription: `before ${ctx.before?.toISOString()}`\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t})\n\n\t\t\tattest(schema).snap({\n\t\t\t\ttype: \"string\",\n\t\t\t\tformat: \"date-time\",\n\t\t\t\tdescription: \"before 2000-06-01T04:00:00.000Z\"\n\t\t\t})\n\t\t})\n\n\t\tit(\"scope config\", () => {\n\t\t\tconst zildjian = Symbol()\n\t\t\tconst { T } = schemaScope(\n\t\t\t\t{\n\t\t\t\t\tT: rootSchema({\n\t\t\t\t\t\tdomain: \"object\",\n\t\t\t\t\t\trequired: [\n\t\t\t\t\t\t\t{ key: zildjian, value: \"string\" },\n\t\t\t\t\t\t\t{ key: \"valid\", value: \"bigint\" }\n\t\t\t\t\t\t]\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttoJsonSchema: {\n\t\t\t\t\t\tfallback: ctx => ctx.base\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t).export()\n\n\t\t\tconst schema = toJsonSchema(T)\n\n\t\t\tattest(schema).snap({\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: { valid: {} },\n\t\t\t\trequired: [\"valid\"]\n\t\t\t})\n\t\t})\n\n\t\tit(\"default fallback precedence\", () => {\n\t\t\tconst { T } = schemaScope(\n\t\t\t\t{\n\t\t\t\t\tT: rootSchema({\n\t\t\t\t\t\tdomain: \"object\",\n\t\t\t\t\t\trequired: [\n\t\t\t\t\t\t\t{ key: \"valid\", value: \"bigint\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkey: \"patterns\",\n\t\t\t\t\t\t\t\tvalue: { domain: \"string\", pattern: [\"^a\", \"z$\"] }\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t]\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttoJsonSchema: {\n\t\t\t\t\t\tfallback: {\n\t\t\t\t\t\t\tdefault: ctx => ({ ...ctx.base, description: \"defaulted\" }),\n\t\t\t\t\t\t\tdomain: ctx => ({ ...ctx.base, description: \"domain\" })\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t).export()\n\n\t\t\tconst schema = toJsonSchema(T)\n\n\t\t\tattest(schema).snap({\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\tpatterns: { type: \"string\", pattern: \"^a\", description: \"defaulted\" },\n\t\t\t\t\tvalid: { description: \"domain\" }\n\t\t\t\t},\n\t\t\t\trequired: [\"patterns\", \"valid\"]\n\t\t\t})\n\t\t})\n\t})\n})\n"
  },
  {
    "path": "ark/schema/__tests__/morphs.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { intrinsic, rootSchema } from \"@ark/schema\"\nimport { throwError, wellFormedNumberMatcher } from \"@ark/util\"\n\ncontextualize(() => {\n\tit(\"in/out\", () => {\n\t\tconst parseNumber = rootSchema({\n\t\t\tin: {\n\t\t\t\tmeta: \"a well-formed numeric string\",\n\t\t\t\tdomain: \"string\",\n\t\t\t\tpattern: wellFormedNumberMatcher\n\t\t\t},\n\t\t\tmorphs: (s: string) => Number.parseFloat(s)\n\t\t})\n\t\tattest(parseNumber.rawIn.json).snap({\n\t\t\tdomain: \"string\",\n\t\t\tpattern: [\n\t\t\t\t\"^(?:(?!^-0\\\\.?0*$)(?:-?(?:(?:0|[1-9]\\\\d*)(?:\\\\.\\\\d*[1-9])?)?))$\"\n\t\t\t],\n\t\t\tmeta: \"a well-formed numeric string\"\n\t\t})\n\t\tattest(parseNumber.rawOut.json).snap({})\n\t})\n\n\tit(\"in/out union\", () => {\n\t\tconst n = rootSchema([\n\t\t\t{\n\t\t\t\tin: \"string\",\n\t\t\t\tmorphs: [(s: string) => Number.parseFloat(s), intrinsic.number]\n\t\t\t},\n\t\t\t\"number\"\n\t\t])\n\t\tattest(n.rawIn.expression).snap(\"number | string\")\n\t\tattest(n.rawOut.expression).snap(\"number\")\n\t})\n\n\tcontextualize.each(\n\t\t\"declared\",\n\t\t() => {\n\t\t\tconst declared = rootSchema({\n\t\t\t\tmeta: \"declared\",\n\t\t\t\tpredicate: () => throwError(\"declared node should not be invoked\")\n\t\t\t}).assertHasKind(\"intersection\")\n\n\t\t\tconst declaredMorph = rootSchema({\n\t\t\t\tmorphs: (s: string) => JSON.parse(s),\n\t\t\t\tdeclaredIn: declared,\n\t\t\t\tdeclaredOut: declared\n\t\t\t})\n\n\t\t\treturn { declared, declaredMorph }\n\t\t},\n\t\tit => {\n\t\t\tit(\"preserves and extracts the declarations without calling them\", ({\n\t\t\t\tdeclaredMorph,\n\t\t\t\tdeclared\n\t\t\t}) => {\n\t\t\t\tattest(declaredMorph.json).equals({\n\t\t\t\t\tmorphs: declaredMorph.assertHasKind(\"morph\").serializedMorphs,\n\t\t\t\t\tdeclaredIn: declared.json,\n\t\t\t\t\tdeclaredOut: declared.json\n\t\t\t\t})\n\n\t\t\t\tattest(declared.description).snap(\"declared\")\n\t\t\t\tattest(declaredMorph.rawIn.description).equals(declared.description)\n\t\t\t\tattest(declaredMorph.rawOut.description).equals(declared.description)\n\n\t\t\t\t// declared validator should not be called\n\t\t\t\tattest(declaredMorph(\"{}\")).equals({})\n\t\t\t})\n\n\t\t\tit(\"can be piped to declaredOut\", ({ declaredMorph, declared }) => {\n\t\t\t\tconst pipeToNode = rootSchema({\n\t\t\t\t\tin: \"string\",\n\t\t\t\t\tmorphs: [(s: string) => s.slice(1), declaredMorph]\n\t\t\t\t})\n\n\t\t\t\tattest(pipeToNode.rawOut.description).equals(declared.description)\n\n\t\t\t\tattest(pipeToNode(\"z{}\")).equals({})\n\t\t\t})\n\t\t}\n\t)\n})\n"
  },
  {
    "path": "ark/schema/__tests__/onFail.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { intrinsic } from \"@ark/schema\"\n\ncontextualize(() => {\n\tit(\"traverse always returns ArkErrors\", () => {\n\t\tconst s = intrinsic.string.configureReferences(\n\t\t\t{\n\t\t\t\tonFail: () => \"foo\"\n\t\t\t},\n\t\t\t\"self\"\n\t\t)\n\t\tattest(s(5)).equals(\"foo\")\n\t\tattest(s.traverse(5)?.toString()).snap(\"must be a string (was a number)\")\n\t})\n\n\tit(\"assert always throws ArkErrors\", () => {\n\t\tconst n = intrinsic.number.configureReferences(\n\t\t\t{\n\t\t\t\tonFail: () => \"foo\"\n\t\t\t},\n\t\t\t\"self\"\n\t\t)\n\t\tattest(() => n.assert(\"five\"))\n\t})\n\n\tit(\"passed onFail overrides meta\", () => {\n\t\tconst b = intrinsic.bigint.configureReferences(\n\t\t\t{\n\t\t\t\tonFail: () => \"foo\"\n\t\t\t},\n\t\t\t\"self\"\n\t\t)\n\n\t\tattest(b(5, undefined, () => \"bar\")).equals(\"bar\")\n\t})\n})\n"
  },
  {
    "path": "ark/schema/__tests__/parse.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { rootSchema } from \"@ark/schema\"\n\ncontextualize(() => {\n\tit(\"single constraint\", () => {\n\t\tconst T = rootSchema({ domain: \"string\", pattern: \".*\" })\n\t\tattest(T.json).snap({ domain: \"string\", pattern: [\".*\"] })\n\t})\n\n\tit(\"multiple constraints\", () => {\n\t\tconst L = rootSchema({\n\t\t\tdomain: \"number\",\n\t\t\tdivisor: 3,\n\t\t\tmin: 5\n\t\t})\n\t\tconst R = rootSchema({\n\t\t\tdomain: \"number\",\n\t\t\tdivisor: 5\n\t\t})\n\t\tconst T = L.and(R)\n\n\t\tattest(T.json).snap({\n\t\t\tdomain: \"number\",\n\t\t\tdivisor: 15,\n\t\t\tmin: 5\n\t\t})\n\t})\n\n\tit(\"throws on reduced minLength disjoint\", () => {\n\t\tattest(() =>\n\t\t\trootSchema({\n\t\t\t\tproto: Array,\n\t\t\t\tmaxLength: 0,\n\t\t\t\tsequence: {\n\t\t\t\t\tprefix: [\"number\"],\n\t\t\t\t\tvariadic: \"number\"\n\t\t\t\t}\n\t\t\t})\n\t\t).throws.snap(\n\t\t\t\"ParseError: Intersection of == 0 and >= 1 results in an unsatisfiable type\"\n\t\t)\n\t})\n})\n"
  },
  {
    "path": "ark/schema/__tests__/props.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { rootSchema } from \"@ark/schema\"\n\ncontextualize(() => {\n\tit(\"normalizes prop order\", () => {\n\t\tconst L = rootSchema({\n\t\t\tdomain: \"object\",\n\t\t\trequired: [\n\t\t\t\t{ key: \"a\", value: \"string\" },\n\t\t\t\t{ key: \"b\", value: \"number\" }\n\t\t\t]\n\t\t})\n\t\tconst R = rootSchema({\n\t\t\tdomain: \"object\",\n\t\t\trequired: [\n\t\t\t\t{ key: \"b\", value: \"number\" },\n\t\t\t\t{ key: \"a\", value: \"string\" }\n\t\t\t]\n\t\t})\n\t\tattest(L.json).equals(R.json)\n\t})\n\n\tit(\"preserves matching literal\", () => {\n\t\tconst L = rootSchema({\n\t\t\tdomain: \"object\",\n\t\t\tindex: [{ signature: \"string\", value: \"string\" }],\n\t\t\tundeclared: \"reject\"\n\t\t})\n\n\t\tconst R = rootSchema({\n\t\t\tdomain: \"object\",\n\t\t\trequired: [{ key: \"a\", value: { unit: \"foo\" } }]\n\t\t})\n\n\t\tconst T = L.and(R)\n\n\t\tattest(T.json).snap({\n\t\t\tundeclared: \"reject\",\n\t\t\trequired: [{ key: \"a\", value: { unit: \"foo\" } }],\n\t\t\tindex: [{ value: \"string\", signature: \"string\" }],\n\t\t\tdomain: \"object\"\n\t\t})\n\t})\n\n\tit(\"preserves matching index\", () => {\n\t\tconst L = rootSchema({\n\t\t\tdomain: \"object\",\n\t\t\tindex: [{ signature: \"string\", value: \"string\" }],\n\t\t\tundeclared: \"reject\"\n\t\t})\n\n\t\tconst R = rootSchema({\n\t\t\tdomain: \"object\",\n\t\t\tindex: [{ signature: \"string\", value: { unit: \"foo\" } }]\n\t\t})\n\n\t\tconst T = L.and(R)\n\n\t\tattest(T.json).snap({\n\t\t\tundeclared: \"reject\",\n\t\t\tindex: [{ signature: \"string\", value: { unit: \"foo\" } }],\n\t\t\tdomain: \"object\"\n\t\t})\n\t})\n\n\tconst startingWithA = rootSchema({ domain: \"string\", pattern: /^a.*/ })\n\n\tconst endingWithZ = rootSchema({ domain: \"string\", pattern: /.*z$/ })\n\n\tconst startingWithAAndEndingWithZ = rootSchema({\n\t\tdomain: \"string\",\n\t\tpattern: [/^a.*/, /.*z$/]\n\t})\n\n\tit(\"intersects nonsubtype index signatures\", () => {\n\t\tconst L = rootSchema({\n\t\t\tdomain: \"object\",\n\t\t\tindex: [{ signature: startingWithA, value: \"string\" }],\n\t\t\tundeclared: \"reject\"\n\t\t})\n\n\t\tconst R = rootSchema({\n\t\t\tdomain: \"object\",\n\t\t\tindex: [{ signature: endingWithZ, value: { unit: \"foo\" } }]\n\t\t})\n\n\t\tconst Result = L.and(R)\n\n\t\tconst Expected = rootSchema({\n\t\t\tdomain: \"object\",\n\t\t\tindex: [\n\t\t\t\t{ signature: startingWithA, value: \"string\" },\n\t\t\t\t{ signature: startingWithAAndEndingWithZ, value: { unit: \"foo\" } }\n\t\t\t],\n\t\t\tundeclared: \"reject\"\n\t\t})\n\n\t\tattest(Result.json).snap(Expected.json)\n\t})\n\n\tit(\"intersects non-subtype strict index signatures\", () => {\n\t\tconst L = rootSchema({\n\t\t\tdomain: \"object\",\n\t\t\tindex: [{ signature: startingWithA, value: endingWithZ }],\n\t\t\tundeclared: \"reject\"\n\t\t})\n\n\t\tconst R = rootSchema({\n\t\t\tdomain: \"object\",\n\t\t\tindex: [{ signature: endingWithZ, value: startingWithA }],\n\t\t\tundeclared: \"reject\"\n\t\t})\n\n\t\tconst Result = L.and(R)\n\n\t\tconst Expected = rootSchema({\n\t\t\tdomain: \"object\",\n\t\t\tindex: [\n\t\t\t\t{\n\t\t\t\t\tsignature: startingWithAAndEndingWithZ,\n\t\t\t\t\tvalue: startingWithAAndEndingWithZ\n\t\t\t\t}\n\t\t\t],\n\t\t\tundeclared: \"reject\"\n\t\t})\n\n\t\tattest(Result.json).equals(Expected.json)\n\t})\n\n\tit(\"prunes undeclared optional\", () => {\n\t\tconst L = rootSchema({\n\t\t\tdomain: \"object\",\n\t\t\trequired: [{ key: \"a\", value: \"string\" }],\n\t\t\tundeclared: \"reject\"\n\t\t})\n\n\t\tconst R = rootSchema({\n\t\t\tdomain: \"object\",\n\t\t\toptional: [{ key: \"b\", value: \"number\" }]\n\t\t})\n\n\t\tconst T = L.and(R)\n\n\t\tattest(T.json).snap(L.json)\n\t})\n\n\tit(\"prunes undeclared index\", () => {\n\t\tconst L = rootSchema({\n\t\t\tdomain: \"object\",\n\t\t\tindex: [{ signature: \"string\", value: \"string\" }]\n\t\t})\n\n\t\tconst R = rootSchema({\n\t\t\tdomain: \"object\",\n\t\t\trequired: [{ key: \"a\", value: { unit: \"foo\" } }],\n\t\t\tundeclared: \"reject\"\n\t\t})\n\n\t\tconst T = L.and(R)\n\n\t\tattest(T.json).snap({\n\t\t\tundeclared: \"reject\",\n\t\t\trequired: [{ key: \"a\", value: { unit: \"foo\" } }],\n\t\t\tdomain: \"object\"\n\t\t})\n\t})\n\n\tit(\"undeclared required\", () => {\n\t\tconst L = rootSchema({\n\t\t\tdomain: \"object\",\n\t\t\trequired: [\n\t\t\t\t{ key: \"a\", value: \"string\" },\n\t\t\t\t{ key: \"b\", value: \"number\" }\n\t\t\t]\n\t\t})\n\t\tconst R = rootSchema({\n\t\t\tdomain: \"object\",\n\t\t\trequired: [{ key: \"a\", value: \"string\" }],\n\t\t\tundeclared: \"reject\"\n\t\t})\n\n\t\tattest(() => L.and(R)).throws.snap(\n\t\t\t\"ParseError: Intersection at b of number and never results in an unsatisfiable type\"\n\t\t)\n\t})\n\n\tit(\"delete & reject\", () => {\n\t\tconst L = rootSchema({\n\t\t\tdomain: \"object\",\n\t\t\trequired: [{ key: \"a\", value: \"string\" }],\n\t\t\tundeclared: \"delete\"\n\t\t})\n\t\tconst R = rootSchema({\n\t\t\tdomain: \"object\",\n\t\t\trequired: [{ key: \"a\", value: \"string\" }],\n\t\t\tundeclared: \"reject\"\n\t\t})\n\n\t\tconst T = L.and(R)\n\n\t\tattest(T.json).equals(R.json)\n\t})\n})\n"
  },
  {
    "path": "ark/schema/__tests__/proto.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { node, rootSchema } from \"@ark/schema\"\n\ncontextualize(() => {\n\tit(\"normalizes node schema\", () => {\n\t\tconst d = node(\"proto\", Date)\n\t\tattest(d.json).snap({ proto: \"Date\" })\n\n\t\tconst reparsed = rootSchema(d)\n\t\tattest(reparsed.json).equals(d.json)\n\t\tattest(reparsed.id).equals(d.id)\n\t})\n\n\tit(\"can parse proto from string\", () => {\n\t\tconst T = rootSchema({\n\t\t\tdomain: \"object\",\n\t\t\trequired: [{ key: \"foo\", value: \"Array\" }]\n\t\t})\n\n\t\tattest(T).snap({\n\t\t\trequired: [{ key: \"foo\", value: \"Array\" }],\n\t\t\tdomain: \"object\"\n\t\t})\n\n\t\tattest(T.get(\"foo\")).snap({ proto: \"Array\" })\n\t})\n})\n"
  },
  {
    "path": "ark/schema/__tests__/scope.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { rootSchema, schemaScope } from \"@ark/schema\"\n\ncontextualize(() => {\n\tit(\"has jit in scope\", () => {\n\t\tconst types = schemaScope({\n\t\t\tfoo: {\n\t\t\t\tdomain: \"string\"\n\t\t\t}\n\t\t}).export()\n\n\t\tattest(types.foo.precompilation).satisfies(\"string\")\n\t})\n\n\tit(\"has jit standalone\", () => {\n\t\tconst node = rootSchema({\n\t\t\tdomain: \"string\"\n\t\t})\n\n\t\tattest(node.precompilation).satisfies(\"string\")\n\t})\n\n\tit(\"reference\", () => {\n\t\tconst types = schemaScope({\n\t\t\ta: {\n\t\t\t\tdomain: \"object\",\n\t\t\t\trequired: {\n\t\t\t\t\tkey: \"b\",\n\t\t\t\t\tvalue: \"$b\"\n\t\t\t\t}\n\t\t\t},\n\t\t\tb: {\n\t\t\t\tdomain: \"string\"\n\t\t\t}\n\t\t}).export()\n\t\tattest(types.a.json).snap({\n\t\t\tdomain: \"object\",\n\t\t\trequired: [{ key: \"b\", value: \"string\" }]\n\t\t})\n\t\tattest(types.b.json).snap({ domain: \"string\" })\n\t})\n\tit(\"cyclic\", () => {\n\t\tconst types = schemaScope({\n\t\t\ta: {\n\t\t\t\tdomain: \"object\",\n\t\t\t\trequired: {\n\t\t\t\t\tkey: \"b\",\n\t\t\t\t\tvalue: \"$b\"\n\t\t\t\t}\n\t\t\t},\n\t\t\tb: {\n\t\t\t\tdomain: \"object\",\n\t\t\t\trequired: {\n\t\t\t\t\tkey: \"a\",\n\t\t\t\t\tvalue: \"$a\"\n\t\t\t\t}\n\t\t\t}\n\t\t}).export()\n\n\t\tattest(types.a.json).snap({\n\t\t\tdomain: \"object\",\n\t\t\trequired: [\n\t\t\t\t{\n\t\t\t\t\tkey: \"b\",\n\t\t\t\t\tvalue: { domain: \"object\", required: [{ key: \"a\", value: \"$a\" }] }\n\t\t\t\t}\n\t\t\t]\n\t\t})\n\n\t\tattest(types.b.json).snap({\n\t\t\tdomain: \"object\",\n\t\t\trequired: [{ key: \"a\", value: \"$a\" }]\n\t\t})\n\n\t\tconst a = {} as { b: typeof b }\n\t\tconst b = { a }\n\t\ta.b = b\n\n\t\tconst almostB = { a: { b: { a: { b: \"whoops\" } } } }\n\n\t\tattest(types.a.allows(a)).equals(true)\n\t\tattest(types.a(a)).equals(a)\n\t\tattest(types.b(b)).equals(b)\n\t\tattest(types.b.allows(b)).equals(true)\n\t\tattest(types.b.allows(almostB)).equals(false)\n\t\tattest(types.b(almostB)?.toString()).snap(\n\t\t\t\"a.b.a.b must be an object (was a string)\"\n\t\t)\n\t})\n})\n"
  },
  {
    "path": "ark/schema/__tests__/select.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport {\n\trootSchema,\n\ttype BaseNode,\n\ttype DomainNode,\n\ttype Intersection,\n\ttype nodeOfKind,\n\ttype PatternNode\n} from \"@ark/schema\"\n\ncontextualize(() => {\n\tconst T = rootSchema({\n\t\tdomain: \"object\",\n\t\trequired: [{ key: \"foo\", value: \"string\" }]\n\t}).assertHasKind(\"intersection\")\n\n\tit(\"kind\", () => {\n\t\tconst result = rootSchema({ domain: \"string\" }).select(\"domain\")\n\t\tattest<DomainNode[]>(result).snap([{ domain: \"string\" }])\n\t})\n\n\tit(\"self\", () => {\n\t\tconst selfResult = T.select(\"self\")\n\t\tattest<Intersection.Node[]>(selfResult).snap([\n\t\t\t{ required: [{ key: \"foo\", value: \"string\" }], domain: \"object\" }\n\t\t])\n\t})\n\n\tit(\"children\", () => {\n\t\tconst children = T.select(\"child\")\n\t\tattest<nodeOfKind<\"intersection\" | Intersection.ChildKind>[]>(\n\t\t\tchildren\n\t\t).snap([\n\t\t\t{ domain: \"object\" },\n\t\t\t{ required: [{ key: \"foo\", value: \"string\" }] }\n\t\t])\n\t})\n\n\tit(\"shallow\", () => {\n\t\tconst shallow = T.select(\"shallow\")\n\t\tattest<BaseNode[]>(shallow).snap([\n\t\t\t{ required: [{ key: \"foo\", value: \"string\" }], domain: \"object\" },\n\t\t\t{ domain: \"object\" },\n\t\t\t{ required: [{ key: \"foo\", value: \"string\" }] },\n\t\t\t{ key: \"foo\", value: \"string\" }\n\t\t])\n\t})\n\n\tit(\"references\", () => {\n\t\tconst refs = T.select(\"references\")\n\t\tattest<BaseNode[]>(refs).snap([\n\t\t\t{ required: [{ key: \"foo\", value: \"string\" }], domain: \"object\" },\n\t\t\t{ domain: \"object\" },\n\t\t\t{ required: [{ key: \"foo\", value: \"string\" }] },\n\t\t\t{ key: \"foo\", value: \"string\" },\n\t\t\t{ domain: \"string\" }\n\t\t])\n\t})\n\n\tit(\"predicate\", () => {\n\t\tconst domains = T.select(n => n.hasKind(\"domain\"))\n\t\tattest<DomainNode[]>(domains).snap([\n\t\t\t{ domain: \"object\" },\n\t\t\t{ domain: \"string\" }\n\t\t])\n\t})\n\n\tit(\"find\", () => {\n\t\tconst domain = T.select({ method: \"find\", kind: \"domain\" })\n\t\tattest<DomainNode | undefined>(domain).snap({ domain: \"object\" })\n\n\t\tconst pattern = T.select({ method: \"find\", kind: \"pattern\" })\n\t\tattest<PatternNode | undefined>(pattern).snap(undefined)\n\t})\n\n\tit(\"assertFind\", () => {\n\t\tconst domain = T.select({ method: \"assertFind\", kind: \"domain\" })\n\t\tattest<DomainNode>(domain).snap({ domain: \"object\" })\n\n\t\tattest(() =>\n\t\t\tT.select({ method: \"assertFind\", kind: \"pattern\" })\n\t\t).throws.snap(\n\t\t\t'Error: Type<{ foo: string }> had no references matching {\"boundary\":\"references\",\"method\":\"assertFind\",\"kind\":\"pattern\"}.'\n\t\t)\n\t})\n\n\tit(\"assertFilter\", () => {\n\t\tconst domains = T.select({ method: \"assertFilter\", kind: \"domain\" })\n\t\tattest<[DomainNode, ...DomainNode[]]>(domains).snap([\n\t\t\t{ domain: \"object\" },\n\t\t\t{ domain: \"string\" }\n\t\t])\n\n\t\tattest(() =>\n\t\t\tT.select({ method: \"assertFilter\", kind: \"pattern\" })\n\t\t).throws.snap(\n\t\t\t'Error: Type<{ foo: string }> had no references matching {\"boundary\":\"references\",\"method\":\"assertFilter\",\"kind\":\"pattern\"}.'\n\t\t)\n\t})\n\n\tdescribe(\"completions\", () => {\n\t\tit(\"shallow completions\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => T.select(\"\")).completions({\n\t\t\t\t\"\": [\n\t\t\t\t\t\"after\",\n\t\t\t\t\t\"alias\",\n\t\t\t\t\t\"before\",\n\t\t\t\t\t\"child\",\n\t\t\t\t\t\"divisor\",\n\t\t\t\t\t\"domain\",\n\t\t\t\t\t\"exactLength\",\n\t\t\t\t\t\"index\",\n\t\t\t\t\t\"intersection\",\n\t\t\t\t\t\"max\",\n\t\t\t\t\t\"maxLength\",\n\t\t\t\t\t\"min\",\n\t\t\t\t\t\"minLength\",\n\t\t\t\t\t\"morph\",\n\t\t\t\t\t\"optional\",\n\t\t\t\t\t\"pattern\",\n\t\t\t\t\t\"predicate\",\n\t\t\t\t\t\"proto\",\n\t\t\t\t\t\"references\",\n\t\t\t\t\t\"required\",\n\t\t\t\t\t\"self\",\n\t\t\t\t\t\"sequence\",\n\t\t\t\t\t\"shallow\",\n\t\t\t\t\t\"structure\",\n\t\t\t\t\t\"union\",\n\t\t\t\t\t\"unit\"\n\t\t\t\t]\n\t\t\t})\n\t\t})\n\n\t\tit(\"composite key completions\", () => {\n\t\t\tattest(() =>\n\t\t\t\tT.select({\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\"\": {} as any\n\t\t\t\t})\n\t\t\t).completions({ \"\": [\"boundary\", \"kind\", \"method\"] })\n\t\t})\n\n\t\tit(\"composite kind completions\", () => {\n\t\t\tattest(() =>\n\t\t\t\tT.select({\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tkind: \"\"\n\t\t\t\t})\n\t\t\t).completions({\n\t\t\t\t\"\": [\n\t\t\t\t\t\"after\",\n\t\t\t\t\t\"alias\",\n\t\t\t\t\t\"before\",\n\t\t\t\t\t\"divisor\",\n\t\t\t\t\t\"domain\",\n\t\t\t\t\t\"exactLength\",\n\t\t\t\t\t\"index\",\n\t\t\t\t\t\"intersection\",\n\t\t\t\t\t\"max\",\n\t\t\t\t\t\"maxLength\",\n\t\t\t\t\t\"min\",\n\t\t\t\t\t\"minLength\",\n\t\t\t\t\t\"morph\",\n\t\t\t\t\t\"optional\",\n\t\t\t\t\t\"pattern\",\n\t\t\t\t\t\"predicate\",\n\t\t\t\t\t\"proto\",\n\t\t\t\t\t\"required\",\n\t\t\t\t\t\"sequence\",\n\t\t\t\t\t\"structure\",\n\t\t\t\t\t\"union\",\n\t\t\t\t\t\"unit\"\n\t\t\t\t]\n\t\t\t})\n\t\t})\n\n\t\tit(\"composite boundary completions\", () => {\n\t\t\tattest(() =>\n\t\t\t\tT.select({\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tboundary: \"\"\n\t\t\t\t})\n\t\t\t).completions({ \"\": [\"child\", \"references\", \"self\", \"shallow\"] })\n\t\t})\n\n\t\tit(\"composite method completions\", () => {\n\t\t\tattest(() =>\n\t\t\t\tT.select({\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tmethod: \"\"\n\t\t\t\t})\n\t\t\t).completions({ \"\": [\"assertFilter\", \"assertFind\", \"filter\", \"find\"] })\n\t\t})\n\t})\n\n\tit(\"non-narrowing where\", () => {\n\t\tconst result = T.select({\n\t\t\tkind: \"domain\",\n\t\t\twhere: d => d.domain === \"string\"\n\t\t})\n\t\tattest<DomainNode[]>(result).snap([{ domain: \"string\" }])\n\t})\n\n\tit(\"predicate narrows kind\", () => {\n\t\ttype StringDomain = DomainNode & { domain: string }\n\t\tconst result = T.select({\n\t\t\tkind: \"domain\",\n\t\t\twhere: (d): d is StringDomain => d.domain === \"string\"\n\t\t})\n\t\tattest<StringDomain[]>(result).snap([{ domain: \"string\" }])\n\t})\n})\n"
  },
  {
    "path": "ark/schema/__tests__/union.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { rootSchema, writeOrderedIntersectionMessage } from \"@ark/schema\"\n\ncontextualize(() => {\n\tit(\"binary\", () => {\n\t\tconst L = rootSchema([\n\t\t\t{\n\t\t\t\tdomain: \"number\",\n\t\t\t\tdivisor: 2\n\t\t\t},\n\t\t\t{\n\t\t\t\tdomain: \"number\",\n\t\t\t\tdivisor: 3\n\t\t\t}\n\t\t])\n\t\tconst R = rootSchema({\n\t\t\tdomain: \"number\",\n\t\t\tdivisor: 5\n\t\t})\n\t\tconst T = L.and(R)\n\t\tattest(T.json).snap([\n\t\t\t{ domain: \"number\", divisor: 10 },\n\t\t\t{ domain: \"number\", divisor: 15 }\n\t\t])\n\t})\n\n\tit(\"reduces union\", () => {\n\t\tconst n = rootSchema([\"number\", {}, { unit: 5 }])\n\t\tattest(n.json).snap({})\n\t})\n\n\tit(\"union of all types reduced to unknown\", () => {\n\t\tconst n = rootSchema([\n\t\t\t\"string\",\n\t\t\t\"number\",\n\t\t\t\"object\",\n\t\t\t\"bigint\",\n\t\t\t\"symbol\",\n\t\t\t{ unit: true },\n\t\t\t{ unit: false },\n\t\t\t{ unit: null },\n\t\t\t{ unit: undefined }\n\t\t])\n\t\tattest(n.json).snap({})\n\t})\n\n\tit(\"normalizes union order\", () => {\n\t\tconst L = rootSchema([\"number\", \"string\"])\n\t\tconst R = rootSchema([\"string\", \"number\"])\n\t\tattest(L.json).equals(R.json)\n\t})\n\n\tit(\"doesn't normalize ordered unions\", () => {\n\t\tconst L = rootSchema({\n\t\t\tbranches: [\"string\", \"number\"],\n\t\t\tordered: true\n\t\t})\n\t\tconst R = rootSchema({\n\t\t\tbranches: [\"number\", \"string\"],\n\t\t\tordered: true\n\t\t})\n\t\tattest(L.equals(R)).equals(false)\n\t})\n\n\tit(\"reducible intersection with union\", () => {\n\t\tconst L = rootSchema({\n\t\t\tdomain: \"string\",\n\t\t\tminLength: 1\n\t\t})\n\t\tconst R = rootSchema([\"string\", Array])\n\t\tconst T = L.and(R)\n\t\tattest(T.json).equals(L.json)\n\t})\n\n\tit(\"unordered union with ordered union\", () => {\n\t\tconst L = rootSchema({\n\t\t\tbranches: [\"string\", \"number\"],\n\t\t\tordered: true\n\t\t})\n\t\tconst R = rootSchema([\"number\", \"string\"])\n\t\tconst T = L.and(R)\n\t\tattest(T.json).equals(L.json)\n\t})\n\n\tit(\"intersection of ordered unions\", () => {\n\t\tconst L = rootSchema({\n\t\t\tbranches: [\"string\", \"number\"],\n\t\t\tordered: true\n\t\t})\n\t\tconst R = rootSchema({\n\t\t\tbranches: [\"number\", \"string\"],\n\t\t\tordered: true\n\t\t})\n\n\t\tattest(() => L.and(R)).throws(\n\t\t\twriteOrderedIntersectionMessage(\"string | number\", \"number | string\")\n\t\t)\n\t})\n})\n"
  },
  {
    "path": "ark/schema/__tests__/unit.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { registeredReference, rootSchema } from \"@ark/schema\"\n\ncontextualize(() => {\n\tit(\"string allows\", () => {\n\t\tconst T = rootSchema({ unit: \"foo\" })\n\t\tattest(T.json).snap({ unit: \"foo\" })\n\t\tattest(T.allows(\"foo\")).equals(true)\n\t\tattest(T.allows(\"bar\")).equals(false)\n\t})\n\n\tit(\"string apply\", () => {\n\t\tconst T = rootSchema({ unit: \"foo\" })\n\t\tattest(T.json).snap({ unit: \"foo\" })\n\t\tattest(T(\"foo\")).equals(\"foo\")\n\t\tattest(T(\"bar\")?.toString()).snap('must be \"foo\" (was \"bar\")')\n\t\tattest(T(5)?.toString()).snap('must be \"foo\" (was 5)')\n\t})\n\tit(\"treats equivalent dates as equal\", () => {\n\t\tconst L = rootSchema({ unit: new Date(1337) })\n\t\tconst R = rootSchema({ unit: new Date(1337) })\n\t\tattest(L.json).snap({ unit: \"1970-01-01T00:00:01.337Z\" })\n\t\tattest(L.json).equals(R.json)\n\t\tattest(L.equals(R)).equals(true)\n\t})\n\n\tit(\"bigint\", () => {\n\t\tconst T = rootSchema({ unit: 7n })\n\t\t// serializes to string for JSON\n\t\tattest(T.json).snap({ unit: \"7n\" })\n\t\t// preserves the bigint for context\n\t\tattest(T.internal.assertHasKind(\"unit\").errorContext).equals({\n\t\t\tcode: \"unit\",\n\t\t\tdescription: \"7n\",\n\t\t\tunit: 7n,\n\t\t\tmeta: {}\n\t\t})\n\t\tattest(T.allows(6n)).equals(false)\n\t\tattest(T.allows(7n)).equals(true)\n\t\tattest(T.allows(8n)).equals(false)\n\t})\n\n\tit(\"undefined\", () => {\n\t\tconst T = rootSchema({ unit: undefined })\n\t\tattest(T.json).snap({ unit: \"undefined\" })\n\t\tattest(T.internal.assertHasKind(\"unit\").errorContext).equals({\n\t\t\tcode: \"unit\",\n\t\t\tdescription: \"undefined\",\n\t\t\tunit: undefined,\n\t\t\tmeta: {}\n\t\t})\n\t\tattest(T.allows(null)).equals(false)\n\t\tattest(T.allows(undefined)).equals(true)\n\t\tattest(T.allows(\"undefined\")).equals(false)\n\t})\n\n\tit(\"symbol\", () => {\n\t\t// this symbol description should not be reused in other tests\n\t\tconst status = Symbol(\"status\")\n\t\tconst T = rootSchema({ unit: status })\n\t\t// serializes to string for JSON\n\t\tattest(T.json).snap({ unit: \"$ark.status\" })\n\t\t// preserves the symbol for context\n\t\tattest(T.internal.assertHasKind(\"unit\").errorContext).equals({\n\t\t\tcode: \"unit\",\n\t\t\tdescription: \"Symbol(status)\",\n\t\t\tunit: status,\n\t\t\tmeta: {}\n\t\t})\n\t\tattest(T.allows(status)).equals(true)\n\t\tattest(T.allows(Symbol(\"test\"))).equals(false)\n\t})\n\n\tit(\"object reference\", () => {\n\t\tconst o = new Object()\n\t\tconst ref = registeredReference(o)\n\t\tconst T = rootSchema({ unit: o })\n\t\tattest(T.json).snap({ unit: ref })\n\t\tattest(T.internal.assertHasKind(\"unit\").errorContext).equals({\n\t\t\tcode: \"unit\",\n\t\t\tdescription: \"{}\",\n\t\t\tunit: o,\n\t\t\tmeta: {}\n\t\t})\n\t\tattest(T.allows(o)).equals(true)\n\t\tattest(T.allows(new Object())).equals(false)\n\t})\n\n\tit(\"NaN\", () => {\n\t\tconst T = rootSchema({ unit: NaN })\n\t\tattest(T.json).snap({ unit: \"NaN\" })\n\t\tattest(T.expression).snap(\"NaN\")\n\t\tattest(T.allows(NaN)).equals(true)\n\t\tattest(T.allows(0)).equals(false)\n\t})\n\n\tit(\"Infinity\", () => {\n\t\tconst T = rootSchema({ unit: Infinity })\n\t\tattest(T.json).snap({ unit: \"Infinity\" })\n\t\tattest(T.expression).snap(\"Infinity\")\n\t\tattest(T.allows(Infinity)).equals(true)\n\t\tattest(T.allows(0)).equals(false)\n\t})\n\n\tit(\"-Infinity\", () => {\n\t\tconst T = rootSchema({ unit: -Infinity })\n\t\tattest(T.json).snap({ unit: \"-Infinity\" })\n\t\tattest(T.expression).snap(\"-Infinity\")\n\t\tattest(T.allows(-Infinity)).equals(true)\n\t\tattest(T.allows(0)).equals(false)\n\t})\n})\n"
  },
  {
    "path": "ark/schema/config.ts",
    "content": "import type { ArkRegistry, requireKeys, show } from \"@ark/util\"\nimport type { intrinsic } from \"./intrinsic.ts\"\nimport type { nodesByRegisteredId } from \"./parse.ts\"\nimport type { TypeMeta } from \"./shared/declare.ts\"\nimport type {\n\tActualConfig,\n\tArkErrorCode,\n\tArkErrors,\n\tExpectedConfig,\n\tMessageConfig,\n\tProblemConfig\n} from \"./shared/errors.ts\"\nimport {\n\tisNodeKind,\n\ttype DescriptionWriter,\n\ttype NodeKind\n} from \"./shared/implement.ts\"\nimport { $ark } from \"./shared/registry.ts\"\nimport { ToJsonSchema } from \"./shared/toJsonSchema.ts\"\nimport type { UndeclaredKeyBehavior } from \"./structure/structure.ts\"\n\nexport interface ArkSchemaRegistry extends ArkRegistry {\n\tintrinsic: typeof intrinsic\n\tconfig: ArkSchemaConfig\n\tdefaultConfig: ResolvedConfig\n\tresolvedConfig: ResolvedConfig\n\tnodesByRegisteredId: typeof nodesByRegisteredId\n}\n\ntype nodeConfigForKind<kind extends NodeKind> = Readonly<\n\tshow<\n\t\t{\n\t\t\tdescription?: DescriptionWriter<kind>\n\t\t} & (kind extends ArkErrorCode ?\n\t\t\t{\n\t\t\t\texpected?: ExpectedConfig<kind>\n\t\t\t\tactual?: ActualConfig<kind>\n\t\t\t\tproblem?: ProblemConfig<kind>\n\t\t\t\tmessage?: MessageConfig<kind>\n\t\t\t}\n\t\t:\t{})\n\t>\n>\n\ntype NodeConfigsByKind = {\n\t[kind in NodeKind]: nodeConfigForKind<kind>\n}\n\nexport type NodeConfig<kind extends NodeKind = NodeKind> =\n\tNodeConfigsByKind[kind]\n\nexport interface UnknownErrorConfigs {\n\texpected?: ExpectedConfig\n\tactual?: ActualConfig\n\tproblem?: ProblemConfig\n\tmessage?: MessageConfig\n}\n\ninterface UnknownNodeConfig extends UnknownErrorConfigs {\n\tdescription?: DescriptionWriter\n}\n\nexport type ResolvedUnknownNodeConfig = requireKeys<\n\tUnknownNodeConfig,\n\t\"description\"\n>\n\n// $ark.config could already be set if it were imported previously from the\n// dedicated config entrypoint, in which case we don't want to reinitialize it\n$ark.config ??= {}\n\nexport const configureSchema = (config: ArkSchemaConfig): ArkSchemaConfig => {\n\tconst result = Object.assign($ark.config, mergeConfigs($ark.config, config))\n\n\tif ($ark.resolvedConfig)\n\t\t$ark.resolvedConfig = mergeConfigs($ark.resolvedConfig, result)\n\n\treturn result\n}\n\nexport const mergeConfigs = <base extends ArkSchemaConfig>(\n\tbase: base,\n\tmerged: ArkSchemaConfig | undefined\n): base => {\n\tif (!merged) return base\n\tconst result: any = { ...base }\n\tlet k: keyof ArkSchemaConfig\n\tfor (k in merged) {\n\t\tconst keywords = { ...base.keywords }\n\t\tif (k === \"keywords\") {\n\t\t\tfor (const flatAlias in merged[k]) {\n\t\t\t\tconst v = merged.keywords![flatAlias]\n\t\t\t\tif (v === undefined) continue\n\t\t\t\tkeywords[flatAlias] = typeof v === \"string\" ? { description: v } : v\n\t\t\t}\n\t\t\tresult.keywords = keywords\n\t\t} else if (k === \"toJsonSchema\") {\n\t\t\tresult[k] = mergeToJsonSchemaConfigs(\n\t\t\t\tbase.toJsonSchema,\n\t\t\t\tmerged.toJsonSchema\n\t\t\t)\n\t\t} else if (isNodeKind(k)) {\n\t\t\tresult[k] =\n\t\t\t\t// not casting this makes TS compute a very inefficient\n\t\t\t\t// type that is not needed\n\t\t\t\t{\n\t\t\t\t\t...base[k],\n\t\t\t\t\t...merged[k]\n\t\t\t\t} as never\n\t\t} else result[k] = merged[k]\n\t}\n\treturn result\n}\n\nconst jsonSchemaTargetToDialect: Record<ToJsonSchema.Target, string> = {\n\t\"draft-2020-12\": \"https://json-schema.org/draft/2020-12/schema\",\n\t\"draft-07\": \"http://json-schema.org/draft-07/schema#\"\n}\n\ntype MergeToJsonSchemaConfigs = <base extends ToJsonSchema.Options | undefined>(\n\tbaseConfig: base,\n\tmergedConfig: ToJsonSchema.Options | undefined\n) => base extends ToJsonSchema.Context ? ToJsonSchema.Context\n:\tToJsonSchema.Options\n\nexport const mergeToJsonSchemaConfigs: MergeToJsonSchemaConfigs = ((\n\tbaseConfig: ToJsonSchema.Options | undefined,\n\tmergedConfig: ToJsonSchema.Options | undefined\n) => {\n\tif (!baseConfig) return resolveTargetToDialect(mergedConfig ?? {}, undefined)\n\tif (!mergedConfig) return baseConfig\n\n\tconst result: ToJsonSchema.Options = { ...baseConfig }\n\n\tlet k: keyof ToJsonSchema.Options\n\tfor (k in mergedConfig) {\n\t\tif (k === \"fallback\") {\n\t\t\tresult.fallback = mergeFallbacks(\n\t\t\t\tbaseConfig.fallback,\n\t\t\t\tmergedConfig.fallback\n\t\t\t)\n\t\t} else result[k] = mergedConfig[k] as never\n\t}\n\n\treturn resolveTargetToDialect(result, mergedConfig)\n}) as MergeToJsonSchemaConfigs\n\nconst resolveTargetToDialect = <T extends ToJsonSchema.Options>(\n\topts: T,\n\tuserOpts: ToJsonSchema.Options | undefined\n): T => {\n\t// If user explicitly provided a dialect, use it\n\t// Otherwise, if user provided a target, resolve it to dialect\n\t// If neither, use the default dialect from opts\n\tif (userOpts?.dialect !== undefined) return opts // dialect was already merged\n\n\tif (userOpts?.target !== undefined) {\n\t\treturn {\n\t\t\t...opts,\n\t\t\tdialect: jsonSchemaTargetToDialect[userOpts.target]\n\t\t}\n\t}\n\treturn opts\n}\n\nconst mergeFallbacks = (\n\tbase: ToJsonSchema.FallbackOption | undefined,\n\tmerged: ToJsonSchema.FallbackOption | undefined\n): ToJsonSchema.FallbackObject => {\n\tbase = normalizeFallback(base)\n\tmerged = normalizeFallback(merged)\n\n\tconst result: ToJsonSchema.HandlerByCode = {} as never\n\n\tlet code: ToJsonSchema.Code\n\tfor (code in ToJsonSchema.defaultConfig.fallback) {\n\t\tresult[code] =\n\t\t\tmerged[code] ??\n\t\t\tmerged.default ??\n\t\t\tbase[code] ??\n\t\t\tbase.default ??\n\t\t\t(ToJsonSchema.defaultConfig.fallback[code] as any)\n\t}\n\n\treturn result\n}\n\nconst normalizeFallback = (\n\tfallback?: ToJsonSchema.FallbackOption | ToJsonSchema.UniversalFallback\n): ToJsonSchema.FallbackObject =>\n\ttypeof fallback === \"function\" ? { default: fallback } : (fallback ?? {})\n\nexport type CloneImplementation = <original extends object>(\n\toriginal: original\n) => original\n\nexport interface ArkSchemaConfig extends Partial<Readonly<NodeConfigsByKind>> {\n\treadonly jitless?: boolean\n\treadonly clone?: boolean | CloneImplementation\n\treadonly onUndeclaredKey?: UndeclaredKeyBehavior\n\treadonly numberAllowsNaN?: boolean\n\treadonly dateAllowsInvalid?: boolean\n\treadonly exactOptionalPropertyTypes?: boolean\n\treadonly onFail?: ArkErrors.Handler | null\n\treadonly keywords?: Record<string, TypeMeta.Collapsible | undefined>\n\treadonly toJsonSchema?: ToJsonSchema.Options\n}\n\nexport type resolveConfig<config extends ArkSchemaConfig> = show<\n\t{\n\t\t[k in keyof ArkSchemaConfig]-?: k extends NodeKind ? Required<config[k]>\n\t\t: k extends \"clone\" ? CloneImplementation | false\n\t\t: k extends \"keywords\" ? Record<string, TypeMeta | undefined>\n\t\t: k extends \"toJsonSchema\" ? ToJsonSchema.Context\n\t\t: config[k]\n\t} & Omit<config, keyof ArkSchemaConfig>\n>\n\nexport type ResolvedConfig = resolveConfig<ArkSchemaConfig>\n"
  },
  {
    "path": "ark/schema/constraint.ts",
    "content": "import {\n\tappend,\n\tappendUnique,\n\tcapitalize,\n\tisArray,\n\tthrowInternalError,\n\tthrowParseError,\n\ttype array,\n\ttype describe,\n\ttype listable,\n\ttype satisfy\n} from \"@ark/util\"\nimport type {\n\tNodeSchema,\n\tPrerequisite,\n\tinnerAttachedAs,\n\tnodeOfKind\n} from \"./kinds.ts\"\nimport { BaseNode } from \"./node.ts\"\nimport type { NodeParseContext } from \"./parse.ts\"\nimport type { Intersection } from \"./roots/intersection.ts\"\nimport type { BaseRoot } from \"./roots/root.ts\"\nimport type { BaseScope } from \"./scope.ts\"\nimport type { NodeCompiler } from \"./shared/compile.ts\"\nimport type { BaseNodeDeclaration } from \"./shared/declare.ts\"\nimport { Disjoint } from \"./shared/disjoint.ts\"\nimport {\n\tcompileObjectLiteral,\n\tconstraintKeys,\n\ttype ConstraintKind,\n\ttype IntersectionContext,\n\ttype NodeKind,\n\ttype RootKind,\n\ttype StructuralKind,\n\ttype UnknownAttachments,\n\ttype kindLeftOf\n} from \"./shared/implement.ts\"\nimport {\n\tintersectNodesRoot,\n\tintersectOrPipeNodes\n} from \"./shared/intersections.ts\"\nimport type { JsonSchema } from \"./shared/jsonSchema.ts\"\nimport { $ark } from \"./shared/registry.ts\"\nimport type { ToJsonSchema } from \"./shared/toJsonSchema.ts\"\nimport type { TraverseAllows, TraverseApply } from \"./shared/traversal.ts\"\nimport { arkKind } from \"./shared/utils.ts\"\nimport type { Structure } from \"./structure/structure.ts\"\n\nexport declare namespace Constraint {\n\texport interface Declaration extends BaseNodeDeclaration {\n\t\tkind: ConstraintKind\n\t}\n\n\texport type ReductionResult = BaseRoot | Disjoint | Intersection.Inner.mutable\n\n\texport interface Attachments {\n\t\timpliedBasis: BaseRoot | null\n\t\timpliedSiblings?: array<BaseConstraint> | null\n\t}\n\n\texport type PrimitiveKind = Exclude<ConstraintKind, StructuralKind>\n}\n\nexport abstract class BaseConstraint<\n\t// uses -ignore rather than -expect-error because this is not an error in .d.ts\n\t/** @ts-ignore allow instantiation assignment to the base type */\n\tout d extends Constraint.Declaration = Constraint.Declaration\n> extends BaseNode<d> {\n\tdeclare readonly [arkKind]: \"constraint\"\n\n\tconstructor(attachments: UnknownAttachments, $: BaseScope) {\n\t\tsuper(attachments, $)\n\t\t// define as a getter to avoid it being enumerable/spreadable\n\t\tObject.defineProperty(this, arkKind, {\n\t\t\tvalue: \"constraint\",\n\t\t\tenumerable: false\n\t\t})\n\t}\n\n\tabstract readonly impliedBasis: BaseRoot | null\n\treadonly impliedSiblings?: array<BaseConstraint>\n\n\tintersect<r extends BaseConstraint>(\n\t\tr: r\n\t): intersectConstraintKinds<d[\"kind\"], r[\"kind\"]> {\n\t\treturn intersectNodesRoot(this, r, this.$) as never\n\t}\n}\n\nexport abstract class InternalPrimitiveConstraint<\n\td extends Constraint.Declaration\n> extends BaseConstraint<d> {\n\tabstract traverseAllows: TraverseAllows<d[\"prerequisite\"]>\n\tabstract readonly compiledCondition: string\n\tabstract readonly compiledNegation: string\n\n\tabstract reduceJsonSchema(\n\t\tbase: JsonSchema.Constrainable,\n\t\tctx: ToJsonSchema.Context\n\t): JsonSchema.Constrainable\n\n\ttraverseApply: TraverseApply<d[\"prerequisite\"]> = (data, ctx) => {\n\t\tif (!this.traverseAllows(data, ctx))\n\t\t\tctx.errorFromNodeContext(this.errorContext as never)\n\t}\n\n\tcompile(js: NodeCompiler): void {\n\t\tif (js.traversalKind === \"Allows\") js.return(this.compiledCondition)\n\t\telse {\n\t\t\tjs.if(this.compiledNegation, () =>\n\t\t\t\tjs.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`)\n\t\t\t)\n\t\t}\n\t}\n\n\tget errorContext(): d[\"errorContext\"] {\n\t\treturn {\n\t\t\tcode: this.kind,\n\t\t\tdescription: this.description,\n\t\t\tmeta: this.meta,\n\t\t\t...this.inner\n\t\t}\n\t}\n\n\tget compiledErrorContext(): string {\n\t\treturn compileObjectLiteral(this.errorContext!)\n\t}\n}\n\nexport const constraintKeyParser =\n\t<kind extends ConstraintKind>(kind: kind) =>\n\t(\n\t\tschema: listable<NodeSchema<kind>>,\n\t\tctx: NodeParseContext\n\t): innerAttachedAs<kind> | undefined => {\n\t\tif (isArray(schema)) {\n\t\t\tif (schema.length === 0) {\n\t\t\t\t// Omit empty lists as input\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst nodes = schema.map(schema => ctx.$.node(kind, schema as never))\n\t\t\t// predicate order must be preserved to ensure inputs are narrowed\n\t\t\t// and checked in the correct order\n\t\t\tif (kind === \"predicate\") return nodes as never\n\t\t\treturn nodes.sort((l, r) => (l.hash < r.hash ? -1 : 1)) as never\n\t\t}\n\t\tconst child = ctx.$.node(kind, schema)\n\t\t// If the constraint was reduced to a root node (like unknown for minLength: 0),\n\t\t// omit it from the schema since it's trivially satisfied\n\t\tif (child.isRoot()) return\n\t\treturn (child.hasOpenIntersection() ? [child] : child) as never\n\t}\n\ntype ConstraintGroupKind = satisfy<NodeKind, \"intersection\" | \"structure\">\n\ninterface ConstraintIntersectionState<\n\tkind extends ConstraintGroupKind = ConstraintGroupKind\n> {\n\tkind: kind\n\tbaseInner: Record<string, unknown>\n\tl: BaseConstraint[]\n\tr: BaseConstraint[]\n\troots: BaseRoot[]\n\tctx: IntersectionContext\n}\n\nexport const intersectConstraints = <kind extends ConstraintGroupKind>(\n\ts: ConstraintIntersectionState<kind>\n): nodeOfKind<RootKind | Extract<kind, \"structure\">> | Disjoint => {\n\tconst head = s.r.shift()\n\tif (!head) {\n\t\tlet result: BaseNode | Disjoint =\n\t\t\ts.l.length === 0 && s.kind === \"structure\" ?\n\t\t\t\t$ark.intrinsic.unknown.internal\n\t\t\t:\ts.ctx.$.node(\n\t\t\t\t\ts.kind,\n\t\t\t\t\tObject.assign(s.baseInner, unflattenConstraints(s.l)),\n\t\t\t\t\t{ prereduced: true }\n\t\t\t\t)\n\n\t\tfor (const root of s.roots) {\n\t\t\tif (result instanceof Disjoint) return result\n\n\t\t\tresult = intersectOrPipeNodes(root, result, s.ctx)!\n\t\t}\n\n\t\treturn result as never\n\t}\n\tlet matched = false\n\tfor (let i = 0; i < s.l.length; i++) {\n\t\tconst result = intersectOrPipeNodes(s.l[i], head, s.ctx)\n\t\tif (result === null) continue\n\t\tif (result instanceof Disjoint) return result\n\n\t\tif (result.isRoot()) {\n\t\t\ts.roots.push(result)\n\t\t\ts.l.splice(i)\n\t\t\treturn intersectConstraints(s)\n\t\t}\n\n\t\tif (!matched) {\n\t\t\ts.l[i] = result as BaseConstraint\n\t\t\tmatched = true\n\t\t} else if (!s.l.includes(result as never)) {\n\t\t\treturn throwInternalError(\n\t\t\t\t`Unexpectedly encountered multiple distinct intersection results for refinement ${head}`\n\t\t\t)\n\t\t}\n\t}\n\tif (!matched) s.l.push(head)\n\n\tif (s.kind === \"intersection\") {\n\t\tif (head.impliedSiblings)\n\t\t\tfor (const node of head.impliedSiblings) appendUnique(s.r, node)\n\t}\n\treturn intersectConstraints(s)\n}\n\nexport const flattenConstraints = (inner: object): BaseConstraint[] => {\n\tconst result = Object.entries(inner)\n\t\t.flatMap(([k, v]) =>\n\t\t\tk in constraintKeys ? (v as listable<BaseConstraint>) : []\n\t\t)\n\t\t.sort((l, r) =>\n\t\t\tl.precedence < r.precedence ? -1\n\t\t\t: l.precedence > r.precedence ? 1\n\t\t\t\t// preserve order for predicates\n\t\t\t: l.kind === \"predicate\" && r.kind === \"predicate\" ? 0\n\t\t\t: l.hash < r.hash ? -1\n\t\t\t: 1\n\t\t)\n\n\treturn result\n}\n\ntype FlatIntersectionInner = Intersection.Inner & Structure.Inner\n\ntype MutableFlatIntersectionInner = Intersection.Inner.mutable &\n\tStructure.Inner.mutable\n\nexport const unflattenConstraints = (\n\tconstraints: array<BaseConstraint>\n): FlatIntersectionInner => {\n\tconst inner: MutableFlatIntersectionInner = {}\n\tfor (const constraint of constraints) {\n\t\tif (constraint.hasOpenIntersection()) {\n\t\t\tinner[constraint.kind] = append(\n\t\t\t\tinner[constraint.kind],\n\t\t\t\tconstraint\n\t\t\t) as never\n\t\t} else {\n\t\t\tif (inner[constraint.kind]) {\n\t\t\t\treturn throwInternalError(\n\t\t\t\t\t`Unexpected intersection of closed refinements of kind ${constraint.kind}`\n\t\t\t\t)\n\t\t\t}\n\t\t\tinner[constraint.kind] = constraint as never\n\t\t}\n\t}\n\treturn inner\n}\n\nexport type constraintKindLeftOf<kind extends ConstraintKind> = ConstraintKind &\n\tkindLeftOf<kind>\n\nexport type constraintKindOrLeftOf<kind extends ConstraintKind> =\n\t| kind\n\t| constraintKindLeftOf<kind>\n\nexport type intersectConstraintKinds<\n\tl extends ConstraintKind,\n\tr extends ConstraintKind\n> = nodeOfKind<l | r | \"unit\" | \"union\"> | Disjoint | null\n\nexport const throwInvalidOperandError = (\n\t...args: Parameters<typeof writeInvalidOperandMessage>\n): never => throwParseError(writeInvalidOperandMessage(...args))\n\nexport const writeInvalidOperandMessage = <\n\tkind extends ConstraintKind,\n\texpected extends BaseRoot,\n\tactual extends BaseRoot\n>(\n\tkind: kind,\n\texpected: expected,\n\tactual: actual\n): string => {\n\tconst actualDescription =\n\t\tactual.hasKind(\"morph\") ? \"a morph\"\n\t\t: actual.isUnknown() ? \"unknown\"\n\t\t: actual.exclude(expected).defaultShortDescription\n\n\treturn `${capitalize(kind)} operand must be ${\n\t\texpected.description\n\t} (was ${actualDescription})` as never\n}\n\nexport type writeInvalidOperandMessage<\n\tkind extends ConstraintKind,\n\tactual\n> = `${Capitalize<kind>} operand must be ${describe<\n\tPrerequisite<kind>\n>} (was ${describe<Exclude<actual, Prerequisite<kind>>>})`\n"
  },
  {
    "path": "ark/schema/generic.ts",
    "content": "import {\n\tCallable,\n\tflatMorph,\n\tsnapshot,\n\tthrowParseError,\n\ttype array,\n\ttype Hkt,\n\ttype JsonStructure\n} from \"@ark/util\"\nimport type { RootSchema } from \"./kinds.ts\"\nimport type { BaseNode } from \"./node.ts\"\nimport type { BaseRoot } from \"./roots/root.ts\"\nimport type { BaseScope } from \"./scope.ts\"\nimport { $ark } from \"./shared/registry.ts\"\nimport { arkKind } from \"./shared/utils.ts\"\n\nexport type GenericParamAst<\n\tname extends string = string,\n\tconstraint = unknown\n> = [name: name, constraint: constraint]\n\nexport type GenericParamDef<name extends string = string> =\n\t| name\n\t| readonly [name, unknown]\n\nexport const parseGeneric = (\n\tparamDefs: array<GenericParamDef>,\n\tbodyDef: unknown,\n\t$: BaseScope\n): GenericRoot => new GenericRoot(paramDefs, bodyDef, $, $, null)\n\nexport type genericParamNames<params extends array<GenericParamAst>> = {\n\t[i in keyof params]: params[i][0]\n}\n\nexport type genericParamConstraints<params extends array<GenericParamAst>> = {\n\t[i in keyof params]: params[i][1]\n}\n\nexport type GenericArgResolutions<\n\tparams extends array<GenericParamAst> = array<GenericParamAst>\n> = {\n\t[i in keyof params as params[i & `${number}`][0]]: BaseRoot\n}\n\nexport class LazyGenericBody<\n\targResolutions = {},\n\treturns = unknown\n> extends Callable<(args: argResolutions) => returns> {}\n\nexport interface GenericAst<\n\tparams extends array<GenericParamAst> = array<GenericParamAst>,\n\tbodyDef = unknown,\n\t$ = unknown,\n\targ$ = $\n> {\n\t[arkKind]: \"generic\"\n\tparamsAst: params\n\tbodyDef: bodyDef\n\t$: $\n\targ$: arg$\n\tnames: genericParamNames<params>\n\tt: this\n}\n\nexport class GenericRoot<\n\tparams extends array<GenericParamAst> = array<GenericParamAst>,\n\tbodyDef = unknown\n> extends Callable<(...args: { [i in keyof params]: BaseRoot }) => BaseRoot> {\n\treadonly [arkKind] = \"generic\"\n\tdeclare readonly paramsAst: params\n\tdeclare readonly t: GenericAst<params, bodyDef, {}, {}>\n\n\tparamDefs: array<GenericParamDef>\n\tbodyDef: bodyDef\n\t$: BaseScope\n\targ$: BaseScope\n\tbaseInstantiation: BaseRoot\n\thkt: Hkt.constructor | null\n\tdescription: string\n\n\tconstructor(\n\t\tparamDefs: array<GenericParamDef>,\n\t\tbodyDef: bodyDef,\n\t\t$: BaseScope,\n\t\targ$: BaseScope,\n\t\thkt: Hkt.constructor | null\n\t) {\n\t\tsuper((...args: any[]) => {\n\t\t\tconst argNodes = flatMorph(this.names, (i, name) => {\n\t\t\t\tconst arg = this.arg$.parse(args[i])\n\t\t\t\tif (!arg.extends(this.constraints[i])) {\n\t\t\t\t\tthrowParseError(\n\t\t\t\t\t\twriteUnsatisfiedParameterConstraintMessage(\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tthis.constraints[i].expression,\n\t\t\t\t\t\t\targ.expression\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\treturn [name, arg]\n\t\t\t}) as GenericArgResolutions<any>\n\n\t\t\tif (this.defIsLazy()) {\n\t\t\t\tconst def = this.bodyDef(argNodes)\n\n\t\t\t\treturn this.$.parse(def)\n\t\t\t}\n\n\t\t\treturn this.$.parse(bodyDef, { args: argNodes })\n\t\t})\n\n\t\tthis.paramDefs = paramDefs\n\t\tthis.bodyDef = bodyDef\n\t\tthis.$ = $\n\t\tthis.arg$ = arg$\n\t\tthis.hkt = hkt\n\t\tthis.description =\n\t\t\thkt ?\n\t\t\t\t(new hkt().description ?? `a generic type for ${hkt.constructor.name}`)\n\t\t\t:\t\"a generic type\"\n\t\tthis.baseInstantiation = this(...(this.constraints as any)) as never\n\t}\n\n\tdefIsLazy(): this is GenericRoot<params, LazyGenericBody> {\n\t\treturn this.bodyDef instanceof LazyGenericBody\n\t}\n\n\tprotected cacheGetter<name extends keyof this>(\n\t\tname: name,\n\t\tvalue: this[name]\n\t): this[name] {\n\t\tObject.defineProperty(this, name, { value })\n\t\treturn value\n\t}\n\n\tget json(): JsonStructure {\n\t\treturn this.cacheGetter(\"json\", {\n\t\t\tparams: this.params.map(param =>\n\t\t\t\tparam[1].isUnknown() ? param[0] : [param[0], param[1].json]\n\t\t\t),\n\t\t\tbody: snapshot(this.bodyDef) as never\n\t\t})\n\t}\n\n\tget params(): { [i in keyof params]: [params[i][0], BaseRoot] } {\n\t\treturn this.cacheGetter(\n\t\t\t\"params\",\n\t\t\tthis.paramDefs.map(param =>\n\t\t\t\ttypeof param === \"string\" ?\n\t\t\t\t\t[param, $ark.intrinsic.unknown]\n\t\t\t\t:\t[param[0], this.$.parse(param[1])]\n\t\t\t) as never\n\t\t)\n\t}\n\n\tget names(): genericParamNames<params> {\n\t\treturn this.cacheGetter(\"names\", this.params.map(e => e[0]) as never)\n\t}\n\n\tget constraints(): { [i in keyof params]: BaseRoot } {\n\t\treturn this.cacheGetter(\"constraints\", this.params.map(e => e[1]) as never)\n\t}\n\n\tget internal(): this {\n\t\treturn this\n\t}\n\n\tget referencesById(): Record<string, BaseNode> {\n\t\treturn this.baseInstantiation.internal.referencesById\n\t}\n\n\tget references(): BaseNode[] {\n\t\treturn this.baseInstantiation.internal.references\n\t}\n}\n\nexport type genericParamSchemasToAst<\n\tschemas extends readonly GenericParamDef[]\n> = {\n\t[i in keyof schemas]: schemas[i] extends GenericParamDef<infer name> ?\n\t\t[name, unknown]\n\t:\tnever\n}\n\nexport type genericHktToConstraints<hkt extends abstract new () => Hkt> =\n\tInstanceType<hkt>[\"constraints\"]\n\nexport type GenericRootParser = <\n\tconst paramsDef extends readonly GenericParamDef[]\n>(\n\t...params: paramsDef\n) => GenericRootBodyParser<genericParamSchemasToAst<paramsDef>>\n\nexport type GenericRootBodyParser<params extends array<GenericParamAst>> = {\n\t<const body>(body: RootSchema): GenericRoot<params, body>\n\n\t<hkt extends Hkt.constructor>(\n\t\tinstantiateDef: LazyGenericBody<GenericArgResolutions<params>>,\n\t\thkt: hkt\n\t): GenericRoot<\n\t\t{\n\t\t\t[i in keyof params]: [params[i][0], genericHktToConstraints<hkt>[i]]\n\t\t},\n\t\tInstanceType<hkt>\n\t>\n}\n\nexport const writeUnsatisfiedParameterConstraintMessage = <\n\tname extends string,\n\tconstraint extends string,\n\targ extends string\n>(\n\tname: name,\n\tconstraint: constraint,\n\targ: arg\n): writeUnsatisfiedParameterConstraintMessage<name, constraint, arg> =>\n\t`${name} must be assignable to ${constraint} (was ${arg})`\n\nexport type writeUnsatisfiedParameterConstraintMessage<\n\tname extends string,\n\tconstraint extends string,\n\targ extends string\n> = `${name} must be assignable to ${constraint} (was ${arg})`\n"
  },
  {
    "path": "ark/schema/index.ts",
    "content": "export * from \"./config.ts\"\nexport * from \"./constraint.ts\"\nexport * from \"./generic.ts\"\nexport * from \"./intrinsic.ts\"\nexport * from \"./kinds.ts\"\nexport * from \"./module.ts\"\nexport * from \"./node.ts\"\nexport * from \"./parse.ts\"\nexport * from \"./predicate.ts\"\nexport * from \"./refinements/after.ts\"\nexport * from \"./refinements/before.ts\"\nexport * from \"./refinements/divisor.ts\"\nexport * from \"./refinements/exactLength.ts\"\nexport * from \"./refinements/kinds.ts\"\nexport * from \"./refinements/max.ts\"\nexport * from \"./refinements/maxLength.ts\"\nexport * from \"./refinements/min.ts\"\nexport * from \"./refinements/minLength.ts\"\nexport * from \"./refinements/pattern.ts\"\nexport * from \"./refinements/range.ts\"\nexport * from \"./roots/domain.ts\"\nexport * from \"./roots/intersection.ts\"\nexport * from \"./roots/morph.ts\"\nexport * from \"./roots/proto.ts\"\nexport * from \"./roots/root.ts\"\nexport * from \"./roots/union.ts\"\nexport * from \"./roots/unit.ts\"\nexport * from \"./scope.ts\"\nexport * from \"./shared/compile.ts\"\nexport * from \"./shared/declare.ts\"\nexport * from \"./shared/disjoint.ts\"\nexport * from \"./shared/errors.ts\"\nexport * from \"./shared/implement.ts\"\nexport * from \"./shared/intersections.ts\"\nexport * from \"./shared/jsonSchema.ts\"\nexport * from \"./shared/registry.ts\"\nexport * from \"./shared/standardSchema.ts\"\nexport * from \"./shared/toJsonSchema.ts\"\nexport * from \"./shared/traversal.ts\"\nexport * from \"./shared/utils.ts\"\nexport * from \"./structure/index.ts\"\nexport * from \"./structure/optional.ts\"\nexport * from \"./structure/prop.ts\"\nexport * from \"./structure/required.ts\"\nexport * from \"./structure/sequence.ts\"\nexport * from \"./structure/structure.ts\"\n\nexport { ParseError } from \"@ark/util\"\n"
  },
  {
    "path": "ark/schema/intrinsic.ts",
    "content": "import { node, schemaScope } from \"./scope.ts\"\nimport { $ark } from \"./shared/registry.ts\"\nimport { arrayIndexSource } from \"./structure/shared.ts\"\n\nconst intrinsicBases = schemaScope(\n\t{\n\t\tbigint: \"bigint\",\n\t\t// since we know this won't be reduced, it can be safely cast to a union\n\t\tboolean: [{ unit: false }, { unit: true }],\n\t\tfalse: { unit: false },\n\t\tnever: [],\n\t\tnull: { unit: null },\n\t\tnumber: \"number\",\n\t\tobject: \"object\",\n\t\tstring: \"string\",\n\t\tsymbol: \"symbol\",\n\t\ttrue: { unit: true },\n\t\tunknown: {},\n\t\tundefined: { unit: undefined },\n\t\tArray,\n\t\tDate\n\t},\n\t{ prereducedAliases: true }\n).export()\n\n$ark.intrinsic = { ...intrinsicBases } as never\n\nconst intrinsicRoots = schemaScope(\n\t{\n\t\tinteger: {\n\t\t\tdomain: \"number\",\n\t\t\tdivisor: 1\n\t\t},\n\t\tlengthBoundable: [\"string\", Array],\n\t\tkey: [\"string\", \"symbol\"],\n\t\tnonNegativeIntegerString: { domain: \"string\", pattern: arrayIndexSource }\n\t},\n\t{ prereducedAliases: true }\n).export()\n\n// needed to parse index signatures for JSON\nObject.assign($ark.intrinsic, intrinsicRoots)\n\nconst intrinsicJson = schemaScope(\n\t{\n\t\tjsonPrimitive: [\n\t\t\t\"string\",\n\t\t\t\"number\",\n\t\t\t{ unit: true },\n\t\t\t{ unit: false },\n\t\t\t{ unit: null }\n\t\t],\n\t\tjsonObject: {\n\t\t\tdomain: \"object\",\n\t\t\tindex: {\n\t\t\t\tsignature: \"string\",\n\t\t\t\tvalue: \"$jsonData\"\n\t\t\t}\n\t\t},\n\t\tjsonData: [\"$jsonPrimitive\", \"$jsonObject\"]\n\t},\n\t{ prereducedAliases: true }\n).export()\n\nexport const intrinsic = {\n\t...intrinsicBases,\n\t...intrinsicRoots,\n\t...intrinsicJson,\n\temptyStructure: node(\"structure\", {}, { prereduced: true })\n}\n\n$ark.intrinsic = { ...intrinsic } as never\n"
  },
  {
    "path": "ark/schema/kinds.ts",
    "content": "import {\n\tdeepClone,\n\tenvHasCsp,\n\tflatMorph,\n\twithAlphabetizedKeys,\n\ttype array,\n\ttype listable\n} from \"@ark/util\"\nimport { mergeConfigs, type ResolvedConfig } from \"./config.ts\"\nimport type { BaseNode } from \"./node.ts\"\nimport { Predicate } from \"./predicate.ts\"\nimport { Divisor } from \"./refinements/divisor.ts\"\nimport {\n\tboundClassesByKind,\n\tboundImplementationsByKind,\n\ttype BoundDeclarations,\n\ttype BoundNodesByKind\n} from \"./refinements/kinds.ts\"\nimport { Pattern } from \"./refinements/pattern.ts\"\nimport { Alias } from \"./roots/alias.ts\"\nimport { Domain } from \"./roots/domain.ts\"\nimport { Intersection } from \"./roots/intersection.ts\"\nimport { Morph } from \"./roots/morph.ts\"\nimport { Proto } from \"./roots/proto.ts\"\nimport { Union } from \"./roots/union.ts\"\nimport { Unit } from \"./roots/unit.ts\"\nimport type { BaseScope } from \"./scope.ts\"\nimport type {\n\tConstraintKind,\n\tNodeKind,\n\tOpenNodeKind,\n\tRootKind,\n\tUnknownAttachments,\n\tUnknownNodeImplementation\n} from \"./shared/implement.ts\"\nimport { $ark } from \"./shared/registry.ts\"\nimport { ToJsonSchema } from \"./shared/toJsonSchema.ts\"\nimport type { makeRootAndArrayPropertiesMutable } from \"./shared/utils.ts\"\nimport { Index } from \"./structure/index.ts\"\nimport { Optional } from \"./structure/optional.ts\"\nimport { Required } from \"./structure/required.ts\"\nimport { Sequence } from \"./structure/sequence.ts\"\nimport { Structure } from \"./structure/structure.ts\"\n\nexport interface NodeDeclarationsByKind extends BoundDeclarations {\n\talias: Alias.Declaration\n\tdomain: Domain.Declaration\n\tunit: Unit.Declaration\n\tproto: Proto.Declaration\n\tunion: Union.Declaration\n\tmorph: Morph.Declaration\n\tintersection: Intersection.Declaration\n\tsequence: Sequence.Declaration\n\tdivisor: Divisor.Declaration\n\trequired: Required.Declaration\n\toptional: Optional.Declaration\n\tindex: Index.Declaration\n\tpattern: Pattern.Declaration\n\tpredicate: Predicate.Declaration\n\tstructure: Structure.Declaration\n}\n\nexport const nodeImplementationsByKind: Record<\n\tNodeKind,\n\tUnknownNodeImplementation\n> = {\n\t...boundImplementationsByKind,\n\talias: Alias.implementation,\n\tdomain: Domain.implementation,\n\tunit: Unit.implementation,\n\tproto: Proto.implementation,\n\tunion: Union.implementation,\n\tmorph: Morph.implementation,\n\tintersection: Intersection.implementation,\n\tdivisor: Divisor.implementation,\n\tpattern: Pattern.implementation,\n\tpredicate: Predicate.implementation,\n\trequired: Required.implementation,\n\toptional: Optional.implementation,\n\tindex: Index.implementation,\n\tsequence: Sequence.implementation,\n\tstructure: Structure.implementation\n} satisfies Record<NodeKind, unknown> as never\n\n$ark.defaultConfig = withAlphabetizedKeys(\n\tObject.assign(\n\t\tflatMorph(nodeImplementationsByKind, (kind, implementation) => [\n\t\t\tkind,\n\t\t\timplementation.defaults\n\t\t]),\n\t\t{\n\t\t\tjitless: envHasCsp(),\n\t\t\tclone: deepClone,\n\t\t\tonUndeclaredKey: \"ignore\",\n\t\t\texactOptionalPropertyTypes: true,\n\t\t\tnumberAllowsNaN: false,\n\t\t\tdateAllowsInvalid: false,\n\t\t\tonFail: null,\n\t\t\tkeywords: {},\n\t\t\ttoJsonSchema: ToJsonSchema.defaultConfig\n\t\t} satisfies Omit<ResolvedConfig, NodeKind>\n\t) as never\n)\n\n$ark.resolvedConfig = mergeConfigs($ark.defaultConfig, $ark.config)\n\nexport const nodeClassesByKind: Record<\n\tNodeKind,\n\tnew (attachments: UnknownAttachments, $: BaseScope) => BaseNode\n> = {\n\t...boundClassesByKind,\n\talias: Alias.Node,\n\tdomain: Domain.Node,\n\tunit: Unit.Node,\n\tproto: Proto.Node,\n\tunion: Union.Node,\n\tmorph: Morph.Node,\n\tintersection: Intersection.Node,\n\tdivisor: Divisor.Node,\n\tpattern: Pattern.Node,\n\tpredicate: Predicate.Node,\n\trequired: Required.Node,\n\toptional: Optional.Node,\n\tindex: Index.Node,\n\tsequence: Sequence.Node,\n\tstructure: Structure.Node\n} satisfies Record<NodeKind, typeof BaseNode<any>> as never\n\ninterface NodesByKind extends BoundNodesByKind {\n\talias: Alias.Node\n\tunion: Union.Node\n\tmorph: Morph.Node\n\tintersection: Intersection.Node\n\tunit: Unit.Node\n\tproto: Proto.Node\n\tdomain: Domain.Node\n\tdivisor: Divisor.Node\n\tpattern: Pattern.Node\n\tpredicate: Predicate.Node\n\trequired: Required.Node\n\toptional: Optional.Node\n\tindex: Index.Node\n\tsequence: Sequence.Node\n\tstructure: Structure.Node\n}\n\nexport type nodeOfKind<kind extends NodeKind> = NodesByKind[kind]\n\nexport type Declaration<kind extends NodeKind> = NodeDeclarationsByKind[kind]\n\nexport type NodeSchema<kind extends NodeKind> = Declaration<kind>[\"schema\"]\n\nexport type RootSchema<kind extends RootKind = RootKind> = NodeSchema<kind>\n\nexport type NormalizedSchema<kind extends NodeKind> =\n\tDeclaration<kind>[\"normalizedSchema\"]\n\nexport type childKindOf<kind extends NodeKind> = Declaration<kind>[\"childKind\"]\n\nexport type Prerequisite<kind extends NodeKind> =\n\tDeclaration<kind>[\"prerequisite\"]\n\nexport type reducibleKindOf<kind extends NodeKind> =\n\tDeclaration<kind>[\"reducibleTo\"] extends NodeKind ?\n\t\tDeclaration<kind>[\"reducibleTo\"]\n\t:\tkind\n\nexport type Inner<kind extends NodeKind> = Declaration<kind>[\"inner\"]\n\nexport type defAttachedAs<kind extends ConstraintKind> =\n\tkind extends OpenNodeKind ? listable<NodeSchema<kind>> : NodeSchema<kind>\n\nexport type innerAttachedAs<kind extends ConstraintKind> =\n\tkind extends OpenNodeKind ? array<nodeOfKind<kind>> : nodeOfKind<kind>\n\n/** make nested arrays mutable while keeping nested nodes immutable */\nexport type mutableInnerOfKind<kind extends NodeKind> =\n\tmakeRootAndArrayPropertiesMutable<Inner<kind>>\n\nexport type mutableNormalizedRootOfKind<kind extends NodeKind> =\n\tmakeRootAndArrayPropertiesMutable<NormalizedSchema<kind>>\n\nexport type errorContext<kind extends NodeKind> =\n\tDeclaration<kind>[\"errorContext\"]\n"
  },
  {
    "path": "ark/schema/module.ts",
    "content": "import { DynamicBase, flatMorph, type anyOrNever } from \"@ark/util\"\nimport type { BaseRoot } from \"./roots/root.ts\"\nimport type {\n\tBaseScope,\n\tInternalResolution,\n\tInternalResolutions\n} from \"./scope.ts\"\nimport { arkKind, hasArkKind } from \"./shared/utils.ts\"\n\nexport type PreparsedNodeResolution = {\n\t[arkKind]: \"generic\" | \"module\"\n}\n\nexport class RootModule<exports extends {} = {}> extends DynamicBase<exports> {\n\t// ensure `[arkKind]` is non-enumerable so it doesn't get spread on import/export\n\tget [arkKind](): \"module\" {\n\t\treturn \"module\"\n\t}\n}\n\nexport interface InternalModule<\n\texports extends InternalResolutions = InternalResolutions\n> extends RootModule<exports> {\n\troot?: BaseRoot\n}\n\nexport const bindModule = (\n\tmodule: InternalModule,\n\t$: BaseScope\n): InternalModule =>\n\tnew RootModule(\n\t\tflatMorph(module, (alias, value) => [\n\t\t\talias,\n\t\t\thasArkKind(value, \"module\") ?\n\t\t\t\tbindModule(value, $)\n\t\t\t:\t$.bindReference(value)\n\t\t])\n\t) as never\n\ntype exportSchemaScope<$> = {\n\t[k in keyof $]: instantiateRoot<$[k]>\n}\n\nexport type instantiateRoot<t> =\n\tt extends InternalResolution ?\n\t\t[t] extends [anyOrNever] ?\n\t\t\tBaseRoot\n\t\t:\tt\n\t:\tBaseRoot\n\nexport const SchemaModule: new <$ = {}>(\n\ttypes: exportSchemaScope<$>\n) => SchemaModule<$> = RootModule\n\nexport interface SchemaModule<$ = {}>\n\textends RootModule<exportSchemaScope<$>> {}\n"
  },
  {
    "path": "ark/schema/node.ts",
    "content": "import {\n\tCallable,\n\tappendUnique,\n\tflatMorph,\n\tincludes,\n\tisArray,\n\tisEmptyObject,\n\tisKeyOf,\n\tliftArray,\n\tprintable,\n\tstringifyPath,\n\tthrowError,\n\tthrowInternalError,\n\ttype Dict,\n\ttype GuardablePredicate,\n\ttype JsonStructure,\n\ttype Key,\n\ttype array,\n\ttype conform,\n\ttype listable,\n\ttype mutable,\n\ttype requireKeys\n} from \"@ark/util\"\nimport type { BaseConstraint } from \"./constraint.ts\"\nimport type {\n\tInner,\n\tNormalizedSchema,\n\tchildKindOf,\n\tmutableInnerOfKind,\n\tnodeOfKind,\n\treducibleKindOf\n} from \"./kinds.ts\"\nimport type { BaseParseOptions } from \"./parse.ts\"\nimport type { Intersection } from \"./roots/intersection.ts\"\nimport type { Morph } from \"./roots/morph.ts\"\nimport type { BaseRoot } from \"./roots/root.ts\"\nimport type { UnionNode } from \"./roots/union.ts\"\nimport type { Unit } from \"./roots/unit.ts\"\nimport type { BaseScope } from \"./scope.ts\"\nimport type { NodeCompiler } from \"./shared/compile.ts\"\nimport type {\n\tBaseNodeDeclaration,\n\tTypeMeta,\n\tattachmentsOf\n} from \"./shared/declare.ts\"\nimport type { ArkErrors } from \"./shared/errors.ts\"\nimport {\n\tbasisKinds,\n\tconstraintKinds,\n\tprecedenceOfKind,\n\trefinementKinds,\n\trootKinds,\n\tstructuralKinds,\n\ttype BasisKind,\n\ttype NodeKind,\n\ttype OpenNodeKind,\n\ttype RefinementKind,\n\ttype StructuralKind,\n\ttype UnknownAttachments\n} from \"./shared/implement.ts\"\nimport { $ark } from \"./shared/registry.ts\"\nimport {\n\tTraversal,\n\ttype TraverseAllows,\n\ttype TraverseApply\n} from \"./shared/traversal.ts\"\nimport { isNode } from \"./shared/utils.ts\"\nimport type { UndeclaredKeyHandling } from \"./structure/structure.ts\"\n\nexport abstract class BaseNode<\n\t// uses -ignore rather than -expect-error because this is not an error in .d.ts\n\t/** @ts-ignore allow instantiation assignment to the base type */\n\tout d extends BaseNodeDeclaration = BaseNodeDeclaration\n> extends Callable<\n\t(\n\t\tdata: d[\"prerequisite\"],\n\t\tctx?: Traversal,\n\t\tonFail?: ArkErrors.Handler | null\n\t) => unknown,\n\tattachmentsOf<d>\n> {\n\tattachments: UnknownAttachments\n\t$: BaseScope\n\tonFail: ArkErrors.Handler | null\n\tincludesTransform: boolean\n\n\tincludesContextualPredicate: boolean\n\tisCyclic: boolean\n\tallowsRequiresContext: boolean\n\trootApplyStrategy:\n\t\t| \"allows\"\n\t\t| \"contextual\"\n\t\t| \"optimistic\"\n\t\t| \"branchedOptimistic\"\n\tcontextFreeMorph: ((data: unknown) => unknown) | undefined\n\trootApply: (data: unknown, onFail: ArkErrors.Handler | null) => unknown\n\n\treferencesById: Record<string, BaseNode>\n\tshallowReferences: BaseNode[]\n\tflatRefs: FlatRef[]\n\tflatMorphs: FlatRef<Morph.Node | Intersection.Node>[]\n\tallows: (data: d[\"prerequisite\"]) => boolean\n\n\tget shallowMorphs(): array<Morph> {\n\t\treturn []\n\t}\n\n\tconstructor(attachments: UnknownAttachments, $: BaseScope) {\n\t\tsuper(\n\t\t\t(\n\t\t\t\tdata: any,\n\t\t\t\tpipedFromCtx?: Traversal | undefined,\n\t\t\t\tonFail: ArkErrors.Handler | null = this.onFail\n\t\t\t) => {\n\t\t\t\tif (pipedFromCtx) {\n\t\t\t\t\tthis.traverseApply(data, pipedFromCtx)\n\t\t\t\t\treturn pipedFromCtx.hasError() ?\n\t\t\t\t\t\t\tpipedFromCtx.errors\n\t\t\t\t\t\t:\tpipedFromCtx.data\n\t\t\t\t}\n\n\t\t\t\treturn this.rootApply(data, onFail)\n\t\t\t},\n\t\t\t{ attach: attachments as never }\n\t\t)\n\t\tthis.attachments = attachments\n\t\tthis.$ = $\n\t\tthis.onFail = this.meta.onFail ?? this.$.resolvedConfig.onFail\n\n\t\tthis.includesTransform =\n\t\t\tthis.hasKind(\"morph\") ||\n\t\t\t(this.hasKind(\"structure\") && this.structuralMorph !== undefined) ||\n\t\t\t(this.hasKind(\"sequence\") && this.inner.defaultables !== undefined)\n\n\t\t// if a predicate accepts exactly one arg, we can safely skip passing context\n\t\t// technically, a predicate could be written like `(data, ...[ctx]) => ctx.mustBe(\"malicious\")`\n\t\t// that would break here, but it feels like a pathological case and is better to let people optimize\n\t\tthis.includesContextualPredicate =\n\t\t\tthis.hasKind(\"predicate\") && this.inner.predicate.length !== 1\n\n\t\tthis.isCyclic = this.kind === \"alias\"\n\t\tthis.referencesById = { [this.id]: this }\n\n\t\tthis.shallowReferences =\n\t\t\tthis.hasKind(\"structure\") ?\n\t\t\t\t[this as BaseNode, ...(this.children as never)]\n\t\t\t:\tthis.children.reduce<BaseNode[]>(\n\t\t\t\t\t(acc, child) => appendUniqueNodes(acc, child.shallowReferences),\n\t\t\t\t\t[this]\n\t\t\t\t)\n\n\t\tconst isStructural = this.isStructural()\n\n\t\tthis.flatRefs = []\n\t\tthis.flatMorphs = []\n\n\t\tfor (let i = 0; i < this.children.length; i++) {\n\t\t\tthis.includesTransform ||= this.children[i].includesTransform\n\t\t\tthis.includesContextualPredicate ||=\n\t\t\t\tthis.children[i].includesContextualPredicate\n\t\t\tthis.isCyclic ||= this.children[i].isCyclic\n\n\t\t\tif (!isStructural) {\n\t\t\t\tconst childFlatRefs = this.children[i].flatRefs\n\t\t\t\tfor (let j = 0; j < childFlatRefs.length; j++) {\n\t\t\t\t\tconst childRef = childFlatRefs[j]\n\t\t\t\t\tif (\n\t\t\t\t\t\t!this.flatRefs.some(existing =>\n\t\t\t\t\t\t\tflatRefsAreEqual(existing, childRef)\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.flatRefs.push(childRef)\n\t\t\t\t\t\tfor (const branch of childRef.node.branches) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tbranch.hasKind(\"morph\") ||\n\t\t\t\t\t\t\t\t(branch.hasKind(\"intersection\") &&\n\t\t\t\t\t\t\t\t\tbranch.structure?.structuralMorph !== undefined)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tthis.flatMorphs.push({\n\t\t\t\t\t\t\t\t\tpath: childRef.path,\n\t\t\t\t\t\t\t\t\tpropString: childRef.propString,\n\t\t\t\t\t\t\t\t\tnode: branch\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tObject.assign(this.referencesById, this.children[i].referencesById)\n\t\t}\n\n\t\tthis.flatRefs.sort((l, r) =>\n\t\t\tl.path.length > r.path.length ? 1\n\t\t\t: l.path.length < r.path.length ? -1\n\t\t\t: l.propString > r.propString ? 1\n\t\t\t: l.propString < r.propString ? -1\n\t\t\t: l.node.expression < r.node.expression ? -1\n\t\t\t: 1\n\t\t)\n\n\t\tthis.allowsRequiresContext =\n\t\t\tthis.includesContextualPredicate || this.isCyclic\n\t\tthis.rootApplyStrategy =\n\t\t\t!this.allowsRequiresContext && this.flatMorphs.length === 0 ?\n\t\t\t\tthis.shallowMorphs.length === 0 ? \"allows\"\n\t\t\t\t: (\n\t\t\t\t\tthis.shallowMorphs.every(\n\t\t\t\t\t\tmorph => morph.length === 1 || morph.name === \"$arkStructuralMorph\"\n\t\t\t\t\t)\n\t\t\t\t) ?\n\t\t\t\t\tthis.hasKind(\"union\") ?\n\t\t\t\t\t\t// multiple morphs not yet supported for optimistic compilation\n\t\t\t\t\t\tthis.branches.some(branch => branch.shallowMorphs.length > 1) ?\n\t\t\t\t\t\t\t\"contextual\"\n\t\t\t\t\t\t:\t\"branchedOptimistic\"\n\t\t\t\t\t: this.shallowMorphs.length > 1 ? \"contextual\"\n\t\t\t\t\t: \"optimistic\"\n\t\t\t\t:\t\"contextual\"\n\t\t\t:\t\"contextual\"\n\n\t\tthis.rootApply = this.createRootApply()\n\t\tthis.allows =\n\t\t\tthis.allowsRequiresContext ?\n\t\t\t\tdata =>\n\t\t\t\t\tthis.traverseAllows(\n\t\t\t\t\t\tdata as never,\n\t\t\t\t\t\tnew Traversal(data, this.$.resolvedConfig)\n\t\t\t\t\t)\n\t\t\t:\tdata => (this.traverseAllows as any)(data)\n\t}\n\n\tprotected createRootApply(): this[\"rootApply\"] {\n\t\tswitch (this.rootApplyStrategy) {\n\t\t\tcase \"allows\":\n\t\t\t\treturn (data, onFail) => {\n\t\t\t\t\tif (this.allows(data)) return data\n\n\t\t\t\t\tconst ctx = new Traversal(data, this.$.resolvedConfig)\n\t\t\t\t\tthis.traverseApply(data, ctx)\n\t\t\t\t\treturn ctx.finalize(onFail)\n\t\t\t\t}\n\n\t\t\tcase \"contextual\":\n\t\t\t\treturn (data, onFail) => {\n\t\t\t\t\tconst ctx = new Traversal(data, this.$.resolvedConfig)\n\t\t\t\t\tthis.traverseApply(data, ctx)\n\t\t\t\t\treturn ctx.finalize(onFail)\n\t\t\t\t}\n\n\t\t\tcase \"optimistic\":\n\t\t\t\tthis.contextFreeMorph = this.shallowMorphs[0] as never\n\t\t\t\tconst clone = this.$.resolvedConfig.clone\n\t\t\t\treturn (data, onFail) => {\n\t\t\t\t\tif (this.allows(data)) {\n\t\t\t\t\t\treturn this.contextFreeMorph!(\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\tclone &&\n\t\t\t\t\t\t\t\t\t((typeof data === \"object\" && data !== null) ||\n\t\t\t\t\t\t\t\t\t\ttypeof data === \"function\")\n\t\t\t\t\t\t\t) ?\n\t\t\t\t\t\t\t\tclone(data)\n\t\t\t\t\t\t\t:\tdata\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\n\t\t\t\t\tconst ctx = new Traversal(data, this.$.resolvedConfig)\n\t\t\t\t\tthis.traverseApply(data, ctx)\n\t\t\t\t\treturn ctx.finalize(onFail)\n\t\t\t\t}\n\t\t\tcase \"branchedOptimistic\":\n\t\t\t\treturn (this as {} as UnionNode).createBranchedOptimisticRootApply()\n\t\t\tdefault:\n\t\t\t\tthis.rootApplyStrategy satisfies never\n\t\t\t\treturn throwInternalError(\n\t\t\t\t\t`Unexpected rootApplyStrategy ${this.rootApplyStrategy}`\n\t\t\t\t)\n\t\t}\n\t}\n\n\tabstract traverseAllows: TraverseAllows<d[\"prerequisite\"]>\n\tabstract traverseApply: TraverseApply<d[\"prerequisite\"]>\n\tabstract expression: string\n\tabstract compile(js: NodeCompiler): void\n\n\treadonly compiledMeta: string = compileMeta(this.metaJson)\n\n\tprotected cacheGetter<name extends keyof this>(\n\t\tname: name,\n\t\tvalue: this[name]\n\t): this[name] {\n\t\tObject.defineProperty(this, name, { value })\n\t\treturn value\n\t}\n\n\tget description(): string {\n\t\treturn this.cacheGetter(\n\t\t\t\"description\",\n\t\t\tthis.meta?.description ??\n\t\t\t\tthis.$.resolvedConfig[this.kind].description(this as never)\n\t\t)\n\t}\n\n\t// we don't cache this currently since it can be updated once a scope finishes\n\t// resolving cyclic references, although it may be possible to ensure it is cached safely\n\tget references(): BaseNode[] {\n\t\treturn Object.values(this.referencesById)\n\t}\n\n\treadonly precedence: number = precedenceOfKind(this.kind)\n\tprecompilation: string | undefined\n\n\t// defined as an arrow function since it is often detached, e.g. when passing to tRPC\n\t// otherwise, would run into issues with this binding\n\tassert = (data: d[\"prerequisite\"], pipedFromCtx?: Traversal): unknown =>\n\t\tthis(data, pipedFromCtx, errors => errors.throw())\n\n\ttraverse(\n\t\tdata: d[\"prerequisite\"],\n\t\tpipedFromCtx?: Traversal\n\t): ArkErrors | {} | null | undefined {\n\t\treturn this(data, pipedFromCtx, null)\n\t}\n\n\t/** rawIn should be used internally instead */\n\tget in(): unknown {\n\t\t// ensure the node has been finalized if in is being used externally\n\t\treturn this.cacheGetter(\n\t\t\t\"in\",\n\t\t\tthis.rawIn.isRoot() ? this.$.finalize(this.rawIn) : this.rawIn\n\t\t)\n\t}\n\n\tget rawIn(): BaseNode {\n\t\treturn this.cacheGetter(\"rawIn\", this.getIo(\"in\")) as never\n\t}\n\n\t/** rawOut should be used internally instead */\n\tget out(): unknown {\n\t\t// ensure the node has been finalized if out is being used externally\n\t\treturn this.cacheGetter(\n\t\t\t\"out\",\n\t\t\tthis.rawOut.isRoot() ? this.$.finalize(this.rawOut) : this.rawOut\n\t\t)\n\t}\n\n\tget rawOut(): BaseNode {\n\t\treturn this.cacheGetter(\"rawOut\", this.getIo(\"out\")) as never\n\t}\n\n\t// Should be refactored to use transform\n\t// https://github.com/arktypeio/arktype/issues/1020\n\tgetIo(ioKind: \"in\" | \"out\"): BaseNode {\n\t\tif (!this.includesTransform) return this as never\n\n\t\tconst ioInner: Record<any, unknown> = {}\n\t\tfor (const [k, v] of this.innerEntries) {\n\t\t\tconst keySchemaImplementation = this.impl.keys[k]\n\n\t\t\tif (keySchemaImplementation.reduceIo)\n\t\t\t\tkeySchemaImplementation.reduceIo(ioKind, ioInner, v)\n\t\t\telse if (keySchemaImplementation.child) {\n\t\t\t\tconst childValue = v as listable<BaseNode>\n\n\t\t\t\tioInner[k] =\n\t\t\t\t\tisArray(childValue) ?\n\t\t\t\t\t\tchildValue.map(child =>\n\t\t\t\t\t\t\tioKind === \"in\" ? child.rawIn : child.rawOut\n\t\t\t\t\t\t)\n\t\t\t\t\t: ioKind === \"in\" ? childValue.rawIn\n\t\t\t\t\t: childValue.rawOut\n\t\t\t} else ioInner[k] = v\n\t\t}\n\n\t\treturn this.$.node(this.kind, ioInner)\n\t}\n\n\ttoJSON(): JsonStructure {\n\t\treturn this.json\n\t}\n\n\ttoString(): string {\n\t\treturn `Type<${this.expression}>`\n\t}\n\n\tequals(r: unknown): boolean {\n\t\tconst rNode: BaseNode = isNode(r) ? r : this.$.parseDefinition(r)\n\t\treturn this.innerHash === rNode.innerHash\n\t}\n\n\tifEquals(r: unknown): BaseNode | undefined {\n\t\treturn this.equals(r) ? this : undefined\n\t}\n\n\thasKind<kind extends NodeKind>(kind: kind): this is nodeOfKind<kind> {\n\t\treturn this.kind === (kind as never)\n\t}\n\n\tassertHasKind<kind extends NodeKind>(kind: kind): nodeOfKind<kind> {\n\t\tif (this.kind !== kind)\n\t\t\tthrowError(`${this.kind} node was not of asserted kind ${kind}`)\n\t\treturn this as never\n\t}\n\n\thasKindIn<kinds extends NodeKind[]>(\n\t\t...kinds: kinds\n\t): this is nodeOfKind<kinds[number]> {\n\t\treturn kinds.includes(this.kind)\n\t}\n\n\tassertHasKindIn<kinds extends NodeKind[]>(\n\t\t...kinds: kinds\n\t): nodeOfKind<kinds[number]> {\n\t\tif (!includes(kinds, this.kind))\n\t\t\tthrowError(`${this.kind} node was not one of asserted kinds ${kinds}`)\n\t\treturn this as never\n\t}\n\n\tisBasis(): this is nodeOfKind<BasisKind> {\n\t\treturn includes(basisKinds, this.kind)\n\t}\n\n\tisConstraint(): this is BaseConstraint {\n\t\treturn includes(constraintKinds, this.kind)\n\t}\n\n\tisStructural(): this is nodeOfKind<StructuralKind> {\n\t\treturn includes(structuralKinds, this.kind)\n\t}\n\n\tisRefinement(): this is nodeOfKind<RefinementKind> {\n\t\treturn includes(refinementKinds, this.kind)\n\t}\n\n\tisRoot(): this is BaseRoot {\n\t\treturn includes(rootKinds, this.kind)\n\t}\n\n\tisUnknown(): boolean {\n\t\treturn this.hasKind(\"intersection\") && this.children.length === 0\n\t}\n\n\tisNever(): boolean {\n\t\treturn this.hasKind(\"union\") && this.children.length === 0\n\t}\n\n\thasUnit<value>(value: unknown): this is Unit.Node & { unit: value } {\n\t\treturn this.hasKind(\"unit\") && this.allows(value)\n\t}\n\n\thasOpenIntersection(): this is nodeOfKind<OpenNodeKind> {\n\t\treturn this.impl.intersectionIsOpen as never\n\t}\n\n\tget nestableExpression(): string {\n\t\treturn this.expression\n\t}\n\n\t// import this overload comes first for object key completions\n\t// to work properly\n\tselect<\n\t\tconst selector extends NodeSelector.CompositeInput,\n\t\tpredicate extends GuardablePredicate<\n\t\t\tNodeSelector.inferSelectKind<d[\"kind\"], selector>\n\t\t>\n\t>(\n\t\tselector: NodeSelector.validateComposite<selector, predicate>\n\t): NodeSelector.infer<d[\"kind\"], selector>\n\tselect<const selector extends NodeSelector.Single>(\n\t\tselector: selector\n\t): NodeSelector.infer<d[\"kind\"], selector>\n\tselect(selector: NodeSelector): NodeSelector.BaseResult {\n\t\tconst normalized = NodeSelector.normalize(selector)\n\t\treturn this._select(normalized)\n\t}\n\n\tprivate _select(selector: NodeSelector.Normalized): NodeSelector.BaseResult {\n\t\tlet nodes =\n\t\t\tNodeSelector.applyBoundary[selector.boundary ?? \"references\"](this)\n\n\t\tif (selector.kind) nodes = nodes.filter(n => n.kind === selector.kind)\n\t\tif (selector.where) nodes = nodes.filter(selector.where)\n\n\t\treturn NodeSelector.applyMethod[selector.method ?? \"filter\"](\n\t\t\tnodes,\n\t\t\tthis,\n\t\t\tselector\n\t\t)\n\t}\n\n\ttransform<mapper extends DeepNodeTransformation>(\n\t\tmapper: mapper,\n\t\topts?: DeepNodeTransformOptions\n\t):\n\t\t| nodeOfKind<reducibleKindOf<this[\"kind\"]>>\n\t\t| Extract<ReturnType<mapper>, null> {\n\t\treturn this._transform(mapper, this._createTransformContext(opts)) as never\n\t}\n\n\tprotected _createTransformContext(\n\t\topts: DeepNodeTransformOptions | undefined\n\t): DeepNodeTransformContext {\n\t\treturn {\n\t\t\troot: this,\n\t\t\tselected: undefined,\n\t\t\tseen: {},\n\t\t\tpath: [],\n\t\t\tparseOptions: {\n\t\t\t\tprereduced: opts?.prereduced ?? false\n\t\t\t},\n\t\t\tundeclaredKeyHandling: undefined,\n\t\t\t...opts\n\t\t}\n\t}\n\n\tprotected _transform(\n\t\tmapper: DeepNodeTransformation,\n\t\tctx: DeepNodeTransformContext\n\t): BaseNode | null {\n\t\tconst $ = ctx.bindScope ?? this.$\n\t\tif (ctx.seen[this.id])\n\t\t\t// Cyclic handling needs to be made more robust\n\t\t\t// https://github.com/arktypeio/arktype/issues/944\n\t\t\treturn this.$.lazilyResolve(ctx.seen[this.id]! as never)\n\t\tif (ctx.shouldTransform?.(this as never, ctx) === false) return this\n\n\t\tlet transformedNode: BaseRoot | undefined\n\n\t\tctx.seen[this.id] = () => transformedNode\n\n\t\tif (\n\t\t\tthis.hasKind(\"structure\") &&\n\t\t\tthis.undeclared !== ctx.undeclaredKeyHandling\n\t\t) {\n\t\t\tctx = {\n\t\t\t\t...ctx,\n\t\t\t\tundeclaredKeyHandling: this.undeclared\n\t\t\t}\n\t\t}\n\n\t\tconst innerWithTransformedChildren = flatMorph(\n\t\t\tthis.inner as Dict,\n\t\t\t(k, v) => {\n\t\t\t\tif (!this.impl.keys[k].child) return [k, v]\n\t\t\t\tconst children = v as listable<BaseNode>\n\t\t\t\tif (!isArray(children)) {\n\t\t\t\t\tconst transformed = children._transform(mapper, ctx)\n\t\t\t\t\treturn transformed ? [k, transformed] : []\n\t\t\t\t}\n\t\t\t\t// if the value was previously explicitly set to an empty list,\n\t\t\t\t// (e.g. branches for `never`), ensure it is not pruned\n\t\t\t\tif (children.length === 0) return [k, v]\n\t\t\t\tconst transformed = children.flatMap(n => {\n\t\t\t\t\tconst transformedChild = n._transform(mapper, ctx)\n\t\t\t\t\treturn transformedChild ?? []\n\t\t\t\t})\n\t\t\t\treturn transformed.length ? [k, transformed] : []\n\t\t\t}\n\t\t)\n\n\t\tdelete ctx.seen[this.id]\n\n\t\tconst innerWithMeta = Object.assign(innerWithTransformedChildren, {\n\t\t\tmeta: this.meta\n\t\t})\n\n\t\tconst transformedInner =\n\t\t\tctx.selected && !ctx.selected.includes(this) ?\n\t\t\t\tinnerWithMeta\n\t\t\t:\tmapper(this.kind, innerWithMeta, ctx)\n\n\t\tif (transformedInner === null) return null\n\n\t\tif (isNode(transformedInner))\n\t\t\treturn (transformedNode = transformedInner as never)\n\n\t\tconst transformedKeys = Object.keys(transformedInner)\n\t\tconst hasNoTypedKeys =\n\t\t\ttransformedKeys.length === 0 ||\n\t\t\t(transformedKeys.length === 1 && transformedKeys[0] === \"meta\")\n\n\t\tif (\n\t\t\thasNoTypedKeys &&\n\t\t\t// if inner was previously an empty object (e.g. unknown) ensure it is not pruned\n\t\t\t!isEmptyObject(this.inner)\n\t\t)\n\t\t\treturn null\n\n\t\tif (\n\t\t\t(this.kind === \"required\" ||\n\t\t\t\tthis.kind === \"optional\" ||\n\t\t\t\tthis.kind === \"index\") &&\n\t\t\t!(\"value\" in transformedInner)\n\t\t) {\n\t\t\treturn ctx.undeclaredKeyHandling ?\n\t\t\t\t\t({ ...transformedInner, value: $ark.intrinsic.unknown } as never)\n\t\t\t\t:\tnull\n\t\t}\n\n\t\tif (this.kind === \"morph\") {\n\t\t\t;(transformedInner as mutableInnerOfKind<\"morph\">).in ??= $ark.intrinsic\n\t\t\t\t.unknown as never\n\t\t}\n\n\t\treturn (transformedNode = $.node(\n\t\t\tthis.kind,\n\t\t\ttransformedInner,\n\t\t\tctx.parseOptions\n\t\t) as never)\n\t}\n\n\tconfigureReferences(\n\t\tmeta: TypeMeta.MappableInput.Internal,\n\t\tselector: NodeSelector = \"references\"\n\t): this {\n\t\tconst normalized = NodeSelector.normalize(selector)\n\n\t\tconst mapper = (\n\t\t\ttypeof meta === \"string\" ?\n\t\t\t\t(kind, inner) => ({\n\t\t\t\t\t...inner,\n\t\t\t\t\tmeta: { ...inner.meta, description: meta }\n\t\t\t\t})\n\t\t\t: typeof meta === \"function\" ?\n\t\t\t\t(kind, inner) => ({ ...inner, meta: meta(inner.meta) })\n\t\t\t:\t(kind, inner) => ({\n\t\t\t\t\t...inner,\n\t\t\t\t\tmeta: { ...inner.meta, ...meta }\n\t\t\t\t})) satisfies DeepNodeTransformation\n\n\t\tif (normalized.boundary === \"self\") {\n\t\t\treturn this.$.node(\n\t\t\t\tthis.kind,\n\t\t\t\tmapper(this.kind, { ...this.inner, meta: this.meta })\n\t\t\t) as never\n\t\t}\n\n\t\tconst rawSelected = this._select(normalized)\n\t\tconst selected = rawSelected && liftArray(rawSelected)\n\n\t\tconst shouldTransform: ShouldTransformFn =\n\t\t\tnormalized.boundary === \"child\" ?\n\t\t\t\t(node, ctx) => ctx.root.children.includes(node as never)\n\t\t\t: normalized.boundary === \"shallow\" ? node => node.kind !== \"structure\"\n\t\t\t: () => true\n\n\t\treturn this.$.finalize(\n\t\t\tthis.transform(mapper, {\n\t\t\t\tshouldTransform,\n\t\t\t\tselected\n\t\t\t}) as never\n\t\t)\n\t}\n}\n\n/** a literal key (named property) or a node (index signatures) representing part of a type structure */\nexport type KeyOrKeyNode = Key | BaseRoot\n\nexport type GettableKeyOrNode = KeyOrKeyNode | number\n\nexport type FlatRef<root extends BaseRoot = BaseRoot> = {\n\tpath: array<KeyOrKeyNode>\n\tnode: root\n\tpropString: string\n}\n\nexport type NodeSelector = NodeSelector.Single | NodeSelector.Composite\n\nconst NodeSelector = {\n\tapplyBoundary: {\n\t\tself: node => [node],\n\t\tchild: node => [...node.children],\n\t\tshallow: node => [...node.shallowReferences],\n\t\treferences: node => [...node.references]\n\t} satisfies Dict<NodeSelector.Boundary, (node: BaseNode) => BaseNode[]>,\n\tapplyMethod: {\n\t\tfilter: nodes => nodes,\n\t\tassertFilter: (nodes, from, selector) => {\n\t\t\tif (nodes.length === 0)\n\t\t\t\tthrowError(writeSelectAssertionMessage(from, selector))\n\t\t\treturn nodes\n\t\t},\n\t\tfind: nodes => nodes[0],\n\t\tassertFind: (nodes, from, selector) => {\n\t\t\tif (nodes.length === 0)\n\t\t\t\tthrowError(writeSelectAssertionMessage(from, selector))\n\t\t\treturn nodes[0]\n\t\t}\n\t} satisfies Dict<\n\t\tNodeSelector.Method,\n\t\t(nodes: BaseNode[], from: BaseNode, selector: NodeSelector) => unknown\n\t>,\n\tnormalize: (selector: NodeSelector): NodeSelector.Normalized =>\n\t\ttypeof selector === \"function\" ?\n\t\t\t{ boundary: \"references\", method: \"filter\", where: selector }\n\t\t: typeof selector === \"string\" ?\n\t\t\tisKeyOf(selector, NodeSelector.applyBoundary) ?\n\t\t\t\t{ method: \"filter\", boundary: selector }\n\t\t\t:\t{ boundary: \"references\", method: \"filter\", kind: selector }\n\t\t:\t{ boundary: \"references\", method: \"filter\", ...selector }\n}\n\nconst writeSelectAssertionMessage = (from: BaseNode, selector: NodeSelector) =>\n\t`${from} had no references matching ${printable(selector)}.`\n\nexport declare namespace NodeSelector {\n\texport type SelectableFn<input, returns, kind extends NodeKind = NodeKind> = {\n\t\t// this overload must come first for object key completions to work\n\t\t<\n\t\t\tconst selector extends NodeSelector.CompositeInput,\n\t\t\tpredicate extends GuardablePredicate<\n\t\t\t\tNodeSelector.inferSelectKind<kind, selector>\n\t\t\t>\n\t\t>(\n\t\t\tinput: input,\n\t\t\tselector?: NodeSelector.validateComposite<selector, predicate>\n\t\t): returns\n\t\t<const selector extends NodeSelector.Single>(\n\t\t\tinput: input,\n\t\t\tselector?: selector\n\t\t): returns\n\t}\n\n\texport type Single =\n\t\t| NodeSelector.Boundary\n\t\t| NodeSelector.Kind\n\t\t| GuardablePredicate<BaseNode>\n\n\texport type Boundary = \"self\" | \"child\" | \"shallow\" | \"references\"\n\n\texport type Kind = NodeKind\n\n\texport type Method = \"filter\" | \"assertFilter\" | \"find\" | \"assertFind\"\n\n\texport interface Composite {\n\t\tmethod?: Method\n\t\tboundary?: Boundary\n\t\tkind?: Kind\n\t\twhere?: GuardablePredicate<BaseNode>\n\t}\n\n\texport type Normalized = requireKeys<Composite, \"method\" | \"boundary\">\n\n\texport type CompositeInput = Omit<Composite, \"where\">\n\n\texport type BaseResult = BaseNode | BaseNode[] | undefined\n\n\texport type validateComposite<selector, predicate> = {\n\t\t[k in keyof selector]: k extends \"where\" ? predicate\n\t\t:\tconform<selector[k], CompositeInput[k & keyof CompositeInput]>\n\t}\n\n\texport type infer<selfKind extends NodeKind, selector> = applyMethod<\n\t\tselector extends NodeSelector.WhereCastInput<any, infer narrowed> ? narrowed\n\t\t:\tNodeSelector.inferSelectKind<selfKind, selector>,\n\t\tselector\n\t>\n\n\ttype BoundaryInput<b extends Boundary> = b | { boundary: b }\n\ttype KindInput<k extends Kind> = k | { kind: k }\n\ttype WhereCastInput<kindNode extends BaseNode, narrowed extends kindNode> =\n\t\t| ((In: kindNode) => In is narrowed)\n\t\t| { where: (In: kindNode) => In is narrowed }\n\n\texport type inferSelectKind<selfKind extends NodeKind, selector> =\n\t\tselectKind<selfKind, selector> extends infer kind extends NodeKind ?\n\t\t\tNodeKind extends kind ?\n\t\t\t\tBaseNode\n\t\t\t:\tnodeOfKind<kind>\n\t\t:\tnever\n\n\ttype selectKind<selfKind extends NodeKind, selector> =\n\t\tselector extends BoundaryInput<\"self\"> ? selfKind\n\t\t: selector extends KindInput<infer kind> ? kind\n\t\t: selector extends BoundaryInput<\"child\"> ? selfKind | childKindOf<selfKind>\n\t\t: NodeKind\n\n\ttype applyMethod<t, selector> =\n\t\tselector extends { method: infer method extends Method } ?\n\t\t\tmethod extends \"filter\" ? t[]\n\t\t\t: method extends \"assertFilter\" ? [t, ...t[]]\n\t\t\t: method extends \"find\" ? t | undefined\n\t\t\t: method extends \"assertFind\" ? t\n\t\t\t: never\n\t\t:\t// default is \"filter\"\n\t\t\tt[]\n}\n\nexport const typePathToPropString = (path: array<KeyOrKeyNode>): string =>\n\tstringifyPath(path, {\n\t\tstringifyNonKey: node => node.expression\n\t})\n\nconst referenceMatcher = /\"(\\$ark\\.[^\"]+)\"/g\n\nconst compileMeta = (metaJson: unknown) =>\n\tJSON.stringify(metaJson).replace(referenceMatcher, \"$1\")\n\nexport const flatRef = <node extends BaseRoot>(\n\tpath: array<KeyOrKeyNode>,\n\tnode: node\n): FlatRef<node> => ({\n\tpath,\n\tnode,\n\tpropString: typePathToPropString(path)\n})\n\nexport const flatRefsAreEqual = (l: FlatRef, r: FlatRef): boolean =>\n\tl.propString === r.propString && l.node.equals(r.node)\n\nexport const appendUniqueFlatRefs = <node extends BaseRoot>(\n\texisting: FlatRef<node>[] | undefined,\n\trefs: listable<FlatRef<node>>\n): FlatRef<node>[] =>\n\tappendUnique(existing, refs, {\n\t\tisEqual: flatRefsAreEqual\n\t})\n\nexport const appendUniqueNodes = <node extends BaseNode>(\n\texisting: node[] | undefined,\n\trefs: listable<node>\n): node[] =>\n\tappendUnique(existing, refs, {\n\t\tisEqual: (l, r) => l.equals(r)\n\t})\n\nexport type DeepNodeTransformOptions = {\n\tshouldTransform?: ShouldTransformFn\n\tbindScope?: BaseScope\n\tprereduced?: boolean\n\tselected?: readonly BaseNode[] | undefined\n}\n\nexport type ShouldTransformFn = (\n\tnode: BaseNode,\n\tctx: DeepNodeTransformContext\n) => boolean\n\nexport interface DeepNodeTransformContext extends DeepNodeTransformOptions {\n\troot: BaseNode\n\tselected: readonly BaseNode[] | undefined\n\tpath: mutable<array<KeyOrKeyNode>>\n\tseen: { [originalId: string]: (() => BaseNode | undefined) | undefined }\n\tparseOptions: BaseParseOptions\n\tundeclaredKeyHandling: UndeclaredKeyHandling | undefined\n}\n\nexport type DeepNodeTransformation = <kind extends NodeKind>(\n\tkind: kind,\n\tinnerWithMeta: Inner<kind> & { meta: ArkEnv.meta },\n\tctx: DeepNodeTransformContext\n) => NormalizedSchema<kind> | null\n"
  },
  {
    "path": "ark/schema/package.json",
    "content": "{\n\t\"name\": \"@ark/schema\",\n\t\"version\": \"0.56.0\",\n\t\"license\": \"MIT\",\n\t\"author\": {\n\t\t\"name\": \"David Blass\",\n\t\t\"email\": \"david@arktype.io\",\n\t\t\"url\": \"https://arktype.io\"\n\t},\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"https://github.com/arktypeio/arktype.git\",\n\t\t\"directory\": \"ark/schema\"\n\t},\n\t\"type\": \"module\",\n\t\"main\": \"./out/index.js\",\n\t\"types\": \"./out/index.d.ts\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"ark-ts\": \"./index.ts\",\n\t\t\t\"default\": \"./out/index.js\"\n\t\t},\n\t\t\"./config\": {\n\t\t\t\"ark-ts\": \"./config.ts\",\n\t\t\t\"default\": \"./out/config.js\"\n\t\t},\n\t\t\"./internal/*.ts\": {\n\t\t\t\"ark-ts\": \"./*.ts\",\n\t\t\t\"default\": \"./out/*.js\"\n\t\t},\n\t\t\"./internal/*.js\": {\n\t\t\t\"ark-ts\": \"./*.ts\",\n\t\t\t\"default\": \"./out/*.js\"\n\t\t}\n\t},\n\t\"files\": [\n\t\t\"out\"\n\t],\n\t\"scripts\": {\n\t\t\"build\": \"ts ../repo/build.ts\",\n\t\t\"bench\": \"ts ./__tests__/comparison.bench.ts\",\n\t\t\"test\": \"ts ../repo/testPackage.ts\",\n\t\t\"tnt\": \"ts ../repo/testPackage.ts --skipTypes\"\n\t},\n\t\"dependencies\": {\n\t\t\"@ark/util\": \"workspace:*\"\n\t},\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t}\n}\n"
  },
  {
    "path": "ark/schema/parse.ts",
    "content": "import {\n\tdomainDescriptions,\n\tentriesOf,\n\tflatMorph,\n\thasDomain,\n\tisArray,\n\tisEmptyObject,\n\tprintable,\n\tthrowInternalError,\n\tthrowParseError,\n\tunset,\n\ttype Brand,\n\ttype dict,\n\ttype Json,\n\ttype listable,\n\ttype PartialRecord\n} from \"@ark/util\"\nimport {\n\tnodeClassesByKind,\n\tnodeImplementationsByKind,\n\ttype NormalizedSchema\n} from \"./kinds.ts\"\nimport type { BaseNode } from \"./node.ts\"\nimport type { BaseRoot } from \"./roots/root.ts\"\nimport type { BaseScope } from \"./scope.ts\"\nimport type { TypeMeta } from \"./shared/declare.ts\"\nimport { Disjoint } from \"./shared/disjoint.ts\"\nimport {\n\tconstraintKeys,\n\tdefaultValueSerializer,\n\tisNodeKind,\n\tprecedenceOfKind,\n\ttype NodeKind,\n\ttype RootKind,\n\ttype UnknownAttachments\n} from \"./shared/implement.ts\"\nimport { $ark } from \"./shared/registry.ts\"\nimport { hasArkKind, isNode, type arkKind } from \"./shared/utils.ts\"\n\nexport type ContextualArgs = Record<string, BaseRoot | NodeId>\n\nexport type BaseParseOptions<prereduced extends boolean = boolean> = {\n\talias?: string\n\tprereduced?: prereduced\n\targs?: ContextualArgs\n\tid?: NodeId\n}\n\nexport interface BaseParseContextInput extends BaseParseOptions {\n\tprefix: string\n\tdef: unknown\n}\n\nexport interface AttachedParseContext {\n\t[arkKind]: \"context\"\n\t$: BaseScope\n\tid: NodeId\n\tphase: \"unresolved\" | \"resolving\" | \"resolved\"\n}\n\nexport interface BaseParseContext\n\textends BaseParseContextInput,\n\t\tAttachedParseContext {\n\tid: NodeId\n}\n\nexport interface NodeParseContextInput<kind extends NodeKind = NodeKind>\n\textends BaseParseContextInput {\n\tkind: kind\n\tdef: NormalizedSchema<kind>\n}\n\nexport interface NodeParseContext<kind extends NodeKind = NodeKind>\n\textends NodeParseContextInput<kind>,\n\t\tAttachedParseContext {\n\tid: NodeId\n}\n\nexport const schemaKindOf = <kind extends RootKind = RootKind>(\n\tschema: unknown,\n\tallowedKinds?: readonly kind[]\n): kind => {\n\tconst kind = discriminateRootKind(schema)\n\tif (allowedKinds && !allowedKinds.includes(kind as never)) {\n\t\treturn throwParseError(\n\t\t\t`Root of kind ${kind} should be one of ${allowedKinds}`\n\t\t)\n\t}\n\treturn kind as never\n}\n\nconst discriminateRootKind = (schema: unknown): RootKind => {\n\tif (hasArkKind(schema, \"root\")) return schema.kind\n\tif (typeof schema === \"string\") {\n\t\treturn (\n\t\t\tschema[0] === \"$\" ? \"alias\"\n\t\t\t: schema in domainDescriptions ? \"domain\"\n\t\t\t: \"proto\"\n\t\t)\n\t}\n\tif (typeof schema === \"function\") return \"proto\"\n\n\t// throw at end of function\n\tif (typeof schema !== \"object\" || schema === null)\n\t\treturn throwParseError(writeInvalidSchemaMessage(schema))\n\n\tif (\"morphs\" in schema) return \"morph\"\n\n\tif (\"branches\" in schema || isArray(schema)) return \"union\"\n\n\tif (\"unit\" in schema) return \"unit\"\n\n\tif (\"reference\" in schema) return \"alias\"\n\n\tconst schemaKeys = Object.keys(schema)\n\n\tif (schemaKeys.length === 0 || schemaKeys.some(k => k in constraintKeys))\n\t\treturn \"intersection\"\n\tif (\"proto\" in schema) return \"proto\"\n\tif (\"domain\" in schema) return \"domain\"\n\n\treturn throwParseError(writeInvalidSchemaMessage(schema))\n}\n\nexport const writeInvalidSchemaMessage = (schema: unknown): string =>\n\t`${printable(schema)} is not a valid type schema`\n\nconst nodeCountsByPrefix: PartialRecord<string, number> = {}\n\nconst serializeListableChild = (listableNode: listable<BaseNode>) =>\n\tisArray(listableNode) ?\n\t\tlistableNode.map(node => node.collapsibleJson)\n\t:\tlistableNode.collapsibleJson\n\nexport type NodeId = Brand<string, \"NodeId\">\n\nexport type NodeResolver = (id: NodeId) => BaseNode\n\nexport const nodesByRegisteredId: Record<\n\tNodeId,\n\tBaseNode | BaseParseContext | undefined\n> = {}\n\n$ark.nodesByRegisteredId = nodesByRegisteredId\n\nexport const registerNodeId = (prefix: string): NodeId => {\n\tnodeCountsByPrefix[prefix] ??= 0\n\treturn `${prefix}${++nodeCountsByPrefix[prefix]!}` as NodeId\n}\n\nexport const parseNode = (ctx: NodeParseContext): BaseNode => {\n\tconst impl = nodeImplementationsByKind[ctx.kind]\n\tconst configuredSchema =\n\t\timpl.applyConfig?.(ctx.def, ctx.$.resolvedConfig) ?? ctx.def\n\tconst inner: dict = {}\n\tconst { meta: metaSchema, ...innerSchema } = configuredSchema as dict & {\n\t\tmeta?: TypeMeta.Collapsible\n\t}\n\n\tconst meta: ArkEnv.meta & dict =\n\t\tmetaSchema === undefined ? {}\n\t\t: typeof metaSchema === \"string\" ? { description: metaSchema }\n\t\t: (metaSchema as never)\n\n\t// ensure node entries are parsed in order of precedence, with non-children\n\t// parsed first\n\tconst innerSchemaEntries = entriesOf(innerSchema)\n\t\t.sort(([lKey], [rKey]) =>\n\t\t\tisNodeKind(lKey) ?\n\t\t\t\tisNodeKind(rKey) ? precedenceOfKind(lKey) - precedenceOfKind(rKey)\n\t\t\t\t:\t1\n\t\t\t: isNodeKind(rKey) ? -1\n\t\t\t: lKey < rKey ? -1\n\t\t\t: 1\n\t\t)\n\t\t.filter(([k, v]) => {\n\t\t\t// move meta. prefixed props to meta, overwriting existing nested\n\t\t\t// props of the same name if they exist\n\t\t\tif (k.startsWith(\"meta.\")) {\n\t\t\t\tconst metaKey = k.slice(5)\n\t\t\t\tmeta[metaKey] = v\n\t\t\t\treturn false\n\t\t\t}\n\t\t\treturn true\n\t\t})\n\n\tfor (const entry of innerSchemaEntries) {\n\t\tconst k = entry[0]\n\t\tconst keyImpl = impl.keys[k]\n\t\tif (!keyImpl)\n\t\t\treturn throwParseError(`Key ${k} is not valid on ${ctx.kind} schema`)\n\n\t\tconst v = keyImpl.parse ? keyImpl.parse(entry[1], ctx) : entry[1]\n\t\tif (v !== unset && (v !== undefined || keyImpl.preserveUndefined))\n\t\t\tinner[k] = v\n\t}\n\n\tif (impl.reduce && !ctx.prereduced) {\n\t\tconst reduced = impl.reduce(inner, ctx.$)\n\t\tif (reduced) {\n\t\t\tif (reduced instanceof Disjoint) return reduced.throw()\n\n\t\t\t// we can't cache this reduction for now in case the reduction involved\n\t\t\t// impliedSiblings\n\t\t\treturn withMeta(reduced, meta)\n\t\t}\n\t}\n\n\tconst node = createNode({\n\t\tid: ctx.id,\n\t\tkind: ctx.kind,\n\t\tinner,\n\t\tmeta,\n\t\t$: ctx.$\n\t})\n\n\treturn node\n}\n\nexport type CreateNodeInput = {\n\tid: NodeId\n\tkind: NodeKind\n\tinner: dict\n\tmeta: ArkEnv.meta\n\t$: BaseScope\n\tignoreCache?: true\n}\n\nexport const createNode = ({\n\tid,\n\tkind,\n\tinner,\n\tmeta,\n\t$,\n\tignoreCache\n}: CreateNodeInput): BaseNode => {\n\tconst impl = nodeImplementationsByKind[kind]\n\tconst innerEntries = entriesOf(inner)\n\tconst children: BaseNode[] = []\n\tlet innerJson: dict = {}\n\n\tfor (const [k, v] of innerEntries) {\n\t\tconst keyImpl = impl.keys[k]\n\t\tconst serialize =\n\t\t\tkeyImpl.serialize ??\n\t\t\t(keyImpl.child ? serializeListableChild : defaultValueSerializer)\n\n\t\tinnerJson[k] = serialize(v as never)\n\n\t\tif (keyImpl.child === true) {\n\t\t\tconst listableNode = v as listable<BaseNode>\n\t\t\tif (isArray(listableNode)) children.push(...listableNode)\n\t\t\telse children.push(listableNode)\n\t\t} else if (typeof keyImpl.child === \"function\")\n\t\t\tchildren.push(...keyImpl.child(v as never))\n\t}\n\n\tif (impl.finalizeInnerJson)\n\t\tinnerJson = impl.finalizeInnerJson(innerJson) as never\n\n\tlet json = { ...innerJson }\n\tlet metaJson: ArkEnv.meta & dict = {}\n\n\tif (!isEmptyObject(meta)) {\n\t\tmetaJson = flatMorph(meta, (k, v) => [\n\t\t\tk,\n\t\t\tk === \"examples\" ? v : defaultValueSerializer(v)\n\t\t]) as never\n\t\tjson.meta = possiblyCollapse(metaJson, \"description\", true)\n\t}\n\n\tinnerJson = possiblyCollapse(innerJson, impl.collapsibleKey, false)\n\tconst innerHash = JSON.stringify({ kind, ...innerJson })\n\n\tjson = possiblyCollapse(json, impl.collapsibleKey, false)\n\tconst collapsibleJson = possiblyCollapse(json, impl.collapsibleKey, true)\n\tconst hash = JSON.stringify({ kind, ...json })\n\n\t// we have to wait until after reduction to return a cached entry,\n\t// since reduction can add impliedSiblings\n\tif ($.nodesByHash[hash] && !ignoreCache) return $.nodesByHash[hash]\n\n\tconst attachments: UnknownAttachments & dict = {\n\t\tid,\n\t\tkind,\n\t\timpl,\n\t\tinner,\n\t\tinnerEntries,\n\t\tinnerJson,\n\t\tinnerHash,\n\t\tmeta,\n\t\tmetaJson,\n\t\tjson,\n\t\thash,\n\t\tcollapsibleJson: collapsibleJson as Json,\n\t\tchildren\n\t}\n\n\tif (kind !== \"intersection\") {\n\t\tfor (const k in inner)\n\t\t\tif (k !== \"in\" && k !== \"out\") attachments[k] = inner[k]\n\t}\n\n\tconst node: BaseNode = new nodeClassesByKind[kind](attachments as never, $)\n\n\treturn ($.nodesByHash[hash] = node)\n}\n\nexport const withId = <node extends BaseNode>(node: node, id: NodeId): node => {\n\tif (node.id === id) return node\n\tif (isNode(nodesByRegisteredId[id]))\n\t\tthrowInternalError(`Unexpected attempt to overwrite node id ${id}`)\n\t// have to ignore cache to force creation of new potentially cyclic id\n\treturn createNode({\n\t\tid,\n\t\tkind: node.kind,\n\t\tinner: node.inner,\n\t\tmeta: node.meta,\n\t\t$: node.$,\n\t\tignoreCache: true\n\t}) as never\n}\n\nexport const withMeta = <node extends BaseNode>(\n\tnode: node,\n\tmeta: ArkEnv.meta,\n\tid?: NodeId\n): node => {\n\tif (id && isNode(nodesByRegisteredId[id]))\n\t\tthrowInternalError(`Unexpected attempt to overwrite node id ${id}`)\n\treturn createNode({\n\t\tid: id ?? registerNodeId(meta.alias ?? node.kind),\n\t\tkind: node.kind,\n\t\tinner: node.inner,\n\t\tmeta,\n\t\t$: node.$\n\t}) as never\n}\n\nconst possiblyCollapse = <allowPrimitive extends boolean>(\n\tjson: dict,\n\ttoKey: string | undefined,\n\tallowPrimitive: allowPrimitive\n): [allowPrimitive] extends [false] ? dict : unknown => {\n\tconst collapsibleKeys = Object.keys(json)\n\tif (collapsibleKeys.length === 1 && collapsibleKeys[0] === toKey) {\n\t\tconst collapsed = json[toKey]\n\n\t\tif (allowPrimitive) return collapsed as never\n\n\t\tif (\n\t\t\t// if the collapsed value is still an object\n\t\t\thasDomain(collapsed, \"object\") &&\n\t\t\t// and the JSON did not include any implied keys\n\t\t\t(Object.keys(collapsed).length === 1 || Array.isArray(collapsed))\n\t\t) {\n\t\t\t// we can replace it with its collapsed value\n\t\t\treturn collapsed as never\n\t\t}\n\t}\n\treturn json as never\n}\n"
  },
  {
    "path": "ark/schema/predicate.ts",
    "content": "import { BaseConstraint } from \"./constraint.ts\"\nimport type { NodeCompiler } from \"./shared/compile.ts\"\nimport type {\n\tBaseErrorContext,\n\tBaseNormalizedSchema,\n\tdeclareNode\n} from \"./shared/declare.ts\"\nimport {\n\tcompileObjectLiteral,\n\timplementNode,\n\ttype nodeImplementationOf\n} from \"./shared/implement.ts\"\nimport type { JsonSchema } from \"./shared/jsonSchema.ts\"\nimport {\n\ttype RegisteredReference,\n\tregisteredReference\n} from \"./shared/registry.ts\"\nimport type { ToJsonSchema } from \"./shared/toJsonSchema.ts\"\nimport type {\n\tTraversal,\n\tTraverseAllows,\n\tTraverseApply\n} from \"./shared/traversal.ts\"\n\nexport declare namespace Predicate {\n\texport type Schema<predicate extends Predicate = Predicate> =\n\t\t| NormalizedSchema<predicate>\n\t\t| predicate\n\n\texport interface NormalizedSchema<predicate extends Predicate = Predicate>\n\t\textends BaseNormalizedSchema {\n\t\treadonly predicate: predicate\n\t}\n\n\texport interface Inner<predicate extends Predicate = Predicate> {\n\t\treadonly predicate: predicate\n\t}\n\n\texport interface ErrorContext extends BaseErrorContext<\"predicate\"> {\n\t\treadonly predicate?: Predicate\n\t}\n\n\texport interface Declaration\n\t\textends declareNode<{\n\t\t\tkind: \"predicate\"\n\t\t\tschema: Schema\n\t\t\tnormalizedSchema: NormalizedSchema\n\t\t\tinner: Inner\n\t\t\tintersectionIsOpen: true\n\t\t\terrorContext: ErrorContext\n\t\t}> {}\n\n\texport type Node = PredicateNode\n}\n\nconst implementation: nodeImplementationOf<Predicate.Declaration> =\n\timplementNode<Predicate.Declaration>({\n\t\tkind: \"predicate\",\n\t\thasAssociatedError: true,\n\t\tcollapsibleKey: \"predicate\",\n\t\tkeys: {\n\t\t\tpredicate: {}\n\t\t},\n\t\tnormalize: schema =>\n\t\t\ttypeof schema === \"function\" ? { predicate: schema } : schema,\n\t\tdefaults: {\n\t\t\tdescription: node =>\n\t\t\t\t`valid according to ${node.predicate.name || \"an anonymous predicate\"}`\n\t\t},\n\t\tintersectionIsOpen: true,\n\t\tintersections: {\n\t\t\t// as long as the narrows in l and r are individually safe to check\n\t\t\t// in the order they're specified, checking them in the order\n\t\t\t// resulting from this intersection should also be safe.\n\t\t\tpredicate: () => null\n\t\t}\n\t})\n\nexport class PredicateNode extends BaseConstraint<Predicate.Declaration> {\n\tserializedPredicate: RegisteredReference = registeredReference(this.predicate)\n\tcompiledCondition = `${this.serializedPredicate}(data, ctx)`\n\tcompiledNegation = `!${this.compiledCondition}`\n\n\timpliedBasis = null\n\n\texpression: string = this.serializedPredicate\n\ttraverseAllows: TraverseAllows = this.predicate as never\n\n\terrorContext: Predicate.ErrorContext = {\n\t\tcode: \"predicate\",\n\t\tdescription: this.description,\n\t\tmeta: this.meta\n\t}\n\n\tcompiledErrorContext = compileObjectLiteral(this.errorContext)\n\n\ttraverseApply: TraverseApply = (data, ctx) => {\n\t\tconst errorCount = ctx.currentErrorCount\n\t\tif (\n\t\t\t!this.predicate(data, ctx.external) &&\n\t\t\tctx.currentErrorCount === errorCount\n\t\t)\n\t\t\tctx.errorFromNodeContext(this.errorContext)\n\t}\n\n\tcompile(js: NodeCompiler): void {\n\t\tif (js.traversalKind === \"Allows\") {\n\t\t\tjs.return(this.compiledCondition)\n\t\t\treturn\n\t\t}\n\n\t\tjs.initializeErrorCount()\n\t\tjs.if(\n\t\t\t// only add the default error if the predicate didn't add one itself\n\t\t\t`${this.compiledNegation} && ctx.currentErrorCount === errorCount`,\n\t\t\t() => js.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`)\n\t\t)\n\t}\n\n\treduceJsonSchema(\n\t\tbase: JsonSchema.Constrainable,\n\t\tctx: ToJsonSchema.Context\n\t): JsonSchema {\n\t\treturn ctx.fallback.predicate({\n\t\t\tcode: \"predicate\",\n\t\t\tbase,\n\t\t\tpredicate: this.predicate\n\t\t})\n\t}\n}\n\nexport const Predicate = {\n\timplementation,\n\tNode: PredicateNode\n}\n\nexport type Predicate<data = any> = (data: data, ctx: Traversal) => boolean\n\nexport declare namespace Predicate {\n\texport type Casted<input = never, narrowed extends input = input> = (\n\t\tinput: input,\n\t\tctx: Traversal\n\t) => input is narrowed\n\n\texport type Castable<input = never, narrowed extends input = input> =\n\t\t| Predicate<input>\n\t\t| Casted<input, narrowed>\n}\n"
  },
  {
    "path": "ark/schema/refinements/after.ts",
    "content": "import { describeCollapsibleDate } from \"@ark/util\"\nimport type { BaseRoot } from \"../roots/root.ts\"\nimport type { BaseErrorContext, declareNode } from \"../shared/declare.ts\"\nimport {\n\timplementNode,\n\ttype nodeImplementationOf\n} from \"../shared/implement.ts\"\nimport type { JsonSchema } from \"../shared/jsonSchema.ts\"\nimport { $ark } from \"../shared/registry.ts\"\nimport type { ToJsonSchema } from \"../shared/toJsonSchema.ts\"\nimport type { TraverseAllows } from \"../shared/traversal.ts\"\nimport {\n\tBaseRange,\n\tcreateDateSchemaNormalizer,\n\tparseDateLimit,\n\ttype BaseRangeInner,\n\ttype LimitSchemaValue,\n\ttype UnknownExpandedRangeSchema,\n\ttype UnknownNormalizedRangeSchema\n} from \"./range.ts\"\n\nexport declare namespace After {\n\texport interface Inner extends BaseRangeInner {\n\t\trule: Date\n\t}\n\n\texport interface NormalizedSchema extends UnknownNormalizedRangeSchema {\n\t\trule: LimitSchemaValue\n\t}\n\n\texport interface ExpandedSchema extends UnknownExpandedRangeSchema {\n\t\trule: LimitSchemaValue\n\t}\n\n\texport type Schema = ExpandedSchema | LimitSchemaValue\n\n\texport interface ErrorContext extends BaseErrorContext<\"after\">, Inner {}\n\n\texport interface Declaration\n\t\textends declareNode<{\n\t\t\tkind: \"after\"\n\t\t\tschema: Schema\n\t\t\tnormalizedSchema: NormalizedSchema\n\t\t\tinner: Inner\n\t\t\tprerequisite: Date\n\t\t\terrorContext: ErrorContext\n\t\t}> {}\n\n\texport type Node = AfterNode\n}\n\nconst implementation: nodeImplementationOf<After.Declaration> =\n\timplementNode<After.Declaration>({\n\t\tkind: \"after\",\n\t\tcollapsibleKey: \"rule\",\n\t\thasAssociatedError: true,\n\t\tkeys: {\n\t\t\trule: {\n\t\t\t\tparse: parseDateLimit,\n\t\t\t\tserialize: schema => schema.toISOString()\n\t\t\t}\n\t\t},\n\t\tnormalize: createDateSchemaNormalizer(\"after\"),\n\t\tdefaults: {\n\t\t\tdescription: node => `${node.collapsibleLimitString} or later`,\n\t\t\tactual: describeCollapsibleDate\n\t\t},\n\t\tintersections: {\n\t\t\tafter: (l, r) => (l.isStricterThan(r) ? l : r)\n\t\t}\n\t})\n\nexport class AfterNode extends BaseRange<After.Declaration> {\n\timpliedBasis: BaseRoot = $ark.intrinsic.Date.internal\n\n\tcollapsibleLimitString = describeCollapsibleDate(this.rule)\n\n\ttraverseAllows: TraverseAllows<Date> = data => data >= this.rule\n\n\treduceJsonSchema(base: JsonSchema, ctx: ToJsonSchema.Context): JsonSchema {\n\t\treturn ctx.fallback.date({ code: \"date\", base, after: this.rule })\n\t}\n}\n\nexport const After = {\n\timplementation,\n\tNode: AfterNode\n}\n"
  },
  {
    "path": "ark/schema/refinements/before.ts",
    "content": "import { describeCollapsibleDate } from \"@ark/util\"\nimport type { BaseRoot } from \"../roots/root.ts\"\nimport type { BaseErrorContext, declareNode } from \"../shared/declare.ts\"\nimport { Disjoint } from \"../shared/disjoint.ts\"\nimport {\n\timplementNode,\n\ttype nodeImplementationOf\n} from \"../shared/implement.ts\"\nimport type { JsonSchema } from \"../shared/jsonSchema.ts\"\nimport { $ark } from \"../shared/registry.ts\"\nimport type { ToJsonSchema } from \"../shared/toJsonSchema.ts\"\nimport type { TraverseAllows } from \"../shared/traversal.ts\"\nimport {\n\tBaseRange,\n\tcreateDateSchemaNormalizer,\n\tparseDateLimit,\n\ttype BaseRangeInner,\n\ttype LimitSchemaValue,\n\ttype UnknownExpandedRangeSchema,\n\ttype UnknownNormalizedRangeSchema\n} from \"./range.ts\"\n\nexport declare namespace Before {\n\texport interface Inner extends BaseRangeInner {\n\t\trule: Date\n\t}\n\n\texport interface NormalizedSchema extends UnknownNormalizedRangeSchema {\n\t\trule: LimitSchemaValue\n\t}\n\n\texport interface ExpandedSchema extends UnknownExpandedRangeSchema {\n\t\trule: LimitSchemaValue\n\t}\n\n\texport type Schema = ExpandedSchema | LimitSchemaValue\n\n\texport interface ErrorContext extends BaseErrorContext<\"before\">, Inner {}\n\n\texport interface Declaration\n\t\textends declareNode<{\n\t\t\tkind: \"before\"\n\t\t\tschema: Schema\n\t\t\tnormalizedSchema: NormalizedSchema\n\t\t\tinner: Inner\n\t\t\tprerequisite: Date\n\t\t\terrorContext: ErrorContext\n\t\t}> {}\n\n\texport type Node = BeforeNode\n}\n\nconst implementation: nodeImplementationOf<Before.Declaration> =\n\timplementNode<Before.Declaration>({\n\t\tkind: \"before\",\n\t\tcollapsibleKey: \"rule\",\n\t\thasAssociatedError: true,\n\t\tkeys: {\n\t\t\trule: {\n\t\t\t\tparse: parseDateLimit,\n\t\t\t\tserialize: schema => schema.toISOString()\n\t\t\t}\n\t\t},\n\t\tnormalize: createDateSchemaNormalizer(\"before\"),\n\t\tdefaults: {\n\t\t\tdescription: node => `${node.collapsibleLimitString} or earlier`,\n\t\t\tactual: describeCollapsibleDate\n\t\t},\n\t\tintersections: {\n\t\t\tbefore: (l, r) => (l.isStricterThan(r) ? l : r),\n\t\t\tafter: (before, after, ctx) =>\n\t\t\t\tbefore.overlapsRange(after) ?\n\t\t\t\t\tbefore.overlapIsUnit(after) ?\n\t\t\t\t\t\tctx.$.node(\"unit\", { unit: before.rule })\n\t\t\t\t\t:\tnull\n\t\t\t\t:\tDisjoint.init(\"range\", before, after)\n\t\t}\n\t})\n\nexport class BeforeNode extends BaseRange<Before.Declaration> {\n\tcollapsibleLimitString = describeCollapsibleDate(this.rule)\n\n\ttraverseAllows: TraverseAllows<Date> = data => data <= this.rule\n\n\timpliedBasis: BaseRoot = $ark.intrinsic.Date.internal\n\n\treduceJsonSchema(base: JsonSchema, ctx: ToJsonSchema.Context): JsonSchema {\n\t\treturn ctx.fallback.date({ code: \"date\", base, before: this.rule })\n\t}\n}\n\nexport const Before = {\n\timplementation,\n\tNode: BeforeNode\n}\n"
  },
  {
    "path": "ark/schema/refinements/divisor.ts",
    "content": "import { throwParseError } from \"@ark/util\"\nimport {\n\tInternalPrimitiveConstraint,\n\twriteInvalidOperandMessage\n} from \"../constraint.ts\"\nimport type { BaseRoot } from \"../roots/root.ts\"\nimport type {\n\tBaseErrorContext,\n\tBaseNormalizedSchema,\n\tdeclareNode\n} from \"../shared/declare.ts\"\nimport {\n\timplementNode,\n\ttype nodeImplementationOf\n} from \"../shared/implement.ts\"\nimport type { JsonSchema } from \"../shared/jsonSchema.ts\"\nimport { $ark } from \"../shared/registry.ts\"\nimport type { TraverseAllows } from \"../shared/traversal.ts\"\n\nexport declare namespace Divisor {\n\texport interface Inner {\n\t\treadonly rule: number\n\t}\n\n\texport interface NormalizedSchema extends BaseNormalizedSchema {\n\t\treadonly rule: number\n\t}\n\n\texport type Schema = NormalizedSchema | number\n\n\texport interface ErrorContext extends BaseErrorContext<\"divisor\">, Inner {}\n\n\texport interface Declaration\n\t\textends declareNode<{\n\t\t\tkind: \"divisor\"\n\t\t\tschema: Schema\n\t\t\tnormalizedSchema: NormalizedSchema\n\t\t\tinner: Inner\n\t\t\tprerequisite: number\n\t\t\terrorContext: ErrorContext\n\t\t}> {}\n\n\texport type Node = DivisorNode\n}\n\nconst implementation: nodeImplementationOf<Divisor.Declaration> =\n\timplementNode<Divisor.Declaration>({\n\t\tkind: \"divisor\",\n\t\tcollapsibleKey: \"rule\",\n\t\tkeys: {\n\t\t\trule: {\n\t\t\t\tparse: divisor =>\n\t\t\t\t\tNumber.isInteger(divisor) ? divisor : (\n\t\t\t\t\t\tthrowParseError(writeNonIntegerDivisorMessage(divisor))\n\t\t\t\t\t)\n\t\t\t}\n\t\t},\n\t\tnormalize: schema =>\n\t\t\ttypeof schema === \"number\" ? { rule: schema } : schema,\n\t\thasAssociatedError: true,\n\t\tdefaults: {\n\t\t\tdescription: node =>\n\t\t\t\tnode.rule === 1 ? \"an integer\"\n\t\t\t\t: node.rule === 2 ? \"even\"\n\t\t\t\t: `a multiple of ${node.rule}`\n\t\t},\n\t\tintersections: {\n\t\t\tdivisor: (l, r, ctx) =>\n\t\t\t\tctx.$.node(\"divisor\", {\n\t\t\t\t\trule: Math.abs(\n\t\t\t\t\t\t(l.rule * r.rule) / greatestCommonDivisor(l.rule, r.rule)\n\t\t\t\t\t)\n\t\t\t\t})\n\t\t},\n\t\tobviatesBasisDescription: true\n\t})\n\nexport class DivisorNode extends InternalPrimitiveConstraint<Divisor.Declaration> {\n\ttraverseAllows: TraverseAllows<number> = data => data % this.rule === 0\n\n\treadonly compiledCondition: string = `data % ${this.rule} === 0`\n\treadonly compiledNegation: string = `data % ${this.rule} !== 0`\n\treadonly impliedBasis: BaseRoot = $ark.intrinsic.number.internal\n\treadonly expression: string = `% ${this.rule}`\n\n\treduceJsonSchema(schema: JsonSchema.Numeric): JsonSchema.Numeric {\n\t\tschema.type = \"integer\"\n\n\t\tif (this.rule === 1) return schema\n\n\t\tschema.multipleOf = this.rule\n\n\t\treturn schema\n\t}\n}\n\nexport const Divisor = {\n\timplementation,\n\tNode: DivisorNode\n}\n\nexport const writeIndivisibleMessage = (t: BaseRoot): string =>\n\twriteInvalidOperandMessage(\"divisor\", $ark.intrinsic.number as never, t)\n\nexport type writeIndivisibleMessage<actual> = writeInvalidOperandMessage<\n\t\"divisor\",\n\tactual\n>\n\nexport const writeNonIntegerDivisorMessage = <divisor extends number>(\n\tdivisor: divisor\n): writeNonIntegerDivisorMessage<divisor> =>\n\t`divisor must be an integer (was ${divisor})`\n\nexport type writeNonIntegerDivisorMessage<divisor extends number> =\n\t`divisor must be an integer (was ${divisor})`\n\n// https://en.wikipedia.org/wiki/Euclidean_algorithm\nconst greatestCommonDivisor = (l: number, r: number) => {\n\tlet previous: number\n\tlet greatestCommonDivisor = l\n\tlet current = r\n\twhile (current !== 0) {\n\t\tprevious = current\n\t\tcurrent = greatestCommonDivisor % current\n\t\tgreatestCommonDivisor = previous\n\t}\n\treturn greatestCommonDivisor\n}\n"
  },
  {
    "path": "ark/schema/refinements/exactLength.ts",
    "content": "import { InternalPrimitiveConstraint } from \"../constraint.ts\"\nimport type { BaseRoot } from \"../roots/root.ts\"\nimport type {\n\tBaseErrorContext,\n\tBaseNormalizedSchema,\n\tdeclareNode\n} from \"../shared/declare.ts\"\nimport { Disjoint } from \"../shared/disjoint.ts\"\nimport {\n\timplementNode,\n\ttype nodeImplementationOf\n} from \"../shared/implement.ts\"\nimport type { JsonSchema } from \"../shared/jsonSchema.ts\"\nimport { $ark } from \"../shared/registry.ts\"\nimport { ToJsonSchema } from \"../shared/toJsonSchema.ts\"\nimport type { TraverseAllows } from \"../shared/traversal.ts\"\nimport { createLengthRuleParser, type LengthBoundableData } from \"./range.ts\"\n\nexport declare namespace ExactLength {\n\texport interface Inner {\n\t\treadonly rule: number\n\t}\n\n\texport interface NormalizedSchema extends BaseNormalizedSchema {\n\t\treadonly rule: number\n\t}\n\n\texport type Schema = NormalizedSchema | number\n\n\texport interface ErrorContext\n\t\textends BaseErrorContext<\"exactLength\">,\n\t\t\tInner {}\n\n\texport type Declaration = declareNode<{\n\t\tkind: \"exactLength\"\n\t\tschema: Schema\n\t\tnormalizedSchema: NormalizedSchema\n\t\tinner: Inner\n\t\tprerequisite: LengthBoundableData\n\t\terrorContext: ErrorContext\n\t}>\n\n\texport type Node = ExactLengthNode\n}\n\nconst implementation: nodeImplementationOf<ExactLength.Declaration> =\n\timplementNode<ExactLength.Declaration>({\n\t\tkind: \"exactLength\",\n\t\tcollapsibleKey: \"rule\",\n\t\tkeys: {\n\t\t\trule: {\n\t\t\t\tparse: createLengthRuleParser(\"exactLength\")\n\t\t\t}\n\t\t},\n\t\tnormalize: schema =>\n\t\t\ttypeof schema === \"number\" ? { rule: schema } : schema,\n\t\thasAssociatedError: true,\n\t\tdefaults: {\n\t\t\tdescription: node => `exactly length ${node.rule}`,\n\t\t\tactual: data => `${data.length}`\n\t\t},\n\t\tintersections: {\n\t\t\texactLength: (l, r, ctx) =>\n\t\t\t\tDisjoint.init(\n\t\t\t\t\t\"unit\",\n\t\t\t\t\tctx.$.node(\"unit\", { unit: l.rule }),\n\t\t\t\t\tctx.$.node(\"unit\", { unit: r.rule }),\n\t\t\t\t\t{ path: [\"length\"] }\n\t\t\t\t),\n\t\t\tminLength: (exactLength, minLength) =>\n\t\t\t\texactLength.rule >= minLength.rule ?\n\t\t\t\t\texactLength\n\t\t\t\t:\tDisjoint.init(\"range\", exactLength, minLength),\n\t\t\tmaxLength: (exactLength, maxLength) =>\n\t\t\t\texactLength.rule <= maxLength.rule ?\n\t\t\t\t\texactLength\n\t\t\t\t:\tDisjoint.init(\"range\", exactLength, maxLength)\n\t\t}\n\t})\n\nexport class ExactLengthNode extends InternalPrimitiveConstraint<ExactLength.Declaration> {\n\ttraverseAllows: TraverseAllows<LengthBoundableData> = data =>\n\t\tdata.length === this.rule\n\n\treadonly compiledCondition: string = `data.length === ${this.rule}`\n\treadonly compiledNegation: string = `data.length !== ${this.rule}`\n\treadonly impliedBasis: BaseRoot = $ark.intrinsic.lengthBoundable.internal\n\treadonly expression: string = `== ${this.rule}`\n\n\treduceJsonSchema(\n\t\tschema: JsonSchema.LengthBoundable\n\t): JsonSchema.LengthBoundable {\n\t\tswitch (schema.type) {\n\t\t\tcase \"string\":\n\t\t\t\tschema.minLength = this.rule\n\t\t\t\tschema.maxLength = this.rule\n\t\t\t\treturn schema\n\t\t\tcase \"array\":\n\t\t\t\tschema.minItems = this.rule\n\t\t\t\tschema.maxItems = this.rule\n\t\t\t\treturn schema\n\t\t\tdefault:\n\t\t\t\treturn ToJsonSchema.throwInternalOperandError(\"exactLength\", schema)\n\t\t}\n\t}\n}\n\nexport const ExactLength = {\n\timplementation,\n\tNode: ExactLengthNode\n}\n"
  },
  {
    "path": "ark/schema/refinements/kinds.ts",
    "content": "import type { BaseConstraint } from \"../constraint.ts\"\nimport type { nodeImplementationOf } from \"../shared/implement.ts\"\nimport { After } from \"./after.ts\"\nimport { Before } from \"./before.ts\"\nimport { ExactLength } from \"./exactLength.ts\"\nimport { Max } from \"./max.ts\"\nimport { MaxLength } from \"./maxLength.ts\"\nimport { Min } from \"./min.ts\"\nimport { MinLength } from \"./minLength.ts\"\n\nexport interface BoundDeclarations {\n\tmin: Min.Declaration\n\tmax: Max.Declaration\n\tminLength: MinLength.Declaration\n\tmaxLength: MaxLength.Declaration\n\texactLength: ExactLength.Declaration\n\tafter: After.Declaration\n\tbefore: Before.Declaration\n}\n\nexport interface BoundNodesByKind {\n\tmin: Min.Node\n\tmax: Max.Node\n\tminLength: MinLength.Node\n\tmaxLength: MaxLength.Node\n\texactLength: ExactLength.Node\n\tafter: After.Node\n\tbefore: Before.Node\n}\n\nexport type BoundKind = keyof BoundDeclarations\n\nexport type RangeKind = Exclude<BoundKind, \"exactLength\">\n\nexport type boundImplementationsByKind = {\n\t[k in BoundKind]: nodeImplementationOf<BoundDeclarations[k]>\n}\n\nexport const boundImplementationsByKind: boundImplementationsByKind = {\n\tmin: Min.implementation,\n\tmax: Max.implementation,\n\tminLength: MinLength.implementation,\n\tmaxLength: MaxLength.implementation,\n\texactLength: ExactLength.implementation,\n\tafter: After.implementation,\n\tbefore: Before.implementation\n}\n\nexport const boundClassesByKind: Record<BoundKind, typeof BaseConstraint<any>> =\n\t{\n\t\tmin: Min.Node,\n\t\tmax: Max.Node,\n\t\tminLength: MinLength.Node,\n\t\tmaxLength: MaxLength.Node,\n\t\texactLength: ExactLength.Node,\n\t\tafter: After.Node,\n\t\tbefore: Before.Node\n\t}\n"
  },
  {
    "path": "ark/schema/refinements/max.ts",
    "content": "import type { BaseRoot } from \"../roots/root.ts\"\nimport type { BaseErrorContext, declareNode } from \"../shared/declare.ts\"\nimport { Disjoint } from \"../shared/disjoint.ts\"\nimport {\n\timplementNode,\n\ttype nodeImplementationOf\n} from \"../shared/implement.ts\"\nimport type { JsonSchema } from \"../shared/jsonSchema.ts\"\nimport { $ark } from \"../shared/registry.ts\"\nimport type { TraverseAllows } from \"../shared/traversal.ts\"\nimport {\n\tBaseRange,\n\tparseExclusiveKey,\n\ttype BaseRangeInner,\n\ttype UnknownExpandedRangeSchema\n} from \"./range.ts\"\n\nexport declare namespace Max {\n\texport interface Inner extends BaseRangeInner {\n\t\trule: number\n\t\texclusive?: true\n\t}\n\n\texport interface NormalizedSchema extends UnknownExpandedRangeSchema {\n\t\trule: number\n\t}\n\n\texport type Schema = NormalizedSchema | number\n\n\texport interface ErrorContext extends BaseErrorContext<\"max\">, Inner {}\n\n\texport interface Declaration\n\t\textends declareNode<{\n\t\t\tkind: \"max\"\n\t\t\tschema: Schema\n\t\t\tnormalizedSchema: NormalizedSchema\n\t\t\tinner: Inner\n\t\t\tprerequisite: number\n\t\t\terrorContext: ErrorContext\n\t\t}> {}\n\n\texport type Node = MaxNode\n}\n\nconst implementation: nodeImplementationOf<Max.Declaration> =\n\timplementNode<Max.Declaration>({\n\t\tkind: \"max\",\n\t\tcollapsibleKey: \"rule\",\n\t\thasAssociatedError: true,\n\t\tkeys: {\n\t\t\trule: {},\n\t\t\texclusive: parseExclusiveKey\n\t\t},\n\t\tnormalize: schema =>\n\t\t\ttypeof schema === \"number\" ? { rule: schema } : schema,\n\t\tdefaults: {\n\t\t\tdescription: node => {\n\t\t\t\tif (node.rule === 0) return node.exclusive ? \"negative\" : \"non-positive\"\n\t\t\t\treturn `${node.exclusive ? \"less than\" : \"at most\"} ${node.rule}`\n\t\t\t}\n\t\t},\n\t\tintersections: {\n\t\t\tmax: (l, r) => (l.isStricterThan(r) ? l : r),\n\t\t\tmin: (max, min, ctx) =>\n\t\t\t\tmax.overlapsRange(min) ?\n\t\t\t\t\tmax.overlapIsUnit(min) ?\n\t\t\t\t\t\tctx.$.node(\"unit\", { unit: max.rule })\n\t\t\t\t\t:\tnull\n\t\t\t\t:\tDisjoint.init(\"range\", max, min)\n\t\t},\n\t\tobviatesBasisDescription: true\n\t})\n\nexport class MaxNode extends BaseRange<Max.Declaration> {\n\timpliedBasis: BaseRoot = $ark.intrinsic.number.internal\n\n\ttraverseAllows: TraverseAllows<number> =\n\t\tthis.exclusive ? data => data < this.rule : data => data <= this.rule\n\n\treduceJsonSchema(schema: JsonSchema.Numeric): JsonSchema.Numeric {\n\t\tif (this.exclusive) schema.exclusiveMaximum = this.rule\n\t\telse schema.maximum = this.rule\n\t\treturn schema\n\t}\n}\n\nexport const Max = {\n\timplementation,\n\tNode: MaxNode\n}\n"
  },
  {
    "path": "ark/schema/refinements/maxLength.ts",
    "content": "import type { BaseRoot } from \"../roots/root.ts\"\nimport type { BaseErrorContext, declareNode } from \"../shared/declare.ts\"\nimport { Disjoint } from \"../shared/disjoint.ts\"\nimport {\n\timplementNode,\n\ttype nodeImplementationOf\n} from \"../shared/implement.ts\"\nimport type { JsonSchema } from \"../shared/jsonSchema.ts\"\nimport { $ark } from \"../shared/registry.ts\"\nimport { ToJsonSchema } from \"../shared/toJsonSchema.ts\"\nimport type { TraverseAllows } from \"../shared/traversal.ts\"\nimport {\n\tBaseRange,\n\tcreateLengthRuleParser,\n\tcreateLengthSchemaNormalizer,\n\ttype BaseRangeInner,\n\ttype LengthBoundableData,\n\ttype UnknownExpandedRangeSchema,\n\ttype UnknownNormalizedRangeSchema\n} from \"./range.ts\"\n\nexport declare namespace MaxLength {\n\texport interface Inner extends BaseRangeInner {\n\t\trule: number\n\t}\n\n\texport interface NormalizedSchema extends UnknownNormalizedRangeSchema {\n\t\trule: number\n\t}\n\n\texport interface ExpandedSchema extends UnknownExpandedRangeSchema {\n\t\trule: number\n\t}\n\n\texport type Schema = ExpandedSchema | number\n\n\texport interface ErrorContext extends BaseErrorContext<\"maxLength\">, Inner {}\n\n\texport interface Declaration\n\t\textends declareNode<{\n\t\t\tkind: \"maxLength\"\n\t\t\tschema: Schema\n\t\t\treducibleTo: \"exactLength\"\n\t\t\tnormalizedSchema: NormalizedSchema\n\t\t\tinner: Inner\n\t\t\tprerequisite: LengthBoundableData\n\t\t\terrorContext: ErrorContext\n\t\t}> {}\n\n\texport type Node = MaxLengthNode\n}\n\nconst implementation: nodeImplementationOf<MaxLength.Declaration> =\n\timplementNode<MaxLength.Declaration>({\n\t\tkind: \"maxLength\",\n\t\tcollapsibleKey: \"rule\",\n\t\thasAssociatedError: true,\n\t\tkeys: {\n\t\t\trule: {\n\t\t\t\tparse: createLengthRuleParser(\"maxLength\")\n\t\t\t}\n\t\t},\n\t\treduce: (inner, $) =>\n\t\t\tinner.rule === 0 ? $.node(\"exactLength\", inner) : undefined,\n\t\tnormalize: createLengthSchemaNormalizer(\"maxLength\"),\n\t\tdefaults: {\n\t\t\tdescription: node => `at most length ${node.rule}`,\n\t\t\tactual: data => `${data.length}`\n\t\t},\n\t\tintersections: {\n\t\t\tmaxLength: (l, r) => (l.isStricterThan(r) ? l : r),\n\t\t\tminLength: (max, min, ctx) =>\n\t\t\t\tmax.overlapsRange(min) ?\n\t\t\t\t\tmax.overlapIsUnit(min) ?\n\t\t\t\t\t\tctx.$.node(\"exactLength\", { rule: max.rule })\n\t\t\t\t\t:\tnull\n\t\t\t\t:\tDisjoint.init(\"range\", max, min)\n\t\t}\n\t})\n\nexport class MaxLengthNode extends BaseRange<MaxLength.Declaration> {\n\treadonly impliedBasis: BaseRoot = $ark.intrinsic.lengthBoundable.internal\n\n\ttraverseAllows: TraverseAllows<LengthBoundableData> = data =>\n\t\tdata.length <= this.rule\n\n\treduceJsonSchema(\n\t\tschema: JsonSchema.LengthBoundable\n\t): JsonSchema.LengthBoundable {\n\t\tswitch (schema.type) {\n\t\t\tcase \"string\":\n\t\t\t\tschema.maxLength = this.rule\n\t\t\t\treturn schema\n\t\t\tcase \"array\":\n\t\t\t\tschema.maxItems = this.rule\n\t\t\t\treturn schema\n\t\t\tdefault:\n\t\t\t\treturn ToJsonSchema.throwInternalOperandError(\"maxLength\", schema)\n\t\t}\n\t}\n}\n\nexport const MaxLength = {\n\timplementation,\n\tNode: MaxLengthNode\n}\n"
  },
  {
    "path": "ark/schema/refinements/min.ts",
    "content": "import type { BaseRoot } from \"../roots/root.ts\"\nimport type { BaseErrorContext, declareNode } from \"../shared/declare.ts\"\nimport {\n\timplementNode,\n\ttype nodeImplementationOf\n} from \"../shared/implement.ts\"\nimport type { JsonSchema } from \"../shared/jsonSchema.ts\"\nimport { $ark } from \"../shared/registry.ts\"\nimport type { TraverseAllows } from \"../shared/traversal.ts\"\nimport {\n\tBaseRange,\n\tparseExclusiveKey,\n\ttype BaseRangeInner,\n\ttype UnknownExpandedRangeSchema\n} from \"./range.ts\"\n\nexport declare namespace Min {\n\texport interface Inner extends BaseRangeInner {\n\t\trule: number\n\t\texclusive?: true\n\t}\n\n\texport interface NormalizedSchema extends UnknownExpandedRangeSchema {\n\t\trule: number\n\t}\n\n\texport type Schema = NormalizedSchema | number\n\n\texport interface ErrorContext extends BaseErrorContext<\"min\">, Inner {}\n\n\texport interface Declaration\n\t\textends declareNode<{\n\t\t\tkind: \"min\"\n\t\t\tschema: Schema\n\t\t\tnormalizedSchema: NormalizedSchema\n\t\t\tinner: Inner\n\t\t\tprerequisite: number\n\t\t\terrorContext: ErrorContext\n\t\t}> {}\n\n\texport type Node = MinNode\n}\n\nconst implementation: nodeImplementationOf<Min.Declaration> =\n\timplementNode<Min.Declaration>({\n\t\tkind: \"min\",\n\t\tcollapsibleKey: \"rule\",\n\t\thasAssociatedError: true,\n\t\tkeys: {\n\t\t\trule: {},\n\t\t\texclusive: parseExclusiveKey\n\t\t},\n\t\tnormalize: schema =>\n\t\t\ttypeof schema === \"number\" ? { rule: schema } : schema,\n\t\tdefaults: {\n\t\t\tdescription: node => {\n\t\t\t\tif (node.rule === 0) return node.exclusive ? \"positive\" : \"non-negative\"\n\t\t\t\treturn `${node.exclusive ? \"more than\" : \"at least\"} ${node.rule}`\n\t\t\t}\n\t\t},\n\t\tintersections: {\n\t\t\tmin: (l, r) => (l.isStricterThan(r) ? l : r)\n\t\t},\n\t\tobviatesBasisDescription: true\n\t})\n\nexport class MinNode extends BaseRange<Min.Declaration> {\n\treadonly impliedBasis: BaseRoot = $ark.intrinsic.number.internal\n\n\ttraverseAllows: TraverseAllows<number> =\n\t\tthis.exclusive ? data => data > this.rule : data => data >= this.rule\n\n\treduceJsonSchema(schema: JsonSchema.Numeric): JsonSchema.Numeric {\n\t\tif (this.exclusive) schema.exclusiveMinimum = this.rule\n\t\telse schema.minimum = this.rule\n\t\treturn schema\n\t}\n}\n\nexport const Min = {\n\timplementation,\n\tNode: MinNode\n}\n"
  },
  {
    "path": "ark/schema/refinements/minLength.ts",
    "content": "import type { IntersectionNode } from \"../roots/intersection.ts\"\nimport type { BaseRoot } from \"../roots/root.ts\"\nimport type { BaseErrorContext, declareNode } from \"../shared/declare.ts\"\nimport {\n\timplementNode,\n\ttype nodeImplementationOf\n} from \"../shared/implement.ts\"\nimport type { JsonSchema } from \"../shared/jsonSchema.ts\"\nimport { $ark } from \"../shared/registry.ts\"\nimport { ToJsonSchema } from \"../shared/toJsonSchema.ts\"\nimport type { TraverseAllows } from \"../shared/traversal.ts\"\nimport {\n\tBaseRange,\n\tcreateLengthRuleParser,\n\tcreateLengthSchemaNormalizer,\n\ttype BaseRangeInner,\n\ttype LengthBoundableData,\n\ttype UnknownExpandedRangeSchema,\n\ttype UnknownNormalizedRangeSchema\n} from \"./range.ts\"\n\nexport declare namespace MinLength {\n\texport interface Inner extends BaseRangeInner {\n\t\trule: number\n\t}\n\n\texport interface NormalizedSchema extends UnknownNormalizedRangeSchema {\n\t\trule: number\n\t}\n\n\texport interface ExpandedSchema extends UnknownExpandedRangeSchema {\n\t\trule: number\n\t}\n\n\texport type Schema = ExpandedSchema | number\n\n\texport interface ErrorContext extends BaseErrorContext<\"minLength\">, Inner {}\n\n\texport interface Declaration\n\t\textends declareNode<{\n\t\t\tkind: \"minLength\"\n\t\t\tschema: Schema\n\t\t\tnormalizedSchema: NormalizedSchema\n\t\t\tinner: Inner\n\t\t\tprerequisite: LengthBoundableData\n\t\t\treducibleTo: \"intersection\"\n\t\t\terrorContext: ErrorContext\n\t\t}> {}\n\n\texport type Node = MinLengthNode\n}\n\nconst implementation: nodeImplementationOf<MinLength.Declaration> =\n\timplementNode<MinLength.Declaration>({\n\t\tkind: \"minLength\",\n\t\tcollapsibleKey: \"rule\",\n\t\thasAssociatedError: true,\n\t\tkeys: {\n\t\t\trule: {\n\t\t\t\tparse: createLengthRuleParser(\"minLength\")\n\t\t\t}\n\t\t},\n\t\treduce: inner =>\n\t\t\tinner.rule === 0 ?\n\t\t\t\t// a minimum length of zero is trivially satisfied\n\t\t\t\t($ark.intrinsic.unknown as IntersectionNode)\n\t\t\t:\tundefined,\n\t\tnormalize: createLengthSchemaNormalizer(\"minLength\"),\n\t\tdefaults: {\n\t\t\tdescription: node =>\n\t\t\t\tnode.rule === 1 ? \"non-empty\" : `at least length ${node.rule}`,\n\t\t\t// avoid default message like \"must be non-empty (was 0)\"\n\t\t\tactual: data => (data.length === 0 ? \"\" : `${data.length}`)\n\t\t},\n\t\tintersections: {\n\t\t\tminLength: (l, r) => (l.isStricterThan(r) ? l : r)\n\t\t}\n\t})\n\nexport class MinLengthNode extends BaseRange<MinLength.Declaration> {\n\treadonly impliedBasis: BaseRoot = $ark.intrinsic.lengthBoundable.internal\n\n\ttraverseAllows: TraverseAllows<LengthBoundableData> = data =>\n\t\tdata.length >= this.rule\n\n\treduceJsonSchema(\n\t\tschema: JsonSchema.LengthBoundable\n\t): JsonSchema.LengthBoundable {\n\t\tswitch (schema.type) {\n\t\t\tcase \"string\":\n\t\t\t\tschema.minLength = this.rule\n\t\t\t\treturn schema\n\t\t\tcase \"array\":\n\t\t\t\tschema.minItems = this.rule\n\t\t\t\treturn schema\n\t\t\tdefault:\n\t\t\t\treturn ToJsonSchema.throwInternalOperandError(\"minLength\", schema)\n\t\t}\n\t}\n}\n\nexport const MinLength = {\n\timplementation,\n\tNode: MinLengthNode\n}\n"
  },
  {
    "path": "ark/schema/refinements/pattern.ts",
    "content": "import { InternalPrimitiveConstraint } from \"../constraint.ts\"\nimport type { BaseRoot } from \"../roots/root.ts\"\nimport type {\n\tBaseErrorContext,\n\tBaseNormalizedSchema,\n\tdeclareNode\n} from \"../shared/declare.ts\"\nimport {\n\timplementNode,\n\ttype nodeImplementationOf\n} from \"../shared/implement.ts\"\nimport type { JsonSchema } from \"../shared/jsonSchema.ts\"\nimport { $ark } from \"../shared/registry.ts\"\nimport type { ToJsonSchema } from \"../shared/toJsonSchema.ts\"\n\nexport declare namespace Pattern {\n\texport interface NormalizedSchema extends BaseNormalizedSchema {\n\t\treadonly rule: string\n\t\treadonly flags?: string\n\t}\n\n\texport interface Inner {\n\t\treadonly rule: string\n\t\treadonly flags?: string\n\t}\n\n\texport type Schema = NormalizedSchema | string | RegExp\n\n\texport interface ErrorContext extends BaseErrorContext<\"pattern\">, Inner {}\n\n\texport interface Declaration\n\t\textends declareNode<{\n\t\t\tkind: \"pattern\"\n\t\t\tschema: Schema\n\t\t\tnormalizedSchema: NormalizedSchema\n\t\t\tinner: Inner\n\t\t\tintersectionIsOpen: true\n\t\t\tprerequisite: string\n\t\t\terrorContext: ErrorContext\n\t\t}> {}\n\n\texport type Node = PatternNode\n}\n\nconst implementation: nodeImplementationOf<Pattern.Declaration> =\n\timplementNode<Pattern.Declaration>({\n\t\tkind: \"pattern\",\n\t\tcollapsibleKey: \"rule\",\n\t\tkeys: {\n\t\t\trule: {},\n\t\t\tflags: {}\n\t\t},\n\t\tnormalize: schema =>\n\t\t\ttypeof schema === \"string\" ? { rule: schema }\n\t\t\t: schema instanceof RegExp ?\n\t\t\t\tschema.flags ?\n\t\t\t\t\t{ rule: schema.source, flags: schema.flags }\n\t\t\t\t:\t{ rule: schema.source }\n\t\t\t:\tschema,\n\t\tobviatesBasisDescription: true,\n\t\tobviatesBasisExpression: true,\n\t\thasAssociatedError: true,\n\t\tintersectionIsOpen: true,\n\t\tdefaults: {\n\t\t\tdescription: node => `matched by ${node.rule}`\n\t\t},\n\t\tintersections: {\n\t\t\t// for now, non-equal regex are naively intersected:\n\t\t\t// https://github.com/arktypeio/arktype/issues/853\n\t\t\tpattern: () => null\n\t\t}\n\t})\n\nexport class PatternNode extends InternalPrimitiveConstraint<Pattern.Declaration> {\n\treadonly instance: RegExp = new RegExp(this.rule, this.flags)\n\treadonly expression: string = `${this.instance}`\n\ttraverseAllows: (string: string) => boolean = this.instance.test.bind(\n\t\tthis.instance\n\t)\n\n\treadonly compiledCondition: string = `${this.expression}.test(data)`\n\treadonly compiledNegation: string = `!${this.compiledCondition}`\n\treadonly impliedBasis: BaseRoot = $ark.intrinsic.string.internal\n\n\treduceJsonSchema(\n\t\tbase: JsonSchema.String,\n\t\tctx: ToJsonSchema.Context\n\t): JsonSchema.String {\n\t\tif (base.pattern) {\n\t\t\treturn ctx.fallback.patternIntersection({\n\t\t\t\tcode: \"patternIntersection\",\n\t\t\t\tbase: base as ToJsonSchema.StringSchemaWithPattern,\n\t\t\t\tpattern: this.rule\n\t\t\t})\n\t\t}\n\t\tbase.pattern = this.rule\n\t\treturn base\n\t}\n}\n\nexport const Pattern = {\n\timplementation,\n\tNode: PatternNode\n}\n"
  },
  {
    "path": "ark/schema/refinements/range.ts",
    "content": "import {\n\ttype array,\n\tisKeyOf,\n\ttype propValueOf,\n\ttype satisfy,\n\tthrowParseError\n} from \"@ark/util\"\nimport { InternalPrimitiveConstraint } from \"../constraint.ts\"\nimport type {\n\tDeclaration,\n\tnodeOfKind,\n\tNodeSchema,\n\tNormalizedSchema\n} from \"../kinds.ts\"\nimport type {\n\tBaseNodeDeclaration,\n\tBaseNormalizedSchema\n} from \"../shared/declare.ts\"\nimport type { keySchemaDefinitions } from \"../shared/implement.ts\"\nimport type { After } from \"./after.ts\"\nimport type { Before } from \"./before.ts\"\nimport type { RangeKind } from \"./kinds.ts\"\nimport type { MaxLength } from \"./maxLength.ts\"\nimport type { MinLength } from \"./minLength.ts\"\n\nexport interface BaseRangeDeclaration extends BaseNodeDeclaration {\n\tkind: RangeKind\n\tinner: BaseRangeInner\n\tnormalizedSchema: UnknownExpandedRangeSchema\n}\n\nexport abstract class BaseRange<\n\td extends BaseRangeDeclaration\n> extends InternalPrimitiveConstraint<d> {\n\tdeclare readonly exclusive?: true\n\n\treadonly boundOperandKind: OperandKindsByBoundKind[d[\"kind\"]] =\n\t\toperandKindsByBoundKind[this.kind]\n\treadonly compiledActual: string =\n\t\tthis.boundOperandKind === \"value\" ? `data`\n\t\t: this.boundOperandKind === \"length\" ? `data.length`\n\t\t: `data.valueOf()`\n\treadonly comparator: RelativeComparator = compileComparator(\n\t\tthis.kind,\n\t\tthis.exclusive\n\t)\n\treadonly numericLimit: number = this.rule.valueOf()\n\treadonly expression: string = `${this.comparator} ${this.rule}`\n\treadonly compiledCondition: string = `${this.compiledActual} ${this.comparator} ${this.numericLimit}`\n\treadonly compiledNegation: string = `${this.compiledActual} ${\n\t\tnegatedComparators[this.comparator]\n\t} ${this.numericLimit}`\n\n\t// we need to compute stringLimit before errorContext, which references it\n\t// transitively through description for date bounds\n\treadonly stringLimit: string =\n\t\tthis.boundOperandKind === \"date\" ?\n\t\t\tdateLimitToString(this.numericLimit)\n\t\t:\t`${this.numericLimit}`\n\treadonly limitKind: LimitKind =\n\t\tthis.comparator[\"0\"] === \"<\" ? \"upper\" : \"lower\"\n\n\tisStricterThan(\n\t\tr: nodeOfKind<d[\"kind\"] | pairedRangeKind<d[\"kind\"]>>\n\t): boolean {\n\t\tconst thisLimitIsStricter =\n\t\t\tthis.limitKind === \"upper\" ?\n\t\t\t\tthis.numericLimit < r.numericLimit\n\t\t\t:\tthis.numericLimit > r.numericLimit\n\t\treturn (\n\t\t\tthisLimitIsStricter ||\n\t\t\t(this.numericLimit === r.numericLimit &&\n\t\t\t\tthis.exclusive === true &&\n\t\t\t\t!r.exclusive)\n\t\t)\n\t}\n\n\toverlapsRange(r: nodeOfKind<pairedRangeKind<d[\"kind\"]>>): boolean {\n\t\tif (this.isStricterThan(r)) return false\n\t\tif (this.numericLimit === r.numericLimit && (this.exclusive || r.exclusive))\n\t\t\treturn false\n\t\treturn true\n\t}\n\n\toverlapIsUnit(r: nodeOfKind<pairedRangeKind<d[\"kind\"]>>): boolean {\n\t\treturn (\n\t\t\tthis.numericLimit === r.numericLimit && !this.exclusive && !r.exclusive\n\t\t)\n\t}\n}\n\nexport interface BaseRangeInner {\n\treadonly rule: LimitValue\n}\n\nexport type LimitValue = Date | number\n\nexport type LimitSchemaValue = Date | number | string\n\nexport type LimitInnerValue<kind extends RangeKind = RangeKind> =\n\tkind extends \"before\" | \"after\" ? Date : number\n\nexport interface UnknownExpandedRangeSchema extends BaseNormalizedSchema {\n\treadonly rule: LimitSchemaValue\n\treadonly exclusive?: boolean\n}\n\nexport interface UnknownNormalizedRangeSchema extends BaseNormalizedSchema {\n\treadonly rule: LimitSchemaValue\n}\n\nexport type UnknownRangeSchema = LimitSchemaValue | UnknownExpandedRangeSchema\n\nexport interface ExclusiveExpandedDateRangeSchema extends BaseNormalizedSchema {\n\trule: LimitSchemaValue\n\texclusive?: true\n}\n\nexport type ExclusiveDateRangeSchema =\n\t| LimitSchemaValue\n\t| ExclusiveExpandedDateRangeSchema\n\nexport interface InclusiveExpandedDateRangeSchema extends BaseNormalizedSchema {\n\trule: LimitSchemaValue\n\texclusive?: false\n}\n\nexport type InclusiveDateRangeSchema =\n\t| LimitSchemaValue\n\t| InclusiveExpandedDateRangeSchema\n\nexport interface ExclusiveNormalizedNumericRangeSchema\n\textends BaseNormalizedSchema {\n\trule: number\n\texclusive?: true\n}\n\nexport type ExclusiveNumericRangeSchema =\n\t| number\n\t| ExclusiveNormalizedNumericRangeSchema\n\nexport interface InclusiveNormalizedNumericRangeSchema\n\textends BaseNormalizedSchema {\n\trule: number\n\texclusive?: false\n}\n\nexport type InclusiveNumericRangeSchema =\n\t| number\n\t| InclusiveNormalizedNumericRangeSchema\n\nexport type LimitKind = \"lower\" | \"upper\"\n\nexport type RelativeComparator<kind extends LimitKind = LimitKind> = {\n\tlower: \">\" | \">=\"\n\tupper: \"<\" | \"<=\"\n}[kind]\n\nconst negatedComparators = {\n\t\"<\": \">=\",\n\t\"<=\": \">\",\n\t\">\": \"<=\",\n\t\">=\": \"<\"\n} as const satisfies Record<RelativeComparator, RelativeComparator>\n\nexport const boundKindPairsByLower: BoundKindPairsByLower = {\n\tmin: \"max\",\n\tminLength: \"maxLength\",\n\tafter: \"before\"\n}\n\ntype BoundKindPairsByLower = {\n\tmin: \"max\"\n\tminLength: \"maxLength\"\n\tafter: \"before\"\n}\n\ntype BoundKindPairsByUpper = {\n\tmax: \"min\"\n\tmaxLength: \"minLength\"\n\tbefore: \"after\"\n}\n\nexport type pairedRangeKind<kind extends RangeKind> =\n\tkind extends LowerBoundKind ? BoundKindPairsByLower[kind]\n\t:\tBoundKindPairsByUpper[kind & UpperBoundKind]\n\nexport type LowerBoundKind = keyof typeof boundKindPairsByLower\n\nexport type LowerNode = nodeOfKind<LowerBoundKind>\n\nexport type UpperBoundKind = propValueOf<typeof boundKindPairsByLower>\n\nexport type UpperNode = nodeOfKind<UpperBoundKind>\n\nexport type NumericallyBoundable = string | number | array\n\nexport type Boundable = NumericallyBoundable | Date\n\nexport const parseExclusiveKey: keySchemaDefinitions<\n\tDeclaration<\"min\" | \"max\">\n>[\"exclusive\"] = {\n\t// omit key with value false since it is the default\n\tparse: (flag: boolean) => flag || undefined\n}\n\nexport const createLengthSchemaNormalizer =\n\t<kind extends \"minLength\" | \"maxLength\">(kind: kind) =>\n\t(schema: NodeSchema<kind>): NormalizedSchema<kind> => {\n\t\tif (typeof schema === \"number\") return { rule: schema }\n\t\tconst { exclusive, ...normalized } = schema as\n\t\t\t| MinLength.ExpandedSchema\n\t\t\t| MaxLength.ExpandedSchema\n\t\treturn exclusive ?\n\t\t\t\t{\n\t\t\t\t\t...normalized,\n\t\t\t\t\trule: kind === \"minLength\" ? normalized.rule + 1 : normalized.rule - 1\n\t\t\t\t}\n\t\t\t:\tnormalized\n\t}\n\nexport const createDateSchemaNormalizer =\n\t<kind extends DateRangeKind>(kind: kind) =>\n\t(schema: NodeSchema<kind>): NormalizedSchema<kind> => {\n\t\tif (\n\t\t\ttypeof schema === \"number\" ||\n\t\t\ttypeof schema === \"string\" ||\n\t\t\tschema instanceof Date\n\t\t)\n\t\t\treturn { rule: schema }\n\n\t\tconst { exclusive, ...normalized } = schema as\n\t\t\t| After.ExpandedSchema\n\t\t\t| Before.ExpandedSchema\n\t\tif (!exclusive) return normalized\n\t\tconst numericLimit =\n\t\t\ttypeof normalized.rule === \"number\" ? normalized.rule\n\t\t\t: typeof normalized.rule === \"string\" ?\n\t\t\t\tnew Date(normalized.rule).valueOf()\n\t\t\t:\tnormalized.rule.valueOf()\n\n\t\treturn exclusive ?\n\t\t\t\t{\n\t\t\t\t\t...normalized,\n\t\t\t\t\trule: kind === \"after\" ? numericLimit + 1 : numericLimit - 1\n\t\t\t\t}\n\t\t\t:\tnormalized\n\t}\n\nexport const parseDateLimit = (limit: LimitSchemaValue): Date =>\n\ttypeof limit === \"string\" || typeof limit === \"number\" ?\n\t\tnew Date(limit)\n\t:\tlimit\n\nexport type LengthBoundKind = \"minLength\" | \"maxLength\" | \"exactLength\"\n\nexport const writeInvalidLengthBoundMessage = (\n\tkind: LengthBoundKind,\n\tlimit: number\n): string => `${kind} bound must be a positive integer (was ${limit})`\n\nexport const createLengthRuleParser =\n\t(kind: LengthBoundKind) =>\n\t(limit: number): number | undefined => {\n\t\tif (!Number.isInteger(limit) || limit < 0)\n\t\t\tthrowParseError(writeInvalidLengthBoundMessage(kind, limit))\n\t\treturn limit\n\t}\n\ntype OperandKindsByBoundKind = satisfy<\n\tRecord<RangeKind, BoundOperandKind>,\n\t{\n\t\tmin: \"value\"\n\t\tmax: \"value\"\n\t\tminLength: \"length\"\n\t\tmaxLength: \"length\"\n\t\tafter: \"date\"\n\t\tbefore: \"date\"\n\t}\n>\n\nconst operandKindsByBoundKind: OperandKindsByBoundKind = {\n\tmin: \"value\",\n\tmax: \"value\",\n\tminLength: \"length\",\n\tmaxLength: \"length\",\n\tafter: \"date\",\n\tbefore: \"date\"\n} as const\n\nexport const compileComparator = (\n\tkind: RangeKind,\n\texclusive: boolean | undefined\n): RelativeComparator =>\n\t`${isKeyOf(kind, boundKindPairsByLower) ? \">\" : \"<\"}${\n\t\texclusive ? \"\" : \"=\"\n\t}` as const\n\nexport type BoundOperandKind = \"value\" | \"length\" | \"date\"\n\nexport type LengthBoundableData = string | array\n\nexport type DateRangeKind = \"before\" | \"after\"\n\nexport const dateLimitToString = (limit: LimitSchemaValue): string =>\n\ttypeof limit === \"string\" ? limit : new Date(limit).toLocaleString()\n\nexport const writeUnboundableMessage = <root extends string>(\n\troot: root\n): writeUnboundableMessage<root> =>\n\t`Bounded expression ${root} must be exactly one of number, string, Array, or Date`\n\nexport type writeUnboundableMessage<root extends string> =\n\t`Bounded expression ${root} must be exactly one of number, string, Array, or Date`\n"
  },
  {
    "path": "ark/schema/roots/alias.ts",
    "content": "import {\n\tappend,\n\tdomainDescriptions,\n\tprintable,\n\tthrowInternalError,\n\tthrowParseError\n} from \"@ark/util\"\nimport { nodesByRegisteredId, type NodeId } from \"../parse.ts\"\nimport type { NodeCompiler } from \"../shared/compile.ts\"\nimport type { BaseNormalizedSchema, declareNode } from \"../shared/declare.ts\"\nimport { Disjoint } from \"../shared/disjoint.ts\"\nimport {\n\timplementNode,\n\ttype nodeImplementationOf\n} from \"../shared/implement.ts\"\nimport { intersectOrPipeNodes } from \"../shared/intersections.ts\"\nimport type { JsonSchema } from \"../shared/jsonSchema.ts\"\nimport { $ark } from \"../shared/registry.ts\"\nimport type { ToJsonSchema } from \"../shared/toJsonSchema.ts\"\nimport type { TraverseAllows, TraverseApply } from \"../shared/traversal.ts\"\nimport { hasArkKind } from \"../shared/utils.ts\"\nimport { BaseRoot } from \"./root.ts\"\nimport { defineRightwardIntersections } from \"./utils.ts\"\n\nexport declare namespace Alias {\n\texport type Schema<alias extends string = string> =\n\t\t| `$${alias}`\n\t\t| NormalizedSchema<alias>\n\n\texport interface NormalizedSchema<alias extends string = string>\n\t\textends BaseNormalizedSchema {\n\t\treadonly reference: alias\n\t\treadonly resolve?: () => BaseRoot\n\t}\n\n\texport interface Inner<alias extends string = string> {\n\t\treadonly reference: alias\n\t\treadonly resolve?: () => BaseRoot\n\t}\n\n\texport interface Declaration\n\t\textends declareNode<{\n\t\t\tkind: \"alias\"\n\t\t\tschema: Schema\n\t\t\tnormalizedSchema: NormalizedSchema\n\t\t\tinner: Inner\n\t\t}> {}\n\n\texport type Node = AliasNode\n}\n\nexport const normalizeAliasSchema = (schema: Alias.Schema): Alias.Inner =>\n\ttypeof schema === \"string\" ? { reference: schema } : schema\n\nconst neverIfDisjoint = (result: BaseRoot | Disjoint): BaseRoot =>\n\tresult instanceof Disjoint ? $ark.intrinsic.never.internal : result\n\nconst implementation: nodeImplementationOf<Alias.Declaration> =\n\timplementNode<Alias.Declaration>({\n\t\tkind: \"alias\",\n\t\thasAssociatedError: false,\n\t\tcollapsibleKey: \"reference\",\n\t\tkeys: {\n\t\t\treference: {\n\t\t\t\tserialize: s => (s.startsWith(\"$\") ? s : `$ark.${s}`)\n\t\t\t},\n\t\t\tresolve: {}\n\t\t},\n\t\tnormalize: normalizeAliasSchema,\n\t\tdefaults: {\n\t\t\tdescription: node => node.reference\n\t\t},\n\t\tintersections: {\n\t\t\talias: (l, r, ctx) =>\n\t\t\t\tctx.$.lazilyResolve(\n\t\t\t\t\t() =>\n\t\t\t\t\t\tneverIfDisjoint(\n\t\t\t\t\t\t\tintersectOrPipeNodes(l.resolution, r.resolution, ctx)\n\t\t\t\t\t\t),\n\t\t\t\t\t`${l.reference}${ctx.pipe ? \"=>\" : \"&\"}${r.reference}`\n\t\t\t\t),\n\t\t\t...defineRightwardIntersections(\"alias\", (l, r, ctx) => {\n\t\t\t\tif (r.isUnknown()) return l\n\t\t\t\tif (r.isNever()) return r\n\t\t\t\tif (r.isBasis() && !r.overlaps($ark.intrinsic.object)) {\n\t\t\t\t\t// can be more robust as part of https://github.com/arktypeio/arktype/issues/1026\n\t\t\t\t\treturn Disjoint.init(\n\t\t\t\t\t\t\"assignability\",\n\t\t\t\t\t\t$ark.intrinsic.object as never,\n\t\t\t\t\t\tr\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\treturn ctx.$.lazilyResolve(\n\t\t\t\t\t() => neverIfDisjoint(intersectOrPipeNodes(l.resolution, r, ctx)),\n\t\t\t\t\t`${l.reference}${ctx.pipe ? \"=>\" : \"&\"}${r.id}`\n\t\t\t\t)\n\t\t\t})\n\t\t}\n\t})\n\nexport class AliasNode extends BaseRoot<Alias.Declaration> {\n\treadonly expression: string = this.reference\n\treadonly structure = undefined\n\n\tget resolution(): BaseRoot {\n\t\tconst result = this._resolve()\n\t\treturn (nodesByRegisteredId[this.id] = result)\n\t}\n\n\tprotected _resolve(): BaseRoot {\n\t\tif (this.resolve) return this.resolve()\n\t\tif (this.reference[0] === \"$\")\n\t\t\treturn this.$.resolveRoot(this.reference.slice(1))\n\n\t\tconst id = this.reference as NodeId\n\n\t\tlet resolution = nodesByRegisteredId[id]\n\t\tconst seen: NodeId[] = []\n\t\twhile (hasArkKind(resolution, \"context\")) {\n\t\t\tif (seen.includes(resolution.id)) {\n\t\t\t\treturn throwParseError(\n\t\t\t\t\twriteShallowCycleErrorMessage(resolution.id, seen)\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tseen.push(resolution.id)\n\t\t\tresolution = nodesByRegisteredId[resolution.id]\n\t\t}\n\t\tif (!hasArkKind(resolution, \"root\")) {\n\t\t\treturn throwInternalError(`Unexpected resolution for reference ${this.reference}\nSeen: [${seen.join(\"->\")}] \nResolution: ${printable(resolution)}`)\n\t\t}\n\t\treturn resolution\n\t}\n\n\tget resolutionId(): NodeId {\n\t\tif (this.reference.includes(\"&\") || this.reference.includes(\"=>\"))\n\t\t\treturn this.resolution.id\n\t\tif (this.reference[0] !== \"$\") return this.reference as NodeId\n\t\tconst alias = this.reference.slice(1)\n\t\tconst resolution = this.$.resolutions[alias]\n\t\tif (typeof resolution === \"string\") return resolution\n\t\tif (hasArkKind(resolution, \"root\")) return resolution.id\n\n\t\treturn throwInternalError(\n\t\t\t`Unexpected resolution for reference ${this.reference}: ${printable(resolution)}`\n\t\t)\n\t}\n\n\tget defaultShortDescription(): string {\n\t\treturn domainDescriptions.object\n\t}\n\n\tprotected innerToJsonSchema(ctx: ToJsonSchema.Context): JsonSchema {\n\t\treturn this.resolution.toJsonSchemaRecurse(ctx)\n\t}\n\n\ttraverseAllows: TraverseAllows = (data, ctx) => {\n\t\tconst seen = ctx.seen[this.reference]\n\t\tif (seen?.includes(data)) return true\n\t\tctx.seen[this.reference] = append(seen, data)\n\t\treturn this.resolution.traverseAllows(data, ctx)\n\t}\n\n\ttraverseApply: TraverseApply = (data, ctx) => {\n\t\tconst seen = ctx.seen[this.reference]\n\t\tif (seen?.includes(data)) return\n\t\tctx.seen[this.reference] = append(seen, data)\n\t\tthis.resolution.traverseApply(data, ctx)\n\t}\n\n\tcompile(js: NodeCompiler): void {\n\t\tconst id = this.resolutionId\n\t\tjs.if(`ctx.seen.${id} && ctx.seen.${id}.includes(data)`, () =>\n\t\t\tjs.return(true)\n\t\t)\n\t\tjs.if(`!ctx.seen.${id}`, () => js.line(`ctx.seen.${id} = []`))\n\t\tjs.line(`ctx.seen.${id}.push(data)`)\n\t\tjs.return(js.invoke(id))\n\t}\n}\n\nexport const writeShallowCycleErrorMessage = (\n\tname: string,\n\tseen: string[]\n): string =>\n\t`Alias '${name}' has a shallow resolution cycle: ${[...seen, name].join(\"->\")}`\n\nexport const Alias = {\n\timplementation,\n\tNode: AliasNode\n}\n"
  },
  {
    "path": "ark/schema/roots/basis.ts",
    "content": "import type { NodeCompiler } from \"../shared/compile.ts\"\nimport { compileObjectLiteral } from \"../shared/implement.ts\"\nimport type { TraverseApply } from \"../shared/traversal.ts\"\nimport { BaseRoot, type InternalRootDeclaration } from \"./root.ts\"\n\nexport abstract class InternalBasis<\n\td extends InternalRootDeclaration = InternalRootDeclaration\n> extends BaseRoot<d> {\n\tabstract compiledCondition: string\n\tabstract compiledNegation: string\n\tdeclare structure: undefined\n\n\ttraverseApply: TraverseApply<d[\"prerequisite\"]> = (data, ctx) => {\n\t\tif (!this.traverseAllows(data, ctx))\n\t\t\tctx.errorFromNodeContext(this.errorContext as never)\n\t}\n\n\tget errorContext(): d[\"errorContext\"] {\n\t\treturn {\n\t\t\tcode: this.kind,\n\t\t\tdescription: this.description,\n\t\t\tmeta: this.meta,\n\t\t\t...this.inner\n\t\t}\n\t}\n\n\tget compiledErrorContext(): string {\n\t\treturn compileObjectLiteral(this.errorContext!)\n\t}\n\n\tcompile(js: NodeCompiler): void {\n\t\tif (js.traversalKind === \"Allows\") js.return(this.compiledCondition)\n\t\telse {\n\t\t\tjs.if(this.compiledNegation, () =>\n\t\t\t\tjs.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`)\n\t\t\t)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "ark/schema/roots/domain.ts",
    "content": "import {\n\tdomainDescriptions,\n\tdomainOf,\n\thasKey,\n\tthrowParseError,\n\ttype Domain as _Domain\n} from \"@ark/util\"\nimport type {\n\tBaseErrorContext,\n\tBaseNormalizedSchema,\n\tdeclareNode\n} from \"../shared/declare.ts\"\nimport { Disjoint } from \"../shared/disjoint.ts\"\nimport {\n\timplementNode,\n\ttype nodeImplementationOf\n} from \"../shared/implement.ts\"\nimport type { JsonSchema } from \"../shared/jsonSchema.ts\"\nimport type { ToJsonSchema } from \"../shared/toJsonSchema.ts\"\nimport type { TraverseAllows } from \"../shared/traversal.ts\"\nimport { InternalBasis } from \"./basis.ts\"\n\nexport type Domain = _Domain\n\nexport declare namespace Domain {\n\texport type Enumerable = \"undefined\" | \"null\" | \"boolean\"\n\n\texport type NonEnumerable = Exclude<Domain, Enumerable>\n\n\texport interface Inner<domain extends NonEnumerable = NonEnumerable> {\n\t\treadonly domain: domain\n\t\treadonly numberAllowsNaN?: boolean\n\t}\n\n\texport interface NormalizedSchema<\n\t\tdomain extends NonEnumerable = NonEnumerable\n\t> extends BaseNormalizedSchema,\n\t\t\tInner<domain> {}\n\n\texport type Schema<\n\t\t// only domains with an infinite number of values are allowed as bases\n\t\tdomain extends NonEnumerable = NonEnumerable\n\t> = domain | NormalizedSchema<domain>\n\n\texport interface ErrorContext extends BaseErrorContext<\"domain\">, Inner {}\n\n\texport interface Declaration\n\t\textends declareNode<{\n\t\t\tkind: \"domain\"\n\t\t\tschema: Schema\n\t\t\tnormalizedSchema: NormalizedSchema\n\t\t\tinner: Inner\n\t\t\terrorContext: ErrorContext\n\t\t}> {}\n\n\texport type Node = DomainNode\n}\n\nconst implementation: nodeImplementationOf<Domain.Declaration> =\n\timplementNode<Domain.Declaration>({\n\t\tkind: \"domain\",\n\t\thasAssociatedError: true,\n\t\tcollapsibleKey: \"domain\",\n\t\tkeys: {\n\t\t\tdomain: {},\n\t\t\tnumberAllowsNaN: {}\n\t\t},\n\t\tnormalize: schema =>\n\t\t\ttypeof schema === \"string\" ? { domain: schema }\n\t\t\t: hasKey(schema, \"numberAllowsNaN\") && schema.domain !== \"number\" ?\n\t\t\t\tthrowParseError(Domain.writeBadAllowNanMessage(schema.domain))\n\t\t\t:\tschema,\n\t\tapplyConfig: (schema, config) =>\n\t\t\t(\n\t\t\t\tschema.numberAllowsNaN === undefined &&\n\t\t\t\tschema.domain === \"number\" &&\n\t\t\t\tconfig.numberAllowsNaN\n\t\t\t) ?\n\t\t\t\t{ ...schema, numberAllowsNaN: true }\n\t\t\t:\tschema,\n\t\tdefaults: {\n\t\t\tdescription: node => domainDescriptions[node.domain],\n\t\t\tactual: data =>\n\t\t\t\tNumber.isNaN(data) ? \"NaN\" : domainDescriptions[domainOf(data)]\n\t\t},\n\t\tintersections: {\n\t\t\tdomain: (l, r) =>\n\t\t\t\t// since l === r is handled by default, remaining cases are disjoint\n\t\t\t\t// outside those including options like numberAllowsNaN\n\t\t\t\tl.domain === \"number\" && r.domain === \"number\" ?\n\t\t\t\t\tl.numberAllowsNaN ?\n\t\t\t\t\t\tr\n\t\t\t\t\t:\tl\n\t\t\t\t:\tDisjoint.init(\"domain\", l, r)\n\t\t}\n\t})\n\nexport class DomainNode extends InternalBasis<Domain.Declaration> {\n\tprivate readonly requiresNaNCheck =\n\t\tthis.domain === \"number\" && !this.numberAllowsNaN\n\n\treadonly traverseAllows: TraverseAllows =\n\t\tthis.requiresNaNCheck ?\n\t\t\tdata => typeof data === \"number\" && !Number.isNaN(data)\n\t\t:\tdata => domainOf(data) === this.domain\n\n\treadonly compiledCondition: string =\n\t\tthis.domain === \"object\" ?\n\t\t\t`((typeof data === \"object\" && data !== null) || typeof data === \"function\")`\n\t\t:\t`typeof data === \"${this.domain}\"${this.requiresNaNCheck ? \" && !Number.isNaN(data)\" : \"\"}`\n\n\treadonly compiledNegation: string =\n\t\tthis.domain === \"object\" ?\n\t\t\t`((typeof data !== \"object\" || data === null) && typeof data !== \"function\")`\n\t\t:\t`typeof data !== \"${this.domain}\"${this.requiresNaNCheck ? \" || Number.isNaN(data)\" : \"\"}`\n\n\treadonly expression: string =\n\t\tthis.numberAllowsNaN ? \"number | NaN\" : this.domain\n\n\tget nestableExpression(): string {\n\t\treturn this.numberAllowsNaN ? `(${this.expression})` : this.expression\n\t}\n\n\tget defaultShortDescription(): string {\n\t\treturn domainDescriptions[this.domain]\n\t}\n\n\tprotected innerToJsonSchema(\n\t\tctx: ToJsonSchema.Context\n\t): JsonSchema.Constrainable {\n\t\tif (this.domain === \"bigint\" || this.domain === \"symbol\") {\n\t\t\treturn ctx.fallback.domain({\n\t\t\t\tcode: \"domain\",\n\t\t\t\tbase: {},\n\t\t\t\tdomain: this.domain\n\t\t\t})\n\t\t}\n\t\treturn {\n\t\t\ttype: this.domain\n\t\t}\n\t}\n}\n\nexport const Domain = {\n\timplementation,\n\tNode: DomainNode,\n\twriteBadAllowNanMessage: (\n\t\tactual: Exclude<Domain.NonEnumerable, \"number\">\n\t): string =>\n\t\t`numberAllowsNaN may only be specified with domain \"number\" (was ${actual})`\n}\n"
  },
  {
    "path": "ark/schema/roots/intersection.ts",
    "content": "import {\n\tflatMorph,\n\thasDomain,\n\tincludes,\n\tisEmptyObject,\n\tisKeyOf,\n\tthrowParseError,\n\ttype array,\n\ttype listable,\n\ttype mutable,\n\ttype show\n} from \"@ark/util\"\nimport {\n\tconstraintKeyParser,\n\tflattenConstraints,\n\tintersectConstraints\n} from \"../constraint.ts\"\nimport type {\n\tnodeOfKind,\n\tNodeSchema,\n\tPrerequisite,\n\tRootSchema\n} from \"../kinds.ts\"\nimport type { PredicateNode } from \"../predicate.ts\"\nimport type { NodeCompiler } from \"../shared/compile.ts\"\nimport type {\n\tBaseErrorContext,\n\tBaseNormalizedSchema,\n\tdeclareNode\n} from \"../shared/declare.ts\"\nimport { Disjoint } from \"../shared/disjoint.ts\"\nimport type { ArkError } from \"../shared/errors.ts\"\nimport {\n\timplementNode,\n\tprestructuralKinds,\n\tstructureKeys,\n\ttype ConstraintKind,\n\ttype IntersectionContext,\n\ttype nodeImplementationOf,\n\ttype OpenNodeKind,\n\ttype PrestructuralKind,\n\ttype RefinementKind,\n\ttype StructuralKind\n} from \"../shared/implement.ts\"\nimport { intersectOrPipeNodes } from \"../shared/intersections.ts\"\nimport type { JsonSchema } from \"../shared/jsonSchema.ts\"\nimport type { ToJsonSchema } from \"../shared/toJsonSchema.ts\"\nimport type { TraverseAllows, TraverseApply } from \"../shared/traversal.ts\"\nimport {\n\thasArkKind,\n\tisNode,\n\ttype makeRootAndArrayPropertiesMutable\n} from \"../shared/utils.ts\"\nimport type { Sequence } from \"../structure/sequence.ts\"\nimport type {\n\tStructure,\n\tUndeclaredKeyBehavior\n} from \"../structure/structure.ts\"\nimport type { Domain } from \"./domain.ts\"\nimport type { Morph } from \"./morph.ts\"\nimport type { Proto } from \"./proto.ts\"\nimport { BaseRoot } from \"./root.ts\"\nimport { defineRightwardIntersections } from \"./utils.ts\"\n\nexport declare namespace Intersection {\n\texport type BasisKind = \"domain\" | \"proto\"\n\n\texport type ChildKind = BasisKind | RefinementKind\n\n\texport type FlattenedChildKind = ChildKind | StructuralKind\n\n\texport type RefinementsInner = {\n\t\t[k in RefinementKind]?: intersectionChildInnerValueOf<k>\n\t}\n\n\texport interface Inner extends RefinementsInner {\n\t\tdomain?: Domain.Node\n\t\tproto?: Proto.Node\n\t\tstructure?: Structure.Node\n\t\tpredicate?: array<PredicateNode>\n\t}\n\n\texport namespace Inner {\n\t\texport type mutable = makeRootAndArrayPropertiesMutable<Inner>\n\t}\n\n\texport type ConstraintsSchema<inferredBasis = any> = show<\n\t\tBaseNormalizedSchema & {\n\t\t\tdomain?: Domain.Schema\n\t\t\tproto?: Proto.Schema\n\t\t} & conditionalRootOf<inferredBasis>\n\t>\n\n\texport type NormalizedSchema = Omit<\n\t\tConstraintsSchema,\n\t\tStructuralKind | \"undeclared\"\n\t>\n\n\texport type Schema<inferredBasis = any> = ConstraintsSchema<inferredBasis>\n\n\texport interface AstSchema extends BaseNormalizedSchema {\n\t\tintersection: readonly RootSchema[]\n\t}\n\n\texport interface ErrorContext\n\t\textends BaseErrorContext<\"intersection\">,\n\t\t\tInner {\n\t\terrors: readonly ArkError[]\n\t}\n\n\texport type Declaration = declareNode<{\n\t\tkind: \"intersection\"\n\t\tschema: Schema\n\t\tnormalizedSchema: NormalizedSchema\n\t\tinner: Inner\n\t\treducibleTo: \"intersection\" | BasisKind\n\t\terrorContext: ErrorContext\n\t\tchildKind: ChildKind\n\t}>\n\n\texport type Node = IntersectionNode\n}\n\nconst implementation: nodeImplementationOf<Intersection.Declaration> =\n\timplementNode<Intersection.Declaration>({\n\t\tkind: \"intersection\",\n\t\thasAssociatedError: true,\n\t\tnormalize: rawSchema => {\n\t\t\tif (isNode(rawSchema)) return rawSchema\n\n\t\t\tconst { structure, ...schema } = rawSchema\n\t\t\tconst hasRootStructureKey = !!structure\n\t\t\tconst normalizedStructure = (structure as mutable<Structure.Schema>) ?? {}\n\t\t\tconst normalized = flatMorph(schema, (k, v) => {\n\t\t\t\tif (isKeyOf(k, structureKeys)) {\n\t\t\t\t\tif (hasRootStructureKey) {\n\t\t\t\t\t\tthrowParseError(\n\t\t\t\t\t\t\t`Flattened structure key ${k} cannot be specified alongside a root 'structure' key.`\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tnormalizedStructure[k] = v as never\n\t\t\t\t\treturn []\n\t\t\t\t}\n\t\t\t\treturn [k, v]\n\t\t\t}) as mutable<Intersection.NormalizedSchema>\n\t\t\tif (\n\t\t\t\thasArkKind(normalizedStructure, \"constraint\") ||\n\t\t\t\t!isEmptyObject(normalizedStructure)\n\t\t\t)\n\t\t\t\tnormalized.structure = normalizedStructure\n\t\t\treturn normalized\n\t\t},\n\t\tfinalizeInnerJson: ({ structure, ...rest }) =>\n\t\t\thasDomain(structure, \"object\") ? { ...structure, ...rest } : rest,\n\t\tkeys: {\n\t\t\tdomain: {\n\t\t\t\tchild: true,\n\t\t\t\tparse: (schema, ctx) => ctx.$.node(\"domain\", schema)\n\t\t\t},\n\t\t\tproto: {\n\t\t\t\tchild: true,\n\t\t\t\tparse: (schema, ctx) => ctx.$.node(\"proto\", schema)\n\t\t\t},\n\t\t\tstructure: {\n\t\t\t\tchild: true,\n\t\t\t\tparse: (schema, ctx) => ctx.$.node(\"structure\", schema),\n\t\t\t\tserialize: node => {\n\t\t\t\t\tif (!node.sequence?.minLength) return node.collapsibleJson\n\t\t\t\t\tconst { sequence, ...structureJson } = node.collapsibleJson as any\n\t\t\t\t\tconst { minVariadicLength, ...sequenceJson } =\n\t\t\t\t\t\tsequence as Sequence.NormalizedSchema\n\t\t\t\t\tconst collapsibleSequenceJson =\n\t\t\t\t\t\tsequenceJson.variadic && Object.keys(sequenceJson).length === 1 ?\n\t\t\t\t\t\t\tsequenceJson.variadic\n\t\t\t\t\t\t:\tsequenceJson\n\t\t\t\t\treturn { ...structureJson, sequence: collapsibleSequenceJson }\n\t\t\t\t}\n\t\t\t},\n\t\t\tdivisor: {\n\t\t\t\tchild: true,\n\t\t\t\tparse: constraintKeyParser(\"divisor\")\n\t\t\t},\n\t\t\tmax: {\n\t\t\t\tchild: true,\n\t\t\t\tparse: constraintKeyParser(\"max\")\n\t\t\t},\n\t\t\tmin: {\n\t\t\t\tchild: true,\n\t\t\t\tparse: constraintKeyParser(\"min\")\n\t\t\t},\n\t\t\tmaxLength: {\n\t\t\t\tchild: true,\n\t\t\t\tparse: constraintKeyParser(\"maxLength\")\n\t\t\t},\n\t\t\tminLength: {\n\t\t\t\tchild: true,\n\t\t\t\tparse: constraintKeyParser(\"minLength\")\n\t\t\t},\n\t\t\texactLength: {\n\t\t\t\tchild: true,\n\t\t\t\tparse: constraintKeyParser(\"exactLength\")\n\t\t\t},\n\t\t\tbefore: {\n\t\t\t\tchild: true,\n\t\t\t\tparse: constraintKeyParser(\"before\")\n\t\t\t},\n\t\t\tafter: {\n\t\t\t\tchild: true,\n\t\t\t\tparse: constraintKeyParser(\"after\")\n\t\t\t},\n\t\t\tpattern: {\n\t\t\t\tchild: true,\n\t\t\t\tparse: constraintKeyParser(\"pattern\")\n\t\t\t},\n\t\t\tpredicate: {\n\t\t\t\tchild: true,\n\t\t\t\tparse: constraintKeyParser(\"predicate\")\n\t\t\t}\n\t\t},\n\t\t// leverage reduction logic from intersection and identity to ensure initial\n\t\t// parse result is reduced\n\t\treduce: (inner, $) =>\n\t\t\t// we cast union out of the result here since that only occurs when intersecting two sequences\n\t\t\t// that cannot occur when reducing a single intersection schema using unknown\n\t\t\tintersectIntersections({}, inner, {\n\t\t\t\t$,\n\t\t\t\tinvert: false,\n\t\t\t\tpipe: false\n\t\t\t}) as nodeOfKind<\"intersection\" | Intersection.BasisKind>,\n\t\tdefaults: {\n\t\t\tdescription: node => {\n\t\t\t\tif (node.children.length === 0) return \"unknown\"\n\t\t\t\tif (node.structure) return node.structure.description\n\n\t\t\t\tconst childDescriptions: string[] = []\n\n\t\t\t\tif (\n\t\t\t\t\tnode.basis &&\n\t\t\t\t\t!node.prestructurals.some(r => r.impl.obviatesBasisDescription)\n\t\t\t\t)\n\t\t\t\t\tchildDescriptions.push(node.basis.description)\n\n\t\t\t\tif (node.prestructurals.length) {\n\t\t\t\t\tconst sortedRefinementDescriptions = node.prestructurals\n\t\t\t\t\t\t.slice()\n\t\t\t\t\t\t// override alphabetization to describe min before max\n\t\t\t\t\t\t.sort((l, r) => (l.kind === \"min\" && r.kind === \"max\" ? -1 : 0))\n\t\t\t\t\t\t.map(r => r.description)\n\t\t\t\t\tchildDescriptions.push(...sortedRefinementDescriptions)\n\t\t\t\t}\n\n\t\t\t\tif (node.inner.predicate) {\n\t\t\t\t\tchildDescriptions.push(\n\t\t\t\t\t\t...node.inner.predicate.map(p => p.description)\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\treturn childDescriptions.join(\" and \")\n\t\t\t},\n\t\t\texpected: source =>\n\t\t\t\t`  ◦ ${source.errors.map(e => e.expected).join(\"\\n  ◦ \")}`,\n\t\t\tproblem: ctx => `(${ctx.actual}) must be...\\n${ctx.expected}`\n\t\t},\n\t\tintersections: {\n\t\t\tintersection: (l, r, ctx) =>\n\t\t\t\tintersectIntersections(l.inner, r.inner, ctx),\n\t\t\t...defineRightwardIntersections(\"intersection\", (l, r, ctx) => {\n\t\t\t\t// if l is unknown, return r\n\t\t\t\tif (l.children.length === 0) return r\n\n\t\t\t\tconst { domain, proto, ...lInnerConstraints } = l.inner\n\n\t\t\t\tconst lBasis = proto ?? domain\n\n\t\t\t\tconst basis = lBasis ? intersectOrPipeNodes(lBasis, r, ctx) : r\n\n\t\t\t\treturn (\n\t\t\t\t\tbasis instanceof Disjoint ? basis\n\t\t\t\t\t: l?.basis?.equals(basis) ?\n\t\t\t\t\t\t// if the basis doesn't change, return the original intesection\n\t\t\t\t\t\tl\n\t\t\t\t\t\t// given we've already precluded l being unknown, the result must\n\t\t\t\t\t\t// be an intersection with the new basis result integrated\n\t\t\t\t\t:\tl.$.node(\n\t\t\t\t\t\t\t\"intersection\",\n\t\t\t\t\t\t\t{ ...lInnerConstraints, [basis.kind]: basis },\n\t\t\t\t\t\t\t{ prereduced: true }\n\t\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t})\n\t\t}\n\t})\n\nexport class IntersectionNode extends BaseRoot<Intersection.Declaration> {\n\tbasis: nodeOfKind<Intersection.BasisKind> | null =\n\t\tthis.inner.domain ?? this.inner.proto ?? null\n\n\tprestructurals: array<nodeOfKind<PrestructuralKind>> = []\n\n\trefinements: array<nodeOfKind<RefinementKind>> = this.children.filter(\n\t\t(node): node is never => {\n\t\t\tif (!node.isRefinement()) return false\n\t\t\tif (includes(prestructuralKinds, node.kind))\n\t\t\t\t// mutation is fine during initialization\n\t\t\t\t(this.prestructurals as unknown[]).push(node)\n\t\t\treturn true\n\t\t}\n\t)\n\n\tstructure: Structure.Node | undefined = this.inner.structure\n\n\texpression: string = writeIntersectionExpression(this)\n\n\tget shallowMorphs(): array<Morph> {\n\t\treturn this.inner.structure?.structuralMorph ?\n\t\t\t\t[this.inner.structure.structuralMorph]\n\t\t\t:\t[]\n\t}\n\n\tget defaultShortDescription(): string {\n\t\treturn this.basis?.defaultShortDescription ?? \"present\"\n\t}\n\n\tprotected innerToJsonSchema(ctx: ToJsonSchema.Context): JsonSchema {\n\t\treturn this.children.reduce<JsonSchema>(\n\t\t\t// cast is required since TS doesn't know children have compatible schema prerequisites\n\t\t\t(schema, child) =>\n\t\t\t\tchild.isBasis() ?\n\t\t\t\t\tchild.toJsonSchemaRecurse(ctx)\n\t\t\t\t:\tchild.reduceJsonSchema(schema as never, ctx),\n\t\t\t{}\n\t\t)\n\t}\n\n\ttraverseAllows: TraverseAllows = (data, ctx) =>\n\t\tthis.children.every(child => child.traverseAllows(data as never, ctx))\n\n\ttraverseApply: TraverseApply = (data, ctx) => {\n\t\tconst errorCount = ctx.currentErrorCount\n\t\tif (this.basis) {\n\t\t\tthis.basis.traverseApply(data, ctx)\n\t\t\tif (ctx.currentErrorCount > errorCount) return\n\t\t}\n\t\tif (this.prestructurals.length) {\n\t\t\tfor (let i = 0; i < this.prestructurals.length - 1; i++) {\n\t\t\t\tthis.prestructurals[i].traverseApply(data as never, ctx)\n\t\t\t\tif (ctx.failFast && ctx.currentErrorCount > errorCount) return\n\t\t\t}\n\t\t\tthis.prestructurals[this.prestructurals.length - 1]!.traverseApply(\n\t\t\t\tdata as never,\n\t\t\t\tctx\n\t\t\t)\n\t\t\tif (ctx.currentErrorCount > errorCount) return\n\t\t}\n\t\tif (this.structure) {\n\t\t\tthis.structure.traverseApply(data as never, ctx)\n\t\t\tif (ctx.currentErrorCount > errorCount) return\n\t\t}\n\t\tif (this.inner.predicate) {\n\t\t\tfor (let i = 0; i < this.inner.predicate.length - 1; i++) {\n\t\t\t\tthis.inner.predicate[i].traverseApply(data as never, ctx)\n\t\t\t\tif (ctx.failFast && ctx.currentErrorCount > errorCount) return\n\t\t\t}\n\t\t\tthis.inner.predicate[this.inner.predicate.length - 1]!.traverseApply(\n\t\t\t\tdata as never,\n\t\t\t\tctx\n\t\t\t)\n\t\t}\n\t}\n\n\tcompile(js: NodeCompiler): void {\n\t\tif (js.traversalKind === \"Allows\") {\n\t\t\tfor (const child of this.children) js.check(child)\n\t\t\tjs.return(true)\n\t\t\treturn\n\t\t}\n\n\t\tjs.initializeErrorCount()\n\n\t\tif (this.basis) {\n\t\t\tjs.check(this.basis)\n\t\t\t// we only have to return conditionally if this is not the last check\n\t\t\tif (this.children.length > 1) js.returnIfFail()\n\t\t}\n\t\tif (this.prestructurals.length) {\n\t\t\tfor (let i = 0; i < this.prestructurals.length - 1; i++) {\n\t\t\t\tjs.check(this.prestructurals[i])\n\t\t\t\tjs.returnIfFailFast()\n\t\t\t}\n\t\t\tjs.check(this.prestructurals[this.prestructurals.length - 1]!)\n\t\t\tif (this.structure || this.inner.predicate) js.returnIfFail()\n\t\t}\n\t\tif (this.structure) {\n\t\t\tjs.check(this.structure)\n\t\t\tif (this.inner.predicate) js.returnIfFail()\n\t\t}\n\t\tif (this.inner.predicate) {\n\t\t\tfor (let i = 0; i < this.inner.predicate.length - 1; i++) {\n\t\t\t\tjs.check(this.inner.predicate[i])\n\t\t\t\t// since predicates can be chained, we have to fail immediately\n\t\t\t\t// if one fails\n\t\t\t\tjs.returnIfFail()\n\t\t\t}\n\t\t\tjs.check(this.inner.predicate[this.inner.predicate.length - 1]!)\n\t\t}\n\t}\n}\n\nexport const Intersection = {\n\timplementation,\n\tNode: IntersectionNode\n}\n\nconst writeIntersectionExpression = (node: Intersection.Node) => {\n\tif (node.structure?.expression) return node.structure.expression\n\n\tconst basisExpression =\n\t\t(\n\t\t\tnode.basis &&\n\t\t\t!node.prestructurals.some(n => n.impl.obviatesBasisExpression)\n\t\t) ?\n\t\t\tnode.basis.nestableExpression\n\t\t:\t\"\"\n\n\tconst refinementsExpression = node.prestructurals\n\t\t.map(n => n.expression)\n\t\t.join(\" & \")\n\n\tconst fullExpression = `${basisExpression}${basisExpression && refinementsExpression ? \" \" : \"\"}${refinementsExpression}`\n\n\tif (fullExpression === \"Array == 0\") return \"[]\"\n\n\treturn fullExpression || \"unknown\"\n}\n\nconst intersectIntersections = (\n\tl: Intersection.Inner,\n\tr: Intersection.Inner,\n\tctx: IntersectionContext\n): BaseRoot | Disjoint => {\n\tconst baseInner: Intersection.Inner.mutable = {}\n\n\tconst lBasis = l.proto ?? l.domain\n\tconst rBasis = r.proto ?? r.domain\n\tconst basisResult =\n\t\tlBasis ?\n\t\t\trBasis ?\n\t\t\t\t(intersectOrPipeNodes(\n\t\t\t\t\tlBasis,\n\t\t\t\t\trBasis,\n\t\t\t\t\tctx\n\t\t\t\t) as nodeOfKind<Intersection.BasisKind>)\n\t\t\t:\tlBasis\n\t\t:\trBasis\n\tif (basisResult instanceof Disjoint) return basisResult\n\n\tif (basisResult) baseInner[basisResult.kind] = basisResult as never\n\n\treturn intersectConstraints({\n\t\tkind: \"intersection\",\n\t\tbaseInner,\n\t\tl: flattenConstraints(l),\n\t\tr: flattenConstraints(r),\n\t\troots: [],\n\t\tctx\n\t})\n}\n\nexport type ConditionalTerminalIntersectionRoot = {\n\tundeclared?: UndeclaredKeyBehavior\n}\n\ntype ConditionalTerminalIntersectionKey =\n\tkeyof ConditionalTerminalIntersectionRoot\n\ntype ConditionalIntersectionKey =\n\t| ConstraintKind\n\t| ConditionalTerminalIntersectionKey\n\nexport type constraintKindOf<t> = {\n\t[k in ConstraintKind]: t extends Prerequisite<k> ? k : never\n}[ConstraintKind]\n\ntype conditionalIntersectionKeyOf<t> =\n\t| constraintKindOf<t>\n\t| (t extends object ? \"undeclared\" : never)\n\ntype intersectionChildSchemaValueOf<k extends Intersection.FlattenedChildKind> =\n\tk extends OpenNodeKind ? listable<NodeSchema<k>> : NodeSchema<k>\n\ntype conditionalSchemaValueOfKey<k extends ConditionalIntersectionKey> =\n\tk extends Intersection.FlattenedChildKind ? intersectionChildSchemaValueOf<k>\n\t:\tConditionalTerminalIntersectionRoot[k & ConditionalTerminalIntersectionKey]\n\ntype intersectionChildInnerValueOf<k extends Intersection.FlattenedChildKind> =\n\tk extends OpenNodeKind ? readonly nodeOfKind<k>[] : nodeOfKind<k>\n\nexport type conditionalRootOf<t> = {\n\t[k in conditionalIntersectionKeyOf<t>]?: conditionalSchemaValueOfKey<k>\n}\n"
  },
  {
    "path": "ark/schema/roots/morph.ts",
    "content": "import {\n\tarrayEquals,\n\tliftArray,\n\tthrowParseError,\n\ttype array,\n\ttype listable,\n\ttype mutable\n} from \"@ark/util\"\nimport type { RootSchema } from \"../kinds.ts\"\nimport type { NodeCompiler } from \"../shared/compile.ts\"\nimport type { BaseNormalizedSchema, declareNode } from \"../shared/declare.ts\"\nimport { Disjoint } from \"../shared/disjoint.ts\"\nimport {\n\timplementNode,\n\ttype nodeImplementationOf,\n\ttype RootKind\n} from \"../shared/implement.ts\"\nimport { intersectOrPipeNodes } from \"../shared/intersections.ts\"\nimport type { JsonSchema } from \"../shared/jsonSchema.ts\"\nimport { $ark, registeredReference } from \"../shared/registry.ts\"\nimport type { ToJsonSchema } from \"../shared/toJsonSchema.ts\"\nimport type {\n\tTraversal,\n\tTraverseAllows,\n\tTraverseApply\n} from \"../shared/traversal.ts\"\nimport { hasArkKind } from \"../shared/utils.ts\"\nimport { BaseRoot } from \"./root.ts\"\nimport { defineRightwardIntersections } from \"./utils.ts\"\n\nexport declare namespace Morph {\n\texport interface Inner {\n\t\treadonly in?: BaseRoot\n\t\treadonly morphs: array<Morph | BaseRoot>\n\t\treadonly declaredIn?: BaseRoot\n\t\treadonly declaredOut?: BaseRoot\n\t}\n\n\texport interface Schema extends BaseNormalizedSchema {\n\t\treadonly in?: RootSchema\n\t\treadonly morphs: listable<Morph | BaseRoot>\n\t\treadonly declaredIn?: BaseRoot\n\t\treadonly declaredOut?: BaseRoot\n\t}\n\n\texport interface Declaration\n\t\textends declareNode<{\n\t\t\tkind: \"morph\"\n\t\t\tschema: Schema\n\t\t\tnormalizedSchema: Schema\n\t\t\tinner: Inner\n\t\t\tchildKind: RootKind\n\t\t}> {}\n\n\texport type Node = MorphNode\n\n\texport type In<morph extends Morph> = morph extends Morph<infer i> ? i : never\n\n\texport type Out<morph extends Morph> =\n\t\tmorph extends Morph<never, infer o> ? o : never\n\n\texport type ContextFree<i = never, o = unknown> = (In: i) => o\n}\n\nexport type Morph<i = never, o = unknown> = (In: i, ctx: Traversal) => o\n\nconst implementation: nodeImplementationOf<Morph.Declaration> =\n\timplementNode<Morph.Declaration>({\n\t\tkind: \"morph\",\n\t\thasAssociatedError: false,\n\t\tkeys: {\n\t\t\tin: {\n\t\t\t\tchild: true,\n\t\t\t\tparse: (schema, ctx) => ctx.$.parseSchema(schema)\n\t\t\t},\n\t\t\tmorphs: {\n\t\t\t\tparse: liftArray,\n\t\t\t\tserialize: morphs =>\n\t\t\t\t\tmorphs.map(m =>\n\t\t\t\t\t\thasArkKind(m, \"root\") ? m.json : registeredReference(m)\n\t\t\t\t\t)\n\t\t\t},\n\t\t\tdeclaredIn: {\n\t\t\t\tchild: false,\n\t\t\t\tserialize: node => node.json\n\t\t\t},\n\t\t\tdeclaredOut: {\n\t\t\t\tchild: false,\n\t\t\t\tserialize: node => node.json\n\t\t\t}\n\t\t},\n\t\tnormalize: schema => schema,\n\t\tdefaults: {\n\t\t\tdescription: node =>\n\t\t\t\t`a morph from ${node.rawIn.description} to ${node.rawOut?.description ?? \"unknown\"}`\n\t\t},\n\t\tintersections: {\n\t\t\tmorph: (l, r, ctx) => {\n\t\t\t\tif (!l.hasEqualMorphs(r)) {\n\t\t\t\t\treturn throwParseError(\n\t\t\t\t\t\twriteMorphIntersectionMessage(l.expression, r.expression)\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tconst inTersection = intersectOrPipeNodes(l.rawIn, r.rawIn, ctx)\n\t\t\t\tif (inTersection instanceof Disjoint) return inTersection\n\n\t\t\t\tconst baseInner: Omit<mutable<Morph.Inner>, \"in\"> = {\n\t\t\t\t\tmorphs: l.morphs\n\t\t\t\t}\n\n\t\t\t\tif (l.declaredIn || r.declaredIn) {\n\t\t\t\t\tconst declaredIn = intersectOrPipeNodes(l.rawIn, r.rawIn, ctx)\n\t\t\t\t\t// we can't treat this as a normal Disjoint since it's just declared\n\t\t\t\t\t// it should only happen if someone's essentially trying to create a broken type\n\t\t\t\t\tif (declaredIn instanceof Disjoint) return declaredIn.throw()\n\t\t\t\t\telse baseInner.declaredIn = declaredIn as never\n\t\t\t\t}\n\n\t\t\t\tif (l.declaredOut || r.declaredOut) {\n\t\t\t\t\tconst declaredOut = intersectOrPipeNodes(l.rawOut, r.rawOut, ctx)\n\t\t\t\t\tif (declaredOut instanceof Disjoint) return declaredOut.throw()\n\t\t\t\t\telse baseInner.declaredOut = declaredOut\n\t\t\t\t}\n\n\t\t\t\t// in case from is a union, we need to distribute the branches\n\t\t\t\t// to can be a union as any schema is allowed\n\t\t\t\treturn inTersection.distribute(\n\t\t\t\t\tinBranch =>\n\t\t\t\t\t\tctx.$.node(\"morph\", {\n\t\t\t\t\t\t\t...baseInner,\n\t\t\t\t\t\t\tin: inBranch\n\t\t\t\t\t\t}),\n\t\t\t\t\tctx.$.parseSchema\n\t\t\t\t)\n\t\t\t},\n\t\t\t...defineRightwardIntersections(\"morph\", (l, r, ctx) => {\n\t\t\t\tconst inTersection =\n\t\t\t\t\tl.inner.in ? intersectOrPipeNodes(l.inner.in, r, ctx) : r\n\t\t\t\treturn (\n\t\t\t\t\tinTersection instanceof Disjoint ? inTersection\n\t\t\t\t\t: inTersection.equals(l.inner.in) ? l\n\t\t\t\t\t: ctx.$.node(\"morph\", {\n\t\t\t\t\t\t\t...l.inner,\n\t\t\t\t\t\t\tin: inTersection\n\t\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t})\n\t\t}\n\t})\n\nexport class MorphNode extends BaseRoot<Morph.Declaration> {\n\tserializedMorphs: string[] = this.morphs.map(registeredReference)\n\tcompiledMorphs = `[${this.serializedMorphs}]`\n\n\tlastMorph: Morph | BaseRoot | undefined =\n\t\tthis.inner.morphs[this.inner.morphs.length - 1]\n\tlastMorphIfNode: BaseRoot | undefined =\n\t\thasArkKind(this.lastMorph, \"root\") ? this.lastMorph : undefined\n\tintrospectableIn: BaseRoot | undefined = this.inner.in\n\tintrospectableOut: BaseRoot | undefined =\n\t\tthis.lastMorphIfNode ?\n\t\t\tObject.assign(this.referencesById, this.lastMorphIfNode.referencesById) &&\n\t\t\tthis.lastMorphIfNode.rawOut\n\t\t:\tundefined\n\n\tget shallowMorphs(): array<Morph> {\n\t\t// if the morph input is a union, it should not contain any other shallow morphs\n\t\treturn Array.isArray(this.inner.in?.shallowMorphs) ?\n\t\t\t\t[...this.inner.in.shallowMorphs, ...this.morphs]\n\t\t\t:\tthis.morphs\n\t}\n\n\toverride get rawIn(): BaseRoot {\n\t\treturn (\n\t\t\tthis.declaredIn ?? this.inner.in?.rawIn ?? $ark.intrinsic.unknown.internal\n\t\t)\n\t}\n\n\toverride get rawOut(): BaseRoot {\n\t\treturn (\n\t\t\tthis.declaredOut ??\n\t\t\tthis.introspectableOut ??\n\t\t\t$ark.intrinsic.unknown.internal\n\t\t)\n\t}\n\n\tdeclareIn(declaredIn: BaseRoot): MorphNode {\n\t\treturn this.$.node(\"morph\", {\n\t\t\t...this.inner,\n\t\t\tdeclaredIn\n\t\t})\n\t}\n\n\tdeclareOut(declaredOut: BaseRoot): MorphNode {\n\t\treturn this.$.node(\"morph\", {\n\t\t\t...this.inner,\n\t\t\tdeclaredOut\n\t\t})\n\t}\n\n\texpression = `(In: ${this.rawIn.expression}) => ${this.lastMorphIfNode ? \"To\" : \"Out\"}<${this.rawOut.expression}>`\n\n\tget defaultShortDescription(): string {\n\t\treturn this.rawIn.meta.description ?? this.rawIn.defaultShortDescription\n\t}\n\n\tprotected innerToJsonSchema(ctx: ToJsonSchema.Context): JsonSchema {\n\t\treturn ctx.fallback.morph({\n\t\t\tcode: \"morph\",\n\t\t\tbase: this.rawIn.toJsonSchemaRecurse(ctx),\n\t\t\tout: this.introspectableOut?.toJsonSchemaRecurse(ctx) ?? null\n\t\t})\n\t}\n\n\tcompile(js: NodeCompiler): void {\n\t\tif (js.traversalKind === \"Allows\") {\n\t\t\tif (!this.introspectableIn) return\n\t\t\tjs.return(js.invoke(this.introspectableIn))\n\t\t\treturn\n\t\t}\n\t\tif (this.introspectableIn) js.line(js.invoke(this.introspectableIn))\n\t\tjs.line(`ctx.queueMorphs(${this.compiledMorphs})`)\n\t}\n\n\ttraverseAllows: TraverseAllows = (data, ctx) =>\n\t\t!this.introspectableIn || this.introspectableIn.traverseAllows(data, ctx)\n\n\ttraverseApply: TraverseApply = (data, ctx) => {\n\t\tif (this.introspectableIn) this.introspectableIn.traverseApply(data, ctx)\n\t\tctx.queueMorphs(this.morphs)\n\t}\n\n\t/** Check if the morphs of r are equal to those of this node */\n\toverride hasEqualMorphs(r: MorphNode): boolean {\n\t\treturn arrayEquals(this.morphs, r.morphs, {\n\t\t\tisEqual: (lMorph, rMorph) =>\n\t\t\t\tlMorph === rMorph ||\n\t\t\t\t(hasArkKind(lMorph, \"root\") &&\n\t\t\t\t\thasArkKind(rMorph, \"root\") &&\n\t\t\t\t\tlMorph.equals(rMorph))\n\t\t})\n\t}\n}\n\nexport const Morph = {\n\timplementation,\n\tNode: MorphNode\n}\n\nexport const writeMorphIntersectionMessage = (\n\tlDescription: string,\n\trDescription: string\n): string =>\n\t`The intersection of distinct morphs at a single path is indeterminate:\nLeft: ${lDescription}\nRight: ${rDescription}`\n"
  },
  {
    "path": "ark/schema/roots/proto.ts",
    "content": "import {\n\tbuiltinConstructors,\n\tconstructorExtends,\n\tdomainOf,\n\tgetBuiltinNameOfConstructor,\n\thasKey,\n\tobjectKindDescriptions,\n\tobjectKindOrDomainOf,\n\tthrowParseError,\n\ttype BuiltinObjectKind,\n\ttype Constructor\n} from \"@ark/util\"\nimport type {\n\tBaseErrorContext,\n\tBaseNormalizedSchema,\n\tdeclareNode\n} from \"../shared/declare.ts\"\nimport { Disjoint } from \"../shared/disjoint.ts\"\nimport {\n\tdefaultValueSerializer,\n\timplementNode,\n\ttype nodeImplementationOf\n} from \"../shared/implement.ts\"\nimport type { JsonSchema } from \"../shared/jsonSchema.ts\"\nimport { $ark } from \"../shared/registry.ts\"\nimport type { ToJsonSchema } from \"../shared/toJsonSchema.ts\"\nimport type { TraverseAllows } from \"../shared/traversal.ts\"\nimport { isNode } from \"../shared/utils.ts\"\nimport { InternalBasis } from \"./basis.ts\"\nimport type { Domain } from \"./domain.ts\"\n\nexport declare namespace Proto {\n\texport type Reference = Constructor | BuiltinObjectKind\n\n\texport type Schema<proto extends Reference = Reference> =\n\t\t| proto\n\t\t| ExpandedSchema<proto>\n\n\texport interface NormalizedSchema<proto extends Constructor = Constructor>\n\t\textends BaseNormalizedSchema {\n\t\treadonly proto: proto\n\t\treadonly dateAllowsInvalid?: boolean\n\t}\n\n\texport interface ExpandedSchema<proto extends Reference = Reference> {\n\t\treadonly proto: proto\n\t\treadonly dateAllowsInvalid?: boolean\n\t}\n\n\texport interface Inner<proto extends Constructor = Constructor> {\n\t\treadonly proto: proto\n\t\treadonly dateAllowsInvalid?: boolean\n\t}\n\n\texport interface ErrorContext extends BaseErrorContext<\"proto\">, Inner {}\n\n\texport interface Declaration\n\t\textends declareNode<{\n\t\t\tkind: \"proto\"\n\t\t\tschema: Schema\n\t\t\tnormalizedSchema: NormalizedSchema\n\t\t\tinner: Inner\n\t\t\terrorContext: ErrorContext\n\t\t}> {}\n\n\texport type Node = ProtoNode\n}\n\nconst implementation: nodeImplementationOf<Proto.Declaration> =\n\timplementNode<Proto.Declaration>({\n\t\tkind: \"proto\",\n\t\thasAssociatedError: true,\n\t\tcollapsibleKey: \"proto\",\n\t\tkeys: {\n\t\t\tproto: {\n\t\t\t\tserialize: ctor =>\n\t\t\t\t\tgetBuiltinNameOfConstructor(ctor) ?? defaultValueSerializer(ctor)\n\t\t\t},\n\t\t\tdateAllowsInvalid: {}\n\t\t},\n\t\tnormalize: schema => {\n\t\t\tconst normalized: Proto.NormalizedSchema<Constructor> =\n\t\t\t\ttypeof schema === \"string\" ? { proto: builtinConstructors[schema] }\n\t\t\t\t: typeof schema === \"function\" ?\n\t\t\t\t\tisNode(schema) ? (schema as {} as ProtoNode)\n\t\t\t\t\t:\t{ proto: schema }\n\t\t\t\t: typeof schema.proto === \"string\" ?\n\t\t\t\t\t{ ...schema, proto: builtinConstructors[schema.proto] }\n\t\t\t\t:\t(schema as never)\n\t\t\tif (typeof normalized.proto !== \"function\")\n\t\t\t\tthrowParseError(Proto.writeInvalidSchemaMessage(normalized.proto))\n\n\t\t\tif (hasKey(normalized, \"dateAllowsInvalid\") && normalized.proto !== Date)\n\t\t\t\tthrowParseError(Proto.writeBadInvalidDateMessage(normalized.proto))\n\t\t\treturn normalized\n\t\t},\n\t\tapplyConfig: (schema, config) => {\n\t\t\tif (\n\t\t\t\tschema.dateAllowsInvalid === undefined &&\n\t\t\t\tschema.proto === Date &&\n\t\t\t\tconfig.dateAllowsInvalid\n\t\t\t)\n\t\t\t\treturn { ...schema, dateAllowsInvalid: true }\n\t\t\treturn schema\n\t\t},\n\t\tdefaults: {\n\t\t\tdescription: node =>\n\t\t\t\tnode.builtinName ?\n\t\t\t\t\tobjectKindDescriptions[node.builtinName]\n\t\t\t\t:\t`an instance of ${node.proto.name}`,\n\t\t\tactual: data =>\n\t\t\t\tdata instanceof Date && data.toString() === \"Invalid Date\" ?\n\t\t\t\t\t\"an invalid Date\"\n\t\t\t\t:\tobjectKindOrDomainOf(data)\n\t\t},\n\t\tintersections: {\n\t\t\tproto: (l, r) =>\n\t\t\t\tl.proto === Date && r.proto === Date ?\n\t\t\t\t\t// since l === r is handled by default,\n\t\t\t\t\t// exactly one of l or r must have allow invalid dates\n\t\t\t\t\tl.dateAllowsInvalid ?\n\t\t\t\t\t\tr\n\t\t\t\t\t:\tl\n\t\t\t\t: constructorExtends(l.proto, r.proto) ? l\n\t\t\t\t: constructorExtends(r.proto, l.proto) ? r\n\t\t\t\t: Disjoint.init(\"proto\", l, r),\n\t\t\tdomain: (proto, domain) =>\n\t\t\t\tdomain.domain === \"object\" ?\n\t\t\t\t\tproto\n\t\t\t\t:\tDisjoint.init(\n\t\t\t\t\t\t\"domain\",\n\t\t\t\t\t\t$ark.intrinsic.object.internal as Domain.Node,\n\t\t\t\t\t\tdomain\n\t\t\t\t\t)\n\t\t}\n\t})\n\nexport class ProtoNode extends InternalBasis<Proto.Declaration> {\n\tbuiltinName: BuiltinObjectKind | null = getBuiltinNameOfConstructor(\n\t\tthis.proto\n\t)\n\tserializedConstructor: string = (this.json as { proto: string }).proto\n\n\tprivate readonly requiresInvalidDateCheck =\n\t\tthis.proto === Date && !this.dateAllowsInvalid\n\n\ttraverseAllows: TraverseAllows =\n\t\tthis.requiresInvalidDateCheck ?\n\t\t\tdata => data instanceof Date && data.toString() !== \"Invalid Date\"\n\t\t:\tdata => data instanceof this.proto\n\n\tcompiledCondition = `data instanceof ${this.serializedConstructor}${this.requiresInvalidDateCheck ? ` && data.toString() !== \"Invalid Date\"` : \"\"}`\n\tcompiledNegation = `!(${this.compiledCondition})`\n\n\tprotected innerToJsonSchema(ctx: ToJsonSchema.Context): JsonSchema {\n\t\tswitch (this.builtinName) {\n\t\t\tcase \"Array\":\n\t\t\t\treturn {\n\t\t\t\t\ttype: \"array\"\n\t\t\t\t}\n\t\t\tcase \"Date\":\n\t\t\t\treturn (\n\t\t\t\t\tctx.fallback.date?.({ code: \"date\", base: {} }) ??\n\t\t\t\t\tctx.fallback.proto({ code: \"proto\", base: {}, proto: this.proto })\n\t\t\t\t)\n\t\t\tdefault:\n\t\t\t\treturn ctx.fallback.proto({\n\t\t\t\t\tcode: \"proto\",\n\t\t\t\t\tbase: {},\n\t\t\t\t\tproto: this.proto\n\t\t\t\t})\n\t\t}\n\t}\n\n\texpression: string =\n\t\tthis.dateAllowsInvalid ? \"Date | InvalidDate\" : this.proto.name\n\n\tget nestableExpression(): string {\n\t\treturn this.dateAllowsInvalid ? `(${this.expression})` : this.expression\n\t}\n\n\treadonly domain = \"object\"\n\n\tget defaultShortDescription(): string {\n\t\treturn this.description\n\t}\n}\n\nexport const Proto = {\n\timplementation,\n\tNode: ProtoNode,\n\twriteBadInvalidDateMessage: (actual: Constructor): string =>\n\t\t`dateAllowsInvalid may only be specified with constructor Date (was ${actual.name})`,\n\twriteInvalidSchemaMessage: (actual: unknown): string =>\n\t\t`instanceOf operand must be a function (was ${domainOf(actual)})`\n}\n"
  },
  {
    "path": "ark/schema/roots/root.ts",
    "content": "import {\n\tarrayEquals,\n\tflatMorph,\n\tincludes,\n\tinferred,\n\tomit,\n\tthrowInternalError,\n\tthrowParseError,\n\ttype Fn,\n\ttype array\n} from \"@ark/util\"\nimport { mergeToJsonSchemaConfigs } from \"../config.ts\"\nimport { throwInvalidOperandError, type Constraint } from \"../constraint.ts\"\nimport type { NodeSchema, nodeOfKind, reducibleKindOf } from \"../kinds.ts\"\nimport {\n\tBaseNode,\n\ttype GettableKeyOrNode,\n\ttype KeyOrKeyNode,\n\ttype NodeSelector\n} from \"../node.ts\"\nimport type { Predicate } from \"../predicate.ts\"\nimport type { Divisor } from \"../refinements/divisor.ts\"\nimport type { ExactLength } from \"../refinements/exactLength.ts\"\nimport type { Pattern } from \"../refinements/pattern.ts\"\nimport type {\n\tExclusiveDateRangeSchema,\n\tExclusiveNumericRangeSchema,\n\tInclusiveDateRangeSchema,\n\tInclusiveNumericRangeSchema,\n\tLimitSchemaValue,\n\tUnknownRangeSchema\n} from \"../refinements/range.ts\"\nimport type { BaseScope } from \"../scope.ts\"\nimport type { BaseNodeDeclaration, TypeMeta } from \"../shared/declare.ts\"\nimport {\n\tDisjoint,\n\twriteUnsatisfiableExpressionError\n} from \"../shared/disjoint.ts\"\nimport { ArkErrors } from \"../shared/errors.ts\"\nimport {\n\tstructuralKinds,\n\ttype NodeKind,\n\ttype RootKind,\n\ttype UnknownAttachments,\n\ttype kindRightOf\n} from \"../shared/implement.ts\"\nimport { intersectNodesRoot, pipeNodesRoot } from \"../shared/intersections.ts\"\nimport type { JsonSchema } from \"../shared/jsonSchema.ts\"\nimport { $ark } from \"../shared/registry.ts\"\nimport type {\n\tStandardJSONSchemaV1,\n\tStandardSchemaV1\n} from \"../shared/standardSchema.ts\"\nimport type { ToJsonSchema } from \"../shared/toJsonSchema.ts\"\nimport { arkKind, hasArkKind } from \"../shared/utils.ts\"\nimport { assertDefaultValueAssignability } from \"../structure/optional.ts\"\nimport type { Prop } from \"../structure/prop.ts\"\nimport type {\n\tPropFlatMapper,\n\tStructure,\n\tUndeclaredKeyBehavior\n} from \"../structure/structure.ts\"\nimport type { Morph } from \"./morph.ts\"\nimport type { Union } from \"./union.ts\"\n\nexport interface InternalRootDeclaration extends BaseNodeDeclaration {\n\tkind: RootKind\n}\n\nexport abstract class BaseRoot<\n\t\t/** @ts-ignore cast variance */\n\t\tout d extends InternalRootDeclaration = InternalRootDeclaration\n\t>\n\textends BaseNode<d>\n\timplements StandardSchemaV1, StandardJSONSchemaV1\n{\n\tdeclare readonly [arkKind]: \"root\"\n\tdeclare readonly [inferred]: unknown\n\n\tconstructor(attachments: UnknownAttachments, $: BaseScope) {\n\t\tsuper(attachments, $)\n\t\t// define as a getter to avoid it being enumerable/spreadable\n\t\tObject.defineProperty(this, arkKind, { value: \"root\", enumerable: false })\n\t}\n\n\t// doesn't seem possible to override this at a type-level (e.g. via declare)\n\t// without TS complaining about getters\n\toverride get rawIn(): BaseRoot {\n\t\treturn super.rawIn as never\n\t}\n\n\toverride get rawOut(): BaseRoot {\n\t\treturn super.rawOut as never\n\t}\n\n\tget internal(): this {\n\t\treturn this\n\t}\n\n\tget \"~standard\"(): StandardSchemaV1.ArkTypeProps {\n\t\treturn {\n\t\t\tvendor: \"arktype\",\n\t\t\tversion: 1,\n\t\t\tvalidate: input => {\n\t\t\t\tconst out = this(input)\n\t\t\t\tif (out instanceof ArkErrors) return out\n\t\t\t\treturn { value: out }\n\t\t\t},\n\t\t\tjsonSchema: {\n\t\t\t\tinput: opts =>\n\t\t\t\t\tthis.rawIn.toJsonSchema({\n\t\t\t\t\t\ttarget: validateStandardJsonSchemaTarget(opts.target),\n\t\t\t\t\t\t...opts.libraryOptions\n\t\t\t\t\t}) as never,\n\t\t\t\toutput: opts =>\n\t\t\t\t\tthis.rawOut.toJsonSchema({\n\t\t\t\t\t\ttarget: validateStandardJsonSchemaTarget(opts.target),\n\t\t\t\t\t\t...opts.libraryOptions\n\t\t\t\t\t}) as never\n\t\t\t}\n\t\t}\n\t}\n\n\tas(): this {\n\t\treturn this\n\t}\n\n\tbrand(name: string): this {\n\t\tif (name === \"\") return throwParseError(emptyBrandNameMessage)\n\t\treturn this\n\t}\n\n\treadonly(): this {\n\t\treturn this\n\t}\n\n\treadonly branches: readonly nodeOfKind<Union.ChildKind>[] =\n\t\tthis.hasKind(\"union\") ? this.inner.branches : [this as never]\n\n\tdistribute<mapOut, reduceOut = mapOut[]>(\n\t\tmapBranch: (\n\t\t\tbranch: nodeOfKind<Union.ChildKind>,\n\t\t\ti: number,\n\t\t\tbranches: array<nodeOfKind<Union.ChildKind>>\n\t\t) => mapOut,\n\t\treduceMapped?: (mappedBranches: mapOut[]) => reduceOut\n\t): reduceOut {\n\t\tconst mappedBranches = this.branches.map(mapBranch)\n\t\treturn reduceMapped?.(mappedBranches) ?? (mappedBranches as never)\n\t}\n\n\tabstract get defaultShortDescription(): string\n\n\tget shortDescription(): string {\n\t\treturn this.meta.description ?? this.defaultShortDescription\n\t}\n\n\ttoJsonSchema(opts: ToJsonSchema.Options = {}): JsonSchema {\n\t\tconst ctx: ToJsonSchema.Context = mergeToJsonSchemaConfigs(\n\t\t\tthis.$.resolvedConfig.toJsonSchema,\n\t\t\topts\n\t\t)\n\n\t\tctx.useRefs ||= this.isCyclic\n\n\t\t// ensure $schema is the first key if present\n\t\tconst schema: JsonSchema =\n\t\t\ttypeof ctx.dialect === \"string\" ? { $schema: ctx.dialect } : {}\n\n\t\tObject.assign(schema, this.toJsonSchemaRecurse(ctx))\n\n\t\tif (ctx.useRefs) {\n\t\t\tconst defs = flatMorph(this.references, (i, ref) =>\n\t\t\t\tref.isRoot() && !ref.alwaysExpandJsonSchema ?\n\t\t\t\t\t[ref.id, ref.toResolvedJsonSchema(ctx)]\n\t\t\t\t:\t[]\n\t\t\t)\n\t\t\t// draft-2020-12 uses $defs, draft-07 uses definitions\n\t\t\tif (ctx.target === \"draft-07\")\n\t\t\t\tObject.assign(schema, { definitions: defs })\n\t\t\telse schema.$defs = defs\n\t\t}\n\n\t\treturn schema\n\t}\n\n\ttoJsonSchemaRecurse(ctx: ToJsonSchema.Context): JsonSchema {\n\t\tif (ctx.useRefs && !this.alwaysExpandJsonSchema) {\n\t\t\t// draft-2020-12 uses $defs, draft-07 uses definitions\n\t\t\tconst defsKey = ctx.target === \"draft-07\" ? \"definitions\" : \"$defs\"\n\t\t\treturn { $ref: `#/${defsKey}/${this.id}` } as JsonSchema.Ref\n\t\t}\n\n\t\treturn this.toResolvedJsonSchema(ctx)\n\t}\n\n\tget alwaysExpandJsonSchema(): boolean {\n\t\treturn (\n\t\t\tthis.isBasis() ||\n\t\t\tthis.kind === \"alias\" ||\n\t\t\t(this.hasKind(\"union\") && this.isBoolean)\n\t\t)\n\t}\n\n\tprotected toResolvedJsonSchema(ctx: ToJsonSchema.Context): JsonSchema {\n\t\tconst result = this.innerToJsonSchema(ctx)\n\n\t\treturn Object.assign(result, this.metaJson)\n\t}\n\n\tprotected abstract innerToJsonSchema(ctx: ToJsonSchema.Context): JsonSchema\n\n\tintersect(r: unknown): BaseRoot | Disjoint {\n\t\tconst rNode = this.$.parseDefinition(r)\n\t\tconst result = this.rawIntersect(rNode)\n\t\tif (result instanceof Disjoint) return result\n\t\treturn this.$.finalize(result as BaseRoot)\n\t}\n\n\trawIntersect(r: BaseRoot): BaseRoot {\n\t\treturn intersectNodesRoot(this, r, this.$) as never\n\t}\n\n\ttoNeverIfDisjoint(): BaseRoot {\n\t\treturn this\n\t}\n\n\tand(r: unknown): BaseRoot {\n\t\tconst result = this.intersect(r)\n\t\treturn result instanceof Disjoint ? result.throw() : (result as never)\n\t}\n\n\trawAnd(r: BaseRoot): BaseRoot {\n\t\tconst result = this.rawIntersect(r)\n\t\treturn result instanceof Disjoint ? result.throw() : result\n\t}\n\n\tor(r: unknown): BaseRoot {\n\t\tconst rNode = this.$.parseDefinition(r)\n\t\treturn this.$.finalize(this.rawOr(rNode)) as never\n\t}\n\n\trawOr(r: BaseRoot): BaseRoot {\n\t\tconst branches = [...this.branches, ...(r.branches as any)]\n\t\treturn this.$.node(\"union\", branches) as never\n\t}\n\n\tmap(flatMapEntry: PropFlatMapper): BaseRoot {\n\t\treturn this.$.schema(this.applyStructuralOperation(\"map\", [flatMapEntry]))\n\t}\n\n\tpick(...keys: KeyOrKeyNode[]): BaseRoot {\n\t\treturn this.$.schema(this.applyStructuralOperation(\"pick\", keys))\n\t}\n\n\tomit(...keys: KeyOrKeyNode[]): BaseRoot {\n\t\treturn this.$.schema(this.applyStructuralOperation(\"omit\", keys))\n\t}\n\n\trequired(): BaseRoot {\n\t\treturn this.$.schema(this.applyStructuralOperation(\"required\", []))\n\t}\n\n\tpartial(): BaseRoot {\n\t\treturn this.$.schema(this.applyStructuralOperation(\"partial\", []))\n\t}\n\n\tprivate _keyof?: BaseRoot\n\tkeyof(): BaseRoot {\n\t\tif (this._keyof) return this._keyof\n\t\tconst result = this.applyStructuralOperation(\"keyof\", []).reduce(\n\t\t\t(result, branch) => result.intersect(branch).toNeverIfDisjoint(),\n\t\t\t$ark.intrinsic.unknown.internal\n\t\t)\n\n\t\tif (result.branches.length === 0) {\n\t\t\tthrowParseError(\n\t\t\t\twriteUnsatisfiableExpressionError(`keyof ${this.expression}`)\n\t\t\t)\n\t\t}\n\t\treturn (this._keyof = this.$.finalize(result))\n\t}\n\n\tget props(): Prop.Node[] {\n\t\tif (this.branches.length !== 1)\n\t\t\treturn throwParseError(writeLiteralUnionEntriesMessage(this.expression))\n\t\treturn [...this.applyStructuralOperation(\"props\", [])[0]]\n\t}\n\n\tmerge(r: unknown): BaseRoot {\n\t\tconst rNode = this.$.parseDefinition(r)\n\t\treturn this.$.schema(\n\t\t\trNode.distribute(branch =>\n\t\t\t\tthis.applyStructuralOperation(\"merge\", [\n\t\t\t\t\tstructureOf(branch) ??\n\t\t\t\t\t\tthrowParseError(\n\t\t\t\t\t\t\twriteNonStructuralOperandMessage(\"merge\", branch.expression)\n\t\t\t\t\t\t)\n\t\t\t\t])\n\t\t\t)\n\t\t)\n\t}\n\n\tprivate applyStructuralOperation<operation extends StructuralOperationName>(\n\t\toperation: operation,\n\t\targs: BaseRoot[operation] extends Fn<infer args> ? args : []\n\t): StructuralOperationBranchResultByName[operation][] {\n\t\treturn this.distribute(branch => {\n\t\t\tif (branch.equals($ark.intrinsic.object) && operation !== \"merge\")\n\t\t\t\t// ideally this wouldn't be a special case, but for now it\n\t\t\t\t// allows us to bypass `assertHasKeys` checks on base\n\t\t\t\t// instantiations of generics like Pick and Omit. Could\n\t\t\t\t// potentially be removed once constraints can reference each other:\n\t\t\t\t// https://github.com/arktypeio/arktype/issues/1053\n\t\t\t\treturn branch\n\n\t\t\tconst structure = structureOf(branch)\n\t\t\tif (!structure) {\n\t\t\t\tthrowParseError(\n\t\t\t\t\twriteNonStructuralOperandMessage(operation, branch.expression)\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tif (operation === \"keyof\") return structure.keyof()\n\t\t\tif (operation === \"get\") return structure.get(...(args as [never]))\n\t\t\tif (operation === \"props\") return structure.props\n\n\t\t\tconst structuralMethodName: keyof Structure.Node =\n\t\t\t\toperation === \"required\" ? \"require\"\n\t\t\t\t: operation === \"partial\" ? \"optionalize\"\n\t\t\t\t: operation\n\n\t\t\treturn this.$.node(\"intersection\", {\n\t\t\t\tdomain: \"object\",\n\t\t\t\tstructure: structure[structuralMethodName](...(args as [never]))\n\t\t\t})\n\t\t})\n\t}\n\n\tget(...path: GettableKeyOrNode[]): BaseRoot {\n\t\tif (path[0] === undefined) return this\n\n\t\treturn this.$.schema(this.applyStructuralOperation(\"get\", path)) as never\n\t}\n\n\textract(r: unknown): BaseRoot {\n\t\tconst rNode = this.$.parseDefinition(r)\n\t\treturn this.$.schema(\n\t\t\tthis.branches.filter(branch => branch.extends(rNode))\n\t\t) as never\n\t}\n\n\texclude(r: unknown): BaseRoot {\n\t\tconst rNode = this.$.parseDefinition(r)\n\t\treturn this.$.schema(\n\t\t\tthis.branches.filter(branch => !branch.extends(rNode))\n\t\t) as never\n\t}\n\n\tarray(): BaseRoot {\n\t\treturn this.$.schema(\n\t\t\tthis.isUnknown() ?\n\t\t\t\t{ proto: Array }\n\t\t\t:\t{\n\t\t\t\t\tproto: Array,\n\t\t\t\t\tsequence: this\n\t\t\t\t},\n\t\t\t{ prereduced: true }\n\t\t) as never\n\t}\n\n\toverlaps(r: unknown): boolean {\n\t\tconst intersection = this.intersect(r)\n\t\treturn !(intersection instanceof Disjoint)\n\t}\n\n\textends(r: unknown): boolean {\n\t\tif (this.isNever()) return true\n\n\t\tconst intersection = this.intersect(r)\n\t\treturn (\n\t\t\t!(intersection instanceof Disjoint) && this.equals(intersection as never)\n\t\t)\n\t}\n\n\tifExtends(r: unknown): BaseRoot | undefined {\n\t\treturn this.extends(r) ? this : undefined\n\t}\n\n\tsubsumes(r: unknown): boolean {\n\t\tconst rNode = this.$.parseDefinition(r)\n\t\treturn rNode.extends(this)\n\t}\n\n\tconfigure(\n\t\tmeta: TypeMeta.MappableInput,\n\t\tselector: NodeSelector = \"shallow\"\n\t): this {\n\t\treturn this.configureReferences(meta, selector)\n\t}\n\n\tdescribe(description: string, selector: NodeSelector = \"shallow\"): this {\n\t\treturn this.configure({ description }, selector)\n\t}\n\n\t// these should ideally be implemented in arktype since they use its syntax\n\t// https://github.com/arktypeio/arktype/issues/1223\n\toptional(): [this, \"?\"] {\n\t\treturn [this, \"?\"]\n\t}\n\n\t// these should ideally be implemented in arktype since they use its syntax\n\t// https://github.com/arktypeio/arktype/issues/1223\n\tdefault(thunkableValue: unknown): [this, \"=\", unknown] {\n\t\tassertDefaultValueAssignability(this, thunkableValue, null)\n\n\t\treturn [this, \"=\", thunkableValue]\n\t}\n\n\tfrom(input: unknown): unknown {\n\t\t// ideally we might not validate here but for now we need to do determine\n\t\t// which morphs to apply\n\t\treturn this.assert(input)\n\t}\n\n\tprotected _pipe(...morphs: Morph[]): BaseRoot {\n\t\tconst result = morphs.reduce<BaseRoot>(\n\t\t\t(acc, morph) => acc.rawPipeOnce(morph),\n\t\t\tthis\n\t\t)\n\t\treturn this.$.finalize(result)\n\t}\n\n\tprotected tryPipe(...morphs: Morph[]): BaseRoot {\n\t\tconst result = morphs.reduce<BaseRoot>(\n\t\t\t(acc, morph) =>\n\t\t\t\tacc.rawPipeOnce(\n\t\t\t\t\thasArkKind(morph, \"root\") ? morph : (\n\t\t\t\t\t\t(In, ctx) => {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\treturn morph(In, ctx)\n\t\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\t\treturn ctx.error({\n\t\t\t\t\t\t\t\t\tcode: \"predicate\",\n\t\t\t\t\t\t\t\t\tpredicate: morph as never,\n\t\t\t\t\t\t\t\t\tactual: `aborted due to error:\\n    ${e}\\n`\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\tthis\n\t\t)\n\t\treturn this.$.finalize(result)\n\t}\n\n\tpipe = Object.assign(this._pipe.bind(this), {\n\t\ttry: this.tryPipe.bind(this)\n\t})\n\n\tto(def: unknown): BaseRoot {\n\t\treturn this.$.finalize(this.toNode(this.$.parseDefinition(def)))\n\t}\n\n\tprivate toNode(root: BaseRoot): BaseRoot {\n\t\tconst result = pipeNodesRoot(this, root, this.$)\n\t\tif (result instanceof Disjoint) return result.throw()\n\t\treturn result as BaseRoot\n\t}\n\n\trawPipeOnce(morph: Morph): BaseRoot {\n\t\tif (hasArkKind(morph, \"root\")) return this.toNode(morph)\n\n\t\treturn this.distribute(\n\t\t\tbranch =>\n\t\t\t\tbranch.hasKind(\"morph\") ?\n\t\t\t\t\tthis.$.node(\"morph\", {\n\t\t\t\t\t\tin: branch.inner.in as never,\n\t\t\t\t\t\tmorphs: [...branch.morphs, morph]\n\t\t\t\t\t})\n\t\t\t\t:\tthis.$.node(\"morph\", {\n\t\t\t\t\t\tin: branch,\n\t\t\t\t\t\tmorphs: [morph]\n\t\t\t\t\t}),\n\t\t\tthis.$.parseSchema\n\t\t)\n\t}\n\n\tnarrow(predicate: Predicate): BaseRoot {\n\t\treturn this.constrainOut(\"predicate\", predicate)\n\t}\n\n\tconstrain<kind extends Constraint.PrimitiveKind>(\n\t\tkind: kind,\n\t\tschema: NodeSchema<kind>\n\t): BaseRoot {\n\t\treturn this._constrain(\"root\", kind, schema)\n\t}\n\n\tconstrainIn<kind extends Constraint.PrimitiveKind>(\n\t\tkind: kind,\n\t\tschema: NodeSchema<kind>\n\t): BaseRoot {\n\t\treturn this._constrain(\"in\", kind, schema)\n\t}\n\n\tconstrainOut<kind extends Constraint.PrimitiveKind>(\n\t\tkind: kind,\n\t\tschema: NodeSchema<kind>\n\t): BaseRoot {\n\t\treturn this._constrain(\"out\", kind, schema)\n\t}\n\n\tprivate _constrain(\n\t\tio: \"root\" | \"in\" | \"out\",\n\t\tkind: Constraint.PrimitiveKind,\n\t\tschema: any\n\t): BaseRoot {\n\t\tconst constraint = this.$.node(kind, schema as never)\n\n\t\tif (constraint.isRoot()) {\n\t\t\t// if the node reduces to `unknown`, nothing to do (e.g. minLength: 0)\n\t\t\treturn constraint.isUnknown() ? this : (\n\t\t\t\t\tthrowInternalError(`Unexpected constraint node ${constraint}`)\n\t\t\t\t)\n\t\t}\n\n\t\tconst operand =\n\t\t\tio === \"root\" ? this\n\t\t\t: io === \"in\" ? this.rawIn\n\t\t\t: this.rawOut\n\t\tif (\n\t\t\toperand.hasKind(\"morph\") ||\n\t\t\t(constraint.impliedBasis && !operand.extends(constraint.impliedBasis))\n\t\t) {\n\t\t\treturn throwInvalidOperandError(\n\t\t\t\tkind,\n\t\t\t\tconstraint.impliedBasis as never,\n\t\t\t\tthis as never\n\t\t\t)\n\t\t}\n\n\t\tconst partialIntersection = this.$.node(\"intersection\", {\n\t\t\t// important this is constraint.kind instead of kind in case\n\t\t\t// the node was reduced during parsing\n\t\t\t[constraint.kind]: constraint\n\t\t})\n\n\t\tconst result =\n\t\t\tio === \"out\" ?\n\t\t\t\tpipeNodesRoot(this, partialIntersection, this.$)\n\t\t\t:\tintersectNodesRoot(this, partialIntersection, this.$)\n\n\t\tif (result instanceof Disjoint) result.throw()\n\n\t\treturn this.$.finalize(result as never)\n\t}\n\n\tonUndeclaredKey(cfg: UndeclaredKeyBehavior | UndeclaredKeyConfig): BaseRoot {\n\t\tconst rule = typeof cfg === \"string\" ? cfg : cfg.rule\n\t\tconst deep = typeof cfg === \"string\" ? false : cfg.deep\n\t\treturn this.$.finalize(\n\t\t\tthis.transform(\n\t\t\t\t(kind, inner) =>\n\t\t\t\t\tkind === \"structure\" ?\n\t\t\t\t\t\trule === \"ignore\" ?\n\t\t\t\t\t\t\tomit(inner as Structure.Inner, { undeclared: 1 })\n\t\t\t\t\t\t:\t{ ...inner, undeclared: rule }\n\t\t\t\t\t:\tinner,\n\t\t\t\tdeep ? undefined : (\n\t\t\t\t\t{ shouldTransform: node => !includes(structuralKinds, node.kind) }\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t}\n\n\thasEqualMorphs(r: BaseRoot): boolean {\n\t\tif (!this.includesTransform && !r.includesTransform) return true\n\n\t\tif (!arrayEquals(this.shallowMorphs as Morph[], r.shallowMorphs as Morph[]))\n\t\t\treturn false\n\n\t\tif (\n\t\t\t!arrayEquals(this.flatMorphs, r.flatMorphs, {\n\t\t\t\tisEqual: (l, r) =>\n\t\t\t\t\tl.propString === r.propString &&\n\t\t\t\t\t(l.node.hasKind(\"morph\") && r.node.hasKind(\"morph\") ?\n\t\t\t\t\t\tl.node.hasEqualMorphs(r.node)\n\t\t\t\t\t: l.node.hasKind(\"intersection\") && r.node.hasKind(\"intersection\") ?\n\t\t\t\t\t\tl.node.structure?.structuralMorphRef ===\n\t\t\t\t\t\tr.node.structure?.structuralMorphRef\n\t\t\t\t\t:\tfalse)\n\t\t\t})\n\t\t)\n\t\t\treturn false\n\n\t\treturn true\n\t}\n\n\tonDeepUndeclaredKey(behavior: UndeclaredKeyBehavior): BaseRoot {\n\t\treturn this.onUndeclaredKey({ rule: behavior, deep: true })\n\t}\n\n\tfilter(predicate: Predicate): BaseRoot {\n\t\treturn this.constrainIn(\"predicate\", predicate)\n\t}\n\n\tdivisibleBy(schema: Divisor.Schema): BaseRoot {\n\t\treturn this.constrain(\"divisor\", schema)\n\t}\n\n\tmatching(schema: Pattern.Schema): BaseRoot {\n\t\treturn this.constrain(\"pattern\", schema)\n\t}\n\n\tatLeast(schema: InclusiveNumericRangeSchema): BaseRoot {\n\t\treturn this.constrain(\"min\", schema)\n\t}\n\n\tatMost(schema: InclusiveNumericRangeSchema): BaseRoot {\n\t\treturn this.constrain(\"max\", schema)\n\t}\n\n\tmoreThan(schema: ExclusiveNumericRangeSchema): BaseRoot {\n\t\treturn this.constrain(\"min\", exclusivizeRangeSchema(schema))\n\t}\n\n\tlessThan(schema: ExclusiveNumericRangeSchema): BaseRoot {\n\t\treturn this.constrain(\"max\", exclusivizeRangeSchema(schema))\n\t}\n\n\tatLeastLength(schema: InclusiveNumericRangeSchema): BaseRoot {\n\t\treturn this.constrain(\"minLength\", schema)\n\t}\n\n\tatMostLength(schema: InclusiveNumericRangeSchema): BaseRoot {\n\t\treturn this.constrain(\"maxLength\", schema)\n\t}\n\n\tmoreThanLength(schema: ExclusiveNumericRangeSchema): BaseRoot {\n\t\treturn this.constrain(\"minLength\", exclusivizeRangeSchema(schema))\n\t}\n\n\tlessThanLength(schema: ExclusiveNumericRangeSchema): BaseRoot {\n\t\treturn this.constrain(\"maxLength\", exclusivizeRangeSchema(schema))\n\t}\n\n\texactlyLength(schema: ExactLength.Schema): BaseRoot {\n\t\treturn this.constrain(\"exactLength\", schema)\n\t}\n\n\tatOrAfter(schema: InclusiveDateRangeSchema): BaseRoot {\n\t\treturn this.constrain(\"after\", schema)\n\t}\n\n\tatOrBefore(schema: InclusiveDateRangeSchema): BaseRoot {\n\t\treturn this.constrain(\"before\", schema)\n\t}\n\n\tlaterThan(schema: ExclusiveDateRangeSchema): BaseRoot {\n\t\treturn this.constrain(\"after\", exclusivizeRangeSchema(schema))\n\t}\n\n\tearlierThan(schema: ExclusiveDateRangeSchema): BaseRoot {\n\t\treturn this.constrain(\"before\", exclusivizeRangeSchema(schema))\n\t}\n}\n\nexport type UndeclaredKeyConfig = {\n\trule: UndeclaredKeyBehavior\n\tdeep?: boolean\n}\n\nexport const emptyBrandNameMessage = `Expected a non-empty brand name after #`\n\nexport type emptyBrandNameMessage = typeof emptyBrandNameMessage\n\nconst supportedJsonSchemaTargets: ToJsonSchema.Target[] = [\n\t\"draft-2020-12\",\n\t\"draft-07\"\n]\n\nexport const writeInvalidJsonSchemaTargetMessage = (target: string): string =>\n\t`JSONSchema target '${target}' is not supported (must be ${supportedJsonSchemaTargets.map(t => `\"${t}\"`).join(\" or \")})`\n\nconst validateStandardJsonSchemaTarget = (\n\ttarget: StandardJSONSchemaV1.Target\n): ToJsonSchema.Target => {\n\tif (!includes(supportedJsonSchemaTargets, target))\n\t\tthrowParseError(writeInvalidJsonSchemaTargetMessage(target))\n\n\treturn target\n}\n\nexport const exclusivizeRangeSchema = <schema extends UnknownRangeSchema>(\n\tschema: schema\n): schema =>\n\t(typeof schema === \"object\" && !(schema instanceof Date) ?\n\t\t{ ...schema, exclusive: true }\n\t:\t{\n\t\t\trule: schema,\n\t\t\texclusive: true\n\t\t}) as schema\n\nexport type exclusivizeRangeSchema<schema extends UnknownRangeSchema> =\n\tschema extends LimitSchemaValue ? { rule: schema; exclusive: true } : schema\n\nexport const typeOrTermExtends = (t: unknown, base: unknown): boolean =>\n\thasArkKind(base, \"root\") ?\n\t\thasArkKind(t, \"root\") ? t.extends(base)\n\t\t:\tbase.allows(t)\n\t: hasArkKind(t, \"root\") ? t.hasUnit(base)\n\t: base === t\n\nexport type intersectRoot<l extends RootKind, r extends NodeKind> =\n\t[l, r] extends [r, l] ? l\n\t:\tasymmetricIntersectionOf<l, r> | asymmetricIntersectionOf<r, l>\n\ntype asymmetricIntersectionOf<l extends NodeKind, r extends NodeKind> =\n\tl extends unknown ?\n\t\tr extends kindRightOf<l> ?\n\t\t\tl | reducibleKindOf<l>\n\t\t:\tnever\n\t:\tnever\n\nexport type schemaKindRightOf<kind extends RootKind> = Extract<\n\tkindRightOf<kind>,\n\tRootKind\n>\n\nexport type schemaKindOrRightOf<kind extends RootKind> =\n\t| kind\n\t| schemaKindRightOf<kind>\n\nconst structureOf = (branch: Union.ChildNode): Structure.Node | null => {\n\tif (branch.hasKind(\"morph\")) return null\n\n\tif (branch.hasKind(\"intersection\")) {\n\t\treturn (\n\t\t\tbranch.inner.structure ??\n\t\t\t(branch.basis?.domain === \"object\" ?\n\t\t\t\tbranch.$.bindReference($ark.intrinsic.emptyStructure)\n\t\t\t:\tnull)\n\t\t)\n\t}\n\n\tif (branch.isBasis() && branch.domain === \"object\")\n\t\treturn branch.$.bindReference($ark.intrinsic.emptyStructure)\n\n\treturn null\n}\n\nexport type StructuralOperationBranchResultByName = {\n\tkeyof: Union.ChildNode\n\tpick: Union.ChildNode\n\tomit: Union.ChildNode\n\tget: Union.ChildNode\n\tmap: Union.ChildNode\n\trequired: Union.ChildNode\n\tpartial: Union.ChildNode\n\tmerge: Union.ChildNode\n\tprops: array<Prop.Node>\n}\n\nexport type StructuralOperationName =\n\tkeyof StructuralOperationBranchResultByName\n\nexport const writeLiteralUnionEntriesMessage = (expression: string): string =>\n\t`Props cannot be extracted from a union. Use .distribute to extract props from each branch instead. Received:\n${expression}`\n\nexport const writeNonStructuralOperandMessage = <\n\toperation extends StructuralOperationName,\n\toperand extends string\n>(\n\toperation: operation,\n\toperand: operand\n): writeNonStructuralOperandMessage<operation, operand> =>\n\t`${operation} operand must be an object (was ${operand})`\n\nexport type writeNonStructuralOperandMessage<\n\toperation extends StructuralOperationName,\n\toperand extends string\n> = `${operation} operand must be an object (was ${operand})`\n"
  },
  {
    "path": "ark/schema/roots/union.ts",
    "content": "import {\n\tappendUnique,\n\tarrayEquals,\n\tdomainDescriptions,\n\tflatMorph,\n\tgroupBy,\n\thasKey,\n\tisArray,\n\tjsTypeOfDescriptions,\n\tprintable,\n\trange,\n\tthrowParseError,\n\tunset,\n\ttype JsTypeOf,\n\ttype JsonStructure,\n\ttype SerializedPrimitive,\n\ttype array,\n\ttype show\n} from \"@ark/util\"\nimport type { NodeSchema, RootSchema, nodeOfKind } from \"../kinds.ts\"\nimport type { BaseNode } from \"../node.ts\"\nimport type { BaseScope } from \"../scope.ts\"\nimport {\n\tcompileLiteralPropAccess,\n\tcompileSerializedValue,\n\ttype NodeCompiler\n} from \"../shared/compile.ts\"\nimport type {\n\tBaseErrorContext,\n\tBaseNormalizedSchema,\n\tdeclareNode\n} from \"../shared/declare.ts\"\nimport { Disjoint } from \"../shared/disjoint.ts\"\nimport type { ArkError } from \"../shared/errors.ts\"\nimport {\n\timplementNode,\n\ttype IntersectionContext,\n\ttype RootKind,\n\ttype UnionChildKind,\n\ttype nodeImplementationOf\n} from \"../shared/implement.ts\"\nimport {\n\tintersectNodesRoot,\n\tintersectOrPipeNodes\n} from \"../shared/intersections.ts\"\nimport type { JsonSchema } from \"../shared/jsonSchema.ts\"\nimport {\n\t$ark,\n\tregisteredReference,\n\ttype RegisteredReference\n} from \"../shared/registry.ts\"\nimport type { ToJsonSchema } from \"../shared/toJsonSchema.ts\"\nimport {\n\tTraversal,\n\ttype TraverseAllows,\n\ttype TraverseApply\n} from \"../shared/traversal.ts\"\nimport { hasArkKind } from \"../shared/utils.ts\"\nimport type { Domain } from \"./domain.ts\"\nimport type { Morph } from \"./morph.ts\"\nimport { BaseRoot } from \"./root.ts\"\nimport type { Unit } from \"./unit.ts\"\nimport { defineRightwardIntersections } from \"./utils.ts\"\n\nexport declare namespace Union {\n\texport type ChildKind = UnionChildKind\n\n\texport type ChildSchema = NodeSchema<ChildKind>\n\n\texport type ChildNode = nodeOfKind<ChildKind>\n\n\texport type Schema = NormalizedSchema | readonly RootSchema[]\n\n\texport interface NormalizedSchema extends BaseNormalizedSchema {\n\t\treadonly branches: array<RootSchema>\n\t\treadonly ordered?: true\n\t}\n\n\texport interface Inner {\n\t\treadonly branches: readonly ChildNode[]\n\t\treadonly ordered?: true\n\t}\n\n\texport interface ErrorContext extends BaseErrorContext<\"union\"> {\n\t\terrors: readonly ArkError[]\n\t}\n\n\texport interface Declaration\n\t\textends declareNode<{\n\t\t\tkind: \"union\"\n\t\t\tschema: Schema\n\t\t\tnormalizedSchema: NormalizedSchema\n\t\t\tinner: Inner\n\t\t\terrorContext: ErrorContext\n\t\t\treducibleTo: RootKind\n\t\t\tchildKind: UnionChildKind\n\t\t}> {}\n\n\texport type Node = UnionNode\n}\n\nconst implementation: nodeImplementationOf<Union.Declaration> =\n\timplementNode<Union.Declaration>({\n\t\tkind: \"union\",\n\t\thasAssociatedError: true,\n\t\tcollapsibleKey: \"branches\",\n\t\tkeys: {\n\t\t\tordered: {},\n\t\t\tbranches: {\n\t\t\t\tchild: true,\n\t\t\t\tparse: (schema, ctx) => {\n\t\t\t\t\tconst branches: Union.ChildNode[] = []\n\t\t\t\t\tfor (const branchSchema of schema) {\n\t\t\t\t\t\tconst branchNodes =\n\t\t\t\t\t\t\thasArkKind(branchSchema, \"root\") ?\n\t\t\t\t\t\t\t\tbranchSchema.branches\n\t\t\t\t\t\t\t:\tctx.$.parseSchema(branchSchema).branches\n\t\t\t\t\t\tfor (const node of branchNodes) {\n\t\t\t\t\t\t\tif (node.hasKind(\"morph\")) {\n\t\t\t\t\t\t\t\tconst matchingMorphIndex = branches.findIndex(\n\t\t\t\t\t\t\t\t\tmatching =>\n\t\t\t\t\t\t\t\t\t\tmatching.hasKind(\"morph\") && matching.hasEqualMorphs(node)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tif (matchingMorphIndex === -1) branches.push(node)\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tconst matchingMorph = branches[\n\t\t\t\t\t\t\t\t\t\tmatchingMorphIndex\n\t\t\t\t\t\t\t\t\t] as Morph.Node\n\t\t\t\t\t\t\t\t\tbranches[matchingMorphIndex] = ctx.$.node(\"morph\", {\n\t\t\t\t\t\t\t\t\t\t...matchingMorph.inner,\n\t\t\t\t\t\t\t\t\t\tin: matchingMorph.rawIn.rawOr(node.rawIn)\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else branches.push(node)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!ctx.def.ordered)\n\t\t\t\t\t\tbranches.sort((l, r) => (l.hash < r.hash ? -1 : 1))\n\n\t\t\t\t\treturn branches\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tnormalize: schema => (isArray(schema) ? { branches: schema } : schema),\n\t\treduce: (inner, $) => {\n\t\t\tconst reducedBranches = reduceBranches(inner)\n\t\t\tif (reducedBranches.length === 1) return reducedBranches[0]\n\n\t\t\tif (reducedBranches.length === inner.branches.length) return\n\n\t\t\treturn $.node(\n\t\t\t\t\"union\",\n\t\t\t\t{\n\t\t\t\t\t...inner,\n\t\t\t\t\tbranches: reducedBranches\n\t\t\t\t},\n\t\t\t\t{ prereduced: true }\n\t\t\t)\n\t\t},\n\t\tdefaults: {\n\t\t\tdescription: node =>\n\t\t\t\tnode.distribute(branch => branch.description, describeBranches),\n\t\t\texpected: ctx => {\n\t\t\t\tconst byPath = groupBy(ctx.errors, \"propString\") as Record<\n\t\t\t\t\tstring,\n\t\t\t\t\tArkError[]\n\t\t\t\t>\n\t\t\t\tconst pathDescriptions = Object.entries(byPath).map(\n\t\t\t\t\t([path, errors]) => {\n\t\t\t\t\t\tconst branchesAtPath: string[] = []\n\t\t\t\t\t\tfor (const errorAtPath of errors)\n\t\t\t\t\t\t\tappendUnique(branchesAtPath, errorAtPath.expected)\n\n\t\t\t\t\t\tconst expected = describeBranches(branchesAtPath)\n\t\t\t\t\t\t// if there are multiple actual descriptions that differ,\n\t\t\t\t\t\t// just fall back to printable, which is the most specific\n\t\t\t\t\t\tconst actual =\n\t\t\t\t\t\t\terrors.every(e => e.actual === errors[0].actual) ?\n\t\t\t\t\t\t\t\terrors[0].actual\n\t\t\t\t\t\t\t:\tprintable(errors[0].data)\n\t\t\t\t\t\treturn `${path && `${path} `}must be ${expected}${\n\t\t\t\t\t\t\tactual && ` (was ${actual})`\n\t\t\t\t\t\t}`\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t\treturn describeBranches(pathDescriptions)\n\t\t\t},\n\t\t\tproblem: ctx => ctx.expected,\n\t\t\tmessage: ctx => {\n\t\t\t\tif (ctx.problem[0] === \"[\") {\n\t\t\t\t\t// clarify paths like [1], [0][1], and [\"key!\"] that could be confusing\n\t\t\t\t\treturn `value at ${ctx.problem}`\n\t\t\t\t}\n\n\t\t\t\treturn ctx.problem\n\t\t\t}\n\t\t},\n\t\tintersections: {\n\t\t\tunion: (l, r, ctx) => {\n\t\t\t\tif (l.isNever !== r.isNever) {\n\t\t\t\t\t// if exactly one operand is never, we can use it to discriminate based on presence\n\t\t\t\t\treturn Disjoint.init(\"presence\", l, r)\n\t\t\t\t}\n\t\t\t\tlet resultBranches: readonly Union.ChildNode[] | Disjoint\n\t\t\t\tif (l.ordered) {\n\t\t\t\t\tif (r.ordered) {\n\t\t\t\t\t\tthrowParseError(\n\t\t\t\t\t\t\twriteOrderedIntersectionMessage(l.expression, r.expression)\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\n\t\t\t\t\tresultBranches = intersectBranches(r.branches, l.branches, ctx)\n\t\t\t\t\tif (resultBranches instanceof Disjoint) resultBranches.invert()\n\t\t\t\t} else resultBranches = intersectBranches(l.branches, r.branches, ctx)\n\n\t\t\t\tif (resultBranches instanceof Disjoint) return resultBranches\n\n\t\t\t\treturn ctx.$.parseSchema(\n\t\t\t\t\tl.ordered || r.ordered ?\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tbranches: resultBranches,\n\t\t\t\t\t\t\tordered: true as const\n\t\t\t\t\t\t}\n\t\t\t\t\t:\t{ branches: resultBranches }\n\t\t\t\t)\n\t\t\t},\n\t\t\t...defineRightwardIntersections(\"union\", (l, r, ctx) => {\n\t\t\t\tconst branches = intersectBranches(l.branches, [r], ctx)\n\t\t\t\tif (branches instanceof Disjoint) return branches\n\n\t\t\t\tif (branches.length === 1) return branches[0]\n\n\t\t\t\treturn ctx.$.parseSchema(\n\t\t\t\t\tl.ordered ? { branches, ordered: true } : { branches }\n\t\t\t\t)\n\t\t\t})\n\t\t}\n\t})\n\nexport class UnionNode extends BaseRoot<Union.Declaration> {\n\tisBoolean: boolean =\n\t\tthis.branches.length === 2 &&\n\t\tthis.branches[0].hasUnit(false) &&\n\t\tthis.branches[1].hasUnit(true)\n\n\tget branchGroups(): BaseRoot[] {\n\t\tconst branchGroups: BaseRoot[] = []\n\t\tlet firstBooleanIndex = -1\n\t\tfor (const branch of this.branches) {\n\t\t\tif (branch.hasKind(\"unit\") && branch.domain === \"boolean\") {\n\t\t\t\tif (firstBooleanIndex === -1) {\n\t\t\t\t\tfirstBooleanIndex = branchGroups.length\n\t\t\t\t\tbranchGroups.push(branch)\n\t\t\t\t} else branchGroups[firstBooleanIndex] = $ark.intrinsic.boolean\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tbranchGroups.push(branch)\n\t\t}\n\n\t\treturn branchGroups as never\n\t}\n\n\tunitBranches = this.branches.filter((n): n is Unit.Node | Morph.Node =>\n\t\tn.rawIn.hasKind(\"unit\")\n\t)\n\n\tdiscriminant = this.discriminate()\n\tdiscriminantJson =\n\t\tthis.discriminant ? discriminantToJson(this.discriminant) : null\n\n\texpression: string = this.distribute(\n\t\tn => n.nestableExpression,\n\t\texpressBranches\n\t)\n\n\tcreateBranchedOptimisticRootApply(): BaseNode[\"rootApply\"] {\n\t\treturn (data, onFail) => {\n\t\t\tconst optimisticResult = this.traverseOptimistic(data)\n\t\t\tif (optimisticResult !== unset) return optimisticResult\n\n\t\t\tconst ctx = new Traversal(data, this.$.resolvedConfig)\n\t\t\tthis.traverseApply(data, ctx)\n\t\t\treturn ctx.finalize(onFail)\n\t\t}\n\t}\n\n\tget shallowMorphs(): array<Morph> {\n\t\treturn this.branches.reduce(\n\t\t\t(morphs, branch) => appendUnique(morphs, branch.shallowMorphs),\n\t\t\t[] as Morph[]\n\t\t)\n\t}\n\n\tget defaultShortDescription(): string {\n\t\treturn this.distribute(\n\t\t\tbranch => branch.defaultShortDescription,\n\t\t\tdescribeBranches\n\t\t)\n\t}\n\n\tprotected innerToJsonSchema(ctx: ToJsonSchema.Context): JsonSchema {\n\t\t// special case to simplify { const: true } | { const: false }\n\t\t// to the canonical JSON Schema representation { type: \"boolean\" }\n\t\tif (\n\t\t\tthis.branchGroups.length === 1 &&\n\t\t\tthis.branchGroups[0].equals($ark.intrinsic.boolean)\n\t\t)\n\t\t\treturn { type: \"boolean\" }\n\n\t\tconst jsonSchemaBranches = this.branchGroups.map(group =>\n\t\t\tgroup.toJsonSchemaRecurse(ctx)\n\t\t)\n\n\t\tif (\n\t\t\tjsonSchemaBranches.every(\n\t\t\t\t(branch): branch is JsonSchema.Const =>\n\t\t\t\t\t// iff all branches are pure unit values with no metadata,\n\t\t\t\t\t// we can simplify the representation to an enum\n\t\t\t\t\tObject.keys(branch).length === 1 && hasKey(branch, \"const\")\n\t\t\t)\n\t\t) {\n\t\t\treturn {\n\t\t\t\tenum: jsonSchemaBranches.map(branch => branch.const)\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tanyOf: jsonSchemaBranches\n\t\t}\n\t}\n\n\ttraverseAllows: TraverseAllows = (data, ctx) =>\n\t\tthis.branches.some(b => b.traverseAllows(data, ctx))\n\n\ttraverseApply: TraverseApply = (data, ctx) => {\n\t\tconst errors: ArkError[] = []\n\t\tfor (let i = 0; i < this.branches.length; i++) {\n\t\t\tctx.pushBranch()\n\t\t\tthis.branches[i].traverseApply(data, ctx)\n\t\t\tif (!ctx.hasError()) {\n\t\t\t\tif (this.branches[i].includesTransform)\n\t\t\t\t\treturn ctx.queuedMorphs.push(...ctx.popBranch()!.queuedMorphs)\n\t\t\t\treturn ctx.popBranch()\n\t\t\t}\n\t\t\terrors.push(ctx.popBranch()!.error!)\n\t\t}\n\t\tctx.errorFromNodeContext({ code: \"union\", errors, meta: this.meta })\n\t}\n\n\ttraverseOptimistic = (data: unknown): unknown => {\n\t\tfor (let i = 0; i < this.branches.length; i++) {\n\t\t\tconst branch = this.branches[i]\n\t\t\tif ((branch.traverseAllows as any)(data)) {\n\t\t\t\tif (branch.contextFreeMorph) return branch.contextFreeMorph(data)\n\t\t\t\t// if we're calling this function and the matching branch didn't have\n\t\t\t\t// a context-free morph, it shouldn't have morphs at all\n\t\t\t\treturn data\n\t\t\t}\n\t\t}\n\t\treturn unset\n\t}\n\n\tcompile(js: NodeCompiler): void {\n\t\tif (\n\t\t\t!this.discriminant ||\n\t\t\t// if we have a union of two units like `boolean`, the\n\t\t\t// undiscriminated compilation will be just as fast\n\t\t\t(this.unitBranches.length === this.branches.length &&\n\t\t\t\tthis.branches.length === 2)\n\t\t)\n\t\t\treturn this.compileIndiscriminable(js)\n\n\t\t// we need to access the path as optional so we don't throw if it isn't present\n\t\tlet condition = this.discriminant.optionallyChainedPropString\n\n\t\tif (this.discriminant.kind === \"domain\")\n\t\t\tcondition = `typeof ${condition} === \"object\" ? ${condition} === null ? \"null\" : \"object\" : typeof ${condition} === \"function\" ? \"object\" : typeof ${condition}`\n\n\t\tconst cases = this.discriminant.cases\n\n\t\tconst caseKeys = Object.keys(cases)\n\n\t\tconst { optimistic } = js\n\t\t// only the first layer can be optimistic\n\t\tjs.optimistic = false\n\n\t\tjs.block(`switch(${condition})`, () => {\n\t\t\tfor (const k in cases) {\n\t\t\t\tconst v = cases[k]\n\t\t\t\tconst caseCondition = k === \"default\" ? k : `case ${k}`\n\n\t\t\t\tlet caseResult: string\n\t\t\t\tif (v === true) caseResult = optimistic ? \"data\" : \"true\"\n\t\t\t\telse if (optimistic) {\n\t\t\t\t\tif (v.rootApplyStrategy === \"branchedOptimistic\")\n\t\t\t\t\t\tcaseResult = js.invoke(v, { kind: \"Optimistic\" })\n\t\t\t\t\telse if (v.contextFreeMorph)\n\t\t\t\t\t\tcaseResult = `${js.invoke(v)} ? ${registeredReference(v.contextFreeMorph)}(data) : \"${unset}\"`\n\t\t\t\t\telse caseResult = `${js.invoke(v)} ? data : \"${unset}\"`\n\t\t\t\t} else caseResult = js.invoke(v)\n\n\t\t\t\tjs.line(`${caseCondition}: return ${caseResult}`)\n\t\t\t}\n\t\t\treturn js\n\t\t})\n\n\t\tif (js.traversalKind === \"Allows\") {\n\t\t\tjs.return(optimistic ? `\"${unset}\"` : false)\n\t\t\treturn\n\t\t}\n\n\t\tconst expected = describeBranches(\n\t\t\tthis.discriminant.kind === \"domain\" ?\n\t\t\t\tcaseKeys.map(k => {\n\t\t\t\t\tconst jsTypeOf = k.slice(1, -1) as JsTypeOf\n\t\t\t\t\treturn jsTypeOf === \"function\" ?\n\t\t\t\t\t\t\tdomainDescriptions.object\n\t\t\t\t\t\t:\tdomainDescriptions[jsTypeOf]\n\t\t\t\t})\n\t\t\t:\tcaseKeys\n\t\t)\n\n\t\tconst serializedPathSegments = this.discriminant.path.map(k =>\n\t\t\ttypeof k === \"symbol\" ? registeredReference(k) : JSON.stringify(k)\n\t\t)\n\n\t\tconst serializedExpected = JSON.stringify(expected)\n\t\tconst serializedActual =\n\t\t\tthis.discriminant.kind === \"domain\" ?\n\t\t\t\t`${serializedTypeOfDescriptions}[${condition}]`\n\t\t\t:\t`${serializedPrintable}(${condition})`\n\n\t\tjs.line(`ctx.errorFromNodeContext({\n\tcode: \"predicate\",\n\texpected: ${serializedExpected},\n\tactual: ${serializedActual},\n\trelativePath: [${serializedPathSegments}],\n\tmeta: ${this.compiledMeta}\n})`)\n\t}\n\n\tprivate compileIndiscriminable(js: NodeCompiler): void {\n\t\tif (js.traversalKind === \"Apply\") {\n\t\t\tjs.const(\"errors\", \"[]\")\n\t\t\tfor (const branch of this.branches) {\n\t\t\t\tjs.line(\"ctx.pushBranch()\")\n\t\t\t\t\t.line(js.invoke(branch))\n\t\t\t\t\t.if(\"!ctx.hasError()\", () =>\n\t\t\t\t\t\tjs.return(\n\t\t\t\t\t\t\tbranch.includesTransform ?\n\t\t\t\t\t\t\t\t\"ctx.queuedMorphs.push(...ctx.popBranch().queuedMorphs)\"\n\t\t\t\t\t\t\t:\t\"ctx.popBranch()\"\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t\t.line(\"errors.push(ctx.popBranch().error)\")\n\t\t\t}\n\n\t\t\tjs.line(\n\t\t\t\t`ctx.errorFromNodeContext({ code: \"union\", errors, meta: ${this.compiledMeta} })`\n\t\t\t)\n\t\t} else {\n\t\t\tconst { optimistic } = js\n\t\t\t// only the first layer can be optimistic\n\t\t\tjs.optimistic = false\n\t\t\tfor (const branch of this.branches) {\n\t\t\t\tjs.if(`${js.invoke(branch)}`, () =>\n\t\t\t\t\tjs.return(\n\t\t\t\t\t\toptimistic ?\n\t\t\t\t\t\t\tbranch.contextFreeMorph ?\n\t\t\t\t\t\t\t\t`${registeredReference(branch.contextFreeMorph)}(data)`\n\t\t\t\t\t\t\t:\t\"data\"\n\t\t\t\t\t\t:\ttrue\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tjs.return(optimistic ? `\"${unset}\"` : false)\n\t\t}\n\t}\n\n\tget nestableExpression(): string {\n\t\t// avoid adding unnecessary parentheses around boolean since it's\n\t\t// already collapsed to a single keyword\n\t\treturn this.isBoolean ? \"boolean\" : `(${this.expression})`\n\t}\n\n\tdiscriminate(): Discriminant | null {\n\t\tif (this.branches.length < 2) return null\n\t\tif (this.unitBranches.length === this.branches.length) {\n\t\t\tconst cases = flatMorph(this.unitBranches, (i, n) => [\n\t\t\t\t`${(n.rawIn as Unit.Node).serializedValue}`,\n\t\t\t\tn.hasKind(\"morph\") ? n : (true as const)\n\t\t\t])\n\n\t\t\treturn {\n\t\t\t\tkind: \"unit\",\n\t\t\t\tpath: [],\n\t\t\t\toptionallyChainedPropString: \"data\",\n\t\t\t\tcases\n\t\t\t}\n\t\t}\n\t\tconst candidates: DiscriminantCandidate[] = []\n\t\tfor (let lIndex = 0; lIndex < this.branches.length - 1; lIndex++) {\n\t\t\tconst l = this.branches[lIndex]\n\t\t\tfor (let rIndex = lIndex + 1; rIndex < this.branches.length; rIndex++) {\n\t\t\t\tconst r = this.branches[rIndex]\n\t\t\t\tconst result = intersectNodesRoot(l.rawIn, r.rawIn, l.$)\n\t\t\t\tif (!(result instanceof Disjoint)) continue\n\n\t\t\t\tfor (const entry of result) {\n\t\t\t\t\tif (!entry.kind || entry.optional) continue\n\n\t\t\t\t\tlet lSerialized: string\n\t\t\t\t\tlet rSerialized: string\n\n\t\t\t\t\tif (entry.kind === \"domain\") {\n\t\t\t\t\t\tconst lValue = entry.l as Domain.Node | Domain.Enumerable\n\t\t\t\t\t\tconst rValue = entry.r as Domain.Node | Domain.Enumerable\n\t\t\t\t\t\tlSerialized = `\"${typeof lValue === \"string\" ? lValue : lValue.domain}\"`\n\t\t\t\t\t\trSerialized = `\"${typeof rValue === \"string\" ? rValue : rValue.domain}\"`\n\t\t\t\t\t} else if (entry.kind === \"unit\") {\n\t\t\t\t\t\tlSerialized = (entry.l as Unit.Node).serializedValue\n\t\t\t\t\t\trSerialized = (entry.r as Unit.Node).serializedValue\n\t\t\t\t\t} else continue\n\n\t\t\t\t\tconst matching = candidates.find(\n\t\t\t\t\t\td => arrayEquals(d.path, entry.path) && d.kind === entry.kind\n\t\t\t\t\t)\n\n\t\t\t\t\tif (!matching) {\n\t\t\t\t\t\tcandidates.push({\n\t\t\t\t\t\t\tkind: entry.kind,\n\t\t\t\t\t\t\tcases: {\n\t\t\t\t\t\t\t\t[lSerialized]: {\n\t\t\t\t\t\t\t\t\tbranchIndices: [lIndex],\n\t\t\t\t\t\t\t\t\tcondition: entry.l as never\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t[rSerialized]: {\n\t\t\t\t\t\t\t\t\tbranchIndices: [rIndex],\n\t\t\t\t\t\t\t\t\tcondition: entry.r as never\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tpath: entry.path\n\t\t\t\t\t\t})\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (matching.cases[lSerialized]) {\n\t\t\t\t\t\t\tmatching.cases[lSerialized].branchIndices = appendUnique(\n\t\t\t\t\t\t\t\tmatching.cases[lSerialized].branchIndices,\n\t\t\t\t\t\t\t\tlIndex\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tmatching.cases[lSerialized] ??= {\n\t\t\t\t\t\t\t\tbranchIndices: [lIndex],\n\t\t\t\t\t\t\t\tcondition: entry.l as never\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (matching.cases[rSerialized]) {\n\t\t\t\t\t\t\tmatching.cases[rSerialized].branchIndices = appendUnique(\n\t\t\t\t\t\t\t\tmatching.cases[rSerialized].branchIndices,\n\t\t\t\t\t\t\t\trIndex\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tmatching.cases[rSerialized] ??= {\n\t\t\t\t\t\t\t\tbranchIndices: [rIndex],\n\t\t\t\t\t\t\t\tcondition: entry.r as never\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst viableCandidates =\n\t\t\tthis.ordered ?\n\t\t\t\tviableOrderedCandidates(candidates, this.branches)\n\t\t\t:\tcandidates\n\n\t\tif (!viableCandidates.length) return null\n\n\t\tconst ctx = createCaseResolutionContext(viableCandidates, this)\n\n\t\tconst cases: DiscriminatedCases = {}\n\n\t\tfor (const k in ctx.best.cases) {\n\t\t\tconst resolution = resolveCase(ctx, k)\n\n\t\t\tif (resolution === null) {\n\t\t\t\tcases[k] = true\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// if all the branches ended up back in pruned, we'd loop if we continued\n\t\t\t// so just bail out- nothing left to discriminate\n\t\t\tif (resolution.length === this.branches.length) return null\n\n\t\t\tif (this.ordered) {\n\t\t\t\t// ensure the original order of the pruned branches is preserved\n\t\t\t\tresolution.sort((l, r) => l.originalIndex - r.originalIndex)\n\t\t\t}\n\n\t\t\tconst branches = resolution.map(entry => entry.branch)\n\n\t\t\tconst caseNode =\n\t\t\t\tbranches.length === 1 ?\n\t\t\t\t\tbranches[0]\n\t\t\t\t:\tthis.$.node(\n\t\t\t\t\t\t\"union\",\n\t\t\t\t\t\tthis.ordered ? { branches, ordered: true } : branches\n\t\t\t\t\t)\n\n\t\t\tObject.assign(this.referencesById, caseNode.referencesById)\n\t\t\tcases[k] = caseNode\n\t\t}\n\n\t\tif (ctx.defaultEntries.length) {\n\t\t\t// we don't have to worry about order here as it is always preserved\n\t\t\t// within defaultEntries\n\t\t\tconst branches = ctx.defaultEntries.map(entry => entry.branch)\n\t\t\tcases.default = this.$.node(\n\t\t\t\t\"union\",\n\t\t\t\tthis.ordered ? { branches, ordered: true } : branches,\n\t\t\t\t{\n\t\t\t\t\tprereduced: true\n\t\t\t\t}\n\t\t\t)\n\n\t\t\tObject.assign(this.referencesById, cases.default.referencesById)\n\t\t}\n\n\t\treturn Object.assign(ctx.location, {\n\t\t\tcases\n\t\t})\n\t}\n}\n// New context object to carry discrimination state between functions.\ntype CaseResolutionContext = {\n\tbest: DiscriminantCandidate\n\tlocation: DiscriminantLocation\n\tdefaultEntries: BranchEntry[]\n\tnode: Union.Node\n}\n\ntype BranchEntry = {\n\toriginalIndex: number\n\tbranch: BaseRoot\n}\n\nconst createCaseResolutionContext = (\n\tviableCandidates: DiscriminantCandidate[],\n\tnode: Union.Node\n): CaseResolutionContext => {\n\tconst ordered = viableCandidates.sort((l, r) =>\n\t\tl.path.length === r.path.length ?\n\t\t\tObject.keys(r.cases).length - Object.keys(l.cases).length\n\t\t\t// prefer shorter paths first\n\t\t:\tl.path.length - r.path.length\n\t)\n\n\tconst best = ordered[0]\n\n\tconst location: DiscriminantLocation = {\n\t\tkind: best.kind,\n\t\tpath: best.path,\n\t\toptionallyChainedPropString: optionallyChainPropString(best.path)\n\t}\n\n\tconst defaultEntries = node.branches.map(\n\t\t(branch, originalIndex): BranchEntry => ({\n\t\t\toriginalIndex,\n\t\t\tbranch\n\t\t})\n\t)\n\n\treturn {\n\t\tbest,\n\t\tlocation,\n\t\tdefaultEntries,\n\t\tnode\n\t}\n}\n\nconst resolveCase = (\n\tctx: CaseResolutionContext,\n\tkey: CaseKey\n): BranchEntry[] | null => {\n\tconst caseCtx = ctx.best.cases[key]\n\tconst discriminantNode = discriminantCaseToNode(\n\t\tcaseCtx.condition,\n\t\tctx.location.path,\n\t\tctx.node.$\n\t)\n\n\tlet resolvedEntries: BranchEntry[] | null = []\n\tconst nextDefaults: BranchEntry[] = []\n\n\tfor (let i = 0; i < ctx.defaultEntries.length; i++) {\n\t\tconst entry = ctx.defaultEntries[i]\n\t\tif (caseCtx.branchIndices.includes(entry.originalIndex)) {\n\t\t\tconst pruned = pruneDiscriminant(\n\t\t\t\tctx.node.branches[entry.originalIndex],\n\t\t\t\tctx.location\n\t\t\t)\n\t\t\tif (pruned === null) {\n\t\t\t\t// if any branch of the union has no constraints (i.e. is\n\t\t\t\t// unknown), the others won't affect the resolution type, but could still\n\t\t\t\t// remove additional cases from defaultEntries\n\t\t\t\tresolvedEntries = null\n\t\t\t} else {\n\t\t\t\tresolvedEntries?.push({\n\t\t\t\t\toriginalIndex: entry.originalIndex,\n\t\t\t\t\tbranch: pruned\n\t\t\t\t})\n\t\t\t}\n\t\t} else if (\n\t\t\t// we shouldn't need a special case for alias to avoid the below\n\t\t\t// once alias resolution issues are improved:\n\t\t\t// https://github.com/arktypeio/arktype/issues/1026\n\t\t\tentry.branch.hasKind(\"alias\") &&\n\t\t\tdiscriminantNode.hasKind(\"domain\") &&\n\t\t\tdiscriminantNode.domain === \"object\"\n\t\t)\n\t\t\tresolvedEntries?.push(entry)\n\t\telse {\n\t\t\tif (entry.branch.rawIn.overlaps(discriminantNode)) {\n\t\t\t\t// include cases where an object not including the\n\t\t\t\t// discriminant path might have that value present as an undeclared key\n\t\t\t\tconst overlapping = pruneDiscriminant(entry.branch, ctx.location)!\n\t\t\t\tresolvedEntries?.push({\n\t\t\t\t\toriginalIndex: entry.originalIndex,\n\t\t\t\t\tbranch: overlapping\n\t\t\t\t})\n\t\t\t}\n\t\t\tnextDefaults.push(entry)\n\t\t}\n\t}\n\n\tctx.defaultEntries = nextDefaults\n\treturn resolvedEntries\n}\n\nconst viableOrderedCandidates = (\n\tcandidates: DiscriminantCandidate[],\n\toriginalBranches: readonly Union.ChildNode[]\n): DiscriminantCandidate[] => {\n\tconst viableCandidates = candidates.filter(candidate => {\n\t\tconst caseGroups = Object.values(candidate.cases).map(\n\t\t\tcaseCtx => caseCtx.branchIndices\n\t\t)\n\n\t\t// compare each group against all subsequent groups.\n\t\tfor (let i = 0; i < caseGroups.length - 1; i++) {\n\t\t\tconst currentGroup = caseGroups[i]\n\t\t\tfor (let j = i + 1; j < caseGroups.length; j++) {\n\t\t\t\tconst nextGroup = caseGroups[j]\n\n\t\t\t\t// for each group pair, check for branches whose order was reversed\n\t\t\t\tfor (const currentIndex of currentGroup) {\n\t\t\t\t\tfor (const nextIndex of nextGroup) {\n\t\t\t\t\t\tif (currentIndex > nextIndex) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\toriginalBranches[currentIndex].overlaps(\n\t\t\t\t\t\t\t\t\toriginalBranches[nextIndex]\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t// if the order was not preserved and the branches overlap,\n\t\t\t\t\t\t\t\t// this is not a viable discriminant as it cannot guarantee the same behavior\n\t\t\t\t\t\t\t\treturn false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// branch groups preserved order for non-disjoint pairs and is viable\n\t\treturn true\n\t})\n\n\treturn viableCandidates\n}\n\nconst discriminantCaseToNode = (\n\tcaseDiscriminant: CaseDiscriminant,\n\tpath: PropertyKey[],\n\t$: BaseScope\n): BaseRoot => {\n\tlet node: BaseRoot =\n\t\tcaseDiscriminant === \"undefined\" ? $.node(\"unit\", { unit: undefined })\n\t\t: caseDiscriminant === \"null\" ? $.node(\"unit\", { unit: null })\n\t\t: caseDiscriminant === \"boolean\" ? $.units([true, false])\n\t\t: caseDiscriminant\n\tfor (let i = path.length - 1; i >= 0; i--) {\n\t\tconst key = path[i]\n\t\tnode = $.node(\n\t\t\t\"intersection\",\n\t\t\ttypeof key === \"number\" ?\n\t\t\t\t{\n\t\t\t\t\tproto: \"Array\",\n\t\t\t\t\t// create unknown for preceding elements (could be optimized with safe imports)\n\t\t\t\t\tsequence: [...range(key).map(_ => ({})), node]\n\t\t\t\t}\n\t\t\t:\t{\n\t\t\t\t\tdomain: \"object\",\n\t\t\t\t\trequired: [{ key, value: node }]\n\t\t\t\t}\n\t\t)\n\t}\n\treturn node\n}\n\nconst optionallyChainPropString = (path: PropertyKey[]): string =>\n\tpath.reduce<string>(\n\t\t(acc, k) => acc + compileLiteralPropAccess(k, true),\n\t\t\"data\"\n\t)\n\nconst serializedTypeOfDescriptions = registeredReference(jsTypeOfDescriptions)\n\nconst serializedPrintable = registeredReference(printable)\n\nexport const Union = {\n\timplementation,\n\tNode: UnionNode\n}\n\nconst discriminantToJson = (discriminant: Discriminant): JsonStructure => ({\n\tkind: discriminant.kind,\n\tpath: discriminant.path.map(k =>\n\t\ttypeof k === \"string\" ? k : compileSerializedValue(k)\n\t),\n\tcases: flatMorph(discriminant.cases, (k, node) => [\n\t\tk,\n\t\tnode === true ? node\n\t\t: node.hasKind(\"union\") && node.discriminantJson ? node.discriminantJson\n\t\t: node.json\n\t])\n})\n\ntype DescribeBranchesOptions = {\n\tdelimiter?: string\n\tfinalDelimiter?: string\n}\n\nconst describeExpressionOptions: DescribeBranchesOptions = {\n\tdelimiter: \" | \",\n\tfinalDelimiter: \" | \"\n}\n\nconst expressBranches = (expressions: string[]) =>\n\tdescribeBranches(expressions, describeExpressionOptions)\n\nexport const describeBranches = (\n\tdescriptions: string[],\n\topts?: DescribeBranchesOptions\n): string => {\n\tconst delimiter = opts?.delimiter ?? \", \"\n\tconst finalDelimiter = opts?.finalDelimiter ?? \" or \"\n\n\tif (descriptions.length === 0) return \"never\"\n\n\tif (descriptions.length === 1) return descriptions[0]\n\tif (\n\t\t(descriptions.length === 2 &&\n\t\t\tdescriptions[0] === \"false\" &&\n\t\t\tdescriptions[1] === \"true\") ||\n\t\t(descriptions[0] === \"true\" && descriptions[1] === \"false\")\n\t)\n\t\treturn \"boolean\"\n\n\t// keep track of seen descriptions to avoid duplication\n\tconst seen: Record<string, true | undefined> = {}\n\tconst unique = descriptions.filter(s => (seen[s] ? false : (seen[s] = true)))\n\tconst last = unique.pop()!\n\n\treturn `${unique.join(delimiter)}${unique.length ? finalDelimiter : \"\"}${last}`\n}\n\nexport const intersectBranches = (\n\tl: readonly Union.ChildNode[],\n\tr: readonly Union.ChildNode[],\n\tctx: IntersectionContext\n): readonly Union.ChildNode[] | Disjoint => {\n\t// If the corresponding r branch is identified as a subtype of an l branch, the\n\t// value at rIndex is set to null so we can avoid including previous/future\n\t// intersections in the reduced result.\n\tconst batchesByR: (BaseRoot[] | null)[] = r.map(() => [])\n\tfor (let lIndex = 0; lIndex < l.length; lIndex++) {\n\t\tlet candidatesByR: { [rIndex: number]: BaseRoot } = {}\n\t\tfor (let rIndex = 0; rIndex < r.length; rIndex++) {\n\t\t\tif (batchesByR[rIndex] === null) {\n\t\t\t\t// rBranch is a subtype of an lBranch and\n\t\t\t\t// will not yield any distinct intersection\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (l[lIndex].equals(r[rIndex])) {\n\t\t\t\t// Combination of subtype and supertype cases\n\t\t\t\tbatchesByR[rIndex] = null\n\t\t\t\tcandidatesByR = {}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tconst branchIntersection = intersectOrPipeNodes(l[lIndex], r[rIndex], ctx)\n\t\t\tif (branchIntersection instanceof Disjoint) {\n\t\t\t\t// Doesn't tell us anything useful about their relationships\n\t\t\t\t// with other branches\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (branchIntersection.equals(l[lIndex])) {\n\t\t\t\t// If the current l branch is a subtype of r, intersections\n\t\t\t\t// with previous and remaining branches of r won't lead to\n\t\t\t\t// distinct intersections.\n\t\t\t\tbatchesByR[rIndex]!.push(l[lIndex])\n\t\t\t\tcandidatesByR = {}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (branchIntersection.equals(r[rIndex])) {\n\t\t\t\t// If the current r branch is a subtype of l, set its batch to\n\t\t\t\t// null, removing any previous intersections and preventing any\n\t\t\t\t// of its remaining intersections from being computed.\n\t\t\t\tbatchesByR[rIndex] = null\n\t\t\t} else {\n\t\t\t\t// If neither l nor r is a subtype of the other, add their\n\t\t\t\t// intersection as a candidate (could still be removed if it is\n\t\t\t\t// determined l or r is a subtype of a remaining branch).\n\t\t\t\tcandidatesByR[rIndex] = branchIntersection\n\t\t\t}\n\t\t}\n\t\tfor (const rIndex in candidatesByR) {\n\t\t\t// batchesByR at rIndex should never be null if it is in candidatesByR\n\t\t\tbatchesByR[rIndex]![lIndex] = candidatesByR[rIndex]\n\t\t}\n\t}\n\t// Compile the reduced intersection result, including:\n\t// \t\t1. Remaining candidates resulting from distinct intersections or strict subtypes of r\n\t// \t\t2. Original r branches corresponding to indices with a null batch (subtypes of l)\n\tconst resultBranches = batchesByR.flatMap(\n\t\t// ensure unions returned from branchable intersections like sequence are flattened\n\t\t(batch, i) => batch?.flatMap(branch => branch.branches) ?? r[i]\n\t)\n\treturn resultBranches.length === 0 ?\n\t\t\tDisjoint.init(\"union\", l, r)\n\t\t:\tresultBranches\n}\n\nexport const reduceBranches = ({\n\tbranches,\n\tordered\n}: Union.Inner): readonly Union.ChildNode[] => {\n\tif (branches.length < 2) return branches\n\n\tconst uniquenessByIndex: Record<number, boolean> = branches.map(() => true)\n\tfor (let i = 0; i < branches.length; i++) {\n\t\tfor (\n\t\t\tlet j = i + 1;\n\t\t\tj < branches.length && uniquenessByIndex[i] && uniquenessByIndex[j];\n\t\t\tj++\n\t\t) {\n\t\t\tif (branches[i].equals(branches[j])) {\n\t\t\t\t// if the two branches are equal, only \"j\" is marked as\n\t\t\t\t// redundant so at least one copy could still be included in\n\t\t\t\t// the final set of branches.\n\t\t\t\tuniquenessByIndex[j] = false\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst intersection = intersectNodesRoot(\n\t\t\t\tbranches[i].rawIn,\n\t\t\t\tbranches[j].rawIn,\n\t\t\t\tbranches[0].$\n\t\t\t)!\n\t\t\tif (intersection instanceof Disjoint) continue\n\n\t\t\tif (!ordered) assertDeterminateOverlap(branches[i], branches[j])\n\n\t\t\tif (intersection.equals(branches[i].rawIn)) {\n\t\t\t\t// preserve ordered branches that are a subtype of a subsequent branch\n\t\t\t\tuniquenessByIndex[i] = !!ordered\n\t\t\t} else if (intersection.equals(branches[j].rawIn))\n\t\t\t\tuniquenessByIndex[j] = false\n\t\t}\n\t}\n\treturn branches.filter((_, i) => uniquenessByIndex[i])\n}\n\nconst assertDeterminateOverlap = (l: Union.ChildNode, r: Union.ChildNode) => {\n\tif (!l.includesTransform && !r.includesTransform) return\n\n\tif (!arrayEquals(l.shallowMorphs as Morph[], r.shallowMorphs as Morph[])) {\n\t\tthrowParseError(\n\t\t\twriteIndiscriminableMorphMessage(l.expression, r.expression)\n\t\t)\n\t}\n\n\tif (\n\t\t!arrayEquals(l.flatMorphs, r.flatMorphs, {\n\t\t\tisEqual: (l, r) =>\n\t\t\t\tl.propString === r.propString &&\n\t\t\t\t(l.node.hasKind(\"morph\") && r.node.hasKind(\"morph\") ?\n\t\t\t\t\tl.node.hasEqualMorphs(r.node)\n\t\t\t\t: l.node.hasKind(\"intersection\") && r.node.hasKind(\"intersection\") ?\n\t\t\t\t\tl.node.structure?.structuralMorphRef ===\n\t\t\t\t\tr.node.structure?.structuralMorphRef\n\t\t\t\t:\tfalse)\n\t\t})\n\t) {\n\t\tthrowParseError(\n\t\t\twriteIndiscriminableMorphMessage(l.expression, r.expression)\n\t\t)\n\t}\n}\n\nexport type CaseKey<kind extends DiscriminantKind = DiscriminantKind> =\n\tDiscriminantKind extends kind ? string : DiscriminantKinds[kind] | \"default\"\n\ntype DiscriminantLocation<kind extends DiscriminantKind = DiscriminantKind> = {\n\tpath: PropertyKey[]\n\toptionallyChainedPropString: string\n\tkind: kind\n}\n\nexport interface Discriminant<kind extends DiscriminantKind = DiscriminantKind>\n\textends DiscriminantLocation<kind> {\n\tcases: DiscriminatedCases<kind>\n}\n\ntype DiscriminantCandidate<kind extends DiscriminantKind = DiscriminantKind> = {\n\tpath: PropertyKey[]\n\tkind: kind\n\tcases: CandidateCases<kind>\n}\n\ntype CandidateCases<kind extends DiscriminantKind = DiscriminantKind> = {\n\t[caseKey in CaseKey<kind>]: CaseContext\n}\n\nexport type CaseContext = {\n\tbranchIndices: number[]\n\tcondition: nodeOfKind<DiscriminantKind> | Domain.Enumerable\n}\n\nexport type CaseDiscriminant = nodeOfKind<DiscriminantKind> | Domain.Enumerable\n\nexport type DiscriminatedCases<\n\tkind extends DiscriminantKind = DiscriminantKind\n> = {\n\t[caseKey in CaseKey<kind>]: BaseRoot | true\n}\n\nexport type DiscriminantKinds = {\n\tdomain: Domain\n\tunit: SerializedPrimitive | RegisteredReference\n}\n\nexport type DiscriminantKind = show<keyof DiscriminantKinds>\n\nexport const pruneDiscriminant = (\n\tdiscriminantBranch: BaseRoot,\n\tdiscriminantCtx: DiscriminantLocation\n): BaseRoot | null =>\n\tdiscriminantBranch.transform(\n\t\t(nodeKind, inner) => {\n\t\t\tif (nodeKind === \"domain\" || nodeKind === \"unit\") return null\n\n\t\t\treturn inner\n\t\t},\n\t\t{\n\t\t\tshouldTransform: (node, ctx) => {\n\t\t\t\t// safe to cast here as index nodes are never discriminants\n\t\t\t\tconst propString = optionallyChainPropString(ctx.path as PropertyKey[])\n\n\t\t\t\tif (!discriminantCtx.optionallyChainedPropString.startsWith(propString))\n\t\t\t\t\treturn false\n\n\t\t\t\tif (node.hasKind(\"domain\") && node.domain === \"object\")\n\t\t\t\t\t// if we've already checked a path at least as long as the current one,\n\t\t\t\t\t// we don't need to revalidate that we're in an object\n\t\t\t\t\treturn true\n\n\t\t\t\tif (\n\t\t\t\t\t(node.hasKind(\"domain\") || discriminantCtx.kind === \"unit\") &&\n\t\t\t\t\tpropString === discriminantCtx.optionallyChainedPropString\n\t\t\t\t)\n\t\t\t\t\t// if the discriminant has already checked the domain at the current path\n\t\t\t\t\t// (or a unit literal, implying a domain), we don't need to recheck it\n\t\t\t\t\treturn true\n\n\t\t\t\t// we don't need to recurse into index nodes as they will never\n\t\t\t\t// have a required path therefore can't be used to discriminate\n\t\t\t\treturn node.children.length !== 0 && node.kind !== \"index\"\n\t\t\t}\n\t\t}\n\t)\n\nexport const writeIndiscriminableMorphMessage = (\n\tlDescription: string,\n\trDescription: string\n): string =>\n\t`An unordered union of a type including a morph and a type with overlapping input is indeterminate:\nLeft: ${lDescription}\nRight: ${rDescription}`\n\nexport const writeOrderedIntersectionMessage = (\n\tlDescription: string,\n\trDescription: string\n): string => `The intersection of two ordered unions is indeterminate:\nLeft: ${lDescription}\nRight: ${rDescription}`\n"
  },
  {
    "path": "ark/schema/roots/unit.ts",
    "content": "import {\n\tdomainDescriptions,\n\tdomainOf,\n\tprintable,\n\ttype Domain,\n\ttype JsonPrimitive\n} from \"@ark/util\"\nimport type {\n\tBaseErrorContext,\n\tBaseNormalizedSchema,\n\tdeclareNode\n} from \"../shared/declare.ts\"\nimport { Disjoint } from \"../shared/disjoint.ts\"\nimport {\n\tdefaultValueSerializer,\n\timplementNode,\n\ttype nodeImplementationOf\n} from \"../shared/implement.ts\"\nimport type { JsonSchema } from \"../shared/jsonSchema.ts\"\nimport { $ark } from \"../shared/registry.ts\"\nimport type { ToJsonSchema } from \"../shared/toJsonSchema.ts\"\nimport type { TraverseAllows } from \"../shared/traversal.ts\"\nimport { InternalBasis } from \"./basis.ts\"\nimport type { DomainNode } from \"./domain.ts\"\nimport { defineRightwardIntersections } from \"./utils.ts\"\n\nexport declare namespace Unit {\n\texport interface Schema<value = unknown> extends BaseNormalizedSchema {\n\t\treadonly unit: value\n\t}\n\n\texport interface Inner<value = unknown> {\n\t\treadonly unit: value\n\t}\n\n\texport interface ErrorContext<value = unknown>\n\t\textends BaseErrorContext<\"unit\">,\n\t\t\tInner<value> {}\n\n\texport interface Declaration\n\t\textends declareNode<{\n\t\t\tkind: \"unit\"\n\t\t\tschema: Schema\n\t\t\tnormalizedSchema: Schema\n\t\t\tinner: Inner\n\t\t\terrorContext: ErrorContext\n\t\t}> {}\n\n\texport type Node = UnitNode\n}\n\nconst implementation: nodeImplementationOf<Unit.Declaration> =\n\timplementNode<Unit.Declaration>({\n\t\tkind: \"unit\",\n\t\thasAssociatedError: true,\n\t\tkeys: {\n\t\t\tunit: {\n\t\t\t\tpreserveUndefined: true,\n\t\t\t\tserialize: schema =>\n\t\t\t\t\tschema instanceof Date ?\n\t\t\t\t\t\tschema.toISOString()\n\t\t\t\t\t:\tdefaultValueSerializer(schema)\n\t\t\t}\n\t\t},\n\t\tnormalize: schema => schema,\n\t\tdefaults: {\n\t\t\tdescription: node => printable(node.unit),\n\t\t\tproblem: ({ expected, actual }) =>\n\t\t\t\t`${expected === actual ? `must be reference equal to ${expected} (serialized to the same value)` : `must be ${expected} (was ${actual})`}`\n\t\t},\n\t\tintersections: {\n\t\t\tunit: (l, r) => Disjoint.init(\"unit\", l, r),\n\t\t\t...defineRightwardIntersections(\"unit\", (l, r) => {\n\t\t\t\tif (r.allows(l.unit)) return l\n\n\t\t\t\t// will always be a disjoint at this point, but we try to use\n\t\t\t\t// a domain Disjoint if possible since it's better for discrimination\n\n\t\t\t\tconst rBasis = r.hasKind(\"intersection\") ? r.basis : r\n\t\t\t\tif (rBasis) {\n\t\t\t\t\tconst rDomain =\n\t\t\t\t\t\trBasis.hasKind(\"domain\") ? rBasis : (\n\t\t\t\t\t\t\t($ark.intrinsic.object as DomainNode)\n\t\t\t\t\t\t)\n\t\t\t\t\tif (l.domain !== rDomain.domain) {\n\t\t\t\t\t\tconst lDomainDisjointValue =\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\tl.domain === \"undefined\" ||\n\t\t\t\t\t\t\t\tl.domain === \"null\" ||\n\t\t\t\t\t\t\t\tl.domain === \"boolean\"\n\t\t\t\t\t\t\t) ?\n\t\t\t\t\t\t\t\tl.domain\n\t\t\t\t\t\t\t:\t($ark.intrinsic[l.domain] as DomainNode)\n\t\t\t\t\t\treturn Disjoint.init(\"domain\", lDomainDisjointValue, rDomain)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn Disjoint.init(\n\t\t\t\t\t\"assignability\",\n\t\t\t\t\tl,\n\t\t\t\t\tr.hasKind(\"intersection\") ?\n\t\t\t\t\t\tr.children.find(\n\t\t\t\t\t\t\trConstraint => !rConstraint.allows(l.unit as never)\n\t\t\t\t\t\t)!\n\t\t\t\t\t:\tr\n\t\t\t\t)\n\t\t\t})\n\t\t}\n\t})\n\nexport class UnitNode extends InternalBasis<Unit.Declaration> {\n\tcompiledValue: JsonPrimitive = (this.json as any).unit\n\tserializedValue: string =\n\t\ttypeof this.unit === \"string\" || this.unit instanceof Date ?\n\t\t\tJSON.stringify(this.compiledValue)\n\t\t:\t`${this.compiledValue}`\n\n\tcompiledCondition: string = compileEqualityCheck(\n\t\tthis.unit,\n\t\tthis.serializedValue\n\t)\n\tcompiledNegation: string = compileEqualityCheck(\n\t\tthis.unit,\n\t\tthis.serializedValue,\n\t\t\"negated\"\n\t)\n\texpression: string = printable(this.unit)\n\tdomain: Domain = domainOf(this.unit)\n\n\tget defaultShortDescription(): string {\n\t\treturn this.domain === \"object\" ?\n\t\t\t\tdomainDescriptions.object\n\t\t\t:\tthis.description\n\t}\n\n\tprotected innerToJsonSchema(ctx: ToJsonSchema.Context): JsonSchema {\n\t\treturn (\n\t\t\t// this is the more standard JSON schema representation, especially for Open API\n\t\t\tthis.unit === null ? { type: \"null\" }\n\t\t\t: $ark.intrinsic.jsonPrimitive.allows(this.unit) ? { const: this.unit }\n\t\t\t: ctx.fallback.unit({ code: \"unit\", base: {}, unit: this.unit })\n\t\t)\n\t}\n\n\ttraverseAllows: TraverseAllows =\n\t\tthis.unit instanceof Date ?\n\t\t\tdata => data instanceof Date && data.toISOString() === this.compiledValue\n\t\t: Number.isNaN(this.unit) ? data => Number.isNaN(data)\n\t\t: data => data === this.unit\n}\n\nexport const Unit = {\n\timplementation,\n\tNode: UnitNode\n}\n\nconst compileEqualityCheck = (\n\tunit: unknown,\n\tserializedValue: JsonPrimitive,\n\tnegated?: \"negated\"\n) => {\n\tif (unit instanceof Date) {\n\t\tconst condition = `data instanceof Date && data.toISOString() === ${serializedValue}`\n\t\treturn negated ? `!(${condition})` : condition\n\t}\n\n\tif (Number.isNaN(unit)) return `${negated ? \"!\" : \"\"}Number.isNaN(data)`\n\n\treturn `data ${negated ? \"!\" : \"=\"}== ${serializedValue}`\n}\n"
  },
  {
    "path": "ark/schema/roots/utils.ts",
    "content": "import { flatMorph } from \"@ark/util\"\nimport {\n\tschemaKindsRightOf,\n\ttype RootIntersection,\n\ttype RootKind\n} from \"../shared/implement.ts\"\nimport type { schemaKindRightOf } from \"./root.ts\"\n\nexport const defineRightwardIntersections = <kind extends RootKind>(\n\tkind: kind,\n\timplementation: RootIntersection<kind, schemaKindRightOf<kind>>\n): { [k in schemaKindRightOf<kind>]: RootIntersection<kind, k> } =>\n\tflatMorph(schemaKindsRightOf(kind), (i, kind) => [\n\t\tkind,\n\t\timplementation\n\t]) as never\n"
  },
  {
    "path": "ark/schema/scope.ts",
    "content": "import {\n\tParseError,\n\tflatMorph,\n\thasDomain,\n\tisArray,\n\tisThunk,\n\tprintable,\n\tthrowInternalError,\n\tthrowParseError,\n\ttype Dict,\n\ttype Fn,\n\ttype Hkt,\n\ttype JsonStructure,\n\ttype anyOrNever,\n\ttype array,\n\ttype conform,\n\ttype flattenListable,\n\ttype intersectUnion,\n\ttype listable,\n\ttype noSuggest,\n\ttype satisfy,\n\ttype show\n} from \"@ark/util\"\nimport {\n\tmergeConfigs,\n\ttype ArkSchemaConfig,\n\ttype ResolvedConfig\n} from \"./config.ts\"\nimport {\n\tGenericRoot,\n\tLazyGenericBody,\n\ttype GenericRootParser\n} from \"./generic.ts\"\nimport {\n\tnodeImplementationsByKind,\n\ttype NodeSchema,\n\ttype RootSchema,\n\ttype nodeOfKind,\n\ttype reducibleKindOf\n} from \"./kinds.ts\"\nimport {\n\tRootModule,\n\tbindModule,\n\ttype InternalModule,\n\ttype PreparsedNodeResolution,\n\ttype SchemaModule,\n\ttype instantiateRoot\n} from \"./module.ts\"\nimport type { BaseNode } from \"./node.ts\"\nimport {\n\tnodesByRegisteredId,\n\tparseNode,\n\tregisterNodeId,\n\tschemaKindOf,\n\twithId,\n\ttype AttachedParseContext,\n\ttype BaseParseContext,\n\ttype BaseParseContextInput,\n\ttype BaseParseOptions,\n\ttype NodeId,\n\ttype NodeParseContext,\n\ttype NodeParseContextInput\n} from \"./parse.ts\"\nimport { Alias } from \"./roots/alias.ts\"\nimport type { BaseRoot } from \"./roots/root.ts\"\nimport type { UnionNode } from \"./roots/union.ts\"\nimport { CompiledFunction, NodeCompiler } from \"./shared/compile.ts\"\nimport type { NodeKind, RootKind } from \"./shared/implement.ts\"\nimport { $ark } from \"./shared/registry.ts\"\nimport {\n\tTraversal,\n\ttype TraverseAllows,\n\ttype TraverseApply\n} from \"./shared/traversal.ts\"\nimport { arkKind, hasArkKind, isNode } from \"./shared/utils.ts\"\n\nexport type InternalResolutions = Record<string, InternalResolution | undefined>\n\nexport type exportedNameOf<$> = Exclude<keyof $ & string, PrivateDeclaration>\n\nexport type resolvableReferenceIn<$> = {\n\t[k in keyof $]: k extends string ?\n\t\tk extends PrivateDeclaration<infer alias> ? alias\n\t\t: // technically, root subtypes are resolvable, but there's never a good\n\t\t// reason to use them over the base alias\n\t\tk extends noSuggest | \"root\" ? never\n\t\t: k\n\t:\tnever\n}[keyof $]\n\nexport type resolveReference<reference extends resolvableReferenceIn<$>, $> =\n\treference extends keyof $ ? $[reference] : $[`#${reference}` & keyof $]\n\nexport type flatResolutionsOf<$> = show<\n\tintersectUnion<\n\t\tresolvableReferenceIn<$> extends infer k ?\n\t\t\tk extends keyof $ & string ?\n\t\t\t\tresolutionsOfReference<k, $[k]>\n\t\t\t:\tunknown\n\t\t:\tunknown\n\t>\n>\n\ntype resolutionsOfReference<k extends string, v> =\n\t[v] extends [{ [arkKind]: \"module\" }] ?\n\t\t[v] extends [anyOrNever] ?\n\t\t\t{ [_ in k]: v }\n\t\t:\tprefixKeys<flatResolutionsOf<v>, k> & {\n\t\t\t\t[innerKey in keyof v as innerKey extends \"root\" ? k\n\t\t\t\t:\tnever]: v[innerKey]\n\t\t\t}\n\t:\t{ [_ in k]: v }\n\ntype prefixKeys<o, prefix extends string> = {\n\t[k in keyof o & string as `${prefix}.${k}`]: o[k]\n} & unknown\n\nexport type PrivateDeclaration<key extends string = string> = `#${key}`\n\nexport type InternalResolution = BaseRoot | GenericRoot | InternalModule\n\nexport type toInternalScope<$> = BaseScope<{\n\t[k in keyof $]: $[k] extends { [arkKind]: infer kind } ?\n\t\t[$[k]] extends [anyOrNever] ? BaseRoot\n\t\t: kind extends \"generic\" ? GenericRoot\n\t\t: kind extends \"module\" ? InternalModule\n\t\t: never\n\t:\tBaseRoot\n}>\n\ntype CachedResolution = NodeId | BaseRoot | GenericRoot\n\nconst schemaBranchesOf = (schema: object) =>\n\tisArray(schema) ? schema\n\t: \"branches\" in schema && isArray(schema.branches) ? schema.branches\n\t: undefined\n\nconst throwMismatchedNodeRootError = (expected: NodeKind, actual: NodeKind) =>\n\tthrowParseError(\n\t\t`Node of kind ${actual} is not valid as a ${expected} definition`\n\t)\n\nexport const writeDuplicateAliasError = <alias extends string>(\n\talias: alias\n): writeDuplicateAliasError<alias> =>\n\t`#${alias} duplicates public alias ${alias}`\n\nexport type writeDuplicateAliasError<alias extends string> =\n\t`#${alias} duplicates public alias ${alias}`\n\nexport type AliasDefEntry = [name: string, defValue: unknown]\n\nconst scopesByName: Record<string, BaseScope | undefined> = {}\n\nexport type GlobalOnlyConfigOptionName = satisfy<\n\tkeyof ArkSchemaConfig,\n\t\"dateAllowsInvalid\" | \"numberAllowsNaN\" | \"onUndeclaredKey\" | \"keywords\"\n>\n\nexport interface ScopeOnlyConfigOptions {\n\tname?: string\n\tprereducedAliases?: boolean\n}\n\nexport interface ArkSchemaScopeConfig\n\textends Omit<ArkSchemaConfig, GlobalOnlyConfigOptionName>,\n\t\tScopeOnlyConfigOptions {}\n\nexport interface ResolvedScopeConfig\n\textends ResolvedConfig,\n\t\tScopeOnlyConfigOptions {}\n\n$ark.ambient ??= {} as never\n\nlet rawUnknownUnion: UnionNode | undefined\n\nconst rootScopeFnName = \"function $\"\n\nconst precompile = (references: readonly BaseNode[]): void =>\n\tbindPrecompilation(references, precompileReferences(references))\n\nconst bindPrecompilation = (\n\treferences: readonly BaseNode[],\n\tprecompiler: CompiledFunction<() => PrecompiledReferences>\n): void => {\n\tconst precompilation = precompiler.write(rootScopeFnName, 4)\n\tconst compiledTraversals = precompiler.compile()()\n\n\tfor (const node of references) {\n\t\tif (node.precompilation) {\n\t\t\t// if node has already been bound to another scope or anonymous type, don't rebind it\n\t\t\tcontinue\n\t\t}\n\t\tnode.traverseAllows =\n\t\t\tcompiledTraversals[`${node.id}Allows`].bind(compiledTraversals)\n\t\tif (node.isRoot() && !node.allowsRequiresContext) {\n\t\t\t// if the reference doesn't require context, we can assign over\n\t\t\t// it directly to avoid having to initialize it\n\t\t\tnode.allows = node.traverseAllows as never\n\t\t}\n\t\tnode.traverseApply =\n\t\t\tcompiledTraversals[`${node.id}Apply`].bind(compiledTraversals)\n\n\t\tif (compiledTraversals[`${node.id}Optimistic`]) {\n\t\t\t;(node as UnionNode).traverseOptimistic =\n\t\t\t\tcompiledTraversals[`${node.id}Optimistic`].bind(compiledTraversals)\n\t\t}\n\t\tnode.precompilation = precompilation\n\t}\n}\n\nexport type PrecompiledReferences = {\n\t[k: `${string}Allows`]: TraverseAllows\n\t[k: `${string}Apply`]: TraverseApply\n\t[k: `${string}Optimistic`]: (data: unknown) => unknown\n}\n\nconst precompileReferences = (references: readonly BaseNode[]) =>\n\tnew CompiledFunction<() => PrecompiledReferences>().return(\n\t\treferences.reduce((js, node) => {\n\t\t\tconst allowsCompiler = new NodeCompiler({ kind: \"Allows\" }).indent()\n\t\t\tnode.compile(allowsCompiler)\n\t\t\tconst allowsJs = allowsCompiler.write(`${node.id}Allows`)\n\n\t\t\tconst applyCompiler = new NodeCompiler({ kind: \"Apply\" }).indent()\n\t\t\tnode.compile(applyCompiler)\n\t\t\tconst applyJs = applyCompiler.write(`${node.id}Apply`)\n\n\t\t\tconst result = `${js}${allowsJs},\\n${applyJs},\\n`\n\n\t\t\tif (!node.hasKind(\"union\")) return result\n\n\t\t\tconst optimisticCompiler = new NodeCompiler({\n\t\t\t\tkind: \"Allows\",\n\t\t\t\toptimistic: true\n\t\t\t}).indent()\n\t\t\tnode.compile(optimisticCompiler)\n\t\t\tconst optimisticJs = optimisticCompiler.write(`${node.id}Optimistic`)\n\n\t\t\treturn `${result}${optimisticJs},\\n`\n\t\t}, \"{\\n\") + \"}\"\n\t)\n\nexport abstract class BaseScope<$ extends {} = {}> {\n\treadonly config: ArkSchemaScopeConfig\n\treadonly resolvedConfig: ResolvedScopeConfig\n\treadonly name: string\n\n\tget [arkKind](): \"scope\" {\n\t\treturn \"scope\"\n\t}\n\n\treadonly referencesById: { [id: string]: BaseNode } = {}\n\treferences: readonly BaseNode[] = []\n\treadonly resolutions: {\n\t\t[alias: string]: CachedResolution | undefined\n\t} = {}\n\n\texportedNames: string[] = []\n\treadonly aliases: Record<string, unknown> = {}\n\tprotected resolved = false\n\treadonly nodesByHash: Record<string, BaseNode> = {}\n\treadonly intrinsic: Omit<typeof $ark.intrinsic, `json${string}`>\n\n\tconstructor(\n\t\t/** The set of names defined at the root-level of the scope mapped to their\n\t\t * corresponding definitions.**/\n\t\tdef: Record<string, unknown>,\n\t\tconfig?: ArkSchemaScopeConfig\n\t) {\n\t\tthis.config = mergeConfigs($ark.config, config)\n\n\t\tthis.resolvedConfig = mergeConfigs($ark.resolvedConfig, config)\n\n\t\tthis.name =\n\t\t\tthis.resolvedConfig.name ??\n\t\t\t`anonymousScope${Object.keys(scopesByName).length}`\n\t\tif (this.name in scopesByName)\n\t\t\tthrowParseError(`A Scope already named ${this.name} already exists`)\n\t\tscopesByName[this.name] = this\n\n\t\tconst aliasEntries = Object.entries(def).map(entry =>\n\t\t\tthis.preparseOwnAliasEntry(...entry)\n\t\t)\n\n\t\tfor (const [k, v] of aliasEntries) {\n\t\t\tlet name = k\n\t\t\tif (k[0] === \"#\") {\n\t\t\t\tname = k.slice(1)\n\t\t\t\tif (name in this.aliases)\n\t\t\t\t\tthrowParseError(writeDuplicateAliasError(name))\n\t\t\t\tthis.aliases[name] = v\n\t\t\t} else {\n\t\t\t\tif (name in this.aliases) throwParseError(writeDuplicateAliasError(k))\n\t\t\t\tthis.aliases[name] = v\n\t\t\t\tthis.exportedNames.push(name)\n\t\t\t}\n\t\t\tif (\n\t\t\t\t!hasArkKind(v, \"module\") &&\n\t\t\t\t!hasArkKind(v, \"generic\") &&\n\t\t\t\t!isThunk(v)\n\t\t\t) {\n\t\t\t\tconst preparsed = this.preparseOwnDefinitionFormat(v, { alias: name })\n\t\t\t\tthis.resolutions[name] =\n\t\t\t\t\thasArkKind(preparsed, \"root\") ?\n\t\t\t\t\t\tthis.bindReference(preparsed)\n\t\t\t\t\t:\tthis.createParseContext(preparsed).id\n\t\t\t}\n\t\t}\n\n\t\t// reduce union of all possible values reduces to unknown\n\t\trawUnknownUnion ??= this.node(\n\t\t\t\"union\",\n\t\t\t{\n\t\t\t\tbranches: [\n\t\t\t\t\t\"string\",\n\t\t\t\t\t\"number\",\n\t\t\t\t\t\"object\",\n\t\t\t\t\t\"bigint\",\n\t\t\t\t\t\"symbol\",\n\t\t\t\t\t{ unit: true },\n\t\t\t\t\t{ unit: false },\n\t\t\t\t\t{ unit: undefined },\n\t\t\t\t\t{ unit: null }\n\t\t\t\t]\n\t\t\t},\n\t\t\t{ prereduced: true }\n\t\t)\n\n\t\tthis.nodesByHash[rawUnknownUnion.hash] = this.node(\n\t\t\t\"intersection\",\n\t\t\t{},\n\t\t\t{ prereduced: true }\n\t\t)\n\n\t\tthis.intrinsic =\n\t\t\t$ark.intrinsic ?\n\t\t\t\tflatMorph($ark.intrinsic, (k, v) =>\n\t\t\t\t\t// don't include cyclic aliases from JSON scope\n\t\t\t\t\tk.startsWith(\"json\") ? [] : [k, this.bindReference(v as never)]\n\t\t\t\t)\n\t\t\t\t// intrinsic won't be available during bootstrapping,  so we lie\n\t\t\t\t// about the type here as an extrnal convenience\n\t\t\t:\t({} as never)\n\t}\n\n\tprotected cacheGetter<name extends keyof this>(\n\t\tname: name,\n\t\tvalue: this[name]\n\t): this[name] {\n\t\tObject.defineProperty(this, name, { value })\n\t\treturn value\n\t}\n\n\tget internal(): this {\n\t\treturn this\n\t}\n\n\t// json is populated when the scope is exported, so ensure it is populated\n\t// before allowing external access\n\tprivate _json: JsonStructure | undefined\n\tget json(): JsonStructure {\n\t\tif (!this._json) this.export()\n\t\treturn this._json!\n\t}\n\n\tdefineSchema<def extends RootSchema>(def: def): def {\n\t\treturn def\n\t}\n\n\tgeneric: GenericRootParser = (...params) => {\n\t\tconst $: BaseScope = this as never\n\t\treturn (def: unknown, possibleHkt?: Hkt.constructor) =>\n\t\t\tnew GenericRoot(\n\t\t\t\tparams,\n\t\t\t\tpossibleHkt ? new LazyGenericBody(def as Fn) : def,\n\t\t\t\t$,\n\t\t\t\t$,\n\t\t\t\tpossibleHkt ?? null\n\t\t\t) as never\n\t}\n\n\tunits = (values: array, opts?: BaseParseOptions): BaseRoot => {\n\t\tconst uniqueValues: unknown[] = []\n\t\tfor (const value of values)\n\t\t\tif (!uniqueValues.includes(value)) uniqueValues.push(value)\n\n\t\tconst branches = uniqueValues.map(unit => this.node(\"unit\", { unit }, opts))\n\t\treturn this.node(\"union\", branches, {\n\t\t\t...opts,\n\t\t\tprereduced: true\n\t\t})\n\t}\n\n\tprotected lazyResolutions: Alias.Node[] = []\n\tlazilyResolve(resolve: () => BaseRoot, syntheticAlias?: string): Alias.Node {\n\t\tconst node = this.node(\n\t\t\t\"alias\",\n\t\t\t{\n\t\t\t\treference: syntheticAlias ?? \"synthetic\",\n\t\t\t\tresolve\n\t\t\t},\n\t\t\t{ prereduced: true }\n\t\t)\n\t\tif (!this.resolved) this.lazyResolutions.push(node)\n\t\treturn node\n\t}\n\n\tschema: InternalSchemaParser = (schema, opts) =>\n\t\tthis.finalize(this.parseSchema(schema, opts))\n\n\tparseSchema: InternalSchemaParser = (schema, opts) =>\n\t\tthis.node(schemaKindOf(schema), schema, opts)\n\n\tprotected preparseNode(\n\t\tkinds: NodeKind | listable<RootKind>,\n\t\tschema: unknown,\n\t\topts: BaseParseOptions\n\t): BaseNode | NodeParseContextInput {\n\t\tlet kind: NodeKind =\n\t\t\ttypeof kinds === \"string\" ? kinds : schemaKindOf(schema, kinds)\n\n\t\tif (isNode(schema) && schema.kind === kind) return schema\n\n\t\tif (kind === \"alias\" && !opts?.prereduced) {\n\t\t\tconst { reference } = Alias.implementation.normalize(\n\t\t\t\tschema as never,\n\t\t\t\tthis\n\t\t\t)\n\t\t\tif (reference.startsWith(\"$\")) {\n\t\t\t\tconst resolution = this.resolveRoot(reference.slice(1))\n\t\t\t\tschema = resolution\n\t\t\t\tkind = resolution.kind\n\t\t\t}\n\t\t} else if (kind === \"union\" && hasDomain(schema, \"object\")) {\n\t\t\tconst branches = schemaBranchesOf(schema)\n\t\t\tif (branches?.length === 1) {\n\t\t\t\tschema = branches[0]\n\t\t\t\tkind = schemaKindOf(schema)\n\t\t\t}\n\t\t}\n\n\t\tif (isNode(schema) && schema.kind === kind) return schema\n\n\t\tconst impl = nodeImplementationsByKind[kind]\n\t\tconst normalizedSchema = impl.normalize?.(schema, this) ?? schema\n\n\t\t// check again after normalization in case a node is a valid collapsed\n\t\t// schema for the kind (e.g. sequence can collapse to element accepting a Node')\n\t\tif (isNode(normalizedSchema)) {\n\t\t\treturn normalizedSchema.kind === kind ?\n\t\t\t\t\tnormalizedSchema\n\t\t\t\t:\tthrowMismatchedNodeRootError(kind, normalizedSchema.kind)\n\t\t}\n\n\t\treturn {\n\t\t\t...opts,\n\t\t\t$: this,\n\t\t\tkind,\n\t\t\tdef: normalizedSchema,\n\t\t\tprefix: opts.alias ?? kind\n\t\t}\n\t}\n\n\tbindReference<reference extends BaseNode | GenericRoot>(\n\t\treference: reference\n\t): reference {\n\t\tlet bound: reference\n\n\t\tif (isNode(reference)) {\n\t\t\tbound =\n\t\t\t\treference.$ === this ?\n\t\t\t\t\treference\n\t\t\t\t:\tnew (reference.constructor as any)(reference.attachments, this)\n\t\t} else {\n\t\t\tbound =\n\t\t\t\treference.$ === this ?\n\t\t\t\t\treference\n\t\t\t\t:\t(new GenericRoot(\n\t\t\t\t\t\treference.params as never,\n\t\t\t\t\t\treference.bodyDef,\n\t\t\t\t\t\treference.$,\n\t\t\t\t\t\tthis as never,\n\t\t\t\t\t\treference.hkt\n\t\t\t\t\t) as never)\n\t\t}\n\n\t\tif (!this.resolved) {\n\t\t\t// we're still parsing the scope itself, so defer compilation but\n\t\t\t// add the node as a reference\n\t\t\tObject.assign(this.referencesById, bound.referencesById)\n\t\t}\n\n\t\treturn bound as never\n\t}\n\n\tresolveRoot(name: string): BaseRoot {\n\t\treturn (\n\t\t\tthis.maybeResolveRoot(name) ??\n\t\t\tthrowParseError(writeUnresolvableMessage(name))\n\t\t)\n\t}\n\n\tmaybeResolveRoot(name: string): BaseRoot | undefined {\n\t\tconst result = this.maybeResolve(name)\n\t\tif (hasArkKind(result, \"generic\")) return\n\t\treturn result\n\t}\n\n\t/** If name is a valid reference to a submodule alias, return its resolution  */\n\tprotected maybeResolveSubalias(\n\t\tname: string\n\t): BaseRoot | GenericRoot | undefined {\n\t\treturn (\n\t\t\tmaybeResolveSubalias(this.aliases, name) ??\n\t\t\tmaybeResolveSubalias(this.ambient, name)\n\t\t)\n\t}\n\n\tget ambient(): InternalModule {\n\t\treturn $ark.ambient as never\n\t}\n\n\tmaybeResolve(name: string): Exclude<CachedResolution, string> | undefined {\n\t\tconst cached = this.resolutions[name]\n\t\tif (cached) {\n\t\t\tif (typeof cached !== \"string\") return this.bindReference(cached)\n\n\t\t\tconst v = nodesByRegisteredId[cached]\n\t\t\tif (hasArkKind(v, \"root\")) return (this.resolutions[name] = v)\n\t\t\tif (hasArkKind(v, \"context\")) {\n\t\t\t\tif (v.phase === \"resolving\") {\n\t\t\t\t\treturn this.node(\n\t\t\t\t\t\t\"alias\",\n\t\t\t\t\t\t{ reference: `$${name}` },\n\t\t\t\t\t\t{ prereduced: true }\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (v.phase === \"resolved\") {\n\t\t\t\t\treturn throwInternalError(\n\t\t\t\t\t\t`Unexpected resolved context for was uncached by its scope: ${printable(v)}`\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tv.phase = \"resolving\"\n\t\t\t\tconst node = this.bindReference(this.parseOwnDefinitionFormat(v.def, v))\n\t\t\t\tv.phase = \"resolved\"\n\t\t\t\tnodesByRegisteredId[node.id] = node\n\t\t\t\tnodesByRegisteredId[v.id] = node\n\t\t\t\treturn (this.resolutions[name] = node)\n\t\t\t}\n\t\t\treturn throwInternalError(\n\t\t\t\t`Unexpected nodesById entry for ${cached}: ${printable(v)}`\n\t\t\t)\n\t\t}\n\t\tlet def: unknown = this.aliases[name] ?? this.ambient?.[name]\n\n\t\tif (!def) return this.maybeResolveSubalias(name)\n\n\t\tdef = this.normalizeRootScopeValue(def)\n\n\t\tif (hasArkKind(def, \"generic\"))\n\t\t\treturn (this.resolutions[name] = this.bindReference(def))\n\n\t\tif (hasArkKind(def, \"module\")) {\n\t\t\tif (!def.root) throwParseError(writeMissingSubmoduleAccessMessage(name))\n\t\t\treturn (this.resolutions[name] = this.bindReference(def.root))\n\t\t}\n\n\t\treturn (this.resolutions[name] = this.parse(def, {\n\t\t\talias: name\n\t\t}))\n\t}\n\n\tprotected createParseContext<input extends BaseParseContextInput>(\n\t\tinput: input\n\t): input & AttachedParseContext {\n\t\tconst id = input.id ?? registerNodeId(input.prefix)\n\t\treturn (nodesByRegisteredId[id] = Object.assign(input, {\n\t\t\t[arkKind]: \"context\" as const,\n\t\t\t$: this as never,\n\t\t\tid,\n\t\t\tphase: \"unresolved\" as const\n\t\t}))\n\t}\n\n\ttraversal(root: unknown): Traversal {\n\t\treturn new Traversal(root, this.resolvedConfig)\n\t}\n\n\timport(): SchemaModule<{\n\t\t[k in exportedNameOf<$> as PrivateDeclaration<k>]: $[k]\n\t}>\n\timport<names extends exportedNameOf<$>[]>(\n\t\t...names: names\n\t): SchemaModule<\n\t\t{\n\t\t\t[k in names[number] as PrivateDeclaration<k>]: $[k]\n\t\t} & unknown\n\t>\n\timport(...names: string[]): SchemaModule {\n\t\treturn new RootModule(\n\t\t\tflatMorph(this.export(...(names as any)), (alias, value) => [\n\t\t\t\t`#${alias}`,\n\t\t\t\tvalue\n\t\t\t]) as never\n\t\t) as never\n\t}\n\n\tprecompilation: string | undefined\n\n\tprivate _exportedResolutions: InternalResolutions | undefined\n\tprivate _exports: RootExportCache | undefined\n\texport(): SchemaModule<{ [k in exportedNameOf<$>]: $[k] }>\n\texport<names extends exportedNameOf<$>[]>(\n\t\t...names: names\n\t): SchemaModule<\n\t\t{\n\t\t\t[k in names[number]]: $[k]\n\t\t} & unknown\n\t>\n\texport(...names: string[]): SchemaModule {\n\t\tif (!this._exports) {\n\t\t\tthis._exports = {}\n\t\t\tfor (const name of this.exportedNames) {\n\t\t\t\tconst def = this.aliases[name]\n\t\t\t\tthis._exports[name] =\n\t\t\t\t\thasArkKind(def, \"module\") ?\n\t\t\t\t\t\tbindModule(def, this)\n\t\t\t\t\t:\tbootstrapAliasReferences(this.maybeResolve(name)!)\n\t\t\t}\n\n\t\t\t// force node.resolution getter evaluation\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unused-expressions\n\t\t\tfor (const node of this.lazyResolutions) node.resolution\n\n\t\t\tthis._exportedResolutions = resolutionsOfModule(this, this._exports)\n\n\t\t\tthis._json = resolutionsToJson(this._exportedResolutions)\n\t\t\tObject.assign(this.resolutions, this._exportedResolutions)\n\n\t\t\tthis.references = Object.values(this.referencesById)\n\t\t\tif (!this.resolvedConfig.jitless) {\n\t\t\t\tconst precompiler = precompileReferences(this.references)\n\t\t\t\tthis.precompilation = precompiler.write(rootScopeFnName, 4)\n\t\t\t\tbindPrecompilation(this.references, precompiler)\n\t\t\t}\n\t\t\tthis.resolved = true\n\t\t}\n\t\tconst namesToExport = names.length ? names : this.exportedNames\n\t\treturn new RootModule(\n\t\t\tflatMorph(namesToExport, (_, name) => [\n\t\t\t\tname,\n\t\t\t\tthis._exports![name]\n\t\t\t]) as never\n\t\t) as never\n\t}\n\n\tresolve<name extends exportedNameOf<$>>(\n\t\tname: name\n\t): instantiateRoot<$[name]> {\n\t\treturn this.export()[name as never]\n\t}\n\n\tnode = <\n\t\tkinds extends NodeKind | array<RootKind>,\n\t\tprereduced extends boolean = false\n\t>(\n\t\tkinds: kinds,\n\t\tnodeSchema: NodeSchema<flattenListable<kinds>>,\n\t\topts = {} as BaseParseOptions<prereduced>\n\t): nodeOfKind<\n\t\tprereduced extends true ? flattenListable<kinds>\n\t\t:\treducibleKindOf<flattenListable<kinds>>\n\t> => {\n\t\tconst ctxOrNode = this.preparseNode(kinds, nodeSchema, opts)\n\n\t\tif (isNode(ctxOrNode)) return this.bindReference(ctxOrNode) as never\n\n\t\tconst ctx = this.createParseContext(ctxOrNode)\n\n\t\tconst node = parseNode(ctx)\n\n\t\tconst bound = this.bindReference(node)\n\n\t\treturn (nodesByRegisteredId[ctx.id] = bound) as never\n\t}\n\n\tparse = (def: unknown, opts: BaseParseOptions = {}): BaseRoot =>\n\t\tthis.finalize(this.parseDefinition(def, opts))\n\n\tparseDefinition(def: unknown, opts: BaseParseOptions = {}): BaseRoot {\n\t\tif (hasArkKind(def, \"root\")) return this.bindReference(def)\n\n\t\tconst ctxInputOrNode = this.preparseOwnDefinitionFormat(def, opts)\n\t\tif (hasArkKind(ctxInputOrNode, \"root\"))\n\t\t\treturn this.bindReference(ctxInputOrNode)\n\n\t\tconst ctx = this.createParseContext(ctxInputOrNode)\n\t\tnodesByRegisteredId[ctx.id] = ctx\n\t\tlet node = this.bindReference(this.parseOwnDefinitionFormat(def, ctx))\n\n\t\t// if the node is recursive e.g. { box: \"this\" }, we need to make sure it\n\t\t// has the original id from context so that its references compile correctly\n\t\tif (node.isCyclic) node = withId(node, ctx.id)\n\n\t\tnodesByRegisteredId[ctx.id] = node\n\n\t\treturn node\n\t}\n\n\tfinalize<node extends BaseRoot>(node: node): node {\n\t\tbootstrapAliasReferences(node)\n\t\tif (!node.precompilation && !this.resolvedConfig.jitless)\n\t\t\tprecompile(node.references)\n\t\treturn node\n\t}\n\n\tprotected abstract preparseOwnDefinitionFormat(\n\t\tdef: unknown,\n\t\topts: BaseParseOptions\n\t): BaseRoot | BaseParseContextInput\n\n\tabstract parseOwnDefinitionFormat(\n\t\tdef: unknown,\n\t\tctx: BaseParseContext\n\t): BaseRoot\n\n\tprotected abstract preparseOwnAliasEntry(k: string, v: unknown): AliasDefEntry\n\n\tprotected abstract normalizeRootScopeValue(resolution: unknown): unknown\n}\n\nexport class SchemaScope<$ extends {} = {}> extends BaseScope<$> {\n\tparseOwnDefinitionFormat(def: unknown, ctx: NodeParseContext): BaseRoot {\n\t\treturn parseNode(ctx) as never\n\t}\n\n\tprotected preparseOwnDefinitionFormat(\n\t\tschema: RootSchema,\n\t\topts: BaseParseOptions\n\t): BaseRoot | NodeParseContextInput {\n\t\treturn this.preparseNode(schemaKindOf(schema), schema, opts) as never\n\t}\n\n\tprotected preparseOwnAliasEntry(k: string, v: unknown): AliasDefEntry {\n\t\treturn [k, v]\n\t}\n\n\tprotected normalizeRootScopeValue(v: unknown): unknown {\n\t\treturn v\n\t}\n}\n\nconst bootstrapAliasReferences = (resolution: BaseRoot | GenericRoot) => {\n\tconst aliases = resolution.references.filter(node => node.hasKind(\"alias\"))\n\tfor (const aliasNode of aliases) {\n\t\tObject.assign(aliasNode.referencesById, aliasNode.resolution.referencesById)\n\t\tfor (const ref of resolution.references) {\n\t\t\tif (aliasNode.id in ref.referencesById)\n\t\t\t\tObject.assign(ref.referencesById, aliasNode.referencesById)\n\t\t}\n\t}\n\treturn resolution\n}\n\nconst resolutionsToJson = (resolutions: InternalResolutions): JsonStructure =>\n\tflatMorph(resolutions, (k, v) => [\n\t\tk,\n\t\thasArkKind(v, \"root\") || hasArkKind(v, \"generic\") ? v.json\n\t\t: hasArkKind(v, \"module\") ? resolutionsToJson(v)\n\t\t: throwInternalError(`Unexpected resolution ${printable(v)}`)\n\t])\n\nconst maybeResolveSubalias = (\n\tbase: Dict,\n\tname: string\n): BaseRoot | GenericRoot | undefined => {\n\tconst dotIndex = name.indexOf(\".\")\n\tif (dotIndex === -1) return\n\n\tconst dotPrefix = name.slice(0, dotIndex)\n\tconst prefixSchema = base[dotPrefix]\n\t// if the name includes \".\", but the prefix is not an alias, it\n\t// might be something like a decimal literal, so just fall through to return\n\tif (prefixSchema === undefined) return\n\tif (!hasArkKind(prefixSchema, \"module\"))\n\t\treturn throwParseError(writeNonSubmoduleDotMessage(dotPrefix))\n\n\tconst subalias = name.slice(dotIndex + 1)\n\tconst resolution = prefixSchema[subalias]\n\n\tif (resolution === undefined)\n\t\treturn maybeResolveSubalias(prefixSchema, subalias)\n\n\tif (hasArkKind(resolution, \"root\") || hasArkKind(resolution, \"generic\"))\n\t\treturn resolution\n\n\tif (hasArkKind(resolution, \"module\")) {\n\t\treturn (\n\t\t\tresolution.root ??\n\t\t\tthrowParseError(writeMissingSubmoduleAccessMessage(name))\n\t\t)\n\t}\n\n\tthrowInternalError(\n\t\t`Unexpected resolution for alias '${name}': ${printable(resolution)}`\n\t)\n}\n\ntype instantiateAliases<aliases> = {\n\t[k in keyof aliases]: aliases[k] extends InternalResolution ? aliases[k]\n\t:\tBaseRoot\n} & unknown\n\nexport type SchemaScopeParser = <const aliases>(\n\taliases: {\n\t\t[k in keyof aliases]: conform<\n\t\t\taliases[k],\n\t\t\tRootSchema | PreparsedNodeResolution\n\t\t>\n\t},\n\tconfig?: ArkSchemaScopeConfig\n) => BaseScope<instantiateAliases<aliases>>\n\nexport const schemaScope: SchemaScopeParser = (aliases, config) =>\n\tnew SchemaScope(aliases, config)\n\nexport type InternalSchemaParser = (\n\tschema: RootSchema,\n\topts?: BaseParseOptions\n) => BaseRoot\n\nexport const rootSchemaScope: SchemaScope = new SchemaScope({})\n\nexport const parseAsSchema = (\n\tdef: unknown,\n\topts?: BaseParseOptions\n): BaseRoot | ParseError => {\n\ttry {\n\t\treturn rootSchema(def as RootSchema, opts) as never\n\t} catch (e) {\n\t\tif (e instanceof ParseError) return e\n\t\tthrow e\n\t}\n}\n\nexport type RootExportCache = Record<\n\tstring,\n\tBaseRoot | GenericRoot | RootModule | undefined\n>\n\nconst resolutionsOfModule = ($: BaseScope, typeSet: RootExportCache) => {\n\tconst result: InternalResolutions = {}\n\tfor (const k in typeSet) {\n\t\tconst v = typeSet[k]\n\t\tif (hasArkKind(v, \"module\")) {\n\t\t\tconst innerResolutions = resolutionsOfModule($, v as never)\n\t\t\tconst prefixedResolutions = flatMorph(\n\t\t\t\tinnerResolutions,\n\t\t\t\t(innerK, innerV) => [`${k}.${innerK}`, innerV]\n\t\t\t)\n\t\t\tObject.assign(result, prefixedResolutions)\n\t\t} else if (hasArkKind(v, \"root\") || hasArkKind(v, \"generic\")) result[k] = v\n\t\telse throwInternalError(`Unexpected scope resolution ${printable(v)}`)\n\t}\n\treturn result\n}\n\nexport const writeUnresolvableMessage = <token extends string>(\n\ttoken: token\n): writeUnresolvableMessage<token> => `'${token}' is unresolvable`\n\nexport type writeUnresolvableMessage<token extends string> =\n\t`'${token}' is unresolvable`\n\nexport const writeNonSubmoduleDotMessage = <name extends string>(\n\tname: name\n): writeNonSubmoduleDotMessage<name> =>\n\t`'${name}' must reference a module to be accessed using dot syntax`\n\nexport type writeNonSubmoduleDotMessage<name extends string> =\n\t`'${name}' must reference a module to be accessed using dot syntax`\n\nexport const writeMissingSubmoduleAccessMessage = <name extends string>(\n\tname: name\n): writeMissingSubmoduleAccessMessage<name> =>\n\t`Reference to submodule '${name}' must specify an alias`\n\nexport type writeMissingSubmoduleAccessMessage<name extends string> =\n\t`Reference to submodule '${name}' must specify an alias`\n\n// ensure the scope is resolved so JIT will be applied to future types\nrootSchemaScope.export()\n\nexport const rootSchema: BaseScope[\"schema\"] = rootSchemaScope.schema\nexport const node: BaseScope[\"node\"] = rootSchemaScope.node\nexport const defineSchema: BaseScope[\"defineSchema\"] =\n\trootSchemaScope.defineSchema\nexport const genericNode: BaseScope[\"generic\"] = rootSchemaScope.generic\n"
  },
  {
    "path": "ark/schema/shared/compile.ts",
    "content": "import {\n\tCastableBase,\n\tDynamicFunction,\n\thasDomain,\n\tisDotAccessible,\n\tserializePrimitive,\n\ttype Fn\n} from \"@ark/util\"\nimport type { BaseNode } from \"../node.ts\"\nimport type { NodeId } from \"../parse.ts\"\nimport { registeredReference } from \"./registry.ts\"\nimport type { TraversalKind } from \"./traversal.ts\"\n\nexport type CoercibleValue = string | number | boolean | null | undefined\n\nexport class CompiledFunction<\n\tcompiledSignature = (...args: unknown[]) => unknown,\n\targs extends readonly string[] = readonly string[]\n> extends CastableBase<{\n\t[k in args[number]]: k\n}> {\n\treadonly argNames: args\n\treadonly body = \"\"\n\n\tconstructor(...args: args) {\n\t\tsuper()\n\t\tthis.argNames = args\n\t\tfor (const arg of args) {\n\t\t\tif (arg in this) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Arg name '${arg}' would overwrite an existing property on FunctionBody`\n\t\t\t\t)\n\t\t\t}\n\t\t\t;(this as any)[arg] = arg\n\t\t}\n\t}\n\n\tindentation = 0\n\tindent(): this {\n\t\tthis.indentation += 4\n\t\treturn this\n\t}\n\n\tdedent(): this {\n\t\tthis.indentation -= 4\n\t\treturn this\n\t}\n\n\tprop(key: PropertyKey, optional = false): string {\n\t\treturn compileLiteralPropAccess(key, optional)\n\t}\n\n\tindex(key: string | number, optional = false): string {\n\t\treturn indexPropAccess(`${key}`, optional)\n\t}\n\n\tline(statement: string): this {\n\t\t;(this.body as any) += `${\" \".repeat(this.indentation)}${statement}\\n`\n\t\treturn this\n\t}\n\n\tconst(identifier: string, expression: CoercibleValue): this {\n\t\tthis.line(`const ${identifier} = ${expression}`)\n\t\treturn this\n\t}\n\n\tlet(identifier: string, expression: CoercibleValue): this {\n\t\treturn this.line(`let ${identifier} = ${expression}`)\n\t}\n\n\tset(identifier: string, expression: CoercibleValue): this {\n\t\treturn this.line(`${identifier} = ${expression}`)\n\t}\n\n\tif(condition: string, then: (self: this) => this): this {\n\t\treturn this.block(`if (${condition})`, then)\n\t}\n\n\telseIf(condition: string, then: (self: this) => this): this {\n\t\treturn this.block(`else if (${condition})`, then)\n\t}\n\n\telse(then: (self: this) => this): this {\n\t\treturn this.block(\"else\", then)\n\t}\n\n\t/** Current index is \"i\" */\n\tfor(\n\t\tuntil: string,\n\t\tbody: (self: this) => this,\n\t\tinitialValue: CoercibleValue = 0\n\t): this {\n\t\treturn this.block(`for (let i = ${initialValue}; ${until}; i++)`, body)\n\t}\n\n\t/** Current key is \"k\" */\n\tforIn(object: string, body: (self: this) => this): this {\n\t\treturn this.block(`for (const k in ${object})`, body)\n\t}\n\n\tblock(prefix: string, contents: (self: this) => this, suffix = \"\"): this {\n\t\tthis.line(`${prefix} {`)\n\t\tthis.indent()\n\t\tcontents(this)\n\t\tthis.dedent()\n\t\treturn this.line(`}${suffix}`)\n\t}\n\n\treturn(expression: CoercibleValue = \"\"): this {\n\t\treturn this.line(`return ${expression}`)\n\t}\n\n\twrite(name = \"anonymous\", indent: number = 0): string {\n\t\treturn `${name}(${this.argNames.join(\", \")}) { ${\n\t\t\tindent ?\n\t\t\t\tthis.body\n\t\t\t\t\t.split(\"\\n\")\n\t\t\t\t\t.map(l => \" \".repeat(indent) + `${l}`)\n\t\t\t\t\t.join(\"\\n\")\n\t\t\t:\tthis.body\n\t\t} }`\n\t}\n\n\tcompile(): compiledSignature {\n\t\treturn new DynamicFunction(...this.argNames, this.body) as never\n\t}\n}\n\nexport const compileSerializedValue = (value: unknown): string =>\n\thasDomain(value, \"object\") || typeof value === \"symbol\" ?\n\t\tregisteredReference(value)\n\t:\tserializePrimitive(value as never)\n\nexport const compileLiteralPropAccess = (\n\tkey: PropertyKey,\n\toptional = false\n): string => {\n\tif (typeof key === \"string\" && isDotAccessible(key))\n\t\treturn `${optional ? \"?\" : \"\"}.${key}`\n\n\treturn indexPropAccess(serializeLiteralKey(key), optional)\n}\n\nexport const serializeLiteralKey = (key: PropertyKey): string =>\n\ttypeof key === \"symbol\" ? registeredReference(key) : JSON.stringify(key)\n\nexport const indexPropAccess = (key: string, optional = false): string =>\n\t`${optional ? \"?.\" : \"\"}[${key}]`\n\nexport interface InvokeOptions extends ReferenceOptions {\n\targ?: string\n}\n\nexport interface ReferenceOptions {\n\tkind?: TraversalKind\n\tbind?: string\n}\n\nexport declare namespace NodeCompiler {\n\texport interface Context {\n\t\tkind: TraversalKind\n\t\toptimistic?: true\n\t}\n}\n\nexport class NodeCompiler extends CompiledFunction<Fn, [\"data\", \"ctx\"]> {\n\ttraversalKind: TraversalKind\n\toptimistic: boolean\n\n\tconstructor(ctx: NodeCompiler.Context) {\n\t\tsuper(\"data\", \"ctx\")\n\t\tthis.traversalKind = ctx.kind\n\t\tthis.optimistic = ctx.optimistic === true\n\t}\n\n\tinvoke(node: BaseNode | NodeId, opts?: InvokeOptions): string {\n\t\tconst arg = opts?.arg ?? this.data\n\t\tconst requiresContext =\n\t\t\ttypeof node === \"string\" ? true : this.requiresContextFor(node)\n\t\tconst id = typeof node === \"string\" ? node : node.id\n\t\tif (requiresContext)\n\t\t\treturn `${this.referenceToId(id, opts)}(${arg}, ${this.ctx})`\n\n\t\treturn `${this.referenceToId(id, opts)}(${arg})`\n\t}\n\n\treferenceToId(id: NodeId, opts?: ReferenceOptions): string {\n\t\tconst invokedKind = opts?.kind ?? this.traversalKind\n\t\tconst base = `this.${id}${invokedKind}`\n\t\treturn opts?.bind ? `${base}.bind(${opts?.bind})` : base\n\t}\n\n\trequiresContextFor(node: BaseNode): boolean {\n\t\treturn this.traversalKind === \"Apply\" || node.allowsRequiresContext\n\t}\n\n\tinitializeErrorCount(): this {\n\t\treturn this.const(\"errorCount\", \"ctx.currentErrorCount\")\n\t}\n\n\treturnIfFail(): this {\n\t\treturn this.if(\"ctx.currentErrorCount > errorCount\", () => this.return())\n\t}\n\n\treturnIfFailFast(): this {\n\t\treturn this.if(\"ctx.failFast && ctx.currentErrorCount > errorCount\", () =>\n\t\t\tthis.return()\n\t\t)\n\t}\n\n\ttraverseKey(\n\t\tkeyExpression: string,\n\t\taccessExpression: string,\n\t\tnode: BaseNode\n\t): this {\n\t\tconst requiresContext = this.requiresContextFor(node)\n\t\tif (requiresContext) this.line(`${this.ctx}.path.push(${keyExpression})`)\n\n\t\tthis.check(node, {\n\t\t\targ: accessExpression\n\t\t})\n\t\tif (requiresContext) this.line(`${this.ctx}.path.pop()`)\n\n\t\treturn this\n\t}\n\n\tcheck(node: BaseNode, opts?: InvokeOptions): this {\n\t\treturn this.traversalKind === \"Allows\" ?\n\t\t\t\tthis.if(`!${this.invoke(node, opts)}`, () => this.return(false))\n\t\t\t:\tthis.line(this.invoke(node, opts))\n\t}\n}\n"
  },
  {
    "path": "ark/schema/shared/declare.ts",
    "content": "import type { merge, show } from \"@ark/util\"\nimport type { UnknownErrorConfigs } from \"../config.ts\"\nimport type { nodeOfKind, reducibleKindOf } from \"../kinds.ts\"\nimport type { Disjoint } from \"./disjoint.ts\"\nimport type { ArkErrors } from \"./errors.ts\"\nimport type { NarrowedAttachments, NodeKind } from \"./implement.ts\"\nimport type { JsonSchema } from \"./jsonSchema.ts\"\n\ntype withMetaPrefixedKeys<o> = {\n\t[k in keyof o as k extends string ? `meta.${k}` : never]: o[k]\n}\n\nexport interface DefaultArkEnv {\n\tmeta(): {}\n\tonFail(errors: ArkErrors): ArkErrors\n}\n\ninterface NodeMeta extends JsonSchema.UniversalMeta, UnknownErrorConfigs {\n\talias?: string\n\tonFail?: ArkErrors.Handler\n}\n\ndeclare global {\n\texport interface ArkEnv extends DefaultArkEnv {}\n\n\texport namespace ArkEnv {\n\t\texport type meta = show<NodeMeta & ReturnType<ArkEnv[\"meta\"]>>\n\n\t\texport type onFail = ReturnType<ArkEnv[\"onFail\"]>\n\t}\n}\n\nexport type TypeMeta = Omit<ArkEnv.meta, \"onFail\">\n\nexport declare namespace TypeMeta {\n\texport type Collapsible<meta extends TypeMeta = TypeMeta> = meta | string\n\n\texport type Mapper<meta extends TypeMeta = TypeMeta> = (\n\t\texisting: Readonly<meta>\n\t) => meta\n\n\texport type MappableInput<meta extends TypeMeta = TypeMeta> =\n\t\t| Collapsible<meta>\n\t\t| Mapper<meta>\n\n\texport namespace MappableInput {\n\t\texport type Internal = MappableInput<ArkEnv.meta>\n\t}\n}\n\nexport interface BaseNormalizedSchema extends withMetaPrefixedKeys<TypeMeta> {\n\treadonly meta?: ArkEnv.meta | string\n}\n\ninterface DeclarationInput {\n\tkind: NodeKind\n\tschema: unknown\n\tnormalizedSchema: BaseNormalizedSchema\n\tinner: object\n\terrorContext?: BaseErrorContext\n\treducibleTo?: NodeKind\n\tintersectionIsOpen?: true\n\tprerequisite?: unknown\n\tchildKind?: NodeKind\n}\n\nexport interface BaseErrorContext<kind extends NodeKind = NodeKind> {\n\treadonly description?: string\n\treadonly code: kind\n\treadonly meta: ArkEnv.meta\n}\n\nexport type defaultErrorContext<d extends DeclarationInput> = show<\n\tBaseErrorContext<d[\"kind\"]> & d[\"inner\"]\n>\n\nexport type declareNode<\n\td extends {\n\t\t[k in keyof d]: k extends keyof DeclarationInput ? DeclarationInput[k]\n\t\t:\tnever\n\t} & DeclarationInput\n> = merge<\n\t{\n\t\tintersectionIsOpen: false\n\t\tprerequisite: prerequisiteOf<d>\n\t\tchildKind: never\n\t\treducibleTo: d[\"kind\"]\n\t\terrorContext: null\n\t},\n\td\n>\n\ntype prerequisiteOf<d extends DeclarationInput> =\n\t\"prerequisite\" extends keyof d ? d[\"prerequisite\"] : unknown\n\nexport type attachmentsOf<d extends BaseNodeDeclaration> =\n\tNarrowedAttachments<d> & attachedInner<d>\n\n// some nonsense to allow TS to infer attache properties on nodes with\n// a base declaration like Prop and Range\ntype attachedInner<d extends BaseNodeDeclaration> =\n\t\"intersection\" & d[\"kind\"] extends never ? d[\"inner\"] : {}\n\nexport interface BaseNodeDeclaration {\n\tkind: NodeKind\n\tschema: unknown\n\tnormalizedSchema: BaseNormalizedSchema\n\tinner: {}\n\treducibleTo: NodeKind\n\tprerequisite: any\n\tintersectionIsOpen: boolean\n\tchildKind: NodeKind\n\terrorContext: BaseErrorContext | null\n}\n\nexport type ownIntersectionResult<d extends BaseNodeDeclaration> =\n\t| nodeOfKind<reducibleKindOf<d[\"kind\"]>>\n\t| Disjoint\n"
  },
  {
    "path": "ark/schema/shared/disjoint.ts",
    "content": "import { isArray, stringifyPath, throwParseError, type Key } from \"@ark/util\"\nimport type { nodeOfKind } from \"../kinds.ts\"\nimport type { BaseNode } from \"../node.ts\"\nimport type { BoundKind } from \"../refinements/kinds.ts\"\nimport type { Domain } from \"../roots/domain.ts\"\nimport type { BaseRoot } from \"../roots/root.ts\"\nimport type { Prop } from \"../structure/prop.ts\"\nimport { $ark } from \"./registry.ts\"\nimport { isNode } from \"./utils.ts\"\n\nexport interface DisjointEntry<kind extends DisjointKind = DisjointKind> {\n\tkind: kind\n\tl: OperandsByDisjointKind[kind]\n\tr: OperandsByDisjointKind[kind]\n\tpath: Key[]\n\toptional: boolean\n}\n\ntype OperandsByDisjointKind = {\n\tdomain: nodeOfKind<\"domain\"> | Domain.Enumerable\n\tunit: nodeOfKind<\"unit\">\n\tproto: nodeOfKind<\"proto\">\n\tpresence: BaseRoot\n\trange: nodeOfKind<BoundKind>\n\tassignability: BaseNode\n\tunion: readonly BaseRoot[]\n}\n\nexport type DisjointEntryContext = {\n\tpath?: Key[]\n\toptional?: true\n}\n\nexport class Disjoint extends Array<DisjointEntry> {\n\tstatic init<kind extends DisjointKind>(\n\t\tkind: kind,\n\t\tl: OperandsByDisjointKind[kind],\n\t\tr: OperandsByDisjointKind[kind],\n\t\tctx?: DisjointEntryContext\n\t): Disjoint {\n\t\treturn new Disjoint({\n\t\t\tkind,\n\t\t\tl,\n\t\t\tr,\n\t\t\tpath: ctx?.path ?? [],\n\t\t\toptional: ctx?.optional ?? false\n\t\t})\n\t}\n\n\tadd<kind extends DisjointKind>(\n\t\tkind: kind,\n\t\tl: OperandsByDisjointKind[kind],\n\t\tr: OperandsByDisjointKind[kind],\n\t\tctx?: DisjointEntryContext\n\t): Disjoint {\n\t\tthis.push({\n\t\t\tkind,\n\t\t\tl,\n\t\t\tr,\n\t\t\tpath: ctx?.path ?? [],\n\t\t\toptional: ctx?.optional ?? false\n\t\t})\n\t\treturn this\n\t}\n\n\tget summary(): string {\n\t\treturn this.describeReasons()\n\t}\n\n\tdescribeReasons(): string {\n\t\tif (this.length === 1) {\n\t\t\tconst { path, l, r } = this[0]\n\t\t\tconst pathString = stringifyPath(path)\n\t\t\treturn writeUnsatisfiableExpressionError(\n\t\t\t\t`Intersection${\n\t\t\t\t\tpathString && ` at ${pathString}`\n\t\t\t\t} of ${describeReasons(l, r)}`\n\t\t\t)\n\t\t}\n\t\treturn `The following intersections result in unsatisfiable types:\\n• ${this.map(\n\t\t\t({ path, l, r }) => `${path}: ${describeReasons(l, r)}`\n\t\t).join(\"\\n• \")}`\n\t}\n\n\tthrow(): never {\n\t\treturn throwParseError(this.describeReasons())\n\t}\n\n\tinvert(): Disjoint {\n\t\tconst result = this.map(entry => ({\n\t\t\t...entry,\n\t\t\tl: entry.r,\n\t\t\tr: entry.l\n\t\t}))\n\n\t\t// Workaround for Static Hermes, which doesn't preserve the Array subclass here\n\t\t// https://github.com/arktypeio/arktype/issues/1027\n\t\tif (!(result instanceof Disjoint)) return new Disjoint(...result)\n\n\t\treturn result\n\t}\n\n\twithPrefixKey(key: PropertyKey, kind: Prop.Kind): Disjoint {\n\t\treturn this.map(entry => ({\n\t\t\t...entry,\n\t\t\tpath: [key, ...entry.path],\n\t\t\toptional: entry.optional || kind === \"optional\"\n\t\t})) as Disjoint\n\t}\n\n\ttoNeverIfDisjoint(): BaseRoot {\n\t\treturn $ark.intrinsic.never as never\n\t}\n}\n\nexport type DisjointKind = keyof OperandsByDisjointKind\n\nconst describeReasons = (l: unknown, r: unknown): string =>\n\t`${describeReason(l)} and ${describeReason(r)}`\n\nconst describeReason = (value: unknown): string =>\n\tisNode(value) ? value.expression\n\t: isArray(value) ? value.map(describeReason).join(\" | \") || \"never\"\n\t: String(value)\n\nexport const writeUnsatisfiableExpressionError = <expression extends string>(\n\texpression: expression\n): writeUnsatisfiableExpressionError<expression> =>\n\t`${expression} results in an unsatisfiable type`\n\nexport type writeUnsatisfiableExpressionError<expression extends string> =\n\t`${expression} results in an unsatisfiable type`\n"
  },
  {
    "path": "ark/schema/shared/errors.ts",
    "content": "import {\n\tCastableBase,\n\tReadonlyArray,\n\tReadonlyPath,\n\tappend,\n\tconflatenateAll,\n\tdefineProperties,\n\tflatMorph,\n\tstringifyPath,\n\ttype JsonArray,\n\ttype JsonObject,\n\ttype array,\n\ttype merge,\n\ttype propwiseXor,\n\ttype show\n} from \"@ark/util\"\nimport type { ResolvedConfig } from \"../config.ts\"\nimport type { Prerequisite, errorContext } from \"../kinds.ts\"\nimport type { NodeKind } from \"./implement.ts\"\nimport type { StandardSchemaV1 } from \"./standardSchema.ts\"\nimport type { Traversal } from \"./traversal.ts\"\nimport { arkKind } from \"./utils.ts\"\n\nexport type ArkErrorResult = ArkError | ArkErrors\n\nexport class ArkError<\n\tcode extends ArkErrorCode = ArkErrorCode\n> extends CastableBase<ArkErrorContextInput<code>> {\n\treadonly [arkKind] = \"error\"\n\tpath: ReadonlyPath\n\tdata: Prerequisite<code>\n\tprivate nodeConfig: ResolvedConfig[code]\n\tprotected input: ArkErrorContextInput<code>\n\tprotected ctx: Traversal\n\n\tconstructor(input: ArkErrorContextInput<code>, ctx: Traversal)\n\t// TS gets confused by <code>, so internally we just use the base type for input\n\tconstructor(\n\t\t{ prefixPath, relativePath, ...input }: ArkErrorContextInput,\n\t\tctx: Traversal\n\t) {\n\t\tsuper()\n\t\tthis.input = input as never\n\t\tthis.ctx = ctx\n\t\tdefineProperties(this, input)\n\t\tconst data = ctx.data\n\t\tif (input.code === \"union\") {\n\t\t\tinput.errors = input.errors.flatMap(innerError => {\n\t\t\t\t// flatten union errors to avoid repeating context like \"foo must be foo must be\"...\n\t\t\t\tconst flat =\n\t\t\t\t\tinnerError.hasCode(\"union\") ? innerError.errors : [innerError]\n\n\t\t\t\tif (!prefixPath && !relativePath) return flat\n\n\t\t\t\treturn flat.map(e =>\n\t\t\t\t\te.transform(\n\t\t\t\t\t\te =>\n\t\t\t\t\t\t\t({\n\t\t\t\t\t\t\t\t...e,\n\t\t\t\t\t\t\t\tpath: conflatenateAll(prefixPath, e.path, relativePath)\n\t\t\t\t\t\t\t}) as never\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t})\n\t\t}\n\t\tthis.nodeConfig = ctx.config[this.code] as never\n\t\tconst basePath = [...(input.path ?? ctx.path)]\n\t\tif (relativePath) basePath.push(...relativePath)\n\t\tif (prefixPath) basePath.unshift(...prefixPath)\n\t\tthis.path = new ReadonlyPath(...basePath)\n\t\tthis.data = \"data\" in input ? input.data : data\n\t}\n\n\ttransform(\n\t\tf: (input: ArkErrorContextInput<code>) => ArkErrorContextInput\n\t): ArkError {\n\t\treturn new ArkError(\n\t\t\tf({\n\t\t\t\tdata: this.data,\n\t\t\t\tpath: this.path,\n\t\t\t\t...this.input\n\t\t\t}),\n\t\t\tthis.ctx\n\t\t) as never\n\t}\n\n\thasCode<code extends ArkErrorCode>(code: code): this is ArkError<code> {\n\t\treturn this.code === code\n\t}\n\n\tget propString(): string {\n\t\treturn stringifyPath(this.path)\n\t}\n\n\tget expected(): string {\n\t\tif (this.input.expected) return this.input.expected\n\n\t\tconst config = this.meta?.expected ?? this.nodeConfig.expected\n\n\t\treturn typeof config === \"function\" ? config(this.input as never) : config\n\t}\n\n\tget actual(): string {\n\t\tif (this.input.actual) return this.input.actual\n\n\t\tconst config = this.meta?.actual ?? this.nodeConfig.actual\n\n\t\treturn typeof config === \"function\" ? config(this.data as never) : config\n\t}\n\n\tget problem(): string {\n\t\tif (this.input.problem) return this.input.problem\n\n\t\tconst config = this.meta?.problem ?? this.nodeConfig.problem\n\n\t\treturn typeof config === \"function\" ? config(this as never) : config\n\t}\n\n\tget message(): string {\n\t\tif (this.input.message) return this.input.message\n\n\t\tconst config = this.meta?.message ?? this.nodeConfig.message\n\n\t\treturn typeof config === \"function\" ? config(this as never) : config\n\t}\n\n\tget flat(): ArkError[] {\n\t\treturn this.hasCode(\"intersection\") ? [...this.errors] : [this as never]\n\t}\n\n\ttoJSON(): JsonObject {\n\t\treturn {\n\t\t\tdata: this.data,\n\t\t\tpath: this.path,\n\t\t\t...this.input,\n\t\t\texpected: this.expected,\n\t\t\tactual: this.actual,\n\t\t\tproblem: this.problem,\n\t\t\tmessage: this.message\n\t\t} as never\n\t}\n\n\ttoString(): string {\n\t\treturn this.message\n\t}\n\n\tthrow(): never {\n\t\tthrow this\n\t}\n}\n\nexport declare namespace ArkErrors {\n\texport type Handler<returns = unknown> = (errors: ArkErrors) => returns\n}\n\n/**\n * A ReadonlyArray of `ArkError`s returned by a Type on invalid input.\n *\n * Subsequent errors added at an existing path are merged into an\n * ArkError intersection.\n */\nexport class ArkErrors\n\textends ReadonlyArray<ArkError>\n\timplements StandardSchemaV1.FailureResult\n{\n\treadonly [arkKind] = \"errors\"\n\n\tprotected ctx: Traversal\n\n\tconstructor(ctx: Traversal) {\n\t\tsuper()\n\t\tthis.ctx = ctx\n\t}\n\n\t/**\n\t * Errors by a pathString representing their location.\n\t */\n\tbyPath: Record<string, ArkError> = Object.create(null)\n\n\t/**\n\t * {@link byPath} flattened so that each value is an array of ArkError instances at that path.\n\t *\n\t * ✅ Since \"intersection\" errors will be flattened to their constituent `.errors`,\n\t * they will never be directly present in this representation.\n\t */\n\tget flatByPath(): Record<string, ArkError[]> {\n\t\treturn flatMorph(this.byPath, (k, v) => [k, v.flat])\n\t}\n\n\t/**\n\t * {@link byPath} flattened so that each value is an array of problem strings at that path.\n\t */\n\tget flatProblemsByPath(): Record<string, string[]> {\n\t\treturn flatMorph(this.byPath, (k, v) => [k, v.flat.map(e => e.problem)])\n\t}\n\n\t/**\n\t * All pathStrings at which errors are present mapped to the errors occuring\n\t * at that path or any nested path within it.\n\t */\n\tbyAncestorPath: Record<string, ArkError[]> = Object.create(null)\n\n\tcount = 0\n\tprivate mutable: ArkError[] = this as never\n\n\t/**\n\t * Throw a TraversalError based on these errors.\n\t */\n\tthrow(): never {\n\t\tthrow this.toTraversalError()\n\t}\n\n\t/**\n\t * Converts ArkErrors to TraversalError, a subclass of `Error` suitable for throwing with nice\n\t * formatting.\n\t */\n\ttoTraversalError(): TraversalError {\n\t\treturn new TraversalError(this)\n\t}\n\n\t/**\n\t * Append an ArkError to this array, ignoring duplicates.\n\t */\n\tadd(error: ArkError): void {\n\t\tconst existing = this.byPath[error.propString]\n\t\tif (existing) {\n\t\t\t// only add if it's not already in the errors collection\n\t\t\tif (error === existing) return\n\t\t\t// If the existing error is an error for a value constrained to \"never\",\n\t\t\t// then we don't want to intersect the error messages.\n\t\t\tif (existing.hasCode(\"union\") && existing.errors.length === 0) return\n\n\t\t\t// If the new error is an error for a value constrained to \"never\",\n\t\t\t// then we want to override any existing errors.\n\t\t\tconst errorIntersection =\n\t\t\t\terror.hasCode(\"union\") && error.errors.length === 0 ?\n\t\t\t\t\terror\n\t\t\t\t:\tnew ArkError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcode: \"intersection\",\n\t\t\t\t\t\t\terrors:\n\t\t\t\t\t\t\t\texisting.hasCode(\"intersection\") ?\n\t\t\t\t\t\t\t\t\t[...existing.errors, error]\n\t\t\t\t\t\t\t\t:\t[existing, error]\n\t\t\t\t\t\t},\n\t\t\t\t\t\tthis.ctx\n\t\t\t\t\t)\n\n\t\t\tconst existingIndex = this.indexOf(existing)\n\t\t\tthis.mutable[existingIndex === -1 ? this.length : existingIndex] =\n\t\t\t\terrorIntersection\n\n\t\t\tthis.byPath[error.propString] = errorIntersection\n\t\t\t// add the original error here rather than the intersection\n\t\t\t// since the intersection is reflected by the array of errors at\n\t\t\t// this path\n\t\t\tthis.addAncestorPaths(error)\n\t\t} else {\n\t\t\tthis.byPath[error.propString] = error\n\t\t\tthis.addAncestorPaths(error)\n\t\t\tthis.mutable.push(error)\n\t\t}\n\t\tthis.count++\n\t}\n\n\ttransform(f: (e: ArkError) => ArkError): ArkErrors {\n\t\tconst result = new ArkErrors(this.ctx)\n\t\tfor (const e of this) result.add(f(e))\n\t\treturn result\n\t}\n\n\t/**\n\t * Add all errors from an ArkErrors instance, ignoring duplicates and\n\t * prefixing their paths with that of the current Traversal.\n\t */\n\tmerge(errors: ArkErrors): void {\n\t\tfor (const e of errors) {\n\t\t\tthis.add(\n\t\t\t\tnew ArkError(\n\t\t\t\t\t{ ...e, path: [...this.ctx.path, ...e.path] } as never,\n\t\t\t\t\tthis.ctx\n\t\t\t\t)\n\t\t\t)\n\t\t}\n\t}\n\n\t/**\n\t * @internal\n\t */\n\taffectsPath(path: ReadonlyPath): boolean {\n\t\tif (this.length === 0) return false\n\n\t\treturn (\n\t\t\t// this would occur if there is an existing error at a prefix of path\n\t\t\t// e.g. the path is [\"foo\", \"bar\"] and there is an error at [\"foo\"]\n\t\t\tpath.stringifyAncestors().some(s => s in this.byPath) ||\n\t\t\t// this would occur if there is an existing error at a suffix of path\n\t\t\t// e.g. the path is [\"foo\"] and there is an error at [\"foo\", \"bar\"]\n\t\t\tpath.stringify() in this.byAncestorPath\n\t\t)\n\t}\n\n\t/**\n\t * A human-readable summary of all errors.\n\t */\n\tget summary(): string {\n\t\treturn this.toString()\n\t}\n\n\t/**\n\t * Alias of this ArkErrors instance for StandardSchema compatibility.\n\t */\n\tget issues(): this {\n\t\treturn this\n\t}\n\n\ttoJSON(): JsonArray {\n\t\treturn [...this.map(e => e.toJSON())]\n\t}\n\n\ttoString(): string {\n\t\treturn this.join(\"\\n\")\n\t}\n\n\tprivate addAncestorPaths(error: ArkError): void {\n\t\tfor (const propString of error.path.stringifyAncestors()) {\n\t\t\tthis.byAncestorPath[propString] = append(\n\t\t\t\tthis.byAncestorPath[propString],\n\t\t\t\terror\n\t\t\t)\n\t\t}\n\t}\n}\n\nexport class TraversalError extends Error {\n\treadonly name = \"TraversalError\"\n\tdeclare arkErrors: ArkErrors\n\n\tconstructor(errors: ArkErrors) {\n\t\tif (errors.length === 1) super(errors.summary)\n\t\telse super(\"\\n\" + errors.map(error => `  • ${indent(error)}`).join(\"\\n\"))\n\n\t\tObject.defineProperty(this, \"arkErrors\", {\n\t\t\tvalue: errors,\n\t\t\tenumerable: false\n\t\t})\n\t}\n}\n\nconst indent = (error: ArkError): string =>\n\terror.toString().split(\"\\n\").join(\"\\n  \")\n\nexport interface DerivableErrorContext<\n\tcode extends ArkErrorCode = ArkErrorCode\n> {\n\texpected: string\n\tactual: string\n\tproblem: string\n\tmessage: string\n\tdata: Prerequisite<code>\n\tpath: array<PropertyKey>\n\tpropString: string\n}\n\nexport type DerivableErrorContextInput<\n\tcode extends ArkErrorCode = ArkErrorCode\n> = Partial<DerivableErrorContext<code>> &\n\tpropwiseXor<\n\t\t{ path?: array<PropertyKey> },\n\t\t{ relativePath?: array<PropertyKey>; prefixPath?: array<PropertyKey> }\n\t>\n\nexport type ArkErrorCode = {\n\t[kind in NodeKind]: errorContext<kind> extends null ? never : kind\n}[NodeKind]\n\ntype ArkErrorContextInputsByCode = {\n\t[code in ArkErrorCode]: errorContext<code> & DerivableErrorContextInput<code>\n}\n\nexport type ArkErrorContextInput<code extends ArkErrorCode = ArkErrorCode> =\n\tmerge<ArkErrorContextInputsByCode[code], { meta?: ArkEnv.meta }>\n\nexport type NodeErrorContextInput<code extends ArkErrorCode = ArkErrorCode> =\n\tArkErrorContextInputsByCode[code] & { meta: ArkEnv.meta }\n\nexport type MessageContext<code extends ArkErrorCode = ArkErrorCode> = Omit<\n\tArkError<code>,\n\t\"message\"\n>\n\nexport type ProblemContext<code extends ArkErrorCode = ArkErrorCode> = Omit<\n\tMessageContext<code>,\n\t\"problem\"\n>\n\nexport type CustomErrorInput = show<\n\t// ensure a custom error can be discriminated on the lack of a code\n\t{ code?: undefined } & DerivableErrorContextInput\n>\n\nexport type ArkErrorInput = string | ArkErrorContextInput | CustomErrorInput\n\nexport type ProblemConfig<code extends ArkErrorCode = ArkErrorCode> =\n\t| string\n\t| ProblemWriter<code>\n\nexport type ProblemWriter<code extends ArkErrorCode = ArkErrorCode> = (\n\tcontext: ProblemContext<code>\n) => string\n\nexport type MessageConfig<code extends ArkErrorCode = ArkErrorCode> =\n\t| string\n\t| MessageWriter<code>\n\nexport type MessageWriter<code extends ArkErrorCode = ArkErrorCode> = (\n\tcontext: MessageContext<code>\n) => string\n\nexport type getAssociatedDataForError<code extends ArkErrorCode> =\n\tcode extends NodeKind ? Prerequisite<code> : unknown\n\nexport type ExpectedConfig<code extends ArkErrorCode = ArkErrorCode> =\n\t| string\n\t| ExpectedWriter<code>\n\nexport type ExpectedWriter<code extends ArkErrorCode = ArkErrorCode> = (\n\tsource: errorContext<code>\n) => string\n\nexport type ActualConfig<code extends ArkErrorCode = ArkErrorCode> =\n\t| string\n\t| ActualWriter<code>\n\nexport type ActualWriter<code extends ArkErrorCode = ArkErrorCode> = (\n\tdata: getAssociatedDataForError<code>\n) => string\n"
  },
  {
    "path": "ark/schema/shared/implement.ts",
    "content": "import {\n\tflatMorph,\n\tprintable,\n\tthrowParseError,\n\ttype Entry,\n\ttype Json,\n\ttype JsonStructure,\n\ttype KeySet,\n\ttype arrayIndexOf,\n\ttype entryOf,\n\ttype keySetOf,\n\ttype listable,\n\ttype requireKeys,\n\ttype show\n} from \"@ark/util\"\nimport type { NodeConfig, ResolvedUnknownNodeConfig } from \"../config.ts\"\nimport type { Declaration, Inner, errorContext, nodeOfKind } from \"../kinds.ts\"\nimport type { BaseNode } from \"../node.ts\"\nimport type { NodeId, NodeParseContext } from \"../parse.ts\"\nimport type {\n\tBaseRoot,\n\tschemaKindOrRightOf,\n\tschemaKindRightOf\n} from \"../roots/root.ts\"\nimport type { BaseScope, ResolvedScopeConfig } from \"../scope.ts\"\nimport type { Structure } from \"../structure/structure.ts\"\nimport { compileSerializedValue } from \"./compile.ts\"\nimport type {\n\tBaseErrorContext,\n\tBaseNodeDeclaration,\n\tBaseNormalizedSchema\n} from \"./declare.ts\"\nimport type { Disjoint } from \"./disjoint.ts\"\nimport { isNode, type makeRootAndArrayPropertiesMutable } from \"./utils.ts\"\n\nexport const basisKinds = [\"unit\", \"proto\", \"domain\"] as const\n\nexport type BasisKind = (typeof basisKinds)[number]\n\nexport const structuralKinds = [\n\t\"required\",\n\t\"optional\",\n\t\"index\",\n\t\"sequence\"\n] as const\n\nexport type StructuralKind = (typeof structuralKinds)[number]\n\nexport const prestructuralKinds = [\n\t\"pattern\",\n\t\"divisor\",\n\t\"exactLength\",\n\t\"max\",\n\t\"min\",\n\t\"maxLength\",\n\t\"minLength\",\n\t\"before\",\n\t\"after\"\n] as const\n\nexport type PrestructuralKind = (typeof prestructuralKinds)[number]\n\nexport const refinementKinds = [\n\t...prestructuralKinds,\n\t\"structure\",\n\t\"predicate\"\n] as const\n\nexport type RefinementKind = (typeof refinementKinds)[number]\n\nexport const constraintKinds = [...refinementKinds, ...structuralKinds] as const\n\nexport type ConstraintKind = (typeof constraintKinds)[number]\n\nexport const rootKinds = [\n\t\"alias\",\n\t\"union\",\n\t\"morph\",\n\t\"unit\",\n\t\"intersection\",\n\t\"proto\",\n\t\"domain\"\n] as const\n\nexport type RootKind = (typeof rootKinds)[number]\n\nexport type NodeKind = RootKind | ConstraintKind\n\ntype orderedNodeKinds = [...typeof rootKinds, ...typeof constraintKinds]\n\nexport const nodeKinds: orderedNodeKinds = [...rootKinds, ...constraintKinds]\n\nexport type OpenNodeKind = {\n\t[k in NodeKind]: Declaration<k>[\"intersectionIsOpen\"] extends true ? k : never\n}[NodeKind]\n\nexport type ClosedNodeKind = Exclude<NodeKind, OpenNodeKind>\n\nexport type PrimitiveKind = Exclude<RefinementKind | BasisKind, \"structure\">\n\nexport type CompositeKind = Exclude<NodeKind, PrimitiveKind>\n\nexport type OrderedNodeKinds = typeof nodeKinds\n\nexport const constraintKeys: KeySet<ConstraintKind> = flatMorph(\n\tconstraintKinds,\n\t(i, kind) => [kind, 1] as const\n)\n\nexport const structureKeys: keySetOf<Structure.Inner> = flatMorph(\n\t[...structuralKinds, \"undeclared\"],\n\t(i, k) => [k, 1] as const\n)\n\ntype RightsByKind = accumulateRightKinds<OrderedNodeKinds, {}>\n\nexport type kindOrRightOf<kind extends NodeKind> = kind | kindRightOf<kind>\n\nexport type kindLeftOf<kind extends NodeKind> = Exclude<\n\tNodeKind,\n\tkindOrRightOf<kind>\n>\n\nexport type kindOrLeftOf<kind extends NodeKind> = kind | kindLeftOf<kind>\n\ntype accumulateRightKinds<remaining extends readonly NodeKind[], result> =\n\tremaining extends (\n\t\treadonly [infer head extends NodeKind, ...infer tail extends NodeKind[]]\n\t) ?\n\t\taccumulateRightKinds<tail, result & { [k in head]: tail[number] }>\n\t:\tresult\n\nexport interface InternalIntersectionOptions {\n\tpipe: boolean\n}\n\nexport interface IntersectionContext extends InternalIntersectionOptions {\n\t$: BaseScope\n\tinvert: boolean\n}\n\nexport type ConstraintIntersection<\n\tlKind extends ConstraintKind,\n\trKind extends kindOrRightOf<lKind>\n> = (\n\tl: nodeOfKind<lKind>,\n\tr: nodeOfKind<rKind>,\n\tctx: IntersectionContext\n) => BaseNode | Disjoint | null\n\nexport type ConstraintIntersectionMap<kind extends ConstraintKind> = show<\n\t{\n\t\t[_ in kind]: ConstraintIntersection<kind, kind>\n\t} & {\n\t\t[rKind in kindRightOf<kind>]?: ConstraintIntersection<kind, rKind>\n\t}\n>\n\nexport type RootIntersection<\n\tlKind extends RootKind,\n\trKind extends schemaKindOrRightOf<lKind>\n> = (\n\tl: nodeOfKind<lKind>,\n\tr: nodeOfKind<rKind>,\n\tctx: IntersectionContext\n) => BaseRoot | Disjoint\n\nexport type TypeIntersectionMap<kind extends RootKind> = {\n\t[rKind in schemaKindOrRightOf<kind>]: RootIntersection<kind, rKind>\n}\n\nexport type IntersectionMap<kind extends NodeKind> =\n\tkind extends RootKind ? TypeIntersectionMap<kind>\n\t:\tConstraintIntersectionMap<kind & ConstraintKind>\n\nexport type UnknownIntersectionMap = {\n\t[k in NodeKind]?: (\n\t\tl: BaseNode,\n\t\tr: BaseNode,\n\t\tctx: IntersectionContext\n\t) => UnknownIntersectionResult\n}\n\nexport type UnknownIntersectionResult = BaseNode | Disjoint | null\n\ntype PrecedenceByKind = {\n\t[i in arrayIndexOf<OrderedNodeKinds> as OrderedNodeKinds[i]]: i\n}\n\nexport const precedenceByKind: PrecedenceByKind = flatMorph(\n\tnodeKinds,\n\t(i, kind) => [kind, i] as entryOf<PrecedenceByKind>\n)\n\nexport const isNodeKind = (value: unknown): value is NodeKind =>\n\ttypeof value === \"string\" && value in precedenceByKind\n\nexport function assertNodeKind<kind extends NodeKind>(\n\tvalue: BaseNode,\n\tkind: kind\n): asserts value is nodeOfKind<kind> {\n\tconst valueIsNode = isNode(value)\n\tif (!valueIsNode || value.kind !== kind) {\n\t\tthrowParseError(\n\t\t\t`Expected node of kind ${kind} (was ${\n\t\t\t\tvalueIsNode ? `${value.kind} node` : printable(value)\n\t\t\t})`\n\t\t)\n\t}\n}\n\nexport type precedenceOfKind<kind extends NodeKind> = PrecedenceByKind[kind]\n\nexport const precedenceOfKind = <kind extends NodeKind>(\n\tkind: kind\n): precedenceOfKind<kind> => precedenceByKind[kind]\n\nexport type kindRightOf<kind extends NodeKind> = RightsByKind[kind]\n\nexport const schemaKindsRightOf = <kind extends RootKind>(\n\tkind: kind\n): schemaKindRightOf<kind>[] =>\n\trootKinds.slice(precedenceOfKind(kind) + 1) as never\n\nexport const unionChildKinds = [\n\t...schemaKindsRightOf(\"union\"),\n\t\"alias\"\n] as const\n\nexport type UnionChildKind = (typeof unionChildKinds)[number]\n\nexport const morphChildKinds = [\n\t...schemaKindsRightOf(\"morph\"),\n\t\"alias\"\n] as const\n\nexport type MorphChildKind = (typeof morphChildKinds)[number]\n\nexport type keySchemaDefinitions<d extends BaseNodeDeclaration> = {\n\t[k in keyRequiringSchemaDefinition<d>]: NodeKeyImplementation<d, k>\n}\n\ntype keyRequiringSchemaDefinition<d extends BaseNodeDeclaration> = Exclude<\n\tkeyof d[\"normalizedSchema\"],\n\tkeyof BaseNormalizedSchema\n>\n\nexport const defaultValueSerializer = (v: unknown): Json => {\n\tif (typeof v === \"string\" || typeof v === \"boolean\" || v === null) return v\n\n\tif (typeof v === \"number\") {\n\t\tif (Number.isNaN(v)) return \"NaN\"\n\t\tif (v === Number.POSITIVE_INFINITY) return \"Infinity\"\n\t\tif (v === Number.NEGATIVE_INFINITY) return \"-Infinity\"\n\t\treturn v\n\t}\n\n\treturn compileSerializedValue(v)\n}\n\nexport type NodeKeyImplementation<\n\td extends BaseNodeDeclaration,\n\tk extends keyof d[\"normalizedSchema\"],\n\tinstantiated = k extends keyof d[\"inner\"] ? Exclude<d[\"inner\"][k], undefined>\n\t:\tnever\n> = requireKeys<\n\t{\n\t\tpreserveUndefined?: true\n\t\tchild?: boolean | ((value: instantiated) => BaseNode[])\n\t\tserialize?: (schema: instantiated) => Json\n\t\treduceIo?: (\n\t\t\tioKind: \"in\" | \"out\",\n\t\t\tinner: makeRootAndArrayPropertiesMutable<d[\"inner\"]>,\n\t\t\tvalue: d[\"inner\"][k]\n\t\t) => void\n\t\tparse?: (\n\t\t\tschema: Exclude<d[\"normalizedSchema\"][k], undefined>,\n\t\t\tctx: NodeParseContext<d[\"kind\"]>\n\t\t) => instantiated | undefined\n\t},\n\t// require parse if we can't guarantee the schema value will be valid on inner\n\t| (d[\"normalizedSchema\"][k] extends instantiated | undefined ? never\n\t  :\t\"parse\")\n\t// require keys containing children specify it, although it can be false in cases like\n\t// declaredOut where we don't want to treat the node as a child\n\t| ([instantiated] extends [listable<BaseNode>] ? \"child\" : never)\n>\n\ninterface CommonNodeImplementationInput<d extends BaseNodeDeclaration> {\n\tkind: d[\"kind\"]\n\tkeys: keySchemaDefinitions<d>\n\tnormalize: (schema: d[\"schema\"], $: BaseScope) => d[\"normalizedSchema\"]\n\tapplyConfig?: (\n\t\tschema: d[\"normalizedSchema\"],\n\t\tconfig: ResolvedScopeConfig\n\t) => d[\"normalizedSchema\"]\n\thasAssociatedError: d[\"errorContext\"] extends null ? false : true\n\tfinalizeInnerJson?: (json: {\n\t\t[k in keyof d[\"inner\"]]: Json\n\t}) => JsonStructure\n\tcollapsibleKey?: keyof d[\"inner\"]\n\treduce?: (\n\t\tinner: d[\"inner\"],\n\t\t$: BaseScope\n\t) => nodeOfKind<d[\"reducibleTo\"]> | Disjoint | undefined\n\tobviatesBasisDescription?: d[\"kind\"] extends RefinementKind ? true : never\n\tobviatesBasisExpression?: d[\"kind\"] extends RefinementKind ? true : never\n}\n\nexport interface UnknownNodeImplementation\n\textends CommonNodeImplementationInput<BaseNodeDeclaration> {\n\tdefaults: ResolvedUnknownNodeConfig\n\tintersectionIsOpen: boolean\n\tintersections: UnknownIntersectionMap\n\tkeys: Record<string, NodeKeyImplementation<any, any>>\n}\n\nexport const compileObjectLiteral = (ctx: object): string => {\n\tlet result = \"{ \"\n\tfor (const [k, v] of Object.entries(ctx))\n\t\tresult += `${k}: ${compileSerializedValue(v)}, `\n\treturn result + \" }\"\n}\n\nexport type nodeImplementationOf<d extends BaseNodeDeclaration> =\n\tnodeImplementationInputOf<d> & {\n\t\tintersections: IntersectionMap<d[\"kind\"]>\n\t\tintersectionIsOpen: d[\"intersectionIsOpen\"]\n\t\tdefaults: Required<NodeConfig<d[\"kind\"]>>\n\t}\n\nexport type nodeImplementationInputOf<d extends BaseNodeDeclaration> =\n\tCommonNodeImplementationInput<d> & {\n\t\tintersections: IntersectionMap<d[\"kind\"]>\n\t\tdefaults: nodeSchemaaultsImplementationInputFor<d[\"kind\"]>\n\t} & (d[\"intersectionIsOpen\"] extends true ? { intersectionIsOpen: true }\n\t\t:\t{}) &\n\t\t// if the node is declared as reducible to a kind other than its own,\n\t\t// there must be a reduce implementation\n\t\t(d[\"reducibleTo\"] extends d[\"kind\"] ? {} : { reduce: {} })\n\ntype nodeSchemaaultsImplementationInputFor<kind extends NodeKind> = requireKeys<\n\tNodeConfig<kind>,\n\t| \"description\"\n\t// if the node's error context is distinct from its inner definition, ensure it is implemented.\n\t// this occurs for nodes like `union` where the error that occurs is not 1:1 with the existing node,\n\t// but rather a single failed condition for each branch.\n\t| (Inner<kind> extends (\n\t\t\tOmit<errorContext<kind>, keyof BaseErrorContext | \"description\">\n\t  ) ?\n\t\t\tnever\n\t  :\t\"expected\" & keyof NodeConfig<kind>)\n>\n\nexport type DescriptionWriter<kind extends NodeKind = NodeKind> = (\n\tnode: nodeOfKind<kind>\n) => string\n\nexport interface UnknownAttachments {\n\treadonly kind: NodeKind\n\treadonly impl: UnknownNodeImplementation\n\treadonly id: NodeId\n\n\treadonly inner: Record<string, any>\n\treadonly innerEntries: readonly Entry<string>[]\n\treadonly innerJson: object\n\treadonly innerHash: string\n\n\treadonly meta: ArkEnv.meta\n\treadonly metaJson: object\n\n\treadonly json: object\n\treadonly hash: string\n\treadonly collapsibleJson: Json\n\treadonly children: BaseNode[]\n}\n\nexport interface NarrowedAttachments<d extends BaseNodeDeclaration>\n\textends UnknownAttachments {\n\tkind: d[\"kind\"]\n\tinner: d[\"inner\"]\n\tjson: JsonStructure\n\tinnerJson: JsonStructure\n\tcollapsibleJson: Json\n\tchildren: nodeOfKind<d[\"childKind\"]>[]\n}\n\nexport const implementNode = <d extends BaseNodeDeclaration = never>(\n\t_: nodeImplementationInputOf<d>\n): nodeImplementationOf<d> => {\n\tconst implementation: UnknownNodeImplementation = _ as never\n\tif (implementation.hasAssociatedError) {\n\t\timplementation.defaults.expected ??= ctx =>\n\t\t\t\"description\" in ctx ?\n\t\t\t\t(ctx.description as string)\n\t\t\t:\timplementation.defaults.description(ctx as never)\n\t\timplementation.defaults.actual ??= data => printable(data)\n\t\timplementation.defaults.problem ??= ctx =>\n\t\t\t`must be ${ctx.expected}${ctx.actual ? ` (was ${ctx.actual})` : \"\"}`\n\t\timplementation.defaults.message ??= ctx => {\n\t\t\tif (ctx.path.length === 0) return ctx.problem\n\t\t\tconst problemWithLocation = `${ctx.propString} ${ctx.problem}`\n\t\t\tif (problemWithLocation[0] === \"[\") {\n\t\t\t\t// clarify paths like [1], [0][1], and [\"key!\"] that could be confusing\n\t\t\t\treturn `value at ${problemWithLocation}`\n\t\t\t}\n\t\t\treturn problemWithLocation\n\t\t}\n\t}\n\treturn implementation as never\n}\n"
  },
  {
    "path": "ark/schema/shared/intersections.ts",
    "content": "import type { PartialRecord, TypeGuard } from \"@ark/util\"\nimport type { mutableNormalizedRootOfKind, nodeOfKind } from \"../kinds.ts\"\nimport type { BaseNode } from \"../node.ts\"\nimport type { Morph } from \"../roots/morph.ts\"\nimport type { BaseRoot } from \"../roots/root.ts\"\nimport type { Union } from \"../roots/union.ts\"\nimport type { BaseScope } from \"../scope.ts\"\nimport { Disjoint } from \"./disjoint.ts\"\nimport {\n\trootKinds,\n\ttype IntersectionContext,\n\ttype RootKind,\n\ttype UnknownIntersectionResult\n} from \"./implement.ts\"\nimport { isNode } from \"./utils.ts\"\n\nconst intersectionCache: PartialRecord<string, UnknownIntersectionResult> = {}\n\ntype InternalNodeIntersection<ctx> = <l extends BaseNode, r extends BaseNode>(\n\tl: l,\n\tr: r,\n\tctx: ctx\n) => l[\"kind\"] | r[\"kind\"] extends RootKind ? BaseRoot | Disjoint\n:\tBaseNode | Disjoint | null\n\nexport const intersectNodesRoot: InternalNodeIntersection<BaseScope> = (\n\tl,\n\tr,\n\t$\n) =>\n\tintersectOrPipeNodes(l, r, {\n\t\t$,\n\t\tinvert: false,\n\t\tpipe: false\n\t})\n\nexport const pipeNodesRoot: InternalNodeIntersection<BaseScope> = (l, r, $) =>\n\tintersectOrPipeNodes(l, r, {\n\t\t$,\n\t\tinvert: false,\n\t\tpipe: true\n\t})\n\nexport const intersectOrPipeNodes: InternalNodeIntersection<IntersectionContext> =\n\t((\n\t\tl: BaseNode,\n\t\tr: BaseNode,\n\t\tctx: IntersectionContext\n\t): BaseNode | Disjoint | null => {\n\t\tconst operator = ctx.pipe ? \"|>\" : \"&\"\n\t\tconst lrCacheKey = `${l.hash}${operator}${r.hash}`\n\t\tif (intersectionCache[lrCacheKey] !== undefined)\n\t\t\treturn intersectionCache[lrCacheKey]! as never\n\n\t\tif (!ctx.pipe) {\n\t\t\t// we can only use this for the commutative & operator\n\t\t\tconst rlCacheKey = `${r.hash}${operator}${l.hash}`\n\t\t\tif (intersectionCache[rlCacheKey] !== undefined) {\n\t\t\t\t// if the cached result was a Disjoint and the operands originally\n\t\t\t\t// appeared in the opposite order, we need to invert it to match\n\t\t\t\tconst rlResult = intersectionCache[rlCacheKey]!\n\t\t\t\tconst lrResult =\n\t\t\t\t\trlResult instanceof Disjoint ? rlResult.invert() : rlResult\n\t\t\t\t// add the lr result to the cache directly to bypass this check in the future\n\t\t\t\tintersectionCache[lrCacheKey] = lrResult\n\t\t\t\treturn lrResult\n\t\t\t}\n\t\t}\n\n\t\tconst isPureIntersection =\n\t\t\t!ctx.pipe || (!l.includesTransform && !r.includesTransform)\n\n\t\tif (isPureIntersection && l.equals(r)) return l\n\n\t\tlet result =\n\t\t\tisPureIntersection ? _intersectNodes(l, r, ctx)\n\t\t\t: l.hasKindIn(...rootKinds) ?\n\t\t\t\t// if l is a RootNode, r will be as well\n\t\t\t\t_pipeNodes(l, r as never, ctx)\n\t\t\t:\t_intersectNodes(l, r, ctx)\n\n\t\tif (isNode(result)) {\n\t\t\t// if the result equals one of the operands, preserve its metadata by\n\t\t\t// returning the original reference\n\t\t\tif (l.equals(result)) result = l\n\t\t\telse if (r.equals(result)) result = r\n\t\t}\n\n\t\tintersectionCache[lrCacheKey] = result\n\t\treturn result as never\n\t}) as never\n\nconst _intersectNodes = (\n\tl: BaseNode,\n\tr: BaseNode,\n\tctx: IntersectionContext\n) => {\n\tconst leftmostKind = l.precedence < r.precedence ? l.kind : r.kind\n\tconst implementation =\n\t\tl.impl.intersections[r.kind] ?? r.impl.intersections[l.kind]\n\tif (implementation === undefined) {\n\t\t// should be two ConstraintNodes that have no relation\n\t\t// this could also happen if a user directly intersects a Type and a ConstraintNode,\n\t\t// but that is not allowed by the external function signature\n\t\treturn null\n\t} else if (leftmostKind === l.kind) return implementation(l, r, ctx)\n\telse {\n\t\tlet result = implementation(r, l, { ...ctx, invert: !ctx.invert })\n\t\tif (result instanceof Disjoint) result = result.invert()\n\t\treturn result\n\t}\n}\n\nconst _pipeNodes = (\n\tl: nodeOfKind<RootKind>,\n\tr: nodeOfKind<RootKind>,\n\tctx: IntersectionContext\n) =>\n\tl.includesTransform || r.includesTransform ?\n\t\tctx.invert ?\n\t\t\tpipeMorphed(r, l, ctx)\n\t\t:\tpipeMorphed(l, r, ctx)\n\t:\t_intersectNodes(l, r, ctx)\n\nconst pipeMorphed = (\n\tfrom: nodeOfKind<RootKind>,\n\tto: nodeOfKind<RootKind>,\n\tctx: IntersectionContext\n) =>\n\tfrom.distribute(\n\t\tfromBranch => _pipeMorphed(fromBranch, to, ctx),\n\t\tresults => {\n\t\t\tconst viableBranches = results.filter(\n\t\t\t\tisNode as TypeGuard<unknown, Morph.Node>\n\t\t\t)\n\n\t\t\tif (viableBranches.length === 0)\n\t\t\t\treturn Disjoint.init(\"union\", from.branches, to.branches)\n\n\t\t\t// if the input type has changed, create a new node without preserving metadata\n\t\t\tif (\n\t\t\t\tviableBranches.length < from.branches.length ||\n\t\t\t\t!from.branches.every((branch, i) =>\n\t\t\t\t\tbranch.rawIn.equals(viableBranches[i].rawIn)\n\t\t\t\t)\n\t\t\t)\n\t\t\t\treturn ctx.$.parseSchema(viableBranches)\n\n\t\t\t// otherwise, the input has not changed so preserve metadata\n\n\t\t\tlet meta: ArkEnv.meta | undefined\n\n\t\t\tif (viableBranches.length === 1) {\n\t\t\t\tconst onlyBranch = viableBranches[0]\n\t\t\t\tif (!meta) return onlyBranch\n\t\t\t\treturn ctx.$.node(\"morph\", {\n\t\t\t\t\t...onlyBranch.inner,\n\t\t\t\t\tin: onlyBranch.rawIn.configure(meta, \"self\")\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tconst schema: mutableNormalizedRootOfKind<\"union\"> = {\n\t\t\t\tbranches: viableBranches\n\t\t\t}\n\n\t\t\tif (meta) schema.meta = meta\n\n\t\t\treturn ctx.$.parseSchema(schema)\n\t\t}\n\t)\n\nconst _pipeMorphed = (\n\tfrom: Union.ChildNode,\n\tto: nodeOfKind<RootKind>,\n\tctx: IntersectionContext\n): Morph.Node | Disjoint => {\n\tconst fromIsMorph = from.hasKind(\"morph\")\n\n\tif (fromIsMorph) {\n\t\tconst morphs = [...from.morphs]\n\t\tif (from.lastMorphIfNode) {\n\t\t\t// still piped from context, so allows appending additional morphs\n\t\t\tconst outIntersection = intersectOrPipeNodes(\n\t\t\t\tfrom.lastMorphIfNode,\n\t\t\t\tto,\n\t\t\t\tctx\n\t\t\t)\n\t\t\tif (outIntersection instanceof Disjoint) return outIntersection\n\t\t\tmorphs[morphs.length - 1] = outIntersection\n\t\t} else morphs.push(to)\n\n\t\treturn ctx.$.node(\"morph\", {\n\t\t\tmorphs,\n\t\t\tin: from.inner.in as any\n\t\t})\n\t}\n\n\tif (to.hasKind(\"morph\")) {\n\t\tconst inTersection = intersectOrPipeNodes(from, to.rawIn, ctx)\n\t\tif (inTersection instanceof Disjoint) return inTersection\n\n\t\treturn ctx.$.node(\"morph\", {\n\t\t\tmorphs: [to],\n\t\t\tin: inTersection\n\t\t})\n\t}\n\n\treturn ctx.$.node(\"morph\", {\n\t\tmorphs: [to],\n\t\tin: from\n\t})\n}\n"
  },
  {
    "path": "ark/schema/shared/jsonSchema.ts",
    "content": "import type {\n\tarray,\n\tautocomplete,\n\tJsonArray,\n\tJsonObject,\n\tlistable\n} from \"@ark/util\"\n\nexport type JsonSchema = JsonSchema.NonBooleanBranch\nexport type ListableJsonSchema = listable<JsonSchema>\nexport type JsonSchemaOrBoolean = listable<JsonSchema.Branch>\n\nexport declare namespace JsonSchema {\n\texport type TypeName =\n\t\t| \"string\"\n\t\t| \"integer\"\n\t\t| \"number\"\n\t\t| \"object\"\n\t\t| \"array\"\n\t\t| \"boolean\"\n\t\t| \"null\"\n\n\t/**\n\t *  a subset of JSON Schema's annotations, see:\n\t *  https://json-schema.org/understanding-json-schema/reference/annotations\n\t **/\n\texport interface Meta<t = unknown> extends UniversalMeta<t> {\n\t\t$schema?: string\n\t\t$defs?: Record<string, JsonSchema>\n\t}\n\n\texport type Format = autocomplete<\n\t\t| \"date-time\"\n\t\t| \"date\"\n\t\t| \"time\"\n\t\t| \"email\"\n\t\t| \"ipv4\"\n\t\t| \"ipv6\"\n\t\t| \"uri\"\n\t\t| \"uuid\"\n\t\t| \"regex\"\n\t>\n\n\t/**\n\t * doesn't include root-only keys like $schema\n\t */\n\texport interface UniversalMeta<t = unknown> {\n\t\ttitle?: string\n\t\tdescription?: string\n\t\tformat?: Format\n\t\tdeprecated?: true\n\t\tdefault?: t\n\t\texamples?: readonly t[]\n\t}\n\n\ttype Composition = Union | OneOf | Intersection | Not\n\n\ttype NonBooleanBranch =\n\t\t| Constrainable\n\t\t| Const\n\t\t| Composition\n\t\t| Enum\n\t\t| String\n\t\t| Numeric\n\t\t| Object\n\t\t| Array\n\t\t| Ref\n\n\texport type Branch = boolean | JsonSchema\n\n\texport type RefString = `#/$defs/${string}`\n\n\t// extending Meta and including \"type\" as an optional prop are important for\n\t// interacting with JsonSchema as a union, although generally $ref should be\n\t// the only key.\n\texport interface Ref extends Meta {\n\t\t$ref: RefString\n\t\ttype?: never\n\t}\n\n\texport interface Constrainable extends Meta {\n\t\ttype?: listable<TypeName>\n\t}\n\n\texport interface Intersection extends Meta {\n\t\tallOf: readonly JsonSchema[]\n\t}\n\n\texport interface Not extends Meta {\n\t\tnot: JsonSchema\n\t}\n\n\texport interface OneOf extends Meta {\n\t\toneOf: readonly JsonSchema[]\n\t}\n\n\texport interface Union extends Meta {\n\t\tanyOf: readonly JsonSchema[]\n\t}\n\n\texport interface Const extends Meta {\n\t\tconst: unknown\n\t}\n\n\texport interface Enum extends Meta {\n\t\tenum: array\n\t}\n\n\texport interface String extends Meta<string> {\n\t\ttype: \"string\"\n\t\tminLength?: number\n\t\tmaxLength?: number\n\t\tpattern?: string\n\t\tformat?: string\n\t}\n\n\t// NB: Technically 'exclusiveMaximum' and 'exclusiveMinimum' are mutually exclusive with 'maximum' and 'minimum', respectively,\n\t// which is reflected at runtime but it's not worth the performance cost to validate this statically.\n\texport interface Numeric extends Meta<number> {\n\t\ttype: \"number\" | \"integer\"\n\t\t// NB: JSON Schema allows decimal multipleOf, but ArkType only supports integer.\n\t\tmultipleOf?: number\n\t\tminimum?: number\n\t\texclusiveMinimum?: number\n\t\tmaximum?: number\n\t\texclusiveMaximum?: number\n\t}\n\n\t// NB: Technically 'properties' is required when 'required' is present,\n\t// which is reflected at runtime but it's not worth the performance cost to validate this statically.\n\texport interface Object extends Meta<JsonObject> {\n\t\ttype: \"object\"\n\t\tproperties?: Record<string, JsonSchema>\n\t\trequired?: string[]\n\t\tpatternProperties?: Record<string, JsonSchema>\n\t\tadditionalProperties?: JsonSchemaOrBoolean\n\t\tmaxProperties?: number\n\t\tminProperties?: number\n\t\tpropertyNames?: String\n\t}\n\n\texport interface Array extends Meta<JsonArray> {\n\t\ttype: \"array\"\n\t\tadditionalItems?: JsonSchemaOrBoolean\n\t\tcontains?: JsonSchemaOrBoolean\n\t\tuniqueItems?: boolean\n\t\tminItems?: number\n\t\tmaxItems?: number\n\t\titems?: JsonSchemaOrBoolean\n\t\tprefixItems?: readonly Branch[]\n\t}\n\n\texport type LengthBoundable = String | Array\n\n\texport type Structure = Object | Array\n}\n"
  },
  {
    "path": "ark/schema/shared/registry.ts",
    "content": "import { register, registry, type NonNegativeIntegerLiteral } from \"@ark/util\"\nimport type { ArkSchemaRegistry } from \"../config.ts\"\n\nlet _registryName = \"$ark\"\nlet suffix = 2\n\nwhile (_registryName in globalThis) _registryName = `$ark${suffix++}`\n\nexport const registryName = _registryName\n;(globalThis as any)[registryName] = registry\n\nexport const $ark: ArkSchemaRegistry = registry as never\n\nexport const reference = (name: string): RegisteredReference =>\n\t`${registryName}.${name}` as never\n\nexport const registeredReference = (\n\tvalue: object | symbol\n): RegisteredReference => reference(register(value))\n\nexport type RegisteredReference<to extends string = string> =\n\t`$ark${\"\" | NonNegativeIntegerLiteral}.${to}`\n"
  },
  {
    "path": "ark/schema/shared/standardSchema.ts",
    "content": "/** From https://github.com/standard-schema/standard-schema */\n\n/** The Standard Typed interface. This is a base type extended by other specs. */\nexport interface StandardTypedV1<Input = unknown, Output = Input> {\n\t/** The Standard properties. */\n\treadonly \"~standard\": StandardTypedV1.Props<Input, Output>\n}\n\nexport declare namespace StandardTypedV1 {\n\t/** The Standard Typed properties interface. */\n\texport interface Props<Input = unknown, Output = Input> {\n\t\t/** The version number of the standard. */\n\t\treadonly version: 1\n\t\t/** The vendor name of the schema library. */\n\t\treadonly vendor: string\n\t\t/** Inferred types associated with the schema. */\n\t\treadonly types?: Types<Input, Output> | undefined\n\t}\n\n\t/** The Standard Typed types interface. */\n\texport interface Types<Input = unknown, Output = Input> {\n\t\t/** The input type of the schema. */\n\t\treadonly input: Input\n\t\t/** The output type of the schema. */\n\t\treadonly output: Output\n\t}\n\n\t/** Infers the input type of a Standard Typed. */\n\texport type InferInput<Schema extends StandardTypedV1> = NonNullable<\n\t\tSchema[\"~standard\"][\"types\"]\n\t>[\"input\"]\n\n\t/** Infers the output type of a Standard Typed. */\n\texport type InferOutput<Schema extends StandardTypedV1> = NonNullable<\n\t\tSchema[\"~standard\"][\"types\"]\n\t>[\"output\"]\n}\n\n/** The Standard Schema interface. */\nexport interface StandardSchemaV1<Input = unknown, Output = Input> {\n\t/** The Standard Schema properties. */\n\treadonly \"~standard\": StandardSchemaV1.Props<Input, Output>\n}\n\nexport declare namespace StandardSchemaV1 {\n\t/** The Standard Schema properties interface. */\n\texport interface Props<Input = unknown, Output = Input>\n\t\textends StandardTypedV1.Props<Input, Output> {\n\t\t/** Validates unknown input values. */\n\t\treadonly validate: (\n\t\t\tvalue: unknown,\n\t\t\toptions?: StandardSchemaV1.Options | undefined\n\t\t) => Result<Output> | Promise<Result<Output>>\n\t}\n\n\t/** The result interface of the validate function. */\n\texport type Result<Output> = SuccessResult<Output> | FailureResult\n\n\t/** The result interface if validation succeeds. */\n\texport interface SuccessResult<Output> {\n\t\t/** The typed output value. */\n\t\treadonly value: Output\n\t\t/** A falsy value for `issues` indicates success. */\n\t\treadonly issues?: undefined\n\t}\n\n\texport interface Options {\n\t\t/** Explicit support for additional vendor-specific parameters, if needed. */\n\t\treadonly libraryOptions?: Record<string, unknown> | undefined\n\t}\n\n\t/** The result interface if validation fails. */\n\texport interface FailureResult {\n\t\t/** The issues of failed validation. */\n\t\treadonly issues: ReadonlyArray<Issue>\n\t}\n\n\t/** The issue interface of the failure output. */\n\texport interface Issue {\n\t\t/** The error message of the issue. */\n\t\treadonly message: string\n\t\t/** The path of the issue, if any. */\n\t\treadonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined\n\t}\n\n\t/** The path segment interface of the issue. */\n\texport interface PathSegment {\n\t\t/** The key representing a path segment. */\n\t\treadonly key: PropertyKey\n\t}\n\n\t/** The Standard types interface. */\n\texport interface Types<Input = unknown, Output = Input>\n\t\textends StandardTypedV1.Types<Input, Output> {}\n\n\t/** Infers the input type of a Standard. */\n\texport type InferInput<Schema extends StandardTypedV1> =\n\t\tStandardTypedV1.InferInput<Schema>\n\n\t/** Infers the output type of a Standard. */\n\texport type InferOutput<Schema extends StandardTypedV1> =\n\t\tStandardTypedV1.InferOutput<Schema>\n\n\t/** ArkType-specific properties that extend the standard schema with JSON Schema support. */\n\texport interface ArkTypeProps<Input = unknown, Output = Input>\n\t\textends Props<Input, Output>,\n\t\t\tStandardJSONSchemaV1.Props<Input, Output> {\n\t\tvendor: \"arktype\"\n\t}\n}\n\n/** The Standard JSON Schema interface. */\nexport interface StandardJSONSchemaV1<Input = unknown, Output = Input> {\n\t/** The Standard JSON Schema properties. */\n\treadonly \"~standard\": StandardJSONSchemaV1.Props<Input, Output>\n}\n\nexport declare namespace StandardJSONSchemaV1 {\n\t/** The Standard JSON Schema properties interface. */\n\texport interface Props<Input = unknown, Output = Input>\n\t\textends StandardTypedV1.Props<Input, Output> {\n\t\t/** Methods for generating the input/output JSON Schema. */\n\t\treadonly jsonSchema: StandardJSONSchemaV1.Converter\n\t}\n\n\t/** The Standard JSON Schema converter interface. */\n\texport interface Converter {\n\t\t/** Converts the input type to JSON Schema. May throw if conversion is not supported. */\n\t\treadonly input: (\n\t\t\toptions: StandardJSONSchemaV1.Options\n\t\t) => Record<string, unknown>\n\t\t/** Converts the output type to JSON Schema. May throw if conversion is not supported. */\n\t\treadonly output: (\n\t\t\toptions: StandardJSONSchemaV1.Options\n\t\t) => Record<string, unknown>\n\t}\n\n\t/**\n\t * The target version of the generated JSON Schema.\n\t *\n\t * It is *strongly recommended* that implementers support `\"draft-2020-12\"` and `\"draft-07\"`, as they are both in wide use. All other targets can be implemented on a best-effort basis. Libraries should throw if they don't support a specified target.\n\t *\n\t * The `\"openapi-3.0\"` target is intended as a standardized specifier for OpenAPI 3.0 which is a superset of JSON Schema `\"draft-04\"`.\n\t */\n\texport type Target =\n\t\t| \"draft-2020-12\"\n\t\t| \"draft-07\"\n\t\t| \"openapi-3.0\"\n\t\t// Accepts any string: allows future targets while preserving autocomplete\n\t\t| ({} & string)\n\n\t/** The options for the input/output methods. */\n\texport interface Options {\n\t\t/** Specifies the target version of the generated JSON Schema. Support for all versions is on a best-effort basis. If a given version is not supported, the library should throw. */\n\t\treadonly target: Target\n\n\t\t/** Explicit support for additional vendor-specific parameters, if needed. */\n\t\treadonly libraryOptions?: Record<string, unknown> | undefined\n\t}\n\n\t/** The Standard types interface. */\n\texport interface Types<Input = unknown, Output = Input>\n\t\textends StandardTypedV1.Types<Input, Output> {}\n\n\t/** Infers the input type of a Standard. */\n\texport type InferInput<Schema extends StandardTypedV1> =\n\t\tStandardTypedV1.InferInput<Schema>\n\n\t/** Infers the output type of a Standard. */\n\texport type InferOutput<Schema extends StandardTypedV1> =\n\t\tStandardTypedV1.InferOutput<Schema>\n}\n"
  },
  {
    "path": "ark/schema/shared/toJsonSchema.ts",
    "content": "import {\n\tprintable,\n\tthrowInternalError,\n\ttype Constructor,\n\ttype Domain,\n\ttype Json,\n\ttype requireKeys,\n\ttype satisfy\n} from \"@ark/util\"\nimport type { Predicate } from \"../predicate.ts\"\nimport type { ConstraintKind } from \"./implement.ts\"\nimport type { JsonSchema } from \"./jsonSchema.ts\"\nimport type { StandardJSONSchemaV1 } from \"./standardSchema.ts\"\n\nclass ToJsonSchemaError<\n\tcode extends ToJsonSchema.Code = ToJsonSchema.Code\n> extends Error {\n\treadonly name = \"ToJsonSchemaError\"\n\treadonly code: code\n\treadonly context: ToJsonSchema.ContextByCode[code]\n\n\tconstructor(code: code, context: ToJsonSchema.ContextByCode[code]) {\n\t\tsuper(printable(context, { quoteKeys: false, indent: 4 }))\n\t\tthis.code = code\n\t\tthis.context = context\n\t}\n\n\thasCode<code extends ToJsonSchema.Code>(\n\t\tcode: code\n\t): this is ToJsonSchemaError<code> {\n\t\treturn this.code === (code as never)\n\t}\n}\n\nconst defaultConfig: ToJsonSchema.Context = {\n\ttarget: \"draft-2020-12\",\n\tdialect: \"https://json-schema.org/draft/2020-12/schema\",\n\tuseRefs: false,\n\tfallback: {\n\t\tarrayObject: ctx => ToJsonSchema.throw(\"arrayObject\", ctx),\n\t\tarrayPostfix: ctx => ToJsonSchema.throw(\"arrayPostfix\", ctx),\n\t\tdefaultValue: ctx => ToJsonSchema.throw(\"defaultValue\", ctx),\n\t\tdomain: ctx => ToJsonSchema.throw(\"domain\", ctx),\n\t\tmorph: ctx => ToJsonSchema.throw(\"morph\", ctx),\n\t\tpatternIntersection: ctx => ToJsonSchema.throw(\"patternIntersection\", ctx),\n\t\tpredicate: ctx => ToJsonSchema.throw(\"predicate\", ctx),\n\t\tproto: ctx => ToJsonSchema.throw(\"proto\", ctx),\n\t\tsymbolKey: ctx => ToJsonSchema.throw(\"symbolKey\", ctx),\n\t\tunit: ctx => ToJsonSchema.throw(\"unit\", ctx),\n\t\tdate: ctx => ToJsonSchema.throw(\"date\", ctx)\n\t}\n}\n\nexport const ToJsonSchema = {\n\tError: ToJsonSchemaError,\n\tthrow: (...args: ConstructorParameters<typeof ToJsonSchemaError>): never => {\n\t\tthrow new ToJsonSchema.Error(...args)\n\t},\n\tthrowInternalOperandError: (\n\t\tkind: ConstraintKind,\n\t\tschema: JsonSchema\n\t): never =>\n\t\tthrowInternalError(\n\t\t\t`Unexpected JSON Schema input for ${kind}: ${printable(schema)}`\n\t\t),\n\tdefaultConfig\n}\n\nexport declare namespace ToJsonSchema {\n\texport type Unjsonifiable = object | symbol | bigint | undefined\n\n\texport type Error = InstanceType<typeof ToJsonSchema.Error>\n\n\texport interface BaseContext<\n\t\tcode extends Code,\n\t\tbase extends JsonSchema = JsonSchema\n\t> {\n\t\tcode: code\n\t\tbase: base\n\t}\n\n\texport interface ArrayObjectContext\n\t\textends BaseContext<\"arrayObject\", JsonSchema.Array> {\n\t\tobject: JsonSchema.Object\n\t}\n\n\texport interface ArrayPostfixContext\n\t\textends BaseContext<\"arrayPostfix\", VariadicArraySchema> {\n\t\telements: readonly JsonSchema[]\n\t}\n\n\texport interface DefaultValueContext\n\t\textends BaseContext<\"defaultValue\", JsonSchema> {\n\t\tvalue: Unjsonifiable\n\t}\n\n\texport interface DomainContext extends BaseContext<\"domain\", JsonSchema> {\n\t\tdomain: satisfy<Domain, \"symbol\" | \"bigint\" | \"undefined\">\n\t}\n\n\texport interface MorphContext extends BaseContext<\"morph\", JsonSchema> {\n\t\tout: JsonSchema | null\n\t}\n\n\texport interface PatternIntersectionContext\n\t\textends BaseContext<\"patternIntersection\", StringSchemaWithPattern> {\n\t\tpattern: string\n\t}\n\n\texport interface PredicateContext\n\t\textends BaseContext<\"predicate\", JsonSchema> {\n\t\tpredicate: Predicate\n\t}\n\n\texport interface ProtoContext extends BaseContext<\"proto\", JsonSchema> {\n\t\tproto: Constructor\n\t}\n\n\texport type SymbolKeyContext =\n\t\t| IndexSymbolKeyContext\n\t\t| RequiredSymbolKeyContext\n\t\t| OptionalSymbolKeyContext\n\n\tinterface IndexSymbolKeyContext\n\t\textends BaseContext<\"symbolKey\", JsonSchema.Object> {\n\t\tkey: null\n\t\tvalue: JsonSchema\n\t\toptional: false\n\t}\n\n\tinterface RequiredSymbolKeyContext\n\t\textends BaseContext<\"symbolKey\", JsonSchema.Object> {\n\t\tkey: symbol\n\t\tvalue: JsonSchema\n\t\toptional: false\n\t}\n\n\tinterface OptionalSymbolKeyContext\n\t\textends BaseContext<\"symbolKey\", JsonSchema.Object> {\n\t\tkey: symbol\n\t\tvalue: JsonSchema\n\t\toptional: true\n\t\tdefault?: Json\n\t}\n\n\texport interface UnitContext extends BaseContext<\"unit\", JsonSchema> {\n\t\tunit: Unjsonifiable\n\t}\n\n\texport interface DateContext extends BaseContext<\"date\", JsonSchema> {\n\t\tbefore?: Date\n\t\tafter?: Date\n\t}\n\n\texport interface ContextByCode {\n\t\tarrayObject: ArrayObjectContext\n\t\tarrayPostfix: ArrayPostfixContext\n\t\tdefaultValue: DefaultValueContext\n\t\tdomain: DomainContext\n\t\tmorph: MorphContext\n\t\tpatternIntersection: PatternIntersectionContext\n\t\tpredicate: PredicateContext\n\t\tproto: ProtoContext\n\t\tsymbolKey: SymbolKeyContext\n\t\tunit: UnitContext\n\t\tdate: DateContext\n\t}\n\n\texport type Code = keyof ContextByCode\n\n\texport type FallbackContext = ContextByCode[Code]\n\n\texport type HandlerByCode = satisfy<\n\t\t{ [code in Code]: (ctx: ContextByCode[code]) => unknown },\n\t\t{\n\t\t\tarrayObject: (ctx: ArrayObjectContext) => JsonSchema.Structure\n\t\t\tarrayPostfix: (ctx: ArrayPostfixContext) => VariadicArraySchema\n\t\t\tdefaultValue: (ctx: DefaultValueContext) => JsonSchema\n\t\t\tdomain: (ctx: DomainContext) => JsonSchema\n\t\t\tmorph: (ctx: MorphContext) => JsonSchema\n\t\t\tpatternIntersection: (\n\t\t\t\tctx: PatternIntersectionContext\n\t\t\t) => JsonSchema.String\n\t\t\tpredicate: (ctx: PredicateContext) => JsonSchema\n\t\t\tproto: (ctx: ProtoContext) => JsonSchema\n\t\t\tsymbolKey: (ctx: SymbolKeyContext) => JsonSchema.Object\n\t\t\tunit: (ctx: UnitContext) => JsonSchema\n\t\t\tdate: (ctx: DateContext) => JsonSchema\n\t\t}\n\t>\n\n\texport type VariadicArraySchema = requireKeys<JsonSchema.Array, \"items\">\n\n\texport type StringSchemaWithPattern = requireKeys<\n\t\tJsonSchema.String,\n\t\t\"pattern\"\n\t>\n\n\texport type UniversalFallback = (ctx: FallbackContext) => JsonSchema\n\n\texport interface FallbackObject extends Partial<HandlerByCode> {\n\t\tdefault?: UniversalFallback\n\t}\n\n\texport type FallbackOption = UniversalFallback | FallbackObject\n\n\texport type Target = satisfy<\n\t\tStandardJSONSchemaV1.Target,\n\t\t\"draft-2020-12\" | \"draft-07\"\n\t>\n\n\texport interface Options {\n\t\t/** value to assign to the generated $schema key\n\t\t *\n\t\t *  - set to `null` to omit the `$schema` key\n\t\t *  - does not affect the contents of the generated schema\n\t\t *  - if `target` is also specified, `dialect` takes precedence\n\t\t *\n\t\t * @default \"https://json-schema.org/draft/2020-12/schema\"\n\t\t */\n\t\tdialect?: string | null\n\t\t/**\n\t\t * Shorthand for specifying the target JSON Schema version.\n\t\t * Maps to the appropriate `dialect` URL.\n\t\t *\n\t\t *  - \"draft-2020-12\" -> \"https://json-schema.org/draft/2020-12/schema\"\n\t\t *  - \"draft-07\" -> \"http://json-schema.org/draft-07/schema#\"\n\t\t *\n\t\t * If `dialect` is also specified, `dialect` takes precedence.\n\t\t */\n\t\ttarget?: Target\n\t\tuseRefs?: boolean\n\t\tfallback?: FallbackOption\n\t}\n\n\texport interface Context extends Required<Options> {\n\t\tfallback: HandlerByCode\n\t}\n}\n"
  },
  {
    "path": "ark/schema/shared/traversal.ts",
    "content": "import { ReadonlyPath, stringifyPath, type array } from \"@ark/util\"\nimport type { ResolvedConfig } from \"../config.ts\"\nimport type { Morph } from \"../roots/morph.ts\"\nimport {\n\tArkError,\n\tArkErrors,\n\ttype ArkErrorCode,\n\ttype ArkErrorContextInput,\n\ttype ArkErrorInput,\n\ttype NodeErrorContextInput\n} from \"./errors.ts\"\nimport { isNode } from \"./utils.ts\"\n\nexport type MorphsAtPath = {\n\tpath: ReadonlyPath\n\tmorphs: array<Morph>\n}\n\nexport type BranchTraversal = {\n\terror: ArkError | undefined\n\tqueuedMorphs: MorphsAtPath[]\n}\n\n// avoid sugar methods internally\nexport type InternalTraversal = Omit<Traversal, \"error\" | \"mustBe\" | \"reject\">\n\nexport class Traversal {\n\t/**\n\t * #### the path being validated or morphed\n\t *\n\t * ✅ array indices represented as numbers\n\t * ⚠️ mutated during traversal - use `path.slice(0)` to snapshot\n\t * 🔗 use {@link propString} for a stringified version\n\t */\n\tpath: PropertyKey[] = []\n\n\t/**\n\t * #### {@link ArkErrors} that will be part of this traversal's finalized result\n\t *\n\t * ✅ will always be an empty array for a valid traversal\n\t */\n\terrors: ArkErrors = new ArkErrors(this)\n\n\t/**\n\t * #### the original value being traversed\n\t */\n\troot: unknown\n\n\t/**\n\t * #### configuration for this traversal\n\t *\n\t * ✅ options can affect traversal results and error messages\n\t * ✅ defaults < global config < scope config\n\t * ✅ does not include options configured on individual types\n\t */\n\tconfig: ResolvedConfig\n\n\tqueuedMorphs: MorphsAtPath[] = []\n\tbranches: BranchTraversal[] = []\n\tseen: { [id in string]?: unknown[] } = {}\n\n\tconstructor(root: unknown, config: ResolvedConfig) {\n\t\tthis.root = root\n\t\tthis.config = config\n\t}\n\n\t/**\n\t * #### the data being validated or morphed\n\t *\n\t * ✅ extracted from {@link root} at {@link path}\n\t */\n\tget data(): unknown {\n\t\tlet result: any = this.root\n\t\tfor (const segment of this.path) result = result?.[segment]\n\n\t\treturn result\n\t}\n\n\t/**\n\t * #### a string representing {@link path}\n\t *\n\t * @propString\n\t */\n\tget propString(): string {\n\t\treturn stringifyPath(this.path)\n\t}\n\n\t/**\n\t * #### add an {@link ArkError} and return `false`\n\t *\n\t * ✅ useful for predicates like `.narrow`\n\t */\n\treject(input: ArkErrorInput): false {\n\t\tthis.error(input)\n\t\treturn false\n\t}\n\n\t/**\n\t * #### add an {@link ArkError} from a description and return `false`\n\t *\n\t * ✅ useful for predicates like `.narrow`\n\t * 🔗 equivalent to {@link reject}({ expected })\n\t */\n\tmustBe(expected: string): false {\n\t\tthis.error(expected)\n\t\treturn false\n\t}\n\n\t/**\n\t * #### add and return an {@link ArkError}\n\t *\n\t * ✅ useful for morphs like `.pipe`\n\t */\n\terror<input extends ArkErrorInput>(\n\t\tinput: input\n\t): ArkError<\n\t\tinput extends { code: ArkErrorCode } ? input[\"code\"] : \"predicate\"\n\t>\n\terror(input: ArkErrorInput): ArkError {\n\t\tconst errCtx: ArkErrorContextInput =\n\t\t\ttypeof input === \"object\" ?\n\t\t\t\tinput.code ?\n\t\t\t\t\tinput\n\t\t\t\t:\t{ ...input, code: \"predicate\" }\n\t\t\t:\t{ code: \"predicate\", expected: input }\n\t\treturn this.errorFromContext(errCtx)\n\t}\n\n\t/**\n\t * #### whether {@link currentBranch} (or the traversal root, outside a union) has one or more errors\n\t */\n\thasError(): boolean {\n\t\treturn this.currentErrorCount !== 0\n\t}\n\n\tget currentBranch(): BranchTraversal | undefined {\n\t\treturn this.branches[this.branches.length - 1]\n\t}\n\n\tqueueMorphs(morphs: array<Morph>): void {\n\t\tconst input: MorphsAtPath = {\n\t\t\tpath: new ReadonlyPath(...this.path),\n\t\t\tmorphs\n\t\t}\n\t\tif (this.currentBranch) this.currentBranch.queuedMorphs.push(input)\n\t\telse this.queuedMorphs.push(input)\n\t}\n\n\tfinalize(onFail?: ArkErrors.Handler | null): unknown {\n\t\tif (this.queuedMorphs.length) {\n\t\t\tif (\n\t\t\t\ttypeof this.root === \"object\" &&\n\t\t\t\tthis.root !== null &&\n\t\t\t\tthis.config.clone\n\t\t\t)\n\t\t\t\tthis.root = this.config.clone(this.root)\n\n\t\t\tthis.applyQueuedMorphs()\n\t\t}\n\n\t\tif (this.hasError()) return onFail ? onFail(this.errors) : this.errors\n\n\t\treturn this.root\n\t}\n\n\tget currentErrorCount(): number {\n\t\treturn (\n\t\t\tthis.currentBranch ?\n\t\t\t\tthis.currentBranch.error ?\n\t\t\t\t\t1\n\t\t\t\t:\t0\n\t\t\t:\tthis.errors.count\n\t\t)\n\t}\n\n\tget failFast(): boolean {\n\t\treturn this.branches.length !== 0\n\t}\n\n\tpushBranch(): void {\n\t\tthis.branches.push({\n\t\t\terror: undefined,\n\t\t\tqueuedMorphs: []\n\t\t})\n\t}\n\n\tpopBranch(): BranchTraversal | undefined {\n\t\treturn this.branches.pop()\n\t}\n\n\t/**\n\t * @internal\n\t * Convenience for casting from InternalTraversal to Traversal\n\t * for cases where the extra methods on the external type are expected, e.g.\n\t * a morph or predicate.\n\t */\n\tget external(): this {\n\t\treturn this\n\t}\n\n\t/**\n\t * @internal\n\t */\n\terrorFromNodeContext<input extends NodeErrorContextInput>(\n\t\tinput: input\n\t): ArkError<input[\"code\"]>\n\terrorFromNodeContext(input: NodeErrorContextInput): ArkError {\n\t\treturn this.errorFromContext(input)\n\t}\n\n\tprivate errorFromContext(errCtx: ArkErrorContextInput): ArkError {\n\t\tconst error = new ArkError(errCtx, this)\n\t\tif (this.currentBranch) this.currentBranch.error = error\n\t\telse this.errors.add(error)\n\n\t\treturn error as never\n\t}\n\n\tprivate applyQueuedMorphs() {\n\t\t// invoking morphs that are Nodes will reuse this context, potentially\n\t\t// adding additional morphs, so we have to continue looping until\n\t\t// queuedMorphs is empty rather than iterating over the list once\n\t\twhile (this.queuedMorphs.length) {\n\t\t\tconst queuedMorphs = this.queuedMorphs\n\t\t\tthis.queuedMorphs = []\n\t\t\tfor (const { path, morphs } of queuedMorphs) {\n\t\t\t\t// even if we already have an error, apply morphs that are not at a path\n\t\t\t\t// with errors to capture potential validation errors\n\t\t\t\tif (this.errors.affectsPath(path)) continue\n\t\t\t\tthis.applyMorphsAtPath(path, morphs)\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate applyMorphsAtPath(path: ReadonlyPath, morphs: array<Morph>): void {\n\t\tconst key = path[path.length - 1]\n\n\t\tlet parent: any\n\n\t\tif (key !== undefined) {\n\t\t\t// find the object on which the key to be morphed exists\n\t\t\tparent = this.root\n\t\t\tfor (let pathIndex = 0; pathIndex < path.length - 1; pathIndex++)\n\t\t\t\tparent = parent[path[pathIndex]]\n\t\t}\n\n\t\tfor (const morph of morphs) {\n\t\t\t// ensure morphs are applied relative to the correct path\n\t\t\t// in case previous operations modified this.path\n\t\t\tthis.path = [...path]\n\t\t\tconst morphIsNode = isNode(morph)\n\n\t\t\tconst result = morph(\n\t\t\t\t(parent === undefined ? this.root : parent[key!]) as never,\n\t\t\t\tthis\n\t\t\t)\n\n\t\t\tif (result instanceof ArkError) {\n\t\t\t\t// if an ArkError was returned, ensure it has been added to errors\n\t\t\t\tthis.errors.add(result)\n\n\t\t\t\t// skip any remaining morphs at the current path\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (result instanceof ArkErrors) {\n\t\t\t\t// if the morph was a direct reference to another node,\n\t\t\t\t// errors will have been added directly via this piped context\n\t\t\t\tif (!morphIsNode) {\n\t\t\t\t\t// otherwise, we have to ensure each error has been added\n\t\t\t\t\tthis.errors.merge(result)\n\t\t\t\t}\n\t\t\t\t// skip any remaining morphs at the current path\n\t\t\t\tthis.queuedMorphs = []\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\t// if the morph was successful, assign the result to the\n\t\t\t// corresponding property, or to root if path is empty\n\t\t\tif (parent === undefined) this.root = result\n\t\t\telse parent[key!] = result\n\n\t\t\t// if the current morph queued additional morphs,\n\t\t\t// applying them before subsequent morphs\n\t\t\tthis.applyQueuedMorphs()\n\t\t}\n\t}\n}\n\nexport const traverseKey = <result>(\n\tkey: PropertyKey,\n\tfn: () => result,\n\t// ctx will be undefined if this node isn't context-dependent\n\tctx: InternalTraversal | undefined\n): result => {\n\tif (!ctx) return fn()\n\n\tctx.path.push(key)\n\tconst result = fn()\n\tctx.path.pop()\n\treturn result\n}\n\nexport type TraversalMethodsByKind<input = unknown> = {\n\tAllows: TraverseAllows<input>\n\tApply: TraverseApply<input>\n\tOptimistic: TraverseApply<input>\n}\n\nexport type TraversalKind = keyof TraversalMethodsByKind & {}\n\nexport type TraverseAllows<data = unknown> = (\n\tdata: data,\n\tctx: InternalTraversal\n) => boolean\n\nexport type TraverseApply<data = unknown> = (\n\tdata: data,\n\tctx: InternalTraversal\n) => void\n"
  },
  {
    "path": "ark/schema/shared/utils.ts",
    "content": "import {\n\tflatMorph,\n\tisArray,\n\tnoSuggest,\n\ttype array,\n\ttype mutable,\n\ttype show,\n\ttype Thunk\n} from \"@ark/util\"\nimport type { BaseConstraint } from \"../constraint.ts\"\nimport type { GenericRoot } from \"../generic.ts\"\nimport type { InternalModule } from \"../module.ts\"\nimport type { BaseNode } from \"../node.ts\"\nimport type { BaseParseContext } from \"../parse.ts\"\nimport type { BaseRoot } from \"../roots/root.ts\"\nimport type { BaseScope } from \"../scope.ts\"\nimport type { ArkError, ArkErrors } from \"./errors.ts\"\n\nexport const makeRootAndArrayPropertiesMutable = <o extends object>(\n\to: o\n): makeRootAndArrayPropertiesMutable<o> =>\n\t// this cast should not be required, but it seems TS is referencing\n\t// the wrong parameters here?\n\tflatMorph(o as never, (k, v) => [k, isArray(v) ? [...v] : v]) as never\n\nexport type makeRootAndArrayPropertiesMutable<inner> = {\n\t-readonly [k in keyof inner]: inner[k] extends array | undefined ?\n\t\tmutable<inner[k]>\n\t:\tinner[k]\n} & unknown\n\nexport type internalImplementationOf<\n\texternal,\n\ttypeOnlyKey extends keyof external = never\n> = {\n\t// ensure functions accept compatible numbers of args\n\t[k in Exclude<keyof external, typeOnlyKey>]: external[k] extends (\n\t\t(...args: infer args) => unknown\n\t) ?\n\t\t(...args: { [i in keyof args]: never }) => unknown\n\t:\tunknown\n}\n\nexport type arkKind = typeof arkKind\n\nexport const arkKind = noSuggest(\"arkKind\")\n\nexport interface ArkKinds {\n\tconstraint: BaseConstraint\n\troot: BaseRoot\n\tscope: BaseScope\n\tgeneric: GenericRoot\n\tmodule: InternalModule\n\terror: ArkError\n\terrors: ArkErrors\n\tcontext: BaseParseContext\n}\n\nexport type ArkKind = show<keyof ArkKinds>\n\nexport const hasArkKind = <kind extends ArkKind>(\n\tvalue: unknown,\n\tkind: kind\n): value is ArkKinds[kind] => (value as any)?.[arkKind] === kind\n\nexport const isNode = (value: unknown): value is BaseNode =>\n\thasArkKind(value, \"root\") || hasArkKind(value, \"constraint\")\n\nexport type unwrapDefault<thunkableValue> =\n\tthunkableValue extends Thunk<infer returnValue> ? returnValue : thunkableValue\n"
  },
  {
    "path": "ark/schema/structure/index.ts",
    "content": "import {\n\tappend,\n\tprintable,\n\tstringAndSymbolicEntriesOf,\n\tthrowParseError\n} from \"@ark/util\"\nimport { BaseConstraint } from \"../constraint.ts\"\nimport type { RootSchema, nodeOfKind } from \"../kinds.ts\"\nimport {\n\tflatRef,\n\ttype BaseNode,\n\ttype DeepNodeTransformContext,\n\ttype DeepNodeTransformation\n} from \"../node.ts\"\nimport type { BaseRoot } from \"../roots/root.ts\"\nimport type { BaseNormalizedSchema, declareNode } from \"../shared/declare.ts\"\nimport { Disjoint } from \"../shared/disjoint.ts\"\nimport {\n\timplementNode,\n\ttype RootKind,\n\ttype nodeImplementationOf\n} from \"../shared/implement.ts\"\nimport { intersectOrPipeNodes } from \"../shared/intersections.ts\"\nimport { $ark } from \"../shared/registry.ts\"\nimport {\n\ttraverseKey,\n\ttype TraverseAllows,\n\ttype TraverseApply\n} from \"../shared/traversal.ts\"\n\nexport declare namespace Index {\n\texport type KeyKind = Exclude<RootKind, \"unit\">\n\n\texport type KeyNode = nodeOfKind<KeyKind>\n\n\texport interface Schema extends BaseNormalizedSchema {\n\t\treadonly signature: RootSchema<KeyKind>\n\t\treadonly value: RootSchema\n\t}\n\n\texport interface Inner {\n\t\treadonly signature: KeyNode\n\t\treadonly value: BaseRoot\n\t}\n\n\texport interface Declaration\n\t\textends declareNode<{\n\t\t\tkind: \"index\"\n\t\t\tschema: Schema\n\t\t\tnormalizedSchema: Schema\n\t\t\tinner: Inner\n\t\t\tprerequisite: object\n\t\t\tintersectionIsOpen: true\n\t\t\tchildKind: RootKind\n\t\t}> {}\n\n\texport type Node = IndexNode\n}\n\nconst implementation: nodeImplementationOf<Index.Declaration> =\n\timplementNode<Index.Declaration>({\n\t\tkind: \"index\",\n\t\thasAssociatedError: false,\n\t\tintersectionIsOpen: true,\n\t\tkeys: {\n\t\t\tsignature: {\n\t\t\t\tchild: true,\n\t\t\t\tparse: (schema, ctx) => {\n\t\t\t\t\tconst key = ctx.$.parseSchema(schema)\n\t\t\t\t\tif (!key.extends($ark.intrinsic.key)) {\n\t\t\t\t\t\treturn throwParseError(\n\t\t\t\t\t\t\twriteInvalidPropertyKeyMessage(key.expression)\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tconst enumerableBranches = key.branches.filter(b => b.hasKind(\"unit\"))\n\t\t\t\t\tif (enumerableBranches.length) {\n\t\t\t\t\t\treturn throwParseError(\n\t\t\t\t\t\t\twriteEnumerableIndexBranches(\n\t\t\t\t\t\t\t\tenumerableBranches.map(b => printable(b.unit))\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\treturn key as Index.KeyNode\n\t\t\t\t}\n\t\t\t},\n\t\t\tvalue: {\n\t\t\t\tchild: true,\n\t\t\t\tparse: (schema, ctx) => ctx.$.parseSchema(schema)\n\t\t\t}\n\t\t},\n\t\tnormalize: schema => schema,\n\t\tdefaults: {\n\t\t\tdescription: node =>\n\t\t\t\t`[${node.signature.expression}]: ${node.value.description}`\n\t\t},\n\t\tintersections: {\n\t\t\tindex: (l, r, ctx) => {\n\t\t\t\tif (l.signature.equals(r.signature)) {\n\t\t\t\t\tconst valueIntersection = intersectOrPipeNodes(l.value, r.value, ctx)\n\t\t\t\t\tconst value =\n\t\t\t\t\t\tvalueIntersection instanceof Disjoint ?\n\t\t\t\t\t\t\t$ark.intrinsic.never.internal\n\t\t\t\t\t\t:\tvalueIntersection\n\t\t\t\t\treturn ctx.$.node(\"index\", { signature: l.signature, value })\n\t\t\t\t}\n\n\t\t\t\t// if r constrains all of l's keys to a subtype of l's value, r is a subtype of l\n\t\t\t\tif (l.signature.extends(r.signature) && l.value.subsumes(r.value))\n\t\t\t\t\treturn r\n\t\t\t\t// if l constrains all of r's keys to a subtype of r's value, l is a subtype of r\n\t\t\t\tif (r.signature.extends(l.signature) && r.value.subsumes(l.value))\n\t\t\t\t\treturn l\n\n\t\t\t\t// other relationships between index signatures can't be generally reduced\n\t\t\t\treturn null\n\t\t\t}\n\t\t}\n\t})\n\nexport class IndexNode extends BaseConstraint<Index.Declaration> {\n\timpliedBasis: BaseRoot = $ark.intrinsic.object.internal\n\texpression = `[${this.signature.expression}]: ${this.value.expression}`\n\n\tflatRefs = append(\n\t\tthis.value.flatRefs.map(ref =>\n\t\t\tflatRef([this.signature, ...ref.path], ref.node)\n\t\t),\n\t\tflatRef([this.signature], this.value)\n\t)\n\n\ttraverseAllows: TraverseAllows<object> = (data, ctx) =>\n\t\tstringAndSymbolicEntriesOf(data).every(entry => {\n\t\t\tif (this.signature.traverseAllows(entry[0], ctx)) {\n\t\t\t\treturn traverseKey(\n\t\t\t\t\tentry[0],\n\t\t\t\t\t() => this.value.traverseAllows(entry[1], ctx),\n\t\t\t\t\tctx\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn true\n\t\t})\n\n\ttraverseApply: TraverseApply<object> = (data, ctx) => {\n\t\tfor (const entry of stringAndSymbolicEntriesOf(data)) {\n\t\t\tif (this.signature.traverseAllows(entry[0], ctx)) {\n\t\t\t\ttraverseKey(\n\t\t\t\t\tentry[0],\n\t\t\t\t\t() => this.value.traverseApply(entry[1], ctx),\n\t\t\t\t\tctx\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected override _transform(\n\t\tmapper: DeepNodeTransformation,\n\t\tctx: DeepNodeTransformContext\n\t): BaseNode | null {\n\t\tctx.path.push(this.signature)\n\t\tconst result = super._transform(mapper, ctx)\n\t\tctx.path.pop()\n\t\treturn result\n\t}\n\n\tcompile(): void {\n\t\t// this is currently handled by StructureNode\n\t}\n}\n\nexport const Index = {\n\timplementation,\n\tNode: IndexNode\n}\n\nexport const writeEnumerableIndexBranches = (keys: string[]): string =>\n\t`Index keys ${keys.join(\", \")} should be specified as named props.`\n\nexport const writeInvalidPropertyKeyMessage = <indexSchema extends string>(\n\tindexSchema: indexSchema\n): writeInvalidPropertyKeyMessage<indexSchema> =>\n\t`Indexed key definition '${indexSchema}' must be a string or symbol`\n\nexport type writeInvalidPropertyKeyMessage<indexSchema extends string> =\n\t`Indexed key definition '${indexSchema}' must be a string or symbol`\n"
  },
  {
    "path": "ark/schema/structure/optional.ts",
    "content": "import {\n\thasDomain,\n\tisThunk,\n\tomit,\n\tprintable,\n\tthrowParseError,\n\ttype requireKeys\n} from \"@ark/util\"\nimport { intrinsic } from \"../intrinsic.ts\"\nimport type { Morph } from \"../roots/morph.ts\"\nimport type { BaseRoot } from \"../roots/root.ts\"\nimport { compileSerializedValue } from \"../shared/compile.ts\"\nimport type { declareNode } from \"../shared/declare.ts\"\nimport { ArkErrors } from \"../shared/errors.ts\"\nimport {\n\tdefaultValueSerializer,\n\timplementNode,\n\ttype nodeImplementationOf\n} from \"../shared/implement.ts\"\nimport { registeredReference } from \"../shared/registry.ts\"\nimport { traverseKey } from \"../shared/traversal.ts\"\nimport { BaseProp, intersectProps, type Prop } from \"./prop.ts\"\n\nexport declare namespace Optional {\n\texport interface Schema extends Prop.Schema {\n\t\tdefault?: unknown\n\t}\n\n\texport interface Inner extends Prop.Inner {\n\t\tdefault?: unknown\n\t}\n\n\texport type Declaration = declareNode<\n\t\tProp.Declaration<\"optional\"> & {\n\t\t\tschema: Schema\n\t\t\tnormalizedSchema: Schema\n\t\t\tinner: Inner\n\t\t}\n\t>\n\n\texport type Node = OptionalNode\n\n\texport namespace Node {\n\t\texport type withDefault = requireKeys<\n\t\t\tNode,\n\t\t\t\"default\" | \"defaultValueMorph\" | \"defaultValueMorphRef\"\n\t\t>\n\t}\n}\n\nconst implementation: nodeImplementationOf<Optional.Declaration> =\n\timplementNode<Optional.Declaration>({\n\t\tkind: \"optional\",\n\t\thasAssociatedError: false,\n\t\tintersectionIsOpen: true,\n\t\tkeys: {\n\t\t\tkey: {},\n\t\t\tvalue: {\n\t\t\t\tchild: true,\n\t\t\t\tparse: (schema, ctx) => ctx.$.parseSchema(schema)\n\t\t\t},\n\t\t\tdefault: {\n\t\t\t\tpreserveUndefined: true\n\t\t\t}\n\t\t},\n\t\tnormalize: schema => schema,\n\t\treduce: (inner, $) => {\n\t\t\tif ($.resolvedConfig.exactOptionalPropertyTypes === false) {\n\t\t\t\tif (!inner.value.allows(undefined)) {\n\t\t\t\t\treturn $.node(\n\t\t\t\t\t\t\"optional\",\n\t\t\t\t\t\t{ ...inner, value: inner.value.or(intrinsic.undefined) },\n\t\t\t\t\t\t{ prereduced: true }\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tdefaults: {\n\t\t\tdescription: node => `${node.compiledKey}?: ${node.value.description}`\n\t\t},\n\t\tintersections: {\n\t\t\toptional: intersectProps\n\t\t}\n\t})\n\nexport class OptionalNode extends BaseProp<\"optional\"> {\n\tconstructor(...args: ConstructorParameters<typeof BaseProp>) {\n\t\tsuper(...args)\n\t\tif (\"default\" in this.inner)\n\t\t\tassertDefaultValueAssignability(this.value, this.inner.default, this.key)\n\t}\n\n\toverride get rawIn(): OptionalNode {\n\t\tconst baseIn = super.rawIn\n\t\tif (!this.hasDefault()) return baseIn as never\n\n\t\treturn this.$.node(\n\t\t\t\"optional\",\n\t\t\tomit(baseIn.inner, { default: true }) as never,\n\t\t\t{\n\t\t\t\tprereduced: true\n\t\t\t}\n\t\t)\n\t}\n\n\tget outProp(): Prop.Node {\n\t\tif (!this.hasDefault()) return this\n\t\tconst { default: defaultValue, ...requiredInner } = this.inner\n\n\t\treturn this.cacheGetter(\n\t\t\t\"outProp\",\n\t\t\tthis.$.node(\"required\", requiredInner, { prereduced: true }) as never\n\t\t)\n\t}\n\n\texpression: string =\n\t\tthis.hasDefault() ?\n\t\t\t`${this.compiledKey}: ${this.value.expression} = ${printable(this.inner.default)}`\n\t\t:\t`${this.compiledKey}?: ${this.value.expression}`\n\n\tdefaultValueMorph: Morph | undefined = getDefaultableMorph(this)\n\n\tdefaultValueMorphRef: string | undefined =\n\t\tthis.defaultValueMorph && registeredReference(this.defaultValueMorph)\n}\n\nexport const Optional = {\n\timplementation,\n\tNode: OptionalNode\n}\n\nconst defaultableMorphCache: Record<string, Morph | undefined> = {}\n\nconst getDefaultableMorph = (node: Optional.Node): Morph | undefined => {\n\tif (!node.hasDefault()) return\n\n\tconst cacheKey = `{${node.compiledKey}: ${node.value.id} = ${defaultValueSerializer(node.default)}}`\n\n\treturn (defaultableMorphCache[cacheKey] ??= computeDefaultValueMorph(\n\t\tnode.key,\n\t\tnode.value,\n\t\tnode.default\n\t))\n}\n\nexport const computeDefaultValueMorph = (\n\tkey: PropertyKey,\n\tvalue: BaseRoot,\n\tdefaultInput: unknown\n): Morph<any> => {\n\tif (typeof defaultInput === \"function\") {\n\t\t// if the value has a morph, pipe context through it\n\t\treturn value.includesTransform ?\n\t\t\t\t(data, ctx) => {\n\t\t\t\t\ttraverseKey(key, () => value((data[key] = defaultInput()), ctx), ctx)\n\t\t\t\t\treturn data\n\t\t\t\t}\n\t\t\t:\tdata => {\n\t\t\t\t\tdata[key] = defaultInput()\n\t\t\t\t\treturn data\n\t\t\t\t}\n\t}\n\n\t// non-functional defaults can be safely cached as long as the morph is\n\t// guaranteed to be pure and the output is primitive\n\tconst precomputedMorphedDefault =\n\t\tvalue.includesTransform ? value.assert(defaultInput) : defaultInput\n\n\treturn hasDomain(precomputedMorphedDefault, \"object\") ?\n\t\t\t// the type signature only allows this if the value was morphed\n\t\t\t(data, ctx) => {\n\t\t\t\ttraverseKey(key, () => value((data[key] = defaultInput), ctx), ctx)\n\t\t\t\treturn data\n\t\t\t}\n\t\t:\tdata => {\n\t\t\t\tdata[key] = precomputedMorphedDefault\n\t\t\t\treturn data\n\t\t\t}\n}\n\nexport const assertDefaultValueAssignability = (\n\tnode: BaseRoot,\n\tvalue: unknown,\n\tkey: PropertyKey | null\n): unknown => {\n\tconst wrapped = isThunk(value)\n\n\tif (hasDomain(value, \"object\") && !wrapped)\n\t\tthrowParseError(writeNonPrimitiveNonFunctionDefaultValueMessage(key))\n\n\t// if the node has a default value, finalize it and apply JIT optimizations\n\t// if applicable to ensure behavior + error logging is externally consistent\n\t// (using .in here insead of .rawIn triggers finalization)\n\tconst out = (node.in as BaseRoot)(wrapped ? value() : value)\n\n\tif (out instanceof ArkErrors) {\n\t\tif (key === null) {\n\t\t\t// e.g. \"Default must be assignable to number (was string)\"\n\t\t\tthrowParseError(`Default ${out.summary}`)\n\t\t}\n\n\t\tconst atPath = out.transform(e =>\n\t\t\te.transform(input => ({ ...input, prefixPath: [key] }) as never)\n\t\t)\n\n\t\t// e.g. \"Default for bar must be assignable to number (was string)\"\n\t\t// e.g. \"Default for value at [0] must be assignable to number (was string)\"\n\t\tthrowParseError(`Default for ${atPath.summary}`)\n\t}\n\n\treturn value\n}\n\nexport type writeUnassignableDefaultValueMessage<\n\tbaseDef extends string,\n\tdefaultValue extends string\n> = `Default value ${defaultValue} must be assignable to ${baseDef}`\n\nexport const writeNonPrimitiveNonFunctionDefaultValueMessage = (\n\tkey: PropertyKey | null\n): string => {\n\tconst keyDescription =\n\t\tkey === null ? \"\"\n\t\t: typeof key === \"number\" ? `for value at [${key}] `\n\t\t: `for ${compileSerializedValue(key)} `\n\treturn `Non-primitive default ${keyDescription}must be specified as a function like () => ({my: 'object'})`\n}\n"
  },
  {
    "path": "ark/schema/structure/prop.ts",
    "content": "import { append, printable, throwParseError, unset, type Key } from \"@ark/util\"\nimport { BaseConstraint } from \"../constraint.ts\"\nimport type { nodeOfKind, RootSchema } from \"../kinds.ts\"\nimport {\n\tflatRef,\n\ttype BaseNode,\n\ttype DeepNodeTransformation,\n\ttype DeepNodeTransformContext,\n\ttype FlatRef\n} from \"../node.ts\"\nimport type { BaseRoot } from \"../roots/root.ts\"\nimport { compileSerializedValue, type NodeCompiler } from \"../shared/compile.ts\"\nimport type { BaseNormalizedSchema } from \"../shared/declare.ts\"\nimport { Disjoint } from \"../shared/disjoint.ts\"\nimport type { IntersectionContext, RootKind } from \"../shared/implement.ts\"\nimport { intersectOrPipeNodes } from \"../shared/intersections.ts\"\nimport { $ark } from \"../shared/registry.ts\"\nimport {\n\ttraverseKey,\n\ttype TraverseAllows,\n\ttype TraverseApply\n} from \"../shared/traversal.ts\"\nimport type { Optional } from \"./optional.ts\"\nimport type { Required } from \"./required.ts\"\n\nexport declare namespace Prop {\n\texport type Kind = \"required\" | \"optional\"\n\n\texport type Node = nodeOfKind<Kind>\n\n\texport interface Schema extends BaseNormalizedSchema {\n\t\treadonly key: Key\n\t\treadonly value: RootSchema\n\t}\n\n\texport interface Inner {\n\t\treadonly key: Key\n\t\treadonly value: BaseRoot\n\t}\n\n\texport interface Declaration<kind extends Kind = Kind> {\n\t\tkind: kind\n\t\tprerequisite: object\n\t\tintersectionIsOpen: true\n\t\tchildKind: RootKind\n\t}\n}\n\nexport const intersectProps = (\n\tl: nodeOfKind<Prop.Kind>,\n\tr: nodeOfKind<Prop.Kind>,\n\tctx: IntersectionContext\n): nodeOfKind<Prop.Kind> | Disjoint | null => {\n\tif (l.key !== r.key) return null\n\n\tconst key = l.key\n\tlet value = intersectOrPipeNodes(l.value, r.value, ctx)\n\tconst kind: Prop.Kind = l.required || r.required ? \"required\" : \"optional\"\n\tif (value instanceof Disjoint) {\n\t\tif (kind === \"optional\") value = $ark.intrinsic.never.internal\n\t\telse {\n\t\t\t// if either operand was optional, the Disjoint has to be treated as optional\n\t\t\treturn value.withPrefixKey(\n\t\t\t\tl.key,\n\t\t\t\tl.required && r.required ? \"required\" : \"optional\"\n\t\t\t)\n\t\t}\n\t}\n\n\tif (kind === \"required\") {\n\t\treturn ctx.$.node(\"required\", {\n\t\t\tkey,\n\t\t\tvalue\n\t\t})\n\t}\n\n\tconst defaultIntersection =\n\t\tl.hasDefault() ?\n\t\t\tr.hasDefault() ?\n\t\t\t\tl.default === r.default ?\n\t\t\t\t\tl.default\n\t\t\t\t:\tthrowParseError(writeDefaultIntersectionMessage(l.default, r.default))\n\t\t\t:\tl.default\n\t\t: r.hasDefault() ? r.default\n\t\t: unset\n\n\treturn ctx.$.node(\"optional\", {\n\t\tkey,\n\t\tvalue,\n\t\t// unset is stripped during parsing\n\t\tdefault: defaultIntersection\n\t})\n}\n\nexport abstract class BaseProp<\n\tkind extends Prop.Kind = Prop.Kind\n> extends BaseConstraint<\n\tkind extends \"required\" ? Required.Declaration : Optional.Declaration\n> {\n\trequired: boolean = this.kind === \"required\"\n\toptional: boolean = this.kind === \"optional\"\n\timpliedBasis: BaseRoot = $ark.intrinsic.object.internal\n\tserializedKey: string = compileSerializedValue(this.key)\n\tcompiledKey: string =\n\t\ttypeof this.key === \"string\" ? this.key : this.serializedKey\n\n\tflatRefs: FlatRef[] = append(\n\t\tthis.value.flatRefs.map(ref => flatRef([this.key, ...ref.path], ref.node)),\n\t\tflatRef([this.key], this.value)\n\t)\n\n\tprotected override _transform(\n\t\tmapper: DeepNodeTransformation,\n\t\tctx: DeepNodeTransformContext\n\t): BaseNode | null {\n\t\tctx.path.push(this.key)\n\t\tconst result = super._transform(mapper, ctx)\n\t\tctx.path.pop()\n\t\treturn result\n\t}\n\n\thasDefault(): this is Optional.Node.withDefault {\n\t\treturn \"default\" in this.inner\n\t}\n\n\ttraverseAllows: TraverseAllows<object> = (data, ctx) => {\n\t\tif (this.key in data) {\n\t\t\t// ctx will be undefined if this node isn't context-dependent\n\t\t\treturn traverseKey(\n\t\t\t\tthis.key,\n\t\t\t\t() => this.value.traverseAllows((data as any)[this.key], ctx),\n\t\t\t\tctx\n\t\t\t)\n\t\t}\n\t\treturn this.optional\n\t}\n\n\ttraverseApply: TraverseApply<object> = (data, ctx) => {\n\t\tif (this.key in data) {\n\t\t\ttraverseKey(\n\t\t\t\tthis.key,\n\t\t\t\t() => this.value.traverseApply((data as any)[this.key], ctx),\n\t\t\t\tctx\n\t\t\t)\n\t\t} else if (this.hasKind(\"required\"))\n\t\t\tctx.errorFromNodeContext(this.errorContext)\n\t}\n\n\tcompile(js: NodeCompiler): void {\n\t\tjs.if(`${this.serializedKey} in data`, () =>\n\t\t\tjs.traverseKey(this.serializedKey, `data${js.prop(this.key)}`, this.value)\n\t\t)\n\n\t\tif (this.hasKind(\"required\")) {\n\t\t\tjs.else(() =>\n\t\t\t\tjs.traversalKind === \"Apply\" ?\n\t\t\t\t\tjs.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`)\n\t\t\t\t:\tjs.return(false)\n\t\t\t)\n\t\t}\n\n\t\tif (js.traversalKind === \"Allows\") js.return(true)\n\t}\n}\n\nexport const writeDefaultIntersectionMessage = (\n\tlValue: unknown,\n\trValue: unknown\n): string =>\n\t`Invalid intersection of default values ${printable(lValue)} & ${printable(rValue)}`\n"
  },
  {
    "path": "ark/schema/structure/required.ts",
    "content": "import type { BaseErrorContext, declareNode } from \"../shared/declare.ts\"\nimport type { NodeErrorContextInput } from \"../shared/errors.ts\"\nimport {\n\tcompileObjectLiteral,\n\timplementNode,\n\ttype nodeImplementationOf\n} from \"../shared/implement.ts\"\nimport { BaseProp, intersectProps, type Prop } from \"./prop.ts\"\n\nexport declare namespace Required {\n\texport interface ErrorContext extends BaseErrorContext<\"required\"> {\n\t\tmissingValueDescription: string\n\t}\n\n\texport interface Schema extends Prop.Schema {}\n\n\texport interface Inner extends Prop.Inner {}\n\n\texport type Declaration = declareNode<\n\t\tProp.Declaration<\"required\"> & {\n\t\t\tschema: Schema\n\t\t\tnormalizedSchema: Schema\n\t\t\tinner: Inner\n\t\t\terrorContext: ErrorContext\n\t\t}\n\t>\n\n\texport type Node = RequiredNode\n}\n\nconst implementation: nodeImplementationOf<Required.Declaration> =\n\timplementNode<Required.Declaration>({\n\t\tkind: \"required\",\n\t\thasAssociatedError: true,\n\t\tintersectionIsOpen: true,\n\t\tkeys: {\n\t\t\tkey: {},\n\t\t\tvalue: {\n\t\t\t\tchild: true,\n\t\t\t\tparse: (schema, ctx) => ctx.$.parseSchema(schema)\n\t\t\t}\n\t\t},\n\t\tnormalize: schema => schema,\n\t\tdefaults: {\n\t\t\tdescription: node => `${node.compiledKey}: ${node.value.description}`,\n\t\t\texpected: ctx => ctx.missingValueDescription,\n\t\t\tactual: () => \"missing\"\n\t\t},\n\t\tintersections: {\n\t\t\trequired: intersectProps,\n\t\t\toptional: intersectProps\n\t\t}\n\t})\n\nexport class RequiredNode extends BaseProp<\"required\"> {\n\texpression = `${this.compiledKey}: ${this.value.expression}`\n\n\terrorContext: NodeErrorContextInput<\"required\"> = Object.freeze({\n\t\tcode: \"required\",\n\t\tmissingValueDescription: this.value.defaultShortDescription,\n\t\trelativePath: [this.key],\n\t\tmeta: this.meta\n\t})\n\n\tcompiledErrorContext: string = compileObjectLiteral(this.errorContext)\n}\n\nexport const Required = {\n\timplementation,\n\tNode: RequiredNode\n}\n"
  },
  {
    "path": "ark/schema/structure/sequence.ts",
    "content": "import {\n\tappend,\n\tconflatenate,\n\tprintable,\n\tthrowInternalError,\n\tthrowParseError,\n\ttype array,\n\ttype mutable,\n\ttype satisfy\n} from \"@ark/util\"\nimport { BaseConstraint } from \"../constraint.ts\"\nimport type { RootSchema, mutableInnerOfKind } from \"../kinds.ts\"\nimport {\n\tappendUniqueFlatRefs,\n\tflatRef,\n\ttype BaseNode,\n\ttype DeepNodeTransformContext,\n\ttype DeepNodeTransformation,\n\ttype FlatRef\n} from \"../node.ts\"\nimport type { ExactLengthNode } from \"../refinements/exactLength.ts\"\nimport type { MaxLengthNode } from \"../refinements/maxLength.ts\"\nimport type { MinLengthNode } from \"../refinements/minLength.ts\"\nimport type { Morph } from \"../roots/morph.ts\"\nimport type { BaseRoot } from \"../roots/root.ts\"\nimport type { NodeCompiler } from \"../shared/compile.ts\"\nimport type { BaseNormalizedSchema, declareNode } from \"../shared/declare.ts\"\nimport { Disjoint } from \"../shared/disjoint.ts\"\nimport {\n\tdefaultValueSerializer,\n\timplementNode,\n\ttype IntersectionContext,\n\ttype RootKind,\n\ttype nodeImplementationOf\n} from \"../shared/implement.ts\"\nimport { intersectOrPipeNodes } from \"../shared/intersections.ts\"\nimport type { JsonSchema } from \"../shared/jsonSchema.ts\"\nimport { $ark, registeredReference } from \"../shared/registry.ts\"\nimport type { ToJsonSchema } from \"../shared/toJsonSchema.ts\"\nimport {\n\ttraverseKey,\n\ttype TraverseAllows,\n\ttype TraverseApply\n} from \"../shared/traversal.ts\"\nimport {\n\tassertDefaultValueAssignability,\n\tcomputeDefaultValueMorph\n} from \"./optional.ts\"\nimport { writeDefaultIntersectionMessage } from \"./prop.ts\"\n\nexport declare namespace Sequence {\n\texport interface NormalizedSchema extends BaseNormalizedSchema {\n\t\treadonly prefix?: array<RootSchema>\n\t\treadonly defaultables?: array<DefaultableSchema>\n\t\treadonly optionals?: array<RootSchema>\n\t\treadonly variadic?: RootSchema\n\t\treadonly minVariadicLength?: number\n\t\treadonly postfix?: array<RootSchema>\n\t}\n\n\texport type Schema = NormalizedSchema | RootSchema\n\n\texport type DefaultableSchema = [schema: RootSchema, defaultValue: unknown]\n\n\texport type DefaultableElement = [node: BaseRoot, defaultValue: unknown]\n\n\texport interface Inner {\n\t\t// a list of fixed position elements starting at index 0\n\t\treadonly prefix?: array<BaseRoot>\n\t\t// a list of optional elements with default values following prefix\n\t\treadonly defaultables?: array<DefaultableElement>\n\t\t// a list of optional elements without default values following defaultables\n\t\treadonly optionals?: array<BaseRoot>\n\t\t// the variadic element (only checked if all optional elements are present)\n\t\treadonly variadic?: BaseRoot\n\t\treadonly minVariadicLength?: number\n\t\t// a list of fixed position elements, the last being the last element of the array\n\t\treadonly postfix?: array<BaseRoot>\n\t}\n\n\texport interface Declaration\n\t\textends declareNode<{\n\t\t\tkind: \"sequence\"\n\t\t\tschema: Schema\n\t\t\tnormalizedSchema: NormalizedSchema\n\t\t\tinner: Inner\n\t\t\tprerequisite: array\n\t\t\treducibleTo: \"sequence\"\n\t\t\tchildKind: RootKind\n\t\t}> {}\n\n\texport type Node = SequenceNode\n}\n\nconst implementation: nodeImplementationOf<Sequence.Declaration> =\n\timplementNode<Sequence.Declaration>({\n\t\tkind: \"sequence\",\n\t\thasAssociatedError: false,\n\t\tcollapsibleKey: \"variadic\",\n\t\tkeys: {\n\t\t\tprefix: {\n\t\t\t\tchild: true,\n\t\t\t\tparse: (schema, ctx) => {\n\t\t\t\t\t// empty affixes are omitted. an empty array should therefore\n\t\t\t\t\t// be specified as `{ proto: Array, length: 0 }`\n\t\t\t\t\tif (schema.length === 0) return undefined\n\n\t\t\t\t\treturn schema.map(element => ctx.$.parseSchema(element))\n\t\t\t\t}\n\t\t\t},\n\t\t\toptionals: {\n\t\t\t\tchild: true,\n\t\t\t\tparse: (schema, ctx) => {\n\t\t\t\t\tif (schema.length === 0) return undefined\n\n\t\t\t\t\treturn schema.map(element => ctx.$.parseSchema(element))\n\t\t\t\t}\n\t\t\t},\n\t\t\tdefaultables: {\n\t\t\t\tchild: defaultables => defaultables.map(element => element[0]),\n\t\t\t\tparse: (defaultables, ctx) => {\n\t\t\t\t\tif (defaultables.length === 0) return undefined\n\n\t\t\t\t\treturn defaultables.map(element => {\n\t\t\t\t\t\tconst node = ctx.$.parseSchema(element[0])\n\t\t\t\t\t\tassertDefaultValueAssignability(node, element[1], null)\n\t\t\t\t\t\treturn [node, element[1]]\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t\tserialize: defaults =>\n\t\t\t\t\tdefaults.map(element => [\n\t\t\t\t\t\telement[0].collapsibleJson,\n\t\t\t\t\t\tdefaultValueSerializer(element[1])\n\t\t\t\t\t]),\n\t\t\t\treduceIo: (ioKind, inner, defaultables) => {\n\t\t\t\t\tif (ioKind === \"in\") {\n\t\t\t\t\t\tinner.optionals = defaultables!.map(d => d[0].rawIn)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\tinner.prefix = defaultables!.map(d => d[0].rawOut)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t},\n\t\t\tvariadic: {\n\t\t\t\tchild: true,\n\t\t\t\tparse: (schema, ctx) => ctx.$.parseSchema(schema, ctx)\n\t\t\t},\n\t\t\tminVariadicLength: {\n\t\t\t\t// minVariadicLength is reflected in the id of this node,\n\t\t\t\t// but not its IntersectionNode parent since it is superceded by the minLength\n\t\t\t\t// node it implies\n\t\t\t\tparse: min => (min === 0 ? undefined : min)\n\t\t\t},\n\t\t\tpostfix: {\n\t\t\t\tchild: true,\n\t\t\t\tparse: (schema, ctx) => {\n\t\t\t\t\tif (schema.length === 0) return undefined\n\n\t\t\t\t\treturn schema.map(element => ctx.$.parseSchema(element))\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tnormalize: schema => {\n\t\t\tif (typeof schema === \"string\") return { variadic: schema }\n\n\t\t\tif (\n\t\t\t\t\"variadic\" in schema ||\n\t\t\t\t\"prefix\" in schema ||\n\t\t\t\t\"defaultables\" in schema ||\n\t\t\t\t\"optionals\" in schema ||\n\t\t\t\t\"postfix\" in schema ||\n\t\t\t\t\"minVariadicLength\" in schema\n\t\t\t) {\n\t\t\t\tif (schema.postfix?.length) {\n\t\t\t\t\tif (!schema.variadic)\n\t\t\t\t\t\treturn throwParseError(postfixWithoutVariadicMessage)\n\n\t\t\t\t\tif (schema.optionals?.length || schema.defaultables?.length)\n\t\t\t\t\t\treturn throwParseError(postfixAfterOptionalOrDefaultableMessage)\n\t\t\t\t}\n\t\t\t\tif (schema.minVariadicLength && !schema.variadic) {\n\t\t\t\t\treturn throwParseError(\n\t\t\t\t\t\t\"minVariadicLength may not be specified without a variadic element\"\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\treturn schema\n\t\t\t}\n\t\t\treturn { variadic: schema }\n\t\t},\n\t\treduce: (raw, $) => {\n\t\t\tlet minVariadicLength = raw.minVariadicLength ?? 0\n\t\t\tconst prefix = raw.prefix?.slice() ?? []\n\t\t\tconst defaultables = raw.defaultables?.slice() ?? []\n\t\t\tconst optionals = raw.optionals?.slice() ?? []\n\t\t\tconst postfix = raw.postfix?.slice() ?? []\n\t\t\tif (raw.variadic) {\n\t\t\t\t// optional elements equivalent to the variadic parameter are redundant\n\t\t\t\twhile (optionals[optionals.length - 1]?.equals(raw.variadic))\n\t\t\t\t\toptionals.pop()\n\n\t\t\t\tif (optionals.length === 0 && defaultables.length === 0) {\n\t\t\t\t\t// If there are no optional, normalize prefix\n\t\t\t\t\t// elements adjacent and equivalent to variadic:\n\t\t\t\t\t// \t\t{ variadic: number, prefix: [string, number] }\n\t\t\t\t\t// reduces to:\n\t\t\t\t\t// \t\t{ variadic: number, prefix: [string], minVariadicLength: 1 }\n\t\t\t\t\twhile (prefix[prefix.length - 1]?.equals(raw.variadic)) {\n\t\t\t\t\t\tprefix.pop()\n\t\t\t\t\t\tminVariadicLength++\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Normalize postfix elements adjacent and equivalent to variadic:\n\t\t\t\t// \t\t{ variadic: number, postfix: [number, number, 5] }\n\t\t\t\t// reduces to:\n\t\t\t\t// \t\t{ variadic: number, postfix: [5], minVariadicLength: 2 }\n\t\t\t\twhile (postfix[0]?.equals(raw.variadic)) {\n\t\t\t\t\tpostfix.shift()\n\t\t\t\t\tminVariadicLength++\n\t\t\t\t}\n\t\t\t} else if (optionals.length === 0 && defaultables.length === 0) {\n\t\t\t\t// if there's no variadic, optional or defaultable elements,\n\t\t\t\t// postfix can just be appended to prefix\n\t\t\t\tprefix.push(...postfix.splice(0))\n\t\t\t}\n\t\t\tif (\n\t\t\t\t// if any variadic adjacent elements were moved to minVariadicLength\n\t\t\t\tminVariadicLength !== raw.minVariadicLength ||\n\t\t\t\t// or any postfix elements were moved to prefix\n\t\t\t\t(raw.prefix && raw.prefix.length !== prefix.length)\n\t\t\t) {\n\t\t\t\t// reparse the reduced def\n\t\t\t\treturn $.node(\n\t\t\t\t\t\"sequence\",\n\t\t\t\t\t{\n\t\t\t\t\t\t...raw,\n\t\t\t\t\t\t// empty lists will be omitted during parsing\n\t\t\t\t\t\tprefix,\n\t\t\t\t\t\tdefaultables,\n\t\t\t\t\t\toptionals,\n\t\t\t\t\t\tpostfix,\n\t\t\t\t\t\tminVariadicLength\n\t\t\t\t\t},\n\t\t\t\t\t{ prereduced: true }\n\t\t\t\t)\n\t\t\t}\n\t\t},\n\t\tdefaults: {\n\t\t\tdescription: node => {\n\t\t\t\tif (node.isVariadicOnly) return `${node.variadic!.nestableExpression}[]`\n\t\t\t\tconst innerDescription = node.tuple\n\t\t\t\t\t.map(element =>\n\t\t\t\t\t\telement.kind === \"defaultables\" ?\n\t\t\t\t\t\t\t`${element.node.nestableExpression} = ${printable(element.default)}`\n\t\t\t\t\t\t: element.kind === \"optionals\" ?\n\t\t\t\t\t\t\t`${element.node.nestableExpression}?`\n\t\t\t\t\t\t: element.kind === \"variadic\" ?\n\t\t\t\t\t\t\t`...${element.node.nestableExpression}[]`\n\t\t\t\t\t\t:\telement.node.expression\n\t\t\t\t\t)\n\t\t\t\t\t.join(\", \")\n\t\t\t\treturn `[${innerDescription}]`\n\t\t\t}\n\t\t},\n\t\tintersections: {\n\t\t\tsequence: (l, r, ctx) => {\n\t\t\t\tconst rootState = _intersectSequences({\n\t\t\t\t\tl: l.tuple,\n\t\t\t\t\tr: r.tuple,\n\t\t\t\t\tdisjoint: new Disjoint(),\n\t\t\t\t\tresult: [],\n\t\t\t\t\tfixedVariants: [],\n\t\t\t\t\tctx\n\t\t\t\t})\n\n\t\t\t\tconst viableBranches =\n\t\t\t\t\trootState.disjoint.length === 0 ?\n\t\t\t\t\t\t[rootState, ...rootState.fixedVariants]\n\t\t\t\t\t:\trootState.fixedVariants\n\n\t\t\t\treturn (\n\t\t\t\t\tviableBranches.length === 0 ? rootState.disjoint!\n\t\t\t\t\t: viableBranches.length === 1 ?\n\t\t\t\t\t\tctx.$.node(\n\t\t\t\t\t\t\t\"sequence\",\n\t\t\t\t\t\t\tsequenceTupleToInner(viableBranches[0].result)\n\t\t\t\t\t\t)\n\t\t\t\t\t:\tctx.$.node(\n\t\t\t\t\t\t\t\"union\",\n\t\t\t\t\t\t\tviableBranches.map(state => ({\n\t\t\t\t\t\t\t\tproto: Array,\n\t\t\t\t\t\t\t\tsequence: sequenceTupleToInner(state.result)\n\t\t\t\t\t\t\t}))\n\t\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t}\n\n\t\t\t// exactLength, minLength, and maxLength don't need to be defined\n\t\t\t// here since impliedSiblings guarantees they will be added\n\t\t\t// directly to the IntersectionNode parent of the SequenceNode\n\t\t\t// they exist on\n\t\t}\n\t})\n\nexport class SequenceNode extends BaseConstraint<Sequence.Declaration> {\n\timpliedBasis: BaseRoot = $ark.intrinsic.Array.internal\n\n\ttuple: SequenceTuple = sequenceInnerToTuple(this.inner)\n\n\tprefixLength: number = this.prefix?.length ?? 0\n\tdefaultablesLength: number = this.defaultables?.length ?? 0\n\toptionalsLength: number = this.optionals?.length ?? 0\n\tpostfixLength: number = this.postfix?.length ?? 0\n\tdefaultablesAndOptionals: BaseRoot[] = []\n\tprevariadic: array<PrevariadicSequenceElement> = this.tuple.filter(\n\t\t(el): el is PrevariadicSequenceElement => {\n\t\t\tif (el.kind === \"defaultables\" || el.kind === \"optionals\") {\n\t\t\t\t// populate defaultablesAndOptionals while filtering prevariadic\n\t\t\t\tthis.defaultablesAndOptionals.push(el.node)\n\t\t\t\treturn true\n\t\t\t}\n\n\t\t\treturn el.kind === \"prefix\"\n\t\t}\n\t)\n\n\tvariadicOrPostfix: array<BaseRoot> = conflatenate(\n\t\tthis.variadic && [this.variadic],\n\t\tthis.postfix\n\t)\n\n\t// have to wait until prevariadic and variadicOrPostfix are set to calculate\n\tflatRefs: FlatRef[] = this.addFlatRefs()\n\n\tprotected addFlatRefs(): FlatRef[] {\n\t\tappendUniqueFlatRefs(\n\t\t\tthis.flatRefs,\n\t\t\tthis.prevariadic.flatMap((element, i) =>\n\t\t\t\tappend(\n\t\t\t\t\telement.node.flatRefs.map(ref =>\n\t\t\t\t\t\tflatRef([`${i}`, ...ref.path], ref.node)\n\t\t\t\t\t),\n\t\t\t\t\tflatRef([`${i}`], element.node)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\n\t\tappendUniqueFlatRefs(\n\t\t\tthis.flatRefs,\n\t\t\tthis.variadicOrPostfix.flatMap(element =>\n\t\t\t\t// a postfix index can't be directly represented as a type\n\t\t\t\t// key, so we just use the same matcher for variadic\n\t\t\t\tappend(\n\t\t\t\t\telement.flatRefs.map(ref =>\n\t\t\t\t\t\tflatRef(\n\t\t\t\t\t\t\t[$ark.intrinsic.nonNegativeIntegerString.internal, ...ref.path],\n\t\t\t\t\t\t\tref.node\n\t\t\t\t\t\t)\n\t\t\t\t\t),\n\t\t\t\t\tflatRef([$ark.intrinsic.nonNegativeIntegerString.internal], element)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\n\t\treturn this.flatRefs\n\t}\n\n\tisVariadicOnly: boolean = this.prevariadic.length + this.postfixLength === 0\n\tminVariadicLength: number = this.inner.minVariadicLength ?? 0\n\tminLength: number =\n\t\tthis.prefixLength + this.minVariadicLength + this.postfixLength\n\tminLengthNode: MinLengthNode | null =\n\t\tthis.minLength === 0 ?\n\t\t\tnull\n\t\t\t// cast is safe here as the only time this would not be a\n\t\t\t// MinLengthNode would be when minLength is 0\n\t\t:\t(this.$.node(\"minLength\", this.minLength) as never)\n\tmaxLength: number | null = this.variadic ? null : this.tuple.length\n\tmaxLengthNode: MaxLengthNode | ExactLengthNode | null =\n\t\tthis.maxLength === null ? null : this.$.node(\"maxLength\", this.maxLength)\n\timpliedSiblings: array<MaxLengthNode | MinLengthNode | ExactLengthNode> =\n\t\tthis.minLengthNode ?\n\t\t\tthis.maxLengthNode ?\n\t\t\t\t[this.minLengthNode, this.maxLengthNode]\n\t\t\t:\t[this.minLengthNode]\n\t\t: this.maxLengthNode ? [this.maxLengthNode]\n\t\t: []\n\n\tdefaultValueMorphs: Morph[] = getDefaultableMorphs(this)\n\n\tdefaultValueMorphsReference =\n\t\tthis.defaultValueMorphs.length ?\n\t\t\tregisteredReference(this.defaultValueMorphs)\n\t\t:\tundefined\n\n\tprotected elementAtIndex(data: array, index: number): SequenceElement {\n\t\tif (index < this.prevariadic.length) return this.tuple[index]\n\t\tconst firstPostfixIndex = data.length - this.postfixLength\n\t\tif (index >= firstPostfixIndex)\n\t\t\treturn { kind: \"postfix\", node: this.postfix![index - firstPostfixIndex] }\n\t\treturn {\n\t\t\tkind: \"variadic\",\n\t\t\tnode:\n\t\t\t\tthis.variadic ??\n\t\t\t\tthrowInternalError(\n\t\t\t\t\t`Unexpected attempt to access index ${index} on ${this}`\n\t\t\t\t)\n\t\t}\n\t}\n\n\t// minLength/maxLength should be checked by Intersection before either traversal\n\ttraverseAllows: TraverseAllows<array> = (data, ctx) => {\n\t\tfor (let i = 0; i < data.length; i++) {\n\t\t\tif (!this.elementAtIndex(data, i).node.traverseAllows(data[i], ctx))\n\t\t\t\treturn false\n\t\t}\n\n\t\treturn true\n\t}\n\n\ttraverseApply: TraverseApply<array> = (data, ctx) => {\n\t\tlet i = 0\n\t\tfor (; i < data.length; i++) {\n\t\t\ttraverseKey(\n\t\t\t\ti,\n\t\t\t\t() => this.elementAtIndex(data, i).node.traverseApply(data[i], ctx),\n\t\t\t\tctx\n\t\t\t)\n\t\t}\n\t}\n\n\tget element(): BaseRoot {\n\t\treturn this.cacheGetter(\"element\", this.$.node(\"union\", this.children))\n\t}\n\n\t// minLength/maxLength compilation should be handled by Intersection\n\tcompile(js: NodeCompiler): void {\n\t\tif (this.prefix) {\n\t\t\tfor (const [i, node] of this.prefix.entries())\n\t\t\t\tjs.traverseKey(`${i}`, `data[${i}]`, node)\n\t\t}\n\n\t\tfor (const [i, node] of this.defaultablesAndOptionals.entries()) {\n\t\t\tconst dataIndex = `${i + this.prefixLength}`\n\t\t\tjs.if(`${dataIndex} >= data.length`, () =>\n\t\t\t\tjs.traversalKind === \"Allows\" ? js.return(true) : js.return()\n\t\t\t)\n\t\t\tjs.traverseKey(dataIndex, `data[${dataIndex}]`, node)\n\t\t}\n\n\t\tif (this.variadic) {\n\t\t\tif (this.postfix) {\n\t\t\t\tjs.const(\n\t\t\t\t\t\"firstPostfixIndex\",\n\t\t\t\t\t`data.length${this.postfix ? `- ${this.postfix.length}` : \"\"}`\n\t\t\t\t)\n\t\t\t}\n\t\t\tjs.for(\n\t\t\t\t`i < ${this.postfix ? \"firstPostfixIndex\" : \"data.length\"}`,\n\t\t\t\t() => js.traverseKey(\"i\", \"data[i]\", this.variadic!),\n\t\t\t\tthis.prevariadic.length\n\t\t\t)\n\t\t\tif (this.postfix) {\n\t\t\t\tfor (const [i, node] of this.postfix.entries()) {\n\t\t\t\t\tconst keyExpression = `firstPostfixIndex + ${i}`\n\t\t\t\t\tjs.traverseKey(keyExpression, `data[${keyExpression}]`, node)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (js.traversalKind === \"Allows\") js.return(true)\n\t}\n\n\tprotected override _transform(\n\t\tmapper: DeepNodeTransformation,\n\t\tctx: DeepNodeTransformContext\n\t): BaseNode | null {\n\t\tctx.path.push($ark.intrinsic.nonNegativeIntegerString.internal)\n\t\tconst result = super._transform(mapper, ctx)\n\t\tctx.path.pop()\n\t\treturn result\n\t}\n\n\t// this depends on tuple so needs to come after it\n\texpression: string = this.description\n\n\treduceJsonSchema(\n\t\tschema: JsonSchema.Array,\n\t\tctx: ToJsonSchema.Context\n\t): JsonSchema.Array {\n\t\tconst isDraft07 = ctx.target === \"draft-07\"\n\n\t\tif (this.prevariadic.length) {\n\t\t\tconst prefixSchemas = this.prevariadic.map(el => {\n\t\t\t\tconst valueSchema = el.node.toJsonSchemaRecurse(ctx)\n\t\t\t\tif (el.kind === \"defaultables\") {\n\t\t\t\t\tconst value =\n\t\t\t\t\t\ttypeof el.default === \"function\" ? el.default() : el.default\n\t\t\t\t\tvalueSchema.default =\n\t\t\t\t\t\t$ark.intrinsic.jsonData.allows(value) ?\n\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t:\tctx.fallback.defaultValue({\n\t\t\t\t\t\t\t\tcode: \"defaultValue\",\n\t\t\t\t\t\t\t\tbase: valueSchema,\n\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\treturn valueSchema\n\t\t\t})\n\n\t\t\t// draft-07 uses items as array, draft-2020-12 uses prefixItems\n\t\t\tif (isDraft07) schema.items = prefixSchemas as JsonSchema.Branch[]\n\t\t\telse schema.prefixItems = prefixSchemas\n\t\t}\n\n\t\t// by default JSON schema prefixElements are optional\n\t\t// add minLength here if there are any required prefix elements\n\t\tif (this.minLength) schema.minItems = this.minLength\n\n\t\tif (this.variadic) {\n\t\t\tconst variadicItemSchema = this.variadic.toJsonSchemaRecurse(ctx)\n\n\t\t\t// draft-07 uses additionalItems when items is an array (tuple),\n\t\t\t// draft-2020-12 uses items\n\t\t\tif (isDraft07 && this.prevariadic.length)\n\t\t\t\tschema.additionalItems = variadicItemSchema\n\t\t\telse schema.items = variadicItemSchema\n\n\t\t\t// maxLength constraint will be enforced by items: false\n\t\t\t// for non-variadic arrays\n\t\t\tif (this.maxLength) schema.maxItems = this.maxLength\n\n\t\t\t// postfix can only be present if variadic is present so nesting this is fine\n\t\t\tif (this.postfix) {\n\t\t\t\tconst elements = this.postfix.map(el => el.toJsonSchemaRecurse(ctx))\n\t\t\t\tschema = ctx.fallback.arrayPostfix({\n\t\t\t\t\tcode: \"arrayPostfix\",\n\t\t\t\t\tbase: schema as ToJsonSchema.VariadicArraySchema,\n\t\t\t\t\telements\n\t\t\t\t})\n\t\t\t}\n\t\t} else {\n\t\t\t// For fixed-length tuples without variadic elements\n\t\t\t// draft-07 uses additionalItems: false, draft-2020-12 uses items: false\n\t\t\tif (isDraft07) schema.additionalItems = false\n\t\t\telse schema.items = false\n\t\t\t// delete maxItems constraint that will have been added by the\n\t\t\t// base intersection node to enforce fixed length\n\t\t\tdelete schema.maxItems\n\t\t}\n\n\t\treturn schema\n\t}\n}\n\nconst defaultableMorphsCache: Record<string, Morph[] | undefined> = {}\n\nconst getDefaultableMorphs = (node: Sequence.Node): Morph[] => {\n\tif (!node.defaultables) return []\n\n\tconst morphs: Morph[] = []\n\tlet cacheKey = \"[\"\n\n\tconst lastDefaultableIndex = node.prefixLength + node.defaultablesLength - 1\n\n\tfor (let i = node.prefixLength; i <= lastDefaultableIndex; i++) {\n\t\tconst [elementNode, defaultValue] = node.defaultables[i - node.prefixLength]\n\t\tmorphs.push(computeDefaultValueMorph(i, elementNode, defaultValue))\n\t\tcacheKey += `${i}: ${elementNode.id} = ${defaultValueSerializer(defaultValue)}, `\n\t}\n\n\tcacheKey += \"]\"\n\n\treturn (defaultableMorphsCache[cacheKey] ??= morphs)\n}\n\nexport const Sequence = {\n\timplementation,\n\tNode: SequenceNode\n}\n\nconst sequenceInnerToTuple = (inner: Sequence.Inner): SequenceTuple => {\n\tconst tuple: mutable<SequenceTuple> = []\n\tif (inner.prefix)\n\t\tfor (const node of inner.prefix) tuple.push({ kind: \"prefix\", node })\n\tif (inner.defaultables) {\n\t\tfor (const [node, defaultValue] of inner.defaultables)\n\t\t\ttuple.push({ kind: \"defaultables\", node, default: defaultValue })\n\t}\n\n\tif (inner.optionals)\n\t\tfor (const node of inner.optionals) tuple.push({ kind: \"optionals\", node })\n\tif (inner.variadic) tuple.push({ kind: \"variadic\", node: inner.variadic })\n\tif (inner.postfix)\n\t\tfor (const node of inner.postfix) tuple.push({ kind: \"postfix\", node })\n\treturn tuple\n}\n\nconst sequenceTupleToInner = (tuple: SequenceTuple): Sequence.Inner =>\n\ttuple.reduce<mutableInnerOfKind<\"sequence\">>((result, element) => {\n\t\tif (element.kind === \"variadic\") result.variadic = element.node\n\t\telse if (element.kind === \"defaultables\") {\n\t\t\tresult.defaultables = append(result.defaultables, [\n\t\t\t\t[element.node, element.default]\n\t\t\t])\n\t\t} else result[element.kind] = append(result[element.kind], element.node)\n\n\t\treturn result\n\t}, {})\n\nexport const postfixAfterOptionalOrDefaultableMessage =\n\t\"A postfix required element cannot follow an optional or defaultable element\"\n\nexport type postfixAfterOptionalOrDefaultableMessage =\n\ttypeof postfixAfterOptionalOrDefaultableMessage\n\nexport const postfixWithoutVariadicMessage =\n\t\"A postfix element requires a variadic element\"\n\nexport type postfixWithoutVariadicMessage = typeof postfixWithoutVariadicMessage\n\nexport type SequenceElement =\n\t| PrevariadicSequenceElement\n\t| VariadicSequenceElement\n\t| PostfixSequenceElement\n\nexport type SequenceElementKind = satisfy<\n\tkeyof Sequence.Inner,\n\tSequenceElement[\"kind\"]\n>\n\nexport type PrevariadicSequenceElement =\n\t| PrefixSequenceElement\n\t| DefaultableSequenceElement\n\t| OptionalSequenceElement\n\nexport type PrefixSequenceElement = {\n\tkind: \"prefix\"\n\tnode: BaseRoot\n}\n\nexport type OptionalSequenceElement = {\n\tkind: \"optionals\"\n\tnode: BaseRoot\n}\n\nexport type PostfixSequenceElement = {\n\tkind: \"postfix\"\n\tnode: BaseRoot\n}\n\nexport type VariadicSequenceElement = {\n\tkind: \"variadic\"\n\tnode: BaseRoot\n}\n\nexport type DefaultableSequenceElement = {\n\tkind: \"defaultables\"\n\tnode: BaseRoot\n\tdefault: unknown\n}\n\nexport type SequenceTuple = array<SequenceElement>\n\ntype SequenceIntersectionState = {\n\tl: SequenceTuple\n\tr: SequenceTuple\n\tdisjoint: Disjoint\n\tresult: SequenceTuple\n\tfixedVariants: SequenceIntersectionState[]\n\tctx: IntersectionContext\n}\n\nconst _intersectSequences = (\n\ts: SequenceIntersectionState\n): SequenceIntersectionState => {\n\tconst [lHead, ...lTail] = s.l\n\tconst [rHead, ...rTail] = s.r\n\n\tif (!lHead || !rHead) return s\n\n\tconst lHasPostfix = lTail[lTail.length - 1]?.kind === \"postfix\"\n\tconst rHasPostfix = rTail[rTail.length - 1]?.kind === \"postfix\"\n\n\tconst kind: SequenceElementKind =\n\t\tlHead.kind === \"prefix\" || rHead.kind === \"prefix\" ? \"prefix\"\n\t\t: lHead.kind === \"postfix\" || rHead.kind === \"postfix\" ? \"postfix\"\n\t\t: lHead.kind === \"variadic\" && rHead.kind === \"variadic\" ? \"variadic\"\n\t\t\t// if either operand has postfix elements, the full-length\n\t\t\t// intersection can't include optional elements (though they may\n\t\t\t// exist in some of the fixed length variants)\n\t\t: lHasPostfix || rHasPostfix ? \"prefix\"\n\t\t: lHead.kind === \"defaultables\" || rHead.kind === \"defaultables\" ?\n\t\t\t\"defaultables\"\n\t\t:\t\"optionals\"\n\n\tif (lHead.kind === \"prefix\" && rHead.kind === \"variadic\" && rHasPostfix) {\n\t\tconst postfixBranchResult = _intersectSequences({\n\t\t\t...s,\n\t\t\tfixedVariants: [],\n\t\t\tr: rTail.map(element => ({ ...element, kind: \"prefix\" }))\n\t\t})\n\t\tif (postfixBranchResult.disjoint.length === 0)\n\t\t\ts.fixedVariants.push(postfixBranchResult)\n\t} else if (\n\t\trHead.kind === \"prefix\" &&\n\t\tlHead.kind === \"variadic\" &&\n\t\tlHasPostfix\n\t) {\n\t\tconst postfixBranchResult = _intersectSequences({\n\t\t\t...s,\n\t\t\tfixedVariants: [],\n\t\t\tl: lTail.map(element => ({ ...element, kind: \"prefix\" }))\n\t\t})\n\t\tif (postfixBranchResult.disjoint.length === 0)\n\t\t\ts.fixedVariants.push(postfixBranchResult)\n\t}\n\n\tconst result = intersectOrPipeNodes(lHead.node, rHead.node, s.ctx)\n\tif (result instanceof Disjoint) {\n\t\tif (kind === \"prefix\" || kind === \"postfix\") {\n\t\t\ts.disjoint.push(\n\t\t\t\t...result.withPrefixKey(\n\t\t\t\t\t// ideally we could handle disjoint paths more precisely here,\n\t\t\t\t\t// but not trivial to serialize postfix elements as keys\n\t\t\t\t\tkind === \"prefix\" ? s.result.length : `-${lTail.length + 1}`,\n\t\t\t\t\t// both operands must be required for the disjoint to be considered required\n\t\t\t\t\telementIsRequired(lHead) && elementIsRequired(rHead) ?\n\t\t\t\t\t\t\"required\"\n\t\t\t\t\t:\t\"optional\"\n\t\t\t\t)\n\t\t\t)\n\t\t\ts.result = [...s.result, { kind, node: $ark.intrinsic.never.internal }]\n\t\t} else if (kind === \"optionals\" || kind === \"defaultables\") {\n\t\t\t// if the element result is optional and unsatisfiable, the\n\t\t\t// intersection can still be satisfied as long as the tuple\n\t\t\t// ends before the disjoint element would occur\n\t\t\treturn s\n\t\t} else {\n\t\t\t// if the element is variadic and unsatisfiable, the intersection\n\t\t\t// can be satisfied with a fixed length variant including zero\n\t\t\t// variadic elements\n\t\t\treturn _intersectSequences({\n\t\t\t\t...s,\n\t\t\t\tfixedVariants: [],\n\t\t\t\t// if there were any optional elements, there will be no postfix elements\n\t\t\t\t// so this mapping will never occur (which would be illegal otherwise)\n\t\t\t\tl: lTail.map(element => ({ ...element, kind: \"prefix\" })),\n\t\t\t\tr: lTail.map(element => ({ ...element, kind: \"prefix\" }))\n\t\t\t})\n\t\t}\n\t} else if (kind === \"defaultables\") {\n\t\tif (\n\t\t\tlHead.kind === \"defaultables\" &&\n\t\t\trHead.kind === \"defaultables\" &&\n\t\t\tlHead.default !== rHead.default\n\t\t) {\n\t\t\tthrowParseError(\n\t\t\t\twriteDefaultIntersectionMessage(lHead.default, rHead.default)\n\t\t\t)\n\t\t}\n\n\t\ts.result = [\n\t\t\t...s.result,\n\t\t\t{\n\t\t\t\tkind,\n\t\t\t\tnode: result,\n\t\t\t\tdefault:\n\t\t\t\t\tlHead.kind === \"defaultables\" ? lHead.default\n\t\t\t\t\t: rHead.kind === \"defaultables\" ? rHead.default\n\t\t\t\t\t: throwInternalError(\n\t\t\t\t\t\t\t`Unexpected defaultable intersection from ${lHead.kind} and ${rHead.kind} elements.`\n\t\t\t\t\t\t)\n\t\t\t}\n\t\t]\n\t} else s.result = [...s.result, { kind, node: result }]\n\n\tconst lRemaining = s.l.length\n\tconst rRemaining = s.r.length\n\n\tif (\n\t\tlHead.kind !== \"variadic\" ||\n\t\t(lRemaining >= rRemaining &&\n\t\t\t(rHead.kind === \"variadic\" || rRemaining === 1))\n\t)\n\t\ts.l = lTail\n\n\tif (\n\t\trHead.kind !== \"variadic\" ||\n\t\t(rRemaining >= lRemaining &&\n\t\t\t(lHead.kind === \"variadic\" || lRemaining === 1))\n\t)\n\t\ts.r = rTail\n\n\treturn _intersectSequences(s)\n}\n\nconst elementIsRequired = (el: SequenceElement) =>\n\tel.kind === \"prefix\" || el.kind === \"postfix\"\n"
  },
  {
    "path": "ark/schema/structure/shared.ts",
    "content": "import {\n\tregisteredReference,\n\ttype RegisteredReference\n} from \"../shared/registry.ts\"\n\nexport const arrayIndexSource = `^(?:0|[1-9]\\\\d*)$`\n\nexport const arrayIndexMatcher = new RegExp(arrayIndexSource)\n\nexport const arrayIndexMatcherReference: RegisteredReference =\n\tregisteredReference(arrayIndexMatcher)\n"
  },
  {
    "path": "ark/schema/structure/structure.ts",
    "content": "import {\n\tappend,\n\tconflatenate,\n\tflatMorph,\n\tprintable,\n\tspliterate,\n\tthrowInternalError,\n\tthrowParseError,\n\ttype array,\n\ttype describe,\n\ttype dict,\n\ttype Key,\n\ttype listable\n} from \"@ark/util\"\nimport {\n\tBaseConstraint,\n\tconstraintKeyParser,\n\tflattenConstraints,\n\tintersectConstraints\n} from \"../constraint.ts\"\nimport { intrinsic } from \"../intrinsic.ts\"\nimport type { nodeOfKind } from \"../kinds.ts\"\nimport type { GettableKeyOrNode, KeyOrKeyNode } from \"../node.ts\"\nimport type { Morph } from \"../roots/morph.ts\"\nimport { typeOrTermExtends, type BaseRoot } from \"../roots/root.ts\"\nimport type { BaseScope } from \"../scope.ts\"\nimport { compileSerializedValue, type NodeCompiler } from \"../shared/compile.ts\"\nimport type {\n\tattachmentsOf,\n\tBaseNormalizedSchema,\n\tdeclareNode\n} from \"../shared/declare.ts\"\nimport { Disjoint } from \"../shared/disjoint.ts\"\nimport {\n\timplementNode,\n\ttype nodeImplementationOf,\n\ttype StructuralKind\n} from \"../shared/implement.ts\"\nimport { intersectNodesRoot } from \"../shared/intersections.ts\"\nimport type { JsonSchema } from \"../shared/jsonSchema.ts\"\nimport {\n\t$ark,\n\tregisteredReference,\n\ttype RegisteredReference\n} from \"../shared/registry.ts\"\nimport { ToJsonSchema } from \"../shared/toJsonSchema.ts\"\nimport {\n\ttraverseKey,\n\ttype InternalTraversal,\n\ttype TraversalKind,\n\ttype TraverseAllows,\n\ttype TraverseApply\n} from \"../shared/traversal.ts\"\nimport {\n\thasArkKind,\n\tisNode,\n\tmakeRootAndArrayPropertiesMutable\n} from \"../shared/utils.ts\"\nimport type { Index } from \"./index.ts\"\nimport { Optional, type OptionalNode } from \"./optional.ts\"\nimport type { Prop } from \"./prop.ts\"\nimport type { Required, RequiredNode } from \"./required.ts\"\nimport type { Sequence } from \"./sequence.ts\"\n\n/**\n * - `\"ignore\"` (default) - allow and preserve extra properties\n * - `\"reject\"` - disallow extra properties\n * - `\"delete\"` - clone and remove extra properties from output\n */\nexport type UndeclaredKeyBehavior = \"ignore\" | UndeclaredKeyHandling\n\nexport type UndeclaredKeyHandling = \"reject\" | \"delete\"\n\nexport declare namespace Structure {\n\texport interface Schema extends BaseNormalizedSchema {\n\t\treadonly optional?: readonly Optional.Schema[]\n\t\treadonly required?: readonly Required.Schema[]\n\t\treadonly index?: readonly Index.Schema[]\n\t\treadonly sequence?: Sequence.Schema\n\t\treadonly undeclared?: UndeclaredKeyBehavior\n\t}\n\n\texport interface Inner {\n\t\treadonly optional?: readonly Optional.Node[]\n\t\treadonly required?: readonly Required.Node[]\n\t\treadonly index?: readonly Index.Node[]\n\t\treadonly sequence?: Sequence.Node\n\t\treadonly undeclared?: UndeclaredKeyHandling\n\t}\n\n\texport namespace Inner {\n\t\texport type mutable = makeRootAndArrayPropertiesMutable<Inner>\n\t}\n\n\texport interface Declaration\n\t\textends declareNode<{\n\t\t\tkind: \"structure\"\n\t\t\tschema: Schema\n\t\t\tnormalizedSchema: Schema\n\t\t\tinner: Inner\n\t\t\tprerequisite: object\n\t\t\tchildKind: StructuralKind\n\t\t}> {}\n\n\texport type Node = StructureNode\n}\n\nconst createStructuralWriter =\n\t(childStringProp: \"expression\" | \"description\") => (node: StructureNode) => {\n\t\tif (node.props.length || node.index) {\n\t\t\tconst parts = node.index?.map(index => index[childStringProp]) ?? []\n\t\t\tfor (const prop of node.props) parts.push(prop[childStringProp])\n\n\t\t\tif (node.undeclared) parts.push(`+ (undeclared): ${node.undeclared}`)\n\n\t\t\tconst objectLiteralDescription = `{ ${parts.join(\", \")} }`\n\t\t\treturn node.sequence ?\n\t\t\t\t\t`${objectLiteralDescription} & ${node.sequence.description}`\n\t\t\t\t:\tobjectLiteralDescription\n\t\t}\n\t\treturn node.sequence?.description ?? \"{}\"\n\t}\n\nconst structuralDescription = createStructuralWriter(\"description\")\nconst structuralExpression = createStructuralWriter(\"expression\")\n\nconst intersectPropsAndIndex = <\n\tl extends nodeOfKind<\"required\"> | nodeOfKind<\"optional\">\n>(\n\tl: l,\n\tr: nodeOfKind<\"index\">,\n\t$: BaseScope\n): l | Disjoint | null => {\n\tconst kind = l.required ? \"required\" : \"optional\"\n\n\tif (!r.signature.allows(l.key)) return null\n\n\tconst value = intersectNodesRoot(l.value, r.value, $)\n\tif (value instanceof Disjoint) {\n\t\treturn kind === \"optional\" ?\n\t\t\t\t($.node(\"optional\", {\n\t\t\t\t\tkey: l.key,\n\t\t\t\t\tvalue: $ark.intrinsic.never.internal\n\t\t\t\t}) as l)\n\t\t\t:\tvalue.withPrefixKey(l.key, l.kind)\n\t}\n\n\treturn null\n}\n\nconst implementation: nodeImplementationOf<Structure.Declaration> =\n\timplementNode<Structure.Declaration>({\n\t\tkind: \"structure\",\n\t\thasAssociatedError: false,\n\t\tnormalize: schema => schema,\n\t\tapplyConfig: (schema, config) => {\n\t\t\tif (!schema.undeclared && config.onUndeclaredKey !== \"ignore\") {\n\t\t\t\treturn {\n\t\t\t\t\t...schema,\n\t\t\t\t\tundeclared: config.onUndeclaredKey\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn schema\n\t\t},\n\t\tkeys: {\n\t\t\trequired: {\n\t\t\t\tchild: true,\n\t\t\t\tparse: constraintKeyParser(\"required\"),\n\t\t\t\treduceIo: (ioKind, inner, nodes) => {\n\t\t\t\t\t// ensure we don't overwrite nodes added by optional\n\t\t\t\t\tinner.required = append(\n\t\t\t\t\t\tinner.required,\n\t\t\t\t\t\tnodes!.map(\n\t\t\t\t\t\t\tnode =>\n\t\t\t\t\t\t\t\t(ioKind === \"in\" ? node.rawIn : node.rawOut) as RequiredNode\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t},\n\t\t\toptional: {\n\t\t\t\tchild: true,\n\t\t\t\tparse: constraintKeyParser(\"optional\"),\n\t\t\t\treduceIo: (ioKind, inner, nodes) => {\n\t\t\t\t\tif (ioKind === \"in\") {\n\t\t\t\t\t\tinner.optional = nodes!.map(node => node.rawIn as OptionalNode)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\tfor (const node of nodes!) {\n\t\t\t\t\t\tinner[node.outProp.kind] = append(\n\t\t\t\t\t\t\tinner[node.outProp.kind],\n\t\t\t\t\t\t\tnode.outProp.rawOut as Prop.Node\n\t\t\t\t\t\t) as never\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tindex: {\n\t\t\t\tchild: true,\n\t\t\t\tparse: constraintKeyParser(\"index\")\n\t\t\t},\n\t\t\tsequence: {\n\t\t\t\tchild: true,\n\t\t\t\tparse: constraintKeyParser(\"sequence\")\n\t\t\t},\n\t\t\tundeclared: {\n\t\t\t\tparse: behavior => (behavior === \"ignore\" ? undefined : behavior),\n\t\t\t\treduceIo: (ioKind, inner, value) => {\n\t\t\t\t\tif (value === \"reject\") {\n\t\t\t\t\t\tinner.undeclared = \"reject\"\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\t// if base is \"delete\", undeclared keys are \"ignore\" (i.e. unconstrained)\n\t\t\t\t\t// on input and \"reject\" on output\n\n\t\t\t\t\tif (ioKind === \"in\") delete inner.undeclared\n\t\t\t\t\telse inner.undeclared = \"reject\"\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tdefaults: {\n\t\t\tdescription: structuralDescription\n\t\t},\n\t\tintersections: {\n\t\t\tstructure: (l, r, ctx) => {\n\t\t\t\tconst lInner = { ...l.inner }\n\t\t\t\tconst rInner = { ...r.inner }\n\t\t\t\tconst disjointResult = new Disjoint()\n\t\t\t\tif (l.undeclared) {\n\t\t\t\t\tconst lKey = l.keyof()\n\t\t\t\t\tfor (const k of r.requiredKeys) {\n\t\t\t\t\t\tif (!lKey.allows(k)) {\n\t\t\t\t\t\t\tdisjointResult.add(\n\t\t\t\t\t\t\t\t\"presence\",\n\t\t\t\t\t\t\t\t$ark.intrinsic.never.internal,\n\t\t\t\t\t\t\t\tr.propsByKey[k]!.value,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tpath: [k]\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (rInner.optional)\n\t\t\t\t\t\trInner.optional = rInner.optional.filter(n => lKey.allows(n.key))\n\t\t\t\t\tif (rInner.index) {\n\t\t\t\t\t\trInner.index = rInner.index.flatMap(n => {\n\t\t\t\t\t\t\tif (n.signature.extends(lKey)) return n\n\t\t\t\t\t\t\tconst indexOverlap = intersectNodesRoot(lKey, n.signature, ctx.$)\n\t\t\t\t\t\t\tif (indexOverlap instanceof Disjoint) return []\n\t\t\t\t\t\t\tconst normalized = normalizeIndex(indexOverlap, n.value, ctx.$)\n\t\t\t\t\t\t\tif (normalized.required) {\n\t\t\t\t\t\t\t\trInner.required = conflatenate(\n\t\t\t\t\t\t\t\t\trInner.required,\n\t\t\t\t\t\t\t\t\tnormalized.required\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (normalized.optional) {\n\t\t\t\t\t\t\t\trInner.optional = conflatenate(\n\t\t\t\t\t\t\t\t\trInner.optional,\n\t\t\t\t\t\t\t\t\tnormalized.optional\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn normalized.index ?? []\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (r.undeclared) {\n\t\t\t\t\tconst rKey = r.keyof()\n\t\t\t\t\tfor (const k of l.requiredKeys) {\n\t\t\t\t\t\tif (!rKey.allows(k)) {\n\t\t\t\t\t\t\tdisjointResult.add(\n\t\t\t\t\t\t\t\t\"presence\",\n\t\t\t\t\t\t\t\tl.propsByKey[k]!.value,\n\t\t\t\t\t\t\t\t$ark.intrinsic.never.internal,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tpath: [k]\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (lInner.optional)\n\t\t\t\t\t\tlInner.optional = lInner.optional.filter(n => rKey.allows(n.key))\n\t\t\t\t\tif (lInner.index) {\n\t\t\t\t\t\tlInner.index = lInner.index.flatMap(n => {\n\t\t\t\t\t\t\tif (n.signature.extends(rKey)) return n\n\t\t\t\t\t\t\tconst indexOverlap = intersectNodesRoot(rKey, n.signature, ctx.$)\n\t\t\t\t\t\t\tif (indexOverlap instanceof Disjoint) return []\n\t\t\t\t\t\t\tconst normalized = normalizeIndex(indexOverlap, n.value, ctx.$)\n\t\t\t\t\t\t\tif (normalized.required) {\n\t\t\t\t\t\t\t\tlInner.required = conflatenate(\n\t\t\t\t\t\t\t\t\tlInner.required,\n\t\t\t\t\t\t\t\t\tnormalized.required\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (normalized.optional) {\n\t\t\t\t\t\t\t\tlInner.optional = conflatenate(\n\t\t\t\t\t\t\t\t\tlInner.optional,\n\t\t\t\t\t\t\t\t\tnormalized.optional\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn normalized.index ?? []\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst baseInner: Structure.Inner.mutable = {}\n\n\t\t\t\tif (l.undeclared || r.undeclared) {\n\t\t\t\t\tbaseInner.undeclared =\n\t\t\t\t\t\tl.undeclared === \"reject\" || r.undeclared === \"reject\" ?\n\t\t\t\t\t\t\t\"reject\"\n\t\t\t\t\t\t:\t\"delete\"\n\t\t\t\t}\n\n\t\t\t\tconst childIntersectionResult = intersectConstraints({\n\t\t\t\t\tkind: \"structure\",\n\t\t\t\t\tbaseInner,\n\t\t\t\t\tl: flattenConstraints(lInner),\n\t\t\t\t\tr: flattenConstraints(rInner),\n\t\t\t\t\troots: [],\n\t\t\t\t\tctx\n\t\t\t\t})\n\n\t\t\t\tif (childIntersectionResult instanceof Disjoint)\n\t\t\t\t\tdisjointResult.push(...childIntersectionResult)\n\n\t\t\t\tif (disjointResult.length) return disjointResult\n\n\t\t\t\treturn childIntersectionResult\n\t\t\t}\n\t\t},\n\t\treduce: (inner, $) => {\n\t\t\tif (!inner.required && !inner.optional) return\n\n\t\t\tconst seen: Record<Key, true | undefined> = {}\n\t\t\tlet updated = false\n\t\t\tconst newOptionalProps: OptionalNode[] =\n\t\t\t\tinner.optional ? [...inner.optional] : []\n\n\t\t\t// check required keys for duplicates and handle index intersections\n\t\t\tif (inner.required) {\n\t\t\t\tfor (let i = 0; i < inner.required.length; i++) {\n\t\t\t\t\tconst requiredProp = inner.required[i]\n\t\t\t\t\tif (requiredProp.key in seen)\n\t\t\t\t\t\tthrowParseError(writeDuplicateKeyMessage(requiredProp.key))\n\t\t\t\t\tseen[requiredProp.key] = true\n\n\t\t\t\t\tif (inner.index) {\n\t\t\t\t\t\tfor (const index of inner.index) {\n\t\t\t\t\t\t\tconst intersection = intersectPropsAndIndex(\n\t\t\t\t\t\t\t\trequiredProp,\n\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\t$\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\tif (intersection instanceof Disjoint) return intersection\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// check optional keys for duplicates and handle index intersections\n\t\t\tif (inner.optional) {\n\t\t\t\tfor (let i = 0; i < inner.optional.length; i++) {\n\t\t\t\t\tconst optionalProp = inner.optional[i]\n\t\t\t\t\tif (optionalProp.key in seen)\n\t\t\t\t\t\tthrowParseError(writeDuplicateKeyMessage(optionalProp.key))\n\t\t\t\t\tseen[optionalProp.key] = true\n\n\t\t\t\t\tif (inner.index) {\n\t\t\t\t\t\tfor (const index of inner.index) {\n\t\t\t\t\t\t\tconst intersection = intersectPropsAndIndex(\n\t\t\t\t\t\t\t\toptionalProp,\n\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\t$\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\tif (intersection instanceof Disjoint) return intersection\n\t\t\t\t\t\t\tif (intersection !== null) {\n\t\t\t\t\t\t\t\tnewOptionalProps[i] = intersection\n\t\t\t\t\t\t\t\tupdated = true\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (updated) {\n\t\t\t\treturn $.node(\n\t\t\t\t\t\"structure\",\n\t\t\t\t\t{ ...inner, optional: newOptionalProps },\n\t\t\t\t\t{ prereduced: true }\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t})\n\nexport class StructureNode extends BaseConstraint<Structure.Declaration> {\n\timpliedBasis: BaseRoot = $ark.intrinsic.object.internal\n\timpliedSiblings = this.children.flatMap(\n\t\tn => (n.impliedSiblings as BaseConstraint[]) ?? []\n\t)\n\n\tprops: array<Prop.Node> = conflatenate<Prop.Node>(\n\t\tthis.required,\n\t\tthis.optional\n\t)\n\n\tpropsByKey: Record<Key, Prop.Node | undefined> = flatMorph(\n\t\tthis.props,\n\t\t(i, node) => [node.key, node] as const\n\t)\n\n\tpropsByKeyReference: RegisteredReference = registeredReference(\n\t\tthis.propsByKey\n\t)\n\n\texpression: string = structuralExpression(this)\n\n\trequiredKeys: Key[] = this.required?.map(node => node.key) ?? []\n\n\toptionalKeys: Key[] = this.optional?.map(node => node.key) ?? []\n\n\tliteralKeys: Key[] = [...this.requiredKeys, ...this.optionalKeys]\n\n\t_keyof: BaseRoot | undefined\n\tkeyof(): BaseRoot {\n\t\tif (this._keyof) return this._keyof\n\t\tlet branches = this.$.units(this.literalKeys).branches\n\t\tif (this.index) {\n\t\t\tfor (const { signature } of this.index)\n\t\t\t\tbranches = branches.concat(signature.branches)\n\t\t}\n\t\treturn (this._keyof = this.$.node(\"union\", branches))\n\t}\n\n\tmap(flatMapProp: PropFlatMapper): StructureNode {\n\t\treturn this.$.node(\n\t\t\t\"structure\",\n\t\t\tthis.props\n\t\t\t\t.flatMap(flatMapProp)\n\t\t\t\t.reduce((structureInner: Structure.Inner.mutable, mapped) => {\n\t\t\t\t\tconst originalProp = this.propsByKey[mapped.key]\n\n\t\t\t\t\tif (isNode(mapped)) {\n\t\t\t\t\t\tif (mapped.kind !== \"required\" && mapped.kind !== \"optional\") {\n\t\t\t\t\t\t\treturn throwParseError(\n\t\t\t\t\t\t\t\t`Map result must have kind \"required\" or \"optional\" (was ${mapped.kind})`\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tstructureInner[mapped.kind] = append(\n\t\t\t\t\t\t\tstructureInner[mapped.kind] as any,\n\t\t\t\t\t\t\tmapped\n\t\t\t\t\t\t)\n\t\t\t\t\t\treturn structureInner\n\t\t\t\t\t}\n\n\t\t\t\t\tconst mappedKind = mapped.kind ?? originalProp?.kind ?? \"required\"\n\n\t\t\t\t\t// extract the inner keys from the map result in case a node was spread,\n\t\t\t\t\t// which would otherwise lead to invalid keys\n\t\t\t\t\tconst mappedPropInner: Prop.Inner = flatMorph(\n\t\t\t\t\t\tmapped as BaseMappedPropInner,\n\t\t\t\t\t\t(k, v) => (k in Optional.implementation.keys ? [k, v] : [])\n\t\t\t\t\t) as never\n\n\t\t\t\t\tstructureInner[mappedKind] = append(\n\t\t\t\t\t\tstructureInner[mappedKind] as any,\n\t\t\t\t\t\tthis.$.node(mappedKind, mappedPropInner)\n\t\t\t\t\t)\n\n\t\t\t\t\treturn structureInner\n\t\t\t\t}, {})\n\t\t)\n\t}\n\n\tassertHasKeys(keys: array<KeyOrKeyNode>): void {\n\t\tconst invalidKeys = keys.filter(k => !typeOrTermExtends(k, this.keyof()))\n\n\t\tif (invalidKeys.length) {\n\t\t\treturn throwParseError(\n\t\t\t\twriteInvalidKeysMessage(this.expression, invalidKeys)\n\t\t\t)\n\t\t}\n\t}\n\n\tget(indexer: GettableKeyOrNode, ...path: array<GettableKeyOrNode>): BaseRoot {\n\t\tlet value: BaseRoot | undefined\n\t\tlet required = false\n\n\t\tconst key = indexerToKey(indexer)\n\n\t\tif (\n\t\t\t(typeof key === \"string\" || typeof key === \"symbol\") &&\n\t\t\tthis.propsByKey[key]\n\t\t) {\n\t\t\tvalue = this.propsByKey[key]!.value\n\t\t\trequired = this.propsByKey[key]!.required\n\t\t}\n\n\t\tif (this.index) {\n\t\t\tfor (const n of this.index) {\n\t\t\t\tif (typeOrTermExtends(key, n.signature))\n\t\t\t\t\tvalue = value?.and(n.value) ?? n.value\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\tthis.sequence &&\n\t\t\ttypeOrTermExtends(key, $ark.intrinsic.nonNegativeIntegerString)\n\t\t) {\n\t\t\tif (hasArkKind(key, \"root\")) {\n\t\t\t\tif (this.sequence.variadic)\n\t\t\t\t\t// if there is a variadic element and we're accessing an index, return a union\n\t\t\t\t\t// of all possible elements. If there is no variadic expression, we're in a tuple\n\t\t\t\t\t// so this access wouldn't be safe based on the array indices\n\t\t\t\t\tvalue = value?.and(this.sequence.element) ?? this.sequence.element\n\t\t\t} else {\n\t\t\t\tconst index = Number.parseInt(key as string)\n\t\t\t\tif (index < this.sequence.prevariadic.length) {\n\t\t\t\t\tconst fixedElement = this.sequence.prevariadic[index].node\n\t\t\t\t\tvalue = value?.and(fixedElement) ?? fixedElement\n\t\t\t\t\trequired ||= index < this.sequence.prefixLength\n\t\t\t\t} else if (this.sequence.variadic) {\n\t\t\t\t\t// ideally we could return something more specific for postfix\n\t\t\t\t\t// but there is no way to represent it using an index alone\n\t\t\t\t\tconst nonFixedElement = this.$.node(\n\t\t\t\t\t\t\"union\",\n\t\t\t\t\t\tthis.sequence.variadicOrPostfix\n\t\t\t\t\t)\n\t\t\t\t\tvalue = value?.and(nonFixedElement) ?? nonFixedElement\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (!value) {\n\t\t\tif (\n\t\t\t\tthis.sequence?.variadic &&\n\t\t\t\thasArkKind(key, \"root\") &&\n\t\t\t\tkey.extends($ark.intrinsic.number)\n\t\t\t) {\n\t\t\t\treturn throwParseError(\n\t\t\t\t\twriteNumberIndexMessage(key.expression, this.sequence.expression)\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn throwParseError(writeInvalidKeysMessage(this.expression, [key]))\n\t\t}\n\n\t\tconst result = value.get(...path)\n\t\treturn required ? result : result.or($ark.intrinsic.undefined)\n\t}\n\n\tpick(...keys: KeyOrKeyNode[]): StructureNode {\n\t\tthis.assertHasKeys(keys)\n\t\treturn this.$.node(\"structure\", this.filterKeys(\"pick\", keys))\n\t}\n\n\tomit(...keys: KeyOrKeyNode[]): StructureNode {\n\t\tthis.assertHasKeys(keys)\n\t\treturn this.$.node(\"structure\", this.filterKeys(\"omit\", keys))\n\t}\n\n\toptionalize(): StructureNode {\n\t\tconst { required, ...inner } = this.inner\n\t\treturn this.$.node(\"structure\", {\n\t\t\t...inner,\n\t\t\toptional: this.props.map(prop =>\n\t\t\t\tprop.hasKind(\"required\") ? this.$.node(\"optional\", prop.inner) : prop\n\t\t\t)\n\t\t})\n\t}\n\n\trequire(): StructureNode {\n\t\tconst { optional, ...inner } = this.inner\n\t\treturn this.$.node(\"structure\", {\n\t\t\t...inner,\n\t\t\trequired: this.props.map(prop =>\n\t\t\t\tprop.hasKind(\"optional\") ?\n\t\t\t\t\t{\n\t\t\t\t\t\tkey: prop.key,\n\t\t\t\t\t\tvalue: prop.value\n\t\t\t\t\t}\n\t\t\t\t:\tprop\n\t\t\t)\n\t\t})\n\t}\n\n\tmerge(r: StructureNode): StructureNode {\n\t\tconst inner = this.filterKeys(\"omit\", [r.keyof()])\n\n\t\tif (r.required) inner.required = append(inner.required, r.required)\n\t\tif (r.optional) inner.optional = append(inner.optional, r.optional)\n\t\tif (r.index) inner.index = append(inner.index, r.index)\n\t\tif (r.sequence) inner.sequence = r.sequence\n\t\tif (r.undeclared) inner.undeclared = r.undeclared\n\t\telse delete inner.undeclared\n\t\treturn this.$.node(\"structure\", inner)\n\t}\n\n\tprivate filterKeys(\n\t\toperation: \"pick\" | \"omit\",\n\t\tkeys: array<BaseRoot | Key>\n\t): Structure.Inner.mutable {\n\t\tconst result = makeRootAndArrayPropertiesMutable(this.inner)\n\n\t\tconst shouldKeep = (key: KeyOrKeyNode) => {\n\t\t\tconst matchesKey = keys.some(k => typeOrTermExtends(key, k))\n\t\t\treturn operation === \"pick\" ? matchesKey : !matchesKey\n\t\t}\n\n\t\tif (result.required)\n\t\t\tresult.required = result.required.filter(prop => shouldKeep(prop.key))\n\n\t\tif (result.optional)\n\t\t\tresult.optional = result.optional.filter(prop => shouldKeep(prop.key))\n\n\t\tif (result.index)\n\t\t\tresult.index = result.index.filter(index => shouldKeep(index.signature))\n\n\t\treturn result\n\t}\n\n\ttraverseAllows: TraverseAllows<object> = (data, ctx) =>\n\t\tthis._traverse(\"Allows\", data, ctx)\n\n\ttraverseApply: TraverseApply<object> = (data, ctx) =>\n\t\tthis._traverse(\"Apply\", data, ctx)\n\n\tprotected _traverse = (\n\t\ttraversalKind: TraversalKind,\n\t\tdata: object,\n\t\tctx: InternalTraversal\n\t): boolean => {\n\t\tconst errorCount = ctx?.currentErrorCount ?? 0\n\t\tfor (let i = 0; i < this.props.length; i++) {\n\t\t\tif (traversalKind === \"Allows\") {\n\t\t\t\tif (!this.props[i].traverseAllows(data, ctx)) return false\n\t\t\t} else {\n\t\t\t\tthis.props[i].traverseApply(data as never, ctx)\n\t\t\t\tif (ctx.failFast && ctx.currentErrorCount > errorCount) return false\n\t\t\t}\n\t\t}\n\n\t\tif (this.sequence) {\n\t\t\tif (traversalKind === \"Allows\") {\n\t\t\t\tif (!this.sequence.traverseAllows(data as never, ctx)) return false\n\t\t\t} else {\n\t\t\t\tthis.sequence.traverseApply(data as never, ctx)\n\t\t\t\tif (ctx.failFast && ctx.currentErrorCount > errorCount) return false\n\t\t\t}\n\t\t}\n\n\t\tif (this.index || this.undeclared === \"reject\") {\n\t\t\tconst keys: Key[] = Object.keys(data)\n\t\t\tkeys.push(...Object.getOwnPropertySymbols(data))\n\n\t\t\tfor (let i = 0; i < keys.length; i++) {\n\t\t\t\tconst k = keys[i]\n\n\t\t\t\tif (this.index) {\n\t\t\t\t\tfor (const node of this.index) {\n\t\t\t\t\t\tif (node.signature.traverseAllows(k, ctx)) {\n\t\t\t\t\t\t\tif (traversalKind === \"Allows\") {\n\t\t\t\t\t\t\t\tconst result = traverseKey(\n\t\t\t\t\t\t\t\t\tk,\n\t\t\t\t\t\t\t\t\t() => node.value.traverseAllows(data[k as never], ctx),\n\t\t\t\t\t\t\t\t\tctx\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tif (!result) return false\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\ttraverseKey(\n\t\t\t\t\t\t\t\t\tk,\n\t\t\t\t\t\t\t\t\t() => node.value.traverseApply(data[k as never], ctx),\n\t\t\t\t\t\t\t\t\tctx\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tif (ctx.failFast && ctx.currentErrorCount > errorCount)\n\t\t\t\t\t\t\t\t\treturn false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (this.undeclared === \"reject\" && !this.declaresKey(k)) {\n\t\t\t\t\tif (traversalKind === \"Allows\") return false\n\n\t\t\t\t\t// this should have its own error code:\n\t\t\t\t\t// https://github.com/arktypeio/arktype/issues/1403\n\t\t\t\t\tctx.errorFromNodeContext({\n\t\t\t\t\t\tcode: \"predicate\",\n\t\t\t\t\t\texpected: \"removed\",\n\t\t\t\t\t\tactual: \"\",\n\t\t\t\t\t\trelativePath: [k],\n\t\t\t\t\t\tmeta: this.meta\n\t\t\t\t\t})\n\n\t\t\t\t\tif (ctx.failFast) return false\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// added additional ctx check here to address\n\t\t// https://github.com/arktypeio/arktype/issues/1346\n\t\tif (this.structuralMorph && ctx && !ctx.hasError())\n\t\t\tctx.queueMorphs([this.structuralMorph])\n\n\t\treturn true\n\t}\n\n\tget defaultable(): Optional.Node.withDefault[] {\n\t\treturn this.cacheGetter(\n\t\t\t\"defaultable\",\n\t\t\tthis.optional?.filter(o => o.hasDefault()) ?? []\n\t\t)\n\t}\n\n\tdeclaresKey = (k: Key): boolean =>\n\t\tk in this.propsByKey ||\n\t\tthis.index?.some(n => n.signature.allows(k)) ||\n\t\t(this.sequence !== undefined &&\n\t\t\t$ark.intrinsic.nonNegativeIntegerString.allows(k))\n\n\t_compileDeclaresKey(js: NodeCompiler): string {\n\t\tconst parts: string[] = []\n\t\tif (this.props.length) parts.push(`k in ${this.propsByKeyReference}`)\n\n\t\tif (this.index) {\n\t\t\tfor (const index of this.index)\n\t\t\t\tparts.push(js.invoke(index.signature, { kind: \"Allows\", arg: \"k\" }))\n\t\t}\n\n\t\tif (this.sequence)\n\t\t\tparts.push(\"$ark.intrinsic.nonNegativeIntegerString.allows(k)\")\n\n\t\t// if parts is empty, this is a structure like { \"+\": \"reject\" }\n\t\t// that declares no keys, so return false\n\t\treturn parts.join(\" || \") || \"false\"\n\t}\n\n\tget structuralMorph(): Morph | undefined {\n\t\treturn this.cacheGetter(\"structuralMorph\", getPossibleMorph(this))\n\t}\n\n\tstructuralMorphRef: RegisteredReference | undefined =\n\t\tthis.structuralMorph && registeredReference(this.structuralMorph)\n\n\tcompile(js: NodeCompiler): unknown {\n\t\tif (js.traversalKind === \"Apply\") js.initializeErrorCount()\n\n\t\tfor (const prop of this.props) {\n\t\t\tjs.check(prop)\n\t\t\tif (js.traversalKind === \"Apply\") js.returnIfFailFast()\n\t\t}\n\n\t\tif (this.sequence) {\n\t\t\tjs.check(this.sequence)\n\t\t\tif (js.traversalKind === \"Apply\") js.returnIfFailFast()\n\t\t}\n\n\t\tif (this.index || this.undeclared === \"reject\") {\n\t\t\tjs.const(\"keys\", \"Object.keys(data)\")\n\t\t\tjs.line(\"keys.push(...Object.getOwnPropertySymbols(data))\")\n\t\t\tjs.for(\"i < keys.length\", () => this.compileExhaustiveEntry(js))\n\t\t}\n\n\t\tif (js.traversalKind === \"Allows\") return js.return(true)\n\n\t\t// always queue deleteUndeclared on valid traversal for \"delete\"\n\t\tif (this.structuralMorphRef) {\n\t\t\t// added additional ctx check here to address\n\t\t\t// https://github.com/arktypeio/arktype/issues/1346\n\t\t\tjs.if(\"ctx && !ctx.hasError()\", () => {\n\t\t\t\tjs.line(`ctx.queueMorphs([`)\n\t\t\t\tprecompileMorphs(js, this)\n\t\t\t\treturn js.line(\"])\")\n\t\t\t})\n\t\t}\n\t}\n\n\tprotected compileExhaustiveEntry(js: NodeCompiler): NodeCompiler {\n\t\tjs.const(\"k\", \"keys[i]\")\n\n\t\tif (this.index) {\n\t\t\tfor (const node of this.index) {\n\t\t\t\tjs.if(\n\t\t\t\t\t`${js.invoke(node.signature, { arg: \"k\", kind: \"Allows\" })}`,\n\t\t\t\t\t() => js.traverseKey(\"k\", \"data[k]\", node.value)\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\tif (this.undeclared === \"reject\") {\n\t\t\tjs.if(`!(${this._compileDeclaresKey(js)})`, () => {\n\t\t\t\tif (js.traversalKind === \"Allows\") return js.return(false)\n\t\t\t\treturn js\n\t\t\t\t\t.line(\n\t\t\t\t\t\t`ctx.errorFromNodeContext({ code: \"predicate\", expected: \"removed\", actual: \"\", relativePath: [k], meta: ${this.compiledMeta} })`\n\t\t\t\t\t)\n\t\t\t\t\t.if(\"ctx.failFast\", () => js.return())\n\t\t\t})\n\t\t}\n\n\t\treturn js\n\t}\n\n\treduceJsonSchema(\n\t\tschema: JsonSchema.Structure,\n\t\tctx: ToJsonSchema.Context\n\t): JsonSchema.Structure {\n\t\tswitch (schema.type) {\n\t\t\tcase \"object\":\n\t\t\t\treturn this.reduceObjectJsonSchema(schema, ctx)\n\t\t\tcase \"array\":\n\t\t\t\tconst arraySchema =\n\t\t\t\t\tthis.sequence?.reduceJsonSchema(schema, ctx) ?? schema\n\t\t\t\tif (this.props.length || this.index) {\n\t\t\t\t\treturn ctx.fallback.arrayObject({\n\t\t\t\t\t\tcode: \"arrayObject\",\n\t\t\t\t\t\tbase: arraySchema,\n\t\t\t\t\t\tobject: this.reduceObjectJsonSchema({ type: \"object\" }, ctx)\n\t\t\t\t\t})\n\t\t\t\t}\n\n\t\t\t\treturn arraySchema\n\n\t\t\tdefault:\n\t\t\t\treturn ToJsonSchema.throwInternalOperandError(\"structure\", schema)\n\t\t}\n\t}\n\n\treduceObjectJsonSchema(\n\t\tschema: JsonSchema.Object,\n\t\tctx: ToJsonSchema.Context\n\t): JsonSchema.Object {\n\t\tif (this.props.length) {\n\t\t\tschema.properties = {}\n\t\t\tfor (const prop of this.props) {\n\t\t\t\tconst valueSchema = prop.value.toJsonSchemaRecurse(ctx)\n\n\t\t\t\tif (typeof prop.key === \"symbol\") {\n\t\t\t\t\tctx.fallback.symbolKey({\n\t\t\t\t\t\tcode: \"symbolKey\",\n\t\t\t\t\t\tbase: schema,\n\t\t\t\t\t\tkey: prop.key,\n\t\t\t\t\t\tvalue: valueSchema,\n\t\t\t\t\t\toptional: prop.optional\n\t\t\t\t\t})\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tif (prop.hasDefault()) {\n\t\t\t\t\tconst value =\n\t\t\t\t\t\ttypeof prop.default === \"function\" ? prop.default() : prop.default\n\t\t\t\t\tvalueSchema.default =\n\t\t\t\t\t\t$ark.intrinsic.jsonData.allows(value) ?\n\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t:\tctx.fallback.defaultValue({\n\t\t\t\t\t\t\t\tcode: \"defaultValue\",\n\t\t\t\t\t\t\t\tbase: valueSchema,\n\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t})\n\t\t\t\t}\n\n\t\t\t\tschema.properties![prop.key] = valueSchema\n\t\t\t}\n\t\t\tif (this.requiredKeys.length && schema.properties) {\n\t\t\t\tschema.required = this.requiredKeys.filter(\n\t\t\t\t\t(k): k is string => typeof k === \"string\" && k in schema.properties!\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\tif (this.index) {\n\t\t\tfor (const index of this.index) {\n\t\t\t\tconst valueJsonSchema = index.value.toJsonSchemaRecurse(ctx)\n\n\t\t\t\tif (index.signature.equals($ark.intrinsic.string)) {\n\t\t\t\t\tschema.additionalProperties = valueJsonSchema\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tfor (const keyBranch of index.signature.branches) {\n\t\t\t\t\tif (!keyBranch.extends($ark.intrinsic.string)) {\n\t\t\t\t\t\tschema = ctx.fallback.symbolKey({\n\t\t\t\t\t\t\tcode: \"symbolKey\",\n\t\t\t\t\t\t\tbase: schema,\n\t\t\t\t\t\t\tkey: null,\n\t\t\t\t\t\t\tvalue: valueJsonSchema,\n\t\t\t\t\t\t\toptional: false\n\t\t\t\t\t\t})\n\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\n\t\t\t\t\tlet keySchema: JsonSchema.String = { type: \"string\" }\n\t\t\t\t\tif (keyBranch.hasKind(\"morph\")) {\n\t\t\t\t\t\tkeySchema = ctx.fallback.morph({\n\t\t\t\t\t\t\tcode: \"morph\",\n\t\t\t\t\t\t\tbase: keyBranch.rawIn.toJsonSchemaRecurse(ctx),\n\t\t\t\t\t\t\tout: keyBranch.rawOut.toJsonSchemaRecurse(ctx)\n\t\t\t\t\t\t}) as never\n\t\t\t\t\t}\n\t\t\t\t\tif (!keyBranch.hasKind(\"intersection\")) {\n\t\t\t\t\t\treturn throwInternalError(\n\t\t\t\t\t\t\t`Unexpected index branch kind ${keyBranch.kind}.`\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\n\t\t\t\t\tconst { pattern } = keyBranch.inner\n\n\t\t\t\t\tif (pattern) {\n\t\t\t\t\t\tconst keySchemaWithPattern = Object.assign(keySchema, {\n\t\t\t\t\t\t\tpattern: pattern[0].rule\n\t\t\t\t\t\t})\n\n\t\t\t\t\t\tfor (let i = 1; i < pattern.length; i++) {\n\t\t\t\t\t\t\tkeySchema = ctx.fallback.patternIntersection({\n\t\t\t\t\t\t\t\tcode: \"patternIntersection\",\n\t\t\t\t\t\t\t\tbase: keySchemaWithPattern,\n\t\t\t\t\t\t\t\tpattern: pattern[i].rule\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tschema.patternProperties ??= {}\n\t\t\t\t\t\tschema.patternProperties[keySchemaWithPattern.pattern] =\n\t\t\t\t\t\t\tvalueJsonSchema\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (this.undeclared && !schema.additionalProperties)\n\t\t\tschema.additionalProperties = false\n\n\t\treturn schema\n\t}\n}\n\nconst defaultableMorphsCache: Record<string, Morph | undefined> = {}\n\ntype PartiallyInitializedStructure = attachmentsOf<Structure.Declaration> &\n\tPick<Structure.Node, \"defaultable\" | \"declaresKey\">\n\nconst constructStructuralMorphCacheKey = (\n\tnode: PartiallyInitializedStructure\n): string => {\n\tlet cacheKey = \"\"\n\n\tfor (let i = 0; i < node.defaultable.length; i++)\n\t\tcacheKey += node.defaultable[i].defaultValueMorphRef\n\n\tif (node.sequence?.defaultValueMorphsReference)\n\t\tcacheKey += node.sequence?.defaultValueMorphsReference\n\n\tif (node.undeclared === \"delete\") {\n\t\tcacheKey += \"delete !(\"\n\t\tif (node.required)\n\t\t\tfor (const n of node.required) cacheKey += n.compiledKey + \" | \"\n\t\tif (node.optional)\n\t\t\tfor (const n of node.optional) cacheKey += n.compiledKey + \" | \"\n\t\tif (node.index)\n\t\t\tfor (const index of node.index) cacheKey += index.signature.id + \" | \"\n\t\tif (node.sequence) {\n\t\t\tif (node.sequence.maxLength === null)\n\t\t\t\tcacheKey += intrinsic.nonNegativeIntegerString.id\n\t\t\telse {\n\t\t\t\tfor (let i = 0; i < node.sequence.tuple.length; i++)\n\t\t\t\t\tcacheKey += i + \" | \"\n\t\t\t}\n\t\t}\n\t\tcacheKey += \")\"\n\t}\n\n\treturn cacheKey\n}\n\nconst getPossibleMorph = (\n\tnode: PartiallyInitializedStructure\n): Morph | undefined => {\n\tconst cacheKey = constructStructuralMorphCacheKey(node)\n\tif (!cacheKey) return undefined\n\n\tif (defaultableMorphsCache[cacheKey]) return defaultableMorphsCache[cacheKey]\n\n\tconst $arkStructuralMorph: Morph<any> = (data, ctx) => {\n\t\tfor (let i = 0; i < node.defaultable.length; i++) {\n\t\t\tif (!(node.defaultable[i].key in data))\n\t\t\t\tnode.defaultable[i].defaultValueMorph(data as never, ctx)\n\t\t}\n\n\t\tif (node.sequence?.defaultables) {\n\t\t\tfor (\n\t\t\t\tlet i = data.length - node.sequence.prefixLength;\n\t\t\t\ti < node.sequence.defaultables.length;\n\t\t\t\ti++\n\t\t\t)\n\t\t\t\tnode.sequence.defaultValueMorphs[i](data as never, ctx)\n\t\t}\n\n\t\tif (node.undeclared === \"delete\")\n\t\t\tfor (const k in data) if (!node.declaresKey(k)) delete (data as dict)[k]\n\n\t\treturn data\n\t}\n\n\treturn (defaultableMorphsCache[cacheKey] = $arkStructuralMorph)\n}\n\nconst precompileMorphs = (js: NodeCompiler, node: Structure.Node) => {\n\tconst requiresContext =\n\t\tnode.defaultable.some(node => node.defaultValueMorph.length === 2) ||\n\t\tnode.sequence?.defaultValueMorphs.some(morph => morph.length === 2)\n\n\tconst args = `(data${requiresContext ? \", ctx\" : \"\"})`\n\n\treturn js.block(`${args} => `, js => {\n\t\tfor (let i = 0; i < node.defaultable.length; i++) {\n\t\t\tconst { serializedKey, defaultValueMorphRef } = node.defaultable[i]\n\t\t\tjs.if(`!(${serializedKey} in data)`, js =>\n\t\t\t\tjs.line(`${defaultValueMorphRef}${args}`)\n\t\t\t)\n\t\t}\n\n\t\tif (node.sequence?.defaultables) {\n\t\t\tjs.for(\n\t\t\t\t`i < ${node.sequence.defaultables.length}`,\n\t\t\t\tjs =>\n\t\t\t\t\tjs.line(`${node.sequence!.defaultValueMorphsReference}[i]${args}`),\n\t\t\t\t`data.length - ${node.sequence.prefixLength}`\n\t\t\t)\n\t\t}\n\n\t\tif (node.undeclared === \"delete\") {\n\t\t\tjs.forIn(\"data\", js =>\n\t\t\t\tjs.if(`!(${node._compileDeclaresKey(js)})`, js =>\n\t\t\t\t\tjs.line(`delete data[k]`)\n\t\t\t\t)\n\t\t\t)\n\t\t}\n\n\t\treturn js.return(\"data\")\n\t})\n}\n\nexport type PropFlatMapper = (entry: Prop.Node) => listable<MappedPropInner>\n\nexport type MappedPropInner = BaseMappedPropInner | OptionalMappedPropInner\n\n// this assumes the props on Required.Inner are a subset of those on Optional.Inner\nexport interface BaseMappedPropInner extends Required.Schema {\n\tkind?: \"required\" | \"optional\"\n}\n\nexport interface OptionalMappedPropInner extends Optional.Schema {\n\tkind: \"optional\"\n}\n\nexport const Structure = {\n\timplementation,\n\tNode: StructureNode\n}\n\nconst indexerToKey = (indexable: GettableKeyOrNode): KeyOrKeyNode => {\n\tif (hasArkKind(indexable, \"root\") && indexable.hasKind(\"unit\"))\n\t\tindexable = indexable.unit as Key\n\tif (typeof indexable === \"number\") indexable = `${indexable}`\n\treturn indexable\n}\n\nexport const writeNumberIndexMessage = (\n\tindexExpression: string,\n\tsequenceExpression: string\n): string =>\n\t`${indexExpression} is not allowed as an array index on ${sequenceExpression}. Use the 'nonNegativeIntegerString' keyword instead.`\n\nexport type NormalizedIndex = {\n\tindex?: Index.Node\n\trequired?: Required.Node[]\n\toptional?: Optional.Node[]\n}\n\n/** extract enumerable named props from an index signature */\nexport const normalizeIndex = (\n\tsignature: BaseRoot,\n\tvalue: BaseRoot,\n\t$: BaseScope\n): NormalizedIndex => {\n\tconst [enumerableBranches, nonEnumerableBranches] = spliterate(\n\t\tsignature.branches,\n\t\tk => k.hasKind(\"unit\")\n\t)\n\n\tif (!enumerableBranches.length)\n\t\treturn { index: $.node(\"index\", { signature, value }) }\n\n\tconst normalized: NormalizedIndex = {}\n\n\tfor (const n of enumerableBranches) {\n\t\t// since required can be reduced to optional if it has a default or\n\t\t// optional meta on its value, we have to assign it depending on the\n\t\t// compiled kind\n\t\tconst prop = $.node(\"required\", { key: n.unit as Key, value })\n\t\tnormalized[prop.kind] = append(normalized[prop.kind], prop as never)\n\t}\n\n\tif (nonEnumerableBranches.length) {\n\t\tnormalized.index = $.node(\"index\", {\n\t\t\tsignature: nonEnumerableBranches,\n\t\t\tvalue\n\t\t})\n\t}\n\n\treturn normalized\n}\n\nexport const typeKeyToString = (k: KeyOrKeyNode): string =>\n\thasArkKind(k, \"root\") ? k.expression : printable(k)\n\nexport const writeInvalidKeysMessage = <\n\to extends string,\n\tkeys extends array<KeyOrKeyNode>\n>(\n\to: o,\n\tkeys: keys\n): string =>\n\t`Key${keys.length === 1 ? \"\" : \"s\"} ${keys.map(typeKeyToString).join(\", \")} ${keys.length === 1 ? \"does\" : \"do\"} not exist on ${o}`\n\nexport const writeDuplicateKeyMessage = <key extends Key>(\n\tkey: key\n): writeDuplicateKeyMessage<key> =>\n\t`Duplicate key ${compileSerializedValue(key) as never}`\n\nexport type writeDuplicateKeyMessage<key extends Key> =\n\t`Duplicate key '${describe<key>}'`\n"
  },
  {
    "path": "ark/themes/.vscode/launch.json",
    "content": "// A launch configuration that launches the extension inside a new window\n{\n\t\"version\": \"0.1.0\",\n\t\"configurations\": [\n\t\t{\n\t\t\t\"name\": \"Debug Themes\",\n\t\t\t\"type\": \"extensionHost\",\n\t\t\t\"request\": \"launch\",\n\t\t\t\"runtimeExecutable\": \"${execPath}\",\n\t\t\t\"args\": [\"--extensionDevelopmentPath=${workspaceRoot}\"]\n\t\t}\n\t]\n}\n"
  },
  {
    "path": "ark/themes/README.md",
    "content": "<div align=\"center\">\n  <img src=\"https://arktype.io/image/logo.png\" height=\"64px\" />\n  <h1>ArkThemes</h1>\n</div>\n\n<div align=\"center\">\n\nA collection of themes with special highlighting for TypeScript generics ⛵\n\nCreated with love by the [ArkType](https://arktype.io) team 🥰\n\n</div>\n\n### Dark\n\n![theme](https://raw.githubusercontent.com/arktypeio/arktype/refs/heads/main/ark/themes/dark.png)\n\n### Light\n\n![theme](https://raw.githubusercontent.com/arktypeio/arktype/refs/heads/main/ark/themes/light.png)\n"
  },
  {
    "path": "ark/themes/arkdark.json",
    "content": "{\n\t\"$schema\": \"vscode://schemas/color-theme\",\n\t\"name\": \"ArkDark\",\n\t\"tokenColors\": [\n\t\t{\n\t\t\t\"name\": \"functions\",\n\t\t\t\"scope\": [\n\t\t\t\t\"entity.name.function\",\n\t\t\t\t\"support.function\",\n\t\t\t\t\"meta.function-call.python\",\n\t\t\t\t\"meta.function.decorator punctuation\",\n\t\t\t\t\"meta.function.decorator support.type\"\n\t\t\t],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#80cff8\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"name\": \"types and decorators\",\n\t\t\t\"scope\": [\"entity.name.type\", \"meta.decorator.ts variable\"],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#40decc\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"scope\": [\"meta.type.declaration.ts entity.name.type\"],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#80cff8\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"name\": \"keywords and operators\",\n\t\t\t\"scope\": [\n\t\t\t\t\"keyword\",\n\t\t\t\t\"storage\",\n\t\t\t\t\"punctuation\",\n\t\t\t\t\"constant.character.escape\"\n\t\t\t],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#ba7e41\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"name\": \"properties and strings\",\n\t\t\t\"scope\": [\n\t\t\t\t\"variable.other.property\",\n\t\t\t\t\"variable.other.constant.property\",\n\t\t\t\t\"string\"\n\t\t\t],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#f5cf8f\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"name\": \"this, primitives, built-in types, quotes\",\n\t\t\t\"scope\": [\n\t\t\t\t\"variable.language\",\n\t\t\t\t\"constant\",\n\t\t\t\t\"support.type\",\n\t\t\t\t\"entity.name.tag\",\n\t\t\t\t\"punctuation.definition.string.begin\",\n\t\t\t\t\"punctuation.definition.string.end\",\n\t\t\t\t\"punctuation.definition.string.template.begin\",\n\t\t\t\t\"punctuation.definition.string.template.end\"\n\t\t\t],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#408fde\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"name\": \"errors\",\n\t\t\t\"scope\": [\"invalid\", \"support.type.exception\"],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#9558f8\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"name\": \"comment\",\n\t\t\t\"scope\": [\"comment\", \"punctuation.definition.comment\"],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#888899\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"name\": \"variable\",\n\t\t\t\"scope\": [\"variable\", \"meta.function-call.arguments\"],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#eeeeee\"\n\t\t\t}\n\t\t}\n\t],\n\t\"colors\": {\n\t\t\"editor.foreground\": \"#eeeeee\",\n\t\t\"editor.background\": \"#080d17\",\n\t\t\"errorForeground\": \"#9558f8\",\n\t\t\"editorError.foreground\": \"#9558f8\",\n\t\t\"editorWarning.foreground\": \"#2faf64\",\n\t\t\"minimap.errorHighlight\": \"#9558f8\",\n\t\t\"list.errorForeground\": \"#9558f8\",\n\t\t\"editorOverviewRuler.errorForeground\": \"#9558f8\",\n\t\t\"editorBracketHighlight.foreground1\": \"#f5cf8f\",\n\t\t\"editorBracketHighlight.foreground2\": \"#ba7e41\",\n\t\t\"editorBracketHighlight.foreground3\": \"#eb9f2e\",\n\t\t\"editorBracketHighlight.unexpectedBracket.foreground\": \"#ba7e41\",\n\t\t\"editorCursor.foreground\": \"#408fde\",\n\t\t\"terminalCursor.foreground\": \"#408fde\",\n\t\t\"editorCodeLens.foreground\": \"#00ccff60\",\n\t\t\"editorInlayHint.background\": \"#00b7e40c\",\n\t\t\"editorInlayHint.foreground\": \"#00ccff60\",\n\t\t\"errorLens.errorBackground\": \"#9558f818\",\n\t\t\"errorLens.errorForeground\": \"#9558f8a0\",\n\t\t\"errorLens.warningBackground\": \"#00b7e40c\",\n\t\t\"errorLens.warningForeground\": \"#00ccff60\",\n\t\t\"errorLens.infoBackground\": \"#00b7e40c\",\n\t\t\"errorLens.infoForeground\": \"#00ccff60\",\n\t\t\"errorLens.hintBackground\": \"#17a2a20c\",\n\t\t\"errorLens.hintForeground\": \"#2faf6460\",\n\t\t\"activityBar.activeBorder\": \"#0078D4\",\n\t\t\"activityBar.background\": \"#070b12\",\n\t\t\"activityBar.border\": \"#101827\",\n\t\t\"activityBar.foreground\": \"#D7D7D7\",\n\t\t\"activityBar.inactiveForeground\": \"#868686\",\n\t\t\"activityBarBadge.background\": \"#0078D4\",\n\t\t\"activityBarBadge.foreground\": \"#FFFFFF\",\n\t\t\"badge.background\": \"#616161\",\n\t\t\"badge.foreground\": \"#F8F8F8\",\n\t\t\"button.background\": \"#0078D4\",\n\t\t\"button.border\": \"#FFFFFF12\",\n\t\t\"button.foreground\": \"#FFFFFF\",\n\t\t\"button.hoverBackground\": \"#026EC1\",\n\t\t\"button.secondaryBackground\": \"#131b26\",\n\t\t\"button.secondaryForeground\": \"#CCCCCC\",\n\t\t\"button.secondaryHoverBackground\": \"#1a2634\",\n\t\t\"chat.slashCommandBackground\": \"#34414B\",\n\t\t\"chat.slashCommandForeground\": \"#40A6FF\",\n\t\t\"checkbox.background\": \"#131b26\",\n\t\t\"checkbox.border\": \"#1a2634\",\n\t\t\"debugToolBar.background\": \"#070b12\",\n\t\t\"descriptionForeground\": \"#9D9D9D\",\n\t\t\"dropdown.background\": \"#131b26\",\n\t\t\"dropdown.border\": \"#1a2634\",\n\t\t\"dropdown.foreground\": \"#CCCCCC\",\n\t\t\"dropdown.listBackground\": \"#080d17\",\n\t\t\"editor.findMatchBackground\": \"#9E6A03\",\n\t\t\"editorGroup.border\": \"#FFFFFF17\",\n\t\t\"editorGroupHeader.tabsBackground\": \"#070b12\",\n\t\t\"editorGroupHeader.tabsBorder\": \"#101827\",\n\t\t\"editorGutter.addedBackground\": \"#2EA043\",\n\t\t\"editorGutter.deletedBackground\": \"#F85149\",\n\t\t\"editorGutter.modifiedBackground\": \"#0078D4\",\n\t\t\"editorLineNumber.activeForeground\": \"#CCCCCC\",\n\t\t\"editorLineNumber.foreground\": \"#6E7681\",\n\t\t\"editorOverviewRuler.border\": \"#010409\",\n\t\t\"editorWidget.background\": \"#0a1320\",\n\t\t\"focusBorder\": \"#0078D4\",\n\t\t\"foreground\": \"#CCCCCC\",\n\t\t\"icon.foreground\": \"#CCCCCC\",\n\t\t\"input.background\": \"#131b26\",\n\t\t\"input.border\": \"#1a2634\",\n\t\t\"input.foreground\": \"#CCCCCC\",\n\t\t\"input.placeholderForeground\": \"#9D9D9D\",\n\t\t\"inputOption.activeBackground\": \"#2489DB82\",\n\t\t\"inputOption.activeBorder\": \"#2488DB\",\n\t\t\"keybindingLabel.foreground\": \"#CCCCCC\",\n\t\t\"menu.background\": \"#080d17\",\n\t\t\"notificationCenterHeader.background\": \"#080d17\",\n\t\t\"notificationCenterHeader.foreground\": \"#CCCCCC\",\n\t\t\"notifications.background\": \"#080d17\",\n\t\t\"notifications.border\": \"#101827\",\n\t\t\"notifications.foreground\": \"#CCCCCC\",\n\t\t\"panel.background\": \"#070b12\",\n\t\t\"panel.border\": \"#101827\",\n\t\t\"panelInput.border\": \"#101827\",\n\t\t\"panelTitle.activeBorder\": \"#0078D4\",\n\t\t\"panelTitle.activeForeground\": \"#CCCCCC\",\n\t\t\"panelTitle.inactiveForeground\": \"#9D9D9D\",\n\t\t\"peekViewEditor.background\": \"#080d17\",\n\t\t\"peekViewEditor.matchHighlightBackground\": \"#BB800966\",\n\t\t\"peekViewResult.background\": \"#080d17\",\n\t\t\"peekViewResult.matchHighlightBackground\": \"#BB800966\",\n\t\t\"pickerGroup.border\": \"#1a2634\",\n\t\t\"progressBar.background\": \"#0078D4\",\n\t\t\"quickInput.background\": \"#0c1522\",\n\t\t\"quickInput.foreground\": \"#CCCCCC\",\n\t\t\"settings.dropdownBackground\": \"#131b26\",\n\t\t\"settings.dropdownBorder\": \"#1a2634\",\n\t\t\"settings.headerForeground\": \"#FFFFFF\",\n\t\t\"settings.modifiedItemIndicator\": \"#BB800966\",\n\t\t\"sideBar.background\": \"#070b12\",\n\t\t\"sideBar.border\": \"#101827\",\n\t\t\"sideBar.foreground\": \"#CCCCCC\",\n\t\t\"sideBarSectionHeader.background\": \"#070b12\",\n\t\t\"sideBarSectionHeader.border\": \"#101827\",\n\t\t\"sideBarSectionHeader.foreground\": \"#CCCCCC\",\n\t\t\"sideBarTitle.foreground\": \"#CCCCCC\",\n\t\t\"statusBar.background\": \"#070b12\",\n\t\t\"statusBar.border\": \"#101827\",\n\t\t\"statusBar.debuggingBackground\": \"#0078D4\",\n\t\t\"statusBar.debuggingForeground\": \"#FFFFFF\",\n\t\t\"statusBar.focusBorder\": \"#0078D4\",\n\t\t\"statusBar.foreground\": \"#CCCCCC\",\n\t\t\"statusBar.noFolderBackground\": \"#080d17\",\n\t\t\"statusBarItem.focusBorder\": \"#0078D4\",\n\t\t\"statusBarItem.prominentBackground\": \"#6E768166\",\n\t\t\"statusBarItem.remoteBackground\": \"#0078D4\",\n\t\t\"statusBarItem.remoteForeground\": \"#FFFFFF\",\n\t\t\"tab.activeBackground\": \"#080d17\",\n\t\t\"tab.activeBorder\": \"#080d17\",\n\t\t\"tab.activeBorderTop\": \"#0078D4\",\n\t\t\"tab.activeForeground\": \"#FFFFFF\",\n\t\t\"tab.border\": \"#101827\",\n\t\t\"tab.hoverBackground\": \"#080d17\",\n\t\t\"tab.inactiveBackground\": \"#070b12\",\n\t\t\"tab.inactiveForeground\": \"#9D9D9D\",\n\t\t\"tab.unfocusedActiveBorder\": \"#080d17\",\n\t\t\"tab.unfocusedActiveBorderTop\": \"#101827\",\n\t\t\"tab.unfocusedHoverBackground\": \"#080d17\",\n\t\t\"terminal.foreground\": \"#CCCCCC\",\n\t\t\"terminal.tab.activeBorder\": \"#0078D4\",\n\t\t\"textBlockQuote.background\": \"#101827\",\n\t\t\"textBlockQuote.border\": \"#616161\",\n\t\t\"textCodeBlock.background\": \"#101827\",\n\t\t\"textLink.activeForeground\": \"#40A6FF\",\n\t\t\"textLink.foreground\": \"#40A6FF\",\n\t\t\"textSeparator.foreground\": \"#21262D\",\n\t\t\"titleBar.activeBackground\": \"#070b12\",\n\t\t\"titleBar.activeForeground\": \"#CCCCCC\",\n\t\t\"titleBar.border\": \"#101827\",\n\t\t\"titleBar.inactiveBackground\": \"#080d17\",\n\t\t\"titleBar.inactiveForeground\": \"#9D9D9D\",\n\t\t\"welcomePage.tileBackground\": \"#101827\",\n\t\t\"welcomePage.progress.foreground\": \"#0078D4\",\n\t\t\"widget.border\": \"#131b26\"\n\t}\n}\n"
  },
  {
    "path": "ark/themes/arkdarkItalic.json",
    "content": "{\n\t\"$schema\": \"vscode://schemas/color-theme\",\n\t\"name\": \"ArkDark (italic)\",\n\t\"tokenColors\": [\n\t\t{\n\t\t\t\"name\": \"functions\",\n\t\t\t\"scope\": [\n\t\t\t\t\"entity.name.function\",\n\t\t\t\t\"support.function\",\n\t\t\t\t\"meta.function-call.python\",\n\t\t\t\t\"meta.function.decorator punctuation\",\n\t\t\t\t\"meta.function.decorator support.type\"\n\t\t\t],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#80cff8\",\n\t\t\t\t\"fontStyle\": \"italic\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"name\": \"types and decorators\",\n\t\t\t\"scope\": [\"entity.name.type\", \"meta.decorator.ts variable\"],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#40decc\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"scope\": [\"meta.type.declaration.ts entity.name.type\"],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#80cff8\",\n\t\t\t\t\"fontStyle\": \"italic\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"scope\": [\n\t\t\t\t\"meta.type.declaration.ts meta.type.parameters.ts entity.name.type\"\n\t\t\t],\n\t\t\t\"settings\": {\n\t\t\t\t\"fontStyle\": \"\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"name\": \"keywords and operators\",\n\t\t\t\"scope\": [\n\t\t\t\t\"keyword\",\n\t\t\t\t\"storage\",\n\t\t\t\t\"punctuation\",\n\t\t\t\t\"constant.character.escape\"\n\t\t\t],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#ba7e41\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"name\": \"properties and strings\",\n\t\t\t\"scope\": [\n\t\t\t\t\"variable.other.property\",\n\t\t\t\t\"variable.other.constant.property\",\n\t\t\t\t\"string\"\n\t\t\t],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#f5cf8f\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"name\": \"this, primitives, built-in types, quotes\",\n\t\t\t\"scope\": [\n\t\t\t\t\"variable.language\",\n\t\t\t\t\"constant\",\n\t\t\t\t\"support.type\",\n\t\t\t\t\"entity.name.tag\",\n\t\t\t\t\"punctuation.definition.string.begin\",\n\t\t\t\t\"punctuation.definition.string.end\",\n\t\t\t\t\"punctuation.definition.string.template.begin\",\n\t\t\t\t\"punctuation.definition.string.template.end\"\n\t\t\t],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#408fde\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"name\": \"errors\",\n\t\t\t\"scope\": [\"invalid\", \"support.type.exception\"],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#9558f8\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"name\": \"comment\",\n\t\t\t\"scope\": [\"comment\", \"punctuation.definition.comment\"],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#888899\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"name\": \"variable\",\n\t\t\t\"scope\": [\"variable\", \"meta.function-call.arguments\"],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#eeeeee\"\n\t\t\t}\n\t\t}\n\t],\n\t\"colors\": {\n\t\t\"editor.foreground\": \"#eeeeee\",\n\t\t\"editor.background\": \"#080d17\",\n\t\t\"errorForeground\": \"#9558f8\",\n\t\t\"editorError.foreground\": \"#9558f8\",\n\t\t\"editorWarning.foreground\": \"#2faf64\",\n\t\t\"minimap.errorHighlight\": \"#9558f8\",\n\t\t\"list.errorForeground\": \"#9558f8\",\n\t\t\"editorOverviewRuler.errorForeground\": \"#9558f8\",\n\t\t\"editorBracketHighlight.foreground1\": \"#f5cf8f\",\n\t\t\"editorBracketHighlight.foreground2\": \"#ba7e41\",\n\t\t\"editorBracketHighlight.foreground3\": \"#eb9f2e\",\n\t\t\"editorBracketHighlight.unexpectedBracket.foreground\": \"#ba7e41\",\n\t\t\"editorCursor.foreground\": \"#408fde\",\n\t\t\"terminalCursor.foreground\": \"#408fde\",\n\t\t\"editorCodeLens.foreground\": \"#00ccff60\",\n\t\t\"editorInlayHint.background\": \"#00b7e40c\",\n\t\t\"editorInlayHint.foreground\": \"#00ccff60\",\n\t\t\"errorLens.errorBackground\": \"#9558f818\",\n\t\t\"errorLens.errorForeground\": \"#9558f8a0\",\n\t\t\"errorLens.warningBackground\": \"#00b7e40c\",\n\t\t\"errorLens.warningForeground\": \"#00ccff60\",\n\t\t\"errorLens.infoBackground\": \"#00b7e40c\",\n\t\t\"errorLens.infoForeground\": \"#00ccff60\",\n\t\t\"errorLens.hintBackground\": \"#17a2a20c\",\n\t\t\"errorLens.hintForeground\": \"#2faf6460\",\n\t\t\"activityBar.activeBorder\": \"#0078D4\",\n\t\t\"activityBar.background\": \"#070b12\",\n\t\t\"activityBar.border\": \"#101827\",\n\t\t\"activityBar.foreground\": \"#D7D7D7\",\n\t\t\"activityBar.inactiveForeground\": \"#868686\",\n\t\t\"activityBarBadge.background\": \"#0078D4\",\n\t\t\"activityBarBadge.foreground\": \"#FFFFFF\",\n\t\t\"badge.background\": \"#616161\",\n\t\t\"badge.foreground\": \"#F8F8F8\",\n\t\t\"button.background\": \"#0078D4\",\n\t\t\"button.border\": \"#FFFFFF12\",\n\t\t\"button.foreground\": \"#FFFFFF\",\n\t\t\"button.hoverBackground\": \"#026EC1\",\n\t\t\"button.secondaryBackground\": \"#131b26\",\n\t\t\"button.secondaryForeground\": \"#CCCCCC\",\n\t\t\"button.secondaryHoverBackground\": \"#1a2634\",\n\t\t\"chat.slashCommandBackground\": \"#34414B\",\n\t\t\"chat.slashCommandForeground\": \"#40A6FF\",\n\t\t\"checkbox.background\": \"#131b26\",\n\t\t\"checkbox.border\": \"#1a2634\",\n\t\t\"debugToolBar.background\": \"#070b12\",\n\t\t\"descriptionForeground\": \"#9D9D9D\",\n\t\t\"dropdown.background\": \"#131b26\",\n\t\t\"dropdown.border\": \"#1a2634\",\n\t\t\"dropdown.foreground\": \"#CCCCCC\",\n\t\t\"dropdown.listBackground\": \"#080d17\",\n\t\t\"editor.findMatchBackground\": \"#9E6A03\",\n\t\t\"editorGroup.border\": \"#FFFFFF17\",\n\t\t\"editorGroupHeader.tabsBackground\": \"#070b12\",\n\t\t\"editorGroupHeader.tabsBorder\": \"#101827\",\n\t\t\"editorGutter.addedBackground\": \"#2EA043\",\n\t\t\"editorGutter.deletedBackground\": \"#F85149\",\n\t\t\"editorGutter.modifiedBackground\": \"#0078D4\",\n\t\t\"editorLineNumber.activeForeground\": \"#CCCCCC\",\n\t\t\"editorLineNumber.foreground\": \"#6E7681\",\n\t\t\"editorOverviewRuler.border\": \"#010409\",\n\t\t\"editorWidget.background\": \"#0a1320\",\n\t\t\"focusBorder\": \"#0078D4\",\n\t\t\"foreground\": \"#CCCCCC\",\n\t\t\"icon.foreground\": \"#CCCCCC\",\n\t\t\"input.background\": \"#131b26\",\n\t\t\"input.border\": \"#1a2634\",\n\t\t\"input.foreground\": \"#CCCCCC\",\n\t\t\"input.placeholderForeground\": \"#9D9D9D\",\n\t\t\"inputOption.activeBackground\": \"#2489DB82\",\n\t\t\"inputOption.activeBorder\": \"#2488DB\",\n\t\t\"keybindingLabel.foreground\": \"#CCCCCC\",\n\t\t\"menu.background\": \"#080d17\",\n\t\t\"notificationCenterHeader.background\": \"#080d17\",\n\t\t\"notificationCenterHeader.foreground\": \"#CCCCCC\",\n\t\t\"notifications.background\": \"#080d17\",\n\t\t\"notifications.border\": \"#101827\",\n\t\t\"notifications.foreground\": \"#CCCCCC\",\n\t\t\"panel.background\": \"#070b12\",\n\t\t\"panel.border\": \"#101827\",\n\t\t\"panelInput.border\": \"#101827\",\n\t\t\"panelTitle.activeBorder\": \"#0078D4\",\n\t\t\"panelTitle.activeForeground\": \"#CCCCCC\",\n\t\t\"panelTitle.inactiveForeground\": \"#9D9D9D\",\n\t\t\"peekViewEditor.background\": \"#080d17\",\n\t\t\"peekViewEditor.matchHighlightBackground\": \"#BB800966\",\n\t\t\"peekViewResult.background\": \"#080d17\",\n\t\t\"peekViewResult.matchHighlightBackground\": \"#BB800966\",\n\t\t\"pickerGroup.border\": \"#1a2634\",\n\t\t\"progressBar.background\": \"#0078D4\",\n\t\t\"quickInput.background\": \"#0c1522\",\n\t\t\"quickInput.foreground\": \"#CCCCCC\",\n\t\t\"settings.dropdownBackground\": \"#131b26\",\n\t\t\"settings.dropdownBorder\": \"#1a2634\",\n\t\t\"settings.headerForeground\": \"#FFFFFF\",\n\t\t\"settings.modifiedItemIndicator\": \"#BB800966\",\n\t\t\"sideBar.background\": \"#070b12\",\n\t\t\"sideBar.border\": \"#101827\",\n\t\t\"sideBar.foreground\": \"#CCCCCC\",\n\t\t\"sideBarSectionHeader.background\": \"#070b12\",\n\t\t\"sideBarSectionHeader.border\": \"#101827\",\n\t\t\"sideBarSectionHeader.foreground\": \"#CCCCCC\",\n\t\t\"sideBarTitle.foreground\": \"#CCCCCC\",\n\t\t\"statusBar.background\": \"#070b12\",\n\t\t\"statusBar.border\": \"#101827\",\n\t\t\"statusBar.debuggingBackground\": \"#0078D4\",\n\t\t\"statusBar.debuggingForeground\": \"#FFFFFF\",\n\t\t\"statusBar.focusBorder\": \"#0078D4\",\n\t\t\"statusBar.foreground\": \"#CCCCCC\",\n\t\t\"statusBar.noFolderBackground\": \"#080d17\",\n\t\t\"statusBarItem.focusBorder\": \"#0078D4\",\n\t\t\"statusBarItem.prominentBackground\": \"#6E768166\",\n\t\t\"statusBarItem.remoteBackground\": \"#0078D4\",\n\t\t\"statusBarItem.remoteForeground\": \"#FFFFFF\",\n\t\t\"tab.activeBackground\": \"#080d17\",\n\t\t\"tab.activeBorder\": \"#080d17\",\n\t\t\"tab.activeBorderTop\": \"#0078D4\",\n\t\t\"tab.activeForeground\": \"#FFFFFF\",\n\t\t\"tab.border\": \"#101827\",\n\t\t\"tab.hoverBackground\": \"#080d17\",\n\t\t\"tab.inactiveBackground\": \"#070b12\",\n\t\t\"tab.inactiveForeground\": \"#9D9D9D\",\n\t\t\"tab.unfocusedActiveBorder\": \"#080d17\",\n\t\t\"tab.unfocusedActiveBorderTop\": \"#101827\",\n\t\t\"tab.unfocusedHoverBackground\": \"#080d17\",\n\t\t\"terminal.foreground\": \"#CCCCCC\",\n\t\t\"terminal.tab.activeBorder\": \"#0078D4\",\n\t\t\"textBlockQuote.background\": \"#101827\",\n\t\t\"textBlockQuote.border\": \"#616161\",\n\t\t\"textCodeBlock.background\": \"#101827\",\n\t\t\"textLink.activeForeground\": \"#40A6FF\",\n\t\t\"textLink.foreground\": \"#40A6FF\",\n\t\t\"textSeparator.foreground\": \"#21262D\",\n\t\t\"titleBar.activeBackground\": \"#070b12\",\n\t\t\"titleBar.activeForeground\": \"#CCCCCC\",\n\t\t\"titleBar.border\": \"#101827\",\n\t\t\"titleBar.inactiveBackground\": \"#080d17\",\n\t\t\"titleBar.inactiveForeground\": \"#9D9D9D\",\n\t\t\"welcomePage.tileBackground\": \"#101827\",\n\t\t\"welcomePage.progress.foreground\": \"#0078D4\",\n\t\t\"widget.border\": \"#131b26\"\n\t}\n}\n"
  },
  {
    "path": "ark/themes/arklight.json",
    "content": "{\n\t\"$schema\": \"vscode://schemas/color-theme\",\n\t\"name\": \"ArkLight\",\n\t\"tokenColors\": [\n\t\t{\n\t\t\t\"name\": \"functions\",\n\t\t\t\"scope\": [\n\t\t\t\t\"entity.name.function\",\n\t\t\t\t\"support.function\",\n\t\t\t\t\"meta.function-call.python\",\n\t\t\t\t\"meta.function.decorator punctuation\",\n\t\t\t\t\"meta.function.decorator support.type\"\n\t\t\t],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#0078D4\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"name\": \"types and decorators\",\n\t\t\t\"scope\": [\"entity.name.type\", \"meta.decorator.ts variable\"],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#04b5a3\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"scope\": [\"meta.type.declaration.ts entity.name.type\"],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#0078D4\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"name\": \"keywords and operators\",\n\t\t\t\"scope\": [\n\t\t\t\t\"keyword\",\n\t\t\t\t\"storage\",\n\t\t\t\t\"punctuation\",\n\t\t\t\t\"constant.character.escape\"\n\t\t\t],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#ca842e\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"name\": \"properties and strings\",\n\t\t\t\"scope\": [\n\t\t\t\t\"variable.other.property\",\n\t\t\t\t\"variable.other.constant.property\",\n\t\t\t\t\"string\"\n\t\t\t],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#844c13\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"name\": \"this, primitives, built-in types, quotes\",\n\t\t\t\"scope\": [\n\t\t\t\t\"variable.language\",\n\t\t\t\t\"constant\",\n\t\t\t\t\"support.type\",\n\t\t\t\t\"entity.name.tag\",\n\t\t\t\t\"punctuation.definition.string.begin\",\n\t\t\t\t\"punctuation.definition.string.end\",\n\t\t\t\t\"punctuation.definition.string.template.begin\",\n\t\t\t\t\"punctuation.definition.string.template.end\"\n\t\t\t],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#07538e\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"name\": \"errors\",\n\t\t\t\"scope\": [\"invalid\", \"support.type.exception\"],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#9558f8\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"name\": \"comment\",\n\t\t\t\"scope\": [\"comment\", \"punctuation.definition.comment\"],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#888899\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"name\": \"variable\",\n\t\t\t\"scope\": [\"variable\", \"meta.function-call.arguments\"],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#07538e\"\n\t\t\t}\n\t\t}\n\t],\n\t\"colors\": {\n\t\t\"editor.foreground\": \"#2e4775\",\n\t\t\"errorForeground\": \"#9558f8\",\n\t\t\"editorError.foreground\": \"#9558f8\",\n\t\t\"editorWarning.foreground\": \"#207A45\",\n\t\t\"minimap.errorHighlight\": \"#9558f8\",\n\t\t\"list.errorForeground\": \"#9558f8\",\n\t\t\"editorOverviewRuler.errorForeground\": \"#9558f8\",\n\t\t\"editorBracketHighlight.foreground1\": \"#844c13\",\n\t\t\"editorBracketHighlight.foreground2\": \"#ca842e\",\n\t\t\"editorBracketHighlight.foreground3\": \"#ffbc49\",\n\t\t\"editorBracketHighlight.unexpectedBracket.foreground\": \"#ca842e\",\n\t\t\"editorCursor.foreground\": \"#00487e\",\n\t\t\"terminalCursor.foreground\": \"#00487e\",\n\t\t\"editorCodeLens.foreground\": \"#0078D490\",\n\t\t\"editorInlayHint.background\": \"#0078D40C\",\n\t\t\"editorInlayHint.foreground\": \"#0078D490\",\n\t\t\"errorLens.errorBackground\": \"#9558f818\",\n\t\t\"errorLens.errorForeground\": \"#9558f8A0\",\n\t\t\"errorLens.warningBackground\": \"#0078D40C\",\n\t\t\"errorLens.warningForeground\": \"#0078D490\",\n\t\t\"errorLens.infoBackground\": \"#0078D40C\",\n\t\t\"errorLens.infoForeground\": \"#0078D490\",\n\t\t\"errorLens.hintBackground\": \"#207A450C\",\n\t\t\"errorLens.hintForeground\": \"#207A4590\",\n\t\t\"activityBar.activeBorder\": \"#005FB8\",\n\t\t\"activityBar.background\": \"#F2EED0\",\n\t\t\"activityBar.border\": \"#E5E5E5\",\n\t\t\"activityBar.foreground\": \"#2e4775\",\n\t\t\"activityBar.inactiveForeground\": \"#616161\",\n\t\t\"activityBarBadge.background\": \"#005FB8\",\n\t\t\"activityBarBadge.foreground\": \"#F9F5D7\",\n\t\t\"badge.background\": \"#CCCCCC\",\n\t\t\"badge.foreground\": \"#3B3B3B\",\n\t\t\"button.background\": \"#005FB8\",\n\t\t\"button.border\": \"#0000001a\",\n\t\t\"button.foreground\": \"#F9F5D7\",\n\t\t\"button.hoverBackground\": \"#0258A8\",\n\t\t\"button.secondaryBackground\": \"#E5E5E5\",\n\t\t\"button.secondaryForeground\": \"#3B3B3B\",\n\t\t\"button.secondaryHoverBackground\": \"#CCCCCC\",\n\t\t\"chat.slashCommandBackground\": \"#D2ECFF\",\n\t\t\"chat.slashCommandForeground\": \"#306CA2\",\n\t\t\"chat.editedFileForeground\": \"#895503\",\n\t\t\"checkbox.background\": \"#F2EED0\",\n\t\t\"checkbox.border\": \"#CECECE\",\n\t\t\"descriptionForeground\": \"#3B3B3B\",\n\t\t\"dropdown.background\": \"#F9F5D7\",\n\t\t\"dropdown.border\": \"#CECECE\",\n\t\t\"dropdown.foreground\": \"#3B3B3B\",\n\t\t\"dropdown.listBackground\": \"#F9F5D7\",\n\t\t\"editor.background\": \"#F9F5D7\",\n\t\t\"editor.selectionHighlightBackground\": \"#ADD6FF80\",\n\t\t\"editorGroup.border\": \"#E5E5E5\",\n\t\t\"editorGroupHeader.tabsBackground\": \"#F2EED0\",\n\t\t\"editorGroupHeader.tabsBorder\": \"#E5E5E5\",\n\t\t\"editorGutter.addedBackground\": \"#2EA043\",\n\t\t\"editorGutter.deletedBackground\": \"#F85149\",\n\t\t\"editorGutter.modifiedBackground\": \"#005FB8\",\n\t\t\"editorIndentGuide.background1\": \"#D3D3D3\",\n\t\t\"editorLineNumber.activeForeground\": \"#171184\",\n\t\t\"editorLineNumber.foreground\": \"#6E7681\",\n\t\t\"editorOverviewRuler.border\": \"#E5E5E5\",\n\t\t\"editorSuggestWidget.background\": \"#F2EED0\",\n\t\t\"editorWidget.background\": \"#F2EED0\",\n\t\t\"focusBorder\": \"#005FB8\",\n\t\t\"foreground\": \"#3B3B3B\",\n\t\t\"icon.foreground\": \"#3B3B3B\",\n\t\t\"input.background\": \"#F9F5D7\",\n\t\t\"input.border\": \"#CECECE\",\n\t\t\"input.foreground\": \"#3B3B3B\",\n\t\t\"input.placeholderForeground\": \"#767676\",\n\t\t\"inputOption.activeBackground\": \"#BED6ED\",\n\t\t\"inputOption.activeBorder\": \"#005FB8\",\n\t\t\"inputOption.activeForeground\": \"#000000\",\n\t\t\"keybindingLabel.foreground\": \"#3B3B3B\",\n\t\t\"list.activeSelectionBackground\": \"#E8E8E8\",\n\t\t\"list.activeSelectionForeground\": \"#000000\",\n\t\t\"list.activeSelectionIconForeground\": \"#000000\",\n\t\t\"list.hoverBackground\": \"#F2F2F2\",\n\t\t\"list.focusAndSelectionOutline\": \"#005FB8\",\n\t\t\"menu.border\": \"#CECECE\",\n\t\t\"menu.selectionBackground\": \"#005FB8\",\n\t\t\"menu.selectionForeground\": \"#F9F5D7\",\n\t\t\"notebook.cellBorderColor\": \"#E5E5E5\",\n\t\t\"notebook.selectedCellBackground\": \"#C8DDF150\",\n\t\t\"notificationCenterHeader.background\": \"#F9F5D7\",\n\t\t\"notificationCenterHeader.foreground\": \"#3B3B3B\",\n\t\t\"notifications.background\": \"#F9F5D7\",\n\t\t\"notifications.border\": \"#E5E5E5\",\n\t\t\"notifications.foreground\": \"#3B3B3B\",\n\t\t\"panel.background\": \"#F2EED0\",\n\t\t\"panel.border\": \"#E5E5E5\",\n\t\t\"panelInput.border\": \"#E5E5E5\",\n\t\t\"panelTitle.activeBorder\": \"#005FB8\",\n\t\t\"panelTitle.activeForeground\": \"#3B3B3B\",\n\t\t\"panelTitle.inactiveForeground\": \"#3B3B3B\",\n\t\t\"peekViewEditor.matchHighlightBackground\": \"#BB800966\",\n\t\t\"peekViewResult.background\": \"#F9F5D7\",\n\t\t\"peekViewResult.matchHighlightBackground\": \"#BB800966\",\n\t\t\"pickerGroup.border\": \"#E5E5E5\",\n\t\t\"pickerGroup.foreground\": \"#8B949E\",\n\t\t\"ports.iconRunningProcessForeground\": \"#369432\",\n\t\t\"progressBar.background\": \"#005FB8\",\n\t\t\"quickInput.background\": \"#F2EED0\",\n\t\t\"quickInput.foreground\": \"#3B3B3B\",\n\t\t\"searchEditor.textInputBorder\": \"#CECECE\",\n\t\t\"settings.dropdownBackground\": \"#F9F5D7\",\n\t\t\"settings.dropdownBorder\": \"#CECECE\",\n\t\t\"settings.headerForeground\": \"#2e4775\",\n\t\t\"settings.modifiedItemIndicator\": \"#BB800966\",\n\t\t\"settings.numberInputBorder\": \"#CECECE\",\n\t\t\"settings.textInputBorder\": \"#CECECE\",\n\t\t\"sideBar.background\": \"#F2EED0\",\n\t\t\"sideBar.border\": \"#E5E5E5\",\n\t\t\"sideBar.foreground\": \"#3B3B3B\",\n\t\t\"sideBarSectionHeader.background\": \"#F2EED0\",\n\t\t\"sideBarSectionHeader.border\": \"#E5E5E5\",\n\t\t\"sideBarSectionHeader.foreground\": \"#3B3B3B\",\n\t\t\"sideBarTitle.foreground\": \"#3B3B3B\",\n\t\t\"statusBar.background\": \"#F2EED0\",\n\t\t\"statusBar.foreground\": \"#3B3B3B\",\n\t\t\"statusBar.border\": \"#E5E5E5\",\n\t\t\"statusBarItem.hoverBackground\": \"#B8B8B850\",\n\t\t\"statusBarItem.compactHoverBackground\": \"#CCCCCC\",\n\t\t\"statusBar.debuggingBackground\": \"#FD716C\",\n\t\t\"statusBar.debuggingForeground\": \"#000000\",\n\t\t\"statusBar.focusBorder\": \"#005FB8\",\n\t\t\"statusBar.noFolderBackground\": \"#F2EED0\",\n\t\t\"statusBarItem.errorBackground\": \"#C72E0F\",\n\t\t\"statusBarItem.focusBorder\": \"#005FB8\",\n\t\t\"statusBarItem.prominentBackground\": \"#6E768166\",\n\t\t\"statusBarItem.remoteBackground\": \"#005FB8\",\n\t\t\"statusBarItem.remoteForeground\": \"#F9F5D7\",\n\t\t\"tab.activeBackground\": \"#F9F5D7\",\n\t\t\"tab.activeBorder\": \"#F2EED0\",\n\t\t\"tab.activeBorderTop\": \"#005FB8\",\n\t\t\"tab.activeForeground\": \"#3B3B3B\",\n\t\t\"tab.selectedBorderTop\": \"#68a3da\",\n\t\t\"tab.border\": \"#E5E5E5\",\n\t\t\"tab.hoverBackground\": \"#F9F5D7\",\n\t\t\"tab.inactiveBackground\": \"#F2EED0\",\n\t\t\"tab.inactiveForeground\": \"#868686\",\n\t\t\"tab.lastPinnedBorder\": \"#D4D4D4\",\n\t\t\"tab.unfocusedActiveBorder\": \"#F2EED0\",\n\t\t\"tab.unfocusedActiveBorderTop\": \"#E5E5E5\",\n\t\t\"tab.unfocusedHoverBackground\": \"#F2EED0\",\n\t\t\"terminal.foreground\": \"#3B3B3B\",\n\t\t\"terminal.inactiveSelectionBackground\": \"#E5EBF1\",\n\t\t\"terminal.tab.activeBorder\": \"#005FB8\",\n\t\t\"textBlockQuote.background\": \"#F2EED0\",\n\t\t\"textBlockQuote.border\": \"#E5E5E5\",\n\t\t\"textCodeBlock.background\": \"#F2EED0\",\n\t\t\"textLink.activeForeground\": \"#005FB8\",\n\t\t\"textLink.foreground\": \"#005FB8\",\n\t\t\"textPreformat.foreground\": \"#3B3B3B\",\n\t\t\"textPreformat.background\": \"#0000001F\",\n\t\t\"textSeparator.foreground\": \"#21262D\",\n\t\t\"titleBar.activeBackground\": \"#F2EED0\",\n\t\t\"titleBar.activeForeground\": \"#1E1E1E\",\n\t\t\"titleBar.border\": \"#E5E5E5\",\n\t\t\"titleBar.inactiveBackground\": \"#F2EED0\",\n\t\t\"titleBar.inactiveForeground\": \"#8B949E\",\n\t\t\"welcomePage.tileBackground\": \"#F3F3F3\",\n\t\t\"widget.border\": \"#E5E5E5\"\n\t}\n}\n"
  },
  {
    "path": "ark/themes/arklightItalic.json",
    "content": "{\n\t\"$schema\": \"vscode://schemas/color-theme\",\n\t\"name\": \"ArkLight (italic)\",\n\t\"tokenColors\": [\n\t\t{\n\t\t\t\"name\": \"functions\",\n\t\t\t\"scope\": [\n\t\t\t\t\"entity.name.function\",\n\t\t\t\t\"support.function\",\n\t\t\t\t\"meta.function-call.python\",\n\t\t\t\t\"meta.function.decorator punctuation\",\n\t\t\t\t\"meta.function.decorator support.type\"\n\t\t\t],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#0078D4\",\n\t\t\t\t\"fontStyle\": \"italic\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"name\": \"types and decorators\",\n\t\t\t\"scope\": [\"entity.name.type\", \"meta.decorator.ts variable\"],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#04b5a3\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"scope\": [\"meta.type.declaration.ts entity.name.type\"],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#0078D4\",\n\t\t\t\t\"fontStyle\": \"italic\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"scope\": [\n\t\t\t\t\"meta.type.declaration.ts meta.type.parameters.ts entity.name.type\"\n\t\t\t],\n\t\t\t\"settings\": {\n\t\t\t\t\"fontStyle\": \"\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"name\": \"keywords and operators\",\n\t\t\t\"scope\": [\n\t\t\t\t\"keyword\",\n\t\t\t\t\"storage\",\n\t\t\t\t\"punctuation\",\n\t\t\t\t\"constant.character.escape\"\n\t\t\t],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#ca842e\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"name\": \"properties and strings\",\n\t\t\t\"scope\": [\n\t\t\t\t\"variable.other.property\",\n\t\t\t\t\"variable.other.constant.property\",\n\t\t\t\t\"string\"\n\t\t\t],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#844c13\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"name\": \"this, primitives, built-in types, quotes\",\n\t\t\t\"scope\": [\n\t\t\t\t\"variable.language\",\n\t\t\t\t\"constant\",\n\t\t\t\t\"support.type\",\n\t\t\t\t\"entity.name.tag\",\n\t\t\t\t\"punctuation.definition.string.begin\",\n\t\t\t\t\"punctuation.definition.string.end\",\n\t\t\t\t\"punctuation.definition.string.template.begin\",\n\t\t\t\t\"punctuation.definition.string.template.end\"\n\t\t\t],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#07538e\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"name\": \"errors\",\n\t\t\t\"scope\": [\"invalid\", \"support.type.exception\"],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#9558f8\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"name\": \"comment\",\n\t\t\t\"scope\": [\"comment\", \"punctuation.definition.comment\"],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#888899\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"name\": \"variable\",\n\t\t\t\"scope\": [\"variable\", \"meta.function-call.arguments\"],\n\t\t\t\"settings\": {\n\t\t\t\t\"foreground\": \"#07538e\"\n\t\t\t}\n\t\t}\n\t],\n\t\"colors\": {\n\t\t\"editor.foreground\": \"#2e4775\",\n\t\t\"errorForeground\": \"#9558f8\",\n\t\t\"editorError.foreground\": \"#9558f8\",\n\t\t\"editorWarning.foreground\": \"#207A45\",\n\t\t\"minimap.errorHighlight\": \"#9558f8\",\n\t\t\"list.errorForeground\": \"#9558f8\",\n\t\t\"editorOverviewRuler.errorForeground\": \"#9558f8\",\n\t\t\"editorBracketHighlight.foreground1\": \"#844c13\",\n\t\t\"editorBracketHighlight.foreground2\": \"#ca842e\",\n\t\t\"editorBracketHighlight.foreground3\": \"#ffbc49\",\n\t\t\"editorBracketHighlight.unexpectedBracket.foreground\": \"#ca842e\",\n\t\t\"editorCursor.foreground\": \"#00487e\",\n\t\t\"terminalCursor.foreground\": \"#00487e\",\n\t\t\"editorCodeLens.foreground\": \"#0078D490\",\n\t\t\"editorInlayHint.background\": \"#0078D40C\",\n\t\t\"editorInlayHint.foreground\": \"#0078D490\",\n\t\t\"errorLens.errorBackground\": \"#9558f818\",\n\t\t\"errorLens.errorForeground\": \"#9558f8A0\",\n\t\t\"errorLens.warningBackground\": \"#0078D40C\",\n\t\t\"errorLens.warningForeground\": \"#0078D490\",\n\t\t\"errorLens.infoBackground\": \"#0078D40C\",\n\t\t\"errorLens.infoForeground\": \"#0078D490\",\n\t\t\"errorLens.hintBackground\": \"#207A450C\",\n\t\t\"errorLens.hintForeground\": \"#207A4590\",\n\t\t\"activityBar.activeBorder\": \"#005FB8\",\n\t\t\"activityBar.background\": \"#F2EED0\",\n\t\t\"activityBar.border\": \"#E5E5E5\",\n\t\t\"activityBar.foreground\": \"#2e4775\",\n\t\t\"activityBar.inactiveForeground\": \"#616161\",\n\t\t\"activityBarBadge.background\": \"#005FB8\",\n\t\t\"activityBarBadge.foreground\": \"#F9F5D7\",\n\t\t\"badge.background\": \"#CCCCCC\",\n\t\t\"badge.foreground\": \"#3B3B3B\",\n\t\t\"button.background\": \"#005FB8\",\n\t\t\"button.border\": \"#0000001a\",\n\t\t\"button.foreground\": \"#F9F5D7\",\n\t\t\"button.hoverBackground\": \"#0258A8\",\n\t\t\"button.secondaryBackground\": \"#E5E5E5\",\n\t\t\"button.secondaryForeground\": \"#3B3B3B\",\n\t\t\"button.secondaryHoverBackground\": \"#CCCCCC\",\n\t\t\"chat.slashCommandBackground\": \"#D2ECFF\",\n\t\t\"chat.slashCommandForeground\": \"#306CA2\",\n\t\t\"chat.editedFileForeground\": \"#895503\",\n\t\t\"checkbox.background\": \"#F2EED0\",\n\t\t\"checkbox.border\": \"#CECECE\",\n\t\t\"descriptionForeground\": \"#3B3B3B\",\n\t\t\"dropdown.background\": \"#F9F5D7\",\n\t\t\"dropdown.border\": \"#CECECE\",\n\t\t\"dropdown.foreground\": \"#3B3B3B\",\n\t\t\"dropdown.listBackground\": \"#F9F5D7\",\n\t\t\"editor.background\": \"#F9F5D7\",\n\t\t\"editor.selectionHighlightBackground\": \"#ADD6FF80\",\n\t\t\"editorGroup.border\": \"#E5E5E5\",\n\t\t\"editorGroupHeader.tabsBackground\": \"#F2EED0\",\n\t\t\"editorGroupHeader.tabsBorder\": \"#E5E5E5\",\n\t\t\"editorGutter.addedBackground\": \"#2EA043\",\n\t\t\"editorGutter.deletedBackground\": \"#F85149\",\n\t\t\"editorGutter.modifiedBackground\": \"#005FB8\",\n\t\t\"editorIndentGuide.background1\": \"#D3D3D3\",\n\t\t\"editorLineNumber.activeForeground\": \"#171184\",\n\t\t\"editorLineNumber.foreground\": \"#6E7681\",\n\t\t\"editorOverviewRuler.border\": \"#E5E5E5\",\n\t\t\"editorSuggestWidget.background\": \"#F2EED0\",\n\t\t\"editorWidget.background\": \"#F2EED0\",\n\t\t\"focusBorder\": \"#005FB8\",\n\t\t\"foreground\": \"#3B3B3B\",\n\t\t\"icon.foreground\": \"#3B3B3B\",\n\t\t\"input.background\": \"#F9F5D7\",\n\t\t\"input.border\": \"#CECECE\",\n\t\t\"input.foreground\": \"#3B3B3B\",\n\t\t\"input.placeholderForeground\": \"#767676\",\n\t\t\"inputOption.activeBackground\": \"#BED6ED\",\n\t\t\"inputOption.activeBorder\": \"#005FB8\",\n\t\t\"inputOption.activeForeground\": \"#000000\",\n\t\t\"keybindingLabel.foreground\": \"#3B3B3B\",\n\t\t\"list.activeSelectionBackground\": \"#E8E8E8\",\n\t\t\"list.activeSelectionForeground\": \"#000000\",\n\t\t\"list.activeSelectionIconForeground\": \"#000000\",\n\t\t\"list.hoverBackground\": \"#F2F2F2\",\n\t\t\"list.focusAndSelectionOutline\": \"#005FB8\",\n\t\t\"menu.border\": \"#CECECE\",\n\t\t\"menu.selectionBackground\": \"#005FB8\",\n\t\t\"menu.selectionForeground\": \"#F9F5D7\",\n\t\t\"notebook.cellBorderColor\": \"#E5E5E5\",\n\t\t\"notebook.selectedCellBackground\": \"#C8DDF150\",\n\t\t\"notificationCenterHeader.background\": \"#F9F5D7\",\n\t\t\"notificationCenterHeader.foreground\": \"#3B3B3B\",\n\t\t\"notifications.background\": \"#F9F5D7\",\n\t\t\"notifications.border\": \"#E5E5E5\",\n\t\t\"notifications.foreground\": \"#3B3B3B\",\n\t\t\"panel.background\": \"#F2EED0\",\n\t\t\"panel.border\": \"#E5E5E5\",\n\t\t\"panelInput.border\": \"#E5E5E5\",\n\t\t\"panelTitle.activeBorder\": \"#005FB8\",\n\t\t\"panelTitle.activeForeground\": \"#3B3B3B\",\n\t\t\"panelTitle.inactiveForeground\": \"#3B3B3B\",\n\t\t\"peekViewEditor.matchHighlightBackground\": \"#BB800966\",\n\t\t\"peekViewResult.background\": \"#F9F5D7\",\n\t\t\"peekViewResult.matchHighlightBackground\": \"#BB800966\",\n\t\t\"pickerGroup.border\": \"#E5E5E5\",\n\t\t\"pickerGroup.foreground\": \"#8B949E\",\n\t\t\"ports.iconRunningProcessForeground\": \"#369432\",\n\t\t\"progressBar.background\": \"#005FB8\",\n\t\t\"quickInput.background\": \"#F2EED0\",\n\t\t\"quickInput.foreground\": \"#3B3B3B\",\n\t\t\"searchEditor.textInputBorder\": \"#CECECE\",\n\t\t\"settings.dropdownBackground\": \"#F9F5D7\",\n\t\t\"settings.dropdownBorder\": \"#CECECE\",\n\t\t\"settings.headerForeground\": \"#2e4775\",\n\t\t\"settings.modifiedItemIndicator\": \"#BB800966\",\n\t\t\"settings.numberInputBorder\": \"#CECECE\",\n\t\t\"settings.textInputBorder\": \"#CECECE\",\n\t\t\"sideBar.background\": \"#F2EED0\",\n\t\t\"sideBar.border\": \"#E5E5E5\",\n\t\t\"sideBar.foreground\": \"#3B3B3B\",\n\t\t\"sideBarSectionHeader.background\": \"#F2EED0\",\n\t\t\"sideBarSectionHeader.border\": \"#E5E5E5\",\n\t\t\"sideBarSectionHeader.foreground\": \"#3B3B3B\",\n\t\t\"sideBarTitle.foreground\": \"#3B3B3B\",\n\t\t\"statusBar.background\": \"#F2EED0\",\n\t\t\"statusBar.foreground\": \"#3B3B3B\",\n\t\t\"statusBar.border\": \"#E5E5E5\",\n\t\t\"statusBarItem.hoverBackground\": \"#B8B8B850\",\n\t\t\"statusBarItem.compactHoverBackground\": \"#CCCCCC\",\n\t\t\"statusBar.debuggingBackground\": \"#FD716C\",\n\t\t\"statusBar.debuggingForeground\": \"#000000\",\n\t\t\"statusBar.focusBorder\": \"#005FB8\",\n\t\t\"statusBar.noFolderBackground\": \"#F2EED0\",\n\t\t\"statusBarItem.errorBackground\": \"#C72E0F\",\n\t\t\"statusBarItem.focusBorder\": \"#005FB8\",\n\t\t\"statusBarItem.prominentBackground\": \"#6E768166\",\n\t\t\"statusBarItem.remoteBackground\": \"#005FB8\",\n\t\t\"statusBarItem.remoteForeground\": \"#F9F5D7\",\n\t\t\"tab.activeBackground\": \"#F9F5D7\",\n\t\t\"tab.activeBorder\": \"#F2EED0\",\n\t\t\"tab.activeBorderTop\": \"#005FB8\",\n\t\t\"tab.activeForeground\": \"#3B3B3B\",\n\t\t\"tab.selectedBorderTop\": \"#68a3da\",\n\t\t\"tab.border\": \"#E5E5E5\",\n\t\t\"tab.hoverBackground\": \"#F9F5D7\",\n\t\t\"tab.inactiveBackground\": \"#F2EED0\",\n\t\t\"tab.inactiveForeground\": \"#868686\",\n\t\t\"tab.lastPinnedBorder\": \"#D4D4D4\",\n\t\t\"tab.unfocusedActiveBorder\": \"#F2EED0\",\n\t\t\"tab.unfocusedActiveBorderTop\": \"#E5E5E5\",\n\t\t\"tab.unfocusedHoverBackground\": \"#F2EED0\",\n\t\t\"terminal.foreground\": \"#3B3B3B\",\n\t\t\"terminal.inactiveSelectionBackground\": \"#E5EBF1\",\n\t\t\"terminal.tab.activeBorder\": \"#005FB8\",\n\t\t\"textBlockQuote.background\": \"#F2EED0\",\n\t\t\"textBlockQuote.border\": \"#E5E5E5\",\n\t\t\"textCodeBlock.background\": \"#F2EED0\",\n\t\t\"textLink.activeForeground\": \"#005FB8\",\n\t\t\"textLink.foreground\": \"#005FB8\",\n\t\t\"textPreformat.foreground\": \"#3B3B3B\",\n\t\t\"textPreformat.background\": \"#0000001F\",\n\t\t\"textSeparator.foreground\": \"#21262D\",\n\t\t\"titleBar.activeBackground\": \"#F2EED0\",\n\t\t\"titleBar.activeForeground\": \"#1E1E1E\",\n\t\t\"titleBar.border\": \"#E5E5E5\",\n\t\t\"titleBar.inactiveBackground\": \"#F2EED0\",\n\t\t\"titleBar.inactiveForeground\": \"#8B949E\",\n\t\t\"welcomePage.tileBackground\": \"#F3F3F3\",\n\t\t\"widget.border\": \"#E5E5E5\"\n\t}\n}\n"
  },
  {
    "path": "ark/themes/package.json",
    "content": "{\n\t\"name\": \"arkthemes\",\n\t\"displayName\": \"ArkThemes\",\n\t\"description\": \"A collection of themes with special highlighting for TypeScript generics ⛵\",\n\t\"version\": \"6.1.0\",\n\t\"publisher\": \"arktypeio\",\n\t\"type\": \"module\",\n\t\"license\": \"MIT\",\n\t\"scripts\": {\n\t\t\"publishExtension\": \"pnpm packageExtension && pnpm publishVsce && pnpm publishOvsx\",\n\t\t\"packageExtension\": \"vsce package --out arkthemes.vsix\",\n\t\t\"publishVsce\": \"vsce publish -i arkthemes.vsix\",\n\t\t\"publishOvsx\": \"ovsx publish -i arkthemes.vsix\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@vscode/vsce\": \"3.6.2\",\n\t\t\"ovsx\": \"0.10.6\"\n\t},\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"https://github.com/arktypeio/arktype\"\n\t},\n\t\"engines\": {\n\t\t\"vscode\": \"^1.0.0\"\n\t},\n\t\"categories\": [\n\t\t\"Themes\"\n\t],\n\t\"icon\": \"icon.png\",\n\t\"exports\": {\n\t\t\"./*.json\": \"./*.json\"\n\t},\n\t\"contributes\": {\n\t\t\"themes\": [\n\t\t\t{\n\t\t\t\t\"label\": \"ArkDark\",\n\t\t\t\t\"uiTheme\": \"vs-dark\",\n\t\t\t\t\"path\": \"./arkdark.json\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"label\": \"ArkDark (italic)\",\n\t\t\t\t\"uiTheme\": \"vs-dark\",\n\t\t\t\t\"path\": \"./arkdarkItalic.json\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"label\": \"ArkLight\",\n\t\t\t\t\"uiTheme\": \"vs\",\n\t\t\t\t\"path\": \"./arklight.json\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"label\": \"ArkLight (italic)\",\n\t\t\t\t\"uiTheme\": \"vs\",\n\t\t\t\t\"path\": \"./arklightItalic.json\"\n\t\t\t}\n\t\t]\n\t}\n}\n"
  },
  {
    "path": "ark/type/CHANGELOG.md",
    "content": "# arktype\n\n## 2.2.0\n\nFull announcement: https://arktype.io/docs/blog/2.2\n\n### `type.fn` - Validated functions\n\nDefine functions with runtime-validated parameters and return types. Supports defaults, optionals, and variadics.\n\n```ts\nconst len = type.fn(\"string | unknown[]\", \":\", \"number\")(s => s.length)\n\nlen(\"foo\") // 3\nlen([1, 2]) // 2\n```\n\n### Type-safe regex via arkregex\n\nRegex literals in definitions now carry full type inference. `x`-prefix parses capture groups at runtime.\n\n```ts\nconst T = type({\n\tbirthday: \"x/^(?<month>\\\\d{2})-(?<day>\\\\d{2})-(?<year>\\\\d{4})$/\"\n})\n\nT.assert({ birthday: \"05-21-1993\" }).birthday.groups.month // \"05\"\n```\n\n### `@ark/json-schema` - Bidirectional JSON Schema\n\nParse JSON Schema into ArkType Types with the new `@ark/json-schema` package, complementing `toJsonSchema()`. Thanks to @TizzySaurus.\n\n### Configurable `toJsonSchema`\n\nHandle incompatibilities between ArkType and JSON Schema with granular fallback codes. Supports `draft-07`/`draft-2020-12` targets and cyclic types.\n\n### Standard Schema as definitions\n\nAny Standard Schema compliant validator (Zod, Valibot, etc.) can be embedded directly in ArkType definitions.\n\n### `select` - Deep reference introspection\n\nQuery the internal structure of a type by node kind and predicate. Use selectors to configure specific references.\n\n### Improved `type.declare`\n\nNow supports morph-aware declarations via a `side` context, and optionality via property values.\n\n### N-ary operators\n\n`type.or`, `type.and`, `type.merge`, and `type.pipe` accept variadic definitions.\n\n### Additional highlights\n\n- `|>` string-embeddable pipe operator\n- `type.valueOf` for TS enums\n- `string.hex` + `string.regex` keywords\n- Serializable `ArkErrors` (`flatByPath`, `flatProblemsByPath`, `toJSON`)\n- `TraversalError` replaces `AggregateError`\n- `exactOptionalPropertyTypes` config\n- ES2020 + Hermes compatibility\n- In-docs playground\n- Better JSDoc + go-to-definition\n- Cyclic unions can now discriminate on nested paths\n\n## 2.1.29\n\n### Improve regex inference for certain numeric expressions\n\n```ts\n// was: Regex<`${bigint}${bigint}`>\n// now: Regex<`${number}`>\nregex(\"^\\\\d{2}$\")\n```\n\nSee arkregex CHANGELOG for full notes.\n\n## 2.1.28\n\n### JSON Schema improvements\n\n- Adds support for the new Standard JSON Schema interface (see standardschema.dev)\n- Now accepts a `target` option and can generate draft-07 in addition to draft-2020-12\n\n### Standard Schema is now a valid definition\n\nAny Standard Schema compliant validator can now be passed directly to `type`, either directly or nested in a structural ArkType definition, and will be fully inferred and validated.\n\n```ts\nimport { type } from \"arktype\"\nimport * as v from \"valibot\"\nimport z from \"zod\"\n\nconst ZodAddress = z.object({\n\tstreet: z.string(),\n\tcity: z.string()\n})\n\nconst User = type({\n\tname: \"string\",\n\tage: v.number(),\n\taddress: ZodAddress\n})\n```\n\n### e(x)ec mode for regex types\n\n```ts\nconst User = type({\n\t// x-prefix a regex literal to parse its type-safe capture groups\n\tbirthday: \"x/^(?<month>\\\\d{2})-(?<day>\\\\d{2})-(?<year>\\\\d{4})$/\"\n})\n\nconst data = User.assert({ birthday: \"05-21-1993\" })\n\n// fully type-safe via arkregex\nconsole.log(data.birthday.groups) // { month: \"05\", day: \"21\", year: \"1993\" }\n```\n\n### more flexible `type.declare`\n\nOptionality can now be expressed via a property value in addition to its key:\n\n```ts\ntype Expected = { f?: string }\n\nconst T = type.declare<Expected>().type({\n\t// previously failed with `\"f?\" is missing`\n\tf: \"string?\"\n})\n```\n\n### fixed a bug causing predicate errors after the first to not be reported\n\n```ts\nimport { type } from \"arktype\"\n\nconst Dates = type({\n\tdate1: \"string.date\",\n\tdate2: \"string.date\",\n\tdate3: \"string.date\"\n})\n\n// now correctly reports the errors on `date2` and `date3` in addition to `date1`\nDates.assert({\n\tdate1: \"\",\n\tdate2: \"\",\n\tdate3: \"\"\n})\n```\n\nSee https://github.com/arktypeio/arktype/issues/1557\n\n## 2.1.27\n\n### fix assignability for certain objects like `Module`\n\nThe following assignment will now correctly fail (thanks @LukeAbby)🔒\n\n```ts\nimport { type } from \"arktype\"\n\nconst types: Module<{ foo: string }> = type.module({ foo: \"unknown\" })\n```\n\n### bump regex inference to arkregex 0.0.3\n\n## 2.1.26\n\n### es2020 compatibility\n\nRemove usages of newer prototypes methods like `.at()` to better support legacy browsers\n\n### improve external generic inference\n\nSome inference scenarios like the following involving default values are now more cooperative (thanks @Andarist) 🎉\n\n```ts\nfunction someFunction<TSchema extends Record<string, any>>(\n\tschema: Type<TSchema, {}>\n): (typeof schema)[\"infer\"] {\n\tconst someData = { hello: \"world\" }\n\treturn schema.assert(someData)\n}\n\nconst schema = type({\n\thello: type(\"string\").pipe(s => s === \"world\"),\n\tgoodbye: \"string='blah'\"\n})\n\nsomeFunction(schema)\n```\n\n## 2.1.25\n\n### bump regex inference to arkregex 0.0.2\n\n## 2.1.24\n\n### bump regex inference to arkregex 0.0.1\n\n### duplicate key errors\n\nDefinitions like the following now throw a descriptive error:\n\n```ts\nconst T = type({\n\tfoo: \"string\",\n\tfoo?: \"string\"\n})\n```\n\n## 2.1.23\n\n### regex literals are now inferred (will be announced and documented as part of 2.2)\n\n### fix an issue with some discriminated morphs (thanks @JeremyMoeglich)\n\nSee https://github.com/arktypeio/arktype/pull/1464\n\n## 2.1.22\n\n### fix an issue with some recursive transforms\n\nSee https://github.com/arktypeio/arktype/issues/1496\n\n## 2.1.21\n\n### ~standard `toJSONSchema` support\n\nAdds support for the upcoming StandardJSONSchemaSourceV1 spec (standardschema.dev)\n\n## 2.1.20\n\n### `toJsonSchema` config\n\nSome ArkType features don't have JSON Schema equivalents. By default, `toJsonSchema()` will throw in these cases.\n\nThis behavior can be configured granularly to match your needs.\n\n```ts\nconst T = type({\n\t\"[symbol]\": \"string\",\n\tbirthday: \"Date\"\n})\n\nconst schema = T.toJsonSchema({\n\tfallback: {\n\t\t// ✅ the \"default\" key is a fallback for any non-explicitly handled code\n\t\t// ✅ ctx includes \"base\" (represents the schema being generated) and other code-specific props\n\t\t// ✅ returning `ctx.base` will effectively ignore the incompatible constraint\n\t\tdefault: ctx => ctx.base,\n\t\t// handle specific incompatibilities granularly\n\t\tdate: ctx => ({\n\t\t\t...ctx.base,\n\t\t\ttype: \"string\",\n\t\t\tformat: \"date-time\",\n\t\t\tdescription: ctx.after ? `after ${ctx.after}` : \"anytime\"\n\t\t})\n\t}\n})\n\nconst result = {\n\t$schema: \"https://json-schema.org/draft/2020-12/schema\",\n\ttype: \"object\",\n\tproperties: {\n\t\t// Date instance is now a date-time string as specified by the `date` handler\n\t\tbirthday: { type: \"string\", format: \"date-time\", description: \"anytime\" }\n\t},\n\trequired: [\"birthday\"]\n\t// symbolic index signature ignored as specified by the `default` handler\n}\n```\n\na `default` handler can also be specified at the root of a `fallback` config:\n\n```ts\nconst T = type({\n\t\"[symbol]\": \"string\",\n\tbirthday: \"Date\"\n})\n\n//--- cut ---\n\nconst schema = T.toJsonSchema({\n\t// \"just make it work\"\n\tfallback: ctx => ctx.base\n})\n```\n\nThese options can also be set at a [global or scope-level](/docs/configuration#levels).\n\n### Fallback Codes\n\nThis is the full list of configurable reasons `toJsonSchema()` can fail.\n\n| Code                  | Description                                                 |\n| --------------------- | ----------------------------------------------------------- |\n| `arrayObject`         | arrays with object properties                               |\n| `arrayPostfix`        | arrays with postfix elements                                |\n| `defaultValue`        | non-serializable default value                              |\n| `domain`              | non-serializable type keyword (always `bigint` or `symbol`) |\n| `morph`               | transformation                                              |\n| `patternIntersection` | multiple regex constraints                                  |\n| `predicate`           | custom narrow function                                      |\n| `proto`               | non-serializable `instanceof`                               |\n| `symbolKey`           | symbolic key on an object                                   |\n| `unit`                | non-serializable `===` reference (e.g. `undefined`)         |\n| `date`                | a Date instance (supersedes `proto` for Dates)              |\n\n### cyclic types can now be converted to JSON Schema\n\n```ts\n// previously this threw\nconst schema = type(\"object.json\").toJsonSchema()\n\n// now generates the following schema\nconst result = {\n\t$ref: \"#/$defs/intersection11\",\n\t$defs: {\n\t\tintersection11: {\n\t\t\ttype: \"object\",\n\t\t\tadditionalProperties: { $ref: \"#/$defs/jsonData1\" }\n\t\t},\n\t\tjsonData1: {\n\t\t\tanyOf: [\n\t\t\t\t{ $ref: \"#/$defs/intersection11\" },\n\t\t\t\t{ type: \"number\" },\n\t\t\t\t{ type: \"string\" },\n\t\t\t\t{ type: \"boolean\" },\n\t\t\t\t{ type: \"null\" }\n\t\t\t]\n\t\t}\n\t}\n}\n```\n\n### temporarily disable discrimination for cyclic unions\n\nThis [addresses](https://github.com/arktypeio/arktype/issues/1188) [multiple](https://github.com/arktypeio/arktype/issues/1209) [issues](https://github.com/arktypeio/arktype/issues/1284) while we work on a permanent solution for accurately discriminating cyclic unions, tracked [here](https://github.com/arktypeio/arktype/issues/1026).\n\n### addresses inference issues on some n-ary APIs like `type.or` outside the default scope (see [the PR](https://github.com/arktypeio/arktype/pull/1423)- thanks @simonwkla) 🎊\n\n## 2.1.19\n\n##### [Multiple](https://github.com/arktypeio/arktype/issues/1328) [improvements](https://github.com/arktypeio/arktype/issues/1279) to `toJsonSchema()` output, aligning it more closely with Open API standards.\n\n##### Faster completion triggers for shallow string definitions\n\n```ts\n// old: ~1s delay after typing this before completions\n// new: completions are almost instant\ntype(\"\")\n```\n\nThis isn't actually an overall perf improvement, but just a language server optimization to trigger autocomplete sooner.\n\nCounterintuitively, in previous 2.x versions, strings that are part of an object definition trigger completions much faster than shallow strings.\n\n## 2.1.18\n\nFix [an issue](https://github.com/arktypeio/arktype/issues/1407) causing metatypes like `Default` and `Out` to not be extracted from some recursive definitions:\n\n```ts\nconst T = type({\n\tdefaulted: \"number = 0\",\n\t\"nested?\": \"this\"\n})\n\nconst t = T.assert({})\n\n// old: Default<number, 0> | undefined\n// new: number | undefined\nt.nested?.defaulted\n```\n\n## 2.1.17\n\nUnsatisfiable types for index signature intersections will now result in a `ParseError` thanks to the work of @TizzySaurus on the upcoming `@ark/json-schema` package 🎉\n\n## 2.1.16\n\n##### Fix [an issue](https://github.com/arktypeio/arktype/issues/1400) causing non-serializable error config to lead to incorrect error messages in some JIT-mode cases:\n\n```ts\nconst MyUnion = type('\"abc\" | \"cde\"').configure({\n\tmessage: () => \"fail\"\n})\n\n// old: \"$ark.message\"\n// new: \"fail\"\nMyUnion.assert(\"efg\")\n```\n\n##### Added a workaround for environments where global prototypes like `FormData` have degenerate resolutions like `{}` (currently the case in `@types/bun`, see https://github.com/oven-sh/bun/issues/18689)\n\n```ts\nconst T = type(\"string.numeric.parse\")\n\n// previously, if a global prototype like FormData resolved to {}, it prevented\n// ArkType from extracting the input/output of morphs, leading to inference like the following:\n\n// old (with @bun/types): (In: string) => To<number>\n// new (with @bun/types): number\ntype Parsed = typeof T.inferOut\n```\n\n## 2.1.15\n\n### `.configure({}, selector)` fixes\n\n```ts\nconst User = type({\n\tname: \"string\",\n\tplatform: \"'android' | 'ios'\",\n\t\"version?\": \"number | string\"\n})\n\n// prior to 2.1.15, the selector was not applied\n// when configuring references\nconst ConfiguredUser = User.configure(\n\t{ description: \"A STRING\" },\n\t{\n\t\tkind: \"domain\",\n\t\twhere: d => d.domain === \"string\"\n\t}\n)\n\n// old: A STRING\n// new: A STRING\nConfiguredUser.get(\"name\").description\n\n// old: A STRING\n// new: \"android\" | \"ios\"\nConfiguredUser.get(\"platform\").description\n\n// old: A STRING or undefined\n// new: a number, A STRING or undefined\nConfiguredUser.get(\"version\").description\n```\n\nWith the much more powerful `.configure` + selector API now available, the internal `.withMeta` method was removed as it can be trivially achieved via a self-selector:\n\n```ts\n// < 2.1.15\nmyType.withMeta(\"some shallow description\")\n\n// >= 2.1.15\nmyType.configure(\"some shallow description\", \"self\")\n```\n\n## 2.1.14\n\n### improve .expression for regex constraints\n\n```ts\nconst T = type(/^a.*z$/)\n\n// old: string /^a.*z$/\n// new: /^a.*z$/\nconsole.log(T.expression)\n```\n\n## 2.1.13\n\n### Add standalone functions for n-ary operators\n\n```ts\n//  accept ...definitions\nconst union = type.or(type.string, \"number\", { key: \"unknown\" })\n\nconst Base = type({\n\tfoo: \"string\"\n})\n\n// accepts ...definitions\nconst intersection = type.and(\n\tBase,\n\t{\n\t\tbar: \"number\"\n\t},\n\t{\n\t\tbaz: \"string\"\n\t}\n)\n\nconst zildjian = Symbol()\n\nconst Base = type({\n\t\"[string]\": \"number\",\n\tfoo: \"0\",\n\t[zildjian]: \"true\"\n})\n\n// accepts ...objectDefinitions\nconst merged = type.merge(\n\tBase,\n\t{\n\t\t\"[string]\": \"bigint\",\n\t\t\"foo?\": \"1n\"\n\t},\n\t{\n\t\tincludeThisPropAlso: \"true\"\n\t}\n)\n\n// accepts ...morphsOrTypes\nconst trimStartToNonEmpty = type.pipe(\n\ttype.string,\n\ts => s.trimStart(),\n\ttype.string.atLeastLength(1)\n)\n```\n\n## 2.1.12\n\n### `exactOptionalPropertyTypes`\n\nBy default, ArkType validates optional keys as if [TypeScript's `exactOptionalPropertyTypes` is set to `true`](https://www.typescriptlang.org/tsconfig/#exactOptionalPropertyTypes).\n\n```ts\nconst MyObj = type({\n\t\"key?\": \"number\"\n})\n\n// valid data\nconst validResult = MyObj({})\n\n// Error: key must be a number (was undefined)\nconst errorResult = MyObj({ key: undefined })\n```\n\nThis approach allows the most granular control over optionality, as `| undefined` can be added to properties that should accept it.\n\nHowever, if you have not enabled TypeScript's `exactOptionalPropertyTypes` setting, you may globally configure ArkType's `exactOptionalPropertyTypes` to `false` to match TypeScript's behavior. If you do this, we'd recommend making a plan to enable `exactOptionalPropertyTypes` in the future.\n\n```ts title=\"config.ts\"\nimport { configure } from \"arktype/config\"\n\n// since the default in ArkType is `true`, this will only have an effect if set to `false`\nconfigure({ exactOptionalPropertyTypes: false })\n```\n\n```ts title=\"app.ts\"\nimport \"./config.ts\"\n// import your config file before arktype\nimport { type } from \"arktype\"\n\nconst MyObj = type({\n\t\"key?\": \"number\"\n})\n\n// valid data\nconst validResult = MyObj({})\n\n// now also valid data (would be an error by default)\nconst secondResult = MyObj({ key: undefined })\n```\n\n**WARNING: exactOptionalPropertyTypes does not yet affect default values!**\n\n```ts\nconst MyObj = type({\n\tkey: \"number = 5\"\n})\n\n// { key: 5 }\nconst omittedResult = MyObj({})\n\n// { key: undefined }\nconst undefinedResult = MyObj({ key: undefined })\n```\n\nSupport for this is tracked as part of [this broader configurable defaultability issue](https://github.com/arktypeio/arktype/issues/1390).\n\n## 2.1.11\n\n- Expose `select` method directly on `Type` (previously was only available on `.internal`)\n- Improve missing property error messages\n\n## 2.1.10\n\n### Added a new `select` method for introspecting references of a node:\n\nNOTE: `@ark/schema`'s API is not semver stable, so this API may change slightly over time (though we will try to ensure it doesn't).\n\n```ts\n// extract deep references to exclusive `min` nodes\nconst result = myType.select({\n\tkind: \"min\",\n\twhere: node => node.exclusive\n})\n```\n\nThese selectors can also be used to select references for configuration:\n\n```ts\n// configure string node references\nconst result = myType.configure(\n\t{ description: \"a referenced string\" },\n\t{\n\t\tkind: \"domain\",\n\t\twhere: node => node.domain === \"string\"\n\t}\n)\n```\n\n### `ArkErrors` are now JSON stringifiable and have two new props: `flatByPath` and `flatProblemsByPath`.\n\n```ts\nconst NEvenAtLeast2 = type({\n\tn: \"number % 2 >= 2\"\n})\n\nconst out = NEvenAtLeast2({ n: 1 })\n\nif (out instanceof type.errors) {\n\tconsole.log(out.flatByPath)\n\tconst output = {\n\t\tn: [\n\t\t\t{\n\t\t\t\tdata: 1,\n\t\t\t\tpath: [\"n\"],\n\t\t\t\tcode: \"divisor\",\n\t\t\t\tdescription: \"even\",\n\t\t\t\tmeta: {},\n\t\t\t\trule: 2,\n\t\t\t\texpected: \"even\",\n\t\t\t\tactual: \"1\",\n\t\t\t\tproblem: \"must be even (was 1)\",\n\t\t\t\tmessage: \"n must be even (was 1)\"\n\t\t\t},\n\t\t\t{\n\t\t\t\tdata: 1,\n\t\t\t\tpath: [\"n\"],\n\t\t\t\tcode: \"min\",\n\t\t\t\tdescription: \"at least 2\",\n\t\t\t\tmeta: {},\n\t\t\t\trule: 2,\n\t\t\t\texpected: \"at least 2\",\n\t\t\t\tactual: \"1\",\n\t\t\t\tproblem: \"must be at least 2 (was 1)\",\n\t\t\t\tmessage: \"n must be at least 2 (was 1)\"\n\t\t\t}\n\t\t]\n\t}\n\n\tconsole.log(out.flatProblemsByPath)\n\tconst output2 = {\n\t\tn: [\"must be even (was 1)\", \"must be at least 2 (was 1)\"]\n\t}\n}\n```\n\n## 2.1.9\n\nThe `|>` operator pipes output to another Type parsed from a definition.\n\nIt is now string-embeddable:\n\n```ts\nconst TrimToNonEmpty = type(\"string.trim |> string > 0\")\n\nconst Equivalent = type(\"string.trim\").to(\"string > 0\")\n```\n\n## 2.1.8\n\n- improve 3+ arg generic invocations\n- add `string.hex` (thanks @HoaX7 - #1351)\n- switch from AggregateError to TraversalError for better crash formatting (thanks @LukeAbby - #1349)\n\n## 2.1.7\n\nAddress a rare crash on an invalid ctx reference in some jitless cases\n\nCloses #1346\n\n## 2.1.6\n\nImprove some type-level parse errors on expressions with invalid finalizers\n\n## 2.1.5\n\n#### Fix JSDoc and go-to definition for unparsed keys\n\nAddresses #1294\n\n```ts\nconst T = type({\n\t/** FOO */\n\tfoo: \"string\",\n\t/** BAR */\n\tbar: \"number?\"\n})\n\nconst out = T.assert({ foo: \"foo\" })\n\n// go-to definition will now navigate to the foo prop from the type call\n// hovering foo now displays \"FOO\"\nconsole.log(out.foo)\n\n// go-to definition will now navigate to the bar prop from the type call\n// hovering bar now displays \"BAR\"\n// (the ? must be in the value for this to work)\nconsole.log(out.bar)\n```\n\n## 2.1.4\n\nStatic hermes compatibility (#1027)\n\n## 2.1.3\n\nFix a jitless-mode bug causing default + `onUndeclaredKey` transformations to not apply (#1335)\n\n## 2.1.2\n\nAllow non-zero-prefixed decimals in string.numeric ([#1333](https://github.com/arktypeio/arktype/pull/1333))\n\n## 2.1.1\n\nFix a crash on attempting to apply the default `clone` to an object with a getter or setter as one of its non-prototype properties.\n\n## 2.1.0\n\n### `match`\n\nThe `match` function provides a powerful way to handle different types of input and return corresponding outputs based on the input type, like a type-safe `switch` statement.\n\n#### Case Record API\n\nThe simplest way to define a matcher is with ArkType definition strings as keys with corresponding handlers as values:\n\n```ts\nimport { match } from \"arktype\"\n\nconst sizeOf = match({\n\t\"string | Array\": v => v.length,\n\tnumber: v => v,\n\tbigint: v => v,\n\tdefault: \"assert\"\n})\n\n// a match definition is complete once a `default` has been specified,\n// either as a case or via the .default() method\n\nsizeOf(\"abc\") // 3\nsizeOf([1, 2, 3, 4]) // 4\nsizeOf(5n) // 5n\n// ArkErrors: must be an object, a string, a number or a bigint (was boolean)\nsizeOf(true)\n```\n\nIn this example, `sizeOf` is a matcher that takes a string, array, number, or bigint as input. It returns the length of strings and arrays, and the value of numbers and bigints.\n\n`default` accepts one of 4 values:\n\n- `\"assert\"`: accept `unknown`, throw if none of the cases match\n- `\"never\"`: accept an input based on inferred cases, throw if none match\n- `\"reject\"`: accept `unknown`, return `ArkErrors` if none of the cases match\n- `(data: In) => unknown`: handle data not matching other cases directly\n\nCases will be checked in the order they are specified, either as object literal keys or via chained methods.\n\n#### Fluent API\n\nThe `match` function also provides a fluent API. This can be convenient for non-string-embeddable definitions:\n\n```ts\n// the Case Record and Fluent APIs can be easily combined\nconst sizeOf = match({\n\tstring: v => v.length,\n\tnumber: v => v,\n\tbigint: v => v\n})\n\t// match any object with a numeric length property and extract it\n\t.case({ length: \"number\" }, o => o.length)\n\t// return 0 for all other data\n\t.default(() => 0)\n\nsizeOf(\"abc\") // 3\nsizeOf({ name: \"David\", length: 5 }) // 5\nsizeOf(null) // 0\n```\n\n#### Narrowing input with `in`, property matching with `at`\n\n```ts\ntype Data =\n\t| {\n\t\t\tid: 1\n\t\t\toneValue: number\n\t  }\n\t| {\n\t\t\tid: 2\n\t\t\ttwoValue: string\n\t  }\n\nconst discriminateValue = match\n\t// .in allows you to specify the input TypeScript allows for your matcher\n\t.in<Data>()\n\t// .at allows you to specify a key at which your input will be matched\n\t.at(\"id\")\n\t.match({\n\t\t1: o => `${o.oneValue}!`,\n\t\t2: o => o.twoValue.length,\n\t\tdefault: \"assert\"\n\t})\n\ndiscriminateValue({ id: 1, oneValue: 1 }) // \"1!\"\ndiscriminateValue({ id: 2, twoValue: \"two\" }) // 3\ndiscriminateValue({ oneValue: 3 })\n```\n\nSpecial thanks to @thetayloredman who did a mind-blowingly good job helping us iterate toward the current type-level pattern-matching implementation🙇\n\n### Built-in keywords can now be globally configured\n\nThis can be very helpful for customizing error messages without needing to create your own aliases or wrappers.\n\n```ts title=\"config.ts\"\nimport { configure } from \"arktype/config\"\n\nconfigure({\n\tkeywords: {\n\t\tstring: \"shorthand description\",\n\t\t\"string.email\": {\n\t\t\tactual: () => \"definitely fake\"\n\t\t}\n\t}\n})\n```\n\n```ts title=\"app.ts\"\nimport \"./config.ts\"\nimport { type } from \"arktype\"\n\nconst User = type({\n\tname: \"string\",\n\temail: \"string.email\"\n})\n\nconst out = User({\n\t// ArkErrors: name must be shorthand description (was a number)\n\tname: 5,\n\t// ArkErrors: email must be an email address (was definitely fake)\n\temail: \"449 Canal St\"\n})\n```\n\nThe options you can provide here are identical to those used to [configure a Type directly](https://arktype.io/docs/expressions#meta), and can also be [extended at a type-level to include custom metadata](https://arktype.io/docs/configuration#metadata).\n\n### Tuple and args expressions for `.to`\n\nIf a morph returns an `ArkErrors` instance, validation will fail with that result instead of it being treated as a value. This is especially useful for using other Types as morphs to validate output or chain transformations.\n\nTo make this easier, there's a special `to` operator that can pipe to a parsed definition without having to wrap it in `type` to make it a function.\n\nThis was added before 2.0, but now it comes with a corresponding operator (`|>`) so that it can be expressed via a tuple or args like most other expressions:\n\n```ts\nconst FluentStillWorks = type(\"string.numeric.parse\").to(\"number % 2\")\n\nconst NowSoDoesTuple = type({\n\tsomeKey: [\"string.numeric.parse\", \"|>\", \"number % 2\"]\n})\n\nconst AndSpreadArgs = type(\"string.numeric.parse\", \"|>\", \"number % 2\")\n```\n\n### Error configurations now accept a string directly\n\n```ts\nconst CustomOne = type(\"1\", \"@\", {\n\t// previously only a function returning a string was allowed here\n\tmessage: \"Yikes.\"\n})\n\n// ArkErrors: Yikes.\nCustomOne(2)\n```\n\nKeep in mind, [as mentioned in the docs](https://arktype.io/docs/configuration#errors), error configs like `message` can clobber more granular config options like `expected` and `actual` and cannot be included in composite errors e.g. for a union.\n\nThough generally, returning a string based on context is the best option, in situations where you always want the same static message, it's now easier to get that!\n\n### Type.toString() now wraps its syntactic representation in `Type<..>`\n\nPreviously, `Type.toString()` just returned `Type.expression`. However, in contexts where the source of a message isn't always a `Type`, it could be confusing:\n\n```ts\n// < 2.1.0:  \"(was string)\"\n// >= 2.1.0: \"(was Type<string>)\"\nconsole.log(`(was ${type.string})`)\n```\n\nHopefully if you interpolate a Type, you'll be less confused by the result from now on!\n\n### Improve how Type instances are inferred when wrapped in external generics\n\nPreviously, we used `NoInfer` in some Type method returns. After migrating those to inlined conditionals, we get the same benefit and external inference for cases like this is more reliable:\n\n```ts\nfunction fn<\n\tT extends {\n\t\tschema: StandardSchemaV1\n\t}\n>(_: T) {\n\treturn {} as StandardSchemaV1.InferOutput<T[\"schema\"]>\n}\n\n// was inferred as unknown (now correctly { name: string })\nconst arkRes = fn({\n\tschema: type({\n\t\tname: \"string\"\n\t})\n})\n```\n\n### Fix an issue causing some discriminated unions to incorrectly reject default cases\n\n```ts\nconst Discriminated = type({\n\tid: \"0\",\n\tk1: \"number\"\n})\n\t.or({ id: \"1\", k1: \"number\" })\n\t.or({\n\t\tname: \"string\"\n\t})\n\n// previously, this was rejected as requiring a \"k1\" key\n\n// will now hit the case discriminated for id: 1,\n// but still correctly be allowed via the { name: string } branch\nDiscriminated({ name: \"foo\", id: 1 })\n```\n\n## 2.0.4\n\n### Fix an issue causing global configs to be overwritten when the primary `\"arktype\"` entry point is imported:\n\n`config.ts`\n\n```ts\nimport { configure } from \"arktype/config\"\n\nconfigure({ numberAllowsNaN: true })\n```\n\n`main.ts`\n\n```ts\nimport \"./config.ts\"\nimport { type } from \"arktype\"\n// now correctly allows NaN\ntype.number.allows(Number.NaN)\n```\n\nPrevious versions of the docs mistakenly suggested this was possible in a single file. This is not the case in ESM due to hoisting. See the updated global configuration docs [here](https://arktype.io/docs/expressions#brand).\n\n### Better `ParseError` when attempting to constraint a morph\n\nPreviously, attempting to directly constrain a transformed type was not a type error but gave a confusing error at runtime:\n\n```ts\n// ParseError: MinLength operand must be a string or an array (was never)\ntype(\"string.trim > 2\")\n```\n\nWe've added a type error and improved the runtime error:\n\n```ts\n// TypeScript: To constrain the output of string.trim, pipe like myMorph.to('number > 0')\n// ParseError: MinLength operand must be a string or an array (was a morph)\ntype(\"string.trim > 2\")\n```\n\n### Fix an issue causing certain complex morph types to not infer output correctly, e.g.:\n\n```ts\nconst types = type.module({\n\tFrom: { a: [\"1\", \"=>\", () => 2] },\n\tMorph: [\"From\", \"=>\", e => e],\n\tTo: { a: \"2\" }\n})\nconst U = types.Morph.pipe(e => e, types.To)\n\n// was:\n//    (In: never) => To<{ a: 2 }>\n// now fixed to:\n//    { a: 2 }\nconst out = U.assert({ a: 1 })\n```\n\n## 2.0.3\n\n- Fix an issue causing some unions with `onUndeclaredKey: \"reject\"` to reject valid data ([#1266](https://github.com/arktypeio/arktype/issues/1266))\n\n- Fix an issue where Types containing arrays were incorrectly treated as including morphs, leading to some unnecessary validation overhead ([#1268](https://github.com/arktypeio/arktype/issues/1268#issuecomment-2613551907))\n\n- Fix an issue causing objects containing functions like `() => never` that are subtypes of `InferredMorph` to be incorrectly treated as morphs ([#1264](https://github.com/arktypeio/arktype/issues/1264))\n\n- Fail early with a `ParseError` if `instanceOf` operand is not actually a function at runtime ([#1262](https://github.com/arktypeio/arktype/issues/1262))\n\n## 2.0.2\n\n- Fix an issue where type-altering (currently config options `numberAllowsNan`, `dateAllowsInvalid` and `onUndeclaredKey`) could be specified at a scope-level, leading to unintuitive cache results ([#1255](https://github.com/arktypeio/arktype/issues/1255))\n\n## 2.0.1\n\n- Fix `@ark/util` version specifier\n\n## 2.0.0\n\n- Initial stable release 🎉\n"
  },
  {
    "path": "ark/type/README.md",
    "content": "<h1 align=\"center\">ArkType</h1>\n<h3 align=\"center\"><i>TypeScript's 1:1 validator, optimized from editor to runtime</i></h1>\n\nArkType is a runtime validation library that parses optimized validators from familiar, type-safe syntax.\n\nIt can be used to check external data like JSON payloads or forms at the boundaries of your code (similar to Zod).\n\n<video\nautoPlay\nloop\ncontrols\nplaysInline\nmuted\ndisablePictureInPicture\nsrc=\"https://github.com/user-attachments/assets/69fdded6-50a9-402d-a28c-afa58db63c90\"\n/>\n\n## Docs\n\nSee our [docs site](https://arktype.io)\n\n## Contributions\n\nWe accept and encourage pull requests from outside ArkType. Planned work is tracked in [this GitHub project](https://github.com/orgs/arktypeio/projects/4).\n\nDepending on your level of familiarity with type systems and TS generics, some parts of the codebase may be hard to jump into. That said, there's plenty of opportunities for more straightforward contributions. We'd generally recommend starting with one of these issues labeled [external-contributor-friendly](https://github.com/orgs/arktypeio/projects/4/?filterQuery=label%3A%22external-contributor-friendly%22).\n\nIf you're planning on submitting a non-trivial fix or a new feature, please [create an issue first](https://github.com/arktypeio/arktype/issues/new) so everyone's on the same page. The last thing we want is for you to spend time on a submission we're unable to merge.\n\nWhen you're ready, check out our [guide](./.github/CONTRIBUTING.md) to get started!\n\n## License\n\nThis project is licensed under the terms of the\n[MIT license](./LICENSE).\n\n## Code of Conduct\n\nWe will not tolerate any form of disrespect toward members of our community. Please refer to our [Code of Conduct](./.github/CODE_OF_CONDUCT.md) and reach out to david@arktype.io immediately if you've seen or experienced an interaction that may violate these standards.\n\n## Sponsorship\n\nWe've been working full-time on this project for multiple years and it means a lot to have the community behind us.\n\nIf the project has been useful to you and you are in a financial position to do so, please chip in via [GitHub Sponsors](https://github.com/sponsors/arktypeio).\n\nOtherwise, consider sending me an email (david@arktype.io) or [message me on Discord](https://arktype.io/discord) to let me know you're a fan of ArkType. Either would make my day!\n\n### ArkSponsors ⛵\n\n<table>\n    <tr>\n        <th>mintlify</th>\n        <th>get-convex</th>\n        <th>inspatiallabs</th>\n        <th>sam-goodwin</th>\n    </tr>\n    <tr>\n        <td>\n            <a href=\"https://github.com/mintlify\"\n                ><img\n                    height=\"64px\"\n                    src=\"https://avatars.githubusercontent.com/mintlify\"\n            /></a>\n        </td>\n        <td>\n            <a href=\"https://github.com/get-convex\"\n                ><img\n                    height=\"64px\"\n                    src=\"https://avatars.githubusercontent.com/get-convex\"\n            /></a>\n        </td>\n        <td>\n            <a href=\"https://github.com/inspatiallabs\"\n                ><img\n                    height=\"64px\"\n                    src=\"https://avatars.githubusercontent.com/inspatiallabs\"\n            /></a>\n        </td>\n        <td>\n            <a href=\"https://github.com/sam-goodwin\"\n                ><img\n                    height=\"64px\"\n                    src=\"https://avatars.githubusercontent.com/sam-goodwin\"\n            /></a>\n        </td>\n    </tr>\n</table>\n\n### Sponsors 🥰\n\n<table>\n    <tr>\n        <th>tmm</th>\n        <th>mewhhaha</th>\n        <th>jahands</th>\n        <th>drwpwrs</th>\n        <th>Phalangers</th>\n    </tr>\n    <tr>\n        <td>\n            <a href=\"https://github.com/tmm\"\n                ><img\n                    height=\"64px\"\n                    src=\"https://avatars.githubusercontent.com/tmm\"\n            /></a>\n        </td>\n        <td>\n            <a href=\"https://github.com/mewhhaha\"\n                ><img\n                    height=\"64px\"\n                    src=\"https://avatars.githubusercontent.com/mewhhaha\"\n            /></a>\n        </td>\n        <td>\n            <a href=\"https://github.com/jahands\"\n                ><img\n                    height=\"64px\"\n                    src=\"https://avatars.githubusercontent.com/jahands\"\n            /></a>\n        </td>\n        <td>\n            <a href=\"https://github.com/drwpwrs\"\n                ><img\n                    height=\"64px\"\n                    src=\"https://avatars.githubusercontent.com/drwpwrs\"\n            /></a>\n        </td>\n        <td>\n            <a href=\"https://github.com/Phalangers\"\n                ><img\n                    height=\"64px\"\n                    src=\"https://avatars.githubusercontent.com/Phalangers\"\n            /></a>\n        </td>\n    </tr>\n    <tr>\n        <th>WilliamConnatser</th>\n        <th>JameEnder</th>\n        <th>tylim88</th>\n    </tr>\n    <tr>\n        <td>\n            <a href=\"https://github.com/WilliamConnatser\"\n                ><img\n                    height=\"64px\"\n                    src=\"https://avatars.githubusercontent.com/WilliamConnatser\"\n            /></a>\n        </td>\n        <td>\n            <a href=\"https://github.com/JameEnder\"\n                ><img\n                    height=\"64px\"\n                    src=\"https://avatars.githubusercontent.com/JameEnder\"\n            /></a>\n        </td>\n        <td>\n            <a href=\"https://github.com/tylim88\"\n                ><img\n                    height=\"64px\"\n                    src=\"https://avatars.githubusercontent.com/tylim88\"\n            /></a>\n        </td>\n    </tr>\n</table>\n"
  },
  {
    "path": "ark/type/__tests__/arrays/array.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { scope, type } from \"arktype\"\nimport { incompleteArrayTokenMessage } from \"arktype/internal/parser/shift/operator/operator.ts\"\nimport {\n\tmultipleVariadicMesage,\n\twriteNonArraySpreadMessage\n} from \"arktype/internal/parser/tupleLiteral.ts\"\n\ncontextualize(() => {\n\tdescribe(\"non-tuple\", () => {\n\t\tit(\"allows and apply\", () => {\n\t\t\tconst T = type(\"string[]\")\n\t\t\tattest<string[]>(T.infer)\n\t\t\tattest(T.allows([])).equals(true)\n\t\t\tattest(T([])).snap([])\n\t\t\tattest(T.allows([\"foo\", \"bar\"])).equals(true)\n\t\t\tattest(T([\"foo\", \"bar\"])).snap([\"foo\", \"bar\"])\n\t\t\tattest(T.allows([\"foo\", \"bar\", 5])).equals(false)\n\t\t\tattest(T([\"foo\", \"bar\", 5]).toString()).snap(\n\t\t\t\t\"value at [2] must be a string (was a number)\"\n\t\t\t)\n\t\t\tattest(T.allows([5, \"foo\", \"bar\"])).equals(false)\n\t\t\tattest(T([5, \"foo\", \"bar\"]).toString()).snap(\n\t\t\t\t\"value at [0] must be a string (was a number)\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"nested\", () => {\n\t\t\tconst T = type(\"string[][]\")\n\t\t\tattest<string[][]>(T.infer)\n\t\t\tattest(T.allows([])).equals(true)\n\t\t\tattest(T([])).snap([])\n\t\t\tattest(T.allows([[\"foo\"]])).equals(true)\n\t\t\tattest(T([[\"foo\"]])).snap([[\"foo\"]])\n\t\t\tattest(T.allows([\"foo\"])).equals(false)\n\t\t\tattest(T([\"foo\"]).toString()).snap(\n\t\t\t\t\"value at [0] must be an array (was string)\"\n\t\t\t)\n\t\t\tattest(T.allows([[\"foo\", 5]])).equals(false)\n\t\t\tattest(T([[\"foo\", 5]]).toString()).snap(\n\t\t\t\t\"value at [0][1] must be a string (was a number)\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"tuple expression\", () => {\n\t\t\tconst T = type([\"string\", \"[]\"])\n\t\t\tattest<string[]>(T.infer)\n\t\t\tattest(T.json).equals(type(\"string[]\").json)\n\t\t})\n\n\t\tit(\"root expression\", () => {\n\t\t\tconst T = type(\"string\", \"[]\")\n\t\t\tattest<string[]>(T.infer)\n\t\t\tattest(T.json).equals(type(\"string[]\").json)\n\t\t})\n\n\t\tit(\"chained\", () => {\n\t\t\tconst T = type({ a: \"string\" }).array()\n\t\t\tattest<{ a: string }[]>(T.infer)\n\t\t\tattest(T.expression).snap(\"{ a: string }[]\")\n\t\t})\n\n\t\tit(\"incomplete token\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"string[\")).throwsAndHasTypeError(\n\t\t\t\tincompleteArrayTokenMessage\n\t\t\t)\n\t\t})\n\t})\n\n\tdescribe(\"non-variadic tuple\", () => {\n\t\tit(\"empty\", () => {\n\t\t\tconst T = type([])\n\t\t\tattest<[]>(T.infer)\n\t\t\tattest(T.expression).snap(\"[]\")\n\t\t\tattest(T.json).snap({ proto: \"Array\", exactLength: 0 })\n\t\t\tattest(T([])).equals([])\n\t\t\tattest(T([1]).toString()).snap(\"must be exactly length 0 (was 1)\")\n\t\t})\n\n\t\tit(\"shallow\", () => {\n\t\t\tconst T = type([\"string\", \"number\"])\n\t\t\tattest<[string, number]>(T.infer)\n\t\t\tattest(T.allows([\"\", 0])).equals(true)\n\t\t\tattest(T([\"\", 0])).snap([\"\", 0])\n\t\t\tattest(T.allows([true, 0])).equals(false)\n\t\t\tattest(T([true, 0]).toString()).snap(\n\t\t\t\t\"value at [0] must be a string (was boolean)\"\n\t\t\t)\n\t\t\tattest(T.allows([0, false])).equals(false)\n\t\t\tattest(T([0, false]).toString())\n\t\t\t\t.snap(`value at [0] must be a string (was a number)\nvalue at [1] must be a number (was boolean)`)\n\t\t\t// too short\n\t\t\tattest(T.allows([\"\"])).equals(false)\n\t\t\tattest(T([\"\"]).toString()).snap(\"must be exactly length 2 (was 1)\")\n\t\t\t// too long\n\t\t\tattest(T.allows([\"\", 0, 1])).equals(false)\n\t\t\tattest(T([\"\", 0, 1]).toString()).snap(\"must be exactly length 2 (was 3)\")\n\t\t\t// non-array\n\t\t\tattest(\n\t\t\t\tT.allows({\n\t\t\t\t\tlength: 2,\n\t\t\t\t\t0: \"\",\n\t\t\t\t\t1: 0\n\t\t\t\t})\n\t\t\t).equals(false)\n\t\t\tattest(\n\t\t\t\tT({\n\t\t\t\t\tlength: 2,\n\t\t\t\t\t0: \"\",\n\t\t\t\t\t1: 0\n\t\t\t\t}).toString()\n\t\t\t).snap(\"must be an array (was object)\")\n\t\t})\n\n\t\tit(\"nested\", () => {\n\t\t\tconst T = type([[\"string\", \"number\"], [{ a: \"bigint\", b: [\"null\"] }]])\n\t\t\tattest<\n\t\t\t\t[\n\t\t\t\t\t[string, number],\n\t\t\t\t\t[\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ta: bigint\n\t\t\t\t\t\t\tb: [null]\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t]\n\t\t\t>(T.infer)\n\t\t\tconst valid: typeof T.infer = [[\"\", 0], [{ a: 0n, b: [null] }]]\n\t\t\tattest(T.allows(valid)).equals(true)\n\t\t\tattest(T(valid)).equals(valid)\n\t\t\tconst invalid = [[\"\", 0], [{ a: 0n, b: [undefined] }]]\n\t\t\tattest(T.allows(invalid)).equals(false)\n\t\t\tattest(T(invalid).toString()).snap(\n\t\t\t\t\"value at [1][0].b[0] must be null (was undefined)\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"optional tuple\", () => {\n\t\t\tconst T = type([[\"string\", \"?\"]])\n\t\t\tattest<[string?]>(T.infer)\n\t\t\tattest(T([])).equals([])\n\t\t\tattest(T([\"foo\"])).equals([\"foo\"])\n\t\t\tattest(T([5]).toString()).snap(\n\t\t\t\t\"value at [0] must be a string (was a number)\"\n\t\t\t)\n\t\t\tattest(T([\"foo\", \"bar\"]).toString()).snap(\n\t\t\t\t\"must be at most length 1 (was 2)\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"optional string-embedded tuple\", () => {\n\t\t\tconst T = type([\"string?\"])\n\n\t\t\tconst Expected = type([[\"string\", \"?\"]])\n\t\t\tattest<typeof Expected>(T)\n\t\t\tattest(T.expression).equals(Expected.expression)\n\t\t})\n\n\t\tit(\"optional object tuple\", () => {\n\t\t\tconst T = type([[{ foo: \"string\" }, \"?\"], \"string?\"])\n\t\t\tattest<\n\t\t\t\t[\n\t\t\t\t\t{\n\t\t\t\t\t\tfoo: string\n\t\t\t\t\t}?,\n\t\t\t\t\tstring?\n\t\t\t\t]\n\t\t\t>(T.t)\n\t\t\tattest(T.expression).snap(\"[{ foo: string }?, string?]\")\n\t\t})\n\n\t\tit(\"optional nested object tuple\", () => {\n\t\t\tconst T = type([[[{ foo: \"string\" }, \"?\"]], [\"string\", \"?\"]])\n\t\t\tattest<\n\t\t\t\t[\n\t\t\t\t\t[\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfoo: string\n\t\t\t\t\t\t}?\n\t\t\t\t\t],\n\t\t\t\t\tstring?\n\t\t\t\t]\n\t\t\t>(T.t)\n\t\t\tattest(T.expression).snap(\"[[{ foo: string }?], string?]\")\n\t\t})\n\t})\n\n\tdescribe(\"variadic tuple\", () => {\n\t\tit(\"spreads simple arrays\", () => {\n\t\t\tconst WellRested = type([\"string\", \"...\", \"number[]\"])\n\t\t\tattest<[string, ...number[]]>(WellRested.infer)\n\t\t\tattest(WellRested([\"foo\"])).equals([\"foo\"])\n\t\t\tattest(WellRested([\"foo\", 1, 2])).equals([\"foo\", 1, 2])\n\t\t})\n\n\t\tit(\"spreads array expressions\", () => {\n\t\t\tconst GreatSpread = type([\"0\", \"...\", \"(Date|RegExp)[]\"])\n\t\t\tattest<[0, ...(RegExp | Date)[]]>(GreatSpread.infer)\n\t\t})\n\n\t\tit(\"distributes spread unions\", () => {\n\t\t\tconst T = type([\"1\", \"...\", \"(Date[] | RegExp[])\"])\n\t\t\tattest<[1, ...(Date[] | RegExp[])]>(T.infer)\n\t\t\tconst Expected = type([\"1\", \"...\", \"Date[]\"]).or([\"1\", \"...\", \"RegExp[]\"])\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"distributes spread union tuples\", () => {\n\t\t\tconst counting = [\"2\", \"3\", \"4\"] as const\n\t\t\tconst fibbing = [\"1\", \"2\", \"3\", \"5\", \"8\"] as const\n\t\t\tconst CountOrFib = type(counting, \"|\", fibbing)\n\t\t\tattest<[2, 3, 4] | [1, 2, 3, 5, 8]>(CountOrFib.infer)\n\t\t\tconst T = type([\"1\", \"...\", CountOrFib])\n\t\t\tattest<[1, 2, 3, 4] | [1, 1, 2, 3, 5, 8]>(T.infer)\n\t\t\tconst Expected = type([\"1\", ...counting]).or([\"1\", ...fibbing])\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"allows array keyword\", () => {\n\t\t\tconst types = scope({\n\t\t\t\tmyArrayKeyword: \"boolean[]\",\n\t\t\t\tmyVariadicKeyword: [\"string\", \"...\", \"myArrayKeyword\"]\n\t\t\t}).export()\n\t\t\tattest<[string, ...boolean[]]>(types.myVariadicKeyword.infer)\n\t\t})\n\n\t\tit(\"errors on non-array\", () => {\n\t\t\tattest(() =>\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttype([\"number\", \"...\", \"string\"])\n\t\t\t).throwsAndHasTypeError(writeNonArraySpreadMessage(\"string\"))\n\t\t})\n\n\t\tit(\"allows multiple fixed spreads\", () => {\n\t\t\tconst T = type([\n\t\t\t\t\"string\",\n\t\t\t\t\"...\",\n\t\t\t\t\"number[]\",\n\t\t\t\t\"...\",\n\t\t\t\t[\"boolean\", \"bigint\"],\n\t\t\t\t\"...\",\n\t\t\t\t[\"symbol\"]\n\t\t\t])\n\t\t\tconst Expected = type([\n\t\t\t\t\"string\",\n\t\t\t\t\"...\",\n\t\t\t\t\"number[]\",\n\t\t\t\t\"boolean\",\n\t\t\t\t\"bigint\",\n\t\t\t\t\"symbol\"\n\t\t\t])\n\t\t\tattest<[string, ...number[], boolean, bigint, symbol]>(T.infer)\n\t\t\tattest<typeof Expected.infer>(T.infer)\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"errors on multiple variadic\", () => {\n\t\t\tattest(() =>\n\t\t\t\ttype([\n\t\t\t\t\t\"...\",\n\t\t\t\t\t\"string[]\",\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\"...\",\n\t\t\t\t\t\"number[]\"\n\t\t\t\t])\n\t\t\t).throwsAndHasTypeError(multipleVariadicMesage)\n\t\t})\n\t})\n\n\tit(\"reduces minLength\", () => {\n\t\tconst T = type([\"number\", \"number\", \"...\", \"number[]\", \"number\"])\n\t\tconst Expected = type(\"number[]>=3\")\n\t\tattest(T.json).equals(Expected.json)\n\t})\n\n\tit(\"multiple errors\", () => {\n\t\tconst StringArray = type(\"string[]\")\n\t\tattest(StringArray([1, 2]).toString())\n\t\t\t.snap(`value at [0] must be a string (was a number)\nvalue at [1] must be a string (was a number)`)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/arrays/base.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { writeUnresolvableMessage } from \"@ark/schema\"\nimport { type } from \"arktype\"\nimport { incompleteArrayTokenMessage } from \"arktype/internal/parser/shift/operator/operator.ts\"\n\ncontextualize(() => {\n\tit(\"allows and apply\", () => {\n\t\tconst T = type(\"string[]\")\n\t\tattest<string[]>(T.infer)\n\t\tattest(T.allows([])).equals(true)\n\t\tattest(T([])).snap([])\n\t\tattest(T.allows([\"foo\", \"bar\"])).equals(true)\n\t\tattest(T([\"foo\", \"bar\"])).snap([\"foo\", \"bar\"])\n\t\tattest(T.allows([\"foo\", \"bar\", 5])).equals(false)\n\t\tattest(T([\"foo\", \"bar\", 5]).toString()).snap(\n\t\t\t\"value at [2] must be a string (was a number)\"\n\t\t)\n\t\tattest(T.allows([5, \"foo\", \"bar\"])).equals(false)\n\t\tattest(T([5, \"foo\", \"bar\"]).toString()).snap(\n\t\t\t\"value at [0] must be a string (was a number)\"\n\t\t)\n\t})\n\n\tit(\"nested\", () => {\n\t\tconst T = type(\"string[][]\")\n\t\tattest<string[][]>(T.infer)\n\t\tattest(T.allows([])).equals(true)\n\t\tattest(T([])).snap([])\n\t\tattest(T.allows([[\"foo\"]])).equals(true)\n\t\tattest(T([[\"foo\"]])).snap([[\"foo\"]])\n\t\tattest(T.allows([\"foo\"])).equals(false)\n\t\tattest(T([\"foo\"]).toString()).snap(\n\t\t\t\"value at [0] must be an array (was string)\"\n\t\t)\n\t\tattest(T.allows([[\"foo\", 5]])).equals(false)\n\t\tattest(T([[\"foo\", 5]]).toString()).snap(\n\t\t\t\"value at [0][1] must be a string (was a number)\"\n\t\t)\n\t})\n\n\tit(\"tuple expression\", () => {\n\t\tconst T = type([\"string\", \"[]\"])\n\t\tattest<string[]>(T.infer)\n\t\tattest(T.json).equals(type(\"string[]\").json)\n\t})\n\n\tit(\"root expression\", () => {\n\t\tconst T = type(\"string\", \"[]\")\n\t\tattest<string[]>(T.infer)\n\t\tattest(T.json).equals(type(\"string[]\").json)\n\t})\n\n\tit(\"chained\", () => {\n\t\tconst T = type({ a: \"string\" }).array()\n\t\tattest<{ a: string }[]>(T.infer)\n\n\t\t// @ts-expect-error\n\t\tattest(() => type({ a: \"hmm\" }).array()).throwsAndHasTypeError(\n\t\t\twriteUnresolvableMessage(\"hmm\")\n\t\t)\n\t})\n\n\tit(\"incomplete token\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"string[\")).throwsAndHasTypeError(\n\t\t\tincompleteArrayTokenMessage\n\t\t)\n\t})\n\n\tit(\"multiple errors\", () => {\n\t\tconst StringArray = type(\"string[]\")\n\t\tattest(StringArray([1, 2]).toString())\n\t\t\t.snap(`value at [0] must be a string (was a number)\nvalue at [1] must be a string (was a number)`)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/arrays/defaults.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { Traversal } from \"@ark/schema\"\nimport { type } from \"arktype\"\nimport { defaultablePostOptionalMessage } from \"arktype/internal/parser/tupleLiteral.ts\"\n\ncontextualize(() => {\n\tit(\"single element tuple\", () => {\n\t\tconst T = type([[\"number\", \"=\", 5]])\n\t\tattest(T.t).type.toString.snap(\"[Default<number, 5>]\")\n\t\tattest(T.expression).snap(\"[number = 5]\")\n\t\tattest(T.json).snap({\n\t\t\tsequence: { defaultables: [[\"number\", 5]] },\n\t\t\tproto: \"Array\",\n\t\t\tmaxLength: 1\n\t\t})\n\t\tattest(T([])).equals([5])\n\t\tattest(T([1])).equals([1])\n\t\tattest(T([null]).toString()).snap(\n\t\t\t\"value at [0] must be a number (was null)\"\n\t\t)\n\t\tattest(T([1, 2]).toString()).snap(\"must be at most length 1 (was 2)\")\n\t})\n\n\tit(\"string\", () => {\n\t\tconst T = type([\"string = 'foo'\"])\n\t\tattest(T.t).type.toString.snap(`[Default<string, \"foo\">]`)\n\t\tattest(T.expression).snap('[string = \"foo\"]')\n\t\tattest(T.json).snap({\n\t\t\tsequence: { defaultables: [[\"string\", \"foo\"]] },\n\t\t\tproto: \"Array\",\n\t\t\tmaxLength: 1\n\t\t})\n\t\tattest(T([])).equals([\"foo\"])\n\t\tattest(T([\"bar\"])).snap([\"bar\"])\n\t\tattest(T([false]).toString()).snap(\n\t\t\t\"value at [0] must be a string (was boolean)\"\n\t\t)\n\t\tattest(T([\"foo\", \"bar\"]).toString()).snap(\n\t\t\t\"must be at most length 1 (was 2)\"\n\t\t)\n\t})\n\n\tit(\"defaults following prefix\", () => {\n\t\tconst T = type([\"string\", \"number = 5\"])\n\t\tattest(T.t).type.toString.snap(\"[string, Default<number, 5>]\")\n\t\tattest(T.expression).snap(\"[string, number = 5]\")\n\t\tattest(T.json).snap({\n\t\t\tsequence: { defaultables: [[\"number\", 5]], prefix: [\"string\"] },\n\t\t\tproto: \"Array\",\n\t\t\tmaxLength: 2,\n\t\t\tminLength: 1\n\t\t})\n\t\tattest(T([\"\"])).equals([\"\", 5])\n\t\tattest(T([\"\", 7])).equals([\"\", 7])\n\n\t\tattest(T([]).toString()).snap(\"must be non-empty\")\n\t\tattest(T([\"foo\", \"bar\"]).toString()).snap(\n\t\t\t\"value at [1] must be a number (was a string)\"\n\t\t)\n\t})\n\n\tit(\"defaults preceding variadic\", () => {\n\t\tconst T = type([\"number\", \"string = 'foo'\", \"...\", \"number[]\"])\n\t\tattest(T.t).type.toString.snap(\n\t\t\t'[number, Default<string, \"foo\">, ...number[]]'\n\t\t)\n\t\tattest(T.expression).snap('[number, string = \"foo\", ...number[]]')\n\t\tattest(T.json).snap({\n\t\t\tsequence: {\n\t\t\t\tdefaultables: [[\"string\", \"foo\"]],\n\t\t\t\tprefix: [\"number\"],\n\t\t\t\tvariadic: \"number\"\n\t\t\t},\n\t\t\tproto: \"Array\",\n\t\t\tminLength: 1\n\t\t})\n\n\t\tattest(T([5])).equals([5, \"foo\"])\n\t\tattest(T([7, \"bar\"])).equals([7, \"bar\"])\n\t\tattest(T([8, \"bar\", 5])).equals([8, \"bar\", 5])\n\n\t\tattest(T([]).toString()).snap(\"must be non-empty\")\n\t\t// all positional elements including optionals\n\t\t// must be specified before variadic elements\n\t\tattest(T([5, 5]).toString()).snap(\n\t\t\t\"value at [1] must be a string (was a number)\"\n\t\t)\n\t})\n\n\tit(\"default after undefaulted optional\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type([\"number?\", \"number = 5\"])).throwsAndHasTypeError(\n\t\t\tdefaultablePostOptionalMessage\n\t\t)\n\t})\n\n\tit(\"input extracted as optional\", () => {\n\t\tconst T = type([\"number = 5\"])\n\t\tattest<[number?]>(T.in.t)\n\t\tattest<[number?]>(T.inferIn)\n\n\t\tattest(T.in.expression).snap(\"[number?]\")\n\t})\n\n\tit(\"output extracted as required\", () => {\n\t\tconst T = type([\"number = 5\"])\n\t\tattest<[number]>(T.out.t)\n\t\tattest<[number]>(T.inferOut)\n\n\t\tattest(T.out.expression).snap(\"[number]\")\n\t})\n\n\tit(\"compiled defaults use correct values\", () => {\n\t\tconst T = type([\"string = 'foo'\"])\n\t\tconst internal = T.internal\n\n\t\t// Call traverseApply directly with a Traversal context\n\t\t// This exercises the JIT-compiled code path\n\t\tconst data: string[] = []\n\t\tconst ctx = new Traversal(data, internal.$.resolvedConfig)\n\t\tinternal.traverseApply(data, ctx)\n\t\tconst result = ctx.finalize(null)\n\n\t\tattest(result).equals([\"foo\"])\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/arrays/intersection.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"shallow array intersection\", () => {\n\t\tconst T = type(\"string[]&'foo'[]\")\n\t\tconst Expected = type(\"'foo'[]\")\n\t\tattest(T.json).equals(Expected.json)\n\t})\n\n\tit(\"deep array intersection\", () => {\n\t\tconst T = type([{ a: \"string\" }, \"[]\"]).and([{ b: \"number\" }, \"[]\"])\n\t\tconst Expected = type([{ a: \"string\", b: \"number\" }, \"[]\"])\n\t\tattest(T.json).equals(Expected.json)\n\t})\n\n\tit(\"tuple intersection\", () => {\n\t\tconst T = type([[{ a: \"string\" }], \"&\", [{ b: \"boolean\" }]])\n\t\tconst Expected = type([{ a: \"string\", b: \"boolean\" }])\n\t\tattest<typeof Expected>(T)\n\t\tattest(T.json).equals(Expected.json)\n\t})\n\n\tit(\"tuple and array\", () => {\n\t\tconst TupleAndArray = type([\n\t\t\t[{ a: \"string\" }],\n\t\t\t\"&\",\n\t\t\t[{ b: \"boolean\" }, \"[]\"]\n\t\t])\n\t\tconst ArrayAndTuple = type([\n\t\t\t[{ b: \"boolean\" }, \"[]\"],\n\t\t\t\"&\",\n\t\t\t[{ a: \"string\" }]\n\t\t])\n\n\t\tconst Expected = type([{ a: \"string\", b: \"boolean\" }])\n\t\tattest<typeof Expected>(TupleAndArray)\n\n\t\tattest<typeof Expected>(ArrayAndTuple)\n\n\t\tattest(TupleAndArray.json).equals(Expected.json)\n\t\tattest(ArrayAndTuple.json).equals(Expected.json)\n\t})\n\n\tit(\"variadic and tuple\", () => {\n\t\tconst B = type([{ b: \"boolean\" }, \"[]\"])\n\t\tconst T = type([{ a: \"string\" }, \"...\", B]).and([\n\t\t\t{ c: \"number\" },\n\t\t\t{ d: \"Date\" }\n\t\t])\n\t\tconst Expected = type([\n\t\t\t{ a: \"string\", c: \"number\" },\n\t\t\t{ b: \"boolean\", d: \"Date\" }\n\t\t])\n\t\tattest(T.json).equals(Expected.json)\n\t})\n\n\tit(\"variadic and array\", () => {\n\t\tconst B = type({ b: \"boolean\" }, \"[]\")\n\t\tconst T = type([{ a: \"string\" }, \"...\", B]).and([{ c: \"number\" }, \"[]\"])\n\t\tconst Expected = type([\n\t\t\t{ a: \"string\", c: \"number\" },\n\t\t\t\"...\",\n\t\t\t[{ b: \"boolean\", c: \"number\" }, \"[]\"]\n\t\t])\n\t\tattest<typeof Expected.infer>(T.infer)\n\t\tattest(T.json).equals(Expected.json)\n\t})\n\n\t// based on the equivalent type-level test from @ark/util\n\tit(\"kitchen sink\", () => {\n\t\tconst L = type([\n\t\t\t{ a: \"0\" },\n\t\t\t[{ b: \"1\" }, \"?\"],\n\t\t\t[{ c: \"2\" }, \"?\"],\n\t\t\t\"...\",\n\t\t\t[{ d: \"3\" }, \"[]\"]\n\t\t])\n\t\tconst R = type([\n\t\t\t[{ e: \"4\" }, \"?\"],\n\t\t\t[{ f: \"5\" }, \"?\"],\n\t\t\t\"...\",\n\t\t\t[{ g: \"6\" }, \"[]\"]\n\t\t])\n\t\tconst T = L.and(R)\n\n\t\tconst Expected = type([\n\t\t\t{ a: \"0\", e: \"4\" },\n\t\t\t[{ b: \"1\", f: \"5\" }, \"?\"],\n\t\t\t[{ c: \"2\", g: \"6\" }, \"?\"],\n\t\t\t\"...\",\n\t\t\t[{ d: \"3\", g: \"6\" }, \"[]\"]\n\t\t])\n\n\t\tattest(T.expression).snap(\n\t\t\t\"[{ a: 0, e: 4 }, { b: 1, f: 5 }?, { c: 2, g: 6 }?, ...{ d: 3, g: 6 }[]]\"\n\t\t)\n\n\t\tattest<typeof Expected>(T)\n\t\tattest(T.expression).equals(Expected.expression)\n\t})\n\n\tit(\"prefix and postfix\", () => {\n\t\tconst L = type([\"...\", [{ a: \"0\" }, \"[]\"], { b: \"0\" }, { c: \"0\" }])\n\t\tconst R = type([{ x: \"0\" }, { y: \"0\" }, \"...\", [{ z: \"0\" }, \"[]\"]])\n\n\t\tconst Expected = type([\n\t\t\t{ a: \"0\", x: \"0\" },\n\t\t\t{ a: \"0\", y: \"0\" },\n\t\t\t\"...\",\n\t\t\t[{ a: \"0\", z: \"0\" }, \"[]\"],\n\t\t\t{ b: \"0\", z: \"0\" },\n\t\t\t{ c: \"0\", z: \"0\" }\n\t\t])\n\t\t\t.or([\n\t\t\t\t{ a: \"0\", x: \"0\" },\n\t\t\t\t{ b: \"0\", y: \"0\" },\n\t\t\t\t{ c: \"0\", z: \"0\" }\n\t\t\t])\n\t\t\t.or([\n\t\t\t\t{ b: \"0\", x: \"0\" },\n\t\t\t\t{ c: \"0\", y: \"0\" }\n\t\t\t])\n\n\t\tconst lrResult = L.and(R)\n\t\tattest(lrResult.json).snap(Expected.json)\n\t\tconst rlResult = R.and(L)\n\t\tattest(rlResult.json).snap(Expected.json)\n\t})\n\n\tit(\"reduces minLength\", () => {\n\t\tconst T = type([\"number\", \"number\", \"...\", \"number[]\", \"number\"])\n\t\tconst Expected = type(\"number[]>=3\")\n\t\tattest(T.json).equals(Expected.json)\n\t})\n\n\tit(\"array with props\", () => {\n\t\tconst T = type(\"Array\").and({ name: \"string\" })\n\n\t\tattest(T.json).snap({\n\t\t\trequired: [{ key: \"name\", value: \"string\" }],\n\t\t\tproto: \"Array\"\n\t\t})\n\n\t\tattest<\n\t\t\tunknown[] & {\n\t\t\t\tname: string\n\t\t\t}\n\t\t>(T.t)\n\n\t\tattest(T({ name: \"foo\" }).toString()).snap(\"must be an array (was object)\")\n\t\tconst arrayWithProps = Object.assign([], { name: \"foo\" })\n\t\tattest(T(arrayWithProps)).equals(arrayWithProps)\n\t})\n\n\tit(\"shallow array intersection\", () => {\n\t\tconst T = type(\"string[]&'foo'[]\")\n\t\tconst Expected = type(\"'foo'[]\")\n\t\tattest(T.json).equals(Expected.json)\n\t})\n\n\tit(\"deep array intersection\", () => {\n\t\tconst T = type([{ a: \"string\" }, \"[]\"]).and([{ b: \"number\" }, \"[]\"])\n\t\tconst Expected = type([{ a: \"string\", b: \"number\" }, \"[]\"])\n\t\tattest(T.json).equals(Expected.json)\n\t})\n\n\tit(\"tuple intersection\", () => {\n\t\tconst T = type([[{ a: \"string\" }], \"&\", [{ b: \"boolean\" }]])\n\t\tconst Expected = type([{ a: \"string\", b: \"boolean\" }])\n\t\tattest<typeof Expected>(T)\n\t\tattest(T.json).equals(Expected.json)\n\t})\n\n\tit(\"tuple and array\", () => {\n\t\tconst TupleAndArray = type([\n\t\t\t[{ a: \"string\" }],\n\t\t\t\"&\",\n\t\t\t[{ b: \"boolean\" }, \"[]\"]\n\t\t])\n\t\tconst ArrayAndTuple = type([\n\t\t\t[{ b: \"boolean\" }, \"[]\"],\n\t\t\t\"&\",\n\t\t\t[{ a: \"string\" }]\n\t\t])\n\n\t\tconst Expected = type([{ a: \"string\", b: \"boolean\" }])\n\t\tattest<typeof Expected>(TupleAndArray)\n\n\t\tattest<typeof Expected>(ArrayAndTuple)\n\n\t\tattest(TupleAndArray.json).equals(Expected.json)\n\t\tattest(ArrayAndTuple.json).equals(Expected.json)\n\t})\n\n\tit(\"variadic and tuple\", () => {\n\t\tconst B = type([{ b: \"boolean\" }, \"[]\"])\n\t\tconst T = type([{ a: \"string\" }, \"...\", B]).and([\n\t\t\t{ c: \"number\" },\n\t\t\t{ d: \"Date\" }\n\t\t])\n\t\tconst Expected = type([\n\t\t\t{ a: \"string\", c: \"number\" },\n\t\t\t{ b: \"boolean\", d: \"Date\" }\n\t\t])\n\t\tattest(T.json).equals(Expected.json)\n\t})\n\n\tit(\"variadic and array\", () => {\n\t\tconst B = type({ b: \"boolean\" }, \"[]\")\n\t\tconst T = type([{ a: \"string\" }, \"...\", B]).and([{ c: \"number\" }, \"[]\"])\n\t\tconst Expected = type([\n\t\t\t{ a: \"string\", c: \"number\" },\n\t\t\t\"...\",\n\t\t\t[{ b: \"boolean\", c: \"number\" }, \"[]\"]\n\t\t])\n\t\tattest<typeof Expected.infer>(T.infer)\n\t\tattest(T.json).equals(Expected.json)\n\t})\n\n\t// based on the equivalent type-level test from @ark/util\n\tit(\"kitchen sink\", () => {\n\t\tconst L = type([\n\t\t\t{ a: \"0\" },\n\t\t\t[{ b: \"1\" }, \"?\"],\n\t\t\t[{ c: \"2\" }, \"?\"],\n\t\t\t\"...\",\n\t\t\t[{ d: \"3\" }, \"[]\"]\n\t\t])\n\t\tconst R = type([\n\t\t\t[{ e: \"4\" }, \"?\"],\n\t\t\t[{ f: \"5\" }, \"?\"],\n\t\t\t\"...\",\n\t\t\t[{ g: \"6\" }, \"[]\"]\n\t\t])\n\t\tconst T = L.and(R)\n\n\t\tconst Expected = type([\n\t\t\t{ a: \"0\", e: \"4\" },\n\t\t\t[{ b: \"1\", f: \"5\" }, \"?\"],\n\t\t\t[{ c: \"2\", g: \"6\" }, \"?\"],\n\t\t\t\"...\",\n\t\t\t[{ d: \"3\", g: \"6\" }, \"[]\"]\n\t\t])\n\n\t\tattest(T.expression).snap(\n\t\t\t\"[{ a: 0, e: 4 }, { b: 1, f: 5 }?, { c: 2, g: 6 }?, ...{ d: 3, g: 6 }[]]\"\n\t\t)\n\n\t\tattest<typeof Expected>(T)\n\t\tattest(T.expression).equals(Expected.expression)\n\t})\n\n\tit(\"prefix and postfix\", () => {\n\t\tconst L = type([\"...\", [{ a: \"0\" }, \"[]\"], { b: \"0\" }, { c: \"0\" }])\n\t\tconst R = type([{ x: \"0\" }, { y: \"0\" }, \"...\", [{ z: \"0\" }, \"[]\"]])\n\n\t\tconst Expected = type([\n\t\t\t{ a: \"0\", x: \"0\" },\n\t\t\t{ a: \"0\", y: \"0\" },\n\t\t\t\"...\",\n\t\t\t[{ a: \"0\", z: \"0\" }, \"[]\"],\n\t\t\t{ b: \"0\", z: \"0\" },\n\t\t\t{ c: \"0\", z: \"0\" }\n\t\t])\n\t\t\t.or([\n\t\t\t\t{ a: \"0\", x: \"0\" },\n\t\t\t\t{ b: \"0\", y: \"0\" },\n\t\t\t\t{ c: \"0\", z: \"0\" }\n\t\t\t])\n\t\t\t.or([\n\t\t\t\t{ b: \"0\", x: \"0\" },\n\t\t\t\t{ c: \"0\", y: \"0\" }\n\t\t\t])\n\n\t\tconst LrResult = L.and(R)\n\t\tattest(LrResult.json).snap(Expected.json)\n\t\tconst RlResult = R.and(L)\n\t\tattest(RlResult.json).snap(Expected.json)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/arrays/nonVariadicTuple.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"empty\", () => {\n\t\tconst T = type([])\n\t\tattest<[]>(T.infer)\n\t\tattest(T.expression).snap(\"[]\")\n\t\tattest(T.json).snap({ proto: \"Array\", exactLength: 0 })\n\t\tattest(T([])).equals([])\n\t\tattest(T([1]).toString()).snap(\"must be exactly length 0 (was 1)\")\n\t})\n\n\tit(\"shallow\", () => {\n\t\tconst T = type([\"string\", \"number\"])\n\t\tattest<[string, number]>(T.infer)\n\t\tattest(T.allows([\"\", 0])).equals(true)\n\t\tattest(T([\"\", 0])).snap([\"\", 0])\n\t\tattest(T.allows([true, 0])).equals(false)\n\t\tattest(T([true, 0]).toString()).snap(\n\t\t\t\"value at [0] must be a string (was boolean)\"\n\t\t)\n\t\tattest(T.allows([0, false])).equals(false)\n\t\tattest(T([0, false]).toString())\n\t\t\t.snap(`value at [0] must be a string (was a number)\nvalue at [1] must be a number (was boolean)`)\n\t\t// too short\n\t\tattest(T.allows([\"\"])).equals(false)\n\t\tattest(T([\"\"]).toString()).snap(\"must be exactly length 2 (was 1)\")\n\t\t// too long\n\t\tattest(T.allows([\"\", 0, 1])).equals(false)\n\t\tattest(T([\"\", 0, 1]).toString()).snap(\"must be exactly length 2 (was 3)\")\n\t\t// non-array\n\t\tattest(\n\t\t\tT.allows({\n\t\t\t\tlength: 2,\n\t\t\t\t0: \"\",\n\t\t\t\t1: 0\n\t\t\t})\n\t\t).equals(false)\n\t\tattest(\n\t\t\tT({\n\t\t\t\tlength: 2,\n\t\t\t\t0: \"\",\n\t\t\t\t1: 0\n\t\t\t}).toString()\n\t\t).snap(\"must be an array (was object)\")\n\t})\n\n\tit(\"nested\", () => {\n\t\tconst T = type([[\"string\", \"number\"], [{ a: \"bigint\", b: [\"null\"] }]])\n\t\tattest<\n\t\t\t[\n\t\t\t\t[string, number],\n\t\t\t\t[\n\t\t\t\t\t{\n\t\t\t\t\t\ta: bigint\n\t\t\t\t\t\tb: [null]\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t]\n\t\t>(T.infer)\n\t\tconst valid: typeof T.infer = [[\"\", 0], [{ a: 0n, b: [null] }]]\n\t\tattest(T.allows(valid)).equals(true)\n\t\tattest(T(valid)).equals(valid)\n\t\tconst invalid = [[\"\", 0], [{ a: 0n, b: [undefined] }]]\n\t\tattest(T.allows(invalid)).equals(false)\n\t\tattest(T(invalid).toString()).snap(\n\t\t\t\"value at [1][0].b[0] must be null (was undefined)\"\n\t\t)\n\t})\n\n\tit(\"optional tuple\", () => {\n\t\tconst T = type([[\"string\", \"?\"]])\n\t\tattest<[string?]>(T.infer)\n\t\tattest(T([])).equals([])\n\t\tattest(T([\"foo\"])).equals([\"foo\"])\n\t\tattest(T([5]).toString()).snap(\n\t\t\t\"value at [0] must be a string (was a number)\"\n\t\t)\n\t\tattest(T([\"foo\", \"bar\"]).toString()).snap(\n\t\t\t\"must be at most length 1 (was 2)\"\n\t\t)\n\t})\n\n\tit(\"optional string-embedded tuple\", () => {\n\t\tconst T = type([\"string?\"])\n\n\t\tconst Expected = type([[\"string\", \"?\"]])\n\t\tattest<typeof Expected>(T)\n\t\tattest(T.expression).equals(Expected.expression)\n\t})\n\n\tit(\"optional object tuple\", () => {\n\t\tconst T = type([[{ foo: \"string\" }, \"?\"], \"string?\"])\n\t\tattest<\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\tfoo: string\n\t\t\t\t}?,\n\t\t\t\tstring?\n\t\t\t]\n\t\t>(T.t)\n\t\tattest(T.expression).snap(\"[{ foo: string }?, string?]\")\n\t})\n\n\tit(\"optional nested object tuple\", () => {\n\t\tconst T = type([[[{ foo: \"string\" }, \"?\"]], [\"string\", \"?\"]])\n\t\tattest<\n\t\t\t[\n\t\t\t\t[\n\t\t\t\t\t{\n\t\t\t\t\t\tfoo: string\n\t\t\t\t\t}?\n\t\t\t\t],\n\t\t\t\tstring?\n\t\t\t]\n\t\t>(T.t)\n\t\tattest(T.expression).snap(\"[[{ foo: string }?], string?]\")\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/arrays/variadicTuple.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { postfixAfterOptionalOrDefaultableMessage } from \"@ark/schema\"\nimport { scope, type } from \"arktype\"\nimport {\n\tmultipleVariadicMesage,\n\toptionalOrDefaultableAfterVariadicMessage,\n\twriteNonArraySpreadMessage\n} from \"arktype/internal/parser/tupleLiteral.ts\"\n\ncontextualize(() => {\n\tit(\"spreads simple arrays\", () => {\n\t\tconst WellRested = type([\"string\", \"...\", \"number[]\"])\n\t\tattest<[string, ...number[]]>(WellRested.infer)\n\t\tattest(WellRested([\"foo\"])).equals([\"foo\"])\n\t\tattest(WellRested([\"foo\", 1, 2])).equals([\"foo\", 1, 2])\n\t})\n\n\tit(\"spreads array expressions\", () => {\n\t\tconst GreatSpread = type([\"0\", \"...\", \"(Date|RegExp)[]\"])\n\t\tattest<[0, ...(RegExp | Date)[]]>(GreatSpread.infer)\n\t})\n\n\tit(\"distributes spread unions\", () => {\n\t\tconst T = type([\"1\", \"...\", \"(Date[] | RegExp[])\"])\n\t\tattest<[1, ...(Date[] | RegExp[])]>(T.infer)\n\t\tconst Expected = type([\"1\", \"...\", \"Date[]\"]).or([\"1\", \"...\", \"RegExp[]\"])\n\t\tattest(T.json).equals(Expected.json)\n\t})\n\n\tit(\"distributes spread union tuples\", () => {\n\t\tconst counting = [\"2\", \"3\", \"4\"] as const\n\t\tconst fibbing = [\"1\", \"2\", \"3\", \"5\", \"8\"] as const\n\t\tconst CountOrFib = type(counting, \"|\", fibbing)\n\t\tattest<[2, 3, 4] | [1, 2, 3, 5, 8]>(CountOrFib.infer)\n\t\tconst T = type([\"1\", \"...\", CountOrFib])\n\t\tattest<[1, 2, 3, 4] | [1, 1, 2, 3, 5, 8]>(T.infer)\n\t\tconst Expected = type([\"1\", ...counting]).or([\"1\", ...fibbing])\n\t\tattest(T.json).equals(Expected.json)\n\t})\n\n\tit(\"allows array keyword\", () => {\n\t\tconst types = scope({\n\t\t\tmyArrayKeyword: \"boolean[]\",\n\t\t\tmyVariadicKeyword: [\"string\", \"...\", \"myArrayKeyword\"]\n\t\t}).export()\n\t\tattest<[string, ...boolean[]]>(types.myVariadicKeyword.infer)\n\t})\n\n\tit(\"errors on non-array\", () => {\n\t\tattest(() =>\n\t\t\t// @ts-expect-error\n\t\t\ttype([\"number\", \"...\", \"string\"])\n\t\t).throwsAndHasTypeError(writeNonArraySpreadMessage(\"string\"))\n\t})\n\n\tit(\"allows multiple fixed spreads\", () => {\n\t\tconst T = type([\n\t\t\t\"string\",\n\t\t\t\"...\",\n\t\t\t\"number[]\",\n\t\t\t\"...\",\n\t\t\t[\"boolean\", \"bigint\"],\n\t\t\t\"...\",\n\t\t\t[\"symbol\"]\n\t\t])\n\t\tconst Expected = type([\n\t\t\t\"string\",\n\t\t\t\"...\",\n\t\t\t\"number[]\",\n\t\t\t\"boolean\",\n\t\t\t\"bigint\",\n\t\t\t\"symbol\"\n\t\t])\n\t\tattest<[string, ...number[], boolean, bigint, symbol]>(T.infer)\n\t\tattest<typeof Expected.infer>(T.infer)\n\t\tattest(T.json).equals(Expected.json)\n\t})\n\n\tit(\"errors on multiple variadic\", () => {\n\t\tattest(() =>\n\t\t\t// @ts-expect-error\n\t\t\ttype([\"...\", \"string[]\", \"...\", \"number[]\"])\n\t\t).throwsAndHasTypeError(multipleVariadicMesage)\n\t})\n\n\tit(\"error on optional post-variadic in spread\", () => {\n\t\t// no type error yet, ideally would have one if tuple\n\t\t// parsing were more precise for nested spread tuples\n\t\tattest(() => type([\"...\", \"string[]\", \"...\", [\"string?\"]])).throws(\n\t\t\toptionalOrDefaultableAfterVariadicMessage\n\t\t)\n\t})\n\n\tit(\"errors on postfix following optional\", () => {\n\t\tattest(() =>\n\t\t\t// @ts-expect-error\n\t\t\ttype([\"number?\", \"...\", \"boolean[]\", \"symbol\"])\n\t\t).throwsAndHasTypeError(postfixAfterOptionalOrDefaultableMessage)\n\t})\n\n\tit(\"errors on postfix following defaultable\", () => {\n\t\tattest(() =>\n\t\t\t// @ts-expect-error\n\t\t\ttype([\"number = 0\", \"...\", \"boolean[]\", \"symbol\"])\n\t\t).throwsAndHasTypeError(postfixAfterOptionalOrDefaultableMessage)\n\t})\n\n\tit(\"doesn't mistake a string literal containing '=' for defaultable\", () => {\n\t\tconst T = type([\"'='\", \"number\"])\n\n\t\tattest<[\"=\", number]>(T.t)\n\t\tattest(T.infer).type.toString.snap(`[\"=\", number]`)\n\t\tattest(T.expression).snap('[\"=\", number]')\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/badDefinitionType.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { type } from \"arktype\"\nimport { writeBadDefinitionTypeMessage } from \"arktype/internal/parser/definition.ts\"\n\ncontextualize(() => {\n\tit(\"undefined\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type({ bad: undefined })).throwsAndHasTypeError(\n\t\t\twriteBadDefinitionTypeMessage(\"undefined\")\n\t\t)\n\t})\n\n\tit(\"null\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type({ bad: null })).throwsAndHasTypeError(\n\t\t\twriteBadDefinitionTypeMessage(\"null\")\n\t\t)\n\t})\n\n\tit(\"boolean\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type({ bad: true })).throwsAndHasTypeError(\n\t\t\twriteBadDefinitionTypeMessage(\"boolean\")\n\t\t)\n\t})\n\n\tit(\"number\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type({ bad: 5 })).throwsAndHasTypeError(\n\t\t\twriteBadDefinitionTypeMessage(\"number\")\n\t\t)\n\t})\n\n\tit(\"bigint\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type({ bad: 99999n })).throwsAndHasTypeError(\n\t\t\twriteBadDefinitionTypeMessage(\"bigint\")\n\t\t)\n\t})\n\n\tit(\"symbol\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type({ bad: Symbol() })).throwsAndHasTypeError(\n\t\t\twriteBadDefinitionTypeMessage(\"symbol\")\n\t\t)\n\t})\n\n\tit(\"any\", () => {\n\t\t// doesn't error, so this test is just to ensure it doesn't infinitely recurse\n\t\tconst T = type({ bad: {} as any })\n\t\tattest<{ bad: any }>(T.infer)\n\t})\n\n\tit(\"never\", () => {\n\t\t// can't error\n\t\tconst T = type({ bad: {} as never })\n\t\tattest<{ bad: never }>(T.infer)\n\t})\n\n\tit(\"unknown\", () => {\n\t\t// @ts-expect-error just results in base completions, so we just check there's an error\n\t\tattest(() => type({ bad: {} as unknown })).type.errors(\"\")\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/basis.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { writeUnsatisfiableExpressionError } from \"@ark/schema\"\nimport { type } from \"arktype\"\n\ncontextualize(() => {\n\tdescribe(\"intersections\", () => {\n\t\tit(\"class & literal\", () => {\n\t\t\tconst a = [0]\n\t\t\tconst Literal = type(\"===\", a)\n\t\t\tconst Cls = type(\"instanceof\", Array)\n\t\t\tconst lr = Literal.and(Cls)\n\t\t\tattest<number[]>(lr.infer)\n\t\t\tattest(lr.json).equals(Literal.json)\n\t\t\tconst rl = Cls.and(Literal)\n\t\t\tattest<number[]>(rl.infer)\n\t\t\tattest(rl.json).equals(Literal.json)\n\t\t})\n\n\t\tit(\"unsatisfiable class & literal\", () => {\n\t\t\tconst a = [0]\n\t\t\tconst Literal = type(\"===\", a)\n\t\t\tconst Cls = type(\"instanceof\", Date)\n\t\t\tattest(() => Literal.and(Cls)).throws(\n\t\t\t\twriteUnsatisfiableExpressionError(\"\")\n\t\t\t)\n\t\t\tattest(() => Cls.and(Literal)).throws(\n\t\t\t\twriteUnsatisfiableExpressionError(\"\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"domain & literal\", () => {\n\t\t\tconst Literal = type(\"'foo'\")\n\t\t\tconst Domain = type(\"string\")\n\t\t\tattest(Literal.and(Domain).json).equals(Literal.json)\n\t\t\tattest(Domain.and(Literal).json).equals(Literal.json)\n\t\t})\n\n\t\tit(\"unsatisfiable domain & literal\", () => {\n\t\t\tconst Literal = type(\"'foo'\")\n\t\t\tconst Domain = type(\"number\")\n\t\t\tattest(() => Literal.and(Domain)).throws(\n\t\t\t\twriteUnsatisfiableExpressionError(\"\")\n\t\t\t)\n\t\t\tattest(() => Domain.and(Literal)).throws(\n\t\t\t\twriteUnsatisfiableExpressionError(\"\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"domain & class\", () => {\n\t\t\tconst Domain = type(\"object\")\n\t\t\tconst Cls = type(\"instanceof\", Date)\n\t\t\tattest(Domain.and(Cls).json).equals(Cls.json)\n\t\t\tattest(Cls.and(Domain).json).equals(Cls.json)\n\t\t})\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/brand.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport type { Brand, Json } from \"@ark/util\"\nimport { type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"fluent\", () => {\n\t\tconst T = type(\"string\").brand(\"foo\")\n\t\tattest(T.t).type.toString.snap('Brand<string, \"foo\">')\n\t\tattest<Brand<string, \"foo\">>(T.infer)\n\t\tattest<string>(T.inferIn)\n\n\t\t// no effect at runtime\n\t\tattest(T.expression).equals(\"string\")\n\n\t\tconst out = T(\"moo\")\n\t\tattest<Brand<string, \"foo\"> | type.errors>(out)\n\t})\n\n\tit(\"string\", () => {\n\t\tconst T = type(\"number#cool\")\n\t\tattest(T.t).type.toString.snap('Brand<number, \"cool\">')\n\t\tattest<Brand<number, \"cool\">>(T.infer)\n\t\tattest<number>(T.inferIn)\n\n\t\tattest(T.expression).equals(\"number\")\n\n\t\tconst out = T(5)\n\t\tattest<Brand<number, \"cool\"> | type.errors>(out)\n\t})\n\n\tit(\"in object\", () => {\n\t\tconst T = type({\n\t\t\tfoo: \"string#foo\",\n\t\t\tbar: \"string.json.parse#json\"\n\t\t})\n\n\t\tattest(T.t).type.toString.snap(`{\n\tfoo: Brand<string, \"foo\">\n\tbar: (In: string) => To<Brand<Json, \"json\">>\n}`)\n\t\tattest<{\n\t\t\tfoo: Brand<string, \"foo\">\n\t\t\tbar: Brand<Json, \"json\">\n\t\t}>(T.infer)\n\t\tattest<{\n\t\t\tfoo: string\n\t\t\tbar: string\n\t\t}>(T.inferIn)\n\t})\n\n\tit(\"in union\", () => {\n\t\tconst T = type(\"string#foo | boolean\")\n\n\t\tattest(T.t).type.toString.snap(`boolean | Brand<string, \"foo\">`)\n\t\tattest<boolean | Brand<string, \"foo\">>(T.infer)\n\t\tattest<boolean | string>(T.inferIn)\n\t})\n\n\tit(\"from morph\", () => {\n\t\tconst Fluent = type(\"string.numeric.parse\").brand(\"num\")\n\n\t\tattest(Fluent.t).type.toString.snap(\n\t\t\t'(In: string) => To<Brand<number, \"num\">>'\n\t\t)\n\t\tattest<Brand<number, \"num\">>(Fluent.infer)\n\t\tattest<string>(Fluent.inferIn)\n\n\t\tconst String = type(\"string.numeric.parse#num\")\n\n\t\tattest(String.json).equals(Fluent.json)\n\t\tattest<typeof Fluent.t>(String.t)\n\t})\n\n\tit(\"docs example\", () => {\n\t\tconst Fluent = type.number.divisibleBy(2).brand(\"even\")\n\n\t\tattest<Brand<number, \"even\">>(Fluent.t)\n\t\tattest<number>(Fluent.inferIn)\n\t\tattest<Brand<number, \"even\">>(Fluent.infer)\n\n\t\tconst String = type(\"(number % 2)#even\")\n\t\tattest<typeof Fluent>(String).is(Fluent)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/cast.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport type { Constructor } from \"@ark/util\"\nimport { type, type Type } from \"arktype\"\n\ncontextualize(() => {\n\tdescribe(\"type.cast\", () => {\n\t\tit(\"primitive\", () => {\n\t\t\tconst Foo = type(\"string\" as type.cast<\"foo\">).t\n\t\t\tattest<\"foo\">(Foo)\n\t\t})\n\n\t\tit(\"object\", () => {\n\t\t\t// definitions that are cast can't be validated\n\t\t\tattest<{ a: \"foo\" }>(type({ a: \"string\" } as type.cast<{ a: \"foo\" }>).t)\n\t\t})\n\n\t\tit(\"primitive to object\", () => {\n\t\t\tattest<{ a: \"foo\" }>(type(\"string\" as type.cast<{ a: \"foo\" }>).t)\n\t\t})\n\n\t\tit(\"object to primitive\", () => {\n\t\t\tattest<\"foo\">(type({ a: \"string\" } as type.cast<\"foo\">).t)\n\t\t})\n\n\t\tit(\"infer function\", () => {\n\t\t\ttype F = () => boolean\n\t\t\tconst Constructable = type({} as type.cast<F>)\n\t\t\tattest<F>(Constructable.t)\n\t\t\tattest<F>(Constructable.infer)\n\t\t\tattest<F>(Constructable.in.infer)\n\t\t})\n\n\t\tit(\"infer constructable\", () => {\n\t\t\tconst Constructable = type({} as type.cast<Constructor>)\n\t\t\tattest<Constructor>(Constructable.t)\n\t\t\tattest<Constructor>(Constructable.infer)\n\t\t\tattest<Constructor>(Constructable.in.infer)\n\t\t})\n\n\t\tit(\"undefined\", () => {\n\t\t\tconst Foo = type(\"string\" as type.cast<\"foo\">).t\n\t\t\tattest<\"foo\">(Foo)\n\t\t})\n\t})\n\n\tdescribe(\"as\", () => {\n\t\tit(\"valid cast\", () => {\n\t\t\tconst From = type(\"/^foo.*$/\")\n\t\t\tconst T = From.as<`foo${string}`>()\n\n\t\t\tattest<`foo${string}`>(T.t)\n\t\t\tattest(T === From).equals(true)\n\t\t})\n\n\t\tit(\"cast to any\", () => {\n\t\t\tconst T = type(\"unknown\").as<any>()\n\t\t\tattest<any>(T.t)\n\t\t})\n\n\t\tit(\"cast to never\", () => {\n\t\t\tconst T = type(\"unknown\").as<never>()\n\t\t\tattest<never>(T.t)\n\t\t})\n\n\t\tit(\"missing type param\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"string\").as()).type.errors.snap(\n\t\t\t\t\"Expected 1 arguments, but got 0.\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"missing type param with arg\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"string\").as(\"foo\")).type.errors(\n\t\t\t\t\"as requires an explicit type parameter like myType.as<t>()\"\n\t\t\t)\n\t\t})\n\t})\n\n\tdescribe(\"readonly \", () => {\n\t\tit(\"object\", () => {\n\t\t\tconst From = type({ foo: \"string\", bar: \"number\" })\n\t\t\tconst T = From.readonly()\n\n\t\t\tattest<\n\t\t\t\tType<{\n\t\t\t\t\treadonly foo: string\n\t\t\t\t\treadonly bar: number\n\t\t\t\t}>\n\t\t\t>(T)\n\t\t\tattest(T === From).equals(true)\n\t\t})\n\n\t\tit(\"array\", () => {\n\t\t\tconst From = type(\"string\").array()\n\t\t\tconst T = From.readonly()\n\n\t\t\tattest<Type<readonly string[]>>(T)\n\t\t\tattest(T === From).equals(true)\n\t\t})\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/clone.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"preserves the original references if no morphs are present\", () => {\n\t\tconst T = type({\n\t\t\tfoo: \"string\"\n\t\t})\n\n\t\tconst original = { foo: \"bar\" }\n\n\t\tconst out = T(original)\n\t\tattest(out).is(original)\n\t})\n\n\tit(\"clones by default before morphing\", () => {\n\t\tconst T = type({\n\t\t\tfoo: \"string.trim\"\n\t\t})\n\n\t\tconst original = { foo: \"  bar  \" }\n\n\t\tconst out = T(original)\n\n\t\tattest(out).snap({ foo: \"bar\" })\n\t\tattest(original).snap({ foo: \"  bar  \" })\n\t})\n\n\tit(\"default clone implementation preserves prototypes\", () => {\n\t\tconst T = type([\"Date\", \"=>\", d => d.toISOString()])\n\t\tattest(T.from(new Date(2000, 1))).equals(\"2000-02-01T05:00:00.000Z\")\n\t})\n\n\tit(\"can be configured to mutate\", () => {\n\t\tconst types = type.module(\n\t\t\t{\n\t\t\t\ttrimAndMutate: { foo: \"string.trim\" }\n\t\t\t},\n\t\t\t{ clone: false }\n\t\t)\n\n\t\tconst original = { foo: \"  bar  \" }\n\n\t\tconst out = types.trimAndMutate(original)\n\n\t\tattest(out).snap({ foo: \"bar\" })\n\t\tattest(out).is(original)\n\t})\n\n\tit(\"can be configured to mutate\", () => {\n\t\tconst types = type.module(\n\t\t\t{\n\t\t\t\ttrimAndMutate: { foo: \"string.trim\" }\n\t\t\t},\n\t\t\t{ clone: false }\n\t\t)\n\n\t\tconst original = { foo: \"  bar  \" }\n\n\t\tconst out = types.trimAndMutate(original)\n\n\t\tattest(out).snap({ foo: \"bar\" })\n\t\tattest(out).is(original)\n\t})\n\n\tit(\"can be configured to use a custom clone implementation\", () => {\n\t\tconst types = type.module(\n\t\t\t{\n\t\t\t\ttrimAndMutate: { foo: \"string.trim\" }\n\t\t\t},\n\t\t\t{ clone: original => ({ ...original, customCloned: true }) }\n\t\t)\n\n\t\tconst out = types.trimAndMutate({ foo: \"  bar  \" })\n\n\t\tattest(out).unknown.snap({ foo: \"bar\", customCloned: true })\n\t})\n\n\t// process.env is an exotic object- ensure it is correctly cloned\n\t// https://discord.com/channels/957797212103016458/1116551844710330458\n\tit(\"can clone process.env\", () => {\n\t\tconst Env = type({\n\t\t\t\"+\": \"delete\",\n\t\t\tTZ: \"'America/New_York'\"\n\t\t})\n\n\t\tconst originalEnv = { ...process.env }\n\n\t\tconst vars = Env(process.env)\n\n\t\tattest(vars).snap({ TZ: \"America/New_York\" })\n\t\t// if process.env is not spread here, the assertion fails apparently\n\t\t// because it's an exotic object? seems like a Node bug\n\t\tattest({ ...process.env }).equals(originalEnv)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/completions.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { scope, type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"completes standalone keyword\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"s\")).completions({ s: [\"string\", \"symbol\"] })\n\t})\n\n\tit(\"completes within objects\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type({ b: \"b\" })).completions({\n\t\t\tb: [\"bigint\", \"boolean\"]\n\t\t})\n\t})\n\n\tit(\"completes within expressions\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"string|n\")).completions({\n\t\t\t\"string|n\": [\"string|never\", \"string|null\", \"string|number\"]\n\t\t})\n\t})\n\n\tit(\"completes within expressions in objects\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type({ key: \"number | b\" })).completions({\n\t\t\t\"number | b\": [\"number | bigint\", \"number | boolean\"]\n\t\t})\n\t})\n\n\tit(\"completes user-defined aliases\", () => {\n\t\tconst $ = scope({\n\t\t\tover9000: \"number>9000\",\n\t\t\tmyArk: {\n\t\t\t\tkind: \"'type'\",\n\t\t\t\tbuoyancy: \"null\",\n\t\t\t\tdxLevel: \"over9000\"\n\t\t\t},\n\t\t\tnoahsArk: {\n\t\t\t\tkind: \"'boat'\",\n\t\t\t\tbuoyancy: \"over9000\",\n\t\t\t\tdxLevel: \"null\"\n\t\t\t}\n\t\t})\n\t\t// this could also have been defined with completions directly in scope!\n\t\tattest(() =>\n\t\t\t$.type({\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttype: \"my\",\n\t\t\t\t// @ts-expect-error\n\t\t\t\tboat: \"noah\"\n\t\t\t})\n\t\t).completions({ my: [\"myArk\"], noah: [\"noahsArk\"] })\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/config.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport {\n\t$ark,\n\trootSchema,\n\tschemaScope,\n\ttype ArkSchemaConfig\n} from \"@ark/schema\"\nimport { configure, scope, type } from \"arktype\"\n\nconst withConfig = (config: ArkSchemaConfig, fn: () => void) => {\n\tconst originalConfig = $ark.config\n\tconst originalResolvedConfig = $ark.resolvedConfig\n\tconfigure(config)\n\tfn()\n\t$ark.config = originalConfig\n\t$ark.resolvedConfig = originalResolvedConfig\n}\n\ncontextualize(() => {\n\tit(\"tuple expression\", () => {\n\t\tconst description = \"a series of characters\"\n\t\tconst types = scope({\n\t\t\ta: [\"string\", \"@\", description],\n\t\t\tb: {\n\t\t\t\ta: \"a\"\n\t\t\t}\n\t\t}).export()\n\t\tattest<string>(types.a.infer)\n\t\tattest(types.a.description).equals(description)\n\t\tattest(types.a(1).toString()).snap(\n\t\t\t\"must be a series of characters (was a number)\"\n\t\t)\n\t\tattest<{ a: string }>(types.b.infer)\n\t\tattest(types.b({ a: true }).toString()).snap(\n\t\t\t\"a must be a series of characters (was boolean)\"\n\t\t)\n\t})\n\n\tit(\"tuple expression at path\", () => {\n\t\tconst description = \"the number of dimensions in the monster group\"\n\t\tconst T = type({\n\t\t\tmonster: [\"196883\", \"@\", description]\n\t\t})\n\t\tattest<{ monster: 196883 }>(T.infer)\n\t\tattest(T.description).snap(\n\t\t\t\"{ monster: the number of dimensions in the monster group }\"\n\t\t)\n\t\tattest(T({ monster: 196882 }).toString()).snap(\n\t\t\t\"monster must be the number of dimensions in the monster group (was 196882)\"\n\t\t)\n\t})\n\n\tit(\"anonymous type config\", () => {\n\t\tconst T = type(type(\"true\", \"@\", { description: \"unfalse\" }))\n\t\tattest<true>(T.infer)\n\t\tattest(T(false).toString()).snap(\"must be unfalse (was false)\")\n\t})\n\n\tit(\"anonymous type config at path\", () => {\n\t\tconst Unfalse = type(\"true\", \"@\", { description: \"unfalse\" })\n\t\tconst T = type({ myKey: Unfalse })\n\t\tattest(T({ myKey: \"500\" }).toString()).snap(\n\t\t\t`myKey must be unfalse (was \"500\")`\n\t\t)\n\t})\n\n\tit(\"anonymous type thunk\", () => {\n\t\tconst T = type(() => type(\"false\", \"@\", { description: \"untrue\" }))\n\t\tattest<false>(T.infer)\n\t\tattest(T.description).snap(\"untrue\")\n\t})\n\n\tit(\"anonymous type thunk at path\", () => {\n\t\tconst T = type({\n\t\t\tmyKey: () => type(\"false\", \"@\", { description: \"untrue\" })\n\t\t})\n\t\tattest<{ myKey: false }>(T.infer)\n\t\tattest(T({ myKey: true }).toString()).snap(\n\t\t\t\"myKey must be untrue (was true)\"\n\t\t)\n\t})\n\n\tit(\"shallow node writer config\", () => {\n\t\tconst CustomOne = type(\"1\", \"@\", {\n\t\t\texpected: ctx => `custom expected ${ctx.description}`,\n\t\t\tactual: data => `custom actual ${data}`,\n\t\t\tproblem: ctx => `custom problem ${ctx.expected} ${ctx.actual}`,\n\t\t\tmessage: ctx => `custom message ${ctx.problem}`\n\t\t})\n\t\tattest<1>(CustomOne.infer)\n\t\tattest(CustomOne(2).toString()).snap(\n\t\t\t\"custom message custom problem custom expected 1 custom actual 2\"\n\t\t)\n\t})\n\n\tit(\"string node configs\", () => {\n\t\tconst CustomTwo = type(\"2\", \"@\", {\n\t\t\texpected: \"2\",\n\t\t\tactual: \"something else\",\n\t\t\tproblem: \"was terrible\",\n\t\t\tmessage: \"root was terrible\"\n\t\t})\n\t\tattest<2>(CustomTwo.infer)\n\t\tattest(CustomTwo(1).toString()).snap(\"root was terrible\")\n\t})\n\n\tit(\"node writer config works on nested constraint\", () => {\n\t\tconst CustomEven = type(\"number % 2\", \"@\", {\n\t\t\texpected: ctx => `custom expected ${ctx.description}`,\n\t\t\tactual: data => `custom actual ${data}`,\n\t\t\tproblem: ctx => `custom problem ${ctx.expected} ${ctx.actual}`,\n\t\t\tmessage: ctx => `custom message ${ctx.problem}`\n\t\t})\n\t\tattest<number>(CustomEven.infer)\n\t\tattest(CustomEven(3).toString()).snap(\n\t\t\t\"custom message custom problem custom expected even custom actual 3\"\n\t\t)\n\t})\n\n\tit(\"applies config to shallow descendants\", () => {\n\t\tconst User = type({\n\t\t\tname: \"string\",\n\t\t\tage: \"number\"\n\t\t}).describe(\"a valid user\")\n\n\t\t// should give the original error at a path\n\t\tattest(\n\t\t\tUser({\n\t\t\t\tname: \"david\",\n\t\t\t\tage: true\n\t\t\t}).toString()\n\t\t).snap(\"age must be a number (was boolean)\")\n\n\t\t// should give the shallow custom error\n\t\tattest(User(null).toString()).snap(\"must be a valid user (was null)\")\n\t})\n\n\tit(\"jitless\", () => {\n\t\tconst types = scope(\n\t\t\t{\n\t\t\t\tfast: \"false\"\n\t\t\t},\n\t\t\t{ jitless: true }\n\t\t).export()\n\n\t\tattest(types.fast.precompilation).equals(undefined)\n\t})\n\n\tit(\"jit by default\", () => {\n\t\tconst T = type(\"/^foo.*$/\")\n\t\tattest(T.precompilation).satisfies(\"string\")\n\t})\n\n\tit(\"built-in keywords jit by default\", () => {\n\t\tconst T = type(\"string\")\n\t\tattest(T.precompilation).satisfies(\"string\")\n\n\t\tconst Sub = type(\"string.normalize.NFC.preformatted\")\n\t\tattest(Sub.precompilation).satisfies(\"string\")\n\t})\n\n\tit(\"jit by default in scope\", () => {\n\t\tconst $ = scope({\n\t\t\tdefined: \"55\",\n\t\t\treferenced: rootSchema({ unit: 5 })\n\t\t})\n\n\t\tconst types = $.export()\n\n\t\tattest(types.defined.precompilation).satisfies(\"string\")\n\t\tattest(types.referenced.precompilation).satisfies(\"string\")\n\n\t\tattest($.type(\"defined\").precompilation).satisfies(\"string\")\n\t\tattest($.type(\"referenced\").precompilation).satisfies(\"string\")\n\t})\n\n\tit(\"jit by default in submodule\", () => {\n\t\tconst types = type.module({\n\t\t\tinner: type.module({\n\t\t\t\tfoo: \"55\"\n\t\t\t})\n\t\t})\n\t\tattest(types.inner.foo.precompilation).satisfies(\"string\")\n\t})\n\n\tit(\"numberAllowsNaN\", () => {\n\t\twithConfig({ numberAllowsNaN: true }, () => {\n\t\t\tconst { nanable } = schemaScope({\n\t\t\t\tnanable: \"number\"\n\t\t\t}).export()\n\n\t\t\tattest(nanable.allows(Number.NaN)).equals(true)\n\n\t\t\tconst { nonNanable } = type.module({\n\t\t\t\tnonNanable: \"number\"\n\t\t\t})\n\n\t\t\tattest(nonNanable.allows(Number.NaN)).equals(false)\n\t\t})\n\t})\n\n\tit(\"dateAllowsInvalid\", () => {\n\t\twithConfig({ dateAllowsInvalid: true }, () => {\n\t\t\tconst { invalidable } = schemaScope({\n\t\t\t\tinvalidable: Date\n\t\t\t}).export()\n\n\t\t\tattest(invalidable.allows(new Date(\"!\"))).equals(true)\n\n\t\t\tconst { uninvalidable } = type.module({\n\t\t\t\tuninvalidable: \"number\"\n\t\t\t})\n\n\t\t\tattest(uninvalidable.allows(new Date(\"!\"))).equals(false)\n\t\t})\n\t})\n\n\tit(\"clone\", () => {\n\t\twithConfig({ clone: false }, () => {\n\t\t\tconst { userForm } = type.module({\n\t\t\t\tuserForm: {\n\t\t\t\t\tage: \"string.numeric.parse\"\n\t\t\t\t}\n\t\t\t})\n\n\t\t\tconst formData = {\n\t\t\t\tage: \"42\"\n\t\t\t}\n\n\t\t\tconst out = userForm(formData)\n\n\t\t\t// the original object's age key is now a number\n\t\t\tattest(formData.age).unknown.equals(42)\n\t\t\tattest(formData).unknown.equals(out)\n\t\t})\n\t})\n\n\tit(\"docs actual example\", () => {\n\t\t// avoid logging \"was supersecret\" for password\n\t\tconst Password = type(\"string >= 8\", \"@\", { actual: () => \"\" })\n\n\t\tconst User = type({\n\t\t\temail: \"string.email\",\n\t\t\tpassword: Password\n\t\t})\n\n\t\tconst out = User({\n\t\t\temail: \"david@arktype.io\",\n\t\t\tpassword: \"ez123\"\n\t\t})\n\n\t\tattest(out.toString()).snap(\"password must be at least length 8\")\n\t})\n\n\tit(\"docs message example\", () => {\n\t\tconst User = type({\n\t\t\tpassword: \"string >= 8\"\n\t\t}).configure({\n\t\t\tmessage: ctx =>\n\t\t\t\t`${ctx.propString || \"(root)\"}: ${ctx.actual} isn't ${ctx.expected}`\n\t\t})\n\t\t// ArkErrors: (root): a string isn't an object\n\t\tconst out1 = User(\"ez123\")\n\t\tattest(out1.toString()).snap(\"(root): a string isn't an object\")\n\t\t// but `.configure` only applies shallowly, so the nested error isn't changed!\n\t\t// ArkErrors: password must be at least length 8 (was 5)\n\t\tconst out2 = User({ password: \"ez123\" })\n\t\tattest(out2.toString()).snap(\"password must be at least length 8 (was 5)\")\n\t})\n\n\tdescribe(\"select\", () => {\n\t\tconst Base = type({\n\t\t\tfoo: \"string\",\n\t\t\t\"bar?\": {\n\t\t\t\tnested: \"string\",\n\t\t\t\tnum: \"number\"\n\t\t\t}\n\t\t})\n\n\t\tit(\"self\", () => {\n\t\t\tconst T = Base.configure({ description: \"root-only\" }, \"self\")\n\n\t\t\tattest(T.json).snap({\n\t\t\t\trequired: [{ key: \"foo\", value: \"string\" }],\n\t\t\t\toptional: [\n\t\t\t\t\t{\n\t\t\t\t\t\tkey: \"bar\",\n\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\trequired: [\n\t\t\t\t\t\t\t\t{ key: \"nested\", value: \"string\" },\n\t\t\t\t\t\t\t\t{ key: \"num\", value: \"number\" }\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tdomain: \"object\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\tdomain: \"object\",\n\t\t\t\tmeta: \"root-only\"\n\t\t\t})\n\t\t})\n\n\t\tdescribe(\"completions\", () => {\n\t\t\t// based on completion tests at ark/schema/select.test.ts\n\t\t\tit(\"shallow completions\", () => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tattest(() => Base.configure(\"foo\", \"\")).completions({\n\t\t\t\t\t\"\": [\n\t\t\t\t\t\t\"after\",\n\t\t\t\t\t\t\"alias\",\n\t\t\t\t\t\t\"before\",\n\t\t\t\t\t\t\"child\",\n\t\t\t\t\t\t\"divisor\",\n\t\t\t\t\t\t\"domain\",\n\t\t\t\t\t\t\"exactLength\",\n\t\t\t\t\t\t\"index\",\n\t\t\t\t\t\t\"intersection\",\n\t\t\t\t\t\t\"max\",\n\t\t\t\t\t\t\"maxLength\",\n\t\t\t\t\t\t\"min\",\n\t\t\t\t\t\t\"minLength\",\n\t\t\t\t\t\t\"morph\",\n\t\t\t\t\t\t\"optional\",\n\t\t\t\t\t\t\"pattern\",\n\t\t\t\t\t\t\"predicate\",\n\t\t\t\t\t\t\"proto\",\n\t\t\t\t\t\t\"references\",\n\t\t\t\t\t\t\"required\",\n\t\t\t\t\t\t\"self\",\n\t\t\t\t\t\t\"sequence\",\n\t\t\t\t\t\t\"shallow\",\n\t\t\t\t\t\t\"structure\",\n\t\t\t\t\t\t\"union\",\n\t\t\t\t\t\t\"unit\"\n\t\t\t\t\t]\n\t\t\t\t})\n\t\t\t})\n\n\t\t\tit(\"composite key completions\", () => {\n\t\t\t\tattest(() =>\n\t\t\t\t\tBase.configure(\"foo\", {\n\t\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\t\"\": {} as any\n\t\t\t\t\t})\n\t\t\t\t).completions({ \"\": [\"boundary\", \"kind\", \"method\"] })\n\t\t\t})\n\n\t\t\tit(\"composite kind completions\", () => {\n\t\t\t\tattest(() =>\n\t\t\t\t\tBase.configure(\"foo\", {\n\t\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\tkind: \"\"\n\t\t\t\t\t})\n\t\t\t\t).completions({\n\t\t\t\t\t\"\": [\n\t\t\t\t\t\t\"after\",\n\t\t\t\t\t\t\"alias\",\n\t\t\t\t\t\t\"before\",\n\t\t\t\t\t\t\"divisor\",\n\t\t\t\t\t\t\"domain\",\n\t\t\t\t\t\t\"exactLength\",\n\t\t\t\t\t\t\"index\",\n\t\t\t\t\t\t\"intersection\",\n\t\t\t\t\t\t\"max\",\n\t\t\t\t\t\t\"maxLength\",\n\t\t\t\t\t\t\"min\",\n\t\t\t\t\t\t\"minLength\",\n\t\t\t\t\t\t\"morph\",\n\t\t\t\t\t\t\"optional\",\n\t\t\t\t\t\t\"pattern\",\n\t\t\t\t\t\t\"predicate\",\n\t\t\t\t\t\t\"proto\",\n\t\t\t\t\t\t\"required\",\n\t\t\t\t\t\t\"sequence\",\n\t\t\t\t\t\t\"structure\",\n\t\t\t\t\t\t\"union\",\n\t\t\t\t\t\t\"unit\"\n\t\t\t\t\t]\n\t\t\t\t})\n\t\t\t})\n\n\t\t\tit(\"composite boundary completions\", () => {\n\t\t\t\tattest(() =>\n\t\t\t\t\tBase.configure(\"foo\", {\n\t\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\tboundary: \"\"\n\t\t\t\t\t})\n\t\t\t\t).completions({ \"\": [\"child\", \"references\", \"self\", \"shallow\"] })\n\t\t\t})\n\n\t\t\tit(\"composite method completions\", () => {\n\t\t\t\tattest(() =>\n\t\t\t\t\tBase.configure(\"foo\", {\n\t\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\tmethod: \"\"\n\t\t\t\t\t})\n\t\t\t\t).completions({ \"\": [\"assertFilter\", \"assertFind\", \"filter\", \"find\"] })\n\t\t\t})\n\t\t})\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/cyclic.bench.ts",
    "content": "import { bench } from \"@ark/attest\"\nimport { scope, type } from \"arktype\"\nimport { cyclic10, cyclic100, cyclic500 } from \"./generated/cyclic.ts\"\n\nbench.baseline(() => type(\"never\"))\n\nbench(\n\t\"cyclic 10 intersection\",\n\t() => scope(cyclic10).type(\"user&user2\").infer\n).types([16711, \"instantiations\"])\n\nbench(\"cyclic(10)\", () => scope(cyclic10).export()).types([\n\t7287,\n\t\"instantiations\"\n])\n\nbench(\"cyclic(100)\", () => scope(cyclic100).export()).types([\n\t48975,\n\t\"instantiations\"\n])\n\nbench(\"cyclic(500)\", () => scope(cyclic500).export()).types([\n\t230903,\n\t\"instantiations\"\n])\n"
  },
  {
    "path": "ark/type/__tests__/dateLiteral.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { type } from \"arktype\"\nimport { writeInvalidDateMessage } from \"arktype/internal/parser/shift/operand/date.ts\"\n\ncontextualize(() => {\n\tit(\"base\", () => {\n\t\tconst T = type(\"d'2000/05/05'\")\n\t\tattest<Date>(T.infer)\n\t\tattest(T.allows(new Date(\"2000/05/05\"))).equals(true)\n\t\tattest(T.allows(new Date(\"2000/06/05\"))).equals(false)\n\t\tattest(T.allows(new Date(\"2000-05-05T09:00:00.000Z\"))).equals(false)\n\t})\n\n\tit(\"with punctuation\", () => {\n\t\tconst ISO = type(\"d'2000-05-05T04:00:00.000Z'\")\n\t\tattest<Date>(ISO.infer)\n\t\tattest(ISO.allows(new Date(\"2000/05/05\"))).equals(true)\n\t\tattest(ISO.allows(new Date(\"2000/07/05\"))).equals(false)\n\t})\n\n\tit(\"allows spaces\", () => {\n\t\tconst T = type(\"d' 2021  /  05  /  01  '\")\n\t\tattest(T.allows(new Date(\"2021/05/01\"))).equals(true)\n\t})\n\n\tit(\"epoch\", () => {\n\t\tconst now = new Date()\n\t\tconst T = type(`d'${now.valueOf()}'`)\n\t\tattest(T.allows(now)).equals(true)\n\t\tattest(T.allows(new Date(now.valueOf() + 1))).equals(false)\n\t})\n\n\tit(\"invalid date\", () => {\n\t\tattest(() => type(\"d'tuesday'\")).throws(writeInvalidDateMessage(\"tuesday\"))\n\t})\n\n\tit(\"morphable\", () => {\n\t\tconst T = type([\"Date\", \"=>\", d => d.toISOString()])\n\t\tattest(T.from(new Date(2000, 1))).snap(\"2000-02-01T05:00:00.000Z\")\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/declared.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { declare, type } from \"arktype\"\nimport { incompleteArrayTokenMessage } from \"arktype/internal/parser/shift/operator/operator.ts\"\n\ncontextualize(() => {\n\tit(\"shallow\", () => {\n\t\tconst shallow = declare<number>().type(\"number\")\n\t\tattest<number>(shallow.infer)\n\t\tattest(shallow.json).equals(type(\"number\").json)\n\t})\n\n\tit(\"obj\", () => {\n\t\ttype Expected = { a: string; b?: number }\n\t\tconst T = declare<Expected>().type({\n\t\t\ta: \"string\",\n\t\t\t\"b?\": \"number\"\n\t\t})\n\t\tattest<Expected>(T.infer)\n\t\t// name should be preserved\n\t\tattest(T.t).type.toString(\"Expected\")\n\t})\n\n\tit(\"syntax error\", () => {\n\t\ttype Expected = { a: string; b?: number }\n\t\tattest(() =>\n\t\t\tdeclare<Expected>().type({\n\t\t\t\t// @ts-expect-error\n\t\t\t\ta: \"string[\"\n\t\t\t})\n\t\t).throwsAndHasTypeError(incompleteArrayTokenMessage)\n\t})\n\n\tit(\"tuple\", () => {\n\t\ttype Expected = [string, number]\n\t\tconst T = declare<Expected>().type([\"string\", \"number\"])\n\t\tattest<Expected>(T.infer)\n\t})\n\n\tit(\"bad element\", () => {\n\t\tattest(\n\t\t\t// @ts-expect-error\n\t\t\tdeclare<[string, number]>().type([\"string\", \"boolean\"])\n\t\t).type.errors(`declared: number; inferred: boolean`)\n\t})\n\n\tit(\"too short\", () => {\n\t\t// @ts-expect-error\n\t\tattest(declare<[string, number]>().type([\"string\"])).type.errors(\n\t\t\t`Source has 1 element(s) but target requires 2`\n\t\t)\n\t})\n\n\tit(\"too long\", () => {\n\t\tattest(\n\t\t\t// @ts-expect-error\n\t\t\tdeclare<[string, number]>().type([\"string\", \"number\", \"number\"])\n\t\t).type.errors(`Source has 3 element(s) but target allows only 2`)\n\t})\n\n\tit(\"tuple expression\", () => {\n\t\tconst T = declare<0 | 1>().type([\"0\", \"|\", \"1\"])\n\t\tattest<0 | 1>(T.infer)\n\t})\n\n\tit(\"regexp\", () => {\n\t\tconst T = declare<string>().type(/.*/)\n\t\tattest<string>(T.t)\n\t\tattest<string>(T.infer)\n\t})\n\n\tit(\"Inferred<t>\", () => {\n\t\tconst Foo = type(\"'foo'\")\n\t\tconst T = declare<\"foo\">().type(Foo)\n\t\tattest<\"foo\">(T.infer)\n\t})\n\n\tit(\"bad tuple expression\", () => {\n\t\tattest(\n\t\t\t// @ts-expect-error\n\t\t\tdeclare<\"foo\" | \"bar\">().type([\"'foo'\", \"|\", \"'baz'\"])\n\t\t).type.errors(`declared: \"foo\" | \"bar\"; inferred: \"foo\" | \"baz\"`)\n\t})\n\n\tit(\"narrower\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => declare<string>().type(\"'foo'\")).type.errors(\n\t\t\t`declared: string; inferred: \"foo\"`\n\t\t)\n\t})\n\n\tit(\"narrower in object (from docs)\", () => {\n\t\ttype Expected = { a: string; b?: number }\n\t\tattest(() =>\n\t\t\ttype.declare<Expected>().type({\n\t\t\t\ta: \"string\",\n\t\t\t\t// @ts-expect-error\n\t\t\t\t\"b?\": \"1\"\n\t\t\t})\n\t\t).type.errors(`declared: number; inferred: 1`)\n\t})\n\n\tit(\"wider\", () => {\n\t\tattest(() =>\n\t\t\tdeclare<{ a: string }>().type({\n\t\t\t\t// @ts-expect-error\n\t\t\t\ta: \"unknown\"\n\t\t\t})\n\t\t).type.errors(`declared: string; inferred: unknown`)\n\t})\n\n\tit(\"missing key\", () => {\n\t\tattest(() =>\n\t\t\t// @ts-expect-error\n\t\t\tdeclare<{ a: string; b: number }>().type({\n\t\t\t\ta: \"string\"\n\t\t\t})\n\t\t).type.errors(\"Property 'b' is missing\")\n\t})\n\n\tit(\"missing optional key\", () => {\n\t\tattest(() =>\n\t\t\t// @ts-expect-error\n\t\t\tdeclare<{ a: string; b?: number }>().type({\n\t\t\t\ta: \"string\"\n\t\t\t})\n\t\t).type.errors(`'\"b?\"' is missing`)\n\t})\n\n\tit(\"empty object optional\", () => {\n\t\ttype Expected = { f?: string }\n\n\t\t// @ts-expect-error\n\t\tattest(() => type.declare<Expected>().type({})).type.errors(\n\t\t\t`'\"f?\"' is missing`\n\t\t)\n\t})\n\n\tit(\"undefined as required value\", () => {\n\t\ttype Expected = { f: string | undefined }\n\n\t\tconst T = declare<Expected>().type({ f: \"string | undefined\" })\n\n\t\tattest<Expected>(T.t)\n\t})\n\n\tit(\"undefined as optional value\", () => {\n\t\ttype Expected = { f?: string | undefined }\n\n\t\tconst T = declare<Expected>().type({ \"f?\": \"string | undefined\" })\n\n\t\tattest<Expected>(T.t)\n\t})\n\n\tit(\"undefined as invalid optional value\", () => {\n\t\ttype Expected = { f?: string }\n\n\t\tattest(() =>\n\t\t\t// @ts-expect-error\n\t\t\tdeclare<Expected>().type({ \"f?\": \"string | undefined\" })\n\t\t).type.errors(\"declared: string; inferred: string | undefined\")\n\t})\n\n\tit(\"extraneous key\", () => {\n\t\tattest(() =>\n\t\t\tdeclare<{ a: string }>().type({\n\t\t\t\ta: \"string\",\n\t\t\t\t// @ts-expect-error\n\t\t\t\tb: \"boolean\"\n\t\t\t})\n\t\t).type.errors(`'b' does not exist`)\n\t})\n\n\tit(\"completions\", () => {\n\t\tattest(() =>\n\t\t\tdeclare<{ a: string; b?: number }>().type({\n\t\t\t\t// @ts-expect-error\n\t\t\t\t\"\": type.unknown\n\t\t\t})\n\t\t).completions({\n\t\t\t\"\": [\"a\", \"b?\"]\n\t\t})\n\t})\n\n\tit(\"nested completions\", () => {\n\t\tattest(() =>\n\t\t\ttype\n\t\t\t\t.declare<{\n\t\t\t\t\ta: {\n\t\t\t\t\t\tnested: boolean[]\n\t\t\t\t\t}\n\t\t\t\t}>()\n\t\t\t\t.type({\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\ta: { \"\": \"boolean[]\" }\n\t\t\t\t})\n\t\t).completions({\n\t\t\t\"\": [\"nested\"]\n\t\t})\n\t})\n\n\tit(\"missing generic argument\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => declare().type({})).type.errors(\n\t\t\t\"declare<ExternalType>() requires a generic argument\"\n\t\t)\n\t})\n\n\tit(\"morph\", () => {\n\t\ttype Expected = { a: string; b?: number }\n\t\tattest(() =>\n\t\t\tdeclare<Expected>().type({\n\t\t\t\t// @ts-expect-error\n\t\t\t\ta: \"string.numeric.parse\",\n\t\t\t\t\"b?\": \"number\"\n\t\t\t})\n\t\t).type.errors(\"declared: string; inferred: (In: string) => To<number>\")\n\t})\n\n\tit(\"morph in\", () => {\n\t\ttype Expected = { a: string; b?: number }\n\t\tconst T = declare<Expected, { side: \"in\" }>().type({\n\t\t\ta: \"string.numeric.parse\",\n\t\t\t\"b?\": \"number\"\n\t\t})\n\n\t\tattest<\n\t\t\t(In: Expected) => {\n\t\t\t\ta: number\n\t\t\t\tb?: number\n\t\t\t}\n\t\t>(T.t).type.toString.snap(\"(In: Expected) => { a: number; b?: number }\")\n\t})\n\n\tit(\"morph in mismatch\", () => {\n\t\ttype Expected = { a: number; b?: number }\n\t\tattest(() =>\n\t\t\tdeclare<Expected, { side: \"in\" }>().type({\n\t\t\t\t// @ts-expect-error\n\t\t\t\ta: \"string.numeric.parse\",\n\t\t\t\t\"b?\": \"number\"\n\t\t\t})\n\t\t).type.errors(\"declared: number; inferred: string\")\n\t})\n\n\tit(\"morph out\", () => {\n\t\ttype Expected = { a: number; b?: number }\n\t\tconst T = declare<Expected, { side: \"out\" }>().type({\n\t\t\ta: \"string.numeric.parse\",\n\t\t\t\"b?\": \"number\"\n\t\t})\n\n\t\tattest<(In: { a: string; b?: number }) => Expected>(T.t).type.toString.snap(\n\t\t\t\"(In: { a: string; b?: number }) => Expected\"\n\t\t)\n\t})\n\n\tit(\"morph out mismatch\", () => {\n\t\ttype Expected = { a: string; b?: number }\n\t\tattest(() =>\n\t\t\tdeclare<Expected, { side: \"out\" }>().type({\n\t\t\t\t// @ts-expect-error\n\t\t\t\ta: \"string.numeric.parse\",\n\t\t\t\t\"b?\": \"number\"\n\t\t\t})\n\t\t).type.errors(\"declared: string; inferred: number\")\n\t})\n\n\tit(\"value-optional\", () => {\n\t\ttype Expected = { f?: string }\n\n\t\tconst T = type.declare<Expected>().type({\n\t\t\tf: \"string?\"\n\t\t})\n\n\t\tattest<Expected>(T.t)\n\t})\n\n\tit(\"invalid value-optional\", () => {\n\t\ttype Expected = { f?: string }\n\n\t\tattest(() =>\n\t\t\ttype.declare<Expected>().type({\n\t\t\t\t// @ts-expect-error\n\t\t\t\tf: \"number?\"\n\t\t\t})\n\t\t).type.errors(\"declared: string; inferred: number\")\n\t})\n\n\t// https://github.com/arktypeio/arktype/issues/1537\n\tit(\"github undefined issue\", () => {\n\t\ttype Member = \"a\" | \"b\" | undefined // without undefined it works\n\t\tconst memberValidator = type.declare<Member>().type(`\"a\" | \"b\" | undefined`)\n\n\t\ttype Object = {\n\t\t\tm: Member\n\t\t}\n\t\tconst objectValidator = type.declare<Object>().type({\n\t\t\tm: memberValidator\n\t\t})\n\n\t\tattest<Object>(objectValidator.t)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/define.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { writeUnresolvableMessage } from \"@ark/schema\"\nimport { define, scope, type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"ark\", () => {\n\t\tconst def = define({\n\t\t\ta: \"string|number\",\n\t\t\tb: [\"boolean\"]\n\t\t})\n\t\tattest<{ a: \"string|number\"; b: readonly [\"boolean\"] }>(def)\n\t})\n\n\tit(\"type attached\", () => {\n\t\tconst T = type.define({\n\t\t\tfoo: \"string\"\n\t\t})\n\n\t\tattest<{ readonly foo: \"string\" }>(T).equals({ foo: \"string\" })\n\n\t\t// @ts-expect-error\n\t\tattest(() => type.define({ foo: \"str\" })).completions({ str: [\"string\"] })\n\t})\n\n\tit(\"ark error\", () => {\n\t\t// currently is a no-op, so only has type error\n\t\t// @ts-expect-error\n\t\tattest(() => define({ a: \"boolean|foo\" })).type.errors(\n\t\t\twriteUnresolvableMessage(\"foo\")\n\t\t)\n\t})\n\n\tit(\"custom scope\", () => {\n\t\tconst $ = scope({\n\t\t\ta: \"string[]\"\n\t\t})\n\n\t\tconst ok = $.define([\"a[]|boolean\"])\n\t\tattest<readonly [\"a[]|boolean\"]>(ok)\n\n\t\t// @ts-expect-error\n\t\tattest(() => $.define({ not: \"ok\" })).type.errors(\n\t\t\twriteUnresolvableMessage(\"ok\")\n\t\t)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/discrimination.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { registeredReference } from \"@ark/schema\"\nimport { scope, type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"2 literal branches\", () => {\n\t\t// should not use a switch with <=2 branches to avoid needless convolution\n\t\tconst T = type(\"'a'|'b'\")\n\t\tattest(T.json).snap([{ unit: \"a\" }, { unit: \"b\" }])\n\t\tattest(T.internal.assertHasKind(\"union\").discriminantJson).snap({\n\t\t\tkind: \"unit\",\n\t\t\tpath: [],\n\t\t\tcases: { '\"a\"': true, '\"b\"': true }\n\t\t})\n\t\tattest(T.allows(\"a\")).equals(true)\n\t\tattest(T.allows(\"b\")).equals(true)\n\t\tattest(T.allows(\"c\")).equals(false)\n\t})\n\n\tit(\">2 literal branches\", () => {\n\t\tconst T = type(\"'a'|'b'|'c'\")\n\t\tattest(T.json).snap([{ unit: \"a\" }, { unit: \"b\" }, { unit: \"c\" }])\n\t\tattest(T.internal.assertHasKind(\"union\").discriminantJson).snap({\n\t\t\tkind: \"unit\",\n\t\t\tpath: [],\n\t\t\tcases: { '\"a\"': true, '\"b\"': true, '\"c\"': true }\n\t\t})\n\t\tattest(T.allows(\"a\")).equals(true)\n\t\tattest(T.allows(\"b\")).equals(true)\n\t\tattest(T.allows(\"c\")).equals(true)\n\t\tattest(T.allows(\"d\")).equals(false)\n\t})\n\n\tit(\">2 domain branches\", () => {\n\t\tconst T = type(\"string|bigint|number\")\n\t\tattest(T.json).snap([\"bigint\", \"number\", \"string\"])\n\t\tattest(T.internal.assertHasKind(\"union\").discriminantJson).snap({\n\t\t\tkind: \"domain\",\n\t\t\tpath: [],\n\t\t\tcases: { '\"bigint\"': true, '\"number\"': true, '\"string\"': true }\n\t\t})\n\t\tattest(T.allows(\"foo\")).equals(true)\n\t\tattest(T.allows(5n)).equals(true)\n\t\tattest(T.allows(5)).equals(true)\n\t\tattest(T.allows(true)).equals(false)\n\t})\n\n\tit(\"literals can be included in domain branches\", () => {\n\t\tconst T = type(\"string|bigint|true\")\n\t\tattest(T.json).snap([\"bigint\", \"string\", { unit: true }])\n\t\tattest(T.internal.assertHasKind(\"union\").discriminantJson).snap({\n\t\t\tkind: \"domain\",\n\t\t\tpath: [],\n\t\t\tcases: { '\"bigint\"': true, '\"string\"': true, '\"boolean\"': { unit: true } }\n\t\t})\n\t\tattest(T.allows(\"foo\")).equals(true)\n\t\tattest(T.allows(5n)).equals(true)\n\t\tattest(T.allows(true)).equals(true)\n\t\tattest(T.allows(5)).equals(false)\n\t})\n\n\tconst getPlaces = () =>\n\t\tscope({\n\t\t\trainForest: {\n\t\t\t\tclimate: \"'wet'\",\n\t\t\t\tcolor: \"'green'\",\n\t\t\t\tisRainForest: \"true\"\n\t\t\t},\n\t\t\tdesert: { climate: \"'dry'\", color: \"'brown'\", isDesert: \"true\" },\n\t\t\tsky: { climate: \"'dry'\", color: \"'blue'\", isSky: \"true\" },\n\t\t\tocean: { climate: \"'wet'\", color: \"'blue'\", isOcean: \"true\" }\n\t\t})\n\n\tit(\"nested\", () => {\n\t\tconst $ = getPlaces()\n\t\tconst climate = $.type(\"ocean | sky | rainForest | desert\")\n\n\t\tconst missingLabel = climate({\n\t\t\tclimate: \"wet\",\n\t\t\tcolor: \"blue\"\n\t\t})\n\n\t\tattest(missingLabel.toString()).snap(\"isOcean must be true (was missing)\")\n\n\t\tconst twoMissingKeys = climate({\n\t\t\tcolor: \"blue\"\n\t\t})\n\n\t\tattest(twoMissingKeys.toString()).snap(\n\t\t\t'climate must be \"dry\" or \"wet\" (was undefined)'\n\t\t)\n\n\t\tattest(climate.internal.assertHasKind(\"union\").discriminantJson).snap({\n\t\t\tkind: \"unit\",\n\t\t\tpath: [\"color\"],\n\t\t\tcases: {\n\t\t\t\t'\"blue\"': {\n\t\t\t\t\tkind: \"unit\",\n\t\t\t\t\tpath: [\"climate\"],\n\t\t\t\t\tcases: {\n\t\t\t\t\t\t'\"dry\"': { required: [{ key: \"isSky\", value: { unit: true } }] },\n\t\t\t\t\t\t'\"wet\"': { required: [{ key: \"isOcean\", value: { unit: true } }] }\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t'\"brown\"': {\n\t\t\t\t\trequired: [\n\t\t\t\t\t\t{ key: \"climate\", value: { unit: \"dry\" } },\n\t\t\t\t\t\t{ key: \"isDesert\", value: { unit: true } }\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t'\"green\"': {\n\t\t\t\t\trequired: [\n\t\t\t\t\t\t{ key: \"climate\", value: { unit: \"wet\" } },\n\t\t\t\t\t\t{ key: \"isRainForest\", value: { unit: true } }\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t})\n\n\tit(\"indiscriminable\", () => {\n\t\tconst T = getPlaces().type([\n\t\t\t\"ocean\",\n\t\t\t\"|\",\n\t\t\t{\n\t\t\t\tclimate: \"'wet'\",\n\t\t\t\tcolor: \"'blue'\",\n\t\t\t\tindistinguishableFrom: \"ocean\"\n\t\t\t}\n\t\t])\n\n\t\tattest(T.internal.assertHasKind(\"union\").discriminantJson).equals(null)\n\t})\n\n\tit(\"discriminate optional key\", () => {\n\t\tconst T = type({\n\t\t\tdirection: \"'forward' | 'backward'\",\n\t\t\t\"operator?\": \"'by'\"\n\t\t}).or({\n\t\t\tduration: \"'s' | 'min' | 'h'\",\n\t\t\toperator: \"'to'\"\n\t\t})\n\n\t\tattest(T.internal.assertHasKind(\"union\").discriminantJson).equals(null)\n\t})\n\n\tit(\"overlapping default case\", () => {\n\t\tconst T = getPlaces().type([\n\t\t\t\"ocean|rainForest\",\n\t\t\t\"|\",\n\t\t\t{ temperature: \"'hot'\" }\n\t\t])\n\n\t\tattest(T.internal.assertHasKind(\"union\").discriminantJson).snap({\n\t\t\tkind: \"unit\",\n\t\t\tpath: [\"color\"],\n\t\t\tcases: {\n\t\t\t\t'\"blue\"': [\n\t\t\t\t\t{\n\t\t\t\t\t\trequired: [\n\t\t\t\t\t\t\t{ key: \"climate\", value: { unit: \"wet\" } },\n\t\t\t\t\t\t\t{ key: \"isOcean\", value: { unit: true } }\n\t\t\t\t\t\t]\n\t\t\t\t\t},\n\t\t\t\t\t{ required: [{ key: \"temperature\", value: { unit: \"hot\" } }] }\n\t\t\t\t],\n\t\t\t\t'\"green\"': [\n\t\t\t\t\t{\n\t\t\t\t\t\trequired: [\n\t\t\t\t\t\t\t{ key: \"climate\", value: { unit: \"wet\" } },\n\t\t\t\t\t\t\t{ key: \"isRainForest\", value: { unit: true } }\n\t\t\t\t\t\t]\n\t\t\t\t\t},\n\t\t\t\t\t{ required: [{ key: \"temperature\", value: { unit: \"hot\" } }] }\n\t\t\t\t],\n\t\t\t\tdefault: {\n\t\t\t\t\trequired: [{ key: \"temperature\", value: { unit: \"hot\" } }],\n\t\t\t\t\tdomain: \"object\"\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t})\n\n\tit(\"discriminable default\", () => {\n\t\tconst T = getPlaces().type([\n\t\t\t{ temperature: \"'cold'\" },\n\t\t\t\"|\",\n\t\t\t[\"ocean|rainForest\", \"|\", { temperature: \"'hot'\" }]\n\t\t])\n\n\t\tattest(T.internal.assertHasKind(\"union\").discriminantJson).snap({\n\t\t\tkind: \"unit\",\n\t\t\tpath: [\"color\"],\n\t\t\tcases: {\n\t\t\t\t'\"blue\"': {\n\t\t\t\t\tkind: \"unit\",\n\t\t\t\t\tpath: [\"temperature\"],\n\t\t\t\t\tcases: {\n\t\t\t\t\t\t'\"cold\"': true,\n\t\t\t\t\t\t'\"hot\"': true,\n\t\t\t\t\t\tdefault: {\n\t\t\t\t\t\t\trequired: [\n\t\t\t\t\t\t\t\t{ key: \"climate\", value: { unit: \"wet\" } },\n\t\t\t\t\t\t\t\t{ key: \"isOcean\", value: { unit: true } }\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t'\"green\"': {\n\t\t\t\t\tkind: \"unit\",\n\t\t\t\t\tpath: [\"temperature\"],\n\t\t\t\t\tcases: {\n\t\t\t\t\t\t'\"cold\"': true,\n\t\t\t\t\t\t'\"hot\"': true,\n\t\t\t\t\t\tdefault: {\n\t\t\t\t\t\t\trequired: [\n\t\t\t\t\t\t\t\t{ key: \"climate\", value: { unit: \"wet\" } },\n\t\t\t\t\t\t\t\t{ key: \"isRainForest\", value: { unit: true } }\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tdefault: {\n\t\t\t\t\tkind: \"unit\",\n\t\t\t\t\tpath: [\"temperature\"],\n\t\t\t\t\tcases: { '\"cold\"': true, '\"hot\"': true }\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t})\n\n\tit(\"won't discriminate between possibly empty arrays\", () => {\n\t\tconst T = type(\"string[]|boolean[]\")\n\t\tattest(T.internal.assertHasKind(\"union\").discriminantJson).equals(null)\n\t})\n\n\tit(\"discriminant path including symbol\", () => {\n\t\tconst s = Symbol(\"lobmyS\")\n\t\tconst sRef = registeredReference(s)\n\t\tconst T = type({ [s]: \"0\" }).or({ [s]: \"1\" })\n\t\tattest(T.internal.assertHasKind(\"union\").discriminantJson).snap({\n\t\t\tkind: \"unit\",\n\t\t\tpath: [sRef],\n\t\t\tcases: {\n\t\t\t\t\"0\": true,\n\t\t\t\t\"1\": true\n\t\t\t}\n\t\t})\n\n\t\tattest(T.allows({ [s]: 0 })).equals(true)\n\t\tattest(T.allows({ [s]: -1 })).equals(false)\n\n\t\tattest(T({ [s]: 1 })).equals({ [s]: 1 })\n\t\tattest(T({ [s]: 2 }).toString()).snap(\n\t\t\t\"value at [Symbol(lobmyS)] must be 0 or 1 (was 2)\"\n\t\t)\n\t})\n\n\t// https://github.com/arktypeio/arktype/issues/1100\n\tit(\"discriminated null + object\", () => {\n\t\tconst Company = type({\n\t\t\tid: \"number\"\n\t\t}).or(\"string | null\")\n\n\t\tattest(Company(null)).equals(null)\n\t\tattest(Company({ id: 1 })).equals({ id: 1 })\n\t\tattest(Company(\"foo\")).equals(\"foo\")\n\t\tattest(Company(5)?.toString()).snap(\n\t\t\t\"must be a string, an object or null (was a number)\"\n\t\t)\n\t})\n\n\tit(\"differing inner discriminated paths\", () => {\n\t\tconst Discriminated = type(\n\t\t\t{\n\t\t\t\tinnerA: {\n\t\t\t\t\tid: \"1\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"|\",\n\t\t\t{\n\t\t\t\tinnerB: {\n\t\t\t\t\tid: \"1\"\n\t\t\t\t}\n\t\t\t}\n\t\t)\n\t\t\t.or({ innerA: { id: \"2\" } })\n\t\t\t.or({ innerB: { id: \"2\" } })\n\n\t\tconst Union = Discriminated.internal.assertHasKind(\"union\")\n\n\t\tattest(Union.discriminantJson).snap({\n\t\t\tkind: \"unit\",\n\t\t\tpath: [\"innerA\", \"id\"],\n\t\t\tcases: {\n\t\t\t\t\"1\": true,\n\t\t\t\t\"2\": true,\n\t\t\t\tdefault: {\n\t\t\t\t\tkind: \"unit\",\n\t\t\t\t\tpath: [\"innerB\", \"id\"],\n\t\t\t\t\tcases: { \"1\": true, \"2\": true }\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\n\t\tattest(Union({ innerA: { id: 1 } })).equals({ innerA: { id: 1 } })\n\t\tattest(Union({ innerB: { id: 1 } })).equals({ innerB: { id: 1 } })\n\t\tattest(Union({ innerA: { id: 2 } })).equals({ innerA: { id: 2 } })\n\t\tattest(Union({ innerB: { id: 2 } })).equals({ innerB: { id: 2 } })\n\n\t\tattest(Union({})?.toString()).snap(\n\t\t\t\"innerB.id must be 1 or 2 (was undefined)\"\n\t\t)\n\t})\n\n\tit(\"allows strict discriminated keys\", () => {\n\t\tconst AorB = type({\n\t\t\ttype: \"'A'\"\n\t\t})\n\t\t\t.or({\n\t\t\t\ttype: \"'B'\"\n\t\t\t})\n\t\t\t.onUndeclaredKey(\"reject\")\n\n\t\tattest(AorB.internal.assertHasKind(\"union\").discriminantJson).snap({\n\t\t\tkind: \"unit\",\n\t\t\tpath: [\"type\"],\n\t\t\tcases: {\n\t\t\t\t'\"A\"': { undeclared: \"reject\", required: [{ key: \"type\", value: {} }] },\n\t\t\t\t'\"B\"': { undeclared: \"reject\", required: [{ key: \"type\", value: {} }] }\n\t\t\t}\n\t\t})\n\n\t\tattest(AorB({ type: \"A\" })).equals({ type: \"A\" })\n\t})\n\n\tit(\"can discriminated objects with disjoint strict keys\", () => {\n\t\tconst AorB = type({\n\t\t\t\"+\": \"reject\",\n\t\t\tsomething: \"'A'\"\n\t\t}).or({\n\t\t\t\"+\": \"reject\",\n\t\t\tsomething: \"'B'\",\n\t\t\tsomethingelse: \"number\"\n\t\t})\n\n\t\tattest(AorB.internal.assertHasKind(\"union\").discriminantJson).snap({\n\t\t\tkind: \"unit\",\n\t\t\tpath: [\"something\"],\n\t\t\tcases: {\n\t\t\t\t'\"A\"': {\n\t\t\t\t\tundeclared: \"reject\",\n\t\t\t\t\trequired: [{ key: \"something\", value: {} }]\n\t\t\t\t},\n\t\t\t\t'\"B\"': {\n\t\t\t\t\tundeclared: \"reject\",\n\t\t\t\t\trequired: [\n\t\t\t\t\t\t{ key: \"something\", value: {} },\n\t\t\t\t\t\t{ key: \"somethingelse\", value: \"number\" }\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\n\t\tattest(AorB({ something: \"A\" })).snap({ something: \"A\" })\n\t})\n\n\tit(\"includes non-disjoint branches in corresponding cases\", () => {\n\t\tconst T = type({\n\t\t\tid: \"0\",\n\t\t\tk1: \"number\"\n\t\t})\n\t\t\t.or({ id: \"1\", k1: \"number\" })\n\t\t\t.or({\n\t\t\t\tname: \"string\"\n\t\t\t})\n\n\t\tattest(T.internal.assertHasKind(\"union\").discriminantJson).snap({\n\t\t\tkind: \"unit\",\n\t\t\tpath: [\"id\"],\n\t\t\tcases: {\n\t\t\t\t\"0\": [\n\t\t\t\t\t{ required: [{ key: \"k1\", value: \"number\" }] },\n\t\t\t\t\t{ required: [{ key: \"name\", value: \"string\" }] }\n\t\t\t\t],\n\t\t\t\t\"1\": [\n\t\t\t\t\t{ required: [{ key: \"k1\", value: \"number\" }] },\n\t\t\t\t\t{ required: [{ key: \"name\", value: \"string\" }] }\n\t\t\t\t],\n\t\t\t\tdefault: {\n\t\t\t\t\trequired: [{ key: \"name\", value: \"string\" }],\n\t\t\t\t\tdomain: \"object\"\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\n\t\t// should hit the case discriminated for id: 1,\n\t\t// but still resolve correctly via the { name: string } branch\n\t\tattest(T({ name: \"foo\", id: 1 })).unknown.snap({ name: \"foo\", id: 1 })\n\t})\n\n\tit(\"correctly dsicriminated onDeclaredKey: reject in the above scenario\", () => {\n\t\tconst T = type({\n\t\t\tid: \"0\",\n\t\t\tk1: \"number\"\n\t\t})\n\t\t\t.or({ id: \"1\", k1: \"number\" })\n\t\t\t.or({\n\t\t\t\t\"+\": \"reject\",\n\t\t\t\tname: \"string\"\n\t\t\t})\n\n\t\tattest(T.internal.assertHasKind(\"union\").discriminantJson).snap({\n\t\t\tkind: \"unit\",\n\t\t\tpath: [\"id\"],\n\t\t\tcases: {\n\t\t\t\t\"0\": { required: [{ key: \"k1\", value: \"number\" }] },\n\t\t\t\t\"1\": { required: [{ key: \"k1\", value: \"number\" }] },\n\t\t\t\tdefault: {\n\t\t\t\t\tundeclared: \"reject\",\n\t\t\t\t\trequired: [{ key: \"name\", value: \"string\" }],\n\t\t\t\t\tdomain: \"object\"\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\n\t\t// now that we are rejecting undeclared keys, all branches fail\n\t\tattest(T({ name: \"foo\", id: 1 }).toString()).snap(\n\t\t\t\"k1 must be a number (was missing)\"\n\t\t)\n\t})\n\n\tit(\"discriminate array and tuple\", () => {\n\t\tconst T = type(\"null[] | false\").or([type.undefined])\n\n\t\tconst { discriminantJson } = T.select({\n\t\t\tkind: \"union\",\n\t\t\tmethod: \"assertFind\"\n\t\t})\n\n\t\tattest(discriminantJson).snap({\n\t\t\tkind: \"domain\",\n\t\t\tpath: [],\n\t\t\tcases: {\n\t\t\t\t'\"object\"': [\n\t\t\t\t\t{\n\t\t\t\t\t\tsequence: { prefix: [{ unit: \"undefined\" }] },\n\t\t\t\t\t\tproto: \"Array\",\n\t\t\t\t\t\texactLength: 1\n\t\t\t\t\t},\n\t\t\t\t\t{ sequence: { unit: null }, proto: \"Array\" }\n\t\t\t\t],\n\t\t\t\t'\"boolean\"': { unit: false }\n\t\t\t}\n\t\t})\n\t})\n\n\tit(\"discriminate bounded array and tuple\", () => {\n\t\tconst T = type(\"3 <= null[] <= 10 | false\").or([type.undefined])\n\n\t\tconst { discriminantJson } = T.select({\n\t\t\tkind: \"union\",\n\t\t\tmethod: \"assertFind\"\n\t\t})\n\n\t\tattest(discriminantJson).snap({\n\t\t\tkind: \"domain\",\n\t\t\tpath: [],\n\t\t\tcases: {\n\t\t\t\t'\"object\"': [\n\t\t\t\t\t{\n\t\t\t\t\t\tsequence: { prefix: [{ unit: \"undefined\" }] },\n\t\t\t\t\t\tproto: \"Array\",\n\t\t\t\t\t\texactLength: 1\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tsequence: { unit: null },\n\t\t\t\t\t\tproto: \"Array\",\n\t\t\t\t\t\tmaxLength: 10,\n\t\t\t\t\t\tminLength: 3\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\t'\"boolean\"': { unit: false }\n\t\t\t}\n\t\t})\n\t})\n\n\tit(\"dimscrinate literal undefined value\", () => {\n\t\tconst T = type([\"number[]\", \"|\", [\"undefined\"]])\n\n\t\tattest(T.assert([])).equals([])\n\t})\n\n\t// https://github.com/arktypeio/arktype/issues/1547\n\tit(\"discriminates cyclic union on nested path\", () => {\n\t\tconst s = scope({\n\t\t\tAChild: { type: \"'AChild'\", children: \"(AParent)[] > 0\" },\n\t\t\tAParent: { type: \"'AParent'\", children: \"(AChild)[] > 0\" },\n\t\t\tBChild: { type: \"'BChild'\", children: \"unknown[]\" },\n\t\t\tBParent: {\n\t\t\t\ttype: \"'BParent'\",\n\t\t\t\tlayout: \"number[]\",\n\t\t\t\tchildren: \"(BChild)[] > 0\"\n\t\t\t}\n\t\t})\n\n\t\tconst Thing = s.type(\"AParent | BParent\")\n\n\t\tattest(Thing.internal.assertHasKind(\"union\").discriminantJson).snap({\n\t\t\tkind: \"unit\",\n\t\t\tpath: [\"type\"],\n\t\t\tcases: {\n\t\t\t\t'\"BParent\"': {\n\t\t\t\t\trequired: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkey: \"children\",\n\t\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\t\tsequence: {\n\t\t\t\t\t\t\t\t\trequired: [\n\t\t\t\t\t\t\t\t\t\t{ key: \"children\", value: \"Array\" },\n\t\t\t\t\t\t\t\t\t\t{ key: \"type\", value: { unit: \"BChild\" } }\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\tdomain: \"object\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tproto: \"Array\",\n\t\t\t\t\t\t\t\tminLength: 1\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ key: \"layout\", value: { sequence: \"number\", proto: \"Array\" } }\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t'\"AParent\"': {\n\t\t\t\t\trequired: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkey: \"children\",\n\t\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\t\tsequence: {\n\t\t\t\t\t\t\t\t\trequired: [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tkey: \"children\",\n\t\t\t\t\t\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\t\t\t\t\t\tsequence: \"$AParent\",\n\t\t\t\t\t\t\t\t\t\t\t\tproto: \"Array\",\n\t\t\t\t\t\t\t\t\t\t\t\tminLength: 1\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t{ key: \"type\", value: { unit: \"AChild\" } }\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\tdomain: \"object\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tproto: \"Array\",\n\t\t\t\t\t\t\t\tminLength: 1\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\n\t\tattest(\n\t\t\tThing({\n\t\t\t\ttype: \"BParent\",\n\t\t\t\tlayout: \"\",\n\t\t\t\tchildren: [{ type: \"BChild\", children: [] }]\n\t\t\t}).toString()\n\t\t).snap(\"layout must be an array (was string)\")\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/divisor.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { intrinsic, writeIndivisibleMessage } from \"@ark/schema\"\nimport { type } from \"arktype\"\nimport { writeInvalidDivisorMessage } from \"arktype/internal/parser/shift/operator/divisor.ts\"\n\ncontextualize(() => {\n\tdescribe(\"parse\", () => {\n\t\tit(\"integer literal\", () => {\n\t\t\tconst DivisibleByTwo = type(\"number%2\")\n\t\t\tattest<number>(DivisibleByTwo.infer)\n\t\t\tattest(DivisibleByTwo.json).snap({ domain: \"number\", divisor: 2 })\n\t\t})\n\n\t\tit(\"chained\", () => {\n\t\t\tconst T = type(\"number\").divisibleBy(2)\n\t\t\tconst Expected = type(\"number%2\")\n\t\t\tattest<typeof Expected>(T)\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"whitespace after %\", () => {\n\t\t\tconst T = type(\"number % 5\")\n\t\t\tattest<number>(T.infer)\n\t\t\tattest(T.json).snap({ domain: \"number\", divisor: 5 })\n\t\t})\n\n\t\tit(\"with bounds\", () => {\n\t\t\tconst T = type(\"7<number%8<222\")\n\t\t\tconst Expected = type(\"number%8\").and(\"7<number<222\")\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t\tattest(T.description).snap(\n\t\t\t\t\"a multiple of 8 and more than 7 and less than 222\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"docs example\", () => {\n\t\t\tconst N = type(\"0 < number <= 100\")\n\n\t\t\tattest(N.description).snap(\"positive and at most 100\")\n\t\t})\n\n\t\tit(\"allows non-narrowed divisor\", () => {\n\t\t\tconst d = 5 as number\n\t\t\tattest<number>(type(`number%${d}`).infer)\n\t\t})\n\n\t\tit(\"fails at runtime on non-integer divisor\", () => {\n\t\t\tattest(() => type(\"number%2.3\")).throws(writeInvalidDivisorMessage(\"2.3\"))\n\t\t})\n\n\t\tit(\"non-numeric divisor\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"number%foobar\")).throwsAndHasTypeError(\n\t\t\t\twriteInvalidDivisorMessage(\"foobar\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"zero divisor\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"number%0\")).throwsAndHasTypeError(\n\t\t\t\twriteInvalidDivisorMessage(0)\n\t\t\t)\n\t\t})\n\n\t\tit(\"unknown\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"unknown%2\")).throwsAndHasTypeError(\n\t\t\t\twriteIndivisibleMessage(intrinsic.unknown)\n\t\t\t)\n\t\t})\n\n\t\tit(\"indivisible\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"string%1\")).throwsAndHasTypeError(\n\t\t\t\twriteIndivisibleMessage(intrinsic.string)\n\t\t\t)\n\t\t})\n\n\t\tit(\"morph\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"string.numeric.parse > 2\"))\n\t\t\t\t.throws.snap(\n\t\t\t\t\t\"ParseError: MinLength operand must be a string or an array (was a morph)\"\n\t\t\t\t)\n\t\t\t\t.type.errors(\n\t\t\t\t\t\"To constrain the output of string.numeric.parse, pipe like myMorph.to('number > 0').\\\\nTo constrain the input, intersect like myMorph.and('number > 0')\"\n\t\t\t\t)\n\t\t})\n\n\t\tit(\"chained indivisible\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"string\").divisibleBy(2))\n\t\t\t\t.throws(writeIndivisibleMessage(intrinsic.string))\n\t\t\t\t.type.errors(\"Property 'divisibleBy' does not exist\")\n\t\t})\n\n\t\tit(\"overlapping\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"(number|string)%10\")).throwsAndHasTypeError(\n\t\t\t\twriteIndivisibleMessage(intrinsic.number.or(intrinsic.string))\n\t\t\t)\n\t\t})\n\t})\n\n\tdescribe(\"intersection\", () => {\n\t\tit(\"identical\", () => {\n\t\t\tconst T = type(\"number%2&number%2\")\n\t\t\tattest(T.json).equals(type(\"number%2\").json)\n\t\t})\n\n\t\tit(\"purely divisible\", () => {\n\t\t\tconst T = type(\"number%4&number%2\")\n\t\t\tattest(T.json).equals(type(\"number%4\").json)\n\t\t})\n\n\t\tit(\"common divisor\", () => {\n\t\t\tconst T = type(\"number%6&number%4\")\n\t\t\tattest(T.json).equals(type(\"number%12\").json)\n\t\t})\n\n\t\tit(\"relatively prime\", () => {\n\t\t\tconst T = type(\"number%2&number%3\")\n\t\t\tattest(T.json).equals(type(\"number%6\").json)\n\t\t})\n\n\t\tit(\"valid literal\", () => {\n\t\t\tconst T = type(\"number%5&0\")\n\t\t\tattest(T.json).equals(type(\"0\").json)\n\t\t})\n\n\t\tit(\"invalid literal\", () => {\n\t\t\tattest(() => type(\"number%3&8\")).throws.snap(\n\t\t\t\t\"ParseError: Intersection of % 3 and 8 results in an unsatisfiable type\"\n\t\t\t)\n\t\t})\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/enclosed.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { writeUnclosedGroupMessage } from \"@ark/util\"\nimport type { RegexExecArray } from \"arkregex/internal/execArray.ts\"\nimport { type, type Out, type Type } from \"arktype\"\nimport { writeUnterminatedEnclosedMessage } from \"arktype/internal/parser/shift/operand/enclosed.ts\"\n\ncontextualize(() => {\n\tit(\"with spaces\", () => {\n\t\tconst T = type(\"'this has spaces'\")\n\t\tattest<\"this has spaces\">(T.infer)\n\t\tattest(T.json).snap({ unit: \"this has spaces\" })\n\t})\n\n\tit(\"with neighbors\", () => {\n\t\tconst T = type(\"'foo'|/.*/[]\")\n\t\tattest<\"foo\" | string[]>(T.infer)\n\t\tattest(T.json).snap([\n\t\t\t{ proto: \"Array\", sequence: { domain: \"string\", pattern: [\".*\"] } },\n\t\t\t{ unit: \"foo\" }\n\t\t])\n\t})\n\n\tit(\"unterminated regex\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"/.*\")).throwsAndHasTypeError(\n\t\t\twriteUnterminatedEnclosedMessage(\".*\", \"/\")\n\t\t)\n\t})\n\n\tit(\"unterminated single-quote\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"'.*\")).throwsAndHasTypeError(\n\t\t\twriteUnterminatedEnclosedMessage(\".*\", \"'\")\n\t\t)\n\t})\n\n\tit(\"unterminated double-quote\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type('\".*')).throwsAndHasTypeError(\n\t\t\twriteUnterminatedEnclosedMessage(\".*\", '\"')\n\t\t)\n\t})\n\n\tit(\"single-quoted\", () => {\n\t\tconst T = type(\"'hello'\")\n\t\tattest<\"hello\">(T.infer)\n\t\tattest(T.json).snap({ unit: \"hello\" })\n\t})\n\n\tit(\"double-quoted\", () => {\n\t\tconst T = type('\"goodbye\"')\n\t\tattest<\"goodbye\">(T.infer)\n\t\tattest(T.expression).snap('\"goodbye\"')\n\t})\n\n\tit(\"regex literal\", () => {\n\t\tconst T = type(\"/.*/\")\n\t\tattest<string>(T.infer)\n\t\tattest(T.expression).snap(\"/.*/\")\n\t})\n\n\tit(\"invalid regex\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"/[/\"))\n\t\t\t.throws(\"Invalid regular expression: /[/: Unterminated character class\")\n\t\t\t.type.errors(writeUnclosedGroupMessage(\"]\"))\n\t})\n\n\tit(\"regex exec literal\", () => {\n\t\tconst T = type(\"x/^a(b)c$/\")\n\t\tattest<Type<(In: \"abc\") => Out<RegexExecArray<[\"abc\", \"b\"], {}, \"\">>>>(T)\n\t\tattest(T.expression).snap(\n\t\t\t\"(In: /^a(b)c$/) => Out<{ groups: object | undefined } & string[]>\"\n\t\t)\n\t\tattest(T(\"abc\")).snap([\"abc\", \"b\"])\n\t})\n\n\tit(\"invalid regex exec literal\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"x/[/\"))\n\t\t\t.throws(\"Invalid regular expression: /[/: Unterminated character class\")\n\t\t\t.type.errors(writeUnclosedGroupMessage(\"]\"))\n\t})\n\n\tit(\"nested regex exec literal\", () => {\n\t\tconst User = type({\n\t\t\t// x-prefix a regex literal to parse its type-safe capture groups\n\t\t\tbirthday: \"x/^(?<month>\\\\d{2})-(?<day>\\\\d{2})-(?<year>\\\\d{4})$/\"\n\t\t})\n\n\t\tattest<\n\t\t\tType<{\n\t\t\t\tbirthday: (In: `${number}-${number}-${number}`) => Out<\n\t\t\t\t\tRegexExecArray<\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t`${number}-${number}-${number}`,\n\t\t\t\t\t\t\t`${number}`,\n\t\t\t\t\t\t\t`${number}`,\n\t\t\t\t\t\t\t`${number}`\n\t\t\t\t\t\t],\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmonth: `${number}`\n\t\t\t\t\t\t\tday: `${number}`\n\t\t\t\t\t\t\tyear: `${number}`\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"\"\n\t\t\t\t\t>\n\t\t\t\t>\n\t\t\t}>\n\t\t>(User)\n\n\t\tconst data = User.assert({ birthday: \"05-21-1993\" })\n\n\t\tattest(data.birthday.groups).snap({ month: \"05\", day: \"21\", year: \"1993\" })\n\t})\n\n\tit(\"mixed quote types\", () => {\n\t\tconst T = type(`\"'single-quoted'\"`)\n\t\tattest<\"'single-quoted'\">(T.infer)\n\t\tattest(T.expression).snap(\"\\\"'single-quoted'\\\"\")\n\n\t\tconst U = type(`'\"double-quoted\"'`)\n\t\tattest<'\"double-quoted\"'>(U.infer)\n\t})\n\n\tit(\"ignores enclosed operators\", () => {\n\t\tconst T = type(\"'yes|no|maybe'\")\n\t\tattest<\"yes|no|maybe\">(T.infer)\n\t\tattest(T.expression).snap('\"yes|no|maybe\"')\n\t})\n\n\tit(\"mix of enclosed and unenclosed operators\", () => {\n\t\tconst T = type(\"'yes|no'|'true|false'\")\n\t\tattest<\"yes|no\" | \"true|false\">(T.infer)\n\t\tattest(T.expression).snap('\"true|false\" | \"yes|no\"')\n\t})\n\n\tit(\"escaped enclosing\", () => {\n\t\tconst T = type(\"'don\\\\'t'\")\n\t\tattest<\"don't\">(T.infer)\n\t\tattest(T.expression).snap('\"don\\'t\"')\n\t})\n\n\tit(\"escaped backslash\", () => {\n\t\tconst T = type(\"'\\\\\\\\'\")\n\n\t\tconst Expected = type.unit(\"\\\\\")\n\n\t\tattest<typeof Expected.t>(T.t)\n\t\tattest(T.expression).equals(Expected.expression)\n\t})\n\n\tit(\"string literal stress\", () => {\n\t\tconst s = `\"3.\n14159265358979323846264338327950288419716939937510\n58209749445923078164062862089986280348253421170679\n82148086513282306647093844609550582231725359408128\n48111745028410270193852110555964462294895493038196\n44288109756659334461284756482337867831652712019091\n45648566923460348610454326648213393607260249141273\n72458700660631558817488152092096282925409171536436\n78925903600113305305488204665213841469519415116094\n33057270365759591953092186117381932611793105118548\n07446237996274956735188575272489122793818301194912\n98336733624406566430860213949463952247371907021798\n60943702770539217176293176752384674818467669405132\n00056812714526356082778577134275778960917363717872\n14684409012249534301465495853710507922796892589235\n42019956112129021960864034418159813629774771309960\n51870721134999999837297804995105973173281609631859\n50244594553469083026425223082533446850352619311881\n71010003137838752886587533208381420617177669147303\n59825349042875546873115956286388235378759375195778\n185778053217122680661300192\"`\n\t\t// parses exactly 1001 characters before hitting a recursion limit\n\t\tconst T = type(s)\n\t\ttype Expected = typeof s extends `\"${infer enclosed}\"` ? enclosed : never\n\t\tattest<Expected>(T.infer)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/expressions.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { rootSchema, writeUnresolvableMessage } from \"@ark/schema\"\nimport { type } from \"arktype\"\nimport { writeMissingRightOperandMessage } from \"arktype/internal/parser/shift/operand/unenclosed.ts\"\n\ncontextualize(() => {\n\tdescribe(\"tuple expressions\", () => {\n\t\tit(\"nested\", () => {\n\t\t\tconst T = type([\"string|bigint\", \"|\", [\"number\", \"|\", \"boolean\"]])\n\t\t\tattest<string | number | bigint | boolean>(T.infer)\n\t\t})\n\n\t\tit(\"autocompletion\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type([\"\"])).completions({\n\t\t\t\t\"\": [\n\t\t\t\t\t\"...\",\n\t\t\t\t\t\"===\",\n\t\t\t\t\t\"Array\",\n\t\t\t\t\t\"ArrayBuffer\",\n\t\t\t\t\t\"Blob\",\n\t\t\t\t\t\"Date\",\n\t\t\t\t\t\"Error\",\n\t\t\t\t\t\"Exclude\",\n\t\t\t\t\t\"Extract\",\n\t\t\t\t\t\"File\",\n\t\t\t\t\t\"FormData\",\n\t\t\t\t\t\"Function\",\n\t\t\t\t\t\"Headers\",\n\t\t\t\t\t\"Key\",\n\t\t\t\t\t\"Map\",\n\t\t\t\t\t\"Merge\",\n\t\t\t\t\t\"Omit\",\n\t\t\t\t\t\"Partial\",\n\t\t\t\t\t\"Pick\",\n\t\t\t\t\t\"Promise\",\n\t\t\t\t\t\"Record\",\n\t\t\t\t\t\"RegExp\",\n\t\t\t\t\t\"Request\",\n\t\t\t\t\t\"Required\",\n\t\t\t\t\t\"Response\",\n\t\t\t\t\t\"Set\",\n\t\t\t\t\t\"TypedArray\",\n\t\t\t\t\t\"URL\",\n\t\t\t\t\t\"WeakMap\",\n\t\t\t\t\t\"WeakSet\",\n\t\t\t\t\t\"bigint\",\n\t\t\t\t\t\"boolean\",\n\t\t\t\t\t\"false\",\n\t\t\t\t\t\"instanceof\",\n\t\t\t\t\t\"keyof\",\n\t\t\t\t\t\"never\",\n\t\t\t\t\t\"null\",\n\t\t\t\t\t\"number\",\n\t\t\t\t\t\"object\",\n\t\t\t\t\t\"string\",\n\t\t\t\t\t\"symbol\",\n\t\t\t\t\t\"this\",\n\t\t\t\t\t\"true\",\n\t\t\t\t\t\"undefined\",\n\t\t\t\t\t\"unknown\"\n\t\t\t\t]\n\t\t\t})\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type([\"string\", \"\"])).completions({\n\t\t\t\t\"\": [\n\t\t\t\t\t\"&\",\n\t\t\t\t\t\"...\",\n\t\t\t\t\t\":\",\n\t\t\t\t\t\"=\",\n\t\t\t\t\t\"=>\",\n\t\t\t\t\t\"?\",\n\t\t\t\t\t\"@\",\n\t\t\t\t\t\"Array\",\n\t\t\t\t\t\"ArrayBuffer\",\n\t\t\t\t\t\"Blob\",\n\t\t\t\t\t\"Date\",\n\t\t\t\t\t\"Error\",\n\t\t\t\t\t\"Exclude\",\n\t\t\t\t\t\"Extract\",\n\t\t\t\t\t\"File\",\n\t\t\t\t\t\"FormData\",\n\t\t\t\t\t\"Function\",\n\t\t\t\t\t\"Headers\",\n\t\t\t\t\t\"Key\",\n\t\t\t\t\t\"Map\",\n\t\t\t\t\t\"Merge\",\n\t\t\t\t\t\"Omit\",\n\t\t\t\t\t\"Partial\",\n\t\t\t\t\t\"Pick\",\n\t\t\t\t\t\"Promise\",\n\t\t\t\t\t\"Record\",\n\t\t\t\t\t\"RegExp\",\n\t\t\t\t\t\"Request\",\n\t\t\t\t\t\"Required\",\n\t\t\t\t\t\"Response\",\n\t\t\t\t\t\"Set\",\n\t\t\t\t\t\"TypedArray\",\n\t\t\t\t\t\"URL\",\n\t\t\t\t\t\"WeakMap\",\n\t\t\t\t\t\"WeakSet\",\n\t\t\t\t\t\"[]\",\n\t\t\t\t\t\"bigint\",\n\t\t\t\t\t\"boolean\",\n\t\t\t\t\t\"false\",\n\t\t\t\t\t\"keyof\",\n\t\t\t\t\t\"never\",\n\t\t\t\t\t\"null\",\n\t\t\t\t\t\"number\",\n\t\t\t\t\t\"object\",\n\t\t\t\t\t\"string\",\n\t\t\t\t\t\"symbol\",\n\t\t\t\t\t\"this\",\n\t\t\t\t\t\"true\",\n\t\t\t\t\t\"undefined\",\n\t\t\t\t\t\"unknown\",\n\t\t\t\t\t\"|\",\n\t\t\t\t\t\"|>\"\n\t\t\t\t]\n\t\t\t})\n\t\t})\n\n\t\tit(\"missing right operand\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type([\"string\", \"|\"])).throwsAndHasTypeError(\n\t\t\t\twriteMissingRightOperandMessage(\"|\", \"\")\n\t\t\t)\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type([\"string\", \"&\"])).throwsAndHasTypeError(\n\t\t\t\twriteMissingRightOperandMessage(\"&\", \"\")\n\t\t\t)\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type([\"string\", \"|>\"])).throwsAndHasTypeError(\n\t\t\t\twriteMissingRightOperandMessage(\"|>\", \"\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"nested parse error\", () => {\n\t\t\tattest(() => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttype([\"string\", \"|\", \"numbr\"])\n\t\t\t}).throwsAndHasTypeError(writeUnresolvableMessage(\"numbr\"))\n\t\t})\n\n\t\tit(\"nested object parse error\", () => {\n\t\t\tattest(() => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttype([{ s: \"strng\" }, \"|\", \"number\"])\n\t\t\t}).throwsAndHasTypeError(writeUnresolvableMessage(\"strng\"))\n\t\t})\n\t})\n\n\tdescribe(\"root expression\", () => {\n\t\tit(\"=== single\", () => {\n\t\t\tconst T = type(\"===\", 5)\n\t\t\tattest<5>(T.infer)\n\t\t\tattest(T.json).equals(type(\"5\").json)\n\t\t})\n\n\t\tit(\"=== branches\", () => {\n\t\t\tconst T = type(\"===\", \"foo\", \"bar\", \"baz\")\n\t\t\tattest<\"foo\" | \"bar\" | \"baz\">(T.infer)\n\t\t\tattest(T.json).snap([{ unit: \"bar\" }, { unit: \"baz\" }, { unit: \"foo\" }])\n\t\t})\n\n\t\tit(\"instanceof single\", () => {\n\t\t\tconst T = type(\"instanceof\", RegExp)\n\t\t\tattest<RegExp>(T.infer)\n\t\t\tconst Expected = rootSchema(RegExp)\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"instanceof branches\", () => {\n\t\t\tconst T = type(\"instanceof\", Array, Date)\n\t\t\tattest<unknown[] | Date>(T.infer)\n\t\t\tconst Expected = rootSchema([Array, Date])\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"postfix\", () => {\n\t\t\tconst T = type({ a: \"string\" }, \"[]\")\n\t\t\tattest<{ a: string }[]>(T.infer)\n\t\t\tattest(T.json).equals(type({ a: \"string\" }).array().json)\n\t\t})\n\n\t\tit(\"infix\", () => {\n\t\t\tconst T = type({ a: \"string\" }, \"|\", { b: \"boolean\" })\n\t\t\tattest<\n\t\t\t\t| {\n\t\t\t\t\t\ta: string\n\t\t\t\t  }\n\t\t\t\t| {\n\t\t\t\t\t\tb: boolean\n\t\t\t\t  }\n\t\t\t>(T.infer)\n\n\t\t\tattest(T.json).equals(type({ a: \"string\" }).or({ b: \"boolean\" }).json)\n\t\t})\n\n\t\tit(\"morph\", () => {\n\t\t\tconst T = type({ a: \"string\" }, \"=>\", In => ({ b: In.a }))\n\t\t\tattest(T).type.toString.snap(\n\t\t\t\t\"Type<(In: { a: string }) => Out<{ b: string }>, {}>\"\n\t\t\t)\n\t\t\tattest(T.expression).snap(\"(In: { a: string }) => Out<unknown>\")\n\t\t})\n\n\t\tit(\"narrow\", () => {\n\t\t\tconst T = type(\n\t\t\t\t{ a: \"string\" },\n\t\t\t\t\":\",\n\t\t\t\t(In): In is { a: \"foo\" } => In.a === \"foo\"\n\t\t\t)\n\t\t\tattest<{ a: \"foo\" }>(T.infer)\n\t\t})\n\n\t\tit(\"tuple as second arg\", () => {\n\t\t\t// this case is not fundamentally unique but TS has a hard time\n\t\t\t// narrowing tuples in contexts like this\n\t\t\tconst T = type(\"keyof\", [{ a: \"string\" }, \"&\", { b: \"boolean\" }])\n\t\t\tconst Expected = type(\"'a' | 'b'\")\n\t\t\tattest<typeof Expected.infer>(T.infer)\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/filter.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { type } from \"arktype\"\nimport type { Out } from \"arktype/internal/attributes.ts\"\n\ncontextualize(() => {\n\tconst parseNumber = (s: string) => Number(s)\n\n\tit(\"applies to input\", () => {\n\t\tconst stringIsLong = (s: string) => s.length > 5\n\t\tconst ParseLongNumber = type(\"string\")\n\t\t\t.pipe(parseNumber)\n\t\t\t.filter(stringIsLong)\n\n\t\tattest<(In: string) => Out<number>>(ParseLongNumber.t)\n\n\t\tattest(ParseLongNumber.json).snap({\n\t\t\tin: { domain: \"string\", predicate: [\"$ark.stringIsLong\"] },\n\t\t\tmorphs: [\"$ark.parseNumber\"]\n\t\t})\n\n\t\tattest(ParseLongNumber(\"123456\")).snap(123456)\n\t\tattest(ParseLongNumber(\"123\").toString()).snap(\n\t\t\t'must be valid according to stringIsLong (was \"123\")'\n\t\t)\n\t\tattest(ParseLongNumber(123456).toString()).snap(\n\t\t\t\"must be a string (was a number)\"\n\t\t)\n\t})\n\n\tit(\"predicate inferred on input\", () => {\n\t\tconst stringIsIntegerLike = (s: string): s is `${bigint}` =>\n\t\t\t/^-?\\d+$/.test(s)\n\t\tconst ParseIntegerLike = type(\"string\")\n\t\t\t.pipe(parseNumber)\n\t\t\t.filter(stringIsIntegerLike)\n\n\t\tattest<(In: `${bigint}`) => Out<number>>(ParseIntegerLike.t)\n\n\t\tattest(ParseIntegerLike.json).snap({\n\t\t\tin: { domain: \"string\", predicate: [\"$ark.stringIsIntegerLike\"] },\n\t\t\tmorphs: [\"$ark.parseNumber\"]\n\t\t})\n\n\t\tattest(ParseIntegerLike(\"123456\")).snap(123456)\n\t\tattest(ParseIntegerLike(\"3.14159\").toString()).snap(\n\t\t\t'must be valid according to stringIsIntegerLike (was \"3.14159\")'\n\t\t)\n\t\tattest(ParseIntegerLike(123456).toString()).snap(\n\t\t\t\"must be a string (was a number)\"\n\t\t)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/fn.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { postfixAfterOptionalOrDefaultableMessage } from \"@ark/schema\"\nimport { type } from \"arktype\"\nimport {\n\tbadFnReturnTypeMessage,\n\ttype Return,\n\ttype TypedFn\n} from \"arktype/internal/fn.ts\"\nimport {\n\tmultipleVariadicMesage,\n\toptionalOrDefaultableAfterVariadicMessage\n} from \"arktype/internal/parser/tupleLiteral.ts\"\n\ncontextualize(() => {\n\tit(\"0 params implicit return\", () => {\n\t\tconst f = type.fn()(() => 5)\n\n\t\tattest<TypedFn<() => number>>(f)\n\n\t\tattest(f()).equals(5)\n\n\t\tattest(f.expression).snap(\"() => unknown\")\n\t})\n\n\tit(\"0 params explicit return\", () => {\n\t\tconst f = type.fn(\":\", \"5\")(() => 5)\n\n\t\tattest<TypedFn<() => 5, {}, Return.introspectable>>(f)\n\n\t\tattest(f()).equals(5)\n\n\t\tattest(f.expression).snap(\"() => 5\")\n\t})\n\n\tit(\"1 param implicit return\", () => {\n\t\tconst len = type.fn(\"string | number[]\")(s => s.length)\n\n\t\tattest<TypedFn<(s: string) => number>>(len)\n\n\t\tattest(len.expression).snap(\"(string | number[]) => unknown\")\n\n\t\tattest(len(\"foo\")).equals(3)\n\n\t\t// @ts-expect-error\n\t\tattest(() => len(1)).throws.snap(\n\t\t\t\"TraversalError: value at [0] must be a string or an object (was a number)\"\n\t\t)\n\t})\n\n\tit(\"1 param explicit return\", () => {\n\t\tconst len = type.fn(\"string | unknown[]\", \":\", \"number\")(s => s.length)\n\n\t\tattest<TypedFn<(s: string) => number, {}, Return.introspectable>>(len)\n\n\t\tattest(len.expression).snap(\"(string | Array) => number\")\n\n\t\tattest(len(\"foo\")).equals(3)\n\n\t\t// @ts-expect-error\n\t\tattest(() => len(1)).throws.snap(\n\t\t\t\"TraversalError: value at [0] must be a string or an object (was a number)\"\n\t\t)\n\t})\n\n\tit(\"2 params implicit return\", () => {\n\t\tconst isNumericEquivalent = type.fn(\n\t\t\t\"string\",\n\t\t\t\"number\"\n\t\t)((s, n) => s === `${n}`)\n\n\t\tattest<TypedFn<(s: string, n: number) => boolean>>(isNumericEquivalent)\n\n\t\tattest(isNumericEquivalent.expression).snap(\"(string, number) => unknown\")\n\n\t\tattest(isNumericEquivalent(\"5\", 5)).equals(true)\n\t})\n\n\tit(\"2 params explicit return\", () => {\n\t\tconst isNumericEquivalent = type.fn(\n\t\t\t\"string\",\n\t\t\t\"number\",\n\t\t\t\":\",\n\t\t\t\"boolean\"\n\t\t)((s, n) => s === `${n}`)\n\n\t\tattest<\n\t\t\tTypedFn<(s: string, n: number) => boolean, {}, Return.introspectable>\n\t\t>(isNumericEquivalent)\n\n\t\tattest(isNumericEquivalent.expression).snap(\"(string, number) => boolean\")\n\n\t\tattest(isNumericEquivalent(\"5\", 5)).equals(true)\n\t})\n\n\tit(\"morphs\", () => {\n\t\tconst stringToLength = type.string.pipe(function _fnStringToLength(s) {\n\t\t\treturn s.length\n\t\t}, type.number)\n\n\t\tconst f = type.fn(stringToLength, \":\", stringToLength)(n => n.toFixed(2))\n\t\tattest<TypedFn<(n: string) => number, {}, Return.introspectable>>(f)\n\t\tattest(f.expression).snap(\n\t\t\t\"((In: string) => To<number>) => (In: string) => To<number>\"\n\t\t)\n\t})\n\n\tit(\"nary inferred return\", () => {\n\t\tconst f = type.fn(\n\t\t\t{ a: \"1\" },\n\t\t\t{ b: \"2\" },\n\t\t\t{ c: \"3\" },\n\t\t\t{ d: \"4\" },\n\t\t\t{ e: \"5\" },\n\t\t\t{ f: \"6\" },\n\t\t\t{ g: \"7\" },\n\t\t\t{ h: \"8\" },\n\t\t\t{ i: \"9\" },\n\t\t\t{ j: \"10\" },\n\t\t\t{ k: \"11\" },\n\t\t\t{ l: \"12\" },\n\t\t\t{ m: \"13\" },\n\t\t\t{ n: \"14\" },\n\t\t\t{ o: \"15\" },\n\t\t\t{ p: \"16\" },\n\t\t\t{ q: \"17\" }\n\t\t)((a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) => ({\n\t\t\t...a,\n\t\t\t...b,\n\t\t\t...c,\n\t\t\t...d,\n\t\t\t...e,\n\t\t\t...f,\n\t\t\t...g,\n\t\t\t...h,\n\t\t\t...i,\n\t\t\t...j,\n\t\t\t...k,\n\t\t\t...l,\n\t\t\t...m,\n\t\t\t...n,\n\t\t\t...o,\n\t\t\t...p,\n\t\t\t...q\n\t\t}))\n\n\t\tattest(f.expression).snap(\n\t\t\t\"({ a: 1 }, { b: 2 }, { c: 3 }, { d: 4 }, { e: 5 }, { f: 6 }, { g: 7 }, { h: 8 }, { i: 9 }, { j: 10 }, { k: 11 }, { l: 12 }, { m: 13 }, { n: 14 }, { o: 15 }, { p: 16 }, { q: 17 }) => unknown\"\n\t\t)\n\n\t\tattest(f).type.toString.snap(`TypedFn<\n\t(\n\t\ta: { a: 1 },\n\t\tb: { b: 2 },\n\t\tc: { c: 3 },\n\t\td: { d: 4 },\n\t\te: { e: 5 },\n\t\tf: { f: 6 },\n\t\tg: { g: 7 },\n\t\th: { h: 8 },\n\t\ti: { i: 9 },\n\t\tj: { j: 10 },\n\t\tk: { k: 11 },\n\t\tl: { l: 12 },\n\t\tm: { m: 13 },\n\t\tn: { n: 14 },\n\t\to: { o: 15 },\n\t\tp: { p: 16 },\n\t\tq: { q: 17 }\n\t) => {\n\t\tq: 17\n\t\tp: 16\n\t\to: 15\n\t\tn: 14\n\t\tm: 13\n\t\tl: 12\n\t\tk: 11\n\t\tj: 10\n\t\ti: 9\n\t\th: 8\n\t\tg: 7\n\t\tf: 6\n\t\te: 5\n\t\td: 4\n\t\tc: 3\n\t\tb: 2\n\t\ta: 1\n\t},\n\t{},\n\t{}\n>`)\n\t})\n\n\tit(\"nary declared return\", () => {\n\t\tconst f = type.fn(\n\t\t\t{ a: \"1\" },\n\t\t\t{ b: \"2\" },\n\t\t\t{ c: \"3\" },\n\t\t\t{ d: \"4\" },\n\t\t\t{ e: \"5\" },\n\t\t\t{ f: \"6\" },\n\t\t\t{ g: \"7\" },\n\t\t\t{ h: \"8\" },\n\t\t\t{ i: \"9\" },\n\t\t\t{ j: \"10\" },\n\t\t\t{ k: \"11\" },\n\t\t\t{ l: \"12\" },\n\t\t\t{ m: \"13\" },\n\t\t\t{ n: \"14\" },\n\t\t\t{ o: \"15\" },\n\t\t\t\":\",\n\t\t\t{ p: \"16\" }\n\t\t)((a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) => ({\n\t\t\t...a,\n\t\t\t...b,\n\t\t\t...c,\n\t\t\t...d,\n\t\t\t...e,\n\t\t\t...f,\n\t\t\t...g,\n\t\t\t...h,\n\t\t\t...i,\n\t\t\t...j,\n\t\t\t...k,\n\t\t\t...l,\n\t\t\t...m,\n\t\t\t...n,\n\t\t\t...o,\n\t\t\tp: 16\n\t\t}))\n\n\t\tattest(f.expression).snap(\n\t\t\t\"({ a: 1 }, { b: 2 }, { c: 3 }, { d: 4 }, { e: 5 }, { f: 6 }, { g: 7 }, { h: 8 }, { i: 9 }, { j: 10 }, { k: 11 }, { l: 12 }, { m: 13 }, { n: 14 }, { o: 15 }) => { p: 16 }\"\n\t\t)\n\n\t\tattest(f).type.toString.snap(`TypedFn<\n\t(\n\t\ta: { a: 1 },\n\t\tb: { b: 2 },\n\t\tc: { c: 3 },\n\t\td: { d: 4 },\n\t\te: { e: 5 },\n\t\tf: { f: 6 },\n\t\tg: { g: 7 },\n\t\th: { h: 8 },\n\t\ti: { i: 9 },\n\t\tj: { j: 10 },\n\t\tk: { k: 11 },\n\t\tl: { l: 12 },\n\t\tm: { m: 13 },\n\t\tn: { n: 14 },\n\t\to: { o: 15 }\n\t) => { p: 16 },\n\t{},\n\tintrospectable\n>`)\n\t})\n\n\tit(\"signature precedence implicit return\", () => {\n\t\tconst f = type.fn(\"string\")((v: string | number): 0 | 1 =>\n\t\t\tv === \"foo\" ? 1 : 0\n\t\t)\n\n\t\t// signature should be wider from the declaration with name \"v\" from implementation\n\t\t// 0 | 1 should be inferred from output since undeclared\n\t\tattest(f).type.toString.snap(\"TypedFn<(v: string) => 0 | 1, {}, {}>\")\n\t})\n\n\tit(\"signature precedence explicit return\", () => {\n\t\tconst f = type.fn(\n\t\t\t\"string\",\n\t\t\t\":\",\n\t\t\t\"number\"\n\t\t)((v: string | number): 0 | 1 => (v === \"foo\" ? 1 : 0))\n\n\t\t// signature should be wider from the declaration with name \"v\" from implementation\n\t\tattest(f).type.toString.snap(\n\t\t\t\"TypedFn<(v: string) => number, {}, introspectable>\"\n\t\t)\n\t})\n\n\tit(\"attached params\", () => {\n\t\tconst len = type.fn(\"string | unknown[]\")(s => s.length)\n\n\t\tconst expectedParams = type([\"string | unknown[]\"])\n\n\t\tattest<typeof expectedParams>(len.params)\n\t\tattest(len.params.expression).equals(expectedParams.expression)\n\t})\n\n\tit(\"inferred returns\", () => {\n\t\tconst len = type.fn(\"string | unknown[]\")(s => s.length)\n\n\t\tconst Expected = type.unknown\n\t\tattest<typeof Expected>(len.returns)\n\t\tattest(len.returns.expression).equals(Expected.expression)\n\t})\n\n\tit(\"introspectable returns\", () => {\n\t\tconst len = type.fn(\"string | unknown[]\", \":\", \"number\")(s => s.length)\n\n\t\tconst Expected = type.number\n\t\tattest<typeof Expected>(len.returns)\n\t\tattest(len.returns.expression).equals(Expected.expression)\n\t})\n\n\tit(\"missing return\", () => {\n\t\t// the type message just ends up being some overload nonsense\n\t\t// but hopefully people will not try to do this and get confused\n\t\t// @ts-expect-error\n\t\tattest(() => type.fn(\"string\", \":\")).throws(badFnReturnTypeMessage)\n\t})\n\n\tit(\"name\", () => {\n\t\tconst f = type.fn(\"string\")(function originalName() {})\n\t\tattest(f.name).snap(\"bound typed originalName\")\n\t})\n\n\tit(\"arg submodule completions\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type.fn(\"string.nu\")).completions({\n\t\t\t\"string.nu\": [\"string.numeric\"]\n\t\t})\n\n\t\t// @ts-expect-error\n\t\tattest(() => type.fn(\"boolean\", \"string.nu\")).completions({\n\t\t\t\"string.nu\": [\"string.numeric\"]\n\t\t})\n\t})\n\n\tit(\"arg object completions\", () => {\n\t\tattest(() =>\n\t\t\ttype.fn({\n\t\t\t\t// @ts-expect-error\n\t\t\t\ta: \"str\"\n\t\t\t})\n\t\t).completions({\n\t\t\tstr: [\"string\"]\n\t\t})\n\n\t\tattest(() =>\n\t\t\ttype.fn(\n\t\t\t\t{\n\t\t\t\t\ta: \"string\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tb: \"boo\"\n\t\t\t\t}\n\t\t\t)\n\t\t).completions({\n\t\t\tboo: [\"boolean\"]\n\t\t})\n\t})\n\n\tit(\"returns submodule completions\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type.fn(\":\", \"string.nu\")).completions({\n\t\t\t\"string.nu\": [\"string.numeric\"]\n\t\t})\n\n\t\t// @ts-expect-error\n\t\tattest(() => type.fn(\"boolean\", \":\", \"string.nu\")).completions({\n\t\t\t\"string.nu\": [\"string.numeric\"]\n\t\t})\n\t})\n\n\tit(\"returns object completions\", () => {\n\t\tattest(() =>\n\t\t\ttype.fn(\":\", {\n\t\t\t\t// @ts-expect-error\n\t\t\t\ta: \"str\"\n\t\t\t})\n\t\t).completions({\n\t\t\tstr: [\"string\"]\n\t\t})\n\n\t\tattest(() =>\n\t\t\ttype.fn(\n\t\t\t\t{\n\t\t\t\t\ta: \"string\"\n\t\t\t\t},\n\t\t\t\t\":\",\n\t\t\t\t{\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tb: \"boo\"\n\t\t\t\t}\n\t\t\t)\n\t\t).completions({\n\t\t\tboo: [\"boolean\"]\n\t\t})\n\t})\n\n\tdescribe(\"scoped\", () => {\n\t\tit(\"scoped param and return\", () => {\n\t\t\tconst $ = type.scope({\n\t\t\t\txxx: \"string\",\n\t\t\t\tzzz: \"number\"\n\t\t\t})\n\n\t\t\tconst f = $.type.fn(\"xxx\", \":\", \"zzz\")(s => s.length)\n\n\t\t\tattest<TypedFn<(s: string) => number, typeof $.t, Return.introspectable>>(\n\t\t\t\tf\n\t\t\t)\n\n\t\t\tattest(f(\"foo\")).equals(3)\n\n\t\t\tattest(f.expression).snap(\"(string) => number\")\n\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => f(null))\n\t\t\t\t.throws.snap(\"TraversalError: value at [0] must be a string (was null)\")\n\t\t\t\t.type.errors.snap(\n\t\t\t\t\t\"Argument of type 'null' is not assignable to parameter of type 'string'.\"\n\t\t\t\t)\n\t\t})\n\n\t\tit(\"completions\", () => {\n\t\t\tconst $ = type.scope({\n\t\t\t\txxx: \"string\",\n\t\t\t\tzzz: \"number\"\n\t\t\t})\n\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => $.type.fn(\"zz\", \":\", \"xx\")).completions({\n\t\t\t\tzz: [\"zzz\"],\n\t\t\t\txx: [\"xxx\"]\n\t\t\t})\n\t\t})\n\t})\n\n\tdescribe(\"tuple elements\", () => {\n\t\tit(\"defaultable and optional\", () => {\n\t\t\tconst f = type.fn(\n\t\t\t\t\"string\",\n\t\t\t\t\"number = 5\",\n\t\t\t\t\"boolean?\"\n\t\t\t)((s, n, b) => `${s}${n}${b}`)\n\n\t\t\tattest(f.expression).snap(\"(string, number = 5, boolean?) => unknown\")\n\t\t})\n\n\t\tit(\"non-variadic array\", () => {\n\t\t\tconst join = type.fn(\"string[]\")((...parts) => parts.join(\",\"))\n\n\t\t\tattest(join.expression).snap(\"(string[]) => unknown\")\n\t\t})\n\n\t\tit(\"variadic array\", () => {\n\t\t\tconst join = type.fn(\n\t\t\t\t\"...\",\n\t\t\t\t\"string[]\",\n\t\t\t\t\":\",\n\t\t\t\t\"string\"\n\t\t\t)((...parts) => parts.join(\",\"))\n\n\t\t\tattest(join.expression).snap(\"(...string[]) => string\")\n\t\t})\n\n\t\tit(\"intro example\", () => {\n\t\t\tconst safe = type.fn(\n\t\t\t\t\"string\",\n\t\t\t\t\"number = 0.1\"\n\t\t\t)((name, version) => `${name}@${version} is safe AF.`)\n\n\t\t\tattest(safe(\"arktype\", 2.2)).snap(\"arktype@2.2 is safe AF.\")\n\t\t\tattest(() => safe(\"shitescript\", \"*\" as any)).throws.snap(\n\t\t\t\t\"TraversalError: value at [1] must be a number (was a string)\"\n\t\t\t)\n\t\t})\n\n\t\tdescribe(\"errors\", () => {\n\t\t\tit(\"errors on multiple variadic\", () => {\n\t\t\t\tattest(() =>\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\ttype.fn(\"...\", \"string[]\", \"...\", \"number[]\")(() => {})\n\t\t\t\t).throwsAndHasTypeError(multipleVariadicMesage)\n\t\t\t})\n\n\t\t\tit(\"error on optional post-variadic in spread\", () => {\n\t\t\t\t// no type error yet, ideally would have one if tuple\n\t\t\t\t// parsing were more precise for nested spread tuples\n\t\t\t\tattest(() =>\n\t\t\t\t\ttype.fn(\"...\", \"string[]\", \"...\", [\"string?\"])(() => {})\n\t\t\t\t).throws(optionalOrDefaultableAfterVariadicMessage)\n\t\t\t})\n\n\t\t\tit(\"errors on postfix following optional\", () => {\n\t\t\t\tattest(() =>\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\ttype.fn(\"number?\", \"...\", \"boolean[]\", \"symbol\")(() => {})\n\t\t\t\t).throwsAndHasTypeError(postfixAfterOptionalOrDefaultableMessage)\n\t\t\t})\n\n\t\t\tit(\"errors on postfix following defaultable\", () => {\n\t\t\t\tattest(() =>\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\ttype.fn(\"number = 0\", \"...\", \"boolean[]\", \"symbol\")(() => {})\n\t\t\t\t).throwsAndHasTypeError(postfixAfterOptionalOrDefaultableMessage)\n\t\t\t})\n\t\t})\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/generateBenchData.ts",
    "content": "// import { writeFileSync } from \"node:fs\"\n// import { fromHere } from \"@ark/fs\"\n\n// const randomInRange = (min: number, max: number) =>\n// \tMath.floor(Math.random() * (max - min + 1)) + min\n\n// const cyclicScopeSeed = Object.freeze({\n// \tuser: {\n// \t\tname: \"string\",\n// \t\t\"friends?\": \"user[]\",\n// \t\tgroups: \"group[]\"\n// \t},\n// \tgroup: {\n// \t\ttitle: \"string\",\n// \t\tmembers: \"user[]\",\n// \t\tisActive: \"boolean|undefined\"\n// \t}\n// })\n\n// const generateScopeJson = (interval: number, seedDefs: object) => {\n// \tconst defs = Object.entries(seedDefs).reduce(\n// \t\t(result, [name, seedDef]) => {\n// \t\t\tconst variants: Record<string, any> = { [name]: seedDef }\n// \t\t\tconst defCopyCount = Math.floor(interval / 2)\n// \t\t\tfor (let i = 2; i <= defCopyCount; i++) {\n// \t\t\t\tvariants[`${name}${i}`] = Object.fromEntries(\n// \t\t\t\t\tObject.entries(seedDef).map(([k, def]) => {\n// \t\t\t\t\t\tconst isOptionalKey = k.endsWith(\"?\")\n// \t\t\t\t\t\tlet randomizedDef = def as string\n// \t\t\t\t\t\tif (typeof def === \"string\") {\n// \t\t\t\t\t\t\t// Only randomize the cyclic scope values\n// \t\t\t\t\t\t\tfor (let name in cyclicScopeSeed) {\n// \t\t\t\t\t\t\t\tif (name.endsWith(\"?\")) {\n// \t\t\t\t\t\t\t\t\tname = name.slice(0, -1)\n// \t\t\t\t\t\t\t\t}\n// \t\t\t\t\t\t\t\trandomizedDef = randomizedDef.replaceAll(\n// \t\t\t\t\t\t\t\t\tname,\n// \t\t\t\t\t\t\t\t\t`${name}${randomInRange(2, defCopyCount)}`\n// \t\t\t\t\t\t\t\t)\n// \t\t\t\t\t\t\t}\n// \t\t\t\t\t\t}\n// \t\t\t\t\t\treturn [\n// \t\t\t\t\t\t\t`${isOptionalKey ? k.slice(0, -1) : k}${i}${\n// \t\t\t\t\t\t\t\tisOptionalKey ? \"?\" : \"\"\n// \t\t\t\t\t\t\t}`,\n// \t\t\t\t\t\t\trandomizedDef\n// \t\t\t\t\t\t]\n// \t\t\t\t\t})\n// \t\t\t\t)\n// \t\t\t}\n// \t\t\treturn { ...result, ...variants }\n// \t\t},\n// \t\t{} as Record<string, any>\n// \t)\n// \treturn JSON.stringify(defs, null, 4)\n// }\n\n// const seedMap = {\n// \tcyclic: cyclicScopeSeed\n// }\n\n// type GenerateScopeBenchesOptions = {\n// \tintervals: number[]\n// \tseed: keyof typeof seedMap\n// }\n\n// const generateScopeBenches = ({\n// \tintervals,\n// \tseed\n// }: GenerateScopeBenchesOptions) => {\n// \tconst toFile = fromHere(\"generated\", `${seed}.ts`)\n// \tlet benchDeclarations = \"\"\n// \tfor (const interval of intervals) {\n// \t\tconst scopeName = `${seed}${interval}`\n// \t\tconsole.log(`Generating dictionary '${scopeName}'...`)\n// \t\tbenchDeclarations += `export const ${scopeName} = ${generateScopeJson(\n// \t\t\tinterval,\n// \t\t\tseedMap[seed]\n// \t\t)} as const\n\n// `\n// \t}\n// \twriteFileSync(toFile, benchDeclarations)\n// }\n\n// generateScopeBenches({\n// \tintervals: [10, 100, 500],\n// \tseed: \"cyclic\"\n// })\n"
  },
  {
    "path": "ark/type/__tests__/generated/cyclic.ts",
    "content": "export const cyclic10 = {\n\tuser: {\n\t\tname: \"string\",\n\t\t\"friends?\": \"user[]\",\n\t\tgroups: \"group[]\"\n\t},\n\tuser2: {\n\t\tname2: \"string\",\n\t\t\"friends2?\": \"user3[]\",\n\t\tgroups2: \"group3[]\"\n\t},\n\tuser3: {\n\t\tname3: \"string\",\n\t\t\"friends3?\": \"user2[]\",\n\t\tgroups3: \"group5[]\"\n\t},\n\tuser4: {\n\t\tname4: \"string\",\n\t\t\"friends4?\": \"user5[]\",\n\t\tgroups4: \"group2[]\"\n\t},\n\tuser5: {\n\t\tname5: \"string\",\n\t\t\"friends5?\": \"user3[]\",\n\t\tgroups5: \"group3[]\"\n\t},\n\tgroup: {\n\t\ttitle: \"string\",\n\t\tmembers: \"user[]\",\n\t\tisActive: \"boolean|undefined\"\n\t},\n\tgroup2: {\n\t\ttitle2: \"string\",\n\t\tmembers2: \"user3[]\",\n\t\tisActive2: \"boolean|undefined\"\n\t},\n\tgroup3: {\n\t\ttitle3: \"string\",\n\t\tmembers3: \"user5[]\",\n\t\tisActive3: \"boolean|undefined\"\n\t},\n\tgroup4: {\n\t\ttitle4: \"string\",\n\t\tmembers4: \"user5[]\",\n\t\tisActive4: \"boolean|undefined\"\n\t},\n\tgroup5: {\n\t\ttitle5: \"string\",\n\t\tmembers5: \"user3[]\",\n\t\tisActive5: \"boolean|undefined\"\n\t}\n} as const\n\nexport const cyclic100 = {\n\tuser: {\n\t\tname: \"string\",\n\t\t\"friends?\": \"user[]\",\n\t\tgroups: \"group[]\"\n\t},\n\tuser2: {\n\t\tname2: \"string\",\n\t\t\"friends2?\": \"user33[]\",\n\t\tgroups2: \"group38[]\"\n\t},\n\tuser3: {\n\t\tname3: \"string\",\n\t\t\"friends3?\": \"user30[]\",\n\t\tgroups3: \"group43[]\"\n\t},\n\tuser4: {\n\t\tname4: \"string\",\n\t\t\"friends4?\": \"user2[]\",\n\t\tgroups4: \"group7[]\"\n\t},\n\tuser5: {\n\t\tname5: \"string\",\n\t\t\"friends5?\": \"user21[]\",\n\t\tgroups5: \"group9[]\"\n\t},\n\tuser6: {\n\t\tname6: \"string\",\n\t\t\"friends6?\": \"user14[]\",\n\t\tgroups6: \"group30[]\"\n\t},\n\tuser7: {\n\t\tname7: \"string\",\n\t\t\"friends7?\": \"user16[]\",\n\t\tgroups7: \"group20[]\"\n\t},\n\tuser8: {\n\t\tname8: \"string\",\n\t\t\"friends8?\": \"user27[]\",\n\t\tgroups8: \"group8[]\"\n\t},\n\tuser9: {\n\t\tname9: \"string\",\n\t\t\"friends9?\": \"user33[]\",\n\t\tgroups9: \"group38[]\"\n\t},\n\tuser10: {\n\t\tname10: \"string\",\n\t\t\"friends10?\": \"user11[]\",\n\t\tgroups10: \"group50[]\"\n\t},\n\tuser11: {\n\t\tname11: \"string\",\n\t\t\"friends11?\": \"user47[]\",\n\t\tgroups11: \"group46[]\"\n\t},\n\tuser12: {\n\t\tname12: \"string\",\n\t\t\"friends12?\": \"user44[]\",\n\t\tgroups12: \"group8[]\"\n\t},\n\tuser13: {\n\t\tname13: \"string\",\n\t\t\"friends13?\": \"user29[]\",\n\t\tgroups13: \"group25[]\"\n\t},\n\tuser14: {\n\t\tname14: \"string\",\n\t\t\"friends14?\": \"user35[]\",\n\t\tgroups14: \"group48[]\"\n\t},\n\tuser15: {\n\t\tname15: \"string\",\n\t\t\"friends15?\": \"user29[]\",\n\t\tgroups15: \"group27[]\"\n\t},\n\tuser16: {\n\t\tname16: \"string\",\n\t\t\"friends16?\": \"user16[]\",\n\t\tgroups16: \"group2[]\"\n\t},\n\tuser17: {\n\t\tname17: \"string\",\n\t\t\"friends17?\": \"user28[]\",\n\t\tgroups17: \"group45[]\"\n\t},\n\tuser18: {\n\t\tname18: \"string\",\n\t\t\"friends18?\": \"user16[]\",\n\t\tgroups18: \"group29[]\"\n\t},\n\tuser19: {\n\t\tname19: \"string\",\n\t\t\"friends19?\": \"user41[]\",\n\t\tgroups19: \"group39[]\"\n\t},\n\tuser20: {\n\t\tname20: \"string\",\n\t\t\"friends20?\": \"user6[]\",\n\t\tgroups20: \"group10[]\"\n\t},\n\tuser21: {\n\t\tname21: \"string\",\n\t\t\"friends21?\": \"user29[]\",\n\t\tgroups21: \"group48[]\"\n\t},\n\tuser22: {\n\t\tname22: \"string\",\n\t\t\"friends22?\": \"user42[]\",\n\t\tgroups22: \"group34[]\"\n\t},\n\tuser23: {\n\t\tname23: \"string\",\n\t\t\"friends23?\": \"user48[]\",\n\t\tgroups23: \"group13[]\"\n\t},\n\tuser24: {\n\t\tname24: \"string\",\n\t\t\"friends24?\": \"user7[]\",\n\t\tgroups24: \"group30[]\"\n\t},\n\tuser25: {\n\t\tname25: \"string\",\n\t\t\"friends25?\": \"user44[]\",\n\t\tgroups25: \"group46[]\"\n\t},\n\tuser26: {\n\t\tname26: \"string\",\n\t\t\"friends26?\": \"user27[]\",\n\t\tgroups26: \"group27[]\"\n\t},\n\tuser27: {\n\t\tname27: \"string\",\n\t\t\"friends27?\": \"user43[]\",\n\t\tgroups27: \"group28[]\"\n\t},\n\tuser28: {\n\t\tname28: \"string\",\n\t\t\"friends28?\": \"user21[]\",\n\t\tgroups28: \"group40[]\"\n\t},\n\tuser29: {\n\t\tname29: \"string\",\n\t\t\"friends29?\": \"user14[]\",\n\t\tgroups29: \"group4[]\"\n\t},\n\tuser30: {\n\t\tname30: \"string\",\n\t\t\"friends30?\": \"user7[]\",\n\t\tgroups30: \"group33[]\"\n\t},\n\tuser31: {\n\t\tname31: \"string\",\n\t\t\"friends31?\": \"user29[]\",\n\t\tgroups31: \"group29[]\"\n\t},\n\tuser32: {\n\t\tname32: \"string\",\n\t\t\"friends32?\": \"user4[]\",\n\t\tgroups32: \"group44[]\"\n\t},\n\tuser33: {\n\t\tname33: \"string\",\n\t\t\"friends33?\": \"user37[]\",\n\t\tgroups33: \"group13[]\"\n\t},\n\tuser34: {\n\t\tname34: \"string\",\n\t\t\"friends34?\": \"user39[]\",\n\t\tgroups34: \"group49[]\"\n\t},\n\tuser35: {\n\t\tname35: \"string\",\n\t\t\"friends35?\": \"user36[]\",\n\t\tgroups35: \"group43[]\"\n\t},\n\tuser36: {\n\t\tname36: \"string\",\n\t\t\"friends36?\": \"user11[]\",\n\t\tgroups36: \"group31[]\"\n\t},\n\tuser37: {\n\t\tname37: \"string\",\n\t\t\"friends37?\": \"user11[]\",\n\t\tgroups37: \"group29[]\"\n\t},\n\tuser38: {\n\t\tname38: \"string\",\n\t\t\"friends38?\": \"user35[]\",\n\t\tgroups38: \"group12[]\"\n\t},\n\tuser39: {\n\t\tname39: \"string\",\n\t\t\"friends39?\": \"user21[]\",\n\t\tgroups39: \"group17[]\"\n\t},\n\tuser40: {\n\t\tname40: \"string\",\n\t\t\"friends40?\": \"user11[]\",\n\t\tgroups40: \"group22[]\"\n\t},\n\tuser41: {\n\t\tname41: \"string\",\n\t\t\"friends41?\": \"user32[]\",\n\t\tgroups41: \"group48[]\"\n\t},\n\tuser42: {\n\t\tname42: \"string\",\n\t\t\"friends42?\": \"user39[]\",\n\t\tgroups42: \"group10[]\"\n\t},\n\tuser43: {\n\t\tname43: \"string\",\n\t\t\"friends43?\": \"user19[]\",\n\t\tgroups43: \"group6[]\"\n\t},\n\tuser44: {\n\t\tname44: \"string\",\n\t\t\"friends44?\": \"user8[]\",\n\t\tgroups44: \"group22[]\"\n\t},\n\tuser45: {\n\t\tname45: \"string\",\n\t\t\"friends45?\": \"user31[]\",\n\t\tgroups45: \"group47[]\"\n\t},\n\tuser46: {\n\t\tname46: \"string\",\n\t\t\"friends46?\": \"user33[]\",\n\t\tgroups46: \"group42[]\"\n\t},\n\tuser47: {\n\t\tname47: \"string\",\n\t\t\"friends47?\": \"user20[]\",\n\t\tgroups47: \"group10[]\"\n\t},\n\tuser48: {\n\t\tname48: \"string\",\n\t\t\"friends48?\": \"user23[]\",\n\t\tgroups48: \"group45[]\"\n\t},\n\tuser49: {\n\t\tname49: \"string\",\n\t\t\"friends49?\": \"user42[]\",\n\t\tgroups49: \"group39[]\"\n\t},\n\tuser50: {\n\t\tname50: \"string\",\n\t\t\"friends50?\": \"user37[]\",\n\t\tgroups50: \"group21[]\"\n\t},\n\tgroup: {\n\t\ttitle: \"string\",\n\t\tmembers: \"user[]\",\n\t\tisActive: \"boolean|undefined\"\n\t},\n\tgroup2: {\n\t\ttitle2: \"string\",\n\t\tmembers2: \"user24[]\",\n\t\tisActive2: \"boolean|undefined\"\n\t},\n\tgroup3: {\n\t\ttitle3: \"string\",\n\t\tmembers3: \"user47[]\",\n\t\tisActive3: \"boolean|undefined\"\n\t},\n\tgroup4: {\n\t\ttitle4: \"string\",\n\t\tmembers4: \"user37[]\",\n\t\tisActive4: \"boolean|undefined\"\n\t},\n\tgroup5: {\n\t\ttitle5: \"string\",\n\t\tmembers5: \"user12[]\",\n\t\tisActive5: \"boolean|undefined\"\n\t},\n\tgroup6: {\n\t\ttitle6: \"string\",\n\t\tmembers6: \"user20[]\",\n\t\tisActive6: \"boolean|undefined\"\n\t},\n\tgroup7: {\n\t\ttitle7: \"string\",\n\t\tmembers7: \"user37[]\",\n\t\tisActive7: \"boolean|undefined\"\n\t},\n\tgroup8: {\n\t\ttitle8: \"string\",\n\t\tmembers8: \"user3[]\",\n\t\tisActive8: \"boolean|undefined\"\n\t},\n\tgroup9: {\n\t\ttitle9: \"string\",\n\t\tmembers9: \"user21[]\",\n\t\tisActive9: \"boolean|undefined\"\n\t},\n\tgroup10: {\n\t\ttitle10: \"string\",\n\t\tmembers10: \"user6[]\",\n\t\tisActive10: \"boolean|undefined\"\n\t},\n\tgroup11: {\n\t\ttitle11: \"string\",\n\t\tmembers11: \"user24[]\",\n\t\tisActive11: \"boolean|undefined\"\n\t},\n\tgroup12: {\n\t\ttitle12: \"string\",\n\t\tmembers12: \"user33[]\",\n\t\tisActive12: \"boolean|undefined\"\n\t},\n\tgroup13: {\n\t\ttitle13: \"string\",\n\t\tmembers13: \"user26[]\",\n\t\tisActive13: \"boolean|undefined\"\n\t},\n\tgroup14: {\n\t\ttitle14: \"string\",\n\t\tmembers14: \"user13[]\",\n\t\tisActive14: \"boolean|undefined\"\n\t},\n\tgroup15: {\n\t\ttitle15: \"string\",\n\t\tmembers15: \"user42[]\",\n\t\tisActive15: \"boolean|undefined\"\n\t},\n\tgroup16: {\n\t\ttitle16: \"string\",\n\t\tmembers16: \"user12[]\",\n\t\tisActive16: \"boolean|undefined\"\n\t},\n\tgroup17: {\n\t\ttitle17: \"string\",\n\t\tmembers17: \"user34[]\",\n\t\tisActive17: \"boolean|undefined\"\n\t},\n\tgroup18: {\n\t\ttitle18: \"string\",\n\t\tmembers18: \"user3[]\",\n\t\tisActive18: \"boolean|undefined\"\n\t},\n\tgroup19: {\n\t\ttitle19: \"string\",\n\t\tmembers19: \"user21[]\",\n\t\tisActive19: \"boolean|undefined\"\n\t},\n\tgroup20: {\n\t\ttitle20: \"string\",\n\t\tmembers20: \"user13[]\",\n\t\tisActive20: \"boolean|undefined\"\n\t},\n\tgroup21: {\n\t\ttitle21: \"string\",\n\t\tmembers21: \"user42[]\",\n\t\tisActive21: \"boolean|undefined\"\n\t},\n\tgroup22: {\n\t\ttitle22: \"string\",\n\t\tmembers22: \"user16[]\",\n\t\tisActive22: \"boolean|undefined\"\n\t},\n\tgroup23: {\n\t\ttitle23: \"string\",\n\t\tmembers23: \"user17[]\",\n\t\tisActive23: \"boolean|undefined\"\n\t},\n\tgroup24: {\n\t\ttitle24: \"string\",\n\t\tmembers24: \"user31[]\",\n\t\tisActive24: \"boolean|undefined\"\n\t},\n\tgroup25: {\n\t\ttitle25: \"string\",\n\t\tmembers25: \"user45[]\",\n\t\tisActive25: \"boolean|undefined\"\n\t},\n\tgroup26: {\n\t\ttitle26: \"string\",\n\t\tmembers26: \"user40[]\",\n\t\tisActive26: \"boolean|undefined\"\n\t},\n\tgroup27: {\n\t\ttitle27: \"string\",\n\t\tmembers27: \"user28[]\",\n\t\tisActive27: \"boolean|undefined\"\n\t},\n\tgroup28: {\n\t\ttitle28: \"string\",\n\t\tmembers28: \"user10[]\",\n\t\tisActive28: \"boolean|undefined\"\n\t},\n\tgroup29: {\n\t\ttitle29: \"string\",\n\t\tmembers29: \"user13[]\",\n\t\tisActive29: \"boolean|undefined\"\n\t},\n\tgroup30: {\n\t\ttitle30: \"string\",\n\t\tmembers30: \"user35[]\",\n\t\tisActive30: \"boolean|undefined\"\n\t},\n\tgroup31: {\n\t\ttitle31: \"string\",\n\t\tmembers31: \"user9[]\",\n\t\tisActive31: \"boolean|undefined\"\n\t},\n\tgroup32: {\n\t\ttitle32: \"string\",\n\t\tmembers32: \"user43[]\",\n\t\tisActive32: \"boolean|undefined\"\n\t},\n\tgroup33: {\n\t\ttitle33: \"string\",\n\t\tmembers33: \"user41[]\",\n\t\tisActive33: \"boolean|undefined\"\n\t},\n\tgroup34: {\n\t\ttitle34: \"string\",\n\t\tmembers34: \"user44[]\",\n\t\tisActive34: \"boolean|undefined\"\n\t},\n\tgroup35: {\n\t\ttitle35: \"string\",\n\t\tmembers35: \"user29[]\",\n\t\tisActive35: \"boolean|undefined\"\n\t},\n\tgroup36: {\n\t\ttitle36: \"string\",\n\t\tmembers36: \"user9[]\",\n\t\tisActive36: \"boolean|undefined\"\n\t},\n\tgroup37: {\n\t\ttitle37: \"string\",\n\t\tmembers37: \"user3[]\",\n\t\tisActive37: \"boolean|undefined\"\n\t},\n\tgroup38: {\n\t\ttitle38: \"string\",\n\t\tmembers38: \"user31[]\",\n\t\tisActive38: \"boolean|undefined\"\n\t},\n\tgroup39: {\n\t\ttitle39: \"string\",\n\t\tmembers39: \"user29[]\",\n\t\tisActive39: \"boolean|undefined\"\n\t},\n\tgroup40: {\n\t\ttitle40: \"string\",\n\t\tmembers40: \"user5[]\",\n\t\tisActive40: \"boolean|undefined\"\n\t},\n\tgroup41: {\n\t\ttitle41: \"string\",\n\t\tmembers41: \"user16[]\",\n\t\tisActive41: \"boolean|undefined\"\n\t},\n\tgroup42: {\n\t\ttitle42: \"string\",\n\t\tmembers42: \"user24[]\",\n\t\tisActive42: \"boolean|undefined\"\n\t},\n\tgroup43: {\n\t\ttitle43: \"string\",\n\t\tmembers43: \"user25[]\",\n\t\tisActive43: \"boolean|undefined\"\n\t},\n\tgroup44: {\n\t\ttitle44: \"string\",\n\t\tmembers44: \"user38[]\",\n\t\tisActive44: \"boolean|undefined\"\n\t},\n\tgroup45: {\n\t\ttitle45: \"string\",\n\t\tmembers45: \"user26[]\",\n\t\tisActive45: \"boolean|undefined\"\n\t},\n\tgroup46: {\n\t\ttitle46: \"string\",\n\t\tmembers46: \"user21[]\",\n\t\tisActive46: \"boolean|undefined\"\n\t},\n\tgroup47: {\n\t\ttitle47: \"string\",\n\t\tmembers47: \"user35[]\",\n\t\tisActive47: \"boolean|undefined\"\n\t},\n\tgroup48: {\n\t\ttitle48: \"string\",\n\t\tmembers48: \"user17[]\",\n\t\tisActive48: \"boolean|undefined\"\n\t},\n\tgroup49: {\n\t\ttitle49: \"string\",\n\t\tmembers49: \"user4[]\",\n\t\tisActive49: \"boolean|undefined\"\n\t},\n\tgroup50: {\n\t\ttitle50: \"string\",\n\t\tmembers50: \"user15[]\",\n\t\tisActive50: \"boolean|undefined\"\n\t}\n} as const\n\nexport const cyclic500 = {\n\tuser: {\n\t\tname: \"string\",\n\t\t\"friends?\": \"user[]\",\n\t\tgroups: \"group[]\"\n\t},\n\tuser2: {\n\t\tname2: \"string\",\n\t\t\"friends2?\": \"user124[]\",\n\t\tgroups2: \"group85[]\"\n\t},\n\tuser3: {\n\t\tname3: \"string\",\n\t\t\"friends3?\": \"user130[]\",\n\t\tgroups3: \"group159[]\"\n\t},\n\tuser4: {\n\t\tname4: \"string\",\n\t\t\"friends4?\": \"user238[]\",\n\t\tgroups4: \"group171[]\"\n\t},\n\tuser5: {\n\t\tname5: \"string\",\n\t\t\"friends5?\": \"user22[]\",\n\t\tgroups5: \"group13[]\"\n\t},\n\tuser6: {\n\t\tname6: \"string\",\n\t\t\"friends6?\": \"user107[]\",\n\t\tgroups6: \"group18[]\"\n\t},\n\tuser7: {\n\t\tname7: \"string\",\n\t\t\"friends7?\": \"user194[]\",\n\t\tgroups7: \"group6[]\"\n\t},\n\tuser8: {\n\t\tname8: \"string\",\n\t\t\"friends8?\": \"user226[]\",\n\t\tgroups8: \"group26[]\"\n\t},\n\tuser9: {\n\t\tname9: \"string\",\n\t\t\"friends9?\": \"user193[]\",\n\t\tgroups9: \"group108[]\"\n\t},\n\tuser10: {\n\t\tname10: \"string\",\n\t\t\"friends10?\": \"user194[]\",\n\t\tgroups10: \"group242[]\"\n\t},\n\tuser11: {\n\t\tname11: \"string\",\n\t\t\"friends11?\": \"user11[]\",\n\t\tgroups11: \"group67[]\"\n\t},\n\tuser12: {\n\t\tname12: \"string\",\n\t\t\"friends12?\": \"user240[]\",\n\t\tgroups12: \"group10[]\"\n\t},\n\tuser13: {\n\t\tname13: \"string\",\n\t\t\"friends13?\": \"user213[]\",\n\t\tgroups13: \"group11[]\"\n\t},\n\tuser14: {\n\t\tname14: \"string\",\n\t\t\"friends14?\": \"user63[]\",\n\t\tgroups14: \"group157[]\"\n\t},\n\tuser15: {\n\t\tname15: \"string\",\n\t\t\"friends15?\": \"user48[]\",\n\t\tgroups15: \"group244[]\"\n\t},\n\tuser16: {\n\t\tname16: \"string\",\n\t\t\"friends16?\": \"user21[]\",\n\t\tgroups16: \"group72[]\"\n\t},\n\tuser17: {\n\t\tname17: \"string\",\n\t\t\"friends17?\": \"user160[]\",\n\t\tgroups17: \"group115[]\"\n\t},\n\tuser18: {\n\t\tname18: \"string\",\n\t\t\"friends18?\": \"user46[]\",\n\t\tgroups18: \"group166[]\"\n\t},\n\tuser19: {\n\t\tname19: \"string\",\n\t\t\"friends19?\": \"user217[]\",\n\t\tgroups19: \"group165[]\"\n\t},\n\tuser20: {\n\t\tname20: \"string\",\n\t\t\"friends20?\": \"user163[]\",\n\t\tgroups20: \"group182[]\"\n\t},\n\tuser21: {\n\t\tname21: \"string\",\n\t\t\"friends21?\": \"user177[]\",\n\t\tgroups21: \"group178[]\"\n\t},\n\tuser22: {\n\t\tname22: \"string\",\n\t\t\"friends22?\": \"user140[]\",\n\t\tgroups22: \"group70[]\"\n\t},\n\tuser23: {\n\t\tname23: \"string\",\n\t\t\"friends23?\": \"user120[]\",\n\t\tgroups23: \"group12[]\"\n\t},\n\tuser24: {\n\t\tname24: \"string\",\n\t\t\"friends24?\": \"user33[]\",\n\t\tgroups24: \"group18[]\"\n\t},\n\tuser25: {\n\t\tname25: \"string\",\n\t\t\"friends25?\": \"user91[]\",\n\t\tgroups25: \"group226[]\"\n\t},\n\tuser26: {\n\t\tname26: \"string\",\n\t\t\"friends26?\": \"user43[]\",\n\t\tgroups26: \"group230[]\"\n\t},\n\tuser27: {\n\t\tname27: \"string\",\n\t\t\"friends27?\": \"user34[]\",\n\t\tgroups27: \"group49[]\"\n\t},\n\tuser28: {\n\t\tname28: \"string\",\n\t\t\"friends28?\": \"user46[]\",\n\t\tgroups28: \"group100[]\"\n\t},\n\tuser29: {\n\t\tname29: \"string\",\n\t\t\"friends29?\": \"user20[]\",\n\t\tgroups29: \"group250[]\"\n\t},\n\tuser30: {\n\t\tname30: \"string\",\n\t\t\"friends30?\": \"user56[]\",\n\t\tgroups30: \"group100[]\"\n\t},\n\tuser31: {\n\t\tname31: \"string\",\n\t\t\"friends31?\": \"user215[]\",\n\t\tgroups31: \"group169[]\"\n\t},\n\tuser32: {\n\t\tname32: \"string\",\n\t\t\"friends32?\": \"user65[]\",\n\t\tgroups32: \"group247[]\"\n\t},\n\tuser33: {\n\t\tname33: \"string\",\n\t\t\"friends33?\": \"user192[]\",\n\t\tgroups33: \"group38[]\"\n\t},\n\tuser34: {\n\t\tname34: \"string\",\n\t\t\"friends34?\": \"user147[]\",\n\t\tgroups34: \"group102[]\"\n\t},\n\tuser35: {\n\t\tname35: \"string\",\n\t\t\"friends35?\": \"user140[]\",\n\t\tgroups35: \"group47[]\"\n\t},\n\tuser36: {\n\t\tname36: \"string\",\n\t\t\"friends36?\": \"user168[]\",\n\t\tgroups36: \"group185[]\"\n\t},\n\tuser37: {\n\t\tname37: \"string\",\n\t\t\"friends37?\": \"user241[]\",\n\t\tgroups37: \"group127[]\"\n\t},\n\tuser38: {\n\t\tname38: \"string\",\n\t\t\"friends38?\": \"user175[]\",\n\t\tgroups38: \"group148[]\"\n\t},\n\tuser39: {\n\t\tname39: \"string\",\n\t\t\"friends39?\": \"user71[]\",\n\t\tgroups39: \"group212[]\"\n\t},\n\tuser40: {\n\t\tname40: \"string\",\n\t\t\"friends40?\": \"user64[]\",\n\t\tgroups40: \"group241[]\"\n\t},\n\tuser41: {\n\t\tname41: \"string\",\n\t\t\"friends41?\": \"user177[]\",\n\t\tgroups41: \"group185[]\"\n\t},\n\tuser42: {\n\t\tname42: \"string\",\n\t\t\"friends42?\": \"user97[]\",\n\t\tgroups42: \"group242[]\"\n\t},\n\tuser43: {\n\t\tname43: \"string\",\n\t\t\"friends43?\": \"user109[]\",\n\t\tgroups43: \"group91[]\"\n\t},\n\tuser44: {\n\t\tname44: \"string\",\n\t\t\"friends44?\": \"user131[]\",\n\t\tgroups44: \"group126[]\"\n\t},\n\tuser45: {\n\t\tname45: \"string\",\n\t\t\"friends45?\": \"user23[]\",\n\t\tgroups45: \"group10[]\"\n\t},\n\tuser46: {\n\t\tname46: \"string\",\n\t\t\"friends46?\": \"user9[]\",\n\t\tgroups46: \"group146[]\"\n\t},\n\tuser47: {\n\t\tname47: \"string\",\n\t\t\"friends47?\": \"user163[]\",\n\t\tgroups47: \"group186[]\"\n\t},\n\tuser48: {\n\t\tname48: \"string\",\n\t\t\"friends48?\": \"user211[]\",\n\t\tgroups48: \"group128[]\"\n\t},\n\tuser49: {\n\t\tname49: \"string\",\n\t\t\"friends49?\": \"user154[]\",\n\t\tgroups49: \"group149[]\"\n\t},\n\tuser50: {\n\t\tname50: \"string\",\n\t\t\"friends50?\": \"user67[]\",\n\t\tgroups50: \"group78[]\"\n\t},\n\tuser51: {\n\t\tname51: \"string\",\n\t\t\"friends51?\": \"user39[]\",\n\t\tgroups51: \"group193[]\"\n\t},\n\tuser52: {\n\t\tname52: \"string\",\n\t\t\"friends52?\": \"user132[]\",\n\t\tgroups52: \"group41[]\"\n\t},\n\tuser53: {\n\t\tname53: \"string\",\n\t\t\"friends53?\": \"user223[]\",\n\t\tgroups53: \"group58[]\"\n\t},\n\tuser54: {\n\t\tname54: \"string\",\n\t\t\"friends54?\": \"user228[]\",\n\t\tgroups54: \"group68[]\"\n\t},\n\tuser55: {\n\t\tname55: \"string\",\n\t\t\"friends55?\": \"user29[]\",\n\t\tgroups55: \"group22[]\"\n\t},\n\tuser56: {\n\t\tname56: \"string\",\n\t\t\"friends56?\": \"user152[]\",\n\t\tgroups56: \"group101[]\"\n\t},\n\tuser57: {\n\t\tname57: \"string\",\n\t\t\"friends57?\": \"user66[]\",\n\t\tgroups57: \"group138[]\"\n\t},\n\tuser58: {\n\t\tname58: \"string\",\n\t\t\"friends58?\": \"user60[]\",\n\t\tgroups58: \"group178[]\"\n\t},\n\tuser59: {\n\t\tname59: \"string\",\n\t\t\"friends59?\": \"user110[]\",\n\t\tgroups59: \"group197[]\"\n\t},\n\tuser60: {\n\t\tname60: \"string\",\n\t\t\"friends60?\": \"user154[]\",\n\t\tgroups60: \"group37[]\"\n\t},\n\tuser61: {\n\t\tname61: \"string\",\n\t\t\"friends61?\": \"user40[]\",\n\t\tgroups61: \"group11[]\"\n\t},\n\tuser62: {\n\t\tname62: \"string\",\n\t\t\"friends62?\": \"user227[]\",\n\t\tgroups62: \"group242[]\"\n\t},\n\tuser63: {\n\t\tname63: \"string\",\n\t\t\"friends63?\": \"user51[]\",\n\t\tgroups63: \"group34[]\"\n\t},\n\tuser64: {\n\t\tname64: \"string\",\n\t\t\"friends64?\": \"user51[]\",\n\t\tgroups64: \"group167[]\"\n\t},\n\tuser65: {\n\t\tname65: \"string\",\n\t\t\"friends65?\": \"user149[]\",\n\t\tgroups65: \"group16[]\"\n\t},\n\tuser66: {\n\t\tname66: \"string\",\n\t\t\"friends66?\": \"user178[]\",\n\t\tgroups66: \"group244[]\"\n\t},\n\tuser67: {\n\t\tname67: \"string\",\n\t\t\"friends67?\": \"user239[]\",\n\t\tgroups67: \"group6[]\"\n\t},\n\tuser68: {\n\t\tname68: \"string\",\n\t\t\"friends68?\": \"user121[]\",\n\t\tgroups68: \"group127[]\"\n\t},\n\tuser69: {\n\t\tname69: \"string\",\n\t\t\"friends69?\": \"user203[]\",\n\t\tgroups69: \"group156[]\"\n\t},\n\tuser70: {\n\t\tname70: \"string\",\n\t\t\"friends70?\": \"user144[]\",\n\t\tgroups70: \"group149[]\"\n\t},\n\tuser71: {\n\t\tname71: \"string\",\n\t\t\"friends71?\": \"user19[]\",\n\t\tgroups71: \"group18[]\"\n\t},\n\tuser72: {\n\t\tname72: \"string\",\n\t\t\"friends72?\": \"user30[]\",\n\t\tgroups72: \"group17[]\"\n\t},\n\tuser73: {\n\t\tname73: \"string\",\n\t\t\"friends73?\": \"user12[]\",\n\t\tgroups73: \"group116[]\"\n\t},\n\tuser74: {\n\t\tname74: \"string\",\n\t\t\"friends74?\": \"user93[]\",\n\t\tgroups74: \"group210[]\"\n\t},\n\tuser75: {\n\t\tname75: \"string\",\n\t\t\"friends75?\": \"user3[]\",\n\t\tgroups75: \"group33[]\"\n\t},\n\tuser76: {\n\t\tname76: \"string\",\n\t\t\"friends76?\": \"user56[]\",\n\t\tgroups76: \"group52[]\"\n\t},\n\tuser77: {\n\t\tname77: \"string\",\n\t\t\"friends77?\": \"user157[]\",\n\t\tgroups77: \"group239[]\"\n\t},\n\tuser78: {\n\t\tname78: \"string\",\n\t\t\"friends78?\": \"user147[]\",\n\t\tgroups78: \"group190[]\"\n\t},\n\tuser79: {\n\t\tname79: \"string\",\n\t\t\"friends79?\": \"user167[]\",\n\t\tgroups79: \"group82[]\"\n\t},\n\tuser80: {\n\t\tname80: \"string\",\n\t\t\"friends80?\": \"user42[]\",\n\t\tgroups80: \"group245[]\"\n\t},\n\tuser81: {\n\t\tname81: \"string\",\n\t\t\"friends81?\": \"user212[]\",\n\t\tgroups81: \"group67[]\"\n\t},\n\tuser82: {\n\t\tname82: \"string\",\n\t\t\"friends82?\": \"user124[]\",\n\t\tgroups82: \"group59[]\"\n\t},\n\tuser83: {\n\t\tname83: \"string\",\n\t\t\"friends83?\": \"user31[]\",\n\t\tgroups83: \"group17[]\"\n\t},\n\tuser84: {\n\t\tname84: \"string\",\n\t\t\"friends84?\": \"user15[]\",\n\t\tgroups84: \"group161[]\"\n\t},\n\tuser85: {\n\t\tname85: \"string\",\n\t\t\"friends85?\": \"user56[]\",\n\t\tgroups85: \"group208[]\"\n\t},\n\tuser86: {\n\t\tname86: \"string\",\n\t\t\"friends86?\": \"user205[]\",\n\t\tgroups86: \"group213[]\"\n\t},\n\tuser87: {\n\t\tname87: \"string\",\n\t\t\"friends87?\": \"user40[]\",\n\t\tgroups87: \"group88[]\"\n\t},\n\tuser88: {\n\t\tname88: \"string\",\n\t\t\"friends88?\": \"user176[]\",\n\t\tgroups88: \"group74[]\"\n\t},\n\tuser89: {\n\t\tname89: \"string\",\n\t\t\"friends89?\": \"user79[]\",\n\t\tgroups89: \"group132[]\"\n\t},\n\tuser90: {\n\t\tname90: \"string\",\n\t\t\"friends90?\": \"user4[]\",\n\t\tgroups90: \"group181[]\"\n\t},\n\tuser91: {\n\t\tname91: \"string\",\n\t\t\"friends91?\": \"user33[]\",\n\t\tgroups91: \"group217[]\"\n\t},\n\tuser92: {\n\t\tname92: \"string\",\n\t\t\"friends92?\": \"user55[]\",\n\t\tgroups92: \"group145[]\"\n\t},\n\tuser93: {\n\t\tname93: \"string\",\n\t\t\"friends93?\": \"user209[]\",\n\t\tgroups93: \"group53[]\"\n\t},\n\tuser94: {\n\t\tname94: \"string\",\n\t\t\"friends94?\": \"user215[]\",\n\t\tgroups94: \"group124[]\"\n\t},\n\tuser95: {\n\t\tname95: \"string\",\n\t\t\"friends95?\": \"user40[]\",\n\t\tgroups95: \"group42[]\"\n\t},\n\tuser96: {\n\t\tname96: \"string\",\n\t\t\"friends96?\": \"user132[]\",\n\t\tgroups96: \"group113[]\"\n\t},\n\tuser97: {\n\t\tname97: \"string\",\n\t\t\"friends97?\": \"user81[]\",\n\t\tgroups97: \"group173[]\"\n\t},\n\tuser98: {\n\t\tname98: \"string\",\n\t\t\"friends98?\": \"user34[]\",\n\t\tgroups98: \"group34[]\"\n\t},\n\tuser99: {\n\t\tname99: \"string\",\n\t\t\"friends99?\": \"user81[]\",\n\t\tgroups99: \"group197[]\"\n\t},\n\tuser100: {\n\t\tname100: \"string\",\n\t\t\"friends100?\": \"user102[]\",\n\t\tgroups100: \"group149[]\"\n\t},\n\tuser101: {\n\t\tname101: \"string\",\n\t\t\"friends101?\": \"user198[]\",\n\t\tgroups101: \"group81[]\"\n\t},\n\tuser102: {\n\t\tname102: \"string\",\n\t\t\"friends102?\": \"user206[]\",\n\t\tgroups102: \"group81[]\"\n\t},\n\tuser103: {\n\t\tname103: \"string\",\n\t\t\"friends103?\": \"user14[]\",\n\t\tgroups103: \"group42[]\"\n\t},\n\tuser104: {\n\t\tname104: \"string\",\n\t\t\"friends104?\": \"user45[]\",\n\t\tgroups104: \"group233[]\"\n\t},\n\tuser105: {\n\t\tname105: \"string\",\n\t\t\"friends105?\": \"user51[]\",\n\t\tgroups105: \"group8[]\"\n\t},\n\tuser106: {\n\t\tname106: \"string\",\n\t\t\"friends106?\": \"user103[]\",\n\t\tgroups106: \"group109[]\"\n\t},\n\tuser107: {\n\t\tname107: \"string\",\n\t\t\"friends107?\": \"user48[]\",\n\t\tgroups107: \"group146[]\"\n\t},\n\tuser108: {\n\t\tname108: \"string\",\n\t\t\"friends108?\": \"user217[]\",\n\t\tgroups108: \"group101[]\"\n\t},\n\tuser109: {\n\t\tname109: \"string\",\n\t\t\"friends109?\": \"user33[]\",\n\t\tgroups109: \"group142[]\"\n\t},\n\tuser110: {\n\t\tname110: \"string\",\n\t\t\"friends110?\": \"user204[]\",\n\t\tgroups110: \"group11[]\"\n\t},\n\tuser111: {\n\t\tname111: \"string\",\n\t\t\"friends111?\": \"user209[]\",\n\t\tgroups111: \"group185[]\"\n\t},\n\tuser112: {\n\t\tname112: \"string\",\n\t\t\"friends112?\": \"user27[]\",\n\t\tgroups112: \"group221[]\"\n\t},\n\tuser113: {\n\t\tname113: \"string\",\n\t\t\"friends113?\": \"user166[]\",\n\t\tgroups113: \"group154[]\"\n\t},\n\tuser114: {\n\t\tname114: \"string\",\n\t\t\"friends114?\": \"user239[]\",\n\t\tgroups114: \"group49[]\"\n\t},\n\tuser115: {\n\t\tname115: \"string\",\n\t\t\"friends115?\": \"user165[]\",\n\t\tgroups115: \"group187[]\"\n\t},\n\tuser116: {\n\t\tname116: \"string\",\n\t\t\"friends116?\": \"user31[]\",\n\t\tgroups116: \"group93[]\"\n\t},\n\tuser117: {\n\t\tname117: \"string\",\n\t\t\"friends117?\": \"user220[]\",\n\t\tgroups117: \"group210[]\"\n\t},\n\tuser118: {\n\t\tname118: \"string\",\n\t\t\"friends118?\": \"user34[]\",\n\t\tgroups118: \"group84[]\"\n\t},\n\tuser119: {\n\t\tname119: \"string\",\n\t\t\"friends119?\": \"user241[]\",\n\t\tgroups119: \"group225[]\"\n\t},\n\tuser120: {\n\t\tname120: \"string\",\n\t\t\"friends120?\": \"user155[]\",\n\t\tgroups120: \"group25[]\"\n\t},\n\tuser121: {\n\t\tname121: \"string\",\n\t\t\"friends121?\": \"user78[]\",\n\t\tgroups121: \"group132[]\"\n\t},\n\tuser122: {\n\t\tname122: \"string\",\n\t\t\"friends122?\": \"user8[]\",\n\t\tgroups122: \"group235[]\"\n\t},\n\tuser123: {\n\t\tname123: \"string\",\n\t\t\"friends123?\": \"user119[]\",\n\t\tgroups123: \"group231[]\"\n\t},\n\tuser124: {\n\t\tname124: \"string\",\n\t\t\"friends124?\": \"user107[]\",\n\t\tgroups124: \"group175[]\"\n\t},\n\tuser125: {\n\t\tname125: \"string\",\n\t\t\"friends125?\": \"user16[]\",\n\t\tgroups125: \"group172[]\"\n\t},\n\tuser126: {\n\t\tname126: \"string\",\n\t\t\"friends126?\": \"user88[]\",\n\t\tgroups126: \"group153[]\"\n\t},\n\tuser127: {\n\t\tname127: \"string\",\n\t\t\"friends127?\": \"user168[]\",\n\t\tgroups127: \"group78[]\"\n\t},\n\tuser128: {\n\t\tname128: \"string\",\n\t\t\"friends128?\": \"user59[]\",\n\t\tgroups128: \"group58[]\"\n\t},\n\tuser129: {\n\t\tname129: \"string\",\n\t\t\"friends129?\": \"user218[]\",\n\t\tgroups129: \"group178[]\"\n\t},\n\tuser130: {\n\t\tname130: \"string\",\n\t\t\"friends130?\": \"user47[]\",\n\t\tgroups130: \"group26[]\"\n\t},\n\tuser131: {\n\t\tname131: \"string\",\n\t\t\"friends131?\": \"user180[]\",\n\t\tgroups131: \"group64[]\"\n\t},\n\tuser132: {\n\t\tname132: \"string\",\n\t\t\"friends132?\": \"user86[]\",\n\t\tgroups132: \"group231[]\"\n\t},\n\tuser133: {\n\t\tname133: \"string\",\n\t\t\"friends133?\": \"user189[]\",\n\t\tgroups133: \"group95[]\"\n\t},\n\tuser134: {\n\t\tname134: \"string\",\n\t\t\"friends134?\": \"user58[]\",\n\t\tgroups134: \"group13[]\"\n\t},\n\tuser135: {\n\t\tname135: \"string\",\n\t\t\"friends135?\": \"user151[]\",\n\t\tgroups135: \"group49[]\"\n\t},\n\tuser136: {\n\t\tname136: \"string\",\n\t\t\"friends136?\": \"user31[]\",\n\t\tgroups136: \"group186[]\"\n\t},\n\tuser137: {\n\t\tname137: \"string\",\n\t\t\"friends137?\": \"user164[]\",\n\t\tgroups137: \"group147[]\"\n\t},\n\tuser138: {\n\t\tname138: \"string\",\n\t\t\"friends138?\": \"user234[]\",\n\t\tgroups138: \"group16[]\"\n\t},\n\tuser139: {\n\t\tname139: \"string\",\n\t\t\"friends139?\": \"user237[]\",\n\t\tgroups139: \"group242[]\"\n\t},\n\tuser140: {\n\t\tname140: \"string\",\n\t\t\"friends140?\": \"user44[]\",\n\t\tgroups140: \"group62[]\"\n\t},\n\tuser141: {\n\t\tname141: \"string\",\n\t\t\"friends141?\": \"user219[]\",\n\t\tgroups141: \"group106[]\"\n\t},\n\tuser142: {\n\t\tname142: \"string\",\n\t\t\"friends142?\": \"user192[]\",\n\t\tgroups142: \"group47[]\"\n\t},\n\tuser143: {\n\t\tname143: \"string\",\n\t\t\"friends143?\": \"user103[]\",\n\t\tgroups143: \"group106[]\"\n\t},\n\tuser144: {\n\t\tname144: \"string\",\n\t\t\"friends144?\": \"user198[]\",\n\t\tgroups144: \"group37[]\"\n\t},\n\tuser145: {\n\t\tname145: \"string\",\n\t\t\"friends145?\": \"user168[]\",\n\t\tgroups145: \"group71[]\"\n\t},\n\tuser146: {\n\t\tname146: \"string\",\n\t\t\"friends146?\": \"user18[]\",\n\t\tgroups146: \"group79[]\"\n\t},\n\tuser147: {\n\t\tname147: \"string\",\n\t\t\"friends147?\": \"user190[]\",\n\t\tgroups147: \"group93[]\"\n\t},\n\tuser148: {\n\t\tname148: \"string\",\n\t\t\"friends148?\": \"user141[]\",\n\t\tgroups148: \"group110[]\"\n\t},\n\tuser149: {\n\t\tname149: \"string\",\n\t\t\"friends149?\": \"user80[]\",\n\t\tgroups149: \"group249[]\"\n\t},\n\tuser150: {\n\t\tname150: \"string\",\n\t\t\"friends150?\": \"user98[]\",\n\t\tgroups150: \"group145[]\"\n\t},\n\tuser151: {\n\t\tname151: \"string\",\n\t\t\"friends151?\": \"user180[]\",\n\t\tgroups151: \"group39[]\"\n\t},\n\tuser152: {\n\t\tname152: \"string\",\n\t\t\"friends152?\": \"user208[]\",\n\t\tgroups152: \"group68[]\"\n\t},\n\tuser153: {\n\t\tname153: \"string\",\n\t\t\"friends153?\": \"user51[]\",\n\t\tgroups153: \"group42[]\"\n\t},\n\tuser154: {\n\t\tname154: \"string\",\n\t\t\"friends154?\": \"user66[]\",\n\t\tgroups154: \"group229[]\"\n\t},\n\tuser155: {\n\t\tname155: \"string\",\n\t\t\"friends155?\": \"user211[]\",\n\t\tgroups155: \"group42[]\"\n\t},\n\tuser156: {\n\t\tname156: \"string\",\n\t\t\"friends156?\": \"user187[]\",\n\t\tgroups156: \"group125[]\"\n\t},\n\tuser157: {\n\t\tname157: \"string\",\n\t\t\"friends157?\": \"user234[]\",\n\t\tgroups157: \"group81[]\"\n\t},\n\tuser158: {\n\t\tname158: \"string\",\n\t\t\"friends158?\": \"user88[]\",\n\t\tgroups158: \"group33[]\"\n\t},\n\tuser159: {\n\t\tname159: \"string\",\n\t\t\"friends159?\": \"user35[]\",\n\t\tgroups159: \"group188[]\"\n\t},\n\tuser160: {\n\t\tname160: \"string\",\n\t\t\"friends160?\": \"user135[]\",\n\t\tgroups160: \"group207[]\"\n\t},\n\tuser161: {\n\t\tname161: \"string\",\n\t\t\"friends161?\": \"user145[]\",\n\t\tgroups161: \"group240[]\"\n\t},\n\tuser162: {\n\t\tname162: \"string\",\n\t\t\"friends162?\": \"user15[]\",\n\t\tgroups162: \"group7[]\"\n\t},\n\tuser163: {\n\t\tname163: \"string\",\n\t\t\"friends163?\": \"user113[]\",\n\t\tgroups163: \"group67[]\"\n\t},\n\tuser164: {\n\t\tname164: \"string\",\n\t\t\"friends164?\": \"user6[]\",\n\t\tgroups164: \"group197[]\"\n\t},\n\tuser165: {\n\t\tname165: \"string\",\n\t\t\"friends165?\": \"user174[]\",\n\t\tgroups165: \"group220[]\"\n\t},\n\tuser166: {\n\t\tname166: \"string\",\n\t\t\"friends166?\": \"user98[]\",\n\t\tgroups166: \"group74[]\"\n\t},\n\tuser167: {\n\t\tname167: \"string\",\n\t\t\"friends167?\": \"user203[]\",\n\t\tgroups167: \"group89[]\"\n\t},\n\tuser168: {\n\t\tname168: \"string\",\n\t\t\"friends168?\": \"user42[]\",\n\t\tgroups168: \"group246[]\"\n\t},\n\tuser169: {\n\t\tname169: \"string\",\n\t\t\"friends169?\": \"user36[]\",\n\t\tgroups169: \"group7[]\"\n\t},\n\tuser170: {\n\t\tname170: \"string\",\n\t\t\"friends170?\": \"user89[]\",\n\t\tgroups170: \"group234[]\"\n\t},\n\tuser171: {\n\t\tname171: \"string\",\n\t\t\"friends171?\": \"user245[]\",\n\t\tgroups171: \"group105[]\"\n\t},\n\tuser172: {\n\t\tname172: \"string\",\n\t\t\"friends172?\": \"user130[]\",\n\t\tgroups172: \"group219[]\"\n\t},\n\tuser173: {\n\t\tname173: \"string\",\n\t\t\"friends173?\": \"user194[]\",\n\t\tgroups173: \"group59[]\"\n\t},\n\tuser174: {\n\t\tname174: \"string\",\n\t\t\"friends174?\": \"user95[]\",\n\t\tgroups174: \"group109[]\"\n\t},\n\tuser175: {\n\t\tname175: \"string\",\n\t\t\"friends175?\": \"user241[]\",\n\t\tgroups175: \"group155[]\"\n\t},\n\tuser176: {\n\t\tname176: \"string\",\n\t\t\"friends176?\": \"user139[]\",\n\t\tgroups176: \"group136[]\"\n\t},\n\tuser177: {\n\t\tname177: \"string\",\n\t\t\"friends177?\": \"user166[]\",\n\t\tgroups177: \"group34[]\"\n\t},\n\tuser178: {\n\t\tname178: \"string\",\n\t\t\"friends178?\": \"user159[]\",\n\t\tgroups178: \"group94[]\"\n\t},\n\tuser179: {\n\t\tname179: \"string\",\n\t\t\"friends179?\": \"user68[]\",\n\t\tgroups179: \"group56[]\"\n\t},\n\tuser180: {\n\t\tname180: \"string\",\n\t\t\"friends180?\": \"user30[]\",\n\t\tgroups180: \"group235[]\"\n\t},\n\tuser181: {\n\t\tname181: \"string\",\n\t\t\"friends181?\": \"user69[]\",\n\t\tgroups181: \"group84[]\"\n\t},\n\tuser182: {\n\t\tname182: \"string\",\n\t\t\"friends182?\": \"user131[]\",\n\t\tgroups182: \"group158[]\"\n\t},\n\tuser183: {\n\t\tname183: \"string\",\n\t\t\"friends183?\": \"user124[]\",\n\t\tgroups183: \"group192[]\"\n\t},\n\tuser184: {\n\t\tname184: \"string\",\n\t\t\"friends184?\": \"user175[]\",\n\t\tgroups184: \"group87[]\"\n\t},\n\tuser185: {\n\t\tname185: \"string\",\n\t\t\"friends185?\": \"user250[]\",\n\t\tgroups185: \"group130[]\"\n\t},\n\tuser186: {\n\t\tname186: \"string\",\n\t\t\"friends186?\": \"user97[]\",\n\t\tgroups186: \"group207[]\"\n\t},\n\tuser187: {\n\t\tname187: \"string\",\n\t\t\"friends187?\": \"user102[]\",\n\t\tgroups187: \"group141[]\"\n\t},\n\tuser188: {\n\t\tname188: \"string\",\n\t\t\"friends188?\": \"user248[]\",\n\t\tgroups188: \"group158[]\"\n\t},\n\tuser189: {\n\t\tname189: \"string\",\n\t\t\"friends189?\": \"user191[]\",\n\t\tgroups189: \"group12[]\"\n\t},\n\tuser190: {\n\t\tname190: \"string\",\n\t\t\"friends190?\": \"user164[]\",\n\t\tgroups190: \"group137[]\"\n\t},\n\tuser191: {\n\t\tname191: \"string\",\n\t\t\"friends191?\": \"user128[]\",\n\t\tgroups191: \"group138[]\"\n\t},\n\tuser192: {\n\t\tname192: \"string\",\n\t\t\"friends192?\": \"user130[]\",\n\t\tgroups192: \"group185[]\"\n\t},\n\tuser193: {\n\t\tname193: \"string\",\n\t\t\"friends193?\": \"user110[]\",\n\t\tgroups193: \"group195[]\"\n\t},\n\tuser194: {\n\t\tname194: \"string\",\n\t\t\"friends194?\": \"user12[]\",\n\t\tgroups194: \"group76[]\"\n\t},\n\tuser195: {\n\t\tname195: \"string\",\n\t\t\"friends195?\": \"user89[]\",\n\t\tgroups195: \"group46[]\"\n\t},\n\tuser196: {\n\t\tname196: \"string\",\n\t\t\"friends196?\": \"user186[]\",\n\t\tgroups196: \"group16[]\"\n\t},\n\tuser197: {\n\t\tname197: \"string\",\n\t\t\"friends197?\": \"user246[]\",\n\t\tgroups197: \"group154[]\"\n\t},\n\tuser198: {\n\t\tname198: \"string\",\n\t\t\"friends198?\": \"user207[]\",\n\t\tgroups198: \"group51[]\"\n\t},\n\tuser199: {\n\t\tname199: \"string\",\n\t\t\"friends199?\": \"user220[]\",\n\t\tgroups199: \"group132[]\"\n\t},\n\tuser200: {\n\t\tname200: \"string\",\n\t\t\"friends200?\": \"user177[]\",\n\t\tgroups200: \"group109[]\"\n\t},\n\tuser201: {\n\t\tname201: \"string\",\n\t\t\"friends201?\": \"user246[]\",\n\t\tgroups201: \"group236[]\"\n\t},\n\tuser202: {\n\t\tname202: \"string\",\n\t\t\"friends202?\": \"user202[]\",\n\t\tgroups202: \"group127[]\"\n\t},\n\tuser203: {\n\t\tname203: \"string\",\n\t\t\"friends203?\": \"user18[]\",\n\t\tgroups203: \"group122[]\"\n\t},\n\tuser204: {\n\t\tname204: \"string\",\n\t\t\"friends204?\": \"user132[]\",\n\t\tgroups204: \"group208[]\"\n\t},\n\tuser205: {\n\t\tname205: \"string\",\n\t\t\"friends205?\": \"user132[]\",\n\t\tgroups205: \"group92[]\"\n\t},\n\tuser206: {\n\t\tname206: \"string\",\n\t\t\"friends206?\": \"user229[]\",\n\t\tgroups206: \"group118[]\"\n\t},\n\tuser207: {\n\t\tname207: \"string\",\n\t\t\"friends207?\": \"user171[]\",\n\t\tgroups207: \"group235[]\"\n\t},\n\tuser208: {\n\t\tname208: \"string\",\n\t\t\"friends208?\": \"user36[]\",\n\t\tgroups208: \"group8[]\"\n\t},\n\tuser209: {\n\t\tname209: \"string\",\n\t\t\"friends209?\": \"user122[]\",\n\t\tgroups209: \"group15[]\"\n\t},\n\tuser210: {\n\t\tname210: \"string\",\n\t\t\"friends210?\": \"user231[]\",\n\t\tgroups210: \"group145[]\"\n\t},\n\tuser211: {\n\t\tname211: \"string\",\n\t\t\"friends211?\": \"user127[]\",\n\t\tgroups211: \"group149[]\"\n\t},\n\tuser212: {\n\t\tname212: \"string\",\n\t\t\"friends212?\": \"user189[]\",\n\t\tgroups212: \"group147[]\"\n\t},\n\tuser213: {\n\t\tname213: \"string\",\n\t\t\"friends213?\": \"user238[]\",\n\t\tgroups213: \"group88[]\"\n\t},\n\tuser214: {\n\t\tname214: \"string\",\n\t\t\"friends214?\": \"user239[]\",\n\t\tgroups214: \"group169[]\"\n\t},\n\tuser215: {\n\t\tname215: \"string\",\n\t\t\"friends215?\": \"user109[]\",\n\t\tgroups215: \"group245[]\"\n\t},\n\tuser216: {\n\t\tname216: \"string\",\n\t\t\"friends216?\": \"user78[]\",\n\t\tgroups216: \"group225[]\"\n\t},\n\tuser217: {\n\t\tname217: \"string\",\n\t\t\"friends217?\": \"user197[]\",\n\t\tgroups217: \"group120[]\"\n\t},\n\tuser218: {\n\t\tname218: \"string\",\n\t\t\"friends218?\": \"user186[]\",\n\t\tgroups218: \"group99[]\"\n\t},\n\tuser219: {\n\t\tname219: \"string\",\n\t\t\"friends219?\": \"user33[]\",\n\t\tgroups219: \"group222[]\"\n\t},\n\tuser220: {\n\t\tname220: \"string\",\n\t\t\"friends220?\": \"user90[]\",\n\t\tgroups220: \"group114[]\"\n\t},\n\tuser221: {\n\t\tname221: \"string\",\n\t\t\"friends221?\": \"user134[]\",\n\t\tgroups221: \"group35[]\"\n\t},\n\tuser222: {\n\t\tname222: \"string\",\n\t\t\"friends222?\": \"user225[]\",\n\t\tgroups222: \"group178[]\"\n\t},\n\tuser223: {\n\t\tname223: \"string\",\n\t\t\"friends223?\": \"user215[]\",\n\t\tgroups223: \"group93[]\"\n\t},\n\tuser224: {\n\t\tname224: \"string\",\n\t\t\"friends224?\": \"user19[]\",\n\t\tgroups224: \"group174[]\"\n\t},\n\tuser225: {\n\t\tname225: \"string\",\n\t\t\"friends225?\": \"user223[]\",\n\t\tgroups225: \"group127[]\"\n\t},\n\tuser226: {\n\t\tname226: \"string\",\n\t\t\"friends226?\": \"user20[]\",\n\t\tgroups226: \"group210[]\"\n\t},\n\tuser227: {\n\t\tname227: \"string\",\n\t\t\"friends227?\": \"user208[]\",\n\t\tgroups227: \"group177[]\"\n\t},\n\tuser228: {\n\t\tname228: \"string\",\n\t\t\"friends228?\": \"user109[]\",\n\t\tgroups228: \"group139[]\"\n\t},\n\tuser229: {\n\t\tname229: \"string\",\n\t\t\"friends229?\": \"user30[]\",\n\t\tgroups229: \"group140[]\"\n\t},\n\tuser230: {\n\t\tname230: \"string\",\n\t\t\"friends230?\": \"user85[]\",\n\t\tgroups230: \"group188[]\"\n\t},\n\tuser231: {\n\t\tname231: \"string\",\n\t\t\"friends231?\": \"user200[]\",\n\t\tgroups231: \"group108[]\"\n\t},\n\tuser232: {\n\t\tname232: \"string\",\n\t\t\"friends232?\": \"user20[]\",\n\t\tgroups232: \"group46[]\"\n\t},\n\tuser233: {\n\t\tname233: \"string\",\n\t\t\"friends233?\": \"user98[]\",\n\t\tgroups233: \"group121[]\"\n\t},\n\tuser234: {\n\t\tname234: \"string\",\n\t\t\"friends234?\": \"user117[]\",\n\t\tgroups234: \"group166[]\"\n\t},\n\tuser235: {\n\t\tname235: \"string\",\n\t\t\"friends235?\": \"user90[]\",\n\t\tgroups235: \"group84[]\"\n\t},\n\tuser236: {\n\t\tname236: \"string\",\n\t\t\"friends236?\": \"user175[]\",\n\t\tgroups236: \"group162[]\"\n\t},\n\tuser237: {\n\t\tname237: \"string\",\n\t\t\"friends237?\": \"user233[]\",\n\t\tgroups237: \"group20[]\"\n\t},\n\tuser238: {\n\t\tname238: \"string\",\n\t\t\"friends238?\": \"user175[]\",\n\t\tgroups238: \"group48[]\"\n\t},\n\tuser239: {\n\t\tname239: \"string\",\n\t\t\"friends239?\": \"user4[]\",\n\t\tgroups239: \"group71[]\"\n\t},\n\tuser240: {\n\t\tname240: \"string\",\n\t\t\"friends240?\": \"user32[]\",\n\t\tgroups240: \"group159[]\"\n\t},\n\tuser241: {\n\t\tname241: \"string\",\n\t\t\"friends241?\": \"user175[]\",\n\t\tgroups241: \"group173[]\"\n\t},\n\tuser242: {\n\t\tname242: \"string\",\n\t\t\"friends242?\": \"user162[]\",\n\t\tgroups242: \"group37[]\"\n\t},\n\tuser243: {\n\t\tname243: \"string\",\n\t\t\"friends243?\": \"user246[]\",\n\t\tgroups243: \"group168[]\"\n\t},\n\tuser244: {\n\t\tname244: \"string\",\n\t\t\"friends244?\": \"user202[]\",\n\t\tgroups244: \"group91[]\"\n\t},\n\tuser245: {\n\t\tname245: \"string\",\n\t\t\"friends245?\": \"user19[]\",\n\t\tgroups245: \"group234[]\"\n\t},\n\tuser246: {\n\t\tname246: \"string\",\n\t\t\"friends246?\": \"user82[]\",\n\t\tgroups246: \"group129[]\"\n\t},\n\tuser247: {\n\t\tname247: \"string\",\n\t\t\"friends247?\": \"user102[]\",\n\t\tgroups247: \"group86[]\"\n\t},\n\tuser248: {\n\t\tname248: \"string\",\n\t\t\"friends248?\": \"user18[]\",\n\t\tgroups248: \"group235[]\"\n\t},\n\tuser249: {\n\t\tname249: \"string\",\n\t\t\"friends249?\": \"user202[]\",\n\t\tgroups249: \"group238[]\"\n\t},\n\tuser250: {\n\t\tname250: \"string\",\n\t\t\"friends250?\": \"user151[]\",\n\t\tgroups250: \"group71[]\"\n\t},\n\tgroup: {\n\t\ttitle: \"string\",\n\t\tmembers: \"user[]\",\n\t\tisActive: \"boolean|undefined\"\n\t},\n\tgroup2: {\n\t\ttitle2: \"string\",\n\t\tmembers2: \"user175[]\",\n\t\tisActive2: \"boolean|undefined\"\n\t},\n\tgroup3: {\n\t\ttitle3: \"string\",\n\t\tmembers3: \"user220[]\",\n\t\tisActive3: \"boolean|undefined\"\n\t},\n\tgroup4: {\n\t\ttitle4: \"string\",\n\t\tmembers4: \"user162[]\",\n\t\tisActive4: \"boolean|undefined\"\n\t},\n\tgroup5: {\n\t\ttitle5: \"string\",\n\t\tmembers5: \"user219[]\",\n\t\tisActive5: \"boolean|undefined\"\n\t},\n\tgroup6: {\n\t\ttitle6: \"string\",\n\t\tmembers6: \"user213[]\",\n\t\tisActive6: \"boolean|undefined\"\n\t},\n\tgroup7: {\n\t\ttitle7: \"string\",\n\t\tmembers7: \"user64[]\",\n\t\tisActive7: \"boolean|undefined\"\n\t},\n\tgroup8: {\n\t\ttitle8: \"string\",\n\t\tmembers8: \"user34[]\",\n\t\tisActive8: \"boolean|undefined\"\n\t},\n\tgroup9: {\n\t\ttitle9: \"string\",\n\t\tmembers9: \"user19[]\",\n\t\tisActive9: \"boolean|undefined\"\n\t},\n\tgroup10: {\n\t\ttitle10: \"string\",\n\t\tmembers10: \"user201[]\",\n\t\tisActive10: \"boolean|undefined\"\n\t},\n\tgroup11: {\n\t\ttitle11: \"string\",\n\t\tmembers11: \"user243[]\",\n\t\tisActive11: \"boolean|undefined\"\n\t},\n\tgroup12: {\n\t\ttitle12: \"string\",\n\t\tmembers12: \"user94[]\",\n\t\tisActive12: \"boolean|undefined\"\n\t},\n\tgroup13: {\n\t\ttitle13: \"string\",\n\t\tmembers13: \"user29[]\",\n\t\tisActive13: \"boolean|undefined\"\n\t},\n\tgroup14: {\n\t\ttitle14: \"string\",\n\t\tmembers14: \"user170[]\",\n\t\tisActive14: \"boolean|undefined\"\n\t},\n\tgroup15: {\n\t\ttitle15: \"string\",\n\t\tmembers15: \"user72[]\",\n\t\tisActive15: \"boolean|undefined\"\n\t},\n\tgroup16: {\n\t\ttitle16: \"string\",\n\t\tmembers16: \"user88[]\",\n\t\tisActive16: \"boolean|undefined\"\n\t},\n\tgroup17: {\n\t\ttitle17: \"string\",\n\t\tmembers17: \"user139[]\",\n\t\tisActive17: \"boolean|undefined\"\n\t},\n\tgroup18: {\n\t\ttitle18: \"string\",\n\t\tmembers18: \"user40[]\",\n\t\tisActive18: \"boolean|undefined\"\n\t},\n\tgroup19: {\n\t\ttitle19: \"string\",\n\t\tmembers19: \"user247[]\",\n\t\tisActive19: \"boolean|undefined\"\n\t},\n\tgroup20: {\n\t\ttitle20: \"string\",\n\t\tmembers20: \"user199[]\",\n\t\tisActive20: \"boolean|undefined\"\n\t},\n\tgroup21: {\n\t\ttitle21: \"string\",\n\t\tmembers21: \"user57[]\",\n\t\tisActive21: \"boolean|undefined\"\n\t},\n\tgroup22: {\n\t\ttitle22: \"string\",\n\t\tmembers22: \"user239[]\",\n\t\tisActive22: \"boolean|undefined\"\n\t},\n\tgroup23: {\n\t\ttitle23: \"string\",\n\t\tmembers23: \"user117[]\",\n\t\tisActive23: \"boolean|undefined\"\n\t},\n\tgroup24: {\n\t\ttitle24: \"string\",\n\t\tmembers24: \"user111[]\",\n\t\tisActive24: \"boolean|undefined\"\n\t},\n\tgroup25: {\n\t\ttitle25: \"string\",\n\t\tmembers25: \"user124[]\",\n\t\tisActive25: \"boolean|undefined\"\n\t},\n\tgroup26: {\n\t\ttitle26: \"string\",\n\t\tmembers26: \"user40[]\",\n\t\tisActive26: \"boolean|undefined\"\n\t},\n\tgroup27: {\n\t\ttitle27: \"string\",\n\t\tmembers27: \"user9[]\",\n\t\tisActive27: \"boolean|undefined\"\n\t},\n\tgroup28: {\n\t\ttitle28: \"string\",\n\t\tmembers28: \"user197[]\",\n\t\tisActive28: \"boolean|undefined\"\n\t},\n\tgroup29: {\n\t\ttitle29: \"string\",\n\t\tmembers29: \"user67[]\",\n\t\tisActive29: \"boolean|undefined\"\n\t},\n\tgroup30: {\n\t\ttitle30: \"string\",\n\t\tmembers30: \"user237[]\",\n\t\tisActive30: \"boolean|undefined\"\n\t},\n\tgroup31: {\n\t\ttitle31: \"string\",\n\t\tmembers31: \"user213[]\",\n\t\tisActive31: \"boolean|undefined\"\n\t},\n\tgroup32: {\n\t\ttitle32: \"string\",\n\t\tmembers32: \"user106[]\",\n\t\tisActive32: \"boolean|undefined\"\n\t},\n\tgroup33: {\n\t\ttitle33: \"string\",\n\t\tmembers33: \"user131[]\",\n\t\tisActive33: \"boolean|undefined\"\n\t},\n\tgroup34: {\n\t\ttitle34: \"string\",\n\t\tmembers34: \"user243[]\",\n\t\tisActive34: \"boolean|undefined\"\n\t},\n\tgroup35: {\n\t\ttitle35: \"string\",\n\t\tmembers35: \"user128[]\",\n\t\tisActive35: \"boolean|undefined\"\n\t},\n\tgroup36: {\n\t\ttitle36: \"string\",\n\t\tmembers36: \"user132[]\",\n\t\tisActive36: \"boolean|undefined\"\n\t},\n\tgroup37: {\n\t\ttitle37: \"string\",\n\t\tmembers37: \"user94[]\",\n\t\tisActive37: \"boolean|undefined\"\n\t},\n\tgroup38: {\n\t\ttitle38: \"string\",\n\t\tmembers38: \"user36[]\",\n\t\tisActive38: \"boolean|undefined\"\n\t},\n\tgroup39: {\n\t\ttitle39: \"string\",\n\t\tmembers39: \"user231[]\",\n\t\tisActive39: \"boolean|undefined\"\n\t},\n\tgroup40: {\n\t\ttitle40: \"string\",\n\t\tmembers40: \"user19[]\",\n\t\tisActive40: \"boolean|undefined\"\n\t},\n\tgroup41: {\n\t\ttitle41: \"string\",\n\t\tmembers41: \"user245[]\",\n\t\tisActive41: \"boolean|undefined\"\n\t},\n\tgroup42: {\n\t\ttitle42: \"string\",\n\t\tmembers42: \"user91[]\",\n\t\tisActive42: \"boolean|undefined\"\n\t},\n\tgroup43: {\n\t\ttitle43: \"string\",\n\t\tmembers43: \"user22[]\",\n\t\tisActive43: \"boolean|undefined\"\n\t},\n\tgroup44: {\n\t\ttitle44: \"string\",\n\t\tmembers44: \"user243[]\",\n\t\tisActive44: \"boolean|undefined\"\n\t},\n\tgroup45: {\n\t\ttitle45: \"string\",\n\t\tmembers45: \"user176[]\",\n\t\tisActive45: \"boolean|undefined\"\n\t},\n\tgroup46: {\n\t\ttitle46: \"string\",\n\t\tmembers46: \"user241[]\",\n\t\tisActive46: \"boolean|undefined\"\n\t},\n\tgroup47: {\n\t\ttitle47: \"string\",\n\t\tmembers47: \"user120[]\",\n\t\tisActive47: \"boolean|undefined\"\n\t},\n\tgroup48: {\n\t\ttitle48: \"string\",\n\t\tmembers48: \"user41[]\",\n\t\tisActive48: \"boolean|undefined\"\n\t},\n\tgroup49: {\n\t\ttitle49: \"string\",\n\t\tmembers49: \"user109[]\",\n\t\tisActive49: \"boolean|undefined\"\n\t},\n\tgroup50: {\n\t\ttitle50: \"string\",\n\t\tmembers50: \"user210[]\",\n\t\tisActive50: \"boolean|undefined\"\n\t},\n\tgroup51: {\n\t\ttitle51: \"string\",\n\t\tmembers51: \"user54[]\",\n\t\tisActive51: \"boolean|undefined\"\n\t},\n\tgroup52: {\n\t\ttitle52: \"string\",\n\t\tmembers52: \"user77[]\",\n\t\tisActive52: \"boolean|undefined\"\n\t},\n\tgroup53: {\n\t\ttitle53: \"string\",\n\t\tmembers53: \"user233[]\",\n\t\tisActive53: \"boolean|undefined\"\n\t},\n\tgroup54: {\n\t\ttitle54: \"string\",\n\t\tmembers54: \"user211[]\",\n\t\tisActive54: \"boolean|undefined\"\n\t},\n\tgroup55: {\n\t\ttitle55: \"string\",\n\t\tmembers55: \"user49[]\",\n\t\tisActive55: \"boolean|undefined\"\n\t},\n\tgroup56: {\n\t\ttitle56: \"string\",\n\t\tmembers56: \"user68[]\",\n\t\tisActive56: \"boolean|undefined\"\n\t},\n\tgroup57: {\n\t\ttitle57: \"string\",\n\t\tmembers57: \"user139[]\",\n\t\tisActive57: \"boolean|undefined\"\n\t},\n\tgroup58: {\n\t\ttitle58: \"string\",\n\t\tmembers58: \"user243[]\",\n\t\tisActive58: \"boolean|undefined\"\n\t},\n\tgroup59: {\n\t\ttitle59: \"string\",\n\t\tmembers59: \"user90[]\",\n\t\tisActive59: \"boolean|undefined\"\n\t},\n\tgroup60: {\n\t\ttitle60: \"string\",\n\t\tmembers60: \"user223[]\",\n\t\tisActive60: \"boolean|undefined\"\n\t},\n\tgroup61: {\n\t\ttitle61: \"string\",\n\t\tmembers61: \"user240[]\",\n\t\tisActive61: \"boolean|undefined\"\n\t},\n\tgroup62: {\n\t\ttitle62: \"string\",\n\t\tmembers62: \"user12[]\",\n\t\tisActive62: \"boolean|undefined\"\n\t},\n\tgroup63: {\n\t\ttitle63: \"string\",\n\t\tmembers63: \"user221[]\",\n\t\tisActive63: \"boolean|undefined\"\n\t},\n\tgroup64: {\n\t\ttitle64: \"string\",\n\t\tmembers64: \"user164[]\",\n\t\tisActive64: \"boolean|undefined\"\n\t},\n\tgroup65: {\n\t\ttitle65: \"string\",\n\t\tmembers65: \"user246[]\",\n\t\tisActive65: \"boolean|undefined\"\n\t},\n\tgroup66: {\n\t\ttitle66: \"string\",\n\t\tmembers66: \"user69[]\",\n\t\tisActive66: \"boolean|undefined\"\n\t},\n\tgroup67: {\n\t\ttitle67: \"string\",\n\t\tmembers67: \"user110[]\",\n\t\tisActive67: \"boolean|undefined\"\n\t},\n\tgroup68: {\n\t\ttitle68: \"string\",\n\t\tmembers68: \"user5[]\",\n\t\tisActive68: \"boolean|undefined\"\n\t},\n\tgroup69: {\n\t\ttitle69: \"string\",\n\t\tmembers69: \"user35[]\",\n\t\tisActive69: \"boolean|undefined\"\n\t},\n\tgroup70: {\n\t\ttitle70: \"string\",\n\t\tmembers70: \"user192[]\",\n\t\tisActive70: \"boolean|undefined\"\n\t},\n\tgroup71: {\n\t\ttitle71: \"string\",\n\t\tmembers71: \"user23[]\",\n\t\tisActive71: \"boolean|undefined\"\n\t},\n\tgroup72: {\n\t\ttitle72: \"string\",\n\t\tmembers72: \"user135[]\",\n\t\tisActive72: \"boolean|undefined\"\n\t},\n\tgroup73: {\n\t\ttitle73: \"string\",\n\t\tmembers73: \"user231[]\",\n\t\tisActive73: \"boolean|undefined\"\n\t},\n\tgroup74: {\n\t\ttitle74: \"string\",\n\t\tmembers74: \"user125[]\",\n\t\tisActive74: \"boolean|undefined\"\n\t},\n\tgroup75: {\n\t\ttitle75: \"string\",\n\t\tmembers75: \"user199[]\",\n\t\tisActive75: \"boolean|undefined\"\n\t},\n\tgroup76: {\n\t\ttitle76: \"string\",\n\t\tmembers76: \"user210[]\",\n\t\tisActive76: \"boolean|undefined\"\n\t},\n\tgroup77: {\n\t\ttitle77: \"string\",\n\t\tmembers77: \"user94[]\",\n\t\tisActive77: \"boolean|undefined\"\n\t},\n\tgroup78: {\n\t\ttitle78: \"string\",\n\t\tmembers78: \"user16[]\",\n\t\tisActive78: \"boolean|undefined\"\n\t},\n\tgroup79: {\n\t\ttitle79: \"string\",\n\t\tmembers79: \"user200[]\",\n\t\tisActive79: \"boolean|undefined\"\n\t},\n\tgroup80: {\n\t\ttitle80: \"string\",\n\t\tmembers80: \"user96[]\",\n\t\tisActive80: \"boolean|undefined\"\n\t},\n\tgroup81: {\n\t\ttitle81: \"string\",\n\t\tmembers81: \"user6[]\",\n\t\tisActive81: \"boolean|undefined\"\n\t},\n\tgroup82: {\n\t\ttitle82: \"string\",\n\t\tmembers82: \"user206[]\",\n\t\tisActive82: \"boolean|undefined\"\n\t},\n\tgroup83: {\n\t\ttitle83: \"string\",\n\t\tmembers83: \"user166[]\",\n\t\tisActive83: \"boolean|undefined\"\n\t},\n\tgroup84: {\n\t\ttitle84: \"string\",\n\t\tmembers84: \"user175[]\",\n\t\tisActive84: \"boolean|undefined\"\n\t},\n\tgroup85: {\n\t\ttitle85: \"string\",\n\t\tmembers85: \"user182[]\",\n\t\tisActive85: \"boolean|undefined\"\n\t},\n\tgroup86: {\n\t\ttitle86: \"string\",\n\t\tmembers86: \"user119[]\",\n\t\tisActive86: \"boolean|undefined\"\n\t},\n\tgroup87: {\n\t\ttitle87: \"string\",\n\t\tmembers87: \"user141[]\",\n\t\tisActive87: \"boolean|undefined\"\n\t},\n\tgroup88: {\n\t\ttitle88: \"string\",\n\t\tmembers88: \"user59[]\",\n\t\tisActive88: \"boolean|undefined\"\n\t},\n\tgroup89: {\n\t\ttitle89: \"string\",\n\t\tmembers89: \"user100[]\",\n\t\tisActive89: \"boolean|undefined\"\n\t},\n\tgroup90: {\n\t\ttitle90: \"string\",\n\t\tmembers90: \"user245[]\",\n\t\tisActive90: \"boolean|undefined\"\n\t},\n\tgroup91: {\n\t\ttitle91: \"string\",\n\t\tmembers91: \"user186[]\",\n\t\tisActive91: \"boolean|undefined\"\n\t},\n\tgroup92: {\n\t\ttitle92: \"string\",\n\t\tmembers92: \"user102[]\",\n\t\tisActive92: \"boolean|undefined\"\n\t},\n\tgroup93: {\n\t\ttitle93: \"string\",\n\t\tmembers93: \"user193[]\",\n\t\tisActive93: \"boolean|undefined\"\n\t},\n\tgroup94: {\n\t\ttitle94: \"string\",\n\t\tmembers94: \"user209[]\",\n\t\tisActive94: \"boolean|undefined\"\n\t},\n\tgroup95: {\n\t\ttitle95: \"string\",\n\t\tmembers95: \"user137[]\",\n\t\tisActive95: \"boolean|undefined\"\n\t},\n\tgroup96: {\n\t\ttitle96: \"string\",\n\t\tmembers96: \"user54[]\",\n\t\tisActive96: \"boolean|undefined\"\n\t},\n\tgroup97: {\n\t\ttitle97: \"string\",\n\t\tmembers97: \"user96[]\",\n\t\tisActive97: \"boolean|undefined\"\n\t},\n\tgroup98: {\n\t\ttitle98: \"string\",\n\t\tmembers98: \"user110[]\",\n\t\tisActive98: \"boolean|undefined\"\n\t},\n\tgroup99: {\n\t\ttitle99: \"string\",\n\t\tmembers99: \"user143[]\",\n\t\tisActive99: \"boolean|undefined\"\n\t},\n\tgroup100: {\n\t\ttitle100: \"string\",\n\t\tmembers100: \"user16[]\",\n\t\tisActive100: \"boolean|undefined\"\n\t},\n\tgroup101: {\n\t\ttitle101: \"string\",\n\t\tmembers101: \"user55[]\",\n\t\tisActive101: \"boolean|undefined\"\n\t},\n\tgroup102: {\n\t\ttitle102: \"string\",\n\t\tmembers102: \"user217[]\",\n\t\tisActive102: \"boolean|undefined\"\n\t},\n\tgroup103: {\n\t\ttitle103: \"string\",\n\t\tmembers103: \"user154[]\",\n\t\tisActive103: \"boolean|undefined\"\n\t},\n\tgroup104: {\n\t\ttitle104: \"string\",\n\t\tmembers104: \"user172[]\",\n\t\tisActive104: \"boolean|undefined\"\n\t},\n\tgroup105: {\n\t\ttitle105: \"string\",\n\t\tmembers105: \"user234[]\",\n\t\tisActive105: \"boolean|undefined\"\n\t},\n\tgroup106: {\n\t\ttitle106: \"string\",\n\t\tmembers106: \"user23[]\",\n\t\tisActive106: \"boolean|undefined\"\n\t},\n\tgroup107: {\n\t\ttitle107: \"string\",\n\t\tmembers107: \"user213[]\",\n\t\tisActive107: \"boolean|undefined\"\n\t},\n\tgroup108: {\n\t\ttitle108: \"string\",\n\t\tmembers108: \"user125[]\",\n\t\tisActive108: \"boolean|undefined\"\n\t},\n\tgroup109: {\n\t\ttitle109: \"string\",\n\t\tmembers109: \"user91[]\",\n\t\tisActive109: \"boolean|undefined\"\n\t},\n\tgroup110: {\n\t\ttitle110: \"string\",\n\t\tmembers110: \"user58[]\",\n\t\tisActive110: \"boolean|undefined\"\n\t},\n\tgroup111: {\n\t\ttitle111: \"string\",\n\t\tmembers111: \"user219[]\",\n\t\tisActive111: \"boolean|undefined\"\n\t},\n\tgroup112: {\n\t\ttitle112: \"string\",\n\t\tmembers112: \"user136[]\",\n\t\tisActive112: \"boolean|undefined\"\n\t},\n\tgroup113: {\n\t\ttitle113: \"string\",\n\t\tmembers113: \"user189[]\",\n\t\tisActive113: \"boolean|undefined\"\n\t},\n\tgroup114: {\n\t\ttitle114: \"string\",\n\t\tmembers114: \"user166[]\",\n\t\tisActive114: \"boolean|undefined\"\n\t},\n\tgroup115: {\n\t\ttitle115: \"string\",\n\t\tmembers115: \"user161[]\",\n\t\tisActive115: \"boolean|undefined\"\n\t},\n\tgroup116: {\n\t\ttitle116: \"string\",\n\t\tmembers116: \"user162[]\",\n\t\tisActive116: \"boolean|undefined\"\n\t},\n\tgroup117: {\n\t\ttitle117: \"string\",\n\t\tmembers117: \"user154[]\",\n\t\tisActive117: \"boolean|undefined\"\n\t},\n\tgroup118: {\n\t\ttitle118: \"string\",\n\t\tmembers118: \"user164[]\",\n\t\tisActive118: \"boolean|undefined\"\n\t},\n\tgroup119: {\n\t\ttitle119: \"string\",\n\t\tmembers119: \"user135[]\",\n\t\tisActive119: \"boolean|undefined\"\n\t},\n\tgroup120: {\n\t\ttitle120: \"string\",\n\t\tmembers120: \"user46[]\",\n\t\tisActive120: \"boolean|undefined\"\n\t},\n\tgroup121: {\n\t\ttitle121: \"string\",\n\t\tmembers121: \"user155[]\",\n\t\tisActive121: \"boolean|undefined\"\n\t},\n\tgroup122: {\n\t\ttitle122: \"string\",\n\t\tmembers122: \"user84[]\",\n\t\tisActive122: \"boolean|undefined\"\n\t},\n\tgroup123: {\n\t\ttitle123: \"string\",\n\t\tmembers123: \"user108[]\",\n\t\tisActive123: \"boolean|undefined\"\n\t},\n\tgroup124: {\n\t\ttitle124: \"string\",\n\t\tmembers124: \"user180[]\",\n\t\tisActive124: \"boolean|undefined\"\n\t},\n\tgroup125: {\n\t\ttitle125: \"string\",\n\t\tmembers125: \"user2[]\",\n\t\tisActive125: \"boolean|undefined\"\n\t},\n\tgroup126: {\n\t\ttitle126: \"string\",\n\t\tmembers126: \"user183[]\",\n\t\tisActive126: \"boolean|undefined\"\n\t},\n\tgroup127: {\n\t\ttitle127: \"string\",\n\t\tmembers127: \"user76[]\",\n\t\tisActive127: \"boolean|undefined\"\n\t},\n\tgroup128: {\n\t\ttitle128: \"string\",\n\t\tmembers128: \"user206[]\",\n\t\tisActive128: \"boolean|undefined\"\n\t},\n\tgroup129: {\n\t\ttitle129: \"string\",\n\t\tmembers129: \"user183[]\",\n\t\tisActive129: \"boolean|undefined\"\n\t},\n\tgroup130: {\n\t\ttitle130: \"string\",\n\t\tmembers130: \"user30[]\",\n\t\tisActive130: \"boolean|undefined\"\n\t},\n\tgroup131: {\n\t\ttitle131: \"string\",\n\t\tmembers131: \"user246[]\",\n\t\tisActive131: \"boolean|undefined\"\n\t},\n\tgroup132: {\n\t\ttitle132: \"string\",\n\t\tmembers132: \"user166[]\",\n\t\tisActive132: \"boolean|undefined\"\n\t},\n\tgroup133: {\n\t\ttitle133: \"string\",\n\t\tmembers133: \"user183[]\",\n\t\tisActive133: \"boolean|undefined\"\n\t},\n\tgroup134: {\n\t\ttitle134: \"string\",\n\t\tmembers134: \"user124[]\",\n\t\tisActive134: \"boolean|undefined\"\n\t},\n\tgroup135: {\n\t\ttitle135: \"string\",\n\t\tmembers135: \"user161[]\",\n\t\tisActive135: \"boolean|undefined\"\n\t},\n\tgroup136: {\n\t\ttitle136: \"string\",\n\t\tmembers136: \"user170[]\",\n\t\tisActive136: \"boolean|undefined\"\n\t},\n\tgroup137: {\n\t\ttitle137: \"string\",\n\t\tmembers137: \"user241[]\",\n\t\tisActive137: \"boolean|undefined\"\n\t},\n\tgroup138: {\n\t\ttitle138: \"string\",\n\t\tmembers138: \"user33[]\",\n\t\tisActive138: \"boolean|undefined\"\n\t},\n\tgroup139: {\n\t\ttitle139: \"string\",\n\t\tmembers139: \"user155[]\",\n\t\tisActive139: \"boolean|undefined\"\n\t},\n\tgroup140: {\n\t\ttitle140: \"string\",\n\t\tmembers140: \"user123[]\",\n\t\tisActive140: \"boolean|undefined\"\n\t},\n\tgroup141: {\n\t\ttitle141: \"string\",\n\t\tmembers141: \"user3[]\",\n\t\tisActive141: \"boolean|undefined\"\n\t},\n\tgroup142: {\n\t\ttitle142: \"string\",\n\t\tmembers142: \"user244[]\",\n\t\tisActive142: \"boolean|undefined\"\n\t},\n\tgroup143: {\n\t\ttitle143: \"string\",\n\t\tmembers143: \"user99[]\",\n\t\tisActive143: \"boolean|undefined\"\n\t},\n\tgroup144: {\n\t\ttitle144: \"string\",\n\t\tmembers144: \"user233[]\",\n\t\tisActive144: \"boolean|undefined\"\n\t},\n\tgroup145: {\n\t\ttitle145: \"string\",\n\t\tmembers145: \"user39[]\",\n\t\tisActive145: \"boolean|undefined\"\n\t},\n\tgroup146: {\n\t\ttitle146: \"string\",\n\t\tmembers146: \"user21[]\",\n\t\tisActive146: \"boolean|undefined\"\n\t},\n\tgroup147: {\n\t\ttitle147: \"string\",\n\t\tmembers147: \"user129[]\",\n\t\tisActive147: \"boolean|undefined\"\n\t},\n\tgroup148: {\n\t\ttitle148: \"string\",\n\t\tmembers148: \"user147[]\",\n\t\tisActive148: \"boolean|undefined\"\n\t},\n\tgroup149: {\n\t\ttitle149: \"string\",\n\t\tmembers149: \"user81[]\",\n\t\tisActive149: \"boolean|undefined\"\n\t},\n\tgroup150: {\n\t\ttitle150: \"string\",\n\t\tmembers150: \"user200[]\",\n\t\tisActive150: \"boolean|undefined\"\n\t},\n\tgroup151: {\n\t\ttitle151: \"string\",\n\t\tmembers151: \"user218[]\",\n\t\tisActive151: \"boolean|undefined\"\n\t},\n\tgroup152: {\n\t\ttitle152: \"string\",\n\t\tmembers152: \"user61[]\",\n\t\tisActive152: \"boolean|undefined\"\n\t},\n\tgroup153: {\n\t\ttitle153: \"string\",\n\t\tmembers153: \"user63[]\",\n\t\tisActive153: \"boolean|undefined\"\n\t},\n\tgroup154: {\n\t\ttitle154: \"string\",\n\t\tmembers154: \"user92[]\",\n\t\tisActive154: \"boolean|undefined\"\n\t},\n\tgroup155: {\n\t\ttitle155: \"string\",\n\t\tmembers155: \"user6[]\",\n\t\tisActive155: \"boolean|undefined\"\n\t},\n\tgroup156: {\n\t\ttitle156: \"string\",\n\t\tmembers156: \"user53[]\",\n\t\tisActive156: \"boolean|undefined\"\n\t},\n\tgroup157: {\n\t\ttitle157: \"string\",\n\t\tmembers157: \"user124[]\",\n\t\tisActive157: \"boolean|undefined\"\n\t},\n\tgroup158: {\n\t\ttitle158: \"string\",\n\t\tmembers158: \"user13[]\",\n\t\tisActive158: \"boolean|undefined\"\n\t},\n\tgroup159: {\n\t\ttitle159: \"string\",\n\t\tmembers159: \"user156[]\",\n\t\tisActive159: \"boolean|undefined\"\n\t},\n\tgroup160: {\n\t\ttitle160: \"string\",\n\t\tmembers160: \"user197[]\",\n\t\tisActive160: \"boolean|undefined\"\n\t},\n\tgroup161: {\n\t\ttitle161: \"string\",\n\t\tmembers161: \"user227[]\",\n\t\tisActive161: \"boolean|undefined\"\n\t},\n\tgroup162: {\n\t\ttitle162: \"string\",\n\t\tmembers162: \"user26[]\",\n\t\tisActive162: \"boolean|undefined\"\n\t},\n\tgroup163: {\n\t\ttitle163: \"string\",\n\t\tmembers163: \"user7[]\",\n\t\tisActive163: \"boolean|undefined\"\n\t},\n\tgroup164: {\n\t\ttitle164: \"string\",\n\t\tmembers164: \"user196[]\",\n\t\tisActive164: \"boolean|undefined\"\n\t},\n\tgroup165: {\n\t\ttitle165: \"string\",\n\t\tmembers165: \"user136[]\",\n\t\tisActive165: \"boolean|undefined\"\n\t},\n\tgroup166: {\n\t\ttitle166: \"string\",\n\t\tmembers166: \"user245[]\",\n\t\tisActive166: \"boolean|undefined\"\n\t},\n\tgroup167: {\n\t\ttitle167: \"string\",\n\t\tmembers167: \"user142[]\",\n\t\tisActive167: \"boolean|undefined\"\n\t},\n\tgroup168: {\n\t\ttitle168: \"string\",\n\t\tmembers168: \"user102[]\",\n\t\tisActive168: \"boolean|undefined\"\n\t},\n\tgroup169: {\n\t\ttitle169: \"string\",\n\t\tmembers169: \"user197[]\",\n\t\tisActive169: \"boolean|undefined\"\n\t},\n\tgroup170: {\n\t\ttitle170: \"string\",\n\t\tmembers170: \"user114[]\",\n\t\tisActive170: \"boolean|undefined\"\n\t},\n\tgroup171: {\n\t\ttitle171: \"string\",\n\t\tmembers171: \"user110[]\",\n\t\tisActive171: \"boolean|undefined\"\n\t},\n\tgroup172: {\n\t\ttitle172: \"string\",\n\t\tmembers172: \"user128[]\",\n\t\tisActive172: \"boolean|undefined\"\n\t},\n\tgroup173: {\n\t\ttitle173: \"string\",\n\t\tmembers173: \"user155[]\",\n\t\tisActive173: \"boolean|undefined\"\n\t},\n\tgroup174: {\n\t\ttitle174: \"string\",\n\t\tmembers174: \"user199[]\",\n\t\tisActive174: \"boolean|undefined\"\n\t},\n\tgroup175: {\n\t\ttitle175: \"string\",\n\t\tmembers175: \"user68[]\",\n\t\tisActive175: \"boolean|undefined\"\n\t},\n\tgroup176: {\n\t\ttitle176: \"string\",\n\t\tmembers176: \"user216[]\",\n\t\tisActive176: \"boolean|undefined\"\n\t},\n\tgroup177: {\n\t\ttitle177: \"string\",\n\t\tmembers177: \"user28[]\",\n\t\tisActive177: \"boolean|undefined\"\n\t},\n\tgroup178: {\n\t\ttitle178: \"string\",\n\t\tmembers178: \"user176[]\",\n\t\tisActive178: \"boolean|undefined\"\n\t},\n\tgroup179: {\n\t\ttitle179: \"string\",\n\t\tmembers179: \"user149[]\",\n\t\tisActive179: \"boolean|undefined\"\n\t},\n\tgroup180: {\n\t\ttitle180: \"string\",\n\t\tmembers180: \"user21[]\",\n\t\tisActive180: \"boolean|undefined\"\n\t},\n\tgroup181: {\n\t\ttitle181: \"string\",\n\t\tmembers181: \"user59[]\",\n\t\tisActive181: \"boolean|undefined\"\n\t},\n\tgroup182: {\n\t\ttitle182: \"string\",\n\t\tmembers182: \"user2[]\",\n\t\tisActive182: \"boolean|undefined\"\n\t},\n\tgroup183: {\n\t\ttitle183: \"string\",\n\t\tmembers183: \"user192[]\",\n\t\tisActive183: \"boolean|undefined\"\n\t},\n\tgroup184: {\n\t\ttitle184: \"string\",\n\t\tmembers184: \"user75[]\",\n\t\tisActive184: \"boolean|undefined\"\n\t},\n\tgroup185: {\n\t\ttitle185: \"string\",\n\t\tmembers185: \"user163[]\",\n\t\tisActive185: \"boolean|undefined\"\n\t},\n\tgroup186: {\n\t\ttitle186: \"string\",\n\t\tmembers186: \"user55[]\",\n\t\tisActive186: \"boolean|undefined\"\n\t},\n\tgroup187: {\n\t\ttitle187: \"string\",\n\t\tmembers187: \"user157[]\",\n\t\tisActive187: \"boolean|undefined\"\n\t},\n\tgroup188: {\n\t\ttitle188: \"string\",\n\t\tmembers188: \"user231[]\",\n\t\tisActive188: \"boolean|undefined\"\n\t},\n\tgroup189: {\n\t\ttitle189: \"string\",\n\t\tmembers189: \"user27[]\",\n\t\tisActive189: \"boolean|undefined\"\n\t},\n\tgroup190: {\n\t\ttitle190: \"string\",\n\t\tmembers190: \"user97[]\",\n\t\tisActive190: \"boolean|undefined\"\n\t},\n\tgroup191: {\n\t\ttitle191: \"string\",\n\t\tmembers191: \"user93[]\",\n\t\tisActive191: \"boolean|undefined\"\n\t},\n\tgroup192: {\n\t\ttitle192: \"string\",\n\t\tmembers192: \"user133[]\",\n\t\tisActive192: \"boolean|undefined\"\n\t},\n\tgroup193: {\n\t\ttitle193: \"string\",\n\t\tmembers193: \"user3[]\",\n\t\tisActive193: \"boolean|undefined\"\n\t},\n\tgroup194: {\n\t\ttitle194: \"string\",\n\t\tmembers194: \"user48[]\",\n\t\tisActive194: \"boolean|undefined\"\n\t},\n\tgroup195: {\n\t\ttitle195: \"string\",\n\t\tmembers195: \"user107[]\",\n\t\tisActive195: \"boolean|undefined\"\n\t},\n\tgroup196: {\n\t\ttitle196: \"string\",\n\t\tmembers196: \"user32[]\",\n\t\tisActive196: \"boolean|undefined\"\n\t},\n\tgroup197: {\n\t\ttitle197: \"string\",\n\t\tmembers197: \"user230[]\",\n\t\tisActive197: \"boolean|undefined\"\n\t},\n\tgroup198: {\n\t\ttitle198: \"string\",\n\t\tmembers198: \"user235[]\",\n\t\tisActive198: \"boolean|undefined\"\n\t},\n\tgroup199: {\n\t\ttitle199: \"string\",\n\t\tmembers199: \"user47[]\",\n\t\tisActive199: \"boolean|undefined\"\n\t},\n\tgroup200: {\n\t\ttitle200: \"string\",\n\t\tmembers200: \"user121[]\",\n\t\tisActive200: \"boolean|undefined\"\n\t},\n\tgroup201: {\n\t\ttitle201: \"string\",\n\t\tmembers201: \"user40[]\",\n\t\tisActive201: \"boolean|undefined\"\n\t},\n\tgroup202: {\n\t\ttitle202: \"string\",\n\t\tmembers202: \"user35[]\",\n\t\tisActive202: \"boolean|undefined\"\n\t},\n\tgroup203: {\n\t\ttitle203: \"string\",\n\t\tmembers203: \"user70[]\",\n\t\tisActive203: \"boolean|undefined\"\n\t},\n\tgroup204: {\n\t\ttitle204: \"string\",\n\t\tmembers204: \"user44[]\",\n\t\tisActive204: \"boolean|undefined\"\n\t},\n\tgroup205: {\n\t\ttitle205: \"string\",\n\t\tmembers205: \"user209[]\",\n\t\tisActive205: \"boolean|undefined\"\n\t},\n\tgroup206: {\n\t\ttitle206: \"string\",\n\t\tmembers206: \"user165[]\",\n\t\tisActive206: \"boolean|undefined\"\n\t},\n\tgroup207: {\n\t\ttitle207: \"string\",\n\t\tmembers207: \"user36[]\",\n\t\tisActive207: \"boolean|undefined\"\n\t},\n\tgroup208: {\n\t\ttitle208: \"string\",\n\t\tmembers208: \"user23[]\",\n\t\tisActive208: \"boolean|undefined\"\n\t},\n\tgroup209: {\n\t\ttitle209: \"string\",\n\t\tmembers209: \"user49[]\",\n\t\tisActive209: \"boolean|undefined\"\n\t},\n\tgroup210: {\n\t\ttitle210: \"string\",\n\t\tmembers210: \"user250[]\",\n\t\tisActive210: \"boolean|undefined\"\n\t},\n\tgroup211: {\n\t\ttitle211: \"string\",\n\t\tmembers211: \"user31[]\",\n\t\tisActive211: \"boolean|undefined\"\n\t},\n\tgroup212: {\n\t\ttitle212: \"string\",\n\t\tmembers212: \"user94[]\",\n\t\tisActive212: \"boolean|undefined\"\n\t},\n\tgroup213: {\n\t\ttitle213: \"string\",\n\t\tmembers213: \"user207[]\",\n\t\tisActive213: \"boolean|undefined\"\n\t},\n\tgroup214: {\n\t\ttitle214: \"string\",\n\t\tmembers214: \"user32[]\",\n\t\tisActive214: \"boolean|undefined\"\n\t},\n\tgroup215: {\n\t\ttitle215: \"string\",\n\t\tmembers215: \"user140[]\",\n\t\tisActive215: \"boolean|undefined\"\n\t},\n\tgroup216: {\n\t\ttitle216: \"string\",\n\t\tmembers216: \"user4[]\",\n\t\tisActive216: \"boolean|undefined\"\n\t},\n\tgroup217: {\n\t\ttitle217: \"string\",\n\t\tmembers217: \"user215[]\",\n\t\tisActive217: \"boolean|undefined\"\n\t},\n\tgroup218: {\n\t\ttitle218: \"string\",\n\t\tmembers218: \"user116[]\",\n\t\tisActive218: \"boolean|undefined\"\n\t},\n\tgroup219: {\n\t\ttitle219: \"string\",\n\t\tmembers219: \"user54[]\",\n\t\tisActive219: \"boolean|undefined\"\n\t},\n\tgroup220: {\n\t\ttitle220: \"string\",\n\t\tmembers220: \"user172[]\",\n\t\tisActive220: \"boolean|undefined\"\n\t},\n\tgroup221: {\n\t\ttitle221: \"string\",\n\t\tmembers221: \"user26[]\",\n\t\tisActive221: \"boolean|undefined\"\n\t},\n\tgroup222: {\n\t\ttitle222: \"string\",\n\t\tmembers222: \"user224[]\",\n\t\tisActive222: \"boolean|undefined\"\n\t},\n\tgroup223: {\n\t\ttitle223: \"string\",\n\t\tmembers223: \"user210[]\",\n\t\tisActive223: \"boolean|undefined\"\n\t},\n\tgroup224: {\n\t\ttitle224: \"string\",\n\t\tmembers224: \"user147[]\",\n\t\tisActive224: \"boolean|undefined\"\n\t},\n\tgroup225: {\n\t\ttitle225: \"string\",\n\t\tmembers225: \"user232[]\",\n\t\tisActive225: \"boolean|undefined\"\n\t},\n\tgroup226: {\n\t\ttitle226: \"string\",\n\t\tmembers226: \"user44[]\",\n\t\tisActive226: \"boolean|undefined\"\n\t},\n\tgroup227: {\n\t\ttitle227: \"string\",\n\t\tmembers227: \"user127[]\",\n\t\tisActive227: \"boolean|undefined\"\n\t},\n\tgroup228: {\n\t\ttitle228: \"string\",\n\t\tmembers228: \"user199[]\",\n\t\tisActive228: \"boolean|undefined\"\n\t},\n\tgroup229: {\n\t\ttitle229: \"string\",\n\t\tmembers229: \"user139[]\",\n\t\tisActive229: \"boolean|undefined\"\n\t},\n\tgroup230: {\n\t\ttitle230: \"string\",\n\t\tmembers230: \"user190[]\",\n\t\tisActive230: \"boolean|undefined\"\n\t},\n\tgroup231: {\n\t\ttitle231: \"string\",\n\t\tmembers231: \"user169[]\",\n\t\tisActive231: \"boolean|undefined\"\n\t},\n\tgroup232: {\n\t\ttitle232: \"string\",\n\t\tmembers232: \"user170[]\",\n\t\tisActive232: \"boolean|undefined\"\n\t},\n\tgroup233: {\n\t\ttitle233: \"string\",\n\t\tmembers233: \"user29[]\",\n\t\tisActive233: \"boolean|undefined\"\n\t},\n\tgroup234: {\n\t\ttitle234: \"string\",\n\t\tmembers234: \"user57[]\",\n\t\tisActive234: \"boolean|undefined\"\n\t},\n\tgroup235: {\n\t\ttitle235: \"string\",\n\t\tmembers235: \"user91[]\",\n\t\tisActive235: \"boolean|undefined\"\n\t},\n\tgroup236: {\n\t\ttitle236: \"string\",\n\t\tmembers236: \"user74[]\",\n\t\tisActive236: \"boolean|undefined\"\n\t},\n\tgroup237: {\n\t\ttitle237: \"string\",\n\t\tmembers237: \"user12[]\",\n\t\tisActive237: \"boolean|undefined\"\n\t},\n\tgroup238: {\n\t\ttitle238: \"string\",\n\t\tmembers238: \"user249[]\",\n\t\tisActive238: \"boolean|undefined\"\n\t},\n\tgroup239: {\n\t\ttitle239: \"string\",\n\t\tmembers239: \"user42[]\",\n\t\tisActive239: \"boolean|undefined\"\n\t},\n\tgroup240: {\n\t\ttitle240: \"string\",\n\t\tmembers240: \"user11[]\",\n\t\tisActive240: \"boolean|undefined\"\n\t},\n\tgroup241: {\n\t\ttitle241: \"string\",\n\t\tmembers241: \"user52[]\",\n\t\tisActive241: \"boolean|undefined\"\n\t},\n\tgroup242: {\n\t\ttitle242: \"string\",\n\t\tmembers242: \"user178[]\",\n\t\tisActive242: \"boolean|undefined\"\n\t},\n\tgroup243: {\n\t\ttitle243: \"string\",\n\t\tmembers243: \"user23[]\",\n\t\tisActive243: \"boolean|undefined\"\n\t},\n\tgroup244: {\n\t\ttitle244: \"string\",\n\t\tmembers244: \"user58[]\",\n\t\tisActive244: \"boolean|undefined\"\n\t},\n\tgroup245: {\n\t\ttitle245: \"string\",\n\t\tmembers245: \"user136[]\",\n\t\tisActive245: \"boolean|undefined\"\n\t},\n\tgroup246: {\n\t\ttitle246: \"string\",\n\t\tmembers246: \"user114[]\",\n\t\tisActive246: \"boolean|undefined\"\n\t},\n\tgroup247: {\n\t\ttitle247: \"string\",\n\t\tmembers247: \"user247[]\",\n\t\tisActive247: \"boolean|undefined\"\n\t},\n\tgroup248: {\n\t\ttitle248: \"string\",\n\t\tmembers248: \"user152[]\",\n\t\tisActive248: \"boolean|undefined\"\n\t},\n\tgroup249: {\n\t\ttitle249: \"string\",\n\t\tmembers249: \"user15[]\",\n\t\tisActive249: \"boolean|undefined\"\n\t},\n\tgroup250: {\n\t\ttitle250: \"string\",\n\t\tmembers250: \"user14[]\",\n\t\tisActive250: \"boolean|undefined\"\n\t}\n} as const\n"
  },
  {
    "path": "ark/type/__tests__/generic.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { chainableNoOpProxy } from \"@ark/attest/internal/utils.ts\"\nimport {\n\tintrinsic,\n\twriteIndivisibleMessage,\n\twriteUnboundableMessage,\n\twriteUnresolvableMessage,\n\twriteUnsatisfiedParameterConstraintMessage\n} from \"@ark/schema\"\nimport { Hkt, writeUnclosedGroupMessage } from \"@ark/util\"\nimport { generic, scope, type, type Generic } from \"arktype\"\nimport { emptyGenericParameterMessage } from \"arktype/internal/generic.ts\"\nimport { writeInvalidGenericArgCountMessage } from \"arktype/internal/parser/shift/operand/genericArgs.ts\"\nimport { writeInvalidDivisorMessage } from \"arktype/internal/parser/shift/operator/divisor.ts\"\nimport { writeUnexpectedCharacterMessage } from \"arktype/internal/parser/shift/operator/operator.ts\"\n\ncontextualize(() => {\n\tdescribe(\"standalone\", () => {\n\t\tit(\"unary\", () => {\n\t\t\tconst boxOf = type(\"<t>\", { box: \"t\" })\n\n\t\t\tconst SchrodingersBox = boxOf({ cat: { isAlive: \"boolean\" } })\n\n\t\t\tconst Expected = type({\n\t\t\t\tbox: {\n\t\t\t\t\tcat: { isAlive: \"boolean\" }\n\t\t\t\t}\n\t\t\t})\n\n\t\t\tattest<typeof Expected.t>(SchrodingersBox.t)\n\t\t\tattest(SchrodingersBox.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"body completions\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"<foobar>\", { a: \"foob\", b: \"bool\" })).completions({\n\t\t\t\tfoob: [\"foobar\"],\n\t\t\t\tbool: [\"boolean\"]\n\t\t\t})\n\t\t})\n\n\t\tit(\"args completions\", () => {\n\t\t\tconst g = type(\"<t>\", { box: \"t\" })\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => g({ box: \"numb\" })).completions({ numb: [\"number\"] })\n\t\t})\n\n\t\tit(\"binary\", () => {\n\t\t\tconst either = type(\"<first, second>\", \"first|second\")\n\t\t\tconst SchrodingersBox = either(\n\t\t\t\t{ cat: { isAlive: \"true\" } },\n\t\t\t\t{ cat: { isAlive: \"false\" } }\n\t\t\t)\n\n\t\t\tconst Expected = type(\n\t\t\t\t{\n\t\t\t\t\tcat: {\n\t\t\t\t\t\tisAlive: \"true\"\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t\"|\",\n\t\t\t\t{\n\t\t\t\t\tcat: {\n\t\t\t\t\t\tisAlive: \"false\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t)\n\n\t\t\tattest<typeof Expected.t>(SchrodingersBox.t)\n\t\t\t// ideally, this would be reduced to { cat: { isAlive: boolean } }:\n\t\t\t// https://github.com/arktypeio/arktype/issues/751\n\t\t\tattest(SchrodingersBox.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"referenced from other scope\", () => {\n\t\t\tconst types = scope({\n\t\t\t\tarrayOf: type(\"<t>\", \"t[]\")\n\t\t\t}).export()\n\n\t\t\tconst StringArray = types.arrayOf(\"string\")\n\t\t\tconst Expected = type(\"string[]\")\n\n\t\t\tattest<typeof Expected.t>(StringArray.t)\n\t\t\tattest(StringArray.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"this not resolvable in generic def\", () => {\n\t\t\tattest(() =>\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttype(\"<t>\", {\n\t\t\t\t\tbox: \"t | this\"\n\t\t\t\t})\n\t\t\t).throwsAndHasTypeError(writeUnresolvableMessage(\"this\"))\n\t\t})\n\n\t\tit(\"this in arg\", () => {\n\t\t\tconst boxOf = type(\"<t>\", {\n\t\t\t\tbox: \"t\"\n\t\t\t})\n\n\t\t\tconst T = boxOf({\n\t\t\t\ta: \"string | this\"\n\t\t\t})\n\n\t\t\tattest(T.t).type.toString.snap(`{ box: { a: string | cyclic } }`)\n\t\t\tattest(T.expression).satisfies(/{ box: { a: type\\d+ \\| string } }/)\n\t\t})\n\n\t\tit(\"too few args\", () => {\n\t\t\tconst pair = type(\"<t, u>\", [\"t\", \"u\"])\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => pair(\"string\")).type.errors(\n\t\t\t\t\"Expected 2 arguments, but got 1\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"too many args\", () => {\n\t\t\tconst pair = type(\"<t, u>\", [\"t\", \"u\"])\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => pair(\"string\", \"boolean\", \"number\")).type.errors(\n\t\t\t\t\"Expected 2 arguments, but got 3\"\n\t\t\t)\n\t\t})\n\t})\n\n\tdescribe(\"constraints\", () => {\n\t\tconst testNonEmpty = (\n\t\t\tnonEmpty: Generic<[[\"arr\", unknown[]]], \"arr > 0\", {}>\n\t\t) => {\n\t\t\tconst T = nonEmpty(\"number[]\")\n\t\t\tconst Expected = type(\"number[] > 0\")\n\n\t\t\tattest<typeof Expected.t>(T.t)\n\t\t\tattest(T.expression).equals(Expected.expression)\n\t\t}\n\n\t\tit(\"can apply constraints to parameters\", () => {\n\t\t\tconst nonEmpty = type(\"<arr extends unknown[]>\", \"arr > 0\")\n\t\t\ttestNonEmpty(nonEmpty)\n\t\t})\n\n\t\tit(\"can apply constraints with whitespace\", () => {\n\t\t\tconst nonEmpty = type(\"<   arr     extends    unknown  []>\", \"arr > 0\")\n\t\t\ttestNonEmpty(nonEmpty)\n\t\t})\n\n\t\tit(\"constrained constraint\", () => {\n\t\t\tconst positiveToInteger = type(\"<n extends number > 0>\", \"n % 1\")\n\n\t\t\tconst T = positiveToInteger(\"number > 0\")\n\t\t\tconst Expected = type(\"number.integer > 0\")\n\n\t\t\tattest<typeof Expected.t>(T.t)\n\t\t\tattest(T.expression).equals(Expected.expression)\n\t\t\tattest(() => positiveToInteger(\"number\")).throws(\n\t\t\t\twriteUnsatisfiedParameterConstraintMessage(\"n\", \"number > 0\", \"number\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"unsatisfied parameter string\", () => {\n\t\t\tconst $ = scope({\n\t\t\t\t\"entry<k extends Key, v>\": [\"k\", \"v\"],\n\t\t\t\tfoobar: \"entry<'foo', 'bar'>\"\n\t\t\t})\n\n\t\t\tconst types = $.export()\n\n\t\t\tconst Expected = type([\"'foo'\", \"'bar'\"])\n\n\t\t\tattest<typeof Expected.t>(types.foobar.t)\n\t\t\tattest(types.foobar.expression).equals(Expected.expression)\n\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => $.type(\"entry<0, 1>\")).throwsAndHasTypeError(\n\t\t\t\twriteUnsatisfiedParameterConstraintMessage(\"k\", \"string | symbol\", \"0\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"can parse constraint including alias from current scope\", () => {\n\t\t\tconst $ = scope({\n\t\t\t\t\"entry<k extends key, v>\": [\"k\", \"v\"],\n\t\t\t\tkey: \"string | symbol\"\n\t\t\t})\n\n\t\t\tconst types = $.export()\n\n\t\t\tconst Ok = types.entry(\"string\", \"number\")\n\n\t\t\tattest<[string, number]>(Ok.t)\n\t\t\tattest(Ok.expression).snap(\"[string, number]\")\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => types.entry(\"boolean\", \"number\"))\n\t\t\t\t.throws(\n\t\t\t\t\twriteUnsatisfiedParameterConstraintMessage(\n\t\t\t\t\t\t\"k\",\n\t\t\t\t\t\t\"string | symbol\",\n\t\t\t\t\t\t\"boolean\"\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t.type.errors(\n\t\t\t\t\t`ErrorType<[\"Invalid argument for k\", expected: string | symbol]>`\n\t\t\t\t)\n\t\t})\n\n\t\tit(\"errors on unsatisfied constraints from current scope\", () => {\n\t\t\tattest(() =>\n\t\t\t\tscope({\n\t\t\t\t\t\"entry<k extends specialKey, v>\": [\"k\", \"v\"],\n\t\t\t\t\tspecialKey: \"string | symbol\",\n\t\t\t\t\tgoodEntry: \"entry<'foo', 1>\",\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tbadEntry: \"entry<1, 0>\"\n\t\t\t\t}).export()\n\t\t\t).throws(\n\t\t\t\twriteUnsatisfiedParameterConstraintMessage(\"k\", \"string | symbol\", \"1\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"constraint parse error\", () => {\n\t\t\tattest(() => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttype(\"<n extends nummer>\", \"n > 0\")\n\t\t\t}).throwsAndHasTypeError(writeUnresolvableMessage(\"nummer\"))\n\t\t})\n\n\t\tit(\"constraint semantic parse error\", () => {\n\t\t\tattest(() => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttype(\"<boo extends boolean > 0>\", \"boo\")\n\t\t\t}).throwsAndHasTypeError(writeUnboundableMessage(\"boolean\"))\n\t\t})\n\n\t\tit(\"default constraint is unknown\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"<arr>\", \"arr > 0\")).throwsAndHasTypeError(\n\t\t\t\twriteUnboundableMessage(\"unknown\")\n\t\t\t)\n\t\t})\n\t})\n\n\tcontextualize.each(\n\t\t\"scoped\",\n\t\t() => {\n\t\t\tconst $ = scope({\n\t\t\t\t\"box<t,u>\": {\n\t\t\t\t\tbox: \"t|u\"\n\t\t\t\t},\n\t\t\t\tbitBox: \"box<0,1>\"\n\t\t\t})\n\n\t\t\treturn { $, types: $.export() }\n\t\t},\n\t\tit => {\n\t\t\tit(\"referenced in scope\", ({ types }) => {\n\t\t\t\tconst Expected = type({ box: \"0|1\" })\n\n\t\t\t\tattest(types.bitBox.json).equals(Expected.json)\n\t\t\t\tattest<typeof Expected.t>(types.bitBox.t)\n\t\t\t})\n\n\t\t\tit(\"nested\", ({ $ }) => {\n\t\t\t\tconst T = $.type(\"box<0|1, box<'one', 'zero'>>\")\n\n\t\t\t\tconst Expected = type({ box: [\"0|1\", \"|\", { box: \"'one'|'zero'\" }] })\n\n\t\t\t\tattest<typeof Expected.t>(T.t)\n\t\t\t\tattest(T.json).equals(Expected.json)\n\t\t\t})\n\n\t\t\tit(\"in expression\", ({ $ }) => {\n\t\t\t\tconst T = $.type(\"string | box<0, 1> | boolean\")\n\n\t\t\t\tconst Expected = type(\"string|boolean\", \"|\", { box: \"0|1\" })\n\n\t\t\t\tattest<typeof Expected.t>(T.t)\n\t\t\t\tattest(T.json).equals(Expected.json)\n\t\t\t})\n\n\t\t\tit(\"right bounds\", ({ $ }) => {\n\t\t\t\t// should be able to differentiate between > that is part of a right\n\t\t\t\t// bound and > that closes a generic instantiation\n\t\t\t\tconst T = $.type(\"box<number>5, string>=7>\")\n\n\t\t\t\tconst Expected = type({\n\t\t\t\t\tbox: \"number>5|string>=7\"\n\t\t\t\t})\n\n\t\t\t\tattest<typeof Expected.t>(T.t)\n\t\t\t\tattest(T.json).equals(Expected.json)\n\t\t\t})\n\n\t\t\tit(\"unclosed instantiation\", ({ $ }) => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tattest(() => $.type(\"box<0,  1\")).throwsAndHasTypeError(\n\t\t\t\t\twriteUnclosedGroupMessage(\">\")\n\t\t\t\t)\n\t\t\t})\n\n\t\t\tit(\"extra >\", ({ $ }) => {\n\t\t\t\tattest(() =>\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t$.type(\"box<0,  1>>\")\n\t\t\t\t).throwsAndHasTypeError(writeUnexpectedCharacterMessage(\">\"))\n\t\t\t})\n\n\t\t\tit(\"too few args\", ({ $ }) => {\n\t\t\t\tattest(() =>\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t$.type(\"box<0,box<2 | 3>>\")\n\t\t\t\t).throwsAndHasTypeError(\n\t\t\t\t\twriteInvalidGenericArgCountMessage(\"box\", [\"t\", \"u\"], [\"2 | 3\"])\n\t\t\t\t)\n\t\t\t})\n\n\t\t\tit(\"too many args\", ({ $ }) => {\n\t\t\t\tattest(() =>\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t$.type(\"box<0, box<1, 2, 3>>\")\n\t\t\t\t).throwsAndHasTypeError(\n\t\t\t\t\twriteInvalidGenericArgCountMessage(\"box\", [\"t\", \"u\"], [\"1\", \"2\", \"3\"])\n\t\t\t\t)\n\t\t\t})\n\n\t\t\tit(\"syntactic error in arg\", ({ $ }) => {\n\t\t\t\tattest(() =>\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t$.type(\"box<1, number%0>\")\n\t\t\t\t).throwsAndHasTypeError(writeInvalidDivisorMessage(0))\n\t\t\t})\n\n\t\t\tit(\"semantic error in arg\", ({ $ }) => {\n\t\t\t\tattest(() =>\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t$.type(\"box<1,string%2>\")\n\t\t\t\t).throwsAndHasTypeError(writeIndivisibleMessage(intrinsic.string))\n\t\t\t})\n\n\t\t\tit(\"parameter supercedes alias with same name\", () => {\n\t\t\t\tconst types = scope({\n\t\t\t\t\t\"box<Foo>\": {\n\t\t\t\t\t\tbox: \"Foo|Bar\"\n\t\t\t\t\t},\n\t\t\t\t\tFoo: \"'foo'\",\n\t\t\t\t\tBar: \"'bar'\"\n\t\t\t\t}).export()\n\n\t\t\t\tconst T = types.box(\"'baz'\")\n\n\t\t\t\tconst Expected = type({ box: \"'bar' | 'baz'\" })\n\n\t\t\t\tattest<typeof Expected.t>(T.t)\n\t\t\t\tattest(T.json).equals(Expected.json)\n\t\t\t})\n\n\t\t\tit(\"declaration and instantiation leading and trailing whitespace\", () => {\n\t\t\t\tconst types = scope({\n\t\t\t\t\t\"box< a , b >\": {\n\t\t\t\t\t\tbox: \" a | b \"\n\t\t\t\t\t},\n\t\t\t\t\tactual: \"  box  < 'foo'  ,   'bar'  > \"\n\t\t\t\t}).export()\n\n\t\t\t\tconst Expected = type({\n\t\t\t\t\tbox: \"'foo' | 'bar'\"\n\t\t\t\t})\n\n\t\t\t\tattest<typeof Expected.t>(types.actual.t)\n\t\t\t\tattest(Expected.json).equals(types.actual.json)\n\t\t\t})\n\n\t\t\tit(\"allows external scope reference to be resolved\", () => {\n\t\t\t\tconst types = scope({\n\t\t\t\t\texternal: \"'external'\",\n\t\t\t\t\t\"orExternal<t>\": \"t|external\"\n\t\t\t\t}).export()\n\n\t\t\t\tconst b = scope({\n\t\t\t\t\torExternal: types.orExternal,\n\t\t\t\t\tinternal: \"orExternal<'internal'>\"\n\t\t\t\t}).export()\n\n\t\t\t\tconst Expected = type(\"'internal' | 'external'\")\n\n\t\t\t\tattest<typeof Expected.t>(b.internal.t)\n\t\t\t\tattest(b.internal.json).equals(Expected.json)\n\t\t\t})\n\n\t\t\tit(\"empty string in declaration\", () => {\n\t\t\t\tattest(() =>\n\t\t\t\t\tscope({\n\t\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\t\"box<t,,u>\": \"string\"\n\t\t\t\t\t}).export()\n\t\t\t\t).throwsAndHasTypeError(emptyGenericParameterMessage)\n\t\t\t})\n\t\t}\n\t)\n\n\tit(\"args completions from type\", () => {\n\t\tconst g = type(\"<t>\", { box: \"t\" })\n\n\t\tattest(() =>\n\t\t\tg({\n\t\t\t\t// @ts-expect-error\n\t\t\t\tFoo: \"numb\",\n\t\t\t\t// @ts-expect-error\n\t\t\t\tBar: \"big\"\n\t\t\t})\n\t\t).completions({\n\t\t\tnumb: [\"number\"],\n\t\t\tbig: [\"bigint\"]\n\t\t})\n\t})\n\n\tcontextualize.each(\n\t\t\"standalone\",\n\t\t() =>\n\t\t\tgeneric([\n\t\t\t\t\"t\",\n\t\t\t\t{\n\t\t\t\t\tfoo: \"number\"\n\t\t\t\t}\n\t\t\t])({ boxOf: \"t\" }),\n\t\tit => {\n\t\t\tit(\"valid\", g => {\n\t\t\t\tconst T = g({\n\t\t\t\t\tfoo: \"number\"\n\t\t\t\t})\n\n\t\t\t\tconst Expected = type({\n\t\t\t\t\tboxOf: {\n\t\t\t\t\t\tfoo: \"number\"\n\t\t\t\t\t}\n\t\t\t\t})\n\n\t\t\t\tattest<typeof Expected.t>(T.t)\n\t\t\t\tattest(T.expression).equals(Expected.expression)\n\t\t\t})\n\n\t\t\tit(\"invalid\", g => {\n\t\t\t\tattest(() =>\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tg({\n\t\t\t\t\t\tfoo: \"string\"\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t\t\t.throws(\n\t\t\t\t\t\twriteUnsatisfiedParameterConstraintMessage(\n\t\t\t\t\t\t\t\"t\",\n\t\t\t\t\t\t\t\"{ foo: number }\",\n\t\t\t\t\t\t\t\"{ foo: string }\"\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t\t.type.errors(\n\t\t\t\t\t\t`ErrorType<[\"Invalid argument for t\", expected: { foo: number; }]>`\n\t\t\t\t\t)\n\t\t\t})\n\n\t\t\tit(\"completions in instantiation\", g => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tattest(() => g({ foo: \"numb\" })).completions({\n\t\t\t\t\tnumb: [\"number\"]\n\t\t\t\t})\n\t\t\t})\n\n\t\t\tit(\"completions in contraint\", () => {\n\t\t\t\tattest(() =>\n\t\t\t\t\tgeneric([\n\t\t\t\t\t\t\"t\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\t\tfoo: \"numb\"\n\t\t\t\t\t\t}\n\t\t\t\t\t])\n\t\t\t\t).completions({\n\t\t\t\t\tnumb: [\"number\"]\n\t\t\t\t})\n\t\t\t})\n\n\t\t\tit(\"is available on type\", () => {\n\t\t\t\tconst nonEmpty = type.generic([\"s\", \"string\"])(\"s > 0\")\n\n\t\t\t\tconst Expected = type(\"string.alpha > 0\")\n\t\t\t\tconst actual = nonEmpty(\"string.alpha\")\n\t\t\t\tattest<typeof Expected>(actual)\n\t\t\t\tattest(actual.expression).equals(Expected.expression)\n\t\t\t})\n\t\t}\n\t)\n\n\tdescribe(\"hkt\", () => {\n\t\tit(\"can infer a generic from an hkt\", () => {\n\t\t\tclass MyExternalClass<T> {\n\t\t\t\tdata: T\n\n\t\t\t\tconstructor(data: T) {\n\t\t\t\t\tthis.data = data\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst validateExternalGeneric = generic(\"T\")(\n\t\t\t\targs =>\n\t\t\t\t\ttype(\"instanceof\", MyExternalClass).and({\n\t\t\t\t\t\tdata: args.T\n\t\t\t\t\t}),\n\t\t\t\tclass extends Hkt {\n\t\t\t\t\tdeclare body: MyExternalClass<this[0]>\n\t\t\t\t}\n\t\t\t)\n\n\t\t\tconst T = validateExternalGeneric({\n\t\t\t\tname: \"string\",\n\t\t\t\tage: \"number\"\n\t\t\t})\n\n\t\t\tattest<\n\t\t\t\tMyExternalClass<{\n\t\t\t\t\tname: string\n\t\t\t\t\tage: number\n\t\t\t\t}>\n\t\t\t>(T.t)\n\n\t\t\tattest(T.json).snap({\n\t\t\t\trequired: [\n\t\t\t\t\t{\n\t\t\t\t\t\tkey: \"data\",\n\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\trequired: [\n\t\t\t\t\t\t\t\t{ key: \"age\", value: \"number\" },\n\t\t\t\t\t\t\t\t{ key: \"name\", value: \"string\" }\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tdomain: \"object\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\tproto: \"$ark.MyExternalClass\"\n\t\t\t})\n\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => validateExternalGeneric({ numb: \"numb\" })).completions({\n\t\t\t\tnumb: [\"number\"]\n\t\t\t})\n\t\t})\n\n\t\tit(\"can infer constrained parameters\", () => {\n\t\t\tconst validateExternalGeneric = generic(\n\t\t\t\t[\"S\", \"string\"],\n\t\t\t\t[\"N\", { value: \"number\" }]\n\t\t\t)(\n\t\t\t\targs => [args.S.atLeastLength(1), args.N],\n\t\t\t\tclass extends Hkt<[string, { value: number }]> {\n\t\t\t\t\tdeclare body: [this[0], this[1]]\n\t\t\t\t}\n\t\t\t)\n\n\t\t\tconst T = validateExternalGeneric(\"string\", { value: \"1\" })\n\n\t\t\tattest<\n\t\t\t\t[\n\t\t\t\t\tstring,\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 1\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t>(T.t)\n\n\t\t\tattest(T.expression).snap(\"[string >= 1, { value: 1 }]\")\n\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => validateExternalGeneric(\"string\", { value: \"string\" }))\n\t\t\t\t.throws(\n\t\t\t\t\twriteUnsatisfiedParameterConstraintMessage(\n\t\t\t\t\t\t\"N\",\n\t\t\t\t\t\t\"{ value: number }\",\n\t\t\t\t\t\t\"{ value: string }\"\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t.type.errors(\n\t\t\t\t\t`ErrorType<[\"Invalid argument for N\", expected: { value: number; }]>`\n\t\t\t\t)\n\n\t\t\tattest(() =>\n\t\t\t\t// @ts-expect-error\n\t\t\t\tvalidateExternalGeneric(\"strin\", { numb: \"number\" })\n\t\t\t).completions({\n\t\t\t\tstrin: [\"string\"]\n\t\t\t})\n\n\t\t\tattest(() =>\n\t\t\t\t// @ts-expect-error\n\t\t\t\tvalidateExternalGeneric(\"string\", { numb: \"numb\" })\n\t\t\t).completions({\n\t\t\t\tnumb: [\"number\"]\n\t\t\t})\n\t\t})\n\t})\n\n\t// currently types only, runtime pending: https://github.com/arktypeio/arktype/issues/1082\n\tdescribe(\"cyclic\", () => {\n\t\tconst enable = false\n\t\tit(\"self-reference\", () => {\n\t\t\tconst getTypes = () =>\n\t\t\t\tscope({\n\t\t\t\t\t\"alternate<a, b>\": {\n\t\t\t\t\t\t// ensures old generic params aren't intersected with\n\t\t\t\t\t\t// updated values (would be never)\n\t\t\t\t\t\tswap: \"alternate<b, a>\",\n\t\t\t\t\t\torder: [\"a\", \"b\"]\n\t\t\t\t\t},\n\t\t\t\t\treference: \"alternate<0, 1>\"\n\t\t\t\t}).export()\n\t\t\tconst types = enable ? getTypes() : (chainableNoOpProxy as never)\n\t\t\tattest<[0, 1]>(types.reference.infer.swap.swap.order)\n\t\t\tattest<[1, 0]>(types.reference.infer.swap.swap.swap.order)\n\t\t\tconst getFromCall = () => types.alternate(\"'off'\", \"'on'\")\n\t\t\tconst fromCall = enable ? getFromCall() : (chainableNoOpProxy as never)\n\n\t\t\tattest<[\"off\", \"on\"]>(fromCall.infer.swap.swap.order)\n\t\t\tattest<[\"on\", \"off\"]>(fromCall.infer.swap.swap.swap.order)\n\t\t})\n\t\tit(\"self-reference no params\", () => {\n\t\t\tattest(() =>\n\t\t\t\tscope({\n\t\t\t\t\t\"nest<t>\": {\n\t\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\tnest: \"nest\"\n\t\t\t\t\t}\n\t\t\t\t}).export()\n\t\t\t)\n\t\t})\n\t})\n\n\tit(\"assignability rules\", () => {\n\t\t// like Type methods, generic invocation needs to return:\n\t\t//  \tr extends infer _ ? _ : never\n\t\t// or similar to avoid breaking assignability\n\n\t\tit(\"unary\", () => {\n\t\t\tconst unary = type(\"<t>\", \"t\")\n\n\t\t\tunary(\"0\") satisfies type<0>\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => unary(\"0\") satisfies type<null>).type.errors(\n\t\t\t\t\"not assignable to type 'null'\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"binary\", () => {\n\t\t\tconst binary = type(\"<t, u>\", \"t | u\")\n\n\t\t\tbinary(\"0\", \"1\") satisfies type<0 | 1>\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => binary(\"0\", \"1\") satisfies type<string>).type.errors(\n\t\t\t\t\"not assignable to type 'string'\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"ternary\", () => {\n\t\t\tconst ternary = type(\"<t, u, v>\", \"t | u | v\")\n\n\t\t\tternary(\"0\", \"1\", \"2\") satisfies type<0 | 1 | 2>\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => ternary(\"0\", \"1\", \"2\") satisfies type<0>).type.errors(\n\t\t\t\t\"not assignable to type '0'\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"quaternary\", () => {\n\t\t\tconst quaternary = type(\"<t, u, v, w>\", \"t | u | v | w\")\n\n\t\t\tquaternary(\"0\", \"1\", \"2\", \"3\") satisfies type<0 | 1 | 2 | 3>\n\n\t\t\tattest(\n\t\t\t\t// @ts-expect-error\n\t\t\t\t() => quaternary(\"0\", \"1\", \"2\", \"3\") satisfies type<string>\n\t\t\t).type.errors(\"not assignable to type 'string'\")\n\t\t})\n\n\t\tit(\"quinary\", () => {\n\t\t\tconst quinary = type(\"<t, u, v, w, x>\", \"t | u | v | w | x\")\n\n\t\t\tquinary(\"0\", \"1\", \"2\", \"3\", \"4\") satisfies type<0 | 1 | 2 | 3 | 4>\n\n\t\t\tattest(\n\t\t\t\t// @ts-expect-error\n\t\t\t\t() => quinary(\"0\", \"1\", \"2\", \"3\", \"4\") satisfies type<null>\n\t\t\t).type.errors(\"not assignable to type 'null'\")\n\t\t})\n\n\t\tit(\"senary\", () => {\n\t\t\tconst senary = type(\"<t, u, v, w, x, y>\", \"t | u | v | w | x | y\")\n\n\t\t\tsenary(\"0\", \"1\", \"2\", \"3\", \"4\", \"5\") satisfies type<0 | 1 | 2 | 3 | 4 | 5>\n\n\t\t\tattest(\n\t\t\t\t// @ts-expect-error\n\t\t\t\t() => senary(\"0\", \"1\", \"2\", \"3\", \"4\", \"5\") satisfies type<boolean>\n\t\t\t).type.errors(\"not assignable to type 'boolean'\")\n\t\t})\n\t})\n\n\tdescribe(\"external\", () => {\n\t\tit(\"docs def\", () => {\n\t\t\tconst createBox = <const def>(\n\t\t\t\tof: type.validate<def>\n\t\t\t): type.instantiate<{ of: def }> =>\n\t\t\t\ttype.raw({\n\t\t\t\t\tbox: of\n\t\t\t\t}) as never\n\n\t\t\tconst BoxType = createBox(\"string\")\n\n\t\t\tattest<{ of: string }>(BoxType.t)\n\t\t})\n\n\t\tit(\"docs def\", () => {\n\t\t\tconst createBox = <const def>(\n\t\t\t\tof: type.validate<def>\n\t\t\t): type.instantiate<{ of: def }> =>\n\t\t\t\ttype.raw({\n\t\t\t\t\tbox: of\n\t\t\t\t}) as never\n\n\t\t\tconst BoxType = createBox(\"string\")\n\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => createBox(\"str\")).completions({\n\t\t\t\tstr: [\"string\"]\n\t\t\t})\n\n\t\t\tattest<{ of: string }>(BoxType.t)\n\t\t})\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/get.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { writeInvalidKeysMessage, writeNumberIndexMessage } from \"@ark/schema\"\nimport { keywords, type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"can get shallow roots by path\", () => {\n\t\tconst T = type({\n\t\t\tfoo: \"string\",\n\t\t\tbar: \"number|bigint\"\n\t\t})\n\n\t\tconst a = T.get(\"bar\")\n\t\tattest<number | bigint>(a.infer)\n\t\tattest(a.expression).snap(\"bigint | number\")\n\t})\n\n\tit(\"can get deep roots by path\", () => {\n\t\tconst T = type({\n\t\t\tfoo: {\n\t\t\t\tbaz: \"1\"\n\t\t\t},\n\t\t\tbar: {\n\t\t\t\tquux: \"2\"\n\t\t\t}\n\t\t})\n\n\t\tconst a = T.get(\"foo\", \"baz\")\n\t\tattest<1>(a.t)\n\t\tattest(a.expression).snap(\"1\")\n\n\t\tconst b = T.get(\"bar\", \"quux\")\n\t\tattest<2>(b.t)\n\t\tattest(b.expression).snap(\"2\")\n\t})\n\n\tit(\"can merge across a deep union\", () => {\n\t\tconst Base = type(\n\t\t\t{\n\t\t\t\tfoo: {\n\t\t\t\t\tbar: \"0\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"|\",\n\t\t\t{\n\t\t\t\tfoo: {\n\t\t\t\t\tbar: \"1\"\n\t\t\t\t}\n\t\t\t}\n\t\t)\n\n\t\tconst T = Base.get(\"foo\", \"bar\")\n\n\t\tattest<0 | 1>(T.infer)\n\t\tattest(T.expression).snap(\"0 | 1\")\n\t})\n\n\tit(\"can get index keys\", () => {\n\t\tconst T = type({\n\t\t\t\"[/^f/]\": \"0\",\n\t\t\tnamed: \"1\"\n\t\t})\n\n\t\tconst a = T.get(\"foo\")\n\t\tattest<0>(a.t)\n\t\tattest(a.expression).snap(\"undefined | 0\")\n\n\t\tattest(() =>\n\t\t\t// @ts-expect-error\n\t\t\tT.get(\"bar\")\n\t\t).throws(writeInvalidKeysMessage(T.expression, [\"bar\"]))\n\t})\n\n\tit(\"named and multiple indices\", () => {\n\t\tconst T = type({\n\t\t\t\"[/^f/]\": {\n\t\t\t\ta: \"1\"\n\t\t\t},\n\t\t\t\"[/f$/]\": { b: \"1\" },\n\t\t\tfoof: { c: \"1\" }\n\t\t})\n\n\t\tconst a = T.get(\"foo\")\n\n\t\tattest<{ a: 1 }>(a.infer)\n\t\tattest(a.expression).snap(\"{ a: 1 } | undefined\")\n\n\t\tconst b = T.get(\"oof\")\n\t\tattest<{ b: 1 }>(b.infer)\n\t\tattest(b.expression).snap(\"{ b: 1 } | undefined\")\n\n\t\tconst c = T.get(\"fof\")\n\t\tattest<{ a: 1 } & { b: 1 }>(c.infer)\n\t\tattest(c.expression).snap(\"{ a: 1, b: 1 } | undefined\")\n\n\t\tconst d = T.get(\"foof\")\n\n\t\tattest<{ c: 1 }>(d.infer)\n\t\tattest(d.expression).snap(\"{ a: 1, b: 1, c: 1 }\")\n\n\t\tattest(\n\t\t\t() =>\n\t\t\t\t// @ts-expect-error\n\t\t\t\tT.get(\"goog\").expression\n\t\t).throws(writeInvalidKeysMessage(T.expression, [\"goog\"]))\n\t})\n\n\tit(\"optional key adds undefined\", () => {\n\t\tconst T = type({\n\t\t\t\"foo?\": \"null\"\n\t\t})\n\n\t\tconst a = T.get(\"foo\")\n\t\tattest<null | undefined>(a.t)\n\t\tattest(a.expression).snap(\"undefined | null\")\n\t})\n\n\tit(\"non-fixed array\", () => {\n\t\tconst T = type(\"string[]\")\n\n\t\tconst a = T.get(\"0\")\n\t\tattest<string>(a.infer)\n\t\tattest(a.expression).snap(\"string | undefined\")\n\n\t\t// @ts-expect-error\n\t\tattest(() => T.get(\"-1\")).throws(\n\t\t\twriteInvalidKeysMessage(T.expression, [\"-1\"])\n\t\t)\n\t\t// @ts-expect-error\n\t\tattest(() => T.get(\"5.5\")).throws(\n\t\t\twriteInvalidKeysMessage(T.expression, [\"5.5\"])\n\t\t)\n\n\t\tattest(T.get(type.arrayIndex).expression).snap(\"string | undefined\")\n\t})\n\n\tit(\"array specific-index access access on non-tuple\", () => {\n\t\tconst T = type({ foo: \"number\" }).array()\n\n\t\tattest(T.get(0).expression).snap(\"{ foo: number } | undefined\")\n\t})\n\n\t// https://github.com/arktypeio/arktype/issues/1261\n\tit(\"nested index access on non-tuple\", () => {\n\t\tconst Simple = type({\n\t\t\tid: \"number\",\n\t\t\tarray: type({\n\t\t\t\tname: \"string\",\n\t\t\t\tage: \"number\"\n\t\t\t}).array()\n\t\t})\n\n\t\tconst Arr = Simple.get(\"array\")\n\t\tconst InnerArr = Arr.get(0)\n\n\t\tattest(InnerArr.expression).snap(\n\t\t\t\"{ age: number, name: string } | undefined\"\n\t\t)\n\t\tInnerArr.assert({ name: \"Rico\", age: 25 })\n\t})\n\n\tit(\"number access on non-tuple\", () => {\n\t\tconst T = type({ foo: \"number\" }).array()\n\n\t\t// @ts-expect-error\n\t\tattest(() => T.get(type.number)).throws(\n\t\t\twriteNumberIndexMessage(\"number\", T.expression)\n\t\t)\n\n\t\t// number subtype\n\t\t// @ts-expect-error\n\t\tattest(() => T.get(keywords.number.integer)).throws(\n\t\t\twriteNumberIndexMessage(\"number % 1\", T.expression)\n\t\t)\n\t})\n\n\tit(\"tuple\", () => {\n\t\tconst T = type([\"1\", \"2?\"])\n\n\t\t// fixed\n\t\tconst a = T.get(0)\n\t\tattest<1>(a.infer)\n\t\tattest(a.expression).snap(\"1\")\n\t\tconst b = T.get(1)\n\t\tattest<2 | undefined>(b.infer)\n\t\tattest(b.expression).snap(\"undefined | 2\")\n\n\t\t// out of bounds\n\t\t// @ts-expect-error\n\t\tattest(() => T.get(2)).throws(writeInvalidKeysMessage(T.expression, [\"2\"]))\n\t})\n\n\tit(\"variadic tuple\", () => {\n\t\tconst T = type([\"1\", \"2\", \"...\", \"3[]\", \"4\", \"5\"])\n\n\t\t// fixed\n\t\tconst a = T.get(0)\n\t\tattest<1>(a.t)\n\t\tattest(a.expression).snap(\"1\")\n\n\t\tconst b = T.get(1)\n\t\tattest<2>(b.t)\n\t\tattest(b.expression).snap(\"2\")\n\n\t\t// variadic\n\t\t// based on length, we could narrow this to remove undefined in the future\n\t\tattest(T.get(\"2\").expression).snap(\"undefined | 3 | 4 | 5\")\n\t\tattest(T.get(\"100\").expression).snap(\"undefined | 3 | 4 | 5\")\n\t})\n\n\tit(\"deep\", () => {\n\t\tconst T = type({\n\t\t\tfoo: {\n\t\t\t\t\"[symbol]\": {\n\t\t\t\t\tbar: \"1\",\n\t\t\t\t\t\"baz?\": \"2\"\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\n\t\tconst bar = T.get(\"foo\", keywords.symbol, \"bar\")\n\t\tattest<1>(bar.t)\n\t\tattest(bar.expression).snap(\"undefined | 1\")\n\n\t\tconst baz = T.get(\"foo\", keywords.symbol, \"baz\")\n\t\tattest<2 | undefined>(baz.t)\n\t\tattest(baz.expression).snap(\"undefined | 2\")\n\n\t\t// @ts-expect-error\n\t\tattest(() => T.get(\"foo\", keywords.symbol, \"\")).completions({\n\t\t\t\"\": [\"bar\", \"baz\"]\n\t\t})\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/group.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport {\n\twriteUnclosedGroupMessage,\n\twriteUnmatchedGroupCloseMessage\n} from \"@ark/util\"\nimport { type } from \"arktype\"\nimport { writeExpressionExpectedMessage } from \"arktype/internal/parser/shift/operand/unenclosed.ts\"\n\ncontextualize(() => {\n\tit(\"entire expression\", () => {\n\t\tconst T = type(\"(string)\")\n\t\tconst Expected = type(\"string\")\n\t\tattest<typeof Expected>(T)\n\t\tattest(T.json).equals(Expected.json)\n\t})\n\n\tit(\"overrides default precedence\", () => {\n\t\tconst T = type(\"(boolean|number)[]\")\n\t\tconst Expected = type(\"boolean|number\").array()\n\t\tattest<typeof Expected>(T)\n\t\tattest(T.json).equals(Expected.json)\n\t})\n\n\tit(\"nested\", () => {\n\t\tattest<((number | boolean)[] | (string | undefined)[])[]>(\n\t\t\ttype(\"((boolean|number)[]|(string|undefined)[])[]\").infer\n\t\t)\n\t})\n\n\tit(\"empty\", () => {\n\t\tattest(() => {\n\t\t\t// @ts-expect-error\n\t\t\ttype(\"()\")\n\t\t}).throws(writeExpressionExpectedMessage(\")\"))\n\t})\n\n\tit(\"unmatched (\", () => {\n\t\tattest(() => {\n\t\t\t// @ts-expect-error\n\t\t\ttype(\"string|(boolean|number[]\")\n\t\t}).throwsAndHasTypeError(writeUnclosedGroupMessage(\")\"))\n\t})\n\n\tit(\"unmatched )\", () => {\n\t\tattest(() => {\n\t\t\t// @ts-expect-error\n\t\t\ttype(\"string|number[]|boolean)\")\n\t\t}).throwsAndHasTypeError(writeUnmatchedGroupCloseMessage(\")\", \"\"))\n\t})\n\n\tit(\"lone )\", () => {\n\t\tattest(() => {\n\t\t\t// @ts-expect-error\n\t\t\ttype(\")\")\n\t\t}).throws(writeExpressionExpectedMessage(\")\"))\n\t})\n\n\tit(\"lone (\", () => {\n\t\tattest(() => {\n\t\t\t// @ts-expect-error\n\t\t\ttype(\"(\")\n\t\t}).throws(writeExpressionExpectedMessage(\"\"))\n\t})\n\n\tit(\"deep unmatched (\", () => {\n\t\tattest(() => {\n\t\t\t// @ts-expect-error\n\t\t\ttype(\"(null|(undefined|(1))|2\")\n\t\t}).throwsAndHasTypeError(writeUnclosedGroupMessage(\")\"))\n\t})\n\n\tit(\"deep unmatched )\", () => {\n\t\tattest(() => {\n\t\t\t// @ts-expect-error\n\t\t\ttype(\"((string|number)[]|boolean))[]\")\n\t\t}).throwsAndHasTypeError(writeUnmatchedGroupCloseMessage(\")\", \"[]\"))\n\t})\n\n\tit(\"starting )\", () => {\n\t\tattest(() => {\n\t\t\t// @ts-expect-error\n\t\t\ttype(\")number(\")\n\t\t}).throws(writeExpressionExpectedMessage(\")number(\"))\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/imports.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { writeDuplicateAliasError } from \"@ark/schema\"\nimport { scope, type, type BoundModule, type Module, type Type } from \"arktype\"\nimport { writePrefixedPrivateReferenceMessage } from \"arktype/internal/parser/ast/validate.ts\"\n\ncontextualize(() => {\n\tcontextualize.each(\n\t\t\"threeSixtyNoScope\",\n\t\t() => {\n\t\t\tconst threeSixtyNoScope = scope({\n\t\t\t\tthree: \"3\",\n\t\t\t\tsixty: \"60\",\n\t\t\t\tno: \"'no'\"\n\t\t\t})\n\t\t\tconst threeSixtyNoModule = threeSixtyNoScope.export()\n\n\t\t\tconst yesScope = scope({ yes: \"'yes'\" })\n\t\t\tconst yesModule = yesScope.export()\n\n\t\t\treturn {\n\t\t\t\tthreeSixtyNoScope,\n\t\t\t\tthreeSixtyNoModule,\n\t\t\t\tyesScope,\n\t\t\t\tyesModule\n\t\t\t}\n\t\t},\n\t\tit => {\n\t\t\tit(\"single\", ({ threeSixtyNoModule }) => {\n\t\t\t\tconst types = scope({\n\t\t\t\t\t...threeSixtyNoModule,\n\t\t\t\t\tthreeSixtyNo: \"three|sixty|no\"\n\t\t\t\t}).export()\n\n\t\t\t\tattest<\n\t\t\t\t\tModule<{\n\t\t\t\t\t\tthree: 3\n\t\t\t\t\t\tsixty: 60\n\t\t\t\t\t\tno: \"no\"\n\t\t\t\t\t\tthreeSixtyNo: 3 | 60 | \"no\"\n\t\t\t\t\t}>\n\t\t\t\t>(types)\n\t\t\t})\n\n\t\t\tit(\"multiple\", ({ threeSixtyNoModule, yesModule }) => {\n\t\t\t\tconst base = scope({\n\t\t\t\t\t...threeSixtyNoModule,\n\t\t\t\t\t...yesModule,\n\t\t\t\t\textra: \"true\"\n\t\t\t\t})\n\n\t\t\t\tconst imported = scope({\n\t\t\t\t\t...base.import(),\n\t\t\t\t\ta: \"three|sixty|no|yes|extra\"\n\t\t\t\t})\n\n\t\t\t\tconst exports = imported.export()\n\n\t\t\t\tattest(Object.keys(exports)).equals([\"a\"])\n\t\t\t\tattest(exports.a.expression).snap('\"no\" | \"yes\" | 3 | 60 | true')\n\n\t\t\t\tattest<Module<{ a: 3 | 60 | \"no\" | \"yes\" | true }>>(exports)\n\t\t\t})\n\n\t\t\tit(\"import & export\", ({ threeSixtyNoScope }) => {\n\t\t\t\tconst scopeCreep = scope({\n\t\t\t\t\thasCrept: \"true\"\n\t\t\t\t})\n\n\t\t\t\tconst types = scope({\n\t\t\t\t\t...threeSixtyNoScope.import(\"three\", \"no\"),\n\t\t\t\t\t...scopeCreep.export(),\n\t\t\t\t\tpublic: \"hasCrept|three|no|private\",\n\t\t\t\t\t\"#private\": \"string.uuid\"\n\t\t\t\t}).export()\n\n\t\t\t\tattest(Object.keys(types)).equals([\"hasCrept\", \"public\"])\n\n\t\t\t\tattest(types.public.json).equals(type(\"3|'no'|string.uuid|true\").json)\n\n\t\t\t\t// have to snapshot the module since TypeScript treats it as bivariant\n\t\t\t\tattest(types).type.toString.snap(`Module<{\n\tpublic: string | true | 3\n\thasCrept: true\n}>`)\n\t\t\t})\n\t\t}\n\t)\n\n\tit(\"docs example\", () => {\n\t\tconst shapeScope = scope({\n\t\t\t// aliases with a \"#\" prefix are treated as private\n\t\t\t\"#baseShapeProps\": {\n\t\t\t\tperimeter: \"number\",\n\t\t\t\tarea: \"number\"\n\t\t\t},\n\t\t\tellipse: {\n\t\t\t\t// when referencing a private alias, the \"#\" should not be included\n\t\t\t\t\"...\": \"baseShapeProps\",\n\t\t\t\tradii: [\"number\", \"number\"]\n\t\t\t},\n\t\t\trectangle: {\n\t\t\t\t\"...\": \"baseShapeProps\",\n\t\t\t\twidth: \"number\",\n\t\t\t\theight: \"number\"\n\t\t\t}\n\t\t})\n\n\t\t// private aliases can be referenced from any scoped definition,\n\t\t// even outside the original scope\n\t\tconst partialShape = shapeScope.type(\"Partial<baseShapeProps>\")\n\n\t\tattest<{\n\t\t\tperimeter?: number\n\t\t\tarea?: number\n\t\t}>(partialShape.t)\n\t\tattest<typeof shapeScope>(partialShape.$)\n\n\t\tattest(partialShape.expression).snap(\n\t\t\t\"{ area?: number, perimeter?: number }\"\n\t\t)\n\n\t\t// when the scope is exported to a Module, they will not be included\n\t\t// hover to see the Scope's exports\n\t\tconst shapeModule = shapeScope.export()\n\n\t\tattest(Object.keys(shapeModule)).equals([\"ellipse\", \"rectangle\"])\n\t\tattest(shapeModule).type.toString.snap(`Module<{\n\tellipse: {\n\t\tperimeter: number\n\t\tarea: number\n\t\tradii: [number, number]\n\t}\n\trectangle: {\n\t\tperimeter: number\n\t\tarea: number\n\t\twidth: number\n\t\theight: number\n\t}\n}>`)\n\t})\n\n\tit(\"docs import example\", () => {\n\t\tconst utilityScope = scope({\n\t\t\t\"withId<o extends object>\": {\n\t\t\t\t\"...\": \"o\",\n\t\t\t\tid: \"string\"\n\t\t\t}\n\t\t})\n\n\t\tconst userModule = type.module({\n\t\t\t// because we use `import()` here, we can reference our utilities\n\t\t\t// internally, but they will not be included in `userModule`.\n\t\t\t// if we used `export()` instead, `withId` could be accessed on `userModule`.\n\t\t\t...utilityScope.import(),\n\t\t\tpayload: {\n\t\t\t\tname: \"string\",\n\t\t\t\tage: \"number\"\n\t\t\t},\n\t\t\tdb: \"withId<payload>\"\n\t\t})\n\n\t\tattest(Object.keys(userModule)).equals([\"payload\", \"db\"])\n\t\tattest(userModule).type.toString.snap(`Module<{\n\tpayload: { name: string; age: number }\n\tdb: { name: string; age: number; id: string }\n}>`)\n\t})\n\n\tit(\"binds destructured exports\", () => {\n\t\tconst types = scope({\n\t\t\tfoo: \"1\",\n\t\t\tbar: \"foo\",\n\t\t\tbaz: \"bar\"\n\t\t}).export(\"baz\")\n\n\t\tattest<\n\t\t\tBoundModule<\n\t\t\t\t{\n\t\t\t\t\tbaz: 1\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tfoo: 1\n\t\t\t\t\tbar: 1\n\t\t\t\t\tbaz: 1\n\t\t\t\t}\n\t\t\t>\n\t\t>(types)\n\n\t\tconst T = types.baz.or({\n\t\t\tfoo: \"foo\",\n\t\t\tbar: \"bar\",\n\t\t\tbaz: \"baz\"\n\t\t})\n\n\t\tattest<\n\t\t\tType<\n\t\t\t\t| 1\n\t\t\t\t| {\n\t\t\t\t\t\tfoo: 1\n\t\t\t\t\t\tbar: 1\n\t\t\t\t\t\tbaz: 1\n\t\t\t\t  },\n\t\t\t\t{\n\t\t\t\t\tfoo: 1\n\t\t\t\t\tbar: 1\n\t\t\t\t\tbaz: 1\n\t\t\t\t}\n\t\t\t>\n\t\t>(T)\n\t\tattest(T.expression).snap(\"{ bar: 1, baz: 1, foo: 1 } | 1\")\n\t\tattest(T.$.json).snap({\n\t\t\tfoo: { unit: 1 },\n\t\t\tbar: { unit: 1 },\n\t\t\tbaz: { unit: 1 }\n\t\t})\n\t})\n\n\tit(\"non-generic\", () => {\n\t\tconst types = scope({\n\t\t\tfoo: \"bar[]\",\n\t\t\t\"#bar\": \"boolean\"\n\t\t}).export()\n\t\tattest(Object.keys(types)).equals([\"foo\"])\n\t\tattest(types.foo.json).equals(type(\"boolean[]\").json)\n\t\tattest<\n\t\t\tModule<{\n\t\t\t\tfoo: boolean[]\n\t\t\t}>\n\t\t>(types)\n\t})\n\n\tit(\"autocompletes private references\", () => {\n\t\tconst $ = scope({\n\t\t\t\"#kekw\": \"true\"\n\t\t})\n\n\t\t// @ts-expect-error\n\t\tattest(() => $.type(\"kek\")).completions({\n\t\t\tkek: [\"kekw\"]\n\t\t})\n\n\t\t// @ts-expect-error\n\t\tattest(() => $.type(\"#\")).completions({})\n\t})\n\n\tit(\"errors on private reference with #\", () => {\n\t\tattest(() =>\n\t\t\tscope({\n\t\t\t\t// @ts-expect-error\n\t\t\t\txdd: \"#kekw\",\n\t\t\t\t\"#kekw\": \"true\"\n\t\t\t}).export()\n\t\t).throwsAndHasTypeError(writePrefixedPrivateReferenceMessage(\"kekw\"))\n\t})\n\n\tit(\"errors on private reference with # in expression\", () => {\n\t\tattest(() =>\n\t\t\tscope({\n\t\t\t\t// @ts-expect-error\n\t\t\t\txdd: \"string|#kekw\",\n\t\t\t\t\"#kekw\": \"true\"\n\t\t\t}).export()\n\t\t).throwsAndHasTypeError(writePrefixedPrivateReferenceMessage(\"kekw\"))\n\t})\n\n\tit(\"errors on public and private reference with same name\", () => {\n\t\tattest(() =>\n\t\t\tscope({\n\t\t\t\tkekw: \"1\",\n\t\t\t\t// @ts-expect-error\n\t\t\t\t\"#kekw\": \"1\"\n\t\t\t}).export()\n\t\t).throwsAndHasTypeError(writeDuplicateAliasError(\"kekw\"))\n\t\tattest(() =>\n\t\t\tscope({\n\t\t\t\t// @ts-expect-error\n\t\t\t\t\"#kekw\": \"1\",\n\t\t\t\tkekw: \"1\"\n\t\t\t}).export()\n\t\t).throwsAndHasTypeError(writeDuplicateAliasError(\"kekw\"))\n\t})\n\n\tit(\"private generic\", () => {\n\t\tconst types = scope({\n\t\t\tfoo: \"bar<string>[]\",\n\t\t\t\"#bar<t>\": [\"t\"]\n\t\t}).export()\n\n\t\tconst Expected = type([\"string\"]).array()\n\n\t\tattest<typeof Expected.t>(types.foo.t)\n\t\tattest(types.foo.expression).snap(\"[string][]\")\n\t\tattest(types.foo.expression).equals(Expected.expression)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/instanceOf.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { Proto, rootSchema } from \"@ark/schema\"\nimport { type } from \"arktype\"\nimport { writeInvalidConstructorMessage } from \"arktype/internal/parser/tupleExpressions.ts\"\n\ncontextualize(() => {\n\tdescribe(\"tuple expression\", () => {\n\t\tit(\"base\", () => {\n\t\t\tconst T = type([\"instanceof\", Error])\n\t\t\tattest<Error>(T.infer)\n\t\t\tconst Expected = rootSchema(Error)\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t\tconst e = new Error()\n\t\t\tattest(T(e)).equals(e)\n\t\t\tattest(T(e)).equals(e)\n\t\t\tattest(T({}).toString()).snap(\"must be an Error (was object)\")\n\t\t\tattest(T(undefined).toString()).snap(\"must be an Error (was undefined)\")\n\t\t})\n\n\t\tit(\"fluent\", () => {\n\t\t\tconst T = type.instanceOf(Error)\n\n\t\t\tconst Expected = type([\"instanceof\", Error])\n\n\t\t\tattest<typeof Expected.t>(T.t)\n\t\t\tattest(T.expression).equals(Expected.expression)\n\t\t})\n\n\t\tit(\"inherited\", () => {\n\t\t\tconst T = type([\"instanceof\", TypeError])\n\t\t\tconst e = new TypeError()\n\t\t\t// for some reason the return of TypeError's constructor is actually\n\t\t\t// inferred as Error? Disabling this check for now, seems like an anomaly.\n\t\t\t// attest<TypeError>(T.infer)\n\t\t\tattest(T(e)).equals(e)\n\t\t\tattest(T(new Error()).toString()).snap(\n\t\t\t\t\"must be an instance of TypeError (was Error)\"\n\t\t\t)\n\t\t})\n\t\tit(\"abstract\", () => {\n\t\t\tabstract class Base {\n\t\t\t\tabstract foo: string\n\t\t\t}\n\t\t\tclass Sub extends Base {\n\t\t\t\tfoo = \"\"\n\t\t\t}\n\t\t\tconst T = type([\"instanceof\", Base])\n\t\t\tattest<Base>(T.infer)\n\t\t\tconst sub = new Sub()\n\t\t\tattest(T(sub)).equals(sub)\n\t\t})\n\t\tit(\"multiple branches\", () => {\n\t\t\tconst T = type([\"instanceof\", Date, Array])\n\t\t\tattest<Date | unknown[]>(T.infer)\n\t\t})\n\t\tit(\"non-constructor\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type([\"instanceof\", () => {}])).type.errors(\n\t\t\t\t\"Type '() => void' is not assignable to type\"\n\t\t\t)\n\t\t})\n\n\t\t// If perf cost too high can use global type config to expand ArkEnv.preserve\n\t\tit(\"user-defined class\", () => {\n\t\t\tclass ArkClass {\n\t\t\t\tisArk = true\n\t\t\t}\n\t\t\tconst Ark = type([\"instanceof\", ArkClass])\n\t\t\tattest<ArkClass>(Ark.t)\n\t\t\t// not expanded since there are no morphs\n\t\t\tattest(Ark.infer).type.toString(\"ArkClass\")\n\t\t\tattest(Ark.in.infer).type.toString(\"ArkClass\")\n\t\t\tconst a = new ArkClass()\n\t\t\tattest(Ark(a)).equals(a)\n\t\t\tattest(Ark({}).toString()).snap(\n\t\t\t\t\"must be an instance of ArkClass (was object)\"\n\t\t\t)\n\t\t})\n\t\tit(\"bidirectional checks doesn't break pipe inference\", () => {\n\t\t\tconst T = type({\n\t\t\t\tf: [\"string\", \"=>\", () => [] as unknown]\n\t\t\t})\n\t\t\t// Should be inferred as {f: unknown}\n\t\t\tattest<{ f: unknown }>(T.infer)\n\t\t})\n\n\t\tit(\"class with private properties\", () => {\n\t\t\tclass ArkClass {\n\t\t\t\tprivate isArk = true\n\t\t\t}\n\t\t\tconst Ark = type([\"instanceof\", ArkClass])\n\n\t\t\tattest<ArkClass>(Ark.t)\n\t\t\t// not expanded since there are no morphs\n\t\t\tattest(Ark.infer).type.toString(\"ArkClass\")\n\t\t\tattest(Ark.in.infer).type.toString(\"ArkClass\")\n\t\t})\n\n\t\tit(\"parse error on non-function\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type.instanceOf({}))\n\t\t\t\t.throws(Proto.writeInvalidSchemaMessage({}))\n\t\t\t\t.type.errors(\n\t\t\t\t\t\"not assignable to parameter of type 'Constructor<object>'\"\n\t\t\t\t)\n\t\t})\n\t})\n\n\tdescribe(\"root expression\", () => {\n\t\tit(\"class\", () => {\n\t\t\tconst T = type(\"instanceof\", Error)\n\t\t\tattest<Error>(T.infer)\n\t\t\tattest(T.json).equals(type([\"instanceof\", Error]).json)\n\t\t})\n\t\tit(\"instance branches\", () => {\n\t\t\tconst T = type(\"instanceof\", Date, Map)\n\t\t\tattest<Date | Map<unknown, unknown>>(T.infer)\n\t\t\tattest(T.json).equals(type(\"Date | Map\").json)\n\t\t})\n\t\tit(\"non-constructor\", () => {\n\t\t\t// @ts-expect-error just an assignability failure so we can't validate an error message\n\t\t\tattest(() => type(\"instanceof\", new Error())).throws(\n\t\t\t\twriteInvalidConstructorMessage(\"Error\")\n\t\t\t)\n\t\t})\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/integration/allConfig.ts",
    "content": "import { configure } from \"arktype/config\"\n\nconfigure({\n\tkeywords: {\n\t\tbigint: {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\tboolean: {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\tfalse: {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\tnever: {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\tnull: {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\tsymbol: {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\ttrue: {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\tundefined: {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\tDate: {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\tError: {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\tFunction: {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\tMap: {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\tPromise: {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\tRegExp: {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\tSet: {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\tWeakMap: {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\tWeakSet: {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\tArrayBuffer: {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\tBlob: {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\tFile: {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\tHeaders: {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\tRequest: {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\tResponse: {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\tURL: {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\tKey: {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"number.integer\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"number.epoch\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"number.safe\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"number.NaN\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"number.Infinity\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"number.NegativeInfinity\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"object.json.stringify\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.alpha\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.alphanumeric\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.hex\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.base64.url\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.capitalize.preformatted\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.creditCard\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.date.parse\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.date.iso.parse\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.date.epoch.parse\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.digits\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.email\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.integer.parse\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.ip.v4\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.ip.v6\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.json.parse\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.lower.preformatted\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.normalize.NFC.preformatted\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.normalize.NFD.preformatted\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.normalize.NFKC.preformatted\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.normalize.NFKD.preformatted\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.numeric.parse\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.regex\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.semver\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.trim.preformatted\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.upper.preformatted\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.url.parse\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.uuid.v1\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.uuid.v2\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.uuid.v3\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.uuid.v4\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.uuid.v5\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.uuid.v6\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.uuid.v7\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"string.uuid.v8\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"unknown.any\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"Array.readonly\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"Array.index\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"FormData.value\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"FormData.parsed\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"FormData.parse\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"TypedArray.Int8\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"TypedArray.Uint8\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"TypedArray.Uint8Clamped\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"TypedArray.Int16\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"TypedArray.Uint16\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"TypedArray.Int32\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"TypedArray.Uint32\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"TypedArray.Float32\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"TypedArray.Float64\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"TypedArray.BigInt64\": {\n\t\t\tdescription: \"configured\"\n\t\t},\n\t\t\"TypedArray.BigUint64\": {\n\t\t\tdescription: \"configured\"\n\t\t}\n\t}\n})\n"
  },
  {
    "path": "ark/type/__tests__/integration/eoptConfig.ts",
    "content": "import { configure } from \"arktype/config\"\n\nexport const config = configure({\n\texactOptionalPropertyTypes: false\n})\n"
  },
  {
    "path": "ark/type/__tests__/integration/generateAllConfig.ts",
    "content": "import { fromHere, writeFile } from \"@ark/fs\"\nimport { hasArkKind } from \"@ark/schema\"\nimport { flatMorph } from \"@ark/util\"\nimport { ark } from \"arktype\"\nimport type { ArkConfig } from \"arktype/config\"\n\nconst config: ArkConfig = {\n\tkeywords: flatMorph(ark.internal.resolutions, (qualifiedName, resolution) => {\n\t\tif (!resolution || typeof resolution === \"string\") return []\n\t\tif (hasArkKind(resolution, \"generic\")) return []\n\t\tif (qualifiedName.endsWith(\".root\")) return []\n\t\treturn [qualifiedName, { description: \"configured\" }]\n\t})\n}\n\nwriteFile(\n\tfromHere(\"allConfig.ts\"),\n\t`import { configure } from \"arktype/config\"\n\nconfigure(${JSON.stringify(config, null, 4)})\n`\n)\n"
  },
  {
    "path": "ark/type/__tests__/integration/onFailConfig.ts",
    "content": "import { configure } from \"arktype/config\"\n\nexport const config = configure({\n\tonFail: errors => errors.throw()\n})\n"
  },
  {
    "path": "ark/type/__tests__/integration/simpleConfig.ts",
    "content": "import { configure } from \"arktype/config\"\n\nexport const config = configure({\n\tnumberAllowsNaN: true,\n\tkeywords: {\n\t\tnull: {\n\t\t\tdescription: \"configured null\"\n\t\t},\n\t\tstring: {\n\t\t\tdescription: \"a configured string\"\n\t\t},\n\t\t\"string.numeric\": {\n\t\t\tdescription: \"a configured numeric string\"\n\t\t},\n\t\t\"string.trim.preformatted\": {\n\t\t\tdescription: \"a configured trimmed string\"\n\t\t}\n\t},\n\tonUndeclaredKey: \"delete\"\n})\n"
  },
  {
    "path": "ark/type/__tests__/integration/testAllConfig.ts",
    "content": "import \"./allConfig.ts\"\n\nimport { hasArkKind } from \"@ark/schema\"\nimport { flatMorph } from \"@ark/util\"\nimport { ark } from \"arktype\"\nimport { AssertionError } from \"node:assert\"\nimport { cases } from \"./util.ts\"\n\ncases({\n\tallResolutionsHaveMatchingQualifiedName: () => {\n\t\tconst mismatches = flatMorph(\n\t\t\tark.internal.resolutions,\n\t\t\t(qualifiedName, resolution, i: number) => {\n\t\t\t\tif (!resolution || typeof resolution === \"string\") return []\n\t\t\t\tif (hasArkKind(resolution, \"generic\")) return []\n\t\t\t\tif (qualifiedName.endsWith(\".root\")) return []\n\t\t\t\tif (resolution.description !== \"configured\") return [i, qualifiedName]\n\t\t\t\treturn []\n\t\t\t}\n\t\t)\n\n\t\tif (mismatches.length) {\n\t\t\tthrow new AssertionError({\n\t\t\t\tmessage: `The following resolutions had mismatching qualifiedNames:\\n${mismatches.join(\"\\n\")}`\n\t\t\t})\n\t\t}\n\t}\n})\n"
  },
  {
    "path": "ark/type/__tests__/integration/testEoptConfig.ts",
    "content": "import \"./eoptConfig.ts\"\n\nimport { type } from \"arktype\"\nimport { equal } from \"node:assert/strict\"\nimport { cases } from \"./util.ts\"\n\ncases({\n\tfromDef: () => {\n\t\tconst O = type({\n\t\t\t\"name?\": \"string\"\n\t\t})\n\n\t\tequal(O.expression, \"{ name?: string | undefined }\")\n\t},\n\tfromRef: () => {\n\t\tconst O = type({\n\t\t\t\"name?\": type.string\n\t\t})\n\n\t\tequal(O.expression, \"{ name?: string | undefined }\")\n\t}\n})\n"
  },
  {
    "path": "ark/type/__tests__/integration/testOnFailConfig.ts",
    "content": "import \"./onFailConfig.ts\"\n\nimport { type } from \"arktype\"\nimport { throws } from \"node:assert/strict\"\nimport { cases } from \"./util.ts\"\n\ncases({\n\tthrowsOnFail: () => {\n\t\tthrows(() => {\n\t\t\ttype.string(5)\n\t\t}, \"must be a string (was number)\")\n\t}\n})\n"
  },
  {
    "path": "ark/type/__tests__/integration/testSimpleConfig.ts",
    "content": "import { config } from \"./simpleConfig.ts\"\n\nimport { type } from \"arktype\"\nimport { deepStrictEqual, strictEqual } from \"node:assert/strict\"\nimport { cases } from \"./util.ts\"\n\ncases({\n\tNaN: () => {\n\t\tstrictEqual(type(\"number\").allows(Number.NaN), true)\n\t},\n\tonUndeclaredKey: () => {\n\t\tconst O = type({ a: \"number\" })\n\t\tconst out = O.assert({ a: 1, b: 2 })\n\t\tdeepStrictEqual(out, { a: 1 })\n\t},\n\tshallowLeafKeyword: () => {\n\t\tconst expected = config.keywords.null.description\n\t\tstrictEqual(type.null.description, expected)\n\t\tstrictEqual(\n\t\t\ttype.null(undefined)?.toString(),\n\t\t\t`must be ${expected} (was undefined)`\n\t\t)\n\t},\n\tshallowModuleKeyword: () => {\n\t\tconst expected = config.keywords.string.description\n\t\tstrictEqual(type.string.description, expected)\n\t\tstrictEqual(type.string(5).toString(), `must be ${expected} (was a number)`)\n\t},\n\tdeepModuleKeyword: () => {\n\t\tconst numeric = type.keywords.string.numeric.root\n\t\tconst expected = config.keywords[\"string.numeric\"].description\n\t\tstrictEqual(numeric.description, expected)\n\t\tstrictEqual(numeric(\"abc\").toString(), `must be ${expected} (was \"abc\")`)\n\t},\n\tdeepLeafKeyword: () => {\n\t\tconst pretrimmed = type.keywords.string.trim.preformatted\n\t\tconst expected = config.keywords[\"string.trim.preformatted\"].description\n\t\tstrictEqual(pretrimmed.description, expected)\n\t\tstrictEqual(pretrimmed(\" \").toString(), `must be ${expected} (was \" \")`)\n\t}\n})\n"
  },
  {
    "path": "ark/type/__tests__/integration/util.ts",
    "content": "import { keysOf } from \"@ark/util\"\nimport { stdout } from \"node:process\"\n\nexport const cases = (cases: Record<string, () => unknown>) => {\n\tlet failed = 0\n\n\tfor (const name of keysOf(cases)) {\n\t\tstdout.write(name)\n\t\ttry {\n\t\t\tcases[name]()\n\t\t\tstdout.write(\"✅\\n\")\n\t\t} catch (e) {\n\t\t\tstdout.write(\"❌\\n\")\n\t\t\tconsole.group()\n\t\t\tconsole.error(String(e))\n\t\t\tconsole.groupEnd()\n\t\t\tfailed = 1\n\t\t}\n\t}\n\n\tif (failed) process.exit(failed)\n}\n"
  },
  {
    "path": "ark/type/__tests__/intersection.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport {\n\tintrinsic,\n\twriteIndivisibleMessage,\n\twriteUnresolvableMessage,\n\twriteUnsatisfiableExpressionError\n} from \"@ark/schema\"\nimport { type } from \"arktype\"\nimport { writeMissingRightOperandMessage } from \"arktype/internal/parser/shift/operand/unenclosed.ts\"\n\ncontextualize(() => {\n\tit(\"two types\", () => {\n\t\tconst T = type(\"boolean&true\")\n\t\tattest<true>(T.infer)\n\t\tattest(T.json).is(type(\"true\").json)\n\t})\n\n\tit(\"intersection parsed before union\", () => {\n\t\t// Should be parsed as:\n\t\t// 1. \"0\" | (\"1\"&\"string\") | \"2\"\n\t\t// 2. \"0\" | \"1\" | \"2\"\n\t\tconst T = type(\"'0'|'1'&string|'2'\")\n\t\tattest<\"0\" | \"1\" | \"2\">(T.infer)\n\t\tattest(T.json).equals(type(\"===\", \"0\", \"1\", \"2\").json)\n\t})\n\n\tit(\"tuple expression\", () => {\n\t\tconst T = type([{ a: \"string\" }, \"&\", { b: \"number\" }])\n\t\tattest<{ a: string; b: number }>(T.infer)\n\t\tattest(T.json).equals(type({ a: \"string\", b: \"number\" }).json)\n\t})\n\n\tit(\"several types\", () => {\n\t\tconst T = type(\"unknown&boolean&false\")\n\t\tattest<false>(T.infer)\n\t\tattest(T.json).equals(type(\"false\").json)\n\t})\n\n\tit(\"method\", () => {\n\t\tconst T = type({ a: \"string\" }).and({ b: \"boolean\" })\n\t\tattest<{ a: string; b: boolean }>(T.infer)\n\t\tattest(T.json).equals(type({ a: \"string\", b: \"boolean\" }).json)\n\t})\n\n\tit(\"chained deep intersections\", () => {\n\t\tconst B = type({ b: \"boolean\" }, \"=>\", o => [o.b])\n\t\tconst T = type({\n\t\t\ta: [\"string\", \"=>\", s => s.length]\n\t\t})\n\t\t\t.and({\n\t\t\t\t// unable to inline this due to:\n\t\t\t\t// https://github.com/arktypeio/arktype/issues/806\n\t\t\t\tb: B\n\t\t\t})\n\t\t\t.and({\n\t\t\t\tb: { b: \"true\" },\n\t\t\t\tc: \"'hello'\"\n\t\t\t})\n\t\tattest<{\n\t\t\ta: string\n\t\t\tb: {\n\t\t\t\tb: true\n\t\t\t}\n\t\t\tc: \"hello\"\n\t\t}>(T.in.infer)\n\n\t\tattest<{ a: number; b: boolean[]; c: \"hello\" }>(T.infer)\n\t})\n\n\tit(\"bad reference\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"boolean&tru\"))\n\t\t\t.throws(writeUnresolvableMessage(\"tru\"))\n\t\t\t.type.errors(\"boolean&true\")\n\t})\n\n\tit(\"double and\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"boolean&&true\")).throws(\n\t\t\twriteMissingRightOperandMessage(\"&\", \"&true\")\n\t\t)\n\t})\n\n\tit(\"implicit never\", () => {\n\t\tattest(() => type(\"string&number\")).throws.snap(\n\t\t\t\"ParseError: Intersection of string and number results in an unsatisfiable type\"\n\t\t)\n\t})\n\n\tit(\"intersection with never\", () => {\n\t\tattest(() => type(\"string&never\")).throws(\n\t\t\twriteUnsatisfiableExpressionError(\"Intersection of string and never\")\n\t\t)\n\t})\n\n\tit(\"left semantic error\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"string%2&'foo'\")).throwsAndHasTypeError(\n\t\t\twriteIndivisibleMessage(intrinsic.string)\n\t\t)\n\t})\n\n\tit(\"right semantic error\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"'foo'&string%2\")).throwsAndHasTypeError(\n\t\t\twriteIndivisibleMessage(intrinsic.string)\n\t\t)\n\t})\n\n\tit(\"chained validation error\", () => {\n\t\tattest(() =>\n\t\t\t// @ts-expect-error\n\t\t\ttype({ a: \"string\" }).and({ b: \"what\" })\n\t\t).throwsAndHasTypeError(writeUnresolvableMessage(\"what\"))\n\t})\n\n\tit(\"error at path\", () => {\n\t\tattest(() => type({ a: \"string\" }).and({ a: \"number\" })).throws.snap(\n\t\t\t\"ParseError: Intersection at a of string and number results in an unsatisfiable type\"\n\t\t)\n\t})\n\n\tit(\"never subtype comparisons\", () => {\n\t\tconst MyType = type({\n\t\t\tsomething: \"string\"\n\t\t})\n\n\t\tattest(type.never.extends(MyType)).equals(true)\n\n\t\tattest(MyType.internal.subsumes(type.never)).equals(true)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/keyof.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport {\n\twriteNonStructuralOperandMessage,\n\twriteUnresolvableMessage,\n\twriteUnsatisfiableExpressionError\n} from \"@ark/schema\"\nimport { scope, type } from \"arktype\"\nimport { writeMissingRightOperandMessage } from \"arktype/internal/parser/shift/operand/unenclosed.ts\"\n\ncontextualize(() => {\n\tit(\"autocompletion\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"k\")).completions({ k: [\"keyof\"] })\n\t})\n\n\tit(\"root expression\", () => {\n\t\tconst T = type(\"keyof\", { foo: \"string\" })\n\t\tattest<\"foo\">(T.t)\n\t\tconst Expected = type(\"===\", \"foo\")\n\t\tattest(T.expression).equals(Expected.expression)\n\t})\n\n\tit(\"object literal\", () => {\n\t\tconst T = type({ a: \"123\", b: \"123\" }).keyof()\n\t\tattest<\"a\" | \"b\">(T.infer)\n\t\tattest(T.json).equals(type(\"'a'|'b'\").json)\n\t})\n\n\tit(\"overlapping union\", () => {\n\t\tconst T = type({ a: \"number\", b: \"boolean\" })\n\t\t\t.or({ b: \"number\", c: \"string\" })\n\t\t\t.keyof()\n\t\tattest<\"b\">(T.infer)\n\t\tattest(T.json).equals(type(\"'b'\").json)\n\t})\n\n\tit(\"non-overlapping union\", () => {\n\t\tattest(() => type({ a: \"number\" }).or({ b: \"number\" }).keyof()).throws(\n\t\t\twriteUnsatisfiableExpressionError(`keyof { a: number } | { b: number }`)\n\t\t)\n\t})\n\n\tit(\"tuple expression\", () => {\n\t\tconst T = type([\"keyof\", { a: \"string\" }])\n\t\tattest<\"a\">(T.infer)\n\t\tattest(T.json).equals(type(\"'a'\").json)\n\t})\n\n\tit(\"keyof non-object in union\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type({ a: \"number\" }).or(\"bigint\").keyof())\n\t\t\t.throws(writeNonStructuralOperandMessage(\"keyof\", \"bigint\"))\n\t\t\t.type.errors(\"Property 'keyof' does not exist\")\n\t})\n\n\tit(\"non-object\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"keyof undefined\")).throwsAndHasTypeError(\n\t\t\twriteNonStructuralOperandMessage(\"keyof\", \"undefined\")\n\t\t)\n\t})\n\n\tit(\"missing operand\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"keyof \"))\n\t\t\t.throws(writeMissingRightOperandMessage(\"keyof\", \"\"))\n\t\t\t// it tries to autocomplete, so this is just a possible completion that would be included\n\t\t\t.type.errors(\"keyof bigint\")\n\t})\n\n\tit(\"invalid operand\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"keyof nope\")).throwsAndHasTypeError(\n\t\t\twriteUnresolvableMessage(\"nope\")\n\t\t)\n\t})\n})\n\ncontextualize.each(\n\t\"scoped\",\n\t() =>\n\t\tscope({\n\t\t\tab: {\n\t\t\t\ta: \"1\",\n\t\t\t\t\"b?\": \"1\"\n\t\t\t},\n\t\t\tbc: {\n\t\t\t\tb: \"1\",\n\t\t\t\t\"c?\": \"1\"\n\t\t\t}\n\t\t}),\n\tit => {\n\t\tit(\"multiple keyofs\", $ => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => $.type(\"keyof keyof ab\")).throwsAndHasTypeError(\n\t\t\t\t\"keyof operand must be an object\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"groupable\", $ => {\n\t\t\tconst T = $.type(\"(keyof ab & string)[]\")\n\t\t\tattest<(\"a\" | \"b\")[]>(T.t)\n\t\t\tattest(T.json).equals(type(\"===\", \"a\", \"b\").array().json)\n\t\t})\n\n\t\tit(\"intersection precedence\", $ => {\n\t\t\tconst T = $.type(\"keyof bc & string\")\n\t\t\tattest<\"b\" | \"c\">(T.t)\n\t\t\tattest(T.json).equals(type(\"===\", \"b\", \"c\").json)\n\t\t})\n\n\t\tit(\"union precedence\", $ => {\n\t\t\tconst T = $.type(\"keyof ab | bc\")\n\t\t\tattest<\"a\" | \"b\" | { b: 1; c?: 1 }>(T.t)\n\t\t\tattest(T.expression).snap('{ b: 1, c?: 1 } | \"a\" | \"b\"')\n\t\t})\n\t}\n)\n"
  },
  {
    "path": "ark/type/__tests__/keywords/date.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"string.date\", () => {\n\t\tconst DateString = type(\"string.date\")\n\t\tattest(DateString(\"2023-01-01\")).equals(\"2023-01-01\")\n\t\tattest(DateString(\"foo\").toString()).snap(\n\t\t\t'must be a parsable date (was \"foo\")'\n\t\t)\n\t\tattest(DateString(new Date()).toString()).snap(\n\t\t\t\"must be a string (was an object)\"\n\t\t)\n\t})\n\n\tit(\"string.date.parse\", () => {\n\t\tconst parseDate = type(\"string.date.parse\")\n\t\tattest(parseDate(\"5/21/1993\").toString()).snap(\n\t\t\t\"Fri May 21 1993 00:00:00 GMT-0400 (Eastern Daylight Time)\"\n\t\t)\n\t\tattest(parseDate(\"foo\").toString()).snap(\n\t\t\t'must be a parsable date (was \"foo\")'\n\t\t)\n\t\tattest(parseDate(5).toString()).snap(\"must be a string (was a number)\")\n\t})\n\n\tit(\"string.date.iso\", () => {\n\t\tconst IsoDate = type(\"string.date.iso\")\n\t\tconst d = new Date().toISOString()\n\t\tattest(IsoDate(d)).equals(d)\n\t\tattest(IsoDate(\"05-21-1993\").toString()).snap(\n\t\t\t'must be an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date (was \"05-21-1993\")'\n\t\t)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/keywords/exclude.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { scope, type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"parsed\", () => {\n\t\tconst types = scope({\n\t\t\tfrom: \"0 | 1\",\n\t\t\tactual: \"Exclude<from, 1>\",\n\t\t\texpected: \"0\"\n\t\t}).export()\n\n\t\tattest<typeof types.expected.t>(types.actual.t)\n\t\tattest(types.actual.expression).equals(types.expected.expression)\n\t})\n\n\tit(\"chained\", () => {\n\t\tconst Excluded = type(\"true | 0 | 'foo'\").exclude(\"string\")\n\n\t\tconst Expected = type(\"true | 0\")\n\n\t\tattest<typeof Expected.t>(Excluded.t)\n\n\t\tattest(Excluded.expression).equals(Expected.expression)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/keywords/extract.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { scope, type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"parsed\", () => {\n\t\tconst types = scope({\n\t\t\tfrom: \"0 | 1\",\n\t\t\tactual: \"Extract<from, 1>\",\n\t\t\texpected: \"1\"\n\t\t}).export()\n\n\t\tattest<typeof types.expected.t>(types.actual.t)\n\t\tattest(types.actual.expression).equals(types.expected.expression)\n\t})\n\n\tit(\"chained\", () => {\n\t\tconst Extracted = type(\"true | 0 | 'foo'\").extract(\"boolean | number\")\n\n\t\tconst Expected = type(\"true | 0\")\n\n\t\tattest<typeof Expected.t>(Extracted.t)\n\n\t\tattest(Extracted.expression).equals(Expected.expression)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/keywords/formData.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { registry } from \"@ark/util\"\nimport { type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"formData\", () => {\n\t\tconst User = type({\n\t\t\temail: \"string.email\",\n\t\t\tfile: \"File\",\n\t\t\ttags: \"Array.liftFrom<string>\"\n\t\t})\n\n\t\tconst parseUserForm = type(\"FormData.parse\").pipe(User)\n\n\t\tattest(parseUserForm).type.toString.snap(`Type<\n\t(\n\t\tIn: FormData\n\t) => To<{\n\t\temail: string\n\t\tfile: File\n\t\ttags: (In: string | string[]) => To<string[]>\n\t}>,\n\t{}\n>`)\n\n\t\tconst data = new FormData()\n\n\t\t// Node18 doesn't have a File constructor\n\t\tif (process.version.startsWith(\"v18\")) return\n\n\t\tconst file = new registry.FileConstructor([], \"\")\n\n\t\tdata.append(\"email\", \"david@arktype.io\")\n\t\tdata.append(\"file\", file)\n\t\tdata.append(\"tags\", \"typescript\")\n\t\tdata.append(\"tags\", \"arktype\")\n\n\t\tconst out = parseUserForm(data)\n\t\tattest(out).equals({\n\t\t\temail: \"david@arktype.io\",\n\t\t\tfile,\n\t\t\ttags: [\"typescript\", \"arktype\"]\n\t\t})\n\n\t\tdata.set(\"email\", \"david\")\n\t\tdata.set(\"file\", null)\n\t\tdata.append(\"tags\", file)\n\n\t\tattest(parseUserForm(data).toString())\n\t\t\t.snap(`email must be an email address (was \"david\")\nfile must be a File instance (was string)\ntags[2] must be a string (was an object)`)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/keywords/format.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"trim\", () => {\n\t\tconst trim = type(\"string.trim\")\n\t\tattest(trim(\"  foo  \")).equals(\"foo\")\n\t\tattest(trim(5).toString()).snap(\"must be a string (was a number)\")\n\t})\n\n\tit(\"lower\", () => {\n\t\tconst lower = type(\"string.lower\")\n\t\tattest(lower(\"FOO\")).equals(\"foo\")\n\t\tattest(lower(5).toString()).snap(\"must be a string (was a number)\")\n\t})\n\n\tit(\"lower.preformatted\", () => {\n\t\tconst Lower = type(\"string.lower.preformatted\")\n\t\tattest(Lower(\"var\")).snap(\"var\")\n\t\tattest(Lower(\"newVar\").toString()).snap(\n\t\t\t'must be only lowercase letters (was \"newVar\")'\n\t\t)\n\t})\n\n\tit(\"upper\", () => {\n\t\tconst upper = type(\"string.upper\")\n\t\tattest(upper(\"foo\")).equals(\"FOO\")\n\t\tattest(upper(5).toString()).snap(\"must be a string (was a number)\")\n\t})\n\n\tit(\"upper.preformatted\", () => {\n\t\tconst Upper = type(\"string.upper.preformatted\")\n\t\tattest(Upper(\"VAR\")).snap(\"VAR\")\n\t\tattest(Upper(\"CONST_VAR\").toString()).snap(\n\t\t\t'must be only uppercase letters (was \"CONST_VAR\")'\n\t\t)\n\t\tattest(Upper(\"myVar\").toString()).snap(\n\t\t\t'must be only uppercase letters (was \"myVar\")'\n\t\t)\n\t})\n\n\tit(\"capitalize\", () => {\n\t\tconst capitalize = type(\"string.capitalize\")\n\t\tattest(capitalize(\"foo\")).equals(\"Foo\")\n\t\tattest(capitalize(5).toString()).snap(\"must be a string (was a number)\")\n\t})\n\n\tit(\"capitalize.preformatted\", () => {\n\t\tconst Capitalized = type(\"string.capitalize.preformatted\")\n\t\tattest(Capitalized(\"Foo\")).equals(\"Foo\")\n\t\tattest(Capitalized(\"bar\").toString()).snap(\n\t\t\t'must be capitalized (was \"bar\")'\n\t\t)\n\t})\n\n\tit(\"normalize\", () => {\n\t\tconst normalize = type(\"string.normalize\")\n\t\tattest(normalize(\"\\u00F1\")).equals(\"ñ\")\n\t\tattest(normalize(\"\\u006E\\u0303\")).equals(\"ñ\")\n\t\tattest(normalize(\"\\u00F1\")).equals(normalize(\"\\u006E\\u0303\"))\n\t\tattest(normalize(5).toString()).snap(\"must be a string (was a number)\")\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/keywords/ip.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { keywords, type } from \"arktype\"\n\nconst validIPv4 = \"192.168.1.1\"\nconst validIPv6 = \"2001:0db8:85a3:0000:0000:8a2e:0370:7334\"\n\ncontextualize(() => {\n\tit(\"root\", () => {\n\t\tconst Ip = type(\"string.ip\")\n\n\t\tattest(Ip(validIPv4)).equals(validIPv4)\n\n\t\tattest(Ip(validIPv6)).equals(validIPv6)\n\n\t\tattest(Ip(\"192.168.1.256\").toString()).snap(\n\t\t\t'must be an IP address (was \"192.168.1.256\")'\n\t\t)\n\t\tattest(Ip(\"2001:0db8:85a3:0000:0000:8a2e:0370:733g\").toString()).snap(\n\t\t\t'must be an IP address (was \"2001:0db8:85a3:0000:0000:8a2e:0370:733g\")'\n\t\t)\n\t})\n\n\tit(\"version subtype\", () => {\n\t\tconst Uuidv4 = type(\"string.ip.v4\")\n\n\t\tattest(Uuidv4(validIPv4)).equals(validIPv4)\n\t\tattest(Uuidv4(\"1234\").toString()).snap(\n\t\t\t'must be an IPv4 address (was \"1234\")'\n\t\t)\n\n\t\tattest(keywords.string.ip.v6(validIPv6)).equals(validIPv6)\n\n\t\tattest(Uuidv4(validIPv6).toString()).snap(\n\t\t\t'must be an IPv4 address (was \"2001:0db8:85a3:0000:0000:8a2e:0370:7334\")'\n\t\t)\n\n\t\tattest(keywords.string.ip.v6(validIPv4).toString()).snap(\n\t\t\t'must be an IPv6 address (was \"192.168.1.1\")'\n\t\t)\n\t})\n\n\tit(\"invalid ipv6 with empty segments\", () => {\n\t\tconst out = type.keywords.string.ip.v6(\"::%8:.-:.:\")\n\t\tattest(out.toString()).snap('must be an IPv6 address (was \"::%8:.-:.:\")')\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/keywords/json.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { type } from \"arktype\"\nimport { writeJsonSyntaxErrorProblem } from \"arktype/internal/keywords/string.ts\"\n\ncontextualize(() => {\n\tlet syntaxError: unknown\n\n\ttry {\n\t\tJSON.parse(\"{\")\n\t} catch (e) {\n\t\tsyntaxError = e\n\t}\n\n\t// this error varies between Node versions, so easiest to compare it this way\n\tconst expectedSyntaxErrorProblem = writeJsonSyntaxErrorProblem(syntaxError)\n\n\tit(\"string.json\", () => {\n\t\tconst parseJson = type(\"string.json\")\n\t\tattest(parseJson('{\"a\": \"hello\"}')).snap('{\"a\": \"hello\"}')\n\t\tattest(parseJson(123).toString()).snap(\"must be a string (was a number)\")\n\n\t\tattest(parseJson(\"{\").toString()).equals(expectedSyntaxErrorProblem)\n\t})\n\n\tit(\"string.json.parse\", () => {\n\t\tconst parseJson = type(\"string.json.parse\")\n\n\t\tattest(parseJson('{\"a\": \"hello\"}')).snap({ a: \"hello\" })\n\t\tattest(parseJson(123)?.toString()).snap(\"must be a string (was a number)\")\n\n\t\tattest(parseJson(\"{\")?.toString()).equals(expectedSyntaxErrorProblem)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/keywords/merge.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { writeNonStructuralOperandMessage } from \"@ark/schema\"\nimport { keywords, scope, type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"parsed\", () => {\n\t\tconst types = scope({\n\t\t\tbase: {\n\t\t\t\t\"foo?\": \"0\",\n\t\t\t\t\"bar?\": \"0\"\n\t\t\t},\n\t\t\tmerged: {\n\t\t\t\tbar: \"1\",\n\t\t\t\t\"baz?\": \"1\"\n\t\t\t},\n\t\t\tactual: \"Merge<base, merged>\",\n\t\t\texpected: {\n\t\t\t\t\"foo?\": \"0\",\n\t\t\t\tbar: \"1\",\n\t\t\t\t\"baz?\": \"1\"\n\t\t\t}\n\t\t}).export()\n\n\t\tattest<typeof types.expected.t>(types.actual.t)\n\t\tattest(types.actual.expression).equals(types.expected.expression)\n\t})\n\n\tit(\"invoked\", () => {\n\t\tconst s = Symbol()\n\t\tconst T = keywords.Merge(\n\t\t\t{\n\t\t\t\t\"[string]\": \"number | bigint\",\n\t\t\t\tfoo: \"0\",\n\t\t\t\t[s]: \"true\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"[string]\": \"bigint\",\n\t\t\t\t\"foo?\": \"1n\"\n\t\t\t}\n\t\t)\n\n\t\tconst Expected = type({\n\t\t\t\"[string]\": \"bigint\",\n\t\t\t\"foo?\": \"1n\",\n\t\t\t[s]: \"true\"\n\t\t})\n\n\t\tattest<typeof Expected.t>(T.t)\n\t\tattest(T.expression).equals(Expected.expression)\n\t})\n\n\tit(\"chained\", () => {\n\t\tconst T = type({\n\t\t\t\"[string]\": \"number\",\n\t\t\t\"bar?\": \"0\",\n\t\t\tfoo: \"0\"\n\t\t}).merge({\n\t\t\t\"foo?\": \"1\",\n\t\t\tbaz: \"1\"\n\t\t})\n\n\t\tconst Expected = type({\n\t\t\t\"[string]\": \"number\",\n\t\t\t\"bar?\": \"0\",\n\t\t\t\"foo?\": \"1\",\n\t\t\tbaz: \"1\"\n\t\t})\n\n\t\tattest<typeof Expected.t>(T.t)\n\t\tattest(T.expression).equals(Expected.expression)\n\t})\n\n\tit(\"non-object operand\", () => {\n\t\tattest(() =>\n\t\t\ttype({\n\t\t\t\tfoo: \"0\"\n\t\t\t\t// @ts-expect-error\n\t\t\t}).merge(\"string\")\n\t\t)\n\t\t\t.throws(writeNonStructuralOperandMessage(\"merge\", \"string\"))\n\t\t\t.type.errors(\n\t\t\t\t`ErrorType<[\"Merged type must be an object\", actual: string]>`\n\t\t\t)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/keywords/number.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"integer\", () => {\n\t\tconst Integer = type(\"number.integer\")\n\t\tattest(Integer(123)).equals(123)\n\t\tattest(Integer(\"123\").toString()).snap(\"must be a number (was a string)\")\n\t\tattest(Integer(12.12).toString()).snap(\"must be an integer (was 12.12)\")\n\t})\n\n\tit(\"epoch\", () => {\n\t\tconst Epoch = type(\"number.epoch\")\n\n\t\t// valid\n\t\tattest(Epoch(1621530000)).equals(1621530000)\n\t\tattest(Epoch(8640000000000000)).equals(8640000000000000)\n\t\tattest(Epoch(-8640000000000000)).equals(-8640000000000000)\n\n\t\t// invalid\n\t\tattest(Epoch(\"foo\").toString()).snap(\n\t\t\t\"must be a number representing a Unix timestamp (was a string)\"\n\t\t)\n\t\tattest(Epoch(1.5).toString()).snap(\n\t\t\t\"must be an integer representing a Unix timestamp (was 1.5)\"\n\t\t)\n\t\tattest(Epoch(-8640000000000001).toString()).snap(\n\t\t\t\"must be a Unix timestamp after -8640000000000000 (was -8640000000000001)\"\n\t\t)\n\t\tattest(Epoch(8640000000000001).toString()).snap(\n\t\t\t\"must be a Unix timestamp before 8640000000000000 (was 8640000000000001)\"\n\t\t)\n\t})\n\n\tit(\"safe\", () => {\n\t\tconst Safe = type(\"number.safe\")\n\n\t\tattest(Safe.allows(Number.MAX_SAFE_INTEGER)).equals(true)\n\t\tattest(Safe.allows(Number.MIN_SAFE_INTEGER)).equals(true)\n\t\tattest(Safe.allows(0)).equals(true)\n\t\tattest(Safe.allows(0.5)).equals(true)\n\t\tattest(Safe(Number.MAX_SAFE_INTEGER + 1).toString()).snap(\n\t\t\t\"must be at most 9007199254740991 (was 9007199254740992)\"\n\t\t)\n\t\tattest(Safe(Number.MIN_SAFE_INTEGER - 1).toString()).snap(\n\t\t\t\"must be at least -9007199254740991 (was -9007199254740992)\"\n\t\t)\n\t\tattest(Safe(Infinity).toString()).snap(\n\t\t\t\"must be at most 9007199254740991 (was Infinity)\"\n\t\t)\n\t\tattest(Safe(-Infinity).toString()).snap(\n\t\t\t\"must be at least -9007199254740991 (was -Infinity)\"\n\t\t)\n\t\tattest(Safe(NaN).toString()).snap(\"must be a number (was NaN)\")\n\t})\n\n\tit(\"doesn't allow NaN by default\", () => {\n\t\tattest(type.number.allows(Number.NaN)).equals(false)\n\t\tattest(type.number(Number.NaN).toString()).snap(\n\t\t\t\"must be a number (was NaN)\"\n\t\t)\n\t})\n\n\tit(\"NaN\", () => {\n\t\tconst Nan = type(\"number.NaN\")\n\n\t\tattest(Nan.allows(Number.NaN)).equals(true)\n\t\tattest(Nan(0).toString()).snap(\"must be NaN (was 0)\")\n\t})\n\n\tit(\"PositiveInfinity\", () => {\n\t\tconst Inf = type(\"number.Infinity\")\n\t\tattest(Inf.allows(Number.POSITIVE_INFINITY)).equals(true)\n\t\tattest(Inf(0).toString()).snap(\"must be Infinity (was 0)\")\n\t\tattest(Inf(Number.NEGATIVE_INFINITY).toString()).snap(\n\t\t\t\"must be Infinity (was -Infinity)\"\n\t\t)\n\t})\n\n\tit(\"NegativeInfinity\", () => {\n\t\tconst NegInf = type(\"number.NegativeInfinity\")\n\t\tattest(NegInf.allows(Number.NEGATIVE_INFINITY)).equals(true)\n\t\tattest(NegInf(0).toString()).snap(\"must be -Infinity (was 0)\")\n\t\tattest(NegInf(Number.POSITIVE_INFINITY).toString()).snap(\n\t\t\t\"must be -Infinity (was Infinity)\"\n\t\t)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/keywords/numericStrings.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"string.numeric\", () => {\n\t\tconst NumericString = type(\"string.numeric\")\n\t\tattest(NumericString(\"5\")).equals(\"5\")\n\t\tattest(NumericString(\"5.5\")).equals(\"5.5\")\n\t\tattest(NumericString(\"five\").toString()).snap(\n\t\t\t'must be a well-formed numeric string (was \"five\")'\n\t\t)\n\t})\n\n\tit(\"string.numeric.parse\", () => {\n\t\tconst parseNum = type(\"string.numeric.parse\")\n\t\tattest(parseNum(\"5\")).equals(5)\n\t\tattest(parseNum(\"5.5\")).equals(5.5)\n\t\tattest(parseNum(\"five\").toString()).snap(\n\t\t\t'must be a well-formed numeric string (was \"five\")'\n\t\t)\n\t})\n\n\tit(\"string.integer\", () => {\n\t\tconst IntegerString = type(\"string.integer\")\n\t\tattest(IntegerString(\"5\")).equals(\"5\")\n\t\tattest(IntegerString(\"5.5\").toString()).snap(\n\t\t\t'must be a well-formed integer string (was \"5.5\")'\n\t\t)\n\t\tattest(IntegerString(\"five\").toString()).snap(\n\t\t\t'must be a well-formed integer string (was \"five\")'\n\t\t)\n\t\tattest(IntegerString(5).toString()).snap(\"must be a string (was a number)\")\n\t\t// unsafe integers are allowed within strings as long as they are not parsed\n\t\tattest(IntegerString(\"9007199254740992\")).equals(\"9007199254740992\")\n\t})\n\n\tit(\"string.integer.parse\", () => {\n\t\tconst parseInt = type(\"string.integer.parse\")\n\t\tattest(parseInt(\"5\")).equals(5)\n\t\tattest(parseInt(\"5.5\").toString()).snap(\n\t\t\t'must be a well-formed integer string (was \"5.5\")'\n\t\t)\n\t\tattest(parseInt(\"five\").toString()).snap(\n\t\t\t'must be a well-formed integer string (was \"five\")'\n\t\t)\n\t\tattest(parseInt(5).toString()).snap(\"must be a string (was a number)\")\n\t\tattest(parseInt(\"9007199254740992\").toString()).snap(\n\t\t\t'must be an integer in the range Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER (was \"9007199254740992\")'\n\t\t)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/keywords/object.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport type { Json } from \"@ark/util\"\nimport { keywords, type } from \"arktype\"\nimport type { To } from \"arktype/internal/attributes.ts\"\n\ncontextualize(() => {\n\tit(\"Function\", () => {\n\t\t// should not be treated as a morph\n\t\tattest<Function>(type(\"Function\").infer)\n\t})\n\n\tit(\"Date\", () => {\n\t\t// should not expand built-in classes\n\t\tattest(type(\"Date\").infer).type.toString.snap(\"Date\")\n\t})\n\n\tdescribe(\"json\", () => {\n\t\tit(\"root\", () => {\n\t\t\tconst Json = type(\"object.json\")\n\n\t\t\tattest<Json>(Json.t)\n\t\t\tattest<Json>(Json.infer)\n\t\t\tattest<Json>(Json.inferIn)\n\n\t\t\tattest(Json({})).equals({})\n\t\t\tattest(Json([])).equals([])\n\t\t\tattest(Json(5)?.toString()).snap(\"must be an object (was a number)\")\n\t\t\tattest(Json({ foo: [5n] })?.toString()).snap(\n\t\t\t\t'foo[\"0\"] must be an object (was a bigint)'\n\t\t\t)\n\t\t})\n\n\t\tit(\"stringify\", () => {\n\t\t\tconst stringify = type(\"object.json.stringify\")\n\n\t\t\tconst out = stringify.assert({ foo: \"bar\" })\n\n\t\t\tattest<string>(out).snap('{\"foo\":\"bar\"}')\n\n\t\t\t// this error kind of sucks, should have more discriminant context\n\t\t\tattest(stringify({ foo: undefined }).toString()).snap(\n\t\t\t\t\"foo must be an object (was undefined)\"\n\t\t\t)\n\n\t\t\t// has declared out\n\t\t\tattest<string>(stringify.out.t)\n\t\t\tattest(stringify.out.expression).snap(\"string\")\n\t\t})\n\t})\n\n\tdescribe(\"liftArray\", () => {\n\t\tit(\"parsed\", () => {\n\t\t\tconst liftNumberArray = type(\"Array.liftFrom<number>\")\n\n\t\t\tattest<(In: number | number[]) => To<number[]>>(liftNumberArray.t)\n\n\t\t\tattest(liftNumberArray(5)).equals([5])\n\t\t\tattest(liftNumberArray([5])).equals([5])\n\t\t\tattest(liftNumberArray(\"five\").toString()).snap(\n\t\t\t\t\"must be a number or an object (was a string)\"\n\t\t\t)\n\t\t\tattest(liftNumberArray([\"five\"]).toString()).snap(\n\t\t\t\t\"value at [0] must be a number (was a string)\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"invoked\", () => {\n\t\t\tconst T = keywords.Array.liftFrom({ data: \"number\" })\n\n\t\t\tattest(T.t).type.toString.snap(`(\n\tIn: { data: number } | { data: number }[]\n) => To<{ data: number }[]>`)\n\t\t\tattest(T.expression).snap(\n\t\t\t\t\"(In: { data: number } | { data: number }[]) => Out<{ data: number }[]>\"\n\t\t\t)\n\t\t})\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/keywords/omit.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { scope, type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"parsed\", () => {\n\t\tconst types = scope({\n\t\t\tfrom: {\n\t\t\t\tfoo: \"1\",\n\t\t\t\t\"bar?\": \"1\",\n\t\t\t\tbaz: \"1\",\n\t\t\t\t\"quux?\": \"1\"\n\t\t\t},\n\t\t\tactual: \"Omit<from, 'foo' | 'bar'>\",\n\t\t\texpected: {\n\t\t\t\tbaz: \"1\",\n\t\t\t\t\"quux?\": \"1\"\n\t\t\t}\n\t\t}).export()\n\n\t\tattest<typeof types.expected.t>(types.actual.t)\n\t\tattest(types.actual.expression).equals(types.expected.expression)\n\t})\n\n\tit(\"chained\", () => {\n\t\tconst User = type({\n\t\t\tname: \"string\",\n\t\t\t\"age?\": \"number\",\n\t\t\tisAdmin: \"boolean\",\n\t\t\t\"isActive?\": \"boolean\"\n\t\t})\n\n\t\tconst extras = User.omit(\"name\", \"age\")\n\n\t\tconst Expected = type({\n\t\t\tisAdmin: \"boolean\",\n\t\t\t\"isActive?\": \"boolean\"\n\t\t})\n\n\t\tattest<typeof Expected.t>(extras.t)\n\n\t\tattest(extras.expression).equals(Expected.expression)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/keywords/parse.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"number\", () => {\n\t\tconst parseNum = type(\"string.numeric.parse\")\n\t\tattest(parseNum(\"5\")).equals(5)\n\t\tattest(parseNum(\".5\")).equals(0.5)\n\t\tattest(parseNum(\"5.5\")).equals(5.5)\n\t\tattest(parseNum(\"five\").toString()).snap(\n\t\t\t'must be a well-formed numeric string (was \"five\")'\n\t\t)\n\t})\n\n\tit(\"integer\", () => {\n\t\tconst parseInt = type(\"string.integer.parse\")\n\t\tattest(parseInt(\"5\")).equals(5)\n\t\tattest(parseInt(\"5.5\").toString()).snap(\n\t\t\t'must be a well-formed integer string (was \"5.5\")'\n\t\t)\n\t\tattest(parseInt(\"five\").toString()).snap(\n\t\t\t'must be a well-formed integer string (was \"five\")'\n\t\t)\n\t\tattest(parseInt(5).toString()).snap(\"must be a string (was a number)\")\n\t\tattest(parseInt(\"9007199254740992\").toString()).snap(\n\t\t\t'must be an integer in the range Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER (was \"9007199254740992\")'\n\t\t)\n\t})\n\n\tit(\"date\", () => {\n\t\tconst parseDate = type(\"string.date.parse\")\n\t\tattest(parseDate(\"5/21/1993\").toString()).snap(\n\t\t\t\"Fri May 21 1993 00:00:00 GMT-0400 (Eastern Daylight Time)\"\n\t\t)\n\t\tattest(parseDate(\"foo\").toString()).snap(\n\t\t\t'must be a parsable date (was \"foo\")'\n\t\t)\n\t\tattest(parseDate(5).toString()).snap(\"must be a string (was a number)\")\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/keywords/partial.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { scope, type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"parsed\", () => {\n\t\tconst types = scope({\n\t\t\tuser: {\n\t\t\t\tname: \"string\",\n\t\t\t\t\"age?\": \"number\"\n\t\t\t},\n\t\t\tactual: \"Partial<user>\",\n\t\t\texpected: {\n\t\t\t\t\"name?\": \"string\",\n\t\t\t\t\"age?\": \"number\"\n\t\t\t}\n\t\t}).export()\n\n\t\tattest<typeof types.expected.t>(types.actual.t)\n\t\tattest(types.actual.expression).equals(types.expected.expression)\n\t})\n\n\tit(\"chained\", () => {\n\t\tconst T = type({\n\t\t\t\"[string]\": \"number\",\n\t\t\tfoo: \"1\",\n\t\t\t\"bar?\": \"1\"\n\t\t}).partial()\n\n\t\tattest<{\n\t\t\t// really this should just be number for the index signature, seems like a TS bug?\n\t\t\t[x: string]: number | undefined\n\t\t\tfoo?: 1\n\t\t\tbar?: 1\n\t\t}>(T.t)\n\n\t\tattest(T.expression).snap(\"{ [string]: number, bar?: 1, foo?: 1 }\")\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/keywords/pick.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport {\n\twriteInvalidKeysMessage,\n\twriteNonStructuralOperandMessage\n} from \"@ark/schema\"\nimport { scope, type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"parsed\", () => {\n\t\tconst types = scope({\n\t\t\tfrom: {\n\t\t\t\tfoo: \"1\",\n\t\t\t\t\"bar?\": \"1\",\n\t\t\t\tbaz: \"1\",\n\t\t\t\t\"quux?\": \"1\"\n\t\t\t},\n\t\t\tactual: \"Pick<from, 'foo' | 'bar'>\",\n\t\t\texpected: {\n\t\t\t\tfoo: \"1\",\n\t\t\t\t\"bar?\": \"1\"\n\t\t\t}\n\t\t}).export()\n\n\t\tattest<typeof types.expected.t>(types.actual.t)\n\t\tattest(types.actual.expression).equals(types.expected.expression)\n\t})\n\n\tit(\"chained\", () => {\n\t\tconst User = type({\n\t\t\tname: \"string\",\n\t\t\t\"age?\": \"number\",\n\t\t\tisAdmin: \"boolean\"\n\t\t})\n\n\t\tconst BasicUser = User.pick(\"name\", \"age\")\n\n\t\tconst Expected = type({\n\t\t\tname: \"string\",\n\t\t\t\"age?\": \"number\"\n\t\t})\n\n\t\tattest<typeof Expected.t>(BasicUser.t)\n\n\t\tattest(BasicUser.expression).equals(Expected.expression)\n\t})\n\n\tit(\"invalid key\", () => {\n\t\tconst User = type({\n\t\t\tname: \"string\"\n\t\t})\n\n\t\t// @ts-expect-error\n\t\tattest(() => User.pick(\"length\"))\n\t\t\t.throws(writeInvalidKeysMessage(User.expression, [\"length\"]))\n\t\t\t.type.errors.snap(\n\t\t\t\t'Argument of type \\'\"length\"\\' is not assignable to parameter of type \\'\"name\" | cast<\"name\">\\'.'\n\t\t\t)\n\t})\n\n\tit(\"non-structure\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"string\").pick(\"length\"))\n\t\t\t.throws(writeNonStructuralOperandMessage(\"pick\", \"string\"))\n\t\t\t.type.errors(\"Property 'pick' does not exist\")\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/keywords/record.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport {\n\tintrinsic,\n\twriteIndivisibleMessage,\n\twriteUnsatisfiedParameterConstraintMessage\n} from \"@ark/schema\"\nimport { keywords, type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"parsed\", () => {\n\t\tconst Expected = type({ \"[string]\": \"number\" })\n\n\t\tconst Expression = type(\"Record<string, number>\")\n\t\tattest(Expression.json).equals(Expected.json)\n\t\tattest<typeof Expected.t>(Expression.t)\n\t})\n\n\tit(\"invoked\", () => {\n\t\tconst Expected = type({ \"[string]\": \"number\" })\n\n\t\tconst T = keywords.Record(\"string\", \"number\")\n\n\t\tattest(T.json).equals(Expected.json)\n\t\tattest<typeof Expected.t>(T.t)\n\t})\n\n\tit(\"invoked validation error\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => keywords.Record(\"string\", \"string % 2\")).throwsAndHasTypeError(\n\t\t\twriteIndivisibleMessage(intrinsic.string)\n\t\t)\n\t})\n\n\tit(\"invoked constraint error\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => keywords.Record(\"boolean\", \"number\"))\n\t\t\t.throws(\n\t\t\t\twriteUnsatisfiedParameterConstraintMessage(\n\t\t\t\t\t\"K\",\n\t\t\t\t\t\"string | symbol\",\n\t\t\t\t\t\"boolean\"\n\t\t\t\t)\n\t\t\t)\n\t\t\t.type.errors(`ErrorType<[\"Invalid argument for K\", expected: Key]>`)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/keywords/required.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { scope, type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"parsed\", () => {\n\t\tconst types = scope({\n\t\t\tuser: {\n\t\t\t\tname: \"string\",\n\t\t\t\t\"age?\": \"number\"\n\t\t\t},\n\t\t\tactual: \"Required<user>\",\n\t\t\texpected: {\n\t\t\t\tname: \"string\",\n\t\t\t\tage: \"number\"\n\t\t\t}\n\t\t}).export()\n\n\t\tattest<typeof types.expected.t>(types.actual.t)\n\t\tattest(types.actual.expression).equals(types.expected.expression)\n\t})\n\n\tit(\"chained\", () => {\n\t\tconst T = type({\n\t\t\t\"[string]\": \"number\",\n\t\t\tfoo: \"1\",\n\t\t\t\"bar?\": \"1\"\n\t\t}).required()\n\n\t\tattest<{\n\t\t\t[x: string]: number\n\t\t\tfoo: 1\n\t\t\tbar: 1\n\t\t}>(T.t)\n\n\t\tattest(T.expression).snap(\"{ [string]: number, bar: 1, foo: 1 }\")\n\t})\n\n\t// https://github.com/arktypeio/arktype/issues/1156\n\tit(\"with default\", () => {\n\t\tconst T = type({ foo: \"string = 'bar'\" }).required()\n\n\t\tconst Expected = type({\n\t\t\tfoo: \"string\"\n\t\t})\n\n\t\t// https://github.com/arktypeio/arktype/issues/1160\n\t\t// attest<typeof Expected.t, typeof T.t>();\n\n\t\tattest(T.expression).equals(Expected.expression)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/keywords/string.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { keywords, type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"alpha\", () => {\n\t\tconst Alpha = type(\"string.alpha\")\n\t\tattest(Alpha(\"user\")).snap(\"user\")\n\t\tattest(Alpha(\"user123\").toString()).snap(\n\t\t\t'must be only letters (was \"user123\")'\n\t\t)\n\t})\n\n\tit(\"alphanumeric\", () => {\n\t\tconst Alphanumeric = type(\"string.alphanumeric\")\n\t\tattest(Alphanumeric(\"user123\")).snap(\"user123\")\n\t\tattest(Alphanumeric(\"user\")).snap(\"user\")\n\t\tattest(Alphanumeric(\"123\")).snap(\"123\")\n\t\tattest(Alphanumeric(\"abc@123\").toString()).equals(\n\t\t\t'must be only letters and digits 0-9 (was \"abc@123\")'\n\t\t)\n\t})\n\n\tit(\"hex\", () => {\n\t\tconst Hex = type(\"string.hex\")\n\t\tattest(Hex(\"1fA3\").toString()).equals(\"1fA3\")\n\t\tattest(Hex(\"0x1A3\").toString()).equals(\n\t\t\t'must be hex characters only (was \"0x1A3\")'\n\t\t)\n\t\tattest(Hex(\"V29.yZA\").toString()).equals(\n\t\t\t'must be hex characters only (was \"V29.yZA\")'\n\t\t)\n\t\tattest(Hex(\"fn5-\").toString()).equals(\n\t\t\t'must be hex characters only (was \"fn5-\")'\n\t\t)\n\t})\n\n\tit(\"base64\", () => {\n\t\tconst B64 = type(\"string.base64\")\n\t\tattest(B64(\"fn5+\")).snap(\"fn5+\")\n\t\tattest(B64(\"V29yZA==\")).snap(\"V29yZA==\")\n\t\tattest(B64(\"V29yZA\").toString()).equals(\n\t\t\t'must be base64-encoded (was \"V29yZA\")'\n\t\t)\n\t\tattest(B64(\"V29.yZA\").toString()).equals(\n\t\t\t'must be base64-encoded (was \"V29.yZA\")'\n\t\t)\n\t\tattest(B64(\"fn5-\").toString()).equals('must be base64-encoded (was \"fn5-\")')\n\n\t\tconst B64url = type(\"string.base64.url\")\n\t\tattest(B64url(\"fn5-\")).snap(\"fn5-\")\n\t\tattest(B64url(\"V29yZA\")).snap(\"V29yZA\")\n\t\tattest(B64url(\"V29yZA==\")).snap(\"V29yZA==\")\n\t\tattest(B64url(\"V29yZA%3D%3D\")).snap(\"V29yZA%3D%3D\")\n\t\tattest(B64url(\"V29.yZA\").toString()).equals(\n\t\t\t'must be base64url-encoded (was \"V29.yZA\")'\n\t\t)\n\t\tattest(B64url(\"fn5+\").toString()).equals(\n\t\t\t'must be base64url-encoded (was \"fn5+\")'\n\t\t)\n\t})\n\n\tit(\"digits\", () => {\n\t\tconst Digits = type(\"string.digits\")\n\t\tattest(Digits(\"123\")).snap(\"123\")\n\t\tattest(Digits(\"user123\").toString()).equals(\n\t\t\t'must be only digits 0-9 (was \"user123\")'\n\t\t)\n\t})\n\n\tit(\"email\", () => {\n\t\tconst Email = type(\"string.email\")\n\t\tattest(Email(\"shawn@mail.com\")).snap(\"shawn@mail.com\")\n\t\tattest(Email(\"shawn@email\").toString()).equals(\n\t\t\t'must be an email address (was \"shawn@email\")'\n\t\t)\n\t})\n\n\tit(\"credit card\", () => {\n\t\tconst validCC = \"5489582921773376\"\n\t\tattest(keywords.string.creditCard(validCC)).equals(validCC)\n\t\t// Regex validation\n\t\tattest(keywords.string.creditCard(\"0\".repeat(16)).toString()).snap(\n\t\t\t'must be a credit card number (was \"0000000000000000\")'\n\t\t)\n\t\t// Luhn validation\n\t\tattest(\n\t\t\tkeywords.string.creditCard(validCC.slice(0, -1) + \"0\").toString()\n\t\t).snap('must be a credit card number (was \"5489582921773370\")')\n\t})\n\n\tit(\"semver\", () => {\n\t\tattest(keywords.string.semver(\"1.0.0\")).snap(\"1.0.0\")\n\t\tattest(keywords.string.semver(\"-1.0.0\").toString()).snap(\n\t\t\t'must be a semantic version (see https://semver.org/) (was \"-1.0.0\")'\n\t\t)\n\t})\n\n\tdescribe(\"ip\", () => {\n\t\tconst validIPv4 = \"192.168.1.1\"\n\t\tconst validIPv6 = \"2001:0db8:85a3:0000:0000:8a2e:0370:7334\"\n\n\t\tit(\"root\", () => {\n\t\t\tconst Ip = type(\"string.ip\")\n\n\t\t\tattest(Ip(validIPv4)).equals(validIPv4)\n\n\t\t\tattest(Ip(validIPv6)).equals(validIPv6)\n\n\t\t\tattest(Ip(\"192.168.1.256\").toString()).snap(\n\t\t\t\t'must be an IP address (was \"192.168.1.256\")'\n\t\t\t)\n\t\t\tattest(Ip(\"2001:0db8:85a3:0000:0000:8a2e:0370:733g\").toString()).snap(\n\t\t\t\t'must be an IP address (was \"2001:0db8:85a3:0000:0000:8a2e:0370:733g\")'\n\t\t\t)\n\t\t})\n\n\t\tit(\"version subtype\", () => {\n\t\t\tconst Uuidv4 = type(\"string.ip.v4\")\n\n\t\t\tattest(Uuidv4(validIPv4)).equals(validIPv4)\n\t\t\tattest(Uuidv4(\"1234\").toString()).snap(\n\t\t\t\t'must be an IPv4 address (was \"1234\")'\n\t\t\t)\n\n\t\t\tattest(keywords.string.ip.v6(validIPv6)).equals(validIPv6)\n\n\t\t\tattest(Uuidv4(validIPv6).toString()).snap(\n\t\t\t\t'must be an IPv4 address (was \"2001:0db8:85a3:0000:0000:8a2e:0370:7334\")'\n\t\t\t)\n\n\t\t\tattest(keywords.string.ip.v6(validIPv4).toString()).snap(\n\t\t\t\t'must be an IPv6 address (was \"192.168.1.1\")'\n\t\t\t)\n\t\t})\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/keywords/tsPrimitives.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { intrinsic, rootSchema } from \"@ark/schema\"\nimport { type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"string strings\", () => {\n\t\t/**\n\t\t * \tIn honor of @ark-expect-beta aka log(n):\n\t\t * \t\t- Zirco author https://github.com/zirco-lang/zrc\n\t\t * \t\t- Shameless Rust stan\n\t\t * \t\t- Occasional user of ArkType libraries\n\t\t * \t\t- Frequent user of ArkType Discord\n\t\t * \t\t- Universally renowned two-finger speed typist\n\t\t */\n\t\tconst String = type(\"string\")\n\t\tattest<string>(String.infer)\n\t\tattest(String(\"string\")).snap(\"string\")\n\t})\n\n\tit(\"any\", () => {\n\t\tconst Any = type(\"unknown.any\")\n\t\t// equivalent to unknown at runtime\n\t\tattest(Any.json).equals(type.unknown.json)\n\t\t// inferred as any\n\t\tattest<any>(Any.infer)\n\t})\n\n\tit(\"any in expression\", () => {\n\t\tconst T = type(\"string\", \"&\", \"unknown.any\")\n\t\tattest<any>(T.infer)\n\t\tattest(T.json).equals(intrinsic.string.json)\n\t})\n\n\tit(\"boolean\", () => {\n\t\tconst Boolean = type(\"boolean\")\n\t\tattest<boolean>(Boolean.infer)\n\t\tconst Expected = rootSchema([{ unit: false }, { unit: true }])\n\t\t// should be simplified to simple checks for true and false literals\n\t\tattest(Boolean.json).equals(Expected.json)\n\t})\n\n\tit(\"never\", () => {\n\t\tconst Never = type(\"never\")\n\t\tattest<never>(Never.infer)\n\t\tconst Expected = rootSchema([])\n\t\t// should be equivalent to a zero-branch union\n\t\tattest(Never.json).equals(Expected.json)\n\t})\n\n\tit(\"never in union\", () => {\n\t\tconst T = type(\"string|never\")\n\t\tattest<string>(T.infer)\n\t\tattest(T.json).equals(intrinsic.string.json)\n\t})\n\n\tit(\"unknown\", () => {\n\t\tconst Expected = rootSchema({})\n\t\t// should be equivalent to an unconstrained predicate\n\t\tattest(type(\"unknown\").json).equals(Expected.json)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/keywords/url.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"root\", () => {\n\t\tconst Url = type(\"string.url\")\n\n\t\tattest(Url).type.toString.snap(\"Type<string, {}>\")\n\n\t\tattest(Url(\"https://arktype.io\")).snap(\"https://arktype.io\")\n\t\tattest(Url(\"arktype\").toString()).snap(\n\t\t\t'must be a URL string (was \"arktype\")'\n\t\t)\n\t})\n\n\tit(\"parse\", () => {\n\t\tconst parseUrl = type(\"string.url.parse\")\n\n\t\tattest(parseUrl).type.toString.snap(\"Type<(In: string) => To<URL>, {}>\")\n\t\tattest(parseUrl(\"https://arktype.io\")).instanceOf(URL)\n\t\tattest(parseUrl(\"arktype\").toString()).snap(\n\t\t\t'must be a URL string (was \"arktype\")'\n\t\t)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/keywords/uuid.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { keywords, type } from \"arktype\"\n\nconst validUuidV4 = \"f70b8242-dd57-4e6b-b0b7-649d997140a0\"\n\nconst validUuidV5 = \"f70b8242-dd57-5e6b-b0b7-649d997140a0\"\n\ncontextualize(() => {\n\tit(\"root\", () => {\n\t\tconst Uuid = type(\"string.uuid\")\n\t\tattest(Uuid(validUuidV4)).equals(validUuidV4)\n\t\tattest(Uuid(\"1234\").toString()).snap('must be a UUID (was \"1234\")')\n\t})\n\n\tit(\"version subtype\", () => {\n\t\tconst Uuidv4 = type(\"string.uuid.v4\")\n\n\t\tattest(Uuidv4(validUuidV4)).equals(validUuidV4)\n\t\tattest(Uuidv4(\"1234\").toString()).snap('must be a UUIDv4 (was \"1234\")')\n\n\t\tattest(keywords.string.uuid.v5(validUuidV5)).equals(validUuidV5)\n\n\t\tattest(Uuidv4(validUuidV5).toString()).equals(\n\t\t\t'must be a UUIDv4 (was \"f70b8242-dd57-5e6b-b0b7-649d997140a0\")'\n\t\t)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/literal.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { registeredReference } from \"@ark/schema\"\nimport { printable } from \"@ark/util\"\nimport { type } from \"arktype\"\n\ncontextualize(() => {\n\tdescribe(\"tuple expression\", () => {\n\t\tit(\"literal\", () => {\n\t\t\tconst T = type([\"===\", 5])\n\t\t\tattest<5>(T.infer)\n\t\t\tattest(T.json).equals(type(\"5\").json)\n\t\t})\n\n\t\tit(\"symbol with description\", () => {\n\t\t\t// if another symbol with the description \"ism\" is used in a test,\n\t\t\t// the snapshotted errors below could break, but I want to test the\n\t\t\t// actual display format.\n\t\t\t// if you're here for that reason, choose another symbol name :P\n\t\t\tconst ism = Symbol(\"ism\")\n\t\t\tconst T = type([\"===\", ism])\n\t\t\tattest(T(ism)).equals(ism)\n\n\t\t\t// same with ick- don't use it\n\t\t\tconst ick = Symbol(\"ick\")\n\n\t\t\tattest(T(ick).toString()).snap(\"must be Symbol(ism) (was Symbol(ick))\")\n\t\t})\n\n\t\tit(\"anonymous symbol\", () => {\n\t\t\tconst anon = Symbol()\n\t\t\t// An anonymous symbol will definitely have a suffix so we need to\n\t\t\t// get the name ahead of time\n\t\t\tconst anonName = printable(anon)\n\t\t\tconst T = type([\"===\", anon])\n\t\t\tattest<typeof anon>(T.infer)\n\t\t\tattest(T(anon)).equals(anon)\n\t\t\tattest(T(\"test\").toString()).equals(`must be ${anonName} (was \"test\")`)\n\t\t})\n\n\t\tit(\"branches\", () => {\n\t\t\tconst o = { ark: true }\n\t\t\tconst oReference = registeredReference(o)\n\t\t\tconst s = Symbol()\n\t\t\tconst sReference = registeredReference(s)\n\t\t\tconst T = type([\"===\", true, \"foo\", 5, 1n, null, undefined, o, s])\n\t\t\tattest<\n\t\t\t\ttrue | \"foo\" | 5 | 1n | null | undefined | { ark: boolean } | typeof s\n\t\t\t>(T.infer)\n\t\t\tattest(T.json).equals([\n\t\t\t\t{ unit: oReference },\n\t\t\t\t{ unit: sReference },\n\t\t\t\t{ unit: \"1n\" },\n\t\t\t\t{ unit: \"foo\" },\n\t\t\t\t{ unit: \"undefined\" },\n\t\t\t\t{ unit: 5 },\n\t\t\t\t{ unit: null },\n\t\t\t\t{ unit: true }\n\t\t\t])\n\t\t})\n\t})\n\n\tdescribe(\"root expression\", () => {\n\t\tit(\"single\", () => {\n\t\t\tconst T = type(\"===\", true)\n\t\t\tattest<true>(T.infer)\n\t\t\tattest(T.json).equals(type(\"true\").json)\n\t\t})\n\n\t\tit(\"branches\", () => {\n\t\t\tconst o = { ark: true }\n\t\t\tconst oReference = registeredReference(o)\n\t\t\tconst s = Symbol()\n\t\t\tconst sReference = registeredReference(s)\n\t\t\tconst T = type(\"===\", \"foo\", 5, true, null, 1n, undefined, o, s)\n\t\t\tattest<\n\t\t\t\ttrue | \"foo\" | 5 | 1n | null | undefined | { ark: boolean } | typeof s\n\t\t\t>(T.infer)\n\t\t\tattest(T.json).equals([\n\t\t\t\t{ unit: oReference },\n\t\t\t\t{ unit: sReference },\n\t\t\t\t{ unit: \"1n\" },\n\t\t\t\t{ unit: \"foo\" },\n\t\t\t\t{ unit: \"undefined\" },\n\t\t\t\t{ unit: 5 },\n\t\t\t\t{ unit: null },\n\t\t\t\t{ unit: true }\n\t\t\t])\n\t\t})\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/match.bench.ts",
    "content": "import { bench } from \"@ark/attest\"\nimport { match, type } from \"arktype\"\n\nbench.baseline(() => {\n\ttype(\"never\")\n\tmatch.case(\"never\", () => {}).default(\"assert\")\n\tmatch({\n\t\tnever: () => {},\n\t\tdefault: \"assert\"\n\t})\n})\n\nbench(\"case(3, define)\", () =>\n\tmatch\n\t\t.case(\"-1\", n => `${n}` as const)\n\t\t.case(\"-2\", n => `${n}` as const)\n\t\t.case(\"-3\", n => `${n}` as const)\n\t\t.default(\"assert\")\n).types([2141, \"instantiations\"])\n\nbench(\"case(10, define)\", () =>\n\tmatch\n\t\t.case(\"0\", n => `${n}` as const)\n\t\t.case(\"1\", n => `${n}` as const)\n\t\t.case(\"2\", n => `${n}` as const)\n\t\t.case(\"3\", n => `${n}` as const)\n\t\t.case(\"4\", n => `${n}` as const)\n\t\t.case(\"5\", n => `${n}` as const)\n\t\t.case(\"6\", n => `${n}` as const)\n\t\t.case(\"7\", n => `${n}` as const)\n\t\t.case(\"8\", n => `${n}` as const)\n\t\t.case(\"9\", n => `${n}` as const)\n\t\t.default(\"assert\")\n).types([7814, \"instantiations\"])\n\nbench(\"match.in<t> cases define and invoke\", () => {\n\tconst matcher = match\n\t\t.in<string | number | boolean>()\n\t\t.case(\"string\", s => s)\n\t\t.case(\"number\", n => n)\n\t\t.case(\"boolean\", b => b)\n\t\t.default(\"assert\")\n\n\tconst zero = matcher(\"abc\")\n\tconst one = matcher(4)\n\tconst two = matcher(true)\n\treturn [zero, one, two]\n}).types([2953, \"instantiations\"])\n\nbench(\"record(3, define)\", () =>\n\tmatch({\n\t\t\"20\": n => `${n}` as const,\n\t\t\"21\": n => `${n}` as const,\n\t\t\"22\": n => `${n}` as const,\n\t\tdefault: \"assert\"\n\t})\n).types([2524, \"instantiations\"])\n\nbench(\"record(10, define)\", () =>\n\tmatch({\n\t\t\"-10n\": n => `${n}` as const,\n\t\t\"-1n\": n => `${n}` as const,\n\t\t\"-2n\": n => `${n}` as const,\n\t\t\"-3n\": n => `${n}` as const,\n\t\t\"-4n\": n => `${n}` as const,\n\t\t\"-5n\": n => `${n}` as const,\n\t\t\"-6n\": n => `${n}` as const,\n\t\t\"-7n\": n => `${n}` as const,\n\t\t\"-8n\": n => `${n}` as const,\n\t\t\"-9n\": n => `${n}` as const,\n\t\tdefault: \"assert\"\n\t})\n).types([7198, \"instantiations\"])\n\nbench(\"record.in<t> define and invoke\", () => {\n\tconst matcher = match.in<string | number | boolean>().match({\n\t\tsymbol: s => s,\n\t\tobject: n => n,\n\t\tboolean: b => b,\n\t\tdefault: \"assert\"\n\t})\n\n\tconst zero = matcher(\"abc\")\n\tconst one = matcher(4)\n\tconst two = matcher(true)\n\treturn [zero, one, two]\n}).types([3831, \"instantiations\"])\n\nconst invokedCases3 = match\n\t.case(\"31\", n => `${n}` as const)\n\t.case(\"32\", n => `${n}` as const)\n\t.case(\"33\", n => `${n}` as const)\n\t.default(\"assert\")\n\nbench(\"case(3, invoke)\", () => {\n\tinvokedCases3(31)\n\tinvokedCases3(32)\n\tinvokedCases3(33)\n}).types([539, \"instantiations\"])\n\nconst invokedCases10 = match\n\t.case(\"0n\", n => `${n}` as const)\n\t.case(\"1n\", n => `${n}` as const)\n\t.case(\"2n\", n => `${n}` as const)\n\t.case(\"3n\", n => `${n}` as const)\n\t.case(\"4n\", n => `${n}` as const)\n\t.case(\"5n\", n => `${n}` as const)\n\t.case(\"6n\", n => `${n}` as const)\n\t.case(\"7n\", n => `${n}` as const)\n\t.case(\"8n\", n => `${n}` as const)\n\t.case(\"9n\", n => `${n}` as const)\n\t.default(\"assert\")\n\nbench(\"case(10, invoke first)\", () => {\n\tinvokedCases10(0n)\n\tinvokedCases10(1n)\n\tinvokedCases10(2n)\n}).types([1140, \"instantiations\"])\n\nbench(\"case(10, invoke last)\", () => {\n\tinvokedCases10(7n)\n\tinvokedCases10(8n)\n\tinvokedCases10(9n)\n}).types([1139, \"instantiations\"])\n"
  },
  {
    "path": "ark/type/__tests__/match.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport {\n\tregisteredReference,\n\twriteUnboundableMessage,\n\ttype ArkErrors\n} from \"@ark/schema\"\nimport { match, scope, type } from \"arktype\"\nimport type { Out } from \"arktype/internal/attributes.ts\"\nimport {\n\tdoubleAtMessage,\n\tthrowOnDefault,\n\ttype Match\n} from \"arktype/internal/match.ts\"\n\nconst throwDefaultRef = registeredReference(throwOnDefault)\n\ncontextualize(() => {\n\tit(\"single object\", () => {\n\t\tconst sizeOf = match({\n\t\t\t\"string|Array\": v => v.length,\n\t\t\tnumber: v => v,\n\t\t\tbigint: v => v,\n\t\t\tdefault: \"assert\"\n\t\t})\n\n\t\tattest<number>(sizeOf(\"abc\")).equals(3)\n\t\tattest<number>(sizeOf([1, 2, 3])).equals(3)\n\t\tattest<bigint>(sizeOf(5n)).equals(5n)\n\n\t\tconst getBad = () => sizeOf(true)\n\t\tattest<() => never>(getBad)\n\t\t// ideally would also include number | bigint, discriminated out\n\t\tattest(getBad).throws.snap(\n\t\t\t\"TraversalError: must be a string or an object (was boolean)\"\n\t\t)\n\t})\n\n\tit(\"completes case keys\", () => {\n\t\tattest(() =>\n\t\t\tmatch({\n\t\t\t\t// prettier-ignore\n\t\t\t\t// @ts-expect-error\n\t\t\t\t\"big\": () => true\n\t\t\t})\n\t\t).completions({ big: [\"bigint\"] })\n\t})\n\n\tit(\"completes default key\", () => {\n\t\tattest(() =>\n\t\t\tmatch({\n\t\t\t\tbigint: () => true,\n\t\t\t\t// prettier-ignore\n\t\t\t\t// @ts-expect-error\n\t\t\t\t\"defaul\": () => false\n\t\t\t})\n\t\t).completions({ defaul: [\"default\"] })\n\t})\n\n\tit(\"completes shallow fluent defs\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => match.case(\"WeakS\")).completions({ WeakS: [\"WeakSet\"] })\n\t})\n\n\tit(\"completes object fluent defs\", () => {\n\t\tattest(() =>\n\t\t\tmatch.case(\n\t\t\t\t{\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tid: \"string | numb\"\n\t\t\t\t},\n\t\t\t\to => o.id\n\t\t\t)\n\t\t).completions({ \"string | numb\": [\"string | number\"] })\n\t})\n\n\tit(\"properly infers types of inputs/outputs based on chained\", () => {\n\t\tconst matcher = match({ string: s => s, number: n => n })\n\t\t\t.case(\"boolean\", b => b)\n\t\t\t.default(\"assert\")\n\n\t\t// properly infers the type of the output based on the input\n\t\tattest<string>(matcher(\"abc\")).equals(\"abc\")\n\t\tattest<number>(matcher(4)).equals(4)\n\t\tattest<boolean>(matcher(true)).equals(true)\n\n\t\t// and properly handles unions in the input type\n\t\tattest<string | number>(matcher(0 as string | number))\n\n\t\tconst getBad = () => matcher(null)\n\t\tattest<() => never>(getBad)\n\t\t// this sucks and should be improved- result of discrimination\n\t\tattest(getBad).throws.snap(\"TraversalError: must be boolean (was null)\")\n\t})\n\n\tit(\"multiple case blocks\", () => {\n\t\tconst m = match({\n\t\t\t\"1\": n => n,\n\t\t\t\"2\": n => n + 2\n\t\t}).match({\n\t\t\t\"3\": n => n + 3,\n\t\t\tdefault: \"assert\"\n\t\t})\n\n\t\tattest<1>(m(1)).equals(1)\n\t\tattest<number>(m(2)).equals(4)\n\t\tattest<number>(m(3)).equals(6)\n\t\tattest(m).type.toString.snap(`Match<\n\tunknown,\n\t[(In: 1) => 1, (In: 2) => number, (In: 3) => number]\n>`)\n\t})\n\n\tit(\"default value\", () => {\n\t\tconst m = match({\n\t\t\tstring: s => s.length,\n\t\t\tdefault: v => v\n\t\t})\n\n\t\tattest(m(\"foo\")).equals(3)\n\t\tattest(m(5)).equals(5)\n\n\t\tattest(m).type.toString.snap(`Match<\n\tunknown,\n\t[(In: string) => number, (v: unknown) => unknown]\n>`)\n\t})\n\n\tit(\"never\", () => {\n\t\tconst m = match({\n\t\t\tstring: s => s.length,\n\t\t\tdefault: \"never\"\n\t\t})\n\n\t\tattest(m(\"foo\")).equals(3)\n\n\t\tattest(m).type.toString.snap(\"Match<string, [(In: string) => number]>\")\n\t})\n\n\tit(\"within scope\", () => {\n\t\tconst threeSixtyNoScope = scope({ three: \"3\", sixty: \"60\", no: \"'no'\" })\n\n\t\tlet threeCount = 0\n\t\tlet sixtyCount = 0\n\n\t\tconst matcher = threeSixtyNoScope\n\t\t\t.match({\n\t\t\t\tthree: three => {\n\t\t\t\t\tthreeCount++\n\t\t\t\t\tattest<3>(three)\n\t\t\t\t\treturn 3\n\t\t\t\t}\n\t\t\t})\n\t\t\t.case(\"sixty\", sixty => {\n\t\t\t\tsixtyCount++\n\t\t\t\tattest<60>(sixty)\n\t\t\t\treturn 60\n\t\t\t})\n\t\t\t.default(\"assert\")\n\n\t\t// for assertions\n\t\tmatcher(3)\n\t\tmatcher(60)\n\n\t\tattest(threeCount).equals(1)\n\t\tattest(sixtyCount).equals(1)\n\t})\n\n\tit(\"properly propagates errors from invalid type definitions in `when`\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => match({}).case(\"strong\", s => s)).type.errors(\n\t\t\t\"'strong' is unresolvable\"\n\t\t)\n\t})\n\n\tit(\"properly propagates errors from invalid type definitions in `cases`\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => match({ strong: s => s })).type.errors(\n\t\t\t\"'strong' is unresolvable\"\n\t\t)\n\t})\n\n\tit(\"semantic error in case\", () => {\n\t\tattest(() =>\n\t\t\tmatch({\n\t\t\t\t// @ts-expect-error\n\t\t\t\t\"boolean < 5\": () => true\n\t\t\t})\n\t\t).throwsAndHasTypeError(writeUnboundableMessage(\"boolean\"))\n\t})\n\n\tit(\"does not accept invalid inputs at a type-level\", () => {\n\t\tconst matcher = match\n\t\t\t.in<string | number>()\n\t\t\t.case(\"string\", s => s)\n\t\t\t.case(\"number\", n => n)\n\t\t\t.default(\"never\")\n\n\t\t// @ts-expect-error\n\t\tattest(() => matcher(true))\n\t\t\t.throws.snap(\"TraversalError: must be a string or a number (was boolean)\")\n\t\t\t.type.errors(\n\t\t\t\t\"Argument of type 'boolean' is not assignable to parameter of type 'string | number'\"\n\t\t\t)\n\t})\n\n\tit(\"from exhaustive\", () => {\n\t\tconst matcher = match\n\t\t\t.in(\"string | number\")\n\t\t\t.match({\n\t\t\t\tstring: s => s,\n\t\t\t\tnumber: n => n\n\t\t\t})\n\t\t\t.default(\"assert\")\n\n\t\tattest(matcher).type.toString.snap(`Match<\n\tstring | number,\n\t[(In: string) => string, (In: number) => number]\n>`)\n\n\t\t// @ts-expect-error\n\t\tattest(() => matcher(true))\n\t\t\t.throws.snap(\"TraversalError: must be a number or a string (was boolean)\")\n\t\t\t.type.errors(\n\t\t\t\t\"Argument of type 'boolean' is not assignable to parameter of type 'string | number'\"\n\t\t\t)\n\t})\n\n\tit(\"argless `in` type error\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => match.in()).type.errors(\"Expected 1 arguments, but got 0\")\n\t})\n\n\tit(\"allows ordered overlapping\", () => {\n\t\tconst m = match({\n\t\t\t\"0 < number < 10\": function _matchOverlapping1(n) {\n\t\t\t\treturn [0, n]\n\t\t\t},\n\t\t\t// this will never be hit since it is a subtype of a previous case\n\t\t\t\"number > 0\": function _matchOverlapping2(n) {\n\t\t\t\treturn [1, n]\n\t\t\t},\n\t\t\tnumber: function _matchOverlapping3(n) {\n\t\t\t\treturn [2, n]\n\t\t\t},\n\t\t\tdefault: function _matchOverlapping4(v) {\n\t\t\t\treturn [3, v]\n\t\t\t}\n\t\t})\n\n\t\tattest(m.internal.json).snap({\n\t\t\tbranches: [\n\t\t\t\t{\n\t\t\t\t\tin: {\n\t\t\t\t\t\tdomain: \"number\",\n\t\t\t\t\t\tmax: { exclusive: true, rule: 10 },\n\t\t\t\t\t\tmin: { exclusive: true, rule: 0 }\n\t\t\t\t\t},\n\t\t\t\t\tmorphs: [\"$ark._matchOverlapping1\"]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tin: { domain: \"number\", min: { exclusive: true, rule: 0 } },\n\t\t\t\t\tmorphs: [\"$ark._matchOverlapping2\"]\n\t\t\t\t},\n\t\t\t\t{ in: \"number\", morphs: [\"$ark._matchOverlapping3\"] },\n\t\t\t\t{ in: {}, morphs: [\"$ark._matchOverlapping4\"] }\n\t\t\t],\n\t\t\tordered: true\n\t\t})\n\n\t\tattest(m(5)).equals([0, 5])\n\t\tattest(m(11)).equals([1, 11])\n\t\tattest(m(0)).equals([2, 0])\n\t\tattest(m(undefined)).equals([3, undefined])\n\t})\n\n\tit(\"prunes subtype cases\", () => {\n\t\tconst m = match({\n\t\t\t\"0 < number < 10\": function _matchPreservedOne(n) {\n\t\t\t\treturn [0, n]\n\t\t\t},\n\t\t\t// this will never be hit since it is a subtype of a previous case\n\t\t\t\"4 < number < 6\": function _matchPrunedOne(n) {\n\t\t\t\treturn [1, n]\n\t\t\t},\n\t\t\tnumber: function _matchPreservedTwo(n) {\n\t\t\t\treturn [2, n]\n\t\t\t},\n\t\t\tdefault: function _matchPreservedDefault(v) {\n\t\t\t\treturn [3, v]\n\t\t\t}\n\t\t})\n\n\t\tattest(m.internal.json).snap({\n\t\t\tbranches: [\n\t\t\t\t{\n\t\t\t\t\tin: {\n\t\t\t\t\t\tdomain: \"number\",\n\t\t\t\t\t\tmax: { exclusive: true, rule: 10 },\n\t\t\t\t\t\tmin: { exclusive: true, rule: 0 }\n\t\t\t\t\t},\n\t\t\t\t\tmorphs: [\"$ark._matchPreservedOne\"]\n\t\t\t\t},\n\t\t\t\t{ in: \"number\", morphs: [\"$ark._matchPreservedTwo\"] },\n\t\t\t\t{ in: {}, morphs: [\"$ark._matchPreservedDefault\"] }\n\t\t\t],\n\t\t\tordered: true\n\t\t})\n\t})\n\n\tdescribe(\"at\", () => {\n\t\tit(\"unknown allows any key\", () => {\n\t\t\tconst m = match.at(\"n\").match({\n\t\t\t\t\"0\": o => `${o.n} = 0` as const,\n\t\t\t\t\"1\": o => `${o.n} = 1` as const,\n\t\t\t\tdefault: \"never\"\n\t\t\t})\n\n\t\t\tattest<\"0 = 0\">(m({ n: 0 })).equals(\"0 = 0\")\n\t\t\tattest<\"1 = 1\">(m({ n: 1 })).equals(\"1 = 1\")\n\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => m({}))\n\t\t\t\t// (was missing) would be better here, undefined is a result of discrimination\n\t\t\t\t.throws.snap(\"TraversalError: n must be 0 or 1 (was undefined)\")\n\t\t\t\t.type.errors.snap(\n\t\t\t\t\t\"Argument of type '{}' is not assignable to parameter of type '{ n: 0; } | { n: 1; }'.\"\n\t\t\t\t)\n\t\t})\n\n\t\tit(\"in\", () => {\n\t\t\tconst m = match\n\t\t\t\t.in<{ kind: string }>()\n\t\t\t\t.at(\"kind\")\n\t\t\t\t.case(\"'a'\", o => {\n\t\t\t\t\tattest<{\n\t\t\t\t\t\tkind: \"a\"\n\t\t\t\t\t}>(o).equals({ kind: \"a\" })\n\t\t\t\t\treturn [o.kind]\n\t\t\t\t})\n\t\t\t\t.default(o => o.kind)\n\n\t\t\tattest(m({ kind: \"a\" })).snap([\"a\"])\n\t\t\tattest(m({ kind: \"b\" })).snap(\"b\")\n\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => m({})).type.errors(\"Property 'kind' is missing\")\n\t\t})\n\n\t\tit(\"in completions\", () => {\n\t\t\tconst base = match.in<{ kind: string }>()\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => base.at(\"\")).completions({ \"\": [\"kind\"] })\n\t\t})\n\n\t\tit(\"keyless in\", () => {\n\t\t\tconst m = match\n\t\t\t\t.in<object>()\n\t\t\t\t.at(\"foo\")\n\t\t\t\t.match({\n\t\t\t\t\ttrue: t => t,\n\t\t\t\t\tdefault: \"assert\"\n\t\t\t\t})\n\n\t\t\tattest(m).type.toString.snap(`Match<\n\tobject,\n\t[(In: { foo: true }) => { foo: true }]\n>`)\n\t\t})\n\n\t\tit(\"at with cases param\", () => {\n\t\t\tconst m = match.at(\"foo\", {\n\t\t\t\tstring: function _atCasesParam1(o) {\n\t\t\t\t\treturn o.foo.length\n\t\t\t\t},\n\t\t\t\tnumber: function _atCasesParam2(o) {\n\t\t\t\t\treturn `${o.foo + 1}`\n\t\t\t\t},\n\t\t\t\tdefault: \"never\"\n\t\t\t})\n\n\t\t\tattest(m.internal.json).snap({\n\t\t\t\tbranches: [\n\t\t\t\t\t{\n\t\t\t\t\t\tin: {\n\t\t\t\t\t\t\trequired: [{ key: \"foo\", value: \"string\" }],\n\t\t\t\t\t\t\tdomain: \"object\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmorphs: [\"$ark._atCasesParam1\"]\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tin: {\n\t\t\t\t\t\t\trequired: [{ key: \"foo\", value: \"number\" }],\n\t\t\t\t\t\t\tdomain: \"object\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmorphs: [\"$ark._atCasesParam2\"]\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\tordered: true,\n\t\t\t\tmeta: { onFail: throwDefaultRef }\n\t\t\t})\n\t\t\tattest(m).type.toString.snap(`Match<\n\t{ foo: string } | { foo: number },\n\t[\n\t\t(In: { foo: string }) => number,\n\t\t(In: { foo: number }) => string\n\t]\n>`)\n\t\t})\n\n\t\tit(\"at after in\", () => {\n\t\t\tconst m = match\n\t\t\t\t.in<{ id: 0 | 1 | 2 }>()\n\t\t\t\t.at(\"id\")\n\t\t\t\t.match({\n\t\t\t\t\t\"0\": function _atAfterIn1(o) {\n\t\t\t\t\t\treturn o.id\n\t\t\t\t\t},\n\t\t\t\t\t// correctly inferred\n\t\t\t\t\tnumber: function _atAfterIn2(o) {\n\t\t\t\t\t\treturn o.id\n\t\t\t\t\t},\n\t\t\t\t\tdefault: \"never\"\n\t\t\t\t})\n\n\t\t\tattest(m.internal.json).snap({\n\t\t\t\tbranches: [\n\t\t\t\t\t{\n\t\t\t\t\t\tin: {\n\t\t\t\t\t\t\trequired: [{ key: \"id\", value: { unit: 0 } }],\n\t\t\t\t\t\t\tdomain: \"object\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmorphs: [\"$ark._atAfterIn1\"]\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tin: {\n\t\t\t\t\t\t\trequired: [{ key: \"id\", value: \"number\" }],\n\t\t\t\t\t\t\tdomain: \"object\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmorphs: [\"$ark._atAfterIn2\"]\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\tordered: true,\n\t\t\t\tmeta: { onFail: throwDefaultRef }\n\t\t\t})\n\t\t\tattest(m).type.toString.snap(`Match<\n\t{ id: 0 | 1 | 2 } | { id: 0 },\n\t[\n\t\t(In: { id: 0 | 1 | 2 }) => 0 | 1 | 2,\n\t\t(In: { id: 0 }) => 0\n\t]\n>`)\n\t\t})\n\n\t\tit(\"multiple ats\", () => {\n\t\t\tattest(() => {\n\t\t\t\tmatch\n\t\t\t\t\t.at(\"foo\", {\n\t\t\t\t\t\tstring: o => o.foo.length\n\t\t\t\t\t})\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t.at(\"bar\")\n\t\t\t}).throwsAndHasTypeError(doubleAtMessage)\n\t\t})\n\t})\n\n\tit(\"attached to type\", () => {\n\t\tattest<typeof match>(type.match).equals(match)\n\t})\n\n\tit(\"initial case\", () => {\n\t\tconst Initial = match.case(\"string\", Number.parseInt).default(\"assert\")\n\n\t\tconst Expected = match({\n\t\t\tstring: Number.parseInt,\n\t\t\tdefault: \"assert\"\n\t\t})\n\n\t\t// ensure structure is identical\n\t\tattest(Initial.internal.json).equals(Expected.internal.json)\n\t\t// ensure we are able to cache ordered unions like from matchers\n\t\tattest(Initial.internal.id).equals(Expected.internal.id)\n\t\t// ensure ids are doing what they're suppoed to\n\n\t\t// for some reason TS can't handle initial/expected comparison so we have to cast\n\t\tattest(Initial === (Expected as {})).equals(true)\n\n\t\t// like the uncasted version of the above equality check,\n\t\t// uncommenting this also causes an infinite depth issue\n\t\t// attest<typeof Expected>(initial)\n\n\t\tconst expectedTypeSnapshot = \"Match<unknown, [(In: string) => number]>\"\n\t\tattest(Initial).type.toString(expectedTypeSnapshot)\n\t\tattest(Initial).type.toString(expectedTypeSnapshot)\n\t})\n\n\tit(\"reference in object\", () => {\n\t\tconst m = match({\n\t\t\tstring: s => s.length,\n\t\t\tdefault: \"assert\"\n\t\t})\n\n\t\tconst T = type({\n\t\t\tfoo: m\n\t\t})\n\n\t\tattest<{\n\t\t\tfoo: (In: string) => Out<number>\n\t\t}>(T.t)\n\t\tattest(T.expression).snap(\"{ foo: (In: string) => Out<unknown> }\")\n\t\tattest(T({ foo: \"foo\" })).equals({ foo: 3 })\n\t\tattest(T({ foo: 5 }).toString()).snap(\"foo must be a string (was a number)\")\n\t})\n\n\tit(\"morph key\", () => {\n\t\tconst parseNum = match({\n\t\t\t\"string.numeric.parse\": function _matchMorphKey1(valid) {\n\t\t\t\treturn valid\n\t\t\t},\n\t\t\tdefault: function _matchMorphKey2() {\n\t\t\t\treturn null\n\t\t\t}\n\t\t})\n\n\t\tattest<number | null>(parseNum(\"12.34\")).equals(12.34)\n\t\tattest<null>(parseNum(12.34)).equals(null)\n\t})\n\n\tit(\"fluent morph\", () => {\n\t\tconst parseInt = match\n\t\t\t.case(\"string.integer.parse\", function _matchFluentMorph1(valid) {\n\t\t\t\treturn valid\n\t\t\t})\n\t\t\t.default(function _matchFluentMorph2() {\n\t\t\t\treturn null\n\t\t\t})\n\n\t\tattest<number | null>(parseInt(\"1234\")).equals(1234)\n\t\tattest<null>(parseInt(1234)).equals(null)\n\t})\n\n\tit(\"accounts for ordering during discrimination\", () => {\n\t\tconst m = match\n\t\t\t.case(\n\t\t\t\t{\n\t\t\t\t\tid: \"string\"\n\t\t\t\t},\n\t\t\t\tfunction _matchOrderedDiscrimination1(o) {\n\t\t\t\t\treturn o.id\n\t\t\t\t}\n\t\t\t)\n\t\t\t.case(\n\t\t\t\t{\n\t\t\t\t\tkind: \"'string'\"\n\t\t\t\t},\n\t\t\t\tfunction _matchOrderedDiscrimination2(o) {\n\t\t\t\t\treturn o.kind\n\t\t\t\t}\n\t\t\t)\n\t\t\t.case(\n\t\t\t\t{\n\t\t\t\t\tkind: \"'number'\"\n\t\t\t\t},\n\t\t\t\tfunction _matchOrderedDiscrimination3(o) {\n\t\t\t\t\treturn o.kind\n\t\t\t\t}\n\t\t\t)\n\t\t\t.case(\n\t\t\t\t{\n\t\t\t\t\tid: \"number\"\n\t\t\t\t},\n\t\t\t\tfunction _matchOrderedDiscrimination4(o) {\n\t\t\t\t\treturn o.id\n\t\t\t\t}\n\t\t\t)\n\t\t\t.default(\"assert\")\n\n\t\tattest(m.internal.assertHasKind(\"union\").discriminantJson).snap({\n\t\t\tkind: \"domain\",\n\t\t\tpath: [\"id\"],\n\t\t\tcases: {\n\t\t\t\t'\"string\"': { in: {}, morphs: [\"$ark._matchOrderedDiscrimination1\"] },\n\t\t\t\t'\"number\"': {\n\t\t\t\t\tkind: \"unit\",\n\t\t\t\t\tpath: [\"kind\"],\n\t\t\t\t\tcases: {\n\t\t\t\t\t\t'\"string\"': {\n\t\t\t\t\t\t\tbranches: [\n\t\t\t\t\t\t\t\t{ in: {}, morphs: [\"$ark._matchOrderedDiscrimination2\"] },\n\t\t\t\t\t\t\t\t{ in: {}, morphs: [\"$ark._matchOrderedDiscrimination4\"] }\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tordered: true\n\t\t\t\t\t\t},\n\t\t\t\t\t\t'\"number\"': {\n\t\t\t\t\t\t\tbranches: [\n\t\t\t\t\t\t\t\t{ in: {}, morphs: [\"$ark._matchOrderedDiscrimination3\"] },\n\t\t\t\t\t\t\t\t{ in: {}, morphs: [\"$ark._matchOrderedDiscrimination4\"] }\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tordered: true\n\t\t\t\t\t\t},\n\t\t\t\t\t\tdefault: { in: {}, morphs: [\"$ark._matchOrderedDiscrimination4\"] }\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tdefault: {\n\t\t\t\t\tkind: \"unit\",\n\t\t\t\t\tpath: [\"kind\"],\n\t\t\t\t\tcases: {\n\t\t\t\t\t\t'\"string\"': {\n\t\t\t\t\t\t\tin: {},\n\t\t\t\t\t\t\tmorphs: [\"$ark._matchOrderedDiscrimination2\"]\n\t\t\t\t\t\t},\n\t\t\t\t\t\t'\"number\"': {\n\t\t\t\t\t\t\tin: {},\n\t\t\t\t\t\t\tmorphs: [\"$ark._matchOrderedDiscrimination3\"]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t\tattest(m).type.toString.snap(`Match<\n\tunknown,\n\t[\n\t\t(In: { id: string }) => string,\n\t\t(In: { kind: \"string\" }) => \"string\",\n\t\t(In: { kind: \"number\" }) => \"number\",\n\t\t(In: { id: number }) => number\n\t]\n>`)\n\t})\n\n\tit(\"allows number keys\", () => {\n\t\tconst numeric = match({\n\t\t\t0: function numericZeroCase(n) {\n\t\t\t\treturn `${n}` as const\n\t\t\t},\n\t\t\t1: function numericOneCase(n) {\n\t\t\t\treturn `${n}` as const\n\t\t\t},\n\t\t\tdefault: \"assert\"\n\t\t})\n\n\t\tattest(numeric).type.toString.snap(`Match<\n\tunknown,\n\t[(In: number) => \"0\", (In: number) => \"1\"]\n>`)\n\t\tattest(numeric.json).snap({\n\t\t\tbranches: [\n\t\t\t\t{ in: { unit: 0 }, morphs: [\"$ark.numericZeroCase\"] },\n\t\t\t\t{ in: { unit: 1 }, morphs: [\"$ark.numericOneCase\"] }\n\t\t\t],\n\t\t\tordered: true,\n\t\t\tmeta: { onFail: \"$ark.throwOnDefault\" }\n\t\t})\n\t})\n\n\tit(\"union inputs\", () => {\n\t\tconst stringifyResponse = match({\n\t\t\t\"true | 1\": n => `${n}`,\n\t\t\t\"false | 0\": n => `${n}`,\n\t\t\tdefault: \"assert\"\n\t\t})\n\n\t\tattest(stringifyResponse).type.toString.snap(`Match<\n\tunknown,\n\t[(In: true | 1) => string, (In: false | 0) => string]\n>`)\n\n\t\tattest(stringifyResponse(true)).snap(\"true\")\n\t\tattest(stringifyResponse(false)).snap(\"false\")\n\t\tattest(stringifyResponse(1)).snap(\"1\")\n\t\tattest(stringifyResponse(0)).snap(\"0\")\n\t})\n\n\tit(\"discriminated\", () => {\n\t\ttype Data =\n\t\t\t| {\n\t\t\t\t\tid: 1\n\t\t\t\t\toneValue: number\n\t\t\t  }\n\t\t\t| {\n\t\t\t\t\tid: 2\n\t\t\t\t\ttwoValue: string\n\t\t\t  }\n\n\t\tconst discriminateValue = match\n\t\t\t.in<Data>()\n\t\t\t.at(\"id\")\n\t\t\t.match({\n\t\t\t\t1: o => `${o.oneValue}!`,\n\t\t\t\t2: o => o.twoValue.length,\n\t\t\t\tdefault: \"assert\"\n\t\t\t})\n\n\t\tattest(discriminateValue).type.toString.snap(`Match<\n\tData,\n\t[(In: Data) => string, (In: Data) => number]\n>`)\n\n\t\tconst a = discriminateValue({ id: 1, oneValue: 1 })\n\t\tattest(a).equals(\"1!\")\n\t\tconst b = discriminateValue({ id: 2, twoValue: \"two\" })\n\t\tattest(b).equals(3)\n\t\t// @ts-expect-error\n\t\tattest(() => discriminateValue({ oneValue: 3 }))\n\t\t\t.throws.snap(\"TraversalError: id must be 1 or 2 (was undefined)\")\n\t\t\t.type.errors(\"Property 'id' is missing in type '{ oneValue: number; }'\")\n\t})\n\n\tit(\"default ArkErrors\", () => {\n\t\tconst m = match({\n\t\t\tstring: s => s.length,\n\t\t\tnumber: n => n,\n\t\t\tdefault: \"reject\"\n\t\t})\n\n\t\tattest(m(\"foo\")).equals(3)\n\t\tattest(m(3)).equals(3)\n\t\t// can access directly since it has no overlap with input\n\t\tattest(m(null).summary).snap(\"must be a string or a number (was null)\")\n\t})\n\n\tit(\"docs example 2\", () => {\n\t\tconst sizeOf = match({\n\t\t\tstring: v => v.length,\n\t\t\tnumber: v => v,\n\t\t\tbigint: v => v\n\t\t\t// match any object with a length property\n\t\t})\n\t\t\t.case({ length: \"number\" }, o => o.length)\n\t\t\t.default(\"assert\")\n\n\t\tattest(sizeOf(\"abc\")).equals(3)\n\t\tattest(sizeOf({ name: \"David\", length: 5 })).equals(5)\n\t\tattest(() => sizeOf(null)).throws.snap(\n\t\t\t\"TraversalError: must be a string, a number, a bigint or an object (was null)\"\n\t\t)\n\t})\n\n\tit(\"validates in\", () => {\n\t\tconst exclaimFoo = match.in({ foo: \"string\" }).at(\"foo\", {\n\t\t\tdefault: o => `${o.foo}!` as const\n\t\t})\n\n\t\tattest(exclaimFoo).type.toString.snap(`Match<\n\t{ foo: string },\n\t[\n\t\t(In: unknown) => ArkErrors,\n\t\t(o: { foo: string }) => \\`\\${string}!\\`\n\t]\n>`)\n\n\t\tconst out = exclaimFoo({ foo: \"foo\" })\n\n\t\t// ensure ArkErrors is added as a possible outcome\n\t\t// since input is validated without assertion\n\t\tattest<ArkErrors | `${string}!`>(out).equals(\"foo!\")\n\n\t\t// @ts-expect-error\n\t\tattest(exclaimFoo({ foo: 5 }).toString())\n\t\t\t.snap(\"foo must be a string (was a number)\")\n\t\t\t.type.errors(\"Type 'number' is not assignable to type 'string'\")\n\t})\n\n\tit(\"asserts in\", () => {\n\t\tconst fooToLength = match.in({ foo: \"string\" }).at(\"foo\", {\n\t\t\t\"string > 0\": o => o.foo.length,\n\t\t\tdefault: \"assert\"\n\t\t})\n\n\t\tattest(fooToLength).type.toString.snap(`Match<\n\t{ foo: string },\n\t[(In: { foo: string }) => number]\n>`)\n\n\t\tconst out = fooToLength({ foo: \"foo\" })\n\n\t\t// ensure ArkErrors is not added to output\n\t\t// since result is asserted\n\t\tattest<number>(out).equals(3)\n\n\t\t// @ts-expect-error\n\t\tattest(() => fooToLength({ foo: 5 }))\n\t\t\t.throws(\"foo must be a string (was a number)\")\n\t\t\t.type.errors(\"Type 'number' is not assignable to type 'string'\")\n\t})\n\n\tit(\"string matcher no in\", () => {\n\t\tconst discriminate = match.at(\"kind\").strings({\n\t\t\ta: o => o.kind,\n\t\t\tb: o => o.kind,\n\t\t\tc: o => o.kind,\n\t\t\tdefault: \"assert\"\n\t\t})\n\t\tattest(discriminate).type.toString.snap(`Match<\n\tunknown,\n\t[\n\t\t(In: { kind: \"a\" }) => \"a\",\n\t\t(In: { kind: \"b\" }) => \"b\",\n\t\t(In: { kind: \"c\" }) => \"c\"\n\t]\n>`)\n\n\t\tconst a = discriminate({ kind: \"a\", value: \"a\" })\n\t\tconst b = discriminate({ kind: \"b\", value: \"b\" })\n\t\tconst c = discriminate({ kind: \"c\", value: \"c\" })\n\n\t\tattest<[\"a\", \"b\", \"c\"]>([a, b, c]).snap([\"a\", \"b\", \"c\"])\n\t})\n\n\ttype Discriminated =\n\t\t| {\n\t\t\t\tkind: \"a\"\n\t\t\t\tvalue: \"a\"\n\t\t  }\n\t\t| {\n\t\t\t\tkind: \"b\"\n\t\t\t\tvalue: \"b\"\n\t\t  }\n\t\t| {\n\t\t\t\tkind: \"c\"\n\t\t\t\tvalue: \"c\"\n\t\t  }\n\n\tit(\"string literal matcher\", () => {\n\t\tconst discriminate = match\n\t\t\t.in<Discriminated>()\n\t\t\t.at(\"kind\")\n\t\t\t.strings({\n\t\t\t\ta: o => o.value,\n\t\t\t\tb: o => o.value,\n\t\t\t\tc: o => o.value,\n\t\t\t\tdefault: \"assert\"\n\t\t\t})\n\n\t\tconst a = discriminate({ kind: \"a\", value: \"a\" })\n\t\tconst b = discriminate({ kind: \"b\", value: \"b\" })\n\t\tconst c = discriminate({ kind: \"c\", value: \"c\" })\n\n\t\tattest<[\"a\", \"b\", \"c\"]>([a, b, c]).snap([\"a\", \"b\", \"c\"])\n\n\t\t// @ts-expect-error\n\t\tattest(() => discriminate({ kind: \"d\", value: \"d\" }))\n\t\t\t.throws.snap('TraversalError: kind must be \"a\", \"b\" or \"c\" (was \"d\")')\n\t\t\t.type.errors(`Type '\"d\"' is not assignable`)\n\t})\n\n\tit(\"invalid string key\", () => {\n\t\tattest(() =>\n\t\t\tmatch\n\t\t\t\t.in<Discriminated>()\n\t\t\t\t.at(\"kind\")\n\t\t\t\t.strings({\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\td: o => o.value,\n\t\t\t\t\tdefault: \"assert\"\n\t\t\t\t})\n\t\t).type.errors(`ErrorType<\"d must be a possible string value\">`)\n\t})\n\n\tit(\"lone invalid string key\", () => {\n\t\tattest(() =>\n\t\t\tmatch\n\t\t\t\t.in<Discriminated>()\n\t\t\t\t.at(\"kind\")\n\t\t\t\t.strings({\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\td: o => o.value\n\t\t\t\t})\n\t\t).type.errors(\"d must be a possible string value\")\n\t})\n\n\tit(\"string cases no default\", () => {\n\t\tconst check = match\n\t\t\t.at(\"foo\")\n\t\t\t.strings({\n\t\t\t\tvalue: o => o.foo\n\t\t\t})\n\t\t\t.default(\"assert\")\n\n\t\tconst out = check({ foo: \"value\" })\n\n\t\tattest<\"value\">(out).equals(\"value\")\n\t})\n\n\tit(\"string cases no default from in\", () => {\n\t\tconst check = match\n\t\t\t.in({ foo: \"string\" })\n\t\t\t.at(\"foo\")\n\t\t\t.strings({\n\t\t\t\tvalue: o => o.foo\n\t\t\t})\n\t\t\t.default(\"assert\")\n\n\t\tconst out = check({ foo: \"value\" })\n\n\t\tattest<\"value\">(out).equals(\"value\")\n\t})\n\n\tit(\"union at input key\", () => {\n\t\ttype Data = {\n\t\t\tid: 1 | 2\n\t\t\tvalue: number\n\t\t}\n\n\t\tconst discriminateValue = type.match\n\t\t\t.in<Data>()\n\t\t\t.at(\"id\")\n\t\t\t.match({\n\t\t\t\t1: o => `${o.value}!`,\n\t\t\t\t2: o => o.value,\n\t\t\t\tdefault: \"assert\"\n\t\t\t})\n\n\t\tattest(discriminateValue).type.toString.snap(`Match<\n\tData,\n\t[(In: Data) => string, (In: Data) => number]\n>`)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/narrow.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { registeredReference } from \"@ark/schema\"\nimport type { equals } from \"@ark/util\"\nimport { type } from \"arktype\"\nimport type { Out } from \"arktype/internal/attributes.ts\"\n\ncontextualize(() => {\n\tit(\"implicit problem\", () => {\n\t\tconst isOdd = (n: number) => n % 2 === 1\n\t\tconst isOddRef = registeredReference(isOdd)\n\t\tconst Odd = type([\"number\", \":\", isOdd])\n\t\tattest<number>(Odd.infer)\n\t\tattest(Odd.json).equals({ domain: \"number\", predicate: [isOddRef] })\n\t\tattest(Odd(1)).equals(1)\n\t\tattest(Odd(2).toString()).snap(\"must be valid according to isOdd (was 2)\")\n\t})\n\n\tit(\"implicit problem anonymous\", () => {\n\t\tconst Even = type(\"number\", \":\", n => n % 2 === 0)\n\t\tattest(Even(1).toString()).snap(\n\t\t\t\"must be valid according to an anonymous predicate (was 1)\"\n\t\t)\n\t})\n\n\tit(\"explicit problem\", () => {\n\t\tconst DivisibleBy3 = type([\n\t\t\t\"number\",\n\t\t\t\":\",\n\t\t\t(n, ctx) => n % 3 === 0 || ctx.reject(\"divisible by 3\")\n\t\t])\n\t\tattest(DivisibleBy3(1).toString()).snap(\"must be divisible by 3 (was 1)\")\n\t})\n\n\tit(\"chained narrows\", () => {\n\t\tconst A = type(\"number\").narrow(\n\t\t\t(n, ctx) => n % 2 === 0 || ctx.reject(\"divisible by 2\")\n\t\t)\n\n\t\tconst b = A.narrow((n, ctx) => n % 3 === 0 || ctx.reject(\"divisible by 3\"))\n\n\t\tconst DivisibleBy30 = b.narrow(\n\t\t\t(n, ctx) => n % 5 === 0 || ctx.reject(\"divisible by 5\")\n\t\t)\n\n\t\tattest<number>(DivisibleBy30.t)\n\n\t\tattest(DivisibleBy30(1).toString()).snap(\"must be divisible by 2 (was 1)\")\n\t\tattest(DivisibleBy30(2).toString()).snap(\"must be divisible by 3 (was 2)\")\n\t\tattest(DivisibleBy30(6).toString()).snap(\"must be divisible by 5 (was 6)\")\n\t\tattest(DivisibleBy30(30)).equals(30)\n\t})\n\n\tit(\"problem at path\", () => {\n\t\tconst AbEqual = type([\n\t\t\t{\n\t\t\t\ta: \"number\",\n\t\t\t\tb: \"number\"\n\t\t\t},\n\t\t\t\":\",\n\t\t\t({ a, b }, ctx) => {\n\t\t\t\tif (a === b) return true\n\n\t\t\t\tctx.error({ expected: \"equal to b\", path: [\"a\"] })\n\t\t\t\tctx.error({ expected: \"equal to a\", path: [\"b\"] })\n\t\t\t\treturn false\n\t\t\t}\n\t\t])\n\n\t\tattest<{ a: number; b: number }>(AbEqual.t)\n\t\tattest<{\n\t\t\ta: number\n\t\t\tb: number\n\t\t}>(AbEqual.infer)\n\t\tattest(AbEqual({ a: 1, b: 1 })).equals({ a: 1, b: 1 })\n\t\tattest(AbEqual({ a: 1, b: 2 }).toString()).snap(\n\t\t\t'a must be equal to b (was {\"a\":1,\"b\":2})\\nb must be equal to a (was {\"a\":1,\"b\":2})'\n\t\t)\n\t})\n\n\tit(\"functional predicate\", () => {\n\t\tconst One = type([\"number\", \":\", (n): n is 1 => n === 1])\n\t\tattest<1>(One.infer)\n\t})\n\n\tit(\"functional parameter inference\", () => {\n\t\ttype Expected = number | boolean[]\n\t\tconst validateNumberOrBooleanList = <t>(\n\t\t\tt: equals<t, Expected> extends true ? t : Expected\n\t\t) => true\n\t\tattest<number | boolean[]>(\n\t\t\ttype([\"number|boolean[]\", \":\", data => validateNumberOrBooleanList(data)])\n\t\t\t\t.infer\n\t\t)\n\t\tattest(() => {\n\t\t\t// @ts-expect-error\n\t\t\ttype([\"number|boolean[]\", \":\", (data: number | string[]) => !!data])\n\t\t}).type.errors(\"Type 'boolean' is not assignable to type 'string'.\")\n\t})\n\n\tit(\"narrow problem\", () => {\n\t\tconst Palindrome = type([\n\t\t\t\"string\",\n\t\t\t\":\",\n\t\t\t(s, ctx) =>\n\t\t\t\ts === [...s].reverse().join(\"\") ? true : ctx.reject(\"a palindrome\")\n\t\t])\n\t\tattest<string>(Palindrome.t)\n\t\tattest(Palindrome(\"dad\")).snap(\"dad\")\n\t\tattest(Palindrome(\"david\").toString()).snap(\n\t\t\t'must be a palindrome (was \"david\")'\n\t\t)\n\t})\n\n\tit(\"narrows the output type of a morph\", () => {\n\t\tconst T = type(\"string\")\n\t\t\t.pipe(function _narrowMorphOutputMorph(s) {\n\t\t\t\treturn s.length\n\t\t\t})\n\t\t\t.narrow(function _narrowMorphOutputNarrow(n): n is 5 {\n\t\t\t\treturn n === 5\n\t\t\t})\n\n\t\tattest(T.json).snap({\n\t\t\tin: \"string\",\n\t\t\tmorphs: [\n\t\t\t\t\"$ark._narrowMorphOutputMorph\",\n\t\t\t\t{ predicate: [\"$ark._narrowMorphOutputNarrow\"] }\n\t\t\t]\n\t\t})\n\n\t\tattest<(In: string) => Out<5>>(T.t)\n\n\t\tattest(T(\"12345\")).snap(5)\n\t\tattest(T(\"1234\").toString()).snap(\n\t\t\t\"must be valid according to _narrowMorphOutputNarrow (was 4)\"\n\t\t)\n\t})\n\n\tit(\"expression\", () => {\n\t\tconst T = type(\"string\", \":\", (s): s is `f${string}` => s[0] === \"f\")\n\t\tattest<`f${string}`>(T.infer)\n\t})\n\n\tit(\"narrows the output type of an morph within a single type\", () => {\n\t\tconst T = type(\"string\")\n\t\t\t.pipe(s => `${s}!`)\n\t\t\t.narrow((s): s is \"foo!\" => s === \"foo!\")\n\n\t\tattest(T.t).type.toString.snap('(In: string) => Out<\"foo!\">')\n\t\tattest<string>(T.inferIn)\n\t\tattest<\"foo!\">(T.infer)\n\t})\n\n\tit(\"narrow then pipe\", () => {\n\t\tconst toString = (bigint: bigint) => bigint.toString()\n\t\tconst predicate = () => true\n\n\t\tconst predicateId = registeredReference(predicate)\n\t\tconst morphId = registeredReference(toString)\n\n\t\tconst A = type(\"bigint\").narrow(predicate).pipe(toString)\n\n\t\tattest<(In: bigint) => Out<string>>(A.t)\n\t\tattest<bigint>(A.in.infer)\n\t\tattest<bigint>(A.inferIn)\n\t\tattest<string>(A.infer)\n\n\t\tattest(A.json).snap({\n\t\t\tin: { domain: \"bigint\", predicate: [predicateId] },\n\t\t\tmorphs: [morphId]\n\t\t})\n\t})\n\n\tit(\"can distill constrained built-ins\", () => {\n\t\tconst N = type(\"number\")\n\t\t\t.narrow(() => true)\n\t\t\t.pipe(() => true)\n\t\tattest<number>(N.inferIn)\n\t\tattest<number>(N.in.infer)\n\n\t\tconst S = type(\"string\")\n\t\t\t.narrow(() => true)\n\t\t\t.pipe(() => true)\n\t\tattest<string>(S.inferIn)\n\t\tattest<string>(S.in.infer)\n\n\t\tconst B = type(\"bigint\")\n\t\t\t.narrow(() => true)\n\t\t\t.pipe(() => true)\n\t\tattest<bigint>(B.inferIn)\n\t\tattest<bigint>(B.in.infer)\n\n\t\tconst Sym = type(\"symbol\")\n\t\t\t.narrow(() => true)\n\t\t\t.pipe(() => true)\n\t\tattest<symbol>(Sym.inferIn)\n\t\tattest<symbol>(Sym.in.infer)\n\n\t\tconst D = type(\"Date\")\n\t\t\t.narrow(() => true)\n\t\t\t.pipe(() => true)\n\t\tattest<Date>(D.inferIn)\n\t})\n\n\tit(\"can distill constrained objects\", () => {\n\t\tconst Obj = type({ foo: \"number\" })\n\t\t\t.narrow(() => true)\n\t\t\t.pipe(() => true)\n\t\tattest<{ foo: number }>(Obj.inferIn)\n\t\tattest<{ foo: number }>(Obj.in.infer)\n\n\t\tconst Nested = type({ foo: [\"number.integer\", \"=>\", n => n++] })\n\t\tattest(Nested.t).type.toString.snap(\"{ foo: (In: number) => Out<number> }\")\n\t\tattest<{ foo: number }>(Nested.inferIn)\n\t\tattest<{ foo: number }>(Nested.in.infer)\n\n\t\tconst Map = type.keywords.Map.narrow(() => true).pipe(m => m)\n\t\tattest(Map.t).type.toString.snap(`(\n\tIn: Map<unknown, unknown>\n) => Out<Map<unknown, unknown>>`)\n\t\tattest(Map.infer).type.toString.snap(\"Map<unknown, unknown>\")\n\t\tattest(Map.inferIn).type.toString(\"Map<unknown, unknown>\")\n\t})\n\n\tit(\"can distill constrained arrays\", () => {\n\t\tconst Arr = type(\"string[]\")\n\t\t\t.narrow(() => true)\n\t\t\t.pipe(() => true)\n\t\tattest<string[]>(Arr.inferIn)\n\t\tattest<string[]>(Arr.in.infer)\n\n\t\tconst ObjArr = type({ foo: \"string.date.parse\" })\n\t\t\t.array()\n\t\t\t.narrow(() => true)\n\t\t\t.pipe(d => d)\n\t\tattest<\n\t\t\t{\n\t\t\t\tfoo: string\n\t\t\t}[]\n\t\t>(ObjArr.inferIn)\n\t\tattest<\n\t\t\t{\n\t\t\t\tfoo: string\n\t\t\t}[]\n\t\t>(ObjArr.in.infer)\n\t})\n\n\tit(\"can distill units\", () => {\n\t\tconst T = type(\"5\").narrow(() => true)\n\t\tattest<5>(T.t)\n\t\tattest<5>(T.infer)\n\t\tattest<5>(T.inferIn)\n\n\t\t// this predicate is evaluated and pruned\n\t\tattest(T.expression).equals(\"5\")\n\t})\n\n\tit(\"unknown is narrowable\", () => {\n\t\tconst unknownPredicate854 = () => true\n\t\tconst T = type(\"unknown\").narrow(unknownPredicate854)\n\t\tattest(T.t).type.toString.snap(\"unknown\")\n\t\tattest(T.json).snap({ predicate: [\"$ark.unknownPredicate854\"] })\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/nary.bench.ts",
    "content": "import { bench } from \"@ark/attest\"\nimport { type } from \"arktype\"\n\nbench.baseline(() => {\n\ttype.or({ foo: \"string\" }, { bar: \"number\" })\n\ttype.and({ foo: \"string\" }, { bar: \"number\" })\n\ttype.merge({ foo: \"string\" }, { bar: \"number\" })\n\ttype.pipe(type({ foo: \"string\" }), o => o.foo, type.string)\n\ttype.fn({ foo: \"string\" })(o => ({\n\t\tbar: o.foo.length\n\t}))\n\ttype.fn({ foo: \"string\" }, \":\", { bar: \"number\" })(o => ({\n\t\tbar: o.foo.length\n\t}))\n})\n\nbench(\"or(2)\", () => {\n\ttype.or({ a1: \"1\" }, { a2: \"2\" })\n}).types([1140, \"instantiations\"])\n\nbench(\"or-chained(2)\", () => {\n\ttype.or({ a1: \"1\" }).or({ a2: \"2\" })\n}).types([1940, \"instantiations\"])\n\nbench(\"or(5)\", () => {\n\ttype.or({ a1: \"1\" }, { a2: \"2\" }, { a3: \"3\" }, { a4: \"4\" }, { a5: \"5\" })\n}).types([4546, \"instantiations\"])\n\nbench(\"or-chained(5)\", () => {\n\ttype\n\t\t.or({ a1: \"1\" })\n\t\t.or({ a2: \"2\" })\n\t\t.or({ a3: \"3\" })\n\t\t.or({ a4: \"4\" })\n\t\t.or({ a5: \"5\" })\n}).types([5159, \"instantiations\"])\n\nbench(\"or(10)\", () => {\n\ttype.or(\n\t\t{ a1: \"1\" },\n\t\t{ a2: \"2\" },\n\t\t{ a3: \"3\" },\n\t\t{ a4: \"4\" },\n\t\t{ a5: \"5\" },\n\t\t{ a6: \"6\" },\n\t\t{ a7: \"7\" },\n\t\t{ a8: \"8\" },\n\t\t{ a9: \"9\" },\n\t\t{ a10: \"10\" }\n\t)\n}).types([9099, \"instantiations\"])\n\nbench(\"or-chained(10)\", () => {\n\ttype\n\t\t.or({ a1: \"1\" })\n\t\t.or({ a2: \"2\" })\n\t\t.or({ a3: \"3\" })\n\t\t.or({ a4: \"4\" })\n\t\t.or({ a5: \"5\" })\n\t\t.or({ a6: \"6\" })\n\t\t.or({ a7: \"7\" })\n\t\t.or({ a8: \"8\" })\n\t\t.or({ a9: \"9\" })\n\t\t.or({ a10: \"10\" })\n}).types([11497, \"instantiations\"])\n\nbench(\"and(2)\", () => {\n\ttype.and({ a1: \"1\" }, { a2: \"2\" })\n}).types([1358, \"instantiations\"])\n\nbench(\"and-chained(2)\", () => {\n\ttype.and({ a1: \"1\" }).and({ a2: \"2\" })\n}).types([2304, \"instantiations\"])\n\nbench(\"and(5)\", () => {\n\ttype.and({ a1: \"1\" }, { a2: \"2\" }, { a3: \"3\" }, { a4: \"4\" }, { a5: \"5\" })\n}).types([7456, \"instantiations\"])\n\nbench(\"and-chained(5)\", () => {\n\ttype\n\t\t.and({ a1: \"1\" })\n\t\t.and({ a2: \"2\" })\n\t\t.and({ a3: \"3\" })\n\t\t.and({ a4: \"4\" })\n\t\t.and({ a5: \"5\" })\n}).types([6918, \"instantiations\"])\n\nbench(\"and(10)\", () => {\n\tconst t = type.and(\n\t\t{ a1: \"1\" },\n\t\t{ a2: \"2\" },\n\t\t{ a3: \"3\" },\n\t\t{ a4: \"4\" },\n\t\t{ a5: \"5\" },\n\t\t{ a6: \"6\" },\n\t\t{ a7: \"7\" },\n\t\t{ a8: \"8\" },\n\t\t{ a9: \"9\" },\n\t\t{ a10: \"10\" }\n\t)\n\t// ⛳ Result: 17760 instantiations (under baseline by 98.90%)!\n}).types([17614, \"instantiations\"])\n\nbench(\"and-chained(10)\", () => {\n\ttype\n\t\t.and({ a1: \"1\" })\n\t\t.and({ a2: \"2\" })\n\t\t.and({ a3: \"3\" })\n\t\t.and({ a4: \"4\" })\n\t\t.and({ a5: \"5\" })\n\t\t.and({ a6: \"6\" })\n\t\t.and({ a7: \"7\" })\n\t\t.and({ a8: \"8\" })\n\t\t.and({ a9: \"9\" })\n\t\t.and({ a10: \"10\" })\n}).types([17341, \"instantiations\"])\n\nbench(\"merge(2)\", () => {\n\ttype.merge({ a1: \"1\" }, { a2: \"2\" })\n}).types([1209, \"instantiations\"])\n\nbench(\"merge-chained(2)\", () => {\n\ttype.merge({ a1: \"1\" }).merge({ a2: \"2\" })\n}).types([1957, \"instantiations\"])\n\nbench(\"merge(5)\", () => {\n\ttype.merge({ a1: \"1\" }, { a2: \"2\" }, { a3: \"3\" }, { a4: \"4\" }, { a5: \"5\" })\n}).types([5305, \"instantiations\"])\n\nbench(\"merge-chained(5)\", () => {\n\ttype\n\t\t.merge({ a1: \"1\" })\n\t\t.merge({ a2: \"2\" })\n\t\t.merge({ a3: \"3\" })\n\t\t.merge({ a4: \"4\" })\n\t\t.merge({ a5: \"5\" })\n}).types([5113, \"instantiations\"])\n\nbench(\"merge(10)\", () => {\n\ttype.merge(\n\t\t{ a1: \"1\" },\n\t\t{ a2: \"2\" },\n\t\t{ a3: \"3\" },\n\t\t{ a4: \"4\" },\n\t\t{ a5: \"5\" },\n\t\t{ a6: \"6\" },\n\t\t{ a7: \"7\" },\n\t\t{ a8: \"8\" },\n\t\t{ a9: \"9\" },\n\t\t{ a10: \"10\" }\n\t)\n}).types([11083, \"instantiations\"])\n\nbench(\"merge-chained(10)\", () => {\n\ttype\n\t\t.merge({ a1: \"1\" })\n\t\t.merge({ a2: \"2\" })\n\t\t.merge({ a3: \"3\" })\n\t\t.merge({ a4: \"4\" })\n\t\t.merge({ a5: \"5\" })\n\t\t.merge({ a6: \"6\" })\n\t\t.merge({ a7: \"7\" })\n\t\t.merge({ a8: \"8\" })\n\t\t.merge({ a9: \"9\" })\n\t\t.merge({ a10: \"10\" })\n}).types([11186, \"instantiations\"])\n\nbench(\"pipe(2)\", () => {\n\ttype.pipe(type.unit(\"a\"), s => `${s}b` as const)\n}).types([2727, \"instantiations\"])\n\nbench(\"pipe-chained(2)\", () => {\n\ttype.unit(\"a\").pipe(s => `${s}b` as const)\n}).types([275, \"instantiations\"])\n\nbench(\"pipe(5)\", () => {\n\ttype.pipe(\n\t\ttype.unit(\"a\"),\n\t\ts => `${s}b` as const,\n\t\ts => `${s}c` as const,\n\t\ts => `${s}d` as const,\n\t\ts => `${s}e` as const\n\t)\n}).types([3470, \"instantiations\"])\n\nbench(\"pipe-chained(5)\", () => {\n\ttype\n\t\t.unit(\"a\")\n\t\t.pipe(s => `${s}b` as const)\n\t\t.pipe(s => `${s}c` as const)\n\t\t.pipe(s => `${s}d` as const)\n\t\t.pipe(s => `${s}e` as const)\n}).types([1481, \"instantiations\"])\n\nbench(\"pipe(10)\", () => {\n\ttype.pipe(\n\t\ttype.unit(\"a\"),\n\t\ts => `${s}b` as const,\n\t\ts => `${s}c` as const,\n\t\ts => `${s}d` as const,\n\t\ts => `${s}e` as const,\n\t\ts => `${s}f` as const,\n\t\ts => `${s}g` as const,\n\t\ts => `${s}h` as const,\n\t\ts => `${s}i` as const,\n\t\ts => `${s}j` as const\n\t)\n}).types([5085, \"instantiations\"])\n\nbench(\"pipe-chained(10)\", () => {\n\ttype\n\t\t.unit(\"a\")\n\t\t.pipe(s => `${s}b` as const)\n\t\t.pipe(s => `${s}c` as const)\n\t\t.pipe(s => `${s}d` as const)\n\t\t.pipe(s => `${s}e` as const)\n\t\t.pipe(s => `${s}f` as const)\n\t\t.pipe(s => `${s}g` as const)\n\t\t.pipe(s => `${s}h` as const)\n\t\t.pipe(s => `${s}i` as const)\n\t\t.pipe(s => `${s}j` as const)\n}).types([4026, \"instantiations\"])\n\nbench(\"fun(0)\", () => {\n\ttype.fn(\":\", { a1: \"1\" })(() => ({ a1: 1 }))\n}).types([1135, \"instantiations\"])\n\nbench(\"fun(1, implicit)\", () => {\n\ttype.fn({ a1: \"1\" })(a => a)\n}).types([1210, \"instantiations\"])\n\nbench(\"fun(1, explicit)\", () => {\n\ttype.fn({ a1: \"1\" }, \":\", { a2: \"2\" })(a => ({ ...a, a2: 2 }))\n}).types([2167, \"instantiations\"])\n\nbench(\"fun(2)\", () => {\n\ttype.fn({ a1: \"1\" }, { a2: \"2\" }, \":\", { a3: \"3\" })((a, b) => ({\n\t\t...a,\n\t\t...b,\n\t\ta3: 3\n\t}))\n}).types([3283, \"instantiations\"])\n\nbench(\"fun(5)\", () => {\n\ttype.fn(\n\t\t{ a1: \"1\" },\n\t\t{ a2: \"2\" },\n\t\t{ a3: \"3\" },\n\t\t{ a4: \"4\" },\n\t\t{ a5: \"5\" },\n\t\t\":\",\n\t\t{ a6: \"6\" }\n\t)((a, b, c, d, e) => ({ ...a, ...b, ...c, ...d, ...e, a6: 6 }))\n}).types([7012, \"instantiations\"])\n\nbench(\"fun(10)\", () => {\n\ttype.fn(\n\t\t{ a1: \"1\" },\n\t\t{ a2: \"2\" },\n\t\t{ a3: \"3\" },\n\t\t{ a4: \"4\" },\n\t\t{ a5: \"5\" },\n\t\t{ a6: \"6\" },\n\t\t{ a7: \"7\" },\n\t\t{ a8: \"8\" },\n\t\t{ a9: \"9\" },\n\t\t{ a10: \"10\" },\n\t\t\":\",\n\t\t{ a11: \"11\" }\n\t)((a, b, c, d, e, f, g, h, i, j) => ({\n\t\t...a,\n\t\t...b,\n\t\t...c,\n\t\t...d,\n\t\t...e,\n\t\t...f,\n\t\t...g,\n\t\t...h,\n\t\t...i,\n\t\t...j,\n\t\ta11: 11\n\t}))\n}).types([14613, \"instantiations\"])\n"
  },
  {
    "path": "ark/type/__tests__/nary.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport type { Morph } from \"@ark/schema\"\nimport { type } from \"arktype\"\nimport type { Out } from \"arktype/internal/attributes.ts\"\n\ncontextualize(() => {\n\tcontextualize.each(\n\t\t\"union\",\n\t\t() => {\n\t\t\tconst $ = type.scope({\n\t\t\t\ta: \"1\",\n\t\t\t\tb: \"2\",\n\t\t\t\tc: \"3\",\n\t\t\t\td: \"4\",\n\t\t\t\te: \"5\",\n\t\t\t\tf: \"6\",\n\t\t\t\tg: \"7\",\n\t\t\t\th: \"8\",\n\t\t\t\ti: \"9\",\n\t\t\t\tj: \"10\",\n\t\t\t\tk: \"11\",\n\t\t\t\tl: \"12\",\n\t\t\t\tm: \"13\",\n\t\t\t\tn: \"14\",\n\t\t\t\to: \"15\",\n\t\t\t\tp: \"16\",\n\t\t\t\tq: \"17\"\n\t\t\t})\n\t\t\treturn $\n\t\t},\n\t\tit => {\n\t\t\tit(\"nullary\", () => {\n\t\t\t\tconst T = type.or()\n\t\t\t\tattest<never>(T.t)\n\n\t\t\t\tattest(T.expression).snap(\"never\")\n\t\t\t\tattest(T.$.internal.name).snap(\"ark\")\n\t\t\t})\n\n\t\t\tit(\"unary\", $ => {\n\t\t\t\tconst T = $.type.or(\"a\")\n\t\t\t\tattest<1>(T.t)\n\t\t\t\tattest(T.expression).snap(\"1\")\n\t\t\t})\n\n\t\t\tit(\"binary\", $ => {\n\t\t\t\tconst T = $.type.or(\"a\", \"b\")\n\t\t\t\tattest<1 | 2>(T.t)\n\t\t\t\tattest(T.expression).snap(\"1 | 2\")\n\t\t\t})\n\n\t\t\tit(\"3-ary\", $ => {\n\t\t\t\tconst T = $.type.or(\"a\", \"b\", \"c\")\n\t\t\t\tattest<1 | 2 | 3>(T.t)\n\t\t\t\tattest(T.expression).snap(\"1 | 2 | 3\")\n\t\t\t})\n\n\t\t\tit(\"4-ary\", $ => {\n\t\t\t\tconst T = $.type.or(\"a\", \"b\", \"c\", \"d\")\n\t\t\t\tattest<1 | 2 | 3 | 4>(T.t)\n\t\t\t\tattest(T.expression).snap(\"1 | 2 | 3 | 4\")\n\t\t\t})\n\n\t\t\tit(\"5-ary\", $ => {\n\t\t\t\tconst T = $.type.or(\"a\", \"b\", \"c\", \"d\", \"e\")\n\t\t\t\tattest<1 | 2 | 3 | 4 | 5>(T.t)\n\t\t\t\tattest(T.expression).snap(\"1 | 2 | 3 | 4 | 5\")\n\t\t\t})\n\n\t\t\tit(\"6-ary\", $ => {\n\t\t\t\tconst T = $.type.or(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\")\n\t\t\t\tattest<1 | 2 | 3 | 4 | 5 | 6>(T.t)\n\t\t\t\tattest(T.expression).snap(\"1 | 2 | 3 | 4 | 5 | 6\")\n\t\t\t})\n\n\t\t\tit(\"7-ary\", $ => {\n\t\t\t\tconst T = $.type.or(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\")\n\t\t\t\tattest<1 | 2 | 3 | 4 | 5 | 6 | 7>(T.t)\n\t\t\t\tattest(T.expression).snap(\"1 | 2 | 3 | 4 | 5 | 6 | 7\")\n\t\t\t})\n\n\t\t\tit(\"8-ary\", $ => {\n\t\t\t\tconst T = $.type.or(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\")\n\t\t\t\tattest<1 | 2 | 3 | 4 | 5 | 6 | 7 | 8>(T.t)\n\t\t\t\tattest(T.expression).snap(\"1 | 2 | 3 | 4 | 5 | 6 | 7 | 8\")\n\t\t\t})\n\n\t\t\tit(\"9-ary\", $ => {\n\t\t\t\tconst T = $.type.or(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\")\n\t\t\t\tattest<1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9>(T.t)\n\t\t\t\tattest(T.expression).snap(\"1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9\")\n\t\t\t})\n\n\t\t\tit(\"10-ary\", $ => {\n\t\t\t\tconst T = $.type.or(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\")\n\t\t\t\tattest<1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10>(T.t)\n\t\t\t\tattest(T.expression).snap(\"10 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9\")\n\t\t\t})\n\n\t\t\tit(\"11-ary\", $ => {\n\t\t\t\tconst T = $.type.or(\n\t\t\t\t\t\"a\",\n\t\t\t\t\t\"b\",\n\t\t\t\t\t\"c\",\n\t\t\t\t\t\"d\",\n\t\t\t\t\t\"e\",\n\t\t\t\t\t\"f\",\n\t\t\t\t\t\"g\",\n\t\t\t\t\t\"h\",\n\t\t\t\t\t\"i\",\n\t\t\t\t\t\"j\",\n\t\t\t\t\t\"k\"\n\t\t\t\t)\n\t\t\t\tattest<1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11>(T.t)\n\t\t\t\tattest(T.expression).snap(\"10 | 11 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9\")\n\t\t\t})\n\n\t\t\tit(\"12-ary\", $ => {\n\t\t\t\tconst T = $.type.or(\n\t\t\t\t\t\"a\",\n\t\t\t\t\t\"b\",\n\t\t\t\t\t\"c\",\n\t\t\t\t\t\"d\",\n\t\t\t\t\t\"e\",\n\t\t\t\t\t\"f\",\n\t\t\t\t\t\"g\",\n\t\t\t\t\t\"h\",\n\t\t\t\t\t\"i\",\n\t\t\t\t\t\"j\",\n\t\t\t\t\t\"k\",\n\t\t\t\t\t\"l\"\n\t\t\t\t)\n\t\t\t\tattest<1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12>(T.t)\n\t\t\t\tattest(T.expression).snap(\n\t\t\t\t\t\"10 | 11 | 12 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9\"\n\t\t\t\t)\n\t\t\t})\n\n\t\t\tit(\"13-ary\", $ => {\n\t\t\t\tconst T = $.type.or(\n\t\t\t\t\t\"a\",\n\t\t\t\t\t\"b\",\n\t\t\t\t\t\"c\",\n\t\t\t\t\t\"d\",\n\t\t\t\t\t\"e\",\n\t\t\t\t\t\"f\",\n\t\t\t\t\t\"g\",\n\t\t\t\t\t\"h\",\n\t\t\t\t\t\"i\",\n\t\t\t\t\t\"j\",\n\t\t\t\t\t\"k\",\n\t\t\t\t\t\"l\",\n\t\t\t\t\t\"m\"\n\t\t\t\t)\n\t\t\t\tattest<1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13>(T.t)\n\t\t\t\tattest(T.expression).snap(\n\t\t\t\t\t\"10 | 11 | 12 | 13 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9\"\n\t\t\t\t)\n\t\t\t})\n\n\t\t\tit(\"14-ary\", $ => {\n\t\t\t\tconst T = $.type.or(\n\t\t\t\t\t\"a\",\n\t\t\t\t\t\"b\",\n\t\t\t\t\t\"c\",\n\t\t\t\t\t\"d\",\n\t\t\t\t\t\"e\",\n\t\t\t\t\t\"f\",\n\t\t\t\t\t\"g\",\n\t\t\t\t\t\"h\",\n\t\t\t\t\t\"i\",\n\t\t\t\t\t\"j\",\n\t\t\t\t\t\"k\",\n\t\t\t\t\t\"l\",\n\t\t\t\t\t\"m\",\n\t\t\t\t\t\"n\"\n\t\t\t\t)\n\t\t\t\tattest<1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14>(T.t)\n\t\t\t\tattest(T.expression).snap(\n\t\t\t\t\t\"10 | 11 | 12 | 13 | 14 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9\"\n\t\t\t\t)\n\t\t\t})\n\n\t\t\tit(\"15-ary\", $ => {\n\t\t\t\tconst T = $.type.or(\n\t\t\t\t\t\"a\",\n\t\t\t\t\t\"b\",\n\t\t\t\t\t\"c\",\n\t\t\t\t\t\"d\",\n\t\t\t\t\t\"e\",\n\t\t\t\t\t\"f\",\n\t\t\t\t\t\"g\",\n\t\t\t\t\t\"h\",\n\t\t\t\t\t\"i\",\n\t\t\t\t\t\"j\",\n\t\t\t\t\t\"k\",\n\t\t\t\t\t\"l\",\n\t\t\t\t\t\"m\",\n\t\t\t\t\t\"n\",\n\t\t\t\t\t\"o\"\n\t\t\t\t)\n\t\t\t\tattest<1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15>(\n\t\t\t\t\tT.t\n\t\t\t\t)\n\t\t\t\tattest(T.expression).snap(\n\t\t\t\t\t\"10 | 11 | 12 | 13 | 14 | 15 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9\"\n\t\t\t\t)\n\t\t\t})\n\n\t\t\tit(\"16-ary\", $ => {\n\t\t\t\tconst T = $.type.or(\n\t\t\t\t\t\"a\",\n\t\t\t\t\t\"b\",\n\t\t\t\t\t\"c\",\n\t\t\t\t\t\"d\",\n\t\t\t\t\t\"e\",\n\t\t\t\t\t\"f\",\n\t\t\t\t\t\"g\",\n\t\t\t\t\t\"h\",\n\t\t\t\t\t\"i\",\n\t\t\t\t\t\"j\",\n\t\t\t\t\t\"k\",\n\t\t\t\t\t\"l\",\n\t\t\t\t\t\"m\",\n\t\t\t\t\t\"n\",\n\t\t\t\t\t\"o\",\n\t\t\t\t\t\"p\"\n\t\t\t\t)\n\t\t\t\tattest<\n\t\t\t\t\t1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16\n\t\t\t\t>(T.t)\n\t\t\t\tattest(T.expression).snap(\n\t\t\t\t\t\"10 | 11 | 12 | 13 | 14 | 15 | 16 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9\"\n\t\t\t\t)\n\t\t\t})\n\n\t\t\tit(\"n-ary\", $ => {\n\t\t\t\tconst T = $.type.or(\n\t\t\t\t\t\"a\",\n\t\t\t\t\t\"b\",\n\t\t\t\t\t\"c\",\n\t\t\t\t\t\"d\",\n\t\t\t\t\t\"e\",\n\t\t\t\t\t\"f\",\n\t\t\t\t\t\"g\",\n\t\t\t\t\t\"h\",\n\t\t\t\t\t\"i\",\n\t\t\t\t\t\"j\",\n\t\t\t\t\t\"k\",\n\t\t\t\t\t\"l\",\n\t\t\t\t\t\"m\",\n\t\t\t\t\t\"n\",\n\t\t\t\t\t\"o\",\n\t\t\t\t\t\"p\",\n\t\t\t\t\t\"q\"\n\t\t\t\t)\n\n\t\t\t\tattest<\n\t\t\t\t\t| 1\n\t\t\t\t\t| 2\n\t\t\t\t\t| 3\n\t\t\t\t\t| 4\n\t\t\t\t\t| 5\n\t\t\t\t\t| 6\n\t\t\t\t\t| 7\n\t\t\t\t\t| 8\n\t\t\t\t\t| 9\n\t\t\t\t\t| 10\n\t\t\t\t\t| 11\n\t\t\t\t\t| 12\n\t\t\t\t\t| 13\n\t\t\t\t\t| 14\n\t\t\t\t\t| 15\n\t\t\t\t\t| 16\n\t\t\t\t\t| 17\n\t\t\t\t>(T.t)\n\t\t\t\tattest(T.expression).snap(\n\t\t\t\t\t\"10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9\"\n\t\t\t\t)\n\t\t\t})\n\n\t\t\tit(\"completions\", () => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tattest(() => type.or(\"boo\", { foo: \"big\" })).completions({\n\t\t\t\t\tboo: [\"boolean\"],\n\t\t\t\t\tbig: [\"bigint\"]\n\t\t\t\t})\n\t\t\t})\n\n\t\t\tit(\"spreadable\", () => {\n\t\t\t\tconst types: type[] = []\n\n\t\t\t\tconst T = type.or(...types)\n\n\t\t\t\tattest<unknown>(T.t)\n\t\t\t\tattest(T.expression).snap(\"never\")\n\t\t\t})\n\n\t\t\tit(\"spreadable scoped\", $ => {\n\t\t\t\tconst types: { key: \"a\" }[] = []\n\n\t\t\t\tconst T = $.type.or(...types)\n\n\t\t\t\tattest<{ key: 1 }>(T.t)\n\t\t\t})\n\t\t}\n\t)\n\n\tcontextualize.each(\n\t\t\"intersection\",\n\t\t() => {\n\t\t\tconst $ = type.scope({\n\t\t\t\ta: { a1: \"1\" },\n\t\t\t\tb: { a2: \"2\" },\n\t\t\t\tc: { a3: \"3\" },\n\t\t\t\td: { a4: \"4\" },\n\t\t\t\te: { a5: \"5\" }\n\t\t\t})\n\t\t\treturn $\n\t\t},\n\t\tit => {\n\t\t\tit(\"nullary\", () => {\n\t\t\t\tconst T = type.and()\n\t\t\t\tattest<unknown>(T.t)\n\t\t\t\tattest(T.expression).snap(\"unknown\")\n\t\t\t\tattest(T.$.internal.name).snap(\"ark\")\n\t\t\t})\n\n\t\t\tit(\"unary\", $ => {\n\t\t\t\tconst T = $.type.and(\"a\")\n\t\t\t\tattest<{ a1: 1 }>(T.t)\n\t\t\t\tattest(T.expression).snap(\"{ a1: 1 }\")\n\t\t\t})\n\n\t\t\tit(\"binary\", $ => {\n\t\t\t\tconst T = $.type.and(\"a\", \"b\")\n\t\t\t\tattest<{ a1: 1; a2: 2 }>(T.t)\n\t\t\t\tattest(T.expression).snap(\"{ a1: 1, a2: 2 }\")\n\t\t\t})\n\n\t\t\tit(\"3-ary\", $ => {\n\t\t\t\tconst T = $.type.and(\"a\", \"b\", \"c\")\n\t\t\t\tattest<{\n\t\t\t\t\ta1: 1\n\t\t\t\t\ta2: 2\n\t\t\t\t\ta3: 3\n\t\t\t\t}>(T.t)\n\t\t\t\tattest(T.expression).snap(\"{ a1: 1, a2: 2, a3: 3 }\")\n\t\t\t})\n\n\t\t\tit(\"4-ary\", $ => {\n\t\t\t\tconst T = $.type.and(\"a\", \"b\", \"c\", \"d\")\n\t\t\t\tattest<{\n\t\t\t\t\ta1: 1\n\t\t\t\t\ta2: 2\n\t\t\t\t\ta3: 3\n\t\t\t\t\ta4: 4\n\t\t\t\t}>(T.t)\n\t\t\t\tattest(T.expression).snap(\"{ a1: 1, a2: 2, a3: 3, a4: 4 }\")\n\t\t\t})\n\n\t\t\tit(\"5-ary\", $ => {\n\t\t\t\tconst T = $.type.and(\"a\", \"b\", \"c\", \"d\", \"e\")\n\t\t\t\tattest<{\n\t\t\t\t\ta1: 1\n\t\t\t\t\ta2: 2\n\t\t\t\t\ta3: 3\n\t\t\t\t\ta4: 4\n\t\t\t\t\ta5: 5\n\t\t\t\t}>(T.t)\n\t\t\t\tattest(T.expression).snap(\"{ a1: 1, a2: 2, a3: 3, a4: 4, a5: 5 }\")\n\t\t\t})\n\n\t\t\t// type-perf currently blows up here, investigation:\n\t\t\t// https://github.com/arktypeio/arktype/issues/1394\n\n\t\t\t// it(\"nary\", () => {\n\t\t\t// \tconst T = type.and(\n\t\t\t// \t\t{ a1: \"1\" },\n\t\t\t// \t\t{ a2: \"2\" },\n\t\t\t// \t\t{ a3: \"3\" },\n\t\t\t// \t\t{ a4: \"4\" },\n\t\t\t// \t\t{ a5: \"5\" },\n\t\t\t// \t\t{ a6: \"6\" },\n\t\t\t// \t\t{ a7: \"7\" },\n\t\t\t// \t\t{ a8: \"8\" },\n\t\t\t// \t\t{ a9: \"9\" },\n\t\t\t// \t\t{ a10: \"10\" },\n\t\t\t// \t\t{ a11: \"11\" },\n\t\t\t// \t\t{ a12: \"12\" },\n\t\t\t// \t\t{ a13: \"13\" },\n\t\t\t// \t\t{ a14: \"14\" },\n\t\t\t// \t\t{ a15: \"15\" },\n\t\t\t// \t\t{ a16: \"16\" },\n\t\t\t// \t\t{ a17: \"17\" }\n\t\t\t// \t)\n\n\t\t\t// \tattest<{\n\t\t\t// \t\ta1: 1\n\t\t\t// \t\ta2: 2\n\t\t\t// \t\ta3: 3\n\t\t\t// \t\ta4: 4\n\t\t\t// \t\ta5: 5\n\t\t\t// \t\ta6: 6\n\t\t\t// \t\ta7: 7\n\t\t\t// \t\ta8: 8\n\t\t\t// \t\ta9: 9\n\t\t\t// \t\ta10: 10\n\t\t\t// \t\ta11: 11\n\t\t\t// \t\ta12: 12\n\t\t\t// \t\ta13: 13\n\t\t\t// \t\ta14: 14\n\t\t\t// \t\ta15: 15\n\t\t\t// \t\ta16: 16\n\t\t\t// \t\ta17: 17\n\t\t\t// \t}>(T.t)\n\n\t\t\t// \tattest(T.expression).snap(\n\t\t\t// \t\t\"{ a1: 1, a10: 10, a11: 11, a12: 12, a13: 13, a14: 14, a15: 15, a16: 16, a17: 17, a2: 2, a3: 3, a4: 4, a5: 5, a6: 6, a7: 7, a8: 8, a9: 9 }\"\n\t\t\t// \t)\n\t\t\t// })\n\n\t\t\t// type-perf currently blows up here, investigation:\n\t\t\t// https://github.com/arktypeio/arktype/issues/1394\n\n\t\t\t// it(\"nary overlapping\", () => {\n\t\t\t// \tconst T = type.and(\n\t\t\t// \t\t{ a1: \"1\" },\n\t\t\t// \t\t{ a1: \"2\" },\n\t\t\t// \t\t{ a1: \"3\" },\n\t\t\t// \t\t{ a1: \"4\" },\n\t\t\t// \t\t{ a1: \"5\" },\n\t\t\t// \t\t{ a1: \"6\" },\n\t\t\t// \t\t{ a1: \"7\" },\n\t\t\t// \t\t{ a1: \"8\" },\n\t\t\t// \t\t{ a1: \"9\" },\n\t\t\t// \t\t{ a1: \"10\" },\n\t\t\t// \t\t{ a1: \"11\" },\n\t\t\t// \t\t{ a1: \"12\" },\n\t\t\t// \t\t{ a1: \"13\" },\n\t\t\t// \t\t{ a1: \"14\" },\n\t\t\t// \t\t{ a1: \"15\" },\n\t\t\t// \t\t{ a1: \"16\" },\n\t\t\t// \t\t{ a1: \"17\" }\n\t\t\t// \t)\n\n\t\t\t// \tattest<{\n\t\t\t// \t\ta1: 17\n\t\t\t// \t}>(T.t)\n\n\t\t\t// \tattest(T.expression).snap()\n\t\t\t// })\n\n\t\t\tit(\"completions\", () => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tattest(() => type.and(\"boo\", { foo: \"big\" })).completions({\n\t\t\t\t\tboo: [\"boolean\"],\n\t\t\t\t\tbig: [\"bigint\"]\n\t\t\t\t})\n\t\t\t})\n\n\t\t\tit(\"spreadable\", () => {\n\t\t\t\tconst types: type[] = []\n\n\t\t\t\tconst T = type.and(...types)\n\n\t\t\t\tattest<unknown>(T.t)\n\t\t\t\tattest(T.expression).snap(\"unknown\")\n\t\t\t})\n\n\t\t\tit(\"spreadable n-length\", $ => {\n\t\t\t\tconst types: (\n\t\t\t\t\t| { a: { key: \"1\" } }\n\t\t\t\t\t| { \"a?\": { another: \"1\" }; \"b?\": \"3\" }\n\t\t\t\t)[] = []\n\n\t\t\t\tconst T = $.type.and(...types)\n\n\t\t\t\tattest<{\n\t\t\t\t\t// should be required if one or branches is required\n\t\t\t\t\ta: {\n\t\t\t\t\t\tkey: 1\n\t\t\t\t\t\tanother: 1\n\t\t\t\t\t}\n\t\t\t\t\t// should be optional if all branches are optional\n\t\t\t\t\tb?: 3\n\t\t\t\t}>(T.t)\n\t\t\t})\n\t\t}\n\t)\n\n\tcontextualize.each(\n\t\t\"merge\",\n\t\t() => {\n\t\t\tconst $ = type.scope({\n\t\t\t\ta: { a1: \"1\" },\n\t\t\t\tb: { a2: \"2\" },\n\t\t\t\tc: { a3: \"3\" },\n\t\t\t\td: { a4: \"4\" },\n\t\t\t\te: { a5: \"5\" }\n\t\t\t})\n\t\t\treturn $\n\t\t},\n\t\tit => {\n\t\t\tit(\"nullary\", () => {\n\t\t\t\tconst T = type.merge()\n\t\t\t\tattest<object>(T.t)\n\t\t\t\tattest(T.expression).snap(\"object\")\n\t\t\t\tattest(T.$.internal.name).snap(\"ark\")\n\t\t\t})\n\n\t\t\tit(\"unary\", $ => {\n\t\t\t\tconst T = $.type.merge(\"a\")\n\t\t\t\tattest<{ a1: 1 }>(T.t)\n\t\t\t\tattest(T.expression).snap(\"{ a1: 1 }\")\n\t\t\t})\n\n\t\t\tit(\"binary\", $ => {\n\t\t\t\tconst T = $.type.merge(\"a\", \"b\")\n\t\t\t\tattest<{ a1: 1; a2: 2 }>(T.t)\n\t\t\t\tattest(T.expression).snap(\"{ a1: 1, a2: 2 }\")\n\t\t\t})\n\n\t\t\tit(\"3-ary\", $ => {\n\t\t\t\tconst T = $.type.merge(\"a\", \"b\", \"c\")\n\t\t\t\tattest<{\n\t\t\t\t\ta1: 1\n\t\t\t\t\ta2: 2\n\t\t\t\t\ta3: 3\n\t\t\t\t}>(T.t)\n\t\t\t\tattest(T.expression).snap(\"{ a1: 1, a2: 2, a3: 3 }\")\n\t\t\t})\n\n\t\t\tit(\"4-ary\", $ => {\n\t\t\t\tconst T = $.type.merge(\"a\", \"b\", \"c\", \"d\")\n\t\t\t\tattest<{\n\t\t\t\t\ta1: 1\n\t\t\t\t\ta2: 2\n\t\t\t\t\ta3: 3\n\t\t\t\t\ta4: 4\n\t\t\t\t}>(T.t)\n\t\t\t\tattest(T.expression).snap(\"{ a1: 1, a2: 2, a3: 3, a4: 4 }\")\n\t\t\t})\n\n\t\t\tit(\"5-ary\", $ => {\n\t\t\t\tconst T = $.type.merge(\"a\", \"b\", \"c\", \"d\", \"e\")\n\n\t\t\t\tattest<{\n\t\t\t\t\ta1: 1\n\t\t\t\t\ta2: 2\n\t\t\t\t\ta3: 3\n\t\t\t\t\ta4: 4\n\t\t\t\t\ta5: 5\n\t\t\t\t}>(T.t)\n\t\t\t\tattest(T.expression).snap(\"{ a1: 1, a2: 2, a3: 3, a4: 4, a5: 5 }\")\n\t\t\t})\n\n\t\t\tit(\"nary\", () => {\n\t\t\t\tconst T = type.merge(\n\t\t\t\t\t{ a1: \"1\" },\n\t\t\t\t\t{ a2: \"2\" },\n\t\t\t\t\t{ a3: \"3\" },\n\t\t\t\t\t{ a4: \"4\" },\n\t\t\t\t\t{ a5: \"5\" },\n\t\t\t\t\t{ a6: \"6\" },\n\t\t\t\t\t{ a7: \"7\" },\n\t\t\t\t\t{ a8: \"8\" },\n\t\t\t\t\t{ a9: \"9\" },\n\t\t\t\t\t{ a10: \"10\" },\n\t\t\t\t\t{ a11: \"11\" },\n\t\t\t\t\t{ a12: \"12\" },\n\t\t\t\t\t{ a13: \"13\" },\n\t\t\t\t\t{ a14: \"14\" },\n\t\t\t\t\t{ a15: \"15\" },\n\t\t\t\t\t{ a16: \"16\" },\n\t\t\t\t\t{ a17: \"17\" }\n\t\t\t\t)\n\n\t\t\t\tattest<{\n\t\t\t\t\ta1: 1\n\t\t\t\t\ta2: 2\n\t\t\t\t\ta3: 3\n\t\t\t\t\ta4: 4\n\t\t\t\t\ta5: 5\n\t\t\t\t\ta6: 6\n\t\t\t\t\ta7: 7\n\t\t\t\t\ta8: 8\n\t\t\t\t\ta9: 9\n\t\t\t\t\ta10: 10\n\t\t\t\t\ta11: 11\n\t\t\t\t\ta12: 12\n\t\t\t\t\ta13: 13\n\t\t\t\t\ta14: 14\n\t\t\t\t\ta15: 15\n\t\t\t\t\ta16: 16\n\t\t\t\t\ta17: 17\n\t\t\t\t}>(T.t)\n\n\t\t\t\tattest(T.expression).snap(\n\t\t\t\t\t\"{ a1: 1, a10: 10, a11: 11, a12: 12, a13: 13, a14: 14, a15: 15, a16: 16, a17: 17, a2: 2, a3: 3, a4: 4, a5: 5, a6: 6, a7: 7, a8: 8, a9: 9 }\"\n\t\t\t\t)\n\t\t\t})\n\n\t\t\t// type-perf currently blows up here, investigation:\n\t\t\t// https://github.com/arktypeio/arktype/issues/1394\n\n\t\t\t// it(\"nary overlapping\", () => {\n\t\t\t// \tconst T = type.merge(\n\t\t\t// \t\t{ a1: \"1\" },\n\t\t\t// \t\t{ a1: \"2\" },\n\t\t\t// \t\t{ a1: \"3\" },\n\t\t\t// \t\t{ a1: \"4\" },\n\t\t\t// \t\t{ a1: \"5\" },\n\t\t\t// \t\t{ a1: \"6\" },\n\t\t\t// \t\t{ a1: \"7\" },\n\t\t\t// \t\t{ a1: \"8\" },\n\t\t\t// \t\t{ a1: \"9\" },\n\t\t\t// \t\t{ a1: \"10\" },\n\t\t\t// \t\t{ a1: \"11\" },\n\t\t\t// \t\t{ a1: \"12\" },\n\t\t\t// \t\t{ a1: \"13\" },\n\t\t\t// \t\t{ a1: \"14\" },\n\t\t\t// \t\t{ a1: \"15\" },\n\t\t\t// \t\t{ a1: \"16\" },\n\t\t\t// \t\t{ a1: \"17\" }\n\t\t\t// \t)\n\n\t\t\t// \tattest<{\n\t\t\t// \t\ta1: 17\n\t\t\t// \t}>(T.t)\n\n\t\t\t// \tattest(T.expression).snap()\n\t\t\t// })\n\n\t\t\tit(\"completions\", () => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tattest(() => type.merge({ boo: \"boo\" }, { foo: \"big\" })).completions({\n\t\t\t\t\tbig: [\"bigint\"],\n\t\t\t\t\tboo: [\"boolean\"]\n\t\t\t\t})\n\t\t\t})\n\n\t\t\tit(\"spreadable\", () => {\n\t\t\t\tconst types: type<object>[] = []\n\n\t\t\t\tconst T = type.merge(...types)\n\n\t\t\t\tattest<{}>(T.t)\n\t\t\t\tattest(T.expression).snap(\"object\")\n\t\t\t})\n\n\t\t\tit(\"spreadable scoped\", $ => {\n\t\t\t\tconst types: { key: \"a\" }[] = []\n\n\t\t\t\tconst T = $.type.merge(...types)\n\n\t\t\t\tattest<{ key: { a1: 1 } }>(T.t)\n\t\t\t})\n\n\t\t\tit(\"spreadable n-length\", $ => {\n\t\t\t\tconst types: ({ a: \"1\" } | { a: \"2?\"; b: \"3\" })[] = []\n\n\t\t\t\tconst T = $.type.merge(...types)\n\n\t\t\t\tattest<{\n\t\t\t\t\t// should be optional if one or more branches are optional\n\t\t\t\t\ta?: 1 | 2\n\t\t\t\t\tb: 3\n\t\t\t\t}>(T.t)\n\t\t\t})\n\t\t}\n\t)\n\n\tdescribe(\"pipe\", () => {\n\t\tit(\"nullary\", () => {\n\t\t\tconst T = type.pipe()\n\t\t\tattest<unknown>(T.t)\n\t\t\tattest(T.expression).snap(\"unknown\")\n\t\t\tattest(T.$.internal.name).snap(\"ark\")\n\t\t})\n\n\t\tit(\"unary Type\", () => {\n\t\t\tconst T = type.pipe(type.string)\n\t\t\tattest<string>(T.t)\n\t\t\tattest(T.expression).snap(\"string\")\n\t\t})\n\n\t\tit(\"unary morph\", () => {\n\t\t\tconst T = type.pipe((u: unknown) => JSON.stringify(u))\n\t\t\tattest<(In: unknown) => Out<string>>(T.t)\n\t\t\tattest(T.expression).snap(\"(In: unknown) => Out<unknown>\")\n\t\t})\n\n\t\tit(\"binary\", () => {\n\t\t\tconst T = type.pipe(type.string, function _upper(s: string) {\n\t\t\t\treturn s.toUpperCase()\n\t\t\t})\n\t\t\tattest<(In: string) => Out<string>>(T.t)\n\t\t\tattest(T.expression).snap(\"(In: string) => Out<unknown>\")\n\t\t})\n\n\t\tit(\"3-ary\", () => {\n\t\t\tconst T = type.pipe(\n\t\t\t\ttype.unit(\"a\"),\n\t\t\t\ts => `${s}b` as const,\n\t\t\t\ts => `${s}c` as const\n\t\t\t)\n\t\t\tattest<\"abc\">(T.infer)\n\t\t\tattest(T(\"a\")).equals(\"abc\")\n\t\t})\n\n\t\tit(\"4-ary\", () => {\n\t\t\tconst T = type.pipe(\n\t\t\t\ttype.unit(\"a\"),\n\t\t\t\ts => `${s}b` as const,\n\t\t\t\ts => `${s}c` as const,\n\t\t\t\ts => `${s}d` as const\n\t\t\t)\n\t\t\tattest<\"abcd\">(T.infer)\n\t\t\tattest(T(\"a\")).equals(\"abcd\")\n\t\t})\n\n\t\tit(\"5-ary\", () => {\n\t\t\tconst T = type.pipe(\n\t\t\t\ttype.unit(\"a\"),\n\t\t\t\ts => `${s}b` as const,\n\t\t\t\ts => `${s}c` as const,\n\t\t\t\ts => `${s}d` as const,\n\t\t\t\ts => `${s}e` as const\n\t\t\t)\n\t\t\tattest<\"abcde\">(T.infer)\n\t\t\tattest(T(\"a\")).equals(\"abcde\")\n\t\t})\n\n\t\tit(\"6-ary\", () => {\n\t\t\tconst T = type.pipe(\n\t\t\t\ttype.unit(\"a\"),\n\t\t\t\ts => `${s}b` as const,\n\t\t\t\ts => `${s}c` as const,\n\t\t\t\ts => `${s}d` as const,\n\t\t\t\ts => `${s}e` as const,\n\t\t\t\ts => `${s}f` as const\n\t\t\t)\n\t\t\tattest<\"abcdef\">(T.infer)\n\t\t\tattest(T(\"a\")).equals(\"abcdef\")\n\t\t})\n\n\t\tit(\"7-ary\", () => {\n\t\t\tconst T = type.pipe(\n\t\t\t\ttype.unit(\"a\"),\n\t\t\t\ts => `${s}b` as const,\n\t\t\t\ts => `${s}c` as const,\n\t\t\t\ts => `${s}d` as const,\n\t\t\t\ts => `${s}e` as const,\n\t\t\t\ts => `${s}f` as const,\n\t\t\t\ts => `${s}g` as const\n\t\t\t)\n\t\t\tattest<\"abcdefg\">(T.infer)\n\t\t\tattest(T(\"a\")).equals(\"abcdefg\")\n\t\t})\n\n\t\tit(\"8-ary\", () => {\n\t\t\tconst T = type.pipe(\n\t\t\t\ttype.unit(\"a\"),\n\t\t\t\ts => `${s}b` as const,\n\t\t\t\ts => `${s}c` as const,\n\t\t\t\ts => `${s}d` as const,\n\t\t\t\ts => `${s}e` as const,\n\t\t\t\ts => `${s}f` as const,\n\t\t\t\ts => `${s}g` as const,\n\t\t\t\ts => `${s}h` as const\n\t\t\t)\n\t\t\tattest<\"abcdefgh\">(T.infer)\n\t\t\tattest(T(\"a\")).equals(\"abcdefgh\")\n\t\t})\n\n\t\tit(\"9-ary\", () => {\n\t\t\tconst T = type.pipe(\n\t\t\t\ttype.unit(\"a\"),\n\t\t\t\ts => `${s}b` as const,\n\t\t\t\ts => `${s}c` as const,\n\t\t\t\ts => `${s}d` as const,\n\t\t\t\ts => `${s}e` as const,\n\t\t\t\ts => `${s}f` as const,\n\t\t\t\ts => `${s}g` as const,\n\t\t\t\ts => `${s}h` as const,\n\t\t\t\ts => `${s}i` as const\n\t\t\t)\n\t\t\tattest<\"abcdefghi\">(T.infer)\n\t\t\tattest(T(\"a\")).equals(\"abcdefghi\")\n\t\t})\n\n\t\tit(\"10-ary\", () => {\n\t\t\tconst T = type.pipe(\n\t\t\t\ttype.unit(\"a\"),\n\t\t\t\ts => `${s}b` as const,\n\t\t\t\ts => `${s}c` as const,\n\t\t\t\ts => `${s}d` as const,\n\t\t\t\ts => `${s}e` as const,\n\t\t\t\ts => `${s}f` as const,\n\t\t\t\ts => `${s}g` as const,\n\t\t\t\ts => `${s}h` as const,\n\t\t\t\ts => `${s}i` as const,\n\t\t\t\ts => `${s}j` as const\n\t\t\t)\n\t\t\tattest<\"abcdefghij\">(T.infer)\n\t\t\tattest(T(\"a\")).equals(\"abcdefghij\")\n\t\t})\n\n\t\tit(\"11-ary\", () => {\n\t\t\tconst T = type.pipe(\n\t\t\t\ttype.unit(\"a\"),\n\t\t\t\ts => `${s}b` as const,\n\t\t\t\ts => `${s}c` as const,\n\t\t\t\ts => `${s}d` as const,\n\t\t\t\ts => `${s}e` as const,\n\t\t\t\ts => `${s}f` as const,\n\t\t\t\ts => `${s}g` as const,\n\t\t\t\ts => `${s}h` as const,\n\t\t\t\ts => `${s}i` as const,\n\t\t\t\ts => `${s}j` as const,\n\t\t\t\ts => `${s}k` as const\n\t\t\t)\n\t\t\tattest<\"abcdefghijk\">(T.infer)\n\t\t\tattest(T(\"a\")).equals(\"abcdefghijk\")\n\t\t})\n\n\t\tit(\"12-ary\", () => {\n\t\t\tconst T = type.pipe(\n\t\t\t\ttype.unit(\"a\"),\n\t\t\t\ts => `${s}b` as const,\n\t\t\t\ts => `${s}c` as const,\n\t\t\t\ts => `${s}d` as const,\n\t\t\t\ts => `${s}e` as const,\n\t\t\t\ts => `${s}f` as const,\n\t\t\t\ts => `${s}g` as const,\n\t\t\t\ts => `${s}h` as const,\n\t\t\t\ts => `${s}i` as const,\n\t\t\t\ts => `${s}j` as const,\n\t\t\t\ts => `${s}k` as const,\n\t\t\t\ts => `${s}l` as const\n\t\t\t)\n\t\t\tattest<\"abcdefghijkl\">(T.infer)\n\t\t\tattest(T(\"a\")).equals(\"abcdefghijkl\")\n\t\t})\n\n\t\tit(\"13-ary\", () => {\n\t\t\tconst T = type.pipe(\n\t\t\t\ttype.unit(\"a\"),\n\t\t\t\ts => `${s}b` as const,\n\t\t\t\ts => `${s}c` as const,\n\t\t\t\ts => `${s}d` as const,\n\t\t\t\ts => `${s}e` as const,\n\t\t\t\ts => `${s}f` as const,\n\t\t\t\ts => `${s}g` as const,\n\t\t\t\ts => `${s}h` as const,\n\t\t\t\ts => `${s}i` as const,\n\t\t\t\ts => `${s}j` as const,\n\t\t\t\ts => `${s}k` as const,\n\t\t\t\ts => `${s}l` as const,\n\t\t\t\ts => `${s}m` as const\n\t\t\t)\n\t\t\tattest<\"abcdefghijklm\">(T.infer)\n\t\t\tattest(T(\"a\")).equals(\"abcdefghijklm\")\n\t\t})\n\n\t\tit(\"14-ary\", () => {\n\t\t\tconst T = type.pipe(\n\t\t\t\ttype.unit(\"a\"),\n\t\t\t\ts => `${s}b` as const,\n\t\t\t\ts => `${s}c` as const,\n\t\t\t\ts => `${s}d` as const,\n\t\t\t\ts => `${s}e` as const,\n\t\t\t\ts => `${s}f` as const,\n\t\t\t\ts => `${s}g` as const,\n\t\t\t\ts => `${s}h` as const,\n\t\t\t\ts => `${s}i` as const,\n\t\t\t\ts => `${s}j` as const,\n\t\t\t\ts => `${s}k` as const,\n\t\t\t\ts => `${s}l` as const,\n\t\t\t\ts => `${s}m` as const,\n\t\t\t\ts => `${s}n` as const\n\t\t\t)\n\t\t\tattest<\"abcdefghijklmn\">(T.infer)\n\t\t\tattest(T(\"a\")).equals(\"abcdefghijklmn\")\n\t\t})\n\n\t\tit(\"15-ary\", () => {\n\t\t\tconst T = type.pipe(\n\t\t\t\ttype.unit(\"a\"),\n\t\t\t\ts => `${s}b` as const,\n\t\t\t\ts => `${s}c` as const,\n\t\t\t\ts => `${s}d` as const,\n\t\t\t\ts => `${s}e` as const,\n\t\t\t\ts => `${s}f` as const,\n\t\t\t\ts => `${s}g` as const,\n\t\t\t\ts => `${s}h` as const,\n\t\t\t\ts => `${s}i` as const,\n\t\t\t\ts => `${s}j` as const,\n\t\t\t\ts => `${s}k` as const,\n\t\t\t\ts => `${s}l` as const,\n\t\t\t\ts => `${s}m` as const,\n\t\t\t\ts => `${s}n` as const,\n\t\t\t\ts => `${s}o` as const\n\t\t\t)\n\t\t\tattest<\"abcdefghijklmno\">(T.infer)\n\t\t\tattest(T(\"a\")).equals(\"abcdefghijklmno\")\n\t\t})\n\n\t\tit(\"16-ary\", () => {\n\t\t\tconst T = type.pipe(\n\t\t\t\ttype.unit(\"a\"),\n\t\t\t\ts => `${s}b` as const,\n\t\t\t\ts => `${s}c` as const,\n\t\t\t\ts => `${s}d` as const,\n\t\t\t\ts => `${s}e` as const,\n\t\t\t\ts => `${s}f` as const,\n\t\t\t\ts => `${s}g` as const,\n\t\t\t\ts => `${s}h` as const,\n\t\t\t\ts => `${s}i` as const,\n\t\t\t\ts => `${s}j` as const,\n\t\t\t\ts => `${s}k` as const,\n\t\t\t\ts => `${s}l` as const,\n\t\t\t\ts => `${s}m` as const,\n\t\t\t\ts => `${s}n` as const,\n\t\t\t\ts => `${s}o` as const,\n\t\t\t\ts => `${s}p` as const\n\t\t\t)\n\t\t\tattest<\"abcdefghijklmnop\">(T.infer)\n\t\t\tattest(T(\"a\")).equals(\"abcdefghijklmnop\")\n\t\t})\n\n\t\tit(\"nary\", () => {\n\t\t\tconst T = type.pipe(\n\t\t\t\ttype.unit(\"a\"),\n\t\t\t\ts => `${s}b` as const,\n\t\t\t\ts => `${s}c` as const,\n\t\t\t\ts => `${s}d` as const,\n\t\t\t\ts => `${s}e` as const,\n\t\t\t\ts => `${s}f` as const,\n\t\t\t\ts => `${s}g` as const,\n\t\t\t\ts => `${s}h` as const,\n\t\t\t\ts => `${s}i` as const,\n\t\t\t\ts => `${s}j` as const,\n\t\t\t\ts => `${s}k` as const,\n\t\t\t\ts => `${s}l` as const,\n\t\t\t\ts => `${s}m` as const,\n\t\t\t\ts => `${s}n` as const,\n\t\t\t\ts => `${s}o` as const,\n\t\t\t\ts => `${s}p` as const,\n\t\t\t\ts => `${s}q` as const\n\t\t\t)\n\t\t\tattest<\"abcdefghijklmnopq\">(T.infer)\n\t\t\tattest(T(\"a\")).equals(\"abcdefghijklmnopq\")\n\t\t})\n\n\t\tit(\"spreadable as Types\", () => {\n\t\t\tconst types: type[] = []\n\n\t\t\tconst T = type.pipe(...types)\n\n\t\t\tattest<unknown>(T.t)\n\t\t\tattest(T.expression).snap(\"unknown\")\n\t\t})\n\n\t\tit(\"spreadable as Morphs\", () => {\n\t\t\tconst morphs: Morph[] = []\n\n\t\t\tconst T = type.pipe(...morphs)\n\n\t\t\tattest<unknown>(T.t)\n\t\t\tattest(T.expression).snap(\"unknown\")\n\t\t})\n\t})\n\n\tit(\"handles base scopes correctly\", () => {\n\t\t// previously errored here because after the first intersection, this was a SchemaScope\n\t\tconst T = type.and({ a1: \"1\" }).and({ a2: \"2\" })\n\n\t\tattest(T.expression).snap(\"{ a1: 1, a2: 2 }\")\n\t\tattest(T.$.internal.name).snap(\"ark\")\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/object.bench.ts",
    "content": "import { bench } from \"@ark/attest\"\nimport { type } from \"arktype\"\n\nbench.baseline(() => {\n\ttype({\n\t\t_: \"symbol[]\",\n\t\t__: { ___: \"symbol[]\" }\n\t})\n\n\ttype([\"symbol[]\", \"symbol[]\", [\"symbol[]\"]])\n})\n\nbench(\"object literal\", () =>\n\ttype({\n\t\ta: \"string[]\",\n\t\tb: \"number[]\",\n\t\tc: { nested: \"boolean[]\" }\n\t})\n).types([2227, \"instantiations\"])\n\nbench(\"declared object literal\", () => {\n\ttype\n\t\t.declare<{\n\t\t\ta: string[]\n\t\t\tb: number[]\n\t\t\tc: {\n\t\t\t\tnested: boolean[]\n\t\t\t}\n\t\t}>()\n\t\t.type({\n\t\t\ta: \"string[]\",\n\t\t\tb: \"number[]\",\n\t\t\tc: { nested: \"boolean[]\" }\n\t\t})\n}).types([3870, \"instantiations\"])\n\nbench(\"object literal with optional keys\", () =>\n\ttype({\n\t\t\"a?\": \"string[]\",\n\t\t\"b?\": \"number[]\",\n\t\t\"c?\": { \"nested?\": \"boolean[]\" }\n\t})\n).types([2052, \"instantiations\"])\n\nbench(\"tuple\", () => type([\"string[]\", \"number[]\", [\"boolean[]\"]])).types([\n\t2703,\n\t\"instantiations\"\n])\n\nbench(\"inline definition\", () =>\n\ttype({\n\t\ta: \"string\"\n\t})\n).types([757, \"instantiations\"])\n\nbench(\"referenced type\", () => {\n\tconst A = type(\"string\")\n\treturn type({\n\t\tA\n\t})\n}).types([942, \"instantiations\"])\n\n// https://github.com/arktypeio/arktype/issues/787\nbench(\"inline reference\", () =>\n\ttype({\n\t\ta: type(\"string\")\n\t})\n).types([958, \"instantiations\"])\n\nbench(\"nested type invocations\", () =>\n\ttype({\n\t\tfoo: type({\n\t\t\tbar: type({\n\t\t\t\tzoo: \"string[]\"\n\t\t\t})\n\t\t\t\t.array()\n\t\t\t\t.or(\"number\"),\n\t\t\tsuperBar: type([\n\t\t\t\ttype(\"string\"),\n\t\t\t\ttype(\"number[]\"),\n\t\t\t\ttype({ inner: type(\"boolean\") })\n\t\t\t])\n\t\t})\n\t\t\t.or({\n\t\t\t\tbaz: \"string\",\n\t\t\t\tquux: \"1 | 2 | 3\"\n\t\t\t})\n\t\t\t.array()\n\t})\n).types([9036, \"instantiations\"])\n"
  },
  {
    "path": "ark/type/__tests__/objects/defaults.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport {\n\tregisteredReference,\n\twriteNonPrimitiveNonFunctionDefaultValueMessage\n} from \"@ark/schema\"\nimport { deepClone } from \"@ark/util\"\nimport { scope, type } from \"arktype\"\nimport type { Default, Out, To } from \"arktype/internal/attributes.ts\"\nimport { shallowDefaultableMessage } from \"arktype/internal/parser/ast/validate.ts\"\nimport { invalidDefaultableKeyKindMessage } from \"arktype/internal/parser/property.ts\"\nimport { writeNonLiteralDefaultMessage } from \"arktype/internal/parser/shift/operator/default.ts\"\nimport { writeUnexpectedCharacterMessage } from \"arktype/internal/parser/shift/operator/operator.ts\"\n\ncontextualize(() => {\n\tdescribe(\"parsing and traversal\", () => {\n\t\tit(\"base\", () => {\n\t\t\tconst fnDefaultTo5 = () => 5 as const\n\t\t\tconst O = type({\n\t\t\t\ta: \"string\",\n\t\t\t\tfoo: \"number = 5\",\n\t\t\t\tbar: [\"number\", \"=\", 5],\n\t\t\t\tbaz: [\"number\", \"=\", fnDefaultTo5]\n\t\t\t})\n\n\t\t\tattest(O.t).type.toString.snap(`{\n\ta: string\n\tfoo: Default<number, 5>\n\tbar: Default<number, 5>\n\tbaz: Default<number, 5>\n}`)\n\t\t\tattest<{\n\t\t\t\ta: string\n\t\t\t\tfoo?: number\n\t\t\t\tbar?: number\n\t\t\t\tbaz?: number\n\t\t\t}>(O.inferIn)\n\t\t\tattest<{ a: string; foo: number; bar: number; baz: number }>(O.infer)\n\n\t\t\tattest(O.json).snap({\n\t\t\t\trequired: [{ key: \"a\", value: \"string\" }],\n\t\t\t\toptional: [\n\t\t\t\t\t{ default: \"$ark.fnDefaultTo5\", key: \"baz\", value: \"number\" },\n\t\t\t\t\t{ default: 5, key: \"bar\", value: \"number\" },\n\t\t\t\t\t{ default: 5, key: \"foo\", value: \"number\" }\n\t\t\t\t],\n\t\t\t\tdomain: \"object\"\n\t\t\t})\n\n\t\t\tattest(O({ a: \"\", foo: 4, bar: 4, baz: 4 })).equals({\n\t\t\t\ta: \"\",\n\t\t\t\tfoo: 4,\n\t\t\t\tbar: 4,\n\t\t\t\tbaz: 4\n\t\t\t})\n\t\t\tattest(O({ a: \"\" })).equals({ a: \"\", foo: 5, bar: 5, baz: 5 })\n\t\t\tattest(O({ bar: 4 }).toString()).snap(\"a must be a string (was missing)\")\n\t\t\tattest(O({ a: \"\", bar: \"\" }).toString()).snap(\n\t\t\t\t\"bar must be a number (was a string)\"\n\t\t\t)\n\t\t})\n\n\t\t// https://github.com/arktypeio/arktype/issues/1335\n\t\tit(\"jitless\", () => {\n\t\t\tconst types = type.module(\n\t\t\t\t{\n\t\t\t\t\tfoo: {\n\t\t\t\t\t\ttest: \"string = 'test'\"\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{ jitless: true }\n\t\t\t)\n\n\t\t\tattest(types.foo({})).equals({ test: \"test\" })\n\t\t\tattest(types.foo({ test: \"provided\" })).equals({ test: \"provided\" })\n\t\t})\n\n\t\tit(\"unions are defaultable\", () => {\n\t\t\tconst O = type({\n\t\t\t\tboo: \"boolean = false\"\n\t\t\t})\n\t\t\t// this should not distribute to Default<true, true> | Default<false, true>\n\t\t\tattest(O).type.toString.snap(\"Type<{ boo: Default<boolean, false> }, {}>\")\n\t\t\tattest(O.json).snap({\n\t\t\t\toptional: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdefault: false,\n\t\t\t\t\t\tkey: \"boo\",\n\t\t\t\t\t\tvalue: [{ unit: false }, { unit: true }]\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\tdomain: \"object\"\n\t\t\t})\n\n\t\t\tattest(O({})).snap({ boo: false })\n\t\t\tattest(O({ boo: true })).snap({ boo: true })\n\t\t\tattest(O({ boo: 5 }).toString()).snap(\"boo must be boolean (was 5)\")\n\t\t})\n\n\t\tit(\"validated default in scope\", () => {\n\t\t\tconst types = scope({\n\t\t\t\tspecialNumber: \"number\",\n\t\t\t\tstringDefault: { foo: \"string\", bar: \"specialNumber = 5\" },\n\t\t\t\ttupleDefault: { foo: \"string\", bar: [\"specialNumber\", \"=\", 5] }\n\t\t\t}).export()\n\n\t\t\tattest<{\n\t\t\t\tfoo: string\n\t\t\t\tbar: Default<number, 5>\n\t\t\t}>(types.stringDefault.t)\n\n\t\t\tattest<typeof types.stringDefault.t>(types.tupleDefault.t)\n\n\t\t\tattest(types.stringDefault.json).snap({\n\t\t\t\trequired: [{ key: \"foo\", value: \"string\" }],\n\t\t\t\toptional: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdefault: 5,\n\t\t\t\t\t\tkey: \"bar\",\n\t\t\t\t\t\tvalue: \"number\"\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\tdomain: \"object\"\n\t\t\t})\n\n\t\t\tattest(types.tupleDefault.json).equals(types.stringDefault.json)\n\t\t})\n\n\t\tit(\"no shallow default in tuple expression\", () => {\n\t\t\tattest(() =>\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttype([\"string = 'foo'\", \"|\", \"number\"])\n\t\t\t).throwsAndHasTypeError(shallowDefaultableMessage)\n\n\t\t\tattest(() =>\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttype([\"string\", \"|\", [\"number\", \"=\", 5]])\n\t\t\t).throwsAndHasTypeError(shallowDefaultableMessage)\n\t\t})\n\n\t\tit(\"no shallow default in scope\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type.module({ foo: \"string = ''\" })).throwsAndHasTypeError(\n\t\t\t\tshallowDefaultableMessage\n\t\t\t)\n\n\t\t\tattest(() =>\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttype.module({ foo: [\"string\", \"=\", \"\"] })\n\t\t\t).throwsAndHasTypeError(shallowDefaultableMessage)\n\t\t})\n\n\t\tit(\"chained\", () => {\n\t\t\tconst DefaultedString = type(\"string\").default(\"\")\n\t\t\tattest(DefaultedString).type.toString.snap('[Type<string, {}>, \"=\", \"\"]')\n\n\t\t\tconst O = type({ a: DefaultedString })\n\t\t\tattest(O.t).type.toString.snap('{ a: Default<string, \"\"> }')\n\t\t\tattest<{ a?: string }>(O.inferIn)\n\t\t\tattest<{ a: string }>(O.infer)\n\t\t\tattest(O.json).snap({\n\t\t\t\toptional: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdefault: \"\",\n\t\t\t\t\t\tkey: \"a\",\n\t\t\t\t\t\tvalue: \"string\"\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\tdomain: \"object\"\n\t\t\t})\n\t\t})\n\n\t\tit(\"unassignable default tuple\", () => {\n\t\t\tattest(() =>\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttype({ foo: \"string\", bar: [\"number\", \"=\", \"5\"] })\n\t\t\t)\n\t\t\t\t.throws.snap(\n\t\t\t\t\t\"ParseError: Default for bar must be a number (was a string)\"\n\t\t\t\t)\n\t\t\t\t.type.errors(\n\t\t\t\t\t\"Type 'string' is not assignable to type 'defaultFor<number>'.\"\n\t\t\t\t)\n\t\t})\n\n\t\tit(\"unassignable default thunk tuple\", () => {\n\t\t\tattest(() =>\n\t\t\t\ttype({\n\t\t\t\t\tfoo: [\n\t\t\t\t\t\t{ foo: \"true\" },\n\t\t\t\t\t\t\"=\",\n\t\t\t\t\t\t() => ({\n\t\t\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\t\tfoo: false\n\t\t\t\t\t\t})\n\t\t\t\t\t]\n\t\t\t\t})\n\t\t\t)\n\t\t\t\t.throws.snap(\"ParseError: Default for foo.foo must be true (was false)\")\n\t\t\t\t.type.errors.snap(\"Type 'false' is not assignable to type 'true'.\")\n\t\t})\n\n\t\tit(\"unassignable default string\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type({ foo: \"number = true\" }))\n\t\t\t\t.throws.snap(\n\t\t\t\t\t\"ParseError: Default for foo must be a number (was boolean)\"\n\t\t\t\t)\n\t\t\t\t.type.errors(\"Default value true must be assignable to number\")\n\t\t})\n\n\t\tit(\"morphed\", () => {\n\t\t\t// https://discord.com/channels/957797212103016458/1280932672029593811/1283368602355109920\n\t\t\tconst ProcessForm = type({\n\t\t\t\tbool_value: type(\"string\")\n\t\t\t\t\t.pipe(v => (v === \"on\" ? true : false))\n\t\t\t\t\t.default(\"off\")\n\t\t\t})\n\n\t\t\tattest<{\n\t\t\t\tbool_value: (In: Default<string, \"off\">) => Out<boolean>\n\t\t\t}>(ProcessForm.t)\n\n\t\t\tattest<{\n\t\t\t\t// key should still be distilled as optional even inside a morph\n\t\t\t\tbool_value?: string\n\t\t\t}>(ProcessForm.inferIn)\n\t\t\tattest<{\n\t\t\t\tbool_value: boolean\n\t\t\t}>(ProcessForm.infer)\n\n\t\t\tconst out = ProcessForm({})\n\n\t\t\tattest(out).snap({ bool_value: false })\n\n\t\t\tattest(ProcessForm({ bool_value: \"on\" })).snap({ bool_value: true })\n\n\t\t\tattest(ProcessForm({ bool_value: true }).toString()).snap(\n\t\t\t\t\"bool_value must be a string (was boolean)\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"primitive morph precomputed\", () => {\n\t\t\tlet callCount = 0\n\n\t\t\tconst toggle = (b: boolean) => {\n\t\t\t\tcallCount++\n\t\t\t\treturn !b\n\t\t\t}\n\n\t\t\tconst toggleRef = registeredReference(toggle)\n\n\t\t\tconst T = type({\n\t\t\t\tblep: type(\"boolean\").pipe(toggle).default(false)\n\t\t\t})\n\n\t\t\tattest(T.t).type.toString.snap(`{\n\tblep: (In: Default<boolean, false>) => Out<boolean>\n}`)\n\n\t\t\tattest(T.json).snap({\n\t\t\t\toptional: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdefault: false,\n\t\t\t\t\t\tkey: \"blep\",\n\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\tin: [{ unit: false }, { unit: true }],\n\t\t\t\t\t\t\tmorphs: [toggleRef]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\tdomain: \"object\"\n\t\t\t})\n\n\t\t\tconst out = T({})\n\n\t\t\tattest(out).snap({ blep: true })\n\t\t\tattest(callCount).equals(1)\n\n\t\t\tT({})\n\t\t\tattest(callCount).equals(1)\n\t\t})\n\n\t\tit(\"default preserved on pipe to node\", () => {\n\t\t\tlet callCount = 0\n\n\t\t\tconst toggle = (b: boolean) => {\n\t\t\t\tcallCount++\n\t\t\t\treturn !b\n\t\t\t}\n\n\t\t\tconst toggleRef = registeredReference(toggle)\n\n\t\t\tconst T = type({\n\t\t\t\tblep: type(\"boolean\").pipe(toggle).to(\"boolean\").default(false)\n\t\t\t})\n\n\t\t\tattest(T.t).type.toString.snap(`{\n\tblep: (In: Default<boolean, false>) => To<boolean>\n}`)\n\n\t\t\tattest(T.json).snap({\n\t\t\t\toptional: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdefault: false,\n\t\t\t\t\t\tkey: \"blep\",\n\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\tin: [{ unit: false }, { unit: true }],\n\t\t\t\t\t\t\tmorphs: [toggleRef, [{ unit: false }, { unit: true }]]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\tdomain: \"object\"\n\t\t\t})\n\n\t\t\tconst out = T({})\n\n\t\t\tattest(out).snap({ blep: true })\n\t\t\tattest(callCount).equals(1)\n\n\t\t\tT({})\n\t\t\tattest(callCount).equals(1)\n\t\t})\n\n\t\tit(\"primitive morphed to object not premorphed\", () => {\n\t\t\tconst T = type({\n\t\t\t\tfoo: type(\"string\")\n\t\t\t\t\t.pipe(s => ({ nest: s }))\n\t\t\t\t\t.default(\"foo\")\n\t\t\t})\n\t\t\tattest<{\n\t\t\t\tfoo: (In: Default<string, \"foo\">) => Out<{\n\t\t\t\t\tnest: string\n\t\t\t\t}>\n\t\t\t}>(T.t)\n\n\t\t\tconst out = T.assert({})\n\n\t\t\tattest(out).snap({ foo: { nest: \"foo\" } })\n\n\t\t\tconst originalOut = deepClone(out)\n\n\t\t\tout.foo.nest = \"baz\"\n\n\t\t\tattest(T({})).equals(originalOut)\n\t\t})\n\t})\n\n\tdescribe(\"string parsing\", () => {\n\t\tit(\"number\", () => {\n\t\t\tconst T = type({ key: \"number = 42\" })\n\t\t\tconst Expected = type({ key: [\"number\", \"=\", 42] })\n\n\t\t\tattest<typeof Expected>(T)\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"bigint\", () => {\n\t\t\tconst T = type({ key: \"bigint = 100n\" })\n\t\t\tconst Expected = type({ key: [\"bigint\", \"=\", 100n] })\n\n\t\t\tattest<typeof Expected>(T)\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"string\", () => {\n\t\t\tconst T = type({ key: 'string = \"default value\"' })\n\t\t\tconst Expected = type({ key: [\"string\", \"=\", \"default value\"] })\n\n\t\t\tattest<typeof Expected>(T)\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"Date\", () => {\n\t\t\tconst T = type({ key: 'Date = d\"1993-05-21\"' })\n\n\t\t\tconst out = T.assert({})\n\n\t\t\tattest(out.key.toISOString()).snap(\"1993-05-21T00:00:00.000Z\")\n\n\t\t\t// we can't check expected here since the Date instance will not\n\t\t\t// have a narrowed literal type\n\t\t\tattest<{\n\t\t\t\tkey: Default<Date, Date>\n\t\t\t}>(T.t)\n\t\t})\n\n\t\tit(\"Date is immutable\", () => {\n\t\t\tconst T = type({ date: 'Date = d\"1993-05-21\"' })\n\t\t\tconst v1 = T.assert({})\n\t\t\tconst time = v1.date.getTime()\n\t\t\tv1.date.setMilliseconds(123)\n\t\t\tconst v2 = T.assert({})\n\t\t\tattest(v2.date.getTime()).equals(time)\n\t\t})\n\n\t\tit(\"true\", () => {\n\t\t\tconst T = type({ key: \"boolean = true\" })\n\t\t\tconst Expected = type({ key: [\"boolean\", \"=\", true] })\n\n\t\t\tattest<typeof Expected>(T)\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"false\", () => {\n\t\t\tconst T = type({ key: \"boolean = false\" })\n\t\t\tconst Expected = type({ key: [\"boolean\", \"=\", false] })\n\n\t\t\tattest<typeof Expected>(T)\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"null\", () => {\n\t\t\t// ideally we could infer a better type here,\n\t\t\t// but attaching attributes to null or undefined\n\t\t\t// is not possible with the current design\n\t\t\tconst T = type({ key: \"object | null = null\" })\n\t\t\tconst Expected = type({ key: [\"object | null\", \"=\", null] })\n\n\t\t\tattest<typeof Expected>(T)\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"undefined\", () => {\n\t\t\tconst T = type({ key: \"unknown = undefined\" })\n\t\t\tconst Expected = type({ key: [\"unknown\", \"=\", undefined] })\n\n\t\t\tattest(T({})).snap({ key: undefined })\n\n\t\t\tattest<typeof Expected>(T)\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"incorrect default type\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type({ foo: \"string\", bar: \"number = true\" }))\n\t\t\t\t.throws.snap(\n\t\t\t\t\t\"ParseError: Default for bar must be a number (was boolean)\"\n\t\t\t\t)\n\t\t\t\t.type.errors(\"Default value true must be assignable to number\")\n\t\t})\n\n\t\tit(\"non-literal\", () => {\n\t\t\tattest(() =>\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttype({ foo: \"string\", bar: \"unknown = number\" })\n\t\t\t).throwsAndHasTypeError(writeNonLiteralDefaultMessage(\"number\"))\n\t\t})\n\n\t\tit(\"validated default in scope\", () => {\n\t\t\tconst $ = scope({\n\t\t\t\tspecialNumber: \"number\",\n\t\t\t\tobj: { foo: \"string\", bar: \"specialNumber = 5\" }\n\t\t\t})\n\n\t\t\t$.export()\n\n\t\t\tattest($.json).snap({\n\t\t\t\tspecialNumber: {\n\t\t\t\t\tdomain: \"number\"\n\t\t\t\t},\n\t\t\t\tobj: {\n\t\t\t\t\trequired: [{ key: \"foo\", value: \"string\" }],\n\t\t\t\t\toptional: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdefault: 5,\n\t\t\t\t\t\t\tkey: \"bar\",\n\t\t\t\t\t\t\tvalue: \"number\"\n\t\t\t\t\t\t}\n\t\t\t\t\t],\n\t\t\t\t\tdomain: \"object\"\n\t\t\t\t}\n\t\t\t})\n\t\t})\n\n\t\tit(\"optional with default\", () => {\n\t\t\tattest(() =>\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttype({ foo: \"string\", \"bar?\": \"number = 5\" })\n\t\t\t).throwsAndHasTypeError(invalidDefaultableKeyKindMessage)\n\n\t\t\tattest(() =>\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttype({ foo: \"string\", \"bar?\": [\"number\", \"=\", 5] })\n\t\t\t).throwsAndHasTypeError(invalidDefaultableKeyKindMessage)\n\t\t})\n\n\t\tit(\"index with default\", () => {\n\t\t\tattest(() =>\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttype({ foo: \"string\", \"[string]\": \"number = 5\" })\n\t\t\t).throwsAndHasTypeError(invalidDefaultableKeyKindMessage)\n\n\t\t\tattest(() =>\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttype({ foo: \"string\", \"[string]\": [\"number\", \"=\", 5] })\n\t\t\t).throwsAndHasTypeError(invalidDefaultableKeyKindMessage)\n\t\t})\n\n\t\tit(\"shallow default\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"string='foo'\")).throwsAndHasTypeError(\n\t\t\t\tshallowDefaultableMessage\n\t\t\t)\n\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type([\"string\", \"=\", \"foo\"])).throwsAndHasTypeError(\n\t\t\t\tshallowDefaultableMessage\n\t\t\t)\n\t\t})\n\n\t\tit(\"defaultable input extracted as optional\", () => {\n\t\t\tconst T = type({ foo: \"number = 0\" })\n\t\t\tattest<{ foo?: number }>(T.in.t)\n\t\t\tattest<{ foo?: number }>(T.inferIn)\n\n\t\t\tattest(T.in.expression).snap(\"{ foo?: number }\")\n\t\t})\n\n\t\tit(\"defaultable output extracted as required\", () => {\n\t\t\tconst T = type({ foo: \"number = 0\" })\n\t\t\tattest<{ foo: number }>(T.out.t)\n\t\t\tattest<{ foo: number }>(T.inferOut)\n\n\t\t\tattest(T.out.expression).snap(\"{ foo: number }\")\n\t\t})\n\n\t\t// https://github.com/arktypeio/arktype/issues/1507\n\t\tit(\"fails on expression value\", () => {\n\t\t\tattest(() =>\n\t\t\t\ttype({\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\ttest: \"'y' | 'n' = 'n' |> 'y'\"\n\t\t\t\t})\n\t\t\t)\n\t\t\t\t.throws(writeUnexpectedCharacterMessage(\"|\"))\n\t\t\t\t.type.errors(writeNonLiteralDefaultMessage(\"'n' |> 'y'\"))\n\t\t})\n\t})\n\n\tdescribe(\"works properly with types\", () => {\n\t\tit(\"allows primitives and factories for anys\", () => {\n\t\t\tconst fn = () => {}\n\t\t\tconst T = type({\n\t\t\t\tfoo1: [\"unknown\", \"=\", true],\n\t\t\t\tbar1: [\"unknown\", \"=\", () => [true]],\n\t\t\t\tbaz1: [\"unknown\", \"=\", () => fn],\n\t\t\t\tfoo2: [\"unknown.any\", \"=\", true],\n\t\t\t\tbar2: [\"unknown.any\", \"=\", () => [true]],\n\t\t\t\tbaz2: [\"unknown.any\", \"=\", () => fn]\n\t\t\t})\n\t\t\tconst out = T.assert({})\n\t\t\tattest(out).snap({\n\t\t\t\tfoo1: true,\n\t\t\t\tbar1: [true],\n\t\t\t\tbaz1: fn,\n\t\t\t\tfoo2: true,\n\t\t\t\tbar2: [true],\n\t\t\t\tbaz2: fn\n\t\t\t})\n\t\t})\n\t\tit(\"disallows plain objects for anys\", () => {\n\t\t\tattest(() => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttype({ foo: [\"unknown\", \"=\", { foo: \"bar\" }] })\n\t\t\t})\n\t\t\t\t.throws(writeNonPrimitiveNonFunctionDefaultValueMessage(\"foo\"))\n\t\t\t\t.type.errors(\"'foo' does not exist in type '() => unknown'.\")\n\n\t\t\tattest(() => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttype({ foo: [\"unknown.any\", \"=\", { foo: \"bar\" }] })\n\t\t\t})\n\t\t\t\t.throws(writeNonPrimitiveNonFunctionDefaultValueMessage(\"foo\"))\n\t\t\t\t.type.errors(\"'foo' does not exist in type '() => any'.\")\n\t\t})\n\n\t\tit(\"allows string subtyping\", () => {\n\t\t\ttype({\n\t\t\t\tfoo: [/^foo/ as type.cast<`foo${string}`>, \"=\", \"foobar\"],\n\t\t\t\tbar: [/bar$/ as type.cast<`${string}bar`>, \"=\", () => \"foobar\" as const]\n\t\t\t})\n\t\t})\n\n\t\tdescribe(\"bad values\", () => {\n\t\t\tit(\"primitive\", () => {\n\t\t\t\tattest(\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t() => type({ foo: [\"number\", \"=\", true] })\n\t\t\t\t)\n\t\t\t\t\t.throws.snap(\n\t\t\t\t\t\t\"ParseError: Default for foo must be a number (was boolean)\"\n\t\t\t\t\t)\n\t\t\t\t\t.type.errors.snap(\n\t\t\t\t\t\t\"Type 'boolean' is not assignable to type 'defaultFor<number>'.\"\n\t\t\t\t\t)\n\t\t\t})\n\n\t\t\tit(\"array\", () => {\n\t\t\t\tattest(\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t() => type({ foo: [\"number[]\", \"=\", true] })\n\t\t\t\t)\n\t\t\t\t\t.throws.snap(\n\t\t\t\t\t\t\"ParseError: Default for foo must be an array (was boolean)\"\n\t\t\t\t\t)\n\t\t\t\t\t.type.errors.snap(\n\t\t\t\t\t\t\"Type 'boolean' is not assignable to type '() => number[]'.\"\n\t\t\t\t\t)\n\t\t\t})\n\n\t\t\tit(\"object\", () => {\n\t\t\t\tattest(\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t() => type({ foo: [{ bar: \"false\" }, \"=\", true] })\n\t\t\t\t)\n\t\t\t\t\t.throws.snap(\n\t\t\t\t\t\t\"ParseError: Default for foo must be an object (was boolean)\"\n\t\t\t\t\t)\n\t\t\t\t\t.type.errors.snap(\n\t\t\t\t\t\t\"Type 'boolean' is not assignable to type '() => { bar: false; }'.\"\n\t\t\t\t\t)\n\t\t\t})\n\n\t\t\tit(\"union\", () => {\n\t\t\t\tattest(\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t() => type({ foo: [[\"number[]\", \"|\", \"string\"], \"=\", true] })\n\t\t\t\t)\n\t\t\t\t\t.throws.snap(\n\t\t\t\t\t\t\"ParseError: Default for foo must be a string or an object (was boolean)\"\n\t\t\t\t\t)\n\t\t\t\t\t.type.errors.snap(\n\t\t\t\t\t\t\"Type 'boolean' is not assignable to type 'defaultFor<string | number[]>'.\"\n\t\t\t\t\t)\n\t\t\t})\n\n\t\t\tit(\"union with default\", () => {\n\t\t\t\t// should not cause \"instantiation is excessively deep\"\n\t\t\t\tattest(\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t() => type(\"number[]\", \"|\", \"string\").default(true)\n\t\t\t\t)\n\t\t\t\t\t.throws.snap(\n\t\t\t\t\t\t\"ParseError: Default must be a string or an object (was boolean)\"\n\t\t\t\t\t)\n\t\t\t\t\t.type.errors.snap(\n\t\t\t\t\t\t\"Argument of type 'boolean' is not assignable to parameter of type 'defaultFor<string | number[]>'.\"\n\t\t\t\t\t)\n\t\t\t})\n\n\t\t\tit(\"union with default function\", () => {\n\t\t\t\t// should not cause \"instantiation is excessively deep\"\n\t\t\t\tattest(\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t() => type(\"number[]\", \"|\", \"string\").default(() => true)\n\t\t\t\t)\n\t\t\t\t\t.throws.snap(\n\t\t\t\t\t\t\"ParseError: Default must be a string or an object (was boolean)\"\n\t\t\t\t\t)\n\t\t\t\t\t.type.errors(\n\t\t\t\t\t\t\"Type 'boolean' is not assignable to type 'string | number[]'.\"\n\t\t\t\t\t)\n\t\t\t})\n\t\t})\n\n\t\tdescribe(\"morph input errors\", () => {\n\t\t\tit(\"string\", () => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tattest(() => type({ foo: [\"string.numeric.parse = true\"] }))\n\t\t\t\t\t.throws(\"must be a string (was boolean)\")\n\t\t\t\t\t.type.errors(\n\t\t\t\t\t\t\"Default value true must be assignable to string.numeric.parse\"\n\t\t\t\t\t)\n\t\t\t})\n\n\t\t\tit(\"tuple\", () => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tattest(() => type({ foo: [\"string.numeric.parse\", \"=\", true] }))\n\t\t\t\t\t.throws(\"must be a string (was boolean)\")\n\t\t\t\t\t.type.errors(\n\t\t\t\t\t\t\"Type 'boolean' is not assignable to type 'defaultFor<string>'.\"\n\t\t\t\t\t)\n\t\t\t})\n\n\t\t\tit(\"function\", () => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tattest(() => type({ foo: [\"string.numeric.parse\", \"=\", () => true] }))\n\t\t\t\t\t.throws(\"must be a string (was boolean)\")\n\t\t\t\t\t.type.errors(\"Type 'boolean' is not assignable to type 'string'.\")\n\t\t\t})\n\n\t\t\tit(\"reference tuple\", () => {\n\t\t\t\tconst Numtos = type(\"number\").pipe(s => `${s}`)\n\t\t\t\t// @ts-expect-error\n\t\t\t\tattest(() => type({ foo: [Numtos, \"=\", true] }))\n\t\t\t\t\t.throws(\"must be a number (was boolean)\")\n\t\t\t\t\t.type.errors(\n\t\t\t\t\t\t\"Type 'boolean' is not assignable to type 'defaultFor<number>'.\"\n\t\t\t\t\t)\n\t\t\t})\n\n\t\t\tit(\"reference function\", () => {\n\t\t\t\tconst Numtos = type(\"number\").pipe(s => `${s}`)\n\t\t\t\t// @ts-expect-error\n\t\t\t\tattest(() => type({ foo: [Numtos, \"=\", () => true] }))\n\t\t\t\t\t.throws(\"must be a number (was boolean)\")\n\t\t\t\t\t.type.errors(\"Type 'boolean' is not assignable to type 'number'.\")\n\t\t\t})\n\t\t})\n\n\t\tit(\"morphed inputs\", () => {\n\t\t\tconst Numtos = type(\"number\").pipe(s => `${s}`)\n\t\t\tconst F = type({\n\t\t\t\tfoo1: \"string.numeric.parse = '123'\",\n\t\t\t\tfoo2: [\"string.numeric.parse\", \"=\", \"123\"],\n\t\t\t\tfoo3: [\"string.numeric.parse\", \"=\", () => \"123\"],\n\t\t\t\tbar1: [Numtos, \"=\", 123],\n\t\t\t\tbar2: [Numtos, \"=\", () => 123],\n\t\t\t\tbaz1: type(Numtos).default(123)\n\t\t\t})\n\t\t\tattest(F.assert({})).snap({\n\t\t\t\tfoo1: 123,\n\t\t\t\tfoo2: 123,\n\t\t\t\tfoo3: 123,\n\t\t\t\tbar1: \"123\",\n\t\t\t\tbar2: \"123\",\n\t\t\t\tbaz1: \"123\"\n\t\t\t})\n\t\t})\n\n\t\tit(\"pipes from undefined or not present\", () => {\n\t\t\tconst defaultDate = new Date(\"2020-01-01\")\n\n\t\t\tconst ParsedDate = type(\"string | undefined\").pipe(\n\t\t\t\t(input: string | undefined) => (input ? new Date(input) : defaultDate)\n\t\t\t)\n\n\t\t\tconst SearchSchema = type({\n\t\t\t\tweek: ParsedDate.default(defaultDate.toISOString())\n\t\t\t})\n\n\t\t\tattest(SearchSchema({ week: \"2023-01-01\" })).snap({\n\t\t\t\tweek: \"2023-01-01T00:00:00.000Z\"\n\t\t\t})\n\n\t\t\tattest(SearchSchema({ week: undefined })).snap({\n\t\t\t\tweek: \"2020-01-01T00:00:00.000Z\"\n\t\t\t})\n\n\t\t\tattest(SearchSchema({})).snap({ week: \"2020-01-01T00:00:00.000Z\" })\n\t\t})\n\t})\n\n\tdescribe(\"intersection\", () => {\n\t\tit(\"two optionals, one default\", () => {\n\t\t\tconst L = type({ bar: [\"number\", \"=\", 5] })\n\t\t\tconst R = type({ \"bar?\": \"5\" })\n\n\t\t\tconst T = L.and(R)\n\t\t\tattest(T.json).snap({\n\t\t\t\toptional: [{ default: 5, key: \"bar\", value: { unit: 5 } }],\n\t\t\t\tdomain: \"object\"\n\t\t\t})\n\t\t})\n\n\t\tit(\"same default\", () => {\n\t\t\tconst L = type({ bar: [\"number\", \"=\", 5] })\n\t\t\tconst R = type({ bar: [\"5\", \"=\", 5] })\n\n\t\t\tconst T = L.and(R)\n\t\t\tattest(T.json).snap({\n\t\t\t\toptional: [{ default: 5, key: \"bar\", value: { unit: 5 } }],\n\t\t\t\tdomain: \"object\"\n\t\t\t})\n\t\t})\n\n\t\tit(\"removed when intersected with required\", () => {\n\t\t\tconst L = type({ bar: [\"number\", \"=\", 5] })\n\t\t\tconst R = type({ bar: \"number\" })\n\n\t\t\tconst T = L.and(R)\n\t\t\tattest(T.json).snap({\n\t\t\t\trequired: [{ key: \"bar\", value: \"number\" }],\n\t\t\t\tdomain: \"object\"\n\t\t\t})\n\t\t})\n\n\t\tit(\"errors on multiple defaults\", () => {\n\t\t\tconst L = type({ bar: [\"number\", \"=\", 5] })\n\t\t\tconst R = type({ bar: [\"number\", \"=\", 6] })\n\t\t\tattest(() => L.and(R)).throws.snap(\n\t\t\t\t\"ParseError: Invalid intersection of default values 5 & 6\"\n\t\t\t)\n\t\t})\n\t})\n\n\tdescribe(\"functions\", () => {\n\t\tit(\"works in tuple\", () => {\n\t\t\tconst T = type({ foo: [\"string\", \"=\", () => \"bar\" as const] })\n\n\t\t\tattest(T.t).type.toString.snap('{ foo: Default<string, \"bar\"> }')\n\t\t\tattest(T.assert({ foo: \"bar\" })).snap({ foo: \"bar\" })\n\t\t})\n\n\t\tit(\"checks the returned value\", () => {\n\t\t\tattest(() => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttype({ foo: [\"number\", \"=\", () => \"bar\"] })\n\t\t\t})\n\t\t\t\t.throws.snap(\n\t\t\t\t\t\"ParseError: Default for foo must be a number (was a string)\"\n\t\t\t\t)\n\t\t\t\t.type.errors(\"Type 'string' is not assignable to type 'number'.\")\n\n\t\t\tattest(() => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttype({ foo: [\"number[]\", \"=\", () => \"bar\"] })\n\t\t\t})\n\t\t\t\t.throws.snap(\n\t\t\t\t\t\"ParseError: Default for foo must be an array (was string)\"\n\t\t\t\t)\n\t\t\t\t.type.errors.snap(\"Type 'string' is not assignable to type 'number[]'.\")\n\n\t\t\tattest(() => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttype({ foo: [{ a: \"number\" }, \"=\", () => ({ a: \"bar\" })] })\n\t\t\t})\n\t\t\t\t.throws.snap(\n\t\t\t\t\t\"ParseError: Default for foo.a must be a number (was a string)\"\n\t\t\t\t)\n\t\t\t\t.type.errors.snap(\"Type 'string' is not assignable to type 'number'.\")\n\t\t})\n\n\t\tit(\"morphs the returned value\", () => {\n\t\t\tconst T = type({ foo: [\"string.numeric.parse\", \"=\", () => \"123\"] })\n\n\t\t\tattest<{\n\t\t\t\tfoo: (In: Default<string, string>) => To<number>\n\t\t\t}>(T.t)\n\t\t\tattest(T.assert({})).snap({ foo: 123 })\n\t\t})\n\n\t\tit(\"only allows argless functions for factories\", () => {\n\t\t\tattest(() => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttype({ bar: [\"Function\", \"=\", class {}] })\n\t\t\t})\n\t\t\t\t.throws.snap(\n\t\t\t\t\t\"TypeError: Class constructors cannot be invoked without 'new'\"\n\t\t\t\t)\n\t\t\t\t.type.errors(\n\t\t\t\t\t\"Type 'typeof (Anonymous class)' is not assignable to type '() => Function'\"\n\t\t\t\t)\n\t\t\tattest(() => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttype({ bar: [\"number\", \"=\", (a: number) => a] })\n\t\t\t}).type.errors(\n\t\t\t\t\"Type '(a: number) => number' is not assignable to type 'defaultFor<number>'\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"default factory may return different values\", () => {\n\t\t\tlet i = 0\n\t\t\tconst T = type({ bar: type(\"number[]\").default(() => [++i]) })\n\t\t\tattest(T.assert({}).bar).snap([3])\n\t\t\tattest(T.assert({}).bar).snap([4])\n\t\t})\n\n\t\tit(\"default function factory\", () => {\n\t\t\tlet i = 0\n\t\t\tconst T = type({\n\t\t\t\tbar: type(\"Function\").default(() => {\n\t\t\t\t\tconst j = ++i\n\t\t\t\t\treturn () => j\n\t\t\t\t})\n\t\t\t})\n\n\t\t\tattest<{\n\t\t\t\tbar: Default<Function, () => number>\n\t\t\t}>(T.t)\n\t\t\tattest(T.assert({}).bar()).snap(3)\n\t\t\tattest(T.assert({}).bar()).snap(4)\n\t\t})\n\n\t\tit(\"allows union factory\", () => {\n\t\t\tlet i = 0\n\t\t\tconst T = type({\n\t\t\t\tfoo: [[\"number\", \"|\", \"number[]\"], \"=\", () => (i % 2 ? ++i : [++i])]\n\t\t\t})\n\t\t\tattest(T.assert({})).snap({ foo: 2 })\n\t\t\tattest(T.assert({})).snap({ foo: [3] })\n\t\t})\n\n\t\tit(\"default array\", () => {\n\t\t\tconst T = type({\n\t\t\t\tfoo: type(\"number[]\").default(() => [1]),\n\t\t\t\tbar: type(\"number[]\")\n\t\t\t\t\t.pipe(v => v.map(e => e.toString()))\n\t\t\t\t\t.default(() => [1])\n\t\t\t})\n\t\t\tconst v1 = T.assert({})\n\t\t\tconst v2 = T.assert({})\n\t\t\tattest(v1).snap({ foo: [1], bar: [\"1\"] })\n\t\t\tattest(v1.foo !== v2.foo)\n\t\t})\n\n\t\tit(\"default array is checked\", () => {\n\t\t\tattest(() => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttype({ bar: type(\"number[]\").default(() => [\"a\"]) })\n\t\t\t}).throws.snap(\n\t\t\t\t\"ParseError: Default value at [0] must be a number (was a string)\"\n\t\t\t)\n\n\t\t\tattest(() => {\n\t\t\t\ttype({\n\t\t\t\t\tbaz: type(\"number[]\")\n\t\t\t\t\t\t.pipe(v => v.map(e => e.toString()))\n\t\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\t.default(() => [\"a\"])\n\t\t\t\t})\n\t\t\t}).throws.snap(\n\t\t\t\t\"ParseError: Default value at [0] must be a number (was a string)\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"default object\", () => {\n\t\t\tconst T = type({\n\t\t\t\tfoo: type({ \"foo?\": \"string\" }).default(() => ({})),\n\t\t\t\tbar: type({ \"foo?\": \"string\" }).default(() => ({ foo: \"foostr\" })),\n\t\t\t\tbaz: type({ foo: \"string = 'foostr'\" }).default(() => ({}))\n\t\t\t})\n\n\t\t\tconst v1 = T.assert({}),\n\t\t\t\tv2 = T.assert({})\n\n\t\t\tattest(v1).snap({\n\t\t\t\tfoo: {},\n\t\t\t\tbar: { foo: \"foostr\" },\n\t\t\t\tbaz: { foo: \"foostr\" }\n\t\t\t})\n\t\t\tattest(v1.foo !== v2.foo)\n\t\t})\n\n\t\tit(\"default object is checked\", () => {\n\t\t\tattest(() => {\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttype({ foo: type({ foo: \"string\" }).default({}) })\n\t\t\t}).throws(writeNonPrimitiveNonFunctionDefaultValueMessage(null))\n\n\t\t\tattest(() => {\n\t\t\t\ttype({\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tbar: type({ foo: \"number\" }).default(() => ({ foo: \"foostr\" }))\n\t\t\t\t})\n\t\t\t}).throws.snap(\"ParseError: Default foo must be a number (was a string)\")\n\t\t})\n\t})\n\n\tit(\"extracted from cyclic type\", () => {\n\t\tconst T = type({\n\t\t\tdefaulted: \"number = 0\",\n\t\t\t\"nested?\": \"this\"\n\t\t})\n\n\t\tconst t = T.assert({})\n\n\t\tattest(t).equals({ defaulted: 0 })\n\n\t\tattest<number>(t.defaulted)\n\t\tattest<number | undefined>(t.nested?.defaulted)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/objects/indexSignatures.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport {\n\twriteInvalidPropertyKeyMessage,\n\twriteUnboundableMessage,\n\twriteUnresolvableMessage\n} from \"@ark/schema\"\nimport { printable } from \"@ark/util\"\nimport { scope, type } from \"arktype\"\nimport { writeUnexpectedCharacterMessage } from \"arktype/internal/parser/shift/operator/operator.ts\"\n\ncontextualize(() => {\n\tit(\"string index\", () => {\n\t\tconst O = type({ \"[string]\": \"string\" })\n\t\tattest<{ [x: string]: string }>(O.infer)\n\t\tattest(O.json).snap({\n\t\t\tdomain: \"object\",\n\t\t\tindex: [{ signature: \"string\", value: \"string\" }]\n\t\t})\n\n\t\tattest(O({})).equals({})\n\t\tattest(O({ a: \"a\", b: \"b\" })).equals({ a: \"a\", b: \"b\" })\n\n\t\tconst validWithSymbol = { a: \"a\", [Symbol()]: null }\n\t\tattest(validWithSymbol).equals(validWithSymbol)\n\n\t\tattest(O({ a: 1 }).toString()).snap(\"a must be a string (was a number)\")\n\t\tattest(O({ a: true, b: false }).toString())\n\t\t\t.snap(`a must be a string (was boolean)\nb must be a string (was boolean)`)\n\t})\n\n\tit(\"symbol index\", () => {\n\t\tconst O = type({ \"[symbol]\": \"1\" })\n\t\tattest<{ [x: symbol]: 1 }>(O.infer)\n\t\tattest(O.json).snap({\n\t\t\tdomain: \"object\",\n\t\t\tindex: [{ signature: \"symbol\", value: { unit: 1 } }]\n\t\t})\n\n\t\tattest(O({})).equals({})\n\n\t\tattest(O({ a: 999 })).unknown.snap({ a: 999 })\n\n\t\tconst zildjian = Symbol()\n\t\tconst zildjianName = printable(zildjian)\n\n\t\t// I've been dope, suspenseful with a pencil\n\t\t// Ever since...\n\t\tconst prince = Symbol()\n\t\tconst princeName = printable(prince)\n\n\t\tattest(O({ [zildjian]: 1, [prince]: 1 })).equals({\n\t\t\t[zildjian]: 1,\n\t\t\t[prince]: 1\n\t\t})\n\n\t\tattest({ a: 0, [zildjian]: 1 }).equals({ a: 0, [zildjian]: 1 })\n\n\t\tattest(O({ [zildjian]: 0 }).toString()).equals(\n\t\t\t`value at [${zildjianName}] must be 1 (was 0)`\n\t\t)\n\t\tattest(O({ [prince]: null, [zildjian]: undefined }).toString())\n\t\t\t.snap(`value at [${princeName}] must be 1 (was null)\nvalue at [${zildjianName}] must be 1 (was undefined)`)\n\t})\n\n\tit(\"enumerable indexed union\", () => {\n\t\tconst O = type({ \"['foo' | 'bar']\": \"string\" })\n\t\tconst Expected = type({ foo: \"string\", bar: \"string\" })\n\t\tattest<typeof Expected>(O)\n\t\tattest(O.json).equals(Expected.json)\n\t})\n\n\tit(\"non-enumerable indexed union\", () => {\n\t\tconst O = type({ \"[string | symbol]\": \"string\" })\n\t\tattest<{ [x: string]: string; [x: symbol]: string }>(O.infer)\n\t\tattest(O.json).snap({\n\t\t\tdomain: \"object\",\n\t\t\tindex: [{ signature: [\"string\", \"symbol\"], value: \"string\" }]\n\t\t})\n\t})\n\n\tit(\"multiple indexed\", () => {\n\t\tconst O = type({\n\t\t\t\"[string]\": \"string\",\n\t\t\t\"[symbol]\": \"number\"\n\t\t})\n\t\tattest<{ [x: string]: string; [x: symbol]: number }>(O.infer)\n\t\tattest(O.json).snap({\n\t\t\tindex: [\n\t\t\t\t{ value: \"string\", signature: \"string\" },\n\t\t\t\t{ value: \"number\", signature: \"symbol\" }\n\t\t\t],\n\t\t\tdomain: \"object\"\n\t\t})\n\n\t\tattest(O({})).equals({})\n\t\tattest(O({ foo: \"f\" })).equals({ foo: \"f\" })\n\n\t\tconst sym = Symbol()\n\n\t\tconst symName = printable(sym)\n\n\t\tconst validWithStringsAndSymbols = {\n\t\t\tstr: \"string\",\n\t\t\t[sym]: 8675309\n\t\t}\n\n\t\tattest(O(validWithStringsAndSymbols)).equals(validWithStringsAndSymbols)\n\n\t\tattest(\n\t\t\tO({\n\t\t\t\tstr: 100,\n\t\t\t\t[sym]: \"💯\"\n\t\t\t}).toString()\n\t\t).equals(`str must be a string (was a number)\nvalue at [${symName}] must be a number (was a string)`)\n\t})\n\n\tit(\"all key kinds\", () => {\n\t\tconst O = type({\n\t\t\t\"[string]\": \"string\",\n\t\t\trequired: \"'foo'\",\n\t\t\t\"optional?\": \"'bar'\"\n\t\t})\n\t\tattest<{ [x: string]: string; required: \"foo\"; optional?: \"bar\" }>(O.infer)\n\t\tattest(O.json).snap({\n\t\t\tdomain: \"object\",\n\t\t\trequired: [{ key: \"required\", value: { unit: \"foo\" } }],\n\t\t\toptional: [{ key: \"optional\", value: { unit: \"bar\" } }],\n\t\t\tindex: [{ signature: \"string\", value: \"string\" }]\n\t\t})\n\n\t\tconst valid: typeof O.infer = { required: \"foo\", other: \"bar\" }\n\t\tattest(O(valid)).equals(valid)\n\t\tattest(\n\t\t\tO({\n\t\t\t\toptional: \"wrongString\",\n\t\t\t\tother: 0n\n\t\t\t}).toString()\n\t\t).snap(`required must be \"foo\" (was missing)\noptional must be \"bar\" (was \"wrongString\")\nother must be a string (was a bigint)`)\n\t})\n\n\tit(\"index key from scope\", () => {\n\t\tconst types = scope({\n\t\t\tkey: \"symbol|'foo'|'bar'|'baz'\",\n\t\t\tobj: {\n\t\t\t\t\"[key]\": \"string\"\n\t\t\t}\n\t\t}).export()\n\t\ttype Key = symbol | \"foo\" | \"bar\" | \"baz\"\n\t\tattest<Key>(types.key.infer)\n\t\tattest<Record<Key, string>>(types.obj.infer)\n\n\t\tconst Expected = type({ \"[symbol]\": \"string\" }).and({\n\t\t\tfoo: \"string\",\n\t\t\tbar: \"string\",\n\t\t\tbaz: \"string\"\n\t\t})\n\n\t\tattest(types.obj.json).snap(Expected.json)\n\t})\n\n\tit(\"intersection with named\", () => {\n\t\tconst T = type({ \"[string]\": \"4\" }).and({ \"a?\": \"1\" })\n\t\tattest<{\n\t\t\t[k: string]: 4\n\t\t\ta?: never\n\t\t}>(T.infer)\n\t\tattest(T.json).snap({\n\t\t\toptional: [{ key: \"a\", value: { unit: 1 } }],\n\t\t\tindex: [{ value: { unit: 4 }, signature: \"string\" }],\n\t\t\tdomain: \"object\"\n\t\t})\n\t})\n\n\tit(\"intersction with right required\", () => {\n\t\tconst T = type({ \"a?\": \"true\" }).and({ a: \"boolean\" })\n\t\tattest<{ a: true }>(T.infer)\n\t\tconst Expected = type({\n\t\t\ta: \"true\"\n\t\t})\n\t\tattest(T.json).equals(Expected.json)\n\t})\n\n\tit(\"syntax error in index definition\", () => {\n\t\tattest(() =>\n\t\t\ttype({\n\t\t\t\t// @ts-expect-error\n\t\t\t\t\"[unresolvable]\": \"string\"\n\t\t\t})\n\t\t).throwsAndHasTypeError(writeUnresolvableMessage(\"unresolvable\"))\n\t})\n\n\tit(\"does not allow syntax error message as value\", () => {\n\t\tattest(() =>\n\t\t\ttype({\n\t\t\t\t// @ts-expect-error\n\t\t\t\t\"[unresolvable]\": \"'unresolvable' is unresolvable\"\n\t\t\t})\n\t\t)\n\t\t\t.throws(writeUnexpectedCharacterMessage(\"i\"))\n\t\t\t.type.errors(writeUnresolvableMessage(\"unresolvable\"))\n\t})\n\n\tit(\"semantic error in index definition\", () => {\n\t\tattest(() =>\n\t\t\ttype({\n\t\t\t\t// @ts-expect-error\n\t\t\t\t\"[symbol<5]\": \"string\"\n\t\t\t})\n\t\t).throwsAndHasTypeError(writeUnboundableMessage(\"symbol\"))\n\t})\n\n\tit(\"invalid key type for index definition\", () => {\n\t\tattest(() =>\n\t\t\ttype({\n\t\t\t\t// @ts-expect-error\n\t\t\t\t\"[object]\": \"string\"\n\t\t\t})\n\t\t).throwsAndHasTypeError(writeInvalidPropertyKeyMessage(\"object\"))\n\t})\n\n\tit(\"does not allow invalid key type error as value\", () => {\n\t\tattest(() =>\n\t\t\ttype({\n\t\t\t\t// @ts-expect-error\n\t\t\t\t\"[object]\":\n\t\t\t\t\t\"Indexed key definition 'object' must be a string, number or symbol\"\n\t\t\t})\n\t\t)\n\t\t\t.throws(writeUnresolvableMessage(\"Indexed\"))\n\t\t\t.type.errors(writeInvalidPropertyKeyMessage(\"object\"))\n\t})\n\n\tit(\"escaped index\", () => {\n\t\tconst O = type({ \"\\\\[string]\": \"string\" })\n\t\tattest<{ \"[string]\": string }>(O.infer)\n\t\tattest(O.json).snap({\n\t\t\tdomain: \"object\",\n\t\t\trequired: [{ key: \"[string]\", value: \"string\" }]\n\t\t})\n\t})\n\n\t// https://github.com/arktypeio/arktype/issues/1040\n\tit(\"can constrain optional keys\", () => {\n\t\tconst Repro = type({\n\t\t\tnormal: \"string>0\",\n\t\t\t\"optional?\": \"string>0\"\n\t\t})\n\n\t\ttype Expected = { normal: string; optional?: string }\n\n\t\tattest<Expected, typeof Repro.infer>()\n\t\tattest<Expected, typeof Repro.inferIn>()\n\n\t\tattest(Repro.expression).snap(\n\t\t\t\"{ normal: string >= 1, optional?: string >= 1 }\"\n\t\t)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/objects/mapped.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport type { anyOrNever, Fn, propValueOf } from \"@ark/util\"\nimport { declare, type } from \"arktype\"\nimport type { Default } from \"arktype/internal/attributes.ts\"\n\ncontextualize(() => {\n\tit(\"identity\", () => {\n\t\tconst Original = type({\n\t\t\t\"foo?\": \"string\",\n\t\t\tbar: \"number\",\n\t\t\tbaz: \"boolean\"\n\t\t})\n\t\tconst T = Original.map(entry => entry)\n\n\t\tattest<typeof Original>(T)\n\t\tattest(T.expression).equals(Original.expression)\n\t})\n\n\tit(\"change values\", () => {\n\t\tconst Original = type({\n\t\t\t\"foo?\": \"string\",\n\t\t\tbar: \"number\",\n\t\t\tbaz: {\n\t\t\t\tinner: \"string\"\n\t\t\t}\n\t\t})\n\n\t\tconst T = Original.map(prop => {\n\t\t\tif (prop.key === \"foo\") {\n\t\t\t\treturn {\n\t\t\t\t\tkey: prop.key,\n\t\t\t\t\tvalue: prop.value.array().atLeastLength(1)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (prop.key === \"bar\") {\n\t\t\t\treturn {\n\t\t\t\t\tkey: prop.key,\n\t\t\t\t\tvalue: prop.value.or(\"null\")\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (prop.key === \"baz\") {\n\t\t\t\treturn {\n\t\t\t\t\tkey: prop.key,\n\t\t\t\t\tvalue: prop.value.and({\n\t\t\t\t\t\tintersectedInner: \"number\"\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn prop\n\t\t})\n\n\t\tconst Expected = type({\n\t\t\t\"foo?\": \"string[] >= 1\",\n\t\t\tbar: \"number | null\",\n\t\t\tbaz: {\n\t\t\t\tinner: \"string\",\n\t\t\t\tintersectedInner: \"number\"\n\t\t\t}\n\t\t})\n\n\t\tattest<typeof Expected>(T)\n\t\tattest(T.expression).equals(Expected.expression)\n\t})\n\n\tit(\"infer method output\", () => {\n\t\ttype ExpectedKey<t = type<object>> =\n\t\t\t| propValueOf<{\n\t\t\t\t\t[k in keyof t as t[k] extends Fn<never, type.Any> ?\n\t\t\t\t\t\t[t[k]] extends [Fn<never, anyOrNever>] ?\n\t\t\t\t\t\t\tnever\n\t\t\t\t\t\t:\tk\n\t\t\t\t\t:\tnever]: k\n\t\t\t  }>\n\t\t\t| \"to\"\n\t\t\t| \"get\"\n\t\t\t| \"pipe\"\n\n\t\tconst Base = type({ base: \"1\" })\n\n\t\ttype Base = typeof Base.infer\n\n\t\ttype Original = { [k in ExpectedKey]: Base }\n\n\t\tconst Original = declare<Original>().type({\n\t\t\tand: Base,\n\t\t\tarray: Base,\n\t\t\tas: Base,\n\t\t\tbrand: Base,\n\t\t\tconfigure: Base,\n\t\t\tdescribe: Base,\n\t\t\texclude: Base,\n\t\t\textract: Base,\n\t\t\tfilter: Base,\n\t\t\tget: Base,\n\t\t\tkeyof: Base,\n\t\t\tmap: Base,\n\t\t\tmerge: Base,\n\t\t\tnarrow: Base,\n\t\t\tomit: Base,\n\t\t\tonDeepUndeclaredKey: Base,\n\t\t\tonUndeclaredKey: Base,\n\t\t\tor: Base,\n\t\t\tpartial: Base,\n\t\t\tpick: Base,\n\t\t\tpipe: Base,\n\t\t\treadonly: Base,\n\t\t\trequired: Base,\n\t\t\tto: Base\n\t\t})\n\n\t\tconst brand = Base.brand(\"brand\")\n\n\t\tconst filterFn = (v: Base): v is Base & { filter: 1 } => true\n\t\tconst narrowFn = (v: Base): v is Base & { narrow: 1 } => true\n\t\tconst pipeFn = () => ({ pipe: 1 })\n\n\t\tconst Expected = type({\n\t\t\tand: { base: \"1\", and: \"1\" },\n\t\t\tarray: Base.array(),\n\t\t\tas: Base.as<{ as: 1 }>(),\n\t\t\tbrand,\n\t\t\tconfigure: Base.configure({ description: \"\" }),\n\t\t\tdescribe: Base.describe(\"\"),\n\t\t\texclude: { exclude: \"1\" },\n\t\t\textract: { extract: \"1\" },\n\t\t\tfilter: [Base, \":\", filterFn],\n\t\t\tget: \"1\",\n\t\t\tkeyof: \"'base'\",\n\t\t\tmap: { base: \"2\" },\n\t\t\tmerge: { base: \"1\", merge: \"1\" },\n\t\t\tnarrow: [Base, \":\", narrowFn],\n\t\t\tomit: {},\n\t\t\tonDeepUndeclaredKey: { \"+\": \"reject\", base: \"1\" },\n\t\t\tonUndeclaredKey: { \"+\": \"reject\", base: \"1\" },\n\t\t\tor: [Base, \"|\", { or: \"1\" }],\n\t\t\tpartial: { \"base?\": \"1\" },\n\t\t\tpick: { pick: \"1\" },\n\t\t\tpipe: [Base, \"=>\", pipeFn],\n\t\t\treadonly: Base.readonly(),\n\t\t\trequired: { base: \"1\", required: \"1\" },\n\t\t\tto: { base: \"1\", to: \"1\" }\n\t\t})\n\n\t\tconst mapped = Original.map(prop => {\n\t\t\tswitch (prop.key) {\n\t\t\t\tcase \"and\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey: prop.key,\n\t\t\t\t\t\tvalue: prop.value.and({ and: \"1\" })\n\t\t\t\t\t}\n\t\t\t\tcase \"array\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey: prop.key,\n\t\t\t\t\t\tvalue: prop.value.array()\n\t\t\t\t\t}\n\t\t\t\tcase \"as\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey: prop.key,\n\t\t\t\t\t\tvalue: prop.value.as<{ as: 1 }>()\n\t\t\t\t\t}\n\t\t\t\tcase \"brand\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey: prop.key,\n\t\t\t\t\t\tvalue: prop.value.brand(\"brand\")\n\t\t\t\t\t}\n\t\t\t\tcase \"configure\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey: prop.key,\n\t\t\t\t\t\tvalue: prop.value.configure({ description: \"\" })\n\t\t\t\t\t}\n\t\t\t\tcase \"describe\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey: prop.key,\n\t\t\t\t\t\tvalue: prop.value.describe(\"\")\n\t\t\t\t\t}\n\t\t\t\tcase \"exclude\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey: prop.key,\n\t\t\t\t\t\tvalue: prop.value.or({ exclude: \"1\" }).exclude(Base)\n\t\t\t\t\t}\n\t\t\t\tcase \"extract\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey: prop.key,\n\t\t\t\t\t\tvalue: prop.value.or({ extract: \"1\" }).extract({ extract: \"1\" })\n\t\t\t\t\t}\n\t\t\t\tcase \"filter\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey: prop.key,\n\t\t\t\t\t\tvalue: prop.value.filter(filterFn)\n\t\t\t\t\t}\n\t\t\t\tcase \"get\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey: prop.key,\n\t\t\t\t\t\tvalue: prop.value.get(\"base\")\n\t\t\t\t\t}\n\t\t\t\tcase \"keyof\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey: prop.key,\n\t\t\t\t\t\tvalue: prop.value.keyof()\n\t\t\t\t\t}\n\t\t\t\tcase \"map\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey: prop.key,\n\t\t\t\t\t\tvalue: prop.value.map(innerProp => ({\n\t\t\t\t\t\t\tkey: innerProp.key,\n\t\t\t\t\t\t\tvalue: type(\"2\")\n\t\t\t\t\t\t}))\n\t\t\t\t\t}\n\t\t\t\tcase \"merge\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey: prop.key,\n\t\t\t\t\t\tvalue: prop.value.merge({\n\t\t\t\t\t\t\tmerge: \"1\"\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\tcase \"narrow\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey: prop.key,\n\t\t\t\t\t\tvalue: prop.value.narrow(narrowFn)\n\t\t\t\t\t}\n\t\t\t\tcase \"omit\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey: prop.key,\n\t\t\t\t\t\tvalue: prop.value.omit(\"base\")\n\t\t\t\t\t}\n\t\t\t\tcase \"onDeepUndeclaredKey\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey: prop.key,\n\t\t\t\t\t\tvalue: prop.value.onDeepUndeclaredKey(\"reject\")\n\t\t\t\t\t}\n\t\t\t\tcase \"onUndeclaredKey\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey: prop.key,\n\t\t\t\t\t\tvalue: prop.value.onUndeclaredKey(\"reject\")\n\t\t\t\t\t}\n\t\t\t\tcase \"or\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey: prop.key,\n\t\t\t\t\t\tvalue: prop.value.or({ or: \"1\" })\n\t\t\t\t\t}\n\t\t\t\tcase \"partial\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey: prop.key,\n\t\t\t\t\t\tvalue: prop.value.partial()\n\t\t\t\t\t}\n\t\t\t\tcase \"pick\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey: prop.key,\n\t\t\t\t\t\tvalue: prop.value.and({ pick: \"1\" }).pick(\"pick\")\n\t\t\t\t\t}\n\t\t\t\tcase \"pipe\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey: prop.key,\n\t\t\t\t\t\tvalue: prop.value.pipe(pipeFn)\n\t\t\t\t\t}\n\t\t\t\tcase \"readonly\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey: prop.key,\n\t\t\t\t\t\tvalue: prop.value.readonly()\n\t\t\t\t\t}\n\t\t\t\tcase \"required\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey: prop.key,\n\t\t\t\t\t\tvalue: prop.value.and({ \"required?\": \"1\" }).required()\n\t\t\t\t\t}\n\t\t\t\tcase \"to\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey: prop.key,\n\t\t\t\t\t\tvalue: prop.value.to({ to: \"1\" })\n\t\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tprop satisfies never\n\t\t\t\t\treturn prop\n\t\t\t}\n\t\t})\n\n\t\tattest<typeof Expected.t>(mapped.t)\n\t\tattest(mapped.json).equals(Expected.json)\n\t})\n\n\tit(\"filter and split values\", () => {\n\t\tconst Original = type({\n\t\t\t\"foo?\": \"string\",\n\t\t\tbar: \"number\",\n\t\t\tbaz: {\n\t\t\t\tinner: \"string\"\n\t\t\t}\n\t\t})\n\n\t\tconst getInner = (data: typeof Original.infer.baz) => data.inner\n\n\t\tconst T = Original.map(prop => {\n\t\t\tif (prop.key === \"bar\") return []\n\n\t\t\tif (prop.key === \"baz\") {\n\t\t\t\treturn [\n\t\t\t\t\tprop,\n\t\t\t\t\t{\n\t\t\t\t\t\tkey: \"fromBaz\" as const,\n\t\t\t\t\t\tvalue: prop.value.pipe(getInner)\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t\treturn prop\n\t\t})\n\n\t\tconst Expected = type({\n\t\t\t\"foo?\": \"string\",\n\t\t\tbaz: {\n\t\t\t\tinner: \"string\"\n\t\t\t},\n\t\t\tfromBaz: Original.get(\"baz\").pipe(getInner)\n\t\t})\n\n\t\tattest<typeof Expected>(T)\n\t\tattest(T.expression).equals(Expected.expression)\n\t})\n\n\tit(\"change optionality\", () => {\n\t\tconst Original = type({\n\t\t\t\"foo?\": \"string\",\n\t\t\tbar: \"number\",\n\t\t\tbaz: \"boolean\"\n\t\t})\n\n\t\tconst T = Original.map(prop => {\n\t\t\tif (prop.key === \"foo\")\n\t\t\t\treturn { kind: \"required\", key: \"foo\", value: prop.value } as const\n\t\t\tif (prop.key === \"bar\")\n\t\t\t\treturn { kind: \"optional\", key: \"bar\", value: prop.value } as const\n\n\t\t\treturn prop\n\t\t})\n\n\t\tconst Expected = type({\n\t\t\tfoo: \"string\",\n\t\t\t\"bar?\": \"number\",\n\t\t\tbaz: \"boolean\"\n\t\t})\n\n\t\tattest<typeof Expected>(T)\n\t\tattest(T.expression).equals(Expected.expression)\n\t})\n\n\tit(\"modify default\", () => {\n\t\tconst Original = type({\n\t\t\tfoo: \"string = 'foo'\",\n\t\t\t\"bar?\": \"number\"\n\t\t})\n\n\t\tattest<{\n\t\t\tfoo: Default<string, \"foo\">\n\t\t\tbar?: number\n\t\t}>(Original.t)\n\t\tattest(Original.expression).snap('{ foo: string = \"foo\", bar?: number }')\n\n\t\tconst T = Original.map(prop => {\n\t\t\tif (prop.key === \"foo\") {\n\t\t\t\treturn {\n\t\t\t\t\t...prop,\n\t\t\t\t\tdefault: `${prop.default}t` as const\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn prop\n\t\t})\n\n\t\tattest<{\n\t\t\tbar?: number\n\t\t\tfoo: Default<string, \"foot\">\n\t\t}>(T.t)\n\t\tattest(T.expression).snap('{ foo: string = \"foot\", bar?: number }')\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/objects/namedKeys.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { registeredReference, writeUnresolvableMessage } from \"@ark/schema\"\nimport { type, type Type } from \"arktype\"\nimport type { Out } from \"arktype/internal/attributes.ts\"\n\ncontextualize(() => {\n\tit(\"empty\", () => {\n\t\tconst O = type({})\n\t\tattest<object>(O.t).type.toString(\"object\")\n\t\tattest(O.json).equals(type(\"object\").json)\n\t})\n\n\tit(\"required\", () => {\n\t\tconst O = type({ a: \"string\", b: \"number\" })\n\t\tattest<{ a: string; b: number }>(O.infer)\n\t\tattest(O.json).snap({\n\t\t\tdomain: \"object\",\n\t\t\trequired: [\n\t\t\t\t{ key: \"a\", value: \"string\" },\n\t\t\t\t{ key: \"b\", value: \"number\" }\n\t\t\t]\n\t\t})\n\t})\n\n\tit(\"optional keys\", () => {\n\t\tconst O = type({ \"a?\": \"string\", b: \"number\" })\n\t\tattest<{ a?: string; b: number }>(O.infer)\n\t\tattest(O.json).snap({\n\t\t\tdomain: \"object\",\n\t\t\trequired: [{ key: \"b\", value: \"number\" }],\n\t\t\toptional: [{ key: \"a\", value: \"string\" }]\n\t\t})\n\t})\n\n\tit(\"chained optional\", () => {\n\t\tconst OptionalString = type(\"string\").optional()\n\t\tattest<[Type<string>, \"?\"]>(OptionalString)\n\n\t\tconst O = type({ a: OptionalString })\n\t\t// directly inferring the optional key causes recursive generics/intersections to fail,\n\t\t// so instead we just distill it out like defaults\n\t\tattest(O.t).type.toString.snap(\"{ a?: string }\")\n\t\tattest(O.infer).type.toString.snap(\"{ a?: string }\")\n\t\tattest(O.inferIn).type.toString.snap(\"{ a?: string }\")\n\t\tattest(O.json).snap({\n\t\t\toptional: [\n\t\t\t\t{\n\t\t\t\t\tkey: \"a\",\n\t\t\t\t\tvalue: \"string\"\n\t\t\t\t}\n\t\t\t],\n\t\t\tdomain: \"object\"\n\t\t})\n\t})\n\n\tit(\"string-embedded value optional\", () => {\n\t\tconst s = Symbol(\"ok\")\n\t\tconst ref = registeredReference(s)\n\t\tconst T = type({ [s]: \"string?\" })\n\n\t\tattest<{\n\t\t\t[s]?: string\n\t\t}>(T.t)\n\t\tattest<{ [s]?: string }>(T.infer)\n\n\t\tattest(T.json).equals({\n\t\t\toptional: [\n\t\t\t\t{\n\t\t\t\t\tkey: ref,\n\t\t\t\t\tvalue: \"string\"\n\t\t\t\t}\n\t\t\t],\n\t\t\tdomain: \"object\"\n\t\t})\n\t})\n\n\tit(\"tuple value optional\", () => {\n\t\tconst s = Symbol(\"ok\")\n\t\tconst ref = registeredReference(s)\n\t\tconst T = type({ [s]: [{ foo: \"string\" }, \"?\"] })\n\n\t\tattest<{ [s]?: { foo: string } }>(T.infer)\n\n\t\tattest(T.json).snap({\n\t\t\toptional: [\n\t\t\t\t{\n\t\t\t\t\tkey: ref,\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\trequired: [{ key: \"foo\", value: \"string\" }],\n\t\t\t\t\t\tdomain: \"object\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t],\n\t\t\tdomain: \"object\"\n\t\t})\n\t})\n\n\t// https://github.com/arktypeio/arktype/issues/1102\n\tit(\"only optional keys not reduced to object\", () => {\n\t\tconst O = type({ \"a?\": \"number\" })\n\n\t\tconst U = type({ b: O })\n\t\tattest(U.expression).snap(\"{ b: { a?: number } }\")\n\t\tattest<{\n\t\t\tb: {\n\t\t\t\ta?: number\n\t\t\t}\n\t\t}>(U.t)\n\t\tattest<typeof U.t>(U.infer)\n\t\tattest<typeof U.t>(U.inferIn)\n\t})\n\n\t// https://github.com/arktypeio/arktype/issues/1102\n\tit(\"optional keys in union not reduced to object\", () => {\n\t\tconst U = type({ b: type({ \"a?\": \"number\" }).or(\"number\") })\n\t\tattest(U.expression).snap(\"{ b: number | { a?: number } }\")\n\t\tattest<{\n\t\t\tb:\n\t\t\t\t| {\n\t\t\t\t\t\ta?: number\n\t\t\t\t  }\n\t\t\t\t| number\n\t\t}>(U.t)\n\t})\n\n\tit(\"symbol key\", () => {\n\t\tconst s = Symbol()\n\t\tconst name = registeredReference(s)\n\t\tconst T = type({\n\t\t\t[s]: \"string\"\n\t\t})\n\t\tattest<{ [s]: string }>(T.infer)\n\t\tattest(T.json).snap({\n\t\t\tdomain: \"object\",\n\t\t\trequired: [{ key: name, value: \"string\" }]\n\t\t})\n\t})\n\n\tit(\"serializes to same value but not reference equal\", () => {\n\t\tconst T = type(\"===\", {})\n\t\tattest(T({}).toString()).snap(\n\t\t\t\"must be reference equal to {} (serialized to the same value)\"\n\t\t)\n\t})\n\n\tit(\"error in obj that has tuple that writes error at proper path\", () => {\n\t\tattest(() =>\n\t\t\t// @ts-expect-error\n\t\t\ttype({ \"a?\": [\"string\", [\"stringx\", \"?\"]] })\n\t\t).throwsAndHasTypeError(writeUnresolvableMessage(\"stringx\"))\n\t})\n\n\tit(\"nested\", () => {\n\t\tconst T = type({ \"a?\": { b: \"boolean\" } })\n\t\tattest<{ a?: { b: boolean } }>(T.infer)\n\t})\n\n\tit(\"intersections\", () => {\n\t\tconst a = { \"a?\": \"string\" } as const\n\t\tconst b = { b: \"string\" } as const\n\t\tconst c = { \"c?\": \"string\" } as const\n\t\tconst Abc = type(a).and(b).and(c)\n\t\tattest<{ a?: string; b: string; c?: string }>(Abc.infer)\n\t\tattest(Abc.json).equals(type({ ...a, ...b, ...c }).json)\n\t\tattest(Abc.json).equals(type([[a, \"&\", b], \"&\", c]).json)\n\t})\n\n\tit(\"intersection\", () => {\n\t\tconst T = type({ a: \"number\" }).and({ b: \"boolean\" })\n\t\t// Should be simplified from {a: number} & {b: boolean} to {a: number, b: boolean}\n\t\tattest(T.infer).type.toString.snap(\"{ a: number; b: boolean }\")\n\t\tattest(T.json).equals(type({ a: \"number\", b: \"boolean\" }).json)\n\t})\n\n\tit(\"escaped optional token\", () => {\n\t\tconst T = type({ \"a\\\\?\": \"string\" })\n\t\tattest<{ \"a?\": string }>(T.infer)\n\t\tattest(T.json).snap({\n\t\t\trequired: [{ key: \"a?\", value: \"string\" }],\n\t\t\tdomain: \"object\"\n\t\t})\n\t})\n\n\tit(\"traverse optional\", () => {\n\t\tconst O = type({ \"a?\": \"string\" })\n\t\tattest(O({ a: \"a\" })).snap({ a: \"a\" })\n\t\tattest(O({})).snap({})\n\t\tattest(O({ a: 1 }).toString()).snap(\"a must be a string (was a number)\")\n\t})\n\n\tit(\"optional symbol\", () => {\n\t\tconst s = Symbol()\n\t\tconst keyReference = registeredReference(s)\n\t\tconst T = type({\n\t\t\t[s]: type.number.optional()\n\t\t})\n\t\tattest<{ [s]?: number }>(T.infer)\n\t\tattest(T.json).equals({\n\t\t\toptional: [\n\t\t\t\t{\n\t\t\t\t\tkey: keyReference,\n\t\t\t\t\tvalue: \"number\"\n\t\t\t\t}\n\t\t\t],\n\t\t\tdomain: \"object\"\n\t\t})\n\t})\n\n\tit(\"morphed\", () => {\n\t\tconst ProcessForm = type({\n\t\t\tbool_value: type(\"string\")\n\t\t\t\t.pipe(v => (v === \"on\" ? true : false))\n\t\t\t\t.optional()\n\t\t})\n\n\t\tattest<{\n\t\t\tbool_value?: (In: string) => Out<boolean>\n\t\t}>(ProcessForm.t)\n\t\tattest<{\n\t\t\t// key should still be distilled as optional even inside a morph\n\t\t\tbool_value?: string\n\t\t}>(ProcessForm.inferIn)\n\t\tattest<{\n\t\t\t// out should also be inferred as optional\n\t\t\tbool_value?: boolean\n\t\t}>(ProcessForm.infer)\n\n\t\tattest(ProcessForm({})).snap({})\n\n\t\tattest(ProcessForm({ bool_value: \"on\" })).snap({ bool_value: true })\n\n\t\tattest(ProcessForm({ bool_value: true }).toString()).snap(\n\t\t\t\"bool_value must be a string (was boolean)\"\n\t\t)\n\t})\n\n\tit(\"required key homomorphic\", () => {\n\t\tconst T = type({\n\t\t\t/** FOO */\n\t\t\tfoo: \"string\"\n\t\t})\n\n\t\tconst out = T.assert({ foo: \"foo\" })\n\n\t\tattest(out.foo).jsdoc.snap(\"FOO\")\n\t})\n\n\tit(\"optional value homomorphic\", () => {\n\t\tconst T = type({\n\t\t\t/** BAR */\n\t\t\tbar: \"number?\"\n\t\t})\n\n\t\tconst out = T.assert({})\n\n\t\tattest(out.bar).jsdoc.snap(\"BAR\")\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/objects/onUndeclaredKey.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { type } from \"arktype\"\nimport { writeInvalidUndeclaredBehaviorMessage } from \"arktype/internal/parser/objectLiteral.ts\"\n\ncontextualize(() => {\n\tit(\"can parse an undeclared restriction\", () => {\n\t\tconst T = type({ \"+\": \"reject\" })\n\t\tattest<{}>(T.infer)\n\t\tattest(T.json).snap({ undeclared: \"reject\", domain: \"object\" })\n\t})\n\n\tit(\"fails on type definition for undeclared\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type({ \"+\": \"string\" }))\n\t\t\t.throws(writeInvalidUndeclaredBehaviorMessage(\"string\"))\n\t\t\t.type.errors.snap(\n\t\t\t\t\"Type '\\\"string\\\"' is not assignable to type 'UndeclaredKeyBehavior'.\"\n\t\t\t)\n\t})\n\n\tit(\"can escape undeclared meta key\", () => {\n\t\tconst T = type({ \"\\\\+\": \"string\" })\n\t\tattest<{ \"+\": string }>(T.infer)\n\t\tattest(T.json).snap({\n\t\t\trequired: [{ key: \"+\", value: \"string\" }],\n\t\t\tdomain: \"object\"\n\t\t})\n\t})\n\n\tdescribe(\"traversal\", () => {\n\t\tconst getExtraneousB = () => ({ a: \"ok\", b: \"why?\" })\n\n\t\tit(\"loose by default\", () => {\n\t\t\tconst T = type({\n\t\t\t\ta: \"string\"\n\t\t\t})\n\n\t\t\tattest(T.json).equals(T.onUndeclaredKey(\"ignore\").json)\n\n\t\t\tconst dataWithExtraneousB = getExtraneousB()\n\t\t\tattest(T(dataWithExtraneousB)).equals(dataWithExtraneousB)\n\t\t})\n\n\t\tit(\"delete keys\", () => {\n\t\t\tconst T = type({\n\t\t\t\ta: \"string\"\n\t\t\t}).onUndeclaredKey(\"delete\")\n\t\t\tattest(T({ a: \"ok\" })).equals({ a: \"ok\" })\n\t\t\tattest(T(getExtraneousB())).snap({ a: \"ok\" })\n\t\t})\n\n\t\tit(\"applies shallowly\", () => {\n\t\t\tconst T = type({\n\t\t\t\ta: \"string\",\n\t\t\t\tnested: {\n\t\t\t\t\ta: \"string\"\n\t\t\t\t}\n\t\t\t}).onUndeclaredKey(\"delete\")\n\n\t\t\tattest(\n\t\t\t\tT({\n\t\t\t\t\t...getExtraneousB(),\n\t\t\t\t\tnested: getExtraneousB()\n\t\t\t\t})\n\t\t\t).equals({ a: \"ok\", nested: { a: \"ok\", b: \"why?\" } as never })\n\t\t})\n\n\t\tit(\"can apply deeply\", () => {\n\t\t\tconst T = type({\n\t\t\t\ta: \"string\",\n\t\t\t\tnested: {\n\t\t\t\t\ta: \"string\"\n\t\t\t\t}\n\t\t\t}).onDeepUndeclaredKey(\"delete\")\n\n\t\t\tattest(T.expression).snap(\n\t\t\t\t\"{ a: string, nested: { a: string, + (undeclared): delete }, + (undeclared): delete }\"\n\t\t\t)\n\n\t\t\tattest(\n\t\t\t\tT({\n\t\t\t\t\t...getExtraneousB(),\n\t\t\t\t\tnested: getExtraneousB()\n\t\t\t\t})\n\t\t\t).equals({ a: \"ok\", nested: { a: \"ok\" } })\n\t\t})\n\n\t\tit(\"delete union key\", () => {\n\t\t\tconst O = type([\n\t\t\t\t{ a: \"string\" },\n\t\t\t\t\"|\",\n\t\t\t\t{ a: \"boolean\", b: \"true\" }\n\t\t\t]).onUndeclaredKey(\"delete\")\n\t\t\t// can distill to first branch\n\t\t\tattest(O({ a: \"to\", z: \"bra\" })).snap({ a: \"to\" })\n\t\t\t// can distill to second branch\n\t\t\tattest(O({ a: true, b: true, c: false })).snap({ a: true, b: true })\n\t\t\t// can handle missing keys\n\t\t\tattest(O({ a: true }).toString()).snap(\n\t\t\t\t\"a must be a string (was boolean) or b must be true (was missing)\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"fails on delete indiscriminable union key\", () => {\n\t\t\tattest(() =>\n\t\t\t\ttype([{ a: \"string\" }, \"|\", { b: \"boolean\" }]).onUndeclaredKey(\"delete\")\n\t\t\t).throws\n\t\t\t\t.snap(`ParseError: An unordered union of a type including a morph and a type with overlapping input is indeterminate:\nLeft: { a: string, + (undeclared): delete }\nRight: { b: boolean, + (undeclared): delete }`)\n\t\t})\n\n\t\tit(\"reject key\", () => {\n\t\t\tconst T = type({\n\t\t\t\ta: \"string\"\n\t\t\t}).onUndeclaredKey(\"reject\")\n\t\t\tattest(T({ a: \"ok\" })).equals({ a: \"ok\" })\n\t\t\tattest(T(getExtraneousB()).toString()).snap(\"b must be removed\")\n\t\t})\n\n\t\tit(\"reject array key\", () => {\n\t\t\tconst O = type({ \"+\": \"reject\", a: \"string[]\" })\n\t\t\tattest(O({ a: [\"shawn\"] })).snap({ a: [\"shawn\"] })\n\t\t\tattest(O({ a: [2] }).toString()).snap(\n\t\t\t\t\"a[0] must be a string (was a number)\"\n\t\t\t)\n\t\t\tattest(O({ b: [\"shawn\"] }).toString())\n\t\t\t\t.snap(`a must be an array (was missing)\nb must be removed`)\n\t\t})\n\n\t\tit(\"reject key from union\", () => {\n\t\t\tconst O = type([{ a: \"string\" }, \"|\", { b: \"boolean\" }]).onUndeclaredKey(\n\t\t\t\t\"reject\"\n\t\t\t)\n\t\t\tattest(O({ a: 2, b: true }).toString()).snap(\n\t\t\t\t\"a must be a string or removed (was 2)\"\n\t\t\t)\n\t\t})\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/objects/props.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport {\n\twriteDuplicateKeyMessage,\n\twriteLiteralUnionEntriesMessage\n} from \"@ark/schema\"\nimport { register, type array } from \"@ark/util\"\nimport { type } from \"arktype\"\nimport type { BaseTypeProp } from \"arktype/internal/variants/object.ts\"\n\n// by default because of the toJSON method, it wouldn't be clear\n// if the snapshotted props were requied or optional\nconst snapshottableProps = (props: array<BaseTypeProp>) =>\n\tprops.map(p => ({\n\t\tkind: p.kind,\n\t\tkey: p.key,\n\t\tvalue: p.value.expression\n\t}))\n\ncontextualize(() => {\n\tit(\"strings\", () => {\n\t\tconst T = type({\n\t\t\tfoo: \"1\",\n\t\t\tbar: \"2\",\n\t\t\t\"baz?\": \"3\"\n\t\t})\n\n\t\tattest<\n\t\t\tarray<\n\t\t\t\t| BaseTypeProp<\"required\", \"foo\", 1, {}>\n\t\t\t\t| BaseTypeProp<\"required\", \"bar\", 2, {}>\n\t\t\t\t| BaseTypeProp<\"optional\", \"baz\", 3, {}>\n\t\t\t>\n\t\t>(T.props)\n\n\t\tattest(snapshottableProps(T.props)).snap([\n\t\t\t{ kind: \"required\", key: \"bar\", value: \"2\" },\n\t\t\t{ kind: \"required\", key: \"foo\", value: \"1\" },\n\t\t\t{ kind: \"optional\", key: \"baz\", value: \"3\" }\n\t\t])\n\t})\n\n\tit(\"mixed keys\", () => {\n\t\tconst s = Symbol()\n\n\t\tconst sReference = register(s)\n\t\tconst s2 = Symbol()\n\t\tconst s2Reference = register(s2)\n\t\tconst T = type({\n\t\t\t[s]: \"1\",\n\t\t\t[s2]: [\"2\", \"?\"],\n\t\t\tfoo: \"3\",\n\t\t\tfoo2: [\"4\", \"?\"]\n\t\t})\n\n\t\tattest<{\n\t\t\t[s]: 1\n\t\t\tfoo: 3\n\t\t\t[s2]?: 2\n\t\t\tfoo2?: 4\n\t\t}>(T.infer)\n\n\t\tattest(snapshottableProps(T.props)).snap([\n\t\t\t{ kind: \"required\", key: `Symbol(${sReference})`, value: \"1\" },\n\t\t\t{ kind: \"required\", key: \"foo\", value: \"3\" },\n\t\t\t{ kind: \"optional\", key: `Symbol(${s2Reference})`, value: \"2\" },\n\t\t\t{ kind: \"optional\", key: \"foo2\", value: \"4\" }\n\t\t])\n\t})\n\n\tit(\"union\", () => {\n\t\tconst T = type({ foo: \"string\" }).or({ bar: \"number\" })\n\t\tattest(() => T.props).throws(writeLiteralUnionEntriesMessage(T.expression))\n\t})\n\n\tit(\"structural operation removes narrow\", () => {\n\t\tconst T = type({ foo: { key: \"string\" } })\n\t\t\t.narrow(o => o.foo.key.length > 0)\n\t\t\t.merge({\n\t\t\t\tfoo: \"null\"\n\t\t\t})\n\n\t\tattest(T({ foo: null })).equals({ foo: null })\n\t\tattest(T.json).snap({\n\t\t\trequired: [{ key: \"foo\", value: { unit: null } }],\n\t\t\tdomain: \"object\"\n\t\t})\n\t})\n\n\tit(\"duplicate optional key\", () => {\n\t\tattest(() =>\n\t\t\ttype({\n\t\t\t\ta: \"true\",\n\t\t\t\t\"a?\": \"true\"\n\t\t\t})\n\t\t).throws(writeDuplicateKeyMessage(\"a\"))\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/objects/spread.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { scope, type } from \"arktype\"\nimport { writeInvalidSpreadTypeMessage } from \"arktype/internal/parser/objectLiteral.ts\"\n\ncontextualize(() => {\n\tit(\"within scope\", () => {\n\t\tconst s = scope({\n\t\t\tuser: { isAdmin: \"false\", name: \"string\" },\n\t\t\tadmin: { \"...\": \"user\", isAdmin: \"true\" }\n\t\t}).export()\n\n\t\tattest<{ isAdmin: true; name: string }>(s.admin.infer)\n\t\tattest(s.admin.json).equals({\n\t\t\tdomain: \"object\",\n\t\t\trequired: [\n\t\t\t\t{ key: \"isAdmin\", value: { unit: true } },\n\t\t\t\t{ key: \"name\", value: \"string\" }\n\t\t\t]\n\t\t})\n\t})\n\n\tit(\"from another `type` call\", () => {\n\t\tconst User = type({ isAdmin: \"false\", name: \"string\" })\n\t\tconst Admin = type({ \"...\": User, isAdmin: \"true\" })\n\n\t\tattest<{ isAdmin: true; name: string }>(Admin.infer)\n\t\tattest(Admin.json).snap({\n\t\t\tdomain: \"object\",\n\t\t\trequired: [\n\t\t\t\t{ key: \"isAdmin\", value: { unit: true } },\n\t\t\t\t{ key: \"name\", value: \"string\" }\n\t\t\t]\n\t\t})\n\t})\n\n\tit(\"from an object literal\", () => {\n\t\t// no idea why you'd want to do this\n\t\tconst T = type({\n\t\t\t\"...\": {\n\t\t\t\tinherited: \"boolean\",\n\t\t\t\toverridden: \"string\"\n\t\t\t},\n\t\t\toverridden: \"number\"\n\t\t})\n\n\t\tattest<{\n\t\t\tinherited: boolean\n\t\t\toverridden: number\n\t\t}>(T.infer)\n\n\t\tattest(T.json).snap({\n\t\t\tdomain: \"object\",\n\t\t\trequired: [\n\t\t\t\t{\n\t\t\t\t\tkey: \"inherited\",\n\t\t\t\t\tvalue: [{ unit: false }, { unit: true }]\n\t\t\t\t},\n\t\t\t\t{ key: \"overridden\", value: \"number\" }\n\t\t\t]\n\t\t})\n\t})\n\n\tit(\"escaped key\", () => {\n\t\tconst T = type({\n\t\t\t\"\\\\...\": \"string\"\n\t\t})\n\n\t\tattest<{ \"...\": string }>(T.infer)\n\n\t\tattest(T.json).snap({\n\t\t\tdomain: \"object\",\n\t\t\trequired: [{ key: \"...\", value: \"string\" }]\n\t\t})\n\t})\n\n\tit(\"with non-object\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type({ \"...\": \"string\" })).throwsAndHasTypeError(\n\t\t\twriteInvalidSpreadTypeMessage(\"string\")\n\t\t)\n\t})\n\n\t// this is a regression test to ensure nodes are handled even if they aren't just an object\n\tit(\"with complex type\", () => {\n\t\tconst AdminUser = type({\n\t\t\t\"...\": [{ name: \"string\" }, \"&\", { isAdmin: \"false\" }],\n\t\t\tisAdmin: \"true\"\n\t\t})\n\n\t\tattest<{ isAdmin: true; name: string }>(AdminUser.infer)\n\t\tattest(AdminUser.json).snap({\n\t\t\tdomain: \"object\",\n\t\t\trequired: [\n\t\t\t\t{ key: \"isAdmin\", value: { unit: true } },\n\t\t\t\t{ key: \"name\", value: \"string\" }\n\t\t\t]\n\t\t})\n\t})\n\n\tit(\"object keyword treated as empty\", () => {\n\t\tconst T = type({\n\t\t\t\"...\": \"object\",\n\t\t\tfoo: \"string\"\n\t\t})\n\n\t\tattest<{\n\t\t\tfoo: string\n\t\t}>(T.t)\n\t\tattest(T.expression).snap(\"{ foo: string }\")\n\t})\n\n\tit(\"narrowed object keyword treated as empty\", () => {\n\t\tconst T = type({\n\t\t\t\"...\": type.object.narrow(() => true),\n\t\t\tfoo: \"string\"\n\t\t})\n\n\t\tattest<{\n\t\t\tfoo: string\n\t\t}>(T.t)\n\t\tattest(T.expression).snap(\"{ foo: string }\")\n\t})\n\n\tit(\"errors on proto node\", () => {\n\t\tattest(() =>\n\t\t\ttype({\n\t\t\t\t\"...\": \"Date\",\n\t\t\t\tfoo: \"string\"\n\t\t\t})\n\t\t).throws(writeInvalidSpreadTypeMessage(\"Date\"))\n\t})\n\n\tit(\"autocompletes shallow string\", () => {\n\t\tattest(() =>\n\t\t\ttype({\n\t\t\t\t// @ts-expect-error\n\t\t\t\t\"...\": \"objec\"\n\t\t\t})\n\t\t).completions({\n\t\t\tobjec: [\"object\"]\n\t\t})\n\t})\n\n\tit(\"autocompletes nested strings\", () => {\n\t\tattest(() =>\n\t\t\ttype({\n\t\t\t\t\"...\": {\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tinner: \"boo\"\n\t\t\t\t}\n\t\t\t})\n\t\t).completions({\n\t\t\tboo: [\"boolean\"]\n\t\t})\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/operand.bench.ts",
    "content": "import { bench } from \"@ark/attest\"\nimport { type } from \"arktype\"\n\nbench.baseline(() => type(\"never\"))\n\nbench(\"single-quoted\", () => type(\"'nineteen characters'\")).types([\n\t732,\n\t\"instantiations\"\n])\n\nbench(\"double-quoted\", () => type('\"nineteen characters\"')).types([\n\t732,\n\t\"instantiations\"\n])\n\nbench(\"regex literal\", () => type(\"/nineteen characters/\")).types([\n\t2178,\n\t\"instantiations\"\n])\n\nbench(\"keyword\", () => type(\"string\")).types([506, \"instantiations\"])\n\nbench(\"number\", () => type(\"-98765.4321\")).types([471, \"instantiations\"])\n\nbench(\"bigint\", () => type(\"-987654321n\")).types([545, \"instantiations\"])\n\nbench(\"object\", () => type({ foo: \"string\" })).types([942, \"instantiations\"])\n\nbench(\"union\", () =>\n\t// Union is automatically discriminated using shallow or deep keys\n\ttype({\n\t\tkind: \"'admin'\",\n\t\t\"powers?\": \"string[]\"\n\t})\n\t\t.or({\n\t\t\tkind: \"'superadmin'\",\n\t\t\t\"superpowers?\": \"string[]\"\n\t\t})\n\t\t.or({\n\t\t\tkind: \"'pleb'\"\n\t\t})\n).types([4159, \"instantiations\"])\n"
  },
  {
    "path": "ark/type/__tests__/operator.bench.ts",
    "content": "import { bench } from \"@ark/attest\"\nimport { declare, type } from \"arktype\"\n\nbench.baseline(() => {\n\ttype(\"symbol\")\n\ttype(\"symbol[]\")\n\ttype(\"symbol\").pipe(s => s)\n\ttype([\"symbol\", \"=>\", s => s])\n\ttype(\"symbol\").narrow(() => true)\n})\n\nbench(\"array-string\", () => type(\"number[]\")).types([839, \"instantiations\"])\n\nbench(\"array-tuple\", () => type([\"number\", \"[]\"])).types([\n\t825,\n\t\"instantiations\"\n])\n\nbench(\"array-chain\", () => type(\"number\").array()).types([\n\t469,\n\t\"instantiations\"\n])\n\nbench(\"union-string\", () => type(\"number|string\")).types([\n\t1067,\n\t\"instantiations\"\n])\n\nbench(\"union-tuple\", () => type([\"number\", \"|\", \"string\"])).types([\n\t1022,\n\t\"instantiations\"\n])\n\nbench(\"union-chain\", () => type(\"number\").or(\"string\")).types([\n\t1292,\n\t\"instantiations\"\n])\n\nbench(\"union-10-ary\", () => type(\"0|1|2|3|4|5|6|7|8|9\")).types([\n\t3848,\n\t\"instantiations\"\n])\n\nbench(\"intersection-string\", () => type(\"number&0\")).types([\n\t1191,\n\t\"instantiations\"\n])\n\nbench(\"intersection-tuple\", () => type([\"number\", \"&\", \"0\"])).types([\n\t1156,\n\t\"instantiations\"\n])\n\nbench(\"intersection-chain\", () => type(\"number\").and(\"0\")).types([\n\t1489,\n\t\"instantiations\"\n])\n\nbench(\"intersection-10-ary\", () =>\n\ttype(\n\t\t\"unknown&unknown&unknown&unknown&unknown&unknown&unknown&unknown&unknown&unknown\"\n\t)\n).types([4646, \"instantiations\"])\n\nbench(\"group-shallow\", () => type(\"string|(number[])\")).types([\n\t1316,\n\t\"instantiations\"\n])\n\nbench(\"group-nested\", () => type(\"string|(number|(boolean))[][]\")).types([\n\t2002,\n\t\"instantiations\"\n])\n\nbench(\"group-deep\", () => type(\"(0|(1|(2|(3|(4|5)[])[])[])[])[]\")).types([\n\t4461,\n\t\"instantiations\"\n])\n\nbench(\"bound-single\", () => type(\"string>5\")).types([1236, \"instantiations\"])\n\nbench(\"bound-double\", () => type(\"-7<=string.integer<99\")).types([\n\t1893,\n\t\"instantiations\"\n])\n\nbench(\"divisor\", () => type(\"number%5\")).types([869, \"instantiations\"])\n\nbench(\"filter-tuple\", () => type([\"boolean\", \":\", b => b])).types([\n\t1169,\n\t\"instantiations\"\n])\n\nbench(\"filter-chain\", () => type(\"boolean\").narrow(b => b)).types([\n\t657,\n\t\"instantiations\"\n])\n\nbench(\"morph-tuple\", () => type([\"boolean\", \"=>\", b => b])).types([\n\t1216,\n\t\"instantiations\"\n])\n\nbench(\"morph-chain\", () => type(\"boolean\").pipe(b => b)).types([\n\t770,\n\t\"instantiations\"\n])\n\nconst A = type(\"'a'\")\n\nbench(\"morph-chain-all\", () => {\n\tconst out = A.pipe(\n\t\ts => `${s}b` as const,\n\t\ts => `${s}c` as const,\n\t\ts => `${s}d` as const,\n\t\ts => `${s}e` as const,\n\t\ts => `${s}f` as const,\n\t\ts => `${s}g` as const,\n\t\ts => `${s}h` as const,\n\t\ts => `${s}i` as const,\n\t\ts => `${s}j` as const,\n\t\ts => `${s}k` as const,\n\t\ts => `${s}l` as const,\n\t\ts => `${s}m` as const,\n\t\ts => `${s}n` as const,\n\t\ts => `${s}o` as const,\n\t\ts => `${s}p` as const,\n\t\ts => `${s}q` as const,\n\t\ts => `${s}r` as const\n\t)\n\treturn out\n}).types([6603, \"instantiations\"])\n\nbench(\"to-string\", () => type(\"string.numeric.parse |> number.integer\")).types([\n\t2157,\n\t\"instantiations\"\n])\n\nbench(\"to-chain\", () =>\n\ttype(\"string.numeric.parse\").to(\"number.integer\")\n).types([2241, \"instantiations\"])\n\nbench(\"to-tuple\", () =>\n\ttype([\"string.numeric.parse\", \"|>\", \"number.integer\"])\n).types([2001, \"instantiations\"])\n\nbench(\"to-args\", () =>\n\ttype(\"string.numeric.parse\", \"|>\", \"number.integer\")\n).types([3928, \"instantiations\"])\n\nbench(\"base object\", () =>\n\ttype({\n\t\treadonly: \"'readonly'\",\n\t\tkeyof: \"'keyof'\",\n\t\tget: \"'get'\",\n\t\tpick: \"'pick'\",\n\t\tomit: \"'omit'\",\n\t\tmerge: \"'merge'\",\n\t\trequired: \"'required'\",\n\t\tpartial: \"'partial'\",\n\t\tmap: \"'map'\",\n\t\tas: \"'as'\",\n\t\tand: \"'and'\",\n\t\tor: \"'or'\",\n\t\textract: \"'extract'\",\n\t\texclude: \"'exclude'\",\n\t\tconfigure: \"'configure'\",\n\t\tdescribe: \"'describe'\",\n\t\tonUndeclaredKey: \"'onUndeclaredKey'\",\n\t\tonDeepUndeclaredKey: \"'onDeepUndeclaredKey'\",\n\t\tbrand: \"'brand'\",\n\t\tarray: \"'array'\",\n\t\tfilter: \"'filter'\",\n\t\tnarrow: \"'narrow'\"\n\t})\n).types([12215, \"instantiations\"])\n\ntype Expected = {\n\treadonly: \"readonly\"\n\tkeyof: \"keyof\"\n\tget: \"get\"\n\tpick: \"pick\"\n\tomit: \"omit\"\n\tmerge: \"merge\"\n\trequired: \"required\"\n\tpartial: \"partial\"\n\tmap: \"map\"\n\tas: \"as\"\n\tand: \"and\"\n\tor: \"or\"\n\textract: \"extract\"\n\texclude: \"exclude\"\n\tconfigure: \"configure\"\n\tdescribe: \"describe\"\n\tonUndeclaredKey: \"onUndeclaredKey\"\n\tonDeepUndeclaredKey: \"onDeepUndeclaredKey\"\n\tbrand: \"brand\"\n\tarray: \"array\"\n\tfilter: \"filter\"\n\tnarrow: \"narrow\"\n}\n\nbench(\"base object\", () =>\n\tdeclare<Expected>().type({\n\t\treadonly: \"'readonly'\",\n\t\tkeyof: \"'keyof'\",\n\t\tget: \"'get'\",\n\t\tpick: \"'pick'\",\n\t\tomit: \"'omit'\",\n\t\tmerge: \"'merge'\",\n\t\trequired: \"'required'\",\n\t\tpartial: \"'partial'\",\n\t\tmap: \"'map'\",\n\t\tas: \"'as'\",\n\t\tand: \"'and'\",\n\t\tor: \"'or'\",\n\t\textract: \"'extract'\",\n\t\texclude: \"'exclude'\",\n\t\tconfigure: \"'configure'\",\n\t\tdescribe: \"'describe'\",\n\t\tonUndeclaredKey: \"'onUndeclaredKey'\",\n\t\tonDeepUndeclaredKey: \"'onDeepUndeclaredKey'\",\n\t\tbrand: \"'brand'\",\n\t\tarray: \"'array'\",\n\t\tfilter: \"'filter'\",\n\t\tnarrow: \"'narrow'\"\n\t})\n).types([12946, \"instantiations\"])\n"
  },
  {
    "path": "ark/type/__tests__/optional.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { type } from \"arktype\"\nimport { shallowOptionalMessage } from \"arktype/internal/parser/ast/validate.ts\"\n\ncontextualize(() => {\n\tit(\"no shallow default in tuple expression\", () => {\n\t\tattest(() =>\n\t\t\t// @ts-expect-error\n\t\t\ttype([\"string?\", \"|\", \"number\"])\n\t\t).throwsAndHasTypeError(shallowOptionalMessage)\n\n\t\tattest(() =>\n\t\t\t// @ts-expect-error\n\t\t\ttype([\"string\", \"|\", [\"number\", \"?\"]])\n\t\t).throwsAndHasTypeError(shallowOptionalMessage)\n\t})\n\n\tit(\"no shallow default in scope\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type.module({ foo: \"string?\" })).throwsAndHasTypeError(\n\t\t\tshallowOptionalMessage\n\t\t)\n\n\t\t// @ts-expect-error\n\t\tattest(() => type.module({ foo: [\"string\", \"?\"] })).throwsAndHasTypeError(\n\t\t\tshallowOptionalMessage\n\t\t)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/pipe.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport {\n\tassertNodeKind,\n\tintrinsic,\n\twriteIndiscriminableMorphMessage,\n\twriteInvalidOperandMessage,\n\twriteMorphIntersectionMessage,\n\ttype ArkErrors\n} from \"@ark/schema\"\nimport { keywords, scope, type, type Type } from \"arktype\"\nimport type { Out, To } from \"arktype/internal/attributes.ts\"\nimport { writeMissingRightOperandMessage } from \"arktype/internal/parser/shift/operand/unenclosed.ts\"\n\ncontextualize(() => {\n\tit(\"base\", () => {\n\t\tconst T = type(\"number\").pipe(data => `${data}`)\n\t\tattest<Type<(In: number) => Out<string>>>(T)\n\t\tattest<string>(T.infer)\n\t\tattest<number>(T.in.infer)\n\t\tconst out = T(5)\n\t\tattest<string | type.errors>(out).equals(\"5\")\n\t\tconst result = T(\"foo\")\n\t\tattest(result.toString()).snap(\"must be a number (was a string)\")\n\t})\n\n\tit(\"disjoint\", () => {\n\t\tattest(() => type(\"number>5\").pipe(type(\"number<3\"))).throws.snap(\n\t\t\t\"ParseError: Intersection of > 5 and < 3 results in an unsatisfiable type\"\n\t\t)\n\t})\n\n\tit(\"to\", () => {\n\t\tconst T = type(\"string.json.parse\").to({\n\t\t\tname: \"string\",\n\t\t\tage: \"number\"\n\t\t})\n\n\t\tconst tOut = T.out\n\t\tconst Expected = type({\n\t\t\tname: \"string\",\n\t\t\tage: \"number\"\n\t\t})\n\n\t\tattest<typeof Expected.t>(tOut.t)\n\t\tattest(tOut.expression).equals(Expected.expression)\n\t})\n\n\tdescribe(\"to string syntax\", () => {\n\t\tit(\"to validator\", () => {\n\t\t\tconst trimToNonEmpty = type(\"string.trim |> string > 0\")\n\t\t\tconst Expected = type(\"string.trim\").to(\"string > 0\")\n\n\t\t\tattest<typeof Expected>(trimToNonEmpty)\n\t\t\tattest(trimToNonEmpty.expression).equals(Expected.expression)\n\t\t})\n\n\t\tit(\"to morph\", () => {\n\t\t\tconst trimAndParseNumber = type(\"string.trim |> string.numeric.parse\")\n\t\t\tconst Expected = type(\"string.trim\").to(\"string.numeric.parse\")\n\n\t\t\tattest<typeof Expected>(trimAndParseNumber)\n\t\t\tattest(trimAndParseNumber.expression).equals(Expected.expression)\n\t\t})\n\n\t\tit(\"lower precedence than union\", () => {\n\t\t\tconst T = type(\"string.numeric.parse |> number.integer | number.safe\")\n\t\t\tconst Expected = type(\"string.numeric.parse\").to(\n\t\t\t\t\"number.integer | number.safe\"\n\t\t\t)\n\n\t\t\tattest<typeof Expected>(T)\n\t\t\tattest(T.expression).equals(Expected.expression)\n\t\t})\n\n\t\tit(\"lower precedence than union reversed\", () => {\n\t\t\tconst T = type(\"string.numeric.parse | number.integer |> number.safe\")\n\t\t\tconst Expected = type(\"string.numeric.parse | number.integer\").to(\n\t\t\t\t\"number.safe\"\n\t\t\t)\n\n\t\t\tattest<typeof Expected>(T)\n\t\t\tattest(T.expression).equals(Expected.expression)\n\t\t})\n\n\t\tit(\"missing operand\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"string |>\")).throws(\n\t\t\t\twriteMissingRightOperandMessage(\"|>\")\n\t\t\t)\n\t\t})\n\t})\n\n\tit(\"to morph\", () => {\n\t\tconst restringifyUser = (o: object) => JSON.stringify(o)\n\n\t\tconst T = type(\"string.json.parse\").to([\n\t\t\t{\n\t\t\t\tname: \"string\",\n\t\t\t\tage: \"number\"\n\t\t\t},\n\t\t\t\"=>\",\n\t\t\trestringifyUser\n\t\t])\n\n\t\tattest(T.t).type.toString.snap(\"(In: string) => Out<string>\")\n\n\t\tattest<string>(T.infer)\n\t\tattest(T.json).snap({\n\t\t\tin: \"string\",\n\t\t\tmorphs: [\n\t\t\t\t\"$ark.parseJson\",\n\t\t\t\t{\n\t\t\t\t\tin: {\n\t\t\t\t\t\trequired: [\n\t\t\t\t\t\t\t{ key: \"age\", value: \"number\" },\n\t\t\t\t\t\t\t{ key: \"name\", value: \"string\" }\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdomain: \"object\"\n\t\t\t\t\t},\n\t\t\t\t\tmorphs: [\"$ark.restringifyUser\"]\n\t\t\t\t}\n\t\t\t]\n\t\t})\n\t})\n\n\tdescribe(\"try\", () => {\n\t\tit(\"can catch thrown errors\", () => {\n\t\t\tconst ParseJson = type(\"string\").pipe.try((s): object => JSON.parse(s))\n\n\t\t\tconst out = ParseJson(\"[]\")\n\n\t\t\tattest<ArkErrors | object>(out)\n\t\t\tattest(out).equals([])\n\n\t\t\tconst badOut = ParseJson(\"{ unquoted: true }\")\n\n\t\t\tattest(badOut.toString()).satisfies(\n\t\t\t\t/^must be valid according to an anonymous predicate \\(was aborted due to error:\\n {4}SyntaxError:/\n\t\t\t)\n\t\t})\n\n\t\tit(\"preserves validated out\", () => {\n\t\t\tconst T = type(\"string\").pipe.try(\n\t\t\t\ts => JSON.parse(s),\n\t\t\t\tkeywords.Array.readonly\n\t\t\t)\n\n\t\t\tconst tOut = T.out\n\t\t\tconst ExpectedOut = keywords.Array.readonly\n\n\t\t\tattest<typeof ExpectedOut.t>(tOut.t)\n\t\t\tattest(tOut.expression).equals(ExpectedOut.expression)\n\t\t})\n\t})\n\n\tit(\"can't directly constrain morph\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"string.numeric.parse\").atMostLength(5))\n\t\t\t.throws(\n\t\t\t\twriteInvalidOperandMessage(\n\t\t\t\t\t\"maxLength\",\n\t\t\t\t\tintrinsic.lengthBoundable,\n\t\t\t\t\tkeywords.string.numeric.parse.internal\n\t\t\t\t)\n\t\t\t)\n\t\t\t.type.errors(\"Property 'atMostLength' does not exist\")\n\t})\n\n\tit(\"within type\", () => {\n\t\tconst T = type([\n\t\t\t\"boolean\",\n\t\t\t\"=>\",\n\t\t\tfunction notMorph(data) {\n\t\t\t\treturn !data\n\t\t\t}\n\t\t])\n\t\tattest<Type<(In: boolean) => Out<boolean>>>(T)\n\n\t\tattest(T.json).snap({\n\t\t\tin: [{ unit: false }, { unit: true }],\n\t\t\tmorphs: [\"$ark.notMorph\"]\n\t\t})\n\n\t\tconst out = T(true)\n\t\tattest<boolean | type.errors>(out).equals(false)\n\t\tattest(T(1).toString()).snap(\"must be boolean (was 1)\")\n\t})\n\n\tit(\"unit branches\", () => {\n\t\tconst T = type(\"0 | 1 | 2\").pipe(n => n + 1)\n\t\tattest<(In: 0 | 1 | 2) => Out<number>>(T.t)\n\n\t\tattest(\n\t\t\tT.internal.select({ method: \"assertFind\", kind: \"union\" })\n\t\t\t\t.discriminantJson\n\t\t).snap({\n\t\t\tkind: \"unit\",\n\t\t\tpath: [],\n\t\t\tcases: { \"0\": true, \"1\": true, \"2\": true }\n\t\t})\n\n\t\tattest(T(0)).equals(1)\n\t\tattest(T(3).toString()).snap(\"must be 0, 1 or 2 (was 3)\")\n\t})\n\n\tit(\"type instance reference\", () => {\n\t\tconst User = type({\n\t\t\tname: \"string\",\n\t\t\tage: \"number\"\n\t\t})\n\t\tconst parseUser = type(\"string\").pipe(s => JSON.parse(s), User)\n\n\t\tattest<\n\t\t\t(In: string) => To<{\n\t\t\t\tname: string\n\t\t\t\tage: number\n\t\t\t}>\n\t\t>(parseUser.t)\n\n\t\tconst validUser = { name: \"David\", age: 30 }\n\t\tattest(parseUser(JSON.stringify(validUser))).equals(validUser)\n\t\tconst missingKey = { name: \"David\" }\n\t\tattest(parseUser(JSON.stringify(missingKey)).toString()).snap(\n\t\t\t\"age must be a number (was missing)\"\n\t\t)\n\t})\n\n\tit(\"many pipes\", () => {\n\t\tconst pipeAlphabet = type(\"'a'\").pipe(\n\t\t\ts => `${s}b` as const,\n\t\t\ts => `${s}c` as const,\n\t\t\ts => `${s}d` as const,\n\t\t\ts => `${s}e` as const,\n\t\t\ts => `${s}f` as const,\n\t\t\ts => `${s}g` as const,\n\t\t\ts => `${s}h` as const,\n\t\t\ts => `${s}i` as const,\n\t\t\ts => `${s}j` as const,\n\t\t\ts => `${s}k` as const,\n\t\t\ts => `${s}l` as const,\n\t\t\ts => `${s}m` as const,\n\t\t\ts => `${s}n` as const,\n\t\t\ts => `${s}o` as const,\n\t\t\ts => `${s}p` as const,\n\t\t\ts => `${s}q` as const,\n\t\t\ts => `${s}r` as const\n\t\t)\n\t\tattest<\"abcdefghijklmnopqr\">(pipeAlphabet.infer)\n\t\tattest(pipeAlphabet(\"a\")).equals(\"abcdefghijklmnopqr\")\n\t})\n\n\tit(\"uses pipe for consecutive types\", () => {\n\t\tconst Bar = type({ bar: \"number\" })\n\t\tconst T = type({ foo: \"string\" }).pipe(Bar)\n\t\tattest<{\n\t\t\tfoo: string\n\t\t\tbar: number\n\t\t}>(T.t)\n\t\tconst Expected = type({ foo: \"string\", bar: \"number\" })\n\t\tattest(T.json).equals(Expected.json)\n\t})\n\n\tit(\"disjoint\", () => {\n\t\tattest(() => type(\"number>5\").pipe(type(\"number<3\"))).throws.snap(\n\t\t\t\"ParseError: Intersection of > 5 and < 3 results in an unsatisfiable type\"\n\t\t)\n\t})\n\n\tit(\"extract in/out at path\", () => {\n\t\tconst T = type({\n\t\t\tfoo: type(\"number\").pipe(n => `${n}`, type.string)\n\t\t})\n\n\t\tattest<{ foo: number }>(T.in.t)\n\t\tattest(T.in.expression).snap(\"{ foo: number }\")\n\n\t\tattest<{ foo: string }>(T.out.t)\n\t\tattest(T.out.expression).snap(\"{ foo: string }\")\n\t})\n\n\tit(\"uses pipe for many consecutive types\", () => {\n\t\tconst T = type({ a: \"1\" }).pipe(\n\t\t\ttype({ b: \"1\" }),\n\t\t\ttype({ c: \"1\" }),\n\t\t\ttype({ d: \"1\" })\n\t\t)\n\t\tattest<\n\t\t\tType<{\n\t\t\t\ta: 1\n\t\t\t\tb: 1\n\t\t\t\tc: 1\n\t\t\t\td: 1\n\t\t\t}>\n\t\t>(T)\n\t\tconst Expected = type({ a: \"1\", b: \"1\", c: \"1\", d: \"1\" })\n\t\tattest(T.json).equals(Expected.json)\n\t})\n\n\tit(\"two morphs\", () => {\n\t\tconst inefficientStringIsEmpty = type(\"string\").pipe(\n\t\t\ts => s.length,\n\t\t\tlength => length === 0\n\t\t)\n\n\t\tattest<(In: string) => Out<boolean>>(inefficientStringIsEmpty.t)\n\t\tattest(inefficientStringIsEmpty(\"\")).equals(true)\n\t\tattest(inefficientStringIsEmpty(\"foo\")).equals(false)\n\t\tattest(inefficientStringIsEmpty(0).toString()).snap(\n\t\t\t\"must be a string (was a number)\"\n\t\t)\n\t})\n\n\tit(\"any as out\", () => {\n\t\tconst T = type(\"string\", \"=>\", s => s as any)\n\t\tattest<string>(T.in.infer)\n\t\t// https://github.com/arktypeio/arktype/issues/1023\n\t\t// attest<any>(T.infer)\n\t})\n\n\tit(\"never as out\", () => {\n\t\tconst T = type(\"string\", \"=>\", s => s as never)\n\t\tattest<string>(T.in.infer)\n\t\tattest<never>(T.infer)\n\t})\n\n\tit(\"return error\", () => {\n\t\tconst divide100By = type(\"number\", \"=>\", (n, ctx) =>\n\t\t\tn !== 0 ? 100 / n : ctx.error(\"non-zero\")\n\t\t)\n\t\tattest<(In: number) => Out<number>>(divide100By.t)\n\t\tattest(divide100By(5)).equals(20)\n\t\tattest(divide100By(0).toString()).snap(\"must be non-zero (was 0)\")\n\t})\n\n\tit(\"at path\", () => {\n\t\tconst T = type({ a: [\"string\", \"=>\", data => data.length] })\n\t\tattest<{ a: (In: string) => Out<number> }>(T.t)\n\n\t\tconst input = { a: \"four\" }\n\n\t\tconst out = T(input)\n\n\t\tattest<{ a: number } | type.errors>(out).equals({ a: 4 })\n\t})\n\n\tit(\"doesn't pipe on error\", () => {\n\t\tconst A = type({ a: \"number\" }).pipe(function addOne(o) {\n\t\t\treturn o.a + 1\n\t\t})\n\n\t\tconst B = type({ a: \"string\" }, \"=>\", function appendExclamation(o) {\n\t\t\treturn o.a + \"!\"\n\t\t})\n\n\t\tconst T = B.or(A)\n\n\t\tattest<\n\t\t\t| ((In: { a: string }) => Out<string>)\n\t\t\t| ((In: { a: number }) => Out<number>)\n\t\t>(T.t)\n\t\tattest(T.json).snap([\n\t\t\t{\n\t\t\t\tin: { required: [{ key: \"a\", value: \"number\" }], domain: \"object\" },\n\t\t\t\tmorphs: [\"$ark.addOne\"]\n\t\t\t},\n\t\t\t{\n\t\t\t\tin: { required: [{ key: \"a\", value: \"string\" }], domain: \"object\" },\n\t\t\t\tmorphs: [\"$ark.appendExclamation\"]\n\t\t\t}\n\t\t])\n\n\t\tattest(T({ a: 2 })).snap(3)\n\t})\n\n\tit(\"in array\", () => {\n\t\tconst types = scope({\n\t\t\tlengthOfString: [\"string\", \"=>\", data => data.length],\n\t\t\tmapToLengths: \"lengthOfString[]\"\n\t\t}).export()\n\t\tattest<((In: string) => Out<number>)[]>(types.mapToLengths.t)\n\t\tconst out = types.mapToLengths([\"1\", \"22\", \"333\"])\n\t\tattest<number[] | type.errors>(out).equals([1, 2, 3])\n\t})\n\n\tit(\"object to string\", () => {\n\t\tconst T = type([{ a: \"string\" }, \"=>\", data => JSON.stringify(data)])\n\t\tconst out = T({ a: \"foo\" })\n\t\tattest<string | type.errors>(out).snap('{\"a\":\"foo\"}')\n\t})\n\n\tit(\".out inferred based on validatedOut\", () => {\n\t\tconst Unvalidated = type(\"string\").pipe(s => s.length)\n\n\t\tattest<number>(Unvalidated.infer)\n\t\t// .out won't be known at runtime\n\t\tattest<Type<unknown>>(Unvalidated.out)\n\n\t\tconst validated = Unvalidated.pipe(type(\"number\"))\n\t\t// now that the output is a validated, type, out can be used standalone\n\t\tattest<Type<number>>(validated.out)\n\t})\n\n\tit(\"intersection\", () => {\n\t\tconst $ = scope({\n\t\t\tb: \"3.14\",\n\t\t\ta: [\n\t\t\t\t\"number\",\n\t\t\t\t\"=>\",\n\t\t\t\tfunction stringifyNumberMorph(data) {\n\t\t\t\t\treturn `${data}`\n\t\t\t\t}\n\t\t\t],\n\t\t\taAndB: () => $.type(\"a&b\"),\n\t\t\tbAndA: () => $.type(\"b&a\")\n\t\t})\n\t\tconst types = $.export()\n\n\t\tattest<(In: 3.14) => Out<string>>(types.aAndB.t)\n\t\tattest(types.aAndB.json).snap({\n\t\t\tin: { unit: 3.14 },\n\t\t\tmorphs: [\"$ark.stringifyNumberMorph\"]\n\t\t})\n\t\tattest<typeof types.aAndB>(types.bAndA)\n\t\tattest(types.bAndA).equals(types.aAndB)\n\t})\n\n\tit(\"object intersection\", () => {\n\t\tconst $ = scope({\n\t\t\ta: [\n\t\t\t\t{ a: \"1\" },\n\t\t\t\t\"=>\",\n\t\t\t\t// as of TS 5.8, removing data's explicit annotation leads to\n\t\t\t\t// the output being inferred as `never`\n\t\t\t\tfunction _pipeScopedObjectIntersection(data: { a: 1 }) {\n\t\t\t\t\treturn `${data}`\n\t\t\t\t}\n\t\t\t],\n\t\t\tb: { b: \"2\" },\n\t\t\tc: \"a&b\"\n\t\t})\n\t\tconst types = $.export()\n\n\t\tattest(types.c.t).type.toString.snap(\"(In: { a: 1; b: 2 }) => Out<string>\")\n\t\tattest(types.c.json).snap({\n\t\t\tin: {\n\t\t\t\trequired: [\n\t\t\t\t\t{ key: \"a\", value: { unit: 1 } },\n\t\t\t\t\t{ key: \"b\", value: { unit: 2 } }\n\t\t\t\t],\n\t\t\t\tdomain: \"object\"\n\t\t\t},\n\t\t\tmorphs: [\"$ark._pipeScopedObjectIntersection\"]\n\t\t})\n\t})\n\n\tit(\"union\", () => {\n\t\tconst types = scope({\n\t\t\ta: [\n\t\t\t\t\"number\",\n\t\t\t\t\"=>\",\n\t\t\t\tfunction _stringifyNumberUnionPipe(data) {\n\t\t\t\t\treturn `${data}`\n\t\t\t\t}\n\t\t\t],\n\t\t\tb: \"boolean\",\n\t\t\taOrB: \"a|b\",\n\t\t\tbOrA: \"b|a\"\n\t\t}).export()\n\t\tattest<boolean | ((In: number) => Out<string>)>(types.aOrB.t)\n\n\t\tattest(types.aOrB.json).snap([\n\t\t\t{ in: \"number\", morphs: [\"$ark._stringifyNumberUnionPipe\"] },\n\t\t\t{ unit: false },\n\t\t\t{ unit: true }\n\t\t])\n\t\tattest<typeof types.aOrB>(types.bOrA)\n\t\tattest(types.bOrA.json).equals(types.aOrB.json)\n\t})\n\n\tit(\"union with output\", () => {\n\t\tconst T = type(\"number|string.numeric.parse\")\n\t\tattest<number>(T.infer)\n\t\tattest<string | number>(T.inferIn)\n\t})\n\n\tit(\"deep union\", () => {\n\t\tconst types = scope({\n\t\t\ta: {\n\t\t\t\ta: [\n\t\t\t\t\t\"number>0\",\n\t\t\t\t\t\"=>\",\n\t\t\t\t\tfunction _stringifyNumberUnionPipeDeep(data) {\n\t\t\t\t\t\treturn `${data}`\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\tb: { a: \"Function\" },\n\t\t\tc: \"a|b\"\n\t\t}).export()\n\t\tattest<\n\t\t\t| {\n\t\t\t\t\ta: (In: number) => Out<string>\n\t\t\t  }\n\t\t\t| {\n\t\t\t\t\ta: Function\n\t\t\t  }\n\t\t>(types.c.t)\n\n\t\tattest(types.c.json).snap([\n\t\t\t{ required: [{ key: \"a\", value: \"Function\" }], domain: \"object\" },\n\t\t\t{\n\t\t\t\trequired: [\n\t\t\t\t\t{\n\t\t\t\t\t\tkey: \"a\",\n\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\tin: { domain: \"number\", min: { exclusive: true, rule: 0 } },\n\t\t\t\t\t\t\tmorphs: [\"$ark._stringifyNumberUnionPipeDeep\"]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\tdomain: \"object\"\n\t\t\t}\n\t\t])\n\t})\n\n\tit(\"chained reference\", () => {\n\t\tconst $ = scope({\n\t\t\ta: type(\"string\").pipe(function stringToLength(s) {\n\t\t\t\treturn s.length\n\t\t\t}),\n\t\t\tb: () =>\n\t\t\t\t$.type(\"a\").pipe(function isZeroLength(n) {\n\t\t\t\t\treturn n === 0\n\t\t\t\t})\n\t\t})\n\t\tconst types = $.export()\n\t\tattest<(In: string) => Out<boolean>>(types.b.t)\n\n\t\tattest(types.b.json).snap({\n\t\t\tin: \"string\",\n\t\t\tmorphs: [\"$ark.stringToLength\", \"$ark.isZeroLength\"]\n\t\t})\n\t})\n\n\tit(\"chained nested\", () => {\n\t\tconst $ = scope({\n\t\t\ta: type(\"string\").pipe(function chainedNestedToLength(s) {\n\t\t\t\treturn s.length\n\t\t\t}),\n\t\t\tb: () =>\n\t\t\t\t$.type({ a: \"a\" }).pipe(function chainedNestedGetA({ a }) {\n\t\t\t\t\treturn a === 0\n\t\t\t\t})\n\t\t})\n\n\t\tconst types = $.export()\n\t\tattest<(In: { a: string }) => Out<boolean>>(types.b.t)\n\t\tattest(types.b.json).snap({\n\t\t\tin: {\n\t\t\t\trequired: [\n\t\t\t\t\t{\n\t\t\t\t\t\tkey: \"a\",\n\t\t\t\t\t\tvalue: { in: \"string\", morphs: [\"$ark.chainedNestedToLength\"] }\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\tdomain: \"object\"\n\t\t\t},\n\t\t\tmorphs: [\"$ark.chainedNestedGetA\"]\n\t\t})\n\t})\n\n\tit(\"directly nested\", () => {\n\t\tconst A = type(\"string\", \"=>\", function _directlyNestedStringToLength(s) {\n\t\t\treturn s.length\n\t\t})\n\t\tconst T = type(\n\t\t\t{\n\t\t\t\t// doesn't work with a nested tuple expression here due to a TS limitation\n\t\t\t\tA\n\t\t\t},\n\t\t\t\"=>\",\n\t\t\tfunction _directlyNestedRoot({ A }) {\n\t\t\t\treturn A === 0\n\t\t\t}\n\t\t)\n\t\tattest<(In: { A: string }) => Out<boolean>>(T.t)\n\t\tassertNodeKind(T.internal, \"morph\")\n\t\tattest(T.json).snap({\n\t\t\tin: {\n\t\t\t\trequired: [\n\t\t\t\t\t{\n\t\t\t\t\t\tkey: \"A\",\n\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\tin: \"string\",\n\t\t\t\t\t\t\tmorphs: [\"$ark._directlyNestedStringToLength\"]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\tdomain: \"object\"\n\t\t\t},\n\t\t\tmorphs: [\"$ark._directlyNestedRoot\"]\n\t\t})\n\t})\n\n\tit(\"discriminable tuple union\", () => {\n\t\tconst $ = scope({\n\t\t\ta: () =>\n\t\t\t\t$.type([\"string\"]).pipe(function _discriminableTupleUnionPipe(s) {\n\t\t\t\t\treturn [...s, \"!\"]\n\t\t\t\t}),\n\t\t\tb: [\"number\"],\n\t\t\tc: () => $.type(\"a|b\")\n\t\t})\n\t\tconst types = $.export()\n\n\t\tattest<[number] | ((In: [string]) => Out<string[]>)>(types.c.t)\n\n\t\tattest(types.c.internal.assertHasKind(\"union\").discriminantJson).snap({\n\t\t\tkind: \"domain\",\n\t\t\tpath: [\"0\"],\n\t\t\tcases: {\n\t\t\t\t'\"number\"': {\n\t\t\t\t\tsequence: { prefix: [\"number\"] },\n\t\t\t\t\tproto: \"Array\",\n\t\t\t\t\texactLength: 1\n\t\t\t\t},\n\t\t\t\t'\"string\"': {\n\t\t\t\t\tin: {\n\t\t\t\t\t\tsequence: { prefix: [\"string\"] },\n\t\t\t\t\t\tproto: \"Array\",\n\t\t\t\t\t\texactLength: 1\n\t\t\t\t\t},\n\t\t\t\t\tmorphs: [\"$ark._discriminableTupleUnionPipe\"]\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t})\n\n\tit(\"ArkTypeError not included in return\", () => {\n\t\tconst ParsedInt = type([\n\t\t\t\"string\",\n\t\t\t\"=>\",\n\t\t\t(s, ctx) => {\n\t\t\t\tconst result = Number.parseInt(s)\n\t\t\t\tif (Number.isNaN(result)) return ctx.error(\"an integer string\")\n\n\t\t\t\treturn result\n\t\t\t}\n\t\t])\n\t\tattest<(In: string) => Out<number>>(ParsedInt.t)\n\t\tattest(ParsedInt(\"5\")).snap(5)\n\t\tattest(ParsedInt(\"five\").toString()).snap(\n\t\t\t'must be an integer string (was \"five\")'\n\t\t)\n\t})\n\n\tit(\"nullable return\", () => {\n\t\tconst toNullableNumber = type([\"string\", \"=>\", s => s.length || null])\n\t\tattest<(In: string) => Out<number | null>>(toNullableNumber.t)\n\t})\n\n\tit(\"undefinable return\", () => {\n\t\tconst toUndefinableNumber = type([\n\t\t\t\"string\",\n\t\t\t\"=>\",\n\t\t\ts => s.length || undefined\n\t\t])\n\t\tattest<(In: string) => Out<number | undefined>>(toUndefinableNumber.t)\n\t})\n\n\tit(\"null or undefined return\", () => {\n\t\tconst toMaybeNumber = type([\n\t\t\t\"string\",\n\t\t\t\"=>\",\n\t\t\ts =>\n\t\t\t\ts.length === 0 ? undefined\n\t\t\t\t: s.length === 1 ? null\n\t\t\t\t: s.length\n\t\t])\n\t\tattest<(In: string) => Out<number | null | undefined>>(toMaybeNumber.t)\n\t})\n\n\tit(\"deep intersection\", () => {\n\t\tconst types = scope({\n\t\t\ta: {\n\t\t\t\ta: [\n\t\t\t\t\t\"number>0\",\n\t\t\t\t\t\"=>\",\n\t\t\t\t\tfunction _deepIntersectionPipePlusOne(data) {\n\t\t\t\t\t\treturn data + 1\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\tb: { a: \"1\" },\n\t\t\tc: \"a&b\"\n\t\t}).export()\n\t\tattest<{ a: (In: 1) => Out<number> }>(types.c.t)\n\n\t\tattest(types.c.json).snap({\n\t\t\trequired: [\n\t\t\t\t{\n\t\t\t\t\tkey: \"a\",\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\tin: { unit: 1 },\n\t\t\t\t\t\tmorphs: [\"$ark._deepIntersectionPipePlusOne\"]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t],\n\t\t\tdomain: \"object\"\n\t\t})\n\t})\n\n\tit(\"morph intersection\", () => {\n\t\tattest(() =>\n\t\t\tscope({\n\t\t\t\ta: [\"string\", \"=>\", data => `${data}`],\n\t\t\t\tb: [\"string\", \"=>\", data => `${data}!!!`],\n\t\t\t\tc: \"a&b\"\n\t\t\t}).export()\n\t\t).throws(\n\t\t\twriteMorphIntersectionMessage(\n\t\t\t\t\"(In: string) => Out<unknown>\",\n\t\t\t\t\"(In: string) => Out<unknown>\"\n\t\t\t)\n\t\t)\n\t})\n\n\tit(\"indiscriminable union\", () => {\n\t\tattest(() => {\n\t\t\tscope({\n\t\t\t\ta: [\"/.*/\", \"=>\", s => s.trim()],\n\t\t\t\tb: \"string\",\n\t\t\t\tc: \"a|b\"\n\t\t\t}).export()\n\t\t}).throws(\n\t\t\twriteIndiscriminableMorphMessage(\"string\", \"(In: /.*/) => Out<unknown>\")\n\t\t)\n\t})\n\n\tit(\"deep morph intersection\", () => {\n\t\tattest(() => {\n\t\t\tscope({\n\t\t\t\ta: { a: [\"number\", \"=>\", data => `${data}`] },\n\t\t\t\tb: { a: [\"number\", \"=>\", data => `${data}!!!`] },\n\t\t\t\tc: \"a&b\"\n\t\t\t}).export()\n\t\t}).throws(\n\t\t\twriteMorphIntersectionMessage(\n\t\t\t\t\"(In: number) => Out<unknown>\",\n\t\t\t\t\"(In: number) => Out<unknown>\"\n\t\t\t)\n\t\t)\n\t})\n\n\tit(\"deep indiscriminable\", () => {\n\t\tconst $ = scope({\n\t\t\ta: { foo: [\"string\", \"=>\", s => s.trim()] },\n\t\t\tb: { foo: \"symbol\" },\n\t\t\tc: { bar: \"symbol\" }\n\t\t})\n\n\t\t// this is fine as a | b can be discriminated via foo\n\t\tconst T = $.type(\"a|b\")\n\t\tattest<\n\t\t\t| {\n\t\t\t\t\tfoo: (In: string) => Out<string>\n\t\t\t  }\n\t\t\t| {\n\t\t\t\t\tfoo: symbol\n\t\t\t  }\n\t\t>(T.t)\n\n\t\tattest(() => $.type(\"a|c\")).throws(\n\t\t\twriteIndiscriminableMorphMessage(\n\t\t\t\t\"{ bar: symbol }\",\n\t\t\t\t\"{ foo: (In: string) => Out<unknown> }\"\n\t\t\t)\n\t\t)\n\t})\n\n\tit(\"array double intersection\", () => {\n\t\tattest(() => {\n\t\t\tscope({\n\t\t\t\ta: { a: [\"number>0\", \"=>\", data => data + 1] },\n\t\t\t\tb: { a: [\"number>0\", \"=>\", data => data + 2] },\n\t\t\t\tc: \"a[]&b[]\"\n\t\t\t}).export()\n\t\t}).throws(\n\t\t\twriteMorphIntersectionMessage(\n\t\t\t\t\"(In: number > 0) => Out<unknown>\",\n\t\t\t\t\"(In: number > 0) => Out<unknown>\"\n\t\t\t)\n\t\t)\n\t})\n\n\tit(\"undiscriminated morph at path\", () => {\n\t\tattest(() => {\n\t\t\tscope({\n\t\t\t\ta: { a: [\"string\", \"=>\", s => s.trim()] },\n\t\t\t\tb: { b: \"bigint\" },\n\t\t\t\tc: { key: \"a|b\" }\n\t\t\t}).export()\n\t\t}).throws(\n\t\t\twriteIndiscriminableMorphMessage(\n\t\t\t\t\"{ a: (In: string) => Out<unknown> }\",\n\t\t\t\t\"{ b: bigint }\"\n\t\t\t)\n\t\t)\n\t})\n\n\tit(\"helper morph intersection\", () => {\n\t\tattest(() =>\n\t\t\ttype(\"string\")\n\t\t\t\t.pipe(s => s.length)\n\t\t\t\t.and(type(\"string\").pipe(s => s.length))\n\t\t).throws(\n\t\t\twriteMorphIntersectionMessage(\n\t\t\t\t\"(In: string) => Out<unknown>\",\n\t\t\t\t\"(In: string) => Out<unknown>\"\n\t\t\t)\n\t\t)\n\t})\n\n\tit(\"union helper undiscriminated\", () => {\n\t\tattest(() =>\n\t\t\ttype(\"string\")\n\t\t\t\t.pipe(s => s.length)\n\t\t\t\t.or(\"'foo'\")\n\t\t).throws(\n\t\t\twriteIndiscriminableMorphMessage(\"(In: string) => Out<unknown>\", '\"foo\"')\n\t\t)\n\t})\n\n\tit(\"allows undiscriminated union if morphs are equal\", () => {\n\t\tconst T = type({ foo: \"1\" })\n\t\t\t.or({ bar: \"1\" })\n\t\t\t.pipe(function getObjectValues(o) {\n\t\t\t\treturn Object.values(o)\n\t\t\t})\n\n\t\tattest<\n\t\t\t(\n\t\t\t\tIn:\n\t\t\t\t\t| {\n\t\t\t\t\t\t\tfoo: 1\n\t\t\t\t\t  }\n\t\t\t\t\t| {\n\t\t\t\t\t\t\tbar: 1\n\t\t\t\t\t  }\n\t\t\t) => Out<1[]>\n\t\t>(T.t)\n\n\t\tattest(T.json).snap({\n\t\t\tin: [\n\t\t\t\t{ required: [{ key: \"bar\", value: { unit: 1 } }], domain: \"object\" },\n\t\t\t\t{ required: [{ key: \"foo\", value: { unit: 1 } }], domain: \"object\" }\n\t\t\t],\n\t\t\tmorphs: [\"$ark.getObjectValues\"]\n\t\t})\n\t\tattest(T({ foo: 1 })).snap([1])\n\t\tattest(T({ bar: 1 })).snap([1])\n\t\tattest(T({ baz: 2 }).toString()).snap(\n\t\t\t\"bar must be 1 (was missing) or foo must be 1 (was missing)\"\n\t\t)\n\t})\n\tit(\"allows undiscriminated union if morphs at path are equal\", () => {\n\t\tconst T = type({ l: \"1\", n: \"string.numeric.parse\" }, \"|\", {\n\t\t\tr: \"1\",\n\t\t\tn: \"string.numeric.parse\"\n\t\t})\n\n\t\tattest(T).type.toString.snap(`Type<\n\t| { l: 1; n: (In: string) => To<number> }\n\t| { r: 1; n: (In: string) => To<number> },\n\t{}\n>`)\n\n\t\tattest(T.expression).snap(\n\t\t\t\"{ l: 1, n: (In: /^(?:(?!^-0\\\\.?0*$)(?:-?(?:(?:0|[1-9]\\\\d*)(?:\\\\.\\\\d+)?)|\\\\.\\\\d+?))$/) => Out<number> } | { n: (In: /^(?:(?!^-0\\\\.?0*$)(?:-?(?:(?:0|[1-9]\\\\d*)(?:\\\\.\\\\d+)?)|\\\\.\\\\d+?))$/) => Out<number>, r: 1 }\"\n\t\t)\n\t\tattest(T({ l: 1, n: \"234\" })).snap({ l: 1, n: 234 })\n\t\tattest(T({ r: 1, n: \"234\" })).snap({ r: 1, n: 234 })\n\t\tattest(T({ l: 1, r: 1, n: \"234\" })).snap({ l: 1, r: 1, n: 234 })\n\t\tattest(T({ n: \"234\" }).toString()).snap(\n\t\t\t\"l must be 1 (was missing) or r must be 1 (was missing)\"\n\t\t)\n\t})\n\tit(\"fails on indiscriminable morph in nested union\", () => {\n\t\tconst indiscriminable = () =>\n\t\t\ttype({\n\t\t\t\tfoo: \"boolean | string.date.parse\"\n\t\t\t}).or({\n\t\t\t\tfoo: \"boolean | string.json.parse\"\n\t\t\t})\n\n\t\tattest(indiscriminable).throws\n\t\t\t.snap(`ParseError: An unordered union of a type including a morph and a type with overlapping input is indeterminate:\nLeft: { foo: (In: string) => Out<Date> | false | true }\nRight: { foo: (In: string) => Out<{ [string]: $jsonObject | number | string | false | null | true }> | false | true }`)\n\t})\n\n\tit(\"multiple chained pipes\", () => {\n\t\tconst T = type(\"string.trim\").to(\"string.lower\")\n\n\t\tattest(T.t).type.toString.snap(\"(In: string) => To<string>\")\n\n\t\tattest(T(\"Success\")).equals(\"success\")\n\t\tattest(T(\"success\")).equals(\"success\")\n\t\tattest(T(\"SUCCESS  \")).equals(\"success\")\n\t\tattest(T(\"success  \")).equals(\"success\")\n\t})\n\n\t// https://github.com/arktypeio/arktype/issues/1144\n\tit(\"multiple chained pipes with literal output\", () => {\n\t\tconst Base = type(\"string.trim\").to(\"string.lower\")\n\n\t\tconst T = Base.to(\"'success'\")\n\n\t\tattest<(In: string) => To<\"success\">>(T.t)\n\n\t\tattest(T(\"Success\")).equals(\"success\")\n\t\tattest(T(\"success\")).equals(\"success\")\n\t\tattest(T(\"SUCCESS  \")).equals(\"success\")\n\t\tattest(T(\"success  \")).equals(\"success\")\n\t})\n\n\tconst appendLengthMorph = (s: string) => `${s}${s.length}`\n\n\t// https://discord.com/channels/957797212103016458/1291014543635517542\n\tit(\"repeated Type pipe\", () => {\n\t\tconst appendLength = type(\"string\", \"=>\", appendLengthMorph)\n\t\tconst appendLengths = type(\"string\").pipe(appendLength, appendLength)\n\n\t\tattest(appendLengths.json).snap({\n\t\t\tin: \"string\",\n\t\t\tmorphs: [\n\t\t\t\t{\n\t\t\t\t\tin: \"string\",\n\t\t\t\t\tmorphs: [\n\t\t\t\t\t\t\"$ark.appendLengthMorph\",\n\t\t\t\t\t\t{ in: \"string\", morphs: [\"$ark.appendLengthMorph\"] }\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t]\n\t\t})\n\n\t\tattest(appendLengths(\"a\")).snap(\"a12\")\n\t})\n\n\t// https://discord.com/channels/957797212103016458/1291014543635517542\n\tit(\"repeated Type pipe with intermediate morph\", () => {\n\t\tconst appendLength = type(\"string\", \"=>\", appendLengthMorph)\n\n\t\tconst appendSeparatorMorph = (s: string) => `${s}|`\n\n\t\tconst appendSeparatedLengths = type(\"string\").pipe(\n\t\t\tappendLength,\n\t\t\tappendLength,\n\t\t\tappendSeparatorMorph,\n\t\t\tappendLength,\n\t\t\tappendLength\n\t\t)\n\n\t\tattest(appendSeparatedLengths.json).snap({\n\t\t\tin: \"string\",\n\t\t\tmorphs: [\n\t\t\t\t{\n\t\t\t\t\tin: \"string\",\n\t\t\t\t\tmorphs: [\n\t\t\t\t\t\t\"$ark.appendLengthMorph\",\n\t\t\t\t\t\t{ in: \"string\", morphs: [\"$ark.appendLengthMorph\"] }\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t\"$ark.appendSeparatorMorph\",\n\t\t\t\t{\n\t\t\t\t\tin: \"string\",\n\t\t\t\t\tmorphs: [\n\t\t\t\t\t\t\"$ark.appendLengthMorph\",\n\t\t\t\t\t\t{ in: \"string\", morphs: [\"$ark.appendLengthMorph\"] }\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t]\n\t\t})\n\n\t\tattest(appendSeparatedLengths(\"a\")).snap(\"a12|45\")\n\t})\n\n\tit(\"doesn't lose input prop morphs\", () => {\n\t\tconst T = type({\n\t\t\tfoo: type(\"string\").pipe(s => s.length)\n\t\t})\n\t\t\t.pipe(o => o)\n\t\t\t.to({\n\t\t\t\tfoo: \"number\"\n\t\t\t})\n\t\tattest(T({ foo: \"bar\" })).snap({ foo: 3 })\n\n\t\tconst types = scope({\n\t\t\tFrom: { a: [\"1\", \"=>\", () => 2] },\n\t\t\tMorph: [\"From\", \"=>\", e => e],\n\t\t\tTo: { a: \"2\" }\n\t\t}).export()\n\t\tconst U = types.Morph.pipe(e => e, types.To)\n\t\tconst out = U({ a: 1 })\n\t\tattest<\n\t\t\t| ArkErrors\n\t\t\t| {\n\t\t\t\t\ta: 2\n\t\t\t  }\n\t\t>(out).snap({ a: 2 })\n\t})\n\n\t// https://github.com/arktypeio/arktype/issues/1185\n\tit(\"pipe doesn't run on rejected descendant prop\", () => {\n\t\tlet callCount = 0\n\t\tconst T = type({\n\t\t\tkey: \"string\"\n\t\t}).pipe(v => {\n\t\t\tcallCount++\n\t\t\treturn v\n\t\t})\n\n\t\tconst out = T({})\n\n\t\tattest(out.toString()).snap(\"key must be a string (was missing)\")\n\t\tattest(callCount).equals(0)\n\t})\n\n\tit(\"to tuple expression\", () => {\n\t\tconst T = type([\"string.json.parse\", \"|>\", { name: \"string\" }])\n\n\t\tconst Expected = type(\"string.json.parse\").to({ name: \"string\" })\n\n\t\tattest<typeof Expected>(T)\n\t\tattest(T.json).equals(Expected.json)\n\t})\n\n\tit(\"to args expression\", () => {\n\t\tconst T = type(\"string.json.parse\", \"|>\", { name: \"string\" })\n\n\t\tconst Expected = type(\"string.json.parse\").to({ name: \"string\" })\n\n\t\tattest<typeof Expected>(T)\n\t\tattest(T.json).equals(Expected.json)\n\t})\n\n\tit(\"infers distributed pipes\", () => {\n\t\tconst T = type(\"string.numeric.parse | number\").to(\"number > 0\")\n\t\tattest(T.t).type.toString.snap(\"number | ((In: string) => To<number>)\")\n\t})\n\n\tit(\"extracted from cyclic type\", () => {\n\t\tconst T = type({\n\t\t\tmorphed: \"string.numeric.parse\",\n\t\t\t\"nested?\": \"this\"\n\t\t})\n\n\t\tconst t = T.assert({ morphed: \"5\" })\n\n\t\tattest(t).equals({ morphed: 5 })\n\t\tattest<number>(t.morphed)\n\t\tattest<number | undefined>(t.nested?.morphed)\n\t})\n\n\tit(\"extract in/out preserves undeclared rejection\", () => {\n\t\tconst T = type({\n\t\t\t\"+\": \"reject\",\n\t\t\tfoo: \"true\"\n\t\t})\n\n\t\tattest(T.in.expression).snap(\"{ foo: true, + (undeclared): reject }\")\n\t})\n\n\tit(\"complex morphs are applied on correct path\", () => {\n\t\tlet c: null | 1\n\n\t\tconst M = type({\n\t\t\tlist: type(\"object\")\n\t\t\t\t.pipe(e => e)\n\t\t\t\t.pipe(\n\t\t\t\t\ttype({\n\t\t\t\t\t\tz: type(\"unknown\").pipe(() => c)\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t\t.array(),\n\t\t\t_: [\"unknown\", \":\", () => true]\n\t\t})\n\n\t\tc = null\n\t\tattest(() =>\n\t\t\tM.assert({\n\t\t\t\tlist: [{ z: \"\" }, { z: \"\" }]\n\t\t\t})\n\t\t).throws.snap(\"TraversalError: _ must be present (was missing)\")\n\n\t\tc = 1\n\t\tattest(() =>\n\t\t\tM.assert({\n\t\t\t\tlist: [{ z: \"\" }, { z: \"\" }]\n\t\t\t})\n\t\t).throws.snap(\"TraversalError: _ must be present (was missing)\")\n\t})\n\n\t// https://github.com/arktypeio/arktype/pull/1464\n\tit(\"branched optimistic pipe union\", () => {\n\t\tclass TypeA {\n\t\t\ttype = \"typeA\"\n\t\t\tconstructor() {}\n\t\t}\n\n\t\tclass TypeB {\n\t\t\ttype = \"typeB\"\n\t\t\tconstructor() {}\n\t\t}\n\n\t\tconst typeA = new TypeA()\n\n\t\tconst Thing = type.or(\n\t\t\ttype.instanceOf(TypeB),\n\t\t\ttype.string.pipe(_value => new TypeB()),\n\t\t\ttype.instanceOf(TypeA).pipe(_value => new TypeB())\n\t\t)\n\n\t\tconst out = Thing.assert(typeA)\n\t\tattest(out).instanceOf(TypeB)\n\t})\n\n\t// https://github.com/arktypeio/arktype/pull/1464\n\tit(\"complex pipes\", () => {\n\t\tconst inputData = [\n\t\t\t{\n\t\t\t\tOuterKey: [\n\t\t\t\t\t{\n\t\t\t\t\t\tMiddleKey: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tInnerKey: []\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t]\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\n\t\tconst genericSchema = type(\"Record<string, unknown>[]\")\n\t\t\t.pipe.try(arr =>\n\t\t\t\tarr.map(item => {\n\t\t\t\t\tconst [kind, value] = Object.entries(item)[0]\n\t\t\t\t\treturn { kind, value }\n\t\t\t\t})\n\t\t\t)\n\t\t\t.pipe(\n\t\t\t\ttype({ kind: \"string\", value: \"unknown\" })\n\t\t\t\t\t.pipe(item => ({ kind: item.kind, value: item.value }))\n\t\t\t\t\t.array(),\n\t\t\t\tarr =>\n\t\t\t\t\tarr.reduce<Record<string, { value: unknown }>>(\n\t\t\t\t\t\t(acc, { kind, value }) => {\n\t\t\t\t\t\t\tacc[kind] = { value }\n\t\t\t\t\t\t\treturn acc\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{}\n\t\t\t\t\t),\n\t\t\t\ttype({\n\t\t\t\t\tOuterKey: {\n\t\t\t\t\t\tvalue: type({\n\t\t\t\t\t\t\tMiddleKey: type({ InnerKey: type(\"object\") })\n\t\t\t\t\t\t\t\t.array()\n\t\t\t\t\t\t\t\t.pipe(v => v[0])\n\t\t\t\t\t\t}).array()\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t)\n\n\t\tconst result = genericSchema(inputData)\n\t\tattest(result).equals({\n\t\t\tOuterKey: {\n\t\t\t\tvalue: [\n\t\t\t\t\t{\n\t\t\t\t\t\tMiddleKey: { InnerKey: [] }\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t})\n\t})\n\n\t// https://github.com/arktypeio/arktype/pull/1464\n\tit(\"nested pipes\", () => {\n\t\tconst parseFirstElementToNumber = type(\"string[]\")\n\t\t\t.pipe(v => v[0])\n\t\t\t.to(\"string.numeric.parse\")\n\n\t\tconst extractAndParseFirstElement = type({\n\t\t\tValue: parseFirstElementToNumber\n\t\t})\n\t\t\t.array()\n\t\t\t.pipe(v => v[0])\n\n\t\tconst Item = type({\n\t\t\tSubItem: extractAndParseFirstElement,\n\t\t\tMeta: {}\n\t\t})\n\n\t\tconst T = type({\n\t\t\tItem: Item.array()\n\t\t})\n\n\t\tconst data = {\n\t\t\tItem: [\n\t\t\t\t{\n\t\t\t\t\tSubItem: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tValue: [\"0\"]\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tSubItem: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tValue: [\"0\"]\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\n\t\tconst result = T(data)\n\n\t\tattest(result.toString()).snap(`Item[0].Meta must be an object (was missing)\nItem[1].Meta must be an object (was missing)`)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/range.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport {\n\tintrinsic,\n\trootSchema,\n\twriteInvalidLengthBoundMessage,\n\twriteInvalidOperandMessage,\n\twriteUnboundableMessage\n} from \"@ark/schema\"\nimport { writeMalformedNumericLiteralMessage } from \"@ark/util\"\nimport { type } from \"arktype\"\nimport { writeDoubleRightBoundMessage } from \"arktype/internal/parser/ast/bounds.ts\"\nimport {\n\twriteMultipleLeftBoundsMessage,\n\twriteOpenRangeMessage,\n\twriteUnpairableComparatorMessage\n} from \"arktype/internal/parser/reduce/shared.ts\"\nimport { writeInvalidLimitMessage } from \"arktype/internal/parser/shift/operator/bounds.ts\"\n\ncontextualize(() => {\n\tdescribe(\"string expressions\", () => {\n\t\tit(\">\", () => {\n\t\t\tconst T = type(\"number>0\")\n\t\t\tattest<number>(T.infer)\n\t\t\tattest(T).type.toString.snap(\"Type<number, {}>\")\n\t\t\tattest(T.json).snap({\n\t\t\t\tdomain: \"number\",\n\t\t\t\tmin: { exclusive: true, rule: 0 }\n\t\t\t})\n\t\t})\n\n\t\tit(\"<\", () => {\n\t\t\tconst T = type(\"number<10\")\n\t\t\tattest<number>(T.infer)\n\t\t\tattest(T).type.toString.snap(\"Type<number, {}>\")\n\t\t\tconst Expected = rootSchema({\n\t\t\t\tdomain: \"number\",\n\t\t\t\tmax: { rule: 10, exclusive: true }\n\t\t\t})\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"<=\", () => {\n\t\t\tconst T = type(\"number<=-49\")\n\t\t\tattest<number>(T.infer)\n\t\t\tattest(T).type.toString.snap(\"Type<number, {}>\")\n\t\t\tconst Expected = rootSchema({\n\t\t\t\tdomain: \"number\",\n\t\t\t\tmax: { rule: -49, exclusive: false }\n\t\t\t})\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"==\", () => {\n\t\t\tconst T = type(\"number==3211993\")\n\t\t\tattest<number>(T.infer)\n\t\t\tattest(T).type.toString.snap(\"Type<number, {}>\")\n\t\t\tconst Expected = rootSchema({ unit: 3211993 })\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"== length\", () => {\n\t\t\tconst T = type({ code: \"string==6\" })\n\n\t\t\tattest(T({ code: \"123456\" })).snap({ code: \"123456\" })\n\t\t\tattest(T({ code: \"foo\" }).toString()).snap(\n\t\t\t\t\"code must be exactly length 6 (was 3)\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"<,<=\", () => {\n\t\t\tconst T = type(\"-5<number<=5\")\n\t\t\tattest(T).type.toString.snap(\"Type<number, {}>\")\n\t\t\tattest<number>(T.infer)\n\t\t\tconst Expected = rootSchema({\n\t\t\t\tdomain: \"number\",\n\t\t\t\tmin: { rule: -5, exclusive: true },\n\t\t\t\tmax: 5\n\t\t\t})\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"<=,<\", () => {\n\t\t\tconst T = type(\"-3.23<=number<4.654\")\n\t\t\tattest(T).type.toString.snap(\"Type<number, {}>\")\n\t\t\tattest<number>(T.infer)\n\t\t\tconst Expected = rootSchema({\n\t\t\t\tdomain: \"number\",\n\t\t\t\tmin: { rule: -3.23 },\n\t\t\t\tmax: { rule: 4.654, exclusive: true }\n\t\t\t})\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"whitespace following comparator\", () => {\n\t\t\tconst T = type(\"number > 3\")\n\t\t\tattest(T).type.toString.snap(\"Type<number, {}>\")\n\t\t\tattest<number>(T.infer)\n\t\t\tconst Expected = rootSchema({\n\t\t\t\tdomain: \"number\",\n\t\t\t\tmin: { rule: 3, exclusive: true }\n\t\t\t})\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"single Date\", () => {\n\t\t\tconst T = type(\"Date<d'2023/1/12'\")\n\t\t\tattest<Date>(T.infer)\n\t\t\tattest(T).type.toString.snap(\"Type<Date, {}>\")\n\t\t\tattest(T.json).snap({ proto: \"Date\", before: \"2023-01-12T04:59:59.999Z\" })\n\t\t})\n\n\t\tit(\"Date equality\", () => {\n\t\t\tconst T = type(\"Date==d'2020-1-1'\")\n\t\t\tattest<Date>(T.infer)\n\t\t\tattest(T).type.toString.snap(\"Type<Date, {}>\")\n\t\t\tattest(T.json).snap({ unit: \"2020-01-01T05:00:00.000Z\" })\n\t\t\tattest(T.allows(new Date(\"2020/01/01\"))).equals(true)\n\t\t\tattest(T.allows(new Date(\"2020/01/02\"))).equals(false)\n\t\t})\n\n\t\tit(\"double Date\", () => {\n\t\t\tconst T = type(\"d'2001/10/10'< Date < d'2005/10/10'\")\n\t\t\tattest<Date>(T.infer)\n\t\t\tattest(T.t).type.toString.snap(\"Date\")\n\t\t\tattest(T.json).snap({\n\t\t\t\tproto: \"Date\",\n\t\t\t\tbefore: \"2005-10-10T03:59:59.999Z\",\n\t\t\t\tafter: \"2001-10-10T04:00:00.001Z\"\n\t\t\t})\n\t\t\tattest(T.allows(new Date(\"2003/10/10\"))).equals(true)\n\t\t\tattest(T.allows(new Date(\"2001/10/10\"))).equals(false)\n\t\t\tattest(T.allows(new Date(\"2005/10/10\"))).equals(false)\n\t\t})\n\n\t\tit(\"dynamic Date\", () => {\n\t\t\tconst now = new Date()\n\t\t\tconst T = type(`d'2000'< Date <=d'${now.toISOString()}'`)\n\t\t\tattest<Date>(T.infer)\n\t\t\tattest(T).type.toString.snap(\"Type<Date, {}>\")\n\t\t\tattest(T.allows(new Date(now.valueOf() - 1000))).equals(true)\n\t\t\tattest(T.allows(now)).equals(true)\n\t\t\tattest(T.allows(new Date(now.valueOf() + 1000))).equals(false)\n\t\t})\n\n\t\tit(\"exclusive length normalized\", () => {\n\t\t\tconst T = type(\"string > 0\")\n\t\t\tconst Expected = type(\"string >= 1\")\n\n\t\t\tattest(T.expression).equals(Expected.expression)\n\t\t})\n\n\t\tit(\"trivially satisfied length normalized\", () => {\n\t\t\tconst T = type(\"string >= 0\")\n\t\t\tconst Expected = type(\"string\")\n\n\t\t\tattest(T.expression).equals(Expected.expression)\n\t\t})\n\n\t\tit(\"invalid left comparator\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"3>number<5\")).throwsAndHasTypeError(\n\t\t\t\twriteUnpairableComparatorMessage(\">\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"invalid right double-bound comparator\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"3<number==5\")).throwsAndHasTypeError(\n\t\t\t\twriteUnpairableComparatorMessage(\"==\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"unpaired left\", () => {\n\t\t\t// @ts-expect-error temporarily disabled type snapshot as it is returning ''\n\t\t\tattest(() => type(\"3<number\")).throws(writeOpenRangeMessage(3, \">\"))\n\t\t})\n\n\t\tit(\"unpaired left group\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"(-1<=number)\")).throws(writeOpenRangeMessage(-1, \">=\"))\n\t\t})\n\n\t\tit(\"double left\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"3<5<8\")).throwsAndHasTypeError(\n\t\t\t\twriteMultipleLeftBoundsMessage(3, \">\", 5, \">\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"empty range\", () => {\n\t\t\tattest(() => type(\"3<=number<2\")).throws.snap(\n\t\t\t\t\"ParseError: Intersection of < 2 and >= 3 results in an unsatisfiable type\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"double right bound\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"number>0<=200\")).type.errors(\n\t\t\t\twriteDoubleRightBoundMessage(\"number\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"negative-length\", () => {\n\t\t\tattest(() => type(\"string < 0\")).throws(\n\t\t\t\twriteInvalidLengthBoundMessage(\"maxLength\", -1)\n\t\t\t)\n\t\t})\n\n\t\tit(\"non-integer length\", () => {\n\t\t\tattest(() => type(\"string >= 2.5\")).throws(\n\t\t\t\twriteInvalidLengthBoundMessage(\"minLength\", 2.5)\n\t\t\t)\n\t\t})\n\n\t\tit(\"non-narrowed bounds\", () => {\n\t\t\tconst a = 5 as number\n\t\t\tconst b = 7 as number\n\t\t\tconst T = type(`${a}<number<${b}`)\n\t\t\tattest<number>(T.infer)\n\t\t})\n\n\t\tit(\"fails at runtime on malformed right\", () => {\n\t\t\tattest(() => type(\"number<07\")).throws(\n\t\t\t\twriteMalformedNumericLiteralMessage(\"07\", \"number\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"fails at runtime on malformed lower\", () => {\n\t\t\tattest(() => type(\"3.0<number<5\")).throws(\n\t\t\t\twriteMalformedNumericLiteralMessage(\"3.0\", \"number\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"number\", () => {\n\t\t\tattest<number>(type(\"number==-3.14159\").infer)\n\t\t})\n\n\t\tit(\"string\", () => {\n\t\t\tattest<string>(type(\"string<=5\").infer)\n\t\t})\n\n\t\tit(\"array\", () => {\n\t\t\tattest<boolean[]>(type(\"87<=boolean[]<89\").infer)\n\t\t})\n\n\t\tit(\"multiple bound kinds\", () => {\n\t\t\tattest(() =>\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttype(\"(number | boolean[])>0\")\n\t\t\t).throwsAndHasTypeError(writeUnboundableMessage(\"number | boolean[]\"))\n\t\t})\n\n\t\tit(\"unknown\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"unknown<10\")).throwsAndHasTypeError(\n\t\t\t\twriteUnboundableMessage(\"unknown\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"unboundable\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"object>10\")).throwsAndHasTypeError(\n\t\t\t\twriteUnboundableMessage(\"object\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"morph\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"string.trim > 2\"))\n\t\t\t\t.throws.snap(\n\t\t\t\t\t\"ParseError: MinLength operand must be a string or an array (was a morph)\"\n\t\t\t\t)\n\t\t\t\t.type.errors(\n\t\t\t\t\t\"To constrain the output of string.trim, pipe like myMorph.to('number > 0').\\\\nTo constrain the input, intersect like myMorph.and('number > 0').\"\n\t\t\t\t)\n\t\t})\n\n\t\tit(\"same bound kind union\", () => {\n\t\t\tconst T = type(\"1<(number[]|object[])<10\")\n\t\t\tattest<number[] | object[]>(T.infer)\n\t\t\tconst Expected = type(\"1<number[]<10 | 1<object[]<10\")\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"number with right Date bound\", () => {\n\t\t\tattest(() =>\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttype(\"number<d'2001/01/01'\")\n\t\t\t).throwsAndHasTypeError(\n\t\t\t\twriteInvalidLimitMessage(\"<\", \"d'2001/01/01'\", \"right\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"number with left Date bound\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"d'2001/01/01'<number<2\")).throwsAndHasTypeError(\n\t\t\t\twriteInvalidLimitMessage(\">\", \"d'2001/01/01'\", \"left\")\n\t\t\t)\n\t\t})\n\t})\n\n\tdescribe(\"chained\", () => {\n\t\tit(\"atLeast\", () => {\n\t\t\tconst T = type(\"number\").atLeast(5)\n\t\t\tconst Expected = type(\"number>=5\")\n\t\t\tattest<typeof Expected>(T)\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"invalid min operand\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"string\").atLeast(5))\n\t\t\t\t.throws(\n\t\t\t\t\twriteInvalidOperandMessage(\"min\", intrinsic.number, intrinsic.string)\n\t\t\t\t)\n\t\t\t\t.type.errors(\"Property 'atLeast' does not exist\")\n\t\t})\n\n\t\tit(\"moreThan\", () => {\n\t\t\tconst T = type(\"number\").moreThan(5)\n\t\t\tconst Expected = type(\"number>5\")\n\t\t\tattest<typeof Expected>(T)\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"atMost\", () => {\n\t\t\tconst T = type(\"number\").atMost(10)\n\t\t\tconst Expected = type(\"number<=10\")\n\t\t\tattest<typeof Expected>(T)\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"lessThan\", () => {\n\t\t\tconst T = type(\"number\").lessThan(10)\n\t\t\tconst Expected = type(\"number<10\")\n\t\t\tattest<typeof Expected>(T)\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"invalid max operand\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"string\").lessThan(5))\n\t\t\t\t.throws(\n\t\t\t\t\twriteInvalidOperandMessage(\"max\", intrinsic.number, intrinsic.string)\n\t\t\t\t)\n\t\t\t\t.type.errors(\"Property 'lessThan' does not exist\")\n\t\t})\n\n\t\tit(\"atLeastLength\", () => {\n\t\t\tconst T = type(\"string\").atLeastLength(5)\n\t\t\tconst Expected = type(\"string>=5\")\n\t\t\tattest<typeof Expected>(T)\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"moreThanLength\", () => {\n\t\t\tconst T = type(\"string[]\").moreThanLength(5)\n\t\t\tconst Expected = type(\"string[]>5\")\n\t\t\tattest<typeof Expected>(T)\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"invalid minLength operand\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"bigint\").atLeastLength(5))\n\t\t\t\t.throws(\n\t\t\t\t\twriteInvalidOperandMessage(\n\t\t\t\t\t\t\"minLength\",\n\t\t\t\t\t\tintrinsic.lengthBoundable,\n\t\t\t\t\t\tintrinsic.bigint\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t.type.errors(\"Property 'atLeastLength' does not exist\")\n\t\t})\n\n\t\tit(\"atMostLength\", () => {\n\t\t\tconst T = type(\"string\").atMostLength(10)\n\t\t\tconst Expected = type(\"string<=10\")\n\t\t\tattest<typeof Expected>(T)\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"lessThanLength\", () => {\n\t\t\tconst T = type(\"string[]\").lessThanLength(10)\n\t\t\tconst Expected = type(\"string[]<10\")\n\t\t\tattest<typeof Expected>(T)\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"invalid maxLength operand\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"null\").lessThanLength(5))\n\t\t\t\t.throws(\n\t\t\t\t\twriteInvalidOperandMessage(\n\t\t\t\t\t\t\"maxLength\",\n\t\t\t\t\t\tintrinsic.lengthBoundable,\n\t\t\t\t\t\tintrinsic.null\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t.type.errors(\"Property 'lessThanLength' does not exist\")\n\t\t})\n\n\t\tit(\"atOrAfter\", () => {\n\t\t\tconst T = type(\"Date\").atOrAfter(new Date(\"2022-01-01\"))\n\t\t\t// widen the input to a string so both are non-narrowed\n\t\t\tconst Expected = type(`Date>=d'${\"2022-01-01\" as string}'`)\n\t\t\tattest<typeof Expected>(T)\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"laterThan\", () => {\n\t\t\tconst T = type(\"Date\").laterThan(new Date(\"2022-01-01\"))\n\t\t\tconst Expected = type(`Date>d'${\"2022-01-01\" as string}'`)\n\t\t\tattest<typeof Expected>(T)\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"invalid after operand\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"false\").laterThan(new Date()))\n\t\t\t\t.throws(\n\t\t\t\t\twriteInvalidOperandMessage(\"after\", intrinsic.Date, intrinsic.false)\n\t\t\t\t)\n\t\t\t\t.type.errors(\"Property 'laterThan' does not exist\")\n\t\t})\n\n\t\tit(\"atOrBefore\", () => {\n\t\t\tconst T = type(\"Date\").atOrBefore(5)\n\t\t\tconst Expected = type(\"Date<=5\")\n\t\t\tattest<typeof Expected>(T)\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"earlierThan\", () => {\n\t\t\tconst T = type(\"Date\").earlierThan(5)\n\t\t\tconst Expected = type(\"Date<5\")\n\t\t\tattest<typeof Expected>(T)\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"invalid before operand\", () => {\n\t\t\tattest(() =>\n\t\t\t\t// @ts-expect-error\n\t\t\t\ttype(\"unknown\").atOrBefore(new Date())\n\t\t\t)\n\t\t\t\t.throws(\n\t\t\t\t\twriteInvalidOperandMessage(\n\t\t\t\t\t\t\"before\",\n\t\t\t\t\t\tintrinsic.Date,\n\t\t\t\t\t\tintrinsic.unknown\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t.type.errors(\"Property 'atOrBefore' does not exist\")\n\t\t})\n\t})\n\n\tit(\"unit overlap\", () => {\n\t\tconst five = type(\"5 <= number < 10\").and(\"0 < number <= 5\")\n\n\t\tattest(five.expression).equals(\"5\")\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/realWorld.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport {\n\tregisteredReference,\n\ttype ArkErrors,\n\ttype StandardSchemaV1\n} from \"@ark/schema\"\nimport { scope, type, type Module, type Type } from \"arktype\"\nimport type { Out, To } from \"arktype/internal/attributes.ts\"\nimport { AssertionError } from \"node:assert\"\n\ndeclare class TimeStub {\n\tdeclare readonly isoString: string\n\n\tprivate constructor()\n\n\tdeclare static from: (isoString: string) => TimeStub\n\n\tdeclare static fromDate: (date: Date) => TimeStub\n\n\tdeclare toDate: () => Date\n\n\tdeclare toString: () => string\n}\n\ncontextualize(() => {\n\t// https://github.com/arktypeio/arktype/issues/915\n\tit(\"time stub w/ private constructor\", () => {\n\t\t// TimeStub is just declared at a type-level since --experimental-strip-types\n\t\t// doesn't yet support private constructors\n\n\t\tconst MockTimeStub = class TimeStub {}\n\n\t\tconst types = scope({\n\t\t\ttimeStub: [\"instanceof\", MockTimeStub] as type.cast<TimeStub>,\n\t\t\taccount: \"clientDocument&accountData\",\n\t\t\tclientDocument: {\n\t\t\t\t\"id?\": \"string\",\n\t\t\t\t\"coll?\": \"string\",\n\t\t\t\t\"ts?\": \"timeStub\",\n\t\t\t\t\"ttl?\": \"timeStub\"\n\t\t\t},\n\t\t\taccountData: {\n\t\t\t\tuser: \"user|timeStub\",\n\t\t\t\tprovider: \"provider\",\n\t\t\t\tproviderUserId: \"string\"\n\t\t\t},\n\t\t\tuser: {\n\t\t\t\tname: \"string\",\n\t\t\t\t\"accounts?\": \"account[]\"\n\t\t\t},\n\t\t\tprovider: \"'GitHub'|'Google'\"\n\t\t}).export()\n\n\t\tattest(types.account.infer).type.toString.snap(`{\n\tid?: string\n\tcoll?: string\n\tts?: TimeStub\n\tttl?: TimeStub\n\tuser: TimeStub | { name: string; accounts?: cyclic[] }\n\tprovider: \"GitHub\" | \"Google\"\n\tproviderUserId: string\n}`)\n\t\tattest(types.account.json).snap({\n\t\t\trequired: [\n\t\t\t\t{ key: \"provider\", value: [{ unit: \"GitHub\" }, { unit: \"Google\" }] },\n\t\t\t\t{ key: \"providerUserId\", value: \"string\" },\n\t\t\t\t{\n\t\t\t\t\tkey: \"user\",\n\t\t\t\t\tvalue: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\trequired: [{ key: \"name\", value: \"string\" }],\n\t\t\t\t\t\t\toptional: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tkey: \"accounts\",\n\t\t\t\t\t\t\t\t\tvalue: { sequence: \"$account\", proto: \"Array\" }\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tdomain: \"object\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"$ark.TimeStub\"\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t],\n\t\t\toptional: [\n\t\t\t\t{ key: \"coll\", value: \"string\" },\n\t\t\t\t{ key: \"id\", value: \"string\" },\n\t\t\t\t{ key: \"ts\", value: \"$ark.TimeStub\" },\n\t\t\t\t{ key: \"ttl\", value: \"$ark.TimeStub\" }\n\t\t\t],\n\t\t\tdomain: \"object\"\n\t\t})\n\t})\n\n\tit(\"nested bound traversal\", () => {\n\t\t// https://github.com/arktypeio/arktype/issues/898\n\t\tconst User = type({\n\t\t\tname: \"string\",\n\t\t\temail: \"string.email\",\n\t\t\ttags: \"(string>=2)[]>=3\",\n\t\t\tscore: \"number.integer>=0\"\n\t\t})\n\n\t\tconst out = User({\n\t\t\tname: \"Ok\",\n\t\t\temail: \"\",\n\t\t\ttags: [\"AB\", \"B\"],\n\t\t\tscore: 0\n\t\t})\n\n\t\tattest(out.toString()).snap(`email must be an email address (was \"\")\ntags must be at least length 3 (was 2)`)\n\t})\n\n\tit(\"multiple refinement errors\", () => {\n\t\tconst nospacePattern = /^\\S*$/\n\n\t\tconst Schema = type({\n\t\t\tname: \"string\",\n\t\t\temail: \"string.email\",\n\t\t\ttags: \"(string>=2)[]>=3\",\n\t\t\tscore: \"number.integer>=0\",\n\t\t\t\"date?\": \"Date\",\n\t\t\t\"nospace?\": nospacePattern,\n\t\t\textra: \"string|null\"\n\t\t})\n\n\t\tconst data = {\n\t\t\tname: \"Ok\",\n\t\t\temail: \"\",\n\t\t\ttags: [\"AB\", \"B\"],\n\t\t\tscore: -1,\n\t\t\tdate: undefined,\n\t\t\tnospace: \"One space\"\n\t\t}\n\n\t\tconst out = Schema(data)\n\n\t\tattest(out.toString()).snap(`email must be an email address (was \"\")\nextra must be a string or null (was missing)\nscore must be non-negative (was -1)\ntags must be at least length 3 (was 2)\ndate must be a Date (was undefined)\nnospace must be matched by ^\\\\S*$ (was \"One space\")`)\n\t})\n\n\tit(\"discrimination false negative\", () => {\n\t\t// https://github.com/arktypeio/arktype/issues/910\n\t\tconst badScope = scope({\n\t\t\ta: {\n\t\t\t\tx: \"'x1'\",\n\t\t\t\ty: \"'y1'\",\n\t\t\t\tz: \"string\"\n\t\t\t},\n\t\t\tb: {\n\t\t\t\tx: \"'x1'\",\n\t\t\t\ty: \"'y2'\",\n\t\t\t\tz: \"number\"\n\t\t\t},\n\t\t\tc: {\n\t\t\t\tx: \"'x2'\",\n\t\t\t\ty: \"'y3'\",\n\t\t\t\tz: \"string\"\n\t\t\t},\n\t\t\tunion: \"a | b | c\"\n\t\t}).export()\n\n\t\tconst badType = badScope.union\n\n\t\ttype Test = typeof badType.infer\n\n\t\tconst value: Test = {\n\t\t\tx: \"x2\",\n\t\t\ty: \"y3\",\n\t\t\tz: \"\"\n\t\t} // no type error\n\n\t\tconst out = badType(value) // matches scope union item 'c'; should not fail\n\t\tattest(out).equals(value)\n\t})\n\tit(\"morph path\", () => {\n\t\t// https://github.com/arktypeio/arktype/issues/754\n\t\tconst withMorph = type({\n\t\t\tkey: type(\"string\").pipe(type(\"3<=string<=4\"), s => s.trim())\n\t\t})\n\n\t\tconst outWithMorph = withMorph({\n\t\t\tkey: \"  This is too long  \"\n\t\t})\n\n\t\tattest(outWithMorph.toString()).snap(\n\t\t\t\"key must be at most length 4 (was 20)\"\n\t\t)\n\n\t\tconst withoutMorph = type({\n\t\t\tkey: type(\"3<=string<=4\")\n\t\t})\n\n\t\tconst outWithoutMorph = withoutMorph({\n\t\t\tkey: \"  This is too long  \"\n\t\t})\n\n\t\tattest(outWithoutMorph.toString()).snap(\n\t\t\t\"key must be at most length 4 (was 20)\"\n\t\t)\n\t})\n\n\tit(\"cross scope reference\", () => {\n\t\t// https://github.com/arktypeio/arktype/issues/700\n\t\tconst A = type({\n\t\t\trequired: \"boolean\"\n\t\t})\n\n\t\tconst B = scope({ A }).type({\n\t\t\ta: \"A\"\n\t\t})\n\n\t\tconst C = scope({\n\t\t\tB\n\t\t}).type({\n\t\t\tb: \"B\"\n\t\t})\n\n\t\tattest<{\n\t\t\tb: {\n\t\t\t\ta: {\n\t\t\t\t\trequired: boolean\n\t\t\t\t}\n\t\t\t}\n\t\t}>(C.t)\n\n\t\tattest<{\n\t\t\tB: {\n\t\t\t\ta: {\n\t\t\t\t\trequired: boolean\n\t\t\t\t}\n\t\t\t}\n\t\t}>(C.$.t)\n\n\t\tattest(C.json).snap({\n\t\t\tdomain: \"object\",\n\t\t\trequired: [\n\t\t\t\t{\n\t\t\t\t\tkey: \"b\",\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\tdomain: \"object\",\n\t\t\t\t\t\trequired: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkey: \"a\",\n\t\t\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\t\t\tdomain: \"object\",\n\t\t\t\t\t\t\t\t\trequired: [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tkey: \"required\",\n\t\t\t\t\t\t\t\t\t\t\tvalue: [{ unit: false }, { unit: true }]\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t})\n\t})\n\n\t// https://github.com/arktypeio/arktype/issues/947\n\tit(\"chained inline type expression inference\", () => {\n\t\tconst A = type({\n\t\t\taction: \"'a' | 'b'\"\n\t\t}).or({\n\t\t\taction: \"'c'\"\n\t\t})\n\n\t\tconst Referenced = type({\n\t\t\tsomeField: \"string\"\n\t\t}).and(A)\n\n\t\tattest<\n\t\t\t| {\n\t\t\t\t\tsomeField: string\n\t\t\t\t\taction: \"a\" | \"b\"\n\t\t\t  }\n\t\t\t| {\n\t\t\t\t\tsomeField: string\n\t\t\t\t\taction: \"c\"\n\t\t\t  }\n\t\t>(Referenced.infer)\n\n\t\tconst Inlined = type({\n\t\t\tsomeField: \"string\"\n\t\t}).and(\n\t\t\ttype({\n\t\t\t\taction: \"'a' | 'b'\"\n\t\t\t}).or({\n\t\t\t\taction: \"'c'\"\n\t\t\t})\n\t\t)\n\n\t\tattest<typeof Referenced>(Inlined)\n\t})\n\n\t// https://discord.com/channels/957797212103016458/1242116299547476100\n\tit(\"infers morphs at nested paths\", () => {\n\t\tconst parseBigint = type(\"string\", \"=>\", (s, ctx) => {\n\t\t\ttry {\n\t\t\t\treturn BigInt(s)\n\t\t\t} catch {\n\t\t\t\treturn ctx.error(\"a valid number\")\n\t\t\t}\n\t\t})\n\n\t\tconst Test = type({\n\t\t\tgroup: {\n\t\t\t\tnested: {\n\t\t\t\t\tvalue: parseBigint\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\n\t\tconst out = Test({ group: { nested: { value: \"5\" } } })\n\t\tattest<bigint, typeof Test.infer.group.nested.value>()\n\t\tattest(out).equals({ group: { nested: { value: 5n } } })\n\t})\n\n\t// https://discord.com/channels/957797212103016458/957804102685982740/1242221022380556400\n\tit(\"nested pipe to validated output\", () => {\n\t\tconst trimString = (s: string) => s.trim()\n\n\t\tconst trimStringReference = registeredReference(trimString)\n\n\t\tconst validatedTrimString = type(\"string\").pipe(\n\t\t\ttrimString,\n\t\t\ttype(\"1<=string<=3\")\n\t\t)\n\n\t\tconst CreatePatientInput = type({\n\t\t\t\"patient_id?\": \"string|null\",\n\t\t\t\"first_name?\": validatedTrimString.or(\"null\"),\n\t\t\t\"middle_name?\": \"string|null\",\n\t\t\t\"last_name?\": \"string|null\"\n\t\t})\n\n\t\tattest<\n\t\t\t((In: string) => To<string>) | null | undefined,\n\t\t\ttypeof CreatePatientInput.t.first_name\n\t\t>()\n\n\t\tattest(CreatePatientInput.json).snap({\n\t\t\toptional: [\n\t\t\t\t{\n\t\t\t\t\tkey: \"first_name\",\n\t\t\t\t\tvalue: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tin: \"string\",\n\t\t\t\t\t\t\tmorphs: [\n\t\t\t\t\t\t\t\ttrimStringReference,\n\t\t\t\t\t\t\t\t{ domain: \"string\", maxLength: 3, minLength: 1 }\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ unit: null }\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{ key: \"last_name\", value: [\"string\", { unit: null }] },\n\t\t\t\t{ key: \"middle_name\", value: [\"string\", { unit: null }] },\n\t\t\t\t{ key: \"patient_id\", value: [\"string\", { unit: null }] }\n\t\t\t],\n\t\t\tdomain: \"object\"\n\t\t})\n\t\tattest(CreatePatientInput({ first_name: \" Bob  \" })).equals({\n\t\t\tfirst_name: \"Bob\"\n\t\t})\n\t\tattest(CreatePatientInput({ first_name: \" John  \" }).toString()).snap(\n\t\t\t\"first_name must be at most length 3 (was 4)\"\n\t\t)\n\n\t\tattest(CreatePatientInput({ first_name: 5 }).toString()).snap(\n\t\t\t\"first_name must be a string or null (was a number)\"\n\t\t)\n\t})\n\n\t// https://github.com/arktypeio/arktype/issues/968\n\tit(\"handles consecutive pipes\", () => {\n\t\tconst MyAssets = scope({\n\t\t\tAsset: {\n\t\t\t\ttoken: \"string\",\n\t\t\t\tamount: type(\"string\").pipe((s, ctx) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn BigInt(s)\n\t\t\t\t\t} catch {\n\t\t\t\t\t\treturn ctx.error(\"a valid non-decimal number\")\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t},\n\t\t\tAssets: {\n\t\t\t\tassets: \"Asset[]>=1\"\n\t\t\t}\n\t\t})\n\t\t\t.export()\n\t\t\t.Assets.pipe(o => {\n\t\t\t\tconst assets = o.assets.reduce<Record<string, bigint>>((acc, asset) => {\n\t\t\t\t\tacc[asset.token] = asset.amount\n\t\t\t\t\treturn acc\n\t\t\t\t}, {})\n\t\t\t\treturn { ...o, assets }\n\t\t\t})\n\n\t\tconst out = MyAssets({ assets: [{ token: \"a\", amount: \"1\" }] })\n\n\t\tattest(out).snap({ assets: { a: 1n } })\n\t})\n\n\t// https://discord.com/channels/957797212103016458/957804102685982740/1243850690644934677\n\tit(\"more chained pipes/narrows\", () => {\n\t\tconst Amount = type(\n\t\t\t\"string\",\n\t\t\t\":\",\n\t\t\t(s, ctx) => Number.isInteger(Number(s)) || ctx.reject(\"number\")\n\t\t)\n\t\t\t.pipe((s, ctx) => {\n\t\t\t\ttry {\n\t\t\t\t\treturn BigInt(s)\n\t\t\t\t} catch {\n\t\t\t\t\treturn ctx.error(\"a non-decimal number\")\n\t\t\t\t}\n\t\t\t})\n\t\t\t.narrow(() => true)\n\n\t\tconst Token = type(\"7<string<=120\")\n\t\t\t.pipe(s => s.toLowerCase())\n\t\t\t.narrow(() => true)\n\n\t\tconst $ = scope({\n\t\t\tAsset: {\n\t\t\t\ttoken: Token,\n\t\t\t\tamount: Amount\n\t\t\t},\n\t\t\tAssets: () => $.type(\"Asset[]>=1\").pipe(assets => assets)\n\t\t})\n\n\t\tconst types = $.export()\n\n\t\tconst out = types.Assets([{ token: \"lovelace\", amount: \"5000000\" }])\n\n\t\tattest(out).snap([{ token: \"lovelace\", amount: 5000000n }])\n\t})\n\n\tit(\"regex index signature\", () => {\n\t\tconst test = scope({\n\t\t\tsvgPath: /^\\.\\/([\\da-f])+(-([\\da-f])+)*\\.svg$/,\n\t\t\tsvgMap: {\n\t\t\t\t\"[svgPath]\": \"string.digits\"\n\t\t\t}\n\t\t}).export()\n\t\tattest<\n\t\t\tModule<{\n\t\t\t\tsvgMap: {\n\t\t\t\t\t[x: string]: string\n\t\t\t\t}\n\t\t\t\tsvgPath: string\n\t\t\t}>\n\t\t>(test)\n\t\tattest(test.svgMap({ \"./f.svg\": \"123\", bar: 5 })).unknown.snap({\n\t\t\t\"./f.svg\": \"123\",\n\t\t\tbar: 5\n\t\t})\n\t\tattest(test.svgMap({ \"./f.svg\": \"123a\" }).toString()).snap(\n\t\t\t'value at [\"./f.svg\"] must be only digits 0-9 (was \"123a\")'\n\t\t)\n\t})\n\n\tit(\"standalone type from cyclic\", () => {\n\t\tconst types = scope({\n\t\t\tJsonSchema: \"JsonSchemaArray|JsonSchemaNumber\",\n\t\t\tJsonSchemaArray: {\n\t\t\t\titems: \"JsonSchema\",\n\t\t\t\ttype: \"'array'\"\n\t\t\t},\n\t\t\tJsonSchemaNumber: {\n\t\t\t\ttype: \"'number'|'integer'\"\n\t\t\t}\n\t\t}).export()\n\n\t\tconst standalone = types.JsonSchemaArray.describe(\"standalone\")\n\n\t\tattest(standalone.json).snap({\n\t\t\trequired: [\n\t\t\t\t{ key: \"items\", value: \"$JsonSchema\" },\n\t\t\t\t{ key: \"type\", value: { unit: \"array\" } }\n\t\t\t],\n\t\t\tmeta: \"standalone\",\n\t\t\tdomain: { meta: \"standalone\", domain: \"object\" }\n\t\t})\n\n\t\tconst valid: typeof standalone.infer = {\n\t\t\ttype: \"array\",\n\t\t\titems: { type: \"array\", items: { type: \"number\" } }\n\t\t}\n\n\t\tconst out = standalone(valid)\n\n\t\tattest(out).equals(valid)\n\n\t\tconst failOut = standalone({\n\t\t\ttype: \"array\",\n\t\t\titems: { type: \"array\" }\n\t\t})\n\n\t\tattest(failOut.toString()).snap(\n\t\t\t'items.items must be an object (was missing) or items.type must be \"integer\" or \"number\" (was \"array\")'\n\t\t)\n\t})\n\n\tit(\"more external cyclic scope references\", () => {\n\t\tconst $ = scope({\n\t\t\tbox: {\n\t\t\t\t\"box?\": \"box\"\n\t\t\t}\n\t\t})\n\n\t\tconst box = $.type(\"box|null\")\n\n\t\tattest(box({})).equals({})\n\t\tattest(box(null)).equals(null)\n\t\tattest(box({ box: { box: { box: {} } } })).snap({\n\t\t\tbox: { box: { box: {} } }\n\t\t})\n\t\tattest(box({ box: { box: { box: \"whoops\" } } })?.toString()).snap(\n\t\t\t\"box.box.box must be an object (was a string)\"\n\t\t)\n\t})\n\n\tit(\"morph with alias child\", () => {\n\t\tconst types = scope({\n\t\t\tArraySchema: {\n\t\t\t\t\"items?\": \"Schema\"\n\t\t\t},\n\t\t\tSchema: \"TypeWithKeywords\",\n\t\t\tTypeWithKeywords: \"ArraySchema\"\n\t\t}).export()\n\n\t\tconst T = types.Schema.pipe(o => JSON.stringify(o))\n\n\t\tattest(T({ items: {} })).snap('{\"items\":{}}')\n\t\tattest(T({ items: null }).toString()).snap(\n\t\t\t\"items must be an object (was null)\"\n\t\t)\n\t})\n\n\tit(\"terse missing key error\", () => {\n\t\tconst types = scope({\n\t\t\tLibrary: {\n\t\t\t\tsections: \"Sections\"\n\t\t\t},\n\t\t\tSections: {\n\t\t\t\t\"[string]\": \"Book[]\"\n\t\t\t},\n\t\t\tBook: {\n\t\t\t\tisbn: \"string\",\n\t\t\t\ttitle: \"string\",\n\t\t\t\t\"subtitle?\": \"string\",\n\t\t\t\tauthors: \"string[]\",\n\t\t\t\tpublisher: \"Publisher\"\n\t\t\t},\n\t\t\tPublisher: {\n\t\t\t\tid: \"string\",\n\t\t\t\tname: \"string\"\n\t\t\t}\n\t\t}).export()\n\n\t\tattest(types.Library({}).toString()).snap(\n\t\t\t\"sections must be an object (was missing)\"\n\t\t)\n\t})\n\n\tit(\"narrowed quoted description\", () => {\n\t\tconst T = type(\"string\")\n\t\t\t.narrow(function _narrowedQuoteDescription() {\n\t\t\t\treturn true\n\t\t\t})\n\t\t\t.describe('This will \"fail\"')\n\n\t\tattest<string>(T.t)\n\n\t\tattest(T.json).snap({\n\t\t\tdomain: { domain: \"string\", meta: 'This will \"fail\"' },\n\t\t\tpredicate: [\n\t\t\t\t{\n\t\t\t\t\tpredicate: \"$ark._narrowedQuoteDescription\",\n\t\t\t\t\tmeta: 'This will \"fail\"'\n\t\t\t\t}\n\t\t\t],\n\t\t\tmeta: 'This will \"fail\"'\n\t\t})\n\t})\n\n\tit(\"extract in of narrowed morph\", () => {\n\t\tconst SubSubType = type(\"string\").pipe(s => parseInt(s))\n\t\tconst SubType = type({ amount: SubSubType }).narrow(() => true)\n\t\tconst MyType = type({\n\t\t\tsub: SubType\n\t\t})\n\n\t\ttype MyType = typeof MyType.in.infer\n\n\t\tattest<\n\t\t\t{\n\t\t\t\tsub: {\n\t\t\t\t\tamount: string\n\t\t\t\t}\n\t\t\t},\n\t\t\tMyType\n\t\t>()\n\t})\n\n\tit(\"narrowed morph\", () => {\n\t\tconst T = type(\"string\")\n\t\t\t.pipe(s => parseInt(s))\n\t\t\t.narrow(() => true)\n\n\t\tattest<(In: string) => Out<number>>(T.t)\n\n\t\tconst u = T.pipe(\n\t\t\tn => `${n}`,\n\t\t\ts => `${s}++` as const\n\t\t)\n\n\t\tattest(u.t).type.toString(\"(In: string) => Out<`${string}++`>\")\n\t})\n\n\tit(\"recursive reference from union\", () => {\n\t\tconst $ = scope({\n\t\t\tTypeWithKeywords: \"ArraySchema\",\n\t\t\tSchema: \"number|ArraySchema\",\n\t\t\tArraySchema: {\n\t\t\t\t\"additionalItems?\": \"Schema\"\n\t\t\t}\n\t\t})\n\n\t\t$.export()\n\n\t\tattest($.json).snap({\n\t\t\tTypeWithKeywords: {\n\t\t\t\toptional: [\n\t\t\t\t\t{ key: \"additionalItems\", value: [\"$ArraySchema\", \"number\"] }\n\t\t\t\t],\n\t\t\t\tdomain: \"object\"\n\t\t\t},\n\t\t\tSchema: [\"$ArraySchema\", \"number\"],\n\t\t\tArraySchema: {\n\t\t\t\toptional: [\n\t\t\t\t\t{ key: \"additionalItems\", value: [\"$ArraySchema\", \"number\"] }\n\t\t\t\t],\n\t\t\t\tdomain: \"object\"\n\t\t\t}\n\t\t})\n\t})\n\n\t// https://discord.com/channels/957797212103016458/957804102685982740/1254900389346807849\n\tit(\"narrows nested morphs\", () => {\n\t\tconst parseBigint = type(\"string\").pipe(s => BigInt(s))\n\t\tconst Fee = type({ amount: parseBigint }).narrow(\n\t\t\tfee => typeof fee.amount === \"bigint\"\n\t\t)\n\n\t\tconst Claim = type({\n\t\t\tfee: Fee\n\t\t})\n\n\t\tconst out = Claim.assert({ fee: { amount: \"5\" } })\n\n\t\tattest(out).equals({ fee: { amount: 5n } })\n\t})\n\n\t// https://github.com/arktypeio/arktype/issues/1037\n\tit(\"can morph an optional key\", () => {\n\t\tconst T = type({\n\t\t\t\"optionalKey?\": [\"string\", \"=>\", x => x.toLowerCase()]\n\t\t})\n\n\t\tattest<{\n\t\t\toptionalKey?: (In: string) => Out<string>\n\t\t}>(T.t)\n\n\t\tattest(T({})).equals({})\n\n\t\tattest(T({ optionalKey: \"FOO\" })).snap({ optionalKey: \"foo\" })\n\t})\n\n\t// https://discord.com/channels/957797212103016458/1261621890775126160/1261621890775126160\n\tit(\"can narrow output of a piped union\", () => {\n\t\tconst parseBigint = (v: string | number) => BigInt(v)\n\t\tconst morphReference = registeredReference(parseBigint)\n\t\tconst validatePositiveBigint = (b: bigint) => b > 0n\n\t\tconst predicateReference = registeredReference(validatePositiveBigint)\n\n\t\tconst Amount = type(\"string|number\")\n\t\t\t.pipe(parseBigint)\n\t\t\t.narrow(validatePositiveBigint)\n\n\t\tattest<(In: string | number) => Out<bigint>>(Amount.t)\n\t\tattest(Amount.json).snap({\n\t\t\tin: [\"number\", \"string\"],\n\t\t\tmorphs: [morphReference, { predicate: [predicateReference] }]\n\t\t})\n\n\t\tattest(Amount(\"1000\")).equals(1000n)\n\t\tattest(Amount(\"-5\").toString()).snap(\n\t\t\t\"must be valid according to validatePositiveBigint (was -5n)\"\n\t\t)\n\t})\n\n\tit(\"nested 'and' chained from morph on optional\", () => {\n\t\tconst validatedTrimString = type(\"string\").pipe(\n\t\t\ts => s.trim(),\n\t\t\ttype(\"1<=string<=3\")\n\t\t)\n\n\t\tconst T = type({\n\t\t\t\"first_name?\": validatedTrimString.and(\"unknown\")\n\t\t})\n\n\t\tattest(T.expression).snap(\n\t\t\t\"{ first_name?: (In: string) => To<string <= 3 & >= 1> }\"\n\t\t)\n\t\tattest(T.t).type.toString.snap(\n\t\t\t\"{ first_name?: (In: string) => To<string> }\"\n\t\t)\n\t})\n\n\tit(\"cyclic narrow in scope\", () => {\n\t\tconst root = scope({\n\t\t\tfilename: \"0<string<255\",\n\t\t\tfile: {\n\t\t\t\ttype: \"'file'\",\n\t\t\t\tname: \"filename\"\n\t\t\t},\n\t\t\tdirectory: {\n\t\t\t\ttype: \"'directory'\",\n\t\t\t\tname: \"filename\",\n\t\t\t\tchildren: [\n\t\t\t\t\t\"root[]\",\n\t\t\t\t\t\":\",\n\t\t\t\t\t(v, ctx) => {\n\t\t\t\t\t\tif (new Set(v.map(f => f.name)).size !== v.length)\n\t\t\t\t\t\t\treturn ctx.mustBe(\"names must be unique in a directory\")\n\n\t\t\t\t\t\treturn true\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\troot: \"file|directory\"\n\t\t}).resolve(\"root\")\n\n\t\tattest(root.t).type.toString.snap(`\t| { type: \"file\"; name: string }\n\t| {\n\t\t\ttype: \"directory\"\n\t\t\tname: string\n\t\t\tchildren: ({ type: \"file\"; name: string } | cyclic)[]\n\t  }`)\n\t})\n\n\t// https://github.com/arktypeio/arktype/discussions/1080#discussioncomment-10247616\n\tit(\"pipe to discriminated morph union\", () => {\n\t\tconst ObjSchema = type({\n\t\t\taction: \"'order.completed'\"\n\t\t}).or({\n\t\t\taction: `'scheduled'`,\n\t\t\tid: \"string.integer.parse\",\n\t\t\tcalendarID: \"string.integer.parse\",\n\t\t\tappointmentTypeID: \"string.integer.parse\"\n\t\t})\n\n\t\tconst parseJsonToObj = type(\"string.json.parse\").pipe(ObjSchema)\n\n\t\tattest(parseJsonToObj.expression).snap(\n\t\t\t'(In: string) => To<{ action: \"order.completed\" } | { action: \"scheduled\", appointmentTypeID: number % 1, calendarID: number % 1, id: number % 1 }>'\n\t\t)\n\n\t\tconst out = parseJsonToObj(\n\t\t\tJSON.stringify({\n\t\t\t\taction: \"scheduled\",\n\t\t\t\tid: \"1\",\n\t\t\t\tcalendarID: \"1\",\n\t\t\t\tappointmentTypeID: \"1\"\n\t\t\t})\n\t\t)\n\n\t\tattest<\n\t\t\t| ArkErrors\n\t\t\t| {\n\t\t\t\t\taction: \"order.completed\"\n\t\t\t  }\n\t\t\t| {\n\t\t\t\t\taction: \"scheduled\"\n\t\t\t\t\tid: number\n\t\t\t\t\tcalendarID: number\n\t\t\t\t\tappointmentTypeID: number\n\t\t\t  }\n\t\t>(out)\n\n\t\tattest(out).snap({\n\t\t\taction: \"scheduled\",\n\t\t\tid: 1,\n\t\t\tcalendarID: 1,\n\t\t\tappointmentTypeID: 1\n\t\t})\n\t})\n\n\t// https://github.com/arktypeio/arktype/discussions/1080#discussioncomment-10247616\n\tit(\"pipe to discriminated morph inner union\", () => {\n\t\tconst ObjSchema = type({\n\t\t\taction: \"'order.completed'\"\n\t\t}).or({\n\t\t\taction: \"'scheduled' | 'rescheduled' | 'canceled' | 'changed'\",\n\t\t\tid: \"string.integer.parse\",\n\t\t\tcalendarID: \"string.integer.parse\",\n\t\t\tappointmentTypeID: \"string.integer.parse\"\n\t\t})\n\n\t\tconst parseJsonToObj = type(\"string.json.parse\").pipe(ObjSchema)\n\n\t\tconst out = parseJsonToObj(\n\t\t\tJSON.stringify({\n\t\t\t\taction: \"scheduled\",\n\t\t\t\tid: \"1\",\n\t\t\t\tcalendarID: \"1\",\n\t\t\t\tappointmentTypeID: \"1\"\n\t\t\t})\n\t\t)\n\n\t\tattest(out).snap({\n\t\t\taction: \"scheduled\",\n\t\t\tid: 1,\n\t\t\tcalendarID: 1,\n\t\t\tappointmentTypeID: 1\n\t\t})\n\t})\n\n\t// https://discord.com/channels/957797212103016458/957804102685982740/1276840721370054688\n\tit(\"directly nested piped type instantiation\", () => {\n\t\tconst T = type({\n\t\t\t\"test?\": type(\"string\").pipe(x => x === \"true\")\n\t\t})\n\n\t\tattest<{\n\t\t\ttest?: (In: string) => Out<boolean>\n\t\t}>(T.t)\n\t})\n\n\tit(\"discriminated union error\", () => {\n\t\tconst C = type({ city: \"string\", \"+\": \"reject\" }).pipe(o => ({\n\t\t\t...o,\n\t\t\ttype: \"city\"\n\t\t}))\n\t\tconst N = type({ name: \"string\", \"+\": \"reject\" }).pipe(o => ({\n\t\t\t...o,\n\t\t\ttype: \"name\"\n\t\t}))\n\n\t\tconst T = C.or(N)\n\n\t\tconst out = T({ city: \"foo\", name: \"foo\" })\n\t\tattest(out.toString()).snap(\"name must be removed or city must be removed\")\n\t})\n\n\tit(\"array intersection with object literal\", () => {\n\t\tconst T = type({ name: \"string\" }).and(\"string[]\")\n\t\tattest(T).type.toString.snap(\"Type<{ name: string } & string[], {}>\")\n\t\tattest(T.infer).type.toString.snap(\"{ name: string } & string[]\")\n\n\t\tattest(T.expression).snap(\"{ name: string } & string[]\")\n\t})\n\n\tit(\"tuple or morph inference\", () => {\n\t\tconst T = type([\"string\", \"string\"]).or([\"null\", \"=>\", () => undefined])\n\n\t\tattest(T.expression).snap(\"[string, string] | (In: null) => Out<unknown>\")\n\t\tattest(T.t).type.toString.snap(\n\t\t\t\"[string, string] | ((In: null) => Out<undefined>)\"\n\t\t)\n\t\tattest(T.inferIn).type.toString(\"[string, string] | null\")\n\t\tattest(T.infer).type.toString(\"[string, string] | undefined\")\n\t})\n\n\tit(\"scoped discrimnated union\", () => {\n\t\tconst $ = scope({\n\t\t\tTypeWithNoKeywords: { type: \"'boolean'|'null'\" },\n\t\t\tTypeWithKeywords: \"ArraySchema|ObjectSchema\", // without both ArraySchema and ObjectSchema there's no error\n\t\t\t// \"#BaseSchema\": \"TypeWithNoKeywords|boolean\", // errors even with union reversed\n\t\t\t\"#BaseSchema\": \"boolean|TypeWithNoKeywords\", // without the `boolean` there's no error (even if still union such as `string|TypeWithNoKeywords`)\n\t\t\tArraySchema: {\n\t\t\t\t\"additionalItems?\": \"BaseSchema\", // without this reference there's no error\n\t\t\t\ttype: \"'array'\"\n\t\t\t},\n\t\t\t// If `ObjectSchema` doesn't have `type` key there's no error\n\t\t\tObjectSchema: {\n\t\t\t\ttype: \"'object'\"\n\t\t\t}\n\t\t})\n\t\tconst JsonSchema = $.export()\n\t\tattest(JsonSchema.TypeWithKeywords.expression).snap(\n\t\t\t'{ type: \"array\", additionalItems?: { type: \"boolean\" | \"null\" } | false | true } | { type: \"object\" }'\n\t\t)\n\n\t\tattest(\n\t\t\tJsonSchema.TypeWithKeywords({\n\t\t\t\ttype: \"array\",\n\t\t\t\tadditionalItems: { type: \"boolean\" }\n\t\t\t})\n\t\t).snap({ type: \"array\", additionalItems: { type: \"boolean\" } })\n\t\tattest(\n\t\t\tJsonSchema.TypeWithKeywords({\n\t\t\t\ttype: \"array\",\n\t\t\t\tadditionalItems: {\n\t\t\t\t\ttype: \"whoops\"\n\t\t\t\t}\n\t\t\t}).toString()\n\t\t).snap('additionalItems.type must be \"boolean\" or \"null\" (was \"whoops\")')\n\t})\n\n\t// https://github.com/arktypeio/arktype/issues/1127\n\tit(\"keys can overlap with RegExp\", () => {\n\t\tconst MaybeEmpty = type(\"<t>\", \"t|undefined|null\")\n\n\t\tconst ApiSchema = type({\n\t\t\tref: MaybeEmpty(\"string\"),\n\t\t\tservice_code: MaybeEmpty(\"number\"),\n\t\t\taction: MaybeEmpty(\"string\"),\n\t\t\tsource: type(\"string | null\"),\n\t\t\tlastIndex: type(\"string | null\")\n\t\t})\n\n\t\tattest<{\n\t\t\tref: string | null | undefined\n\t\t\tservice_code: number | null | undefined\n\t\t\taction: string | null | undefined\n\t\t\tsource: string | null\n\t\t\tlastIndex: string | null\n\t\t}>(ApiSchema.t)\n\n\t\tattest(ApiSchema.expression).snap(\n\t\t\t\"{ action: string | undefined | null, lastIndex: string | null, ref: string | undefined | null, service_code: number | undefined | null, source: string | null }\"\n\t\t)\n\t})\n\n\tit(\"error on bounded liftArray\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"2 < Array.liftFrom<string> < 4\"))\n\t\t\t.throws.snap(\n\t\t\t\t\"ParseError: MaxLength operand must be a string or an array (was a morph)\"\n\t\t\t)\n\t\t\t.type.errors(\n\t\t\t\t\"To constrain the output of ... < 4, pipe like myMorph.to('number > 0').\\\\nTo constrain the input, intersect like myMorph.and('number > 0').\"\n\t\t\t)\n\t})\n\n\t// https://discord.com/channels/957797212103016458/1290304355643293747\n\tit(\"can extract proto Node at property\", () => {\n\t\tconst D = type(\"Date\")\n\n\t\tconst O = type({\n\t\t\tlast_updated: D\n\t\t})\n\n\t\tconst T = O.get(\"last_updated\")\n\n\t\tattest<Date>(T.t)\n\t\tattest(D.expression).snap(\"Date\")\n\t\tattest(T.expression).equals(D.expression)\n\t\tattest(T.extends(D)).equals(true)\n\t})\n\n\tit(\"piped through Type\", () => {\n\t\tconst Letters = type(\"'a'|'b'|'c'\")\n\t\t// normally, this would just be .to(Letters), but this should work as\n\t\t// well, even if it's less efficient\n\t\tconst Letter = type(\"string\").pipe(s => Letters(s))\n\n\t\tattest(Letter(\"d\").toString()).snap('must be \"a\", \"b\" or \"c\" (was \"d\")')\n\t})\n\n\tit(\".in types are always unionable\", () => {\n\t\tconst MorphArrayMorph = type(\"string\")\n\t\t\t.pipe(e => e)\n\t\t\t.array()\n\t\t\t.pipe(e => e)\n\t\tconst OtherType = type(\"string[]\")\n\t\tconst EitherInput = MorphArrayMorph.in.or(OtherType.in)\n\n\t\tattest(EitherInput([\"str\"])).snap([\"str\"])\n\t})\n\n\tit(\"intersecting unknown with piped type preserves identity\", () => {\n\t\tconst Base = type({\n\t\t\tfoo: type(\"string\").pipe(() => 123)\n\t\t})\n\t\t\t.pipe(c => c)\n\t\t\t.to({\n\t\t\t\tfoo: \"123\"\n\t\t\t})\n\n\t\tconst Identity = Base.and(\"unknown\")\n\n\t\tattest(Base.json).equals(Identity.json)\n\t\tattest(Base.internal.id).equals(Identity.internal.id)\n\t})\n\n\tit(\"index signature union intersection with default\", () => {\n\t\tconst T = type({\n\t\t\tstoreA: \"Record<string, string>\"\n\t\t})\n\t\t\t.or({\n\t\t\t\tstoreB: {\n\t\t\t\t\tfoo: \"Record<string, string>\"\n\t\t\t\t}\n\t\t\t})\n\t\t\t.and({\n\t\t\t\text: [\"string\", \"=\", \".txt\"]\n\t\t\t})\n\n\t\tattest(T.expression).snap(\n\t\t\t'{ storeA: { [string]: string }, ext: string = \".txt\" } | { storeB: { foo: { [string]: string } }, ext: string = \".txt\" }'\n\t\t)\n\t})\n\n\tit(\"correct toString for array of union\", () => {\n\t\tconst T = type(\"(string | number)[]\")\n\t\tattest(T.expression).snap(\"(number | string)[]\")\n\t})\n\n\tit(\"union with length constraint\", () => {\n\t\tconst Feedback = type({\n\t\t\tcontact: \"string.email | string == 0\"\n\t\t})\n\n\t\tattest(Feedback.expression).snap(\n\t\t\t\"{ contact: string == 0 | /^[\\\\w%+.-]+@[\\\\d.A-Za-z-]+\\\\.[A-Za-z]{2,}$/ }\"\n\t\t)\n\t\tattest(Feedback.t).type.toString.snap(`{ contact: string }`)\n\t})\n\n\tit(\"deleted undeclared keys allowed in input\", () => {\n\t\tconst T = type({ foo: \"string\" }).onUndeclaredKey(\"delete\")\n\n\t\tattest(T.json).snap({\n\t\t\tundeclared: \"delete\",\n\t\t\trequired: [{ key: \"foo\", value: \"string\" }],\n\t\t\tdomain: \"object\"\n\t\t})\n\n\t\tattest(T.in.json).snap({\n\t\t\trequired: [{ key: \"foo\", value: \"string\" }],\n\t\t\tdomain: \"object\"\n\t\t})\n\n\t\tconst extras = { foo: \"hi\", bar: 3 }\n\n\t\tattest(T(extras)).equals({ foo: \"hi\" })\n\t\tattest(T.allows(extras)).equals(true)\n\t\tattest(T.in(extras)).equals(extras)\n\t})\n\n\tit(\"deleted undeclared keys rejected in output\", () => {\n\t\tconst T = type({ foo: \"string\" }).onUndeclaredKey(\"delete\")\n\n\t\tattest(T.json).snap({\n\t\t\tundeclared: \"delete\",\n\t\t\trequired: [{ key: \"foo\", value: \"string\" }],\n\t\t\tdomain: \"object\"\n\t\t})\n\n\t\tattest(T.out.json).snap({\n\t\t\tundeclared: \"reject\",\n\t\t\trequired: [{ key: \"foo\", value: \"string\" }],\n\t\t\tdomain: \"object\"\n\t\t})\n\n\t\tattest(T.out({ foo: \"hi\", bar: 3 }).toString()).snap(\"bar must be removed\")\n\t})\n\n\tit(\"includesMorph only when expected\", () => {\n\t\tconst Unmorphed = type({\n\t\t\t\"optional?\": \"string\",\n\t\t\trequired: \"string\",\n\t\t\ttuple: [\"string\", \"number?\"],\n\t\t\tarray: \"string[]\",\n\t\t\tclosed: {\n\t\t\t\t\"+\": \"reject\",\n\t\t\t\ta: \"true\"\n\t\t\t}\n\t\t})\n\t\tattest(Unmorphed.internal.includesTransform).equals(false)\n\t})\n\n\tit(\"morph includesMorph\", () => {\n\t\tconst T = type({\n\t\t\tprop: [\"string\", \"=>\", s => s.length]\n\t\t})\n\n\t\tattest(T.internal.includesTransform).equals(true)\n\t})\n\n\tit(\"default prop includesMorph\", () => {\n\t\tconst T = type({\n\t\t\tprop: \"number = 5\"\n\t\t})\n\n\t\tattest(T.internal.includesTransform).equals(true)\n\t})\n\n\tit(\"default tuple includesMorph\", () => {\n\t\tconst T = type({\n\t\t\ttuple: [\"number = 5\"]\n\t\t})\n\n\t\tattest(T.internal.includesTransform).equals(true)\n\t})\n\n\tit(\"onUndeclaredKey delete includesMorph\", () => {\n\t\tconst T = type({\n\t\t\tinner: {\n\t\t\t\t\"+\": \"delete\",\n\t\t\t\tfoo: \"string\"\n\t\t\t}\n\t\t})\n\t\tattest(T.internal.includesTransform).equals(true)\n\t})\n\n\tit(\"distill doesn't treat functions returning any/never as morphs\", () => {\n\t\ttype T = {\n\t\t\tany(): any\n\t\t\tnever(): never\n\t\t}\n\t\tconst T = type(\"unknown\").as<T>()\n\n\t\tattest(T.infer).type.toString.equals(\"T\")\n\t\tattest(T.inferIn).type.toString.equals(\"T\")\n\t})\n\n\tit(\"distills morphs returning any/never\", () => {\n\t\tconst T = type({\n\t\t\tany: [\"unknown\", \"=>\", (): any => {}],\n\t\t\tnever: [\"unknown\", \"=>\", () => [] as never]\n\t\t})\n\n\t\tattest(T.t).type.toString.snap(`{\n\tany: (In: unknown) => Out<any>\n\tnever: (In: unknown) => Out<never>\n}`)\n\t\tattest(T.infer).type.toString.snap(\"{ any: any; never: never }\")\n\t\tattest(T.inferIn).type.toString.snap(\"{ any: unknown; never: unknown }\")\n\t})\n\n\t// https://github.com/arktypeio/arktype/issues/1274\n\tit(\"fail on non-discriminable union of objects with onUndeclaredKey: delete\", () => {\n\t\tconst Point2d = type({\n\t\t\tx: \"number\",\n\t\t\ty: \"number\",\n\t\t\t\"+\": \"delete\"\n\t\t})\n\n\t\tconst Point3d = type({\n\t\t\tx: \"number\",\n\t\t\ty: \"number\",\n\t\t\tz: \"number\",\n\t\t\t\"+\": \"delete\"\n\t\t})\n\n\t\tattest(() => Point2d.or(Point3d)).throws\n\t\t\t.snap(`ParseError: An unordered union of a type including a morph and a type with overlapping input is indeterminate:\nLeft: { x: number, y: number, z: number, + (undeclared): delete }\nRight: { x: number, y: number, + (undeclared): delete }`)\n\t})\n\n\t// https://github.com/arktypeio/arktype/issues/1266\n\tit(\"onUndeclaredKey intersection cases\", () => {\n\t\tconst types = type.module({\n\t\t\t// Works: overlapping fields are named the same, have simple type\n\t\t\tModelA_V1: { times: \"number\", \"+\": \"reject\" },\n\t\t\tModelA_V2: {\n\t\t\t\ttimes: \"number\",\n\t\t\t\tversion: \"2\",\n\t\t\t\t\"+\": \"reject\"\n\t\t\t},\n\t\t\tModelA: \"ModelA_V2 | ModelA_V1\",\n\t\t\t// Works: non-overlapping list fields\n\t\t\tModelB_V1: { times: \"number.integer[]\", \"+\": \"reject\" },\n\t\t\tModelB_V2: {\n\t\t\t\tframes: \"number.integer[]\",\n\t\t\t\tversion: \"2\",\n\t\t\t\t\"+\": \"reject\"\n\t\t\t},\n\t\t\tModelB: \"ModelB_V2 | ModelB_V1\",\n\t\t\t// Does not work: overlapping array field\n\t\t\tModelC_V1: { times: \"number[]\", \"+\": \"reject\" },\n\t\t\tModelC_V2: {\n\t\t\t\ttimes: \"number[]\",\n\t\t\t\tversion: \"2\",\n\t\t\t\t\"+\": \"reject\"\n\t\t\t},\n\t\t\tModelC: \"ModelC_V2 | ModelC_V1\",\n\t\t\t// Works: overlapping map fields\n\t\t\tModelD_V1: { times: \"Record<string, number>\", \"+\": \"reject\" },\n\t\t\tModelD_V2: {\n\t\t\t\ttimes: \"Record<string, number>\",\n\t\t\t\tversion: \"2\",\n\t\t\t\t\"+\": \"reject\"\n\t\t\t},\n\t\t\tModelD: \"ModelD_V2 | ModelD_V1\",\n\t\t\t// Works: overlapping user-defined sub-model\n\t\t\tTime: { value: \"number\" },\n\t\t\tModelE_V1: { time: \"Time\", \"+\": \"reject\" },\n\t\t\tModelE_V2: {\n\t\t\t\ttime: \"Time\",\n\t\t\t\tversion: \"2\",\n\t\t\t\t\"+\": \"reject\"\n\t\t\t},\n\t\t\tModelE: \"ModelE_V2 | ModelE_V1\",\n\t\t\tTimes: { values: \"number[]\" },\n\t\t\t// Does not work: arrays within overlapping sub-model\n\t\t\tModelF_V1: { times: \"Times\", \"+\": \"reject\" },\n\t\t\tModelF_V2: {\n\t\t\t\ttimes: \"Times\",\n\t\t\t\tversion: \"2\",\n\t\t\t\t\"+\": \"reject\"\n\t\t\t},\n\t\t\tModelF: \"ModelF_V2 | ModelF_V1\"\n\t\t})\n\n\t\ttypes.ModelA.assert({ times: 0.0, version: 2 })\n\t\ttypes.ModelB.assert({ frames: [0], version: 2 })\n\t\ttypes.ModelC.assert({ times: [0.0], version: 2 })\n\t\ttypes.ModelD.assert({ times: { age: 7.3 }, version: 2 })\n\t\ttypes.ModelE.assert({ time: { value: 0.0 }, version: 2 })\n\t\ttypes.ModelF.assert({ times: { values: [0.0] }, version: 2 })\n\t})\n\n\tit(\"can nested type call from standard schema generic\", () => {\n\t\tfunction fn<\n\t\t\tT extends {\n\t\t\t\tschema: StandardSchemaV1\n\t\t\t}\n\t\t>(_: T) {\n\t\t\treturn {} as StandardSchemaV1.InferOutput<T[\"schema\"]>\n\t\t}\n\n\t\t// was inferred as unknown before NoInfer was refactored to conditionals\n\t\tconst arkRes = fn({\n\t\t\tschema: type({\n\t\t\t\tname: \"string\"\n\t\t\t})\n\t\t})\n\n\t\tattest<{ name: string }>(arkRes)\n\t})\n\n\t// https://github.com/arktypeio/arktype/issues/1317\n\tit(\"discriminated tuple/array union\", () => {\n\t\tconst TupleType = type([\"number\", \"number\"])\n\t\tconst TupleArrayType = TupleType.array()\n\t\tconst UnionType = TupleType.or(TupleArrayType)\n\n\t\tattest(TupleType.assert([1, 2])).equals([1, 2])\n\t\tattest(TupleArrayType.assert([[1, 2]])).equals([[1, 2]])\n\t\tattest(UnionType.assert([[1, 2]])).equals([[1, 2]])\n\t})\n\n\tit(\"doomed shirt example\", () => {\n\t\tconst urDOOMed = type({\n\t\t\tgrouping: \"(0 | (1 | (2 | (3 | (4 | 5)[])[])[])[])[]\",\n\t\t\tnestedGenerics:\n\t\t\t\t\"Exclude<0n | unknown[] | Record<string, unknown>, object>\",\n\t\t\t\"escapes\\\\?\": \"'a | b' | 'c | d'\"\n\t\t})\n\n\t\tattest<{\n\t\t\tgrouping: (0 | (1 | (2 | (3 | (4 | 5)[])[])[])[])[]\n\t\t\tnestedGenerics: 0n\n\t\t\t\"escapes?\": \"a | b\" | \"c | d\"\n\t\t}>(urDOOMed.t)\n\n\t\tattest(urDOOMed.expression).snap(\n\t\t\t'{ escapes?: \"a | b\" | \"c | d\", grouping: (((((4 | 5)[] | 3)[] | 2)[] | 1)[] | 0)[], nestedGenerics: 0n }'\n\t\t)\n\t})\n\n\tit(\"ArkErrors not assignable to ArkErrorInput\", () => {\n\t\tattest(() =>\n\t\t\ttype({\n\t\t\t\ttype: \"string\"\n\t\t\t}).narrow((_, ctx) => {\n\t\t\t\tconst result = type.number(\"foo\")\n\t\t\t\t// @ts-expect-error\n\t\t\t\tif (result instanceof type.errors) return ctx.reject(result)\n\n\t\t\t\treturn true\n\t\t\t})\n\t\t).type.errors(\n\t\t\t\"Argument of type 'ArkErrors' is not assignable to parameter of type 'ArkErrorInput'\"\n\t\t)\n\t})\n\n\tit(\"described input of morph\", () => {\n\t\tclass ValidatedUserID {\n\t\t\tstatic fromString(value: string): ValidatedUserID {\n\t\t\t\treturn new ValidatedUserID(value)\n\t\t\t}\n\t\t\tprivate constructor(readonly data: string) {}\n\t\t}\n\n\t\tconst UserID = type(\"string\")\n\t\t\t.describe(\"a userID\")\n\t\t\t.pipe.try(ValidatedUserID.fromString)\n\n\t\tconst User = type({\n\t\t\tid: UserID\n\t\t})\n\n\t\tconst out = User({\n\t\t\tiD: \"typo, oops\"\n\t\t})\n\n\t\tattest(out.toString()).snap(\"id must be a userID (was missing)\")\n\t})\n\n\t// https://github.com/arktypeio/arktype/issues/1400\n\tit(\"configured union message\", () => {\n\t\tconst Schema = type('\"abc\" | \"cde\"').configure({\n\t\t\tmessage: () => \"hello world\"\n\t\t})\n\n\t\tconst res = Schema(\"efg\")\n\n\t\tattest(res.toString()).snap(\"hello world\")\n\t})\n\n\tit(\"allows morph union with non-overlapping root objects\", () => {\n\t\tconst MasterSkinItem = type({\n\t\t\t\"+\": \"reject\",\n\t\t\ttype: \"'skin'\",\n\t\t\tmasterItem: \"true\",\n\n\t\t\tskin: \"string\",\n\t\t\tshort: \"string\",\n\n\t\t\tminPrice: \"number.integer >=0\",\n\t\t\tstattrakAvailable: \"boolean = false\",\n\t\t\tsouvenirAvailable: \"boolean = false\",\n\t\t\tqualities: type(\"1 | 2 | 3 | 4 |5\").array().or([\"null\"])\n\t\t})\n\n\t\tconst SkinItem = type({\n\t\t\t\"+\": \"reject\",\n\t\t\ttype: \"'skin'\",\n\t\t\t// \"masterItem?\": \"false\",\n\t\t\tskin: \"string\",\n\t\t\tshort: \"string\",\n\n\t\t\t\"weight?\": \"number\",\n\t\t\tsouvenir: \"boolean = false\",\n\t\t\tstattrak: \"boolean = false\",\n\t\t\tquality: type(\"1 | 2 | 3 | 4 |5\").optional()\n\t\t})\n\n\t\tconst Skinish = MasterSkinItem.or(SkinItem)\n\t\tattest(Skinish.expression).snap(\n\t\t\t'{ masterItem: true, minPrice: number % 1 & >= 0, qualities: (1 | 2 | 3 | 4 | 5)[] | [null], short: string, skin: string, type: \"skin\", souvenirAvailable: boolean = false, stattrakAvailable: boolean = false, + (undeclared): reject } | { short: string, skin: string, type: \"skin\", souvenir: boolean = false, stattrak: boolean = false, quality?: 1 | 2 | 3 | 4 | 5, weight?: number, + (undeclared): reject }'\n\t\t)\n\t})\n\n\tit(\"allows inferring a schema's type argument in a generic wrapper function when the type uses Default\", () => {\n\t\tfunction someFunction<TSchema extends Record<string, any>>(\n\t\t\tschema: Type<TSchema, {}>\n\t\t): (typeof schema)[\"infer\"] {\n\t\t\tconst someData = { hello: \"world\" }\n\t\t\treturn schema.assert(someData)\n\t\t}\n\n\t\tconst schema = type({\n\t\t\thello: type(\"string\").pipe(s => s === \"world\"),\n\t\t\tgoodbye: \"string='blah'\"\n\t\t})\n\n\t\tsomeFunction(schema)\n\t})\n\n\tit(\"allows inferring a schema in a generic wrapper function when the type uses Default\", () => {\n\t\tfunction someFunction<schema extends type.Any<Record<string, any>>>(\n\t\t\tschema: schema\n\t\t) {\n\t\t\tconst someData = { hello: \"world\" }\n\t\t\treturn schema.assert(someData)\n\t\t}\n\n\t\tconst schema = type({\n\t\t\thello: type(\"string\").pipe(s => s === \"world\"),\n\t\t\tgoodbye: \"string='blah'\"\n\t\t})\n\n\t\tsomeFunction(schema)\n\t})\n\n\tit(\"reports all string.date errors\", () => {\n\t\tconst Thing = type({\n\t\t\tdate1: \"string.date\",\n\t\t\tdate2: \"string.date\",\n\t\t\tdate3: \"string.date\"\n\t\t})\n\n\t\tconst out = Thing({\n\t\t\tdate1: \"\",\n\t\t\tdate2: \"\",\n\t\t\tdate3: \"\"\n\t\t})\n\n\t\tif (!(out instanceof type.errors)) throw new AssertionError({})\n\n\t\tattest(out.length).equals(3)\n\t\tattest(out.summary).snap(`date1 must be a parsable date (was \"\")\ndate2 must be a parsable date (was \"\")\ndate3 must be a parsable date (was \"\")`)\n\t})\n\n\t// https://github.com/arktypeio/arktype/issues/1188\n\tit(\"cyclic discriminated union issue 1\", () => {\n\t\tlet wasPiped = false\n\n\t\tconst $ = scope({\n\t\t\tFoo: {\n\t\t\t\t\"oneOf?\": \"Bar[]\" // NB: don't get the error if this is not an array\n\t\t\t},\n\t\t\tBar: \"Foo\"\n\t\t}).export()\n\n\t\tconst baz = $.Bar.pipe((_: object): type.Any | undefined => {\n\t\t\twasPiped = true\n\t\t\treturn type(\"string\")\n\t\t})\n\n\t\t// previously threw \"TypeError: this.Foo1Apply is not a function\"\n\t\tconst r = baz({ oneOf: [{}] })\n\n\t\tattest(wasPiped).equals(true)\n\t\tattest(r?.toString()).snap(\"Type<string>\")\n\t})\n\n\t// https://github.com/arktypeio/arktype/issues/1367\n\tit(\"cyclic discriminated union issue 2\", () => {\n\t\tconst componentModule = type.module({\n\t\t\tcontainer: {\n\t\t\t\ttype: \"'container'\",\n\t\t\t\tcontent: \"component\"\n\t\t\t},\n\n\t\t\tflexbox: {\n\t\t\t\ttype: \"'flexbox'\",\n\t\t\t\titems: \"component\"\n\t\t\t},\n\n\t\t\ttabsItem: {\n\t\t\t\tid: \"string\",\n\t\t\t\ttitle: \"component\",\n\t\t\t\tcontent: \"component\"\n\t\t\t},\n\t\t\ttabs: {\n\t\t\t\ttype: \"'tabs'\",\n\t\t\t\titems: \"tabsItem[]\"\n\t\t\t},\n\n\t\t\tsingleComponent: \"string | flexbox | tabs\",\n\t\t\tcomponent: \"singleComponent | singleComponent[]\"\n\t\t})\n\t\tconst componentSchema = componentModule.component\n\n\t\tconst component: typeof componentSchema.infer = {\n\t\t\ttype: \"tabs\",\n\t\t\titems: [\n\t\t\t\t{\n\t\t\t\t\tid: \"tab-id\",\n\t\t\t\t\ttitle: \"tab-title\",\n\t\t\t\t\tcontent: []\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\n\t\tconst result = componentSchema(component)\n\n\t\tattest(result).equals(component)\n\t})\n\n\t// https://github.com/arktypeio/arktype/issues/1209\n\tit(\"cyclic discriminated union issue 3\", () => {\n\t\tconst $ = scope({\n\t\t\tliteral: '\"foo\"',\n\t\t\trecord: {\n\t\t\t\t\"[string]\": \"value\"\n\t\t\t},\n\t\t\tvalue: \"literal|literal[]|record\"\n\t\t}).export()\n\n\t\tconst result = $.value({})\n\n\t\tattest(result).equals({})\n\t})\n\n\t// https://github.com/arktypeio/arktype/issues/1284\n\tit(\"cyclic discriminated union issue 4\", () => {\n\t\tconst ruleset = scope({\n\t\t\tTypeX: {\n\t\t\t\tid: \"string\",\n\t\t\t\t\"+\": \"reject\"\n\t\t\t},\n\t\t\t// always worked\n\t\t\tTypeA: {\n\t\t\t\tlabel: \"string\",\n\t\t\t\tid: \"string\",\n\t\t\t\t\"result?\": \"TypeA | TypeX\",\n\t\t\t\t\"+\": \"reject\"\n\t\t\t},\n\t\t\t// previously did not work\n\t\t\tTypeB: {\n\t\t\t\tlabel: \"string\",\n\t\t\t\tid: \"string\",\n\t\t\t\t\"result?\": \"TypeB | TypeX | null\",\n\t\t\t\t\"+\": \"reject\"\n\t\t\t},\n\t\t\t// always worked\n\t\t\tTypeC: {\n\t\t\t\tlabel: \"string\",\n\t\t\t\tid: \"string\",\n\t\t\t\t\"result?\": \"TypeA | TypeX | null\",\n\t\t\t\t\"+\": \"reject\"\n\t\t\t}\n\t\t})\n\t\tconst types = ruleset.export()\n\n\t\tconst data = {\n\t\t\tlabel: \"hi\",\n\t\t\tid: \"C\",\n\t\t\tresult: { label: \"A\", id: \"B\" }\n\t\t}\n\n\t\tattest(types.TypeA(data)).equals(data)\n\t\t// previously resulted in error:\n\t\t// result.label must be removed\n\t\tattest(types.TypeB(data)).equals(data)\n\t\tattest(types.TypeC(data)).equals(data)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/regex.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { intrinsic, writeInvalidOperandMessage } from \"@ark/schema\"\nimport { regex, type Type, type } from \"arktype\"\n\ncontextualize(() => {\n\tdescribe(\"intersection\", () => {\n\t\tit(\"distinct strings\", () => {\n\t\t\tconst T = type(\"/a/&/b/\")\n\t\t\tattest<`${string}a${string}` & `${string}b${string}`>(T.infer)\n\t\t\tattest(T.allows(\"a\")).equals(false)\n\t\t\tattest(T.allows(\"b\")).equals(false)\n\t\t\tattest(T.allows(\"ab\")).equals(true)\n\t\t})\n\n\t\tit(\"identical strings\", () => {\n\t\t\tconst T = type(\"/a/&/a/\")\n\t\t\tattest(T.json).equals(type(\"/a/\").json)\n\t\t})\n\n\t\tit(\"string and list\", () => {\n\t\t\tconst Expected = type(\"/a/&/b/&/c/\").json\n\t\t\tattest(type([\"/a/\", \"&\", \"/b/&/c/\"]).json).equals(Expected)\n\t\t\tattest(type([\"/a/\", \"&\", \"/b/&/c/\"]).json).equals(Expected)\n\t\t})\n\n\t\tit(\"redundant string and list\", () => {\n\t\t\tconst Expected = type(\"/a/&/b/&/c/\").json\n\t\t\tattest(type([\"/a/\", \"&\", \"/a/&/b/&/c/\"]).json).equals(Expected)\n\t\t\tattest(type([\"/a/&/b/&/c/\", \"&\", \"/c/\"]).json).equals(Expected)\n\t\t})\n\n\t\tit(\"distinct lists\", () => {\n\t\t\tconst T = type([\"/a/&/b/\", \"&\", \"/c/&/d/\"])\n\t\t\tattest(T.json).equals(type(\"/a/&/b/&/c/&/d/\").json)\n\t\t})\n\n\t\tit(\"overlapping lists\", () => {\n\t\t\tconst T = type([\"/a/&/b/\", \"&\", \"/c/&/b/\"])\n\t\t\tattest(T.json).equals(type(\"/a/&/b/&/c/\").json)\n\t\t})\n\n\t\tit(\"identical lists\", () => {\n\t\t\tconst T = type([\"/a/&/b/\", \"&\", \"/b/&/a/\"])\n\t\t\tattest(T.json).equals(type(\"/a/&/b/\").json)\n\t\t})\n\t})\n\n\tdescribe(\"instance\", () => {\n\t\tit(\"flagless\", () => {\n\t\t\tconst T = type(/.*/)\n\t\t\tattest<string>(T.infer)\n\t\t\tattest(T.json).equals(type(\"/.*/\").json)\n\t\t})\n\n\t\tit(\"single flag preserved\", () => {\n\t\t\tconst T = type(/a/i)\n\t\t\t// the flag should prevent it from reducing to the same regex\n\t\t\tattest(T.json === type(\"/a/\").json).equals(false)\n\t\t\tattest(T.allows(\"A\")).equals(true)\n\t\t})\n\n\t\tit(\"flag order doesn't matter\", () => {\n\t\t\tconst A = type(/a/gi)\n\t\t\tconst B = type(new RegExp(\"a\", \"ig\"))\n\t\t\tattest(A.json).equals(B.json)\n\t\t})\n\t})\n\n\tdescribe(\"chained\", () => {\n\t\tit(\"matching\", () => {\n\t\t\tconst T = type(\"string\").matching(\"foo\")\n\t\t\tconst Expected = type(\"/foo/\")\n\t\t\tattest<typeof Expected>(T)\n\t\t\tattest(T.json).equals(Expected.json)\n\t\t})\n\n\t\tit(\"invalid operand\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"number\").matching(\"foo\"))\n\t\t\t\t.throws(\n\t\t\t\t\twriteInvalidOperandMessage(\n\t\t\t\t\t\t\"pattern\",\n\t\t\t\t\t\tintrinsic.string,\n\t\t\t\t\t\tintrinsic.number\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t.type.errors(\"Property 'matching' does not exist\")\n\t\t})\n\t})\n\n\tit(\"expression doesn't include string basis\", () => {\n\t\tconst T = type(/^a.*z$/)\n\n\t\tattest(T.expression).snap(\"/^a.*z$/\")\n\t})\n\n\tit(\"arkregex integration\", () => {\n\t\tconst T = type({\n\t\t\temail: regex(\"^.*@.*$\")\n\t\t})\n\n\t\tattest(T.expression).snap(\"{ email: /^.*@.*$/ }\")\n\t\tattest<\n\t\t\tType<{\n\t\t\t\temail: `${string}@${string}`\n\t\t\t}>\n\t\t>(T)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/runtime.bench.ts",
    "content": "import { bench } from \"@ark/attest\"\nimport { match, type } from \"arktype\"\n\nexport const validData = {\n\tnumber: 1,\n\tnegNumber: -1,\n\tmaxNumber: Number.MAX_VALUE,\n\tstring: \"string\",\n\tlongString:\n\t\t\"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Vivendum intellegat et qui, ei denique consequuntur vix. Semper aeterno percipit ut his, sea ex utinam referrentur repudiandae. No epicuri hendrerit consetetur sit, sit dicta adipiscing ex, in facete detracto deterruisset duo. Quot populo ad qui. Sit fugit nostrum et. Ad per diam dicant interesset, lorem iusto sensibus ut sed. No dicam aperiam vis. Pri posse graeco definitiones cu, id eam populo quaestio adipiscing, usu quod malorum te. Ex nam agam veri, dicunt efficiantur ad qui, ad legere adversarium sit. Commune platonem mel id, brute adipiscing duo an. Vivendum intellegat et qui, ei denique consequuntur vix. Offendit eleifend moderatius ex vix, quem odio mazim et qui, purto expetendis cotidieque quo cu, veri persius vituperata ei nec. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.\",\n\tboolean: true,\n\tdeeplyNested: {\n\t\tfoo: \"bar\",\n\t\tnum: 1,\n\t\tbool: false\n\t}\n}\n\nconst TReject = type({\n\tnumber: \"number\",\n\tnegNumber: \"number\",\n\tmaxNumber: \"number\",\n\tstring: \"string\",\n\tlongString: \"string\",\n\tboolean: \"boolean\",\n\tdeeplyNested: {\n\t\tfoo: \"string\",\n\t\tnum: \"number\",\n\t\tbool: \"boolean\"\n\t}\n}).onDeepUndeclaredKey(\"reject\")\n\nbench(\"moltar reject\", () => {\n\tTReject(validData)\n}).median([5.97, \"us\"])\n\nexport const T = type({\n\tnumber: \"number\",\n\tnegNumber: \"number\",\n\tmaxNumber: \"number\",\n\tstring: \"string\",\n\tlongString: \"string\",\n\tboolean: \"boolean\",\n\tdeeplyNested: {\n\t\tfoo: \"string\",\n\t\tnum: \"number\",\n\t\tbool: \"boolean\"\n\t}\n})\n\nbench(\"moltar allows\", () => {\n\tT.allows(validData)\n}).median([13.72, \"ns\"])\n\nbench(\"moltar apply\", () => {\n\tT(validData)\n}).median([21.31, \"ns\"])\n\nconst tDelete = type\n\t.scope({}, { clone: false })\n\t.type({\n\t\tnumber: \"number\",\n\t\tnegNumber: \"number\",\n\t\tmaxNumber: \"number\",\n\t\tstring: \"string\",\n\t\tlongString: \"string\",\n\t\tboolean: \"boolean\",\n\t\tdeeplyNested: {\n\t\t\tfoo: \"string\",\n\t\t\tnum: \"number\",\n\t\t\tbool: \"boolean\"\n\t\t}\n\t})\n\t.onDeepUndeclaredKey(\"delete\")\n\nbench(\"moltar delete\", () => {\n\ttDelete(validData)\n}).median([3.54, \"us\"])\n\nconst tShallowDelete = type.scope({}, { clone: false }).type({\n\t\"+\": \"delete\",\n\tnumber: \"number\",\n\tnegNumber: \"number\",\n\tmaxNumber: \"number\",\n\tstring: \"string\",\n\tlongString: \"string\",\n\tboolean: \"boolean\"\n})\n\nbench(\"shallow delete\", () => {\n\ttShallowDelete(validData)\n}).median([370, \"ns\"])\n\nbench(\"shallow primitive allows\", () => {\n\ttype.string.allows(\"foo\")\n}).median([10.01, \"ns\"])\n\nbench(\"shallow primitive apply\", () => {\n\ttype.string(\"foo\")\n}).median([25.01, \"ns\"])\n\nconst stringToLength = type.string.pipe(s => s.length)\n\nbench(\"shallow primitive morph\", () => {\n\tstringToLength(\"foo\")\n}).median([9.02, \"ns\"])\n\nconst invokedCases3 = match\n\t.case(\"31\", n => `${n}` as const)\n\t.case(\"32\", n => `${n}` as const)\n\t.case(\"33\", n => `${n}` as const)\n\t.default(\"assert\")\n\nbench(\"case(3, invoke)\", () => {\n\tinvokedCases3(31)\n\tinvokedCases3(32)\n\tinvokedCases3(33)\n}).median([55.72, \"ns\"])\n\nconst invokedCases10 = match\n\t.case(\"0n\", n => `${n}` as const)\n\t.case(\"1n\", n => `${n}` as const)\n\t.case(\"2n\", n => `${n}` as const)\n\t.case(\"3n\", n => `${n}` as const)\n\t.case(\"4n\", n => `${n}` as const)\n\t.case(\"5n\", n => `${n}` as const)\n\t.case(\"6n\", n => `${n}` as const)\n\t.case(\"7n\", n => `${n}` as const)\n\t.case(\"8n\", n => `${n}` as const)\n\t.case(\"9n\", n => `${n}` as const)\n\t.default(\"never\")\n\nbench(\"case(10, invoke first)\", () => {\n\tinvokedCases10(0n)\n\tinvokedCases10(1n)\n\tinvokedCases10(2n)\n}).median([151.45, \"ns\"])\n\nbench(\"case(10, invoke last)\", () => {\n\tinvokedCases10(7n)\n\tinvokedCases10(8n)\n\tinvokedCases10(9n)\n}).median([198.78, \"ns\"])\n\ntype Data =\n\t| {\n\t\t\tid: 1\n\t\t\toneValue: number\n\t  }\n\t| {\n\t\t\tid: 2\n\t\t\ttwoValue: string\n\t  }\n\nconst discriminateValue = match\n\t.in<Data>()\n\t.at(\"id\")\n\t.match({\n\t\t1: o => `${o.oneValue}!`,\n\t\t2: o => o.twoValue.length,\n\t\tdefault: \"assert\"\n\t})\n\nbench(\"discriminate\", () => {\n\tdiscriminateValue({ id: 1, oneValue: 1 })\n\tdiscriminateValue({ id: 2, twoValue: \"two\" })\n}).median([68.36, \"ns\"])\n"
  },
  {
    "path": "ark/type/__tests__/scope.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport {\n\trootSchema,\n\twriteUnboundableMessage,\n\twriteUnresolvableMessage,\n\ttype ArkErrors\n} from \"@ark/schema\"\nimport { scope, type, type Module, type Scope } from \"arktype\"\nimport type { distill } from \"arktype/internal/attributes.ts\"\nimport { writeUnexpectedCharacterMessage } from \"arktype/internal/parser/shift/operator/operator.ts\"\n\ncontextualize(() => {\n\tit(\"base definition\", () => {\n\t\tconst types = scope({ actual: { name: \"string\" } }).export()\n\n\t\tconst Expected = type({\n\t\t\tname: \"string\"\n\t\t})\n\n\t\tattest<typeof Expected.t>(types.actual.t)\n\t\tattest(types.actual.expression).equals(Expected.expression)\n\t\tattest(() =>\n\t\t\t// @ts-expect-error\n\t\t\tscope({ a: \"strong\" }).export()\n\t\t).throwsAndHasTypeError(writeUnresolvableMessage(\"strong\"))\n\t})\n\n\tit(\"define\", () => {\n\t\tconst aliases = scope.define({ foo: \"string\", bar: { foo: \"foo\" } })\n\t\tattest<{\n\t\t\treadonly foo: \"string\"\n\t\t\treadonly bar: {\n\t\t\t\treadonly foo: \"foo\"\n\t\t\t}\n\t\t}>(aliases).snap({ foo: \"string\", bar: { foo: \"foo\" } })\n\t})\n\n\tit(\"docs example\", () => {\n\t\tconst $ = type.scope({\n\t\t\t// built-in keywords are still available in your scope\n\t\t\tid: \"string\",\n\t\t\t// but you can also reference your own aliases directly!\n\t\t\tuser: { id: \"id\", friends: \"id[]\" },\n\t\t\t// your aliases will be autocompleted alongside built-in keywords\n\t\t\tusersById: {\n\t\t\t\t\"[id]\": \"user | undefined\"\n\t\t\t}\n\t\t})\n\n\t\t$.export()\n\n\t\tattest<\n\t\t\tScope<{\n\t\t\t\tid: string\n\t\t\t\tuser: {\n\t\t\t\t\tid: string\n\t\t\t\t\tfriends: string[]\n\t\t\t\t}\n\t\t\t\tusersById: {\n\t\t\t\t\t[x: string]:\n\t\t\t\t\t\t| {\n\t\t\t\t\t\t\t\tid: string\n\t\t\t\t\t\t\t\tfriends: string[]\n\t\t\t\t\t\t  }\n\t\t\t\t\t\t| undefined\n\t\t\t\t}\n\t\t\t}>\n\t\t>($)\n\t\tattest($.json).snap({\n\t\t\tid: { domain: \"string\" },\n\t\t\tuser: {\n\t\t\t\trequired: [\n\t\t\t\t\t{ key: \"friends\", value: { sequence: \"string\", proto: \"Array\" } },\n\t\t\t\t\t{ key: \"id\", value: \"string\" }\n\t\t\t\t],\n\t\t\t\tdomain: \"object\"\n\t\t\t},\n\t\t\tusersById: {\n\t\t\t\tindex: [\n\t\t\t\t\t{\n\t\t\t\t\t\tsignature: \"string\",\n\t\t\t\t\t\tvalue: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\trequired: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tkey: \"friends\",\n\t\t\t\t\t\t\t\t\t\tvalue: { sequence: \"string\", proto: \"Array\" }\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{ key: \"id\", value: \"string\" }\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tdomain: \"object\"\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ unit: \"undefined\" }\n\t\t\t\t\t\t]\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\tdomain: \"object\"\n\t\t\t}\n\t\t})\n\t})\n\n\tit(\"type definition inline\", () => {\n\t\tconst $ = scope({ actual: type({ name: \"string\" }) })\n\t\tconst types = $.export()\n\n\t\tconst Expected = type({ name: \"string\" })\n\n\t\tattest<typeof Expected.t>(types.actual.t)\n\t\tattest(types.actual.expression).equals(Expected.expression)\n\t\tattest(types.actual.$.json).equals($.json)\n\n\t\tattest(() =>\n\t\t\t// @ts-expect-error\n\t\t\tscope({ a: type(\"strong\") })\n\t\t).throwsAndHasTypeError(writeUnresolvableMessage(\"strong\"))\n\t})\n\n\tit(\"interdependent\", () => {\n\t\tconst types = scope({\n\t\t\tl: \"string > 5\",\n\t\t\tr: \"string.email <= 10\",\n\t\t\tactual: \"l & r\"\n\t\t}).export()\n\n\t\tconst Expected = type(\"string.email <= 10 & string > 5\")\n\n\t\tattest<typeof Expected.t>(types.actual.t)\n\t\tattest(types.actual.expression).equals(Expected.expression)\n\t})\n\n\tit(\"object tuple\", () => {\n\t\tconst types = scope({ ref: \"string\", actual: [{ c: \"ref\" }] }).export()\n\t\tconst Expected = type([{ c: \"string\" }])\n\n\t\tattest<typeof Expected.t>(types.actual.t)\n\t\tattest(types.actual.expression).equals(Expected.expression)\n\t})\n\n\tit(\"doesn't try to validate any in scope\", () => {\n\t\tconst $ = scope({ a: {} as any })\n\t\tattest<any>($.resolve(\"a\").infer)\n\n\t\tconst T = $.type([\"number\", \"a\"])\n\n\t\tattest<[number, any]>(T.infer)\n\t})\n\n\tit(\"infers input and output\", () => {\n\t\tconst $ = scope({\n\t\t\ta: [\"string\", \"=>\", s => s.length]\n\t\t})\n\t\tattest<number>($.resolve(\"a\").infer)\n\n\t\tattest<string>($.resolve(\"a\").inferIn)\n\t})\n\n\tit(\"infers its own helpers\", () => {\n\t\tconst $ = scope({\n\t\t\ta: () => $.type(\"string\"),\n\t\t\tb: () => $.type(\"number\")\n\t\t})\n\t\tconst types = $.export()\n\n\t\tattest<string>(types.a.infer)\n\t\tattest(types.a.expression).equals(\"string\")\n\t\tattest(types.a.$.json).equals($.json)\n\n\t\tattest<number>(types.b.infer)\n\t\tattest(types.b.expression).equals(\"number\")\n\t\tattest(types.b.$.json).equals($.json)\n\t})\n\n\tit(\"allows semantically valid helpers\", () => {\n\t\tconst $ = scope({\n\t\t\tn: () => $.type(\"number\"),\n\t\t\tlessThan10: () => $.type(\"n<10\")\n\t\t})\n\t\tconst types = $.export()\n\n\t\tattest<number>(types.n.t)\n\t\tattest(types.n.expression).equals(\"number\")\n\n\t\tconst Expected = type(\"number\").lessThan(10)\n\n\t\tattest<typeof Expected.t>(types.lessThan10.t)\n\t\tattest(types.lessThan10.expression).equals(Expected.expression)\n\t})\n\n\tit(\"errors on helper parse error\", () => {\n\t\tattest(() => {\n\t\t\tconst $ = scope({\n\t\t\t\t// @ts-expect-error\n\t\t\t\ta: () => $.type(\"kung|foo\")\n\t\t\t})\n\t\t\t$.export()\n\t\t}).throwsAndHasTypeError(writeUnresolvableMessage(\"kung\"))\n\t})\n\n\tit(\"errors on semantically invalid helper\", () => {\n\t\tattest(() => {\n\t\t\tconst $ = scope({\n\t\t\t\tb: () => $.type(\"boolean\"),\n\t\t\t\t// @ts-expect-error\n\t\t\t\tlessThan10: () => $.type(\"b<10\")\n\t\t\t})\n\t\t\t$.export()\n\t\t}).throwsAndHasTypeError(writeUnboundableMessage(\"boolean\"))\n\t})\n\n\tit(\"errors on ridiculous unexpected alias scenario\", () => {\n\t\tattest(() =>\n\t\t\tscope({\n\t\t\t\tUnexpected: {},\n\t\t\t\tUser: {\n\t\t\t\t\t// Previously, using the alias `Unexpected` allowed creating\n\t\t\t\t\t// this type string which matched its own error message.\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tname: \"Unexpected character 'c'\"\n\t\t\t\t}\n\t\t\t}).export()\n\t\t).throwsAndHasTypeError(writeUnexpectedCharacterMessage(\"c\"))\n\t})\n\n\tit(\"autocompletion\", () => {\n\t\tattest(() => {\n\t\t\tscope({\n\t\t\t\tfoobar: \"string\",\n\t\t\t\t// @ts-expect-error\n\t\t\t\tbaz: \"foo\"\n\t\t\t}).export()\n\t\t}).completions({ foo: [\"foobar\"] })\n\t})\n\n\tit(\"cross-scope reference\", () => {\n\t\tconst { Apple } = scope({\n\t\t\tApple: {\n\t\t\t\tpear: \"Pear\"\n\t\t\t},\n\t\t\tPear: {\n\t\t\t\ttasty: \"true\"\n\t\t\t}\n\t\t}).export()\n\n\t\tconst { X } = scope({\n\t\t\tX: Apple\n\t\t}).export()\n\n\t\tconst out = X({ pear: { tasty: true } })\n\t\tattest(out).snap({ pear: { tasty: true } })\n\t})\n\n\tdescribe(\"cyclic\", () => {\n\t\tit(\"base\", () => {\n\t\t\tconst types = scope({ a: { b: \"b\" }, b: { a: \"a\" } }).export()\n\n\t\t\tconst a = {} as { b: typeof b }\n\t\t\tconst b = { a }\n\t\t\ta.b = b\n\n\t\t\tattest(types.a(a)).equals(a)\n\t\t\tattest(types.a({ b: { a: { b: { a: 5 } } } }).toString()).snap(\n\t\t\t\t\"b.a.b.a must be an object (was a number)\"\n\t\t\t)\n\n\t\t\t// Type hint displays as \"...\" on hitting cycle (or any if \"noErrorTruncation\" is true)\n\t\t\tattest({} as typeof types.a.infer).type.toString.snap(\n\t\t\t\t\"{ b: { a: cyclic } }\"\n\t\t\t)\n\t\t\tattest({} as typeof types.b.infer.a.b.a.b.a.b.a).type.toString.snap(\n\t\t\t\t\"{ b: { a: cyclic } }\"\n\t\t\t)\n\n\t\t\t// @ts-expect-error\n\t\t\tattest({} as typeof types.a.infer.b.a.b.c).type.errors.snap(\n\t\t\t\t\"Property 'c' does not exist on type '{ a: { b: ...; }; }'.\"\n\t\t\t)\n\t\t})\n\n\t\tconst getCyclicScope = () =>\n\t\t\tscope({\n\t\t\t\tpackage: {\n\t\t\t\t\tname: \"string\",\n\t\t\t\t\t\"dependencies?\": \"package[]\",\n\t\t\t\t\t\"contributors?\": \"contributor[]\"\n\t\t\t\t},\n\t\t\t\tcontributor: {\n\t\t\t\t\temail: \"string.email\",\n\t\t\t\t\t\"packages?\": \"package[]\"\n\t\t\t\t}\n\t\t\t})\n\n\t\ttype Package = distill.Out<\n\t\t\tReturnType<typeof getCyclicScope>[\"t\"][\"package\"]\n\t\t>\n\n\t\tconst getCyclicData = () => {\n\t\t\tconst packageData = {\n\t\t\t\tname: \"arktype\",\n\t\t\t\tdependencies: [{ name: \"typescript\" }],\n\t\t\t\tcontributors: [{ email: \"david@arktype.io\" }]\n\t\t\t} satisfies Package\n\t\t\tpackageData.dependencies.push(packageData)\n\t\t\treturn packageData\n\t\t}\n\n\t\tit(\"cyclic intersection\", () => {\n\t\t\tconst types = scope({\n\t\t\t\ta: { b: \"b&a\" },\n\t\t\t\tb: { a: \"a&b\" }\n\t\t\t}).export()\n\t\t\tattest(types.a.t).type.toString.snap(\n\t\t\t\t\"{ b: { a: { b: cyclic; a: cyclic }; b: cyclic } }\"\n\t\t\t)\n\t\t\tattest(types.b.t).type.toString.snap(\n\t\t\t\t\"{ a: { b: { a: cyclic; b: cyclic }; a: cyclic } }\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"cyclic union\", () => {\n\t\t\tconst types = scope({\n\t\t\t\ta: { b: \"b|false\" },\n\t\t\t\tb: { a: \"a|true\" }\n\t\t\t}).export()\n\t\t\tattest(types.a.t).type.toString.snap(\n\t\t\t\t\"{ b: false | { a: true | cyclic } }\"\n\t\t\t)\n\t\t\tattest(types.b.t).type.toString.snap(\n\t\t\t\t\"{ a: true | { b: false | cyclic } }\"\n\t\t\t)\n\t\t})\n\n\t\tit(\"allows valid\", () => {\n\t\t\tconst types = getCyclicScope().export()\n\t\t\tconst data = getCyclicData()\n\t\t\tattest(types.package(data)).snap({\n\t\t\t\tname: \"arktype\",\n\t\t\t\tdependencies: [{ name: \"typescript\" }, \"(cycle)\" as never],\n\t\t\t\tcontributors: [{ email: \"david@arktype.io\" }]\n\t\t\t})\n\t\t})\n\n\t\tit(\"adds errors on invalid\", () => {\n\t\t\tconst types = getCyclicScope().export()\n\t\t\tconst data = getCyclicData()\n\t\t\tdata.contributors[0].email = \"ssalbdivad\"\n\t\t\t// ideally would only include one error, see:\n\t\t\t// https://github.com/arktypeio/arktype/issues/924\n\t\t\tattest(types.package(data).toString())\n\t\t\t\t.snap(`contributors[0].email must be an email address (was \"ssalbdivad\")\ndependencies[1].contributors[0].email must be an email address (was \"ssalbdivad\")`)\n\t\t})\n\n\t\tit(\"can include cyclic data in message\", () => {\n\t\t\tconst data = getCyclicData()\n\t\t\tconst nonSelfDependent = getCyclicScope().type([\n\t\t\t\t\"package\",\n\t\t\t\t\":\",\n\t\t\t\tp => !p.dependencies?.some(d => d.name === p.name)\n\t\t\t])\n\t\t\tattest(nonSelfDependent(data).toString()).snap(\n\t\t\t\t'must be valid according to an anonymous predicate (was {\"name\":\"arktype\",\"dependencies\":[{\"name\":\"typescript\"},\"(cycle)\"],\"contributors\":[{\"email\":\"david@arktype.io\"}]})'\n\t\t\t)\n\t\t})\n\n\t\tit(\"intersect cyclic reference\", () => {\n\t\t\tconst types = scope({\n\t\t\t\tarf: {\n\t\t\t\t\tb: \"bork\"\n\t\t\t\t},\n\t\t\t\tbork: {\n\t\t\t\t\tc: \"arf&bork\"\n\t\t\t\t}\n\t\t\t}).export()\n\t\t\tattest(types.arf.infer).type.toString.snap(\n\t\t\t\t\"{ b: { c: { b: cyclic; c: cyclic } } }\"\n\t\t\t)\n\t\t\tattest(types.bork.infer).type.toString.snap(\n\t\t\t\t\"{ c: { b: cyclic; c: cyclic } }\"\n\t\t\t)\n\n\t\t\tconst expectedCyclicJson = types.arf.internal.select({\n\t\t\t\tkind: \"alias\",\n\t\t\t\tmethod: \"assertFind\"\n\t\t\t}).json\n\n\t\t\tattest(types.arf.json).snap({\n\t\t\t\tdomain: \"object\",\n\t\t\t\trequired: [\n\t\t\t\t\t{\n\t\t\t\t\t\tkey: \"b\",\n\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\tdomain: \"object\",\n\t\t\t\t\t\t\trequired: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tkey: \"c\",\n\t\t\t\t\t\t\t\t\tvalue: expectedCyclicJson\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t})\n\t\t\tconst a = {} as typeof types.arf.infer\n\t\t\tconst b = { c: {} } as typeof types.bork.infer\n\t\t\ta.b = b\n\t\t\tb.c.b = b\n\t\t\tb.c.c = b.c\n\n\t\t\tattest(types.arf.expression).snap(\"{ b: { c: $arf&$bork } }\")\n\t\t\tattest(types.bork.expression).snap(\"{ c: $arf&$bork }\")\n\n\t\t\tattest(types.arf(a)).equals(a)\n\t\t\tattest(types.arf({ b: { c: {} } }).toString())\n\t\t\t\t.snap(`b.c.b must be an object (was missing)\nb.c.c must be an object (was missing)`)\n\n\t\t\tattest(types.bork.json).snap({\n\t\t\t\tdomain: \"object\",\n\t\t\t\trequired: [\n\t\t\t\t\t{\n\t\t\t\t\t\tkey: \"c\",\n\t\t\t\t\t\tvalue: expectedCyclicJson\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t})\n\t\t})\n\n\t\tit(\"union cyclic reference\", () => {\n\t\t\tconst types = scope({\n\t\t\t\ta: {\n\t\t\t\t\tb: \"b\"\n\t\t\t\t},\n\t\t\t\tb: {\n\t\t\t\t\ta: \"a|3\"\n\t\t\t\t}\n\t\t\t}).export()\n\t\t\tattest(types.a.infer).type.toString.snap(\"{ b: { a: 3 | cyclic } }\")\n\n\t\t\tattest(types.a.json).snap({\n\t\t\t\tdomain: \"object\",\n\t\t\t\trequired: [\n\t\t\t\t\t{\n\t\t\t\t\t\tkey: \"b\",\n\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\tdomain: \"object\",\n\t\t\t\t\t\t\trequired: [{ key: \"a\", value: [\"$a\", { unit: 3 }] }]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t})\n\n\t\t\tconst valid: typeof types.a.infer = { b: { a: 3 } }\n\n\t\t\tattest(types.a(valid)).equals(valid)\n\n\t\t\tvalid.b.a = valid\n\n\t\t\t// check cyclic\n\t\t\tattest(types.a(valid)).equals(valid)\n\n\t\t\tattest(types.a({ b: { a: { b: { a: 4 } } } }).toString()).snap(\n\t\t\t\t'b.a.b.a must be an object or 3 (was 4) or b.a must be 3 (was {\"b\":{\"a\":4}})'\n\t\t\t)\n\n\t\t\tattest(types.b.infer).type.toString.snap(\"{ a: 3 | { b: cyclic } }\")\n\t\t\tattest(types.b.json).snap({\n\t\t\t\tdomain: \"object\",\n\t\t\t\trequired: [{ key: \"a\", value: [\"$a\", { unit: 3 }] }]\n\t\t\t})\n\t\t})\n\n\t\t// https://github.com/arktypeio/arktype/issues/1138\n\t\tit(\"cyclic array\", () => {\n\t\t\ttype Value = boolean | number | string | { [k: string]: Value } | Value[]\n\n\t\t\tconst types = scope({\n\t\t\t\tprimitive: \"boolean | number | string\",\n\t\t\t\trecord: {\n\t\t\t\t\t\"[string]\": \"value\"\n\t\t\t\t},\n\t\t\t\tvalue: \"primitive | record | value[]\",\n\t\t\t\tcastValue: \"value\" as type.cast<Value>\n\t\t\t}).export()\n\n\t\t\t// TS type display blows up but it's equivalent to Value\n\t\t\tconst out = types.value(5)\n\t\t\t// casting to Value also works\n\t\t\tconst castOut = types.value(5)\n\n\t\t\tattest<Value | ArkErrors>(out).equals(5)\n\t\t\tattest<Value | ArkErrors>(castOut).equals(5)\n\t\t})\n\t})\n\n\tit(\"can override ambient aliases\", () => {\n\t\tconst types = scope({\n\t\t\tfoo: {\n\t\t\t\tbar: \"string\"\n\t\t\t},\n\t\t\tstring: type.number\n\t\t}).export()\n\t\tattest<\n\t\t\tModule<{\n\t\t\t\tstring: number\n\t\t\t\tfoo: {\n\t\t\t\t\tbar: number\n\t\t\t\t}\n\t\t\t}>\n\t\t>(types)\n\t\tattest(types.foo.json).snap({\n\t\t\trequired: [{ key: \"bar\", value: \"number\" }],\n\t\t\tdomain: \"object\"\n\t\t})\n\t})\n\n\tit(\"module\", () => {\n\t\tconst types = type.module({\n\t\t\tfoo: \"string\",\n\t\t\tbar: \"number\"\n\t\t})\n\t\tattest<\n\t\t\tModule<{\n\t\t\t\tfoo: string\n\t\t\t\tbar: number\n\t\t\t}>\n\t\t>(types)\n\t\tattest(types.foo.json).snap({ domain: \"string\" })\n\t\tattest(types.bar.json).snap({ domain: \"number\" })\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/select.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport type { DomainNode } from \"@ark/schema\"\nimport { type } from \"arktype\"\n\ncontextualize(() => {\n\tcontextualize.each(\n\t\t\"select from User\",\n\t\t() => {\n\t\t\tconst User = type({\n\t\t\t\tname: \"string\",\n\t\t\t\tplatform: \"'android' | 'ios'\",\n\t\t\t\t\"version?\": \"number | string\"\n\t\t\t})\n\n\t\t\tconst ExpectedConfiguredUser = User.configure(\n\t\t\t\t{ description: \"A STRING\" },\n\t\t\t\t{\n\t\t\t\t\tkind: \"domain\",\n\t\t\t\t\twhere: d => d.domain === \"string\"\n\t\t\t\t}\n\t\t\t)\n\n\t\t\treturn { User, ExpectedConfiguredUser }\n\t\t},\n\t\tit => {\n\t\t\tit(\"can select a domain\", ({ User }) => {\n\t\t\t\tconst selected = User.select({\n\t\t\t\t\tkind: \"domain\",\n\t\t\t\t\twhere: d => d.domain === \"string\"\n\t\t\t\t})\n\n\t\t\t\tattest<DomainNode[]>(selected).snap([{ domain: \"string\" }])\n\t\t\t})\n\n\t\t\tit(\"fluent selector\", ({\n\t\t\t\tExpectedConfiguredUser: ExpectedConfiguredUser\n\t\t\t}) => {\n\t\t\t\tattest(ExpectedConfiguredUser).snap({\n\t\t\t\t\trequired: [\n\t\t\t\t\t\t{ key: \"name\", value: { domain: \"string\", meta: \"A STRING\" } },\n\t\t\t\t\t\t{ key: \"platform\", value: [{ unit: \"android\" }, { unit: \"ios\" }] }\n\t\t\t\t\t],\n\t\t\t\t\toptional: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkey: \"version\",\n\t\t\t\t\t\t\tvalue: [\"number\", { domain: \"string\", meta: \"A STRING\" }]\n\t\t\t\t\t\t}\n\t\t\t\t\t],\n\t\t\t\t\tdomain: \"object\"\n\t\t\t\t})\n\t\t\t})\n\n\t\t\tit(\"tuple expression selector\", ({ User, ExpectedConfiguredUser }) => {\n\t\t\t\tconst T = type([\n\t\t\t\t\tUser,\n\t\t\t\t\t\"@\",\n\t\t\t\t\t{\n\t\t\t\t\t\tdescription: \"A STRING\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tkind: \"domain\",\n\t\t\t\t\t\t// tuple expression syntax doesn't support narrowing d from kind here\n\t\t\t\t\t\twhere: d => d.assertHasKind(\"domain\").domain === \"string\"\n\t\t\t\t\t}\n\t\t\t\t])\n\n\t\t\t\tattest(T.json).equals(ExpectedConfiguredUser.json)\n\t\t\t})\n\n\t\t\tit(\"args expression selector\", ({ User, ExpectedConfiguredUser }) => {\n\t\t\t\tconst T = type(\n\t\t\t\t\tUser,\n\t\t\t\t\t\"@\",\n\t\t\t\t\t{\n\t\t\t\t\t\tdescription: \"A STRING\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tkind: \"domain\",\n\t\t\t\t\t\t// args expression syntax doesn't support narrowing d from kind here\n\t\t\t\t\t\twhere: d => d.assertHasKind(\"domain\").domain === \"string\"\n\t\t\t\t\t}\n\t\t\t\t)\n\n\t\t\t\tattest(T.json).equals(ExpectedConfiguredUser.json)\n\t\t\t})\n\t\t}\n\t)\n\n\tit(\"docs select config example\", () => {\n\t\tconst SelectivelyConfigured = type({\n\t\t\tname: \"string\",\n\t\t\tage: \"number\"\n\t\t}).configure(\n\t\t\t{\n\t\t\t\tdescription: \"a special string\"\n\t\t\t},\n\t\t\t// only add the description to string keywords\n\t\t\t{\n\t\t\t\tkind: \"domain\",\n\t\t\t\twhere: d => d.domain === \"string\"\n\t\t\t}\n\t\t)\n\n\t\tattest(SelectivelyConfigured.get(\"name\").description).equals(\n\t\t\t\"a special string\"\n\t\t)\n\t\tattest(SelectivelyConfigured.get(\"age\").description).equals(\"a number\")\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/serialization.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { rootSchema } from \"@ark/schema\"\nimport { type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"built-in prototypes\", () => {\n\t\tconst A = type({\n\t\t\tage: \"number\"\n\t\t})\n\n\t\tconst B = type({\n\t\t\tages: A.array()\n\t\t})\n\n\t\tconst C = rootSchema(B.json as never)\n\n\t\tattest(B.json).equals(C.json)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/standardSchema.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport {\n\twriteInvalidJsonSchemaTargetMessage,\n\ttype StandardJSONSchemaV1,\n\ttype StandardSchemaV1\n} from \"@ark/schema\"\nimport type { promisable } from \"@ark/util\"\nimport { type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"validation conforms to spec\", () => {\n\t\tconst T = type({ foo: \"string\" })\n\t\tconst standard: StandardSchemaV1<{ foo: string }> = T\n\t\tconst standardOut = standard[\"~standard\"].validate({\n\t\t\tfoo: \"bar\"\n\t\t})\n\t\tattest<promisable<StandardSchemaV1.Result<{ foo: string }>>>(\n\t\t\tstandardOut\n\t\t).equals({\n\t\t\tvalue: { foo: \"bar\" }\n\t\t})\n\n\t\tconst badStandardOut = standard[\"~standard\"].validate({\n\t\t\tfoo: 5\n\t\t}) as StandardSchemaV1.FailureResult\n\n\t\tattest(badStandardOut.issues).instanceOf(type.errors)\n\t\tattest(badStandardOut.issues.toString()).snap(\n\t\t\t\"foo must be a string (was a number)\"\n\t\t)\n\t})\n\n\tit(\"can infer generic parameter from standard schema\", () => {\n\t\tconst acceptsStandardSchema = <T extends StandardSchemaV1>(\n\t\t\tschema: T\n\t\t): {\n\t\t\tinput: StandardSchemaV1.InferInput<T>\n\t\t\toutput: StandardSchemaV1.InferOutput<T>\n\t\t} => ({}) as never\n\n\t\tconst result = acceptsStandardSchema(type({ foo: \"string.numeric.parse\" }))\n\n\t\tattest<{ foo: string }>(result.input)\n\t\tattest<{ foo: number }>(result.output)\n\t})\n\n\tdescribe(\"~standard.jsonSchema\", () => {\n\t\tit(\"generates input schema with draft-2020-12\", () => {\n\t\t\tconst T = type({ foo: \"string\" })\n\t\t\tconst standard: StandardJSONSchemaV1 = T\n\t\t\tconst jsonSchema = standard[\"~standard\"].jsonSchema.input({\n\t\t\t\ttarget: \"draft-2020-12\"\n\t\t\t})\n\t\t\tattest(jsonSchema).snap({\n\t\t\t\t$schema: \"https://json-schema.org/draft/2020-12/schema\",\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: { foo: { type: \"string\" } },\n\t\t\t\trequired: [\"foo\"]\n\t\t\t})\n\t\t})\n\n\t\tit(\"generates output schema with draft-2020-12\", () => {\n\t\t\tconst T = type({ foo: \"string\" })\n\t\t\tconst standard: StandardJSONSchemaV1 = T\n\t\t\tconst jsonSchema = standard[\"~standard\"].jsonSchema.output({\n\t\t\t\ttarget: \"draft-2020-12\"\n\t\t\t})\n\t\t\tattest(jsonSchema).snap({\n\t\t\t\t$schema: \"https://json-schema.org/draft/2020-12/schema\",\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: { foo: { type: \"string\" } },\n\t\t\t\trequired: [\"foo\"]\n\t\t\t})\n\t\t})\n\n\t\tit(\"generates input schema with draft-07\", () => {\n\t\t\tconst T = type({ foo: \"string\" })\n\t\t\tconst standard: StandardJSONSchemaV1 = T\n\t\t\tconst jsonSchema = standard[\"~standard\"].jsonSchema.input({\n\t\t\t\ttarget: \"draft-07\"\n\t\t\t})\n\t\t\tattest(jsonSchema).snap({\n\t\t\t\t$schema: \"http://json-schema.org/draft-07/schema#\",\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: { foo: { type: \"string\" } },\n\t\t\t\trequired: [\"foo\"]\n\t\t\t})\n\t\t})\n\n\t\tit(\"generates output schema with draft-07\", () => {\n\t\t\tconst T = type({ foo: \"string\" })\n\t\t\tconst standard: StandardJSONSchemaV1 = T\n\t\t\tconst jsonSchema = standard[\"~standard\"].jsonSchema.output({\n\t\t\t\ttarget: \"draft-07\"\n\t\t\t})\n\t\t\tattest(jsonSchema).snap({\n\t\t\t\t$schema: \"http://json-schema.org/draft-07/schema#\",\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: { foo: { type: \"string\" } },\n\t\t\t\trequired: [\"foo\"]\n\t\t\t})\n\t\t})\n\n\t\tit(\"passes libraryOptions to toJsonSchema\", () => {\n\t\t\tconst T = type({ foo: \"string\" })\n\t\t\tconst standard: StandardJSONSchemaV1 = T\n\t\t\tconst jsonSchema = standard[\"~standard\"].jsonSchema.input({\n\t\t\t\ttarget: \"draft-2020-12\",\n\t\t\t\tlibraryOptions: {\n\t\t\t\t\tdialect: null\n\t\t\t\t}\n\t\t\t})\n\t\t\tattest(jsonSchema).snap({\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: { foo: { type: \"string\" } },\n\t\t\t\trequired: [\"foo\"]\n\t\t\t})\n\t\t})\n\n\t\tit(\"throws for unsupported target\", () => {\n\t\t\tconst T = type({ foo: \"string\" })\n\t\t\tconst standard: StandardJSONSchemaV1 = T\n\t\t\tattest(() =>\n\t\t\t\tstandard[\"~standard\"].jsonSchema.input({\n\t\t\t\t\ttarget: \"openapi-3.0\"\n\t\t\t\t})\n\t\t\t).throws(writeInvalidJsonSchemaTargetMessage(\"openapi-3.0\"))\n\t\t})\n\n\t\tit(\"generates different input/output schemas for morphs\", () => {\n\t\t\tconst T = type({ foo: \"string.numeric.parse\" })\n\t\t\tconst standard: StandardJSONSchemaV1 = T\n\n\t\t\tconst inputSchema = standard[\"~standard\"].jsonSchema.input({\n\t\t\t\ttarget: \"draft-2020-12\"\n\t\t\t})\n\t\t\tattest(inputSchema).snap({\n\t\t\t\t$schema: \"https://json-schema.org/draft/2020-12/schema\",\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\tfoo: {\n\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\tpattern:\n\t\t\t\t\t\t\t\"^(?:(?!^-0\\\\.?0*$)(?:-?(?:(?:0|[1-9]\\\\d*)(?:\\\\.\\\\d+)?)|\\\\.\\\\d+?))$\"\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\trequired: [\"foo\"]\n\t\t\t})\n\n\t\t\tconst outputSchema = standard[\"~standard\"].jsonSchema.output({\n\t\t\t\ttarget: \"draft-2020-12\"\n\t\t\t})\n\t\t\tattest(outputSchema).snap({\n\t\t\t\t$schema: \"https://json-schema.org/draft/2020-12/schema\",\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: { foo: { type: \"number\" } },\n\t\t\t\trequired: [\"foo\"]\n\t\t\t})\n\t\t})\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/string.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { writeUnresolvableMessage } from \"@ark/schema\"\nimport { type } from \"arktype\"\nimport { writeUnterminatedEnclosedMessage } from \"arktype/internal/parser/shift/operand/enclosed.ts\"\nimport { writeExpressionExpectedMessage } from \"arktype/internal/parser/shift/operand/unenclosed.ts\"\n\ncontextualize(() => {\n\tit(\"errors on empty string\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"\")).throws(writeExpressionExpectedMessage(\"\"))\n\t})\n\n\tit(\"ignores whitespace between identifiers/operators\", () => {\n\t\tconst T = type(`  \\n   string  |\n           number\n    \\t|boolean    []   `)\n\t\tattest<string | number | boolean[]>(T.infer)\n\t\tattest(T.json).equals(type(\"string|number|boolean[]\").json)\n\t})\n\n\tit(\"errors on bad whitespace\", () => {\n\t\tattest(() =>\n\t\t\t// @ts-expect-error\n\t\t\ttype(\"string | boo lean[]\")\n\t\t)\n\t\t\t.throws(writeUnresolvableMessage(\"boo\"))\n\t\t\t.type.errors(\"string | boolean\")\n\t})\n\n\tit(\"unterminated string\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"'bob\")).throwsAndHasTypeError(\n\t\t\twriteUnterminatedEnclosedMessage(\"bob\", \"'\")\n\t\t)\n\t})\n\n\tit(\"shallow single autocomplete\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"str\")).completions({ str: [\"string\"] })\n\t})\n\n\tit(\"shallow multi autocomplete\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"s\")).completions({ s: [\"string\", \"symbol\"] })\n\t})\n\n\tit(\"post-operator autocomplete\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"string|num\")).completions({\n\t\t\t\"string|num\": [\"string|number\"]\n\t\t})\n\t})\n\n\tit(\"post-operator autocomplete with spaces\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"  string  |  num\")).completions({\n\t\t\t\"  string  |  num\": [\"  string  |  number\"]\n\t\t})\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/submodule.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport {\n\twriteMissingSubmoduleAccessMessage,\n\twriteNonSubmoduleDotMessage,\n\twriteUnresolvableMessage\n} from \"@ark/schema\"\nimport {\n\tscope,\n\ttype,\n\ttype BoundModule,\n\ttype Module,\n\ttype Scope,\n\ttype Submodule,\n\ttype Type\n} from \"arktype\"\n\ncontextualize.each(\n\t\"submodule\",\n\t() =>\n\t\tscope({\n\t\t\ta: \"string\",\n\t\t\tb: \"sub.alias\",\n\t\t\tsub: scope({ alias: \"number\" }).export()\n\t\t}),\n\tit => {\n\t\tit(\"base\", $ => {\n\t\t\tconst types = $.export()\n\t\t\tattest<\n\t\t\t\tModule<{\n\t\t\t\t\ta: string\n\t\t\t\t\tb: number\n\t\t\t\t\tsub: Submodule<{\n\t\t\t\t\t\talias: number\n\t\t\t\t\t}>\n\t\t\t\t}>\n\t\t\t>(types)\n\n\t\t\tattest<number>(types.sub.alias.infer)\n\t\t\tconst Expected = type(\"number\").json\n\t\t\tattest(types.sub.alias.json).equals(Expected)\n\t\t\tattest(types.b.json).equals(Expected)\n\t\t})\n\n\t\tit(\"non-submodule dot access\", $ => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => $.type(\"b.foo\")).throwsAndHasTypeError(\n\t\t\t\twriteNonSubmoduleDotMessage(\"b\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"thunk submodule\", () => {\n\t\t\tconst $ = scope({\n\t\t\t\ta: \"string\",\n\t\t\t\tc: \"a\",\n\t\t\t\tsub: () =>\n\t\t\t\t\tscope({\n\t\t\t\t\t\t...$.import(\"a\", \"c\"),\n\t\t\t\t\t\tfoo: \"a\",\n\t\t\t\t\t\tbar: \"foo\"\n\t\t\t\t\t}).export()\n\t\t\t})\n\t\t\tattest<\n\t\t\t\tScope<{\n\t\t\t\t\ta: string\n\t\t\t\t\tc: string\n\t\t\t\t\tsub: Submodule<{\n\t\t\t\t\t\tfoo: string\n\t\t\t\t\t\tbar: string\n\t\t\t\t\t}>\n\t\t\t\t}>\n\t\t\t>($)\n\t\t})\n\n\t\tit(\"no alias reference\", $ => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => $.type(\"sub\")).throwsAndHasTypeError(\n\t\t\t\twriteMissingSubmoduleAccessMessage(\"sub\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"bad alias reference\", $ => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => $.type(\"sub.marine\")).throwsAndHasTypeError(\n\t\t\t\twriteUnresolvableMessage(\"sub.marine\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"completions\", () => {\n\t\t\tconst base = scope({ foo: \"true\" }).export()\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => scope({ base, reference: \"base.\" }).export())\n\t\t\t\t.throws(writeUnresolvableMessage(\"base.\"))\n\t\t\t\t.type.completions({ \"base.\": [\"base.foo\"] })\n\t\t})\n\n\t\tit(\"can reference subaliases in expression\", () => {\n\t\t\tconst dateFrom = type(\"string.date.parse | Date\")\n\n\t\t\tattest(dateFrom.t).type.toString.snap(\"Date | ((In: string) => To<Date>)\")\n\n\t\t\tattest(dateFrom(\"05-21-1993\")).instanceOf(Date)\n\t\t\tattest(dateFrom(new Date())).instanceOf(Date)\n\n\t\t\tattest(dateFrom(\"foobar\").toString()).snap(\n\t\t\t\t'must be a parsable date (was \"foobar\")'\n\t\t\t)\n\t\t})\n\n\t\tit(\"allows unbound module in scope\", () => {\n\t\t\tconst mod = scope({\n\t\t\t\ta: \"number\"\n\t\t\t}).export()\n\n\t\t\tconst use1 = scope({\n\t\t\t\tmod,\n\t\t\t\tb: \"mod.a\"\n\t\t\t})\n\n\t\t\tattest(use1).type.toString.snap(\n\t\t\t\t\"Scope<{ b: number; mod: Submodule<{ a: number }> }>\"\n\t\t\t)\n\n\t\t\tuse1.export()\n\t\t\tattest(use1.json).snap({\n\t\t\t\t\"mod.a\": { domain: \"number\" },\n\t\t\t\tb: { domain: \"number\" }\n\t\t\t})\n\t\t})\n\n\t\t// https://github.com/arktypeio/arktype/issues/1103\n\t\tit(\"allows BoundModule reference in scope\", () => {\n\t\t\tconst mod2 = scope({\n\t\t\t\ta: \"number\",\n\t\t\t\tc: \"string\"\n\t\t\t}).export(\"a\")\n\n\t\t\tconst use2 = scope({\n\t\t\t\tmod2,\n\t\t\t\tb: \"mod2.a\"\n\t\t\t})\n\n\t\t\tattest(use2).type.toString.snap(`Scope<{\n\tb: number\n\tmod2: Submodule<{ a: number }>\n}>`)\n\n\t\t\tuse2.export()\n\t\t\tattest(use2.json).snap({\n\t\t\t\t\"mod2.a\": { domain: \"number\" },\n\t\t\t\tb: { domain: \"number\" }\n\t\t\t})\n\t\t})\n\t}\n)\n\ncontextualize.each(\n\t\"rooted submodules\",\n\t() => {\n\t\tconst foo = type.module({ root: \"'foo'\", bar: \"'bar'\" })\n\n\t\tconst $ = scope({\n\t\t\tfoo,\n\t\t\tfooBare: \"foo\",\n\t\t\tfooBar: \"foo.bar\"\n\t\t})\n\n\t\treturn $\n\t},\n\tit => {\n\t\tit(\"base\", $ => {\n\t\t\tattest<\n\t\t\t\tScope<{\n\t\t\t\t\tfoo: Submodule<{\n\t\t\t\t\t\troot: \"foo\"\n\t\t\t\t\t\tbar: \"bar\"\n\t\t\t\t\t}>\n\t\t\t\t\tfooBare: \"foo\"\n\t\t\t\t\tfooBar: \"bar\"\n\t\t\t\t}>\n\t\t\t>($)\n\n\t\t\tconst types = $.export()\n\n\t\t\tattest(types.foo.bar.expression).snap('\"bar\"')\n\t\t\tattest(types.foo.root.expression).snap('\"foo\"')\n\n\t\t\tattest(types.fooBar.expression).snap('\"bar\"')\n\t\t\tattest(types.fooBare.expression).snap('\"foo\"')\n\t\t})\n\n\t\tit(\"completions\", $ => {\n\t\t\t// `foo.root` should not be included since it is redundant with `foo`\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => $.type(\"foo.\")).completions({ \"foo.\": [\"foo.bar\"] })\n\t\t})\n\n\t\tit(\"docs example\", () => {\n\t\t\tconst userModule = type.module({\n\t\t\t\troot: {\n\t\t\t\t\tname: \"string\"\n\t\t\t\t},\n\t\t\t\t// subaliases can extend a base type by referencing 'root'\n\t\t\t\t// like any other alias\n\t\t\t\tadmin: {\n\t\t\t\t\t\"...\": \"root\",\n\t\t\t\t\tisAdmin: \"true\"\n\t\t\t\t},\n\t\t\t\tsaiyan: {\n\t\t\t\t\t\"...\": \"root\",\n\t\t\t\t\tpowerLevel: \"number > 9000\"\n\t\t\t\t}\n\t\t\t})\n\n\t\t\tconst rootScope = type.scope({\n\t\t\t\tuser: userModule,\n\t\t\t\t// user can now be referenced directly in a definition\n\t\t\t\tgroup: \"user[]\",\n\t\t\t\t// or used as a prefix to access subaliases\n\t\t\t\televatedUser: \"user.admin | user.saiyan\"\n\t\t\t})\n\n\t\t\tattest(rootScope).type.toString.snap(`Scope<{\n\tgroup: { name: string }[]\n\tuser: Submodule<{\n\t\troot: { name: string }\n\t\tadmin: { name: string; isAdmin: true }\n\t\tsaiyan: { name: string; powerLevel: number }\n\t}>\n\televatedUser:\n\t\t| { name: string; isAdmin: true }\n\t\t| { name: string; powerLevel: number }\n}>`)\n\t\t\tattest(rootScope.json).snap({\n\t\t\t\t\"user.root\": {\n\t\t\t\t\trequired: [{ key: \"name\", value: \"string\" }],\n\t\t\t\t\tdomain: \"object\"\n\t\t\t\t},\n\t\t\t\t\"user.admin\": {\n\t\t\t\t\trequired: [\n\t\t\t\t\t\t{ key: \"isAdmin\", value: { unit: true } },\n\t\t\t\t\t\t{ key: \"name\", value: \"string\" }\n\t\t\t\t\t],\n\t\t\t\t\tdomain: \"object\"\n\t\t\t\t},\n\t\t\t\t\"user.saiyan\": {\n\t\t\t\t\trequired: [\n\t\t\t\t\t\t{ key: \"name\", value: \"string\" },\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkey: \"powerLevel\",\n\t\t\t\t\t\t\tvalue: { domain: \"number\", min: { exclusive: true, rule: 9000 } }\n\t\t\t\t\t\t}\n\t\t\t\t\t],\n\t\t\t\t\tdomain: \"object\"\n\t\t\t\t},\n\t\t\t\tgroup: {\n\t\t\t\t\tsequence: {\n\t\t\t\t\t\trequired: [{ key: \"name\", value: \"string\" }],\n\t\t\t\t\t\tdomain: \"object\"\n\t\t\t\t\t},\n\t\t\t\t\tproto: \"Array\"\n\t\t\t\t},\n\t\t\t\televatedUser: [\n\t\t\t\t\t{\n\t\t\t\t\t\trequired: [\n\t\t\t\t\t\t\t{ key: \"isAdmin\", value: { unit: true } },\n\t\t\t\t\t\t\t{ key: \"name\", value: \"string\" }\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdomain: \"object\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\trequired: [\n\t\t\t\t\t\t\t{ key: \"name\", value: \"string\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkey: \"powerLevel\",\n\t\t\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\t\t\tdomain: \"number\",\n\t\t\t\t\t\t\t\t\tmin: { exclusive: true, rule: 9000 }\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdomain: \"object\"\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t})\n\t\t})\n\t}\n)\n\ncontextualize.each(\n\t\"nested submodule\",\n\t() =>\n\t\tscope({\n\t\t\touter: scope({\n\t\t\t\tinner: scope({\n\t\t\t\t\talias: \"1\"\n\t\t\t\t}).export()\n\t\t\t}).export()\n\t\t}),\n\tit => {\n\t\ttype Expected$ = {\n\t\t\touter: Submodule<{\n\t\t\t\tinner: Submodule<{\n\t\t\t\t\talias: 1\n\t\t\t\t}>\n\t\t\t}>\n\t\t}\n\n\t\tit(\"export\", $ => {\n\t\t\tconst types = $.export()\n\n\t\t\tattest<Module<Expected$>>(types)\n\n\t\t\tattest<\n\t\t\t\tBoundModule<\n\t\t\t\t\t{\n\t\t\t\t\t\tinner: Submodule<{\n\t\t\t\t\t\t\talias: 1\n\t\t\t\t\t\t}>\n\t\t\t\t\t},\n\t\t\t\t\tExpected$\n\t\t\t\t>\n\t\t\t>(types.outer)\n\t\t\tattest<\n\t\t\t\tBoundModule<\n\t\t\t\t\t{\n\t\t\t\t\t\talias: 1\n\t\t\t\t\t},\n\t\t\t\t\tExpected$\n\t\t\t\t>\n\t\t\t>(types.outer.inner)\n\t\t\tattest<Type<1, Expected$>>(types.outer.inner.alias)\n\n\t\t\tattest(types.outer.inner.alias.expression).equals(\"1\")\n\t\t\tattest(types.outer.inner.alias.$.json).snap({\n\t\t\t\t\"outer.inner.alias\": { unit: 1 }\n\t\t\t})\n\t\t})\n\n\t\tit(\"reference\", $ => {\n\t\t\tconst T = $.type([\"outer.inner.alias\"])\n\t\t\tattest<Type<[1], Expected$>>(T)\n\t\t\tattest(T.expression).snap(\"[1]\")\n\t\t})\n\n\t\tit(\"non-submodule dot access\", () => {\n\t\t\tattest(() =>\n\t\t\t\ttype({\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\ta: \"true.subtype\"\n\t\t\t\t})\n\t\t\t).throwsAndHasTypeError(writeNonSubmoduleDotMessage(\"true\"))\n\t\t})\n\n\t\tit(\"completions\", $ => {\n\t\t\tattest(() =>\n\t\t\t\t$.type({\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\ta: \"ou\",\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tb: \"outer.\",\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tc: \"outer.inner.\"\n\t\t\t\t})\n\t\t\t).completions({\n\t\t\t\tou: [\"outer\"],\n\t\t\t\t\"outer.\": [\"outer.inner\"],\n\t\t\t\t\"outer.inner.\": [\"outer.inner.alias\"]\n\t\t\t})\n\t\t})\n\n\t\ttype DeepExpected$ = {\n\t\t\ta: Submodule<{\n\t\t\t\tb: Submodule<{\n\t\t\t\t\tc: Submodule<{\n\t\t\t\t\t\td: Submodule<{\n\t\t\t\t\t\t\te: Submodule<{\n\t\t\t\t\t\t\t\tf: Submodule<{\n\t\t\t\t\t\t\t\t\tg: Submodule<{\n\t\t\t\t\t\t\t\t\t\talias: 1\n\t\t\t\t\t\t\t\t\t}>\n\t\t\t\t\t\t\t\t}>\n\t\t\t\t\t\t\t}>\n\t\t\t\t\t\t}>\n\t\t\t\t\t}>\n\t\t\t\t}>\n\t\t\t}>\n\t\t}\n\n\t\tit(\"deep\", () => {\n\t\t\tconst $ = scope({\n\t\t\t\ta: scope({\n\t\t\t\t\tb: scope({\n\t\t\t\t\t\tc: scope({\n\t\t\t\t\t\t\td: scope({\n\t\t\t\t\t\t\t\te: scope({\n\t\t\t\t\t\t\t\t\tf: scope({\n\t\t\t\t\t\t\t\t\t\tg: scope({\n\t\t\t\t\t\t\t\t\t\t\talias: \"1\"\n\t\t\t\t\t\t\t\t\t\t}).export()\n\t\t\t\t\t\t\t\t\t}).export()\n\t\t\t\t\t\t\t\t}).export()\n\t\t\t\t\t\t\t}).export()\n\t\t\t\t\t\t}).export()\n\t\t\t\t\t}).export()\n\t\t\t\t}).export()\n\t\t\t})\n\n\t\t\tconst T = $.type(\"0 | a.b.c.d.e.f.g.alias\")\n\t\t\tattest<Type<0 | 1, DeepExpected$>>(T)\n\t\t\tattest(T.expression).snap(\"0 | 1\")\n\t\t\tattest(() =>\n\t\t\t\t$.type({\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tfoo: \"a.b.c.d.e.f.g.\"\n\t\t\t\t})\n\t\t\t).completions({ \"a.b.c.d.e.f.g.\": [\"a.b.c.d.e.f.g.alias\"] })\n\t\t})\n\t}\n)\n"
  },
  {
    "path": "ark/type/__tests__/this.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { writeUnresolvableMessage } from \"@ark/schema\"\nimport { scope, type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"resolves from type\", () => {\n\t\tconst DisappointingGift = type({\n\t\t\tlabel: \"string\",\n\t\t\t\"box?\": \"this\"\n\t\t})\n\n\t\ttype ExpectedDisappointingGift = {\n\t\t\tlabel: string\n\t\t\tbox?: ExpectedDisappointingGift\n\t\t}\n\t\tattest<ExpectedDisappointingGift>(DisappointingGift.infer)\n\n\t\tattest(DisappointingGift({ label: \"foo\" })).snap({ label: \"foo\" })\n\t\tattest(DisappointingGift({ label: \"foo\", box: { label: \"bar\" } })).snap({\n\t\t\tlabel: \"foo\",\n\t\t\tbox: { label: \"bar\" }\n\t\t})\n\t\tattest(\n\t\t\tDisappointingGift({\n\t\t\t\tlabel: \"foo\",\n\t\t\t\tbox: { label: \"bar\", box: {} }\n\t\t\t}).toString()\n\t\t).snap(\"box.box.label must be a string (was missing)\")\n\t})\n\n\tit(\"at nested path\", () => {\n\t\tconst T = type({ foo: { bar: \"this\" } })\n\n\t\tattest(T).type.toString.snap(\"Type<{ foo: { bar: cyclic } }, {}>\")\n\n\t\tconst validData = { foo: { bar: {} } } as typeof T.infer\n\t\tvalidData.foo.bar = validData\n\n\t\tattest(T(validData)).equals(validData)\n\n\t\tconst invalidData = { foo: { bar: {} as any } }\n\t\tinvalidData.foo.bar = invalidData.foo\n\t\tattest(T(invalidData).toString()).snap(\n\t\t\t\"foo.bar.foo must be an object (was missing)\"\n\t\t)\n\t})\n\n\tit(\"this preserved when referencing at path\", () => {\n\t\tconst Initial = type({\n\t\t\tinitial: \"this\"\n\t\t})\n\n\t\tconst Reference = type({\n\t\t\treference: Initial\n\t\t})\n\t\ttype Initial = {\n\t\t\tinitial: Initial\n\t\t}\n\t\ttype Expected = {\n\t\t\treference: Initial\n\t\t}\n\n\t\tattest<Expected>(Reference.infer)\n\n\t\tconst initialData = {} as typeof Initial.infer\n\t\tinitialData.initial = initialData\n\n\t\tconst referenceData = { reference: initialData }\n\n\t\tattest(Initial(initialData)).equals(initialData)\n\t\tattest(Reference(referenceData)).equals(referenceData)\n\t\tattest(Reference({ reference: {} }).toString()).snap(\n\t\t\t\"reference.initial must be an object (was missing)\"\n\t\t)\n\t})\n\n\tit(\"unresolvable in scope\", () => {\n\t\tattest(() =>\n\t\t\tscope({\n\t\t\t\tdisappointingGift: {\n\t\t\t\t\tlabel: \"string\",\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\"box?\": \"this\"\n\t\t\t\t}\n\t\t\t}).export()\n\t\t).throwsAndHasTypeError(writeUnresolvableMessage(\"this\"))\n\t})\n\n\tit(\"tuple expression\", () => {\n\t\tconst T = type([{ a: \"string\" }, \"|\", { b: \"this\" }])\n\t\tattest(T.infer).type.toString.snap(\n\t\t\t\"{ a: string } | { b: { a: string } | cyclic }\"\n\t\t)\n\t\tattest(T({ a: \"foo\" })).snap({ a: \"foo\" })\n\t\tattest(T({ b: { a: \"bar\" } })).snap({ b: { a: \"bar\" } })\n\t\tattest(T({ b: { b: {} } }).toString()).snap(\n\t\t\t\"a must be a string (was missing), b.a must be a string (was missing) or b.b must be b.b.a must be a string (was missing) or b.b.b must be an object (was missing) (was {})\"\n\t\t)\n\t})\n\n\tit(\"root expression\", () => {\n\t\tconst T = type({ a: \"string\" }, \"|\", { b: \"this\" })\n\t\tattest(T.infer).type.toString.snap(\n\t\t\t\"{ a: string } | { b: { a: string } | cyclic }\"\n\t\t)\n\t\tattest(T({ a: \"foo\" })).snap({ a: \"foo\" })\n\t\tattest(T({ b: { a: \"bar\" } })).snap({ b: { a: \"bar\" } })\n\t\tattest(T({ b: { b: {} } }).toString()).snap(\n\t\t\t\"a must be a string (was missing), b.a must be a string (was missing) or b.b must be b.b.a must be a string (was missing) or b.b.b must be an object (was missing) (was {})\"\n\t\t)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/thunk.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { writeUnresolvableMessage } from \"@ark/schema\"\nimport type { Brand } from \"@ark/util\"\nimport { scope, type, type Scope } from \"arktype\"\nimport type { Out } from \"arktype/internal/attributes.ts\"\nimport { writeBadDefinitionTypeMessage } from \"arktype/internal/parser/definition.ts\"\n\ncontextualize(() => {\n\tit(\"in type\", () => {\n\t\tconst T = type(() => type(\"boolean\"))\n\t\tattest<boolean>(T.infer)\n\t\tattest(() => {\n\t\t\t// @ts-expect-error\n\t\t\ttype(() => type(\"moolean\"))\n\t\t}).throwsAndHasTypeError(writeUnresolvableMessage(\"moolean\"))\n\t})\n\n\tit(\"in scope\", () => {\n\t\tconst $ = scope({\n\t\t\ta: () => $.type({ b: \"b\" }),\n\t\t\tb: () => $.type({ a: \"string\" })\n\t\t})\n\t\tattest<{\n\t\t\ta: {\n\t\t\t\tb: {\n\t\t\t\t\ta: string\n\t\t\t\t}\n\t\t\t}\n\t\t\tb: {\n\t\t\t\ta: string\n\t\t\t}\n\t\t}>($[\"t\"])\n\n\t\tconst types = $.export()\n\t\tattest<{\n\t\t\tb: {\n\t\t\t\ta: string\n\t\t\t}\n\t\t}>(types.a.infer)\n\n\t\tattest(types.a.json).snap({\n\t\t\trequired: [\n\t\t\t\t{\n\t\t\t\t\tkey: \"b\",\n\t\t\t\t\tvalue: { required: [{ key: \"a\", value: \"string\" }], domain: \"object\" }\n\t\t\t\t}\n\t\t\t],\n\t\t\tdomain: \"object\"\n\t\t})\n\t\tattest<{ a: string }>(types.b.infer)\n\n\t\tattest(types.b.json).snap({\n\t\t\trequired: [{ key: \"a\", value: \"string\" }],\n\t\t\tdomain: \"object\"\n\t\t})\n\t})\n\n\tit(\"expression from thunk\", () => {\n\t\tconst $ = scope({\n\t\t\ta: () => $.type({ a: \"string\" }),\n\t\t\tb: { b: \"boolean\" },\n\t\t\taAndB: () => $.type(\"a&b\")\n\t\t})\n\t\tconst types = $.export()\n\t\tattest<{ a: string; b: boolean }>(types.aAndB.infer)\n\t\tattest(types.aAndB.json).snap({\n\t\t\trequired: [\n\t\t\t\t{ key: \"a\", value: \"string\" },\n\t\t\t\t{ key: \"b\", value: [{ unit: false }, { unit: true }] }\n\t\t\t],\n\t\t\tdomain: \"object\"\n\t\t})\n\t})\n\n\tit(\"shallow in type\", () => {\n\t\tconst T = type(() => type(\"string\"))\n\t\tattest(T.json).equals(type(\"string\").json)\n\t\tattest<string>(T.infer)\n\t})\n\n\tit(\"deep in type\", () => {\n\t\tconst T = type({ a: () => type(\"string\") })\n\t\tattest(T.json).equals(type({ a: \"string\" }).json)\n\t\tattest<{ a: string }>(T.infer)\n\t})\n\n\tit(\"non-type thunk in scope\", () => {\n\t\tconst $ = scope({\n\t\t\ta: () => 42\n\t\t})\n\t\tattest(() => $.export()).throws(writeBadDefinitionTypeMessage(\"number\"))\n\t})\n\n\tit(\"parse error in thunk in scope\", () => {\n\t\tconst $ = scope({\n\t\t\t// @ts-expect-error\n\t\t\ta: () => $.type(\"bad\")\n\t\t})\n\t\tattest(() => $.export()).throws(writeUnresolvableMessage(\"bad\"))\n\t})\n\n\tit(\"docs example\", () => {\n\t\tconst $ = type.scope({\n\t\t\tid: \"string#id\",\n\t\t\texpandUserGroup: () =>\n\t\t\t\t$.type({\n\t\t\t\t\tname: \"string\",\n\t\t\t\t\tid: \"id\"\n\t\t\t\t})\n\t\t\t\t\t.or(\"id\")\n\t\t\t\t\t.pipe(function _docsExampleThunkMorph(user) {\n\t\t\t\t\t\treturn typeof user === \"string\" ?\n\t\t\t\t\t\t\t\t{ id: user, name: \"Anonymous\" }\n\t\t\t\t\t\t\t:\tuser\n\t\t\t\t\t})\n\t\t\t\t\t.array()\n\t\t\t\t\t.atLeastLength(2)\n\t\t})\n\n\t\tattest<\n\t\t\tScope<{\n\t\t\t\tid: Brand<string, \"id\">\n\t\t\t\texpandUserGroup: ((\n\t\t\t\t\tIn:\n\t\t\t\t\t\t| string\n\t\t\t\t\t\t| {\n\t\t\t\t\t\t\t\tname: string\n\t\t\t\t\t\t\t\tid: string\n\t\t\t\t\t\t  }\n\t\t\t\t) => Out<{\n\t\t\t\t\tname: string\n\t\t\t\t\tid: Brand<string, \"id\">\n\t\t\t\t}>)[]\n\t\t\t}>\n\t\t>($)\n\n\t\tconst types = $.export()\n\n\t\tattest($.json).snap({\n\t\t\tid: { domain: \"string\" },\n\t\t\texpandUserGroup: {\n\t\t\t\tsequence: {\n\t\t\t\t\tin: [\n\t\t\t\t\t\t\"string\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\trequired: [\n\t\t\t\t\t\t\t\t{ key: \"id\", value: \"string\" },\n\t\t\t\t\t\t\t\t{ key: \"name\", value: \"string\" }\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tdomain: \"object\"\n\t\t\t\t\t\t}\n\t\t\t\t\t],\n\t\t\t\t\tmorphs: [\"$ark._docsExampleThunkMorph\"]\n\t\t\t\t},\n\t\t\t\tproto: \"Array\",\n\t\t\t\tminLength: 2\n\t\t\t}\n\t\t})\n\n\t\tconst groups = types.expandUserGroup([\n\t\t\t{ name: \"Magical Crawdad\", id: \"777\" },\n\t\t\t\"778\"\n\t\t])\n\n\t\ttype BrandedId = typeof types.id.t\n\n\t\tattest(groups).snap([\n\t\t\t{ name: \"Magical Crawdad\", id: \"777\" as BrandedId },\n\t\t\t{ id: \"778\" as BrandedId, name: \"Anonymous\" }\n\t\t])\n\t})\n\n\tit(\"docs inelegant\", () => {\n\t\t// you *can* use them anywhere, but *should* you? (no)\n\t\tconst Inelegant = type(() =>\n\t\t\ttype({ inelegantKey: () => type(\"'inelegant value'\") })\n\t\t)\n\n\t\tattest(Inelegant.t).type.toString.snap(\n\t\t\t'{ inelegantKey: \"inelegant value\" }'\n\t\t)\n\t\tattest(Inelegant.expression).snap('{ inelegantKey: \"inelegant value\" }')\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/toJsonSchema.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { type } from \"arktype\"\n\ncontextualize(() => {\n\tdescribe(\"target option\", () => {\n\t\tit(\"generates draft-2020-12 schema by default\", () => {\n\t\t\tconst T = type({ foo: \"string\" })\n\t\t\tconst schema = T.toJsonSchema()\n\t\t\tattest(schema).snap({\n\t\t\t\t$schema: \"https://json-schema.org/draft/2020-12/schema\",\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: { foo: { type: \"string\" } },\n\t\t\t\trequired: [\"foo\"]\n\t\t\t})\n\t\t})\n\n\t\tit(\"generates draft-2020-12 schema when specified\", () => {\n\t\t\tconst T = type({ foo: \"string\" })\n\t\t\tconst schema = T.toJsonSchema({ target: \"draft-2020-12\" })\n\t\t\tattest(schema).snap({\n\t\t\t\t$schema: \"https://json-schema.org/draft/2020-12/schema\",\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: { foo: { type: \"string\" } },\n\t\t\t\trequired: [\"foo\"]\n\t\t\t})\n\t\t})\n\n\t\tit(\"generates draft-07 schema when specified\", () => {\n\t\t\tconst T = type({ foo: \"string\" })\n\t\t\tconst schema = T.toJsonSchema({ target: \"draft-07\" })\n\t\t\tattest(schema).snap({\n\t\t\t\t$schema: \"http://json-schema.org/draft-07/schema#\",\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: { foo: { type: \"string\" } },\n\t\t\t\trequired: [\"foo\"]\n\t\t\t})\n\t\t})\n\t})\n\n\tdescribe(\"draft-specific syntax\", () => {\n\t\tit(\"draft-2020-12 uses prefixItems for tuples\", () => {\n\t\t\tconst T = type([\"string\", \"number\"])\n\t\t\tconst schema = T.toJsonSchema({ target: \"draft-2020-12\" })\n\t\t\tattest(schema).snap({\n\t\t\t\t$schema: \"https://json-schema.org/draft/2020-12/schema\",\n\t\t\t\ttype: \"array\",\n\t\t\t\tprefixItems: [{ type: \"string\" }, { type: \"number\" }],\n\t\t\t\titems: false,\n\t\t\t\tminItems: 2\n\t\t\t})\n\t\t})\n\n\t\tit(\"draft-07 uses items array for tuples\", () => {\n\t\t\tconst T = type([\"string\", \"number\"])\n\t\t\tconst schema = T.toJsonSchema({ target: \"draft-07\" })\n\t\t\tattest(schema).snap({\n\t\t\t\t$schema: \"http://json-schema.org/draft-07/schema#\",\n\t\t\t\ttype: \"array\",\n\t\t\t\titems: [{ type: \"string\" }, { type: \"number\" }],\n\t\t\t\tadditionalItems: false,\n\t\t\t\tminItems: 2\n\t\t\t})\n\t\t})\n\n\t\tit(\"draft-2020-12 uses items for variadic tuple elements\", () => {\n\t\t\tconst T = type([\"string\", \"...\", \"number[]\"])\n\t\t\tconst schema = T.toJsonSchema({ target: \"draft-2020-12\" })\n\t\t\tattest(schema).snap({\n\t\t\t\t$schema: \"https://json-schema.org/draft/2020-12/schema\",\n\t\t\t\ttype: \"array\",\n\t\t\t\tprefixItems: [{ type: \"string\" }],\n\t\t\t\titems: { type: \"number\" },\n\t\t\t\tminItems: 1\n\t\t\t})\n\t\t})\n\n\t\tit(\"draft-07 uses additionalItems for variadic tuple elements\", () => {\n\t\t\tconst T = type([\"string\", \"...\", \"number[]\"])\n\t\t\tconst schema = T.toJsonSchema({ target: \"draft-07\" })\n\t\t\tattest(schema).snap({\n\t\t\t\t$schema: \"http://json-schema.org/draft-07/schema#\",\n\t\t\t\ttype: \"array\",\n\t\t\t\titems: [{ type: \"string\" }],\n\t\t\t\tadditionalItems: { type: \"number\" },\n\t\t\t\tminItems: 1\n\t\t\t})\n\t\t})\n\n\t\tit(\"draft-2020-12 uses $defs for references\", () => {\n\t\t\tconst types = type.module({\n\t\t\t\tuser: {\n\t\t\t\t\tname: \"string\",\n\t\t\t\t\tfriend: \"user?\"\n\t\t\t\t}\n\t\t\t})\n\t\t\tconst schema = types.user.toJsonSchema({\n\t\t\t\ttarget: \"draft-2020-12\"\n\t\t\t}) as Record<string, unknown>\n\t\t\tattest(\"$defs\" in schema).equals(true)\n\t\t\tattest(\"definitions\" in schema).equals(false)\n\t\t\tattest(Object.keys(schema.$defs as object).length > 0).equals(true)\n\t\t})\n\n\t\tit(\"draft-07 uses definitions for references\", () => {\n\t\t\tconst types = type.module({\n\t\t\t\tuser: {\n\t\t\t\t\tname: \"string\",\n\t\t\t\t\tfriend: \"user?\"\n\t\t\t\t}\n\t\t\t})\n\t\t\tconst schema = types.user.toJsonSchema({\n\t\t\t\ttarget: \"draft-07\"\n\t\t\t}) as Record<string, unknown>\n\t\t\tattest(\"definitions\" in schema).equals(true)\n\t\t\tattest(\"$defs\" in schema).equals(false)\n\t\t\tattest(Object.keys(schema.definitions as object).length > 0).equals(true)\n\t\t})\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/traverse.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { ArkErrors, TraversalError } from \"@ark/schema\"\nimport { scope, type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"divisible\", () => {\n\t\tconst T = type(\"number%2\")\n\t\tattest(T(4)).snap(4)\n\t\tattest(T(5).toString()).snap(\"must be even (was 5)\")\n\t})\n\n\tit(\"range\", () => {\n\t\tconst T = type(\"number>2\")\n\t\tattest(T(3)).snap(3)\n\t\tattest(T(2).toString()).snap(\"must be more than 2 (was 2)\")\n\t})\n\n\tit(\"domain\", () => {\n\t\tconst T = type(\"number\")\n\t\tattest(T(5)).snap(5)\n\t\tattest(T(\"foo\").toString()).snap(\"must be a number (was a string)\")\n\t})\n\n\tit(\"pattern\", () => {\n\t\tconst T = type(\"/.*@arktype.io/\")\n\t\tattest(T(\"shawn@arktype.io\")).snap(\"shawn@arktype.io\")\n\t\tattest(T(\"shawn@hotmail.com\").toString()).snap(\n\t\t\t'must be matched by .*@arktype.io (was \"shawn@hotmail.com\")'\n\t\t)\n\t})\n\n\tit(\"required keys\", () => {\n\t\tconst T = type({\n\t\t\tname: \"string\",\n\t\t\tage: \"number\",\n\t\t\t\"title?\": \"string\"\n\t\t})\n\t\tattest(T({ name: \"Shawn\", age: 99 })).snap({\n\t\t\tname: \"Shawn\",\n\t\t\tage: 99\n\t\t})\n\t\tattest(T({ name: \"Shawn\" }).toString()).snap(\n\t\t\t\"age must be a number (was missing)\"\n\t\t)\n\t})\n\n\tit(\"customized built-in problem\", () => {\n\t\tconst types = scope(\n\t\t\t{ isEven: \"number%2\" },\n\t\t\t{\n\t\t\t\tdivisor: {\n\t\t\t\t\texpected: ctx => `% ${ctx.rule} !== 0`,\n\t\t\t\t\tproblem: ctx => `${ctx.actual} ${ctx.expected}`\n\t\t\t\t}\n\t\t\t}\n\t\t).export()\n\t\tattest(types.isEven(3).toString()).snap(\"3 % 2 !== 0\")\n\t})\n\n\tit(\"domains\", () => {\n\t\tconst T = type(\"string|number[]\")\n\t\tattest(T([1])).snap([1])\n\t\tattest(T(\"hello\")).snap(\"hello\")\n\t\tattest(T(2).toString()).snap(\"must be a string or an object (was a number)\")\n\t\tattest(T({}).toString()).snap(\"must be an array (was object)\")\n\t})\n\n\tit(\"tuple length\", () => {\n\t\tconst T = type([\"string\", \"number\", \"string\", \"string[]\"])\n\t\tconst data: typeof T.infer = [\"foo\", 5, \"boo\", []]\n\t\tattest(T(data)).equals(data)\n\t\tattest(T([\"hello\"]).toString()).snap(\"must be exactly length 4 (was 1)\")\n\t})\n\n\tit(\"branches\", () => {\n\t\tconst T = type({ bar: \"boolean\" }, \"|\", { foo: \"string\" })\n\t\tattest(T({ foo: \"ok\" })).snap({ foo: \"ok\" })\n\t\tattest(T({ bar: true })).snap({ bar: true })\n\t\tattest(T({}).toString()).snap(\n\t\t\t\"bar must be boolean (was missing) or foo must be a string (was missing)\"\n\t\t)\n\t\tattest(T({ bar: \"swapped\", foo: true }).toString()).snap(\n\t\t\t'bar must be boolean (was \"swapped\") or foo must be a string (was boolean)'\n\t\t)\n\t})\n\n\tit(\"common errors collapse\", () => {\n\t\tconst T = type({ base: \"1\", a: \"1\" }, \"|\", { base: \"1\", b: \"1\" })\n\t\tattest(T({ base: 1, a: 1 })).snap({ base: 1, a: 1 })\n\t\tattest(T({ base: 1, b: 1 })).snap({ base: 1, b: 1 })\n\t\tattest(T({ a: 1, b: 1 }).toString()).snap(\"base must be 1 (was missing)\")\n\t})\n\n\tit(\"branches at path\", () => {\n\t\tconst T = type({ key: [{ a: \"string\" }, \"|\", { b: \"boolean\" }] })\n\t\tattest(T({ key: { a: \"ok\" } })).snap({ key: { a: \"ok\" } })\n\t\tattest(T({ key: { b: true } })).snap({ key: { b: true } })\n\t\tattest(T({ key: {} }).toString()).snap(\n\t\t\t\"key.a must be a string (was missing) or key.b must be boolean (was missing)\"\n\t\t)\n\t})\n\n\tit(\"switch\", () => {\n\t\tconst T = type({ a: \"string\" }).or({ a: \"null\" }).or({ a: \"number\" })\n\t\tattest(T({ a: \"ok\" })).snap({ a: \"ok\" })\n\t\tattest(T({ a: 5 })).snap({ a: 5 })\n\t\t// value isn't present\n\t\tattest(T({}).toString()).snap(\n\t\t\t\"a must be a number, a string or null (was undefined)\"\n\t\t)\n\t\t// unsatisfying value\n\t\tattest(T({ a: false }).toString()).snap(\n\t\t\t\"a must be a number, a string or null (was boolean)\"\n\t\t)\n\t})\n\n\t// previously was affected by a caching issue\n\t// https://github.com/arktypeio/arktype/issues/962\n\tit(\"multiple switch\", () => {\n\t\tconst types = scope({\n\t\t\ta: { foo: \"string\" },\n\t\t\tb: { foo: \"number\" },\n\t\t\tc: { foo: \"Function\" },\n\t\t\td: \"a|b|c\"\n\t\t}).export()\n\t\tattest(types.d({}).toString()).snap(\n\t\t\t\"foo must be an object, a number or a string (was undefined)\"\n\t\t)\n\t\tattest(types.d({ foo: null }).toString()).snap(\n\t\t\t\"foo must be an object, a number or a string (was null)\"\n\t\t)\n\t})\n\n\tit(\"serialized actual for discriminated union\", () => {\n\t\tconst T = type({ a: \"'foo'\" }).or({ a: \"'bar'\" })\n\t\tattest(T({ a: '\"extra quotes\"' }).toString()).snap(\n\t\t\t'a must be \"bar\" or \"foo\" (was \"\\\\\"extra quotes\\\\\"\")'\n\t\t)\n\t\tattest(T({ a: \"\" }).toString()).snap('a must be \"bar\" or \"foo\" (was \"\")')\n\t\tattest(T({ a: 5 }).toString()).snap('a must be \"bar\" or \"foo\" (was 5)')\n\t})\n\n\tit(\"multi\", () => {\n\t\tconst NaturalNumber = type(\"number.integer>0\")\n\t\tattest(NaturalNumber(-1.2).toString()).snap(`(-1.2) must be...\n  ◦ an integer\n  ◦ positive`)\n\t\tconst NaturalAtPath = type({\n\t\t\tnatural: NaturalNumber\n\t\t})\n\t\tattest(NaturalAtPath({ natural: -0.1 }).toString())\n\t\t\t.snap(`natural (-0.1) must be...\n  ◦ an integer\n  ◦ positive`)\n\t})\n\n\tit(\"multi indented\", () => {\n\t\tconst NaturalSchema = type({\n\t\t\tnatural: \"number.integer>0\",\n\t\t\tname: \"string\"\n\t\t})\n\t\tconst result = NaturalSchema({\n\t\t\tnatural: -Math.PI,\n\t\t\tname: [\"negative\", \"PI\"]\n\t\t})\n\t\tattest(result).instanceOf(ArkErrors)\n\t\tconst traversalError = (result as ArkErrors).toTraversalError()\n\t\tattest(traversalError).instanceOf(TraversalError)\n\t\tattest(traversalError.message).snap(`\n  • name must be a string (was an object)\n  • natural (-3.141592653589793) must be...\n    ◦ an integer\n    ◦ positive`)\n\t})\n\n\tit(\"homepage example\", () => {\n\t\tconst User = type({\n\t\t\tname: \"string\",\n\t\t\tluckyNumbers: \"(number | bigint)[]\",\n\t\t\t\"isAdmin?\": \"boolean | null\"\n\t\t})\n\n\t\tconst out = User({\n\t\t\tluckyNumbers: [31, \"255\", 1337n],\n\t\t\tisAdmin: 1\n\t\t})\n\n\t\tattest(out.toString())\n\t\t\t.snap(`luckyNumbers[1] must be a bigint or a number (was a string)\nname must be a string (was missing)\nisAdmin must be false, null or true (was 1)`)\n\t})\n\n\tit(\"relative path\", () => {\n\t\tconst Signup = type({\n\t\t\temail: \"string.email\",\n\t\t\tpassword: \"string\",\n\t\t\trepeatPassword: \"string\"\n\t\t}).narrow(\n\t\t\t(d, ctx) =>\n\t\t\t\td.password === d.repeatPassword ||\n\t\t\t\tctx.reject({\n\t\t\t\t\texpected: \"identical to password\",\n\t\t\t\t\tactual: \"\",\n\t\t\t\t\trelativePath: [\"repeatPassword\"]\n\t\t\t\t})\n\t\t)\n\n\t\t// ensure the relativePath is relative\n\t\tconst NestedSignup = type({\n\t\t\tuser: Signup\n\t\t})\n\n\t\tconst validSignup: typeof Signup.infer = {\n\t\t\temail: \"david@arktype.io\",\n\t\t\tpassword: \"secure\",\n\t\t\trepeatPassword: \"secure\"\n\t\t}\n\n\t\tconst valid: typeof NestedSignup.infer = { user: validSignup }\n\n\t\tattest(NestedSignup(valid)).equals(valid)\n\t\tattest(\n\t\t\tNestedSignup({\n\t\t\t\tuser: { ...validSignup, repeatPassword: \"insecure\" }\n\t\t\t}).toString()\n\t\t).snap(\"user.repeatPassword must be identical to password\")\n\t})\n\n\t// https://github.com/arktypeio/arktype/issues/1149\n\tit(\"morphs apply when not at an error path, even on failed validation\", () => {\n\t\tconst AgeType = type(\"string.numeric.parse\").to(\"number>18\")\n\t\tconst ObjType = type({ name: \"string\", \"age?\": AgeType })\n\n\t\tconst out = ObjType({ name: 2, age: \"2\" })\n\t\tattest(out.toString()).snap(`name must be a string (was a number)\nage must be more than 18 (was 2)`)\n\t})\n\n\tit(\"morphs don't apply when at an error path\", () => {\n\t\tlet callCount = 0\n\t\tconst T = type(\"unknown\")\n\t\t\t.narrow((data, ctx) => ctx.mustBe(\"valid\"))\n\t\t\t.pipe(() => callCount++)\n\n\t\tconst out = T(1)\n\n\t\tattest(out.toString()).snap(\"must be valid (was 1)\")\n\t\tattest(callCount).equals(0)\n\t})\n\n\tit(\"morphs don't apply when under an error path\", () => {\n\t\tlet callCount = 0\n\t\tconst T = type({\n\t\t\tfoo: [\"unknown\", \"=>\", () => callCount++]\n\t\t}).filter((data, ctx) => ctx.mustBe(\"valid\"))\n\n\t\tattest(T.t).type.toString.snap(\"{ foo: (In: unknown) => Out<number> }\")\n\t\tconst out = T({ foo: 1 })\n\n\t\tattest(out.toString()).snap('must be valid (was {\"foo\":1})')\n\t\tattest(callCount).equals(0)\n\t})\n\n\tit(\"ctx.path docs example\", () => {\n\t\tconst symbolicKey = Symbol(\"ctxPathExampleSymbol\")\n\n\t\tlet path: PropertyKey[] | undefined\n\n\t\tconst notFoo = type.string.narrow((s, ctx) => {\n\t\t\tif (s !== \"foo\") return true\n\t\t\tpath = ctx.path.slice(0)\n\t\t\treturn ctx.mustBe(\"not foo\")\n\t\t})\n\n\t\tconst Obj = type({\n\t\t\tstringKey: {\n\t\t\t\t[symbolicKey]: notFoo.array()\n\t\t\t}\n\t\t})\n\n\t\tattest(\n\t\t\tObj({ stringKey: { [symbolicKey]: [\"bar\", \"foo\"] } }).toString()\n\t\t).snap(\n\t\t\t'stringKey[Symbol(ctxPathExampleSymbol)][1] must be not foo (was \"foo\")'\n\t\t)\n\t\tattest(path).snap([\"stringKey\", \"Symbol(ctxPathExampleSymbol)\", 1])\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/type.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { TraversalError, type JsonSchema, type UnitNode } from \"@ark/schema\"\nimport { flatMorph } from \"@ark/util\"\nimport { Generic, keywords, scope, Type, type, type Ark } from \"arktype\"\nimport * as assert from \"node:assert/strict\"\n\ncontextualize(() => {\n\tit(\"root discriminates\", () => {\n\t\tconst T = type(\"string\")\n\t\tconst out = T(\"\")\n\t\tif (out instanceof type.errors) out.throw()\n\t\telse attest<string>(out)\n\t})\n\n\tit(\"allows\", () => {\n\t\tconst T = type(\"number%2\")\n\t\tconst data: unknown = 4\n\t\tif (T.allows(data)) {\n\t\t\t// narrows correctly\n\t\t\tattest<number>(data)\n\t\t} else throw new Error()\n\n\t\tattest(T.allows(5)).equals(false)\n\t})\n\n\tit(\"allows doc example\", () => {\n\t\tconst Numeric = type(\"number | bigint\")\n\t\tconst numerics = [0, \"one\", 2n].filter(Numeric.allows)\n\t\tattest(numerics).snap([0, 2n])\n\t})\n\n\tit(\"extends doc example\", () => {\n\t\tconst N = type(Math.random() > 0.5 ? \"boolean\" : \"string\")\n\t\tattest(N.expression).satisfies(\"string | boolean\")\n\t\tattest(N.t).type.toString.snap(\"string | boolean\")\n\t\tconst ez = N.ifExtends(\"boolean\")\n\t\tattest(ez?.expression).satisfies(\"'boolean' | undefined\")\n\t\tattest(ez?.t).type.toString.snap(\"boolean | undefined\")\n\t})\n\n\tit(\"errors can be thrown\", () => {\n\t\tconst T = type(\"number\")\n\t\ttry {\n\t\t\tconst result = T(\"invalid\")\n\t\t\tif (result instanceof type.errors) result.throw()\n\t\t} catch (e) {\n\t\t\tattest(e).instanceOf(TraversalError)\n\t\t\tattest((e as TraversalError).arkErrors instanceof type.errors)\n\t\t\treturn\n\t\t}\n\t\tthrow new assert.AssertionError({ message: \"Expected to throw\" })\n\t})\n\n\tit(\"assert\", () => {\n\t\tconst T = type({ a: \"string\" })\n\t\tattest(T.assert({ a: \"1\" })).equals({ a: \"1\" })\n\t\tattest(() => T.assert({ a: 1 })).throws.snap(\n\t\t\t\"TraversalError: a must be a string (was a number)\"\n\t\t)\n\t})\n\n\tit(\"select\", () => {\n\t\tconst Units = type(\"'red' | 'blue'\").select(\"unit\")\n\n\t\tattest<UnitNode[]>(Units)\n\t\tattest(Units).snap([{ unit: \"blue\" }, { unit: \"red\" }])\n\t})\n\n\tit(\"is treated as covariant\", () => {\n\t\ttype(\"1\") satisfies Type<number>\n\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"1\") satisfies Type<string>).type.errors(\n\t\t\t\"missing the following properties from type 'Type<string, {}>'\"\n\t\t)\n\n\t\t// errors correctly if t is declared as its own type param\n\t\tconst accept = <t extends string>(t: Type<t>) => t\n\n\t\tconst T = type(\"1\")\n\n\t\t// @ts-expect-error\n\t\tattest(() => accept(T)).type.errors(\n\t\t\t\"Argument of type 'Type<1, {}>' is not assignable to parameter of type 'Type<string, {}>'\"\n\t\t)\n\t})\n\n\t// the negative cases of these assignability tests\n\t// contribute a ton of instantiations and check time\n\n\tit(\"base signature obeys assignability rules\", () => {\n\t\ttype(\"'foo'[]\") satisfies Type<string[]>\n\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"number[]\") satisfies Type<string[]>).type.errors(\n\t\t\t\"Type 'number' is not assignable to type 'string'\"\n\t\t)\n\t\tattest.instantiations([525881, \"instantiations\"])\n\t})\n\n\tit(\"args signature obeys assignability rules\", () => {\n\t\ttype(\"'foo'\", \"[]\") satisfies Type<string[]>\n\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"number\", \"[]\") satisfies Type<string[]>).type.errors(\n\t\t\t\"Type 'number' is not assignable to type 'string'\"\n\t\t)\n\t\tattest.instantiations([524238, \"instantiations\"])\n\t})\n\n\tit(\"type.Any allows arbitrary scope\", () => {\n\t\tconst foo = scope({\n\t\t\tfoo: \"string\"\n\t\t}).resolve(\"foo\")\n\n\t\tfoo satisfies type.Any<string>\n\n\t\t// @ts-expect-error (fails with default ambient type)\n\t\tattest((): Type<string> => foo).type.errors(\n\t\t\t\"Type<string, { foo: string; }>' is not assignable to type 'Type<string, {}>'\"\n\t\t)\n\t})\n\n\tit(\"distribute\", () => {\n\t\tconst T = type(\"===\", 0, \"1\", \"2\", 3, \"4\", 5)\n\n\t\tconst numbers = T.distribute(\n\t\t\tn =>\n\t\t\t\tn.ifExtends(type.number) ??\n\t\t\t\ttype.raw(n.expression.slice(1, -1)).as<number>(),\n\t\t\tbranches => type.raw(branches).as<number[]>()\n\t\t)\n\n\t\tattest(numbers.expression).snap(\"[1, 2, 4, 0, 3, 5]\")\n\t})\n\n\tit(\"attached types\", () => {\n\t\tconst attachments: Record<keyof Ark.typeAttachments, string | object> =\n\t\t\tflatMorph({ ...type }, (k, v) =>\n\t\t\t\tv instanceof Type ? [k, v.expression]\n\t\t\t\t: v instanceof Generic ? [k, v.json]\n\t\t\t\t: []\n\t\t\t)\n\n\t\tattest(attachments).snap({\n\t\t\tbigint: \"bigint\",\n\t\t\tboolean: \"boolean\",\n\t\t\tfalse: \"false\",\n\t\t\tnever: \"never\",\n\t\t\tnull: \"null\",\n\t\t\tnumber: \"number\",\n\t\t\tobject: \"object\",\n\t\t\tstring: \"string\",\n\t\t\tsymbol: \"symbol\",\n\t\t\ttrue: \"true\",\n\t\t\tunknown: \"unknown\",\n\t\t\tundefined: \"undefined\",\n\t\t\tarrayIndex: type.arrayIndex.expression,\n\t\t\tKey: \"string | symbol\",\n\t\t\tRecord: keywords.Record.internal.json,\n\t\t\tDate: \"Date\",\n\t\t\tArray: \"Array\"\n\t\t})\n\n\t\tattest<number>(type.number.t)\n\t})\n\n\tit(\"ark attached\", () => {\n\t\tattest<string>(type.keywords.number.integer.expression).snap(\"number % 1\")\n\t})\n\n\tit(\"unit\", () => {\n\t\tconst T = type.unit(5)\n\t\tattest<5>(T.t)\n\t\tattest(T.expression).equals(\"5\")\n\t})\n\n\tit(\"enumerated\", () => {\n\t\tconst T = type.enumerated(5, true, null)\n\t\tattest<5 | true | null>(T.t)\n\t\tattest(T.expression).snap(\"5 | null | true\")\n\t})\n\n\tit(\"schema\", () => {\n\t\tconst T = type.schema({ domain: \"string\" })\n\t\t// uninferred for now\n\t\tattest<unknown>(T.t)\n\t\tattest(T.expression).equals(\"string\")\n\t})\n\n\tit(\"ifEquals\", () => {\n\t\tconst T = type(\"string\")\n\t\tattest(T.ifEquals(\"string\")).equals(T)\n\t\t// subtype\n\t\tattest(T.ifEquals(\"'foo'\")).equals(undefined)\n\t\t// supertype\n\t\tattest(T.ifEquals(\"string | number\")).equals(undefined)\n\t})\n\n\tit(\"ifExtends\", () => {\n\t\tconst T = type(\"string\")\n\t\tattest<type<string> | undefined>(T.ifExtends(\"string\")).equals(T)\n\t\t// subtype\n\t\tattest<type<\"foo\"> | undefined>(T.ifExtends(\"'foo'\")).equals(undefined)\n\t\t// supertype\n\t\tattest<type<string | number> | undefined>(\n\t\t\tT.ifExtends(\"string | number\")\n\t\t).equals(T)\n\t})\n\n\tit(\"allows assignment to unparameterized Type\", () => {\n\t\tconst T = type({\n\t\t\tname: \"string >= 2\",\n\t\t\temail: \"string.email\"\n\t\t})\n\n\t\tT satisfies Type\n\t})\n\n\tit(\"allows morph assignment to unparameterized Type\", () => {\n\t\tconst T = type(\"string\").pipe(s => s.length)\n\n\t\tT satisfies Type\n\t})\n\n\tit(\"assert callable as standalone function\", () => {\n\t\tconst { assert } = type(\"string\")\n\n\t\tattest<(data: unknown) => string>(assert)\n\t\tattest(assert(\"foo\")).equals(\"foo\")\n\t\tattest(() => assert(5)).throws.snap(\n\t\t\t\"TraversalError: must be a string (was a number)\"\n\t\t)\n\t})\n\n\tit(\"toString()\", () => {\n\t\t// represent a variety of structures to ensure it is correctly composed\n\t\tconst T = type({\n\t\t\t\"[string]\": \"number | unknown[]\",\n\t\t\ta: \"1\",\n\t\t\t\"b?\": \"2\",\n\t\t\tc: [\"0 < string < 5\", \"boolean?\", \"...\", \"number[]\"],\n\t\t\td: [\n\t\t\t\t[\"string\", \"=>\", s => s.length],\n\t\t\t\t\"0 < number % 2 < 100\",\n\t\t\t\t\"...\",\n\t\t\t\t\"bigint[]\",\n\t\t\t\t\"(/^a.*z$/ & string.lower)[]\"\n\t\t\t]\n\t\t})\n\t\tattest(T.expression).snap(\n\t\t\t\"{ [string]: number | Array, a: 1, c: [string <= 4 & >= 1, boolean?, ...number[]], d: [(In: string) => Out<unknown>, number % 2 & < 100 & > 0, ...bigint[], (In: /^a.*z$/) => Out</^[a-z]*$/>[]], b?: 2 }\"\n\t\t)\n\t\tattest(`${T}`).equals(`Type<${T.expression}>`)\n\t})\n\n\tit(\"valueOf\", () => {\n\t\t//    🪦R.I.P. TS enums🪦\n\t\t//         2012-2025\n\t\t// Killed by --erasableSyntaxOnly\n\n\t\t// enum TsEnum {\n\t\t// \tnumeric = 1,\n\t\t// \tsymmetrical = \"symmetrical\",\n\t\t// \tasymmetrical = \"lacirtemmysa\"\n\t\t// }\n\n\t\tconst EquivalentObject = {\n\t\t\tnumeric: 1,\n\t\t\tsymmetrical: \"symmetrical\",\n\t\t\tasymmetrical: \"lacirtemmysa\"\n\t\t} as const\n\n\t\t// TS reverse assigns numeric values\n\t\t// need to make sure we don't extract them at runtime\n\n\t\t// Object.assign avoids TS inferring this key (it wouldn't for an enum)\n\t\tObject.assign(EquivalentObject, {\n\t\t\t\"1\": \"numeric\"\n\t\t})\n\n\t\tconst T = type.valueOf(EquivalentObject)\n\n\t\tconst Expected = type.enumerated(1, \"symmetrical\", \"lacirtemmysa\")\n\n\t\tattest<typeof Expected>(T)\n\t\tattest(T.expression).equals(Expected.expression)\n\t})\n\n\tit(\"toJsonSchema docs\", () => {\n\t\tconst User = type({\n\t\t\tname: \"string\",\n\t\t\temail: \"string.email\",\n\t\t\t\"age?\": \"number >= 18\"\n\t\t})\n\n\t\tconst schema = User.toJsonSchema()\n\n\t\tconst expected: JsonSchema = {\n\t\t\t$schema: \"https://json-schema.org/draft/2020-12/schema\",\n\t\t\ttype: \"object\",\n\t\t\tproperties: {\n\t\t\t\tname: { type: \"string\" },\n\t\t\t\temail: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\tformat: \"email\",\n\t\t\t\t\tpattern: \"^[\\\\w%+.-]+@[\\\\d.A-Za-z-]+\\\\.[A-Za-z]{2,}$\"\n\t\t\t\t},\n\t\t\t\tage: { type: \"number\", minimum: 18 }\n\t\t\t},\n\t\t\trequired: [\"email\", \"name\"]\n\t\t}\n\n\t\tattest(schema).equals(expected)\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/typeReference.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { writeUnresolvableMessage } from \"@ark/schema\"\nimport { ark, scope, type } from \"arktype\"\n\ncontextualize(() => {\n\tit(\"shallow type reference\", () => {\n\t\tconst T = type(type(\"boolean\"))\n\t\tattest<boolean>(T.infer)\n\t})\n\n\tit(\"bad shallow type reference\", () => {\n\t\tattest(() => {\n\t\t\t// @ts-expect-error\n\t\t\ttype(type(\"foolean\"))\n\t\t}).throwsAndHasTypeError(writeUnresolvableMessage(\"foolean\"))\n\t})\n\n\tit(\"deep type reference\", () => {\n\t\tconst T = type({ a: type(\"boolean\") })\n\t\tattest<{ a: boolean }>(T.infer)\n\t})\n\n\tit(\"type reference in scope\", () => {\n\t\tconst A = type({ a: \"string\" })\n\t\tconst $ = scope({ a: A })\n\t\tconst types = $.export()\n\t\tattest(types.a.json).equals(A.json)\n\t\tattest(A.$.json).equals(ark.json)\n\t\tattest(types.a.$.json).equals($.json)\n\t\tattest<{ a: string }>(types.a.infer)\n\t})\n\n\tit(\"bad deep type reference\", () => {\n\t\tattest(() => {\n\t\t\t// @ts-expect-error\n\t\t\ttype({ a: type(\"goolean\") })\n\t\t}).throwsAndHasTypeError(writeUnresolvableMessage(\"goolean\"))\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/unenclosed.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { writeUnresolvableMessage } from \"@ark/schema\"\nimport { writeMalformedNumericLiteralMessage } from \"@ark/util\"\nimport { scope, type } from \"arktype\"\n\ncontextualize(() => {\n\tdescribe(\"identifier\", () => {\n\t\tit(\"keyword\", () => {\n\t\t\tattest<string>(type(\"string\").infer)\n\t\t})\n\n\t\tit(\"alias\", () => {\n\t\t\tconst a = scope({ a: \"string\" }).type(\"a\")\n\t\t\tattest<string>(a.infer)\n\t\t})\n\n\t\tit(\"unresolvable\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"HUH\")).throwsAndHasTypeError(\n\t\t\t\twriteUnresolvableMessage(\"HUH\")\n\t\t\t)\n\t\t})\n\t})\n\n\tdescribe(\"number\", () => {\n\t\tit(\"positive whole\", () => {\n\t\t\tconst Four = type(\"4\")\n\t\t\tattest<4>(Four.infer)\n\t\t\tattest(Four.json).snap({ unit: 4 })\n\t\t})\n\n\t\tit(\"positive decimal\", () => {\n\t\t\tattest<3.14159>(type(\"3.14159\").infer)\n\t\t})\n\n\t\tit(\"positive decimal with zero whole portion\", () => {\n\t\t\tattest<0.5>(type(\"0.5\").infer)\n\t\t})\n\n\t\tit(\"negative whole\", () => {\n\t\t\tattest<-12>(type(\"-12\").infer)\n\t\t})\n\n\t\tit(\"negative decimal\", () => {\n\t\t\tattest<-1.618>(type(\"-1.618\").infer)\n\t\t})\n\n\t\tit(\"negative decimal with zero whole portion\", () => {\n\t\t\tattest<-0.001>(type(\"-0.001\").infer)\n\t\t})\n\n\t\tit(\"zero\", () => {\n\t\t\tattest<0>(type(\"0\").infer)\n\t\t})\n\n\t\tit(\"multiple decimals\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"127.0.0.1\")).throwsAndHasTypeError(\n\t\t\t\twriteUnresolvableMessage(\"127.0.0.1\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"with alpha\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"13three7\")).throwsAndHasTypeError(\n\t\t\t\twriteUnresolvableMessage(\"13three7\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"leading zeroes\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"010\")).throwsAndHasTypeError(\n\t\t\t\twriteMalformedNumericLiteralMessage(\"010\", \"number\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"trailing zeroes\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"4.0\")).throws(\n\t\t\t\twriteMalformedNumericLiteralMessage(\"4.0\", \"number\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"negative zero\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"-0\")).throws(\n\t\t\t\twriteMalformedNumericLiteralMessage(\"-0\", \"number\")\n\t\t\t)\n\t\t})\n\t})\n\n\tdescribe(\"bigint\", () => {\n\t\tit(\"positive\", () => {\n\t\t\tconst T = type(\"12345678910987654321n\")\n\t\t\t// Is prime :D\n\t\t\tattest<12345678910987654321n>(T.infer)\n\t\t\tattest(T.json).snap({ unit: \"12345678910987654321n\" })\n\t\t})\n\n\t\tit(\"negative\", () => {\n\t\t\tconst T = type(\"-9801n\")\n\t\t\tattest<-9801n>(T.infer)\n\t\t\tattest(T.json).snap({ unit: \"-9801n\" })\n\t\t})\n\n\t\tit(\"zero\", () => {\n\t\t\tconst T = type(\"0n\")\n\t\t\tattest<0n>(T.infer)\n\t\t\tattest(T.json).snap({ unit: \"0n\" })\n\t\t})\n\n\t\tit(\"decimal\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"999.1n\")).throwsAndHasTypeError(\n\t\t\t\twriteUnresolvableMessage(\"999.1n\")\n\t\t\t)\n\t\t})\n\n\t\tit(\"leading zeroes\", () => {\n\t\t\t// TS currently doesn't try to infer this as bigint even\n\t\t\t// though it matches our rules for a \"malformed\" integer.\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"007n\"))\n\t\t\t\t.throws(writeMalformedNumericLiteralMessage(\"007n\", \"bigint\"))\n\t\t\t\t.type.errors(writeUnresolvableMessage(\"007n\"))\n\t\t})\n\n\t\tit(\"negative zero\", () => {\n\t\t\t// @ts-expect-error\n\t\t\tattest(() => type(\"-0n\")).throwsAndHasTypeError(\n\t\t\t\twriteMalformedNumericLiteralMessage(\"-0n\", \"bigint\")\n\t\t\t)\n\t\t})\n\t})\n})\n"
  },
  {
    "path": "ark/type/__tests__/union.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport {\n\tintrinsic,\n\trootSchema,\n\twriteIndivisibleMessage,\n\twriteUnresolvableMessage\n} from \"@ark/schema\"\nimport { type } from \"arktype\"\nimport { writeMissingRightOperandMessage } from \"arktype/internal/parser/shift/operand/unenclosed.ts\"\n\ncontextualize(() => {\n\tit(\"binary\", () => {\n\t\tconst Binary = type(\"number|string\")\n\t\tattest<number | string>(Binary.infer)\n\t\tattest(Binary.json).snap([\"number\", \"string\"])\n\t})\n\n\tit(\"nary\", () => {\n\t\tconst Nary = type(\"false|null|undefined|0|''\")\n\t\tattest<false | \"\" | 0 | null | undefined>(Nary.infer)\n\t\tconst Expected = type(\"===\", false, null, undefined, 0, \"\")\n\t\tattest(Nary.json).equals(Expected.json)\n\t})\n\n\tit(\"subtype pruning\", () => {\n\t\tconst T = type({ a: \"string\" }, \"|\", { a: \"'foo'\" })\n\t\tconst Expected = type({ a: \"string\" })\n\t\tattest<typeof Expected>(T)\n\t\tattest(T.json).equals(Expected.json)\n\t})\n\n\tit(\"multiple subtypes pruned\", () => {\n\t\tconst T = type(\"'foo'|'bar'|string|'baz'|/.*/\")\n\t\tconst Expected = type(\"string\")\n\t\tattest<string>(T.infer)\n\t\tattest(T.json).equals(Expected.json)\n\t})\n\n\tit(\"boolean is a union of true | false\", () => {\n\t\tconst T = type(\"true|false\")\n\t\tattest(T.infer).type.toString(\"boolean\")\n\t\tattest(T.json).equals(type(\"boolean\").json)\n\t})\n\n\tit(\"nested tuple union\", () => {\n\t\tconst T = type([\"string|bigint\", \"|\", [\"number\", \"|\", \"boolean\"]])\n\t\tattest<string | number | bigint | boolean>(T.infer)\n\t\tattest(T.json).equals(type(\"string|bigint|number|boolean\").json)\n\t})\n\n\tit(\"length stress\", () => {\n\t\t// as of TS 5.1, can handle a max of 46 branches before an inifinitely\n\t\t// deep error not the end of the world if this changes slightly, but\n\t\t// wanted to make those changes explicit if something reduces it it's\n\t\t// also still very responsive up until it hits the limit, so it is\n\t\t// likely a safeguard rather than a limitation of the parser\n\t\tconst T = type(\n\t\t\t\"0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45\"\n\t\t)\n\t\t// prettier-ignore\n\t\tattest<\n\t\t\t\t| 0\n\t\t\t\t| 1\n\t\t\t\t| 2\n\t\t\t\t| 3\n\t\t\t\t| 4\n\t\t\t\t| 5\n\t\t\t\t| 6\n\t\t\t\t| 7\n\t\t\t\t| 8\n\t\t\t\t| 9\n\t\t\t\t| 10\n\t\t\t\t| 11\n\t\t\t\t| 12\n\t\t\t\t| 13\n\t\t\t\t| 14\n\t\t\t\t| 15\n\t\t\t\t| 16\n\t\t\t\t| 17\n\t\t\t\t| 18\n\t\t\t\t| 19\n\t\t\t\t| 20\n\t\t\t\t| 21\n\t\t\t\t| 22\n\t\t\t\t| 23\n\t\t\t\t| 24\n\t\t\t\t| 25\n\t\t\t\t| 26\n\t\t\t\t| 27\n\t\t\t\t| 28\n\t\t\t\t| 29\n\t\t\t\t| 30\n\t\t\t\t| 31\n\t\t\t\t| 32\n\t\t\t\t| 33\n\t\t\t\t| 34\n\t\t\t\t| 35\n\t\t\t\t| 36\n\t\t\t\t| 37\n\t\t\t\t| 38\n\t\t\t\t| 39\n\t\t\t\t| 40\n\t\t\t\t| 41\n\t\t\t\t| 42\n\t\t\t\t| 43\n\t\t\t\t| 44\n\t\t\t\t| 45\n\t\t\t>(T.infer)\n\n\t\tattest(T.json).snap([\n\t\t\t{ unit: 0 },\n\t\t\t{ unit: 10 },\n\t\t\t{ unit: 11 },\n\t\t\t{ unit: 12 },\n\t\t\t{ unit: 13 },\n\t\t\t{ unit: 14 },\n\t\t\t{ unit: 15 },\n\t\t\t{ unit: 16 },\n\t\t\t{ unit: 17 },\n\t\t\t{ unit: 18 },\n\t\t\t{ unit: 19 },\n\t\t\t{ unit: 1 },\n\t\t\t{ unit: 20 },\n\t\t\t{ unit: 21 },\n\t\t\t{ unit: 22 },\n\t\t\t{ unit: 23 },\n\t\t\t{ unit: 24 },\n\t\t\t{ unit: 25 },\n\t\t\t{ unit: 26 },\n\t\t\t{ unit: 27 },\n\t\t\t{ unit: 28 },\n\t\t\t{ unit: 29 },\n\t\t\t{ unit: 2 },\n\t\t\t{ unit: 30 },\n\t\t\t{ unit: 31 },\n\t\t\t{ unit: 32 },\n\t\t\t{ unit: 33 },\n\t\t\t{ unit: 34 },\n\t\t\t{ unit: 35 },\n\t\t\t{ unit: 36 },\n\t\t\t{ unit: 37 },\n\t\t\t{ unit: 38 },\n\t\t\t{ unit: 39 },\n\t\t\t{ unit: 3 },\n\t\t\t{ unit: 40 },\n\t\t\t{ unit: 41 },\n\t\t\t{ unit: 42 },\n\t\t\t{ unit: 43 },\n\t\t\t{ unit: 44 },\n\t\t\t{ unit: 45 },\n\t\t\t{ unit: 4 },\n\t\t\t{ unit: 5 },\n\t\t\t{ unit: 6 },\n\t\t\t{ unit: 7 },\n\t\t\t{ unit: 8 },\n\t\t\t{ unit: 9 }\n\t\t])\n\t})\n\n\tconst expected = () =>\n\t\trootSchema([\n\t\t\t{\n\t\t\t\tdomain: \"object\",\n\t\t\t\trequired: {\n\t\t\t\t\tkey: \"a\",\n\t\t\t\t\tvalue: { domain: \"string\" }\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\tdomain: \"object\",\n\t\t\t\trequired: {\n\t\t\t\t\tkey: \"b\",\n\t\t\t\t\tvalue: { domain: \"number\" }\n\t\t\t\t}\n\t\t\t}\n\t\t]).json\n\n\tit(\"tuple\", () => {\n\t\tconst T = type([{ a: \"string\" }, \"|\", { b: \"number\" }])\n\t\tattest<{ a: string } | { b: number }>(T.infer)\n\t\tattest(T.json).equals(expected())\n\t})\n\n\tit(\"root\", () => {\n\t\tconst T = type({ a: \"string\" }, \"|\", { b: \"number\" })\n\t\tattest<{ a: string } | { b: number }>(T.infer)\n\t\tattest(T.json).equals(expected())\n\t})\n\n\tit(\"chained\", () => {\n\t\tconst T = type({ a: \"string\" }).or({ b: \"number\" })\n\t\tattest<\n\t\t\t| {\n\t\t\t\t\ta: string\n\t\t\t  }\n\t\t\t| {\n\t\t\t\t\tb: number\n\t\t\t  }\n\t\t>(T.infer)\n\t\tattest(T.json).equals(expected())\n\t})\n\n\tit(\"root autocompletion\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type({ a: \"s\" }, \"|\", { b: \"boolean\" })).completions({\n\t\t\ts: [\"string\", \"symbol\"],\n\t\t\t\"|\": [\"|>\"]\n\t\t})\n\t\t// @ts-expect-error\n\t\tattest(() => type({ a: \"string\" }, \"|\", { b: \"b\" })).completions({\n\t\t\t\"|\": [\"|>\"],\n\t\t\tb: [\"bigint\", \"boolean\"]\n\t\t})\n\t})\n\n\tit(\"bad reference\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"number|strng\")).throwsAndHasTypeError(\n\t\t\twriteUnresolvableMessage(\"strng\")\n\t\t)\n\t})\n\n\tit(\"consecutive tokens\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"boolean||null\")).throws(\n\t\t\twriteMissingRightOperandMessage(\"|\", \"|null\")\n\t\t)\n\t})\n\n\tit(\"ends with |\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"boolean|\")).throws(\n\t\t\twriteMissingRightOperandMessage(\"|\", \"\")\n\t\t)\n\t})\n\n\tit(\"long missing union member\", () => {\n\t\tattest(() =>\n\t\t\t// @ts-expect-error\n\t\t\ttype(\"boolean[]|(string|number|)|object\")\n\t\t).throws(writeMissingRightOperandMessage(\"|\", \")|object\"))\n\t})\n\n\tit(\"left semantic error\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"symbol%2|string\")).throwsAndHasTypeError(\n\t\t\twriteIndivisibleMessage(intrinsic.symbol)\n\t\t)\n\t})\n\n\tit(\"right semantic error\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"string|symbol%2\")).throwsAndHasTypeError(\n\t\t\twriteIndivisibleMessage(intrinsic.symbol)\n\t\t)\n\t})\n\n\tit(\"chained bad reference\", () => {\n\t\t// @ts-expect-error\n\t\tattest(() => type(\"string\").or(\"nummer\")).throwsAndHasTypeError(\n\t\t\twriteUnresolvableMessage(\"nummer\")\n\t\t)\n\t})\n\n\tit(\"chained description\", () => {\n\t\tconst T = type(\"number|string\").describe(\"My custom type\")\n\t\tattest(T.json).snap({\n\t\t\tbranches: [\n\t\t\t\t{ meta: \"My custom type\", domain: \"number\" },\n\t\t\t\t{ meta: \"My custom type\", domain: \"string\" }\n\t\t\t],\n\t\t\tmeta: \"My custom type\"\n\t\t})\n\t})\n})\n"
  },
  {
    "path": "ark/type/attributes.ts",
    "content": "import type { ArkError, ArkErrors, Morph } from \"@ark/schema\"\nimport {\n\tnoSuggest,\n\ttype anyOrNever,\n\ttype array,\n\ttype Brand,\n\ttype equals,\n\ttype Hkt,\n\ttype intersectArrays,\n\ttype isSafelyMappable,\n\ttype merge,\n\ttype optionalKeyOf,\n\ttype Primitive,\n\ttype show,\n\ttype unionKeyOf,\n\ttype unionToTuple\n} from \"@ark/util\"\nimport type { arkPrototypes } from \"./keywords/constructors.ts\"\nimport type { type } from \"./keywords/keywords.ts\"\nimport type { Type } from \"./type.ts\"\nexport type { arkPrototypes as object } from \"./keywords/constructors.ts\"\n\nexport type Comparator = \"<\" | \"<=\" | \">\" | \">=\" | \"==\"\n\nexport type RegexLiteral<source extends string = string> = `/${source}/`\n\nexport type DateLiteral<source extends string = string> =\n\t| `d\"${source}\"`\n\t| `d'${source}'`\n\nexport type LimitLiteral = number | DateLiteral\n\nexport type normalizeLimit<limit> =\n\tlimit extends DateLiteral<infer source> ? source\n\t: limit extends number | string ? limit\n\t: never\n\nexport type distill<t, side extends distill.Side> = finalizeDistillation<\n\tt,\n\t_distill<t, side>\n>\n\nexport declare namespace distill {\n\texport type Side = \"in\" | \"out\" | \"introspectableOut\"\n\n\texport type In<t> = distill<t, \"in\">\n\n\texport type Out<t> = distill<t, \"out\">\n\n\texport namespace introspectable {\n\t\texport type Out<t> = distill<t, \"introspectableOut\">\n\t}\n}\n\ntype finalizeDistillation<t, distilled> =\n\tequals<t, distilled> extends true ? t : distilled\n\ntype _distill<t, side extends distill.Side> =\n\t// ensure optional keys don't prevent extracting defaults\n\tt extends undefined ? t\n\t: [t] extends [anyOrNever] ? t\n\t: unknown extends t ? unknown\n\t: t extends Brand<infer base> ?\n\t\tside extends \"in\" ?\n\t\t\tbase\n\t\t:\tt\n\t: // Function is excluded from TerminallyInferredObjectKind so that\n\t// those types could be inferred before checking for morphs\n\tt extends TerminallyInferredObject | Primitive ? t\n\t: t extends Function ?\n\t\t// don't treat functions like () => never as morphs\n\t\tt extends (...args: never) => anyOrNever ? t\n\t\t: t extends InferredMorph<infer i, infer o> ? distillIo<i, o, side>\n\t\t: t\n\t: t extends Default<infer constraint> ? _distill<constraint, side>\n\t: t extends array ? distillArray<t, side>\n\t: isSafelyMappable<t> extends true ? distillMappable<t, side>\n\t: t\n\ntype distillMappable<o, side extends distill.Side> =\n\tside extends \"in\" ?\n\t\tshow<\n\t\t\t{\n\t\t\t\t// this is homomorphic so includes parsed optional keys like \"key?\": \"string\"\n\t\t\t\t[k in keyof o as k extends inferredDefaultKeyOf<o> ? never\n\t\t\t\t:\tk]: _distill<o[k], side>\n\t\t\t} & {\n\t\t\t\t[k in inferredDefaultKeyOf<o>]?: _distill<o[k], side>\n\t\t\t}\n\t\t>\n\t:\t{ [k in keyof o]: _distill<o[k], side> }\n\ntype distillIo<i, o extends Out, side extends distill.Side> =\n\tside extends \"out\" ? _distill<o[\"t\"], side>\n\t: side extends \"in\" ? _distill<i, side>\n\t: // out.introspectable only respects To (schema-validated output)\n\to extends To<infer validatedOut> ? _distill<validatedOut, side>\n\t: unknown\n\ntype unwrapInput<t> =\n\tt extends InferredMorph<infer i> ?\n\t\tt extends anyOrNever ?\n\t\t\tt\n\t\t:\ti\n\t:\tt\n\ntype inferredDefaultKeyOf<o> =\n\tkeyof o extends infer k ?\n\t\tk extends keyof o ?\n\t\t\tunwrapInput<o[k]> extends Default<infer t> ?\n\t\t\t\t[t] extends [anyOrNever] ?\n\t\t\t\t\tnever\n\t\t\t\t:\tk\n\t\t\t:\tnever\n\t\t:\tnever\n\t:\tnever\n\ntype distillArray<t extends array, side extends distill.Side> =\n\t// fast path for non-tuple arrays with no extra props\n\t// this also allows TS to infer certain recursive arrays like JSON\n\tt[number][] extends t ? alignReadonly<_distill<t[number], side>[], t>\n\t:\tdistillNonArraykeys<\n\t\t\tt,\n\t\t\talignReadonly<distillArrayFromPrefix<[...t], side, []>, t>,\n\t\t\tside\n\t\t>\n\ntype alignReadonly<result extends unknown[], original extends array> =\n\toriginal extends unknown[] ? result : Readonly<result>\n\n// re-intersect non-array props for a type like `{ name: string } & string[]`\ntype distillNonArraykeys<\n\toriginalArray extends array,\n\tdistilledArray,\n\tside extends distill.Side\n> =\n\tkeyof originalArray extends keyof distilledArray ? distilledArray\n\t:\tdistilledArray &\n\t\t\t_distill<\n\t\t\t\t{\n\t\t\t\t\t[k in keyof originalArray as k extends keyof distilledArray ? never\n\t\t\t\t\t:\tk]: originalArray[k]\n\t\t\t\t},\n\t\t\t\tside\n\t\t\t>\n\ntype distillArrayFromPrefix<\n\tt extends array,\n\tside extends distill.Side,\n\tprefix extends array\n> =\n\tt extends readonly [infer head, ...infer tail] ?\n\t\tdistillArrayFromPrefix<\n\t\t\ttail,\n\t\t\tside,\n\t\t\t[side, head] extends [\"in\", Default] ? [...prefix, _distill<head, side>?]\n\t\t\t:\t[...prefix, _distill<head, side>]\n\t\t>\n\t:\t[...prefix, ...distillArrayFromPostfix<t, side, []>]\n\ntype distillArrayFromPostfix<\n\tt extends array,\n\tside extends distill.Side,\n\tpostfix extends array\n> =\n\tt extends readonly [...infer init, infer last] ?\n\t\tdistillArrayFromPostfix<init, side, [_distill<last, side>, ...postfix]>\n\t:\t[...{ [i in keyof t]: _distill<t[i], side> }, ...postfix]\n\ntype BuiltinTerminalObjectKind = Exclude<\n\tarkPrototypes.NonDegenerateName,\n\t\"Array\" | \"Function\"\n>\n\n/** Objects we don't want to expand during inference like Date or Promise */\ntype TerminallyInferredObject =\n\t| arkPrototypes.instanceOf<BuiltinTerminalObjectKind>\n\t| ArkEnv.prototypes\n\nexport type inferPredicate<t, predicate> =\n\tpredicate extends (data: any, ...args: any[]) => data is infer narrowed ?\n\t\tnarrowed\n\t:\tt\n\nexport type inferNaryPipe<morphs extends readonly Morph[]> = _inferNaryPipe<\n\tmorphs,\n\tunknown\n>\n\ntype _inferNaryPipe<remaining extends readonly unknown[], result> =\n\tremaining extends (\n\t\treadonly [infer head extends Morph, ...infer tail extends Morph[]]\n\t) ?\n\t\t_inferNaryPipe<tail, inferMorph<result, head>>\n\t:\tresult\n\nexport type inferNaryIntersection<types extends readonly unknown[]> =\n\tnumber extends types[\"length\"] ?\n\t\t_inferNaryIntersection<unionToTuple<types[number]>, unknown>\n\t:\t_inferNaryIntersection<types, unknown>\n\ntype _inferNaryIntersection<remaining extends readonly unknown[], result> =\n\tremaining extends readonly [infer head, ...infer tail] ?\n\t\t_inferNaryIntersection<tail, inferIntersection<result, head>>\n\t:\tresult\n\nexport type inferNaryMerge<types extends readonly unknown[]> =\n\tnumber extends types[\"length\"] ? _inferUnorderedMerge<types>\n\t:\t_inferNaryMerge<types, {}>\n\ntype _inferUnorderedMerge<\n\ttypes extends readonly unknown[],\n\toptionalKey extends PropertyKey = optionalAtLeastOnceUnionKeyOf<\n\t\ttypes[number]\n\t>,\n\trequiredKey extends PropertyKey = Exclude<\n\t\tunionKeyOf<types[number]>,\n\t\toptionalKey\n\t>\n> = show<\n\t{\n\t\t[k in requiredKey]: types[number] extends infer v ?\n\t\t\tv extends unknown ?\n\t\t\t\tk extends keyof v ?\n\t\t\t\t\tv[k]\n\t\t\t\t:\tnever\n\t\t\t:\tnever\n\t\t:\tnever\n\t} & {\n\t\t[k in optionalKey]?: types[number] extends infer v ?\n\t\t\tv extends unknown ?\n\t\t\t\tk extends keyof v ?\n\t\t\t\t\tv[k]\n\t\t\t\t:\tnever\n\t\t\t:\tnever\n\t\t:\tnever\n\t}\n>\n\n/** Coalesce keys that exist and are optional on one or more branches of a union */\ntype optionalAtLeastOnceUnionKeyOf<t> =\n\tt extends unknown ? optionalKeyOf<t> : never\n\ntype _inferNaryMerge<remaining extends readonly unknown[], result> =\n\tremaining extends (\n\t\treadonly [infer head, ...infer tail extends readonly unknown[]]\n\t) ?\n\t\t_inferNaryMerge<tail, merge<result, head>>\n\t:\tresult\n\nexport type inferMorphOut<morph extends Morph> = Exclude<\n\tReturnType<morph>,\n\tArkError | ArkErrors\n>\n\nconst isMorphOutKey = noSuggest(\"isMorphOut\")\n\nexport interface Out<o = any> {\n\t[isMorphOutKey]: true\n\tt: o\n\tintrospectable: boolean\n}\n\nexport interface To<o = any> extends Out<o> {\n\tintrospectable: true\n}\n\nexport type InferredMorph<i = never, o extends Out = Out> = (In: i) => o\n\nconst defaultsToKey = noSuggest(\"defaultsTo\")\n\nexport type Default<t = unknown, v = unknown> = { [defaultsToKey]: [t, v] }\n\n// we have to distribute over morphs to preserve the i/o relationship\n// this avoids stuff like:\n// Default<boolean, true> => Default<true, true> | Default<false, true>\nexport type withDefault<t, v, undistributed = t> =\n\tt extends InferredMorph ? addDefaultToMorph<t, v>\n\t:\tDefault<Exclude<undistributed, InferredMorph>, v>\n\ntype addDefaultToMorph<t extends InferredMorph, v> =\n\t[normalizeMorphDistribution<t>] extends [InferredMorph<infer i, infer o>] ?\n\t\t(In: Default<i, v>) => o\n\t:\tnever\n\n// will return `boolean` if some morphs are unequal\n// so should be compared against `true`\ntype normalizeMorphDistribution<\n\tt,\n\tundistributedIn = t extends InferredMorph<infer i> ? i : never,\n\tundistributedOut extends Out = t extends InferredMorph<never, infer o> ?\n\t\t[o] extends [To<infer unwrappedOut>] ?\n\t\t\tTo<unwrappedOut>\n\t\t:\to\n\t:\tnever\n> =\n\t// using Extract here rather than distributing normally helps TS collapse the union\n\t// was otherwise getting duplicated branches, e.g.:\n\t// (In: boolean) => To<boolean> | (In: boolean) => To<boolean>\n\t// revert to `t extends InferredMorph...` if it doesn't break the tests in the future\n\t| (Extract<t, InferredMorph> extends anyOrNever ? never\n\t  : Extract<t, InferredMorph> extends InferredMorph<infer i, infer o> ?\n\t\t\t[undistributedOut] extends [o] ? (In: undistributedIn) => undistributedOut\n\t\t\t: [undistributedIn] extends [i] ?\n\t\t\t\t(In: undistributedIn) => undistributedOut\n\t\t\t:\tt\n\t  :\tnever)\n\t| Exclude<t, InferredMorph> extends infer _ ?\n\t\t// needed to avoid normalizeMorphDistribution or similar showing up in finalized type\n\t\t_\n\t:\tnever\n\nexport type defaultFor<t = unknown> =\n\t| (Primitive extends t ? Primitive\n\t  : t extends Primitive ? t\n\t  : never)\n\t| (() => t)\n\nexport type termOrType<t> = t | Type<t, any>\n\nexport type inferIntersection<l, r> = normalizeMorphDistribution<\n\t_inferIntersection<l, r, false>\n>\n\nexport type inferMorph<t, morph extends Morph> =\n\tmorph extends type.cast<infer tMorph> ? inferPipe<t, tMorph>\n\t: inferMorphOut<morph> extends infer out ? (In: distill.In<t>) => Out<out>\n\t: never\n\nexport type inferPipe<l, r> = normalizeMorphDistribution<\n\t_inferIntersection<l, r, true>\n>\n\ntype _inferIntersection<l, r, piped extends boolean> =\n\t[l & r] extends [infer t extends anyOrNever] ? t\n\t: l extends InferredMorph<infer lIn, infer lOut> ?\n\t\tr extends InferredMorph<never, infer rOut> ?\n\t\t\tpiped extends true ?\n\t\t\t\t(In: lIn) => rOut\n\t\t\t:\t// a commutative intersection between two morphs is a ParseError\n\t\t\t\tnever\n\t\t: piped extends true ? (In: lIn) => To<r>\n\t\t: (In: _inferIntersection<lIn, r, false>) => lOut\n\t: r extends InferredMorph<infer rIn, infer rOut> ?\n\t\t(In: _inferIntersection<rIn, l, false>) => rOut\n\t: [l, r] extends [object, object] ?\n\t\t// adding this intermediate infer result avoids extra instantiations\n\t\tintersectObjects<l, r, piped> extends infer result ?\n\t\t\tresult\n\t\t:\tnever\n\t:\tl & r\n\ninterface MorphableIntersection<piped extends boolean>\n\textends Hkt<[unknown, unknown]> {\n\tbody: _inferIntersection<this[0], this[1], piped>\n}\n\ntype intersectObjects<l, r, piped extends boolean> =\n\tl extends array ?\n\t\tr extends array ?\n\t\t\tintersectArrays<l, r, MorphableIntersection<piped>>\n\t\t:\t// for an intersection with exactly one array operand like { name: string } & string[],\n\t\t\t// don't compute the intersection to avoid including prototype props\n\t\t\tl & r\n\t: r extends array ? l & r\n\t: keyof l & keyof r extends never ? show<l & r>\n\t: show<\n\t\t\t// this looks redundant, but should hit the cache anyways and\n\t\t\t// preserves index signature + optional keys correctly\n\t\t\t{\n\t\t\t\t[k in keyof l]: k extends keyof r ?\n\t\t\t\t\t_inferIntersection<l[k], r[k], piped>\n\t\t\t\t:\tl[k]\n\t\t\t} & {\n\t\t\t\t[k in keyof r]: k extends keyof l ?\n\t\t\t\t\t_inferIntersection<l[k], r[k], piped>\n\t\t\t\t:\tr[k]\n\t\t\t}\n\t\t>\n"
  },
  {
    "path": "ark/type/config.ts",
    "content": "import type { arkKind, TypeMeta } from \"@ark/schema\"\nimport type { Ark } from \"./keywords/keywords.ts\"\n// eslint-disable-next-line @typescript-eslint/no-restricted-imports\nimport { configureSchema, type ArkSchemaConfig } from \"@ark/schema/config\"\nimport type { anyOrNever } from \"@ark/util\"\n\nexport type KeywordConfig = {\n\t[k in keyof Ark.flat as parseConfigurableFlatAlias<\n\t\tk,\n\t\tArk.flat[k]\n\t>]?: TypeMeta.Collapsible\n}\n\ntype parseConfigurableFlatAlias<k extends string, v> =\n\t[v] extends [anyOrNever] ? k\n\t: v extends { [arkKind]: \"generic\" | \"module\" } ? never\n\t: k extends `${infer prefix}.root` ? prefix\n\t: k\n\nexport interface ArkConfig extends ArkSchemaConfig {\n\tkeywords?: KeywordConfig\n}\n\nexport const configure: <config extends ArkConfig>(config: config) => config =\n\tconfigureSchema as never\n\ndeclare global {\n\texport interface ArkEnv {\n\t\t$(): Ark\n\t}\n}\n\n/**\n * This mirrors the global ArkEnv namespace as a local export. We use it instead\n * of the global internally due to a bug in twoslash that prevents `ark/docs`\n * from building if we refer to the global directly.\n *\n * If, in the future, docs can build while arktype refers to `ArkEnv.$` directly,\n * this can be removed.\n */\nexport declare namespace ArkAmbient {\n\texport type $ = ReturnType<ArkEnv[\"$\"]>\n\n\texport type meta = ArkEnv.meta\n\n\texport type prototypes = ArkEnv.prototypes\n}\n"
  },
  {
    "path": "ark/type/declare.ts",
    "content": "import type {\n\tanyOrNever,\n\tarray,\n\tequals,\n\tErrorMessage,\n\tErrorType,\n\toptionalKeyOf,\n\trequiredKeyOf,\n\tshow,\n\tunset\n} from \"@ark/util\"\nimport type { distill } from \"./attributes.ts\"\nimport type { type } from \"./keywords/keywords.ts\"\nimport type {\n\tinferDefinition,\n\tTerminalObjectDefinition,\n\tThunkCast\n} from \"./parser/definition.ts\"\nimport type { OptionalPropertyDefinition } from \"./parser/property.ts\"\nimport type { TupleExpression } from \"./parser/tupleExpressions.ts\"\nimport type { bindThis } from \"./scope.ts\"\nimport type { Type } from \"./type.ts\"\n\nexport type DeclarationParser<$> = <\n\tpreinferred = unset,\n\tctx extends DeclareContext = {}\n>() => {\n\ttype: <const def>(\n\t\tdef: [preinferred] extends [unset] ?\n\t\t\t[preinferred] extends [anyOrNever] ?\n\t\t\t\tvalidateDeclared<preinferred, def, $, ctx>\n\t\t\t:\tErrorMessage<`declare<ExternalType>() requires a generic argument`>\n\t\t:\tvalidateDeclared<preinferred, def, $, ctx>\n\t) => Type<finalizePreinferred<preinferred, def, $, ctx>, $>\n}\n\ntype finalizePreinferred<preinferred, def, $, ctx extends DeclareContext> =\n\tctx[\"side\"] extends distill.Side ?\n\t\tctx[\"side\"] extends \"in\" ?\n\t\t\t(In: preinferred) => type.infer.Out<def, $>\n\t\t:\t(In: type.infer.In<def, $>) => preinferred\n\t:\tpreinferred\n\nexport type DeclareContext = {\n\tside?: \"in\" | \"out\"\n}\n\nexport type validateDeclared<declared, def, $, ctx extends DeclareContext> =\n\tdef extends type.validate<def, $> ?\n\t\tvalidateInference<def, declared, $, bindThis<def>, ctx>\n\t:\ttype.validate<def, $>\n\ntype validateInference<def, declared, $, args, ctx extends DeclareContext> =\n\tdef extends TerminalObjectDefinition | ThunkCast | TupleExpression ?\n\t\t// {} as a def is handled here since according to TS it extends { \" arkInferred\"?: t  }.\n\t\tkeyof def extends never ?\n\t\t\t// special case it to pass through normal object validation\n\t\t\tvalidateObjectInference<def, declared, $, args, ctx>\n\t\t:\tvalidateShallowInference<inferDefinition<def, $, args>, declared, ctx>\n\t: def extends array ? validateArrayInference<def, declared, $, args, ctx>\n\t: def extends object ? validateObjectInference<def, declared, $, args, ctx>\n\t: validateShallowInference<inferDefinition<def, $, args>, declared, ctx>\n\ntype validateArrayInference<\n\tdef extends array,\n\tdeclared,\n\t$,\n\targs,\n\tctx extends DeclareContext\n> =\n\tdeclared extends array ?\n\t\t{\n\t\t\t[i in keyof declared]: i extends keyof def ?\n\t\t\t\tvalidateInference<def[i], declared[i], $, args, ctx>\n\t\t\t:\tdeclared[i]\n\t\t}\n\t:\tshow<declarationMismatch<inferDefinition<def, $, args>, declared>>\n\ntype validateObjectInference<\n\tdef extends object,\n\tdeclared,\n\t$,\n\targs,\n\tctx extends DeclareContext\n> = show<\n\t{\n\t\t[k in requiredKeyOf<declared>]: k extends keyof def ?\n\t\t\tvalidateInference<def[k], declared[k], $, args, ctx>\n\t\t:\tdeclared[k]\n\t} & {\n\t\t[k in optionalKeyOf<declared> & string as declaredOptionalKeySuggestion<\n\t\t\tk,\n\t\t\tdef\n\t\t>]: declaredOptionalValueSuggestion<def, k, declared, $, args, ctx>\n\t}\n>\n\ntype declaredOptionalKeySuggestion<k extends string, def> =\n\tk extends keyof def ?\n\t\tdef[k] extends OptionalPropertyDefinition ?\n\t\t\tk\n\t\t:\t`${k}?`\n\t:\t`${k}?`\n\ntype declaredOptionalValueSuggestion<\n\tdef,\n\tk extends keyof declared & string,\n\tdeclared,\n\t$,\n\targs,\n\tctx extends DeclareContext\n> =\n\tk extends keyof def ?\n\t\tdef[k] extends OptionalPropertyDefinition ?\n\t\t\t// Required<declared>[k] ensures that we can distinguish { foo?: true } from { foo?: true | undefined }\n\t\t\tvalidateInference<def[k], Required<declared>[k], $, args, ctx>\n\t\t:\tdeclared[k]\n\t: `${k}?` extends keyof def ?\n\t\tvalidateInference<def[`${k}?`], Required<declared>[k], $, args, ctx>\n\t:\tdeclared[k]\n\ntype validateShallowInference<\n\tt,\n\tdeclared,\n\tctx extends DeclareContext,\n\tinferred = ctx[\"side\"] extends distill.Side ? distill<t, ctx[\"side\"]> : t\n> =\n\tequals<inferred, declared> extends true ? unknown\n\t:\tshow<declarationMismatch<inferred, declared>>\n\ntype declarationMismatch<inferred, declared> = ErrorType<{\n\tdeclared: declared\n\tinferred: inferred\n}>\n"
  },
  {
    "path": "ark/type/fn.ts",
    "content": "import type { BaseRoot, IntersectionNode } from \"@ark/schema\"\nimport {\n\tCallable,\n\tthrowParseError,\n\ttype applyElementLabels,\n\ttype conform,\n\ttype Fn,\n\ttype get\n} from \"@ark/util\"\nimport type { distill } from \"./attributes.ts\"\nimport type { type } from \"./keywords/keywords.ts\"\nimport type { validateInnerDefinition } from \"./parser/definition.ts\"\nimport type {\n\tinferTupleLiteral,\n\tvalidateTupleLiteral\n} from \"./parser/tupleLiteral.ts\"\nimport type { InternalScope, Scope } from \"./scope.ts\"\nimport type { Type } from \"./type.ts\"\n\nexport type BaseFnParser<$ = {}> = <\n\tconst args extends readonly unknown[],\n\tparamsT extends readonly unknown[] = inferTupleLiteral<\n\t\targs extends readonly [...infer params, \":\", unknown] ? params : args,\n\t\t$,\n\t\t{}\n\t>,\n\treturnT = args extends readonly [...unknown[], \":\", infer returnDef] ?\n\t\ttype.infer<returnDef, $>\n\t:\tunknown\n>(\n\t...args: {\n\t\t[i in keyof args]: conform<args[i], get<validateFnArgs<args, $>, i>>\n\t}\n) => <\n\tinternalSignature extends (\n\t\t...args: distill.Out<paramsT>\n\t) => distill.In<returnT>,\n\texternalSignature extends Fn = (\n\t\t...args: applyElementLabels<\n\t\t\tdistill.In<paramsT>,\n\t\t\tParameters<internalSignature>\n\t\t>\n\t) => args extends readonly [...unknown[], \":\", unknown] ? distill.Out<returnT>\n\t:\tReturnType<internalSignature>\n>(\n\timplementation: internalSignature\n) => TypedFn<\n\texternalSignature,\n\t$,\n\targs extends readonly [...unknown[], \":\", unknown] ? Return.introspectable\n\t:\t{}\n>\n\nexport interface FnParser<$ = {}> extends BaseFnParser<$> {\n\t/**\n\t * The {@link Scope} in which definitions passed to this function will be parsed.\n\t */\n\t$: Scope<$>\n\n\t/**\n\t * An alias of `fn` with no type-level validation or inference.\n\t *\n\t * Useful when wrapping `fn` or using it to parse a dynamic definition.\n\t */\n\traw: RawFnParser\n}\n\nexport type RawFnParser = (\n\t...args: unknown[]\n) => (...args: unknown[]) => unknown\n\ntype FnParserAttachments = Omit<FnParser, never>\n\nexport class InternalFnParser extends Callable<(...args: unknown[]) => Fn> {\n\tconstructor($: InternalScope) {\n\t\tconst attach: FnParserAttachments = {\n\t\t\t$: $ as never,\n\t\t\traw: $.fn\n\t\t}\n\n\t\tsuper(\n\t\t\t(...signature) => {\n\t\t\t\tconst returnOperatorIndex = signature.indexOf(\":\")\n\t\t\t\tconst lastParamIndex =\n\t\t\t\t\treturnOperatorIndex === -1 ?\n\t\t\t\t\t\tsignature.length - 1\n\t\t\t\t\t:\treturnOperatorIndex - 1\n\n\t\t\t\tconst paramDefs = signature.slice(0, lastParamIndex + 1)\n\n\t\t\t\tconst paramTuple = $.parse(paramDefs).assertHasKind(\"intersection\")\n\n\t\t\t\tlet returnType: BaseRoot = $.intrinsic.unknown\n\n\t\t\t\tif (returnOperatorIndex !== -1) {\n\t\t\t\t\tif (returnOperatorIndex !== signature.length - 2)\n\t\t\t\t\t\treturn throwParseError(badFnReturnTypeMessage)\n\t\t\t\t\treturnType = $.parse(signature[returnOperatorIndex + 1])\n\t\t\t\t}\n\n\t\t\t\treturn (impl: Fn) => new InternalTypedFn(impl, paramTuple, returnType)\n\t\t\t},\n\t\t\t{ attach }\n\t\t)\n\t}\n}\n\nexport declare namespace TypedFn {\n\texport type meta = {\n\t\tintrospectableReturn?: true\n\t}\n}\n\nexport interface TypedFn<\n\tsignature extends Fn = Fn,\n\t$ = {},\n\tmeta extends TypedFn.meta = {}\n> extends Callable<signature> {\n\texpression: string\n\tparams: signature extends Fn<infer params> ? Type<params, $> : never\n\treturns: Type<\n\t\tmeta extends Return.introspectable ? ReturnType<signature> : unknown,\n\t\t$\n\t>\n}\n\nexport class InternalTypedFn extends Callable<(...args: unknown[]) => unknown> {\n\traw: Fn\n\tparams: IntersectionNode\n\treturns: BaseRoot\n\texpression: string\n\n\tconstructor(raw: Fn, params: IntersectionNode, returns: BaseRoot) {\n\t\tconst typedName = `typed ${raw.name}`\n\t\tconst typed = {\n\t\t\t// assign to a key with the expected name to force it to be created that way\n\t\t\t[typedName]: (...args: unknown[]) => {\n\t\t\t\tconst validatedArgs = params.assert(args) as unknown[]\n\t\t\t\tconst returned = raw(...validatedArgs)\n\t\t\t\treturn returns.assert(returned)\n\t\t\t}\n\t\t}[typedName]\n\n\t\tsuper(typed)\n\t\tthis.raw = raw\n\t\tthis.params = params\n\t\tthis.returns = returns\n\n\t\tlet argsExpression = params.expression\n\t\tif (\n\t\t\targsExpression[0] === \"[\" &&\n\t\t\targsExpression[argsExpression.length - 1] === \"]\"\n\t\t)\n\t\t\targsExpression = argsExpression.slice(1, -1)\n\t\telse if (argsExpression.endsWith(\"[]\"))\n\t\t\targsExpression = `...${argsExpression}`\n\n\t\tthis.expression = `(${argsExpression}) => ${returns?.expression ?? \"unknown\"}`\n\t}\n}\n\nexport declare namespace Return {\n\texport interface introspectable {\n\t\tintrospectableReturn: true\n\t}\n}\n\ntype validateFnArgs<args, $> =\n\targs extends readonly unknown[] ?\n\t\targs extends readonly [...infer paramDefs, \":\", infer returnDef] ?\n\t\t\treadonly [\n\t\t\t\t...validateFnParamDefs<paramDefs, $>,\n\t\t\t\t\":\",\n\t\t\t\ttype.validate<returnDef, $>\n\t\t\t]\n\t\t:\tvalidateFnParamDefs<args, $>\n\t:\tnever\n\ntype validateFnParamDefs<paramDefs extends readonly unknown[], $> =\n\tparamDefs extends validateTupleLiteral<paramDefs, $, {}> ? paramDefs\n\t: paramDefs extends {\n\t\t[i in keyof paramDefs]: paramDefs[i] extends \"...\" ? paramDefs[i]\n\t\t:\tvalidateInnerDefinition<paramDefs[i], $, {}>\n\t} ?\n\t\tvalidateTupleLiteral<paramDefs, $, {}>\n\t:\t{ [i in keyof paramDefs]: validateInnerDefinition<paramDefs[i], $, {}> }\n\nexport const badFnReturnTypeMessage = `\":\" must be followed by exactly one return type e.g:\nfn(\"string\", \":\", \"number\")(s => s.length)`\n"
  },
  {
    "path": "ark/type/generic.ts",
    "content": "import {\n\tGenericRoot,\n\ttype arkKind,\n\ttype BaseParseContext,\n\ttype GenericAst,\n\ttype GenericParamAst,\n\ttype GenericParamDef,\n\ttype genericParamNames,\n\ttype LazyGenericBody\n} from \"@ark/schema\"\nimport {\n\tthrowParseError,\n\ttype array,\n\ttype Callable,\n\ttype conform,\n\ttype ErrorMessage,\n\ttype ErrorType,\n\ttype Hkt,\n\ttype JsonStructure,\n\ttype Scanner,\n\ttype WhitespaceChar\n} from \"@ark/util\"\nimport type { type } from \"./keywords/keywords.ts\"\nimport type { inferAstRoot } from \"./parser/ast/infer.ts\"\nimport type { validateAst } from \"./parser/ast/validate.ts\"\nimport type { inferDefinition } from \"./parser/definition.ts\"\nimport { RuntimeState } from \"./parser/reduce/dynamic.ts\"\nimport type { s, StaticState } from \"./parser/reduce/static.ts\"\nimport { terminatingChars } from \"./parser/shift/tokens.ts\"\nimport { parseUntilFinalizer } from \"./parser/string.ts\"\nimport type { Scope } from \"./scope.ts\"\nimport type { Type } from \"./type.ts\"\n\nexport type ParameterString<params extends string = string> = `<${params}>`\n\nexport type extractParams<s extends ParameterString> =\n\ts extends ParameterString<infer params> ? params : never\n\nexport type validateParameterString<s extends ParameterString, $> =\n\tparseGenericParams<extractParams<s>, $> extends infer e extends ErrorMessage ?\n\t\te\n\t:\ts\n\nexport type validateGenericArg<arg, param extends GenericParamAst, $> =\n\ttype.infer<arg, $> extends param[1] ? unknown\n\t:\tErrorType<[`Invalid argument for ${param[0]}`, expected: param[1]]>\n\nexport type GenericInstantiator<\n\tparams extends array<GenericParamAst>,\n\tdef,\n\t$,\n\targs$\n> =\n\tparams[\"length\"] extends 1 ?\n\t\t{\n\t\t\t// precomputing the results as default parameters is more efficient\n\t\t\t// here than inferring them into aliases conditionally as we do in\n\t\t\t// some of type's methods\n\t\t\t<const a, r = instantiateGeneric<def, params, [a], $, args$>>(\n\t\t\t\ta: type.validate<a, args$> & validateGenericArg<a, params[0], args$>\n\t\t\t): r extends infer _ ? _ : never\n\t\t}\n\t: params[\"length\"] extends 2 ?\n\t\t{\n\t\t\t<const a, const b, r = instantiateGeneric<def, params, [a, b], $, args$>>(\n\t\t\t\t...args: [\n\t\t\t\t\ttype.validate<a, args$> & validateGenericArg<a, params[0], args$>,\n\t\t\t\t\ttype.validate<b, args$> & validateGenericArg<b, params[1], args$>\n\t\t\t\t]\n\t\t\t): r extends infer _ ? _ : never\n\t\t}\n\t: params[\"length\"] extends 3 ?\n\t\t{\n\t\t\t<\n\t\t\t\tconst a,\n\t\t\t\tconst b,\n\t\t\t\tconst c,\n\t\t\t\tr = instantiateGeneric<def, params, [a, b, c], $, args$>\n\t\t\t>(\n\t\t\t\t...args: [\n\t\t\t\t\ttype.validate<a, args$> & validateGenericArg<a, params[0], args$>,\n\t\t\t\t\ttype.validate<b, args$> & validateGenericArg<b, params[1], args$>,\n\t\t\t\t\ttype.validate<c, args$> & validateGenericArg<c, params[2], args$>\n\t\t\t\t]\n\t\t\t): r extends infer _ ? _ : never\n\t\t}\n\t: params[\"length\"] extends 4 ?\n\t\t{\n\t\t\t<\n\t\t\t\tconst a,\n\t\t\t\tconst b,\n\t\t\t\tconst c,\n\t\t\t\tconst d,\n\t\t\t\tr = instantiateGeneric<def, params, [a, b, c, d], $, args$>\n\t\t\t>(\n\t\t\t\t...args: [\n\t\t\t\t\ttype.validate<a, args$> & validateGenericArg<a, params[0], args$>,\n\t\t\t\t\ttype.validate<b, args$> & validateGenericArg<b, params[1], args$>,\n\t\t\t\t\ttype.validate<c, args$> & validateGenericArg<c, params[2], args$>,\n\t\t\t\t\ttype.validate<d, args$> & validateGenericArg<d, params[3], args$>\n\t\t\t\t]\n\t\t\t): r extends infer _ ? _ : never\n\t\t}\n\t: params[\"length\"] extends 5 ?\n\t\t{\n\t\t\t<\n\t\t\t\tconst a,\n\t\t\t\tconst b,\n\t\t\t\tconst c,\n\t\t\t\tconst d,\n\t\t\t\tconst e,\n\t\t\t\tr = instantiateGeneric<def, params, [a, b, c, d, e], $, args$>\n\t\t\t>(\n\t\t\t\t...args: [\n\t\t\t\t\ttype.validate<a, args$> & validateGenericArg<a, params[0], args$>,\n\t\t\t\t\ttype.validate<b, args$> & validateGenericArg<b, params[1], args$>,\n\t\t\t\t\ttype.validate<c, args$> & validateGenericArg<c, params[2], args$>,\n\t\t\t\t\ttype.validate<d, args$> & validateGenericArg<d, params[3], args$>,\n\t\t\t\t\ttype.validate<e, args$> & validateGenericArg<e, params[4], args$>\n\t\t\t\t]\n\t\t\t): r extends infer _ ? _ : never\n\t\t}\n\t: params[\"length\"] extends 6 ?\n\t\t{\n\t\t\t<\n\t\t\t\tconst a,\n\t\t\t\tconst b,\n\t\t\t\tconst c,\n\t\t\t\tconst d,\n\t\t\t\tconst e,\n\t\t\t\tconst f,\n\t\t\t\tr = instantiateGeneric<def, params, [a, b, c, d, e, f], $, args$>\n\t\t\t>(\n\t\t\t\t...args: [\n\t\t\t\t\ttype.validate<a, args$> & validateGenericArg<a, params[0], args$>,\n\t\t\t\t\ttype.validate<b, args$> & validateGenericArg<b, params[1], args$>,\n\t\t\t\t\ttype.validate<c, args$> & validateGenericArg<c, params[2], args$>,\n\t\t\t\t\ttype.validate<d, args$> & validateGenericArg<d, params[3], args$>,\n\t\t\t\t\ttype.validate<e, args$> & validateGenericArg<e, params[4], args$>,\n\t\t\t\t\ttype.validate<f, args$> & validateGenericArg<f, params[5], args$>\n\t\t\t\t]\n\t\t\t): r extends infer _ ? _ : never\n\t\t}\n\t:\t(\n\t\t\terror: ErrorMessage<`You may not define more than 6 positional generic parameters`>\n\t\t) => never\n\ntype instantiateGeneric<\n\tdef,\n\tparams extends array<GenericParamAst>,\n\targs,\n\t$,\n\targs$\n> = Type<\n\t[def] extends [Hkt] ?\n\t\tHkt.apply<def, { [i in keyof args]: type.infer<args[i], args$> }>\n\t:\tinferDefinition<def, $, bindGenericArgs<params, args$, args>>,\n\targs$\n>\n\ntype bindGenericArgs<params extends array<GenericParamAst>, $, args> = {\n\t[i in keyof params & `${number}` as params[i][0]]: type.infer<\n\t\targs[i & keyof args],\n\t\t$\n\t>\n}\n\ntype baseGenericResolutions<params extends array<GenericParamAst>, $> =\n\tbaseGenericConstraints<params> extends infer baseConstraints ?\n\t\t{ [k in keyof baseConstraints]: Type<baseConstraints[k], $> }\n\t:\tnever\n\nexport type baseGenericConstraints<params extends array<GenericParamAst>> = {\n\t[i in keyof params & `${number}` as params[i][0]]: params[i][1]\n}\n\nexport interface Generic<\n\tparams extends array<GenericParamAst> = array<GenericParamAst>,\n\tbodyDef = unknown,\n\t$ = {},\n\targ$ = $\n> extends Callable<GenericInstantiator<params, bodyDef, $, arg$>> {\n\t[arkKind]: \"generic\"\n\tt: GenericAst<params, bodyDef, $, arg$>\n\n\tbodyDef: bodyDef\n\tparams: { [i in keyof params]: [params[i][0], Type<params[i][1], $>] }\n\tnames: genericParamNames<params>\n\tconstraints: { [i in keyof params]: Type<params[i][1], $> }\n\n\t$: Scope<$>\n\targ$: Scope<arg$>\n\n\tinternal: GenericRoot\n\tjson: JsonStructure\n}\n\nexport type GenericConstructor<\n\tparams extends array<GenericParamAst> = array<GenericParamAst>,\n\tbodyDef = unknown,\n\t$ = {},\n\targ$ = {}\n> = new () => Generic<params, bodyDef, $, arg$>\n\nexport const Generic: GenericConstructor = GenericRoot as never\n\nexport type GenericDeclaration<\n\tname extends string = string,\n\tparams extends ParameterString = ParameterString\n> = `${name}${params}`\n\nexport type parseValidGenericParams<def extends ParameterString, $> = conform<\n\tparseGenericParams<extractParams<def>, $>,\n\tarray<GenericParamAst>\n>\n\nexport const emptyGenericParameterMessage =\n\t\"An empty string is not a valid generic parameter name\"\n\nexport type emptyGenericParameterMessage = typeof emptyGenericParameterMessage\n\nexport type parseGenericParams<def extends string, $> = parseNextNameChar<\n\tScanner.skipWhitespace<def>,\n\t\"\",\n\t[],\n\t$\n>\n\ntype ParamsTerminator = WhitespaceChar | \",\"\n\nexport const parseGenericParamName = (\n\tscanner: Scanner,\n\tresult: GenericParamDef[],\n\tctx: BaseParseContext\n): GenericParamDef[] => {\n\tscanner.shiftUntilNonWhitespace()\n\tconst name = scanner.shiftUntilLookahead(terminatingChars)\n\tif (name === \"\") {\n\t\t// if we've reached the end of the string and have parsed at least one\n\t\t// param, return the valid result\n\t\tif (scanner.lookahead === \"\" && result.length) return result\n\t\treturn throwParseError(emptyGenericParameterMessage)\n\t}\n\n\tscanner.shiftUntilNonWhitespace()\n\n\treturn _parseOptionalConstraint(scanner, name, result, ctx)\n}\n\ntype parseName<\n\tunscanned extends string,\n\tresult extends array<GenericParamAst>,\n\t$\n> = parseNextNameChar<Scanner.skipWhitespace<unscanned>, \"\", result, $>\n\ntype parseNextNameChar<\n\tunscanned extends string,\n\tname extends string,\n\tresult extends array<GenericParamAst>,\n\t$\n> =\n\tunscanned extends `${infer lookahead}${infer nextUnscanned}` ?\n\t\tlookahead extends ParamsTerminator ?\n\t\t\tname extends \"\" ? ErrorMessage<emptyGenericParameterMessage>\n\t\t\t: lookahead extends \",\" ?\n\t\t\t\tparseName<nextUnscanned, [...result, [name, unknown]], $>\n\t\t\t: lookahead extends WhitespaceChar ?\n\t\t\t\t_parseOptionalConstraint<nextUnscanned, name, result, $>\n\t\t\t:\tnever\n\t\t:\tparseNextNameChar<nextUnscanned, `${name}${lookahead}`, result, $>\n\t: name extends \"\" ? result\n\t: [...result, [name, unknown]]\n\nconst extendsToken = \"extends \"\n\ntype extendsToken = typeof extendsToken\n\nconst _parseOptionalConstraint = (\n\tscanner: Scanner,\n\tname: string,\n\tresult: GenericParamDef[],\n\tctx: BaseParseContext\n): GenericParamDef[] => {\n\tscanner.shiftUntilNonWhitespace()\n\tif (scanner.unscanned.startsWith(extendsToken))\n\t\tscanner.jumpForward(extendsToken.length)\n\telse {\n\t\t// if we don't have a contraining token here, return now so we can\n\t\t// assume in the rest of the function body we do have a constraint\n\t\tif (scanner.lookahead === \",\") scanner.shift()\n\t\tresult.push(name)\n\t\treturn parseGenericParamName(scanner, result, ctx)\n\t}\n\n\tconst s = parseUntilFinalizer(new RuntimeState(scanner, ctx))\n\tresult.push([name, s.root])\n\n\treturn parseGenericParamName(scanner, result, ctx)\n}\n\ntype _parseOptionalConstraint<\n\tunscanned extends string,\n\tname extends string,\n\tresult extends array<GenericParamAst>,\n\t$\n> =\n\tScanner.skipWhitespace<unscanned> extends (\n\t\t`${extendsToken}${infer nextUnscanned}`\n\t) ?\n\t\tparseUntilFinalizer<s.initialize<nextUnscanned>, $, {}> extends (\n\t\t\tinfer finalArgState extends StaticState\n\t\t) ?\n\t\t\tvalidateAst<finalArgState[\"root\"], $, {}> extends (\n\t\t\t\tinfer e extends ErrorMessage\n\t\t\t) ?\n\t\t\t\te\n\t\t\t:\tparseName<\n\t\t\t\t\tfinalArgState[\"unscanned\"],\n\t\t\t\t\t[...result, [name, inferAstRoot<finalArgState[\"root\"], $, {}>]],\n\t\t\t\t\t$\n\t\t\t\t>\n\t\t:\tnever\n\t:\tparseName<\n\t\t\tScanner.skipWhitespace<unscanned> extends `,${infer nextUnscanned}` ?\n\t\t\t\tnextUnscanned\n\t\t\t:\tunscanned,\n\t\t\t[...result, [name, unknown]],\n\t\t\t$\n\t\t>\n\ntype genericParamDefToAst<schema extends GenericParamDef, $> =\n\tschema extends string ? [schema, unknown]\n\t: schema extends readonly [infer name, infer def] ? [name, type.infer<def, $>]\n\t: never\n\nexport type genericParamDefsToAst<defs extends array<GenericParamDef>, $> = [\n\t...{ [i in keyof defs]: genericParamDefToAst<defs[i], $> }\n]\n\nexport type GenericParser<$ = {}> = <\n\tconst paramsDef extends array<GenericParamDef>\n>(\n\t...params: {\n\t\t[i in keyof paramsDef]: paramsDef[i] extends (\n\t\t\treadonly [infer name, infer def]\n\t\t) ?\n\t\t\treadonly [name, type.validate<def, $>]\n\t\t:\t// if the param  is only a name, no validation is required\n\t\t\tparamsDef[i]\n\t}\n) => GenericBodyParser<genericParamDefsToAst<paramsDef, $>, $>\n\ninterface GenericBodyParser<params extends array<GenericParamAst>, $> {\n\t<const body>(\n\t\tbody: type.validate<body, $, baseGenericConstraints<params>>\n\t): Generic<params, body, $, $>\n\n\t<hkt extends Hkt.constructor>(\n\t\tinstantiateDef: LazyGenericBody<baseGenericResolutions<params, $>>,\n\t\thkt: hkt\n\t): Generic<params, InstanceType<hkt>, $, $>\n}\n"
  },
  {
    "path": "ark/type/index.ts",
    "content": "export {\n\tArkError,\n\tArkErrors,\n\tTraversal,\n\tTraversalError,\n\ttype ArkSchemaConfig,\n\ttype ArkSchemaScopeConfig,\n\ttype JsonSchema\n} from \"@ark/schema\"\nexport { Hkt, inferred, ParseError } from \"@ark/util\"\nexport { regex } from \"arkregex\"\nexport type { distill, Out } from \"./attributes.ts\"\nexport * from \"./config.ts\"\nexport { Generic } from \"./generic.ts\"\nexport {\n\tark,\n\tdeclare,\n\tdefine,\n\tfn,\n\tgeneric,\n\tkeywords,\n\tmatch,\n\ttype,\n\ttype Ark\n} from \"./keywords/keywords.ts\"\nexport { Module, type BoundModule, type Submodule } from \"./module.ts\"\nexport type {\n\tinferDefinition,\n\tvalidateDefinition\n} from \"./parser/definition.ts\"\nexport { scope, type bindThis, type Scope } from \"./scope.ts\"\nexport { Type } from \"./type.ts\"\nexport type { BaseType } from \"./variants/base.ts\"\n"
  },
  {
    "path": "ark/type/keywords/Array.ts",
    "content": "import { genericNode, intrinsic, rootSchema } from \"@ark/schema\"\nimport { Hkt, liftArray, type Digit } from \"@ark/util\"\nimport type { To } from \"../attributes.ts\"\nimport type { Module, Submodule } from \"../module.ts\"\nimport { Scope } from \"../scope.ts\"\n\nclass liftFromHkt extends Hkt<[element: unknown]> {\n\tdeclare body: liftArray<this[0]> extends infer lifted ?\n\t\t(In: this[0] | lifted) => To<lifted>\n\t:\tnever\n}\n\nconst liftFrom = genericNode(\"element\")(args => {\n\tconst nonArrayElement = args.element.exclude(intrinsic.Array)\n\tconst lifted = nonArrayElement.array()\n\treturn nonArrayElement\n\t\t.rawOr(lifted)\n\t\t.pipe(liftArray)\n\t\t.distribute(\n\t\t\tbranch => branch.assertHasKind(\"morph\").declareOut(lifted),\n\t\t\trootSchema\n\t\t)\n}, liftFromHkt)\n\nexport const arkArray: arkArray.module = Scope.module(\n\t{\n\t\troot: intrinsic.Array,\n\t\treadonly: \"root\",\n\t\tindex: intrinsic.nonNegativeIntegerString,\n\t\tliftFrom\n\t},\n\t{\n\t\tname: \"Array\"\n\t}\n) as never\n\nexport declare namespace arkArray {\n\texport type module = Module<submodule>\n\n\texport type submodule = Submodule<$>\n\n\texport type $ = {\n\t\troot: unknown[]\n\t\treadonly: readonly unknown[]\n\t\tindex: NonNegativeIntegerString\n\t\tliftFrom: typeof liftFrom.t\n\t}\n}\n\nexport type NonNegativeIntegerString =\n\t| `${Digit}`\n\t| (`${Exclude<Digit, 0>}${string}` & `${bigint}`)\n"
  },
  {
    "path": "ark/type/keywords/FormData.ts",
    "content": "import { rootSchema } from \"@ark/schema\"\nimport { registry } from \"@ark/util\"\nimport type { To } from \"../attributes.ts\"\nimport type { Module, Submodule } from \"../module.ts\"\nimport { Scope } from \"../scope.ts\"\n\nexport type FormDataValue = string | File\n\nexport type ParsedFormData = Record<string, FormDataValue | FormDataValue[]>\n\nconst value = rootSchema([\"string\", registry.FileConstructor])\n\nconst parsedFormDataValue = value.rawOr(value.array())\n\nconst parsed = rootSchema({\n\tmeta: \"an object representing parsed form data\",\n\tdomain: \"object\",\n\tindex: {\n\t\tsignature: \"string\",\n\t\tvalue: parsedFormDataValue\n\t}\n})\n\nexport const arkFormData: arkFormData.module = Scope.module(\n\t{\n\t\troot: [\"instanceof\", FormData],\n\t\tvalue,\n\t\tparsed,\n\t\tparse: rootSchema({\n\t\t\tin: FormData,\n\t\t\tmorphs: (data: FormData): ParsedFormData => {\n\t\t\t\tconst result: ParsedFormData = {}\n\n\t\t\t\t// no cast is actually required here, but with\n\t\t\t\t// typescript.tsserver.experimental.enableProjectDiagnostics: true\n\t\t\t\t// this file periodically displays as having an error, likely due to the\n\t\t\t\t// lack of a `File` type.\n\t\t\t\ttype FormDataEntries = [string, FormDataValue][]\n\t\t\t\tfor (const [k, v] of data as {} as FormDataEntries) {\n\t\t\t\t\tif (k in result) {\n\t\t\t\t\t\tconst existing = result[k]\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\ttypeof existing === \"string\" ||\n\t\t\t\t\t\t\texisting instanceof registry.FileConstructor\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\tresult[k] = [existing, v]\n\t\t\t\t\t\telse existing.push(v)\n\t\t\t\t\t} else result[k] = v\n\t\t\t\t}\n\t\t\t\treturn result\n\t\t\t},\n\t\t\tdeclaredOut: parsed\n\t\t})\n\t},\n\t{\n\t\tname: \"FormData\"\n\t}\n) as never\n\nexport declare namespace arkFormData {\n\texport type module = Module<submodule>\n\n\texport type submodule = Submodule<$>\n\n\texport type $ = {\n\t\troot: FormData\n\t\tvalue: FormDataValue\n\t\tparse: (In: FormData) => To<ParsedFormData>\n\t\tparsed: ParsedFormData\n\t}\n}\n"
  },
  {
    "path": "ark/type/keywords/TypedArray.ts",
    "content": "import type { Module, Submodule } from \"../module.ts\"\nimport { Scope } from \"../scope.ts\"\n\nexport const TypedArray: TypedArray.module = Scope.module(\n\t{\n\t\tInt8: [\"instanceof\", Int8Array],\n\t\tUint8: [\"instanceof\", Uint8Array],\n\t\tUint8Clamped: [\"instanceof\", Uint8ClampedArray],\n\t\tInt16: [\"instanceof\", Int16Array],\n\t\tUint16: [\"instanceof\", Uint16Array],\n\t\tInt32: [\"instanceof\", Int32Array],\n\t\tUint32: [\"instanceof\", Uint32Array],\n\t\tFloat32: [\"instanceof\", Float32Array],\n\t\tFloat64: [\"instanceof\", Float64Array],\n\t\tBigInt64: [\"instanceof\", BigInt64Array],\n\t\tBigUint64: [\"instanceof\", BigUint64Array]\n\t},\n\t{\n\t\tname: \"TypedArray\"\n\t}\n) as never\n\nexport declare namespace TypedArray {\n\texport type module = Module<TypedArray.$>\n\n\t// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray\n\texport type submodule = Submodule<$>\n\n\texport type $ = {\n\t\tInt8: Int8Array\n\t\tUint8: Uint8Array\n\t\tUint8Clamped: Uint8ClampedArray\n\t\tInt16: Int16Array\n\t\tUint16: Uint16Array\n\t\tInt32: Int32Array\n\t\tUint32: Uint32Array\n\t\tFloat32: Float32Array\n\t\tFloat64: Float64Array\n\t\tBigInt64: BigInt64Array\n\t\tBigUint64: BigUint64Array\n\t}\n}\n"
  },
  {
    "path": "ark/type/keywords/builtins.ts",
    "content": "import { genericNode, intrinsic } from \"@ark/schema\"\nimport type * as util from \"@ark/util\"\nimport { Hkt, type Key } from \"@ark/util\"\nimport type { Module, Submodule } from \"../module.ts\"\nimport { Scope } from \"../scope.ts\"\n\nclass MergeHkt extends Hkt<[base: object, props: object]> {\n\tdeclare body: util.merge<this[0], this[1]>\n\n\tdescription =\n\t\t'merge an object\\'s properties onto another like `Merge(User, { isAdmin: \"true\" })`'\n}\n\nconst Merge = genericNode(\n\t[\"base\", intrinsic.object],\n\t[\"props\", intrinsic.object]\n)(args => args.base.merge(args.props), MergeHkt)\n\nexport const arkBuiltins: arkBuiltins = Scope.module({\n\tKey: intrinsic.key,\n\tMerge\n}) as never\n\nexport type arkBuiltins = Module<arkBuiltins.$>\n\nexport declare namespace arkBuiltins {\n\texport type submodule = Submodule<$>\n\n\texport type $ = {\n\t\tKey: Key\n\t\tMerge: typeof Merge.t\n\t}\n}\n"
  },
  {
    "path": "ark/type/keywords/constructors.ts",
    "content": "import {\n\tecmascriptConstructors,\n\tflatMorph,\n\tplatformConstructors,\n\ttype EcmascriptObjects,\n\ttype KeySet,\n\ttype PlatformObjects\n} from \"@ark/util\"\nimport type { Module, Submodule } from \"../module.ts\"\nimport { Scope } from \"../scope.ts\"\nimport { arkArray } from \"./Array.ts\"\nimport { arkFormData } from \"./FormData.ts\"\nimport { TypedArray } from \"./TypedArray.ts\"\n\nconst omittedPrototypes = {\n\tBoolean: 1,\n\tNumber: 1,\n\tString: 1\n} satisfies KeySet<keyof EcmascriptObjects>\n\nexport const arkPrototypes: arkPrototypes.module = Scope.module({\n\t...flatMorph(\n\t\t{ ...ecmascriptConstructors, ...platformConstructors },\n\t\t(k, v) => (k in omittedPrototypes ? [] : ([k, [\"instanceof\", v]] as const))\n\t),\n\tArray: arkArray,\n\tTypedArray,\n\tFormData: arkFormData\n}) as never\n\nexport declare namespace arkPrototypes {\n\texport type module = Module<submodule>\n\n\texport type submodule = Submodule<$>\n\n\texport interface keywords extends ecmascript, platform {}\n\n\tinterface $ extends Omit<keywords, keyof wrapped>, wrapped {}\n\n\texport interface wrapped {\n\t\tArray: arkArray.submodule\n\t\tTypedArray: TypedArray.submodule\n\t\tFormData: arkFormData.submodule\n\t}\n\n\texport type ecmascript = Omit<\n\t\tEcmascriptObjects,\n\t\tkeyof typeof omittedPrototypes\n\t>\n\n\texport type platform = PlatformObjects\n\n\texport interface instances extends ecmascript, platform {}\n\n\t// avoid bad prototypes polluting inference:\n\t// https://github.com/arktypeio/arktype/issues/1399\n\texport type NonDegenerateName =\n\t\tkeyof instances extends infer k ?\n\t\t\tk extends keyof instances ?\n\t\t\t\t{} extends instances[k] ?\n\t\t\t\t\tnever\n\t\t\t\t:\tk\n\t\t\t:\tnever\n\t\t:\tnever\n\n\texport type instanceOf<name extends NonDegenerateName = NonDegenerateName> =\n\t\tinstances[name]\n}\n"
  },
  {
    "path": "ark/type/keywords/keywords.ts",
    "content": "import type { ArkErrors, arkKind, flatResolutionsOf } from \"@ark/schema\"\nimport type { Brand, inferred } from \"@ark/util\"\nimport type { distill, InferredMorph, Out, To } from \"../attributes.ts\"\nimport type { DeclarationParser } from \"../declare.ts\"\nimport type { FnParser } from \"../fn.ts\"\nimport type { GenericParser } from \"../generic.ts\"\nimport type { MatchParser } from \"../match.ts\"\nimport type { BoundModule, Module } from \"../module.ts\"\nimport type {\n\tinferDefinition,\n\tvalidateDefinition\n} from \"../parser/definition.ts\"\nimport { $arkTypeRegistry, scope, type bindThis, type Scope } from \"../scope.ts\"\nimport type {\n\tDefinitionParser,\n\tSchemaParser,\n\tType,\n\tTypeParser\n} from \"../type.ts\"\nimport type { BaseType } from \"../variants/base.ts\"\nimport type { instantiateType } from \"../variants/instantiate.ts\"\nimport { arkBuiltins } from \"./builtins.ts\"\nimport { arkPrototypes } from \"./constructors.ts\"\nimport { number } from \"./number.ts\"\nimport { string } from \"./string.ts\"\nimport { arkTsGenerics, arkTsKeywords, object, unknown } from \"./ts.ts\"\n\nexport interface Ark\n\textends Omit<Ark.keywords, keyof Ark.wrapped>,\n\t\tArk.wrapped {}\n\nexport declare namespace Ark {\n\texport interface keywords\n\t\textends arkTsKeywords.$,\n\t\t\tarkTsGenerics.$,\n\t\t\t// don't include TypedArray since it is only a Module\n\t\t\tarkPrototypes.keywords,\n\t\t\tarkBuiltins.$ {}\n\n\texport interface wrapped extends arkPrototypes.wrapped {\n\t\tstring: string.submodule\n\t\tnumber: number.submodule\n\t\tobject: object.submodule\n\t\tunknown: unknown.submodule\n\t}\n\n\texport type flat = flatResolutionsOf<Ark>\n\n\texport interface typeAttachments extends arkTsKeywords.$ {\n\t\tarrayIndex: arkPrototypes.$[\"Array\"][\"index\"]\n\t\tKey: arkBuiltins.$[\"Key\"]\n\t\tRecord: arkTsGenerics.$[\"Record\"]\n\t\tDate: arkPrototypes.$[\"Date\"]\n\t\tArray: arkPrototypes.$[\"Array\"][\"root\"]\n\t}\n\n\texport interface boundTypeAttachments<$>\n\t\textends Omit<BoundModule<typeAttachments, $>, arkKind> {}\n}\n\nexport const ark: Scope<Ark> = scope(\n\t{\n\t\t...arkTsKeywords,\n\t\t...arkTsGenerics,\n\t\t...arkPrototypes,\n\t\t...arkBuiltins,\n\t\tstring,\n\t\tnumber,\n\t\tobject,\n\t\tunknown\n\t},\n\t{ prereducedAliases: true, name: \"ark\" }\n) as never\n\nexport const keywords: Module<Ark> = ark.export()\n\nObject.assign($arkTypeRegistry.ambient, keywords)\n\n$arkTypeRegistry.typeAttachments = {\n\tstring: keywords.string.root,\n\tnumber: keywords.number.root,\n\tbigint: keywords.bigint,\n\tboolean: keywords.boolean,\n\tsymbol: keywords.symbol,\n\tundefined: keywords.undefined,\n\tnull: keywords.null,\n\tobject: keywords.object.root,\n\tunknown: keywords.unknown.root,\n\tfalse: keywords.false,\n\ttrue: keywords.true,\n\tnever: keywords.never,\n\tarrayIndex: keywords.Array.index,\n\tKey: keywords.Key,\n\tRecord: keywords.Record,\n\tArray: keywords.Array.root,\n\tDate: keywords.Date\n}\n\nexport const type: TypeParser<{}> = Object.assign(\n\tark.type,\n\t// assign attachments newly parsed in keywords\n\t// future scopes add these directly from the\n\t// registry when their TypeParsers are instantiated\n\t$arkTypeRegistry.typeAttachments\n) as never\n\nexport declare namespace type {\n\texport interface cast<to> {\n\t\t[inferred]?: to\n\t}\n\n\texport type errors = ArkErrors\n\n\texport type validate<def, $ = {}, args = bindThis<def>> = validateDefinition<\n\t\tdef,\n\t\t$,\n\t\targs\n\t>\n\n\texport type instantiate<def, $ = {}, args = bindThis<def>> = instantiateType<\n\t\tinferDefinition<def, $, args>,\n\t\t$\n\t>\n\n\texport type infer<def, $ = {}, args = bindThis<def>> = inferDefinition<\n\t\tdef,\n\t\t$,\n\t\targs\n\t>\n\n\texport namespace infer {\n\t\texport type In<def, $ = {}, args = {}> = distill.In<\n\t\t\tinferDefinition<def, $, args>\n\t\t>\n\n\t\texport type Out<def, $ = {}, args = {}> = distill.Out<\n\t\t\tinferDefinition<def, $, args>\n\t\t>\n\n\t\texport namespace introspectable {\n\t\t\texport type Out<def, $ = {}, args = {}> = distill.introspectable.Out<\n\t\t\t\tinferDefinition<def, $, args>\n\t\t\t>\n\t\t}\n\t}\n\n\texport type brand<t, id> =\n\t\tt extends InferredMorph<infer i, infer o> ?\n\t\t\to[\"introspectable\"] extends true ?\n\t\t\t\t(In: i) => To<Brand<o[\"t\"], id>>\n\t\t\t:\t(In: i) => Out<Brand<o[\"t\"], id>>\n\t\t:\tBrand<t, id>\n\n\t/** @ts-ignore cast variance */\n\texport interface Any<out t = any, $ = any> extends BaseType<t, $> {}\n}\n\nexport type type<t = unknown, $ = {}> = Type<t, $>\n\nexport const match: MatchParser<{}> = ark.match as never\n\nexport const fn: FnParser<{}> = ark.fn as never\n\nexport const generic: GenericParser<{}> = ark.generic as never\n\nexport const schema: SchemaParser<{}> = ark.schema as never\n\nexport const define: DefinitionParser<{}> = ark.define as never\n\nexport const declare: DeclarationParser<{}> = ark.declare as never\n"
  },
  {
    "path": "ark/type/keywords/number.ts",
    "content": "import { intrinsic, rootSchema } from \"@ark/schema\"\nimport type { Module, Submodule } from \"../module.ts\"\nimport { Scope } from \"../scope.ts\"\n\n/**\n * As per the ECMA-262 specification:\n * A time value supports a slightly smaller range of -8,640,000,000,000,000 to 8,640,000,000,000,000 milliseconds.\n *\n * @see https://262.ecma-international.org/15.0/index.html#sec-time-values-and-time-range\n */\n\nexport const epoch = rootSchema({\n\tdomain: {\n\t\tdomain: \"number\",\n\t\tmeta: \"a number representing a Unix timestamp\"\n\t},\n\tdivisor: {\n\t\trule: 1,\n\t\tmeta: `an integer representing a Unix timestamp`\n\t},\n\tmin: {\n\t\trule: -8640000000000000,\n\t\tmeta: `a Unix timestamp after -8640000000000000`\n\t},\n\tmax: {\n\t\trule: 8640000000000000,\n\t\tmeta: \"a Unix timestamp before 8640000000000000\"\n\t},\n\tmeta: \"an integer representing a safe Unix timestamp\"\n})\n\nexport const integer = rootSchema({\n\tdomain: \"number\",\n\tdivisor: 1\n})\n\nexport const number: number.module = Scope.module(\n\t{\n\t\troot: intrinsic.number,\n\t\tinteger,\n\t\tepoch,\n\t\tsafe: rootSchema({\n\t\t\tdomain: {\n\t\t\t\tdomain: \"number\",\n\t\t\t\tnumberAllowsNaN: false\n\t\t\t},\n\t\t\tmin: Number.MIN_SAFE_INTEGER,\n\t\t\tmax: Number.MAX_SAFE_INTEGER\n\t\t}),\n\t\tNaN: [\"===\", Number.NaN],\n\t\tInfinity: [\"===\", Number.POSITIVE_INFINITY],\n\t\tNegativeInfinity: [\"===\", Number.NEGATIVE_INFINITY]\n\t},\n\t{\n\t\tname: \"number\"\n\t}\n) as never\n\nexport declare namespace number {\n\texport type module = Module<submodule>\n\n\texport type submodule = Submodule<$>\n\n\texport type $ = {\n\t\troot: number\n\t\tepoch: number\n\t\tinteger: number\n\t\tsafe: number\n\t\tNaN: number\n\t\tInfinity: number\n\t\tNegativeInfinity: number\n\t}\n}\n"
  },
  {
    "path": "ark/type/keywords/string.ts",
    "content": "import {\n\tArkErrors,\n\tintrinsic,\n\tnode,\n\trootSchema,\n\ttype Intersection,\n\ttype JsonSchema,\n\ttype Morph,\n\ttype mutableNormalizedRootOfKind,\n\ttype Traversal\n} from \"@ark/schema\"\nimport {\n\tflatMorph,\n\tnumericStringMatcher,\n\twellFormedIntegerMatcher,\n\ttype Json\n} from \"@ark/util\"\nimport type { To } from \"../attributes.ts\"\nimport type { Module, Submodule } from \"../module.ts\"\nimport { Scope } from \"../scope.ts\"\nimport { number } from \"./number.ts\"\n\n// non-trivial expressions should have an explanation or attribution\n\nexport const regexStringNode = (\n\tregex: RegExp,\n\tdescription: string,\n\tjsonSchemaFormat?: JsonSchema.Format\n): Intersection.Node => {\n\tconst schema: mutableNormalizedRootOfKind<\"intersection\"> = {\n\t\tdomain: \"string\",\n\t\tpattern: {\n\t\t\trule: regex.source,\n\t\t\tflags: regex.flags,\n\t\t\tmeta: description\n\t\t}\n\t}\n\n\tif (jsonSchemaFormat) schema.meta = { format: jsonSchemaFormat }\n\n\treturn node(\"intersection\", schema) as never\n}\n\nconst stringIntegerRoot = regexStringNode(\n\twellFormedIntegerMatcher,\n\t\"a well-formed integer string\"\n)\n\nexport const stringInteger: stringInteger.module = Scope.module(\n\t{\n\t\troot: stringIntegerRoot,\n\t\tparse: rootSchema({\n\t\t\tin: stringIntegerRoot,\n\t\t\tmorphs: (s: string, ctx: Traversal) => {\n\t\t\t\tconst parsed = Number.parseInt(s)\n\t\t\t\treturn Number.isSafeInteger(parsed) ? parsed : (\n\t\t\t\t\t\tctx.error(\n\t\t\t\t\t\t\t\"an integer in the range Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER\"\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t},\n\t\t\tdeclaredOut: intrinsic.integer\n\t\t})\n\t},\n\t{\n\t\tname: \"string.integer\"\n\t}\n) as never\n\nexport declare namespace stringInteger {\n\texport type module = Module<submodule>\n\n\texport type submodule = Submodule<$>\n\n\texport type $ = {\n\t\troot: string\n\t\tparse: (In: string) => To<number>\n\t}\n}\n\nconst hex = regexStringNode(/^[\\dA-Fa-f]+$/, \"hex characters only\")\n\nconst base64 = Scope.module(\n\t{\n\t\troot: regexStringNode(\n\t\t\t/^(?:[\\d+/A-Za-z]{4})*(?:[\\d+/A-Za-z]{2}==|[\\d+/A-Za-z]{3}=)?$/,\n\t\t\t\"base64-encoded\"\n\t\t),\n\t\turl: regexStringNode(\n\t\t\t/^(?:[\\w-]{4})*(?:[\\w-]{2}(?:==|%3D%3D)?|[\\w-]{3}(?:=|%3D)?)?$/,\n\t\t\t\"base64url-encoded\"\n\t\t)\n\t},\n\t{\n\t\tname: \"string.base64\"\n\t}\n)\n\ndeclare namespace base64 {\n\texport type module = Module<submodule>\n\n\texport type submodule = Submodule<$>\n\n\texport type $ = {\n\t\troot: string\n\t\turl: string\n\t}\n}\n\nconst preformattedCapitalize = regexStringNode(/^[A-Z].*$/, \"capitalized\")\n\nexport const capitalize: capitalize.module = Scope.module(\n\t{\n\t\troot: rootSchema({\n\t\t\tin: \"string\",\n\t\t\tmorphs: (s: string) => s.charAt(0).toUpperCase() + s.slice(1),\n\t\t\tdeclaredOut: preformattedCapitalize\n\t\t}),\n\t\tpreformatted: preformattedCapitalize\n\t},\n\t{\n\t\tname: \"string.capitalize\"\n\t}\n) as never\n\nexport declare namespace capitalize {\n\texport type module = Module<submodule>\n\n\texport type submodule = Submodule<$>\n\n\texport type $ = {\n\t\troot: (In: string) => To<string>\n\t\tpreformatted: string\n\t}\n}\n\n// https://github.com/validatorjs/validator.js/blob/master/src/lib/isLuhnNumber.js\nexport const isLuhnValid = (creditCardInput: string): boolean => {\n\tconst sanitized = creditCardInput.replace(/[ -]+/g, \"\")\n\tlet sum = 0\n\tlet digit: string\n\tlet tmpNum: number\n\tlet shouldDouble = false\n\tfor (let i = sanitized.length - 1; i >= 0; i--) {\n\t\tdigit = sanitized.substring(i, i + 1)\n\t\ttmpNum = Number.parseInt(digit, 10)\n\t\tif (shouldDouble) {\n\t\t\ttmpNum *= 2\n\t\t\tsum += tmpNum >= 10 ? (tmpNum % 10) + 1 : tmpNum\n\t\t} else sum += tmpNum\n\n\t\tshouldDouble = !shouldDouble\n\t}\n\treturn !!(sum % 10 === 0 ? sanitized : false)\n}\n\n// https://github.com/validatorjs/validator.js/blob/master/src/lib/isCreditCard.js\nconst creditCardMatcher: RegExp =\n\t/^(?:4\\d{12}(?:\\d{3,6})?|5[1-5]\\d{14}|(222[1-9]|22[3-9]\\d|2[3-6]\\d{2}|27[01]\\d|2720)\\d{12}|6(?:011|5\\d\\d)\\d{12,15}|3[47]\\d{13}|3(?:0[0-5]|[68]\\d)\\d{11}|(?:2131|1800|35\\d{3})\\d{11}|6[27]\\d{14}|^(81\\d{14,17}))$/\n\nexport const creditCard = rootSchema({\n\tdomain: \"string\",\n\tpattern: {\n\t\tmeta: \"a credit card number\",\n\t\trule: creditCardMatcher.source\n\t},\n\tpredicate: {\n\t\tmeta: \"a credit card number\",\n\t\tpredicate: isLuhnValid\n\t}\n})\n\ntype DayDelimiter = \".\" | \"/\" | \"-\"\n\nconst dayDelimiterMatcher = /^[./-]$/\n\ntype DayPart = DayPatterns[PartKey]\n\ntype PartKey = keyof DayPatterns\n\ntype DayPatterns = {\n\ty: \"yy\" | \"yyyy\"\n\tm: \"mm\" | \"m\"\n\td: \"dd\" | \"d\"\n}\n\ntype fragment<part extends DayPart, delimiter extends DayDelimiter> =\n\t| `${delimiter}${part}`\n\t| \"\"\n\nexport type DayPattern<delimiter extends DayDelimiter = DayDelimiter> =\n\tdelimiter extends unknown ?\n\t\t{\n\t\t\t[k1 in keyof DayPatterns]: {\n\t\t\t\t[k2 in Exclude<keyof DayPatterns, k1>]: `${DayPatterns[k1]}${fragment<\n\t\t\t\t\tDayPatterns[k2],\n\t\t\t\t\tdelimiter\n\t\t\t\t>}${fragment<\n\t\t\t\t\tDayPatterns[Exclude<keyof DayPatterns, k1 | k2>],\n\t\t\t\t\tdelimiter\n\t\t\t\t>}`\n\t\t\t}[Exclude<keyof DayPatterns, k1>]\n\t\t}[keyof DayPatterns]\n\t:\tnever\n\nexport type DateFormat = \"iso\" | DayPattern\n\nexport type DateOptions = {\n\tformat?: DateFormat\n}\n\n// ISO 8601 date/time modernized from https://github.com/validatorjs/validator.js/blob/master/src/lib/isISO8601.js\n// Based on https://tc39.es/ecma262/#sec-date-time-string-format, the T\n// delimiter for date/time is mandatory. Regex from validator.js strict matcher:\nexport const iso8601Matcher =\n\t/^([+-]?\\d{4}(?!\\d{2}\\b))((-?)((0[1-9]|1[0-2])(\\3([12]\\d|0[1-9]|3[01]))?|W([0-4]\\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\\d|[12]\\d{2}|3([0-5]\\d|6[1-6])))(T((([01]\\d|2[0-3])((:?)[0-5]\\d)?|24:?00)([,.]\\d+(?!:))?)?(\\17[0-5]\\d([,.]\\d+)?)?([Zz]|([+-])([01]\\d|2[0-3]):?([0-5]\\d)?)?)?)?$/\n\ntype ParsedDayParts = {\n\ty?: string\n\tm?: string\n\td?: string\n}\n\nconst isValidDateInstance = (date: Date) => !Number.isNaN(+date)\n\nconst writeFormattedExpected = (format: DateFormat) =>\n\t`a ${format}-formatted date`\n\nexport const tryParseDatePattern = (\n\tdata: string,\n\topts?: DateOptions\n): Date | string => {\n\tif (!opts?.format) {\n\t\tconst result = new Date(data)\n\t\treturn isValidDateInstance(result) ? result : \"a valid date\"\n\t}\n\tif (opts.format === \"iso\") {\n\t\treturn iso8601Matcher.test(data) ?\n\t\t\t\tnew Date(data)\n\t\t\t:\twriteFormattedExpected(\"iso\")\n\t}\n\tconst dataParts = data.split(dayDelimiterMatcher)\n\t// will be the first delimiter matched, if there is one\n\tconst delimiter: string | undefined = data[dataParts[0].length]\n\tconst formatParts = delimiter ? opts.format.split(delimiter) : [opts.format]\n\n\tif (dataParts.length !== formatParts.length)\n\t\treturn writeFormattedExpected(opts.format)\n\n\tconst parsedParts: ParsedDayParts = {}\n\tfor (let i = 0; i < formatParts.length; i++) {\n\t\tif (\n\t\t\tdataParts[i].length !== formatParts[i].length &&\n\t\t\t// if format is \"m\" or \"d\", data is allowed to be 1 or 2 characters\n\t\t\t!(formatParts[i].length === 1 && dataParts[i].length === 2)\n\t\t)\n\t\t\treturn writeFormattedExpected(opts.format)\n\n\t\tparsedParts[formatParts[i][0] as PartKey] = dataParts[i]\n\t}\n\n\tconst date = new Date(`${parsedParts.m}/${parsedParts.d}/${parsedParts.y}`)\n\n\tif (`${date.getDate()}` === parsedParts.d) return date\n\n\treturn writeFormattedExpected(opts.format)\n}\n\nconst isParsableDate = (s: string) => !Number.isNaN(new Date(s).valueOf())\n\nconst parsableDate = rootSchema({\n\tdomain: \"string\",\n\tpredicate: {\n\t\tmeta: \"a parsable date\",\n\t\tpredicate: isParsableDate\n\t}\n}).assertHasKind(\"intersection\")\n\nconst epochRoot = stringInteger.root.internal\n\t.narrow((s, ctx) => {\n\t\t// this is safe since it has already\n\t\t// been validated as an integer string\n\t\tconst n = Number.parseInt(s)\n\t\tconst out = number.epoch(n)\n\t\tif (out instanceof ArkErrors) {\n\t\t\tctx.errors.merge(out)\n\t\t\treturn false\n\t\t}\n\t\treturn true\n\t})\n\t.configure(\n\t\t{\n\t\t\tdescription: \"an integer string representing a safe Unix timestamp\"\n\t\t},\n\t\t\"self\"\n\t)\n\t.assertHasKind(\"intersection\")\n\nconst epoch = Scope.module(\n\t{\n\t\troot: epochRoot,\n\t\tparse: rootSchema({\n\t\t\tin: epochRoot,\n\t\t\tmorphs: (s: string) => new Date(s),\n\t\t\tdeclaredOut: intrinsic.Date\n\t\t})\n\t},\n\t{\n\t\tname: \"string.date.epoch\"\n\t}\n)\n\nconst isoRoot = regexStringNode(\n\tiso8601Matcher,\n\t\"an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date\"\n).internal.assertHasKind(\"intersection\")\n\nconst iso = Scope.module(\n\t{\n\t\troot: isoRoot,\n\t\tparse: rootSchema({\n\t\t\tin: isoRoot,\n\t\t\tmorphs: (s: string) => new Date(s),\n\t\t\tdeclaredOut: intrinsic.Date\n\t\t})\n\t},\n\t{\n\t\tname: \"string.date.iso\"\n\t}\n)\n\nexport const stringDate: stringDate.module = Scope.module(\n\t{\n\t\troot: parsableDate,\n\t\tparse: rootSchema({\n\t\t\tdeclaredIn: parsableDate,\n\t\t\tin: \"string\",\n\t\t\tmorphs: (s: string, ctx: Traversal) => {\n\t\t\t\tconst date = new Date(s)\n\t\t\t\tif (Number.isNaN(date.valueOf())) return ctx.error(\"a parsable date\")\n\t\t\t\treturn date\n\t\t\t},\n\t\t\tdeclaredOut: intrinsic.Date\n\t\t}),\n\t\tiso,\n\t\tepoch\n\t},\n\t{\n\t\tname: \"string.date\"\n\t}\n) as never\n\nexport declare namespace stringDate {\n\texport type module = Module<stringDate.submodule>\n\n\texport type submodule = Submodule<$>\n\n\texport type $ = {\n\t\troot: string\n\t\tparse: (In: string) => To<Date>\n\t\tiso: iso.submodule\n\t\tepoch: epoch.submodule\n\t}\n\n\texport namespace iso {\n\t\texport type submodule = Submodule<$>\n\n\t\texport type $ = {\n\t\t\troot: string\n\t\t\tparse: (In: string) => To<Date>\n\t\t}\n\t}\n\n\texport namespace epoch {\n\t\texport type submodule = Submodule<$>\n\n\t\texport type $ = {\n\t\t\troot: string\n\t\t\tparse: (In: string) => To<Date>\n\t\t}\n\t}\n}\n\nconst email = regexStringNode(\n\t// considered https://colinhacks.com/essays/reasonable-email-regex but it includes a lookahead\n\t// which breaks some integrations e.g. fast-check\n\n\t// regex based on:\n\t// https://www.regular-expressions.info/email.html\n\t/^[\\w%+.-]+@[\\d.A-Za-z-]+\\.[A-Za-z]{2,}$/,\n\t\"an email address\",\n\t\"email\"\n)\n\n// based on https://github.com/validatorjs/validator.js/blob/master/src/lib/isIP.js\nconst ipv4Segment = \"(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\"\nconst ipv4Address = `(${ipv4Segment}[.]){3}${ipv4Segment}`\nconst ipv4Matcher = new RegExp(`^${ipv4Address}$`)\n\nconst ipv6Segment = \"(?:[0-9a-fA-F]{1,4})\"\nconst ipv6Matcher = new RegExp(\n\t\"^(\" +\n\t\t`(?:${ipv6Segment}:){7}(?:${ipv6Segment}|:)|` +\n\t\t`(?:${ipv6Segment}:){6}(?:${ipv4Address}|:${ipv6Segment}|:)|` +\n\t\t`(?:${ipv6Segment}:){5}(?::${ipv4Address}|(:${ipv6Segment}){1,2}|:)|` +\n\t\t`(?:${ipv6Segment}:){4}(?:(:${ipv6Segment}){0,1}:${ipv4Address}|(:${ipv6Segment}){1,3}|:)|` +\n\t\t`(?:${ipv6Segment}:){3}(?:(:${ipv6Segment}){0,2}:${ipv4Address}|(:${ipv6Segment}){1,4}|:)|` +\n\t\t`(?:${ipv6Segment}:){2}(?:(:${ipv6Segment}){0,3}:${ipv4Address}|(:${ipv6Segment}){1,5}|:)|` +\n\t\t`(?:${ipv6Segment}:){1}(?:(:${ipv6Segment}){0,4}:${ipv4Address}|(:${ipv6Segment}){1,6}|:)|` +\n\t\t`(?::((?::${ipv6Segment}){0,5}:${ipv4Address}|(?::${ipv6Segment}){1,7}|:))` +\n\t\t\")(%[0-9a-zA-Z.]{1,})?$\"\n)\n\nexport const ip: ip.module = Scope.module(\n\t{\n\t\troot: [\"v4 | v6\", \"@\", \"an IP address\"],\n\t\tv4: regexStringNode(ipv4Matcher, \"an IPv4 address\", \"ipv4\"),\n\t\tv6: regexStringNode(ipv6Matcher, \"an IPv6 address\", \"ipv6\")\n\t},\n\t{\n\t\tname: \"string.ip\"\n\t}\n) as never\n\nexport declare namespace ip {\n\texport type module = Module<submodule>\n\n\texport type submodule = Submodule<$>\n\n\texport type $ = {\n\t\troot: string\n\t\tv4: string\n\t\tv6: string\n\t}\n}\n\nconst jsonStringDescription = \"a JSON string\"\n\nexport const writeJsonSyntaxErrorProblem = (error: unknown): string => {\n\tif (!(error instanceof SyntaxError)) throw error\n\treturn `must be ${jsonStringDescription} (${error})`\n}\n\nconst jsonRoot = rootSchema({\n\tmeta: jsonStringDescription,\n\tdomain: \"string\",\n\tpredicate: {\n\t\tmeta: jsonStringDescription,\n\t\tpredicate: (s: string, ctx) => {\n\t\t\ttry {\n\t\t\t\tJSON.parse(s)\n\t\t\t\treturn true\n\t\t\t} catch (e) {\n\t\t\t\treturn ctx.reject({\n\t\t\t\t\tcode: \"predicate\",\n\t\t\t\t\texpected: jsonStringDescription,\n\t\t\t\t\tproblem: writeJsonSyntaxErrorProblem(e)\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n})\n\nconst parseJson: Morph<string> = (s: string, ctx: Traversal) => {\n\tif (s.length === 0) {\n\t\treturn ctx.error({\n\t\t\tcode: \"predicate\",\n\t\t\texpected: jsonStringDescription,\n\t\t\tactual: \"empty\"\n\t\t})\n\t}\n\ttry {\n\t\treturn JSON.parse(s)\n\t} catch (e) {\n\t\treturn ctx.error({\n\t\t\tcode: \"predicate\",\n\t\t\texpected: jsonStringDescription,\n\t\t\tproblem: writeJsonSyntaxErrorProblem(e)\n\t\t})\n\t}\n}\n\nexport const json: stringJson.module = Scope.module(\n\t{\n\t\troot: jsonRoot,\n\t\tparse: rootSchema({\n\t\t\tmeta: \"safe JSON string parser\",\n\t\t\tin: \"string\",\n\t\t\tmorphs: parseJson,\n\t\t\tdeclaredOut: intrinsic.jsonObject\n\t\t})\n\t},\n\t{\n\t\tname: \"string.json\"\n\t}\n) as never\n\nexport declare namespace stringJson {\n\texport type module = Module<submodule>\n\n\texport type submodule = Submodule<$>\n\n\texport type $ = {\n\t\troot: string\n\t\tparse: (In: string) => To<Json>\n\t}\n}\n\nconst preformattedLower = regexStringNode(/^[a-z]*$/, \"only lowercase letters\")\n\nconst lower: lower.module = Scope.module(\n\t{\n\t\troot: rootSchema({\n\t\t\tin: \"string\",\n\t\t\tmorphs: (s: string) => s.toLowerCase(),\n\t\t\tdeclaredOut: preformattedLower\n\t\t}),\n\t\tpreformatted: preformattedLower\n\t},\n\t{\n\t\tname: \"string.lower\"\n\t}\n) as never\n\nexport declare namespace lower {\n\texport type module = Module<submodule>\n\n\texport type submodule = Submodule<$>\n\n\texport type $ = {\n\t\troot: (In: string) => To<string>\n\t\tpreformatted: string\n\t}\n}\n\nexport const normalizedForms = [\"NFC\", \"NFD\", \"NFKC\", \"NFKD\"] as const\n\nexport type NormalizedForm = (typeof normalizedForms)[number]\n\nconst preformattedNodes = flatMorph(\n\tnormalizedForms,\n\t(i, form) =>\n\t\t[\n\t\t\tform,\n\t\t\trootSchema({\n\t\t\t\tdomain: \"string\",\n\t\t\t\tpredicate: (s: string) => s.normalize(form) === s,\n\t\t\t\tmeta: `${form}-normalized unicode`\n\t\t\t})\n\t\t] as const\n)\n\nconst normalizeNodes = flatMorph(\n\tnormalizedForms,\n\t(i, form) =>\n\t\t[\n\t\t\tform,\n\t\t\trootSchema({\n\t\t\t\tin: \"string\",\n\t\t\t\tmorphs: (s: string) => s.normalize(form),\n\t\t\t\tdeclaredOut: preformattedNodes[form]\n\t\t\t})\n\t\t] as const\n)\n\nexport const NFC = Scope.module(\n\t{\n\t\troot: normalizeNodes.NFC,\n\t\tpreformatted: preformattedNodes.NFC\n\t},\n\t{\n\t\tname: \"string.normalize.NFC\"\n\t}\n)\n\nexport const NFD = Scope.module(\n\t{\n\t\troot: normalizeNodes.NFD,\n\t\tpreformatted: preformattedNodes.NFD\n\t},\n\t{\n\t\tname: \"string.normalize.NFD\"\n\t}\n)\n\nexport const NFKC = Scope.module(\n\t{\n\t\troot: normalizeNodes.NFKC,\n\t\tpreformatted: preformattedNodes.NFKC\n\t},\n\t{\n\t\tname: \"string.normalize.NFKC\"\n\t}\n)\n\nexport const NFKD = Scope.module(\n\t{\n\t\troot: normalizeNodes.NFKD,\n\t\tpreformatted: preformattedNodes.NFKD\n\t},\n\t{\n\t\tname: \"string.normalize.NFKD\"\n\t}\n)\n\nexport const normalize = Scope.module(\n\t{\n\t\troot: \"NFC\",\n\t\tNFC,\n\t\tNFD,\n\t\tNFKC,\n\t\tNFKD\n\t},\n\t{\n\t\tname: \"string.normalize\"\n\t}\n)\n\nexport declare namespace normalize {\n\texport type module = Module<submodule>\n\n\texport type submodule = Submodule<$>\n\n\texport type $ = {\n\t\troot: (In: string) => To<string>\n\t\tNFC: NFC.submodule\n\t\tNFD: NFD.submodule\n\t\tNFKC: NFKC.submodule\n\t\tNFKD: NFKD.submodule\n\t}\n\n\texport namespace NFC {\n\t\texport type submodule = Submodule<$>\n\n\t\texport type $ = {\n\t\t\troot: (In: string) => To<string>\n\t\t\tpreformatted: string\n\t\t}\n\t}\n\n\texport namespace NFD {\n\t\texport type submodule = Submodule<$>\n\n\t\texport type $ = {\n\t\t\troot: (In: string) => To<string>\n\t\t\tpreformatted: string\n\t\t}\n\t}\n\n\texport namespace NFKC {\n\t\texport type submodule = Submodule<$>\n\n\t\texport type $ = {\n\t\t\troot: (In: string) => To<string>\n\t\t\tpreformatted: string\n\t\t}\n\t}\n\n\texport namespace NFKD {\n\t\texport type submodule = Submodule<$>\n\n\t\texport type $ = {\n\t\t\troot: (In: string) => To<string>\n\t\t\tpreformatted: string\n\t\t}\n\t}\n}\n\nconst numericRoot = regexStringNode(\n\tnumericStringMatcher,\n\t\"a well-formed numeric string\"\n)\n\nexport const stringNumeric: stringNumeric.module = Scope.module(\n\t{\n\t\troot: numericRoot,\n\t\tparse: rootSchema({\n\t\t\tin: numericRoot,\n\t\t\tmorphs: (s: string) => Number.parseFloat(s),\n\t\t\tdeclaredOut: intrinsic.number\n\t\t})\n\t},\n\t{\n\t\tname: \"string.numeric\"\n\t}\n) as never\n\nexport declare namespace stringNumeric {\n\texport type module = Module<submodule>\n\n\texport type submodule = Submodule<$>\n\n\texport type $ = {\n\t\troot: string\n\t\tparse: (In: string) => To<number>\n\t}\n}\n\nconst regexPatternDescription = \"a regex pattern\"\nconst regex = rootSchema({\n\tdomain: \"string\",\n\tpredicate: {\n\t\tmeta: regexPatternDescription,\n\t\tpredicate: (s: string, ctx) => {\n\t\t\ttry {\n\t\t\t\tnew RegExp(s)\n\t\t\t\treturn true\n\t\t\t} catch (e) {\n\t\t\t\treturn ctx.reject({\n\t\t\t\t\tcode: \"predicate\",\n\t\t\t\t\texpected: regexPatternDescription,\n\t\t\t\t\tproblem: String(e)\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t},\n\tmeta: { format: \"regex\" }\n})\n\nconst semverMatcher =\n\t/^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[A-Za-z-][\\dA-Za-z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[A-Za-z-][\\dA-Za-z-]*))*))?(?:\\+([\\dA-Za-z-]+(?:\\.[\\dA-Za-z-]+)*))?$/\n\nconst semver = regexStringNode(\n\tsemverMatcher,\n\t\"a semantic version (see https://semver.org/)\"\n)\n\nconst preformattedTrim = regexStringNode(\n\t// no leading or trailing whitespace\n\t/^\\S.*\\S$|^\\S?$/,\n\t\"trimmed\"\n)\n\nconst trim: trim.module = Scope.module(\n\t{\n\t\troot: rootSchema({\n\t\t\tin: \"string\",\n\t\t\tmorphs: (s: string) => s.trim(),\n\t\t\tdeclaredOut: preformattedTrim\n\t\t}),\n\t\tpreformatted: preformattedTrim\n\t},\n\t{\n\t\tname: \"string.trim\"\n\t}\n) as never\n\nexport declare namespace trim {\n\texport type module = Module<submodule>\n\n\texport type submodule = Submodule<$>\n\n\texport type $ = {\n\t\troot: (In: string) => To<string>\n\t\tpreformatted: string\n\t}\n}\n\nconst preformattedUpper = regexStringNode(/^[A-Z]*$/, \"only uppercase letters\")\n\nconst upper: upper.module = Scope.module(\n\t{\n\t\troot: rootSchema({\n\t\t\tin: \"string\",\n\t\t\tmorphs: (s: string) => s.toUpperCase(),\n\t\t\tdeclaredOut: preformattedUpper\n\t\t}),\n\t\tpreformatted: preformattedUpper\n\t},\n\t{\n\t\tname: \"string.upper\"\n\t}\n) as never\n\ndeclare namespace upper {\n\texport type module = Module<submodule>\n\n\texport type submodule = Submodule<$>\n\n\texport type $ = {\n\t\troot: (In: string) => To<string>\n\t\tpreformatted: string\n\t}\n}\n\nconst isParsableUrl = (s: string) => URL.canParse(s)\n\nconst urlRoot = rootSchema({\n\tdomain: \"string\",\n\tpredicate: {\n\t\tmeta: \"a URL string\",\n\t\tpredicate: isParsableUrl\n\t},\n\t// URL.canParse allows a subset of the RFC-3986 URI spec\n\t// since there is no other serializable validation, best include a format\n\tmeta: { format: \"uri\" }\n})\n\nexport const url: url.module = Scope.module(\n\t{\n\t\troot: urlRoot,\n\t\tparse: rootSchema({\n\t\t\tdeclaredIn: urlRoot,\n\t\t\tin: \"string\",\n\t\t\tmorphs: (s: string, ctx: Traversal) => {\n\t\t\t\ttry {\n\t\t\t\t\treturn new URL(s)\n\t\t\t\t} catch {\n\t\t\t\t\treturn ctx.error(\"a URL string\")\n\t\t\t\t}\n\t\t\t},\n\t\t\tdeclaredOut: rootSchema(URL)\n\t\t})\n\t},\n\t{\n\t\tname: \"string.url\"\n\t}\n) as never\n\nexport declare namespace url {\n\texport type module = Module<submodule>\n\n\texport type submodule = Submodule<$>\n\n\texport type $ = {\n\t\troot: string\n\t\tparse: (In: string) => To<URL>\n\t}\n}\n\n// based on https://github.com/validatorjs/validator.js/blob/master/src/lib/isUUID.js\nexport const uuid = Scope.module(\n\t{\n\t\t// the meta tuple expression ensures the error message does not delegate\n\t\t// to the individual branches, which are too detailed\n\t\troot: [\n\t\t\t\"versioned | nil | max\",\n\t\t\t\"@\",\n\t\t\t{ description: \"a UUID\", format: \"uuid\" }\n\t\t],\n\t\t\"#nil\": \"'00000000-0000-0000-0000-000000000000'\",\n\t\t\"#max\": \"'ffffffff-ffff-ffff-ffff-ffffffffffff'\",\n\t\t\"#versioned\":\n\t\t\t/[\\da-f]{8}-[\\da-f]{4}-[1-8][\\da-f]{3}-[89ab][\\da-f]{3}-[\\da-f]{12}/i,\n\t\tv1: regexStringNode(\n\t\t\t/^[\\da-f]{8}-[\\da-f]{4}-1[\\da-f]{3}-[89ab][\\da-f]{3}-[\\da-f]{12}$/i,\n\t\t\t\"a UUIDv1\"\n\t\t),\n\t\tv2: regexStringNode(\n\t\t\t/^[\\da-f]{8}-[\\da-f]{4}-2[\\da-f]{3}-[89ab][\\da-f]{3}-[\\da-f]{12}$/i,\n\t\t\t\"a UUIDv2\"\n\t\t),\n\t\tv3: regexStringNode(\n\t\t\t/^[\\da-f]{8}-[\\da-f]{4}-3[\\da-f]{3}-[89ab][\\da-f]{3}-[\\da-f]{12}$/i,\n\t\t\t\"a UUIDv3\"\n\t\t),\n\t\tv4: regexStringNode(\n\t\t\t/^[\\da-f]{8}-[\\da-f]{4}-4[\\da-f]{3}-[89ab][\\da-f]{3}-[\\da-f]{12}$/i,\n\t\t\t\"a UUIDv4\"\n\t\t),\n\t\tv5: regexStringNode(\n\t\t\t/^[\\da-f]{8}-[\\da-f]{4}-5[\\da-f]{3}-[89ab][\\da-f]{3}-[\\da-f]{12}$/i,\n\t\t\t\"a UUIDv5\"\n\t\t),\n\t\tv6: regexStringNode(\n\t\t\t/^[\\da-f]{8}-[\\da-f]{4}-6[\\da-f]{3}-[89ab][\\da-f]{3}-[\\da-f]{12}$/i,\n\t\t\t\"a UUIDv6\"\n\t\t),\n\t\tv7: regexStringNode(\n\t\t\t/^[\\da-f]{8}-[\\da-f]{4}-7[\\da-f]{3}-[89ab][\\da-f]{3}-[\\da-f]{12}$/i,\n\t\t\t\"a UUIDv7\"\n\t\t),\n\t\tv8: regexStringNode(\n\t\t\t/^[\\da-f]{8}-[\\da-f]{4}-8[\\da-f]{3}-[89ab][\\da-f]{3}-[\\da-f]{12}$/i,\n\t\t\t\"a UUIDv8\"\n\t\t)\n\t},\n\t{\n\t\tname: \"string.uuid\"\n\t}\n)\n\nexport declare namespace uuid {\n\texport type module = Module<submodule>\n\n\texport type submodule = Submodule<$>\n\n\texport type $ = {\n\t\troot: string\n\t\tv1: string\n\t\tv2: string\n\t\tv3: string\n\t\tv4: string\n\t\tv5: string\n\t\tv6: string\n\t\tv7: string\n\t\tv8: string\n\t}\n\n\texport namespace $ {\n\t\texport type flat = {}\n\t}\n}\n\nexport const string = Scope.module(\n\t{\n\t\troot: intrinsic.string,\n\t\talpha: regexStringNode(/^[A-Za-z]*$/, \"only letters\"),\n\t\talphanumeric: regexStringNode(\n\t\t\t/^[\\dA-Za-z]*$/,\n\t\t\t\"only letters and digits 0-9\"\n\t\t),\n\t\thex,\n\t\tbase64,\n\t\tcapitalize,\n\t\tcreditCard,\n\t\tdate: stringDate,\n\t\tdigits: regexStringNode(/^\\d*$/, \"only digits 0-9\"),\n\t\temail,\n\t\tinteger: stringInteger,\n\t\tip,\n\t\tjson,\n\t\tlower,\n\t\tnormalize,\n\t\tnumeric: stringNumeric,\n\t\tregex,\n\t\tsemver,\n\t\ttrim,\n\t\tupper,\n\t\turl,\n\t\tuuid\n\t},\n\t{\n\t\tname: \"string\"\n\t}\n)\n\nexport declare namespace string {\n\texport type module = Module<string.submodule>\n\n\texport type submodule = Submodule<$>\n\n\texport type $ = {\n\t\troot: string\n\t\talpha: string\n\t\talphanumeric: string\n\t\thex: string\n\t\tbase64: base64.submodule\n\t\tcapitalize: capitalize.submodule\n\t\tcreditCard: string\n\t\tdate: stringDate.submodule\n\t\tdigits: string\n\t\temail: string\n\t\tinteger: stringInteger.submodule\n\t\tip: ip.submodule\n\t\tjson: stringJson.submodule\n\t\tlower: lower.submodule\n\t\tnormalize: normalize.submodule\n\t\tnumeric: stringNumeric.submodule\n\t\tregex: string\n\t\tsemver: string\n\t\ttrim: trim.submodule\n\t\tupper: upper.submodule\n\t\turl: url.submodule\n\t\tuuid: uuid.submodule\n\t}\n}\n"
  },
  {
    "path": "ark/type/keywords/ts.ts",
    "content": "import { genericNode, intrinsic, node } from \"@ark/schema\"\nimport {\n\tHkt,\n\ttype Json,\n\ttype Key,\n\ttype omit,\n\ttype pick,\n\ttype show\n} from \"@ark/util\"\nimport type { To } from \"../attributes.ts\"\nimport type { Module, Submodule } from \"../module.ts\"\nimport { Scope } from \"../scope.ts\"\n\nexport const arkTsKeywords: arkTsKeywords = Scope.module({\n\tbigint: intrinsic.bigint,\n\tboolean: intrinsic.boolean,\n\tfalse: intrinsic.false,\n\tnever: intrinsic.never,\n\tnull: intrinsic.null,\n\tnumber: intrinsic.number,\n\tobject: intrinsic.object,\n\tstring: intrinsic.string,\n\tsymbol: intrinsic.symbol,\n\ttrue: intrinsic.true,\n\tunknown: intrinsic.unknown,\n\tundefined: intrinsic.undefined\n}) as never\n\nexport type arkTsKeywords = Module<arkTsKeywords.$>\n\nexport declare namespace arkTsKeywords {\n\texport type submodule = Submodule<$>\n\n\texport type $ = {\n\t\tbigint: bigint\n\t\tboolean: boolean\n\t\tfalse: false\n\t\tnever: never\n\t\tnull: null\n\t\tnumber: number\n\t\tobject: object\n\t\tstring: string\n\t\tsymbol: symbol\n\t\ttrue: true\n\t\tunknown: unknown\n\t\tundefined: undefined\n\t}\n}\n\nexport const unknown = Scope.module(\n\t{\n\t\troot: intrinsic.unknown,\n\t\tany: intrinsic.unknown\n\t},\n\t{\n\t\tname: \"unknown\"\n\t}\n)\n\nexport declare namespace unknown {\n\texport type submodule = Submodule<$>\n\n\texport type $ = {\n\t\troot: unknown\n\t\tany: any\n\t}\n}\n\nexport const json = Scope.module(\n\t{\n\t\troot: intrinsic.jsonObject,\n\t\tstringify: node(\"morph\", {\n\t\t\tin: intrinsic.jsonObject,\n\t\t\tmorphs: (data: Json) => JSON.stringify(data),\n\t\t\tdeclaredOut: intrinsic.string\n\t\t})\n\t},\n\t{\n\t\tname: \"object.json\"\n\t}\n)\n\nexport declare namespace json {\n\texport type submodule = Submodule<$>\n\n\texport type $ = {\n\t\troot: Json\n\t\tstringify: (In: Json) => To<string>\n\t}\n}\n\nexport const object = Scope.module(\n\t{\n\t\troot: intrinsic.object,\n\t\tjson\n\t},\n\t{\n\t\tname: \"object\"\n\t}\n)\n\nexport declare namespace object {\n\texport type submodule = Submodule<$>\n\n\texport type $ = {\n\t\troot: object\n\t\tjson: json.submodule\n\t}\n}\n\nclass RecordHkt extends Hkt<[Key, unknown]> {\n\tdeclare body: Record<this[0], this[1]>\n\n\tdescription =\n\t\t'instantiate an object from an index signature and corresponding value type like `Record(\"string\", \"number\")`'\n}\n\nconst Record = genericNode([\"K\", intrinsic.key], \"V\")(\n\targs => ({\n\t\tdomain: \"object\",\n\t\tindex: {\n\t\t\tsignature: args.K,\n\t\t\tvalue: args.V\n\t\t}\n\t}),\n\tRecordHkt\n)\n\nclass PickHkt extends Hkt<[object, Key]> {\n\tdeclare body: pick<this[0], this[1] & keyof this[0]>\n\n\tdescription =\n\t\t'pick a set of properties from an object like `Pick(User, \"name | age\")`'\n}\n\nconst Pick = genericNode([\"T\", intrinsic.object], [\"K\", intrinsic.key])(\n\targs => args.T.pick(args.K as never),\n\tPickHkt\n)\n\nclass OmitHkt extends Hkt<[object, Key]> {\n\tdeclare body: omit<this[0], this[1] & keyof this[0]>\n\n\tdescription =\n\t\t'omit a set of properties from an object like `Omit(User, \"age\")`'\n}\n\nconst Omit = genericNode([\"T\", intrinsic.object], [\"K\", intrinsic.key])(\n\targs => args.T.omit(args.K as never),\n\tOmitHkt\n)\n\nclass PartialHkt extends Hkt<[object]> {\n\tdeclare body: show<Partial<this[0]>>\n\n\tdescription =\n\t\t\"make all named properties of an object optional like `Partial(User)`\"\n}\n\nconst Partial = genericNode([\"T\", intrinsic.object])(\n\targs => args.T.partial(),\n\tPartialHkt\n)\n\nclass RequiredHkt extends Hkt<[object]> {\n\tdeclare body: show<Required<this[0]>>\n\n\tdescription =\n\t\t\"make all named properties of an object required like `Required(User)`\"\n}\n\nconst Required = genericNode([\"T\", intrinsic.object])(\n\targs => args.T.required(),\n\tRequiredHkt\n)\n\nclass ExcludeHkt extends Hkt<[unknown, unknown]> {\n\tdeclare body: Exclude<this[0], this[1]>\n\n\tdescription = 'exclude branches of a union like `Exclude(\"boolean\", \"true\")`'\n}\n\nconst Exclude = genericNode(\"T\", \"U\")(\n\targs => args.T.exclude(args.U),\n\tExcludeHkt\n)\n\nclass ExtractHkt extends Hkt<[unknown, unknown]> {\n\tdeclare body: Extract<this[0], this[1]>\n\n\tdescription =\n\t\t'extract branches of a union like `Extract(\"0 | false | 1\", \"number\")`'\n}\n\nconst Extract = genericNode(\"T\", \"U\")(\n\targs => args.T.extract(args.U),\n\tExtractHkt\n)\n\nexport const arkTsGenerics: arkTsGenerics.module = Scope.module({\n\tExclude,\n\tExtract,\n\tOmit,\n\tPartial,\n\tPick,\n\tRecord,\n\tRequired\n}) as never\n\nexport declare namespace arkTsGenerics {\n\texport type module = Module<arkTsGenerics.$>\n\n\texport type submodule = Submodule<$>\n\n\texport type $ = {\n\t\tExclude: typeof Exclude.t\n\t\tExtract: typeof Extract.t\n\t\tOmit: typeof Omit.t\n\t\tPartial: typeof Partial.t\n\t\tPick: typeof Pick.t\n\t\tRecord: typeof Record.t\n\t\tRequired: typeof Required.t\n\t}\n}\n"
  },
  {
    "path": "ark/type/match.ts",
    "content": "import {\n\tintrinsic,\n\ttype ArkErrors,\n\ttype BaseRoot,\n\ttype Morph,\n\ttype Union\n} from \"@ark/schema\"\nimport {\n\tCallable,\n\tdomainOf,\n\tthrowParseError,\n\ttype conform,\n\ttype ErrorMessage,\n\ttype ErrorType,\n\ttype isDisjoint,\n\ttype Key,\n\ttype mutable,\n\ttype numericStringKeyOf,\n\ttype propValueOf,\n\ttype show,\n\ttype unionToTuple\n} from \"@ark/util\"\nimport type { distill, Out } from \"./attributes.ts\"\nimport type { type } from \"./keywords/keywords.ts\"\nimport type { BaseCompletions } from \"./parser/string.ts\"\nimport type { InternalScope } from \"./scope.ts\"\nimport type { Inferred } from \"./variants/base.ts\"\n\ntype MatchParserContext<input = unknown> = {\n\tcases: Morph[]\n\t$: unknown\n\tinput: input\n\tchecked: boolean\n\tkey: PropertyKey | null\n}\n\ndeclare namespace ctx {\n\texport type from<ctx extends MatchParserContext> = ctx\n\n\texport type init<$, input = unknown, checked extends boolean = false> = from<{\n\t\tcases: []\n\t\t$: $\n\t\tinput: input\n\t\tchecked: checked\n\t\tkey: null\n\t}>\n\n\texport type atKey<ctx extends MatchParserContext, key extends string> = from<{\n\t\tcases: ctx[\"cases\"]\n\t\t$: ctx[\"$\"]\n\t\tinput: ctx[\"input\"]\n\t\tchecked: ctx[\"checked\"]\n\t\tkey: key\n\t}>\n}\n\nexport interface MatchParser<$> extends CaseMatchParser<ctx.init<$>> {\n\tin<const def>(\n\t\tdef: type.validate<def, $>\n\t): ChainableMatchParser<ctx.init<$, type.infer<def, $>, true>>\n\tin<const typedInput = never>(\n\t\t...args: [typedInput] extends [never] ?\n\t\t\t[\n\t\t\t\tErrorMessage<\"in requires a definition or type argument (in('string') or in<string>())\">\n\t\t\t]\n\t\t:\t[]\n\t): ChainableMatchParser<ctx.init<$, typedInput>>\n\t// include this signature a second time so that e.g. `match.in({ foo: \"strin\" })` shows the right error\n\tin<const def>(\n\t\tdef: type.validate<def, $>\n\t): ChainableMatchParser<ctx.init<$, type.infer<def, $>, true>>\n\n\tcase: CaseParser<ctx.init<$>>\n\n\tat: AtParser<ctx.init<$>>\n}\n\ntype addCasesToContext<\n\tctx extends MatchParserContext,\n\tcases extends unknown[]\n> =\n\tcases extends Morph[] ?\n\t\tctx.from<{\n\t\t\t$: ctx[\"$\"]\n\t\t\tinput: ctx[\"input\"]\n\t\t\tcases: [...ctx[\"cases\"], ...cases]\n\t\t\tchecked: ctx[\"checked\"]\n\t\t\tkey: ctx[\"key\"]\n\t\t}>\n\t:\tnever\n\ntype addDefaultToContext<\n\tctx extends MatchParserContext,\n\tdefaultCase extends DefaultCase<ctx>\n> = ctx.from<{\n\t$: ctx[\"$\"]\n\tinput: defaultCase extends \"never\" ? Morph.In<ctx[\"cases\"][number]>\n\t:\tctx[\"input\"]\n\tcases: defaultCase extends \"never\" | \"assert\" ? ctx[\"cases\"]\n\t: defaultCase extends Morph ?\n\t\tctx[\"checked\"] extends true ?\n\t\t\t[(In: unknown) => ArkErrors, ...ctx[\"cases\"], defaultCase]\n\t\t:\t[...ctx[\"cases\"], defaultCase]\n\t:\t// we already are guaranteed ArkErrors as a possible output here\n\t\t// so don't bother adding it as an input case\n\t\t[...ctx[\"cases\"], (In: ctx[\"input\"]) => ArkErrors]\n\tchecked: ctx[\"checked\"]\n\tkey: ctx[\"key\"]\n}>\n\ntype CaseKeyKind = \"def\" | \"string\"\n\ntype casesToMorphTuple<\n\tcases,\n\tctx extends MatchParserContext,\n\tkind extends CaseKeyKind\n> = unionToTuple<\n\tpropValueOf<{\n\t\t[def in Exclude<keyof cases, \"default\">]: cases[def] extends (\n\t\t\tMorph<never, infer o>\n\t\t) ?\n\t\t\tkind extends \"def\" ?\n\t\t\t\t(\n\t\t\t\t\tIn: inferCaseArg<def extends number ? `${number}` : def, ctx, \"in\">\n\t\t\t\t) => o\n\t\t\t:\t(In: maybeLiftToKey<def, ctx>) => o\n\t\t:\tnever\n\t}>\n>\n\ntype addCasesToParser<\n\tcases,\n\tctx extends MatchParserContext,\n\tkind extends CaseKeyKind\n> =\n\tcases extends { default: infer defaultDef extends DefaultCase<ctx> } ?\n\t\tfinalizeMatchParser<\n\t\t\taddCasesToContext<ctx, casesToMorphTuple<cases, ctx, kind>>,\n\t\t\tdefaultDef\n\t\t>\n\t:\tChainableMatchParser<\n\t\t\taddCasesToContext<ctx, casesToMorphTuple<cases, ctx, kind>>\n\t\t>\n\ntype inferCaseArg<\n\tdef,\n\tctx extends MatchParserContext,\n\tendpoint extends \"in\" | \"out\"\n> = _finalizeCaseArg<\n\tmaybeLiftToKey<type.infer<def, ctx[\"$\"]>, ctx>,\n\tctx,\n\tendpoint\n>\n\ntype maybeLiftToKey<t, ctx extends MatchParserContext> =\n\tctx[\"key\"] extends PropertyKey ? { [k in ctx[\"key\"]]: t } : t\n\ntype _finalizeCaseArg<\n\tt,\n\tctx extends MatchParserContext,\n\tendpoint extends \"in\" | \"out\",\n\tctxInput = ctx[\"input\"]\n> =\n\tctxInput extends unknown ?\n\t\tt extends unknown ?\n\t\t\tdistill<t, endpoint> extends infer result ?\n\t\t\t\tctxInput extends result ?\n\t\t\t\t\tctxInput\n\t\t\t\t:\tshow<ctxInput & result>\n\t\t\t:\tnever\n\t\t:\tnever\n\t:\tnever\n\ntype CaseParser<ctx extends MatchParserContext> = <const def, ret>(\n\tdef: type.validate<def, ctx[\"$\"]>,\n\tresolve: (In: inferCaseArg<def, ctx, \"out\">) => ret\n) => ChainableMatchParser<\n\taddCasesToContext<ctx, [(In: inferCaseArg<def, ctx, \"in\">) => ret]>\n>\n\ntype validateKey<key extends Key, ctx extends MatchParserContext> =\n\tctx[\"key\"] extends Key ? ErrorMessage<doubleAtMessage>\n\t: ctx[\"cases\"][\"length\"] extends 0 ?\n\t\tkeyof ctx[\"input\"] extends never ?\n\t\t\tkey\n\t\t:\tconform<key, keyof ctx[\"input\"]>\n\t:\tErrorMessage<chainedAtMessage>\n\ninterface StringsParser<ctx extends MatchParserContext> {\n\t<const cases>(\n\t\tdef: cases extends validateStringCases<cases, ctx> ? cases\n\t\t:\tvalidateStringCases<cases, ctx>\n\t): addCasesToParser<cases, ctx, \"string\">\n}\n\ntype validateStringCases<cases, ctx extends MatchParserContext> =\n\tunknown extends ctx[\"input\"] ?\n\t\t{\n\t\t\t[k in keyof cases]?: k extends \"default\" ? DefaultCase<ctx>\n\t\t\t:\t(In: _finalizeCaseArg<maybeLiftToKey<k, ctx>, ctx, \"out\">) => unknown\n\t\t\t// always autocomplete the \"default\" key\n\t\t} & { default?: DefaultCase<ctx> }\n\t:\t{\n\t\t\t[k in keyof cases]?: k extends \"default\" ? DefaultCase<ctx>\n\t\t\t: k extends stringValue<ctx> ?\n\t\t\t\t(In: _finalizeCaseArg<maybeLiftToKey<k, ctx>, ctx, \"out\">) => unknown\n\t\t\t:\tErrorType<`${k & string} must be a possible string value`>\n\t\t} & { [k in stringValue<ctx>]?: unknown } & {\n\t\t\tdefault?: DefaultCase<ctx>\n\t\t}\n\ntype stringValue<ctx extends MatchParserContext> =\n\tctx[\"input\"] extends string ? ctx[\"input\"]\n\t: ctx[\"key\"] extends keyof ctx[\"input\"] ?\n\t\tctx[\"input\"][ctx[\"key\"]] extends infer s extends string ?\n\t\t\ts\n\t\t:\tnever\n\t:\tnever\n\ninterface AtParser<ctx extends MatchParserContext> {\n\t<const key extends string>(\n\t\tkey: validateKey<key, ctx>\n\t): ChainableMatchParser<ctx.atKey<ctx, key>>\n\n\t<\n\t\tconst key extends string,\n\t\tconst cases,\n\t\tctxAtKey extends MatchParserContext = ctx.atKey<ctx, key>\n\t>(\n\t\tkey: validateKey<key, ctx>,\n\t\tcases: cases extends validateCases<cases, ctxAtKey> ? cases\n\t\t:\terrorCases<cases, ctxAtKey>\n\t): addCasesToParser<cases, ctxAtKey, \"def\">\n}\n\ninterface ChainableMatchParser<ctx extends MatchParserContext> {\n\tcase: CaseParser<ctx>\n\tmatch: CaseMatchParser<ctx>\n\tdefault: DefaultMethod<ctx>\n\tat: AtParser<ctx>\n\t/** @experimental */\n\tstrings: StringsParser<ctx>\n}\n\nexport type DefaultCaseKeyword = \"never\" | \"assert\" | \"reject\"\n\ntype DefaultCase<ctx extends MatchParserContext = MatchParserContext<any>> =\n\t| DefaultCaseKeyword\n\t| Morph<ctx[\"input\"]>\n\ntype DefaultMethod<ctx extends MatchParserContext> = <\n\tconst def extends DefaultCase<ctx>\n>(\n\tdef: def\n) => finalizeMatchParser<ctx, def>\n\ntype validateCases<cases, ctx extends MatchParserContext> = {\n\t[def in\n\t\t| keyof cases\n\t\t| BaseCompletions<ctx[\"$\"], {}, \"default\">]?: def extends \"default\" ?\n\t\tDefaultCase<ctx>\n\t: def extends number ? (In: inferCaseArg<`${def}`, ctx, \"out\">) => unknown\n\t: def extends type.validate<def, ctx[\"$\"]> ?\n\t\t(In: inferCaseArg<def, ctx, \"out\">) => unknown\n\t:\ttype.validate<def, ctx[\"$\"]>\n}\n\ntype errorCases<cases, ctx extends MatchParserContext> = {\n\t[def in keyof cases]?: def extends \"default\" ? DefaultCase<ctx>\n\t: def extends number ? (In: inferCaseArg<`${def}`, ctx, \"out\">) => unknown\n\t: def extends type.validate<def, ctx[\"$\"]> ?\n\t\t(In: inferCaseArg<def, ctx, \"out\">) => unknown\n\t:\tErrorType<type.validate<def, ctx[\"$\"]>>\n} & {\n\t[k in BaseCompletions<ctx[\"$\"], {}>]?: (\n\t\tIn: inferCaseArg<k, ctx, \"out\">\n\t) => unknown\n} & {\n\tdefault?: DefaultCase<ctx>\n}\n\nexport type CaseMatchParser<ctx extends MatchParserContext> = <const cases>(\n\tdef: cases extends validateCases<cases, ctx> ? cases : errorCases<cases, ctx>\n) => addCasesToParser<cases, ctx, \"def\">\n\ntype finalizeMatchParser<\n\tctx extends MatchParserContext,\n\tdefaultCase extends DefaultCase<ctx>\n> =\n\taddDefaultToContext<ctx, defaultCase> extends (\n\t\tinfer ctx extends MatchParserContext\n\t) ?\n\t\tMatch<ctx[\"input\"], ctx[\"cases\"]>\n\t:\tnever\n\nexport interface Match<In = any, cases extends Morph[] = Morph[]>\n\textends Inferred<\n\t\t(In: Morph.In<cases[number]>) => Out<ReturnType<cases[number]>>\n\t> {\n\t<const data extends In>(\n\t\tdata: data\n\t): {\n\t\t[i in numericStringKeyOf<cases>]: isDisjoint<\n\t\t\tdata,\n\t\t\tMorph.In<cases[i]>\n\t\t> extends true ?\n\t\t\tnever\n\t\t:\tMorph.Out<cases[i]>\n\t}[numericStringKeyOf<cases>]\n}\n\nexport class InternalMatchParser extends Callable<InternalCaseParserFn> {\n\t$: InternalScope\n\n\tconstructor($: InternalScope) {\n\t\tsuper((...args) => new InternalChainedMatchParser($)(...args), {\n\t\t\tbind: $\n\t\t})\n\t\tthis.$ = $\n\t}\n\n\tin(def?: unknown): InternalChainedMatchParser {\n\t\treturn new InternalChainedMatchParser(\n\t\t\tthis.$,\n\t\t\tdef === undefined ? undefined : this.$.parse(def)\n\t\t)\n\t}\n\n\tat(key: Key, cases?: InternalCases): InternalChainedMatchParser | Match {\n\t\treturn new InternalChainedMatchParser(this.$).at(key, cases)\n\t}\n\n\tcase(when: unknown, then: Morph): InternalChainedMatchParser {\n\t\treturn new InternalChainedMatchParser(this.$).case(when, then)\n\t}\n}\n\ntype InternalCases = Record<string, Morph | DefaultCase>\n\ntype InternalCaseParserFn = (\n\tcases: InternalCases\n) => InternalChainedMatchParser | Match\n\ntype CaseEntry = [BaseRoot, Morph] | [\"default\", DefaultCase]\n\nexport class InternalChainedMatchParser extends Callable<InternalCaseParserFn> {\n\t$: InternalScope;\n\tin: BaseRoot | undefined\n\tprotected key: Key | undefined\n\tprotected branches: BaseRoot[] = []\n\n\tconstructor($: InternalScope, In?: BaseRoot) {\n\t\tsuper(cases =>\n\t\t\tthis.caseEntries(\n\t\t\t\tObject.entries(cases).map(([k, v]) =>\n\t\t\t\t\tk === \"default\" ? [k, v as never] : [this.$.parse(k), v as Morph]\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t\tthis.$ = $\n\t\tthis.in = In\n\t}\n\n\tat(key: Key, cases?: InternalCases): InternalChainedMatchParser | Match {\n\t\tif (this.key) throwParseError(doubleAtMessage)\n\t\tif (this.branches.length) throwParseError(chainedAtMessage)\n\t\tthis.key = key\n\t\treturn cases ? this.match(cases) : this\n\t}\n\n\tcase(def: unknown, resolver: Morph): InternalChainedMatchParser {\n\t\treturn this.caseEntry(this.$.parse(def), resolver)\n\t}\n\n\tprotected caseEntry(\n\t\tnode: BaseRoot,\n\t\tresolver: Morph\n\t): InternalChainedMatchParser {\n\t\tconst wrappableNode = this.key ? this.$.parse({ [this.key]: node }) : node\n\t\tconst branch = wrappableNode.pipe(resolver as never)\n\t\tthis.branches.push(branch)\n\t\treturn this\n\t}\n\n\tmatch(cases: InternalCases): InternalChainedMatchParser | Match {\n\t\treturn this(cases)\n\t}\n\n\tstrings(cases: InternalCases): InternalChainedMatchParser | Match {\n\t\treturn this.caseEntries(\n\t\t\tObject.entries(cases).map(([k, v]) =>\n\t\t\t\tk === \"default\" ?\n\t\t\t\t\t[k, v as never]\n\t\t\t\t:\t[this.$.node(\"unit\", { unit: k }), v as Morph]\n\t\t\t)\n\t\t)\n\t}\n\n\tprotected caseEntries(\n\t\tentries: CaseEntry[]\n\t): InternalChainedMatchParser | Match {\n\t\tfor (let i = 0; i < entries.length; i++) {\n\t\t\tconst [k, v] = entries[i]\n\t\t\tif (k === \"default\") {\n\t\t\t\tif (i !== entries.length - 1) {\n\t\t\t\t\tthrowParseError(\n\t\t\t\t\t\t`default may only be specified as the last key of a switch definition`\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\treturn this.default(v)\n\t\t\t}\n\t\t\tif (typeof v !== \"function\") {\n\t\t\t\treturn throwParseError(\n\t\t\t\t\t`Value for case \"${k}\" must be a function (was ${domainOf(v)})`\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tthis.caseEntry(k, v)\n\t\t}\n\n\t\treturn this\n\t}\n\n\tdefault(defaultCase: DefaultCase): Match {\n\t\tif (typeof defaultCase === \"function\")\n\t\t\tthis.case(intrinsic.unknown, defaultCase)\n\n\t\tconst schema: mutable<Union.Schema> = {\n\t\t\tbranches: this.branches,\n\t\t\tordered: true\n\t\t}\n\n\t\tif (defaultCase === \"never\" || defaultCase === \"assert\")\n\t\t\tschema.meta = { onFail: throwOnDefault }\n\n\t\tconst cases = this.$.node(\"union\", schema)\n\n\t\tif (!this.in) return this.$.finalize(cases) as never\n\n\t\tlet inputValidatedCases = this.in.pipe(cases)\n\n\t\tif (defaultCase === \"never\" || defaultCase === \"assert\") {\n\t\t\tinputValidatedCases = inputValidatedCases.configureReferences(\n\t\t\t\t{\n\t\t\t\t\tonFail: throwOnDefault\n\t\t\t\t},\n\t\t\t\t\"self\"\n\t\t\t)\n\t\t}\n\n\t\treturn this.$.finalize(inputValidatedCases) as never\n\t}\n}\n\nexport const throwOnDefault: ArkErrors.Handler = errors => errors.throw()\n\nexport const chainedAtMessage = `A key matcher must be specified before the first case i.e. match.at('foo') or match.in<object>().at('bar')`\nexport type chainedAtMessage = typeof chainedAtMessage\n\nexport const doubleAtMessage = `At most one key matcher may be specified per expression`\nexport type doubleAtMessage = typeof doubleAtMessage\n"
  },
  {
    "path": "ark/type/module.ts",
    "content": "import {\n\tRootModule,\n\ttype GenericAst,\n\ttype PreparsedNodeResolution\n} from \"@ark/schema\"\nimport type { anyOrNever, inferred } from \"@ark/util\"\nimport type { Generic } from \"./generic.ts\"\nimport type { Type } from \"./type.ts\"\n\nexport const Module: new <$ extends {}>(exports: exportScope<$>) => Module<$> =\n\tRootModule as never\n\nexport interface Module<$ extends {} = {}> extends RootModule<exportScope<$>> {}\n\nexport type exportScope<$> = bindExportsToScope<$, $>\n\nexport const BoundModule: new <exports extends {}, $ extends {}>(\n\texports: bindExportsToScope<exports, $>,\n\t$: $\n) => BoundModule<exports, $> = RootModule as never\n\nexport interface BoundModule<exports extends {}, $>\n\textends RootModule<bindExportsToScope<exports, $>> {}\n\nexport type bindExportsToScope<exports, $> = {\n\t[k in keyof exports]: instantiateExport<exports[k], $>\n} & unknown\n\nexport type Submodule<exports extends {}> = RootModule<\n\texports &\n\t\t(\"root\" extends keyof exports ? { [inferred]: exports[\"root\"] } : {})\n>\n\nexport type instantiateExport<t, $> =\n\t[t] extends [PreparsedNodeResolution] ?\n\t\t[t] extends [anyOrNever] ? Type<t, $>\n\t\t: t extends GenericAst<infer params, infer body, infer body$> ?\n\t\t\tGeneric<params, body, body$, $>\n\t\t: t extends Submodule<infer exports> ? BoundModule<exports, $>\n\t\t: never\n\t:\tType<t, $>\n"
  },
  {
    "path": "ark/type/nary.ts",
    "content": "import type { Morph } from \"@ark/schema\"\nimport type { ErrorType, merge } from \"@ark/util\"\nimport type {\n\tdistill,\n\tinferIntersection,\n\tinferMorph,\n\tinferMorphOut,\n\tinferNaryIntersection,\n\tinferNaryMerge,\n\tinferNaryPipe\n} from \"./attributes.ts\"\nimport type { type } from \"./keywords/keywords.ts\"\nimport type { Type } from \"./type.ts\"\nimport type { instantiateType } from \"./variants/instantiate.ts\"\nimport type { NonObjectMergeErrorMessage } from \"./variants/object.ts\"\n\nexport type NaryUnionParser<$> = {\n\t(): Type<never, $>\n\t<const a, r = Type<type.infer<a, $>, $>>(\n\t\ta: type.validate<a, $>\n\t): r extends infer _ ? _ : never\n\t<const a, const b, r = Type<type.infer<a, $> | type.infer<b, $>, $>>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tr = Type<type.infer<a, $> | type.infer<b, $> | type.infer<c, $>, $>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tr = Type<\n\t\t\ttype.infer<a, $> | type.infer<b, $> | type.infer<c, $> | type.infer<d, $>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>,\n\t\td: type.validate<d, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tr = Type<\n\t\t\t| type.infer<a, $>\n\t\t\t| type.infer<b, $>\n\t\t\t| type.infer<c, $>\n\t\t\t| type.infer<d, $>\n\t\t\t| type.infer<e, $>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>,\n\t\td: type.validate<d, $>,\n\t\te: type.validate<e, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tr = Type<\n\t\t\t| type.infer<a, $>\n\t\t\t| type.infer<b, $>\n\t\t\t| type.infer<c, $>\n\t\t\t| type.infer<d, $>\n\t\t\t| type.infer<e, $>\n\t\t\t| type.infer<f, $>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>,\n\t\td: type.validate<d, $>,\n\t\te: type.validate<e, $>,\n\t\tf: type.validate<f, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tr = Type<\n\t\t\t| type.infer<a, $>\n\t\t\t| type.infer<b, $>\n\t\t\t| type.infer<c, $>\n\t\t\t| type.infer<d, $>\n\t\t\t| type.infer<e, $>\n\t\t\t| type.infer<f, $>\n\t\t\t| type.infer<g, $>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>,\n\t\td: type.validate<d, $>,\n\t\te: type.validate<e, $>,\n\t\tf: type.validate<f, $>,\n\t\tg: type.validate<g, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tr = Type<\n\t\t\t| type.infer<a, $>\n\t\t\t| type.infer<b, $>\n\t\t\t| type.infer<c, $>\n\t\t\t| type.infer<d, $>\n\t\t\t| type.infer<e, $>\n\t\t\t| type.infer<f, $>\n\t\t\t| type.infer<g, $>\n\t\t\t| type.infer<h, $>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>,\n\t\td: type.validate<d, $>,\n\t\te: type.validate<e, $>,\n\t\tf: type.validate<f, $>,\n\t\tg: type.validate<g, $>,\n\t\th: type.validate<h, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tconst i,\n\t\tr = Type<\n\t\t\t| type.infer<a, $>\n\t\t\t| type.infer<b, $>\n\t\t\t| type.infer<c, $>\n\t\t\t| type.infer<d, $>\n\t\t\t| type.infer<e, $>\n\t\t\t| type.infer<f, $>\n\t\t\t| type.infer<g, $>\n\t\t\t| type.infer<h, $>\n\t\t\t| type.infer<i, $>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>,\n\t\td: type.validate<d, $>,\n\t\te: type.validate<e, $>,\n\t\tf: type.validate<f, $>,\n\t\tg: type.validate<g, $>,\n\t\th: type.validate<h, $>,\n\t\ti: type.validate<i, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tconst i,\n\t\tconst j,\n\t\tr = Type<\n\t\t\t| type.infer<a, $>\n\t\t\t| type.infer<b, $>\n\t\t\t| type.infer<c, $>\n\t\t\t| type.infer<d, $>\n\t\t\t| type.infer<e, $>\n\t\t\t| type.infer<f, $>\n\t\t\t| type.infer<g, $>\n\t\t\t| type.infer<h, $>\n\t\t\t| type.infer<i, $>\n\t\t\t| type.infer<j, $>\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>,\n\t\td: type.validate<d, $>,\n\t\te: type.validate<e, $>,\n\t\tf: type.validate<f, $>,\n\t\tg: type.validate<g, $>,\n\t\th: type.validate<h, $>,\n\t\ti: type.validate<i, $>,\n\t\tj: type.validate<j, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tconst i,\n\t\tconst j,\n\t\tconst k,\n\t\tr = Type<\n\t\t\t| type.infer<a, $>\n\t\t\t| type.infer<b, $>\n\t\t\t| type.infer<c, $>\n\t\t\t| type.infer<d, $>\n\t\t\t| type.infer<e, $>\n\t\t\t| type.infer<f, $>\n\t\t\t| type.infer<g, $>\n\t\t\t| type.infer<h, $>\n\t\t\t| type.infer<i, $>\n\t\t\t| type.infer<j, $>\n\t\t\t| type.infer<k, $>\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>,\n\t\td: type.validate<d, $>,\n\t\te: type.validate<e, $>,\n\t\tf: type.validate<f, $>,\n\t\tg: type.validate<g, $>,\n\t\th: type.validate<h, $>,\n\t\ti: type.validate<i, $>,\n\t\tj: type.validate<j, $>,\n\t\tk: type.validate<k, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tconst i,\n\t\tconst j,\n\t\tconst k,\n\t\tconst l,\n\t\tr = Type<\n\t\t\t| type.infer<a, $>\n\t\t\t| type.infer<b, $>\n\t\t\t| type.infer<c, $>\n\t\t\t| type.infer<d, $>\n\t\t\t| type.infer<e, $>\n\t\t\t| type.infer<f, $>\n\t\t\t| type.infer<g, $>\n\t\t\t| type.infer<h, $>\n\t\t\t| type.infer<i, $>\n\t\t\t| type.infer<j, $>\n\t\t\t| type.infer<k, $>\n\t\t\t| type.infer<l, $>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>,\n\t\td: type.validate<d, $>,\n\t\te: type.validate<e, $>,\n\t\tf: type.validate<f, $>,\n\t\tg: type.validate<g, $>,\n\t\th: type.validate<h, $>,\n\t\ti: type.validate<i, $>,\n\t\tj: type.validate<j, $>,\n\t\tk: type.validate<k, $>,\n\t\tl: type.validate<l, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tconst i,\n\t\tconst j,\n\t\tconst k,\n\t\tconst l,\n\t\tconst m,\n\t\tr = Type<\n\t\t\t| type.infer<a, $>\n\t\t\t| type.infer<b, $>\n\t\t\t| type.infer<c, $>\n\t\t\t| type.infer<d, $>\n\t\t\t| type.infer<e, $>\n\t\t\t| type.infer<f, $>\n\t\t\t| type.infer<g, $>\n\t\t\t| type.infer<h, $>\n\t\t\t| type.infer<i, $>\n\t\t\t| type.infer<j, $>\n\t\t\t| type.infer<k, $>\n\t\t\t| type.infer<l, $>\n\t\t\t| type.infer<m, $>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>,\n\t\td: type.validate<d, $>,\n\t\te: type.validate<e, $>,\n\t\tf: type.validate<f, $>,\n\t\tg: type.validate<g, $>,\n\t\th: type.validate<h, $>,\n\t\ti: type.validate<i, $>,\n\t\tj: type.validate<j, $>,\n\t\tk: type.validate<k, $>,\n\t\tl: type.validate<l, $>,\n\t\tm: type.validate<m, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tconst i,\n\t\tconst j,\n\t\tconst k,\n\t\tconst l,\n\t\tconst m,\n\t\tconst n,\n\t\tr = Type<\n\t\t\t| type.infer<a, $>\n\t\t\t| type.infer<b, $>\n\t\t\t| type.infer<c, $>\n\t\t\t| type.infer<d, $>\n\t\t\t| type.infer<e, $>\n\t\t\t| type.infer<f, $>\n\t\t\t| type.infer<g, $>\n\t\t\t| type.infer<h, $>\n\t\t\t| type.infer<i, $>\n\t\t\t| type.infer<j, $>\n\t\t\t| type.infer<k, $>\n\t\t\t| type.infer<l, $>\n\t\t\t| type.infer<m, $>\n\t\t\t| type.infer<n, $>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>,\n\t\td: type.validate<d, $>,\n\t\te: type.validate<e, $>,\n\t\tf: type.validate<f, $>,\n\t\tg: type.validate<g, $>,\n\t\th: type.validate<h, $>,\n\t\ti: type.validate<i, $>,\n\t\tj: type.validate<j, $>,\n\t\tk: type.validate<k, $>,\n\t\tl: type.validate<l, $>,\n\t\tm: type.validate<m, $>,\n\t\tn: type.validate<n, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tconst i,\n\t\tconst j,\n\t\tconst k,\n\t\tconst l,\n\t\tconst m,\n\t\tconst n,\n\t\tconst o,\n\t\tr = Type<\n\t\t\t| type.infer<a, $>\n\t\t\t| type.infer<b, $>\n\t\t\t| type.infer<c, $>\n\t\t\t| type.infer<d, $>\n\t\t\t| type.infer<e, $>\n\t\t\t| type.infer<f, $>\n\t\t\t| type.infer<g, $>\n\t\t\t| type.infer<h, $>\n\t\t\t| type.infer<i, $>\n\t\t\t| type.infer<j, $>\n\t\t\t| type.infer<k, $>\n\t\t\t| type.infer<l, $>\n\t\t\t| type.infer<m, $>\n\t\t\t| type.infer<n, $>\n\t\t\t| type.infer<o, $>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>,\n\t\td: type.validate<d, $>,\n\t\te: type.validate<e, $>,\n\t\tf: type.validate<f, $>,\n\t\tg: type.validate<g, $>,\n\t\th: type.validate<h, $>,\n\t\ti: type.validate<i, $>,\n\t\tj: type.validate<j, $>,\n\t\tk: type.validate<k, $>,\n\t\tl: type.validate<l, $>,\n\t\tm: type.validate<m, $>,\n\t\tn: type.validate<n, $>,\n\t\to: type.validate<o, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tconst i,\n\t\tconst j,\n\t\tconst k,\n\t\tconst l,\n\t\tconst m,\n\t\tconst n,\n\t\tconst o,\n\t\tconst p,\n\t\tr = Type<\n\t\t\t| type.infer<a, $>\n\t\t\t| type.infer<b, $>\n\t\t\t| type.infer<c, $>\n\t\t\t| type.infer<d, $>\n\t\t\t| type.infer<e, $>\n\t\t\t| type.infer<f, $>\n\t\t\t| type.infer<g, $>\n\t\t\t| type.infer<h, $>\n\t\t\t| type.infer<i, $>\n\t\t\t| type.infer<j, $>\n\t\t\t| type.infer<k, $>\n\t\t\t| type.infer<l, $>\n\t\t\t| type.infer<m, $>\n\t\t\t| type.infer<n, $>\n\t\t\t| type.infer<o, $>\n\t\t\t| type.infer<p, $>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>,\n\t\td: type.validate<d, $>,\n\t\te: type.validate<e, $>,\n\t\tf: type.validate<f, $>,\n\t\tg: type.validate<g, $>,\n\t\th: type.validate<h, $>,\n\t\ti: type.validate<i, $>,\n\t\tj: type.validate<j, $>,\n\t\tk: type.validate<k, $>,\n\t\tl: type.validate<l, $>,\n\t\tm: type.validate<m, $>,\n\t\tn: type.validate<n, $>,\n\t\to: type.validate<o, $>,\n\t\tp: type.validate<p, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tconst i,\n\t\tconst j,\n\t\tconst k,\n\t\tconst l,\n\t\tconst m,\n\t\tconst n,\n\t\tconst o,\n\t\tconst p,\n\t\tconst q,\n\t\tr = Type<\n\t\t\t| type.infer<a, $>\n\t\t\t| type.infer<b, $>\n\t\t\t| type.infer<c, $>\n\t\t\t| type.infer<d, $>\n\t\t\t| type.infer<e, $>\n\t\t\t| type.infer<f, $>\n\t\t\t| type.infer<g, $>\n\t\t\t| type.infer<h, $>\n\t\t\t| type.infer<i, $>\n\t\t\t| type.infer<j, $>\n\t\t\t| type.infer<k, $>\n\t\t\t| type.infer<l, $>\n\t\t\t| type.infer<m, $>\n\t\t\t| type.infer<n, $>\n\t\t\t| type.infer<o, $>\n\t\t\t| type.infer<p, $>\n\t\t\t| type.infer<q, $>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>,\n\t\td: type.validate<d, $>,\n\t\te: type.validate<e, $>,\n\t\tf: type.validate<f, $>,\n\t\tg: type.validate<g, $>,\n\t\th: type.validate<h, $>,\n\t\ti: type.validate<i, $>,\n\t\tj: type.validate<j, $>,\n\t\tk: type.validate<k, $>,\n\t\tl: type.validate<l, $>,\n\t\tm: type.validate<m, $>,\n\t\tn: type.validate<n, $>,\n\t\to: type.validate<o, $>,\n\t\tp: type.validate<p, $>,\n\t\tq: type.validate<q, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst defs extends readonly unknown[],\n\t\tr = Type<type.infer<defs[number], $>, $>\n\t>(\n\t\t...defs: { [i in keyof defs]: type.validate<defs[i], $> }\n\t): r extends infer _ ? _ : never\n}\n\nexport type NaryIntersectionParser<$> = {\n\t(): Type<unknown, $>\n\t<const a, r = Type<type.infer<a, $>, $>>(\n\t\ta: type.validate<a, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tr = Type<inferIntersection<type.infer<a, $>, type.infer<b, $>>, $>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tr = Type<\n\t\t\tinferNaryIntersection<\n\t\t\t\t[type.infer<a, $>, type.infer<b, $>, type.infer<c, $>]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tr = Type<\n\t\t\tinferNaryIntersection<\n\t\t\t\t[type.infer<a, $>, type.infer<b, $>, type.infer<c, $>, type.infer<d, $>]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>,\n\t\td: type.validate<d, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tr = Type<\n\t\t\tinferNaryIntersection<\n\t\t\t\t[\n\t\t\t\t\ttype.infer<a, $>,\n\t\t\t\t\ttype.infer<b, $>,\n\t\t\t\t\ttype.infer<c, $>,\n\t\t\t\t\ttype.infer<d, $>,\n\t\t\t\t\ttype.infer<e, $>\n\t\t\t\t]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>,\n\t\td: type.validate<d, $>,\n\t\te: type.validate<e, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tr = Type<\n\t\t\tinferNaryIntersection<\n\t\t\t\t[\n\t\t\t\t\ttype.infer<a, $>,\n\t\t\t\t\ttype.infer<b, $>,\n\t\t\t\t\ttype.infer<c, $>,\n\t\t\t\t\ttype.infer<d, $>,\n\t\t\t\t\ttype.infer<e, $>,\n\t\t\t\t\ttype.infer<f, $>\n\t\t\t\t]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>,\n\t\td: type.validate<d, $>,\n\t\te: type.validate<e, $>,\n\t\tf: type.validate<f, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tr = Type<\n\t\t\tinferNaryIntersection<\n\t\t\t\t[\n\t\t\t\t\ttype.infer<a, $>,\n\t\t\t\t\ttype.infer<b, $>,\n\t\t\t\t\ttype.infer<c, $>,\n\t\t\t\t\ttype.infer<d, $>,\n\t\t\t\t\ttype.infer<e, $>,\n\t\t\t\t\ttype.infer<f, $>,\n\t\t\t\t\ttype.infer<g, $>\n\t\t\t\t]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>,\n\t\td: type.validate<d, $>,\n\t\te: type.validate<e, $>,\n\t\tf: type.validate<f, $>,\n\t\tg: type.validate<g, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tr = Type<\n\t\t\tinferNaryIntersection<\n\t\t\t\t[\n\t\t\t\t\ttype.infer<a, $>,\n\t\t\t\t\ttype.infer<b, $>,\n\t\t\t\t\ttype.infer<c, $>,\n\t\t\t\t\ttype.infer<d, $>,\n\t\t\t\t\ttype.infer<e, $>,\n\t\t\t\t\ttype.infer<f, $>,\n\t\t\t\t\ttype.infer<g, $>,\n\t\t\t\t\ttype.infer<h, $>\n\t\t\t\t]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>,\n\t\td: type.validate<d, $>,\n\t\te: type.validate<e, $>,\n\t\tf: type.validate<f, $>,\n\t\tg: type.validate<g, $>,\n\t\th: type.validate<h, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tconst i,\n\t\tr = Type<\n\t\t\tinferNaryIntersection<\n\t\t\t\t[\n\t\t\t\t\ttype.infer<a, $>,\n\t\t\t\t\ttype.infer<b, $>,\n\t\t\t\t\ttype.infer<c, $>,\n\t\t\t\t\ttype.infer<d, $>,\n\t\t\t\t\ttype.infer<e, $>,\n\t\t\t\t\ttype.infer<f, $>,\n\t\t\t\t\ttype.infer<g, $>,\n\t\t\t\t\ttype.infer<h, $>,\n\t\t\t\t\ttype.infer<i, $>\n\t\t\t\t]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>,\n\t\td: type.validate<d, $>,\n\t\te: type.validate<e, $>,\n\t\tf: type.validate<f, $>,\n\t\tg: type.validate<g, $>,\n\t\th: type.validate<h, $>,\n\t\ti: type.validate<i, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tconst i,\n\t\tconst j,\n\t\tr = Type<\n\t\t\tinferNaryIntersection<\n\t\t\t\t[\n\t\t\t\t\ttype.infer<a, $>,\n\t\t\t\t\ttype.infer<b, $>,\n\t\t\t\t\ttype.infer<c, $>,\n\t\t\t\t\ttype.infer<d, $>,\n\t\t\t\t\ttype.infer<e, $>,\n\t\t\t\t\ttype.infer<f, $>,\n\t\t\t\t\ttype.infer<g, $>,\n\t\t\t\t\ttype.infer<h, $>,\n\t\t\t\t\ttype.infer<i, $>,\n\t\t\t\t\ttype.infer<j, $>\n\t\t\t\t]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>,\n\t\td: type.validate<d, $>,\n\t\te: type.validate<e, $>,\n\t\tf: type.validate<f, $>,\n\t\tg: type.validate<g, $>,\n\t\th: type.validate<h, $>,\n\t\ti: type.validate<i, $>,\n\t\tj: type.validate<j, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tconst i,\n\t\tconst j,\n\t\tconst k,\n\t\tr = Type<\n\t\t\tinferNaryIntersection<\n\t\t\t\t[\n\t\t\t\t\ttype.infer<a, $>,\n\t\t\t\t\ttype.infer<b, $>,\n\t\t\t\t\ttype.infer<c, $>,\n\t\t\t\t\ttype.infer<d, $>,\n\t\t\t\t\ttype.infer<e, $>,\n\t\t\t\t\ttype.infer<f, $>,\n\t\t\t\t\ttype.infer<g, $>,\n\t\t\t\t\ttype.infer<h, $>,\n\t\t\t\t\ttype.infer<i, $>,\n\t\t\t\t\ttype.infer<j, $>,\n\t\t\t\t\ttype.infer<k, $>\n\t\t\t\t]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>,\n\t\td: type.validate<d, $>,\n\t\te: type.validate<e, $>,\n\t\tf: type.validate<f, $>,\n\t\tg: type.validate<g, $>,\n\t\th: type.validate<h, $>,\n\t\ti: type.validate<i, $>,\n\t\tj: type.validate<j, $>,\n\t\tk: type.validate<k, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tconst i,\n\t\tconst j,\n\t\tconst k,\n\t\tconst l,\n\t\tr = Type<\n\t\t\tinferNaryIntersection<\n\t\t\t\t[\n\t\t\t\t\ttype.infer<a, $>,\n\t\t\t\t\ttype.infer<b, $>,\n\t\t\t\t\ttype.infer<c, $>,\n\t\t\t\t\ttype.infer<d, $>,\n\t\t\t\t\ttype.infer<e, $>,\n\t\t\t\t\ttype.infer<f, $>,\n\t\t\t\t\ttype.infer<g, $>,\n\t\t\t\t\ttype.infer<h, $>,\n\t\t\t\t\ttype.infer<i, $>,\n\t\t\t\t\ttype.infer<j, $>,\n\t\t\t\t\ttype.infer<k, $>,\n\t\t\t\t\ttype.infer<l, $>\n\t\t\t\t]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>,\n\t\td: type.validate<d, $>,\n\t\te: type.validate<e, $>,\n\t\tf: type.validate<f, $>,\n\t\tg: type.validate<g, $>,\n\t\th: type.validate<h, $>,\n\t\ti: type.validate<i, $>,\n\t\tj: type.validate<j, $>,\n\t\tk: type.validate<k, $>,\n\t\tl: type.validate<l, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tconst i,\n\t\tconst j,\n\t\tconst k,\n\t\tconst l,\n\t\tconst m,\n\t\tr = Type<\n\t\t\tinferNaryIntersection<\n\t\t\t\t[\n\t\t\t\t\ttype.infer<a, $>,\n\t\t\t\t\ttype.infer<b, $>,\n\t\t\t\t\ttype.infer<c, $>,\n\t\t\t\t\ttype.infer<d, $>,\n\t\t\t\t\ttype.infer<e, $>,\n\t\t\t\t\ttype.infer<f, $>,\n\t\t\t\t\ttype.infer<g, $>,\n\t\t\t\t\ttype.infer<h, $>,\n\t\t\t\t\ttype.infer<i, $>,\n\t\t\t\t\ttype.infer<j, $>,\n\t\t\t\t\ttype.infer<k, $>,\n\t\t\t\t\ttype.infer<l, $>,\n\t\t\t\t\ttype.infer<m, $>\n\t\t\t\t]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>,\n\t\td: type.validate<d, $>,\n\t\te: type.validate<e, $>,\n\t\tf: type.validate<f, $>,\n\t\tg: type.validate<g, $>,\n\t\th: type.validate<h, $>,\n\t\ti: type.validate<i, $>,\n\t\tj: type.validate<j, $>,\n\t\tk: type.validate<k, $>,\n\t\tl: type.validate<l, $>,\n\t\tm: type.validate<m, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tconst i,\n\t\tconst j,\n\t\tconst k,\n\t\tconst l,\n\t\tconst m,\n\t\tconst n,\n\t\tr = Type<\n\t\t\tinferNaryIntersection<\n\t\t\t\t[\n\t\t\t\t\ttype.infer<a, $>,\n\t\t\t\t\ttype.infer<b, $>,\n\t\t\t\t\ttype.infer<c, $>,\n\t\t\t\t\ttype.infer<d, $>,\n\t\t\t\t\ttype.infer<e, $>,\n\t\t\t\t\ttype.infer<f, $>,\n\t\t\t\t\ttype.infer<g, $>,\n\t\t\t\t\ttype.infer<h, $>,\n\t\t\t\t\ttype.infer<i, $>,\n\t\t\t\t\ttype.infer<j, $>,\n\t\t\t\t\ttype.infer<k, $>,\n\t\t\t\t\ttype.infer<l, $>,\n\t\t\t\t\ttype.infer<m, $>,\n\t\t\t\t\ttype.infer<n, $>\n\t\t\t\t]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>,\n\t\td: type.validate<d, $>,\n\t\te: type.validate<e, $>,\n\t\tf: type.validate<f, $>,\n\t\tg: type.validate<g, $>,\n\t\th: type.validate<h, $>,\n\t\ti: type.validate<i, $>,\n\t\tj: type.validate<j, $>,\n\t\tk: type.validate<k, $>,\n\t\tl: type.validate<l, $>,\n\t\tm: type.validate<m, $>,\n\t\tn: type.validate<n, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tconst i,\n\t\tconst j,\n\t\tconst k,\n\t\tconst l,\n\t\tconst m,\n\t\tconst n,\n\t\tconst o,\n\t\tr = Type<\n\t\t\tinferNaryIntersection<\n\t\t\t\t[\n\t\t\t\t\ttype.infer<a, $>,\n\t\t\t\t\ttype.infer<b, $>,\n\t\t\t\t\ttype.infer<c, $>,\n\t\t\t\t\ttype.infer<d, $>,\n\t\t\t\t\ttype.infer<e, $>,\n\t\t\t\t\ttype.infer<f, $>,\n\t\t\t\t\ttype.infer<g, $>,\n\t\t\t\t\ttype.infer<h, $>,\n\t\t\t\t\ttype.infer<i, $>,\n\t\t\t\t\ttype.infer<j, $>,\n\t\t\t\t\ttype.infer<k, $>,\n\t\t\t\t\ttype.infer<l, $>,\n\t\t\t\t\ttype.infer<m, $>,\n\t\t\t\t\ttype.infer<n, $>,\n\t\t\t\t\ttype.infer<o, $>\n\t\t\t\t]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>,\n\t\td: type.validate<d, $>,\n\t\te: type.validate<e, $>,\n\t\tf: type.validate<f, $>,\n\t\tg: type.validate<g, $>,\n\t\th: type.validate<h, $>,\n\t\ti: type.validate<i, $>,\n\t\tj: type.validate<j, $>,\n\t\tk: type.validate<k, $>,\n\t\tl: type.validate<l, $>,\n\t\tm: type.validate<m, $>,\n\t\tn: type.validate<n, $>,\n\t\to: type.validate<o, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tconst i,\n\t\tconst j,\n\t\tconst k,\n\t\tconst l,\n\t\tconst m,\n\t\tconst n,\n\t\tconst o,\n\t\tconst p,\n\t\tr = Type<\n\t\t\tinferNaryIntersection<\n\t\t\t\t[\n\t\t\t\t\ttype.infer<a, $>,\n\t\t\t\t\ttype.infer<b, $>,\n\t\t\t\t\ttype.infer<c, $>,\n\t\t\t\t\ttype.infer<d, $>,\n\t\t\t\t\ttype.infer<e, $>,\n\t\t\t\t\ttype.infer<f, $>,\n\t\t\t\t\ttype.infer<g, $>,\n\t\t\t\t\ttype.infer<h, $>,\n\t\t\t\t\ttype.infer<i, $>,\n\t\t\t\t\ttype.infer<j, $>,\n\t\t\t\t\ttype.infer<k, $>,\n\t\t\t\t\ttype.infer<l, $>,\n\t\t\t\t\ttype.infer<m, $>,\n\t\t\t\t\ttype.infer<n, $>,\n\t\t\t\t\ttype.infer<o, $>,\n\t\t\t\t\ttype.infer<p, $>\n\t\t\t\t]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>,\n\t\td: type.validate<d, $>,\n\t\te: type.validate<e, $>,\n\t\tf: type.validate<f, $>,\n\t\tg: type.validate<g, $>,\n\t\th: type.validate<h, $>,\n\t\ti: type.validate<i, $>,\n\t\tj: type.validate<j, $>,\n\t\tk: type.validate<k, $>,\n\t\tl: type.validate<l, $>,\n\t\tm: type.validate<m, $>,\n\t\tn: type.validate<n, $>,\n\t\to: type.validate<o, $>,\n\t\tp: type.validate<p, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tconst i,\n\t\tconst j,\n\t\tconst k,\n\t\tconst l,\n\t\tconst m,\n\t\tconst n,\n\t\tconst o,\n\t\tconst p,\n\t\tconst q,\n\t\tr = Type<\n\t\t\tinferNaryIntersection<\n\t\t\t\t[\n\t\t\t\t\ttype.infer<a, $>,\n\t\t\t\t\ttype.infer<b, $>,\n\t\t\t\t\ttype.infer<c, $>,\n\t\t\t\t\ttype.infer<d, $>,\n\t\t\t\t\ttype.infer<e, $>,\n\t\t\t\t\ttype.infer<f, $>,\n\t\t\t\t\ttype.infer<g, $>,\n\t\t\t\t\ttype.infer<h, $>,\n\t\t\t\t\ttype.infer<i, $>,\n\t\t\t\t\ttype.infer<j, $>,\n\t\t\t\t\ttype.infer<k, $>,\n\t\t\t\t\ttype.infer<l, $>,\n\t\t\t\t\ttype.infer<m, $>,\n\t\t\t\t\ttype.infer<n, $>,\n\t\t\t\t\ttype.infer<o, $>,\n\t\t\t\t\ttype.infer<p, $>,\n\t\t\t\t\ttype.infer<q, $>\n\t\t\t\t]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $>,\n\t\tb: type.validate<b, $>,\n\t\tc: type.validate<c, $>,\n\t\td: type.validate<d, $>,\n\t\te: type.validate<e, $>,\n\t\tf: type.validate<f, $>,\n\t\tg: type.validate<g, $>,\n\t\th: type.validate<h, $>,\n\t\ti: type.validate<i, $>,\n\t\tj: type.validate<j, $>,\n\t\tk: type.validate<k, $>,\n\t\tl: type.validate<l, $>,\n\t\tm: type.validate<m, $>,\n\t\tn: type.validate<n, $>,\n\t\to: type.validate<o, $>,\n\t\tp: type.validate<p, $>,\n\t\tq: type.validate<q, $>\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst defs extends readonly unknown[],\n\t\tr = Type<\n\t\t\tinferNaryIntersection<{ [i in keyof defs]: type.infer<defs[i], $> }>,\n\t\t\t$\n\t\t>\n\t>(\n\t\t...defs: { [i in keyof defs]: type.validate<defs[i], $> }\n\t): r extends infer _ ? _ : never\n}\n\nexport type NaryMergeParser<$> = {\n\t(): Type<object, $>\n\t<const a, inferredA = type.infer<a, $>, r = Type<inferredA, $>>(\n\t\ta: type.validate<a, $> &\n\t\t\t// if you can figure out a way to avoid inlining this without\n\t\t\t// breaking autocomplete and error display, do it!\n\t\t\t(inferredA extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>)\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tinferredA = type.infer<a, $>,\n\t\tinferredB = type.infer<b, $>,\n\t\tr = Type<merge<inferredA, inferredB>, $>\n\t>(\n\t\ta: type.validate<a, $> &\n\t\t\t(inferredA extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>),\n\t\tb: type.validate<b, $> &\n\t\t\t(inferredB extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>)\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tinferredA = type.infer<a, $>,\n\t\tinferredB = type.infer<b, $>,\n\t\tinferredC = type.infer<c, $>,\n\t\tr = Type<inferNaryMerge<[inferredA, inferredB, inferredC]>, $>\n\t>(\n\t\ta: type.validate<a, $> &\n\t\t\t(inferredA extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>),\n\t\tb: type.validate<b, $> &\n\t\t\t(inferredB extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>),\n\t\tc: type.validate<c, $> &\n\t\t\t(inferredC extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>)\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tinferredA = type.infer<a, $>,\n\t\tinferredB = type.infer<b, $>,\n\t\tinferredC = type.infer<c, $>,\n\t\tinferredD = type.infer<d, $>,\n\t\tr = Type<inferNaryMerge<[inferredA, inferredB, inferredC, inferredD]>, $>\n\t>(\n\t\ta: type.validate<a, $> &\n\t\t\t(inferredA extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>),\n\t\tb: type.validate<b, $> &\n\t\t\t(inferredB extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>),\n\t\tc: type.validate<c, $> &\n\t\t\t(inferredC extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>),\n\t\td: type.validate<d, $> &\n\t\t\t(inferredD extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredD]>)\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tinferredA = type.infer<a, $>,\n\t\tinferredB = type.infer<b, $>,\n\t\tinferredC = type.infer<c, $>,\n\t\tinferredD = type.infer<d, $>,\n\t\tinferredE = type.infer<e, $>,\n\t\tr = Type<\n\t\t\tinferNaryMerge<[inferredA, inferredB, inferredC, inferredD, inferredE]>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $> &\n\t\t\t(inferredA extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>),\n\t\tb: type.validate<b, $> &\n\t\t\t(inferredB extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>),\n\t\tc: type.validate<c, $> &\n\t\t\t(inferredC extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>),\n\t\td: type.validate<d, $> &\n\t\t\t(inferredD extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredD]>),\n\t\te: type.validate<e, $> &\n\t\t\t(inferredE extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredE]>)\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tinferredA = type.infer<a, $>,\n\t\tinferredB = type.infer<b, $>,\n\t\tinferredC = type.infer<c, $>,\n\t\tinferredD = type.infer<d, $>,\n\t\tinferredE = type.infer<e, $>,\n\t\tinferredF = type.infer<f, $>,\n\t\tr = Type<\n\t\t\tinferNaryMerge<\n\t\t\t\t[inferredA, inferredB, inferredC, inferredD, inferredE, inferredF]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $> &\n\t\t\t(inferredA extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>),\n\t\tb: type.validate<b, $> &\n\t\t\t(inferredB extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>),\n\t\tc: type.validate<c, $> &\n\t\t\t(inferredC extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>),\n\t\td: type.validate<d, $> &\n\t\t\t(inferredD extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredD]>),\n\t\te: type.validate<e, $> &\n\t\t\t(inferredE extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredE]>),\n\t\tf: type.validate<f, $> &\n\t\t\t(inferredF extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredF]>)\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tinferredA = type.infer<a, $>,\n\t\tinferredB = type.infer<b, $>,\n\t\tinferredC = type.infer<c, $>,\n\t\tinferredD = type.infer<d, $>,\n\t\tinferredE = type.infer<e, $>,\n\t\tinferredF = type.infer<f, $>,\n\t\tinferredG = type.infer<g, $>,\n\t\tr = Type<\n\t\t\tinferNaryMerge<\n\t\t\t\t[\n\t\t\t\t\tinferredA,\n\t\t\t\t\tinferredB,\n\t\t\t\t\tinferredC,\n\t\t\t\t\tinferredD,\n\t\t\t\t\tinferredE,\n\t\t\t\t\tinferredF,\n\t\t\t\t\tinferredG\n\t\t\t\t]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $> &\n\t\t\t(inferredA extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>),\n\t\tb: type.validate<b, $> &\n\t\t\t(inferredB extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>),\n\t\tc: type.validate<c, $> &\n\t\t\t(inferredC extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>),\n\t\td: type.validate<d, $> &\n\t\t\t(inferredD extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredD]>),\n\t\te: type.validate<e, $> &\n\t\t\t(inferredE extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredE]>),\n\t\tf: type.validate<f, $> &\n\t\t\t(inferredF extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredF]>),\n\t\tg: type.validate<g, $> &\n\t\t\t(inferredG extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredG]>)\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tinferredA = type.infer<a, $>,\n\t\tinferredB = type.infer<b, $>,\n\t\tinferredC = type.infer<c, $>,\n\t\tinferredD = type.infer<d, $>,\n\t\tinferredE = type.infer<e, $>,\n\t\tinferredF = type.infer<f, $>,\n\t\tinferredG = type.infer<g, $>,\n\t\tinferredH = type.infer<h, $>,\n\t\tr = Type<\n\t\t\tinferNaryMerge<\n\t\t\t\t[\n\t\t\t\t\tinferredA,\n\t\t\t\t\tinferredB,\n\t\t\t\t\tinferredC,\n\t\t\t\t\tinferredD,\n\t\t\t\t\tinferredE,\n\t\t\t\t\tinferredF,\n\t\t\t\t\tinferredG,\n\t\t\t\t\tinferredH\n\t\t\t\t]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $> &\n\t\t\t(inferredA extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>),\n\t\tb: type.validate<b, $> &\n\t\t\t(inferredB extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>),\n\t\tc: type.validate<c, $> &\n\t\t\t(inferredC extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>),\n\t\td: type.validate<d, $> &\n\t\t\t(inferredD extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredD]>),\n\t\te: type.validate<e, $> &\n\t\t\t(inferredE extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredE]>),\n\t\tf: type.validate<f, $> &\n\t\t\t(inferredF extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredF]>),\n\t\tg: type.validate<g, $> &\n\t\t\t(inferredG extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredG]>),\n\t\th: type.validate<h, $> &\n\t\t\t(inferredH extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredH]>)\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tconst i,\n\t\tinferredA = type.infer<a, $>,\n\t\tinferredB = type.infer<b, $>,\n\t\tinferredC = type.infer<c, $>,\n\t\tinferredD = type.infer<d, $>,\n\t\tinferredE = type.infer<e, $>,\n\t\tinferredF = type.infer<f, $>,\n\t\tinferredG = type.infer<g, $>,\n\t\tinferredH = type.infer<h, $>,\n\t\tinferredI = type.infer<i, $>,\n\t\tr = Type<\n\t\t\tinferNaryMerge<\n\t\t\t\t[\n\t\t\t\t\tinferredA,\n\t\t\t\t\tinferredB,\n\t\t\t\t\tinferredC,\n\t\t\t\t\tinferredD,\n\t\t\t\t\tinferredE,\n\t\t\t\t\tinferredF,\n\t\t\t\t\tinferredG,\n\t\t\t\t\tinferredH,\n\t\t\t\t\tinferredI\n\t\t\t\t]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $> &\n\t\t\t(inferredA extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>),\n\t\tb: type.validate<b, $> &\n\t\t\t(inferredB extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>),\n\t\tc: type.validate<c, $> &\n\t\t\t(inferredC extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>),\n\t\td: type.validate<d, $> &\n\t\t\t(inferredD extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredD]>),\n\t\te: type.validate<e, $> &\n\t\t\t(inferredE extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredE]>),\n\t\tf: type.validate<f, $> &\n\t\t\t(inferredF extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredF]>),\n\t\tg: type.validate<g, $> &\n\t\t\t(inferredG extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredG]>),\n\t\th: type.validate<h, $> &\n\t\t\t(inferredH extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredH]>),\n\t\ti: type.validate<i, $> &\n\t\t\t(inferredI extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredI]>)\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tconst i,\n\t\tconst j,\n\t\tinferredA = type.infer<a, $>,\n\t\tinferredB = type.infer<b, $>,\n\t\tinferredC = type.infer<c, $>,\n\t\tinferredD = type.infer<d, $>,\n\t\tinferredE = type.infer<e, $>,\n\t\tinferredF = type.infer<f, $>,\n\t\tinferredG = type.infer<g, $>,\n\t\tinferredH = type.infer<h, $>,\n\t\tinferredI = type.infer<i, $>,\n\t\tinferredJ = type.infer<j, $>,\n\t\tr = Type<\n\t\t\tinferNaryMerge<\n\t\t\t\t[\n\t\t\t\t\tinferredA,\n\t\t\t\t\tinferredB,\n\t\t\t\t\tinferredC,\n\t\t\t\t\tinferredD,\n\t\t\t\t\tinferredE,\n\t\t\t\t\tinferredF,\n\t\t\t\t\tinferredG,\n\t\t\t\t\tinferredH,\n\t\t\t\t\tinferredI,\n\t\t\t\t\tinferredJ\n\t\t\t\t]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $> &\n\t\t\t(inferredA extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>),\n\t\tb: type.validate<b, $> &\n\t\t\t(inferredB extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>),\n\t\tc: type.validate<c, $> &\n\t\t\t(inferredC extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>),\n\t\td: type.validate<d, $> &\n\t\t\t(inferredD extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredD]>),\n\t\te: type.validate<e, $> &\n\t\t\t(inferredE extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredE]>),\n\t\tf: type.validate<f, $> &\n\t\t\t(inferredF extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredF]>),\n\t\tg: type.validate<g, $> &\n\t\t\t(inferredG extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredG]>),\n\t\th: type.validate<h, $> &\n\t\t\t(inferredH extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredH]>),\n\t\ti: type.validate<i, $> &\n\t\t\t(inferredI extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredI]>),\n\t\tj: type.validate<j, $> &\n\t\t\t(inferredJ extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredJ]>)\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tconst i,\n\t\tconst j,\n\t\tconst k,\n\t\tinferredA = type.infer<a, $>,\n\t\tinferredB = type.infer<b, $>,\n\t\tinferredC = type.infer<c, $>,\n\t\tinferredD = type.infer<d, $>,\n\t\tinferredE = type.infer<e, $>,\n\t\tinferredF = type.infer<f, $>,\n\t\tinferredG = type.infer<g, $>,\n\t\tinferredH = type.infer<h, $>,\n\t\tinferredI = type.infer<i, $>,\n\t\tinferredJ = type.infer<j, $>,\n\t\tinferredK = type.infer<k, $>,\n\t\tr = Type<\n\t\t\tinferNaryMerge<\n\t\t\t\t[\n\t\t\t\t\tinferredA,\n\t\t\t\t\tinferredB,\n\t\t\t\t\tinferredC,\n\t\t\t\t\tinferredD,\n\t\t\t\t\tinferredE,\n\t\t\t\t\tinferredF,\n\t\t\t\t\tinferredG,\n\t\t\t\t\tinferredH,\n\t\t\t\t\tinferredI,\n\t\t\t\t\tinferredJ,\n\t\t\t\t\tinferredK\n\t\t\t\t]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $> &\n\t\t\t(inferredA extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>),\n\t\tb: type.validate<b, $> &\n\t\t\t(inferredB extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>),\n\t\tc: type.validate<c, $> &\n\t\t\t(inferredC extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>),\n\t\td: type.validate<d, $> &\n\t\t\t(inferredD extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredD]>),\n\t\te: type.validate<e, $> &\n\t\t\t(inferredE extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredE]>),\n\t\tf: type.validate<f, $> &\n\t\t\t(inferredF extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredF]>),\n\t\tg: type.validate<g, $> &\n\t\t\t(inferredG extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredG]>),\n\t\th: type.validate<h, $> &\n\t\t\t(inferredH extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredH]>),\n\t\ti: type.validate<i, $> &\n\t\t\t(inferredI extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredI]>),\n\t\tj: type.validate<j, $> &\n\t\t\t(inferredJ extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredJ]>),\n\t\tk: type.validate<k, $> &\n\t\t\t(inferredK extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredK]>)\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tconst i,\n\t\tconst j,\n\t\tconst k,\n\t\tconst l,\n\t\tinferredA = type.infer<a, $>,\n\t\tinferredB = type.infer<b, $>,\n\t\tinferredC = type.infer<c, $>,\n\t\tinferredD = type.infer<d, $>,\n\t\tinferredE = type.infer<e, $>,\n\t\tinferredF = type.infer<f, $>,\n\t\tinferredG = type.infer<g, $>,\n\t\tinferredH = type.infer<h, $>,\n\t\tinferredI = type.infer<i, $>,\n\t\tinferredJ = type.infer<j, $>,\n\t\tinferredK = type.infer<k, $>,\n\t\tinferredL = type.infer<l, $>,\n\t\tr = Type<\n\t\t\tinferNaryMerge<\n\t\t\t\t[\n\t\t\t\t\tinferredA,\n\t\t\t\t\tinferredB,\n\t\t\t\t\tinferredC,\n\t\t\t\t\tinferredD,\n\t\t\t\t\tinferredE,\n\t\t\t\t\tinferredF,\n\t\t\t\t\tinferredG,\n\t\t\t\t\tinferredH,\n\t\t\t\t\tinferredI,\n\t\t\t\t\tinferredJ,\n\t\t\t\t\tinferredK,\n\t\t\t\t\tinferredL\n\t\t\t\t]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $> &\n\t\t\t(inferredA extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>),\n\t\tb: type.validate<b, $> &\n\t\t\t(inferredB extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>),\n\t\tc: type.validate<c, $> &\n\t\t\t(inferredC extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>),\n\t\td: type.validate<d, $> &\n\t\t\t(inferredD extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredD]>),\n\t\te: type.validate<e, $> &\n\t\t\t(inferredE extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredE]>),\n\t\tf: type.validate<f, $> &\n\t\t\t(inferredF extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredF]>),\n\t\tg: type.validate<g, $> &\n\t\t\t(inferredG extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredG]>),\n\t\th: type.validate<h, $> &\n\t\t\t(inferredH extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredH]>),\n\t\ti: type.validate<i, $> &\n\t\t\t(inferredI extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredI]>),\n\t\tj: type.validate<j, $> &\n\t\t\t(inferredJ extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredJ]>),\n\t\tk: type.validate<k, $> &\n\t\t\t(inferredK extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredK]>),\n\t\tl: type.validate<l, $> &\n\t\t\t(inferredL extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredL]>)\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tconst i,\n\t\tconst j,\n\t\tconst k,\n\t\tconst l,\n\t\tconst m,\n\t\tinferredA = type.infer<a, $>,\n\t\tinferredB = type.infer<b, $>,\n\t\tinferredC = type.infer<c, $>,\n\t\tinferredD = type.infer<d, $>,\n\t\tinferredE = type.infer<e, $>,\n\t\tinferredF = type.infer<f, $>,\n\t\tinferredG = type.infer<g, $>,\n\t\tinferredH = type.infer<h, $>,\n\t\tinferredI = type.infer<i, $>,\n\t\tinferredJ = type.infer<j, $>,\n\t\tinferredK = type.infer<k, $>,\n\t\tinferredL = type.infer<l, $>,\n\t\tinferredM = type.infer<m, $>,\n\t\tr = Type<\n\t\t\tinferNaryMerge<\n\t\t\t\t[\n\t\t\t\t\tinferredA,\n\t\t\t\t\tinferredB,\n\t\t\t\t\tinferredC,\n\t\t\t\t\tinferredD,\n\t\t\t\t\tinferredE,\n\t\t\t\t\tinferredF,\n\t\t\t\t\tinferredG,\n\t\t\t\t\tinferredH,\n\t\t\t\t\tinferredI,\n\t\t\t\t\tinferredJ,\n\t\t\t\t\tinferredK,\n\t\t\t\t\tinferredL,\n\t\t\t\t\tinferredM\n\t\t\t\t]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $> &\n\t\t\t(inferredA extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>),\n\t\tb: type.validate<b, $> &\n\t\t\t(inferredB extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>),\n\t\tc: type.validate<c, $> &\n\t\t\t(inferredC extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>),\n\t\td: type.validate<d, $> &\n\t\t\t(inferredD extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredD]>),\n\t\te: type.validate<e, $> &\n\t\t\t(inferredE extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredE]>),\n\t\tf: type.validate<f, $> &\n\t\t\t(inferredF extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredF]>),\n\t\tg: type.validate<g, $> &\n\t\t\t(inferredG extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredG]>),\n\t\th: type.validate<h, $> &\n\t\t\t(inferredH extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredH]>),\n\t\ti: type.validate<i, $> &\n\t\t\t(inferredI extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredI]>),\n\t\tj: type.validate<j, $> &\n\t\t\t(inferredJ extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredJ]>),\n\t\tk: type.validate<k, $> &\n\t\t\t(inferredK extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredK]>),\n\t\tl: type.validate<l, $> &\n\t\t\t(inferredL extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredL]>),\n\t\tm: type.validate<m, $> &\n\t\t\t(inferredM extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredM]>)\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tconst i,\n\t\tconst j,\n\t\tconst k,\n\t\tconst l,\n\t\tconst m,\n\t\tconst n,\n\t\tinferredA = type.infer<a, $>,\n\t\tinferredB = type.infer<b, $>,\n\t\tinferredC = type.infer<c, $>,\n\t\tinferredD = type.infer<d, $>,\n\t\tinferredE = type.infer<e, $>,\n\t\tinferredF = type.infer<f, $>,\n\t\tinferredG = type.infer<g, $>,\n\t\tinferredH = type.infer<h, $>,\n\t\tinferredI = type.infer<i, $>,\n\t\tinferredJ = type.infer<j, $>,\n\t\tinferredK = type.infer<k, $>,\n\t\tinferredL = type.infer<l, $>,\n\t\tinferredM = type.infer<m, $>,\n\t\tinferredN = type.infer<n, $>,\n\t\tr = Type<\n\t\t\tinferNaryMerge<\n\t\t\t\t[\n\t\t\t\t\tinferredA,\n\t\t\t\t\tinferredB,\n\t\t\t\t\tinferredC,\n\t\t\t\t\tinferredD,\n\t\t\t\t\tinferredE,\n\t\t\t\t\tinferredF,\n\t\t\t\t\tinferredG,\n\t\t\t\t\tinferredH,\n\t\t\t\t\tinferredI,\n\t\t\t\t\tinferredJ,\n\t\t\t\t\tinferredK,\n\t\t\t\t\tinferredL,\n\t\t\t\t\tinferredM,\n\t\t\t\t\tinferredN\n\t\t\t\t]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $> &\n\t\t\t(inferredA extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>),\n\t\tb: type.validate<b, $> &\n\t\t\t(inferredB extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>),\n\t\tc: type.validate<c, $> &\n\t\t\t(inferredC extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>),\n\t\td: type.validate<d, $> &\n\t\t\t(inferredD extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredD]>),\n\t\te: type.validate<e, $> &\n\t\t\t(inferredE extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredE]>),\n\t\tf: type.validate<f, $> &\n\t\t\t(inferredF extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredF]>),\n\t\tg: type.validate<g, $> &\n\t\t\t(inferredG extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredG]>),\n\t\th: type.validate<h, $> &\n\t\t\t(inferredH extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredH]>),\n\t\ti: type.validate<i, $> &\n\t\t\t(inferredI extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredI]>),\n\t\tj: type.validate<j, $> &\n\t\t\t(inferredJ extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredJ]>),\n\t\tk: type.validate<k, $> &\n\t\t\t(inferredK extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredK]>),\n\t\tl: type.validate<l, $> &\n\t\t\t(inferredL extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredL]>),\n\t\tm: type.validate<m, $> &\n\t\t\t(inferredM extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredM]>),\n\t\tn: type.validate<n, $> &\n\t\t\t(inferredN extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredN]>)\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tconst i,\n\t\tconst j,\n\t\tconst k,\n\t\tconst l,\n\t\tconst m,\n\t\tconst n,\n\t\tconst o,\n\t\tinferredA = type.infer<a, $>,\n\t\tinferredB = type.infer<b, $>,\n\t\tinferredC = type.infer<c, $>,\n\t\tinferredD = type.infer<d, $>,\n\t\tinferredE = type.infer<e, $>,\n\t\tinferredF = type.infer<f, $>,\n\t\tinferredG = type.infer<g, $>,\n\t\tinferredH = type.infer<h, $>,\n\t\tinferredI = type.infer<i, $>,\n\t\tinferredJ = type.infer<j, $>,\n\t\tinferredK = type.infer<k, $>,\n\t\tinferredL = type.infer<l, $>,\n\t\tinferredM = type.infer<m, $>,\n\t\tinferredN = type.infer<n, $>,\n\t\tinferredO = type.infer<o, $>,\n\t\tr = Type<\n\t\t\tinferNaryMerge<\n\t\t\t\t[\n\t\t\t\t\tinferredA,\n\t\t\t\t\tinferredB,\n\t\t\t\t\tinferredC,\n\t\t\t\t\tinferredD,\n\t\t\t\t\tinferredE,\n\t\t\t\t\tinferredF,\n\t\t\t\t\tinferredG,\n\t\t\t\t\tinferredH,\n\t\t\t\t\tinferredI,\n\t\t\t\t\tinferredJ,\n\t\t\t\t\tinferredK,\n\t\t\t\t\tinferredL,\n\t\t\t\t\tinferredM,\n\t\t\t\t\tinferredN,\n\t\t\t\t\tinferredO\n\t\t\t\t]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $> &\n\t\t\t(inferredA extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>),\n\t\tb: type.validate<b, $> &\n\t\t\t(inferredB extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>),\n\t\tc: type.validate<c, $> &\n\t\t\t(inferredC extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>),\n\t\td: type.validate<d, $> &\n\t\t\t(inferredD extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredD]>),\n\t\te: type.validate<e, $> &\n\t\t\t(inferredE extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredE]>),\n\t\tf: type.validate<f, $> &\n\t\t\t(inferredF extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredF]>),\n\t\tg: type.validate<g, $> &\n\t\t\t(inferredG extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredG]>),\n\t\th: type.validate<h, $> &\n\t\t\t(inferredH extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredH]>),\n\t\ti: type.validate<i, $> &\n\t\t\t(inferredI extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredI]>),\n\t\tj: type.validate<j, $> &\n\t\t\t(inferredJ extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredJ]>),\n\t\tk: type.validate<k, $> &\n\t\t\t(inferredK extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredK]>),\n\t\tl: type.validate<l, $> &\n\t\t\t(inferredL extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredL]>),\n\t\tm: type.validate<m, $> &\n\t\t\t(inferredM extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredM]>),\n\t\tn: type.validate<n, $> &\n\t\t\t(inferredN extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredN]>),\n\t\to: type.validate<o, $> &\n\t\t\t(inferredO extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredO]>)\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tconst i,\n\t\tconst j,\n\t\tconst k,\n\t\tconst l,\n\t\tconst m,\n\t\tconst n,\n\t\tconst o,\n\t\tconst p,\n\t\tinferredA = type.infer<a, $>,\n\t\tinferredB = type.infer<b, $>,\n\t\tinferredC = type.infer<c, $>,\n\t\tinferredD = type.infer<d, $>,\n\t\tinferredE = type.infer<e, $>,\n\t\tinferredF = type.infer<f, $>,\n\t\tinferredG = type.infer<g, $>,\n\t\tinferredH = type.infer<h, $>,\n\t\tinferredI = type.infer<i, $>,\n\t\tinferredJ = type.infer<j, $>,\n\t\tinferredK = type.infer<k, $>,\n\t\tinferredL = type.infer<l, $>,\n\t\tinferredM = type.infer<m, $>,\n\t\tinferredN = type.infer<n, $>,\n\t\tinferredO = type.infer<o, $>,\n\t\tinferredP = type.infer<p, $>,\n\t\tr = Type<\n\t\t\tinferNaryMerge<\n\t\t\t\t[\n\t\t\t\t\tinferredA,\n\t\t\t\t\tinferredB,\n\t\t\t\t\tinferredC,\n\t\t\t\t\tinferredD,\n\t\t\t\t\tinferredE,\n\t\t\t\t\tinferredF,\n\t\t\t\t\tinferredG,\n\t\t\t\t\tinferredH,\n\t\t\t\t\tinferredI,\n\t\t\t\t\tinferredJ,\n\t\t\t\t\tinferredK,\n\t\t\t\t\tinferredL,\n\t\t\t\t\tinferredM,\n\t\t\t\t\tinferredN,\n\t\t\t\t\tinferredO,\n\t\t\t\t\tinferredP\n\t\t\t\t]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $> &\n\t\t\t(inferredA extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>),\n\t\tb: type.validate<b, $> &\n\t\t\t(inferredB extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>),\n\t\tc: type.validate<c, $> &\n\t\t\t(inferredC extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>),\n\t\td: type.validate<d, $> &\n\t\t\t(inferredD extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredD]>),\n\t\te: type.validate<e, $> &\n\t\t\t(inferredE extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredE]>),\n\t\tf: type.validate<f, $> &\n\t\t\t(inferredF extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredF]>),\n\t\tg: type.validate<g, $> &\n\t\t\t(inferredG extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredG]>),\n\t\th: type.validate<h, $> &\n\t\t\t(inferredH extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredH]>),\n\t\ti: type.validate<i, $> &\n\t\t\t(inferredI extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredI]>),\n\t\tj: type.validate<j, $> &\n\t\t\t(inferredJ extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredJ]>),\n\t\tk: type.validate<k, $> &\n\t\t\t(inferredK extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredK]>),\n\t\tl: type.validate<l, $> &\n\t\t\t(inferredL extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredL]>),\n\t\tm: type.validate<m, $> &\n\t\t\t(inferredM extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredM]>),\n\t\tn: type.validate<n, $> &\n\t\t\t(inferredN extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredN]>),\n\t\to: type.validate<o, $> &\n\t\t\t(inferredO extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredO]>),\n\t\tp: type.validate<p, $> &\n\t\t\t(inferredP extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredP]>)\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst a,\n\t\tconst b,\n\t\tconst c,\n\t\tconst d,\n\t\tconst e,\n\t\tconst f,\n\t\tconst g,\n\t\tconst h,\n\t\tconst i,\n\t\tconst j,\n\t\tconst k,\n\t\tconst l,\n\t\tconst m,\n\t\tconst n,\n\t\tconst o,\n\t\tconst p,\n\t\tconst q,\n\t\tinferredA = type.infer<a, $>,\n\t\tinferredB = type.infer<b, $>,\n\t\tinferredC = type.infer<c, $>,\n\t\tinferredD = type.infer<d, $>,\n\t\tinferredE = type.infer<e, $>,\n\t\tinferredF = type.infer<f, $>,\n\t\tinferredG = type.infer<g, $>,\n\t\tinferredH = type.infer<h, $>,\n\t\tinferredI = type.infer<i, $>,\n\t\tinferredJ = type.infer<j, $>,\n\t\tinferredK = type.infer<k, $>,\n\t\tinferredL = type.infer<l, $>,\n\t\tinferredM = type.infer<m, $>,\n\t\tinferredN = type.infer<n, $>,\n\t\tinferredO = type.infer<o, $>,\n\t\tinferredP = type.infer<p, $>,\n\t\tinferredQ = type.infer<q, $>,\n\t\tr = Type<\n\t\t\tinferNaryMerge<\n\t\t\t\t[\n\t\t\t\t\tinferredA,\n\t\t\t\t\tinferredB,\n\t\t\t\t\tinferredC,\n\t\t\t\t\tinferredD,\n\t\t\t\t\tinferredE,\n\t\t\t\t\tinferredF,\n\t\t\t\t\tinferredG,\n\t\t\t\t\tinferredH,\n\t\t\t\t\tinferredI,\n\t\t\t\t\tinferredJ,\n\t\t\t\t\tinferredK,\n\t\t\t\t\tinferredL,\n\t\t\t\t\tinferredM,\n\t\t\t\t\tinferredN,\n\t\t\t\t\tinferredO,\n\t\t\t\t\tinferredP,\n\t\t\t\t\tinferredQ\n\t\t\t\t]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: type.validate<a, $> &\n\t\t\t(inferredA extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredA]>),\n\t\tb: type.validate<b, $> &\n\t\t\t(inferredB extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredB]>),\n\t\tc: type.validate<c, $> &\n\t\t\t(inferredC extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredC]>),\n\t\td: type.validate<d, $> &\n\t\t\t(inferredD extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredD]>),\n\t\te: type.validate<e, $> &\n\t\t\t(inferredE extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredE]>),\n\t\tf: type.validate<f, $> &\n\t\t\t(inferredF extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredF]>),\n\t\tg: type.validate<g, $> &\n\t\t\t(inferredG extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredG]>),\n\t\th: type.validate<h, $> &\n\t\t\t(inferredH extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredH]>),\n\t\ti: type.validate<i, $> &\n\t\t\t(inferredI extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredI]>),\n\t\tj: type.validate<j, $> &\n\t\t\t(inferredJ extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredJ]>),\n\t\tk: type.validate<k, $> &\n\t\t\t(inferredK extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredK]>),\n\t\tl: type.validate<l, $> &\n\t\t\t(inferredL extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredL]>),\n\t\tm: type.validate<m, $> &\n\t\t\t(inferredM extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredM]>),\n\t\tn: type.validate<n, $> &\n\t\t\t(inferredN extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredN]>),\n\t\to: type.validate<o, $> &\n\t\t\t(inferredO extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredO]>),\n\t\tp: type.validate<p, $> &\n\t\t\t(inferredP extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredP]>),\n\t\tq: type.validate<q, $> &\n\t\t\t(inferredQ extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredQ]>)\n\t): r extends infer _ ? _ : never\n\t<\n\t\tconst defs extends readonly unknown[],\n\t\tr = Type<inferNaryMerge<{ [i in keyof defs]: type.infer<defs[i], $> }>, $>\n\t>(\n\t\t...defs: {\n\t\t\t[i in keyof defs]: type.validate<defs[i], $> &\n\t\t\t\t(type.infer<defs[i], $> extends object ? unknown\n\t\t\t\t:\tErrorType<\n\t\t\t\t\t\t[NonObjectMergeErrorMessage, actual: type.infer<defs[i], $>]\n\t\t\t\t\t>)\n\t\t}\n\t): r extends infer _ ? _ : never\n}\n\nexport type NaryPipeParser<$, initial = unknown> = {\n\t(): Type<initial, $>\n\t<\n\t\ta extends Morph<distill.Out<initial>>,\n\t\tr = instantiateType<inferMorph<initial, a>, $>\n\t>(\n\t\ta: a\n\t): r extends infer _ ? _ : never\n\t<\n\t\ta extends Morph<distill.Out<initial>>,\n\t\tb extends Morph<inferMorphOut<a>>,\n\t\tr = instantiateType<inferNaryPipe<[Type<initial>, a, b]>, $>\n\t>(\n\t\ta: a,\n\t\tb: b\n\t): r extends infer _ ? _ : never\n\t<\n\t\ta extends Morph<distill.Out<initial>>,\n\t\tb extends Morph<inferMorphOut<a>>,\n\t\tc extends Morph<inferMorphOut<b>>,\n\t\tr = instantiateType<inferNaryPipe<[Type<initial>, a, b, c]>, $>\n\t>(\n\t\ta: a,\n\t\tb: b,\n\t\tc: c\n\t): r extends infer _ ? _ : never\n\t<\n\t\ta extends Morph<distill.Out<initial>>,\n\t\tb extends Morph<inferMorphOut<a>>,\n\t\tc extends Morph<inferMorphOut<b>>,\n\t\td extends Morph<inferMorphOut<c>>,\n\t\tr = instantiateType<inferNaryPipe<[Type<initial>, a, b, c, d]>, $>\n\t>(\n\t\ta: a,\n\t\tb: b,\n\t\tc: c,\n\t\td: d\n\t): r extends infer _ ? _ : never\n\t<\n\t\ta extends Morph<distill.Out<initial>>,\n\t\tb extends Morph<inferMorphOut<a>>,\n\t\tc extends Morph<inferMorphOut<b>>,\n\t\td extends Morph<inferMorphOut<c>>,\n\t\te extends Morph<inferMorphOut<d>>,\n\t\tr = instantiateType<inferNaryPipe<[Type<initial>, a, b, c, d, e]>, $>\n\t>(\n\t\ta: a,\n\t\tb: b,\n\t\tc: c,\n\t\td: d,\n\t\te: e\n\t): r extends infer _ ? _ : never\n\t<\n\t\ta extends Morph<distill.Out<initial>>,\n\t\tb extends Morph<inferMorphOut<a>>,\n\t\tc extends Morph<inferMorphOut<b>>,\n\t\td extends Morph<inferMorphOut<c>>,\n\t\te extends Morph<inferMorphOut<d>>,\n\t\tf extends Morph<inferMorphOut<e>>,\n\t\tr = instantiateType<inferNaryPipe<[Type<initial>, a, b, c, d, e, f]>, $>\n\t>(\n\t\ta: a,\n\t\tb: b,\n\t\tc: c,\n\t\td: d,\n\t\te: e,\n\t\tf: f\n\t): r extends infer _ ? _ : never\n\t<\n\t\ta extends Morph<distill.Out<initial>>,\n\t\tb extends Morph<inferMorphOut<a>>,\n\t\tc extends Morph<inferMorphOut<b>>,\n\t\td extends Morph<inferMorphOut<c>>,\n\t\te extends Morph<inferMorphOut<d>>,\n\t\tf extends Morph<inferMorphOut<e>>,\n\t\tg extends Morph<inferMorphOut<f>>,\n\t\tr = instantiateType<inferNaryPipe<[Type<initial>, a, b, c, d, e, f, g]>, $>\n\t>(\n\t\ta: a,\n\t\tb: b,\n\t\tc: c,\n\t\td: d,\n\t\te: e,\n\t\tf: f,\n\t\tg: g\n\t): r extends infer _ ? _ : never\n\t<\n\t\ta extends Morph<distill.Out<initial>>,\n\t\tb extends Morph<inferMorphOut<a>>,\n\t\tc extends Morph<inferMorphOut<b>>,\n\t\td extends Morph<inferMorphOut<c>>,\n\t\te extends Morph<inferMorphOut<d>>,\n\t\tf extends Morph<inferMorphOut<e>>,\n\t\tg extends Morph<inferMorphOut<f>>,\n\t\th extends Morph<inferMorphOut<g>>,\n\t\tr = instantiateType<\n\t\t\tinferNaryPipe<[Type<initial>, a, b, c, d, e, f, g, h]>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: a,\n\t\tb: b,\n\t\tc: c,\n\t\td: d,\n\t\te: e,\n\t\tf: f,\n\t\tg: g,\n\t\th: h\n\t): r extends infer _ ? _ : never\n\t<\n\t\ta extends Morph<distill.Out<initial>>,\n\t\tb extends Morph<inferMorphOut<a>>,\n\t\tc extends Morph<inferMorphOut<b>>,\n\t\td extends Morph<inferMorphOut<c>>,\n\t\te extends Morph<inferMorphOut<d>>,\n\t\tf extends Morph<inferMorphOut<e>>,\n\t\tg extends Morph<inferMorphOut<f>>,\n\t\th extends Morph<inferMorphOut<g>>,\n\t\ti extends Morph<inferMorphOut<h>>,\n\t\tr = instantiateType<\n\t\t\tinferNaryPipe<[Type<initial>, a, b, c, d, e, f, g, h, i]>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: a,\n\t\tb: b,\n\t\tc: c,\n\t\td: d,\n\t\te: e,\n\t\tf: f,\n\t\tg: g,\n\t\th: h,\n\t\ti: i\n\t): r extends infer _ ? _ : never\n\t<\n\t\ta extends Morph<distill.Out<initial>>,\n\t\tb extends Morph<inferMorphOut<a>>,\n\t\tc extends Morph<inferMorphOut<b>>,\n\t\td extends Morph<inferMorphOut<c>>,\n\t\te extends Morph<inferMorphOut<d>>,\n\t\tf extends Morph<inferMorphOut<e>>,\n\t\tg extends Morph<inferMorphOut<f>>,\n\t\th extends Morph<inferMorphOut<g>>,\n\t\ti extends Morph<inferMorphOut<h>>,\n\t\tj extends Morph<inferMorphOut<i>>,\n\t\tr = instantiateType<\n\t\t\tinferNaryPipe<[Type<initial>, a, b, c, d, e, f, g, h, i, j]>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: a,\n\t\tb: b,\n\t\tc: c,\n\t\td: d,\n\t\te: e,\n\t\tf: f,\n\t\tg: g,\n\t\th: h,\n\t\ti: i,\n\t\tj: j\n\t): r extends infer _ ? _ : never\n\t<\n\t\ta extends Morph<distill.Out<initial>>,\n\t\tb extends Morph<inferMorphOut<a>>,\n\t\tc extends Morph<inferMorphOut<b>>,\n\t\td extends Morph<inferMorphOut<c>>,\n\t\te extends Morph<inferMorphOut<d>>,\n\t\tf extends Morph<inferMorphOut<e>>,\n\t\tg extends Morph<inferMorphOut<f>>,\n\t\th extends Morph<inferMorphOut<g>>,\n\t\ti extends Morph<inferMorphOut<h>>,\n\t\tj extends Morph<inferMorphOut<i>>,\n\t\tk extends Morph<inferMorphOut<j>>,\n\t\tr = instantiateType<\n\t\t\tinferNaryPipe<[Type<initial>, a, b, c, d, e, f, g, h, i, j, k]>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: a,\n\t\tb: b,\n\t\tc: c,\n\t\td: d,\n\t\te: e,\n\t\tf: f,\n\t\tg: g,\n\t\th: h,\n\t\ti: i,\n\t\tj: j,\n\t\tk: k\n\t): r extends infer _ ? _ : never\n\t<\n\t\ta extends Morph<distill.Out<initial>>,\n\t\tb extends Morph<inferMorphOut<a>>,\n\t\tc extends Morph<inferMorphOut<b>>,\n\t\td extends Morph<inferMorphOut<c>>,\n\t\te extends Morph<inferMorphOut<d>>,\n\t\tf extends Morph<inferMorphOut<e>>,\n\t\tg extends Morph<inferMorphOut<f>>,\n\t\th extends Morph<inferMorphOut<g>>,\n\t\ti extends Morph<inferMorphOut<h>>,\n\t\tj extends Morph<inferMorphOut<i>>,\n\t\tk extends Morph<inferMorphOut<j>>,\n\t\tl extends Morph<inferMorphOut<k>>,\n\t\tr = instantiateType<\n\t\t\tinferNaryPipe<[Type<initial>, a, b, c, d, e, f, g, h, i, j, k, l]>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: a,\n\t\tb: b,\n\t\tc: c,\n\t\td: d,\n\t\te: e,\n\t\tf: f,\n\t\tg: g,\n\t\th: h,\n\t\ti: i,\n\t\tj: j,\n\t\tk: k,\n\t\tl: l\n\t): r extends infer _ ? _ : never\n\t<\n\t\ta extends Morph<distill.Out<initial>>,\n\t\tb extends Morph<inferMorphOut<a>>,\n\t\tc extends Morph<inferMorphOut<b>>,\n\t\td extends Morph<inferMorphOut<c>>,\n\t\te extends Morph<inferMorphOut<d>>,\n\t\tf extends Morph<inferMorphOut<e>>,\n\t\tg extends Morph<inferMorphOut<f>>,\n\t\th extends Morph<inferMorphOut<g>>,\n\t\ti extends Morph<inferMorphOut<h>>,\n\t\tj extends Morph<inferMorphOut<i>>,\n\t\tk extends Morph<inferMorphOut<j>>,\n\t\tl extends Morph<inferMorphOut<k>>,\n\t\tm extends Morph<inferMorphOut<l>>,\n\t\tr = instantiateType<\n\t\t\tinferNaryPipe<[Type<initial>, a, b, c, d, e, f, g, h, i, j, k, l, m]>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: a,\n\t\tb: b,\n\t\tc: c,\n\t\td: d,\n\t\te: e,\n\t\tf: f,\n\t\tg: g,\n\t\th: h,\n\t\ti: i,\n\t\tj: j,\n\t\tk: k,\n\t\tl: l,\n\t\tm: m\n\t): r extends infer _ ? _ : never\n\t<\n\t\ta extends Morph<distill.Out<initial>>,\n\t\tb extends Morph<inferMorphOut<a>>,\n\t\tc extends Morph<inferMorphOut<b>>,\n\t\td extends Morph<inferMorphOut<c>>,\n\t\te extends Morph<inferMorphOut<d>>,\n\t\tf extends Morph<inferMorphOut<e>>,\n\t\tg extends Morph<inferMorphOut<f>>,\n\t\th extends Morph<inferMorphOut<g>>,\n\t\ti extends Morph<inferMorphOut<h>>,\n\t\tj extends Morph<inferMorphOut<i>>,\n\t\tk extends Morph<inferMorphOut<j>>,\n\t\tl extends Morph<inferMorphOut<k>>,\n\t\tm extends Morph<inferMorphOut<l>>,\n\t\tn extends Morph<inferMorphOut<m>>,\n\t\tr = instantiateType<\n\t\t\tinferNaryPipe<[Type<initial>, a, b, c, d, e, f, g, h, i, j, k, l, m, n]>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: a,\n\t\tb: b,\n\t\tc: c,\n\t\td: d,\n\t\te: e,\n\t\tf: f,\n\t\tg: g,\n\t\th: h,\n\t\ti: i,\n\t\tj: j,\n\t\tk: k,\n\t\tl: l,\n\t\tm: m,\n\t\tn: n\n\t): r extends infer _ ? _ : never\n\t<\n\t\ta extends Morph<distill.Out<initial>>,\n\t\tb extends Morph<inferMorphOut<a>>,\n\t\tc extends Morph<inferMorphOut<b>>,\n\t\td extends Morph<inferMorphOut<c>>,\n\t\te extends Morph<inferMorphOut<d>>,\n\t\tf extends Morph<inferMorphOut<e>>,\n\t\tg extends Morph<inferMorphOut<f>>,\n\t\th extends Morph<inferMorphOut<g>>,\n\t\ti extends Morph<inferMorphOut<h>>,\n\t\tj extends Morph<inferMorphOut<i>>,\n\t\tk extends Morph<inferMorphOut<j>>,\n\t\tl extends Morph<inferMorphOut<k>>,\n\t\tm extends Morph<inferMorphOut<l>>,\n\t\tn extends Morph<inferMorphOut<m>>,\n\t\to extends Morph<inferMorphOut<n>>,\n\t\tr = instantiateType<\n\t\t\tinferNaryPipe<\n\t\t\t\t[Type<initial>, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: a,\n\t\tb: b,\n\t\tc: c,\n\t\td: d,\n\t\te: e,\n\t\tf: f,\n\t\tg: g,\n\t\th: h,\n\t\ti: i,\n\t\tj: j,\n\t\tk: k,\n\t\tl: l,\n\t\tm: m,\n\t\tn: n,\n\t\to: o\n\t): r extends infer _ ? _ : never\n\t<\n\t\ta extends Morph<distill.Out<initial>>,\n\t\tb extends Morph<inferMorphOut<a>>,\n\t\tc extends Morph<inferMorphOut<b>>,\n\t\td extends Morph<inferMorphOut<c>>,\n\t\te extends Morph<inferMorphOut<d>>,\n\t\tf extends Morph<inferMorphOut<e>>,\n\t\tg extends Morph<inferMorphOut<f>>,\n\t\th extends Morph<inferMorphOut<g>>,\n\t\ti extends Morph<inferMorphOut<h>>,\n\t\tj extends Morph<inferMorphOut<i>>,\n\t\tk extends Morph<inferMorphOut<j>>,\n\t\tl extends Morph<inferMorphOut<k>>,\n\t\tm extends Morph<inferMorphOut<l>>,\n\t\tn extends Morph<inferMorphOut<m>>,\n\t\to extends Morph<inferMorphOut<n>>,\n\t\tp extends Morph<inferMorphOut<o>>,\n\t\tr = instantiateType<\n\t\t\tinferNaryPipe<\n\t\t\t\t[Type<initial>, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: a,\n\t\tb: b,\n\t\tc: c,\n\t\td: d,\n\t\te: e,\n\t\tf: f,\n\t\tg: g,\n\t\th: h,\n\t\ti: i,\n\t\tj: j,\n\t\tk: k,\n\t\tl: l,\n\t\tm: m,\n\t\tn: n,\n\t\to: o,\n\t\tp: p\n\t): r extends infer _ ? _ : never\n\t<\n\t\ta extends Morph<distill.Out<initial>>,\n\t\tb extends Morph<inferMorphOut<a>>,\n\t\tc extends Morph<inferMorphOut<b>>,\n\t\td extends Morph<inferMorphOut<c>>,\n\t\te extends Morph<inferMorphOut<d>>,\n\t\tf extends Morph<inferMorphOut<e>>,\n\t\tg extends Morph<inferMorphOut<f>>,\n\t\th extends Morph<inferMorphOut<g>>,\n\t\ti extends Morph<inferMorphOut<h>>,\n\t\tj extends Morph<inferMorphOut<i>>,\n\t\tk extends Morph<inferMorphOut<j>>,\n\t\tl extends Morph<inferMorphOut<k>>,\n\t\tm extends Morph<inferMorphOut<l>>,\n\t\tn extends Morph<inferMorphOut<m>>,\n\t\to extends Morph<inferMorphOut<n>>,\n\t\tp extends Morph<inferMorphOut<o>>,\n\t\tq extends Morph<inferMorphOut<p>>,\n\t\tr = instantiateType<\n\t\t\tinferNaryPipe<\n\t\t\t\t[Type<initial>, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q]\n\t\t\t>,\n\t\t\t$\n\t\t>\n\t>(\n\t\ta: a,\n\t\tb: b,\n\t\tc: c,\n\t\td: d,\n\t\te: e,\n\t\tf: f,\n\t\tg: g,\n\t\th: h,\n\t\ti: i,\n\t\tj: j,\n\t\tk: k,\n\t\tl: l,\n\t\tm: m,\n\t\tn: n,\n\t\to: o,\n\t\tp: p,\n\t\tq: q\n\t): r extends infer _ ? _ : never\n\n\t<const morphs extends readonly Morph[], r = Type<inferNaryPipe<morphs>, $>>(\n\t\t...defs: morphs\n\t): r extends infer _ ? _ : never\n}\n"
  },
  {
    "path": "ark/type/package.json",
    "content": "{\n\t\"name\": \"arktype\",\n\t\"description\": \"TypeScript's 1:1 validator, optimized from editor to runtime\",\n\t\"version\": \"2.2.0\",\n\t\"license\": \"MIT\",\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"https://github.com/arktypeio/arktype.git\",\n\t\t\"directory\": \"ark/type\"\n\t},\n\t\"author\": {\n\t\t\"name\": \"David Blass\",\n\t\t\"email\": \"david@arktype.io\",\n\t\t\"url\": \"https://arktype.io\"\n\t},\n\t\"type\": \"module\",\n\t\"main\": \"./out/index.js\",\n\t\"types\": \"./out/index.d.ts\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"ark-ts\": \"./index.ts\",\n\t\t\t\"default\": \"./out/index.js\"\n\t\t},\n\t\t\"./config\": {\n\t\t\t\"ark-ts\": \"./config.ts\",\n\t\t\t\"default\": \"./out/config.js\"\n\t\t},\n\t\t\"./internal/*.ts\": {\n\t\t\t\"ark-ts\": \"./*.ts\",\n\t\t\t\"default\": \"./out/*.js\"\n\t\t},\n\t\t\"./internal/*.js\": {\n\t\t\t\"ark-ts\": \"./*.ts\",\n\t\t\t\"default\": \"./out/*.js\"\n\t\t}\n\t},\n\t\"files\": [\n\t\t\"out\"\n\t],\n\t\"scripts\": {\n\t\t\"build\": \"ts ../repo/build.ts\",\n\t\t\"test\": \"ts ../repo/testPackage.ts; pnpm testIntegration\",\n\t\t\"testIntegration\": \"pnpm testSimpleConfig && pnpm testAllConfig && pnpm testOnFailConfig && pnpm testEoptConfig\",\n\t\t\"testSimpleConfig\": \"ts ./__tests__/integration/testSimpleConfig.ts\",\n\t\t\"testAllConfig\": \"ts ./__tests__/integration/testAllConfig.ts\",\n\t\t\"testOnFailConfig\": \"ts ./__tests__/integration/testOnFailConfig.ts\",\n\t\t\"testEoptConfig\": \"ts ./__tests__/integration/testEoptConfig.ts\"\n\t},\n\t\"dependencies\": {\n\t\t\"@ark/util\": \"workspace:*\",\n\t\t\"@ark/schema\": \"workspace:*\",\n\t\t\"arkregex\": \"workspace:*\"\n\t},\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t}\n}\n"
  },
  {
    "path": "ark/type/parser/ast/bounds.ts",
    "content": "import type { writeUnboundableMessage } from \"@ark/schema\"\nimport type { ErrorMessage, array, typeToString } from \"@ark/util\"\nimport type { InferredMorph, LimitLiteral } from \"../../attributes.ts\"\nimport type { Comparator } from \"../reduce/shared.ts\"\nimport type {\n\tBoundExpressionKind,\n\twriteInvalidLimitMessage\n} from \"../shift/operator/bounds.ts\"\nimport type { inferAstRoot } from \"./infer.ts\"\nimport type { astToString, writeConstrainedMorphMessage } from \"./utils.ts\"\nimport type { validateAst } from \"./validate.ts\"\n\nexport type validateRange<l, comparator extends Comparator, r, $, args> =\n\t[l] extends [LimitLiteral] ? validateBound<r, comparator, l, \"left\", $, args>\n\t: [l] extends [[infer leftAst, Comparator, unknown]] ?\n\t\tErrorMessage<writeDoubleRightBoundMessage<astToString<leftAst>>>\n\t:\tvalidateBound<l, comparator, r & LimitLiteral, \"right\", $, args>\n\nexport type validateBound<\n\tboundedAst,\n\tcomparator extends Comparator,\n\tlimit extends LimitLiteral,\n\tboundKind extends BoundExpressionKind,\n\t$,\n\targs\n> =\n\tinferAstRoot<boundedAst, $, args> extends infer bounded ?\n\t\tisNumericallyBoundable<bounded> extends true ?\n\t\t\tlimit extends number ?\n\t\t\t\tvalidateAst<boundedAst, $, args>\n\t\t\t:\tErrorMessage<writeInvalidLimitMessage<comparator, limit, boundKind>>\n\t\t: [bounded] extends [Date] ?\n\t\t\t// allow numeric or date literal as a Date limit\n\t\t\tvalidateAst<boundedAst, $, args>\n\t\t: [bounded] extends [InferredMorph] ?\n\t\t\tErrorMessage<writeConstrainedMorphMessage<boundedAst>>\n\t\t:\tErrorMessage<writeUnboundableMessage<typeToString<bounded>>>\n\t:\tnever\n\n// Check each numerically boundable type individually so an expression comprised\n// of mixed bound kinds like (string|number)<5 isn't allowed\ntype isNumericallyBoundable<bounded> =\n\t[bounded] extends [number] ? true\n\t: [bounded] extends [string] ? true\n\t: [bounded] extends [array] ? true\n\t: false\n\nexport const writeDoubleRightBoundMessage = <root extends string>(\n\troot: root\n): writeDoubleRightBoundMessage<root> =>\n\t`Expression ${root} must have at most one right bound`\n\ntype writeDoubleRightBoundMessage<root extends string> =\n\t`Expression ${root} must have at most one right bound`\n"
  },
  {
    "path": "ark/type/parser/ast/default.ts",
    "content": "import type { writeUnassignableDefaultValueMessage } from \"@ark/schema\"\nimport type { ErrorMessage } from \"@ark/util\"\nimport type { type } from \"../../keywords/keywords.ts\"\nimport type { UnitLiteral } from \"../shift/operator/default.ts\"\nimport type { inferAstIn } from \"./infer.ts\"\nimport type { astToString } from \"./utils.ts\"\nimport type { validateAst } from \"./validate.ts\"\n\nexport type validateDefault<baseAst, unitLiteral extends UnitLiteral, $, args> =\n\tvalidateAst<baseAst, $, args> extends infer e extends ErrorMessage ? e\n\t: // check against the output of the type since morphs will not occur\n\t//  ambient infer is safe since the default value is always a literal\n\ttype.infer<unitLiteral> extends inferAstIn<baseAst, $, args> ? undefined\n\t: ErrorMessage<\n\t\t\twriteUnassignableDefaultValueMessage<astToString<baseAst>, unitLiteral>\n\t\t>\n"
  },
  {
    "path": "ark/type/parser/ast/divisor.ts",
    "content": "import type { writeIndivisibleMessage } from \"@ark/schema\"\nimport type { ErrorMessage } from \"@ark/util\"\nimport type { InferredMorph } from \"../../attributes.ts\"\nimport type { inferAstRoot } from \"./infer.ts\"\nimport type { writeConstrainedMorphMessage } from \"./utils.ts\"\nimport type { validateAst } from \"./validate.ts\"\n\nexport type validateDivisor<l, $, args> =\n\tinferAstRoot<l, $, args> extends infer data ?\n\t\t[data] extends [number] ? validateAst<l, $, args>\n\t\t: [data] extends [InferredMorph] ?\n\t\t\tErrorMessage<writeConstrainedMorphMessage<l>>\n\t\t:\tErrorMessage<writeIndivisibleMessage<data>>\n\t:\tnever\n"
  },
  {
    "path": "ark/type/parser/ast/generic.ts",
    "content": "import type {\n\tGenericAst,\n\tGenericParamAst,\n\twriteUnsatisfiedParameterConstraintMessage\n} from \"@ark/schema\"\nimport type { array, ErrorMessage, Hkt, typeToString } from \"@ark/util\"\nimport type { UnparsedScope } from \"../../scope.ts\"\nimport type { inferDefinition } from \"../definition.ts\"\nimport type { inferAstRoot, inferExpression } from \"./infer.ts\"\nimport type { astToString } from \"./utils.ts\"\nimport type { validateAst } from \"./validate.ts\"\n\nexport type GenericInstantiationAst<\n\tgeneric extends GenericAst = GenericAst,\n\targAsts extends unknown[] = unknown[]\n> = [generic, \"<>\", argAsts]\n\nexport type inferGenericInstantiation<\n\tg extends GenericAst,\n\targAsts extends unknown[],\n\t$,\n\targs\n> =\n\tg[\"bodyDef\"] extends Hkt ?\n\t\tHkt.apply<\n\t\t\tg[\"bodyDef\"],\n\t\t\t{ [i in keyof argAsts]: inferExpression<argAsts[i], $, args> }\n\t\t>\n\t:\tinferDefinition<\n\t\t\tg[\"bodyDef\"],\n\t\t\tresolveScope<g[\"$\"], $>,\n\t\t\t{\n\t\t\t\t// intersect `${number}` to ensure that only array indices are mapped\n\t\t\t\t[i in keyof g[\"names\"] & `${number}` as g[\"names\"][i]]: inferExpression<\n\t\t\t\t\targAsts[i & keyof argAsts],\n\t\t\t\t\tresolveScope<g[\"arg$\"], $>,\n\t\t\t\t\targs\n\t\t\t\t>\n\t\t\t}\n\t\t>\n\nexport type validateGenericInstantiation<\n\tg extends GenericAst,\n\targAsts extends unknown[],\n\t$,\n\targs\n> = validateGenericArgs<g[\"paramsAst\"], argAsts, $, args, []>\n\ntype validateGenericArgs<\n\tparams extends array<GenericParamAst>,\n\targAsts extends array,\n\t$,\n\targs,\n\tindices extends 1[]\n> =\n\targAsts extends readonly [infer arg, ...infer argsTail] ?\n\t\tvalidateAst<arg, $, args> extends infer e extends ErrorMessage ? e\n\t\t: inferAstRoot<arg, $, args> extends params[indices[\"length\"]][1] ?\n\t\t\tvalidateGenericArgs<params, argsTail, $, args, [...indices, 1]>\n\t\t:\tErrorMessage<\n\t\t\t\twriteUnsatisfiedParameterConstraintMessage<\n\t\t\t\t\tparams[indices[\"length\"]][0],\n\t\t\t\t\ttypeToString<params[indices[\"length\"]][1]>,\n\t\t\t\t\tastToString<arg>\n\t\t\t\t>\n\t\t\t>\n\t:\tundefined\n\ntype resolveScope<g$, $> =\n\t// If the generic was defined in the current scope, its definition can be\n\t// resolved using the same scope as that of the input args.\n\tg$ extends UnparsedScope ? $\n\t:\t// Otherwise, use the scope that was explicitly bound to it.\n\t\tg$\n"
  },
  {
    "path": "ark/type/parser/ast/infer.ts",
    "content": "import type { arkKeyOf, array } from \"@ark/util\"\nimport type {\n\tdistill,\n\tinferIntersection,\n\tinferPipe,\n\tLimitLiteral,\n\twithDefault\n} from \"../../attributes.ts\"\nimport type { type } from \"../../keywords/keywords.ts\"\nimport type { inferDefinition } from \"../definition.ts\"\nimport type { Comparator } from \"../reduce/shared.ts\"\nimport type { InfixToken, PostfixToken } from \"../shift/tokens.ts\"\nimport type {\n\tGenericInstantiationAst,\n\tinferGenericInstantiation\n} from \"./generic.ts\"\n\nexport type inferAstRoot<ast, $, args> =\n\tast extends array ? inferExpression<ast, $, args> : never\n\nexport type inferAstIn<ast, $, args> = distill.In<inferAstRoot<ast, $, args>>\n\nexport type inferAstOut<ast, $, args> = distill.Out<inferAstRoot<ast, $, args>>\n\nexport type DefAst<def = unknown, alias extends string = string> = [\n\tdef,\n\t\"def\",\n\talias\n]\n\nexport type InferredAst<t = unknown, def extends string = string> = [\n\tt,\n\t\"inferred\",\n\tdef\n]\n\nexport type inferExpression<ast, $, args> =\n\tast extends array ?\n\t\tast extends InferredAst<infer resolution> ? resolution\n\t\t: ast extends DefAst<infer def> ? inferDefinition<def, $, args>\n\t\t: ast extends GenericInstantiationAst<infer g, infer argAsts> ?\n\t\t\tinferGenericInstantiation<g, argAsts, $, args>\n\t\t: ast[1] extends \"[]\" ? inferExpression<ast[0], $, args>[]\n\t\t: ast[1] extends \"|\" ?\n\t\t\tinferExpression<ast[0], $, args> | inferExpression<ast[2], $, args>\n\t\t: ast[1] extends \"&\" ?\n\t\t\tinferIntersection<\n\t\t\t\tinferExpression<ast[0], $, args>,\n\t\t\t\tinferExpression<ast[2], $, args>\n\t\t\t>\n\t\t: ast[1] extends \"|>\" ?\n\t\t\tinferPipe<\n\t\t\t\tinferExpression<ast[0], $, args>,\n\t\t\t\tinferExpression<ast[2], $, args>\n\t\t\t>\n\t\t: ast[1] extends \"=\" ?\n\t\t\t// unscoped type.infer is safe since the default value is always a literal\n\t\t\t// as of TS5.6, inlining defaultValue causes a bunch of extra types and instantiations\n\t\t\ttype.infer<ast[2]> extends infer defaultValue ?\n\t\t\t\twithDefault<inferExpression<ast[0], $, args>, defaultValue>\n\t\t\t:\tnever\n\t\t: ast[1] extends \"#\" ? type.brand<inferExpression<ast[0], $, args>, ast[2]>\n\t\t: ast[1] extends Comparator ?\n\t\t\tast[0] extends LimitLiteral ?\n\t\t\t\tinferExpression<ast[2], $, args>\n\t\t\t:\tinferExpression<ast[0], $, args>\n\t\t: ast[1] extends \"%\" ? inferExpression<ast[0], $, args>\n\t\t: ast[1] extends \"?\" ? inferExpression<ast[0], $, args>\n\t\t: ast[0] extends \"keyof\" ? arkKeyOf<inferExpression<ast[1], $, args>>\n\t\t: never\n\t:\tnever\n\nexport type PrefixOperator = \"keyof\" | \"instanceof\" | \"===\" | \"node\"\n\nexport type PrefixExpression<\n\toperator extends PrefixOperator = PrefixOperator,\n\toperand = unknown\n> = [operator, operand]\n\nexport type PostfixExpression<\n\toperator extends PostfixToken = PostfixToken,\n\toperand = unknown\n> = readonly [operand, operator]\n\nexport type InfixExpression<\n\toperator extends InfixToken = InfixToken,\n\tl = unknown,\n\tr = unknown\n> = [l, operator, r]\n"
  },
  {
    "path": "ark/type/parser/ast/keyof.ts",
    "content": "import type { writeNonStructuralOperandMessage } from \"@ark/schema\"\nimport type { ErrorMessage, typeToString } from \"@ark/util\"\nimport type { inferAstRoot } from \"./infer.ts\"\nimport type { validateAst } from \"./validate.ts\"\n\nexport type validateKeyof<operandAst, $, args> =\n\tinferAstRoot<operandAst, $, args> extends infer data ?\n\t\t[data] extends [object] ?\n\t\t\tvalidateAst<operandAst, $, args>\n\t\t:\tErrorMessage<writeNonStructuralOperandMessage<\"keyof\", typeToString<data>>>\n\t:\tnever\n"
  },
  {
    "path": "ark/type/parser/ast/utils.ts",
    "content": "import type { satisfy, Stringifiable } from \"@ark/util\"\nimport type { Comparator } from \"../reduce/shared.ts\"\nimport type { OperatorToken } from \"../shift/tokens.ts\"\nimport type {\n\tDefAst,\n\tInferredAst,\n\tInfixExpression,\n\tPostfixExpression\n} from \"./infer.ts\"\n\nexport type astToString<ast> =\n\tast extends InferredAst | DefAst ? ast[2]\n\t: ast extends PostfixExpression<infer operator, infer operand> ?\n\t\toperator extends \"[]\" ?\n\t\t\t`${astToString<operand>}[]`\n\t\t:\tnever\n\t: ast extends InfixExpression<infer operator, infer l, infer r> ?\n\t\toperator extends \"&\" | \"|\" | \"%\" | Comparator ?\n\t\t\t`${astToString<l>} ${operator} ${astToString<r>}`\n\t\t:\tnever\n\t: ast extends Stringifiable ? `${ast extends bigint ? `${ast}n` : ast}`\n\t: \"...\"\n\nexport type ConstraintOperator = satisfy<OperatorToken, \"%\" | Comparator>\n\nexport type writeConstrainedMorphMessage<constrainedAst> =\n\t`To constrain the output of ${astToString<constrainedAst>}, pipe like myMorph.to('number > 0').\nTo constrain the input, intersect like myMorph.and('number > 0').`\n"
  },
  {
    "path": "ark/type/parser/ast/validate.ts",
    "content": "import type {\n\tarkKind,\n\tPrivateDeclaration,\n\twriteMissingSubmoduleAccessMessage\n} from \"@ark/schema\"\nimport type {\n\tanyOrNever,\n\tBigintLiteral,\n\tCompletion,\n\tErrorMessage,\n\tNumberLiteral,\n\twriteMalformedNumericLiteralMessage\n} from \"@ark/util\"\nimport type { Generic } from \"../../generic.ts\"\nimport type { BranchOperator, Comparator } from \"../reduce/shared.ts\"\nimport type { writeInvalidGenericArgCountMessage } from \"../shift/operand/genericArgs.ts\"\nimport type { UnitLiteral } from \"../shift/operator/default.ts\"\nimport type { parseString } from \"../string.ts\"\nimport type { validateRange } from \"./bounds.ts\"\nimport type { validateDefault } from \"./default.ts\"\nimport type { validateDivisor } from \"./divisor.ts\"\nimport type {\n\tGenericInstantiationAst,\n\tvalidateGenericInstantiation\n} from \"./generic.ts\"\nimport type {\n\tDefAst,\n\tInferredAst,\n\tInfixExpression,\n\tPostfixExpression\n} from \"./infer.ts\"\nimport type { validateKeyof } from \"./keyof.ts\"\nimport type { astToString } from \"./utils.ts\"\n\nexport type validateAst<ast, $, args> =\n\tast extends ErrorMessage ? ast\n\t: ast extends InferredAst ? validateInferredAst<ast[0], ast[2]>\n\t: ast extends DefAst ?\n\t\tast[2] extends PrivateDeclaration<infer name> ?\n\t\t\tErrorMessage<writePrefixedPrivateReferenceMessage<name>>\n\t\t:\tundefined\n\t: ast extends PostfixExpression<\"[]\" | \"?\", infer operand> ?\n\t\t// shallowOptionalMessage is handled in type.validate\n\t\t// invalidOptionalKeyKindMessage is handled in property parsing\n\n\t\t// it would be natural to handle them here by adding context\n\t\t// to the generic args, but it makes the cache less reusable\n\t\t// (was tested and had a significant impact on repo-wide perf)\n\t\tvalidateAst<operand, $, args>\n\t: ast extends InfixExpression<infer operator, infer l, infer r> ?\n\t\toperator extends BranchOperator ? validateInfix<ast, $, args>\n\t\t: operator extends Comparator ? validateRange<l, operator, r, $, args>\n\t\t: operator extends \"%\" ? validateDivisor<l, $, args>\n\t\t: // shallowDefaultableMessage is handled in type.validate\n\t\t// invalidDefaultableKeyKindMessage is handled in property parsing\n\t\toperator extends \"=\" ? validateDefault<l, r & UnitLiteral, $, args>\n\t\t: operator extends \"#\" ? validateAst<l, $, args>\n\t\t: ErrorMessage<writeUnexpectedExpressionMessage<astToString<ast>>>\n\t: ast extends [\"keyof\", infer operand] ? validateKeyof<operand, $, args>\n\t: ast extends GenericInstantiationAst<infer g, infer argAsts> ?\n\t\tvalidateGenericInstantiation<g, argAsts, $, args>\n\t:\tErrorMessage<writeUnexpectedExpressionMessage<astToString<ast>>> & {\n\t\t\tast: ast\n\t\t}\n\ntype writeUnexpectedExpressionMessage<expression extends string> =\n\t`Failed to parse the expression resulting from ${expression}`\n\nexport const writePrefixedPrivateReferenceMessage = <name extends string>(\n\tname: name\n): writePrefixedPrivateReferenceMessage<name> =>\n\t`Private type references should not include '#'. Use '${name}' instead.`\n\nexport type writePrefixedPrivateReferenceMessage<name extends string> =\n\t`Private type references should not include '#'. Use '${name}' instead.`\n\ntype validateInferredAst<inferred, def extends string> =\n\tdef extends NumberLiteral ?\n\t\tnumber extends inferred ?\n\t\t\tErrorMessage<writeMalformedNumericLiteralMessage<def, \"number\">>\n\t\t:\tundefined\n\t: def extends BigintLiteral ?\n\t\tbigint extends inferred ?\n\t\t\tErrorMessage<writeMalformedNumericLiteralMessage<def, \"bigint\">>\n\t\t:\tundefined\n\t: [inferred] extends [anyOrNever] ? undefined\n\t: def extends PrivateDeclaration<infer name> ?\n\t\tErrorMessage<writePrefixedPrivateReferenceMessage<name>>\n\t: // these problems would've been caught during a fullStringParse, but it's most\n\t// efficient to check for them here in case the string was naively parsed\n\tinferred extends Generic ?\n\t\tErrorMessage<writeInvalidGenericArgCountMessage<def, inferred[\"names\"], []>>\n\t: inferred extends { [arkKind]: \"module\" } ?\n\t\t\"root\" extends keyof inferred ?\n\t\t\tundefined\n\t\t:\tErrorMessage<writeMissingSubmoduleAccessMessage<def>>\n\t: def extends ErrorMessage ? def\n\t: undefined\n\nexport type validateString<def extends string, $, args> =\n\tparseString<def, $, args> extends infer ast ?\n\t\tvalidateAst<ast, $, args> extends infer result extends ErrorMessage ?\n\t\t\t// completions have the same suffix as error messages as a sentinel\n\t\t\t// but don't want to include that in what TS suggests\n\t\t\tresult extends Completion<infer text> ?\n\t\t\t\ttext\n\t\t\t:\tresult\n\t\t:\tdef\n\t:\tnever\n\ntype validateInfix<ast extends InfixExpression, $, args> =\n\tvalidateAst<ast[0], $, args> extends infer e extends ErrorMessage ? e\n\t: validateAst<ast[2], $, args> extends infer e extends ErrorMessage ? e\n\t: undefined\n\nexport const shallowOptionalMessage =\n\t\"Optional definitions like 'string?' are only valid as properties in an object or tuple\"\n\nexport type shallowOptionalMessage = typeof shallowOptionalMessage\n\nexport const shallowDefaultableMessage =\n\t\"Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple\"\n\nexport type shallowDefaultableMessage = typeof shallowDefaultableMessage\n"
  },
  {
    "path": "ark/type/parser/definition.ts",
    "content": "import {\n\thasArkKind,\n\ttype BaseParseContext,\n\ttype BaseRoot,\n\ttype StandardSchemaV1\n} from \"@ark/schema\"\nimport {\n\tdomainOf,\n\thasDomain,\n\tisThunk,\n\tobjectKindOf,\n\tprintable,\n\tthrowParseError,\n\tuncapitalize,\n\ttype anyOrNever,\n\ttype array,\n\ttype Dict,\n\ttype ErrorMessage,\n\ttype Fn,\n\ttype ifEmptyObjectLiteral,\n\ttype objectKindOrDomainOf,\n\ttype Primitive\n} from \"@ark/util\"\nimport type { Out } from \"../attributes.ts\"\nimport type { type } from \"../keywords/keywords.ts\"\nimport type { InnerParseResult } from \"../scope.ts\"\nimport type {\n\tshallowDefaultableMessage,\n\tshallowOptionalMessage,\n\tvalidateString\n} from \"./ast/validate.ts\"\nimport {\n\tparseObjectLiteral,\n\ttype inferObjectLiteral,\n\ttype validateObjectLiteral\n} from \"./objectLiteral.ts\"\nimport type { isDefaultable, OptionalPropertyDefinition } from \"./property.ts\"\nimport {\n\tparseString,\n\ttype BaseCompletions,\n\ttype inferString\n} from \"./string.ts\"\nimport {\n\tmaybeParseTupleExpression,\n\ttype inferTupleExpression,\n\ttype maybeValidateTupleExpression,\n\ttype TupleExpression\n} from \"./tupleExpressions.ts\"\nimport {\n\tparseTupleLiteral,\n\ttype inferTupleLiteral,\n\ttype validateTupleLiteral\n} from \"./tupleLiteral.ts\"\n\nconst parseCache: {\n\t[cacheId: string]: { [def: string]: InnerParseResult } | undefined\n} = {}\n\nexport const parseInnerDefinition = (\n\tdef: unknown,\n\tctx: BaseParseContext\n): InnerParseResult => {\n\tif (typeof def === \"string\") {\n\t\tif (ctx.args && Object.keys(ctx.args).some(k => def.includes(k))) {\n\t\t\t// we can only rely on the cache if there are no contextual\n\t\t\t// resolutions like \"this\" or generic args\n\t\t\treturn parseString(def, ctx)\n\t\t}\n\t\tconst scopeCache = (parseCache[ctx.$.name] ??= {})\n\t\treturn (scopeCache[def] ??= parseString(def, ctx))\n\t}\n\treturn hasDomain(def, \"object\") ?\n\t\t\tparseObject(def, ctx)\n\t\t:\tthrowParseError(writeBadDefinitionTypeMessage(domainOf(def)))\n}\n\nexport const parseObject = (def: object, ctx: BaseParseContext): BaseRoot => {\n\tconst objectKind = objectKindOf(def)\n\tswitch (objectKind) {\n\t\tcase undefined:\n\t\t\tif (hasArkKind(def, \"root\")) return def\n\t\t\tif (\"~standard\" in def) return parseStandardSchema(def as never, ctx)\n\t\t\treturn parseObjectLiteral(def as Dict, ctx)\n\t\tcase \"Array\":\n\t\t\treturn parseTuple(def as array, ctx)\n\t\tcase \"RegExp\":\n\t\t\treturn ctx.$.node(\n\t\t\t\t\"intersection\",\n\t\t\t\t{\n\t\t\t\t\tdomain: \"string\",\n\t\t\t\t\tpattern: def as RegExp\n\t\t\t\t},\n\t\t\t\t{ prereduced: true }\n\t\t\t)\n\t\tcase \"Function\": {\n\t\t\tconst resolvedDef = isThunk(def) ? def() : def\n\t\t\tif (hasArkKind(resolvedDef, \"root\")) return resolvedDef\n\t\t\treturn throwParseError(writeBadDefinitionTypeMessage(\"Function\"))\n\t\t}\n\t\tdefault:\n\t\t\treturn throwParseError(\n\t\t\t\twriteBadDefinitionTypeMessage(objectKind ?? printable(def))\n\t\t\t)\n\t}\n}\n\nconst parseStandardSchema = (\n\tdef: StandardSchemaV1,\n\tctx: BaseParseContext\n): BaseRoot =>\n\tctx.$.intrinsic.unknown.pipe((v, ctx) => {\n\t\tconst result = def[\"~standard\"].validate(\n\t\t\tv\n\t\t) as StandardSchemaV1.Result<unknown>\n\n\t\tif (!result.issues) return result.value\n\n\t\tfor (const { message, path } of result.issues) {\n\t\t\tif (path) {\n\t\t\t\tif (path.length) {\n\t\t\t\t\tctx.error({\n\t\t\t\t\t\tproblem: uncapitalize(message),\n\t\t\t\t\t\trelativePath: path.map(k => (typeof k === \"object\" ? k.key : k))\n\t\t\t\t\t})\n\t\t\t\t} else {\n\t\t\t\t\tctx.error({\n\t\t\t\t\t\tmessage\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tctx.error({\n\t\t\t\t\tmessage\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t})\n\nexport type inferDefinition<def, $, args> =\n\t[def] extends [anyOrNever] ? def\n\t: def extends type.cast<infer t> ?\n\t\t// {} as a def is handled here since according to TS it extends { \" arkInferred\"?: t  }.\n\t\t// Unlike in TS however, ArkType object literals are constrained to object\n\t\t// so we use that as the base type inferred when parsing {}.\n\t\tifEmptyObjectLiteral<def, object, t>\n\t: def extends ThunkCast<infer t> ? t\n\t: def extends string ? inferString<def, $, args>\n\t: def extends array ? inferTuple<def, $, args>\n\t: def extends RegExp ? string\n\t: def extends StandardSchemaV1 ? inferStandardSchema<def>\n\t: def extends object ? inferObjectLiteral<def, $, args>\n\t: never\n\ntype inferStandardSchema<\n\tschema extends StandardSchemaV1,\n\ti = StandardSchemaV1.InferInput<schema>,\n\to = StandardSchemaV1.InferOutput<schema>\n> = [i, o] extends [o, i] ? i : (In: i) => Out<o>\n\n// validates a shallow definition, ensuring it does not represent an optional or\n// defaultable before drilling down further. a definition is shallow if it is either...\n\n// 1. the root value passed to type()\n// 2. a tuple expression\nexport type validateDefinition<def, $, args> =\n\tnull extends undefined ?\n\t\tErrorMessage<`'strict' or 'strictNullChecks' must be set to true in your tsconfig's 'compilerOptions'`>\n\t: [def] extends [anyOrNever] ? def\n\t: def extends OptionalPropertyDefinition ?\n\t\tErrorMessage<shallowOptionalMessage>\n\t: isDefaultable<def, $, args> extends true ?\n\t\tErrorMessage<shallowDefaultableMessage>\n\t:\tvalidateInnerDefinition<def, $, args>\n\n// validates the definition without checking for optionals/defaults this should\n// be used when one of these is true...\n\n// 1. we are validating a shallow definition and have already ensured it does not\n//    represent an optional or defaultable\n// 2. we are validating the root of a property definition\nexport type validateInnerDefinition<def, $, args> =\n\t[def] extends [TerminalObjectDefinition] ? def\n\t: def extends string ? validateString<def, $, args>\n\t: unknown extends def ?\n\t\t// this allows the initial list of autocompletions to be populated when a user writes \"type()\",\n\t\t// before having specified a definition\n\t\tBaseCompletions<$, args> | {}\n\t: def extends readonly unknown[] ? validateTuple<def, $, args>\n\t: def extends BadDefinitionType ?\n\t\tErrorMessage<writeBadDefinitionTypeMessage<objectKindOrDomainOf<def>>>\n\t:\tvalidateObjectLiteral<def, $, args>\n\nexport const parseTuple = (def: array, ctx: BaseParseContext): BaseRoot =>\n\tmaybeParseTupleExpression(def, ctx) ?? parseTupleLiteral(def, ctx)\n\nexport type validateTuple<def extends array, $, args> =\n\tmaybeValidateTupleExpression<def, $, args> extends infer result ?\n\t\tresult extends null ?\n\t\t\tvalidateTupleLiteral<def, $, args>\n\t\t:\tresult\n\t:\tnever\n\nexport type inferTuple<def extends array, $, args> =\n\tdef extends TupleExpression ? inferTupleExpression<def, $, args>\n\t:\tinferTupleLiteral<def, $, args>\n\n// functions are ignored in validation so that cyclic thunk definitions can be\n// inferred in scopes\nexport type TerminalObjectDefinition =\n\t| type.cast<unknown>\n\t| Fn\n\t| RegExp\n\t| StandardSchemaV1\n\nexport type ThunkCast<t = unknown> = () => type.cast<t>\n\ntype BadDefinitionType = Exclude<Primitive, string>\n\nexport const writeBadDefinitionTypeMessage = <actual extends string>(\n\tactual: actual\n): writeBadDefinitionTypeMessage<actual> =>\n\t`Type definitions must be strings or objects (was ${actual})`\n\ntype writeBadDefinitionTypeMessage<actual extends string> =\n\t`Type definitions must be strings or objects (was ${actual})`\n"
  },
  {
    "path": "ark/type/parser/objectLiteral.ts",
    "content": "import {\n\tintrinsic,\n\tnormalizeIndex,\n\ttype BaseParseContext,\n\ttype BaseRoot,\n\ttype Inner,\n\ttype NodeSchema,\n\ttype Prop,\n\ttype Structure,\n\ttype writeInvalidPropertyKeyMessage\n} from \"@ark/schema\"\nimport {\n\tappend,\n\tBackslash,\n\tisArray,\n\tisEmptyObject,\n\tprintable,\n\tstringAndSymbolicEntriesOf,\n\tthrowParseError,\n\ttype anyOrNever,\n\ttype Dict,\n\ttype ErrorMessage,\n\ttype ErrorType,\n\ttype Key,\n\ttype merge,\n\ttype mutable,\n\ttype show\n} from \"@ark/util\"\nimport type { validateString } from \"./ast/validate.ts\"\nimport type { inferDefinition } from \"./definition.ts\"\nimport {\n\tinvalidDefaultableKeyKindMessage,\n\tinvalidOptionalKeyKindMessage,\n\tparseProperty,\n\ttype OptionalPropertyDefinition,\n\ttype validateProperty\n} from \"./property.ts\"\n\ntype MutableStructureSchema = mutable<NodeSchema<\"structure\">, 2>\n\nexport const parseObjectLiteral = (\n\tdef: Dict,\n\tctx: BaseParseContext\n): BaseRoot => {\n\tlet spread: Structure.Node | undefined\n\tconst structure: MutableStructureSchema = {}\n\t// We only allow a spread operator to be used as the first key in an object\n\t// because to match JS behavior any keys before the spread are overwritten\n\t// by the values in the target object, so there'd be no useful purpose in having it\n\t// anywhere except for the beginning.\n\tconst defEntries = stringAndSymbolicEntriesOf(def)\n\n\tfor (const [k, v] of defEntries) {\n\t\tconst parsedKey = preparseKey(k)\n\n\t\tif (parsedKey.kind === \"spread\") {\n\t\t\tif (!isEmptyObject(structure))\n\t\t\t\treturn throwParseError(nonLeadingSpreadError)\n\t\t\tconst operand = ctx.$.parseOwnDefinitionFormat(v, ctx)\n\t\t\t// treat object domain as empty for spreading (useful for generic constraints)\n\t\t\tif (operand.equals(intrinsic.object)) continue\n\t\t\tif (\n\t\t\t\t!operand.hasKind(\"intersection\") ||\n\t\t\t\t// still error on attempts to spread proto nodes like ...Date\n\t\t\t\t!operand.basis?.equals(intrinsic.object)\n\t\t\t) {\n\t\t\t\treturn throwParseError(\n\t\t\t\t\twriteInvalidSpreadTypeMessage(operand.expression)\n\t\t\t\t)\n\t\t\t}\n\t\t\tspread = operand.structure\n\t\t\tcontinue\n\t\t}\n\n\t\tif (parsedKey.kind === \"undeclared\") {\n\t\t\tif (v !== \"reject\" && v !== \"delete\" && v !== \"ignore\")\n\t\t\t\tthrowParseError(writeInvalidUndeclaredBehaviorMessage(v))\n\t\t\tstructure.undeclared = v\n\t\t\tcontinue\n\t\t}\n\n\t\tconst parsedValue = parseProperty(v, ctx)\n\t\tconst parsedEntryKey = parsedKey as PreparsedEntryKey\n\n\t\tif (parsedKey.kind === \"required\") {\n\t\t\tif (!isArray(parsedValue)) {\n\t\t\t\tappendNamedProp(\n\t\t\t\t\tstructure,\n\t\t\t\t\t\"required\",\n\t\t\t\t\t{\n\t\t\t\t\t\tkey: parsedKey.normalized,\n\t\t\t\t\t\tvalue: parsedValue\n\t\t\t\t\t},\n\t\t\t\t\tctx\n\t\t\t\t)\n\t\t\t} else {\n\t\t\t\tappendNamedProp(\n\t\t\t\t\tstructure,\n\t\t\t\t\t\"optional\",\n\t\t\t\t\tparsedValue[1] === \"=\" ?\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkey: parsedKey.normalized,\n\t\t\t\t\t\t\tvalue: parsedValue[0],\n\t\t\t\t\t\t\tdefault: parsedValue[2]\n\t\t\t\t\t\t}\n\t\t\t\t\t:\t{\n\t\t\t\t\t\t\tkey: parsedKey.normalized,\n\t\t\t\t\t\t\tvalue: parsedValue[0]\n\t\t\t\t\t\t},\n\t\t\t\t\tctx\n\t\t\t\t)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tif (isArray(parsedValue)) {\n\t\t\tif (parsedValue[1] === \"?\") throwParseError(invalidOptionalKeyKindMessage)\n\n\t\t\tif (parsedValue[1] === \"=\")\n\t\t\t\tthrowParseError(invalidDefaultableKeyKindMessage)\n\t\t}\n\n\t\t// value must be a BaseRoot at this point\n\n\t\tif (parsedKey.kind === \"optional\") {\n\t\t\tappendNamedProp(\n\t\t\t\tstructure,\n\t\t\t\t\"optional\",\n\t\t\t\t{\n\t\t\t\t\tkey: parsedKey.normalized,\n\t\t\t\t\tvalue: parsedValue\n\t\t\t\t},\n\t\t\t\tctx\n\t\t\t)\n\t\t\tcontinue\n\t\t}\n\n\t\t// must be index at this point\n\n\t\tconst signature = ctx.$.parseOwnDefinitionFormat(\n\t\t\tparsedEntryKey.normalized,\n\t\t\tctx\n\t\t)\n\n\t\tconst normalized = normalizeIndex(signature, parsedValue, ctx.$)\n\n\t\tif (normalized.index)\n\t\t\tstructure.index = append(structure.index, normalized.index)\n\n\t\tif (normalized.required)\n\t\t\tstructure.required = append(structure.required, normalized.required)\n\t}\n\n\tconst structureNode = ctx.$.node(\"structure\", structure)\n\n\treturn ctx.$.parseSchema({\n\t\tdomain: \"object\",\n\t\tstructure: spread?.merge(structureNode) ?? structureNode\n\t})\n}\n\nconst appendNamedProp = <kind extends Prop.Kind>(\n\tstructure: MutableStructureSchema,\n\tkind: kind,\n\tinner: Inner<kind>,\n\tctx: BaseParseContext\n) => {\n\tstructure[kind] = append(\n\t\t// doesn't seem like this cast should be necessary\n\t\tstructure[kind] as MutableStructureSchema[Prop.Kind],\n\t\tctx.$.node(kind, inner)\n\t)\n}\n\nexport type inferObjectLiteral<def extends object, $, args> = show<\n\t\"...\" extends keyof def ?\n\t\tmerge<\n\t\t\tinferDefinition<def[\"...\"], $, args>,\n\t\t\t_inferObjectLiteral<def, $, args>\n\t\t>\n\t:\t_inferObjectLiteral<def, $, args>\n>\n\n/**\n * Infers the contents of an object literal, ignoring a spread definition\n */\ntype _inferObjectLiteral<def extends object, $, args> = {\n\t// since def is a const parameter, we remove the readonly modifier here\n\t// support for built-in readonly tracked here:\n\t// https://github.com/arktypeio/arktype/issues/808\n\t-readonly [k in keyof def as nonOptionalKeyFromEntry<\n\t\tk,\n\t\tdef[k],\n\t\t$,\n\t\targs\n\t>]: inferDefinition<def[k], $, args>\n} & {\n\t-readonly [k in keyof def as optionalKeyFromEntry<\n\t\tk,\n\t\tdef[k]\n\t>]?: def[k] extends OptionalPropertyDefinition<infer baseDef> ?\n\t\tinferDefinition<baseDef, $, args>\n\t:\tinferDefinition<def[k], $, args>\n}\n\nexport type validateObjectLiteral<def, $, args> = {\n\t[k in keyof def]: preparseKey<k> extends (\n\t\tinfer parsedKey extends PreparsedKey\n\t) ?\n\t\tparsedKey extends PreparsedEntryKey<\"index\"> ?\n\t\t\tvalidateString<parsedKey[\"normalized\"], $, args> extends (\n\t\t\t\tErrorMessage<infer message>\n\t\t\t) ?\n\t\t\t\t// add a nominal type here to avoid allowing the error message as input\n\t\t\t\tErrorType<message>\n\t\t\t: inferDefinition<parsedKey[\"normalized\"], $, args> extends Key ?\n\t\t\t\t// if the index def is syntactically and semantically valid,\n\t\t\t\t// move on to the validating the value definition\n\t\t\t\tvalidateProperty<def[k], parsedKey[\"kind\"], $, args>\n\t\t\t:\tErrorMessage<writeInvalidPropertyKeyMessage<parsedKey[\"normalized\"]>>\n\t\t:\tvalidateProperty<def[k], parsedKey[\"kind\"], $, args>\n\t:\tnever\n}\n\ntype nonOptionalKeyFromEntry<k extends PropertyKey, v, $, args> =\n\t// inferring into parsedKey with no extends check seems to\n\t// help TS preserve homomorphic mapping for required keys\n\tpreparseKey<k> extends infer parsedKey ?\n\t\tparsedKey extends PreparsedEntryKey<\"required\"> ?\n\t\t\t[v] extends [OptionalPropertyDefinition] ?\n\t\t\t\t[v] extends [anyOrNever] ?\n\t\t\t\t\tparsedKey[\"normalized\"]\n\t\t\t\t:\tnever\n\t\t\t:\tparsedKey[\"normalized\"]\n\t\t: parsedKey extends PreparsedEntryKey<\"index\"> ?\n\t\t\tinferDefinition<parsedKey[\"normalized\"], $, args> & Key\n\t\t:\t// optional keys are not included by definition\n\t\t\t// \"...\" is handled at the type root so is handled neither here nor in optionalKeyFrom\n\t\t\t// \"+\" has no effect on inference\n\t\t\tnever\n\t:\tnever\n\ntype optionalKeyFromEntry<k extends PropertyKey, v> =\n\t// inferring into parsedKey with no extends check seems to\n\t// help TS preserve homomorphic mapping for value-optional keys\n\tpreparseKey<k> extends infer parsedKey ?\n\t\tparsedKey extends PreparsedEntryKey<\"optional\"> ? parsedKey[\"normalized\"]\n\t\t: v extends OptionalPropertyDefinition ? k\n\t\t: never\n\t:\tnever\n\nexport const writeInvalidUndeclaredBehaviorMessage = (\n\tactual: unknown\n): string =>\n\t`Value of '+' key must be 'reject', 'delete', or 'ignore' (was ${printable(actual)})`\n\nexport const nonLeadingSpreadError =\n\t\"Spread operator may only be used as the first key in an object\"\n\nexport type PreparsedKey = PreparsedEntryKey | PreparsedSpecialKey\n\ntype normalizedKeyKind<kind extends EntryKeyKind> =\n\tkind extends \"index\" ? string : Key\n\nexport type PreparsedEntryKey<\n\tkind extends EntryKeyKind = EntryKeyKind,\n\tnormalized extends normalizedKeyKind<kind> = normalizedKeyKind<kind>\n> = {\n\tkind: kind\n\tnormalized: normalized\n}\n\nexport type PreparsedSpecialKey<kind extends SpecialKeyKind = SpecialKeyKind> =\n\t{\n\t\tkind: kind\n\t}\n\ndeclare namespace PreparsedKey {\n\texport type from<t extends PreparsedKey> = t\n}\n\nexport type ParsedKeyKind = EntryKeyKind | SpecialKeyKind\n\nexport type EntryKeyKind = \"required\" | \"optional\" | \"index\"\n\nexport type SpecialKeyKind = \"spread\" | \"undeclared\"\n\nexport type MetaKey = \"...\" | \"+\"\n\nexport type IndexKey<def extends string = string> = `[${def}]`\n\nexport const preparseKey = (key: Key): PreparsedKey =>\n\ttypeof key === \"symbol\" ? { kind: \"required\", normalized: key }\n\t: key[key.length - 1] === \"?\" ?\n\t\tkey[key.length - 2] === Backslash ?\n\t\t\t{ kind: \"required\", normalized: `${key.slice(0, -2)}?` }\n\t\t:\t{\n\t\t\t\tkind: \"optional\",\n\t\t\t\tnormalized: key.slice(0, -1)\n\t\t\t}\n\t: key[0] === \"[\" && key[key.length - 1] === \"]\" ?\n\t\t{ kind: \"index\", normalized: key.slice(1, -1) }\n\t: key[0] === Backslash && key[1] === \"[\" && key[key.length - 1] === \"]\" ?\n\t\t{ kind: \"required\", normalized: key.slice(1) }\n\t: key === \"...\" ? { kind: \"spread\" }\n\t: key === \"+\" ? { kind: \"undeclared\" }\n\t: {\n\t\t\tkind: \"required\",\n\t\t\tnormalized:\n\t\t\t\tkey === \"\\\\...\" ? \"...\"\n\t\t\t\t: key === \"\\\\+\" ? \"+\"\n\t\t\t\t: key\n\t\t}\n\nexport type preparseKey<k> =\n\tk extends symbol ?\n\t\tPreparsedKey.from<{\n\t\t\tkind: \"required\"\n\t\t\tnormalized: k\n\t\t}>\n\t: k extends `${infer inner}?` ?\n\t\tinner extends `${infer baseName}${Backslash}` ?\n\t\t\tPreparsedKey.from<{\n\t\t\t\tkind: \"required\"\n\t\t\t\tnormalized: `${baseName}?`\n\t\t\t}>\n\t\t:\tPreparsedKey.from<{\n\t\t\t\tkind: \"optional\"\n\t\t\t\tnormalized: inner\n\t\t\t}>\n\t: k extends \"+\" ? { kind: \"undeclared\" }\n\t: k extends \"...\" ? { kind: \"spread\" }\n\t: k extends `${Backslash}${infer escapedMeta extends MetaKey}` ?\n\t\tPreparsedKey.from<{ kind: \"required\"; normalized: escapedMeta }>\n\t: k extends IndexKey<infer def> ?\n\t\tPreparsedKey.from<{\n\t\t\tkind: \"index\"\n\t\t\tnormalized: def\n\t\t}>\n\t:\tPreparsedKey.from<{\n\t\t\tkind: \"required\"\n\t\t\tnormalized: k extends (\n\t\t\t\t`${Backslash}${infer escapedIndexKey extends IndexKey}`\n\t\t\t) ?\n\t\t\t\tescapedIndexKey\n\t\t\t: k extends Key ? k\n\t\t\t: `${k & number}`\n\t\t}>\n\nexport const writeInvalidSpreadTypeMessage = <def extends string>(\n\tdef: def\n): writeInvalidSpreadTypeMessage<def> =>\n\t`Spread operand must resolve to an object literal type (was ${def})`\n\nexport type writeInvalidSpreadTypeMessage<def extends string> =\n\t`Spread operand must resolve to an object literal type (was ${def})`\n"
  },
  {
    "path": "ark/type/parser/property.ts",
    "content": "import type {\n\tBaseParseContext,\n\tBaseRoot,\n\tUndeclaredKeyBehavior\n} from \"@ark/schema\"\nimport {\n\tisArray,\n\ttype anyOrNever,\n\ttype ErrorMessage,\n\ttype ErrorType,\n\ttype typeToString\n} from \"@ark/util\"\nimport {\n\tparseInnerDefinition,\n\ttype inferDefinition,\n\ttype validateInnerDefinition\n} from \"./definition.ts\"\nimport type {\n\tParsedKeyKind,\n\twriteInvalidSpreadTypeMessage\n} from \"./objectLiteral.ts\"\nimport type { ParsedDefaultableProperty } from \"./shift/operator/default.ts\"\nimport type { parseString } from \"./string.ts\"\n\nexport type ParsedPropertyKind = \"plain\" | \"optional\" | \"defaultable\"\n\nexport type ParsedProperty =\n\t| ParsedRequiredProperty\n\t| ParsedOptionalProperty\n\t| ParsedDefaultableProperty\n\nexport type ParsedRequiredProperty = BaseRoot\n\nexport type ParsedOptionalProperty = readonly [BaseRoot, \"?\"]\n\nexport const parseProperty = (\n\tdef: unknown,\n\tctx: BaseParseContext\n): ParsedProperty => {\n\tif (isArray(def)) {\n\t\tif (def[1] === \"=\")\n\t\t\treturn [ctx.$.parseOwnDefinitionFormat(def[0], ctx), \"=\", def[2]]\n\n\t\tif (def[1] === \"?\")\n\t\t\treturn [ctx.$.parseOwnDefinitionFormat(def[0], ctx), \"?\"]\n\t}\n\n\t// string-embedded defaults/optionals are handled by the string parser\n\treturn parseInnerDefinition(def, ctx)\n}\n\nexport type validateProperty<def, keyKind extends ParsedKeyKind, $, args> =\n\t[def] extends [anyOrNever] ?\n\t\t/** this extra [anyOrNever] check is required to ensure that nested `type` invocations\n\t\t * like the following are not prematurely validated by the outer call:\n\t\t *\n\t\t * ```ts\n\t\t * type({\n\t\t * \t\"test?\": type(\"string\").pipe(x => x === \"true\")\n\t\t * })\n\t\t * ```\n\t\t */\n\t\tdef\n\t: keyKind extends \"spread\" ?\n\t\tdef extends validateInnerDefinition<def, $, args> ?\n\t\t\tinferDefinition<def, $, args> extends object ?\n\t\t\t\tdef\n\t\t\t:\tErrorType<\n\t\t\t\t\twriteInvalidSpreadTypeMessage<\n\t\t\t\t\t\ttypeToString<inferDefinition<def, $, args>>\n\t\t\t\t\t>\n\t\t\t\t>\n\t\t:\tvalidateInnerDefinition<def, $, args>\n\t: keyKind extends \"undeclared\" ? UndeclaredKeyBehavior\n\t: keyKind extends \"required\" ? validateInnerDefinition<def, $, args>\n\t: // check to ensure we don't have an optional or defaultable value on\n\t// an already optional or index key\n\tdef extends OptionalPropertyDefinition ?\n\t\tErrorMessage<invalidOptionalKeyKindMessage>\n\t: isDefaultable<def, $, args> extends true ?\n\t\tErrorMessage<invalidDefaultableKeyKindMessage>\n\t:\tvalidateInnerDefinition<def, $, args>\n\nexport type isDefaultable<def, $, args> =\n\tdef extends DefaultablePropertyTuple ? true\n\t: def extends PossibleDefaultableStringDefinition ?\n\t\tparseString<def, $, args> extends DefaultablePropertyTuple ?\n\t\t\ttrue\n\t\t:\tfalse\n\t:\tfalse\n\nexport type OptionalPropertyDefinition<baseDef = unknown> =\n\t| OptionalPropertyTuple<baseDef>\n\t| OptionalPropertyString<baseDef & string>\n\nexport type OptionalPropertyString<baseDef extends string = string> =\n\t`${baseDef}?`\n\nexport type OptionalPropertyTuple<baseDef = unknown> = readonly [baseDef, \"?\"]\n\n// a precise type for a defaultable string definition\n// isn't possible due to arbitrary whitespace surrounding \"=\",\n// so that must be checked by parsing and testing if\n// the root is a DefaultablePropertyTuple\nexport type PossibleDefaultableStringDefinition = `${string}=${string}`\n\nexport type DefaultablePropertyTuple<\n\tbaseDef = unknown,\n\tthunkableProperty = unknown\n> = readonly [baseDef, \"=\", thunkableProperty]\n\n// single quote use here is better for TypeScript's inlined error to avoid escapes\nexport const invalidOptionalKeyKindMessage = `Only required keys may make their values optional, e.g. { [mySymbol]: ['number', '?'] }`\n\nexport type invalidOptionalKeyKindMessage = typeof invalidOptionalKeyKindMessage\n\n// single quote use here is better for TypeScript's inlined error to avoid escapes\nexport const invalidDefaultableKeyKindMessage = `Only required keys may specify default values, e.g. { value: 'number = 0' }`\n\nexport type invalidDefaultableKeyKindMessage =\n\ttypeof invalidDefaultableKeyKindMessage\n"
  },
  {
    "path": "ark/type/parser/reduce/dynamic.ts",
    "content": "import type { BaseParseContext, BaseRoot } from \"@ark/schema\"\nimport {\n\tisKeyOf,\n\ttype requireKeys,\n\ttype Scanner,\n\tthrowInternalError,\n\tthrowParseError,\n\twriteUnclosedGroupMessage,\n\twriteUnmatchedGroupCloseMessage\n} from \"@ark/util\"\nimport type { LimitLiteral } from \"../../attributes.ts\"\nimport { parseOperand } from \"../shift/operand/operand.ts\"\nimport { parseOperator } from \"../shift/operator/operator.ts\"\nimport type { FinalizingLookahead, InfixToken } from \"../shift/tokens.ts\"\nimport { parseUntilFinalizer } from \"../string.ts\"\nimport {\n\ttype BranchOperator,\n\ttype Comparator,\n\tinvertedComparators,\n\ttype MinComparator,\n\tminComparators,\n\ttype OpenLeftBound,\n\ttype StringifiablePrefixOperator,\n\twriteMultipleLeftBoundsMessage,\n\twriteOpenRangeMessage,\n\twriteUnpairableComparatorMessage\n} from \"./shared.ts\"\n\ntype BranchState = {\n\tprefixes: StringifiablePrefixOperator[]\n\tleftBound: OpenLeftBound | null\n\tintersection: BaseRoot | null\n\tunion: BaseRoot | null\n\tpipe: BaseRoot | null\n}\n\nexport type RootedRuntimeState = requireKeys<RuntimeState, \"root\">\n\nexport class RuntimeState {\n\troot: BaseRoot | undefined\n\tbranches: BranchState = {\n\t\tprefixes: [],\n\t\tleftBound: null,\n\t\tintersection: null,\n\t\tunion: null,\n\t\tpipe: null\n\t}\n\tfinalizer: FinalizingLookahead | undefined\n\tgroups: BranchState[] = []\n\n\tscanner: Scanner\n\tctx: BaseParseContext\n\n\tconstructor(scanner: Scanner, ctx: BaseParseContext) {\n\t\tthis.scanner = scanner\n\t\tthis.ctx = ctx\n\t}\n\n\terror(message: string): never {\n\t\treturn throwParseError(message)\n\t}\n\n\thasRoot(): this is RootedRuntimeState {\n\t\treturn this.root !== undefined\n\t}\n\n\tsetRoot(root: BaseRoot): void {\n\t\tthis.root = root\n\t}\n\n\tunsetRoot(): this[\"root\"] {\n\t\tconst value = this.root\n\t\tthis.root = undefined\n\t\treturn value\n\t}\n\n\tconstrainRoot(...args: Parameters<BaseRoot<any>[\"constrain\"]>): void {\n\t\tthis.root = this.root!.constrain(args[0], args[1])\n\t}\n\n\tfinalize(finalizer: FinalizingLookahead): void {\n\t\tif (this.groups.length) return this.error(writeUnclosedGroupMessage(\")\"))\n\n\t\tthis.finalizeBranches()\n\t\tthis.finalizer = finalizer\n\t}\n\n\treduceLeftBound(limit: LimitLiteral, comparator: Comparator): void {\n\t\tconst invertedComparator = invertedComparators[comparator]\n\t\tif (!isKeyOf(invertedComparator, minComparators))\n\t\t\treturn this.error(writeUnpairableComparatorMessage(comparator))\n\n\t\tif (this.branches.leftBound) {\n\t\t\treturn this.error(\n\t\t\t\twriteMultipleLeftBoundsMessage(\n\t\t\t\t\tthis.branches.leftBound.limit,\n\t\t\t\t\tthis.branches.leftBound.comparator,\n\t\t\t\t\tlimit,\n\t\t\t\t\tinvertedComparator\n\t\t\t\t)\n\t\t\t)\n\t\t}\n\t\tthis.branches.leftBound = {\n\t\t\tcomparator: invertedComparator,\n\t\t\tlimit\n\t\t}\n\t}\n\n\tfinalizeBranches(): void {\n\t\tthis.assertRangeUnset()\n\n\t\tif (this.branches.pipe) {\n\t\t\tthis.pushRootToBranch(\"|>\")\n\t\t\tthis.root = this.branches.pipe\n\t\t\treturn\n\t\t}\n\n\t\tif (this.branches.union) {\n\t\t\tthis.pushRootToBranch(\"|\")\n\t\t\tthis.root = this.branches.union\n\t\t\treturn\n\t\t}\n\n\t\tif (this.branches.intersection) {\n\t\t\tthis.pushRootToBranch(\"&\")\n\t\t\tthis.root = this.branches.intersection\n\t\t\treturn\n\t\t}\n\n\t\tthis.applyPrefixes()\n\t}\n\n\tfinalizeGroup(): void {\n\t\tthis.finalizeBranches()\n\t\tconst topBranchState = this.groups.pop()\n\t\tif (!topBranchState) {\n\t\t\treturn this.error(\n\t\t\t\twriteUnmatchedGroupCloseMessage(\")\", this.scanner.unscanned)\n\t\t\t)\n\t\t}\n\n\t\tthis.branches = topBranchState\n\t}\n\n\taddPrefix(prefix: StringifiablePrefixOperator): void {\n\t\tthis.branches.prefixes.push(prefix)\n\t}\n\n\tapplyPrefixes(): void {\n\t\twhile (this.branches.prefixes.length) {\n\t\t\tconst lastPrefix = this.branches.prefixes.pop()!\n\t\t\tthis.root =\n\t\t\t\tlastPrefix === \"keyof\" ?\n\t\t\t\t\tthis.root!.keyof()\n\t\t\t\t:\tthrowInternalError(`Unexpected prefix '${lastPrefix}'`)\n\t\t}\n\t}\n\n\tpushRootToBranch(token: BranchOperator): void {\n\t\tthis.assertRangeUnset()\n\t\tthis.applyPrefixes()\n\t\tconst root = this.root!\n\t\tthis.root = undefined\n\n\t\tthis.branches.intersection =\n\t\t\tthis.branches.intersection?.rawAnd(root) ?? root\n\n\t\tif (token === \"&\") return\n\n\t\tthis.branches.union =\n\t\t\tthis.branches.union?.rawOr(this.branches.intersection) ??\n\t\t\tthis.branches.intersection\n\t\tthis.branches.intersection = null\n\n\t\tif (token === \"|\") return\n\n\t\tthis.branches.pipe =\n\t\t\tthis.branches.pipe?.rawPipeOnce(this.branches.union) ??\n\t\t\tthis.branches.union\n\t\tthis.branches.union = null\n\t}\n\n\tparseUntilFinalizer(): RootedRuntimeState {\n\t\treturn parseUntilFinalizer(new RuntimeState(this.scanner, this.ctx))\n\t}\n\n\tparseOperator(this: RootedRuntimeState): void {\n\t\treturn parseOperator(this)\n\t}\n\n\tparseOperand(): void {\n\t\treturn parseOperand(this)\n\t}\n\n\tprivate assertRangeUnset() {\n\t\tif (this.branches.leftBound) {\n\t\t\treturn this.error(\n\t\t\t\twriteOpenRangeMessage(\n\t\t\t\t\tthis.branches.leftBound.limit,\n\t\t\t\t\tthis.branches.leftBound.comparator\n\t\t\t\t)\n\t\t\t)\n\t\t}\n\t}\n\n\treduceGroupOpen(): void {\n\t\tthis.groups.push(this.branches)\n\t\tthis.branches = {\n\t\t\tprefixes: [],\n\t\t\tleftBound: null,\n\t\t\tunion: null,\n\t\t\tintersection: null,\n\t\t\tpipe: null\n\t\t}\n\t}\n\n\tpreviousOperator():\n\t\t| MinComparator\n\t\t| StringifiablePrefixOperator\n\t\t| InfixToken\n\t\t| undefined {\n\t\treturn (\n\t\t\tthis.branches.leftBound?.comparator ??\n\t\t\tthis.branches.prefixes[this.branches.prefixes.length - 1] ??\n\t\t\t(this.branches.intersection ? \"&\"\n\t\t\t: this.branches.union ? \"|\"\n\t\t\t: this.branches.pipe ? \"|>\"\n\t\t\t: undefined)\n\t\t)\n\t}\n\n\tshiftedBy(count: number): this {\n\t\tthis.scanner.jumpForward(count)\n\t\treturn this\n\t}\n}\n"
  },
  {
    "path": "ark/type/parser/reduce/shared.ts",
    "content": "import type { LimitLiteral } from \"../../attributes.ts\"\n\nexport type StringifiablePrefixOperator = \"keyof\"\n\nexport const minComparators = {\n\t\">\": true,\n\t\">=\": true\n} as const\n\nexport type MinComparator = keyof typeof minComparators\n\nexport const maxComparators = {\n\t\"<\": true,\n\t\"<=\": true\n} as const\n\nexport type MaxComparator = keyof typeof maxComparators\n\nexport const comparators = {\n\t\">\": true,\n\t\">=\": true,\n\t\"<\": true,\n\t\"<=\": true,\n\t\"==\": true\n}\n\nexport type Comparator = keyof typeof comparators\n\nexport const invertedComparators: InvertedComparators = {\n\t\"<\": \">\",\n\t\">\": \"<\",\n\t\"<=\": \">=\",\n\t\">=\": \"<=\",\n\t\"==\": \"==\"\n}\n\nexport type InvertedComparators = {\n\t\"<\": \">\"\n\t\">\": \"<\"\n\t\"<=\": \">=\"\n\t\">=\": \"<=\"\n\t\"==\": \"==\"\n}\n\nexport type BranchOperator = \"&\" | \"|\" | \"|>\"\n\nexport type OpenLeftBound = { limit: LimitLiteral; comparator: MinComparator }\n\nexport const writeOpenRangeMessage = <\n\tmin extends LimitLiteral,\n\tcomparator extends MinComparator\n>(\n\tmin: min,\n\tcomparator: comparator\n): writeOpenRangeMessage<min, comparator> =>\n\t`Left bounds are only valid when paired with right bounds (try ...${comparator}${min})`\n\nexport type writeOpenRangeMessage<\n\tmin extends LimitLiteral,\n\tcomparator extends MinComparator\n> = `Left bounds are only valid when paired with right bounds (try ...${comparator}${min})`\n\nexport type writeUnpairableComparatorMessage<comparator extends Comparator> =\n\t`Left-bounded expressions must specify their limits using < or <= (was ${comparator})`\n\nexport const writeUnpairableComparatorMessage = <comparator extends Comparator>(\n\tcomparator: comparator\n): writeUnpairableComparatorMessage<comparator> =>\n\t`Left-bounded expressions must specify their limits using < or <= (was ${comparator})`\n\nexport const writeMultipleLeftBoundsMessage = <\n\topenLimit extends LimitLiteral,\n\topenComparator extends MinComparator,\n\tlimit extends LimitLiteral,\n\tcomparator extends MinComparator\n>(\n\topenLimit: openLimit,\n\topenComparator: openComparator,\n\tlimit: limit,\n\tcomparator: comparator\n): writeMultipleLeftBoundsMessage<\n\topenLimit,\n\topenComparator,\n\tlimit,\n\tcomparator\n> =>\n\t`An expression may have at most one left bound (parsed ${openLimit}${invertedComparators[openComparator]}, ${limit}${invertedComparators[comparator]})`\n\nexport type writeMultipleLeftBoundsMessage<\n\topenLimit extends LimitLiteral,\n\topenComparator extends MinComparator,\n\tlimit extends LimitLiteral,\n\tcomparator extends MinComparator\n> = `An expression may have at most one left bound (parsed ${openLimit}${InvertedComparators[openComparator]}, ${limit}${InvertedComparators[comparator]})`\n"
  },
  {
    "path": "ark/type/parser/reduce/static.ts",
    "content": "import type {\n\tCompletion,\n\tErrorMessage,\n\tdefined,\n\twriteUnclosedGroupMessage,\n\twriteUnmatchedGroupCloseMessage\n} from \"@ark/util\"\nimport type { LimitLiteral } from \"../../attributes.ts\"\nimport type { FinalizingLookahead } from \"../shift/tokens.ts\"\nimport type {\n\tBranchOperator,\n\tComparator,\n\tInvertedComparators,\n\tMaxComparator,\n\tMinComparator,\n\tOpenLeftBound,\n\tStringifiablePrefixOperator,\n\twriteMultipleLeftBoundsMessage,\n\twriteOpenRangeMessage,\n\twriteUnpairableComparatorMessage\n} from \"./shared.ts\"\n\nexport type StaticState = {\n\troot: unknown\n\tbranches: BranchState\n\tgroups: BranchState[]\n\tfinalizer: FinalizingLookahead | ErrorMessage | undefined\n\tscanned: string\n\tunscanned: string\n}\n\ntype BranchState = {\n\tprefixes: StringifiablePrefixOperator[]\n\tleftBound: OpenLeftBound | undefined\n\tintersection: unknown\n\tpipe: unknown\n\tunion: unknown\n}\n\nexport type AutocompletePrefix = `${StringifiablePrefixOperator} `\n\nexport declare namespace s {\n\texport type initialize<def extends string> = from<{\n\t\troot: undefined\n\t\tbranches: initialBranches\n\t\tgroups: []\n\t\tfinalizer: undefined\n\t\tscanned: \"\"\n\t\tunscanned: def\n\t}>\n\n\texport type error<message extends string> = from<{\n\t\troot: ErrorMessage<message>\n\t\tbranches: initialBranches\n\t\tgroups: []\n\t\tfinalizer: ErrorMessage<message>\n\t\tscanned: \"\"\n\t\tunscanned: \"\"\n\t}>\n\n\texport type completion<text extends string> = from<{\n\t\troot: Completion<text>\n\t\tbranches: initialBranches\n\t\tgroups: []\n\t\tfinalizer: Completion<text>\n\t\tscanned: \"\"\n\t\tunscanned: \"\"\n\t}>\n\n\ttype initialBranches = branchesFrom<{\n\t\tprefixes: []\n\t\tleftBound: undefined\n\t\tintersection: undefined\n\t\tpipe: undefined\n\t\tunion: undefined\n\t}>\n\n\ttype updateScanned<\n\t\tpreviousScanned extends string,\n\t\tpreviousUnscanned extends string,\n\t\tupdatedUnscanned extends string\n\t> =\n\t\tpreviousUnscanned extends `${infer justScanned}${updatedUnscanned}` ?\n\t\t\t`${previousScanned}${justScanned}`\n\t\t:\tpreviousScanned\n\n\texport type setRoot<\n\t\ts extends StaticState,\n\t\troot,\n\t\tunscanned extends string = s[\"unscanned\"]\n\t> = from<{\n\t\troot: root\n\t\tbranches: s[\"branches\"]\n\t\tgroups: s[\"groups\"]\n\t\tfinalizer: s[\"finalizer\"]\n\t\tscanned: updateScanned<s[\"scanned\"], s[\"unscanned\"], unscanned>\n\t\tunscanned: unscanned\n\t}>\n\n\texport type addPrefix<\n\t\ts extends StaticState,\n\t\tprefix extends StringifiablePrefixOperator,\n\t\tunscanned extends string = s[\"unscanned\"]\n\t> = from<{\n\t\troot: s[\"root\"]\n\t\tbranches: {\n\t\t\tprefixes: [...s[\"branches\"][\"prefixes\"], prefix]\n\t\t\tleftBound: s[\"branches\"][\"leftBound\"]\n\t\t\tintersection: s[\"branches\"][\"intersection\"]\n\t\t\tpipe: s[\"branches\"][\"pipe\"]\n\t\t\tunion: s[\"branches\"][\"union\"]\n\t\t}\n\t\tgroups: s[\"groups\"]\n\t\tfinalizer: s[\"finalizer\"]\n\t\tscanned: updateScanned<s[\"scanned\"], s[\"unscanned\"], unscanned>\n\t\tunscanned: unscanned\n\t}>\n\n\texport type reduceBranch<\n\t\ts extends StaticState,\n\t\ttoken extends BranchOperator,\n\t\tunscanned extends string\n\t> =\n\t\ts[\"branches\"][\"leftBound\"] extends {} ?\n\t\t\topenRangeError<s[\"branches\"][\"leftBound\"]>\n\t\t:\tfrom<{\n\t\t\t\troot: undefined\n\t\t\t\tbranches: {\n\t\t\t\t\tprefixes: []\n\t\t\t\t\tleftBound: undefined\n\t\t\t\t\tintersection: token extends \"&\" ? mergeToIntersection<s> : undefined\n\t\t\t\t\tunion: token extends \"|\" ? mergeToUnion<s>\n\t\t\t\t\t: token extends \"|>\" ? undefined\n\t\t\t\t\t: s[\"branches\"][\"union\"]\n\t\t\t\t\tpipe: token extends \"|>\" ? mergeToPipe<s> : s[\"branches\"][\"pipe\"]\n\t\t\t\t}\n\t\t\t\tgroups: s[\"groups\"]\n\t\t\t\tfinalizer: s[\"finalizer\"]\n\t\t\t\tscanned: updateScanned<s[\"scanned\"], s[\"unscanned\"], unscanned>\n\t\t\t\tunscanned: unscanned\n\t\t\t}>\n\n\texport type reduceLeftBound<\n\t\ts extends StaticState,\n\t\tlimit extends LimitLiteral,\n\t\tcomparator extends Comparator,\n\t\tunscanned extends string\n\t> =\n\t\tcomparator extends \"<\" | \"<=\" ?\n\t\t\ts[\"branches\"][\"leftBound\"] extends {} ?\n\t\t\t\ts.error<\n\t\t\t\t\twriteMultipleLeftBoundsMessage<\n\t\t\t\t\t\ts[\"branches\"][\"leftBound\"][\"limit\"],\n\t\t\t\t\t\ts[\"branches\"][\"leftBound\"][\"comparator\"],\n\t\t\t\t\t\tlimit,\n\t\t\t\t\t\tInvertedComparators[comparator]\n\t\t\t\t\t>\n\t\t\t\t>\n\t\t\t:\tfrom<{\n\t\t\t\t\troot: undefined\n\t\t\t\t\tbranches: {\n\t\t\t\t\t\tprefixes: s[\"branches\"][\"prefixes\"]\n\t\t\t\t\t\tleftBound: {\n\t\t\t\t\t\t\tlimit: limit\n\t\t\t\t\t\t\tcomparator: InvertedComparators[comparator]\n\t\t\t\t\t\t}\n\t\t\t\t\t\tintersection: s[\"branches\"][\"intersection\"]\n\t\t\t\t\t\tpipe: s[\"branches\"][\"pipe\"]\n\t\t\t\t\t\tunion: s[\"branches\"][\"union\"]\n\t\t\t\t\t}\n\t\t\t\t\tgroups: s[\"groups\"]\n\t\t\t\t\tfinalizer: s[\"finalizer\"]\n\t\t\t\t\tscanned: updateScanned<s[\"scanned\"], s[\"unscanned\"], unscanned>\n\t\t\t\t\tunscanned: unscanned\n\t\t\t\t}>\n\t\t:\ts.error<writeUnpairableComparatorMessage<comparator>>\n\n\texport type reduceRange<\n\t\ts extends StaticState,\n\t\tminLimit extends LimitLiteral,\n\t\tminComparator extends MinComparator,\n\t\tmaxComparator extends MaxComparator,\n\t\tmaxLimit extends LimitLiteral,\n\t\tunscanned extends string\n\t> = s.from<{\n\t\troot: [minLimit, minComparator, [s[\"root\"], maxComparator, maxLimit]]\n\t\tbranches: {\n\t\t\tprefixes: s[\"branches\"][\"prefixes\"]\n\t\t\tleftBound: undefined\n\t\t\tintersection: s[\"branches\"][\"intersection\"]\n\t\t\tpipe: s[\"branches\"][\"pipe\"]\n\t\t\tunion: s[\"branches\"][\"union\"]\n\t\t}\n\t\tgroups: s[\"groups\"]\n\t\tfinalizer: s[\"finalizer\"]\n\t\tscanned: updateScanned<s[\"scanned\"], s[\"unscanned\"], unscanned>\n\t\tunscanned: unscanned\n\t}>\n\n\texport type reduceSingleBound<\n\t\ts extends StaticState,\n\t\tcomparator extends Comparator,\n\t\tlimit extends number | string,\n\t\tunscanned extends string\n\t> = s.from<{\n\t\troot: [s[\"root\"], comparator, limit]\n\t\tbranches: {\n\t\t\tprefixes: s[\"branches\"][\"prefixes\"]\n\t\t\tleftBound: undefined\n\t\t\tintersection: s[\"branches\"][\"intersection\"]\n\t\t\tpipe: s[\"branches\"][\"pipe\"]\n\t\t\tunion: s[\"branches\"][\"union\"]\n\t\t}\n\t\tgroups: s[\"groups\"]\n\t\tfinalizer: s[\"finalizer\"]\n\t\tscanned: updateScanned<s[\"scanned\"], s[\"unscanned\"], unscanned>\n\t\tunscanned: unscanned\n\t}>\n\n\ttype mergeToIntersection<s extends StaticState> =\n\t\ts[\"branches\"][\"intersection\"] extends undefined ? mergePrefixes<s>\n\t\t:\t[s[\"branches\"][\"intersection\"], \"&\", mergePrefixes<s>]\n\n\ttype mergeToUnion<s extends StaticState> =\n\t\ts[\"branches\"][\"union\"] extends undefined ? mergeToIntersection<s>\n\t\t:\t[s[\"branches\"][\"union\"], \"|\", mergeToIntersection<s>]\n\n\ttype mergeToPipe<s extends StaticState> =\n\t\ts[\"branches\"][\"pipe\"] extends undefined ? mergeToUnion<s>\n\t\t:\t[s[\"branches\"][\"pipe\"], \"|>\", mergeToUnion<s>]\n\n\ttype mergePrefixes<\n\t\ts extends StaticState,\n\t\tremaining extends unknown[] = s[\"branches\"][\"prefixes\"]\n\t> =\n\t\tremaining extends [infer head, ...infer tail] ?\n\t\t\t[head, mergePrefixes<s, tail>]\n\t\t:\ts[\"root\"]\n\n\ttype popGroup<stack extends BranchState[], top extends BranchState> = [\n\t\t...stack,\n\t\ttop\n\t]\n\n\texport type finalizeGroup<s extends StaticState, unscanned extends string> =\n\t\ts[\"branches\"][\"leftBound\"] extends {} ?\n\t\t\topenRangeError<s[\"branches\"][\"leftBound\"]>\n\t\t: s[\"groups\"] extends popGroup<infer stack, infer top> ?\n\t\t\tfrom<{\n\t\t\t\tgroups: stack\n\t\t\t\tbranches: top\n\t\t\t\troot: mergeToPipe<s>\n\t\t\t\tfinalizer: s[\"finalizer\"]\n\t\t\t\tscanned: updateScanned<s[\"scanned\"], s[\"unscanned\"], unscanned>\n\t\t\t\tunscanned: unscanned\n\t\t\t}>\n\t\t:\ts.error<writeUnmatchedGroupCloseMessage<\")\", unscanned>>\n\n\texport type reduceGroupOpen<\n\t\ts extends StaticState,\n\t\tunscanned extends string\n\t> = from<{\n\t\tgroups: [...s[\"groups\"], s[\"branches\"]]\n\t\tbranches: initialBranches\n\t\troot: undefined\n\t\tfinalizer: s[\"finalizer\"]\n\t\tscanned: updateScanned<s[\"scanned\"], s[\"unscanned\"], unscanned>\n\t\tunscanned: unscanned\n\t}>\n\n\texport type finalize<\n\t\ts extends StaticState,\n\t\tfinalizer extends FinalizingLookahead\n\t> =\n\t\ts[\"groups\"] extends [] ?\n\t\t\ts[\"branches\"][\"leftBound\"] extends {} ?\n\t\t\t\topenRangeError<s[\"branches\"][\"leftBound\"]>\n\t\t\t:\tfrom<{\n\t\t\t\t\troot: mergeToPipe<s>\n\t\t\t\t\tgroups: s[\"groups\"]\n\t\t\t\t\tbranches: initialBranches\n\t\t\t\t\tfinalizer: finalizer\n\t\t\t\t\tscanned: s[\"scanned\"]\n\t\t\t\t\tunscanned: s[\"unscanned\"]\n\t\t\t\t}>\n\t\t:\ts.error<writeUnclosedGroupMessage<\")\">>\n\n\ttype openRangeError<range extends defined<BranchState[\"leftBound\"]>> =\n\t\ts.error<writeOpenRangeMessage<range[\"limit\"], range[\"comparator\"]>>\n\n\texport type previousOperator<s extends StaticState> =\n\t\ts[\"branches\"][\"leftBound\"] extends {} ?\n\t\t\ts[\"branches\"][\"leftBound\"][\"comparator\"]\n\t\t: s[\"branches\"][\"prefixes\"] extends (\n\t\t\t[...unknown[], infer tail extends string]\n\t\t) ?\n\t\t\ttail\n\t\t: s[\"branches\"][\"intersection\"] extends {} ? \"&\"\n\t\t: s[\"branches\"][\"union\"] extends {} ? \"|\"\n\t\t: undefined\n\n\texport type scanTo<s extends StaticState, unscanned extends string> = from<{\n\t\troot: s[\"root\"]\n\t\tbranches: s[\"branches\"]\n\t\tgroups: s[\"groups\"]\n\t\tfinalizer: s[\"finalizer\"]\n\t\tscanned: updateScanned<s[\"scanned\"], s[\"unscanned\"], unscanned>\n\t\tunscanned: unscanned\n\t}>\n\n\texport type from<s extends StaticState> = s\n\n\texport type branchesFrom<b extends BranchState> = b\n}\n"
  },
  {
    "path": "ark/type/parser/shift/operand/date.ts",
    "content": "import { throwParseError, tryParseNumber } from \"@ark/util\"\nimport type { DateLiteral } from \"../../../attributes.ts\"\n\nexport const isDateLiteral = (value: unknown): value is DateLiteral =>\n\ttypeof value === \"string\" &&\n\tvalue[0] === \"d\" &&\n\t(value[1] === \"'\" || value[1] === '\"') &&\n\tvalue[value.length - 1] === value[1]\n\nexport const isValidDate = (d: Date): boolean => d.toString() !== \"Invalid Date\"\n\nexport const extractDateLiteralSource = <literal extends DateLiteral>(\n\tliteral: literal\n): extractDateLiteralSource<literal> => literal.slice(2, -1) as never\n\ntype extractDateLiteralSource<literal extends DateLiteral> =\n\tliteral extends DateLiteral<infer source> ? source : never\n\nexport const writeInvalidDateMessage = <source extends string>(\n\tsource: source\n): writeInvalidDateMessage<source> =>\n\t`'${source}' could not be parsed by the Date constructor`\n\nexport type writeInvalidDateMessage<source extends string> =\n\t`'${source}' could not be parsed by the Date constructor`\n\nexport type DateInput = ConstructorParameters<typeof Date>[0]\n\nexport type DateParseResult<\n\terrorOnFail extends boolean | string = boolean | string\n> = Date | (errorOnFail extends true | string ? never : undefined)\n\nexport const tryParseDate = <errorOnFail extends boolean | string>(\n\tsource: string,\n\terrorOnFail?: errorOnFail\n): DateParseResult<errorOnFail> => maybeParseDate(source, errorOnFail)\n\nconst maybeParseDate = <errorOnFail extends boolean | string>(\n\tsource: string,\n\terrorOnFail?: errorOnFail\n): DateParseResult<errorOnFail> => {\n\tconst stringParsedDate = new Date(source)\n\tif (isValidDate(stringParsedDate)) return stringParsedDate\n\n\tconst epochMillis = tryParseNumber(source)\n\tif (epochMillis !== undefined) {\n\t\tconst numberParsedDate = new Date(epochMillis)\n\t\tif (isValidDate(numberParsedDate)) return numberParsedDate\n\t}\n\treturn errorOnFail ?\n\t\t\tthrowParseError(\n\t\t\t\terrorOnFail === true ? writeInvalidDateMessage(source) : errorOnFail\n\t\t\t)\n\t\t:\t(undefined as never)\n}\n"
  },
  {
    "path": "ark/type/parser/shift/operand/enclosed.ts",
    "content": "import { rootSchema } from \"@ark/schema\"\nimport {\n\tisKeyOf,\n\tthrowParseError,\n\ttype ErrorMessage,\n\ttype Scanner\n} from \"@ark/util\"\nimport type { Regex, regex } from \"arkregex\"\nimport type { Out } from \"../../../attributes.ts\"\nimport type { InferredAst } from \"../../ast/infer.ts\"\nimport type { RuntimeState } from \"../../reduce/dynamic.ts\"\nimport type { StaticState, s } from \"../../reduce/static.ts\"\nimport { tryParseDate, writeInvalidDateMessage } from \"./date.ts\"\n\nexport type StringLiteral<contents extends string = string> =\n\t| DoubleQuotedStringLiteral<contents>\n\t| SingleQuotedStringLiteral<contents>\n\nexport type DoubleQuotedStringLiteral<contents extends string = string> =\n\t`\"${contents}\"`\n\nexport type SingleQuotedStringLiteral<contents extends string = string> =\n\t`'${contents}'`\n\nconst regexExecArray = rootSchema({\n\tproto: \"Array\",\n\tsequence: \"string\",\n\trequired: {\n\t\tkey: \"groups\",\n\t\tvalue: [\"object\", { unit: undefined }]\n\t}\n})\n\nexport const parseEnclosed = (\n\ts: RuntimeState,\n\tenclosing: EnclosingStartToken\n): void => {\n\tconst enclosed = s.scanner.shiftUntilEscapable(\n\t\tuntilLookaheadIsClosing[enclosingTokens[enclosing]]\n\t)\n\tif (s.scanner.lookahead === \"\")\n\t\treturn s.error(writeUnterminatedEnclosedMessage(enclosed, enclosing))\n\n\t// Shift the scanner one additional time for the second enclosing token\n\ts.scanner.shift()\n\tif (enclosing in enclosingRegexTokens) {\n\t\tlet regex: RegExp\n\n\t\ttry {\n\t\t\tregex = new RegExp(enclosed)\n\t\t} catch (e) {\n\t\t\tthrowParseError(String(e))\n\t\t}\n\n\t\ts.root = s.ctx.$.node(\n\t\t\t\"intersection\",\n\t\t\t{\n\t\t\t\tdomain: \"string\",\n\t\t\t\tpattern: enclosed\n\t\t\t},\n\t\t\t{ prereduced: true }\n\t\t)\n\n\t\tif (enclosing === \"x/\") {\n\t\t\ts.root = s.ctx.$.node(\"morph\", {\n\t\t\t\tin: s.root,\n\t\t\t\tmorphs: (s: string) => regex.exec(s),\n\t\t\t\tdeclaredOut: regexExecArray\n\t\t\t})\n\t\t}\n\t} else if (isKeyOf(enclosing, enclosingQuote))\n\t\ts.root = s.ctx.$.node(\"unit\", { unit: enclosed })\n\telse {\n\t\tconst date = tryParseDate(enclosed, writeInvalidDateMessage(enclosed))\n\t\ts.root = s.ctx.$.node(\"unit\", { meta: enclosed, unit: date })\n\t}\n}\n\nexport type parseEnclosed<\n\ts extends StaticState,\n\tenclosingStart extends EnclosingStartToken,\n\tunscanned extends string\n> =\n\tScanner.shiftUntilEscapable<\n\t\tunscanned,\n\t\tEnclosingTokens[enclosingStart],\n\t\t\"\"\n\t> extends Scanner.shiftResult<infer scanned, infer nextUnscanned> ?\n\t\t_parseEnclosed<s, enclosingStart, scanned, nextUnscanned>\n\t:\tnever\n\ntype _parseEnclosed<\n\ts extends StaticState,\n\tenclosingStart extends EnclosingStartToken,\n\tscanned extends string,\n\tnextUnscanned extends string,\n\tdef extends\n\t\tstring = `${enclosingStart}${scanned}${EnclosingTokens[enclosingStart]}`\n> =\n\tnextUnscanned extends \"\" ?\n\t\ts.error<writeUnterminatedEnclosedMessage<scanned, enclosingStart>>\n\t: enclosingStart extends EnclosingQuote ?\n\t\ts.setRoot<\n\t\t\ts,\n\t\t\tInferredAst<scanned, def>,\n\t\t\tnextUnscanned extends Scanner.shift<string, infer unscanned> ? unscanned\n\t\t\t:\t\"\"\n\t\t>\n\t: enclosingStart extends EnclosingRegexToken ?\n\t\tregex.parse<scanned> extends infer r ?\n\t\t\tr extends Regex ?\n\t\t\t\ts.setRoot<\n\t\t\t\t\ts,\n\t\t\t\t\tInferredAst<\n\t\t\t\t\t\tenclosingStart extends \"/\" ? r[\"infer\"]\n\t\t\t\t\t\t:\t(In: r[\"infer\"]) => Out<r[\"inferExecArray\"]>,\n\t\t\t\t\t\tdef\n\t\t\t\t\t>,\n\t\t\t\t\tnextUnscanned extends Scanner.shift<string, infer unscanned> ?\n\t\t\t\t\t\tunscanned\n\t\t\t\t\t:\t\"\"\n\t\t\t\t>\n\t\t\t: r extends ErrorMessage<infer e> ? s.error<e>\n\t\t\t: never\n\t\t:\tnever\n\t:\ts.setRoot<\n\t\t\ts,\n\t\t\tInferredAst<Date, def>,\n\t\t\tnextUnscanned extends Scanner.shift<string, infer unscanned> ? unscanned\n\t\t\t:\t\"\"\n\t\t>\n\nexport const enclosingQuote = {\n\t\"'\": 1,\n\t'\"': 1\n} as const\n\nexport type EnclosingQuote = keyof typeof enclosingQuote\n\nexport const enclosingChar = {\n\t\"/\": 1,\n\t\"'\": 1,\n\t'\"': 1\n} as const\n\nexport const enclosingLiteralTokens = {\n\t\"d'\": \"'\",\n\t'd\"': '\"',\n\t\"'\": \"'\",\n\t'\"': '\"'\n} as const\n\nexport type EnclosingLiteralTokens = typeof enclosingLiteralTokens\nexport type EnclosingLiteralStartToken = keyof EnclosingLiteralTokens\n\nexport const enclosingRegexTokens = {\n\t\"/\": \"/\",\n\t\"x/\": \"/\"\n} as const\n\nexport type EnclosingRegexTokens = typeof enclosingRegexTokens\nexport type EnclosingRegexToken = keyof EnclosingRegexTokens\n\nexport const enclosingTokens = {\n\t...enclosingLiteralTokens,\n\t...enclosingRegexTokens\n} as const\n\nexport type EnclosingTokens = typeof enclosingTokens\n\nexport type EnclosingStartToken = keyof EnclosingTokens\n\nexport type EnclosingEndToken = EnclosingTokens[keyof EnclosingTokens]\n\nexport const untilLookaheadIsClosing: Record<\n\tEnclosingEndToken,\n\tScanner.UntilCondition\n> = {\n\t\"'\": scanner => scanner.lookahead === `'`,\n\t'\"': scanner => scanner.lookahead === `\"`,\n\t\"/\": scanner => scanner.lookahead === `/`\n}\n\nconst enclosingCharDescriptions = {\n\t'\"': \"double-quote\",\n\t\"'\": \"single-quote\",\n\t\"/\": \"forward slash\"\n} as const\n\ntype enclosingCharDescriptions = typeof enclosingCharDescriptions\n\nexport const writeUnterminatedEnclosedMessage = <\n\tfragment extends string,\n\tenclosingStart extends EnclosingStartToken\n>(\n\tfragment: fragment,\n\tenclosingStart: enclosingStart\n): writeUnterminatedEnclosedMessage<fragment, enclosingStart> =>\n\t`${enclosingStart}${fragment} requires a closing ${\n\t\tenclosingCharDescriptions[enclosingTokens[enclosingStart]]\n\t}`\n\nexport type writeUnterminatedEnclosedMessage<\n\tfragment extends string,\n\tenclosingStart extends EnclosingStartToken\n> = `${enclosingStart}${fragment} requires a closing ${enclosingCharDescriptions[EnclosingTokens[enclosingStart]]}`\n"
  },
  {
    "path": "ark/type/parser/shift/operand/genericArgs.ts",
    "content": "import type {\n\tBaseRoot,\n\tGenericAst,\n\tgenericParamNames,\n\tGenericRoot\n} from \"@ark/schema\"\nimport {\n\twriteUnclosedGroupMessage,\n\ttype array,\n\ttype ErrorMessage,\n\ttype join\n} from \"@ark/util\"\nimport type { RuntimeState } from \"../../reduce/dynamic.ts\"\nimport type { s, StaticState } from \"../../reduce/static.ts\"\nimport type { parseUntilFinalizer } from \"../../string.ts\"\n\nexport const parseGenericArgs = (\n\tname: string,\n\tg: GenericRoot,\n\ts: RuntimeState\n): BaseRoot[] => _parseGenericArgs(name, g, s, [])\n\nexport type parseGenericArgs<\n\tname extends string,\n\tg extends GenericAst,\n\tunscanned extends string,\n\t$,\n\targs\n> = _parseGenericArgs<name, g, unscanned, $, args, [], []>\n\nconst _parseGenericArgs = (\n\tname: string,\n\tg: GenericRoot,\n\ts: RuntimeState,\n\targNodes: BaseRoot[]\n): BaseRoot[] => {\n\tconst argState = s.parseUntilFinalizer()\n\targNodes.push(argState.root)\n\tif (argState.finalizer === \">\") {\n\t\tif (argNodes.length !== g.params.length) {\n\t\t\treturn s.error(\n\t\t\t\twriteInvalidGenericArgCountMessage(\n\t\t\t\t\tname,\n\t\t\t\t\tg.names,\n\t\t\t\t\targNodes.map(arg => arg.expression)\n\t\t\t\t)\n\t\t\t)\n\t\t}\n\t\treturn argNodes\n\t}\n\tif (argState.finalizer === \",\") return _parseGenericArgs(name, g, s, argNodes)\n\n\treturn argState.error(writeUnclosedGroupMessage(\">\"))\n}\n\nexport type ParsedArgs<\n\tresult extends unknown[] = unknown[],\n\tunscanned extends string = string\n> = {\n\tresult: result\n\tunscanned: unscanned\n}\n\ntype _parseGenericArgs<\n\tname extends string,\n\tg extends GenericAst,\n\tunscanned extends string,\n\t$,\n\targs,\n\targDefs extends string[],\n\targAsts extends unknown[]\n> =\n\tparseUntilFinalizer<s.initialize<unscanned>, $, args> extends (\n\t\tinfer finalArgState extends StaticState\n\t) ?\n\t\t{\n\t\t\tdefs: [\n\t\t\t\t...argDefs,\n\t\t\t\tfinalArgState[\"scanned\"] extends `${infer def}${\",\" | \">\"}` ? def\n\t\t\t\t:\tfinalArgState[\"scanned\"]\n\t\t\t]\n\t\t\tasts: [...argAsts, finalArgState[\"root\"]]\n\t\t\tunscanned: finalArgState[\"unscanned\"]\n\t\t} extends (\n\t\t\t{\n\t\t\t\tdefs: infer nextDefs extends string[]\n\t\t\t\tasts: infer nextAsts extends unknown[]\n\t\t\t\tunscanned: infer nextUnscanned extends string\n\t\t\t}\n\t\t) ?\n\t\t\tfinalArgState[\"finalizer\"] extends \">\" ?\n\t\t\t\tnextAsts[\"length\"] extends g[\"paramsAst\"][\"length\"] ?\n\t\t\t\t\tParsedArgs<nextAsts, nextUnscanned>\n\t\t\t\t:\ts.error<\n\t\t\t\t\t\twriteInvalidGenericArgCountMessage<\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tgenericParamNames<g[\"paramsAst\"]>,\n\t\t\t\t\t\t\tnextDefs\n\t\t\t\t\t\t>\n\t\t\t\t\t>\n\t\t\t: finalArgState[\"finalizer\"] extends \",\" ?\n\t\t\t\t_parseGenericArgs<name, g, nextUnscanned, $, args, nextDefs, nextAsts>\n\t\t\t: finalArgState[\"finalizer\"] extends ErrorMessage ? finalArgState\n\t\t\t: s.error<writeUnclosedGroupMessage<\">\">>\n\t\t:\tnever\n\t:\tnever\n\nexport const writeInvalidGenericArgCountMessage = <\n\tname extends string,\n\tparams extends array<string>,\n\targDefs extends array<string>\n>(\n\tname: name,\n\tparams: params,\n\targDefs: argDefs\n): writeInvalidGenericArgCountMessage<name, params, argDefs> =>\n\t`${name}<${params.join(\", \")}> requires exactly ${\n\t\tparams.length\n\t} args (got ${argDefs.length}${\n\t\targDefs.length === 0 ? \"\" : `: ${argDefs.join(\", \")}`\n\t})` as never\n\nexport type writeInvalidGenericArgCountMessage<\n\tname extends string,\n\tparams extends array<string>,\n\targDefs extends array<string>\n> = `${name}<${join<\n\tparams,\n\t\", \"\n>}> requires exactly ${params[\"length\"]} args (got ${argDefs[\"length\"]}${argDefs[\"length\"] extends (\n\t0\n) ?\n\t\"\"\n:\t`: ${join<argDefs, \",\">}`})`\n"
  },
  {
    "path": "ark/type/parser/shift/operand/operand.ts",
    "content": "import { whitespaceChars, type Scanner, type WhitespaceChar } from \"@ark/util\"\nimport type { RuntimeState } from \"../../reduce/dynamic.ts\"\nimport type { StaticState, s } from \"../../reduce/static.ts\"\nimport type { BaseCompletions } from \"../../string.ts\"\nimport {\n\tenclosingChar,\n\tenclosingQuote,\n\tparseEnclosed,\n\ttype EnclosingQuote,\n\ttype EnclosingStartToken\n} from \"./enclosed.ts\"\nimport { parseUnenclosed, writeMissingOperandMessage } from \"./unenclosed.ts\"\n\nexport const parseOperand = (s: RuntimeState): void =>\n\ts.scanner.lookahead === \"\" ? s.error(writeMissingOperandMessage(s))\n\t: s.scanner.lookahead === \"(\" ? s.shiftedBy(1).reduceGroupOpen()\n\t: s.scanner.lookaheadIsIn(enclosingChar) ? parseEnclosed(s, s.scanner.shift())\n\t: s.scanner.lookaheadIsIn(whitespaceChars) ? parseOperand(s.shiftedBy(1))\n\t: s.scanner.lookahead === \"d\" ?\n\t\ts.scanner.nextLookahead in enclosingQuote ?\n\t\t\tparseEnclosed(\n\t\t\t\ts,\n\t\t\t\t`${s.scanner.shift()}${s.scanner.shift()}` as EnclosingStartToken\n\t\t\t)\n\t\t:\tparseUnenclosed(s)\n\t: s.scanner.lookahead === \"x\" ?\n\t\ts.scanner.nextLookahead === \"/\" ?\n\t\t\ts.shiftedBy(2) && parseEnclosed(s, \"x/\")\n\t\t:\tparseUnenclosed(s)\n\t:\tparseUnenclosed(s)\n\nexport type parseOperand<s extends StaticState, $, args> =\n\ts[\"unscanned\"] extends Scanner.shift<infer lookahead, infer unscanned> ?\n\t\tlookahead extends \"(\" ? s.reduceGroupOpen<s, unscanned>\n\t\t: lookahead extends EnclosingStartToken ?\n\t\t\tparseEnclosed<s, lookahead, unscanned>\n\t\t: lookahead extends WhitespaceChar ?\n\t\t\tparseOperand<s.scanTo<s, unscanned>, $, args>\n\t\t: lookahead extends \"d\" ?\n\t\t\tunscanned extends (\n\t\t\t\tScanner.shift<\n\t\t\t\t\tinfer enclosing extends EnclosingQuote,\n\t\t\t\t\tinfer nextUnscanned\n\t\t\t\t>\n\t\t\t) ?\n\t\t\t\tparseEnclosed<s, `d${enclosing}`, nextUnscanned>\n\t\t\t:\tparseUnenclosed<s, $, args>\n\t\t: lookahead extends \"x\" ?\n\t\t\tunscanned extends Scanner.shift<\"/\", infer nextUnscanned> ?\n\t\t\t\tparseEnclosed<s, \"x/\", nextUnscanned>\n\t\t\t:\tparseUnenclosed<s, $, args>\n\t\t:\tparseUnenclosed<s, $, args>\n\t:\ts.completion<`${s[\"scanned\"]}${BaseCompletions<$, args>}`>\n"
  },
  {
    "path": "ark/type/parser/shift/operand/unenclosed.ts",
    "content": "import {\n\thasArkKind,\n\twriteUnresolvableMessage,\n\ttype BaseRoot,\n\ttype GenericAst,\n\ttype GenericRoot,\n\ttype arkKind,\n\ttype genericParamNames,\n\ttype resolvableReferenceIn,\n\ttype writeNonSubmoduleDotMessage\n} from \"@ark/schema\"\nimport {\n\tprintable,\n\tthrowParseError,\n\ttryParseWellFormedBigint,\n\ttryParseWellFormedNumber,\n\ttype BigintLiteral,\n\ttype NumberLiteral,\n\ttype Scanner,\n\ttype join,\n\ttype lastOf\n} from \"@ark/util\"\nimport type { ArkAmbient } from \"../../../config.ts\"\nimport type { resolutionToAst } from \"../../../scope.ts\"\nimport type { GenericInstantiationAst } from \"../../ast/generic.ts\"\nimport type { InferredAst } from \"../../ast/infer.ts\"\nimport { writePrefixedPrivateReferenceMessage } from \"../../ast/validate.ts\"\nimport type { RuntimeState } from \"../../reduce/dynamic.ts\"\nimport type { StaticState, s } from \"../../reduce/static.ts\"\nimport type { BaseCompletions } from \"../../string.ts\"\nimport { terminatingChars, type TerminatingChar } from \"../tokens.ts\"\nimport {\n\tparseGenericArgs,\n\twriteInvalidGenericArgCountMessage,\n\ttype ParsedArgs\n} from \"./genericArgs.ts\"\n\nexport const parseUnenclosed = (s: RuntimeState): void => {\n\tconst token = s.scanner.shiftUntilLookahead(terminatingChars)\n\tif (token === \"keyof\") s.addPrefix(\"keyof\")\n\telse s.root = unenclosedToNode(s, token)\n}\n\nexport type parseUnenclosed<s extends StaticState, $, args> =\n\tScanner.shiftUntil<s[\"unscanned\"], TerminatingChar> extends (\n\t\tScanner.shiftResult<infer token, infer unscanned>\n\t) ?\n\t\ttryResolve<s, unscanned, token, $, args> extends s.from<infer s> ?\n\t\t\ts\n\t\t:\tnever\n\t:\tnever\n\ntype parseResolution<\n\ts extends StaticState,\n\tunscanned extends string,\n\talias extends string,\n\tresolution,\n\t$,\n\targs\n> =\n\tresolutionToAst<alias, resolution> extends infer ast ?\n\t\tast extends GenericAst ?\n\t\t\tparseGenericInstantiation<alias, ast, s.scanTo<s, unscanned>, $, args>\n\t\t:\ts.setRoot<s, ast, unscanned>\n\t:\tnever\n\nexport const parseGenericInstantiation = (\n\tname: string,\n\tg: GenericRoot,\n\ts: RuntimeState\n): BaseRoot => {\n\ts.scanner.shiftUntilNonWhitespace()\n\tconst lookahead = s.scanner.shift()\n\tif (lookahead !== \"<\")\n\t\treturn s.error(writeInvalidGenericArgCountMessage(name, g.names, []))\n\n\tconst parsedArgs = parseGenericArgs(name, g, s)\n\treturn g(...parsedArgs) as never\n}\n\nexport type parseGenericInstantiation<\n\tname extends string,\n\tg extends GenericAst,\n\ts extends StaticState,\n\t$,\n\targs\n> =\n\t// skip whitepsace to allow instantiations like `Partial    <T>`\n\tScanner.skipWhitespace<s[\"unscanned\"]> extends `<${infer unscanned}` ?\n\t\tparseGenericArgs<name, g, unscanned, $, args> extends infer result ?\n\t\t\tresult extends ParsedArgs<infer argAsts, infer nextUnscanned> ?\n\t\t\t\ts.setRoot<s, GenericInstantiationAst<g, argAsts>, nextUnscanned>\n\t\t\t:\t// propagate error\n\t\t\t\tresult\n\t\t:\tnever\n\t:\ts.error<\n\t\t\twriteInvalidGenericArgCountMessage<\n\t\t\t\tname,\n\t\t\t\tgenericParamNames<g[\"paramsAst\"]>,\n\t\t\t\t[]\n\t\t\t>\n\t\t>\n\nconst unenclosedToNode = (s: RuntimeState, token: string): BaseRoot =>\n\tmaybeParseReference(s, token) ??\n\tmaybeParseUnenclosedLiteral(s, token) ??\n\ts.error(\n\t\ttoken === \"\" ?\n\t\t\ts.scanner.lookahead === \"#\" ?\n\t\t\t\twritePrefixedPrivateReferenceMessage(\n\t\t\t\t\ts.shiftedBy(1).scanner.shiftUntilLookahead(terminatingChars)\n\t\t\t\t)\n\t\t\t:\twriteMissingOperandMessage(s)\n\t\t:\twriteUnresolvableMessage(token)\n\t)\n\nconst maybeParseReference = (\n\ts: RuntimeState,\n\ttoken: string\n): BaseRoot | undefined => {\n\tif (s.ctx.args?.[token]) {\n\t\tconst arg = s.ctx.args[token]\n\t\tif (typeof arg !== \"string\") return arg\n\n\t\treturn s.ctx.$.node(\"alias\", { reference: arg }, { prereduced: true })\n\t}\n\tconst resolution = s.ctx.$.maybeResolve(token)\n\tif (hasArkKind(resolution, \"root\")) return resolution\n\tif (resolution === undefined) return\n\tif (hasArkKind(resolution, \"generic\"))\n\t\treturn parseGenericInstantiation(token, resolution, s)\n\n\treturn throwParseError(`Unexpected resolution ${printable(resolution)}`)\n}\n\nconst maybeParseUnenclosedLiteral = (\n\ts: RuntimeState,\n\ttoken: string\n): BaseRoot | undefined => {\n\tconst maybeNumber = tryParseWellFormedNumber(token)\n\tif (maybeNumber !== undefined)\n\t\treturn s.ctx.$.node(\"unit\", { unit: maybeNumber })\n\n\tconst maybeBigint = tryParseWellFormedBigint(token)\n\tif (maybeBigint !== undefined)\n\t\treturn s.ctx.$.node(\"unit\", { unit: maybeBigint })\n}\n\ntype tryResolve<\n\ts extends StaticState,\n\tunscanned extends string,\n\ttoken extends string,\n\t$,\n\targs\n> =\n\ttoken extends keyof args ?\n\t\tparseResolution<s, unscanned, token, args[token], $, args>\n\t: token extends keyof $ ?\n\t\tparseResolution<s, unscanned, token, $[token], $, args>\n\t: // this assumes there are no private aliases in the ambient scope\n\ttoken extends keyof ArkAmbient.$ ?\n\t\tparseResolution<s, unscanned, token, ArkAmbient.$[token], $, args>\n\t: `#${token}` extends keyof $ ?\n\t\tparseResolution<s, unscanned, token, $[`#${token}`], $, args>\n\t: token extends NumberLiteral<infer n> ?\n\t\ts.setRoot<s, InferredAst<n, token>, unscanned>\n\t: token extends (\n\t\t`${infer submodule extends keyof $ & string}.${infer reference}`\n\t) ?\n\t\ttryResolveSubmodule<\n\t\t\ttoken,\n\t\t\t$[submodule],\n\t\t\treference,\n\t\t\ts,\n\t\t\tunscanned,\n\t\t\t$,\n\t\t\targs,\n\t\t\t[submodule]\n\t\t>\n\t: token extends (\n\t\t`${infer submodule extends keyof ArkAmbient.$ & string}.${infer reference}`\n\t) ?\n\t\ttryResolveSubmodule<\n\t\t\ttoken,\n\t\t\tArkAmbient.$[submodule],\n\t\t\treference,\n\t\t\ts,\n\t\t\tunscanned,\n\t\t\t$,\n\t\t\targs,\n\t\t\t[submodule]\n\t\t>\n\t: token extends BigintLiteral<infer b> ?\n\t\ts.setRoot<s, InferredAst<b, token>, unscanned>\n\t: token extends \"keyof\" ? s.addPrefix<s, \"keyof\", unscanned>\n\t: unresolvableState<s, token, $, args, []>\n\ntype tryResolveSubmodule<\n\ttoken extends string,\n\tresolution,\n\treference extends string,\n\ts extends StaticState,\n\tunscanned extends string,\n\t$,\n\targs,\n\tsubmodulePath extends string[]\n> =\n\tresolution extends { [arkKind]: \"module\" } ?\n\t\treference extends keyof resolution ?\n\t\t\tparseResolution<s, unscanned, token, resolution[reference], $, args>\n\t\t: reference extends (\n\t\t\t`${infer nestedSubmodule extends keyof resolution & string}.${infer nestedReference}`\n\t\t) ?\n\t\t\ttryResolveSubmodule<\n\t\t\t\ttoken,\n\t\t\t\tresolution[nestedSubmodule],\n\t\t\t\tnestedReference,\n\t\t\t\ts,\n\t\t\t\tunscanned,\n\t\t\t\t$,\n\t\t\t\targs,\n\t\t\t\t[...submodulePath, nestedSubmodule]\n\t\t\t>\n\t\t:\tunresolvableState<s, reference, resolution, {}, submodulePath>\n\t:\ts.error<writeNonSubmoduleDotMessage<lastOf<submodulePath>>>\n\n/** Provide valid completions for the current token, or fallback to an\n * unresolvable error if there are none */\nexport type unresolvableState<\n\ts extends StaticState,\n\ttoken extends string,\n\tresolutions,\n\targs,\n\tsubmodulePath extends string[]\n> =\n\t[token, s[\"unscanned\"]] extends [\"\", Scanner.shift<\"#\", infer unscanned>] ?\n\t\tScanner.shiftUntil<unscanned, TerminatingChar> extends (\n\t\t\tScanner.shiftResult<infer name, string>\n\t\t) ?\n\t\t\ts.error<writePrefixedPrivateReferenceMessage<name>>\n\t\t:\tnever\n\t: validReferenceFromToken<token, resolutions, args, submodulePath> extends (\n\t\tnever\n\t) ?\n\t\ts.error<writeUnresolvableMessage<qualifiedReference<token, submodulePath>>>\n\t:\ts.completion<`${s[\"scanned\"]}${qualifiedReference<\n\t\t\tvalidReferenceFromToken<token, resolutions, args, submodulePath>,\n\t\t\tsubmodulePath\n\t\t>}`>\n\ntype qualifiedReference<\n\treference extends string,\n\tsubmodulePath extends string[]\n> = join<[...submodulePath, reference], \".\">\n\ntype validReferenceFromToken<\n\ttoken extends string,\n\t$,\n\targs,\n\tsubmodulePath extends string[]\n> = Extract<\n\tsubmodulePath[\"length\"] extends 0 ? BaseCompletions<$, args>\n\t:\tresolvableReferenceIn<$>,\n\t`${token}${string}`\n>\n\nexport const writeMissingOperandMessage = (s: RuntimeState): string => {\n\tconst operator = s.previousOperator()\n\treturn operator ?\n\t\t\twriteMissingRightOperandMessage(operator, s.scanner.unscanned)\n\t\t:\twriteExpressionExpectedMessage(s.scanner.unscanned)\n}\n\nexport type writeMissingRightOperandMessage<\n\ttoken extends string,\n\tunscanned extends string = \"\"\n> = `Token '${token}' requires a right operand${unscanned extends \"\" ? \"\"\n:\t` before '${unscanned}'`}`\n\nexport const writeMissingRightOperandMessage = <\n\ttoken extends string,\n\tunscanned extends string\n>(\n\ttoken: token,\n\tunscanned = \"\" as unscanned\n): writeMissingRightOperandMessage<token, unscanned> =>\n\t`Token '${token}' requires a right operand${\n\t\tunscanned ? (` before '${unscanned}'` as any) : \"\"\n\t}`\n\nexport const writeExpressionExpectedMessage = <unscanned extends string>(\n\tunscanned: unscanned\n): writeExpressionExpectedMessage<unscanned> =>\n\t`Expected an expression${unscanned ? ` before '${unscanned}'` : \"\"}` as never\n\nexport type writeExpressionExpectedMessage<unscanned extends string> =\n\t`Expected an expression${unscanned extends \"\" ? \"\"\n\t:\t` before '${unscanned}'`}`\n"
  },
  {
    "path": "ark/type/parser/shift/operator/bounds.ts",
    "content": "import {\n\t$ark,\n\twriteUnboundableMessage,\n\ttype BaseRoot,\n\ttype BoundKind,\n\ttype NodeSchema\n} from \"@ark/schema\"\nimport { isKeyOf, throwParseError, type KeySet, type Scanner } from \"@ark/util\"\nimport type { DateLiteral } from \"../../../attributes.ts\"\nimport type { InferredAst } from \"../../ast/infer.ts\"\nimport type { astToString } from \"../../ast/utils.ts\"\nimport type { RootedRuntimeState, RuntimeState } from \"../../reduce/dynamic.ts\"\nimport {\n\tinvertedComparators,\n\tmaxComparators,\n\twriteUnpairableComparatorMessage,\n\ttype Comparator,\n\ttype InvertedComparators,\n\ttype MaxComparator,\n\ttype OpenLeftBound\n} from \"../../reduce/shared.ts\"\nimport type { s, StaticState } from \"../../reduce/static.ts\"\nimport { extractDateLiteralSource, isDateLiteral } from \"../operand/date.ts\"\nimport type { parseOperand } from \"../operand/operand.ts\"\n\nexport const parseBound = (\n\ts: RootedRuntimeState,\n\tstart: ComparatorStartChar\n): void => {\n\tconst comparator = shiftComparator(s, start)\n\tif (s.root.hasKind(\"unit\")) {\n\t\tif (typeof s.root.unit === \"number\") {\n\t\t\ts.reduceLeftBound(s.root.unit, comparator)\n\t\t\ts.unsetRoot()\n\t\t\treturn\n\t\t}\n\t\tif (s.root.unit instanceof Date) {\n\t\t\tconst literal =\n\t\t\t\t`d'${s.root.description ?? s.root.unit.toISOString()}'` as const\n\t\t\ts.unsetRoot()\n\t\t\ts.reduceLeftBound(literal, comparator)\n\t\t\treturn\n\t\t}\n\t}\n\treturn parseRightBound(s, comparator)\n}\n\nexport type parseBound<\n\ts extends StaticState,\n\tstart extends ComparatorStartChar,\n\tunscanned extends string,\n\t$,\n\targs\n> =\n\tshiftComparator<start, unscanned> extends infer shiftResultOrError ?\n\t\tshiftResultOrError extends (\n\t\t\tScanner.shiftResult<\n\t\t\t\tinfer comparator extends Comparator,\n\t\t\t\tinfer nextUnscanned\n\t\t\t>\n\t\t) ?\n\t\t\ts[\"root\"] extends (\n\t\t\t\tInferredAst<\n\t\t\t\t\tDate | number,\n\t\t\t\t\t`${infer limit extends number | DateLiteral}`\n\t\t\t\t>\n\t\t\t) ?\n\t\t\t\ts.reduceLeftBound<s, limit, comparator, nextUnscanned>\n\t\t\t:\tparseRightBound<s.scanTo<s, nextUnscanned>, comparator, $, args>\n\t\t:\tshiftResultOrError\n\t:\tnever\n\ntype OneCharComparator = \">\" | \"<\"\n\nexport type ComparatorStartChar =\n\tComparator extends `${infer char}${string}` ? char : never\n\nexport const comparatorStartChars: KeySet<ComparatorStartChar> = {\n\t\"<\": 1,\n\t\">\": 1,\n\t\"=\": 1\n}\n\nconst shiftComparator = (\n\ts: RuntimeState,\n\tstart: ComparatorStartChar\n): Comparator =>\n\ts.scanner.lookaheadIs(\"=\") ?\n\t\t`${start}${s.scanner.shift()}`\n\t:\t(start as OneCharComparator)\n\ntype shiftComparator<\n\tstart extends ComparatorStartChar,\n\tunscanned extends string\n> =\n\tunscanned extends `=${infer nextUnscanned}` ? [`${start}=`, nextUnscanned]\n\t:\t[start & OneCharComparator, unscanned]\n\nexport const writeIncompatibleRangeMessage = (\n\tl: BoundKind,\n\tr: BoundKind\n): string => `Bound kinds ${l} and ${r} are incompatible`\n\nexport const getBoundKinds = (\n\tcomparator: Comparator,\n\tlimit: number | DateLiteral,\n\troot: BaseRoot,\n\tboundKind: BoundExpressionKind\n): BoundKind[] => {\n\tif (root.extends($ark.intrinsic.number)) {\n\t\tif (typeof limit !== \"number\") {\n\t\t\treturn throwParseError(\n\t\t\t\twriteInvalidLimitMessage(comparator, limit, boundKind)\n\t\t\t)\n\t\t}\n\t\treturn (\n\t\t\tcomparator === \"==\" ? [\"min\", \"max\"]\n\t\t\t: comparator[0] === \">\" ? [\"min\"]\n\t\t\t: [\"max\"]\n\t\t)\n\t}\n\n\tif (root.extends($ark.intrinsic.lengthBoundable)) {\n\t\tif (typeof limit !== \"number\") {\n\t\t\treturn throwParseError(\n\t\t\t\twriteInvalidLimitMessage(comparator, limit, boundKind)\n\t\t\t)\n\t\t}\n\t\treturn (\n\t\t\tcomparator === \"==\" ? [\"exactLength\"]\n\t\t\t: comparator[0] === \">\" ? [\"minLength\"]\n\t\t\t: [\"maxLength\"]\n\t\t)\n\t}\n\tif (root.extends($ark.intrinsic.Date)) {\n\t\t// allow either numeric or date limits\n\t\treturn (\n\t\t\tcomparator === \"==\" ? [\"after\", \"before\"]\n\t\t\t: comparator[0] === \">\" ? [\"after\"]\n\t\t\t: [\"before\"]\n\t\t)\n\t}\n\treturn throwParseError(writeUnboundableMessage(root.expression))\n}\n\nconst openLeftBoundToRoot = (\n\tleftBound: OpenLeftBound\n): NodeSchema<BoundKind> => ({\n\trule:\n\t\tisDateLiteral(leftBound.limit) ?\n\t\t\textractDateLiteralSource(leftBound.limit)\n\t\t:\tleftBound.limit,\n\texclusive: leftBound.comparator.length === 1\n})\n\nexport const parseRightBound = (\n\ts: RootedRuntimeState,\n\tcomparator: Comparator\n): void => {\n\t// store the node that will be bounded\n\tconst previousRoot = s.unsetRoot()\n\tconst previousScannerIndex = s.scanner.location\n\ts.parseOperand()\n\tconst limitNode = s.unsetRoot()\n\t// after parsing the next operand, use the locations to get the\n\t// token from which it was parsed\n\tconst limitToken = s.scanner.sliceChars(\n\t\tpreviousScannerIndex,\n\t\ts.scanner.location\n\t)\n\ts.root = previousRoot\n\tif (\n\t\t!limitNode.hasKind(\"unit\") ||\n\t\t(typeof limitNode.unit !== \"number\" && !(limitNode.unit instanceof Date))\n\t)\n\t\treturn s.error(writeInvalidLimitMessage(comparator, limitToken, \"right\"))\n\n\tconst limit = limitNode.unit\n\t// apply the newly-parsed right bound\n\tconst exclusive = comparator.length === 1\n\n\tconst boundKinds = getBoundKinds(\n\t\tcomparator,\n\t\ttypeof limit === \"number\" ? limit : (limitToken as DateLiteral),\n\t\tpreviousRoot,\n\t\t\"right\"\n\t)\n\n\tfor (const kind of boundKinds) {\n\t\ts.constrainRoot(\n\t\t\tkind,\n\t\t\tcomparator === \"==\" ? { rule: limit } : { rule: limit, exclusive }\n\t\t)\n\t}\n\n\tif (!s.branches.leftBound) return\n\n\t// if there's an open left bound, perform additional validation and apply it\n\tif (!isKeyOf(comparator, maxComparators))\n\t\treturn s.error(writeUnpairableComparatorMessage(comparator))\n\n\tconst lowerBoundKind = getBoundKinds(\n\t\ts.branches.leftBound.comparator,\n\t\ts.branches.leftBound.limit,\n\t\tpreviousRoot,\n\t\t\"left\"\n\t)\n\ts.constrainRoot(lowerBoundKind[0], openLeftBoundToRoot(s.branches.leftBound))\n\ts.branches.leftBound = null\n}\n\nexport type parseRightBound<\n\ts extends StaticState,\n\tcomparator extends Comparator,\n\t$,\n\targs\n> =\n\tparseOperand<s, $, args> extends infer nextState extends StaticState ?\n\t\tnextState[\"root\"] extends (\n\t\t\tInferredAst<unknown, `${infer limit extends number | DateLiteral}`>\n\t\t) ?\n\t\t\ts[\"branches\"][\"leftBound\"] extends {} ?\n\t\t\t\tcomparator extends MaxComparator ?\n\t\t\t\t\ts.reduceRange<\n\t\t\t\t\t\ts,\n\t\t\t\t\t\ts[\"branches\"][\"leftBound\"][\"limit\"],\n\t\t\t\t\t\ts[\"branches\"][\"leftBound\"][\"comparator\"],\n\t\t\t\t\t\tcomparator,\n\t\t\t\t\t\tlimit,\n\t\t\t\t\t\tnextState[\"unscanned\"]\n\t\t\t\t\t>\n\t\t\t\t:\ts.error<writeUnpairableComparatorMessage<comparator>>\n\t\t\t:\ts.reduceSingleBound<s, comparator, limit, nextState[\"unscanned\"]>\n\t\t:\ts.error<\n\t\t\t\twriteInvalidLimitMessage<\n\t\t\t\t\tcomparator,\n\t\t\t\t\tastToString<nextState[\"root\"]>,\n\t\t\t\t\t\"right\"\n\t\t\t\t>\n\t\t\t>\n\t:\tnever\n\nexport const writeInvalidLimitMessage = <\n\tcomparator extends Comparator,\n\tlimit extends string | number,\n\tboundKind extends BoundExpressionKind\n>(\n\tcomparator: comparator,\n\tlimit: limit,\n\tboundKind: boundKind\n): writeInvalidLimitMessage<comparator, limit, boundKind> =>\n\t`Comparator ${\n\t\tboundKind === \"left\" ? invertedComparators[comparator] : (comparator as any)\n\t} must be ${\n\t\tboundKind === \"left\" ? \"preceded\" : (\"followed\" as any)\n\t} by a corresponding literal (was ${limit})`\n\nexport type writeInvalidLimitMessage<\n\tcomparator extends Comparator,\n\tlimit extends string | number,\n\tboundKind extends BoundExpressionKind\n> = `Comparator ${boundKind extends \"left\" ? InvertedComparators[comparator]\n:\tcomparator} must be ${boundKind extends \"left\" ? \"preceded\"\n:\t\"followed\"} by a corresponding literal (was ${limit})`\n\nexport type BoundExpressionKind = \"left\" | \"right\"\n"
  },
  {
    "path": "ark/type/parser/shift/operator/brand.ts",
    "content": "import type { emptyBrandNameMessage } from \"@ark/schema\"\nimport type { Scanner } from \"@ark/util\"\nimport type { RootedRuntimeState } from \"../../reduce/dynamic.ts\"\nimport type { StaticState, s } from \"../../reduce/static.ts\"\nimport { terminatingChars, type TerminatingChar } from \"../tokens.ts\"\n\nexport const parseBrand = (s: RootedRuntimeState): void => {\n\ts.scanner.shiftUntilNonWhitespace()\n\tconst brandName = s.scanner.shiftUntilLookahead(terminatingChars)\n\ts.root = s.root.brand(brandName)\n}\n\nexport type parseBrand<s extends StaticState, unscanned extends string> =\n\tScanner.shiftUntil<\n\t\tScanner.skipWhitespace<unscanned>,\n\t\tTerminatingChar\n\t> extends Scanner.shiftResult<`${infer brandName}`, infer nextUnscanned> ?\n\t\tbrandName extends \"\" ?\n\t\t\ts.error<emptyBrandNameMessage>\n\t\t:\ts.setRoot<s, [s[\"root\"], \"#\", brandName], nextUnscanned>\n\t:\tnever\n"
  },
  {
    "path": "ark/type/parser/shift/operator/default.ts",
    "content": "import type { BaseRoot } from \"@ark/schema\"\nimport type {\n\tBigintLiteral,\n\tErrorMessage,\n\tNumberLiteral,\n\tScanner,\n\ttrim\n} from \"@ark/util\"\nimport type { DateLiteral } from \"../../../attributes.ts\"\nimport type { RootedRuntimeState } from \"../../reduce/dynamic.ts\"\nimport type {\n\tEnclosingLiteralStartToken,\n\tEnclosingLiteralTokens,\n\tStringLiteral\n} from \"../operand/enclosed.ts\"\n\ntype UnitLiteralKeyword = \"null\" | \"undefined\" | \"true\" | \"false\"\n\nexport type UnitLiteral = UnenclosedUnitLiteral | EnclosedUnitLiteral\n\nexport type UnenclosedUnitLiteral =\n\t| BigintLiteral\n\t| NumberLiteral\n\t| UnitLiteralKeyword\n\nexport type EnclosedUnitLiteral = StringLiteral | DateLiteral\n\nexport type ParsedDefaultableProperty = readonly [BaseRoot, \"=\", unknown]\n\nexport const parseDefault = (\n\ts: RootedRuntimeState\n): ParsedDefaultableProperty => {\n\t// store the node that will be bounded\n\tconst baseNode = s.unsetRoot()\n\ts.parseOperand()\n\tconst defaultNode = s.unsetRoot()\n\t// after parsing the next operand, use the locations to get the\n\t// token from which it was parsed\n\tif (!defaultNode.hasKind(\"unit\"))\n\t\treturn s.error(writeNonLiteralDefaultMessage(defaultNode.expression))\n\tconst defaultValue =\n\t\tdefaultNode.unit instanceof Date ?\n\t\t\t() => new Date(defaultNode.unit as Date)\n\t\t:\tdefaultNode.unit\n\treturn [baseNode, \"=\", defaultValue]\n}\n\nexport type parseDefault<root, unscanned extends string> =\n\t// default values must always appear at the end of a string definition,\n\t// so parse the rest of the string and ensure it is a valid unit literal\n\ttrim<unscanned> extends infer defaultExpression extends string ?\n\t\tdefaultExpression extends UnenclosedUnitLiteral ?\n\t\t\t[root, \"=\", defaultExpression]\n\t\t: defaultExpression extends (\n\t\t\t`${infer start extends EnclosingLiteralStartToken}${string}`\n\t\t) ?\n\t\t\tdefaultExpression extends `${start}${infer nextUnscanned}` ?\n\t\t\t\tisValidEnclosedLiteral<start, nextUnscanned> extends true ?\n\t\t\t\t\t[root, \"=\", defaultExpression]\n\t\t\t\t:\tErrorMessage<writeNonLiteralDefaultMessage<defaultExpression>>\n\t\t\t:\tnever\n\t\t:\tErrorMessage<writeNonLiteralDefaultMessage<defaultExpression>>\n\t:\tnever\n\nexport type isValidEnclosedLiteral<\n\tstart extends EnclosingLiteralStartToken,\n\tunscanned extends string\n> =\n\tScanner.shiftUntilEscapable<\n\t\tunscanned,\n\t\tEnclosingLiteralTokens[start],\n\t\t\"\"\n\t> extends Scanner.shiftResult<string, infer nextUnscanned> ?\n\t\tnextUnscanned extends EnclosingLiteralTokens[start] ?\n\t\t\ttrue\n\t\t:\tfalse\n\t:\tfalse\n\nexport const writeNonLiteralDefaultMessage = <defaultDef extends string>(\n\tdefaultDef: defaultDef\n): writeNonLiteralDefaultMessage<defaultDef> =>\n\t`Default value '${defaultDef}' must be a literal value`\n\nexport type writeNonLiteralDefaultMessage<defaultDef extends string> =\n\t`Default value '${defaultDef}' must be a literal value`\n"
  },
  {
    "path": "ark/type/parser/shift/operator/divisor.ts",
    "content": "import { tryParseInteger, type Scanner } from \"@ark/util\"\nimport type { RootedRuntimeState } from \"../../reduce/dynamic.ts\"\nimport type { StaticState, s } from \"../../reduce/static.ts\"\nimport { terminatingChars, type TerminatingChar } from \"../tokens.ts\"\n\nexport const parseDivisor = (s: RootedRuntimeState): void => {\n\ts.scanner.shiftUntilNonWhitespace()\n\tconst divisorToken = s.scanner.shiftUntilLookahead(terminatingChars)\n\tconst divisor = tryParseInteger(divisorToken, {\n\t\terrorOnFail: writeInvalidDivisorMessage(divisorToken)\n\t})\n\tif (divisor === 0) s.error(writeInvalidDivisorMessage(0))\n\n\ts.root = s.root.constrain(\"divisor\", divisor)\n}\n\nexport type parseDivisor<s extends StaticState, unscanned extends string> =\n\tScanner.shiftUntil<\n\t\tScanner.skipWhitespace<unscanned>,\n\t\tTerminatingChar\n\t> extends Scanner.shiftResult<infer scanned, infer nextUnscanned> ?\n\t\tscanned extends `${infer divisor extends number}` ?\n\t\t\tdivisor extends 0 ?\n\t\t\t\ts.error<writeInvalidDivisorMessage<0>>\n\t\t\t:\ts.setRoot<s, [s[\"root\"], \"%\", divisor], nextUnscanned>\n\t\t:\ts.error<writeInvalidDivisorMessage<scanned>>\n\t:\tnever\n\nexport const writeInvalidDivisorMessage = <divisor extends string | number>(\n\tdivisor: divisor\n): writeInvalidDivisorMessage<divisor> =>\n\t`% operator must be followed by a non-zero integer literal (was ${divisor})`\n\nexport type writeInvalidDivisorMessage<divisor extends string | number> =\n\t`% operator must be followed by a non-zero integer literal (was ${divisor})`\n"
  },
  {
    "path": "ark/type/parser/shift/operator/operator.ts",
    "content": "import {\n\tisKeyOf,\n\twhitespaceChars,\n\ttype Scanner,\n\ttype WhitespaceChar\n} from \"@ark/util\"\nimport type { RootedRuntimeState } from \"../../reduce/dynamic.ts\"\nimport type { StaticState, s } from \"../../reduce/static.ts\"\nimport { lookaheadIsFinalizing, type FinalizingLookahead } from \"../tokens.ts\"\nimport {\n\tcomparatorStartChars,\n\tparseBound,\n\ttype ComparatorStartChar\n} from \"./bounds.ts\"\nimport { parseBrand } from \"./brand.ts\"\nimport { parseDivisor } from \"./divisor.ts\"\n\nexport const parseOperator = (s: RootedRuntimeState): void => {\n\tconst lookahead = s.scanner.shift()\n\treturn (\n\t\tlookahead === \"\" ? s.finalize(\"\")\n\t\t: lookahead === \"[\" ?\n\t\t\ts.scanner.shift() === \"]\" ?\n\t\t\t\ts.setRoot(s.root.array())\n\t\t\t:\ts.error(incompleteArrayTokenMessage)\n\t\t: lookahead === \"|\" ?\n\t\t\ts.scanner.lookahead === \">\" ?\n\t\t\t\ts.shiftedBy(1).pushRootToBranch(\"|>\")\n\t\t\t:\ts.pushRootToBranch(lookahead)\n\t\t: lookahead === \"&\" ? s.pushRootToBranch(lookahead)\n\t\t: lookahead === \")\" ? s.finalizeGroup()\n\t\t: lookaheadIsFinalizing(lookahead, s.scanner.unscanned) ?\n\t\t\ts.finalize(lookahead)\n\t\t: isKeyOf(lookahead, comparatorStartChars) ? parseBound(s, lookahead)\n\t\t: lookahead === \"%\" ? parseDivisor(s)\n\t\t: lookahead === \"#\" ? parseBrand(s)\n\t\t: lookahead in whitespaceChars ? parseOperator(s)\n\t\t: s.error(writeUnexpectedCharacterMessage(lookahead))\n\t)\n}\n\nexport type parseOperator<s extends StaticState, $, args> =\n\ts[\"unscanned\"] extends Scanner.shift<infer lookahead, infer unscanned> ?\n\t\tlookahead extends \"[\" ?\n\t\t\tunscanned extends Scanner.shift<\"]\", infer nextUnscanned> ?\n\t\t\t\ts.setRoot<s, [s[\"root\"], \"[]\"], nextUnscanned>\n\t\t\t:\ts.error<incompleteArrayTokenMessage>\n\t\t: lookahead extends \"|\" ?\n\t\t\tunscanned extends Scanner.shift<\">\", infer nextUnscanned> ?\n\t\t\t\ts.reduceBranch<s, \"|>\", nextUnscanned>\n\t\t\t:\ts.reduceBranch<s, lookahead, unscanned>\n\t\t: lookahead extends \"&\" ? s.reduceBranch<s, lookahead, unscanned>\n\t\t: lookahead extends \")\" ? s.finalizeGroup<s, unscanned>\n\t\t: lookaheadIsFinalizing<lookahead, unscanned> extends true ?\n\t\t\ts.finalize<s.scanTo<s, unscanned>, lookahead & FinalizingLookahead>\n\t\t: lookahead extends ComparatorStartChar ?\n\t\t\tparseBound<s, lookahead, unscanned, $, args>\n\t\t: lookahead extends \"%\" ? parseDivisor<s, unscanned>\n\t\t: lookahead extends \"#\" ? parseBrand<s, unscanned>\n\t\t: lookahead extends WhitespaceChar ?\n\t\t\tparseOperator<s.scanTo<s, unscanned>, $, args>\n\t\t:\ts.error<writeUnexpectedCharacterMessage<lookahead>>\n\t:\ts.finalize<s, \"\">\n\nexport const writeUnexpectedCharacterMessage = <\n\tchar extends string,\n\tshouldBe extends string\n>(\n\tchar: char,\n\tshouldBe: shouldBe = \"\" as shouldBe\n): writeUnexpectedCharacterMessage<char, shouldBe> =>\n\t`'${char}' is not allowed here${\n\t\tshouldBe && (` (should be ${shouldBe})` as any)\n\t}`\n\nexport type writeUnexpectedCharacterMessage<\n\tchar extends string,\n\tshouldBe extends string = \"\"\n> = `'${char}' is not allowed here${shouldBe extends \"\" ? \"\"\n:\t` (should be ${shouldBe})`}`\n\nexport const incompleteArrayTokenMessage = `Missing expected ']'`\n\ntype incompleteArrayTokenMessage = typeof incompleteArrayTokenMessage\n"
  },
  {
    "path": "ark/type/parser/shift/tokens.ts",
    "content": "import { isKeyOf, whitespaceChars, type Scanner } from \"@ark/util\"\nimport type { Comparator } from \"../reduce/shared.ts\"\n\nexport const terminatingChars = {\n\t\"<\": 1,\n\t\">\": 1,\n\t\"=\": 1,\n\t\"|\": 1,\n\t\"&\": 1,\n\t\")\": 1,\n\t\"[\": 1,\n\t\"%\": 1,\n\t\",\": 1,\n\t\":\": 1,\n\t\"?\": 1,\n\t\"#\": 1,\n\t...whitespaceChars\n} as const\n\nexport type TerminatingChar = keyof typeof terminatingChars\n\nexport const finalizingLookaheads = {\n\t\">\": 1,\n\t\",\": 1,\n\t\"\": 1,\n\t\"=\": 1,\n\t\"?\": 1\n} as const\n\nexport type FinalizingLookahead = keyof typeof finalizingLookaheads\n\nexport const lookaheadIsFinalizing = (\n\tlookahead: string,\n\tunscanned: string\n): lookahead is \">\" | \",\" | \"=\" | \"?\" =>\n\tlookahead === \">\" ?\n\t\tunscanned[0] === \"=\" ?\n\t\t\t// >== would only occur in an expression like Array<number>==5\n\t\t\t// otherwise, >= would only occur as part of a bound like number>=5\n\t\t\tunscanned[1] === \"=\"\n\t\t\t// if > is the end of a generic instantiation, the next token will be\n\t\t\t// an operator or the end of the string\n\t\t:\tunscanned.trimStart() === \"\" ||\n\t\t\tisKeyOf(unscanned.trimStart()[0], terminatingChars)\n\t\t// \"=\" is a finalizer on its own (representing a default value),\n\t\t// but not with a second \"=\" (an equality comparator)\n\t: lookahead === \"=\" ? unscanned[0] !== \"=\"\n\t\t// \",\" and \"?\" are unambiguously finalizers\n\t: lookahead === \",\" || lookahead === \"?\"\n\nexport type lookaheadIsFinalizing<\n\tlookahead extends string,\n\tunscanned extends string\n> =\n\tlookahead extends \">\" ?\n\t\tunscanned extends `=${infer nextUnscanned}` ?\n\t\t\tnextUnscanned extends `=${string}` ?\n\t\t\t\ttrue\n\t\t\t:\tfalse\n\t\t: Scanner.skipWhitespace<unscanned> extends (\n\t\t\t\"\" | `${TerminatingChar}${string}`\n\t\t) ?\n\t\t\ttrue\n\t\t:\tfalse\n\t: lookahead extends \"=\" ?\n\t\tunscanned extends `=${string}` ?\n\t\t\tfalse\n\t\t:\ttrue\n\t: lookahead extends \",\" | \"?\" ? true\n\t: false\n\nexport type InfixToken =\n\t| Comparator\n\t| \"|\"\n\t| \"&\"\n\t| \"%\"\n\t| \":\"\n\t| \"=>\"\n\t| \"|>\"\n\t| \"#\"\n\t| \"@\"\n\t| \"=\"\n\nexport type PostfixToken = \"[]\" | \"?\"\n\nexport type OperatorToken = InfixToken | PostfixToken\n"
  },
  {
    "path": "ark/type/parser/string.ts",
    "content": "import type { BaseParseContext, resolvableReferenceIn } from \"@ark/schema\"\nimport {\n\tScanner,\n\tthrowInternalError,\n\tthrowParseError,\n\ttype ErrorMessage\n} from \"@ark/util\"\nimport type { ArkAmbient } from \"../config.ts\"\nimport type { InnerParseResult, resolutionToAst } from \"../scope.ts\"\nimport type { inferAstRoot } from \"./ast/infer.ts\"\nimport { RuntimeState, type RootedRuntimeState } from \"./reduce/dynamic.ts\"\nimport type { StringifiablePrefixOperator } from \"./reduce/shared.ts\"\nimport type { s, StaticState } from \"./reduce/static.ts\"\nimport type { parseOperand } from \"./shift/operand/operand.ts\"\nimport { parseDefault } from \"./shift/operator/default.ts\"\nimport {\n\twriteUnexpectedCharacterMessage,\n\ttype parseOperator\n} from \"./shift/operator/operator.ts\"\n\nexport const parseString = (\n\tdef: string,\n\tctx: BaseParseContext\n): InnerParseResult => {\n\tconst aliasResolution = ctx.$.maybeResolveRoot(def)\n\tif (aliasResolution) return aliasResolution\n\n\tif (def.endsWith(\"[]\")) {\n\t\tconst possibleElementResolution = ctx.$.maybeResolveRoot(def.slice(0, -2))\n\t\tif (possibleElementResolution) return possibleElementResolution.array()\n\t}\n\n\tconst s = new RuntimeState(new Scanner(def), ctx)\n\n\tconst node = fullStringParse(s)\n\n\tif (s.finalizer === \">\") throwParseError(writeUnexpectedCharacterMessage(\">\"))\n\n\treturn node\n}\n\n/**\n * Try to parse the definition from right to left using the most common syntax.\n * This can be much more efficient for simple definitions.\n */\nexport type parseString<def extends string, $, args> =\n\tdef extends keyof $ ?\n\t\t// def could also be a generic reference here, in which case it will\n\t\t// fail semantic validation because it has no args\n\t\tresolutionToAst<def, $[def]>\n\t: def extends `${infer child}[]` ?\n\t\tchild extends keyof $ ?\n\t\t\t[resolutionToAst<child, $[child]>, \"[]\"]\n\t\t:\tfullStringParse<s.initialize<def>, $, args>\n\t:\tfullStringParse<s.initialize<def>, $, args>\n\nexport type inferString<def extends string, $, args> = inferAstRoot<\n\tparseString<def, $, args>,\n\t$,\n\targs\n>\n\nexport type BaseCompletions<$, args, otherSuggestions extends string = never> =\n\t| resolvableReferenceIn<$>\n\t| resolvableReferenceIn<ArkAmbient.$>\n\t| (keyof args & string)\n\t| StringifiablePrefixOperator\n\t| otherSuggestions\n\nexport const fullStringParse = (s: RuntimeState): InnerParseResult => {\n\ts.parseOperand()\n\tlet result: InnerParseResult = parseUntilFinalizer(s).root\n\tif (!result) {\n\t\treturn throwInternalError(\n\t\t\t`Root was unexpectedly unset after parsing string '${s.scanner.scanned}'`\n\t\t)\n\t}\n\n\tif (s.finalizer === \"=\") result = parseDefault(s as RootedRuntimeState)\n\telse if (s.finalizer === \"?\") result = [result, \"?\"]\n\n\ts.scanner.shiftUntilNonWhitespace()\n\tif (s.scanner.lookahead) {\n\t\t// throw a parse error if non-whitespace characters made it here without being parsed\n\t\tthrowParseError(writeUnexpectedCharacterMessage(s.scanner.lookahead))\n\t}\n\treturn result\n}\n\ntype fullStringParse<s extends StaticState, $, args> = extractFinalizedResult<\n\tparseUntilFinalizer<s, $, args>\n>\n\nexport const parseUntilFinalizer = (s: RuntimeState): RootedRuntimeState => {\n\twhile (s.finalizer === undefined) next(s)\n\n\treturn s as RootedRuntimeState\n}\n\nexport type parseUntilFinalizer<s extends StaticState, $, args> =\n\ts[\"finalizer\"] extends undefined ?\n\t\tparseUntilFinalizer<next<s, $, args>, $, args>\n\t:\ts\n\nconst next = (s: RuntimeState): void =>\n\ts.hasRoot() ? s.parseOperator() : s.parseOperand()\n\ntype next<s extends StaticState, $, args> =\n\ts[\"root\"] extends undefined ? parseOperand<s, $, args>\n\t:\tparseOperator<s, $, args>\n\nexport type extractFinalizedResult<s extends StaticState> =\n\ts[\"finalizer\"] extends \"\" ? s[\"root\"]\n\t: s[\"finalizer\"] extends ErrorMessage ? s[\"finalizer\"]\n\t: s[\"finalizer\"] extends \"?\" ? [s[\"root\"], \"?\"]\n\t: s[\"finalizer\"] extends \"=\" ? parseDefault<s[\"root\"], s[\"unscanned\"]>\n\t: ErrorMessage<writeUnexpectedCharacterMessage<s[\"finalizer\"] & string>>\n"
  },
  {
    "path": "ark/type/parser/tupleExpressions.ts",
    "content": "import {\n\tDisjoint,\n\tintersectNodesRoot,\n\tpipeNodesRoot,\n\ttype BaseParseContext,\n\ttype BaseRoot,\n\ttype Morph,\n\ttype NodeSelector,\n\ttype Predicate,\n\ttype TypeMeta,\n\ttype unwrapDefault\n} from \"@ark/schema\"\nimport {\n\tobjectKindOrDomainOf,\n\tthrowParseError,\n\ttype array,\n\ttype BuiltinObjectKind,\n\ttype Constructor,\n\ttype Domain,\n\ttype show\n} from \"@ark/util\"\nimport type {\n\tdefaultFor,\n\tdistill,\n\tinferIntersection,\n\tinferMorphOut,\n\tinferPipe,\n\tinferPredicate,\n\tOut,\n\twithDefault\n} from \"../attributes.ts\"\nimport type { type } from \"../keywords/keywords.ts\"\nimport {\n\tshallowDefaultableMessage,\n\tshallowOptionalMessage\n} from \"./ast/validate.ts\"\nimport type { inferDefinition, validateDefinition } from \"./definition.ts\"\nimport type { BranchOperator } from \"./reduce/shared.ts\"\nimport { writeMissingRightOperandMessage } from \"./shift/operand/unenclosed.ts\"\nimport type { InfixToken } from \"./shift/tokens.ts\"\nimport type { BaseCompletions } from \"./string.ts\"\n\nexport const maybeParseTupleExpression = (\n\tdef: array,\n\tctx: BaseParseContext\n): BaseRoot | null =>\n\tisIndexZeroExpression(def) ? indexZeroParsers[def[0]](def as never, ctx)\n\t: isIndexOneExpression(def) ? indexOneParsers[def[1]](def as never, ctx)\n\t: null\n\nexport type maybeValidateTupleExpression<def extends array, $, args> =\n\tdef extends IndexZeroExpression ? validatePrefixExpression<def, $, args>\n\t: def extends IndexOneExpression ? validateIndexOneExpression<def, $, args>\n\t: def extends (\n\t\treadonly [\"\", ...unknown[]] | readonly [unknown, \"\", ...unknown[]]\n\t) ?\n\t\treadonly [\n\t\t\tdef[0] extends \"\" ? BaseCompletions<$, args, IndexZeroOperator | \"...\">\n\t\t\t:\tdef[0],\n\t\t\tdef[1] extends \"\" ? BaseCompletions<$, args, IndexOneOperator | \"...\">\n\t\t\t:\tdef[1]\n\t\t]\n\t:\tnull\n\nexport type inferTupleExpression<def extends TupleExpression, $, args> =\n\tdef[1] extends \"[]\" ? inferDefinition<def[0], $, args>[]\n\t: def[1] extends \"?\" ? inferDefinition<def[0], $, args>\n\t: def[1] extends \"&\" ?\n\t\tinferIntersection<\n\t\t\tinferDefinition<def[0], $, args>,\n\t\t\tinferDefinition<def[2], $, args>\n\t\t>\n\t: def[1] extends \"|\" ?\n\t\tinferDefinition<def[0], $, args> | inferDefinition<def[2], $, args>\n\t: def[1] extends \":\" ?\n\t\tinferPredicate<inferDefinition<def[0], $, args>, def[2]>\n\t: def[1] extends \"=>\" ? parseMorph<def[0], def[2], $, args>\n\t: def[1] extends \"|>\" ? parseTo<def[0], def[2], $, args>\n\t: def[1] extends \"=\" ?\n\t\twithDefault<inferDefinition<def[0], $, args>, unwrapDefault<def[2]>>\n\t: def[1] extends \"@\" ? inferDefinition<def[0], $, args>\n\t: def extends readonly [\"===\", ...infer values] ? values[number]\n\t: def extends (\n\t\treadonly [\"instanceof\", ...infer constructors extends Constructor[]]\n\t) ?\n\t\tInstanceType<constructors[number]>\n\t: def[0] extends \"keyof\" ? inferKeyOfExpression<def[1], $, args>\n\t: never\n\nexport type validatePrefixExpression<def extends IndexZeroExpression, $, args> =\n\tdef[\"length\"] extends 1 ? readonly [writeMissingRightOperandMessage<def[0]>]\n\t: def[0] extends \"keyof\" ?\n\t\treadonly [def[0], validateDefinition<def[1], $, args>]\n\t: def[0] extends \"===\" ? readonly [def[0], ...unknown[]]\n\t: def[0] extends \"instanceof\" ? readonly [def[0], ...Constructor[]]\n\t: never\n\nexport type validateIndexOneExpression<\n\tdef extends IndexOneExpression,\n\t$,\n\targs\n> =\n\tdef[1] extends TuplePostfixOperator ?\n\t\t// use type.validate here since optional/defaultables are not allowed\n\t\t// within tuple expressions\n\t\treadonly [validateDefinition<def[0], $, args>, def[1]]\n\t:\treadonly [\n\t\t\tvalidateDefinition<def[0], $, args>,\n\t\t\tdef[\"length\"] extends 2 ? writeMissingRightOperandMessage<def[1]>\n\t\t\t:\tdef[1],\n\t\t\tdef[1] extends \"|\" ? validateDefinition<def[2], $, args>\n\t\t\t: def[1] extends \"&\" ? validateDefinition<def[2], $, args>\n\t\t\t: def[1] extends \":\" ? Predicate<type.infer.Out<def[0], $, args>>\n\t\t\t: def[1] extends \"=>\" ? Morph<type.infer.Out<def[0], $, args>>\n\t\t\t: def[1] extends \"|>\" ? validateDefinition<def[2], $, args>\n\t\t\t: def[1] extends \"=\" ? defaultFor<type.infer.In<def[0], $, args>>\n\t\t\t: def[1] extends \"@\" ? TypeMeta.MappableInput\n\t\t\t: validateDefinition<def[2], $, args>,\n\t\t\t...(def[1] extends \"@\" ? [NodeSelector?] : [])\n\t\t]\n\nexport type UnparsedTupleExpressionInput = {\n\tinstanceof: Constructor\n\t\"===\": unknown\n}\n\nexport type UnparsedTupleOperator = show<keyof UnparsedTupleExpressionInput>\n\nexport const parseKeyOfTuple: IndexZeroParser<\"keyof\"> = (def, ctx) =>\n\tctx.$.parseOwnDefinitionFormat(def[1], ctx).keyof()\n\nexport type inferKeyOfExpression<operandDef, $, args> = show<\n\tkeyof inferDefinition<operandDef, $, args>\n>\n\nconst parseBranchTuple: IndexOneParser<BranchOperator> = (def, ctx) => {\n\tif (def[2] === undefined)\n\t\treturn throwParseError(writeMissingRightOperandMessage(def[1], \"\"))\n\n\tconst l = ctx.$.parseOwnDefinitionFormat(def[0], ctx)\n\tconst r = ctx.$.parseOwnDefinitionFormat(def[2], ctx)\n\tif (def[1] === \"|\") return ctx.$.node(\"union\", { branches: [l, r] })\n\tconst result =\n\t\tdef[1] === \"&\" ?\n\t\t\tintersectNodesRoot(l, r, ctx.$)\n\t\t:\tpipeNodesRoot(l, r, ctx.$)\n\tif (result instanceof Disjoint) return result.throw()\n\treturn result\n}\n\nconst parseArrayTuple: IndexOneParser<\"[]\"> = (def, ctx) =>\n\tctx.$.parseOwnDefinitionFormat(def[0], ctx).array()\n\nexport type TupleExpression = IndexZeroExpression | IndexOneExpression\n\nexport type TupleExpressionOperator = IndexZeroOperator | IndexOneOperator\n\nexport type ArgTwoOperator = Exclude<IndexOneOperator, \"?\" | \"=\">\n\nexport const parseMorphTuple: IndexOneParser<\"=>\"> = (def, ctx) => {\n\tif (typeof def[2] !== \"function\") {\n\t\treturn throwParseError(\n\t\t\twriteMalformedFunctionalExpressionMessage(\"=>\", def[2])\n\t\t)\n\t}\n\treturn ctx.$.parseOwnDefinitionFormat(def[0], ctx).pipe(def[2] as Morph)\n}\n\nexport const writeMalformedFunctionalExpressionMessage = (\n\toperator: \":\" | \"=>\",\n\tvalue: unknown\n): string =>\n\t`${\n\t\toperator === \":\" ? \"Narrow\" : \"Morph\"\n\t} expression requires a function following '${operator}' (was ${typeof value})`\n\nexport type parseTo<inDef, outDef, $, args> = inferPipe<\n\tinferDefinition<inDef, $, args>,\n\tinferDefinition<outDef, $, args>\n>\n\nexport type parseMorph<inDef, morph, $, args> =\n\tmorph extends Morph ?\n\t\tinferMorphOut<morph> extends infer out ?\n\t\t\t(In: distill.In<inferDefinition<inDef, $, args>>) => Out<out>\n\t\t:\tnever\n\t:\tnever\n\nexport const parseNarrowTuple: IndexOneParser<\":\"> = (def, ctx) => {\n\tif (typeof def[2] !== \"function\") {\n\t\treturn throwParseError(\n\t\t\twriteMalformedFunctionalExpressionMessage(\":\", def[2])\n\t\t)\n\t}\n\treturn ctx.$.parseOwnDefinitionFormat(def[0], ctx).constrain(\n\t\t\"predicate\",\n\t\tdef[2] as Predicate\n\t)\n}\n\nconst parseMetaTuple: IndexOneParser<\"@\"> = (def, ctx) =>\n\tctx.$.parseOwnDefinitionFormat(def[0], ctx).configure(\n\t\tdef[2] as never,\n\t\tdef[3] as NodeSelector\n\t)\n\nexport type IndexOneExpression<token extends string = IndexOneOperator> =\n\treadonly [unknown, token, ...unknown[]]\n\ntype IndexOneParser<token extends string> = (\n\tdef: IndexOneExpression<token>,\n\tctx: BaseParseContext\n) => BaseRoot\n\nconst defineIndexOneParsers = <parsers>(parsers: {\n\t[k in keyof parsers & string]: IndexOneParser<k>\n}) => parsers\n\nconst postfixParsers = defineIndexOneParsers({\n\t\"[]\": parseArrayTuple,\n\t\"?\": () => throwParseError(shallowOptionalMessage)\n})\n\nexport type TuplePostfixOperator = keyof typeof postfixParsers\n\nconst infixParsers = defineIndexOneParsers({\n\t\"|\": parseBranchTuple,\n\t\"&\": parseBranchTuple,\n\t\":\": parseNarrowTuple,\n\t\"=>\": parseMorphTuple,\n\t\"|>\": parseBranchTuple,\n\t\"@\": parseMetaTuple,\n\t// since object and tuple literals parse there via `parseProperty`,\n\t// they must be shallow if parsed directly as a tuple expression\n\t\"=\": () => throwParseError(shallowDefaultableMessage)\n})\n\nexport type TupleInfixOperator = keyof typeof infixParsers\n\nconst indexOneParsers = { ...postfixParsers, ...infixParsers }\n\nexport type IndexOneOperator = keyof typeof indexOneParsers\n\nconst isIndexOneExpression = (def: array): def is IndexOneExpression =>\n\tindexOneParsers[def[1] as IndexOneOperator] !== undefined\n\nexport type InfixExpression = readonly [unknown, InfixToken, ...unknown[]]\n\ntype IndexZeroParser<token extends string> = (\n\tdef: IndexZeroExpression<token>,\n\tctx: BaseParseContext\n) => BaseRoot\n\ntype IndexZeroExpression<token extends string = IndexZeroOperator> = readonly [\n\ttoken,\n\t...unknown[]\n]\n\nconst defineIndexZeroParsers = <parsers>(parsers: {\n\t[k in keyof parsers & string]: IndexZeroParser<k>\n}) => parsers\n\nconst indexZeroParsers = defineIndexZeroParsers({\n\tkeyof: parseKeyOfTuple,\n\tinstanceof: (def, ctx) => {\n\t\tif (typeof def[1] !== \"function\") {\n\t\t\treturn throwParseError(\n\t\t\t\twriteInvalidConstructorMessage(objectKindOrDomainOf(def[1]))\n\t\t\t)\n\t\t}\n\t\tconst branches = def\n\t\t\t.slice(1)\n\t\t\t.map(ctor =>\n\t\t\t\ttypeof ctor === \"function\" ?\n\t\t\t\t\tctx.$.node(\"proto\", { proto: ctor as Constructor })\n\t\t\t\t:\tthrowParseError(\n\t\t\t\t\t\twriteInvalidConstructorMessage(objectKindOrDomainOf(ctor))\n\t\t\t\t\t)\n\t\t\t)\n\t\treturn branches.length === 1 ?\n\t\t\t\tbranches[0]\n\t\t\t:\tctx.$.node(\"union\", { branches })\n\t},\n\t\"===\": (def, ctx) => ctx.$.units(def.slice(1))\n})\n\nexport type IndexZeroOperator = keyof typeof indexZeroParsers\n\nconst isIndexZeroExpression = (def: array): def is IndexZeroExpression =>\n\tindexZeroParsers[def[0] as IndexZeroOperator] !== undefined\n\nexport const writeInvalidConstructorMessage = <\n\tactual extends Domain | BuiltinObjectKind\n>(\n\tactual: actual\n): string =>\n\t`Expected a constructor following 'instanceof' operator (was ${actual})`\n"
  },
  {
    "path": "ark/type/parser/tupleLiteral.ts",
    "content": "import {\n\t$ark,\n\tmakeRootAndArrayPropertiesMutable,\n\tpostfixAfterOptionalOrDefaultableMessage,\n\ttype BaseParseContext,\n\ttype BaseRoot,\n\ttype mutableInnerOfKind,\n\ttype Sequence\n} from \"@ark/schema\"\nimport {\n\tappend,\n\tisArray,\n\tisEmptyObject,\n\tthrowParseError,\n\ttype array,\n\ttype conform,\n\ttype ErrorMessage,\n\ttype satisfy\n} from \"@ark/util\"\nimport type { inferDefinition, validateInnerDefinition } from \"./definition.ts\"\nimport {\n\tparseProperty,\n\ttype DefaultablePropertyTuple,\n\ttype isDefaultable,\n\ttype OptionalPropertyDefinition\n} from \"./property.ts\"\n\nexport const parseTupleLiteral = (\n\tdef: array,\n\tctx: BaseParseContext\n): BaseRoot => {\n\tlet sequences: mutableInnerOfKind<\"sequence\">[] = [{}]\n\tlet i = 0\n\twhile (i < def.length) {\n\t\tlet spread = false\n\t\tif (def[i] === \"...\" && i < def.length - 1) {\n\t\t\tspread = true\n\t\t\ti++\n\t\t}\n\n\t\tconst parsedProperty = parseProperty(def[i], ctx)\n\n\t\tconst [valueNode, operator, possibleDefaultValue] =\n\t\t\t!isArray(parsedProperty) ? [parsedProperty] : parsedProperty\n\n\t\ti++\n\t\tif (spread) {\n\t\t\tif (!valueNode.extends($ark.intrinsic.Array))\n\t\t\t\treturn throwParseError(writeNonArraySpreadMessage(valueNode.expression))\n\n\t\t\t// a spread must be distributed over branches e.g.:\n\t\t\t// def: [string, ...(number[] | [true, false])]\n\t\t\t// nodes: [string, ...number[]] | [string, true, false]\n\t\t\tsequences = sequences.flatMap(base =>\n\t\t\t\t// since appendElement mutates base, we have to shallow-ish clone it for each branch\n\t\t\t\tvalueNode.distribute(branch =>\n\t\t\t\t\tappendSpreadBranch(makeRootAndArrayPropertiesMutable(base), branch)\n\t\t\t\t)\n\t\t\t)\n\t\t} else {\n\t\t\tsequences = sequences.map(base => {\n\t\t\t\tif (operator === \"?\") return appendOptionalElement(base, valueNode)\n\n\t\t\t\tif (operator === \"=\")\n\t\t\t\t\treturn appendDefaultableElement(base, valueNode, possibleDefaultValue)\n\n\t\t\t\treturn appendRequiredElement(base, valueNode)\n\t\t\t})\n\t\t}\n\t}\n\n\treturn ctx.$.parseSchema(\n\t\tsequences.map(sequence =>\n\t\t\tisEmptyObject(sequence) ?\n\t\t\t\t{\n\t\t\t\t\tproto: Array,\n\t\t\t\t\texactLength: 0\n\t\t\t\t}\n\t\t\t:\t({\n\t\t\t\t\tproto: Array,\n\t\t\t\t\tsequence\n\t\t\t\t} as const)\n\t\t)\n\t)\n}\n\nexport type validateTupleLiteral<def extends array, $, args> =\n\tparseSequence<def, $, args> extends infer s extends SequenceParseState ?\n\t\tReadonly<s[\"validated\"]>\n\t:\tnever\n\nexport type inferTupleLiteral<def extends array, $, args> =\n\tparseSequence<def, $, args> extends infer s extends SequenceParseState ?\n\t\ts[\"inferred\"]\n\t:\tnever\n\nconst appendRequiredElement = (\n\tbase: mutableInnerOfKind<\"sequence\">,\n\telement: BaseRoot\n): mutableInnerOfKind<\"sequence\"> => {\n\tif (base.defaultables || base.optionals) {\n\t\treturn throwParseError(\n\t\t\tbase.variadic ?\n\t\t\t\t// e.g. [boolean = true, ...string[], number]\n\t\t\t\tpostfixAfterOptionalOrDefaultableMessage\n\t\t\t\t// e.g. [string?, number]\n\t\t\t:\trequiredPostOptionalMessage\n\t\t)\n\t}\n\tif (base.variadic) {\n\t\t// e.g. [...string[], number]\n\t\tbase.postfix = append(base.postfix, element)\n\t} else {\n\t\t// e.g. [string, number]\n\t\tbase.prefix = append(base.prefix, element)\n\t}\n\treturn base\n}\n\nconst appendOptionalElement = (\n\tbase: mutableInnerOfKind<\"sequence\">,\n\telement: BaseRoot\n): mutableInnerOfKind<\"sequence\"> => {\n\tif (base.variadic)\n\t\t// e.g. [...string[], number?]\n\t\treturn throwParseError(optionalOrDefaultableAfterVariadicMessage)\n\t// e.g. [string, number?]\n\tbase.optionals = append(base.optionals, element)\n\treturn base\n}\n\nconst appendDefaultableElement = (\n\tbase: mutableInnerOfKind<\"sequence\">,\n\telement: BaseRoot,\n\tvalue: unknown\n): mutableInnerOfKind<\"sequence\"> => {\n\tif (base.variadic)\n\t\t// e.g. [...string[], number = 0]\n\t\treturn throwParseError(optionalOrDefaultableAfterVariadicMessage)\n\tif (base.optionals)\n\t\t// e.g. [string?, number = 0]\n\t\treturn throwParseError(defaultablePostOptionalMessage)\n\n\t// value's assignability to element will be checked when the\n\t// sequence is instantiated by @ark/schema\n\t// e.g. [string, number = 0]\n\tbase.defaultables = append(base.defaultables, [[element, value]])\n\treturn base\n}\n\nconst appendVariadicElement = (\n\tbase: mutableInnerOfKind<\"sequence\">,\n\telement: BaseRoot\n): mutableInnerOfKind<\"sequence\"> => {\n\t// e.g. [...string[], number, ...string[]]\n\tif (base.postfix) throwParseError(multipleVariadicMesage)\n\tif (base.variadic) {\n\t\tif (!base.variadic.equals(element)) {\n\t\t\t// e.g. [...string[], ...number[]]\n\t\t\tthrowParseError(multipleVariadicMesage)\n\t\t}\n\t\t// e.g. [...string[], ...string[]]\n\t\t// do nothing, second spread doesn't change the type\n\t} else {\n\t\t// e.g. [string, ...number[]]\n\t\tbase.variadic = element.internal\n\t}\n\treturn base\n}\n\nconst appendSpreadBranch = (\n\tbase: mutableInnerOfKind<\"sequence\">,\n\tbranch: BaseRoot\n): mutableInnerOfKind<\"sequence\"> => {\n\tconst spread = branch.select({ method: \"find\", kind: \"sequence\" })\n\tif (!spread) {\n\t\t// the only array with no sequence reference is unknown[]\n\t\treturn appendVariadicElement(base, $ark.intrinsic.unknown)\n\t}\n\n\tif (spread.prefix)\n\t\tfor (const node of spread.prefix) appendRequiredElement(base, node)\n\tif (spread.optionals)\n\t\tfor (const node of spread.optionals) appendOptionalElement(base, node)\n\tif (spread.variadic) appendVariadicElement(base, spread.variadic)\n\tif (spread.postfix)\n\t\tfor (const node of spread.postfix) appendRequiredElement(base, node)\n\n\treturn base\n}\n\ntype SequencePhase = satisfy<\n\tkeyof Sequence.Inner,\n\t| SequencePhase.prefix\n\t| SequencePhase.optionals\n\t| SequencePhase.defaultables\n\t| SequencePhase.postfix\n>\n\ndeclare namespace SequencePhase {\n\texport type prefix = \"prefix\"\n\n\texport type optionals = \"optionals\"\n\n\texport type defaultables = \"defaultables\"\n\n\texport type postfix = \"postfix\"\n}\n\ntype SequenceParseState = {\n\tunscanned: array\n\tinferred: array\n\tvalidated: array\n\tphase: SequencePhase\n}\n\ntype parseSequence<def extends array, $, args> = parseNextElement<\n\t{\n\t\tunscanned: def\n\t\tinferred: []\n\t\tvalidated: []\n\t\tphase: SequencePhase.prefix\n\t},\n\t$,\n\targs\n>\n\ntype PreparsedElementKind =\n\t| \"required\"\n\t| SequencePhase.optionals\n\t| SequencePhase.defaultables\n\ntype PreparsedElement = {\n\thead: unknown\n\ttail: array\n\tinferred: unknown\n\tvalidated: unknown\n\tkind: PreparsedElementKind\n\tspread: boolean\n}\n\ndeclare namespace PreparsedElement {\n\texport type from<result extends PreparsedElement> = result\n\n\texport type required = \"required\"\n\n\texport type optionals = \"optionals\"\n\n\texport type defaultables = \"defaultables\"\n}\n\ntype preparseNextState<s extends SequenceParseState, $, args> =\n\ts[\"unscanned\"] extends readonly [\"...\", infer head, ...infer tail] ?\n\t\tpreparseNextElement<head, tail, true, $, args>\n\t: s[\"unscanned\"] extends readonly [infer head, ...infer tail] ?\n\t\tpreparseNextElement<head, tail, false, $, args>\n\t:\tnull\n\ntype preparseNextElement<\n\thead,\n\ttail extends array,\n\tspread extends boolean,\n\t$,\n\targs\n> = PreparsedElement.from<{\n\thead: head\n\ttail: tail\n\tinferred: inferDefinition<head, $, args>\n\tvalidated: validateInnerDefinition<head, $, args>\n\t// if inferredHead is optional and the element is spread, this will be an error\n\t// handled in nextValidatedSpreadElements\n\tkind: head extends OptionalPropertyDefinition ? PreparsedElement.optionals\n\t: head extends DefaultablePropertyTuple ? PreparsedElement.defaultables\n\t: isDefaultable<head, $, args> extends true ? PreparsedElement.defaultables\n\t: PreparsedElement.required\n\tspread: spread\n}>\n\ntype parseNextElement<s extends SequenceParseState, $, args> =\n\tpreparseNextState<s, $, args> extends infer next extends PreparsedElement ?\n\t\tparseNextElement<\n\t\t\t{\n\t\t\t\tunscanned: next[\"tail\"]\n\t\t\t\tinferred: nextInferred<s, next>\n\t\t\t\tvalidated: nextValidated<s, next>\n\t\t\t\tphase: next[\"kind\"] extends (\n\t\t\t\t\tSequencePhase.optionals | SequencePhase.defaultables\n\t\t\t\t) ?\n\t\t\t\t\tnext[\"kind\"]\n\t\t\t\t: // if we're parsing the variadic element, don't update the phase\n\t\t\t\t// so that we can still check it to ensure we don't have\n\t\t\t\t// postfix elements following optionals or defaultables\n\t\t\t\tnumber extends nextInferred<s, next>[\"length\"] ? s[\"phase\"]\n\t\t\t\t: SequencePhase.prefix\n\t\t\t},\n\t\t\t$,\n\t\t\targs\n\t\t>\n\t:\ts\n\ntype nextInferred<s extends SequenceParseState, next extends PreparsedElement> =\n\tnext[\"spread\"] extends true ?\n\t\t[...s[\"inferred\"], ...conform<next[\"inferred\"], array>]\n\t: next[\"kind\"] extends SequencePhase.optionals ?\n\t\t[...s[\"inferred\"], next[\"inferred\"]?]\n\t:\t[...s[\"inferred\"], next[\"inferred\"]]\n\ntype nextValidated<\n\ts extends SequenceParseState,\n\tnext extends PreparsedElement\n> = [\n\t...s[\"validated\"],\n\t...nextValidatedSpreadOperatorIfPresent<s, next>,\n\tnextValidatedElement<s, next>\n]\n\ntype nextValidatedSpreadOperatorIfPresent<\n\ts extends SequenceParseState,\n\tnext extends PreparsedElement\n> =\n\tnext[\"spread\"] extends true ?\n\t\t[\n\t\t\tnext[\"inferred\"] extends infer spreadOperand extends array ?\n\t\t\t\t// if the spread operand is a fixed-length tuple, it won't be a variadic element\n\t\t\t\t// and therefore doesn't need to be validated as one\n\t\t\t\t// there are some edge cases around spreads like `[string?, ...[number?]]` which should\n\t\t\t\t// result in a type error but currently don't. TS also doesn't handle those,\n\t\t\t\t// but would be nice to have at some point regardless.\n\t\t\t\t[number, number] extends (\n\t\t\t\t\t[s[\"inferred\"][\"length\"], spreadOperand[\"length\"]]\n\t\t\t\t) ?\n\t\t\t\t\tErrorMessage<multipleVariadicMessage>\n\t\t\t\t:\t\"...\"\n\t\t\t:\tErrorMessage<writeNonArraySpreadMessage<next[\"head\"]>>\n\t\t]\n\t:\t[]\n\ntype nextValidatedElement<\n\ts extends SequenceParseState,\n\tnext extends PreparsedElement\n> =\n\tnext[\"kind\"] extends SequencePhase.optionals ?\n\t\tnext[\"spread\"] extends true ? ErrorMessage<spreadOptionalMessage>\n\t\t: s[\"phase\"] extends SequencePhase.postfix ?\n\t\t\tErrorMessage<optionalOrDefaultableAfterVariadicMessage>\n\t\t:\tnext[\"validated\"]\n\t: next[\"kind\"] extends SequencePhase.defaultables ?\n\t\tnext[\"spread\"] extends true ? ErrorMessage<spreadDefaultableMessage>\n\t\t: s[\"phase\"] extends SequencePhase.optionals ?\n\t\t\tErrorMessage<defaultablePostOptionalMessage>\n\t\t: s[\"phase\"] extends SequencePhase.postfix ?\n\t\t\tErrorMessage<optionalOrDefaultableAfterVariadicMessage>\n\t\t:\tnext[\"validated\"]\n\t: [s[\"phase\"], next[\"spread\"]] extends (\n\t\t[SequencePhase.optionals | SequencePhase.defaultables, false]\n\t) ?\n\t\tErrorMessage<postfixAfterOptionalOrDefaultableMessage>\n\t:\tnext[\"validated\"]\n\nexport const writeNonArraySpreadMessage = <operand extends string>(\n\toperand: operand\n): writeNonArraySpreadMessage<operand> =>\n\t`Spread element must be an array (was ${operand})` as never\n\ntype writeNonArraySpreadMessage<operand> =\n\t`Spread element must be an array${operand extends string ? ` (was ${operand})`\n\t:\t\"\"}`\n\nexport const multipleVariadicMesage =\n\t\"A tuple may have at most one variadic element\"\n\ntype multipleVariadicMessage = typeof multipleVariadicMesage\n\nexport const requiredPostOptionalMessage =\n\t\"A required element may not follow an optional element\"\n\ntype requiredPostOptionalMessage = typeof requiredPostOptionalMessage\n\nexport const optionalOrDefaultableAfterVariadicMessage =\n\t\"An optional element may not follow a variadic element\"\n\ntype optionalOrDefaultableAfterVariadicMessage =\n\ttypeof optionalOrDefaultableAfterVariadicMessage\n\nexport const spreadOptionalMessage = \"A spread element cannot be optional\"\n\ntype spreadOptionalMessage = typeof spreadOptionalMessage\n\nexport const spreadDefaultableMessage = \"A spread element cannot have a default\"\n\ntype spreadDefaultableMessage = typeof spreadDefaultableMessage\n\nexport const defaultablePostOptionalMessage =\n\t\"A defaultable element may not follow an optional element without a default\"\n\ntype defaultablePostOptionalMessage = typeof defaultablePostOptionalMessage\n"
  },
  {
    "path": "ark/type/scope.ts",
    "content": "import {\n\t$ark,\n\tBaseScope,\n\thasArkKind,\n\tparseGeneric,\n\ttype AliasDefEntry,\n\ttype ArkSchemaRegistry,\n\ttype ArkSchemaScopeConfig,\n\ttype BaseNode,\n\ttype BaseParseContext,\n\ttype BaseParseContextInput,\n\ttype BaseParseOptions,\n\ttype BaseRoot,\n\ttype GenericAst,\n\ttype GenericParamAst,\n\ttype GenericParamDef,\n\ttype GenericRoot,\n\ttype Morph,\n\ttype NodeKind,\n\ttype NodeSchema,\n\ttype PreparsedNodeResolution,\n\ttype PrivateDeclaration,\n\ttype RootKind,\n\ttype RootSchema,\n\ttype arkKind,\n\ttype exportedNameOf,\n\ttype nodeOfKind,\n\ttype reducibleKindOf,\n\ttype toInternalScope,\n\ttype writeDuplicateAliasError\n} from \"@ark/schema\"\nimport {\n\tScanner,\n\tenumValues,\n\tflatMorph,\n\tisArray,\n\tisThunk,\n\tthrowParseError,\n\ttype Brand,\n\ttype Dict,\n\ttype ErrorType,\n\ttype JsonStructure,\n\ttype anyOrNever,\n\ttype array,\n\ttype flattenListable,\n\ttype noSuggest\n} from \"@ark/util\"\nimport type { DeclarationParser } from \"./declare.ts\"\nimport { InternalFnParser, type FnParser } from \"./fn.ts\"\nimport {\n\tparseGenericParamName,\n\ttype GenericDeclaration,\n\ttype GenericParser,\n\ttype ParameterString,\n\ttype baseGenericConstraints,\n\ttype parseGenericParams,\n\ttype parseValidGenericParams\n} from \"./generic.ts\"\nimport type { Ark, type } from \"./keywords/keywords.ts\"\nimport { InternalMatchParser, type MatchParser } from \"./match.ts\"\nimport type {\n\tBoundModule,\n\tModule,\n\tSubmodule,\n\texportScope,\n\tinstantiateExport\n} from \"./module.ts\"\nimport type {\n\tNaryIntersectionParser,\n\tNaryMergeParser,\n\tNaryPipeParser,\n\tNaryUnionParser\n} from \"./nary.ts\"\nimport type { DefAst, InferredAst } from \"./parser/ast/infer.ts\"\nimport {\n\tshallowDefaultableMessage,\n\tshallowOptionalMessage\n} from \"./parser/ast/validate.ts\"\nimport {\n\tparseInnerDefinition,\n\ttype inferDefinition\n} from \"./parser/definition.ts\"\nimport type { ParsedOptionalProperty } from \"./parser/property.ts\"\nimport type { ParsedDefaultableProperty } from \"./parser/shift/operator/default.ts\"\nimport type { TupleExpression } from \"./parser/tupleExpressions.ts\"\nimport {\n\tInternalTypeParser,\n\ttype DefinitionParser,\n\ttype EnumeratedTypeParser,\n\ttype InstanceOfTypeParser,\n\ttype SchemaParser,\n\ttype TypeParser,\n\ttype UnitTypeParser,\n\ttype ValueOfTypeParser\n} from \"./type.ts\"\n\n/** The convenience properties attached to `scope` */\nexport type ScopeParserAttachments =\n\t// map over to remove call signatures\n\tOmit<ScopeParser, never>\n\nexport interface ArkScopeConfig extends ArkSchemaScopeConfig {}\n\nexport interface ScopeParser {\n\t<const def>(\n\t\tdef: scope.validate<def>,\n\t\tconfig?: ArkScopeConfig\n\t): Scope<scope.infer<def>>\n\n\tdefine: <const def>(def: scope.validate<def>) => def\n}\n\nexport type ModuleParser = <const def>(\n\tdef: scope.validate<def>,\n\tconfig?: ArkScopeConfig\n) => scope.infer<def> extends infer $ ?\n\tModule<{ [k in exportedNameOf<$>]: $[k] }>\n:\tnever\n\nexport type bindThis<def> = { this: Def<def> }\n\n/** nominal type for an unparsed definition used during scope bootstrapping */\ntype Def<def = {}> = Brand<def, \"unparsed\">\n\n/** sentinel indicating a scope that will be associated with a generic has not yet been parsed */\nexport type UnparsedScope = \"$\"\n\n/** These are legal as values of a scope but not as definitions in other contexts */\ntype PreparsedResolution = PreparsedNodeResolution\n\ntype bootstrapAliases<def> = {\n\t[k in Exclude<keyof def, GenericDeclaration>]: def[k] extends (\n\t\tPreparsedResolution\n\t) ?\n\t\tdef[k] extends { t: infer g extends GenericAst } ? g\n\t\t: def[k] extends Module<infer $> | BoundModule<infer $, any> ? Submodule<$>\n\t\t: def[k]\n\t: def[k] extends (() => infer thunkReturn extends PreparsedResolution) ?\n\t\tthunkReturn extends { t: infer g extends GenericAst } ? g\n\t\t: thunkReturn extends Module<infer $> | BoundModule<infer $, any> ?\n\t\t\tSubmodule<$>\n\t\t:\tthunkReturn\n\t:\tDef<def[k]>\n} & {\n\t[k in keyof def & GenericDeclaration as extractGenericName<k>]: GenericAst<\n\t\tparseValidGenericParams<extractGenericParameters<k>, bootstrapAliases<def>>,\n\t\tdef[k],\n\t\tUnparsedScope\n\t>\n}\n\ntype inferBootstrapped<$> = {\n\t[name in keyof $]: $[name] extends Def<infer def> ?\n\t\tinferDefinition<def, $, {}>\n\t: $[name] extends { t: infer g extends GenericAst } ? bindGenericToScope<g, $>\n\t: // should be submodule\n\t\t$[name]\n} & unknown\n\nexport type bindGenericToScope<g extends GenericAst, $> = GenericAst<\n\tg[\"paramsAst\"],\n\tg[\"bodyDef\"],\n\tg[\"$\"] extends UnparsedScope ? $ : g[\"$\"],\n\t$\n>\n\ntype extractGenericName<k> =\n\tk extends GenericDeclaration<infer name> ? name : never\n\ntype extractGenericParameters<k> =\n\t// using extends GenericDeclaration<string, infer params>\n\t// causes TS fail to infer a narrowed result as of 5.5\n\tk extends `${string}<${infer params}>` ? ParameterString<params> : never\n\nexport type resolutionToAst<alias extends string, resolution> =\n\t[resolution] extends [anyOrNever] ? InferredAst<resolution, alias>\n\t: resolution extends Def<infer def> ? DefAst<def, alias>\n\t: resolution extends { [arkKind]: \"module\"; root: infer root } ?\n\t\tInferredAst<root, alias>\n\t: resolution extends GenericAst ? resolution\n\t: InferredAst<resolution, alias>\n\nexport type moduleKeyOf<$> = {\n\t[k in keyof $]: $[k] extends { [arkKind]: \"module\" } ?\n\t\t[$[k]] extends [anyOrNever] ?\n\t\t\tnever\n\t\t:\tk & string\n\t:\tnever\n}[keyof $]\n\nexport interface ArkTypeRegistry extends ArkSchemaRegistry {\n\ttypeAttachments?: Ark.boundTypeAttachments<any>\n\tambient: exportScope<Ark>\n}\n\nexport const $arkTypeRegistry: ArkTypeRegistry = $ark as never\n\nexport interface InternalScope {\n\tconstructor: typeof InternalScope\n}\n\nexport class InternalScope<$ extends {} = {}> extends BaseScope<$> {\n\tget ambientAttachments(): Ark.boundTypeAttachments<$> | undefined {\n\t\tif (!$arkTypeRegistry.typeAttachments) return\n\t\treturn this.cacheGetter(\n\t\t\t\"ambientAttachments\",\n\t\t\tflatMorph($arkTypeRegistry.typeAttachments, (k, v) => [\n\t\t\t\tk,\n\t\t\t\tthis.bindReference(v as {} as BaseRoot | GenericRoot)\n\t\t\t]) as never\n\t\t)\n\t}\n\n\tprotected preparseOwnAliasEntry(alias: string, def: unknown): AliasDefEntry {\n\t\tconst firstParamIndex = alias.indexOf(\"<\")\n\t\tif (firstParamIndex === -1) {\n\t\t\tif (hasArkKind(def, \"module\") || hasArkKind(def, \"generic\"))\n\t\t\t\treturn [alias, def]\n\n\t\t\tconst qualifiedName =\n\t\t\t\tthis.name === \"ark\" ? alias\n\t\t\t\t: alias === \"root\" ? this.name\n\t\t\t\t: `${this.name}.${alias}`\n\n\t\t\tconst config = this.resolvedConfig.keywords?.[qualifiedName]\n\n\t\t\tif (config) def = [def, \"@\", config] satisfies TupleExpression\n\n\t\t\treturn [alias, def]\n\t\t}\n\n\t\tif (alias[alias.length - 1] !== \">\") {\n\t\t\tthrowParseError(\n\t\t\t\t`'>' must be the last character of a generic declaration in a scope`\n\t\t\t)\n\t\t}\n\n\t\tconst name = alias.slice(0, firstParamIndex)\n\t\tconst paramString = alias.slice(firstParamIndex + 1, -1)\n\n\t\treturn [\n\t\t\tname,\n\t\t\t// use a thunk definition for the generic so that we can parse\n\t\t\t// constraints within the current scope\n\t\t\t() => {\n\t\t\t\tconst params = this.parseGenericParams(paramString, { alias: name })\n\n\t\t\t\tconst generic = parseGeneric(params, def, this as never)\n\n\t\t\t\treturn generic\n\t\t\t}\n\t\t]\n\t}\n\n\tparseGenericParams(\n\t\tdef: string,\n\t\topts: BaseParseOptions\n\t): array<GenericParamDef> {\n\t\treturn parseGenericParamName(\n\t\t\tnew Scanner(def),\n\t\t\t[],\n\t\t\tthis.createParseContext({\n\t\t\t\t...opts,\n\t\t\t\tdef,\n\t\t\t\tprefix: \"generic\"\n\t\t\t})\n\t\t)\n\t}\n\n\tprotected normalizeRootScopeValue(resolution: unknown): unknown {\n\t\tif (isThunk(resolution) && !hasArkKind(resolution, \"generic\"))\n\t\t\treturn resolution()\n\t\treturn resolution\n\t}\n\n\tprotected preparseOwnDefinitionFormat(\n\t\tdef: unknown,\n\t\topts: BaseParseOptions\n\t): BaseRoot | BaseParseContextInput {\n\t\treturn {\n\t\t\t...opts,\n\t\t\tdef,\n\t\t\tprefix: opts.alias ?? \"type\"\n\t\t}\n\t}\n\n\tparseOwnDefinitionFormat(def: unknown, ctx: BaseParseContext): BaseRoot {\n\t\tconst isScopeAlias = ctx.alias && ctx.alias in this.aliases\n\n\t\t// if the definition being parsed is not a scope alias and is not a\n\t\t// generic instantiation (i.e. opts don't include args), add `this` as a resolution.\n\n\t\t// if we're parsing a nested string, ctx.args will have already been set\n\t\tif (!isScopeAlias && !ctx.args) ctx.args = { this: ctx.id }\n\n\t\tconst result = parseInnerDefinition(def, ctx)\n\n\t\tif (isArray(result)) {\n\t\t\tif (result[1] === \"=\") return throwParseError(shallowDefaultableMessage)\n\n\t\t\tif (result[1] === \"?\") return throwParseError(shallowOptionalMessage)\n\t\t}\n\n\t\treturn result\n\t}\n\n\tunit: UnitTypeParser<$> = value => this.units([value]) as never\n\n\tvalueOf: ValueOfTypeParser<$> = tsEnum =>\n\t\tthis.units(enumValues(tsEnum)) as never\n\n\tenumerated: EnumeratedTypeParser<$> = (...values) =>\n\t\tthis.units(values) as never\n\n\tinstanceOf: InstanceOfTypeParser<$> = ctor =>\n\t\tthis.node(\"proto\", { proto: ctor }, { prereduced: true }) as never\n\n\tor: NaryUnionParser<$> = (...defs: unknown[]) =>\n\t\tthis.schema(defs.map(def => this.parse(def))) as never\n\n\tand: NaryIntersectionParser<$> = (...defs: unknown[]) =>\n\t\tdefs.reduce<BaseRoot>(\n\t\t\t(node, def) => node.and(this.parse(def)),\n\t\t\tthis.intrinsic.unknown\n\t\t) as never\n\n\tmerge: NaryMergeParser<$> = (...defs: unknown[]) =>\n\t\tdefs.reduce<BaseRoot>(\n\t\t\t(node, def) => node.merge(this.parse(def)),\n\t\t\tthis.intrinsic.object\n\t\t) as never\n\n\tpipe: NaryPipeParser<$> = (...morphs: Morph[]) =>\n\t\tthis.intrinsic.unknown.pipe(...morphs) as never\n\n\tfn: InternalFnParser = new InternalFnParser(this as never)\n\tmatch: InternalMatchParser = new InternalMatchParser(this as never)\n\n\tdeclare = (): { type: InternalTypeParser } => ({\n\t\ttype: this.type\n\t})\n\n\tdefine<def>(def: def): def {\n\t\treturn def\n\t}\n\n\ttype: InternalTypeParser = new InternalTypeParser(this as never)\n\n\tstatic scope: ScopeParser = ((def: Dict, config: ArkScopeConfig = {}) =>\n\t\tnew InternalScope(def, config)) as never\n\n\tstatic module: ModuleParser = ((def: Dict, config: ArkScopeConfig = {}) =>\n\t\tthis.scope(def as never, config).export()) as never\n}\n\nexport const scope: ScopeParser = Object.assign(InternalScope.scope, {\n\tdefine: (def: unknown) => def as never\n} satisfies ScopeParserAttachments)\n\nexport declare namespace scope {\n\texport type validate<def> = {\n\t\t[k in keyof def]: k extends noSuggest ?\n\t\t\t// avoid trying to parse meta keys when spreading modules\n\t\t\tunknown\n\t\t: parseScopeKey<k, def>[\"params\"] extends infer params ?\n\t\t\tparams extends array<GenericParamAst> ?\n\t\t\t\tparams[\"length\"] extends 0 ?\n\t\t\t\t\t// not including Type here directly breaks some cyclic tests (last checked w/ TS 5.5).\n\t\t\t\t\t// if you are from the future with a better version of TS and can remove it\n\t\t\t\t\t// without breaking `pnpm typecheck`, go for it.\n\t\t\t\t\tdef[k] extends type.Any | PreparsedResolution ? def[k]\n\t\t\t\t\t: k extends (\n\t\t\t\t\t\tPrivateDeclaration<infer name extends keyof def & string>\n\t\t\t\t\t) ?\n\t\t\t\t\t\tErrorType<writeDuplicateAliasError<name>>\n\t\t\t\t\t:\ttype.validate<def[k], bootstrapAliases<def>, {}>\n\t\t\t\t:\ttype.validate<\n\t\t\t\t\t\tdef[k],\n\t\t\t\t\t\tbootstrapAliases<def>,\n\t\t\t\t\t\tbaseGenericConstraints<params>\n\t\t\t\t\t>\n\t\t\t:\t// if we get here, the params failed to parse- return the error\n\t\t\t\tparams\n\t\t:\tnever\n\t}\n\n\texport type infer<def> = inferBootstrapped<bootstrapAliases<def>>\n}\n\nexport interface Scope<$ = {}> {\n\tt: $\n\t[arkKind]: \"scope\"\n\tconfig: ArkScopeConfig\n\treferences: readonly BaseNode[]\n\tjson: JsonStructure\n\texportedNames: array<exportedNameOf<$>>\n\n\t/** The set of names defined at the root-level of the scope mapped to their\n\t * corresponding definitions.**/\n\taliases: Record<string, unknown>\n\tinternal: toInternalScope<$>\n\n\tdefineSchema<const def extends RootSchema>(schema: def): def\n\n\tnode<kinds extends NodeKind | array<RootKind>>(\n\t\tkinds: kinds,\n\t\tschema: NodeSchema<flattenListable<kinds>>,\n\t\topts?: BaseParseOptions\n\t): nodeOfKind<reducibleKindOf<flattenListable<kinds>>>\n\n\tunit: UnitTypeParser<$>\n\tenumerated: EnumeratedTypeParser<$>\n\tvalueOf: ValueOfTypeParser<$>\n\tinstanceOf: InstanceOfTypeParser<$>\n\n\ttype: TypeParser<$>\n\n\tmatch: MatchParser<$>\n\n\tfn: FnParser<$>\n\n\tdeclare: DeclarationParser<$>\n\n\tdefine: DefinitionParser<$>\n\n\tgeneric: GenericParser<$>\n\n\tschema: SchemaParser<$>\n\n\timport(): Module<{ [k in exportedNameOf<$> as PrivateDeclaration<k>]: $[k] }>\n\timport<names extends exportedNameOf<$>[]>(\n\t\t...names: names\n\t): BoundModule<\n\t\t{\n\t\t\t[k in names[number] as PrivateDeclaration<k>]: $[k]\n\t\t} & unknown,\n\t\t$\n\t>\n\n\texport(): Module<{ [k in exportedNameOf<$>]: $[k] }>\n\texport<names extends exportedNameOf<$>[]>(\n\t\t...names: names\n\t): BoundModule<\n\t\t{\n\t\t\t[k in names[number]]: $[k]\n\t\t} & unknown,\n\t\t$\n\t>\n\n\tresolve<name extends exportedNameOf<$>>(\n\t\tname: name\n\t): instantiateExport<$[name], $>\n}\n\nexport interface ScopeConstructor {\n\tnew <$ = {}>(...args: ConstructorParameters<typeof InternalScope>): Scope<$>\n\tscope: ScopeParser\n\tmodule: ModuleParser\n}\n\nexport const Scope: ScopeConstructor = InternalScope as never\n\nexport type parseScopeKey<k, def> =\n\t// trying to infer against GenericDeclaration here directly also fails as of TS 5.5\n\tk extends `${infer name}<${infer params}>` ?\n\t\tparseGenericScopeKey<name, params, def>\n\t:\t{\n\t\t\tname: k\n\t\t\tparams: []\n\t\t}\n\ntype parseGenericScopeKey<name extends string, params extends string, def> = {\n\tname: name\n\tparams: parseGenericParams<params, bootstrapAliases<def>>\n}\n\nexport type InnerParseResult =\n\t| BaseRoot\n\t| ParsedOptionalProperty\n\t| ParsedDefaultableProperty\n"
  },
  {
    "path": "ark/type/type.ts",
    "content": "import {\n\tArkErrors,\n\tBaseRoot,\n\tGenericRoot,\n\ttype BaseParseOptions,\n\ttype Morph,\n\ttype NodeSelector,\n\ttype Predicate,\n\ttype RootSchema,\n\ttype TypeMeta\n} from \"@ark/schema\"\nimport {\n\tCallable,\n\tHkt,\n\ttype Constructor,\n\ttype array,\n\ttype conform\n} from \"@ark/util\"\nimport type { distill } from \"./attributes.ts\"\nimport type { DeclarationParser } from \"./declare.ts\"\nimport type { FnParser } from \"./fn.ts\"\nimport type {\n\tGeneric,\n\tGenericParser,\n\tParameterString,\n\tbaseGenericConstraints,\n\tparseValidGenericParams,\n\tvalidateParameterString\n} from \"./generic.ts\"\nimport type { Ark, keywords, type } from \"./keywords/keywords.ts\"\nimport type { MatchParser } from \"./match.ts\"\nimport type {\n\tNaryIntersectionParser,\n\tNaryMergeParser,\n\tNaryPipeParser,\n\tNaryUnionParser\n} from \"./nary.ts\"\nimport type {\n\tArgTwoOperator,\n\tIndexZeroOperator,\n\tTupleInfixOperator\n} from \"./parser/tupleExpressions.ts\"\nimport type {\n\tInternalScope,\n\tModuleParser,\n\tScope,\n\tScopeParser\n} from \"./scope.ts\"\nimport type { BaseType } from \"./variants/base.ts\"\nimport type { instantiateType } from \"./variants/instantiate.ts\"\n\n/** The convenience properties attached to `type` */\nexport type TypeParserAttachments =\n\t// map over to remove call signatures\n\tOmit<TypeParser, never>\n\nexport interface TypeParser<$ = {}> extends Ark.boundTypeAttachments<$> {\n\t/**\n\t * Create a {@link Type} from your definition.\n\t *\n\t * @example const Person = type({ name: \"string\" })\n\t */\n\t<const def, r = type.instantiate<def, $>>(\n\t\t// Parse and check the definition, returning either the original input for a\n\t\t// valid definition or a string representing an error message.\n\t\tdef: type.validate<def, $>\n\t): r extends infer _ ? _ : never\n\n\t/**\n\t * Create a {@link Generic} from a parameter string and body definition.\n\t *\n\t * @param params A string like \"<t, n extends number>\" specifying the\n\t * {@link Generic}'s parameters and any associated constraints via `extends`.\n\t *\n\t * @param def The definition for the body of the {@link Generic}. Can reference the\n\t * parameter names specified in the previous argument in addition to aliases\n\t * from its {@link Scope}.\n\t *\n\t * @example const BoxOf = type(\"<t extends string | number>\", { contents: \"t\" })\n\t */\n\t<\n\t\tconst params extends ParameterString,\n\t\tconst def,\n\t\tr = Generic<parseValidGenericParams<params, $>, def, $>\n\t>(\n\t\tparams: validateParameterString<params, $>,\n\t\tdef: type.validate<\n\t\t\tdef,\n\t\t\t$,\n\t\t\tbaseGenericConstraints<parseValidGenericParams<params, $>>\n\t\t>\n\t): r extends infer _ ? _ : never\n\n\t/**\n\t * Create a {@link Type} from a [tuple expression](http://localhost:3000/docs/expressions)\n\t * spread as this function's arguments.\n\t *\n\t * @example type(\"string\", \"|\", { foo: \"number\" })\n\t */\n\t<\n\t\tconst zero,\n\t\tconst one,\n\t\tconst rest extends array,\n\t\tr = type.instantiate<[zero, one, ...rest], $>\n\t>(\n\t\t_0: zero extends IndexZeroOperator ? zero : type.validate<zero, $>,\n\t\t_1: zero extends \"keyof\" ? type.validate<one, $>\n\t\t: zero extends \"instanceof\" ? conform<one, Constructor>\n\t\t: zero extends \"===\" ? conform<one, unknown>\n\t\t: conform<one, ArgTwoOperator>,\n\t\t..._2: zero extends \"===\" ? rest\n\t\t: zero extends \"instanceof\" ? conform<rest, readonly Constructor[]>\n\t\t: one extends TupleInfixOperator ?\n\t\t\tone extends \":\" ? [Predicate<distill.In<type.infer<zero, $>>>]\n\t\t\t: one extends \"=>\" ? [Morph<distill.Out<type.infer<zero, $>>, unknown>]\n\t\t\t: one extends \"|>\" ? [type.validate<rest[0], $>]\n\t\t\t: one extends \"@\" ? [TypeMeta.MappableInput, NodeSelector?]\n\t\t\t: [type.validate<rest[0], $>]\n\t\t:\t[]\n\t): r extends infer _ ? _ : never\n\n\t/**\n\t * An alias of the {@link ArkErrors} class, an instance of which is returned when a {@link Type}\n\t * is invoked with invalid input.\n\t *\n\t * @example\n\t * const out = myType(data)\n\t *\n\t * if(out instanceof type.errors) console.log(out.summary)\n\t */\n\terrors: typeof ArkErrors\n\thkt: typeof Hkt\n\tkeywords: typeof keywords\n\t/**\n\t * The {@link Scope} in which definitions passed to this function will be parsed.\n\t */\n\t$: Scope<$>\n\t/**\n\t * An alias of `type` with no type-level validation or inference.\n\t *\n\t * Useful when wrapping `type` or using it to parse a dynamic definition.\n\t */\n\traw(def: unknown): BaseType<any, $>\n\tmodule: ModuleParser\n\tscope: ScopeParser\n\tdefine: DefinitionParser<$>\n\tdeclare: DeclarationParser<$>\n\tgeneric: GenericParser<$>\n\tmatch: MatchParser<$>\n\tschema: SchemaParser<$>\n\t/**\n\t * Create a {@link Type} that is satisfied only by a value strictly equal (`===`) to the argument passed to this function.\n\t * @example const foo = type.unit('foo') // {@link Type}<'foo'>\n\t * @example const sym: unique symbol = Symbol(); type.unit(sym) // {@link Type}<typeof sym>\n\t */\n\tunit: UnitTypeParser<$>\n\t/**\n\t * Create a {@link Type} that is satisfied only by a value strictly equal (`===`) to one of the arguments passed to this function.\n\t * @example const enum = type.enumerated('foo', 'bar', obj) // obj is a by-reference object\n\t * @example const TupleForm = type(['===', 'foo', 'bar', obj])\n\t * @example const ArgsForm = type('===', 'foo', 'bar', obj)\n\t */\n\tenumerated: EnumeratedTypeParser<$>\n\t/**\n\t * Create a {@link Type} that is satisfied only by one of the Object.values() of the argument passed to this function.\n\t *\n\t * ⚠️ For TypeScript enum compatibility, values at numeric keys with corresponding numeric values will not be included.\n\t * @example const myEnum = type.valueOf(myTsEnum)\n\t */\n\tvalueOf: ValueOfTypeParser<$>\n\t/**\n\t * Create a {@link Type} that is satisfied only by a value of a specific class.\n\t * @example const array = type.instanceOf(Array)\n\t */\n\tinstanceOf: InstanceOfTypeParser<$>\n\t/**\n\t * Create a {@link Type} from a union of definitions\n\t * @example const T = type.or(\"string\", \"number\")\n\t */\n\tor: NaryUnionParser<$>\n\t/**\n\t * Create a {@link Type} from an intersection of definitions\n\t * @example const T = type.and({ a: \"1\" }, { b: \"2\" })\n\t */\n\tand: NaryIntersectionParser<$>\n\t/**\n\t * Create a {@link Type} by merging object definitions, with later\n\t * definitions having precedence for overlapping keys\n\t * @example\n\t * // Type<{ a: \"3\", b: \"2\", c: \"4\" }>\n\t * const T = type.merge({ a: \"1\", b: \"2\" }, { a: \"3\", c: \"4\" })\n\t */\n\tmerge: NaryMergeParser<$>\n\t/**\n\t * Create a {@link Type} from a set of morphs (including Types)\n\t * @example\n\t * // Type<(In: string) => To<object>>\n\t * const T = type.pipe(type.string, s => JSON.parse(s), type.object)\n\t */\n\tpipe: NaryPipeParser<$>\n\t/**\n\t * Define a validated function\n\t * @example\n\t * const len = type.fn(\"string | unknown[]\", \":\", \"number\")(s => s.length)\n\t * len(\"foo\") // 3\n\t * // TypeScript: boolean is not assignable to string | unknown[]\n\t * // Runtime (throws): must be a string or an object (was boolean)\n\t * len(true)\n\t */\n\tfn: FnParser<$>\n}\n\nexport class InternalTypeParser extends Callable<\n\t(...args: unknown[]) => BaseRoot | Generic,\n\tTypeParserAttachments\n> {\n\tconstructor($: InternalScope) {\n\t\tconst attach: TypeParserAttachments = Object.assign(\n\t\t\t{\n\t\t\t\terrors: ArkErrors,\n\t\t\t\thkt: Hkt,\n\t\t\t\t$: $ as never,\n\t\t\t\traw: $.parse as never,\n\t\t\t\tmodule: $.constructor.module,\n\t\t\t\tscope: $.constructor.scope,\n\t\t\t\tdeclare: $.declare as never,\n\t\t\t\tdefine: $.define as never,\n\t\t\t\tmatch: $.match as never,\n\t\t\t\tgeneric: $.generic as never,\n\t\t\t\tschema: $.schema as never,\n\t\t\t\t// this won't be defined during bootstrapping, but externally always will be\n\t\t\t\tkeywords: $.ambient as never,\n\t\t\t\tunit: $.unit,\n\t\t\t\tenumerated: $.enumerated,\n\t\t\t\tinstanceOf: $.instanceOf,\n\t\t\t\tvalueOf: $.valueOf,\n\t\t\t\tor: $.or,\n\t\t\t\tand: $.and,\n\t\t\t\tmerge: $.merge,\n\t\t\t\tpipe: $.pipe,\n\t\t\t\tfn: $.fn as never\n\t\t\t} satisfies Omit<TypeParserAttachments, keyof Ark.typeAttachments>,\n\t\t\t// also won't be defined during bootstrapping\n\t\t\t$.ambientAttachments!\n\t\t)\n\t\tsuper(\n\t\t\t(...args) => {\n\t\t\t\tif (args.length === 1) {\n\t\t\t\t\t// treat as a simple definition\n\t\t\t\t\treturn $.parse(args[0])\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\targs.length === 2 &&\n\t\t\t\t\ttypeof args[0] === \"string\" &&\n\t\t\t\t\targs[0][0] === \"<\" &&\n\t\t\t\t\targs[0][args[0].length - 1] === \">\"\n\t\t\t\t) {\n\t\t\t\t\t// if there are exactly two args, the first of which looks like <${string}>,\n\t\t\t\t\t// treat as a generic\n\t\t\t\t\tconst paramString = args[0].slice(1, -1)\n\t\t\t\t\tconst params = $.parseGenericParams(paramString, {})\n\n\t\t\t\t\treturn new GenericRoot(\n\t\t\t\t\t\tparams,\n\t\t\t\t\t\targs[1],\n\t\t\t\t\t\t$ as never,\n\t\t\t\t\t\t$ as never,\n\t\t\t\t\t\tnull\n\t\t\t\t\t) as never\n\t\t\t\t}\n\t\t\t\t// otherwise, treat as a tuple expression. technically, this also allows\n\t\t\t\t// non-expression tuple definitions to be parsed, but it's not a supported\n\t\t\t\t// part of the API as specified by the associated types\n\t\t\t\treturn $.parse(args)\n\t\t\t},\n\t\t\t{\n\t\t\t\tattach\n\t\t\t}\n\t\t)\n\t}\n}\n\nexport type UnitTypeParser<$> = <const t>(value: t) => Type<t, $>\n\nexport type InstanceOfTypeParser<$> = <const t extends object>(\n\tctor: Constructor<t>\n) => Type<t, $>\n\nexport type EnumeratedTypeParser<$> = <const values extends readonly unknown[]>(\n\t...values: values\n) => Type<values[number], $>\n\nexport type ValueOfTypeParser<$> = <const o extends object>(\n\to: o\n) => Type<o[keyof o], $>\n\nexport type DefinitionParser<$> = <const def>(def: type.validate<def, $>) => def\n\nexport type SchemaParser<$> = (\n\tschema: RootSchema,\n\topts?: BaseParseOptions\n) => Type<unknown, $>\n\nexport type Type<t = unknown, $ = {}> = instantiateType<t, $>\n\nexport type TypeConstructor<t = unknown, $ = {}> = new (\n\tdef: unknown,\n\t$: Scope<$>\n) => Type<t, $>\n\nexport const Type: TypeConstructor = BaseRoot as never\n"
  },
  {
    "path": "ark/type/variants/array.ts",
    "content": "import type {\n\tExactLength,\n\tExclusiveNumericRangeSchema,\n\tInclusiveNumericRangeSchema\n} from \"@ark/schema\"\nimport type { ObjectType } from \"./object.ts\"\n\ninterface Type<\n\t/** @ts-ignore cast variance */\n\tout t extends readonly unknown[] = readonly unknown[],\n\t$ = {}\n> extends ObjectType<t, $> {\n\tatLeastLength(schema: InclusiveNumericRangeSchema): this\n\n\tatMostLength(schema: InclusiveNumericRangeSchema): this\n\n\tmoreThanLength(schema: ExclusiveNumericRangeSchema): this\n\n\tlessThanLength(schema: ExclusiveNumericRangeSchema): this\n\n\texactlyLength(schema: ExactLength.Schema): this\n}\n\nexport type { Type as ArrayType }\n"
  },
  {
    "path": "ark/type/variants/base.ts",
    "content": "import type {\n\tBaseNode,\n\tBaseRoot,\n\tDisjoint,\n\tJsonSchema,\n\tNodeSelector,\n\tPredicate,\n\tStandardSchemaV1,\n\tToJsonSchema,\n\tTypeMeta,\n\tUndeclaredKeyBehavior\n} from \"@ark/schema\"\nimport type {\n\tanyOrNever,\n\tarray,\n\tCallable,\n\tErrorMessage,\n\tinferred,\n\tJsonStructure,\n\tunset\n} from \"@ark/util\"\nimport type {\n\tdefaultFor,\n\tdistill,\n\tinferIntersection,\n\tinferPipe,\n\tInferredMorph,\n\tOut,\n\tTo\n} from \"../attributes.ts\"\nimport type { ArkAmbient } from \"../config.ts\"\nimport type { type } from \"../keywords/keywords.ts\"\nimport type { NaryPipeParser } from \"../nary.ts\"\nimport type { Scope } from \"../scope.ts\"\nimport type { ArrayType } from \"./array.ts\"\nimport type { instantiateType } from \"./instantiate.ts\"\n\n/** @ts-ignore cast variance */\nexport interface Inferred<out t = unknown, $ = {}> {\n\tinternal: BaseRoot\n\t[inferred]: t\n\n\t/**\n\t * precompiled JS used to optimize validation\n\t *\n\t * ⚠️ will be `undefined` in [jitless](https://arktype.io/docs/configuration#jitless) mode\n\t */\n\tprecompilation: string | undefined\n\n\t/**\n\t * generic parameter representing this Type\n\t *\n\t * @typeonly\n\t *\n\t * ⚠️ May contain types representing morphs or default values that would\n\t * be inaccurate if used directly for runtime values. In those cases,\n\t * you should use {@link infer} or {@link inferIn} on this object instead.\n\t */\n\tt: t\n\n\t/**\n\t * #### {@link Scope} in which chained methods are parsed\n\t */\n\t$: Scope<$>\n\n\t/**\n\t * #### type of output this returns\n\t *\n\t * @typeonly\n\t *\n\t * @example\n\t * const parseNumber = type(\"string\").pipe(s => Number.parseInt(s))\n\t * type ParsedNumber = typeof parseNumber.infer // number\n\t */\n\tinfer: this[\"inferOut\"]\n\n\t/**\n\t * type of output this returns\n\t *\n\t * 🔗 alias of {@link infer}\n\t * @typeonly\n\t *\n\t *\n\t * @example\n\t * const parseNumber = type(\"string\").pipe(s => Number.parseInt(s))\n\t * type ParsedNumber = typeof parseNumber.infer // number\n\t */\n\tinferOut: distill.Out<t>\n\n\t/**\n\t * type of output that can be introspected at runtime (e.g. via {@link out})\n\t *\n\t * ⚠️ If your Type contains morphs, they will be inferred as `unknown` unless\n\t * they are an ArkType keyword or have an explicitly defined output validator.\n\t *\n\t * @typeonly\n\t *\n\t * @example\n\t * const Unmorphed = type(\"string\")\n\t * // with no morphs, we can introspect the input and output as a single Type\n\t * type UnmorphedOut = typeof Unmorphed.inferIntrospectableOut // string\n\t *\n\t * const Morphed = type(\"string\").pipe(s => s.length)\n\t * // with a standard user-defined morph, TypeScript can infer a\n\t * // return type from your function, but we have no way to\n\t * // know the shape at runtime\n\t * type MorphOut = typeof Morphed.inferIntrospectableOut  // unknown\n\t *\n\t * const Validated = type(\"string\").pipe(s => s.length).to(\"number\")\n\t * // morphs with validated output, including all morph keywords, are introspectable\n\t * type ValidatedMorphOut = typeof Validated.inferIntrospectableOut\n\t */\n\tinferIntrospectableOut: distill.introspectable.Out<t>\n\n\t/**\n\t * #### type of input this allows\n\t *\n\t * @typeonly\n\t *\n\t * @example\n\t * const parseNumber = type(\"string\").pipe(s => Number.parseInt(s))\n\t * type UnparsedNumber = typeof parseNumber.inferIn // string\n\t */\n\tinferIn: distill.In<t>\n\n\t/**\n\t * #### internal JSON representation\n\t */\n\tjson: JsonStructure\n\n\t/**\n\t * alias of {@link json} for `JSON.stringify` compatibility\n\t */\n\ttoJSON(): JsonStructure\n\n\t/**\n\t * #### generate a JSON Schema\n\t *\n\t * @throws {ToJsonSchema.Error} if this cannot be converted to JSON Schema\n\t */\n\ttoJsonSchema(options?: ToJsonSchema.Options): JsonSchema\n\n\t/**\n\t * #### metadata like custom descriptions and error messages\n\t *\n\t * ✅ type {@link https://arktype.io/docs/configuration#custom | can be customized} for your project\n\t */\n\tmeta: ArkAmbient.meta\n\n\t/**\n\t * #### human-readable English description\n\t *\n\t * ✅ works best for primitive values\n\t *\n\t * @example\n\t * const N = type(\"0 < number <= 100\")\n\t * console.log(N.description) // positive and at most 100\n\t */\n\tdescription: string\n\n\t/**\n\t * #### syntax string similar to native TypeScript\n\t *\n\t * ✅ works well for both primitives and structures\n\t *\n\t * @example\n\t * const Loc = type({ coords: [\"number\", \"number\"] })\n\t * console.log(Loc.expression) // { coords: [number, number] }\n\t */\n\texpression: string\n\n\t/**\n\t * #### validate and return transformed data or throw\n\t *\n\t * ✅ sugar to avoid checking for {@link type.errors} if they are unrecoverable\n\t *\n\t * @example\n\t * const CriticalPayload = type({\n\t *     superImportantValue: \"string\"\n\t * })\n\t * // throws TraversalError: superImportantValue must be a string (was missing)\n\t * const data = CriticalPayload.assert({ irrelevantValue: \"whoops\" })\n\t * console.log(data.superImportantValue) // valid output can be accessed directly\n\t *\n\t * @throws {TraversalError}\n\t */\n\tassert: (data: unknown) => this[\"infer\"]\n\n\t/**\n\t * #### check input without applying morphs\n\t *\n\t * ✅ good for stuff like filtering that doesn't benefit from detailed errors\n\t *\n\t * @example\n\t * const Numeric = type(\"number | bigint\")\n\t * // [0, 2n]\n\t * const numerics = [0, \"one\", 2n].filter(Numeric.allows)\n\t */\n\tallows: (data: unknown) => data is this[\"inferIn\"]\n\n\t/**\n\t * #### add metadata to shallow references\n\t *\n\t * ⚠️ does not affect error messages within properties of an object\n\t *\n\t * @example\n\t * const NotOdd = type(\"number % 2\").configure({ description: \"not odd\" })\n\t * // all constraints at the root are affected\n\t * const odd = NotOdd(3) // must be not odd (was 3)\n\t * const nonNumber = NotOdd(\"two\") // must be not odd (was \"two\")\n\t *\n\t * const NotOddBox = type({\n\t *    // we should have referenced notOdd or added meta here\n\t *    notOdd: \"number % 2\",\n\t * // but instead chained from the root object\n\t * }).configure({ description: \"not odd\" })\n\t * // error message at path notOdd is not affected\n\t * const oddProp = NotOddBox({ notOdd: 3 }) // notOdd must be even (was 3)\n\t * // error message at root is affected, leading to a misleading description\n\t * const nonObject = NotOddBox(null) // must be not odd (was null)\n\t */\n\tconfigure: NodeSelector.SelectableFn<TypeMeta.MappableInput, this>\n\n\t/**\n\t * #### add description to shallow references\n\t *\n\t * 🔗 equivalent to `.configure({ description })` (see {@link configure})\n\t * ⚠️ does not affect error messages within properties of an object\n\t *\n\t * @example\n\t * const AToZ = type(/^a.*z$/).describe(\"a string like 'a...z'\")\n\t * const good = AToZ(\"alcatraz\") // \"alcatraz\"\n\t * // ArkErrors: must be a string like 'a...z' (was \"albatross\")\n\t * const badPattern = AToZ(\"albatross\")\n\t */\n\tdescribe: NodeSelector.SelectableFn<string, this>\n\n\t/**\n\t * #### apply undeclared key behavior\n\t *\n\t * {@inheritDoc UndeclaredKeyBehavior}\n\t */\n\tonUndeclaredKey(behavior: UndeclaredKeyBehavior): this\n\n\t/**\n\t * #### deeply apply undeclared key behavior\n\t *\n\t * {@inheritDoc UndeclaredKeyBehavior}\n\t **/\n\tonDeepUndeclaredKey(behavior: UndeclaredKeyBehavior): this\n\n\t/**\n\t * #### alias for {@link assert} with typed input\n\t *\n\t * @example\n\t * const T = type({ foo: \"string\" });\n\t * // TypeScript: foo must be a string (was 5)\n\t * const data = T.from({ foo: 5 });\n\t */\n\tfrom(literal: this[\"inferIn\"]): this[\"infer\"]\n\n\t/**\n\t * #### deeply extract inputs\n\t *\n\t * ✅ will never include morphs\n\t * ✅ good for generating JSON Schema or other non-transforming formats\n\t *\n\t * @example\n\t * const User = type({\n\t *    age: \"string.numeric.parse\"\n\t * })\n\t * // { age: 25 } (age parsed to a number)\n\t * const out = User({ age: \"25\" })\n\t * // { age: \"25\" } (age is still a string)\n\t * const inOut = User.in({ age: \"25\" })\n\t */\n\tget in(): instantiateType<this[\"inferIn\"], $>\n\n\t/**\n\t * #### deeply extract outputs\n\t *\n\t * ✅ will never include morphs\n\t * ⚠️ if your type includes morphs, their output will likely be unknown unless they\n\t * were defined with an explicit output validator via `.to(outputDef)` or `.pipe(morph, outputType)`\n\t *\n\t * @example\n\t * const join = type(\"string[]\").pipe(a => a.join(\",\"))\n\t *\n\t * const T = type({\n\t *    // all keywords have introspectable output\n\t *    keyword: \"string.numeric.parse\",\n\t *    // TypeScript knows this returns a string, but we can't introspect that at runtime\n\t *    unvalidated: join,\n\t *    // if needed, it can be made introspectable with an output validator\n\t *    validated: join.to(\"string\")\n\t * })\n\t *\n\t * // Type<{ keyword: number; unvalidated: unknown; validated: string }>\n\t * const baseOut = base.out\n\t */\n\tget out(): instantiateType<this[\"inferIntrospectableOut\"], $>\n\n\t/**\n\t * #### add a compile-time brand to output\n\t *\n\t * @typenoop\n\t *\n\t * @example\n\t * const Palindrome = type(\"string\")\n\t *     .narrow(s => s === [...s].reverse().join(\"\"))\n\t *     .brand(\"palindrome\")\n\t * // Brand<string, \"palindrome\">\n\t * const out = Palindrome.assert(\"racecar\")\n\t */\n\tbrand<const name extends string, r = instantiateType<type.brand<t, name>, $>>(\n\t\tname: name\n\t): r extends infer _ ? _ : never\n\n\t/**\n\t * #### an array of this\n\t *\n\t * @example\n\t * // Type<{ rebmun: number }[]>\n\t * const T = type({ rebmun: \"number\" }).array();\n\t */\n\tarray(): ArrayType<t[], $>\n\n\t/**\n\t * #### {@link https://arktype.io/docs/objects#properties-optional | optional definition}\n\t *\n\t * @chainedDefinition\n\t *\n\t * @example\n\t * const Prop = type({ foo: \"number\" })\n\t * // Type<{ bar?: { foo: number } }>\n\t * const Obj = type({ bar: Prop.optional() })\n\t */\n\toptional(): [this, \"?\"]\n\n\t/**\n\t * #### {@link https://arktype.io/docs/objects#properties-defaultable | defaultable definition}\n\t *\n\t * ✅ object defaults can be returned from a function\n\t * ⚠️ throws if the default value is not allowed\n\t * @chainedDefinition\n\t *\n\t * @example\n\t * // Type<{ count: Default<number, 0> }>\n\t * const State = type({ count: type.number.default(0) })\n\t * const Prop = type({ nested: \"boolean\" })\n\t * const ForObj = type({\n\t *     key: Prop.default(() => ({ nested: false }))\n\t * })\n\t */\n\tdefault<const value extends defaultFor<this[\"inferIn\"]>>(\n\t\tvalue: value\n\t): [this, \"=\", value]\n\n\t/**\n\t * #### apply a predicate function to input\n\t *\n\t * ⚠️ the behavior of {@link narrow}, this method's output counterpart, is usually more desirable\n\t * ✅ most useful for morphs with input types that are re-used externally\n\t * @predicateCast\n\t *\n\t * @example\n\t * const stringifyUser = type({ name: \"string\" }).pipe(user => JSON.stringify(user))\n\t * const stringifySafe = stringifyUser.filter(user => user.name !== \"Bobby Tables\")\n\t * // Type<(In: `${string}Z`) => To<Date>>\n\t * const WithPredicate = type(\"string.date.parse\").filter((s): s is `${string}Z` =>\n\t *     s.endsWith(\"Z\")\n\t * )\n\t */\n\tfilter<\n\t\tnarrowed extends this[\"inferIn\"] = never,\n\t\tr = instantiateType<\n\t\t\t[narrowed] extends [never] ? t\n\t\t\t: t extends InferredMorph<never, infer o> ? (In: narrowed) => o\n\t\t\t: narrowed,\n\t\t\t$\n\t\t>\n\t>(\n\t\tpredicate: Predicate.Castable<this[\"inferIn\"], narrowed>\n\t): r extends infer _ ? _ : never\n\n\t/**\n\t * #### apply a predicate function to output\n\t *\n\t * ✅ go-to fallback for validation not composable via built-in types and operators\n\t * ✅ runs after all other validators and morphs, if present\n\t * @predicateCast\n\t *\n\t * @example\n\t * const Palindrome = type(\"string\").narrow(s => s === [...s].reverse().join(\"\"))\n\t *\n\t * const PalindromicEmail = type(\"string.date.parse\").narrow((date, ctx) =>\n\t *\t\tdate.getFullYear() === 2025 || ctx.mustBe(\"the current year\")\n\t * )\n\t * // Type<`${string}.tsx`>\n\t * const WithPredicate = type(\"string\").narrow((s): s is `${string}.tsx` => /\\.tsx?$/.test(s))\n\t */\n\tnarrow<\n\t\tnarrowed extends this[\"infer\"] = never,\n\t\tr = instantiateType<\n\t\t\t[narrowed] extends [never] ? t\n\t\t\t: t extends InferredMorph<infer i, infer o> ?\n\t\t\t\to extends To ?\n\t\t\t\t\t(In: i) => To<narrowed>\n\t\t\t\t:\t(In: i) => Out<narrowed>\n\t\t\t:\tnarrowed,\n\t\t\t$\n\t\t>\n\t>(\n\t\tpredicate: Predicate.Castable<this[\"infer\"], narrowed>\n\t): r extends infer _ ? _ : never\n\n\t/**\n\t * #### pipe output through arbitrary transformations or other Types\n\t *\n\t * @example\n\t * const User = type({ name: \"string\" })\n\t *\n\t * // parse a string and validate that the result as a user\n\t * const parseUser = type(\"string\").pipe(s => JSON.parse(s), user)\n\t */\n\tpipe: ChainedPipeParser<$, t>\n\n\t/**\n\t * #### parse a definition as an output validator\n\t *\n\t * 🔗 `to({ name: \"string\" })` is equivalent to `.pipe(type({ name: \"string\" }))`\n\t *\n\t * @example\n\t * // parse a string and validate that the result as a user\n\t * const parseUser = type(\"string\").pipe(s => JSON.parse(s)).to({ name: \"string\" })\n\t */\n\tto<const def, r = instantiateType<inferPipe<t, type.infer<def, $>>, $>>(\n\t\tdef: type.validate<def, $>\n\t): r extends infer _ ? _ : never\n\n\t/**\n\t * #### query internal node references\n\t *\n\t * @experimental filters and returns the Type's internal representation from `@ark/schema`\n\t *\n\t * @example\n\t * // [\"blue\", \"red\"]\n\t * const values = type(\"'red' | 'blue'\").select(\"unit\").map(u => u.unit)\n\t */\n\tselect: BaseNode[\"select\"]\n}\n\n/** @ts-ignore cast variance */\ninterface Type<out t = unknown, $ = {}>\n\textends Callable<(data: unknown) => distill.Out<t> | ArkEnv.onFail>,\n\t\tInferred<t, $> {\n\t/**\n\t * #### cast the way this is inferred\n\t *\n\t * @typenoop\n\t *\n\t * @example\n\t * // Type<`LEEEEEEEE${string}ROY`>\n\t * const Leeroy = type(/^LE{8,}ROY$/).as<`LEEEEEEEE${string}ROY`>()\n\t */\n\tas<castTo = unset>(\n\t\t...args: validateChainedAsArgs<castTo>\n\t): instantiateType<castTo, $>\n\n\t/**\n\t * #### intersect the parsed Type, throwing if the result is unsatisfiable\n\t *\n\t * @example\n\t * // Type<{ foo: number; bar: string }>\n\t * const T = type({ foo: \"number\" }).and({ bar: \"string\" })\n\t * // ParseError: Intersection at foo of number and string results in an unsatisfiable type\n\t * const Bad = type({ foo: \"number\" }).and({ foo: \"string\" })\n\t */\n\tand<\n\t\tconst def,\n\t\tr = instantiateType<inferIntersection<t, type.infer<def, $>>, $>\n\t>(\n\t\tdef: type.validate<def, $>\n\t): r extends infer _ ? _ : never\n\n\t/**\n\t * #### union with the parsed Type\n\t *\n\t * ⚠️ a union that could apply different morphs to the same data is a ParseError ({@link https://arktype.io/docs/expressions#union-morphs | docs})\n\t *\n\t * @example\n\t * // Type<string | { box: string }>\n\t * const T = type(\"string\").or({ box: \"string\" })\n\t */\n\tor<const def, r = instantiateType<t | type.infer<def, $>, $>>(\n\t\tdef: type.validate<def, $>\n\t): r extends infer _ ? _ : never\n\n\t// inferring r into an alias improves perf and avoids return type inference\n\t// that can lead to incorrect results. See:\n\t// https://discord.com/channels/957797212103016458/1285420361415917680/1285545752172429312\n\t/**\n\t * #### intersect the parsed Type, returning an introspectable {@link Disjoint} if the result is unsatisfiable\n\t *\n\t * @example\n\t * // Type<{ foo: number; bar: string }>\n\t * const T = type({ foo: \"number\" }).intersect({ bar: \"string\" })\n\t * const Bad = type(\"number > 10\").intersect(\"number < 5\")\n\t * // logs \"Intersection of > 10 and < 5 results in an unsatisfiable type\"\n\t * if (Bad instanceof Disjoint) console.log(`${bad.summary}`)\n\t */\n\tintersect<\n\t\tconst def,\n\t\tr = instantiateType<inferIntersection<t, type.infer<def, $>>, $>\n\t>(\n\t\tdef: type.validate<def, $>\n\t): r extends infer _ ? _ | Disjoint : never\n\n\t/**\n\t * #### check if the parsed Type's constraints are identical\n\t *\n\t * ✅ equal types have identical input and output constraints and transforms\n\t * @ignoresMeta\n\t *\n\t * @example\n\t * const DivisibleBy6 = type.number.divisibleBy(6).moreThan(0)\n\t * // false (left side must also be positive)\n\t * DivisibleBy6.equals(\"number % 6\")\n\t * // false (right side has an additional <100 constraint)\n\t * console.log(DivisibleBy6.equals(\"0 < (number % 6) < 100\"))\n\t * const ThirdTry = type(\"(number % 2) > 0\").divisibleBy(3)\n\t * // true (types are normalized and reduced)\n\t * console.log(DivisibleBy6.equals(ThirdTry))\n\t */\n\tequals<const def>(def: type.validate<def, $>): boolean\n\n\t/**\n\t * #### narrow this based on an {@link equals} check\n\t *\n\t * @ignoresMeta\n\t *\n\t * @example\n\t * const N = type.raw(`${Math.random()}`)\n\t * // Type<0.5> | undefined\n\t * const Ez = N.ifEquals(\"0.5\")\n\t */\n\tifEquals<const def, r = type.instantiate<def, $>>(\n\t\tdef: type.validate<def, $>\n\t): r extends infer _ ? _ | undefined : never\n\n\t/**\n\t * #### check if this is a subtype of the parsed Type\n\t *\n\t * ✅ a subtype must include all constraints from the base type\n\t * ✅ unlike {@link equals}, additional constraints may be present\n\t * @ignoresMeta\n\t *\n\t * @example\n\t * type.string.extends(\"unknown\") // true\n\t * type.string.extends(/^a.*z$/) // false\n\t */\n\textends<const def>(other: type.validate<def, $>): boolean\n\n\t/**\n\t * #### narrow this based on an {@link extends} check\n\t *\n\t * @ignoresMeta\n\t *\n\t * @example\n\t * const N = type(Math.random() > 0.5 ? \"true\" : \"0\") // Type<0 | true>\n\t * const Ez = N.ifExtends(\"boolean\") // Type<true> | undefined\n\t */\n\tifExtends<const def, r = type.instantiate<def, $>>(\n\t\tother: type.validate<def, $>\n\t): r extends infer _ ? _ | undefined : never\n\n\t/**\n\t * #### check if a value could satisfy this and the parsed Type\n\t *\n\t * ⚠️ will return true unless a {@link Disjoint} can be proven\n\t *\n\t * @example\n\t * type.string.overlaps(\"string | number\") // true (e.g. \"foo\")\n\t * type(\"string | number\").overlaps(\"1\") // true (1)\n\t * type(\"number > 0\").overlaps(\"number < 0\") // false (no values exist)\n\t *\n\t * const NoAt = type(\"string\").narrow(s => !s.includes(\"@\"))\n\t * NoAt.overlaps(\"string.email\") // true (no values exist, but not provable)\n\t */\n\toverlaps<const def>(r: type.validate<def, $>): boolean\n\n\t/**\n\t * #### extract branches {@link extend}ing the parsed Type\n\t *\n\t * @example\n\t * // Type<true | 0 | 2>\n\t * const T = type(\"boolean | 0 | 'one' | 2 | bigint\").extract(\"number | 0n | true\")\n\t */\n\textract<\n\t\tconst def,\n\t\tr = instantiateType<t extends type.infer<def, $> ? t : never, $>\n\t>(\n\t\tr: type.validate<def, $>\n\t): r extends infer _ extends r ? _ : never\n\n\t/**\n\t * #### exclude branches {@link extend}ing the parsed Type\n\t *\n\t * @example\n\t *\n\t * // Type<false | 'one' | bigint>\n\t * const T = type(\"boolean | 0 | 'one' | 2 | bigint\").exclude(\"number | 0n | true\")\n\t */\n\texclude<\n\t\tconst def,\n\t\tr = instantiateType<t extends type.infer<def, $> ? never : t, $>\n\t>(\n\t\tr: type.validate<def, $>\n\t): r extends infer _ ? _ : never\n\n\t/**\n\t * @experimental\n\t * Map and optionally reduce branches of a union. Types that are not unions\n\t * are treated as a single branch.\n\t *\n\t * @param mapBranch - the mapping function, accepting a branch Type\n\t *     Returning another `Type` is common, but any value can be returned and\n\t *     inferred as part of the output.\n\t *\n\t * @param [reduceMapped] - an operation to perform on the mapped branches\n\t *     Can be used to e.g. merge an array of returned Types representing\n\t *     branches back to a single union.\n\t */\n\tdistribute<mapOut, reduceOut = mapOut[]>(\n\t\tmapBranch: (branch: Type, i: number, branches: array<Type>) => mapOut,\n\t\treduceMapped?: (mappedBranches: mapOut[]) => reduceOut\n\t): reduceOut\n\n\t/** The Type's [StandardSchema](https://github.com/standard-schema/standard-schema) properties */\n\t\"~standard\": StandardSchemaV1.ArkTypeProps<\n\t\tthis[\"inferIn\"] extends infer _ ? _ : never,\n\t\tthis[\"inferOut\"] extends infer _ ? _ : never\n\t>\n\n\t// deprecate Function methods so they are deprioritized as suggestions\n\n\t/** @deprecated */\n\tapply: Function[\"apply\"]\n\n\t/** @deprecated */\n\tbind: Function[\"bind\"]\n\n\t/** @deprecated */\n\tcall: Function[\"call\"]\n\n\t/** @deprecated */\n\tcaller: Function\n\n\t/** @deprecated */\n\tlength: number\n\n\t/** @deprecated */\n\tname: string\n\n\t/** @deprecated */\n\tprototype: Function[\"prototype\"]\n\n\t/** @deprecated */\n\targuments: Function[\"arguments\"]\n\n\t// TS suggests Symbol to allow built-in symbolic access, so override that as well\n\t/** @deprecated */\n\tSymbol: never\n}\n\nexport interface ChainedPipeParser<$, t> extends NaryPipeParser<$, t> {\n\ttry: NaryPipeParser<$, t>\n}\n\ntype validateChainedAsArgs<t> =\n\t[t] extends [unset] ?\n\t\t[t] extends [anyOrNever] ?\n\t\t\t[]\n\t\t:\t[\n\t\t\t\tErrorMessage<\"as requires an explicit type parameter like myType.as<t>()\">\n\t\t\t]\n\t:\t[]\n\nexport type { Type as BaseType }\n"
  },
  {
    "path": "ark/type/variants/date.ts",
    "content": "import type {\n\tExclusiveDateRangeSchema,\n\tInclusiveDateRangeSchema\n} from \"@ark/schema\"\nimport type { ObjectType } from \"./object.ts\"\n\n/** @ts-ignore cast variance */\ninterface Type<out t extends globalThis.Date = globalThis.Date, $ = {}>\n\textends ObjectType<t, $> {\n\tatOrAfter(schema: InclusiveDateRangeSchema): this\n\n\tatOrBefore(schema: InclusiveDateRangeSchema): this\n\n\tlaterThan(schema: ExclusiveDateRangeSchema): this\n\n\tearlierThan(schema: ExclusiveDateRangeSchema): this\n}\n\nexport type { Type as DateType }\n"
  },
  {
    "path": "ark/type/variants/instantiate.ts",
    "content": "import type { anyOrNever, array } from \"@ark/util\"\nimport type { ArrayType } from \"./array.ts\"\nimport type { BaseType } from \"./base.ts\"\nimport type { DateType } from \"./date.ts\"\nimport type { NumberType } from \"./number.ts\"\nimport type { ObjectType } from \"./object.ts\"\nimport type { StringType } from \"./string.ts\"\n\nexport type instantiateType<t, $> =\n\t// all branches have to conform to a single basis type those methods to be available\n\t[t] extends [anyOrNever] ? BaseType<t, $>\n\t: [t] extends [object] ?\n\t\t[t] extends [array] ? ArrayType<t, $>\n\t\t: [t] extends [Date] ? DateType<t, $>\n\t\t: ObjectType<t, $>\n\t: [t] extends [string] ? StringType<t, $>\n\t: [t] extends [number] ? NumberType<t, $>\n\t: BaseType<t, $>\n"
  },
  {
    "path": "ark/type/variants/number.ts",
    "content": "import type {\n\tDivisor,\n\tExclusiveNumericRangeSchema,\n\tInclusiveNumericRangeSchema\n} from \"@ark/schema\"\nimport type { BaseType } from \"./base.ts\"\n\n/** @ts-ignore cast variance */\ninterface Type<out t extends number = number, $ = {}> extends BaseType<t, $> {\n\tdivisibleBy(schema: Divisor.Schema): this\n\n\tatLeast(schema: InclusiveNumericRangeSchema): this\n\n\tatMost(schema: InclusiveNumericRangeSchema): this\n\n\tmoreThan(schema: ExclusiveNumericRangeSchema): this\n\n\tlessThan(schema: ExclusiveNumericRangeSchema): this\n}\n\nexport type { Type as NumberType }\n"
  },
  {
    "path": "ark/type/variants/object.ts",
    "content": "import type {\n\tBaseMappedPropInner,\n\tOptionalMappedPropInner,\n\tProp\n} from \"@ark/schema\"\nimport type {\n\tarkGet,\n\tarkIndexableOf,\n\tarkKeyOf,\n\tarray,\n\tErrorType,\n\tinferred,\n\tintersectUnion,\n\tJsonStructure,\n\tKey,\n\tlistable,\n\tmerge,\n\toptionalKeyOf,\n\tshow,\n\ttoArkKey\n} from \"@ark/util\"\nimport type { Default, withDefault } from \"../attributes.ts\"\nimport type { type } from \"../keywords/keywords.ts\"\nimport type { ArrayType } from \"./array.ts\"\nimport type { BaseType } from \"./base.ts\"\nimport type { instantiateType } from \"./instantiate.ts\"\n\n/** @ts-ignore cast variance */\ninterface Type<out t extends object = object, $ = {}> extends BaseType<t, $> {\n\treadonly(): t extends array ? ArrayType<{ readonly [i in keyof t]: t[i] }, $>\n\t:\tType<{ readonly [k in keyof t]: t[k] }, $>\n\n\tkeyof(): instantiateType<arkKeyOf<t>, $>\n\n\t/**\n\t * Get the `Type` of a property of this `Type<object>`.\n\t * @example type({ foo: \"string\" }).get(\"foo\") // Type<string>\n\t */\n\tget<\n\t\tconst k1 extends arkIndexableOf<t>,\n\t\tr = instantiateType<arkGet<t, k1>, $>\n\t>(\n\t\tk1: k1 | type.cast<k1>\n\t): r extends infer _ ? _ : never\n\tget<\n\t\tconst k1 extends arkIndexableOf<t>,\n\t\tconst k2 extends arkIndexableOf<arkGet<t, k1>>,\n\t\tr = instantiateType<arkGet<arkGet<t, k1>, k2>, $>\n\t>(\n\t\tk1: k1 | type.cast<k1>,\n\t\tk2: k2 | type.cast<k2>\n\t): r extends infer _ ? _ : never\n\tget<\n\t\tconst k1 extends arkIndexableOf<t>,\n\t\tconst k2 extends arkIndexableOf<arkGet<t, k1>>,\n\t\tconst k3 extends arkIndexableOf<arkGet<arkGet<t, k1>, k2>>,\n\t\tr = instantiateType<arkGet<arkGet<arkGet<t, k1>, k2>, k3>, $>\n\t>(\n\t\tk1: k1 | type.cast<k1>,\n\t\tk2: k2 | type.cast<k2>,\n\t\tk3: k3 | type.cast<k3>\n\t): r extends infer _ ? _ : never\n\n\t/**\n\t * Create a copy of this `Type` with only the specified properties.\n\t * @example type({ foo: \"string\", bar: \"number\" }).pick(\"foo\") // Type<{ foo: string }>\n\t */\n\tpick<const key extends arkKeyOf<t> = never>(\n\t\t...keys: (key | type.cast<key>)[]\n\t): Type<\n\t\t{\n\t\t\t[k in keyof t as Extract<toArkKey<t, k>, key>]: t[k]\n\t\t},\n\t\t$\n\t>\n\n\t/**\n\t * Create a copy of this `Type` with all properties except the specified ones.\n\t * @example type({ foo: \"string\", bar: \"number\" }).omit(\"foo\") // Type<{ bar: number }>\n\t */\n\tomit<const key extends arkKeyOf<t> = never>(\n\t\t...keys: (key | type.cast<key>)[]\n\t): Type<\n\t\t{\n\t\t\t[k in keyof t as Exclude<toArkKey<t, k>, key>]: t[k]\n\t\t},\n\t\t$\n\t>\n\n\t/**\n\t * Merge another `Type` definition, overriding properties of this `Type` with the duplicate keys.\n\t * @example type({ a: \"1\", b: \"2\" }).merge({ b: \"3\", c: \"4\" }) // Type<{ a: 1, b: 3, c: 4 }>\n\t */\n\tmerge<\n\t\tconst def,\n\t\tinferredDef = type.infer<def, $>,\n\t\tr = Type<merge<t, inferredDef>, $>\n\t>(\n\t\tdef: type.validate<def, $> &\n\t\t\t// if you can figure out a way to avoid inlining this without\n\t\t\t// breaking autocomplete and validation, do it!\n\t\t\t(inferredDef extends object ? unknown\n\t\t\t:\tErrorType<[NonObjectMergeErrorMessage, actual: inferredDef]>)\n\t): r extends infer _ ? _ : never\n\n\t/**\n\t * Create a copy of this `Type` with all properties required.\n\t * @example const T = type({ \"foo?\"\": \"string\" }).required() // Type<{ foo: string }>\n\t */\n\trequired(): Type<{ [k in keyof t]-?: t[k] }, $>\n\n\t/**\n\t * Create a copy of this `Type` with all properties optional.\n\t * @example: const T = type({ foo: \"string\" }).optional() // Type<{ foo?: string }>\n\t */\n\tpartial(): Type<{ [k in keyof t]?: t[k] }, $>\n\n\tmap<\n\t\ttransformed extends listable<MappedTypeProp>,\n\t\tr = Type<constructMapped<t, transformed>, $>\n\t>(\n\t\t// v isn't used directly here but helps TS infer a precise type for transformed\n\t\tflatMapEntry: (entry: typePropOf<t, $>) => transformed\n\t): r extends infer _ ? _ : never\n\n\t/**\n\t * List of property info of this `Type<object>`.\n\t * @example type({ foo: \"string = \"\" }).props // [{ kind: \"required\", key: \"foo\", value: Type<string>, default: \"\" }]\n\t */\n\tprops: array<typePropOf<t, $>>\n}\n\ntype typePropOf<o, $> =\n\tkeyof o extends infer k ?\n\t\tk extends keyof o ?\n\t\t\ttypeProp<o, k, $>\n\t\t:\tnever\n\t:\tnever\n\ntype typeProp<o, k extends keyof o, $, t = o[k] & ({} | null)> =\n\tt extends Default<infer t, infer defaultValue> ?\n\t\tDefaultedTypeProp<k & Key, t, defaultValue, $>\n\t:\tBaseTypeProp<\n\t\t\tk extends optionalKeyOf<o> ? \"optional\" : \"required\",\n\t\t\tk & Key,\n\t\t\tt,\n\t\t\t$\n\t\t>\n\nexport interface BaseTypeProp<\n\tkind extends Prop.Kind = Prop.Kind,\n\tk extends Key = Key,\n\t/** @ts-ignore cast variance */\n\tout v = unknown,\n\t$ = {}\n> {\n\tkind: kind\n\tkey: k\n\tvalue: instantiateType<v, $>\n\tmeta: ArkEnv.meta\n\ttoJSON: () => JsonStructure\n}\n\nexport interface DefaultedTypeProp<\n\tk extends Key = Key,\n\tv = unknown,\n\tdefaultValue = v,\n\t$ = {}\n> extends BaseTypeProp<\"optional\", k, v, $> {\n\tdefault: defaultValue\n}\n\ntype MappedTypeProp<k extends Key = Key, v = unknown> =\n\t| BaseMappedTypeProp<k, v>\n\t| OptionalMappedTypeProp<k, v>\n\ntype BaseMappedTypeProp<k extends Key, v> = merge<\n\tBaseMappedPropInner,\n\t{\n\t\tkey: k\n\t\tvalue: type.cast<v>\n\t}\n>\n\ntype OptionalMappedTypeProp<k extends Key, v> = merge<\n\tOptionalMappedPropInner,\n\t{\n\t\tkey: k\n\t\tvalue: type.cast<v>\n\t\tdefault?: v\n\t}\n>\n\ntype constructMapped<t, transformed extends listable<MappedTypeProp>> = show<\n\tintersectUnion<\n\t\tfromTypeProps<t, transformed extends array ? transformed : [transformed]>\n\t>\n>\n\ntype fromTypeProps<t, props extends array<MappedTypeProp>> = show<\n\t{\n\t\t[prop in props[number] as Extract<\n\t\t\tapplyHomomorphicOptionality<t, prop>,\n\t\t\t{ kind: \"required\" }\n\t\t>[\"key\"]]: prop[\"value\"][inferred]\n\t} & {\n\t\t[prop in props[number] as Extract<\n\t\t\tapplyHomomorphicOptionality<t, prop>,\n\t\t\t{ kind: \"optional\"; default?: never }\n\t\t>[\"key\"]]?: prop[\"value\"][inferred]\n\t} & {\n\t\t[prop in props[number] as Extract<\n\t\t\tapplyHomomorphicOptionality<t, prop>,\n\t\t\t{ kind: \"optional\"; default: unknown }\n\t\t>[\"key\"]]: withDefault<\n\t\t\tprop[\"value\"][inferred],\n\t\t\tprop[\"default\" & keyof prop]\n\t\t>\n\t}\n>\n\nexport type NonObjectMergeErrorMessage = \"Merged type must be an object\"\n\ntype applyHomomorphicOptionality<t, prop extends MappedTypeProp> =\n\tprop[\"kind\"] extends string ? prop\n\t:\tprop & {\n\t\t\tkind: prop[\"key\"] extends optionalKeyOf<t> ? \"optional\" : \"required\"\n\t\t}\n\nexport type { Type as ObjectType }\n"
  },
  {
    "path": "ark/type/variants/string.ts",
    "content": "import type {\n\tExactLength,\n\tExclusiveNumericRangeSchema,\n\tInclusiveNumericRangeSchema,\n\tPattern\n} from \"@ark/schema\"\nimport type { regex } from \"arkregex\"\nimport type { BaseType } from \"./base.ts\"\n\n/** @ts-ignore cast variance */\ninterface Type<out t extends string = string, $ = {}> extends BaseType<t, $> {\n\tmatching<const schema extends Pattern.Schema>(\n\t\tschema: schema\n\t): schema extends string ? Type<regex.infer<schema>, $>\n\t: schema extends { rule: infer pattern extends string } ?\n\t\tType<regex.infer<pattern>, $>\n\t:\tthis\n\n\tatLeastLength(schema: InclusiveNumericRangeSchema): this\n\n\tatMostLength(schema: InclusiveNumericRangeSchema): this\n\n\tmoreThanLength(schema: ExclusiveNumericRangeSchema): this\n\n\tlessThanLength(schema: ExclusiveNumericRangeSchema): this\n\n\texactlyLength(schema: ExactLength.Schema): this\n}\n\nexport type { Type as StringType }\n"
  },
  {
    "path": "ark/util/__tests__/arrays.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { getDuplicatesOf, groupBy, spliterate, type setIndex } from \"@ark/util\"\n\ntype PinkLady = { group: \"apple\"; kind: \"Pink Lady\" }\ntype Gala = { group: \"apple\"; kind: \"Gala\" }\ntype Bengal = { group: \"lychee\"; kind: \"Bengal\" }\ntype Valencia = { group: \"orange\"; kind: \"Valencia\" }\ntype Bartlett = { group: \"pear\"; kind: \"Bartlett\" }\ntype Anjou = { group: \"pear\"; kind: \"Anjou\" }\ntype VisionPro = { group: \"apple\"; kind: \"Vision Pro\" }\n\nexport type Fruit =\n\t| PinkLady\n\t| Gala\n\t| Bengal\n\t| Valencia\n\t| Bartlett\n\t| Anjou\n\t| VisionPro\n\nconst pinkLady: PinkLady = { group: \"apple\", kind: \"Pink Lady\" }\nconst visionPro: VisionPro = { group: \"apple\", kind: \"Vision Pro\" }\nconst bengal: Bengal = { group: \"lychee\", kind: \"Bengal\" }\n\nconst fruits: Fruit[] = [pinkLady, visionPro, bengal]\n\ncontextualize(() => {\n\tit(\"getDuplicatesOf\", () => {\n\t\tconst duplicates = getDuplicatesOf([\"foo\", 55, 31, \"bar\", {}, [], true], {\n\t\t\tisEqual: (l, r) => typeof l === typeof r\n\t\t})\n\t\tattest(duplicates).equals([\n\t\t\t{ element: 55, indices: [1, 2] },\n\t\t\t{ element: \"foo\", indices: [0, 3] },\n\t\t\t{ element: {}, indices: [4, 5] }\n\t\t])\n\t})\n\n\tit(\"groupBy\", () => {\n\t\tconst grouped = groupBy(fruits, \"group\")\n\t\tattest<{\n\t\t\tapple?: (PinkLady | Gala | VisionPro)[]\n\t\t\tlychee?: Bengal[]\n\t\t\torange?: Valencia[]\n\t\t\tpear?: (Bartlett | Anjou)[]\n\t\t}>(grouped).equals({\n\t\t\tapple: [pinkLady, visionPro],\n\t\t\tlychee: [bengal]\n\t\t})\n\t})\n\n\tit(\"spliterate\", () => {\n\t\tconst list = [1, \"2\", \"3\", 4, 5]\n\t\tconst [numbers, strings] = spliterate(\n\t\t\tlist,\n\t\t\t// explicitly annotated so tests pass pre TS 5.5\n\t\t\t(x): x is number => typeof x === \"number\"\n\t\t)\n\n\t\tattest<number[]>(numbers).equals([1, 4, 5])\n\t\tattest<string[]>(strings).equals([\"2\", \"3\"])\n\t})\n\n\tit(\"setIndex\", () => {\n\t\ttype T = setIndex<[1, 2], 1, 1>\n\n\t\tattest<[1, 1], T>()\n\t})\n\n\tit(\"setIndex readonly\", () => {\n\t\ttype T = setIndex<readonly [1, 2], 1, 1>\n\n\t\tattest<readonly [1, 1], T>()\n\t})\n})\n"
  },
  {
    "path": "ark/util/__tests__/callable.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { Callable } from \"@ark/util\"\n\ncontextualize(() => {\n\tclass Sub extends Callable<(name: string) => string> {\n\t\tconstructor() {\n\t\t\tsuper((name: string) => \"Hello: \" + this.salutation + name)\n\t\t}\n\t\tsalutation = \"Mr. \"\n\t\tdoSomething() {\n\t\t\treturn this.salutation + \"doSomething\"\n\t\t}\n\t}\n\tit(\"can be extended\", () => {\n\t\tconst f = new Sub()\n\t\tattest(f instanceof Sub).equals(true)\n\t\tattest(f instanceof Callable).equals(true)\n\t\tattest(f(\"ff\")).snap(\"Hello: Mr. ff\")\n\t\tattest(f.doSomething()).snap(\"Mr. doSomething\")\n\t})\n\n\tit(\"subclasses can be chained\", () => {\n\t\tclass SecondSub extends Sub {\n\t\t\tsalutation = \"Ms.\"\n\t\t}\n\t\tconst f = new SecondSub()\n\t\tattest(f instanceof SecondSub).equals(true)\n\t\tattest(f instanceof Sub).equals(true)\n\t\tattest(f instanceof Callable).equals(true)\n\t\tattest(f(\"ff\")).snap(\"Hello: Ms.ff\")\n\t\tattest(f.doSomething()).snap(\"Ms.doSomething\")\n\t})\n\n\tit(\"can attach properties\", () => {\n\t\tconst s = new Callable(() => 1, { attach: { a: 2 } })\n\n\t\tattest(s()).equals(1)\n\t\tattest(s.a).equals(2)\n\t})\n\n\tit(\"can attach properties\", () => {\n\t\t// inferred directly from constructor\n\t\tconst s = new Callable(() => 1 as const, { attach: { a: 2 } } as const)\n\n\t\tattest<1>(s()).equals(1)\n\t\tattest<2>(s.a).equals(2)\n\t})\n\n\tit(\"can attach properties to a subclass\", () => {\n\t\tclass Foo<attach extends object> extends Callable<() => 0, attach> {\n\t\t\tconstructor(attach: attach) {\n\t\t\t\tsuper(() => 0, { attach })\n\t\t\t}\n\n\t\t\tb() {\n\t\t\t\treturn 2 as const\n\t\t\t}\n\n\t\t\tgetAttached<k extends keyof attach>(k: k): attach[k] {\n\t\t\t\treturn (this as any)[k]\n\t\t\t}\n\t\t}\n\n\t\tconst foo = new Foo({ a: 1 } as const)\n\t\tattest(foo instanceof Foo).equals(true)\n\t\tattest(foo instanceof Callable).equals(true)\n\t\t// callable preserved\n\t\tattest<0>(foo()).snap(0)\n\t\t// attachments present\n\t\tattest<1>(foo.a).snap(1)\n\t\t// subclass methods preserved\n\t\tattest<2>(foo.b()).snap(2)\n\t\t// can access attached on methods\n\t\tattest<1>(foo.getAttached(\"a\")).snap(1)\n\t})\n\n\tit(\"can access attached properties and prototype methods\", () => {\n\t\tclass GetAttached<attach extends object> extends Callable<\n\t\t\t<k extends keyof attach>(k: k) => attach[k],\n\t\t\tattach\n\t\t> {\n\t\t\tconstructor(attach: attach) {\n\t\t\t\tsuper(<k extends keyof attach>(k: k) => this.protoGetAttached(k), {\n\t\t\t\t\tattach\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tprotoGetAttached(k: PropertyKey) {\n\t\t\t\treturn (this as any)[k]\n\t\t\t}\n\n\t\t\tgetAttached<k extends keyof attach>(k: k): attach[k] {\n\t\t\t\treturn this(k)\n\t\t\t}\n\t\t}\n\n\t\tconst foo = new GetAttached({ a: 1 } as const)\n\t\tattest<1>(foo.a).equals(1)\n\t\tattest<1>(foo.getAttached(\"a\")).equals(1)\n\t\tattest<1>(foo(\"a\")).equals(1)\n\t})\n\n\tit(\"preserves original name\", () => {\n\t\tconst f = new Callable(function originalName() {})\n\n\t\tattest(f.name).snap(\"bound originalName\")\n\t})\n})\n"
  },
  {
    "path": "ark/util/__tests__/clone.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { deepClone } from \"@ark/util\"\n\ncontextualize(() => {\n\tit(\"should return a deep clone of a simple object\", () => {\n\t\tconst obj = { a: 1, b: 2, c: 3 }\n\t\tconst cloned = deepClone(obj)\n\t\tattest<typeof obj>(cloned).equals(obj)\n\t\tattest(cloned !== obj).equals(true)\n\t})\n\n\tit(\"should return a deep clone of a nested object\", () => {\n\t\tconst obj = { a: 1, b: { c: 2 } }\n\t\tconst cloned = deepClone(obj)\n\t\tattest<typeof obj>(cloned).equals(obj)\n\t\tattest(cloned !== obj).equals(true)\n\t\tattest(cloned.b !== obj.b).equals(true)\n\t})\n\n\tit(\"should handle cycles correctly\", () => {\n\t\tconst obj: any = { a: 1 }\n\t\tobj.self = obj\n\t\tconst cloned = deepClone(obj)\n\t\tattest<typeof obj>(cloned).equals(obj)\n\t\tattest(cloned !== obj).equals(true)\n\t\tattest(cloned.self === cloned).equals(true)\n\t})\n\n\tit(\"should handle deep cycles correctly\", () => {\n\t\tconst obj: any = { a: 1, b: { c: 2 } }\n\t\tobj.b.self = obj\n\t\tconst cloned = deepClone(obj)\n\t\tattest<typeof obj>(cloned).equals(obj)\n\t\tattest(cloned !== obj).equals(true)\n\t\tattest(cloned.b.self === cloned).equals(true)\n\t})\n\n\tit(\"should handle null values correctly\", () => {\n\t\tconst obj = { a: 1, b: null }\n\t\tconst cloned = deepClone(obj)\n\t\tattest<typeof obj>(cloned).equals(obj)\n\t\tattest(cloned !== obj).equals(true)\n\t})\n\n\tit(\"should handle undefined values correctly\", () => {\n\t\tconst obj = { a: 1, b: undefined }\n\t\tconst cloned = deepClone(obj)\n\t\tattest<typeof obj>(cloned).equals(obj)\n\t\tattest(cloned !== obj).equals(true)\n\t})\n\n\tit(\"should handle arrays correctly\", () => {\n\t\tconst obj = { a: 1, b: [2, 3, 4] }\n\t\tconst cloned = deepClone(obj)\n\t\tattest<typeof obj>(cloned).equals(obj)\n\t\tattest(cloned !== obj).equals(true)\n\t\tattest(cloned.b !== obj.b).equals(true)\n\t})\n\n\tit(\"Date\", () => {\n\t\tconst original = new Date(2000, 1)\n\t\tconst cloned = deepClone(original)\n\t\tattest(cloned).instanceOf(Date)\n\t\tattest(cloned.toISOString()).equals(original.toISOString())\n\t\toriginal.setDate(original.getDate() + 1)\n\t\tattest(cloned.getDate()).equals(1)\n\t\tattest(original.getDate()).equals(2)\n\t\tcloned.setDate(3)\n\t\tattest(cloned.getDate()).equals(3)\n\t\tattest(original.getDate()).equals(2)\n\t})\n\n\tit(\"can handle own getters\", () => {\n\t\tlet callCount = 0\n\t\tconst o = {\n\t\t\tget foo() {\n\t\t\t\treturn `foo${++callCount}`\n\t\t\t}\n\t\t}\n\n\t\tconst cloned = deepClone(o)\n\n\t\tattest(cloned).snap({ foo: \"foo2\" })\n\t\tattest(o.foo).snap(\"foo3\")\n\t\tattest(cloned.foo).snap(\"foo4\")\n\t})\n})\n"
  },
  {
    "path": "ark/util/__tests__/collapsibleDate.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { describeCollapsibleDate, throwError } from \"@ark/util\"\n\nconst newYorkDate = (dateString: string) => {\n\tconst date = new Date(dateString)\n\tif (date.getMonth() > 1 && date.getMonth() < 11) {\n\t\tthrowError(\n\t\t\t`This test util only supports months not affected by Daylight Savings Time`\n\t\t)\n\t}\n\tdate.setHours(date.getHours() + 5)\n\treturn date\n}\n\ncontextualize(() => {\n\tit(\"returns year for date with only year precision\", () => {\n\t\tconst date = newYorkDate(\"2023-01-01\")\n\t\tconst result = describeCollapsibleDate(date)\n\t\tattest(result).snap(\"2023\")\n\t})\n\n\tit(\"returns full date for date with day precision\", () => {\n\t\tconst date = newYorkDate(\"2023-01-15\")\n\t\tconst result = describeCollapsibleDate(date)\n\t\tattest(result).snap(\"January 15, 2023\")\n\t})\n\n\tit(\"returns full date and time for date with minutes precision\", () => {\n\t\tconst date = newYorkDate(\"2023-01-15T14:30:00.000Z\")\n\t\tconst result = describeCollapsibleDate(date)\n\t\tattest(result).snap(\"2:30 PM, January 15, 2023\")\n\t})\n\n\tit(\"returns full date and time for date with seconds\", () => {\n\t\tconst date = newYorkDate(\"1993-02-15T14:30:31\")\n\t\tconst result = describeCollapsibleDate(date)\n\t\tattest(result).snap(\"7:30:31 PM, February 15, 1993\")\n\t})\n\n\tit(\"returns full date and time with milliseconds\", () => {\n\t\tconst date = newYorkDate(\"2023-12-15T14:30:00.123Z\")\n\t\tconst result = describeCollapsibleDate(date)\n\t\tattest(result).snap(\"2:30:00.123 PM, December 15, 2023\")\n\t})\n\n\tit(\"handles midnight correctly\", () => {\n\t\tconst date = newYorkDate(\"2023-01-15T00:00:00.000Z\")\n\t\tconst result = describeCollapsibleDate(date)\n\t\tattest(result).snap(\"January 15, 2023\")\n\t})\n\n\tit(\"handles noon correctly\", () => {\n\t\tconst date = newYorkDate(\"2023-02-15T12:00:00.000Z\")\n\t\tconst result = describeCollapsibleDate(date)\n\t\tattest(result).snap(\"12:00 PM, February 15, 2023\")\n\t})\n\n\tit(\"handles AM/PM correctly\", () => {\n\t\tconst dateAM = newYorkDate(\"2023-01-15T09:00:00.000Z\")\n\t\tconst resultAM = describeCollapsibleDate(dateAM)\n\t\tattest(resultAM).snap(\"9:00 AM, January 15, 2023\")\n\n\t\tconst datePM = newYorkDate(\"2023-01-15T21:00:00.000Z\")\n\t\tconst resultPM = describeCollapsibleDate(datePM)\n\t\tattest(resultPM).snap(\"9:00 PM, January 15, 2023\")\n\t})\n})\n"
  },
  {
    "path": "ark/util/__tests__/flatMorph.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { flatMorph } from \"@ark/util\"\n\ncontextualize(() => {\n\tit(\"object\", () => {\n\t\tconst result = flatMorph({ a: true, b: false }, (k, v) =>\n\t\t\tk === \"a\" ?\n\t\t\t\t([\n\t\t\t\t\t[k, v],\n\t\t\t\t\t[\"c\", \"d\"]\n\t\t\t\t] as const)\n\t\t\t:\t([\"e\", \"f\"] as const)\n\t\t)\n\t\tattest<{\n\t\t\ta: true\n\t\t\tc: \"d\"\n\t\t\te: \"f\"\n\t\t}>(result).equals({ a: true, c: \"d\", e: \"f\" })\n\t})\n\n\tit(\"filters empty result\", () => {\n\t\tconst result = flatMorph({ a: true, b: false }, (k, v) =>\n\t\t\tk === \"a\" ? ([k, v] as const) : []\n\t\t)\n\t\tattest<{\n\t\t\ta: true\n\t\t}>(result).equals({ a: true })\n\t})\n\n\tit(\"object with index\", () => {\n\t\t// needs to be annotated for now due to a TS bug\n\t\tconst result = flatMorph({ a: true, b: false }, (k, v, i: number) =>\n\t\t\tk === \"a\" ?\n\t\t\t\t([\n\t\t\t\t\t[k, v],\n\t\t\t\t\t[\"c\", \"d\"]\n\t\t\t\t] as const)\n\t\t\t:\t([`${i}`, \"f\"] as const)\n\t\t)\n\n\t\tattest<{\n\t\t\t[x: `${number}`]: \"f\"\n\t\t\ta: true\n\t\t\tc: \"d\"\n\t\t}>(result).equals({ a: true, c: \"d\", \"1\": \"f\" })\n\t})\n\n\tit(\"converts numeric keys to array\", () => {\n\t\tconst result = flatMorph({ a: true, b: false, c: 5 }, (k, v) =>\n\t\t\tk === \"a\" ? ([0, v] as const) : ([1, v] as const)\n\t\t)\n\t\tattest<[true, false | 5]>(result).equals([true, 5])\n\t})\n\n\tit(\"converts numeric key with index to array\", () => {\n\t\t// index needs to be annotated for now due to a TS bug\n\t\tconst result = flatMorph({ a: true, b: false, c: 5 }, (k, v, i: number) =>\n\t\t\tk === \"a\" ? ([0, v] as const) : ([i, v] as const)\n\t\t)\n\t\tattest<(boolean | 5)[]>(result).equals([true, false, 5])\n\t})\n\n\tit(\"maps from array using numeric keys\", () => {\n\t\tconst result = flatMorph([0, 1, 2, 3], (i, v) =>\n\t\t\ti === 0 ? ([i, 5] as const) : ([i, v] as const)\n\t\t)\n\t\tattest<[5, ...(1 | 2 | 3)[]]>(result).equals([5, 1, 2, 3])\n\t})\n\n\tit(\"maps from array to object\", () => {\n\t\tconst result = flatMorph([\"a\", \"b\", \"c\"], (i, v) => [v, i])\n\t\tattest<{\n\t\t\ta: 0 | 2 | 1\n\t\t\tb: 0 | 2 | 1\n\t\t\tc: 0 | 2 | 1\n\t\t}>(result).equals({ a: 0, b: 1, c: 2 })\n\t})\n\n\tit(\"filters array\", () => {\n\t\tconst result = flatMorph([1, 2, 3] as const, (i, v) =>\n\t\t\tv === 2 ? [] : [i, v]\n\t\t)\n\t\tattest<(1 | 3)[]>(result).equals([1, 3])\n\t})\n\n\tit(\"groupable\", () => {\n\t\tconst result = flatMorph({ a: true, b: false, c: 0, d: 1 }, (k, v) =>\n\t\t\ttypeof v === \"boolean\" ?\n\t\t\t\t([{ group: \"bools\" }, v] as const)\n\t\t\t:\t([{ group: \"nums\" }, v] as const)\n\t\t)\n\n\t\tattest<{\n\t\t\tbools: boolean[]\n\t\t\tnums: (0 | 1)[]\n\t\t}>(result).snap({ bools: [true, false], nums: [0, 1] })\n\t})\n})\n"
  },
  {
    "path": "ark/util/__tests__/hkt.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport type { Hkt } from \"@ark/util\"\n\ncontextualize(() => {\n\tinterface AppendKind<element = unknown>\n\t\textends Hkt<[element: element, to: readonly element[]]> {\n\t\tbody: [...this[1], this[0]]\n\t}\n\n\tit(\"base\", () => {\n\t\ttype result = Hkt.apply<AppendKind, [2, [0, 1]]>\n\t\tattest<[0, 1, 2], result>()\n\t})\n\n\tit(\"type error on unsatisfied constraint\", () => {\n\t\t// @ts-expect-error\n\t\tattest((t: Hkt.apply<AppendKind, [2, 0]>) => t).type.errors(\n\t\t\t\"Type 'number' is not assignable to type 'readonly unknown[]'\"\n\t\t)\n\t})\n})\n"
  },
  {
    "path": "ark/util/__tests__/intersections.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport type { intersectArrays, intersectParameters } from \"@ark/util\"\n\ncontextualize(() => {\n\tdescribe(\"parameters\", () => {\n\t\tit(\"both empty\", () => {\n\t\t\ttype t = intersectParameters<[], []>\n\t\t\tattest<[], t>()\n\t\t})\n\n\t\tit(\"one empty\", () => {\n\t\t\ttype t = intersectParameters<[], [string, number, ...boolean[]]>\n\t\t\tattest<[string, number, ...boolean[]], t>()\n\t\t})\n\n\t\tit(\"longer parameters preserved\", () => {\n\t\t\ttype t = intersectParameters<[\"a\"], [string, number]>\n\t\t\tattest<[\"a\", number], t>()\n\t\t})\n\n\t\tit(\"objects evaluated\", () => {\n\t\t\ttype t = intersectParameters<[{ a: string }], [{ b: boolean }]>\n\t\t\t// Snapshotted so that { a: string } & { b: boolean } fails\n\t\t\tattest({} as t).type.toString.snap(\"[{ a: string; b: boolean }]\")\n\t\t})\n\n\t\tit(\"unknown preserved\", () => {\n\t\t\ttype t = intersectParameters<[unknown], []>\n\t\t\t// Avoids evaluating unknown to {}\n\t\t\tattest<[unknown], t>()\n\t\t})\n\n\t\tit(\"one optional\", () => {\n\t\t\ttype t = intersectParameters<[(\"a\" | \"b\" | \"c\")?], [string, 1 | 2 | 3]>\n\t\t\tattest<[\"a\" | \"b\" | \"c\", 1 | 2 | 3], t>()\n\t\t})\n\n\t\tit(\"both optional\", () => {\n\t\t\ttype t = intersectParameters<[{ a: 0 }?], [{ b: 1 }?]>\n\t\t\tattest<[{ a: 0; b: 1 }?], t>()\n\t\t})\n\n\t\tit(\"optional+not-present\", () => {\n\t\t\ttype t = intersectParameters<[{ a: 0 }?], []>\n\t\t\tattest<[{ a: 0 }?], t>()\n\t\t})\n\n\t\tit(\"two non-fixed arrays\", () => {\n\t\t\ttype t = intersectParameters<{ a: 0 }[], { b: 1 }[]>\n\t\t\tattest<{ a: 0; b: 1 }[], t>()\n\t\t})\n\n\t\tit(\"one non-fixed array\", () => {\n\t\t\ttype t = intersectParameters<[{ a: 0 }, { b: 1 }], { c: 2 }[]>\n\t\t\tattest<\n\t\t\t\t[\n\t\t\t\t\t{\n\t\t\t\t\t\ta: 0\n\t\t\t\t\t\tc: 2\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tb: 1\n\t\t\t\t\t\tc: 2\n\t\t\t\t\t},\n\t\t\t\t\t...{\n\t\t\t\t\t\tc: 2\n\t\t\t\t\t}[]\n\t\t\t\t],\n\t\t\t\tt\n\t\t\t>()\n\t\t})\n\n\t\tit(\"one trailing rest\", () => {\n\t\t\ttype t = intersectParameters<\n\t\t\t\t[{ a: 0 }, ...{ b: 1 }[]],\n\t\t\t\t[{ c: 2 }, { d: 3 }]\n\t\t\t>\n\t\t\tattest<\n\t\t\t\t[\n\t\t\t\t\t{\n\t\t\t\t\t\ta: 0\n\t\t\t\t\t\tc: 2\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tb: 1\n\t\t\t\t\t\td: 3\n\t\t\t\t\t},\n\t\t\t\t\t...{\n\t\t\t\t\t\tb: 1\n\t\t\t\t\t}[]\n\t\t\t\t],\n\t\t\t\tt\n\t\t\t>()\n\t\t})\n\n\t\tit(\"two trailing rest\", () => {\n\t\t\ttype t = intersectParameters<\n\t\t\t\t[{ a: 0 }, ...{ b: 1 }[]],\n\t\t\t\t[{ c: 2 }, { d: 3 }, ...{ e: 4 }[]]\n\t\t\t>\n\t\t\tattest<\n\t\t\t\t[\n\t\t\t\t\t{\n\t\t\t\t\t\ta: 0\n\t\t\t\t\t\tc: 2\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tb: 1\n\t\t\t\t\t\td: 3\n\t\t\t\t\t},\n\t\t\t\t\t...{\n\t\t\t\t\t\tb: 1\n\t\t\t\t\t\te: 4\n\t\t\t\t\t}[]\n\t\t\t\t],\n\t\t\t\tt\n\t\t\t>()\n\t\t})\n\n\t\tit(\"kitchen sink\", () => {\n\t\t\ttype t = intersectParameters<\n\t\t\t\t[{ a: 0 }, { b: 1 }?, { c: 2 }?, ...{ d: 3 }[]],\n\t\t\t\t[{ e: 4 }?, { f: 5 }?, ...{ g: 6 }[]]\n\t\t\t>\n\t\t\tattest<\n\t\t\t\t[\n\t\t\t\t\t{\n\t\t\t\t\t\ta: 0\n\t\t\t\t\t\te: 4\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tb: 1\n\t\t\t\t\t\tf: 5\n\t\t\t\t\t}?,\n\t\t\t\t\t{\n\t\t\t\t\t\tc: 2\n\t\t\t\t\t\tg: 6\n\t\t\t\t\t}?,\n\t\t\t\t\t...{\n\t\t\t\t\t\td: 3\n\t\t\t\t\t\tg: 6\n\t\t\t\t\t}[]\n\t\t\t\t],\n\t\t\t\tt\n\t\t\t>()\n\t\t})\n\n\t\tit(\"extra variadic args preserved\", () => {\n\t\t\ttype t = intersectParameters<[\"a\", \"b\"], [string, ...string[]]>\n\t\t\tattest<[\"a\", \"b\", ...string[]], t>()\n\t\t})\n\t})\n\n\tdescribe(\"arrays\", () => {\n\t\t// Ideally this might be reduced to a top-level never\n\t\tit(\"incompatible lengths\", () => {\n\t\t\ttype t = intersectArrays<[], [string]>\n\t\t\tattest<never>({} as t)\n\t\t})\n\n\t\tit(\"extra variadic args truncated\", () => {\n\t\t\ttype t = intersectArrays<[\"a\", \"b\"], [string, ...string[]]>\n\t\t\tattest<[\"a\", \"b\"], t>()\n\t\t})\n\n\t\tit(\"postfix\", () => {\n\t\t\ttype t = intersectArrays<[...0[], number], [...number[], 1]>\n\t\t\tattest<[...0[], 1], t>()\n\t\t})\n\n\t\tit(\"asymmetric postfix\", () => {\n\t\t\ttype l = [...{ a: 1 }[], { b: 1 }]\n\t\t\ttype r = [...{ c: 1 }[]]\n\n\t\t\ttype expected = [\n\t\t\t\t...{\n\t\t\t\t\ta: 1\n\t\t\t\t\tc: 1\n\t\t\t\t}[],\n\t\t\t\t{\n\t\t\t\t\tb: 1\n\t\t\t\t\tc: 1\n\t\t\t\t}\n\t\t\t]\n\n\t\t\tattest<expected, intersectArrays<l, r>>()\n\t\t\tattest<expected, intersectArrays<r, l>>()\n\t\t})\n\n\t\tit(\"prefix and postfix\", () => {\n\t\t\ttype l = [\n\t\t\t\t...{\n\t\t\t\t\ta: 0\n\t\t\t\t}[],\n\t\t\t\t{\n\t\t\t\t\tb: 0\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tc: 0\n\t\t\t\t}\n\t\t\t]\n\t\t\ttype r = [\n\t\t\t\t{\n\t\t\t\t\tx: 0\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ty: 0\n\t\t\t\t},\n\t\t\t\t...{\n\t\t\t\t\tz: 0\n\t\t\t\t}[]\n\t\t\t]\n\n\t\t\t// currently getting the precise \"Expected\" result at a type-level incurs\n\t\t\t// too high a performance cost for such a niche intersection,\n\t\t\t// so instead we widen it\n\n\t\t\t// see ArkType's \"prefix and postfix\" intersection test for arrays for the\n\t\t\t// ideal result\n\t\t\ttype expected = [\n\t\t\t\t{\n\t\t\t\t\ta: 0\n\t\t\t\t\tx: 0\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ta: 0\n\t\t\t\t\ty: 0\n\t\t\t\t},\n\t\t\t\t...{\n\t\t\t\t\ta: 0\n\t\t\t\t\tz: 0\n\t\t\t\t}[],\n\t\t\t\t(\n\t\t\t\t\t| {\n\t\t\t\t\t\t\tb: 0\n\t\t\t\t\t\t\tx: 0\n\t\t\t\t\t  }\n\t\t\t\t\t| {\n\t\t\t\t\t\t\tb: 0\n\t\t\t\t\t\t\ty: 0\n\t\t\t\t\t  }\n\t\t\t\t\t| {\n\t\t\t\t\t\t\tb: 0\n\t\t\t\t\t\t\tz: 0\n\t\t\t\t\t  }\n\t\t\t\t),\n\t\t\t\t(\n\t\t\t\t\t| {\n\t\t\t\t\t\t\tc: 0\n\t\t\t\t\t\t\tx: 0\n\t\t\t\t\t  }\n\t\t\t\t\t| {\n\t\t\t\t\t\t\tc: 0\n\t\t\t\t\t\t\ty: 0\n\t\t\t\t\t  }\n\t\t\t\t\t| {\n\t\t\t\t\t\t\tc: 0\n\t\t\t\t\t\t\tz: 0\n\t\t\t\t\t  }\n\t\t\t\t)\n\t\t\t]\n\n\t\t\tattest<expected, intersectArrays<l, r>>()\n\t\t\tattest<expected, intersectArrays<r, l>>()\n\t\t})\n\t})\n})\n"
  },
  {
    "path": "ark/util/__tests__/labels.test.ts",
    "content": "import { attest } from \"@ark/attest\"\nimport type { applyElementLabels } from \"@ark/util\"\n\ndescribe(\"labels\", () => {\n\tit(\"same length\", () => {\n\t\tconst t = {} as applyElementLabels<[1, 2], [a: \"a\", b: \"b\"]>\n\t\tattest(t).type.toString(\"[a: 1, b: 2]\")\n\t})\n\n\tit(\"single optional element\", () => {\n\t\tconst t = {} as applyElementLabels<[1?], [a: \"a\", b: \"b\"]>\n\t\tattest(t).type.toString(\"[a?: 1]\")\n\t})\n\n\tit(\"two elements with the second one optional\", () => {\n\t\tconst t = {} as applyElementLabels<[1, 2?], [a: \"a\", b: \"b\"]>\n\t\tattest(t).type.toString(\"[a: 1, b?: 2]\")\n\t})\n\n\tit(\"three elements with the third one optional\", () => {\n\t\tconst t = {} as applyElementLabels<[1, 2, 3?], [a: \"a\", b: \"b\"]>\n\t\tattest(t).type.toString(\"[a: 1, b: 2, 3?]\")\n\t})\n\n\tit(\"optional first element and variadic elements\", () => {\n\t\tconst t = {} as applyElementLabels<[1?, ...0[]], [a: \"a\", b: \"b\"]>\n\t\tattest(t).type.toString(\"[a?: 1, b?: 0, ...0[]]\")\n\t})\n\n\tit(\"two elements with the second one optional and variadic elements\", () => {\n\t\tconst t = {} as applyElementLabels<[1, 2?, ...0[]], [a: \"a\", b: \"b\"]>\n\t\tattest(t).type.toString(\"[a: 1, b?: 2, ...0[]]\")\n\t})\n\n\tit(\"extra labels with rest\", () => {\n\t\tconst t = {} as applyElementLabels<string[], [a: \"a\", b: \"b\", c: \"c\"]>\n\t\tattest(t).type.toString(\"[a?: string, b?: string, c?: string, ...string[]]\")\n\t})\n})\n"
  },
  {
    "path": "ark/util/__tests__/numbers.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { isNumericString, isWellFormedNumber, nearestFloat } from \"@ark/util\"\n\ncontextualize(() => {\n\tdescribe(\"nearestFloat\", () => {\n\t\tit(\"0\", () => {\n\t\t\tattest(nearestFloat(0)).equals(Number.MIN_VALUE)\n\t\t\tattest(nearestFloat(0, \"-\")).equals(-Number.MIN_VALUE)\n\t\t})\n\n\t\tit(\"small integer\", () => {\n\t\t\tattest(nearestFloat(2)).snap(2.0000000000000004)\n\t\t\tattest(nearestFloat(-2)).snap(-1.9999999999999998)\n\t\t})\n\n\t\tit(\"small decimal\", () => {\n\t\t\tattest(nearestFloat(2.1)).snap(2.1000000000000005)\n\t\t\tattest(nearestFloat(-2.1)).snap(-2.0999999999999996)\n\t\t})\n\n\t\tit(\"large integer\", () => {\n\t\t\tattest(nearestFloat(5555555555555555)).equals(5555555555555556)\n\t\t\tattest(nearestFloat(5555555555555555, \"-\")).equals(5555555555555554)\n\t\t\tattest(nearestFloat(-5555555555555555)).snap(-5555555555555554)\n\t\t\tattest(nearestFloat(-5555555555555555, \"-\")).equals(-5555555555555556)\n\t\t})\n\t})\n\n\tdescribe(\"number matchers\", () => {\n\t\tit(\"wellFormedNumberMatcher rejects decimal-only numbers\", () => {\n\t\t\tattest(isWellFormedNumber(\".5\")).equals(false)\n\t\t\tattest(isWellFormedNumber(\"0.5\")).equals(true)\n\t\t})\n\n\t\tit(\"numericStringMatcher accepts decimal-only numbers\", () => {\n\t\t\tattest(isNumericString(\".5\")).equals(true)\n\t\t\tattest(isNumericString(\"0.5\")).equals(true)\n\t\t})\n\n\t\tit(\"wellFormedNumberMatcher rejects trailing zeros in decimals\", () => {\n\t\t\tattest(isWellFormedNumber(\"0.10\")).equals(false)\n\t\t\tattest(isWellFormedNumber(\"0.1\")).equals(true)\n\t\t})\n\n\t\tit(\"numericStringMatcher accepts trailing zeros in decimals\", () => {\n\t\t\tattest(isNumericString(\"0.10\")).equals(true)\n\t\t\tattest(isNumericString(\"0.1\")).equals(true)\n\t\t})\n\n\t\tit(\"both matchers reject negative zero\", () => {\n\t\t\tattest(isWellFormedNumber(\"-0\")).equals(false)\n\t\t\tattest(isNumericString(\"-0\")).equals(false)\n\t\t})\n\n\t\tit(\"both matchers accept valid integers\", () => {\n\t\t\tattest(isWellFormedNumber(\"123\")).equals(true)\n\t\t\tattest(isNumericString(\"123\")).equals(true)\n\t\t\tattest(isWellFormedNumber(\"-123\")).equals(true)\n\t\t\tattest(isNumericString(\"-123\")).equals(true)\n\t\t})\n\n\t\tit(\"both matchers accept valid decimals\", () => {\n\t\t\tattest(isWellFormedNumber(\"123.456\")).equals(true)\n\t\t\tattest(isNumericString(\"123.456\")).equals(true)\n\t\t\tattest(isWellFormedNumber(\"-123.456\")).equals(true)\n\t\t\tattest(isNumericString(\"-123.456\")).equals(true)\n\t\t})\n\t})\n})\n"
  },
  {
    "path": "ark/util/__tests__/overloads.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport type { array, conform, overloadOf } from \"@ark/util\"\n\ntype fn = {\n\t(): void\n\t(a?: 1): 1\n\t(a: 2, b: 2): 2\n}\n\nconst pipe = <fn extends (...args: any[]) => unknown, args extends array>(\n\targs: conform<args, Parameters<overloadOf<fn>>>,\n\tf: fn\n): ReturnType<overloadOf<fn, args>> => f(...args) as never\n\ncontextualize(() => {\n\tit(\"parameters\", () => {\n\t\tconst T = {} as Parameters<overloadOf<fn>>\n\t\tattest<[a: 2, b: 2] | [a?: 1 | undefined] | []>(T)\n\t})\n\n\tit(\"returns\", () => {\n\t\tconst T = {} as ReturnType<overloadOf<fn>>\n\t\tattest<void | 1 | 2>(T)\n\t})\n\n\tit(\"overload return\", () => {\n\t\ttype limit = ((s: string) => string) & ((n: number) => number)\n\t\ttype fromNumber = ReturnType<overloadOf<limit, [number]>>\n\t\tattest<number, fromNumber>()\n\t\t// currently doesn't work for subtypes\n\t\t// type fromString = overloadOf<typeof limit, [\"foo\"]>\n\t\t// attest<string, fromString>()\n\t})\n\n\tit(\"()=>never\", () => {\n\t\ttype result = Parameters<\n\t\t\toverloadOf<{\n\t\t\t\t(): void\n\t\t\t\t(a?: 1): 1\n\t\t\t\t(a: 2, b: 2): 2\n\t\t\t\t(): never\n\t\t\t}>\n\t\t>\n\t\tattest<[a: 2, b: 2] | [a?: 1 | undefined] | [], result>()\n\t})\n\n\tit(\"pipe\", () => {\n\t\tconst limit = (_ => _) as ((s: string) => string) & ((n: number) => number)\n\t\tconst n = pipe([5], limit)\n\t\tattest<number>(n)\n\t\tconst s = pipe([\"foo\"], limit)\n\t\tattest<string>(s)\n\t\t// @ts-expect-error\n\t\tattest(() => pipe([], limit))\n\t\t// @ts-expect-error\n\t\tattest(() => pipe([\"foo\", \"bar\"], limit))\n\t\t// @ts-expect-error\n\t\tattest(() => pipe([true], limit))\n\t})\n})\n"
  },
  {
    "path": "ark/util/__tests__/path.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { ReadonlyPath } from \"@ark/util\"\n\ncontextualize(() => {\n\tit(\"creates an array of a single number\", () => {\n\t\tconst path = new ReadonlyPath(5)\n\n\t\tattest([...path]).snap([5])\n\t})\n\n\tit(\"arary methods preserve subclass\", () => {\n\t\tconst path = new ReadonlyPath()\n\n\t\tattest(path.slice()).instanceOf(ReadonlyPath)\n\t})\n})\n"
  },
  {
    "path": "ark/util/__tests__/printable.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { printable } from \"@ark/util\"\n\ncontextualize(() => {\n\tit(\"primitives\", () => {\n\t\tattest(printable(5)).snap(\"5\")\n\t\tattest(printable(\"foo\")).snap('\"foo\"')\n\t\tattest(printable(true)).snap(\"true\")\n\t\tattest(printable(null)).snap(\"null\")\n\t\tattest(printable(undefined)).snap(\"undefined\")\n\t\tattest(printable(123n)).snap(\"123n\")\n\t\tconst s = Symbol(\"ark\")\n\t\tattest(printable(s)).snap(\"Symbol(ark)\")\n\t})\n\n\tit(\"simple object\", () => {\n\t\tconst data = { a: 1, b: \"foo\" }\n\t\tattest(printable(data)).snap('{\"a\":1,\"b\":\"foo\"}')\n\t})\n\n\tit(\"simple array\", () => {\n\t\tconst data = [1, \"foo\"]\n\t\tattest(printable(data)).snap('[1,\"foo\"]')\n\t})\n\n\tit(\"nested\", () => {\n\t\tconst data = { a: [1, { b: \"foo\" }] }\n\t\tattest(printable(data)).snap('{\"a\":[1,{\"b\":\"foo\"}]}')\n\t})\n\n\tit(\"indent\", () => {\n\t\tconst data = { a: [1, { b: \"foo\" }] }\n\t\tattest(printable(data, { indent: 2 })).snap(`{\n  \"a\": [\n    1,\n    {\n      \"b\": \"foo\"\n    }\n  ]\n}`)\n\t})\n\n\tit(\"quoteKeys: false\", () => {\n\t\tconst data = { a: 1, b: \"foo\" }\n\t\tattest(printable(data, { quoteKeys: false })).snap('{a: 1, b: \"foo\"}')\n\t})\n\n\tit(\"quoteKeys: false, indent\", () => {\n\t\tconst data = { a: [1, { b: \"foo\" }] }\n\t\tattest(printable(data, { indent: 2, quoteKeys: false })).snap(`{\n  a: [\n    1,\n    {\n      b: \"foo\"\n    }\n  ]\n}`)\n\t})\n\n\tit(\"quoteKeys: false, non-identifier key\", () => {\n\t\tconst data = { \"a-b\": 1 }\n\t\tattest(printable(data, { quoteKeys: false })).snap('{\"a-b\": 1}')\n\t})\n\n\tit(\"quoteKeys: false, symbol key\", () => {\n\t\tconst s = Symbol(\"symbolNoQuote\")\n\t\tconst data = { [s]: 1 }\n\t\tattest(printable(data, { quoteKeys: false })).snap(\n\t\t\t\"{Symbol(symbolNoQuote): 1}\"\n\t\t)\n\t})\n\n\tit(\"quoteKeys: false, indent, symbol key\", () => {\n\t\tconst s = Symbol(\"symbolNoQuoteIndent\")\n\t\tconst data = { [s]: { nested: true } }\n\t\tattest(printable(data, { indent: 2, quoteKeys: false })).snap(`{\n  Symbol(symbolNoQuoteIndent): {\n    nested: true\n  }\n}`)\n\t})\n\n\tit(\"cycle\", () => {\n\t\tconst data: any = { a: 1 }\n\t\tdata.cycle = data\n\t\tattest(printable(data)).snap('{\"a\":1,\"cycle\":\"(cycle)\"}')\n\t})\n\n\tit(\"cycle array\", () => {\n\t\tconst data: any[] = [1]\n\t\tdata.push(data)\n\t\tattest(printable(data)).snap('[1,\"(cycle)\"]')\n\t})\n\n\tit(\"function\", () => {\n\t\tconst printableFunctionTest = () => {}\n\t\tattest(printable(printableFunctionTest)).snap(\n\t\t\t\"Function(printableFunctionTest)\"\n\t\t)\n\t})\n\n\tit(\"date\", () => {\n\t\tconst d = new Date(\"2023-10-03T14:30:15.123Z\")\n\t\tattest(printable(d)).snap(\"10:30:15.123 AM, October 3, 2023\")\n\t})\n\n\tit(\"date only year\", () => {\n\t\tconst d = new Date(\"2023-01-01T00:00:00.000Z\")\n\t\tattest(printable(d)).snap(\"7:00 PM, December 31, 2022\")\n\t})\n\n\tit(\"date only date\", () => {\n\t\tconst d = new Date(\"2023-05-15T00:00:00.000Z\")\n\t\tattest(printable(d)).snap(\"8:00 PM, May 14, 2023\")\n\t})\n\n\tit(\"instance with expression\", () => {\n\t\tclass Type {\n\t\t\texpression = \"number > 5\"\n\t\t}\n\t\tattest(printable(new Type())).snap(\"number > 5\")\n\t})\n\n\tit(\"custom constructor\", () => {\n\t\tclass MyClass {}\n\t\tconst instance = new MyClass()\n\t\tattest(printable(instance)).snap(\"MyClass\")\n\t})\n\n\tit(\"object with toJSON\", () => {\n\t\tconst obj = {\n\t\t\ta: 1,\n\t\t\ttoJSON: () => ({ b: 2 })\n\t\t}\n\t\tattest(printable(obj)).snap('{\"b\":2}')\n\t})\n})\n"
  },
  {
    "path": "ark/util/__tests__/records.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport {\n\tenumValues,\n\ttype merge,\n\ttype unionToPropwiseXor,\n\ttype withJsDoc,\n\ttype DynamicBase,\n\tCastableBase\n} from \"@ark/util\"\n\ncontextualize(() => {\n\tit(\"identical keys\", () => {\n\t\tinterface Source {\n\t\t\t/** is a foo */\n\t\t\tfoo?: string\n\t\t}\n\n\t\tinterface Target {\n\t\t\tfoo: \"bar\"\n\t\t}\n\n\t\ttype Result = withJsDoc<Target, Source>\n\n\t\tconst result: Result = { foo: \"bar\" }\n\t\t// should have annotation \"is a foo\"\n\t\tconst { foo } = result\n\n\t\tattest(foo)\n\n\t\tattest<Result, Target>()\n\t})\n\n\tit(\"less keys\", () => {\n\t\tinterface Source {\n\t\t\t/** is a foo */\n\t\t\tfoo?: string\n\t\t\tbar: number\n\t\t}\n\n\t\tinterface Target {\n\t\t\tfoo: \"foo\"\n\t\t}\n\n\t\ttype Result = withJsDoc<Target, Source>\n\n\t\tconst result: Result = { foo: \"foo\" }\n\t\t// should have annotation \"is a foo\"\n\t\tconst { foo } = result\n\n\t\tattest(foo)\n\n\t\tattest<withJsDoc<Target, Source>, Target>()\n\t})\n\n\tit(\"more keys\", () => {\n\t\tinterface Source {\n\t\t\t/** is a foo */\n\t\t\tfoo?: string\n\t\t}\n\n\t\tinterface Target {\n\t\t\tfoo: \"foo\"\n\t\t\tbaz: \"baz\"\n\t\t}\n\n\t\ttype Result = withJsDoc<Target, Source>\n\n\t\tconst result: Result = { foo: \"foo\", baz: \"baz\" }\n\t\t// should have annotation \"is a foo\"\n\t\tconst { foo } = result\n\n\t\tattest(foo)\n\n\t\tattest<withJsDoc<Target, Source>, Target>()\n\t})\n\n\tit(\"requires optional keys on target\", () => {\n\t\tinterface Source {\n\t\t\t/** is a foo */\n\t\t\tfoo?: string\n\t\t}\n\n\t\tinterface Target {\n\t\t\tfoo?: \"foo\"\n\t\t}\n\n\t\ttype Result = withJsDoc<Target, Source>\n\n\t\tconst result: Result = { foo: \"foo\" }\n\t\t// should have annotation \"is a foo\"\n\t\tconst { foo } = result\n\n\t\tattest(foo)\n\n\t\tattest<withJsDoc<Target, Source>, { foo: \"foo\" }>()\n\t})\n\n\tit(\"merge with index signatures\", () => {\n\t\ttype t = merge<\n\t\t\t{ [k: string]: number | string; foo?: 1; bar: 1 },\n\t\t\t{ [k: string]: number; bar: 0; baz?: 0 }\n\t\t>\n\n\t\tattest<\n\t\t\t{\n\t\t\t\t[x: string]: number\n\t\t\t\tbar: 0\n\t\t\t\tbaz?: 0\n\t\t\t},\n\t\t\tt\n\t\t>()\n\t})\n\n\tit(\"unionToPropwiseXor\", () => {\n\t\ttype t = unionToPropwiseXor<{ a: 1; b?: 2 } | { c: 3 } | { d?: 4 }>\n\n\t\tattest<\n\t\t\t| {\n\t\t\t\t\ta: 1\n\t\t\t\t\tb?: 2\n\t\t\t\t\tc?: undefined\n\t\t\t\t\td?: undefined\n\t\t\t  }\n\t\t\t| {\n\t\t\t\t\tc: 3\n\t\t\t\t\ta?: undefined\n\t\t\t\t\tb?: undefined\n\t\t\t\t\td?: undefined\n\t\t\t  }\n\t\t\t| {\n\t\t\t\t\td?: 4\n\t\t\t\t\ta?: undefined\n\t\t\t\t\tb?: undefined\n\t\t\t\t\tc?: undefined\n\t\t\t  },\n\t\t\tt\n\t\t>()\n\t})\n\n\tit(\"enumValues\", () => {\n\t\tconst fakeEnum = {\n\t\t\tfoo: 1,\n\t\t\tbar: \"bar\",\n\t\t\tmapped: \"MAPPED\"\n\t\t} as const\n\n\t\t// ts reverse assigns numeric values\n\t\t// need to make sure we don't extract them at runtime\n\t\tObject.assign(fakeEnum, {\n\t\t\t1: \"foo\"\n\t\t})\n\n\t\tattest<(1 | \"bar\" | \"MAPPED\")[]>(enumValues(fakeEnum)).snap([\n\t\t\t1,\n\t\t\t\"bar\",\n\t\t\t\"MAPPED\"\n\t\t])\n\t})\n\n\tit(\"DynamicBase assignability\", () => {\n\t\tlet a: DynamicBase<{ foo: 123 }> = { foo: 123 }\n\t\tlet b: DynamicBase<{ bar: 456 }> = { bar: 456 }\n\n\t\t// @ts-expect-error - Without `Uses` this would succeed.\n\t\ta = b\n\n\t\t// @ts-expect-error - Without `Uses` this would succeed.\n\t\tb = a\n\n\t\tconst c: DynamicBase<{ foo: 123 }> = { foo: 123 }\n\t\tconst d: DynamicBase<{ foo: number }> = c\n\t})\n\n\tit(\"CastableBase assignability\", () => {\n\t\tlet a = new CastableBase<{ foo: 123 }>()\n\t\tlet b = new CastableBase<{ bar: 456 }>()\n\n\t\t// @ts-expect-error - Without `#uses` this would succeed.\n\t\ta = b\n\n\t\t// @ts-expect-error - Without `#uses` this would succeed.\n\t\tb = a\n\n\t\tconst c = new CastableBase<{ foo: 123 }>()\n\t\tconst d: CastableBase<{ foo: number }> = c\n\t})\n})\n"
  },
  {
    "path": "ark/util/__tests__/registry.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { readPackageJson } from \"@ark/fs\"\nimport { arkUtilVersion } from \"@ark/util\"\n\ncontextualize(() => {\n\tit(\"version matches package.json\", () => {\n\t\tconst { version } = readPackageJson()\n\t\tattest(arkUtilVersion).equals(version)\n\t})\n})\n"
  },
  {
    "path": "ark/util/__tests__/string.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { anchoredSource, deanchoredSource } from \"@ark/util\"\n\ncontextualize(() => {\n\tit(\"anchors a simple source correctly\", () => {\n\t\tconst source = \"abc\"\n\t\tconst anchored = anchoredSource(source)\n\t\tattest(anchored).equals(\"^(?:abc)$\")\n\t})\n\n\tit(\"re-anchors an already anchored source correctly\", () => {\n\t\tconst source = \"^abc$\"\n\t\tconst anchored = anchoredSource(source)\n\t\tattest(anchored).equals(\"^(?:^abc$)$\")\n\t})\n\n\tit(\"anchors a source with union correctly\", () => {\n\t\tconst source = \"abc|def\"\n\t\tconst anchored = anchoredSource(source)\n\t\tattest(anchored).equals(\"^(?:abc|def)$\")\n\t})\n\n\tit(\"deanchors an anchored source correctly\", () => {\n\t\tconst source = \"^(?:abc)$\"\n\t\tconst deanchored = deanchoredSource(source)\n\t\tattest(deanchored).equals(\"abc\")\n\t})\n\n\tit(\"deanchors a complex anchored source with union correctly\", () => {\n\t\tconst source = \"^(?:abc|def)$\"\n\t\tconst deanchored = deanchoredSource(source)\n\t\tattest(deanchored).equals(\"abc|def\")\n\t})\n\n\tit(\"deanchors a re-anchored source correctly\", () => {\n\t\tconst source = \"^(?:^abc$)$\"\n\t\tconst deanchored = deanchoredSource(source)\n\t\tattest(deanchored).equals(\"^abc$\")\n\t})\n\n\tit(\"leaves a non-anchored source unchanged when deanchoring\", () => {\n\t\tconst source = \"abc\"\n\t\tconst deanchored = deanchoredSource(source)\n\t\tattest(deanchored).equals(\"abc\")\n\t})\n})\n"
  },
  {
    "path": "ark/util/__tests__/traits.scratch.ts",
    "content": "import { Trait, implement } from \"@ark/util\"\n\n// Declare a trait just like a normal class\nexport class Rectangle extends Trait {\n\tlength: number\n\twidth: number\n\n\tconstructor(length: number, width: number) {\n\t\tsuper()\n\t\tthis.length = length\n\t\tthis.width = width\n\t}\n\n\tarea(): number {\n\t\treturn this.length * this.width\n\t}\n\n\tperimeter(): number {\n\t\treturn 2 * (this.length + this.width)\n\t}\n}\n\n// Pass an object to the generic parameter to declare abstract methods\nexport class Rhombus extends Trait<{\n\tabstractMethods: {\n\t\tcalculateArea(): number\n\t}\n\tabstractProps: {\n\t\tlargestAngle: number\n\t}\n}> {\n\tside: number\n\n\tconstructor(side: number) {\n\t\tsuper()\n\t\tthis.side = side\n\t}\n\n\tperimeter(): number {\n\t\treturn this.side * 4\n\t}\n}\n\n// Use compose to implement a type-safe set of Traits\nexport class Square extends implement(\n\tRectangle,\n\tRhombus,\n\t// Here we have to implement any declared abstract methods.\n\t// Notice we don't need to reimplement area() since it can be derived from Rectangle!\n\t{\n\t\tcalculateArea() {\n\t\t\treturn this.side ** 2\n\t\t},\n\t\tconstruct: () => ({ largestAngle: 90 })\n\t}\n) {\n\treadonly isRegular = true\n\n\tconstructor(side: number) {\n\t\t// the composed constructor will be the minimal set of parameters\n\t\t// that satisfies all Traits- in this case (number, number).\n\t\tsuper(side, side)\n\t}\n}\n\n// Instantiate your class as you normally would\nconst square = new Square(5)\n// derived from Rectangle\nsquare.area() //?\n// derived from Rhombus\nsquare.perimeter() //?\n// from Square\nsquare.isRegular //?\n// You can even use `instanceof` or get a list of implemented traits!\nsquare instanceof Square //?\nsquare instanceof Rectangle //?\nsquare instanceof Rhombus //?\nsquare.traitsOf() //?\n"
  },
  {
    "path": "ark/util/__tests__/traits.test.ts",
    "content": "import { attest, contextualize } from \"@ark/attest\"\nimport { Trait, compose, implement } from \"@ark/util\"\nimport { Rectangle, Rhombus, Square } from \"./traits.scratch.ts\"\n\nexport class Describable extends Trait<{\n\tabstractMethods: {\n\t\twriteDefaultDescription(): string\n\t}\n}> {\n\tdescription: string\n\n\tconstructor(rule: unknown, attributes?: { description?: string }) {\n\t\tsuper()\n\t\tthis.description = attributes?.description ?? this.writeDefaultDescription()\n\t}\n}\n\nexport class Boundable<data> extends Trait<{\n\tabstractMethods: { sizeOf(data: data): number }\n}> {\n\tlimit: number | undefined\n\n\tconstructor(rule: { limit?: number }) {\n\t\tsuper()\n\t\tthis.limit = rule.limit\n\t}\n\n\tcheck(data: data): boolean {\n\t\treturn this.limit === undefined || this.sizeOf(data) <= this.limit\n\t}\n}\n\ncontextualize(() => {\n\tit(\"implement\", () => {\n\t\tclass StringChecker extends implement(Describable, Boundable<string>, {\n\t\t\twriteDefaultDescription: () => \"foo\",\n\t\t\tsizeOf: (data: string) => data.length\n\t\t}) {}\n\n\t\tconst shortString = new StringChecker(\n\t\t\t{ limit: 5 },\n\t\t\t{ description: \"a short string\" }\n\t\t)\n\n\t\ttype Params = ConstructorParameters<typeof StringChecker>\n\t\tattest<\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\tlimit?: number\n\t\t\t\t},\n\t\t\t\t(\n\t\t\t\t\t| {\n\t\t\t\t\t\t\tdescription?: string\n\t\t\t\t\t  }\n\t\t\t\t\t| undefined\n\t\t\t\t)?\n\t\t\t],\n\t\t\tParams\n\t\t>()\n\t\tattest(shortString.check(\"foo\")).equals(true)\n\t\tattest(shortString.check(\"toolong\")).equals(false)\n\t\tattest(shortString.description).equals(\"a short string\")\n\t\tattest(shortString.writeDefaultDescription()).equals(\"foo\")\n\n\t\tconst withDefault = new StringChecker({ limit: 5 })\n\t\tattest(withDefault.description).equals(\"foo\")\n\t\tattest([\n\t\t\twithDefault instanceof StringChecker,\n\t\t\twithDefault instanceof Boundable,\n\t\t\twithDefault instanceof Describable\n\t\t]).equals([true, true, true])\n\t})\n\n\tit(\"works with subclasses\", () => {\n\t\tclass Foo extends Boundable<number> {\n\t\t\tgetFoo() {\n\t\t\t\treturn \"foo\"\n\t\t\t}\n\t\t}\n\t\tclass Bar extends implement(Foo, {\n\t\t\tsizeOf: (data: number) => data\n\t\t}) {}\n\t\tconst b = new Bar({ limit: 2 })\n\t\tattest(b.check(1)).equals(true)\n\t\tattest(b.check(3)).equals(false)\n\t\tattest(b.getFoo()).equals(\"foo\")\n\t})\n\n\tit(\"preserves static\", () => {\n\t\tclass A extends Trait {\n\t\t\tstatic readonly a = \"a\"\n\n\t\t\treadonly a = \"a\"\n\t\t}\n\t\tclass B extends Trait<{\n\t\t\tabstractStatics: {\n\t\t\t\tfoo: \"Bar\"\n\t\t\t}\n\t\t}> {\n\t\t\tstatic readonly b = \"b\"\n\n\t\t\treadonly b = \"b\"\n\t\t}\n\n\t\tclass C extends compose(A, B) {\n\t\t\tstatic readonly c = \"c\"\n\n\t\t\treadonly c = \"c\"\n\t\t}\n\n\t\tattest<\"a\">(C.a).equals(\"a\")\n\t\tattest<\"b\">(C.b).equals(\"b\")\n\t\tattest<\"c\">(C.c).equals(\"c\")\n\t\tconst c = new C()\n\t\tattest<\"a\">(c.a).equals(\"a\")\n\t\tattest<\"b\">(c.b).equals(\"b\")\n\t\tattest<\"c\">(c.c).equals(\"c\")\n\t})\n\n\tit(\"trait from trait\", () => {\n\t\tclass A extends Trait {\n\t\t\treadonly a = \"a\"\n\t\t}\n\t\tclass B extends Trait {\n\t\t\treadonly b = \"b\"\n\t\t}\n\t\tclass C extends compose(A, B) {\n\t\t\treadonly c = \"c\"\n\t\t}\n\t\tclass D extends Trait {\n\t\t\treadonly d = \"d\"\n\t\t}\n\t\tclass E extends compose(C, D) {\n\t\t\treadonly e = \"e\"\n\t\t}\n\t\tconst e = new E()\n\t\tattest<\"a\">(e.a).equals(\"a\")\n\t\tattest<\"b\">(e.b).equals(\"b\")\n\t\tattest<\"c\">(e.c).equals(\"c\")\n\t\tattest<\"d\">(e.d).equals(\"d\")\n\t\tattest<\"e\">(e.e).equals(\"e\")\n\t\tattest(e.traitsOf()).equals([A, B, C, D])\n\t})\n\n\tit(\"requires abstract properties be implemented\", () => {\n\t\tclass A extends Trait<{ abstractMethods: { a(): number } }> {}\n\t\tclass B extends Trait<{ abstractMethods: { b(): number } }> {}\n\t\t// @ts-expect-error\n\t\tattest(class C extends implement(A, B, {}) {}).type.errors(\n\t\t\t/missing the following properties.*(?:b, a|a, b)/\n\t\t)\n\t})\n\n\tit(\"example\", () => {\n\t\tconst square = new Square(5)\n\t\tattest(square.area()).equals(25)\n\t\tattest(square.perimeter()).equals(20)\n\t\tattest(square.isRegular).equals(true)\n\t\tattest(square instanceof Square).equals(true)\n\t\tattest(square instanceof Rectangle).equals(true)\n\t\tattest(square instanceof Rhombus).equals(true)\n\t\tattest(square.traitsOf()).equals([Rectangle, Rhombus])\n\t})\n})\n"
  },
  {
    "path": "ark/util/arrays.ts",
    "content": "import type { GuardablePredicate } from \"./functions.ts\"\nimport type { anyOrNever, conform } from \"./generics.ts\"\nimport type { isDisjoint } from \"./intersections.ts\"\nimport type { parseNonNegativeInteger } from \"./numbers.ts\"\n\ntype DuplicateData<val = unknown> = { element: val; indices: number[] }\n\n/**\n * Extracts duplicated elements and their indices from an array, returning them.\n *\n * Note that given `a === b && b === c`, then `c === a` must be `true` for this to give accurate results.\n *\n * @param arr The array to extract duplicate elements from.\n */ export const getDuplicatesOf = <const arr extends array>(\n\tarr: arr,\n\topts?: ComparisonOptions<arr[number]>\n): DuplicateData<arr[number]>[] => {\n\tconst isEqual = opts?.isEqual ?? ((l, r) => l === r)\n\n\tconst elementFirstSeenIndx: Map<arr[number], number> = new Map()\n\tconst duplicates: DuplicateData<arr[number]>[] = []\n\n\tfor (const [indx, element] of arr.entries()) {\n\t\tconst duplicatesIndx = duplicates.findIndex(duplicate =>\n\t\t\tisEqual(duplicate.element, element)\n\t\t)\n\t\tif (duplicatesIndx !== -1) {\n\t\t\t// This is at least the third occurrence of an item equal to `element`,\n\t\t\t// so add this index to the list of indices where the element is duplicated.\n\t\t\tduplicates[duplicatesIndx].indices.push(indx)\n\t\t\tcontinue\n\t\t}\n\n\t\t// At this point, we know this is either the first\n\t\t// or second occurrence of an item equal to `element`...\n\n\t\tlet found = false\n\t\tfor (const [existingElement, firstSeenIndx] of elementFirstSeenIndx) {\n\t\t\tif (isEqual(element, existingElement)) {\n\t\t\t\t// This is the second occurrence of an item equal to `element`,\n\t\t\t\t// so store it as a duplicate.\n\t\t\t\tfound = true\n\t\t\t\tduplicates.push({\n\t\t\t\t\telement: existingElement,\n\t\t\t\t\tindices: [firstSeenIndx, indx]\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tif (!found) {\n\t\t\t// We haven't seen this element before,\n\t\t\t// so just store the index it was first seen\n\t\t\telementFirstSeenIndx.set(element, indx)\n\t\t}\n\t}\n\n\treturn duplicates\n}\n\nexport type pathToString<\n\tsegments extends string[],\n\tdelimiter extends string = \"/\"\n> = segments extends [] ? \"/\" : join<segments, delimiter>\n\nexport const join = <segments extends array<string>, delimiter extends string>(\n\tsegments: segments,\n\tdelimiter: delimiter\n): join<segments, delimiter> => segments.join(delimiter) as never\n\nexport type join<\n\tsegments extends array<string>,\n\tdelimiter extends string,\n\tresult extends string = \"\"\n> =\n\tsegments extends (\n\t\treadonly [infer head extends string, ...infer tail extends string[]]\n\t) ?\n\t\tjoin<\n\t\t\ttail,\n\t\t\tdelimiter,\n\t\t\tresult extends \"\" ? head : `${result}${delimiter}${head}`\n\t\t>\n\t:\tresult\n\nexport const getPath = (root: unknown, path: string[]): unknown => {\n\tlet result: any = root\n\tfor (const segment of path) {\n\t\tif (typeof result !== \"object\" || result === null) return undefined\n\n\t\tresult = result[segment]\n\t}\n\treturn result\n}\n\nexport const intersectUniqueLists = <item>(\n\tl: readonly item[],\n\tr: readonly item[]\n): item[] => {\n\tconst intersection = [...l]\n\tfor (const item of r) if (!l.includes(item)) intersection.push(item)\n\n\treturn intersection\n}\n\nexport type filter<t extends array, constraint, result extends unknown[] = []> =\n\tt extends readonly [infer head, ...infer tail] ?\n\t\tfilter<\n\t\t\ttail,\n\t\t\tconstraint,\n\t\t\thead extends constraint ? [...result, head] : result\n\t\t>\n\t:\tresult\n\nexport type array<t = unknown> = readonly t[]\n\nexport declare namespace array {\n\texport type multiply<t extends array, count extends number> = _multiply<\n\t\tt,\n\t\t[],\n\t\tcount,\n\t\t[]\n\t>\n\n\ttype _multiply<\n\t\tbase extends array,\n\t\tresult extends array,\n\t\tcount extends number,\n\t\ti extends 1[]\n\t> =\n\t\ti[\"length\"] extends count ? result\n\t\t:\t_multiply<base, [...result, ...base], count, [...i, 1]>\n\n\texport type repeat<element, count extends number> = buildFromSegments<\n\t\telement,\n\t\t[],\n\t\texponentials.max<count>,\n\t\tcount\n\t>\n\n\ttype buildFromSegments<\n\t\telement,\n\t\tresult extends 1[],\n\t\tsegments extends 1[][],\n\t\tcount extends number,\n\t\tnext extends 1[] = [...result, ...segments[0]]\n\t> =\n\t\t// next is just right\n\t\tnext[\"length\"] extends count ? { [i in keyof next]: element }\n\t\t: `${count}` extends keyof next ?\n\t\t\t// next is too long\n\t\t\tbuildFromSegments<element, result, nextSegments<segments>, count>\n\t\t:\t// next is too short\n\t\t\tbuildFromSegments<element, next, nextSegments<segments>, count>\n\n\ttype nextSegments<segments extends 1[][]> =\n\t\tsegments extends [unknown, ...infer nextSegments extends 1[][]] ?\n\t\t\tnextSegments\n\t\t:\tnever\n\n\texport type minLength<element, minLength extends number> = readonly [\n\t\t...multiply<[element], minLength>,\n\t\t...element[]\n\t]\n}\n\nexport type listable<t> = t | readonly t[]\n\nexport type flattenListable<t> = t extends array<infer element> ? element : t\n\nexport type longerThan<t extends array, n extends number> =\n\t`${n}` extends keyof t ? true : false\n\nexport type CollapsingList<t = unknown> =\n\t| readonly []\n\t| t\n\t| readonly [t, t, ...t[]]\n\nexport type headOf<t extends array> = t[0]\n\nexport type tailOf<t extends array> =\n\tt extends readonly [unknown, ...infer tail] ? tail : never\n\nexport type lastIndexOf<t extends array> = tailOf<t>[\"length\"]\n\nexport type lastOf<t extends array> = t[lastIndexOf<t>]\n\nexport type initOf<t extends array> =\n\tt extends readonly [...infer init, unknown] ? init : never\n\nexport type numericStringKeyOf<t extends array> = Extract<keyof t, `${number}`>\n\nexport type arrayIndexOf<a extends array> =\n\tkeyof a extends infer k ? parseNonNegativeInteger<k & string> : never\n\nexport type liftArray<t> =\n\tt extends array ?\n\t\t[t] extends [anyOrNever] ?\n\t\t\tt[]\n\t\t:\tt\n\t:\tt[]\n\nexport const liftArray = <t>(data: t): liftArray<t> =>\n\t(Array.isArray(data) ? data : [data]) as never\n\n/**\n * Splits an array into two arrays based on the result of a predicate\n *\n * @param predicate - The guard function used to determine which items to include.\n * @returns A tuple containing two arrays:\n * \t\t\t\t- the first includes items for which `predicate` returns true\n * \t\t\t\t- the second includes items for which `predicate` returns false\n *\n * @example\n * const list = [1, \"2\", \"3\", 4, 5];\n * const [numbers, strings] = spliterate(list, (x) => typeof x === \"number\");\n * // Type: number[]\n * // Output: [1, 4, 5]\n * console.log(evens);\n * // Type: string[]\n * // Output: [\"2\", \"3\"]\n * console.log(odds);\n */\nexport const spliterate = <item, included extends item>(\n\tarr: readonly item[],\n\tpredicate: GuardablePredicate<item, included>\n): [\n\tincluded: included[],\n\texcluded: [item] extends [included] ? item[] : Exclude<item, included>[]\n] => {\n\tconst result: [unknown[], unknown[]] = [[], []]\n\tfor (const item of arr) {\n\t\tif (predicate(item)) result[0].push(item)\n\t\telse result[1].push(item)\n\t}\n\treturn result as never\n}\n\nexport const ReadonlyArray = Array as unknown as new <T>(\n\t...args: ConstructorParameters<typeof Array<T>>\n) => ReadonlyArray<T>\n\nexport const includes = <a extends array>(\n\tarray: a,\n\telement: unknown\n): element is a[number] => array.includes(element)\n\nexport const range = (length: number, offset = 0): number[] =>\n\t[...new Array(length)].map((_, i) => i + offset)\n\nexport type AppendOptions = {\n\t/** If true, adds the element to the beginning of the array instead of the end */\n\tprepend?: boolean\n}\n\n/**\n * Adds a value or array to an array, returning the concatenated result\n */\nexport const append = <\n\tto extends unknown[] | undefined,\n\tvalue extends appendableValue<to>\n>(\n\tto: to,\n\tvalue: value,\n\topts?: AppendOptions\n): to & {} => {\n\tif (to === undefined) {\n\t\treturn (\n\t\t\tvalue === undefined ? []\n\t\t\t: Array.isArray(value) ? value\n\t\t\t: [value]) as never\n\t}\n\n\tif (opts?.prepend) {\n\t\tif (Array.isArray(value)) to.unshift(...value)\n\t\telse to.unshift(value as never)\n\t} else {\n\t\tif (Array.isArray(value)) to.push(...value)\n\t\telse to.push(value as never)\n\t}\n\n\treturn to as never\n}\n\n// ensure a nested array element is not treated as a list to append\nexport type appendableValue<to extends array | undefined> =\n\tto extends array<infer element> ?\n\t\telement extends array ?\n\t\t\tarray<element>\n\t\t:\tlistable<element>\n\t:\tnever\n\n/**\n * Concatenates an element or list with a readonly list\n */\nexport const conflatenate = <element>(\n\tto: readonly element[] | undefined | null,\n\telementOrList: appendableValue<readonly element[]> | undefined | null\n): readonly element[] => {\n\tif (elementOrList === undefined || elementOrList === null)\n\t\treturn to ?? ([] as never)\n\n\tif (to === undefined || to === null) return liftArray(elementOrList) as never\n\n\treturn to.concat(elementOrList) as never\n}\n\n/**\n * Concatenates a variadic list of elements or lists with a readonly list\n */\nexport const conflatenateAll = <element>(\n\t...elementsOrLists: (listable<element> | undefined | null)[]\n): readonly element[] =>\n\telementsOrLists.reduce<readonly element[]>(conflatenate as never, [])\n\nexport interface ComparisonOptions<t = unknown> {\n\tisEqual?: (l: t, r: t) => boolean\n}\n\n/**\n * Appends a value or concatenates an array to an array if it is not already included, returning the array\n */\nexport const appendUnique = <to extends unknown[]>(\n\tto: to | undefined,\n\tvalue: NoInfer<Readonly<to> | to[number]>,\n\topts?: ComparisonOptions<to[number]>\n): to => {\n\tif (to === undefined)\n\t\treturn Array.isArray(value) ? (value as never) : ([value] as never)\n\n\tconst isEqual = opts?.isEqual ?? ((l, r) => l === r)\n\tfor (const v of liftArray(value))\n\t\tif (!to.some(existing => isEqual(existing as never, v as never))) to.push(v)\n\n\treturn to\n}\n\nexport type groupableKeyOf<o> =\n\tkeyof o extends infer k ?\n\t\tk extends keyof o ?\n\t\t\to[k] extends PropertyKey ?\n\t\t\t\tk\n\t\t\t:\tnever\n\t\t:\tnever\n\t:\tnever\n\nexport type groupBy<element, discriminant extends groupableKeyOf<element>> = {\n\t[k in element[discriminant] & PropertyKey]?: (element extends unknown ?\n\t\tisDisjoint<element[discriminant], k> extends true ?\n\t\t\tnever\n\t\t:\telement\n\t:\tnever)[]\n} & unknown\n\nexport const groupBy = <element, discriminant extends groupableKeyOf<element>>(\n\tarray: readonly element[],\n\tdiscriminant: discriminant\n): groupBy<element, discriminant> =>\n\tarray.reduce<Record<PropertyKey, any>>((result, item) => {\n\t\tconst key = item[discriminant] as never\n\t\tresult[key] = append(result[key], item)\n\t\treturn result\n\t}, {}) as never\n\nexport const arrayEquals = <element>(\n\tl: array<element>,\n\tr: array<element>,\n\topts?: ComparisonOptions<element>\n): boolean =>\n\tl.length === r.length &&\n\tl.every(\n\t\topts?.isEqual ?\n\t\t\t(lItem, i) => opts.isEqual!(lItem, r[i])\n\t\t:\t(lItem, i) => lItem === r[i]\n\t)\n\nexport type validateExhaustiveKeys<\n\tkeys extends readonly PropertyKey[],\n\texpectedKey extends PropertyKey\n> =\n\tkeys extends readonly [infer head, ...infer tail extends PropertyKey[]] ?\n\t\treadonly [\n\t\t\tconform<head, expectedKey>,\n\t\t\t...validateExhaustiveKeys<tail, Exclude<expectedKey, head>>\n\t\t]\n\t: [expectedKey] extends [never] ? []\n\t: [expectedKey]\n\nexport type applyElementLabels<\n\tt extends readonly unknown[],\n\tlabels extends readonly unknown[]\n> =\n\tlabels extends [unknown, ...infer labelsTail] ?\n\t\tt extends readonly [infer head, ...infer tail] ?\n\t\t\treadonly [\n\t\t\t\t...labelElement<head, labels>,\n\t\t\t\t...applyElementLabels<tail, labelsTail>\n\t\t\t]\n\t\t:\tapplyOptionalElementLabels<Required<t>, labels>\n\t:\tt\n\ntype applyOptionalElementLabels<\n\tt extends readonly unknown[],\n\tlabels extends readonly unknown[]\n> =\n\tlabels extends readonly [unknown, ...infer labelsTail] ?\n\t\tt extends readonly [infer head, ...infer tail] ?\n\t\t\t[\n\t\t\t\t...labelOptionalElement<head, labels>,\n\t\t\t\t...applyOptionalElementLabels<tail, labelsTail>\n\t\t\t]\n\t\t:\tapplyRestElementLabels<t, labels>\n\t:\tt\n\ntype applyRestElementLabels<\n\tt extends readonly unknown[],\n\tlabels extends readonly unknown[]\n> =\n\tt extends readonly [] ? []\n\t: labels extends readonly [unknown, ...infer tail] ?\n\t\t[...labelOptionalElement<t[0], labels>, ...applyRestElementLabels<t, tail>]\n\t:\tt\n\ntype labelElement<element, labels extends readonly unknown[]> =\n\tlabels extends readonly [unknown] ? { [K in keyof labels]: element }\n\t: labels extends readonly [...infer head, unknown] ?\n\t\tlabelElement<element, head>\n\t:\t[_: element]\n\ntype labelOptionalElement<element, label extends readonly unknown[]> =\n\tlabel extends readonly [unknown] ? { [K in keyof label]?: element }\n\t: label extends readonly [...infer head, unknown] ?\n\t\tlabelOptionalElement<element, head>\n\t:\t[_?: element]\n\nexport type setIndex<\n\tarr extends readonly unknown[],\n\ti extends number,\n\tto extends arr[number]\n> =\n\t// preserve mutability of original array\n\tarr extends arr[number][] ? _setIndex<arr, i, to, []>\n\t:\tReadonly<_setIndex<arr, i, to, []>>\n\ntype _setIndex<\n\tarr extends readonly unknown[],\n\ti extends number,\n\tto extends arr[number],\n\tresult extends arr[number][]\n> =\n\tarr extends readonly [infer head, ...infer tail] ?\n\t\t_setIndex<tail, i, to, [...result, result[\"length\"] extends i ? to : head]>\n\t:\tresult\n\ntype zero = []\n\ntype one = [1]\n\ntype two = [1, 1]\n\ntype three = [...two, ...two]\n\ntype four = [...three, ...three]\n\ntype five = [...four, ...four]\n\ntype six = [...five, ...five]\n\ntype seven = [...six, ...six]\n\ntype eight = [...seven, ...seven]\n\ntype nine = [...eight, ...eight]\n\ntype ten = [...nine, ...nine]\n\ntype eleven = [...ten, ...ten]\n\ntype twelve = [...eleven, ...eleven]\n\ntype thirteen = [...twelve, ...twelve]\n\ntype fourteen = [...thirteen, ...thirteen]\n\n// extending this pattern further results in:\n// \"Expression produces a tuple type that is too large to represnet\"\n\ntype exponentials = [\n\tfourteen,\n\tthirteen,\n\ttwelve,\n\televen,\n\tten,\n\tnine,\n\teight,\n\tseven,\n\tsix,\n\tfive,\n\tfour,\n\tthree,\n\ttwo,\n\tone,\n\tzero\n]\n\ndeclare namespace exponentials {\n\texport type max<n extends number> = _max<n, exponentials>\n\n\ttype _max<n extends number, filtered extends unknown[]> =\n\t\t`${n}` extends keyof filtered[0] ? _max<n, tailOf<filtered>> : filtered\n}\n"
  },
  {
    "path": "ark/util/clone.ts",
    "content": "import { getBuiltinNameOfConstructor } from \"./objectKinds.ts\"\n\n/** Shallowly copy the properties of the object. */\nexport const shallowClone: <input extends object>(\n\tinput: input\n) => input = input => _clone(input, null)\n\n/** Deeply copy the properties of the a non-subclassed Object, Array or Date.*/\nexport const deepClone = <input extends object>(input: input): input =>\n\t_clone(input, new Map())\n\nconst _clone = (input: unknown, seen: Map<unknown, unknown> | null): any => {\n\tif (typeof input !== \"object\" || input === null) return input\n\tif (seen?.has(input)) return seen.get(input)\n\n\tconst builtinConstructorName = getBuiltinNameOfConstructor(input.constructor)\n\n\tif (builtinConstructorName === \"Date\")\n\t\treturn new Date((input as Date).getTime())\n\n\t// we don't try and clone other prototypes here since this we can't guarantee arrow functions attached to the object\n\t// are rebound in case they reference `this` (see https://x.com/colinhacks/status/1818422039210049985)\n\tif (builtinConstructorName && builtinConstructorName !== \"Array\") return input\n\n\tconst cloned =\n\t\tArray.isArray(input) ?\n\t\t\tinput.slice()\n\t\t:\tObject.create(Object.getPrototypeOf(input))\n\n\tconst propertyDescriptors = Object.getOwnPropertyDescriptors(input)\n\n\tif (seen) {\n\t\tseen.set(input, cloned)\n\t\tfor (const k in propertyDescriptors) {\n\t\t\tconst desc = propertyDescriptors[k]\n\n\t\t\tif (\"get\" in desc || \"set\" in desc) continue\n\t\t\tdesc.value = _clone(desc.value, seen)\n\t\t}\n\t}\n\n\tObject.defineProperties(cloned, propertyDescriptors)\n\n\treturn cloned\n}\n"
  },
  {
    "path": "ark/util/describe.ts",
    "content": "import type { array } from \"./arrays.ts\"\nimport type { describeDomainOf, domainOf, inferDomain } from \"./domain.ts\"\nimport type { anyOrNever, satisfy, Stringifiable } from \"./generics.ts\"\nimport type { describeObject } from \"./objectKinds.ts\"\nimport type { stringifyUnion } from \"./unionToTuple.ts\"\n\nexport type DescribeOptions = {\n\tincludeArticles?: boolean\n\tbranchDelimiter?: string\n}\n\nexport type typeToString<t, opts extends DescribeOptions = {}> = stringifyUnion<\n\t[t] extends [anyOrNever] ?\n\t\tunknown extends t ?\n\t\t\t\"any\"\n\t\t:\t\"never\"\n\t: unknown extends t ? \"unknown\"\n\t: boolean extends t ?\n\t\t| \"boolean\"\n\t\t| ([t] extends [boolean] ? never : typeToString<Exclude<t, boolean>, opts>)\n\t: t extends array ? arrayTypeToString<t, opts>\n\t: t extends object ? describeObject<t, opts>\n\t: t extends Stringifiable ? stringifiableToString<t, opts>\n\t: describeDomainOf<t, opts>,\n\topts[\"branchDelimiter\"] extends string ? opts[\"branchDelimiter\"]\n\t:\tdescribeDefaults[\"branchDelimiter\"]\n>\n\ntype stringifiableToString<\n\tt extends Stringifiable,\n\topts extends DescribeOptions\n> =\n\t// if it's the base wideneded domain, use that name\n\tinferDomain<domainOf<t>> extends t ? describeDomainOf<t, opts>\n\t:\t// otherwise if it's a literal, use that\n\t\t`${t}`\n\nexport type describe<t> = typeToString<\n\tt,\n\t{\n\t\tincludeArticles: true\n\t\tbranchDelimiter: \" or \"\n\t}\n>\n\ntype arrayTypeToString<t extends array, opts extends DescribeOptions> =\n\ttypeToString<t[number], opts> extends infer element extends string ?\n\t\topts[\"includeArticles\"] extends true ? describeArrayOf<element>\n\t\t: includesDelimiter<element, opts> extends true ? `(${element})[]`\n\t\t: `${element}[]`\n\t:\tnever\n\ntype describeArrayOf<element extends string> =\n\telement extends \"unknown\" ? \"an array\" : `an array of ${element}`\n\ntype includesDelimiter<s extends string, opts extends DescribeOptions> =\n\ts extends (\n\t\t`${string}${opts[\"branchDelimiter\"] extends string ? opts[\"branchDelimiter\"] : describeDefaults[\"branchDelimiter\"]}${string}`\n\t) ?\n\t\ttrue\n\t:\tfalse\n\nexport type describeDefaults = satisfy<\n\tRequired<DescribeOptions>,\n\t{\n\t\tincludeArticles: false\n\t\tbranchDelimiter: \" | \"\n\t}\n>\n"
  },
  {
    "path": "ark/util/domain.ts",
    "content": "import type { describeDefaults, DescribeOptions } from \"./describe.ts\"\nimport type { show } from \"./generics.ts\"\nimport type { stringifyUnion } from \"./unionToTuple.ts\"\n\nexport type JsTypeOf =\n\t| \"object\"\n\t| \"function\"\n\t| \"number\"\n\t| \"bigint\"\n\t| \"boolean\"\n\t| \"string\"\n\t| \"symbol\"\n\t| \"undefined\"\n\t| \"null\"\n\nexport const hasDomain = <data, domain extends Domain>(\n\tdata: data,\n\tkind: domain\n): data is data & inferDomain<domain> => domainOf(data as any) === kind\n\ntype TypesByDomain = {\n\tbigint: bigint\n\tboolean: boolean\n\tnumber: number\n\tobject: object\n\tstring: string\n\tsymbol: symbol\n\tundefined: undefined\n\tnull: null\n}\n\nexport type inferDomain<kind extends Domain> =\n\tDomain extends kind ? unknown : TypesByDomain[kind]\n\nexport type Domain = show<keyof TypesByDomain>\n\nexport type NullishDomain = \"undefined\" | \"null\"\n\nexport type NonNullishDomain = Exclude<Domain, NullishDomain>\n\nexport type PrimitiveDomain = Exclude<Domain, \"object\">\n\nexport type Primitive = inferDomain<PrimitiveDomain>\n\nexport type domainOf<data> =\n\tunknown extends data ? Domain\n\t: data extends object ? \"object\"\n\t: data extends string ? \"string\"\n\t: data extends number ? \"number\"\n\t: data extends boolean ? \"boolean\"\n\t: data extends undefined ? \"undefined\"\n\t: data extends null ? \"null\"\n\t: data extends bigint ? \"bigint\"\n\t: data extends symbol ? \"symbol\"\n\t: never\n\nexport const domainOf = <data>(data: data): domainOf<data> => {\n\tconst builtinType = typeof data\n\treturn (\n\t\tbuiltinType === \"object\" ?\n\t\t\tdata === null ?\n\t\t\t\t\"null\"\n\t\t\t:\t\"object\"\n\t\t: builtinType === \"function\" ? \"object\"\n\t\t: builtinType) as domainOf<data>\n}\n\n/** Each domain's completion for the phrase \"must be _____\" */\nexport const domainDescriptions = {\n\tboolean: \"boolean\",\n\tnull: \"null\",\n\tundefined: \"undefined\",\n\tbigint: \"a bigint\",\n\tnumber: \"a number\",\n\tobject: \"an object\",\n\tstring: \"a string\",\n\tsymbol: \"a symbol\"\n} as const satisfies Record<Domain, string>\n\nexport const jsTypeOfDescriptions = {\n\t...domainDescriptions,\n\tfunction: \"a function\"\n} as const satisfies Record<JsTypeOf, string>\n\nexport type domainDescriptions = typeof domainDescriptions\n\nexport type describeDomainOf<\n\tt,\n\topts extends DescribeOptions = {}\n> = stringifyUnion<\n\topts[\"includeArticles\"] extends true ? domainDescriptions[domainOf<t>]\n\t:\tdomainOf<t>,\n\topts[\"branchDelimiter\"] extends string ? opts[\"branchDelimiter\"]\n\t:\tdescribeDefaults[\"branchDelimiter\"]\n>\n"
  },
  {
    "path": "ark/util/errors.ts",
    "content": "import type { brand } from \"./generics.ts\"\nimport type { CastableBase } from \"./records.ts\"\n\nexport class InternalArktypeError extends Error {}\n\nexport const throwInternalError: (message: string) => never = message =>\n\tthrowError(message, InternalArktypeError)\n\nexport const throwError: (\n\tmessage: string,\n\tctor?: new (message: string) => Error\n) => never = (message, ctor = Error) => {\n\tthrow new ctor(message)\n}\n\nexport class ParseError extends Error {\n\treadonly name = \"ParseError\"\n}\n\nexport const throwParseError: (message: string) => never = message =>\n\tthrowError(message, ParseError)\n\n/**\n *  TypeScript won't suggest strings beginning with a space as properties.\n *  Useful for symbol-like string properties.\n */\nexport const noSuggest = <s extends string>(s: s): noSuggest<s> => ` ${s}`\n\n/**\n *  TypeScript won't suggest strings beginning with a space as properties.\n *  Useful for symbol-like string properties.\n */\nexport type noSuggest<s extends string = string> = ` ${s}`\n\n/** Unrendered character (U+200B) used to mark a string type */\nexport const ZeroWidthSpace = \"\\u{200B}\"\n\n/** Unrendered character (U+200B) used to mark a string type */\nexport type ZeroWidthSpace = typeof ZeroWidthSpace\n\nexport type ErrorMessage<message extends string = string> =\n\t`${message}${ZeroWidthSpace}`\n\nexport interface ErrorType<ctx extends {} = {}> extends CastableBase<ctx> {\n\t[brand]: \"ErrorType\"\n}\n\nexport type Completion<text extends string = string> =\n\t`${text}${ZeroWidthSpace}${ZeroWidthSpace}`\n"
  },
  {
    "path": "ark/util/flatMorph.ts",
    "content": "import { append, type array, type listable } from \"./arrays.ts\"\nimport type { conform, show } from \"./generics.ts\"\nimport type { Key } from \"./keys.ts\"\nimport type { Entry, entryOf } from \"./records.ts\"\nimport type { intersectUnion } from \"./unionToTuple.ts\"\n\ntype objectFromListableEntries<transformed extends readonly GroupableEntry[]> =\n\tshow<intersectUnion<fromGroupableEntries<transformed>>>\n\ntype fromGroupableEntries<entries extends readonly GroupableEntry[]> = {\n\t[entry in entries[number] as entry extends GroupedEntry ? entry[0][\"group\"]\n\t:\tconform<entry[0], PropertyKey>]: entry extends GroupedEntry ? entry[1][]\n\t:\tentry[1]\n}\n\ntype arrayFromListableEntries<transformed extends Entry> =\n\tEntry<number, never> extends transformed ? transformed[1][]\n\t:\t_arrayFromListableEntries<transformed, []>\n\ntype _arrayFromListableEntries<\n\ttransformed extends Entry,\n\tresult extends unknown[]\n> =\n\t[transformed] extends [never] ? result\n\t: Extract<transformed, Entry<result[\"length\"]>> extends (\n\t\tinfer next extends Entry\n\t) ?\n\t\tExclude<transformed, next> extends infer remaining extends Entry ?\n\t\t\t[transformed] extends [remaining] ?\n\t\t\t\t[...result, ...transformed[1][]]\n\t\t\t:\t_arrayFromListableEntries<remaining, [...result, next[1]]>\n\t\t:\tnever\n\t:\t[...result, ...transformed[1][]]\n\ntype extractEntrySets<e extends listable<GroupableEntry>> =\n\te extends readonly GroupableEntry[] ? e : [e]\n\ntype extractEntries<e extends listable<Entry>> =\n\te extends readonly Entry[] ? e[number] : e\n\ntype entryArgsWithIndex<o> = {\n\t[k in keyof o]-?: [k: k, v: Exclude<o[k], undefined>, i: number]\n}[keyof o]\n\ntype numericArrayEntry<a extends array> =\n\tnumber extends a[\"length\"] ? [number, a[number]]\n\t:\t{\n\t\t\t[i in keyof a]: i extends `${infer n extends number}` ? [n, a[i]] : never\n\t\t}[number]\n\nexport type GroupedEntry = readonly [key: { group: Key }, value: unknown]\n\nexport type GroupableEntry = Entry<Key> | Entry<number> | GroupedEntry\n\nexport type ListableEntry = listable<GroupableEntry>\n\nexport type fromMappedEntries<transformed extends ListableEntry> =\n\t[transformed] extends [listable<Entry<number>>] ?\n\t\tarrayFromListableEntries<extractEntries<transformed>>\n\t:\tobjectFromListableEntries<extractEntrySets<transformed>>\n\nexport type FlatMorph = {\n\t<const o extends array, transformed extends ListableEntry>(\n\t\to: o,\n\t\tflatMapEntry: (...args: numericArrayEntry<o>) => transformed\n\t): fromMappedEntries<transformed>\n\n\t<const o extends object, transformed extends ListableEntry>(\n\t\to: o,\n\t\tflatMapEntry: (...args: entryOf<o>) => transformed\n\t): fromMappedEntries<transformed>\n\n\t<const o extends object, transformed extends ListableEntry>(\n\t\to: o,\n\t\tflatMapEntry: (...args: entryArgsWithIndex<o>) => transformed\n\t): fromMappedEntries<transformed>\n}\n\nexport const flatMorph: FlatMorph = (\n\to: object,\n\tflatMapEntry: (...args: any[]) => listable<GroupableEntry>\n): any => {\n\tconst result: any = {}\n\tconst inputIsArray = Array.isArray(o)\n\tlet outputShouldBeArray = false\n\n\tfor (const [i, entry] of Object.entries(o).entries()) {\n\t\tconst mapped =\n\t\t\tinputIsArray ? flatMapEntry(i, entry[1]) : flatMapEntry(...entry, i)\n\n\t\toutputShouldBeArray ||= typeof mapped[0] === \"number\"\n\n\t\tconst flattenedEntries =\n\t\t\tArray.isArray(mapped[0]) || mapped.length === 0 ?\n\t\t\t\t// if we have an empty array (for filtering) or an array with\n\t\t\t\t// another array as its first element, treat it as a list\n\t\t\t\t(mapped as GroupableEntry[])\n\t\t\t\t// otherwise, it should be a single entry, so nest it in a tuple\n\t\t\t\t// so it doesn't get spread when the result is flattened\n\t\t\t:\t[mapped as GroupableEntry]\n\n\t\tfor (const [k, v] of flattenedEntries) {\n\t\t\tif (typeof k === \"object\") result[k.group] = append(result[k.group], v)\n\t\t\telse result[k] = v\n\t\t}\n\t}\n\n\treturn outputShouldBeArray ? Object.values(result) : result\n}\n"
  },
  {
    "path": "ark/util/functions.ts",
    "content": "import { throwInternalError } from \"./errors.ts\"\nimport { unset } from \"./records.ts\"\n\nexport type Fn<\n\targs extends readonly any[] = readonly any[],\n\treturns = unknown\n> = (...args: args) => returns\n\nexport const cached = <t>(thunk: () => t): (() => t) => {\n\tlet result: t | unset = unset\n\treturn () => (result === unset ? (result = thunk()) : result)\n}\n\nexport const isThunk = <value>(\n\tvalue: value\n): value is Extract<value, Thunk> extends never ? value & Thunk\n:\tExtract<value, Thunk> => typeof value === \"function\" && value.length === 0\n\nexport type Thunk<ret = unknown> = () => ret\n\nexport type thunkable<t> = t | Thunk<t>\n\nexport const tryCatch = <returns, onError = never>(\n\tfn: () => returns,\n\tonError?: (e: unknown) => onError\n): returns | onError => {\n\ttry {\n\t\treturn fn()\n\t} catch (e) {\n\t\treturn onError?.(e) as onError\n\t}\n}\n\nexport const DynamicFunction = class extends Function {\n\tconstructor(...args: [string, ...string[]]) {\n\t\tconst params = args.slice(0, -1)\n\t\tconst body = args[args.length - 1]!\n\t\ttry {\n\t\t\tsuper(...params, body)\n\t\t} catch (e) {\n\t\t\treturn throwInternalError(\n\t\t\t\t`Encountered an unexpected error while compiling your definition:\n                Message: ${e} \n                Source: (${args.slice(0, -1)}) => {\n                    ${args[args.length - 1]}\n                }`\n\t\t\t)\n\t\t}\n\t}\n} as DynamicFunction\n\nexport type DynamicFunction = new <fn extends Fn>(\n\t...args: ConstructorParameters<typeof Function>\n) => fn & {\n\tapply(thisArg: null, args: Parameters<fn>): ReturnType<fn>\n\n\tcall(thisArg: null, ...args: Parameters<fn>): ReturnType<fn>\n}\n\nexport type CallableOptions<attachments extends object> = {\n\tattach?: attachments\n\tbind?: object\n}\n\n/** @ts-ignore required to cast function type */\nexport interface Callable<fn extends Fn, attachments extends object>\n\textends fn,\n\t\tattachments {}\n\nexport class Callable<fn extends Fn, attachments extends object = {}> {\n\tconstructor(\n\t\tfn: fn,\n\t\t...[opts]: {} extends attachments ? [opts?: CallableOptions<attachments>]\n\t\t:\t[opts: CallableOptions<attachments>]\n\t) {\n\t\treturn Object.assign(\n\t\t\tObject.setPrototypeOf(\n\t\t\t\tfn.bind(opts?.bind ?? this),\n\t\t\t\tthis.constructor.prototype\n\t\t\t),\n\t\t\topts?.attach\n\t\t)\n\t}\n}\n\nexport type GuardablePredicate<\n\tinput = unknown,\n\tnarrowed extends input = input\n> = ((In: input) => In is narrowed) | ((In: input) => boolean)\n\nexport type TypeGuard<input = unknown, narrowed extends input = input> = (\n\tIn: input\n) => In is narrowed\n\n/**\n * Checks if the environment has Content Security Policy (CSP) enabled,\n * preventing JIT-optimized code from being compiled via new Function().\n *\n * @returns `true` if a function created using new Function() can be\n * successfully invoked in the environment, `false` otherwise.\n *\n * The result is cached for subsequent invocations.\n */\nexport const envHasCsp = cached((): boolean => {\n\ttry {\n\t\treturn new Function(\"return false\")()\n\t} catch {\n\t\treturn true\n\t}\n})\n"
  },
  {
    "path": "ark/util/generics.ts",
    "content": "import type { Primitive } from \"./domain.ts\"\nimport { noSuggest, type ErrorMessage } from \"./errors.ts\"\nimport type { unionToTuple } from \"./unionToTuple.ts\"\n\nexport type Stringifiable =\n\t| string\n\t| boolean\n\t| number\n\t| bigint\n\t| null\n\t| undefined\n\n/** Force an operation like `{ a: 0 } & { b: 1 }` to be computed so that it displays `{ a: 0; b: 1 }`. */\nexport type show<t> = { [k in keyof t]: t[k] } & unknown\n\n/** @deprecated use \"show\" instead */\nexport type evaluate<t> = { [k in keyof t]: t[k] } & unknown\n\nexport type get<t, k extends PropertyKey> = t[k & keyof t]\n\nexport type exact<t extends object, u extends object> = {\n\t[k in keyof t]: k extends keyof u ? conform<t[k], u[k]> : never\n}\n\nexport type exactMessageOnError<t extends object, u extends object> = {\n\t[k in keyof t]: k extends keyof u ? conform<t[k], u[k]>\n\t:\tErrorMessage<`'${k & string}' is not a valid key`>\n} & u\n\nexport type promisable<t> = t | Promise<t>\n\nexport type leftIfEqual<l, r> = [l, r] extends [r, l] ? l : r\n\nexport type UnknownUnion =\n\t| string\n\t| number\n\t| symbol\n\t| bigint\n\t| boolean\n\t| object\n\t| null\n\t| undefined\n\n/**\n * Interesection (`&`) that avoids evaluating `unknown` to `{}`\n */\nexport type andPreserveUnknown<l, r> =\n\tunknown extends l & r ? unknown : show<l & r>\n\n/** Can be used to test for the universal subtypes, `any` and `never`, e.g.:\n *\n * ```ts\n * type isAnyOrNever<t> = [t] extends [anyOrNever] ? true : false\n * ```\n *\n *  The actual value is a string literal, but the only realistic subtypes\n *  of that literal are `any` and `never`.\n */\nexport type anyOrNever = \" anyOrNever\"\n\nexport type conform<t, base> = t extends base ? t : base\n\nexport type equals<l, r> = [l, r] extends [r, l] ? true : false\n\nexport type exactEquals<l, r> =\n\t(<_>() => _ extends l ? 1 : 2) extends <_>() => _ extends r ? 1 : 2 ? true\n\t:\tfalse\n\nexport const brand = noSuggest(\"brand\")\n\nexport type Brand<t = unknown, id = unknown> = t & {\n\treadonly [brand]: [t, id]\n}\n\nexport type unbrand<t> = t extends Brand<infer base, string> ? base : never\n\nexport type satisfy<base, t extends base> = t\n\nexport type defined<t> = t & ({} | null)\n\nexport type autocomplete<suggestions extends string> =\n\t| suggestions\n\t| (string & {})\n\nexport type widen<t, supertypes> = collectWidenedType<\n\tt,\n\tunionToTuple<supertypes>\n>\n\ntype collectWidenedType<t, remaining extends unknown[], result = never> =\n\tremaining extends [infer head, ...infer tail] ?\n\t\tcollectWidenedType<t, tail, t extends head ? result | head : result>\n\t:\tresult\n\ntype narrowTuple<t extends readonly unknown[]> =\n\tt extends readonly [infer head, ...infer tail] ?\n\t\treadonly [head, ...narrowTuple<tail>]\n\t:\t[]\n\nexport type narrow<t> =\n\tt extends Primitive ? t\n\t: t extends readonly unknown[] ? narrowTuple<t>\n\t: { [k in keyof t]: narrow<t[k]> }\n\nexport const narrow = <t>(t: narrow<t>): t => t as t\n\n/** primitive key used to represent an inferred type at compile-time */\nexport const inferred = noSuggest(\"arkInferred\")\n\n/** primitive key used to represent an inferred type at compile-time */\nexport type inferred = typeof inferred\n"
  },
  {
    "path": "ark/util/get.ts",
    "content": "import type { conform } from \"./generics.ts\"\nimport type { keyOf } from \"./records.ts\"\n\ntype getKey<o, k> =\n\tk extends keyof o ? o[k]\n\t: k extends `${infer n extends number & keyof o}` ? o[n]\n\t: never\n\ntype getPath<o, path extends string> =\n\tpath extends `${infer head}.${infer tail}` ? getPath<getKey<o, head>, tail>\n\t:\tgetKey<o, path>\n\ntype validatePath<o, path extends string, prefix extends string = \"\"> =\n\tpath extends `${infer head}.${infer tail}` ?\n\t\thead extends keyOf<o> ?\n\t\t\tvalidatePath<getKey<o, head>, tail, `${prefix}${head}.`>\n\t\t:\t`Key '${head}' is not valid following '${prefix}'`\n\t:\t{\n\t\t\t// find suffixes that would make the segment valid\n\t\t\t[k in keyOf<o>]: k extends `${path}${string}` ? `${prefix}${k}` : never\n\t\t}[keyOf<o>]\n\nexport const get = <const o extends object, path extends string>(\n\tdata: o,\n\tpathStr: conform<path, string & validatePath<o, path>>\n): getPath<o, path> => {\n\tlet target: any = data\n\tconst path = pathStr.split(\".\")\n\twhile (path.length) target = target[path.shift()!]\n\treturn target\n}\n"
  },
  {
    "path": "ark/util/hkt.ts",
    "content": "import { noSuggest } from \"./errors.ts\"\n\nconst args = noSuggest(\"args\")\ntype args = typeof args\n\nexport abstract class Hkt<constraints extends unknown[] = any> {\n\tdeclare [args]: unknown[]\n\tdeclare constraints: constraints\n\tdeclare args: this[args] extends infer args extends unknown[] ? args : never\n\tdeclare 0: this[args] extends [infer arg, ...any] ? arg : never\n\tdeclare 1: this[args] extends [any, infer arg, ...any] ? arg : never\n\tdeclare 2: this[args] extends [any, any, infer arg, ...any] ? arg : never\n\tdeclare 3: this[args] extends [any, any, any, infer arg, ...any] ? arg : never\n\tabstract body: unknown\n\n\tdeclare description?: string\n\n\tconstructor() {}\n}\n\n/** A small set of HKT utility types based on https://github.com/gvergnaud/hotscript\n *  See https://github.com/gvergnaud/hotscript/blob/main/src/internals/core/Core.ts\n */\nexport declare namespace Hkt {\n\texport type constructor<constraints extends unknown[] = any> =\n\t\tnew () => Hkt<constraints>\n\n\texport type args = typeof args\n\n\texport type apply<\n\t\thkt extends Hkt,\n\t\targs extends { [i in keyof args]: hkt[\"constraints\"][i] }\n\t> = (hkt & {\n\t\t[args]: args\n\t})[\"body\"]\n}\n"
  },
  {
    "path": "ark/util/index.ts",
    "content": "export * from \"./arrays.ts\"\nexport * from \"./clone.ts\"\nexport * from \"./describe.ts\"\nexport * from \"./domain.ts\"\nexport * from \"./errors.ts\"\nexport * from \"./flatMorph.ts\"\nexport * from \"./functions.ts\"\nexport * from \"./generics.ts\"\nexport * from \"./hkt.ts\"\nexport * from \"./intersections.ts\"\nexport * from \"./isomorphic.ts\"\nexport * from \"./keys.ts\"\nexport * from \"./lazily.ts\"\nexport * from \"./numbers.ts\"\nexport * from \"./objectKinds.ts\"\nexport * from \"./path.ts\"\nexport * from \"./primitive.ts\"\nexport * from \"./records.ts\"\nexport * from \"./registry.ts\"\nexport * from \"./scanner.ts\"\nexport * from \"./serialize.ts\"\nexport * from \"./strings.ts\"\nexport * from \"./traits.ts\"\nexport * from \"./unionToTuple.ts\"\n"
  },
  {
    "path": "ark/util/intersections.ts",
    "content": "import type { array } from \"./arrays.ts\"\nimport type { domainOf } from \"./domain.ts\"\nimport type { andPreserveUnknown } from \"./generics.ts\"\nimport type { Hkt } from \"./hkt.ts\"\nimport type { propValueOf, requiredKeyOf } from \"./records.ts\"\n\nexport interface AndPreserveUnknown extends Hkt<[unknown, unknown]> {\n\tbody: andPreserveUnknown<this[0], this[1]>\n}\n\ntype SequenceIntersectionKind = \"array\" | \"parameters\"\n\nexport type intersectArrays<\n\tl extends array,\n\tr extends array,\n\toperator extends Hkt = AndPreserveUnknown\n> = intersectSequences<l, r, [], [], operator, \"array\">\n\nexport type intersectParameters<\n\tl extends array,\n\tr extends array,\n\toperator extends Hkt = AndPreserveUnknown\n> = intersectSequences<l, r, [], [], operator, \"parameters\">\n\ntype intersectSequences<\n\tl extends array,\n\tr extends array,\n\tacc extends array,\n\tpostfix extends array,\n\toperation extends Hkt,\n\tkind extends SequenceIntersectionKind\n> =\n\tl extends readonly [] ?\n\t\t// a longer array is assignable to a shorter one when treated as\n\t\t// parameters, but not when treated as a tuple\n\t\tkind extends \"array\" ?\n\t\t\t[] extends r ?\n\t\t\t\t[...acc, ...postfix]\n\t\t\t:\tnever\n\t\t:\t[...acc, ...r, ...postfix]\n\t: r extends readonly [] ?\n\t\tkind extends \"array\" ?\n\t\t\t[] extends l ?\n\t\t\t\t[...acc, ...postfix]\n\t\t\t:\tnever\n\t\t:\t[...acc, ...l, ...postfix]\n\t: // credit to @alexandroppolus for this part of the implementation\n\t// https://github.com/type-challenges/type-challenges/issues/33210\n\t[l, r] extends (\n\t\t[\n\t\t\treadonly [(infer lHead)?, ...infer lTail],\n\t\t\treadonly [(infer rHead)?, ...infer rTail]\n\t\t]\n\t) ?\n\t\t// if either operand has a non-variadic element at index 0\n\t\t// and both operands do not have postfix elements\n\t\t// (which causes the inferred head to widen to unknown)\n\t\t[\"0\", lHead, rHead] extends [keyof l | keyof r, l[0], r[0]] ?\n\t\t\tintersectSequences<\n\t\t\t\tlTail,\n\t\t\t\trTail,\n\t\t\t\t[[], []] extends [l, r] ?\n\t\t\t\t\t[...acc, Hkt.apply<operation, [lHead, rHead]>?]\n\t\t\t\t:\t[...acc, Hkt.apply<operation, [lHead, rHead]>],\n\t\t\t\tpostfix,\n\t\t\t\toperation,\n\t\t\t\tkind\n\t\t\t>\n\t\t: l extends readonly [...infer lInit, infer lLast] ?\n\t\t\tr extends readonly [...infer rInit, infer rLast] ?\n\t\t\t\tintersectSequences<\n\t\t\t\t\tlInit,\n\t\t\t\t\trInit,\n\t\t\t\t\tacc,\n\t\t\t\t\t[Hkt.apply<operation, [lLast, rLast]>, ...postfix],\n\t\t\t\t\toperation,\n\t\t\t\t\tkind\n\t\t\t\t>\n\t\t\t:\tintersectSequences<\n\t\t\t\t\tlInit,\n\t\t\t\t\tr,\n\t\t\t\t\tacc,\n\t\t\t\t\t[Hkt.apply<operation, [lLast, r[number]]>, ...postfix],\n\t\t\t\t\toperation,\n\t\t\t\t\tkind\n\t\t\t\t>\n\t\t: r extends readonly [...infer rInit, infer rLast] ?\n\t\t\tintersectSequences<\n\t\t\t\tl,\n\t\t\t\trInit,\n\t\t\t\tacc,\n\t\t\t\t[Hkt.apply<operation, [l[number], rLast]>, ...postfix],\n\t\t\t\toperation,\n\t\t\t\tkind\n\t\t\t>\n\t\t:\t[...acc, ...Hkt.apply<operation, [lHead, rHead]>[], ...postfix]\n\t:\tnever\n\nexport type isDisjoint<l, r> = overlaps<l, r> extends true ? false : true\n\nexport type overlaps<l, r> =\n\tl & r extends never ? false\n\t: domainOf<l> & domainOf<r> extends never ? false\n\t: [l, r] extends [object, object] ?\n\t\tfalse extends (\n\t\t\tpropValueOf<{\n\t\t\t\t[k in Extract<\n\t\t\t\t\tkeyof l & keyof r,\n\t\t\t\t\trequiredKeyOf<l> | requiredKeyOf<r>\n\t\t\t\t>]: overlaps<l[k], r[k]>\n\t\t\t}>\n\t\t) ?\n\t\t\tfalse\n\t\t:\ttrue\n\t:\ttrue\n"
  },
  {
    "path": "ark/util/isomorphic.ts",
    "content": "// based on the util of the same name in @ark/fs\n// isolated here for use with registry\n\nimport type { autocomplete } from \"./generics.ts\"\n\n/** get a CJS/ESM compatible string representing the current file */\nconst fileName = (): string => {\n\ttry {\n\t\tconst error = new Error()\n\t\tconst stackLine = error.stack?.split(\"\\n\")[2]?.trim() || \"\" // [1]=this func, [2]=caller\n\t\tconst filePath =\n\t\t\tstackLine.match(/\\(?(.+?)(?::\\d+:\\d+)?\\)?$/)?.[1] || \"unknown\"\n\t\treturn filePath.replace(/^file:\\/\\//, \"\")\n\t} catch {\n\t\treturn \"unknown\"\n\t}\n}\n\ntype ArkKnownEnvVar = \"ARK_DEBUG\"\n\nconst env: Record<\n\tautocomplete<ArkKnownEnvVar>,\n\tstring | undefined\n> = (globalThis.process?.env as never) ?? {}\n\nexport const isomorphic = {\n\tfileName,\n\tenv\n}\n"
  },
  {
    "path": "ark/util/keys.ts",
    "content": "import type { array, join } from \"./arrays.ts\"\nimport type { NonNegativeIntegerLiteral } from \"./numbers.ts\"\n\nexport type Key = string | symbol\n\nexport type toArkKey<o, k extends keyof o> =\n\tk extends number ?\n\t\t[o, number] extends [array, k] ?\n\t\t\tNonNegativeIntegerLiteral\n\t\t:\t`${k}`\n\t:\tk\n\nexport type arkIndexableOf<o> =\n\tarkKeyOf<o> extends infer k ?\n\t\tk extends `${infer index extends number}` ?\n\t\t\tindex | k\n\t\t:\tk\n\t:\tnever\n\nexport type arkKeyOf<o> =\n\t[o] extends [object] ?\n\t\t[o] extends [array] ?\n\t\t\tarkArrayKeyOf<o>\n\t\t:\tarkObjectLiteralKeyOf<o>\n\t:\tnever\n\ntype arkArrayKeyOf<a extends array> =\n\tnumber extends a[\"length\"] ? NonNegativeIntegerLiteral\n\t: keyof a extends infer i ?\n\t\ti extends `${number}` ?\n\t\t\ti\n\t\t:\tnever\n\t:\tnever\n\ntype arkObjectLiteralKeyOf<o extends object> =\n\tkeyof o extends infer k ?\n\t\tk extends number ?\n\t\t\t`${k}`\n\t\t:\tk\n\t:\tnever\n\nexport type arkGet<o, k extends arkIndexableOf<o>> = o[k extends keyof o ? k\n: NonNegativeIntegerLiteral extends k ? number & keyof o\n: k extends number ? `${k}` & keyof o\n: never]\n\nexport type writeInvalidKeysMessage<\n\to extends string,\n\tkeys extends array<string>\n> = `Key${keys[\"length\"] extends 1 ? \"\" : \"s\"} ${join<keys, \", \">} ${keys[\"length\"] extends 1 ? \"does\" : \"do\"} not exist on ${o}`\n"
  },
  {
    "path": "ark/util/lazily.ts",
    "content": "export const lazily = <t extends object>(thunk: () => t): t => {\n\tlet cached: any\n\treturn new Proxy<t>({} as t, {\n\t\tget: (_, prop) => {\n\t\t\tif (!cached) cached = thunk()\n\n\t\t\treturn cached[prop as keyof t]\n\t\t},\n\t\tset: (_, prop, value) => {\n\t\t\tif (!cached) cached = thunk()\n\n\t\t\tcached[prop] = value\n\t\t\treturn true\n\t\t}\n\t})\n}\n"
  },
  {
    "path": "ark/util/numbers.ts",
    "content": "import { throwParseError } from \"./errors.ts\"\nimport { anchoredRegex, RegexPatterns } from \"./strings.ts\"\n\nexport type Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9\n\nexport type NumberLiteral<n extends number = number> = `${n}`\n\nexport type BigintLiteral<n extends bigint = bigint> = `${n}n`\n\nexport type IntegerLiteral<n extends bigint = bigint> = `${n}`\n\nexport type NonNegativeIntegerLiteral<n extends bigint = bigint> =\n\t| `${Digit}`\n\t| (`${Exclude<Digit, 0>}${string}` & `${n}`)\n\n/*\n * The goal of the number literal and bigint literal regular expressions is to:\n *\n *   1. Ensure definitions form a bijection with the values they represent.\n *   2. Attempt to mirror TypeScript's own format for stringification of numeric\n *      values such that the regex should match a given definition if any only if\n *      a precise literal type will be inferred (in TS4.8+).\n */\n\nconst anchoredNegativeZeroPattern = /^-0\\.?0*$/.source\nconst positiveIntegerPattern = /[1-9]\\d*/.source\nconst looseDecimalPattern = /\\.\\d+/.source\nconst strictDecimalPattern = /\\.\\d*[1-9]/.source\n\ntype CreateNumberMatcherOptions = {\n\tdecimalPattern: string\n\tallowDecimalOnly: boolean\n}\n\nconst createNumberMatcher = (opts: CreateNumberMatcherOptions) =>\n\tanchoredRegex(\n\t\tRegexPatterns.negativeLookahead(anchoredNegativeZeroPattern) +\n\t\t\tRegexPatterns.nonCapturingGroup(\n\t\t\t\t\"-?\" +\n\t\t\t\t\tRegexPatterns.nonCapturingGroup(\n\t\t\t\t\t\tRegexPatterns.nonCapturingGroup(\"0|\" + positiveIntegerPattern) +\n\t\t\t\t\t\t\tRegexPatterns.nonCapturingGroup(opts.decimalPattern) +\n\t\t\t\t\t\t\t\"?\"\n\t\t\t\t\t) +\n\t\t\t\t\t(opts.allowDecimalOnly ? \"|\" + opts.decimalPattern : \"\") +\n\t\t\t\t\t\"?\"\n\t\t\t)\n\t)\n\n/**\n *  Matches a well-formatted numeric expression according to the following rules:\n *    1. Must include an integer portion (i.e. '.321' must be written as '0.321')\n *    2. The first digit of the value must not be 0, unless the entire integer portion is 0\n *    3. If the value includes a decimal, its last digit may not be 0\n *    4. The value may not be \"-0\"\n */\nexport const wellFormedNumberMatcher: RegExp = createNumberMatcher({\n\tdecimalPattern: strictDecimalPattern,\n\tallowDecimalOnly: false\n})\n\nexport const isWellFormedNumber: RegExp[\"test\"] =\n\twellFormedNumberMatcher.test.bind(wellFormedNumberMatcher)\n\n/**\n * Similar to wellFormedNumber but more permissive in the following ways:\n *\n *  - Allows numbers without an integer portion like \".5\" (well-formed equivalent is \"0.5\")\n *  - Allows decimals with trailing zeroes like \"0.10\" (well-formed equivalent is \"0.1\")\n */\nexport const numericStringMatcher: RegExp = createNumberMatcher({\n\tdecimalPattern: looseDecimalPattern,\n\tallowDecimalOnly: true\n})\n\nexport const isNumericString =\n\tnumericStringMatcher.test.bind(numericStringMatcher)\n\nexport const numberLikeMatcher = /^-?\\d*\\.?\\d*$/\nconst isNumberLike = (s: string) => s.length !== 0 && numberLikeMatcher.test(s)\n\n/**\n *  Matches a well-formatted integer according to the following rules:\n *    1. must begin with an integer, the first digit of which cannot be 0 unless the entire value is 0\n *    2. The value may not be \"-0\"\n */\nexport const wellFormedIntegerMatcher: RegExp = anchoredRegex(\n\tRegexPatterns.negativeLookahead(\"^-0$\") +\n\t\t\"-?\" +\n\t\tRegexPatterns.nonCapturingGroup(\n\t\t\tRegexPatterns.nonCapturingGroup(\"0|\" + positiveIntegerPattern)\n\t\t)\n)\n\nexport const isWellFormedInteger: RegExp[\"test\"] =\n\twellFormedIntegerMatcher.test.bind(wellFormedIntegerMatcher)\n\nexport const integerLikeMatcher = /^-?\\d+$/\nconst isIntegerLike = integerLikeMatcher.test.bind(integerLikeMatcher)\n\ntype NumericLiteralKind = \"number\" | \"bigint\" | \"integer\"\n\nconst numericLiteralDescriptions = {\n\tnumber: \"a number\",\n\tbigint: \"a bigint\",\n\tinteger: \"an integer\"\n} as const\n\ntype numericLiteralDescriptions = typeof numericLiteralDescriptions\n\nexport type writeMalformedNumericLiteralMessage<\n\tdef extends string,\n\tkind extends NumericLiteralKind\n> = `'${def}' was parsed as ${numericLiteralDescriptions[kind]} but could not be narrowed to a literal value. Avoid unnecessary leading or trailing zeros and other abnormal notation`\n\nexport const writeMalformedNumericLiteralMessage = <\n\tdef extends string,\n\tkind extends NumericLiteralKind\n>(\n\tdef: def,\n\tkind: kind\n): writeMalformedNumericLiteralMessage<def, kind> =>\n\t`'${def}' was parsed as ${numericLiteralDescriptions[kind]} but could not be narrowed to a literal value. Avoid unnecessary leading or trailing zeros and other abnormal notation`\n\ntype ValidationKind = \"number\" | \"integer\"\n\nconst isWellFormed = (def: string, kind: ValidationKind) =>\n\tkind === \"number\" ? isWellFormedNumber(def) : isWellFormedInteger(def)\n\nconst parseKind = (def: string, kind: ValidationKind) =>\n\tkind === \"number\" ? Number(def) : Number.parseInt(def)\n\nconst isKindLike = (def: string, kind: ValidationKind) =>\n\tkind === \"number\" ? isNumberLike(def) : isIntegerLike(def)\n\nexport const tryParseNumber = <errorOnFail extends boolean | string>(\n\ttoken: string,\n\toptions?: NumericParseOptions<errorOnFail>\n): errorOnFail extends true | string ? number : number | undefined =>\n\tparseNumeric(token, \"number\", options)\n\nexport const tryParseWellFormedNumber: typeof tryParseNumber = (\n\ttoken,\n\toptions\n) => parseNumeric(token, \"number\", { ...options, strict: true })\n\nexport type tryParseNumber<token extends string, messageOnFail extends string> =\n\ttoken extends `${infer n extends number}` ?\n\t\tnumber extends n ?\n\t\t\twriteMalformedNumericLiteralMessage<token, \"number\">\n\t\t:\tn\n\t:\tmessageOnFail\n\nexport type parseNumber<token extends string> =\n\ttoken extends `${infer n extends number}` ? n : never\n\nexport const tryParseInteger = <errorOnFail extends boolean | string>(\n\ttoken: string,\n\toptions?: NumericParseOptions<errorOnFail>\n): errorOnFail extends true | string ? number : number | undefined =>\n\tparseNumeric(token, \"integer\", options)\n\n// We use bigint to check if the string matches an integer, but here we\n// convert it to a plain number by exploiting the fact that TS stringifies\n// numbers and bigints the same way.\nexport type tryParseInteger<\n\ttoken extends string,\n\tmessageOnFail extends string\n> =\n\ttoken extends `${infer b extends bigint}` ?\n\t\tbigint extends b ? writeMalformedNumericLiteralMessage<token, \"integer\">\n\t\t: token extends `${infer n extends number}` ? n\n\t\t: never\n\t:\tmessageOnFail\n\nexport type parseInteger<token extends string> =\n\ttoken extends `${bigint}` ?\n\t\ttoken extends `${infer n extends number}` ?\n\t\t\tn\n\t\t:\tnever\n\t:\tnever\n\nexport type parseNonNegativeInteger<token extends string> =\n\ttoken extends `-${string}` ? never : parseInteger<token>\n\nexport type NumericParseOptions<errorOnFail extends boolean | string> = {\n\terrorOnFail?: errorOnFail\n\tstrict?: boolean\n}\n\nconst parseNumeric = <errorOnFail extends boolean | string>(\n\ttoken: string,\n\tkind: ValidationKind,\n\toptions?: NumericParseOptions<errorOnFail>\n): errorOnFail extends true | string ? number : number | undefined => {\n\tconst value = parseKind(token, kind)\n\tif (!Number.isNaN(value)) {\n\t\tif (isKindLike(token, kind)) {\n\t\t\tif (options?.strict) {\n\t\t\t\treturn isWellFormed(token, kind) ? value : (\n\t\t\t\t\t\tthrowParseError(writeMalformedNumericLiteralMessage(token, kind))\n\t\t\t\t\t)\n\t\t\t}\n\t\t\treturn value\n\t\t}\n\t}\n\treturn (\n\t\toptions?.errorOnFail ?\n\t\t\tthrowParseError(\n\t\t\t\toptions?.errorOnFail === true ?\n\t\t\t\t\t`Failed to parse ${numericLiteralDescriptions[kind]} from '${token}'`\n\t\t\t\t:\toptions?.errorOnFail\n\t\t\t)\n\t\t:\tundefined) as never\n}\n\nexport const tryParseWellFormedBigint = (def: string): bigint | undefined => {\n\tif (def[def.length - 1] !== \"n\") return\n\n\tconst maybeIntegerLiteral = def.slice(0, -1)\n\tlet value\n\ttry {\n\t\tvalue = BigInt(maybeIntegerLiteral)\n\t} catch {\n\t\treturn\n\t}\n\tif (wellFormedIntegerMatcher.test(maybeIntegerLiteral)) return value\n\n\tif (integerLikeMatcher.test(maybeIntegerLiteral)) {\n\t\t// If the definition looks like a bigint but is\n\t\t// not well-formed, throw.\n\t\treturn throwParseError(writeMalformedNumericLiteralMessage(def, \"bigint\"))\n\t}\n}\n\n/**\n * Returns the next or previous representable floating-point number after the given input.\n *\n * @param {\"+\" | \"-\"} [direction=\"+\"] - The direction to find the nearest float. \"+\" for the next float, \"-\" for the previous float.\n * @throws {Error} If the input is not a finite number.\n *\n * @example\n * console.log(nearestFloat(0)); // Smallest positive number\n * console.log(nearestFloat(2)); // 2.0000000000000004\n * console.log(nearestFloat(2.1)); // 2.1000000000000005\n * console.log(nearestFloat(2, \"-\")); // 1.9999999999999998\n * console.log(nearestFloat(2.1, \"-\")); // 2.0999999999999996\n * // as size of input increases, the increments become larger to stay within what\n * // JS can represent in a numeric value\n * console.log(nearestFloat(5555555555555555)); // 5555555555555556\n * console.log(nearestFloat(5555555555555555, \"-\")); // 5555555555555554\n */\nexport const nearestFloat = (n: number, direction: \"+\" | \"-\" = \"+\"): number => {\n\tconst buffer = new ArrayBuffer(8)\n\tconst f64 = new Float64Array(buffer)\n\tconst u32 = new Uint32Array(buffer)\n\n\tf64[0] = n\n\n\tif (n === 0) {\n\t\tu32[0] = 1\n\t\tu32[1] = direction === \"-\" ? 1 << 31 : 0\n\t} else if ((n > 0 && direction === \"+\") || (n < 0 && direction === \"-\")) {\n\t\tif (u32[0]++ === 0xffffffff) u32[1]++\n\t} else if (u32[0]-- === 0) u32[1]--\n\n\treturn f64[0]\n}\n"
  },
  {
    "path": "ark/util/objectKinds.ts",
    "content": "import type { DescribeOptions } from \"./describe.ts\"\nimport { type domainDescriptions, domainOf } from \"./domain.ts\"\nimport type { Fn } from \"./functions.ts\"\nimport type { satisfy } from \"./generics.ts\"\nimport { isKeyOf } from \"./records.ts\"\n\n// ECMAScript Objects\n// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects\nexport const ecmascriptConstructors = {\n\tArray,\n\tBoolean,\n\tDate,\n\tError,\n\tFunction,\n\tMap,\n\tNumber,\n\tPromise,\n\tRegExp,\n\tSet,\n\tString,\n\tWeakMap,\n\tWeakSet\n}\n\nexport type ecmascriptConstructors = typeof ecmascriptConstructors\n\n// we have to narrow instantiateConstructors here since a lot of the builtin defaults use `any`\nexport type EcmascriptObjects = satisfy<\n\tinstantiateConstructors<keyof ecmascriptConstructors>,\n\t{\n\t\tArray: Array<unknown>\n\t\tBoolean: Boolean\n\t\tDate: Date\n\t\tError: Error\n\t\tFunction: Function\n\t\tMap: Map<unknown, unknown>\n\t\tNumber: Number\n\t\tRegExp: RegExp\n\t\tSet: Set<unknown>\n\t\tString: String\n\t\tWeakMap: WeakMap<object, unknown>\n\t\tWeakSet: WeakSet<object>\n\t\tPromise: Promise<unknown>\n\t}\n>\n\n/** Node18 */\nexport const FileConstructor = globalThis.File ?? Blob\n\n// need to type these explicitly due to a resolution issue\nexport type platformConstructors = {\n\tArrayBuffer: ArrayBufferConstructor\n\tBlob: typeof Blob\n\tFile: typeof File\n\tFormData: typeof FormData\n\tHeaders: typeof Headers\n\tRequest: typeof Request\n\tResponse: typeof Response\n\tURL: typeof URL\n}\n\n// Platform APIs\n// See https://developer.mozilla.org/en-US/docs/Web/API\n// Must be implemented in Node etc. as well as the browser to include here\nexport const platformConstructors: platformConstructors = {\n\tArrayBuffer,\n\tBlob,\n\tFile: FileConstructor,\n\tFormData,\n\tHeaders,\n\tRequest,\n\tResponse,\n\tURL\n}\n\nexport type PlatformObjects = instantiateConstructors<\n\tkeyof platformConstructors\n>\n\nexport const typedArrayConstructors = {\n\tInt8Array,\n\tUint8Array,\n\tUint8ClampedArray,\n\tInt16Array,\n\tUint16Array,\n\tInt32Array,\n\tUint32Array,\n\tFloat32Array,\n\tFloat64Array,\n\tBigInt64Array,\n\tBigUint64Array\n}\n\nexport type typedArrayConstructors = typeof typedArrayConstructors\n\nexport type TypedArrayObjects = instantiateConstructors<\n\tkeyof typedArrayConstructors\n>\n\n// Built-in object constructors based on a subset of:\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects\nexport const builtinConstructors = {\n\t...ecmascriptConstructors,\n\t...platformConstructors,\n\t...typedArrayConstructors,\n\tString,\n\tNumber,\n\tBoolean\n}\n\nexport type builtinConstructors = typeof builtinConstructors\n\nexport type BuiltinObjectKind = keyof builtinConstructors\n\nexport type GlobalName = keyof typeof globalThis\n\ntype instantiateConstructors<kind extends BuiltinObjectKind> = {\n\t// one of these conditions will always be true internally, but they prevent\n\t// failed resolutions from being inferred as any if TS is configured\n\t// in such a way that they are unavailable:\n\t// https://github.com/arktypeio/arktype/issues/1246\n\t[k in kind]: k extends GlobalName ? InstanceType<(typeof globalThis)[k]>\n\t: `${k}Constructor` extends GlobalName ?\n\t\tInstanceType<(typeof globalThis)[`${k}Constructor`]>\n\t:\tnever\n}\n\nexport type BuiltinObjects = instantiateConstructors<BuiltinObjectKind>\n\nexport type objectKindOf<data extends object> =\n\tobject extends data ? keyof builtinConstructors | undefined\n\t: data extends Fn ? \"Function\"\n\t: instantiableObjectKind<data> extends never ? undefined\n\t: instantiableObjectKind<data>\n\nexport type describeObject<\n\to extends object,\n\topts extends DescribeOptions = {}\n> =\n\tobjectKindOf<o> extends string ?\n\t\t[opts[\"includeArticles\"]] extends [true] ?\n\t\t\tobjectKindDescriptions[objectKindOf<o>]\n\t\t:\tobjectKindOf<o>\n\t: [opts[\"includeArticles\"]] extends [true] ? domainDescriptions[\"object\"]\n\t: \"object\"\n\ntype instantiableObjectKind<data extends object> = {\n\t[kind in keyof builtinConstructors]: data extends (\n\t\tInstanceType<builtinConstructors[kind]>\n\t) ?\n\t\tkind\n\t:\tnever\n}[keyof builtinConstructors]\n\nexport const objectKindOf = <data extends object>(\n\tdata: data\n): objectKindOf<data> | undefined => {\n\tlet prototype: Partial<Object> | null = Object.getPrototypeOf(data)\n\twhile (\n\t\tprototype?.constructor &&\n\t\t(!isKeyOf(prototype.constructor.name, builtinConstructors) ||\n\t\t\t!(data instanceof builtinConstructors[prototype.constructor.name]))\n\t)\n\t\tprototype = Object.getPrototypeOf(prototype)\n\n\tconst name = prototype?.constructor?.name\n\tif (name === undefined || name === \"Object\") return undefined\n\n\treturn name as never\n}\n\nexport const objectKindOrDomainOf = <data>(\n\tdata: data\n): (objectKindOf<data & object> & {}) | domainOf<data> =>\n\t(typeof data === \"object\" && data !== null ?\n\t\t(objectKindOf(data) ?? \"object\")\n\t:\tdomainOf(data)) as never\n\nexport type objectKindOrDomainOf<data> =\n\tdata extends object ?\n\t\tobjectKindOf<data> extends undefined ?\n\t\t\t\"object\"\n\t\t:\tobjectKindOf<data>\n\t:\tdomainOf<data>\n\nexport const hasObjectKind = <kind extends keyof builtinConstructors>(\n\tdata: object,\n\tkind: kind\n): data is InstanceType<builtinConstructors[kind]> =>\n\tobjectKindOf(data) === (kind as never)\n\nexport const isArray: (data: unknown) => data is readonly unknown[] =\n\tArray.isArray\n\nexport const ecmascriptDescriptions = {\n\tArray: \"an array\",\n\tFunction: \"a function\",\n\tDate: \"a Date\",\n\tRegExp: \"a RegExp\",\n\tError: \"an Error\",\n\tMap: \"a Map\",\n\tSet: \"a Set\",\n\tString: \"a String object\",\n\tNumber: \"a Number object\",\n\tBoolean: \"a Boolean object\",\n\tPromise: \"a Promise\",\n\tWeakMap: \"a WeakMap\",\n\tWeakSet: \"a WeakSet\"\n} as const satisfies Record<keyof EcmascriptObjects, string>\n\nexport const platformDescriptions = {\n\tArrayBuffer: \"an ArrayBuffer instance\",\n\tBlob: \"a Blob instance\",\n\tFile: \"a File instance\",\n\tFormData: \"a FormData instance\",\n\tHeaders: \"a Headers instance\",\n\tRequest: \"a Request instance\",\n\tResponse: \"a Response instance\",\n\tURL: \"a URL instance\"\n}\n\nexport const typedArrayDescriptions = {\n\tInt8Array: \"an Int8Array\",\n\tUint8Array: \"a Uint8Array\",\n\tUint8ClampedArray: \"a Uint8ClampedArray\",\n\tInt16Array: \"an Int16Array\",\n\tUint16Array: \"a Uint16Array\",\n\tInt32Array: \"an Int32Array\",\n\tUint32Array: \"a Uint32Array\",\n\tFloat32Array: \"a Float32Array\",\n\tFloat64Array: \"a Float64Array\",\n\tBigInt64Array: \"a BigInt64Array\",\n\tBigUint64Array: \"a BigUint64Array\"\n} as const satisfies Record<keyof typedArrayConstructors, string>\n\n/** Each defaultObjectKind's completion for the phrase \"must be _____\" */\nexport const objectKindDescriptions = {\n\t...ecmascriptDescriptions,\n\t...platformDescriptions,\n\t...typedArrayDescriptions\n} as const satisfies Record<BuiltinObjectKind, string>\n\nexport type objectKindDescriptions = typeof objectKindDescriptions\n\n/**\n * this will only return an object kind if it's the root constructor\n * example TypeError would return null not 'Error'\n **/\nexport const getBuiltinNameOfConstructor = (\n\tctor: Function\n): BuiltinObjectKind | null => {\n\tconst constructorName: string | null = Object(ctor).name ?? null\n\treturn (\n\t\t\tconstructorName &&\n\t\t\t\tisKeyOf(constructorName, builtinConstructors) &&\n\t\t\t\tbuiltinConstructors[constructorName] === ctor\n\t\t) ?\n\t\t\tconstructorName\n\t\t:\tnull\n}\n\nexport type Constructor<instance = {}> = abstract new (\n\t...args: never[]\n) => instance\n\nexport type instanceOf<constructor> =\n\tconstructor extends Constructor<infer instance> ? instance : never\n\n/**\n * Returns an array of constructors for all ancestors (i.e., prototypes) of a given object.\n */\nexport const ancestorsOf = (o: object): Function[] => {\n\tlet proto = Object.getPrototypeOf(o)\n\tconst result: Function[] = []\n\twhile (proto !== null) {\n\t\tresult.push(proto.constructor)\n\t\tproto = Object.getPrototypeOf(proto)\n\t}\n\treturn result\n}\n\nexport type normalizedKeyOf<t> =\n\tkeyof t extends infer k ?\n\t\tk extends number ?\n\t\t\t`${k}`\n\t\t:\tk\n\t:\tnever\n\nexport const constructorExtends = (\n\tctor: Constructor,\n\tbase: Constructor\n): boolean => {\n\tlet current = ctor.prototype\n\n\twhile (current !== null) {\n\t\tif (current === base.prototype) return true\n\n\t\tcurrent = Object.getPrototypeOf(current)\n\t}\n\treturn false\n}\n"
  },
  {
    "path": "ark/util/package.json",
    "content": "{\n\t\"name\": \"@ark/util\",\n\t\"version\": \"0.56.0\",\n\t\"license\": \"MIT\",\n\t\"author\": {\n\t\t\"name\": \"David Blass\",\n\t\t\"email\": \"david@arktype.io\",\n\t\t\"url\": \"https://arktype.io\"\n\t},\n\t\"type\": \"module\",\n\t\"main\": \"./out/index.js\",\n\t\"types\": \"./out/index.d.ts\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"ark-ts\": \"./index.ts\",\n\t\t\t\"default\": \"./out/index.js\"\n\t\t},\n\t\t\"./tsconfig.base.json\": \"./tsconfig.base.json\",\n\t\t\"./internal/*.ts\": {\n\t\t\t\"ark-ts\": \"./*.ts\",\n\t\t\t\"default\": \"./out/*.js\"\n\t\t},\n\t\t\"./internal/*.js\": {\n\t\t\t\"ark-ts\": \"./*.ts\",\n\t\t\t\"default\": \"./out/*.js\"\n\t\t}\n\t},\n\t\"files\": [\n\t\t\"out\",\n\t\t\"tsconfig.base.json\"\n\t],\n\t\"scripts\": {\n\t\t\"build\": \"ts ../repo/build.ts\",\n\t\t\"test\": \"ts ../repo/testPackage.ts\"\n\t},\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t}\n}\n"
  },
  {
    "path": "ark/util/path.ts",
    "content": "import { ReadonlyArray, type array } from \"./arrays.ts\"\nimport { throwParseError } from \"./errors.ts\"\nimport type { requireKeys } from \"./records.ts\"\nimport { isDotAccessible } from \"./registry.ts\"\nimport { printable, type JsonArray } from \"./serialize.ts\"\n\nexport type StringifyPathOptions<stringifiable = PropertyKey> = requireKeys<\n\t{\n\t\tstringifySymbol?: (s: symbol) => string\n\t\tstringifyNonKey?: (o: Exclude<stringifiable, PropertyKey>) => string\n\t},\n\tstringifiable extends PropertyKey ? never : \"stringifyNonKey\"\n>\n\nexport type StringifyPathFn = <stringifiable>(\n\tpath: array<stringifiable>,\n\t...[opts]: [stringifiable] extends [PropertyKey] ?\n\t\t[opts?: StringifyPathOptions]\n\t:\tNoInfer<[opts: StringifyPathOptions<stringifiable>]>\n) => string\n\nexport type AppendStringifiedKeyFn = <stringifiable>(\n\tpath: string,\n\tprop: stringifiable,\n\t...[opts]: [stringifiable] extends [PropertyKey] ?\n\t\t[opts?: StringifyPathOptions]\n\t:\tNoInfer<[opts: StringifyPathOptions<stringifiable>]>\n) => string\n\nexport const appendStringifiedKey: AppendStringifiedKeyFn = (\n\tpath,\n\tprop,\n\t...[opts]\n) => {\n\tconst stringifySymbol = opts?.stringifySymbol ?? printable\n\tlet propAccessChain: string = path\n\tswitch (typeof prop) {\n\t\tcase \"string\":\n\t\t\tpropAccessChain =\n\t\t\t\tisDotAccessible(prop) ?\n\t\t\t\t\tpath === \"\" ?\n\t\t\t\t\t\tprop\n\t\t\t\t\t:\t`${path}.${prop}`\n\t\t\t\t:\t`${path}[${JSON.stringify(prop)}]`\n\t\t\tbreak\n\t\tcase \"number\":\n\t\t\tpropAccessChain = `${path}[${prop}]`\n\t\t\tbreak\n\t\tcase \"symbol\":\n\t\t\tpropAccessChain = `${path}[${stringifySymbol(prop)}]`\n\t\t\tbreak\n\t\tdefault:\n\t\t\tif (opts?.stringifyNonKey)\n\t\t\t\tpropAccessChain = `${path}[${opts.stringifyNonKey(prop as never)}]`\n\t\t\telse {\n\t\t\t\tthrowParseError(\n\t\t\t\t\t`${printable(prop)} must be a PropertyKey or stringifyNonKey must be passed to options`\n\t\t\t\t)\n\t\t\t}\n\t}\n\treturn propAccessChain\n}\n\nexport const stringifyPath: StringifyPathFn = (path, ...opts) =>\n\tpath.reduce<string>(\n\t\t(s, k) => appendStringifiedKey(s, k, ...(opts as any)),\n\t\t\"\"\n\t)\n\nexport class ReadonlyPath extends ReadonlyArray<PropertyKey> {\n\t// alternate strategy for caching since the base object is frozen\n\tprivate cache: {\n\t\tstringify?: string\n\t\tstringifyAncestors?: readonly string[]\n\t\tjson?: JsonArray\n\t} = {}\n\n\tconstructor(...items: array<PropertyKey>) {\n\t\tsuper()\n\t\t// avoid case where a single number will create empty slots\n\t\t;(this as any).push(...items)\n\t}\n\n\ttoJSON(): JsonArray {\n\t\tif (this.cache.json) return this.cache.json\n\t\tthis.cache.json = []\n\t\tfor (let i = 0; i < this.length; i++) {\n\t\t\tthis.cache.json.push(\n\t\t\t\ttypeof this[i] === \"symbol\" ? printable(this[i]) : (this[i] as never)\n\t\t\t)\n\t\t}\n\n\t\treturn this.cache.json\n\t}\n\n\tstringify(): string {\n\t\tif (this.cache.stringify) return this.cache.stringify\n\t\treturn (this.cache.stringify = stringifyPath(this))\n\t}\n\n\tstringifyAncestors(): readonly string[] {\n\t\tif (this.cache.stringifyAncestors) return this.cache.stringifyAncestors\n\t\tlet propString = \"\"\n\t\tconst result: string[] = [propString]\n\t\tfor (const path of this) {\n\t\t\tpropString = appendStringifiedKey(propString, path)\n\t\t\tresult.push(propString)\n\t\t}\n\t\treturn (this.cache.stringifyAncestors = result)\n\t}\n}\n"
  },
  {
    "path": "ark/util/primitive.ts",
    "content": "import type { inferDomain } from \"./domain.ts\"\nimport type { BigintLiteral } from \"./numbers.ts\"\n\ntype SerializedString<value extends string = string> = `\"${value}\"`\n\nexport type SerializedPrimitives = {\n\tstring: SerializedString\n\tnumber: `${number}`\n\tbigint: BigintLiteral\n\tboolean: \"true\" | \"false\"\n\tnull: \"null\"\n\tundefined: \"undefined\"\n}\n\nexport type SerializedPrimitive =\n\tSerializedPrimitives[keyof SerializedPrimitives]\n\nexport type SerializablePrimitive = inferDomain<keyof SerializedPrimitives>\n\nexport const serializePrimitive = <value extends SerializablePrimitive>(\n\tvalue: value\n): serializePrimitive<value> =>\n\t(typeof value === \"string\" ? JSON.stringify(value)\n\t: typeof value === \"bigint\" ? `${value}n`\n\t: `${value}`) as never\n\nexport type serializePrimitive<value extends SerializablePrimitive> =\n\tvalue extends string ? `\"${value}\"`\n\t: value extends bigint ? `${value}n`\n\t: `${value}`\n"
  },
  {
    "path": "ark/util/records.ts",
    "content": "import type { array } from \"./arrays.ts\"\nimport type { Primitive } from \"./domain.ts\"\nimport { noSuggest, ZeroWidthSpace } from \"./errors.ts\"\nimport { flatMorph } from \"./flatMorph.ts\"\nimport type { Fn } from \"./functions.ts\"\nimport type { defined, show } from \"./generics.ts\"\nimport type { Key } from \"./keys.ts\"\nimport type { intersectUnion } from \"./unionToTuple.ts\"\n\nexport type Dict<k extends string = string, v = unknown> = {\n\treadonly [_ in k]: v\n}\n\nexport type dict<v = unknown, k extends string = string> = {\n\t[_ in k]: v\n}\n\n/** Either:\n * A, with all properties of B undefined\n * OR\n * B, with all properties of A undefined\n **/\nexport type propwiseXor<a, b> =\n\t| show<a & { [k in keyof b]?: undefined }>\n\t| show<b & { [k in keyof a]?: undefined }>\n\nexport type unionToPropwiseXor<\n\tprops extends object,\n\tbranchKey extends PropertyKey = keyof intersectUnion<props>\n> =\n\tprops extends infer distributed ?\n\t\tshow<\n\t\t\tdistributed & {\n\t\t\t\t// ensure keys not present on the current branch are undefined\n\t\t\t\t[k in branchKey]?: k extends keyof distributed ? unknown : undefined\n\t\t\t}\n\t\t>\n\t:\tnever\n\nexport type requireKeys<o, key extends keyof o> = o & {\n\t[requiredKey in key]-?: defined<o[requiredKey]>\n}\n\nexport type require<o, maxDepth extends number = 1> = _require<o, [], maxDepth>\n\ntype _require<o, depth extends 1[], maxDepth extends number> =\n\tdepth[\"length\"] extends maxDepth ? o\n\t: o extends object ?\n\t\to extends Fn ?\n\t\t\to\n\t\t:\t{\n\t\t\t\t[k in keyof o]-?: _require<o[k], [...depth, 1], maxDepth>\n\t\t\t}\n\t:\to\n\nexport type PartialRecord<k extends PropertyKey = PropertyKey, v = unknown> = {\n\t[_ in k]?: v\n}\n\n/** Returns true if a type can be homomorphically mapped without losing information.\n * Useful for avoiding e.g. classes with private properties while mapping.\n */\nexport type isSafelyMappable<t> =\n\t{ [k in keyof t]: t[k] } extends t ? true : false\n\nexport type KeySet<key extends string = string> = { readonly [_ in key]?: 1 }\n\nexport type keySetOf<o extends object> = KeySet<Extract<keyof o, string>>\n\nexport type mutable<o, maxDepth extends number = 1> = _mutable<o, [], maxDepth>\n\ntype _mutable<o, depth extends 1[], maxDepth extends number> =\n\tdepth[\"length\"] extends maxDepth ? o\n\t: o extends Primitive ? o\n\t: o extends Fn ? o\n\t: {\n\t\t\t-readonly [k in keyof o]: _mutable<o[k], [...depth, 1], maxDepth>\n\t\t}\n\n/**\n * extracts entries mimicking Object.entries, accounting for whether the\n * object is an array\n **/\nexport type entryOf<o> = {\n\t[k in keyof o]-?: [k, o[k] & ({} | null)]\n}[o extends readonly unknown[] ? keyof o & number : keyof o] &\n\tunknown\n\nexport type entriesOf<o extends object> = entryOf<o>[]\n\n/**\n * Object.entries wrapper providing narrowed types for objects with known sets\n * of keys, e.g. those defined internally as configs\n */\nexport const entriesOf: <o extends object>(o: o) => entryOf<o>[] =\n\tObject.entries as never\n\nexport type Entry<\n\tkey extends PropertyKey = PropertyKey,\n\tvalue = unknown\n> = readonly [key: key, value: value]\n\nexport type fromEntries<entries extends readonly Entry[]> = show<{\n\t[entry in entries[number] as entry[0]]: entry[1]\n}>\n\nexport const fromEntries = <const entries extends readonly Entry[]>(\n\tentries: entries\n): fromEntries<entries> => Object.fromEntries(entries) as never\n\n/** Mimics the result of Object.keys(...) */\nexport type keyOf<o> =\n\to extends array ?\n\t\tnumber extends o[\"length\"] ?\n\t\t\t`${number}`\n\t\t:\tkeyof o & `${number}`\n\t: keyof o extends infer k ?\n\t\tk extends string ? k\n\t\t: k extends number ? `${k}`\n\t\t: never\n\t:\tnever\n\nexport const keysOf = <o extends object>(o: o): keyOf<o>[] =>\n\tObject.keys(o) as never\n\nexport const isKeyOf = <k extends string | number | symbol, o extends object>(\n\tk: k,\n\to: o\n): k is Extract<keyof o, k> => k in o\n\n/** Coalesce keys that exist on one or more branches of a union */\nexport type unionKeyOf<t> = t extends unknown ? keyof t : never\n\nexport type extractKeyed<o extends object, k extends unionKeyOf<o>> = Extract<\n\to,\n\t{ [_ in k]?: unknown }\n>\n\nexport const hasKey = <o extends object, k extends unionKeyOf<o>>(\n\to: o,\n\tk: k\n): o is extractKeyed<o, k> => k in o\n\nexport type extractDefinedKey<o extends object, k extends unionKeyOf<o>> = show<\n\textractKeyed<o, k> & { [_ in k]: {} | null }\n>\n\n// must be defined this way to avoid https://github.com/microsoft/TypeScript/issues/55049\nexport const hasDefinedKey: <o extends object, k extends unionKeyOf<o>>(\n\to: o,\n\tk: k\n) => o is extractDefinedKey<o, k> = (o, k): o is any =>\n\t(o as any)[k] !== undefined\n\nexport type requiredKeyOf<o> =\n\tkeyof o extends infer k ?\n\t\tk extends keyof o ?\n\t\t\to extends { [_ in k]-?: o[k] } ?\n\t\t\t\tk\n\t\t\t:\tnever\n\t\t:\tnever\n\t:\tnever\n\nexport type optionalKeyOf<o> = Exclude<keyof o, requiredKeyOf<o>>\n\nexport type merge<base, props> =\n\tbase extends unknown ?\n\t\tprops extends unknown ?\n\t\t\tkeyof base & keyof props extends never ?\n\t\t\t\tshow<base & props>\n\t\t\t:\tshow<omit<base, keyof props & keyof base> & props>\n\t\t:\tnever\n\t:\tnever\n\nexport type override<\n\tbase,\n\tmerged extends { [k in keyof base]?: unknown }\n> = merge<base, merged>\n\nexport type propValueOf<o> = o[keyof o]\n\nexport const InnerDynamicBase = class {} as new <t extends object>(base: t) => t\n\nexport declare class Covariant<t> {\n\t/**\n\t * Patterns of the form `interface Example<T> extends T {}` don't count as using `T`.\n\t * From tsc's point of view when calculating variance it may as well look like `interface Example<T> {}`.\n\t * Fundamentally this ordinarily means `Example<T>` will always be assignable to `Example<U>` and\n\t * vice versa.\n\t *\n\t * Obviously this is a problem, so `Covariant` exists to add an unobtrusive covariant usage of the type\n\t * parameter, making `Example<T>` assignable to `Example<U>` only if `T` is a subtype of `U`.\n\t */\n\tprivate \" covariant\"?: t\n}\n\n/** @ts-ignore (needed to extend `t`) **/\nexport interface DynamicBase<t extends object> extends t, Covariant<t> {}\nexport class DynamicBase<t extends object> {\n\tconstructor(properties: t) {\n\t\tObject.assign(this, properties)\n\t}\n}\n\nexport const NoopBase = class {} as new <t extends object>() => t\n\n/** @ts-ignore (needed to extend `t`) **/\nexport class CastableBase<t extends object> extends NoopBase<t> {\n\tdeclare private \" covariant\"?: t\n}\n\nexport const splitByKeys = <o extends object, leftKeys extends keySetOf<o>>(\n\to: o,\n\tleftKeys: leftKeys\n): [\n\tshow<Pick<o, keyof leftKeys & keyof o>>,\n\tshow<Omit<o, keyof leftKeys & keyof o>>\n] => {\n\tconst l: any = {}\n\tconst r: any = {}\n\tlet k: keyof o\n\tfor (k in o) {\n\t\tif (k in leftKeys) l[k] = o[k]\n\t\telse r[k] = o[k]\n\t}\n\treturn [l, r]\n}\n\n/** Homomorphic implementation of the builtin Pick.\n *\n * Gives different results for certain union expressions like the following:\n *\n * @example\n * // flattens result to { a?: 1 | 2; b?: 1 | 2 }\n * type PickResult = Pick<{ a: 1; b?: 1 } | { a?: 2; b: 2 }, \"a\" | \"b\">\n *\n * @example\n * // preserves original type w/ modifier groupings\n * type pickResult = pick<{ a: 1; b?: 1 } | { a?: 2; b: 2 }, \"a\" | \"b\">\n */\nexport type pick<o, key extends keyof o> =\n\to extends unknown ?\n\t\t{\n\t\t\t[k in keyof o as k extends key ? k : never]: o[k]\n\t\t}\n\t:\t// could also consider adding the following to extract literal keys from\n\t\t// index signatures as optional. doesn't match existing TS behavior though:\n\t\t//  & { [k in keyof o as key extends k ? key : never]?: o[k] }\n\t\tnever\n\nexport const pick = <o extends object, keys extends keySetOf<o>>(\n\to: o,\n\tkeys: keys\n): pick<o, keyof keys & keyof o> => splitByKeys(o, keys)[0] as never\n\n/** Homomorphic implementation of the builtin Omit.\n *\n * Gives different results for many union expressions like the following:\n *\n * @example\n * // {}\n * type OmitResult = Omit<{ a: 1 } | { b: 2 }, never>\n *\n * @example\n * // preserves original type w/ modifier groupings\n * type omitResult = omit<{ a: 1 } | { b: 2 }, never>\n */\nexport type omit<o, key extends keyof o> = {\n\t[k in keyof o as k extends key ? never : k]: o[k]\n}\n\nexport const omit = <o extends object, keys extends keySetOf<o>>(\n\to: o,\n\tkeys: keys\n): omit<o, keyof keys & keyof o> => splitByKeys(o, keys)[1] as never\n\n/** Returns onTrue if the type is exactly `{}` and onFalse otherwise*/\nexport type ifEmptyObjectLiteral<t, onTrue = true, onFalse = false> =\n\t[unknown, t & (null | undefined)] extends [t | null | undefined, never] ?\n\t\tonTrue\n\t:\tonFalse\n\nexport type EmptyObject = Record<PropertyKey, never>\n\nexport const isEmptyObject = (o: object): o is EmptyObject =>\n\tObject.keys(o).length === 0\n\nexport const stringAndSymbolicEntriesOf = (o: object): Entry<Key>[] => [\n\t...Object.entries(o),\n\t...Object.getOwnPropertySymbols(o).map(k => [k, (o as any)[k]] as const)\n]\n\n/** Like Object.assign, but it will preserve getters instead of evaluating them. */\nexport const defineProperties: <base extends object, merged extends object>(\n\tbase: base,\n\tmerged: merged\n) => merge<base, merged> = (base, merged) =>\n\t// declared like this to avoid https://github.com/microsoft/TypeScript/issues/55049\n\tObject.defineProperties(\n\t\tbase,\n\t\tObject.getOwnPropertyDescriptors(merged)\n\t) as never\n\n/** Copies enumerable keys of o to a new object in alphabetical order */\nexport const withAlphabetizedKeys: <o extends object>(o: o) => o = (o: any) => {\n\tconst keys = Object.keys(o).sort()\n\tconst result: any = {}\n\n\tfor (let i = 0; i < keys.length; i++) result[keys[i]] = o[keys[i]]\n\n\treturn result\n}\n\nexport type invert<t extends Record<PropertyKey, PropertyKey>> = {\n\t[k in t[keyof t]]: {\n\t\t[k2 in keyof t]: t[k2] extends k ? k2 : never\n\t}[keyof t]\n} & unknown\n\nexport const invert = <t extends Record<PropertyKey, PropertyKey>>(\n\tt: t\n): invert<t> => flatMorph(t as any, (k, v) => [v, k]) as never\n\nexport const unset = noSuggest(`unset${ZeroWidthSpace}`)\n\nexport type unset = typeof unset\n\n/**\n *  For each keyof o that also exists on jsDocSource, add associated JsDoc annotations to o.\n *  Does not preserve modifiers on o like optionality.\n */\nexport type withJsDoc<o, jsDocSource> = show<\n\tkeyof o extends keyof jsDocSource ?\n\t\tkeyof jsDocSource extends keyof o ?\n\t\t\t_withJsDoc<o, jsDocSource>\n\t\t:\tPick<_withJsDoc<o, jsDocSource>, keyof o & keyof jsDocSource>\n\t:\tPick<_withJsDoc<o, jsDocSource>, keyof o & keyof jsDocSource> & {\n\t\t\t[k in Exclude<keyof o, keyof jsDocSource>]: o[k]\n\t\t}\n>\n\ntype _withJsDoc<o, jsDocSource> = {\n\t[k in keyof jsDocSource]-?: o[k & keyof o]\n}\n\nexport type propertyDescriptorsOf<o extends object> = {\n\t[k in keyof o]: TypedPropertyDescriptor<o[k]>\n}\n\nexport type keyWithValue<t, constraint> =\n\tkeyof t extends infer k ?\n\t\tk extends keyof t ?\n\t\t\tt[k] extends constraint ?\n\t\t\t\tk\n\t\t\t:\tnever\n\t\t:\tnever\n\t:\tnever\n\nexport const enumValues = <tsEnum extends object>(\n\ttsEnum: tsEnum\n): tsEnum[keyof tsEnum][] =>\n\tObject.values(tsEnum).filter(v => {\n\t\tif (typeof v === \"number\") return true\n\n\t\treturn typeof tsEnum[v as never] !== \"number\"\n\t}) as never\n"
  },
  {
    "path": "ark/util/registry.ts",
    "content": "import { domainOf } from \"./domain.ts\"\nimport { throwInternalError } from \"./errors.ts\"\nimport { isomorphic } from \"./isomorphic.ts\"\nimport { FileConstructor, objectKindOf } from \"./objectKinds.ts\"\n\n// Eventually we can just import from package.json in the source itself\n// but for now, import assertions are too unstable and it wouldn't support\n// recent node versions (https://nodejs.org/api/esm.html#json-modules).\n\n// For now, we assert this matches the package.json version via a unit test.\nexport const arkUtilVersion = \"0.56.0\"\n\nexport const initialRegistryContents = {\n\tversion: arkUtilVersion,\n\tfilename: isomorphic.fileName(),\n\tFileConstructor\n}\n\nexport type InitialRegistryContents = typeof initialRegistryContents\n\nexport interface ArkRegistry extends InitialRegistryContents {\n\t[k: string]: unknown\n}\n\nexport const registry: ArkRegistry = initialRegistryContents as never\n\ndeclare global {\n\texport interface ArkEnv {\n\t\tprototypes(): never\n\t}\n\n\texport namespace ArkEnv {\n\t\texport type prototypes = ReturnType<ArkEnv[\"prototypes\"]>\n\t}\n}\n\nconst namesByResolution = new Map<object | symbol, string>()\nconst nameCounts: Record<string, number | undefined> = Object.create(null)\n\nexport const register = (value: object | symbol): string => {\n\tconst existingName = namesByResolution.get(value)\n\tif (existingName) return existingName\n\n\tlet name = baseNameFor(value)\n\tif (nameCounts[name]) name = `${name}${nameCounts[name]!++}`\n\telse nameCounts[name] = 1\n\n\tregistry[name] = value\n\tnamesByResolution.set(value, name)\n\treturn name\n}\n\nexport const isDotAccessible = (keyName: string): boolean =>\n\t/^[$A-Z_a-z][\\w$]*$/.test(keyName)\n\nconst baseNameFor = (value: object | symbol) => {\n\tswitch (typeof value) {\n\t\tcase \"object\": {\n\t\t\tif (value === null) break\n\n\t\t\tconst prefix = objectKindOf(value) ?? \"object\"\n\t\t\t// convert to camelCase\n\t\t\treturn prefix[0].toLowerCase() + prefix.slice(1)\n\t\t}\n\t\tcase \"function\":\n\t\t\treturn isDotAccessible(value.name) ? value.name : \"fn\"\n\t\tcase \"symbol\":\n\t\t\treturn value.description && isDotAccessible(value.description) ?\n\t\t\t\t\tvalue.description\n\t\t\t\t:\t\"symbol\"\n\t}\n\treturn throwInternalError(\n\t\t`Unexpected attempt to register serializable value of type ${domainOf(\n\t\t\tvalue\n\t\t)}`\n\t)\n}\n"
  },
  {
    "path": "ark/util/scanner.ts",
    "content": "import type { KeySet } from \"./records.ts\"\nimport { Backslash, whitespaceChars, type WhitespaceChar } from \"./strings.ts\"\n\nexport class Scanner<lookahead extends string = string> {\n\tchars: string[]\n\ti: number\n\tdef: string\n\n\tconstructor(def: string) {\n\t\tthis.def = def\n\t\tthis.chars = [...def]\n\t\tthis.i = 0\n\t}\n\n\t/** Get lookahead and advance scanner by one */\n\tshift(): this[\"lookahead\"] {\n\t\treturn (this.chars[this.i++] ?? \"\") as never\n\t}\n\n\tget lookahead(): lookahead {\n\t\treturn (this.chars[this.i] ?? \"\") as never\n\t}\n\n\tget nextLookahead(): string {\n\t\treturn this.chars[this.i + 1] ?? \"\"\n\t}\n\n\tget length(): number {\n\t\treturn this.chars.length\n\t}\n\n\tshiftUntil(condition: Scanner.UntilCondition): string {\n\t\tlet shifted = \"\"\n\t\twhile (this.lookahead) {\n\t\t\tif (condition(this, shifted)) break\n\t\t\telse shifted += this.shift()\n\t\t}\n\t\treturn shifted\n\t}\n\n\tshiftUntilEscapable(condition: Scanner.UntilCondition): string {\n\t\tlet shifted = \"\"\n\t\twhile (this.lookahead) {\n\t\t\tif (this.lookahead === Backslash) {\n\t\t\t\tthis.shift()\n\t\t\t\tif (condition(this, shifted)) shifted += this.shift()\n\t\t\t\telse if (this.lookahead === Backslash) shifted += this.shift()\n\t\t\t\telse shifted += `${Backslash}${this.shift()}`\n\t\t\t} else if (condition(this, shifted)) break\n\t\t\telse shifted += this.shift()\n\t\t}\n\t\treturn shifted\n\t}\n\n\tshiftUntilLookahead(charOrSet: string | KeySet): string {\n\t\treturn typeof charOrSet === \"string\" ?\n\t\t\t\tthis.shiftUntil(s => s.lookahead === charOrSet)\n\t\t\t:\tthis.shiftUntil(s => s.lookahead in charOrSet)\n\t}\n\n\tshiftUntilNonWhitespace(): string {\n\t\treturn this.shiftUntil(() => !(this.lookahead in whitespaceChars))\n\t}\n\n\tjumpToIndex(i: number): void {\n\t\tthis.i = i < 0 ? this.length + i : i\n\t}\n\n\tjumpForward(count: number): void {\n\t\tthis.i += count\n\t}\n\n\tget location(): number {\n\t\treturn this.i\n\t}\n\n\tget unscanned(): string {\n\t\treturn this.chars.slice(this.i, this.length).join(\"\")\n\t}\n\n\tget scanned(): string {\n\t\treturn this.chars.slice(0, this.i).join(\"\")\n\t}\n\n\tsliceChars(start: number, end?: number): string {\n\t\treturn this.chars.slice(start, end).join(\"\")\n\t}\n\n\tlookaheadIs<char extends lookahead>(char: char): this is Scanner<char> {\n\t\treturn this.lookahead === char\n\t}\n\n\tlookaheadIsIn<keySet extends KeySet>(\n\t\ttokens: keySet\n\t): this is Scanner<Extract<keyof keySet, string>> {\n\t\treturn this.lookahead in tokens\n\t}\n}\n\nexport declare namespace Scanner {\n\texport type UntilCondition = (scanner: Scanner, shifted: string) => boolean\n\n\texport type shift<\n\t\tlookahead extends string,\n\t\tunscanned extends string\n\t> = `${lookahead}${unscanned}`\n\n\texport type shiftUntil<\n\t\tunscanned extends string,\n\t\tterminator extends string,\n\t\tappendTo extends string = \"\"\n\t> =\n\t\tunscanned extends shift<infer lookahead, infer nextUnscanned> ?\n\t\t\tlookahead extends terminator ?\n\t\t\t\t[appendTo, unscanned]\n\t\t\t:\tshiftUntil<nextUnscanned, terminator, `${appendTo}${lookahead}`>\n\t\t:\t[appendTo, \"\"]\n\n\texport type shiftUntilEscapable<\n\t\tunscanned extends string,\n\t\tterminator extends string,\n\t\tescapeEscape extends Backslash | \"\",\n\t\tappendTo extends string = \"\"\n\t> =\n\t\tunscanned extends shift<infer lookahead, infer nextUnscanned> ?\n\t\t\tlookahead extends terminator ? [appendTo, unscanned]\n\t\t\t: lookahead extends Backslash ?\n\t\t\t\tnextUnscanned extends (\n\t\t\t\t\tshift<infer nextLookahead, infer postEscapedUnscanned>\n\t\t\t\t) ?\n\t\t\t\t\tshiftUntilEscapable<\n\t\t\t\t\t\tpostEscapedUnscanned,\n\t\t\t\t\t\tterminator,\n\t\t\t\t\t\tescapeEscape,\n\t\t\t\t\t\t`${appendTo}${nextLookahead extends terminator ? \"\"\n\t\t\t\t\t\t: nextLookahead extends Backslash ? escapeEscape\n\t\t\t\t\t\t: Backslash}${nextLookahead}`\n\t\t\t\t\t>\n\t\t\t\t:\t[`${appendTo}${Backslash}`, \"\"]\n\t\t\t:\tshiftUntilEscapable<\n\t\t\t\t\tnextUnscanned,\n\t\t\t\t\tterminator,\n\t\t\t\t\tescapeEscape,\n\t\t\t\t\t`${appendTo}${lookahead}`\n\t\t\t\t>\n\t\t:\t[appendTo, \"\"]\n\n\texport type shiftUntilNot<\n\t\tunscanned extends string,\n\t\tnonTerminator extends string,\n\t\tappendTo extends string = \"\"\n\t> =\n\t\tunscanned extends shift<infer lookahead, infer nextUnscanned> ?\n\t\t\tlookahead extends nonTerminator ?\n\t\t\t\tshiftUntilNot<nextUnscanned, nonTerminator, `${appendTo}${lookahead}`>\n\t\t\t:\t[appendTo, unscanned]\n\t\t:\t[appendTo, \"\"]\n\n\texport type skipWhitespace<unscanned extends string> = shiftUntilNot<\n\t\tunscanned,\n\t\tWhitespaceChar\n\t>[1]\n\n\texport type shiftResult<scanned extends string, unscanned extends string> = [\n\t\tscanned,\n\t\tunscanned\n\t]\n}\n\nexport const writeUnmatchedGroupCloseMessage = <\n\tchar extends string,\n\tunscanned extends string\n>(\n\tchar: char,\n\tunscanned: unscanned\n): writeUnmatchedGroupCloseMessage<char, unscanned> =>\n\t`Unmatched ${char}${(unscanned === \"\" ? \"\" : ` before ${unscanned}`) as any}`\n\nexport type writeUnmatchedGroupCloseMessage<\n\tchar extends string,\n\tunscanned extends string\n> = `Unmatched ${char}${unscanned extends \"\" ? \"\" : ` before ${unscanned}`}`\n\nexport const writeUnclosedGroupMessage = <missingChar extends string>(\n\tmissingChar: missingChar\n): writeUnclosedGroupMessage<missingChar> => `Missing ${missingChar}`\n\nexport type writeUnclosedGroupMessage<missingChar extends string> =\n\t`Missing ${missingChar}`\n"
  },
  {
    "path": "ark/util/serialize.ts",
    "content": "import type { array } from \"./arrays.ts\"\nimport { domainOf, type Primitive } from \"./domain.ts\"\nimport { serializePrimitive, type SerializablePrimitive } from \"./primitive.ts\"\nimport { stringAndSymbolicEntriesOf, type dict } from \"./records.ts\"\nimport { isDotAccessible, register } from \"./registry.ts\"\n\nexport type SerializationOptions = {\n\tonCycle?: (value: object) => string\n\tonSymbol?: (value: symbol) => string\n\tonFunction?: (value: Function) => string\n\tonUndefined?: string\n\tonBigInt?: (value: bigint) => string\n}\n\nexport type JsonStructure = JsonObject | JsonArray\n\nexport interface JsonObject {\n\t[k: string]: Json\n}\n\nexport type JsonArray = Json[]\n\nexport type JsonPrimitive = string | boolean | number | null\n\nexport type Json = JsonStructure | JsonPrimitive\n\nexport const snapshot = <t>(\n\tdata: t,\n\topts: SerializationOptions = {}\n): snapshot<t> =>\n\t_serialize(\n\t\tdata,\n\t\t{\n\t\t\tonUndefined: `$ark.undefined`,\n\t\t\tonBigInt: n => `$ark.bigint-${n}`,\n\t\t\t...opts\n\t\t},\n\t\t[]\n\t) as never\n\nexport type snapshot<t, depth extends 1[] = []> =\n\tunknown extends t ? unknown\n\t: t extends Primitive ? snapshotPrimitive<t>\n\t: t extends { toJSON: () => infer serialized } ? serialized\n\t: t extends Function ? `Function(${string})`\n\t: t extends Date ? string\n\t: depth[\"length\"] extends 10 ? unknown\n\t: t extends array<infer item> ? array<snapshot<item, [...depth, 1]>>\n\t: {\n\t\t\t[k in keyof t as snapshotPrimitive<k>]: snapshot<t[k], [...depth, 1]>\n\t\t}\n\ntype snapshotPrimitive<t> = t extends symbol ? `Symbol(${string})` : t\n\nexport type PrintableOptions = {\n\tindent?: number\n\tquoteKeys?: boolean\n}\n\nexport const print = (data: unknown, opts?: PrintableOptions): void =>\n\tconsole.log(printable(data, opts))\n\nexport const printable = (data: unknown, opts?: PrintableOptions): string => {\n\tswitch (domainOf(data)) {\n\t\tcase \"object\":\n\t\t\tconst o = data as dict\n\t\t\tconst ctorName = o.constructor?.name ?? \"Object\"\n\t\t\treturn (\n\t\t\t\tctorName === \"Object\" || ctorName === \"Array\" ?\n\t\t\t\t\topts?.quoteKeys === false ?\n\t\t\t\t\t\tstringifyUnquoted(o, opts?.indent ?? 0, \"\")\n\t\t\t\t\t:\tJSON.stringify(_serialize(o, printableOpts, []), null, opts?.indent)\n\t\t\t\t:\tstringifyUnquoted(o, opts?.indent ?? 0, \"\")\n\t\t\t)\n\t\tcase \"symbol\":\n\t\t\treturn printableOpts.onSymbol(data as symbol)\n\t\tdefault:\n\t\t\treturn serializePrimitive(data as SerializablePrimitive)\n\t}\n}\n\nconst stringifyUnquoted = (\n\tvalue: unknown,\n\tindent: number,\n\tcurrentIndent: string\n): string => {\n\tif (typeof value === \"function\") return printableOpts.onFunction(value)\n\tif (typeof value !== \"object\" || value === null)\n\t\treturn serializePrimitive(value as never)\n\n\tconst nextIndent = currentIndent + \" \".repeat(indent)\n\n\tif (Array.isArray(value)) {\n\t\tif (value.length === 0) return \"[]\"\n\t\tconst items = value\n\t\t\t.map(item => stringifyUnquoted(item, indent, nextIndent))\n\t\t\t.join(\",\\n\" + nextIndent)\n\t\treturn indent ? `[\\n${nextIndent}${items}\\n${currentIndent}]` : `[${items}]`\n\t}\n\n\tconst ctorName = value.constructor?.name ?? \"Object\"\n\n\tif (ctorName === \"Object\") {\n\t\tconst keyValues = stringAndSymbolicEntriesOf(value).map(([key, val]) => {\n\t\t\tconst stringifiedKey =\n\t\t\t\ttypeof key === \"symbol\" ? printableOpts.onSymbol(key)\n\t\t\t\t: isDotAccessible(key) ? key\n\t\t\t\t: JSON.stringify(key)\n\t\t\tconst stringifiedValue = stringifyUnquoted(val, indent, nextIndent)\n\t\t\treturn `${nextIndent}${stringifiedKey}: ${stringifiedValue}`\n\t\t})\n\n\t\tif (keyValues.length === 0) return \"{}\"\n\n\t\treturn indent ?\n\t\t\t\t`{\\n${keyValues.join(\",\\n\")}\\n${currentIndent}}`\n\t\t\t:\t`{${keyValues.join(\", \")}}`\n\t}\n\n\tif (value instanceof Date) return describeCollapsibleDate(value)\n\n\tif (\"expression\" in value && typeof value.expression === \"string\")\n\t\treturn value.expression\n\n\treturn ctorName\n}\n\nconst printableOpts = {\n\tonCycle: () => \"(cycle)\",\n\tonSymbol: v => `Symbol(${register(v)})`,\n\tonFunction: v => `Function(${register(v)})`\n} satisfies SerializationOptions\n\nconst _serialize = (\n\tdata: unknown,\n\topts: SerializationOptions,\n\tseen: unknown[]\n): unknown => {\n\tswitch (domainOf(data)) {\n\t\tcase \"object\": {\n\t\t\tconst o = data as object\n\t\t\tif (\"toJSON\" in o && typeof o.toJSON === \"function\") return o.toJSON()\n\t\t\tif (typeof o === \"function\") return printableOpts.onFunction(o)\n\n\t\t\tif (seen.includes(o)) return \"(cycle)\"\n\n\t\t\tconst nextSeen = [...seen, o]\n\t\t\tif (Array.isArray(o))\n\t\t\t\treturn o.map(item => _serialize(item, opts, nextSeen))\n\n\t\t\tif (o instanceof Date) return o.toDateString()\n\n\t\t\tconst result: Record<string, unknown> = {}\n\t\t\tfor (const k in o) result[k] = _serialize((o as any)[k], opts, nextSeen)\n\n\t\t\tfor (const s of Object.getOwnPropertySymbols(o)) {\n\t\t\t\tresult[opts.onSymbol?.(s as symbol) ?? s.toString()] = _serialize(\n\t\t\t\t\t(o as any)[s],\n\t\t\t\t\topts,\n\t\t\t\t\tnextSeen\n\t\t\t\t)\n\t\t\t}\n\n\t\t\treturn result\n\t\t}\n\t\tcase \"symbol\":\n\t\t\treturn printableOpts.onSymbol(data as symbol)\n\t\tcase \"bigint\":\n\t\t\treturn opts.onBigInt?.(data as bigint) ?? `${data}n`\n\t\tcase \"undefined\":\n\t\t\treturn opts.onUndefined ?? \"undefined\"\n\t\tcase \"string\":\n\t\t\treturn (data as string).replace(/\\\\/g, \"\\\\\\\\\")\n\t\tdefault:\n\t\t\treturn data\n\t}\n}\n\n/**\n * Converts a Date instance to a human-readable description relative to its precision\n */\nexport const describeCollapsibleDate = (date: Date): string => {\n\tconst year = date.getFullYear()\n\tconst month = date.getMonth()\n\tconst dayOfMonth = date.getDate()\n\tconst hours = date.getHours()\n\tconst minutes = date.getMinutes()\n\tconst seconds = date.getSeconds()\n\tconst milliseconds = date.getMilliseconds()\n\n\tif (\n\t\tmonth === 0 &&\n\t\tdayOfMonth === 1 &&\n\t\thours === 0 &&\n\t\tminutes === 0 &&\n\t\tseconds === 0 &&\n\t\tmilliseconds === 0\n\t)\n\t\treturn `${year}`\n\n\tconst datePortion = `${months[month]} ${dayOfMonth}, ${year}`\n\n\tif (hours === 0 && minutes === 0 && seconds === 0 && milliseconds === 0)\n\t\treturn datePortion\n\n\tlet timePortion = date.toLocaleTimeString()\n\n\tconst suffix =\n\t\ttimePortion.endsWith(\" AM\") || timePortion.endsWith(\" PM\") ?\n\t\t\ttimePortion.slice(-3)\n\t\t:\t\"\"\n\n\tif (suffix) timePortion = timePortion.slice(0, -suffix.length)\n\n\tif (milliseconds) timePortion += `.${pad(milliseconds, 3)}`\n\telse if (timeWithUnnecessarySeconds.test(timePortion))\n\t\ttimePortion = timePortion.slice(0, -3)\n\n\treturn `${timePortion + suffix}, ${datePortion}`\n}\n\nconst months = [\n\t\"January\",\n\t\"February\",\n\t\"March\",\n\t\"April\",\n\t\"May\",\n\t\"June\",\n\t\"July\",\n\t\"August\",\n\t\"September\",\n\t\"October\",\n\t\"November\",\n\t\"December\"\n]\n\nconst timeWithUnnecessarySeconds = /:\\d\\d:00$/\n\nconst pad = (value: number, length: number) =>\n\tString(value).padStart(length, \"0\")\n"
  },
  {
    "path": "ark/util/strings.ts",
    "content": "import type { KeySet } from \"./records.ts\"\n\nexport const capitalize = <s extends string>(s: s): Capitalize<s> =>\n\t(s[0].toUpperCase() + s.slice(1)) as never\n\nexport const uncapitalize = <s extends string>(s: s): Uncapitalize<s> =>\n\t(s[0].toLowerCase() + s.slice(1)) as never\n\nexport type firstChar<s extends string> =\n\ts extends `${infer head}${string}` ? head : \"\"\n\nexport type charsAfterFirst<s extends string> =\n\ts extends `${string}${infer tail}` ? tail : \"\"\n\nexport type lastChar<s extends string> =\n\ts extends `${infer head}${infer tail}` ?\n\t\ttail extends \"\" ?\n\t\t\thead\n\t\t:\tlastChar<tail>\n\t:\ts\n\nexport type charsBeforeLast<s extends string> =\n\ts extends `${infer head}${infer tail}` ?\n\t\ttail extends \"\" ?\n\t\t\t\"\"\n\t\t:\t`${head}${charsBeforeLast<tail>}`\n\t:\t\"\"\n\nexport type contains<s extends string, sub extends string> =\n\ts extends `${string}${sub}${string}` ? true : false\n\nexport const anchoredRegex = (regex: RegExp | string): RegExp =>\n\tnew RegExp(\n\t\tanchoredSource(regex),\n\t\ttypeof regex === \"string\" ? \"\" : regex.flags\n\t)\n\nexport const deanchoredRegex = (regex: RegExp | string): RegExp =>\n\tnew RegExp(\n\t\tdeanchoredSource(regex),\n\t\ttypeof regex === \"string\" ? \"\" : regex.flags\n\t)\n\nexport const anchoredSource = (regex: RegExp | string): string => {\n\tconst source = typeof regex === \"string\" ? regex : regex.source\n\treturn `^(?:${source})$`\n}\n\nexport const deanchoredSource = (regex: RegExp | string): string => {\n\tconst source = typeof regex === \"string\" ? regex : regex.source\n\n\tif (source.startsWith(\"^(?:\") && source.endsWith(\")$\"))\n\t\treturn source.slice(4, -2)\n\n\treturn source.slice(\n\t\tsource[0] === \"^\" ? 1 : 0,\n\t\tsource[source.length - 1] === \"$\" ? -1 : undefined\n\t)\n}\n\nexport const RegexPatterns = {\n\tnegativeLookahead: (pattern: string) => `(?!${pattern})` as const,\n\tnonCapturingGroup: (pattern: string) => `(?:${pattern})` as const\n}\n\nexport const Backslash = \"\\\\\"\n\nexport type Backslash = typeof Backslash\n\nexport const whitespaceChars = {\n\t\" \": 1,\n\t\"\\n\": 1,\n\t\"\\t\": 1\n} as const satisfies KeySet\n\nexport type WhitespaceChar = keyof typeof whitespaceChars\n\nexport type trim<s extends string> = trimEnd<trimStart<s>>\n\nexport type trimStart<s extends string> =\n\ts extends `${WhitespaceChar}${infer tail}` ? trimEnd<tail> : s\n\nexport type trimEnd<s extends string> =\n\ts extends `${infer init}${WhitespaceChar}` ? trimEnd<init> : s\n\n// Credit to @gugaguichard for this! https://x.com/gugaguichard/status/1720528864500150534\nexport type isStringLiteral<t> =\n\t[t] extends [string] ?\n\t\t[string] extends [t] ? false\n\t\t: Uppercase<t> extends Uppercase<Lowercase<t>> ?\n\t\t\tLowercase<t> extends Lowercase<Uppercase<t>> ?\n\t\t\t\ttrue\n\t\t\t:\tfalse\n\t\t:\tfalse\n\t:\tfalse\n\nexport const emojiToUnicode = (emoji: string): string =>\n\temoji\n\t\t.split(\"\")\n\t\t.map(char => {\n\t\t\tconst codePoint = char.codePointAt(0)\n\t\t\treturn codePoint ? `\\\\u${codePoint.toString(16).padStart(4, \"0\")}` : \"\"\n\t\t})\n\t\t.join(\"\")\n\nexport const alphabet = [\n\t\"a\",\n\t\"b\",\n\t\"c\",\n\t\"d\",\n\t\"e\",\n\t\"f\",\n\t\"g\",\n\t\"h\",\n\t\"i\",\n\t\"j\",\n\t\"k\",\n\t\"l\",\n\t\"m\",\n\t\"n\",\n\t\"o\",\n\t\"p\",\n\t\"q\",\n\t\"r\",\n\t\"s\",\n\t\"t\",\n\t\"u\",\n\t\"v\",\n\t\"w\",\n\t\"x\",\n\t\"y\",\n\t\"z\"\n] as const\n"
  },
  {
    "path": "ark/util/traits.ts",
    "content": "import type { array } from \"./arrays.ts\"\nimport { hasDomain } from \"./domain.ts\"\nimport { noSuggest } from \"./errors.ts\"\nimport type { conform, satisfy, show } from \"./generics.ts\"\nimport type { intersectParameters } from \"./intersections.ts\"\nimport { type Constructor, ancestorsOf } from \"./objectKinds.ts\"\nimport { NoopBase } from \"./records.ts\"\n\nexport type TraitImplementation = <\n\ttraits extends TraitConstructor[],\n\timplementation extends implementationOf<s>,\n\ts extends CompositionState = composeTraits<\n\t\t[...traits, implementation],\n\t\t\"implementation\"\n\t>,\n\tcls extends TraitConstructor = TraitConstructor<\n\t\ts[\"params\"],\n\t\ts[\"implemented\"],\n\t\ts[\"statics\"],\n\t\ts[\"abstractMethods\"],\n\t\ts[\"abstractProps\"],\n\t\ts[\"abstractStatics\"]\n\t>\n>(\n\t...args: [...traits, implementation & ThisType<InstanceType<cls>>]\n) => cls\n\nexport type TraitComposition = <\n\ttraits extends TraitConstructor[],\n\ts extends CompositionState = composeTraits<traits, \"abstract\">\n>(\n\t...traits: conform<traits, s[\"validated\"]>\n) => TraitConstructor<\n\ts[\"params\"],\n\ts[\"implemented\"],\n\ts[\"statics\"],\n\ts[\"abstractMethods\"],\n\ts[\"abstractProps\"],\n\ts[\"abstractStatics\"]\n>\n\n// even though the value we attach will be identical, we use this so classes\n// won't be treated as instanceof a Trait\nconst implementedTraits = noSuggest(\"implementedTraits\")\n\nexport const hasTrait =\n\t(traitClass: Constructor) =>\n\t(o: unknown): boolean => {\n\t\tif (!hasDomain(o, \"object\")) return false\n\n\t\tif (\n\t\t\timplementedTraits in o.constructor &&\n\t\t\t(o.constructor[implementedTraits] as Function[]).includes(traitClass)\n\t\t)\n\t\t\treturn true\n\n\t\t// emulate standard instanceof behavior\n\t\treturn ancestorsOf(o).includes(traitClass)\n\t}\n\nexport type TraitDeclaration = {\n\tabstractMethods?: object\n\tabstractProps?: object\n\tabstractStatics?: object\n\tdynamicBase?: object\n}\n\n/** @ts-ignore required to extend NoopBase */\nexport abstract class Trait<\n\td extends TraitDeclaration = {},\n\t// we have to enumerate these for TS to understand extending their intersection\n\tabstractMethods extends object = d[\"abstractMethods\"] & {},\n\tabstractProps extends object = d[\"abstractProps\"] & {},\n\tabstractStatics extends object = d[\"abstractStatics\"] & {},\n\tdynamicBase extends object = d[\"dynamicBase\"] & {}\n> extends NoopBase<abstractMethods & abstractProps & dynamicBase> {\n\tdeclare abstractMethods: abstractMethods\n\tdeclare abstractProps: abstractProps\n\tdeclare abstractStatic: abstractStatics\n\n\tstatic get [Symbol.hasInstance](): (o: unknown) => boolean {\n\t\treturn hasTrait(this)\n\t}\n\n\ttraitsOf(): readonly TraitConstructor[] {\n\t\treturn implementedTraits in this.constructor ?\n\t\t\t\t(this.constructor[implementedTraits] as TraitConstructor[])\n\t\t\t:\t[]\n\t}\n}\n\nconst collectPrototypeDescriptors = (trait: TraitConstructor) => {\n\tlet proto = trait.prototype\n\tlet result: PropertyDescriptorMap = {}\n\tdo {\n\t\t// ensure prototypes are sorted from lowest to highest precedence\n\t\tresult = Object.assign(Object.getOwnPropertyDescriptors(proto), result)\n\t\tproto = Object.getPrototypeOf(proto)\n\t} while (proto !== Object.prototype && proto !== null)\n\treturn result\n}\n\nexport const compose: TraitComposition = ((...traits: TraitConstructor[]) => {\n\tconst base: any = function (this: Trait, ...args: any[]) {\n\t\tfor (const trait of traits) {\n\t\t\tconst instance = Reflect.construct(trait, args, this.constructor)\n\t\t\tObject.assign(this, instance)\n\t\t}\n\t}\n\tconst flatImplementedTraits: TraitConstructor[] = []\n\tfor (const trait of traits) {\n\t\t// copy static properties\n\t\tObject.assign(base, trait)\n\t\t// flatten and copy prototype\n\t\tObject.defineProperties(base.prototype, collectPrototypeDescriptors(trait))\n\t\tif (implementedTraits in trait) {\n\t\t\t// add any ancestor traits from which the current trait was composed\n\t\t\tfor (const innerTrait of trait[implementedTraits] as TraitConstructor[]) {\n\t\t\t\tif (!flatImplementedTraits.includes(innerTrait))\n\t\t\t\t\tflatImplementedTraits.push(innerTrait)\n\t\t\t}\n\t\t}\n\t\tif (!flatImplementedTraits.includes(trait))\n\t\t\tflatImplementedTraits.push(trait)\n\t}\n\tObject.defineProperty(base, implementedTraits, {\n\t\tvalue: flatImplementedTraits,\n\t\tenumerable: false\n\t})\n\treturn base as never\n}) as TraitComposition\n\nexport const implement: TraitImplementation = (...args) => {\n\tif (args[args.length - 1] instanceof Trait)\n\t\treturn compose(...(args as any)) as never\n\n\tconst implementation = args[args.length - 1]\n\tconst base = compose(...(args.slice(0, -1) as any))\n\t// copy implementation last since it overrides traits\n\tObject.defineProperties(\n\t\tbase.prototype,\n\t\tObject.getOwnPropertyDescriptors(implementation)\n\t)\n\treturn base as never\n}\n\nexport type TraitConstructor<\n\tparams extends array = any[],\n\tinstance extends object = {},\n\tstatics = {},\n\tabstractMethods extends object = {},\n\tabstractProps extends object = {},\n\tabstractStatics extends object = {}\n> = statics &\n\t(new (...args: params) => Trait<{\n\t\tabstractMethods: abstractMethods\n\t\tabstractProps: abstractProps\n\t\tabstractStatics: abstractStatics\n\t}> &\n\t\tinstance)\n\ntype CompositionState = {\n\tvalidated: array\n\tremaining: array\n\tparams: array\n\tkind: TraitCompositionKind\n\timplemented: object\n\tabstractMethods: object\n\tabstractProps: object\n\tabstractStatics: object\n\tstatics: object\n}\n\nexport type TraitCompositionKind = \"abstract\" | \"implementation\"\n\nexport type composeTraits<\n\ttraits extends array,\n\tkind extends TraitCompositionKind\n> = _compose<{\n\tvalidated: []\n\tremaining: traits\n\tkind: kind\n\tparams: []\n\timplemented: {}\n\tabstractMethods: {}\n\tabstractProps: {}\n\tabstractStatics: {}\n\tstatics: {}\n}>\n\ntype intersectImplementations<l, r> = {\n\t[k in keyof l]: k extends keyof r ?\n\t\tl[k] extends (...args: infer lArgs) => infer lReturn ?\n\t\t\tr[k] extends (...args: infer rArgs) => infer rReturn ?\n\t\t\t\t// ensure function intersections aren't handled as overloads which leads to unsafe behavior\n\t\t\t\t(...args: intersectParameters<lArgs, rArgs>) => lReturn & rReturn\n\t\t\t:\tl[k] & r[k]\n\t\t:\tl[k] & r[k]\n\t:\tl[k]\n} & Omit<r, keyof l>\n\ntype _compose<s extends CompositionState> =\n\ts[\"remaining\"] extends (\n\t\treadonly [\n\t\t\tTraitConstructor<\n\t\t\t\tinfer params,\n\t\t\t\tinfer instance,\n\t\t\t\tinfer statics,\n\t\t\t\tinfer abstractMethods,\n\t\t\t\tinfer abstractProps,\n\t\t\t\tinfer abstractStatics\n\t\t\t>,\n\t\t\t...infer tail\n\t\t]\n\t) ?\n\t\t_compose<{\n\t\t\tvalidated: [...s[\"validated\"], s[\"remaining\"][0]]\n\t\t\tremaining: tail\n\t\t\tkind: s[\"kind\"]\n\t\t\tparams: intersectParameters<s[\"params\"], params>\n\t\t\timplemented: intersectImplementations<\n\t\t\t\ts[\"implemented\"],\n\t\t\t\tOmit<instance, keyof abstractMethods | keyof abstractProps>\n\t\t\t>\n\t\t\tstatics: intersectImplementations<\n\t\t\t\ts[\"statics\"],\n\t\t\t\tOmit<statics, keyof abstractStatics>\n\t\t\t>\n\t\t\tabstractMethods: intersectImplementations<\n\t\t\t\ts[\"abstractMethods\"],\n\t\t\t\tabstractMethods\n\t\t\t>\n\t\t\tabstractProps: intersectImplementations<s[\"abstractProps\"], abstractProps>\n\t\t\tabstractStatics: intersectImplementations<\n\t\t\t\ts[\"abstractStatics\"],\n\t\t\t\tabstractStatics\n\t\t\t>\n\t\t}>\n\t:\tfinalizeState<s>\n\ntype finalizeState<s extends CompositionState> = satisfy<\n\tCompositionState,\n\t{\n\t\tparams: s[\"params\"]\n\t\tvalidated: s[\"validated\"]\n\t\tremaining: s[\"remaining\"]\n\t\tkind: s[\"kind\"]\n\t\timplemented: show<s[\"implemented\"]>\n\t\tstatics: show<Omit<s[\"statics\"], keyof typeof Trait>>\n\t\tabstractMethods: show<Omit<s[\"abstractMethods\"], keyof s[\"implemented\"]>>\n\t\tabstractProps: show<Omit<s[\"abstractProps\"], keyof s[\"implemented\"]>>\n\t\tabstractStatics: show<Omit<s[\"abstractStatics\"], keyof s[\"statics\"]>>\n\t}\n>\n\nexport type implementationOf<s extends CompositionState> =\n\ts[\"abstractMethods\"] &\n\t\t({} extends s[\"abstractProps\"] ? {}\n\t\t:\t{\n\t\t\t\tconstruct: (...args: s[\"params\"]) => s[\"abstractProps\"]\n\t\t\t}) &\n\t\t({} extends s[\"abstractStatics\"] ? {}\n\t\t:\t{\n\t\t\t\tstatics: s[\"abstractStatics\"]\n\t\t\t})\n"
  },
  {
    "path": "ark/util/tsconfig.base.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"module\": \"NodeNext\",\n\t\t\"target\": \"ES2023\",\n\t\t\"moduleResolution\": \"NodeNext\",\n\t\t\"lib\": [\"ESNext\"],\n\t\t\"noEmit\": true,\n\t\t\"skipLibCheck\": true,\n\t\t\"strict\": true,\n\t\t\"noUncheckedSideEffectImports\": true,\n\t\t\"declaration\": true,\n\t\t\"verbatimModuleSyntax\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"resolveJsonModule\": true,\n\t\t\"exactOptionalPropertyTypes\": true,\n\t\t\"forceConsistentCasingInFileNames\": true\n\t}\n}\n"
  },
  {
    "path": "ark/util/unionToTuple.ts",
    "content": "import type { array, join } from \"./arrays.ts\"\nimport type { Fn } from \"./functions.ts\"\nimport type { conform } from \"./generics.ts\"\n\nexport type stringifyUnion<\n\tt extends string,\n\tdelimiter extends string = \", \"\n> = join<unionToTuple<t>, delimiter>\n\nexport type unionToTuple<t> =\n\t_unionToTuple<t, []> extends infer result ? conform<result, t[]> : never\n\ntype _unionToTuple<t, result extends unknown[]> =\n\tgetLastBranch<t> extends infer current ?\n\t\t[t] extends [never] ?\n\t\t\tresult\n\t\t:\t_unionToTuple<Exclude<t, current>, [current, ...result]>\n\t:\tnever\n\ntype getLastBranch<t> =\n\tintersectUnion<t extends unknown ? (x: t) => void : never> extends (\n\t\t(x: infer branch) => void\n\t) ?\n\t\tbranch\n\t:\tnever\n\nexport type intersectUnion<t> =\n\t(t extends unknown ? (_: t) => void : never) extends (\n\t\t(_: infer intersection) => void\n\t) ?\n\t\tintersection\n\t:\tnever\n\nexport type intersectOverloadReturns<fn extends Fn> = intersectUnion<\n\tReturnType<overloadOf<fn>>\n>\n\n// Based on: https://tsplay.dev/WvydBm\nexport type overloadOf<\n\tfn extends Fn,\n\tgivenArgs extends array = array\n> = Exclude<\n\tcollectSignatures<\n\t\t// The \"() => never\" signature must be hoisted to the \"front\" of the\n\t\t// intersection, for two reasons: a) because recursion stops when it is\n\t\t// encountered, and b) it seems to prevent the collapse of subsequent\n\t\t// \"compatible\" signatures (eg. \"() => void\" into \"(a?: 1) => void\"),\n\t\t// which gives a direct conversion to a union.\n\t\t(() => never) & fn,\n\t\tgivenArgs,\n\t\tunknown\n\t>,\n\tfn extends () => never ? never : () => never\n>\n\ntype collectSignatures<fn, givenArgs extends array, result> =\n\tresult & fn extends (...args: infer args) => infer returns ?\n\t\tresult extends fn ?\n\t\t\tnever\n\t\t:\t| collectSignatures<\n\t\t\t\t\tfn,\n\t\t\t\t\tgivenArgs,\n\t\t\t\t\tPick<fn, keyof fn> & result & ((...args: args) => returns)\n\t\t\t  >\n\t\t\t| (args extends givenArgs ? (...args: args) => returns : never)\n\t:\tnever\n"
  },
  {
    "path": "eslint.config.js",
    "content": "// @ts-check\nimport tseslint from \"typescript-eslint\"\n\n/** These actually have types but I'm not sure how to enable esModuleInterop\n * with allowJs in the root tsconfig, which dramatically slows typechecking */\n// @ts-ignore\nimport eslint from \"@eslint/js\"\n// @ts-ignore\nimport importPlugin from \"eslint-plugin-import\"\nimport eslintPluginUnicorn from \"eslint-plugin-unicorn\"\n\n/** These actually don't have types as of now */\n// @ts-ignore\nimport onlyWarn from \"eslint-plugin-only-warn\"\n// @ts-ignore\nimport preferArrowFunctions from \"eslint-plugin-prefer-arrow-functions\"\n\nexport default tseslint.config(\n\t{\n\t\tignores: [\n\t\t\t\"**/dist/**/*\",\n\t\t\t\"**/out/**/*\",\n\t\t\t\"**/node_modules/**/*\",\n\t\t\t\"**/*js\",\n\t\t\t\"**/*.astro\",\n\t\t\t\"**/.next/**/*\",\n\t\t\t\"**/.source/**/*\",\n\t\t\t\"**/*scratch.ts\",\n\t\t\t\"**/scratch/**/*\",\n\t\t\t\"**/examples/**/*\"\n\t\t]\n\t},\n\teslint.configs.recommended,\n\t...tseslint.configs.recommended,\n\t{\n\t\tplugins: {\n\t\t\t\"@typescript-eslint\": tseslint.plugin,\n\t\t\timport: importPlugin,\n\t\t\tunicorn: eslintPluginUnicorn,\n\t\t\t// @ts-ignore\n\t\t\t\"only-warn\": onlyWarn,\n\t\t\t\"prefer-arrow-functions\": preferArrowFunctions\n\t\t},\n\t\tlinterOptions: {\n\t\t\treportUnusedDisableDirectives: \"error\"\n\t\t}\n\t},\n\t{\n\t\trules: {\n\t\t\teqeqeq: \"warn\",\n\t\t\tcurly: [\"warn\", \"multi-or-nest\"],\n\t\t\t\"no-lone-blocks\": \"warn\",\n\t\t\t\"object-shorthand\": \"warn\",\n\t\t\t\"prefer-arrow-functions/prefer-arrow-functions\": [\n\t\t\t\t\"warn\",\n\t\t\t\t{\n\t\t\t\t\tdisallowPrototype: true\n\t\t\t\t}\n\t\t\t],\n\t\t\t\"arrow-body-style\": [\"warn\", \"as-needed\"],\n\t\t\t\"unicorn/better-regex\": \"warn\",\n\t\t\t\"unicorn/expiring-todo-comments\": [\n\t\t\t\t\"warn\",\n\t\t\t\t{ allowWarningComments: false }\n\t\t\t],\n\t\t\t\"unicorn/no-array-for-each\": \"warn\",\n\t\t\t\"unicorn/no-typeof-undefined\": \"warn\",\n\t\t\t\"unicorn/prefer-node-protocol\": \"warn\",\n\t\t\t\"unicorn/prefer-regexp-test\": \"warn\",\n\t\t\t\"unicorn/prefer-ternary\": \"warn\",\n\t\t\t\"@typescript-eslint/no-unused-vars\": [\n\t\t\t\t\"warn\",\n\t\t\t\t{\n\t\t\t\t\targs: \"after-used\",\n\t\t\t\t\targsIgnorePattern: \"^_\",\n\t\t\t\t\t// ignore eslint parsing issue with parser state namespace s\n\t\t\t\t\tvarsIgnorePattern: \"^s$\",\n\t\t\t\t\tignoreRestSiblings: true\n\t\t\t\t}\n\t\t\t],\n\t\t\t\"@typescript-eslint/default-param-last\": \"warn\",\n\t\t\t\"@typescript-eslint/no-empty-interface\": \"off\",\n\t\t\t\"import/no-cycle\": \"warn\",\n\t\t\t// Exporting types and values with the same name is a common pattern in the repo\n\t\t\t\"import/export\": \"off\",\n\t\t\t\"@typescript-eslint/explicit-module-boundary-types\": [\n\t\t\t\t\"warn\",\n\t\t\t\t{\n\t\t\t\t\tallowArgumentsExplicitlyTypedAsAny: true\n\t\t\t\t}\n\t\t\t],\n\t\t\t\"@typescript-eslint/consistent-type-imports\": [\n\t\t\t\t\"warn\",\n\t\t\t\t{\n\t\t\t\t\t// can be useful for cjs/esm interop type imports\n\t\t\t\t\tdisallowTypeAnnotations: false,\n\t\t\t\t\tfixStyle: \"inline-type-imports\"\n\t\t\t\t}\n\t\t\t],\n\t\t\t\"@typescript-eslint/no-import-type-side-effects\": \"warn\",\n\t\t\t\"import/no-duplicates\": [\n\t\t\t\t\"warn\",\n\t\t\t\t{\n\t\t\t\t\t\"prefer-inline\": true\n\t\t\t\t}\n\t\t\t],\n\t\t\t\"no-restricted-imports\": \"off\",\n\t\t\t\"@typescript-eslint/no-restricted-imports\": [\n\t\t\t\t\"warn\",\n\t\t\t\t{\n\t\t\t\t\tpatterns: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tgroup: [\n\t\t\t\t\t\t\t\t\"**/fs/**\",\n\t\t\t\t\t\t\t\t\"**/attest/**\",\n\t\t\t\t\t\t\t\t\"**/schema/**\",\n\t\t\t\t\t\t\t\t\"**/type/**\",\n\t\t\t\t\t\t\t\t\"**/util/**\"\n\t\t\t\t\t\t\t],\n\n\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t\"Use a specifier like '@ark/util' to import from a package\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tgroup: [\"**/index.ts\", \"!**/structure/index.ts\"],\n\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t\"Use a path like '../original/definition.ts' instead of a package entrypoint\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tgroup: [\"arktype/config\"],\n\t\t\t\t\t\t\tmessage: \"Use a relative path to ark/type/config.ts instead\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t],\n\t\t\t\"@typescript-eslint/no-empty-object-type\": \"off\",\n\t\t\t\"@typescript-eslint/no-unsafe-function-type\": \"off\",\n\t\t\t\"@typescript-eslint/no-wrapper-object-types\": \"off\",\n\t\t\t\"@typescript-eslint/ban-types\": \"off\",\n\t\t\t\"@typescript-eslint/no-explicit-any\": \"off\",\n\t\t\t\"@typescript-eslint/no-non-null-assertion\": \"off\",\n\t\t\t\"@typescript-eslint/no-unsafe-declaration-merging\": \"off\",\n\t\t\t\"@typescript-eslint/no-namespace\": [\"warn\", { allowDeclarations: true }],\n\t\t\t\"@typescript-eslint/no-empty-function\": \"off\",\n\t\t\t\"@typescript-eslint/no-this-alias\": \"off\",\n\t\t\t\"no-case-declarations\": \"off\",\n\t\t\t\"@typescript-eslint/ban-ts-comment\": [\n\t\t\t\t\"warn\",\n\t\t\t\t{\n\t\t\t\t\t\"ts-ignore\": \"allow-with-description\"\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\t},\n\t{\n\t\tfiles: [\"**/ark/type/**\", \"**/ark/schema/**\", \"**/ark/util/**\"],\n\t\trules: {\n\t\t\t\"import/no-nodejs-modules\": \"warn\",\n\t\t\t\"import/no-extraneous-dependencies\": \"warn\"\n\t\t}\n\t},\n\t{\n\t\tfiles: [\"**/ark/schema/structure/**\"],\n\t\trules: {\n\t\t\t\"@typescript-eslint/no-restricted-imports\": [\n\t\t\t\t\"warn\",\n\t\t\t\t{\n\t\t\t\t\tpatterns: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tgroup: [\n\t\t\t\t\t\t\t\t\"**/fs/**\",\n\t\t\t\t\t\t\t\t\"**/attest/**\",\n\t\t\t\t\t\t\t\t\"**/schema/**\",\n\t\t\t\t\t\t\t\t\"**/type/**\",\n\t\t\t\t\t\t\t\t\"**/util/**\",\n\t\t\t\t\t\t\t\t\"arktype/internal/**\"\n\t\t\t\t\t\t\t],\n\n\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t\"Use a specifier like '@ark/util' to import from a package\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tgroup: [\"../**/index.ts\"],\n\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t\"Use a path like '../original/definition.ts' instead of a package entrypoint\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\t},\n\t{\n\t\tfiles: [\"**/ark/attest/**\", \"**/ark/fs/**\", \"**/ark/docs/**\"],\n\t\trules: {\n\t\t\t\"import/no-extraneous-dependencies\": \"warn\"\n\t\t}\n\t},\n\t{\n\t\tfiles: [\"**/ark/repo/**\", \"**/ark/docs/**\"],\n\t\trules: {\n\t\t\t\"@typescript-eslint/explicit-module-boundary-types\": \"off\"\n\t\t}\n\t},\n\t{\n\t\tfiles: [\"**/__tests__/**\", \"**/*.bench.ts\", \"**/*.test.ts\"],\n\t\trules: {\n\t\t\t\"@typescript-eslint/ban-ts-comment\": \"off\",\n\t\t\t\"@typescript-eslint/explicit-module-boundary-types\": \"off\",\n\t\t\t\"@typescript-eslint/no-unused-vars\": \"off\",\n\t\t\t\"import/no-extraneous-dependencies\": \"off\",\n\t\t\t\"import/no-nodejs-modules\": \"off\",\n\t\t\t\"@typescript-eslint/no-restricted-imports\": [\n\t\t\t\t\"warn\",\n\t\t\t\t{\n\t\t\t\t\tpatterns: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tgroup: [\"../**\"],\n\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t\"Tests must import from package entrypoints (use /internal if necessary)\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t],\n\t\t\t// function foo is particularly useful for defining a named function inline e.g. to\n\t\t\t// be passed to a morph so it can be uniquely snapshotted\n\t\t\t\"prefer-arrow-functions/prefer-arrow-functions\": \"off\"\n\t\t}\n\t}\n)\n"
  },
  {
    "path": "package.json",
    "content": "{\n\t\"name\": \"ark\",\n\t\"description\": \"TypeScript's 1:1 validator, optimized from editor to runtime\",\n\t\"license\": \"MIT\",\n\t\"funding\": \"https://github.com/sponsors/arktypeio\",\n\t\"author\": {\n\t\t\"name\": \"David Blass\",\n\t\t\"email\": \"david@arktype.io\",\n\t\t\"url\": \"https://arktype.io\"\n\t},\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"https://github.com/arktypeio/arktype.git\"\n\t},\n\t\"type\": \"module\",\n\t\"private\": true,\n\t\"scripts\": {\n\t\t\"test\": \"pnpm testTyped --skipTypes\",\n\t\t\"testTyped\": \"mocha --exclude \\\"ark/attest/**/*.test.*\\\"\",\n\t\t\"prChecks\": \"pnpm lint && pnpm buildRepo && pnpm testRepoWithVersionsAndBenches\",\n\t\t\"attest\": \"ts ./ark/attest/cli/cli.ts\",\n\t\t\"build\": \"pnpm -r --filter !\\\"@ark/docs\\\" build\",\n\t\t\"buildRepo\": \"pnpm rmBuild && pnpm build && pnpm buildDocs\",\n\t\t\"buildDocs\": \"pnpm -r --filter \\\"@ark/docs\\\" build\",\n\t\t\"buildCjs\": \"ARKTYPE_CJS=1 pnpm -r build\",\n\t\t\"rmBuild\": \"pnpm -r exec rm -rf out\",\n\t\t\"ts\": \"node ./ark/repo/ts.js\",\n\t\t\"testRepoWithVersionsAndBenches\": \"pnpm typecheckRepo && pnpm testRepo && pnpm bench && pnpm testTsVersions\",\n\t\t\"typecheckRepo\": \"pnpm tsc\",\n\t\t\"testRepo\": \"pnpm test && pnpm testV8 && pnpm testIntegration && pnpm -r --filter \\\"@ark/attest\\\" test\",\n\t\t\"testIntegration\": \"pnpm -r --filter \\\"arktype\\\" testIntegration\",\n\t\t\"testV8\": \"node --allow-natives-syntax ./ark/repo/testV8.js\",\n\t\t\"testTsVersions\": \"pnpm testTyped --tsconfig null --tsVersions \\\"*\\\" --compilerOptions \\\"{ \\\\\\\"module\\\\\\\": \\\\\\\"NodeNext\\\\\\\", \\\\\\\"moduleResolution\\\\\\\": \\\\\\\"NodeNext\\\\\\\", \\\\\\\"strictNullChecks\\\\\\\": true, \\\\\\\"exactOptionalPropertyTypes\\\\\\\": true }\\\"\",\n\t\t\"bench\": \" ATTEST_benchErrorOnThresholdExceeded=\\\"\\\\\\\"types\\\\\\\"\\\" pnpm benchOperand && pnpm benchOperator && pnpm benchNary && pnpm benchObject && pnpm benchMatch && pnpm benchCyclic\",\n\t\t\"benchUp\": \"ATTEST_updateSnapshots=1 pnpm bench\",\n\t\t\"benchOperand\": \"ts ./ark/type/__tests__/operand.bench.ts\",\n\t\t\"benchOperator\": \"ts ./ark/type/__tests__/operator.bench.ts\",\n\t\t\"benchNary\": \"ts ./ark/type/__tests__/nary.bench.ts\",\n\t\t\"benchObject\": \"ts ./ark/type/__tests__/object.bench.ts\",\n\t\t\"benchMatch\": \"ts ./ark/type/__tests__/match.bench.ts\",\n\t\t\"benchCyclic\": \"ts ./ark/type/__tests__/cyclic.bench.ts\",\n\t\t\"benchRuntime\": \"ts ./ark/type/__tests__/runtime.bench.ts\",\n\t\t\"benchRegex\": \"ts ./ark/regex/__tests__/regex.bench.ts\",\n\t\t\"scratch\": \"ts ./ark/repo/scratch.ts\",\n\t\t\"lint\": \"pnpm checkPrettier && pnpm checkEslint\",\n\t\t\"checkPrettier\": \"prettier --ignore-path .gitignore --ignore-path ./ark/repo/.prettierignore --check .\",\n\t\t\"checkEslint\": \"eslint --max-warnings=0 .\",\n\t\t\"format\": \"prettier --ignore-path .gitignore --ignore-path ./ark/repo/.prettierignore --write .\",\n\t\t\"knip\": \"knip\",\n\t\t\"ci:publish\": \"ts ./ark/repo/publish.ts\",\n\t\t\"publishExtension\": \"cd ark/dark && pnpm publishExtension\",\n\t\t\"upDeps\": \"pnpm up -r --latest\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@ark/attest\": \"link:ark/attest\",\n\t\t\"@ark/attest-ts-min\": \"catalog:\",\n\t\t\"@ark/attest-ts-next\": \"catalog:\",\n\t\t\"@ark/fs\": \"workspace:*\",\n\t\t\"@ark/json-schema\": \"workspace:*\",\n\t\t\"@ark/repo\": \"workspace:*\",\n\t\t\"@ark/util\": \"workspace:*\",\n\t\t\"@eslint/js\": \"9.37.0\",\n\t\t\"@standard-schema/spec\": \"1.0.0\",\n\t\t\"@types/mocha\": \"10.0.10\",\n\t\t\"@types/node\": \"24.7.2\",\n\t\t\"c8\": \"10.1.3\",\n\t\t\"dts-bundle-generator\": \"9.5.1\",\n\t\t\"eslint\": \"9.37.0\",\n\t\t\"eslint-plugin-import\": \"2.32.0\",\n\t\t\"eslint-plugin-only-warn\": \"1.1.0\",\n\t\t\"eslint-plugin-prefer-arrow-functions\": \"3.9.1\",\n\t\t\"eslint-plugin-unicorn\": \"61.0.2\",\n\t\t\"knip\": \"5.65.0\",\n\t\t\"mocha\": \"11.7.4\",\n\t\t\"prettier\": \"3.6.2\",\n\t\t\"tsup\": \"8.5.0\",\n\t\t\"tsx\": \"4.20.6\",\n\t\t\"typescript\": \"catalog:\",\n\t\t\"typescript-eslint\": \"8.46.1\"\n\t},\n\t\"mocha\": {\n\t\t\"//\": \"IF YOU UPDATE THE MOCHA CONFIG HERE, PLEASE ALSO UPDATE ark/repo/mocha.jsonc AND .vscode/settings.json\",\n\t\t\"spec\": [\n\t\t\t\"**/__tests__/**/*.test.*\"\n\t\t],\n\t\t\"ignore\": \"**/node_modules/**/*\",\n\t\t\"node-option\": [\n\t\t\t\"conditions=ark-ts\",\n\t\t\t\"import=tsx\"\n\t\t],\n\t\t\"require\": \"./ark/repo/mocha.globalSetup.ts\",\n\t\t\"timeout\": 10000\n\t},\n\t\"c8\": {\n\t\t\"checkCoverage\": true,\n\t\t\"lines\": 96,\n\t\t\"src\": \"./src\",\n\t\t\"exclude\": [\n\t\t\t\"__tests__/**\"\n\t\t],\n\t\t\"extension\": \".ts\",\n\t\t\"reporter\": \"lcovonly\"\n\t},\n\t\"prettier\": {\n\t\t\"useTabs\": true,\n\t\t\"semi\": false,\n\t\t\"trailingComma\": \"none\",\n\t\t\"experimentalTernaries\": true,\n\t\t\"arrowParens\": \"avoid\"\n\t},\n\t\"engines\": {\n\t\t\"node\": \">=18\",\n\t\t\"pnpm\": \">=10\"\n\t},\n\t\"packageManager\": \"pnpm@10.19.0\",\n\t\"pnpm\": {\n\t\t\"overrides\": {\n\t\t\t\"@ark/attest\": \"link:ark/attest\"\n\t\t},\n\t\t\"peerDependencyRules\": {\n\t\t\t\"allowedVersions\": {\n\t\t\t\t\"typescript\": \"*\",\n\t\t\t\t\"eslint\": \"*\"\n\t\t\t}\n\t\t},\n\t\t\"ignoredBuiltDependencies\": [\n\t\t\t\"sharp\"\n\t\t]\n\t}\n}\n"
  },
  {
    "path": "pnpm-workspace.yaml",
    "content": "packages:\n  - \"ark/*\"\n\ncatalog:\n  typescript: 5.9.3\n  \"@ark/attest-ts-min\": npm:typescript@5.1.6\n  \"@ark/attest-ts-next\": npm:typescript@next\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n\t\"extends\": \"./ark/util/tsconfig.base.json\",\n\t\"compilerOptions\": {\n\t\t\"allowImportingTsExtensions\": true,\n\t\t\"rewriteRelativeImportExtensions\": true,\n\t\t\"customConditions\": [\"ark-ts\"],\n\t\t\"types\": [\"mocha\", \"node\"],\n\t\t// avoid prototype methods that are not available and cannot easily be transpiled\n\t\t\"lib\": [\"ES2020\"]\n\t\t// \"noErrorTruncation\": true\n\t\t// disabling until compatible with tsgo\n\t\t// \"erasableSyntaxOnly\": true\n\t},\n\t\"exclude\": [\"**/out\", \"**/node_modules\", \"./ark/docs\", \"**/*.scratch.ts\"]\n}\n"
  }
]