{"version":3,"file":"swim-codec.mjs","sources":["../main/source/Tag.ts","../main/source/Mark.ts","../main/source/Span.ts","../main/format/OutputStyle.ts","../main/output/OutputSettings.ts","../main/input/InputException.ts","../main/input/InputSettings.ts","../main/input/Input.ts","../main/input/InputError.ts","../main/unicode/StringInput.ts","../main/output/OutputException.ts","../main/output/Output.ts","../main/unicode/StringOutput.ts","../main/writer/WriterException.ts","../main/writer/Writer.ts","../main/unicode/StringWriter.ts","../main/unicode/Unicode.ts","../main/format/Format.ts","../main/number/Base10.ts","../main/source/Diagnostic.ts","../main/input/InputEmpty.ts","../main/input/InputDone.ts","../main/input/InputBuffer.ts","../main/input/InputBufferEmpty.ts","../main/input/InputBufferDone.ts","../main/input/InputBufferError.ts","../main/output/OutputFull.ts","../main/output/OutputDone.ts","../main/output/OutputError.ts","../main/output/OutputBuffer.ts","../main/output/OutputBufferFull.ts","../main/output/OutputBufferDone.ts","../main/output/OutputBufferError.ts","../main/parser/ParserException.ts","../main/parser/Parser.ts","../main/parser/ParserDone.ts","../main/parser/ParserError.ts","../main/writer/WriterEnd.ts","../main/writer/WriterDone.ts","../main/writer/WriterError.ts","../main/writer/WriterSequence.ts","../main/binary/ByteOutput.ts","../main/binary/ByteOutputUint8Array.ts","../main/binary/ByteOutputBuffer.ts","../main/binary/Binary.ts","../main/unicode/UtfErrorMode.ts","../main/unicode/UtfErrorModeFatal.ts","../main/unicode/UtfErrorModeReplacement.ts","../main/number/Base16.ts","../main/unicode/Utf8DecodedOutput.ts","../main/unicode/Utf8EncodedOutput.ts","../main/unicode/Utf8.ts","../main/number/Base10NumberParser.ts","../main/number/Base10IntegerWriter.ts","../main/number/Base16Parser.ts","../main/number/Base16Writer.ts","../main/number/Base16IntegerWriter.ts","../main/number/Base64.ts","../main/number/Base64Parser.ts","../main/number/Base64Writer.ts"],"sourcesContent":["// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {HashCode} from \"@swim/util\";\nimport type {Mark} from \"./Mark\";\nimport type {Output} from \"../output/Output\";\nimport type {Display} from \"../format/Display\";\nimport type {Debug} from \"../format/Debug\";\n\n/**\n * Description of a source location. Tags are used to annotate input sources,\n * particularly for [[Diagnostic diagnostic]] purposes. A [[Mark]] tag\n * annotates a source position. A [[Span]] tag annotate a source range.\n *\n * @see [[Diagnostic]]\n * @public\n */\nexport abstract class Tag implements HashCode, Display, Debug {\n  /**\n   * The first source position covered by this `Tag`.\n   */\n  abstract readonly start: Mark;\n\n  /**\n   * The last source position covered by this `Tag`.\n   */\n  abstract readonly end: Mark;\n\n  /**\n   * Returns a `Tag` that includes all source locations covered by\n   * both this tag, and `that` tag.\n   */\n  abstract union(that: Tag): Tag;\n\n  /**\n   * Returns the position of this `Tag` relative to the given `mark`.\n   */\n  abstract shift(mark: Mark): Tag;\n\n  abstract display<T>(output: Output<T>): Output<T>;\n\n  abstract debug<T>(output: Output<T>): Output<T>;\n\n  abstract equals(that: unknown): boolean;\n\n  abstract hashCode(): number;\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {Lazy} from \"@swim/util\";\nimport {Murmur3} from \"@swim/util\";\nimport {Numbers} from \"@swim/util\";\nimport {Strings} from \"@swim/util\";\nimport {Constructors} from \"@swim/util\";\nimport {Tag} from \"./Tag\";\nimport {Span} from \"../\"; // forward import\nimport type {Output} from \"../output/Output\";\nimport {Format} from \"../\"; // forward import\n\n/**\n * Description of a source position, identified by byte offset, line, and\n * column number, with an optional note.\n * @public\n */\nexport class Mark extends Tag {\n  /** @internal */\n  constructor(offset: number, line: number, column: number, note: string | undefined) {\n    super();\n    this.offset = offset;\n    this.line = line;\n    this.column = column;\n    this.note = note;\n  }\n\n  /**\n   * The zero-based byte offset of this position.\n   */\n  readonly offset: number;\n\n  /**\n   * The one-based line number of this position.\n   */\n  readonly line: number;\n\n  /**\n   * The one-based column number of this position.\n   */\n  readonly column: number;\n\n  /**\n   * The note attached to the marked position, or `null` if this position has\n   * no attached note.\n   */\n  readonly note: string | undefined;\n\n  withNote(note: string | undefined): Mark {\n    if (this.note !== note) {\n      return Mark.at(this.offset, this.line, this.column, note);\n    } else {\n      return this;\n    }\n  }\n\n  /**\n   * Returns this position, if its byte offset is less than or equal to\n   * `that` position; otherwise returns `that` position.\n   */\n  min(that: Mark): Mark {\n    return this.offset <= that.offset ? this : that;\n  }\n\n  /**\n   * Returns this position, if its byte offset is greater than or equal to\n   * `that` position; otherwise returns `that` position.\n   */\n  max(that: Mark): Mark {\n    return this.offset >= that.offset ? this : that;\n  }\n\n  override get start(): Mark {\n    return this;\n  }\n\n  override get end(): Mark {\n    return this;\n  }\n\n  override union(that: Tag): Tag {\n    if (that instanceof Mark) {\n      if (this.offset === that.offset && this.line === that.line\n          && this.column === that.column) {\n        return this;\n      } else {\n        return Span.from(this, that);\n      }\n    } else if (that instanceof Span) {\n      const start = this.min(that.start);\n      const end = this.max(that.end);\n      if (start === that.start && end === that.end) {\n        return that;\n      } else {\n        return Span.from(start, end);\n      }\n    }\n    throw new Error(that.toString());\n  }\n\n  override shift(mark: Mark): Mark {\n    const offset = this.offset + (this.offset - mark.offset);\n    const line = this.line + (this.line - mark.line);\n    let column = this.column;\n    if (line === 1) {\n      column += (this.column - mark.column);\n    }\n    if (offset === this.offset && line === this.line && column === this.column) {\n      return this;\n    } else {\n      return Mark.at(offset, line, column, this.note);\n    }\n  }\n\n  override equals(that: unknown): boolean {\n    if (this === that) {\n      return true;\n    } else if (that instanceof Mark) {\n      return this.offset === that.offset && this.line === that.line\n          && this.column === that.column && this.note === that.note;\n    }\n    return false;\n  }\n\n  override hashCode(): number {\n    return Murmur3.mash(Murmur3.mix(Murmur3.mix(Murmur3.mix(Murmur3.mix(Constructors.hash(Mark),\n        Numbers.hash(this.offset)), Numbers.hash(this.line)), Numbers.hash(this.column)),\n        Strings.hash(this.note)));\n  }\n\n  override display<T>(output: Output<T>): Output<T> {\n    output = Format.displayNumber(output, this.line);\n    output = output.write(58/*':'*/);\n    output = Format.displayNumber(output, this.column);\n    if (this.note !== void 0) {\n      output = output.write(58/*':'*/).write(32/*' '*/).write(this.note);\n    }\n    return output;\n  }\n\n  override debug<T>(output: Output<T>): Output<T> {\n    output = output.write(\"Mark\").write(\".\").write(\"at\").write(\"(\");\n    output = Format.debugNumber(output, this.offset);\n    output = output.write(\", \");\n    output = Format.debugNumber(output, this.line);\n    output = output.write(\", \");\n    output = Format.debugNumber(output, this.column);\n    if (this.note !== void 0) {\n      output = output.write(\", \");\n      output = Format.debugString(output, this.note);\n    }\n    output = output.write(\")\");\n    return output;\n  }\n\n  override toString(): string {\n    return Format.display(this);\n  }\n\n  /**\n   * Returns a `Mark` at byte offset `0`, line `1`, and column `1`, with no\n   * attached note.\n   */\n  @Lazy\n  static get zero(): Mark {\n    return new Mark(0, 1, 1, void 0);\n  }\n\n  /**\n   * Returns a new `Mark` at the given zero-based byte `offset`, one-based\n   * `line` number, and one-based `column` number, with an optionally attached\n   * `note`.\n   */\n  static at(offset: number, line: number, column: number, note?: string | undefined): Mark {\n    return new Mark(offset, line, column, note);\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {Murmur3} from \"@swim/util\";\nimport {Constructors} from \"@swim/util\";\nimport {Tag} from \"./Tag\";\nimport {Mark} from \"./Mark\";\nimport type {Output} from \"../output/Output\";\nimport {Format} from \"../\"; // forward import\n\n/**\n * Description of a source range, identified by a closed interval between start\n * and end [[Mark marks]].\n * @public\n */\nexport class Span extends Tag {\n  /** @internal */\n  constructor(start: Mark, end: Mark) {\n    super();\n    this.start = start;\n    this.end = end;\n  }\n\n  override readonly start: Mark;\n\n  override readonly end: Mark;\n\n  override union(that: Tag): Tag {\n    if (that instanceof Mark) {\n      const start = this.start.min(that);\n      const end = this.end.max(that);\n      if (start === this.start && end === this.end) {\n        return this;\n      } else {\n        return Span.from(start, end);\n      }\n    } else if (that instanceof Span) {\n      const start = this.start.min(that.start);\n      const end = this.end.max(that.end);\n      if (start === this.start && end === this.end) {\n        return this;\n      } else {\n        return Span.from(start, end);\n      }\n    }\n    throw new Error(that.toString());\n  }\n\n  override shift(mark: Mark): Span {\n    const start = this.start.shift(mark);\n    const end = this.end.shift(mark);\n    if (start === this.start && end === this.end) {\n      return this;\n    } else {\n      return Span.from(start, end);\n    }\n  }\n\n  override equals(that: unknown): boolean {\n    if (this === that) {\n      return true;\n    } else if (that instanceof Span) {\n      return this.start.equals(that.start) && this.end.equals(that.end);\n    }\n    return false;\n  }\n\n  override hashCode(): number {\n    return Murmur3.mash(Murmur3.mix(Murmur3.mix(Constructors.hash(Span),\n        this.start.hashCode()), this.end.hashCode()));\n  }\n\n  override display<T>(output: Output<T>): Output<T> {\n    if (this.start.note !== void 0) {\n      output = output.write(this.start.note).write(58/*':'*/).write(32/*' '*/);\n    }\n    output = Format.displayNumber(output, this.start.line);\n    output = output.write(58/*':'*/);\n    output = Format.displayNumber(output, this.start.column);\n    output = output.write(45/*'-'*/);\n    output = Format.displayNumber(output, this.end.line);\n    output = output.write(58/*':'*/);\n    output = Format.displayNumber(output, this.end.column);\n    if (this.end.note !== void 0) {\n      output = output.write(58/*':'*/).write(32/*' '*/).write(this.end.note);\n    }\n    return output;\n  }\n\n  override debug<T>(output: Output<T>): Output<T> {\n    output = output.write(\"Span\").write(\".\").write(\"from\").write(\"(\");\n    output = this.start.debug(output);\n    output = output.write(\", \");\n    output = this.end.debug(output);\n    output = output.write(\")\");\n    return output;\n  }\n\n  override toString(): string {\n    return Format.display(this);\n  }\n\n  /**\n   * Returns a new `Span` representing the closed interval between the given\n   * `start` and `end` marks.\n   */\n  static from(start: Mark, end: Mark): Span {\n    if (start.offset > end.offset) {\n      const tmp = start;\n      start = end;\n      end = tmp;\n    }\n    return new Span(start, end);\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {Output} from \"../output/Output\";\n\n/**\n * Stylized text output utility functions.\n * @public\n */\nexport const OutputStyle = (function () {\n  const OutputStyle = {} as {\n    /**\n     * Writes the ASCII reset escape code to `output`,\n     * if [[OutputSettings.isStyled `output.settings.isStyled()`]] is `true`.\n     *\n     * @returns the continuation of the `output`.\n     */\n    reset<T>(output: Output<T>): Output<T>\n\n    /**\n     * Writes the ASCII bold (increased intensity) escape code to `output`,\n     * if [[OutputSettings.isStyled `output.settings.isStyled()`]] is `true`.\n     *\n     * @returns the continuation of the `output`.\n     */\n    bold<T>(output: Output<T>): Output<T>;\n\n    /**\n     * Writes the ASCII faint (decreased intensity) escape code to `output`,\n     * if [[OutputSettings.isStyled `output.settings.isStyled()`]] is `true`.\n     *\n     * @returns the continuation of the `output`.\n     */\n    faint<T>(output: Output<T>): Output<T>;\n\n    /**\n     * Writes the ASCII black foreground color escape code to `output`,\n     * if [[OutputSettings.isStyled `output.settings.isStyled()`]] is `true`.\n     *\n     * @returns the continuation of the `output`.\n     */\n    black<T>(output: Output<T>): Output<T>;\n\n    /**\n     * Writes the ASCII red foreground color escape code to `output`,\n     * if [[OutputSettings.isStyled `output.settings.isStyled()`]] is `true`.\n     *\n     * @returns the continuation of the `output`.\n     */\n    red<T>(output: Output<T>): Output<T>;\n\n    /**\n     * Writes the ASCII green foreground color escape code to `output`,\n     * if [[OutputSettings.isStyled `output.settings.isStyled()`]] is `true`.\n     *\n     * @returns the continuation of the `output`.\n     */\n    green<T>(output: Output<T>): Output<T>;\n\n    /**\n     * Writes the ASCII yellow foreground color escape code to `output`,\n     * if [[OutputSettings.isStyled `output.settings.isStyled()`]] is `true`.\n     *\n     * @returns the continuation of the `output`.\n     */\n    yellow<T>(output: Output<T>): Output<T>;\n\n    /**\n     * Writes the ASCII blue foreground color escape code to `output`,\n     * if [[OutputSettings.isStyled `output.settings.isStyled()`]] is `true`.\n     *\n     * @returns the continuation of the `output`.\n     */\n    blue<T>(output: Output<T>): Output<T>;\n\n    /**\n     * Writes the ASCII magenta foreground color escape code to `output`,\n     * if [[OutputSettings.isStyled `output.settings.isStyled()`]] is `true`.\n     *\n     * @returns the continuation of the `output`.\n     */\n    magenta<T>(output: Output<T>): Output<T>;\n\n    /**\n     * Writes the ASCII cyan foreground color escape code to `output`,\n     * if [[OutputSettings.isStyled `output.settings.isStyled()`]] is `true`.\n     *\n     * @returns the continuation of the `output`.\n     */\n    cyan<T>(output: Output<T>): Output<T>;\n\n    /**\n     * Writes the ASCII gray foreground color escape code to `output`,\n     * if [[OutputSettings.isStyled `output.settings.isStyled()`]] is `true`.\n     *\n     * @returns the continuation of the `output`.\n     */\n    gray<T>(output: Output<T>): Output<T>;\n\n    /**\n     * Writes the ASCII bold black foreground color escape code to `output`,\n     * if [[OutputSettings.isStyled `output.settings.isStyled()`]] is `true`.\n     *\n     * @returns the continuation of the `output`.\n     */\n    blackBold<T>(output: Output<T>): Output<T>;\n\n    /**\n     * Writes the ASCII bold red foreground color escape code to `output`,\n     * if [[OutputSettings.isStyled `output.settings.isStyled()`]] is `true`.\n     *\n     * @returns the continuation of the `output`.\n     */\n    redBold<T>(output: Output<T>): Output<T>;\n\n    /**\n     * Writes the ASCII bold green foreground color escape code to `output`,\n     * if [[OutputSettings.isStyled `output.settings.isStyled()`]] is `true`.\n     *\n     * @returns the continuation of the `output`.\n     */\n    greenBold<T>(output: Output<T>): Output<T>;\n\n    /**\n     * Writes the ASCII bold yellow foreground color escape code to `output`,\n     * if [[OutputSettings.isStyled `output.settings.isStyled()`]] is `true`.\n     *\n     * @returns the continuation of the `output`.\n     */\n    yellowBold<T>(output: Output<T>): Output<T>;\n\n    /**\n     * Writes the ASCII bold blue foreground color escape code to `output`,\n     * if [[OutputSettings.isStyled `output.settings.isStyled()`]] is `true`.\n     *\n     * @returns the continuation of the `output`.\n     */\n    blueBold<T>(output: Output<T>): Output<T>;\n\n    /**\n     * Writes the ASCII bold magenta foreground color escape code to `output`,\n     * if [[OutputSettings.isStyled `output.settings.isStyled()`]] is `true`.\n     *\n     * @returns the continuation of the `output`.\n     */\n    magentaBold<T>(output: Output<T>): Output<T>;\n\n    /**\n     * Writes the ASCII bold cyan foreground color escape code to `output`,\n     * if [[OutputSettings.isStyled `output.settings.isStyled()`]] is `true`.\n     *\n     * @returns the continuation of the `output`.\n     */\n    cyanBold<T>(output: Output<T>): Output<T>;\n\n    /**\n     * Writes the ASCII bold gray foreground color escape code to `output`,\n     * if [[OutputSettings.isStyled `output.settings.isStyled()`]] is `true`.\n     *\n     * @returns the continuation of the `output`.\n     */\n    grayBold<T>(output: Output<T>): Output<T>;\n  };\n\n  OutputStyle.reset = function <T>(output: Output<T>): Output<T> {\n    if (output.settings.isStyled()) {\n      output = output.write(27).write(91/*'['*/).write(48/*'0'*/).write(109/*'m'*/);\n    }\n    return output;\n  };\n\n  OutputStyle.bold = function <T>(output: Output<T>): Output<T> {\n    if (output.settings.isStyled()) {\n      output = output.write(27).write(91/*'['*/).write(49/*'1'*/).write(109/*'m'*/);\n    }\n    return output;\n  };\n\n  OutputStyle.faint = function <T>(output: Output<T>): Output<T> {\n    if (output.settings.isStyled()) {\n      output = output.write(27).write(91/*'['*/).write(50/*'2'*/).write(109/*'m'*/);\n    }\n    return output;\n  };\n\n  OutputStyle.black = function <T>(output: Output<T>): Output<T> {\n    if (output.settings.isStyled()) {\n      output = output.write(27).write(91/*'['*/).write(48/*'0'*/).write(59/*';'*/)\n                     .write(51/*'3'*/).write(48/*'0'*/).write(109/*'m'*/);\n    }\n    return output;\n  };\n\n  OutputStyle.red = function <T>(output: Output<T>): Output<T> {\n    if (output.settings.isStyled()) {\n      output = output.write(27).write(91/*'['*/).write(48/*'0'*/).write(59/*';'*/)\n                     .write(51/*'3'*/).write(49/*'1'*/).write(109/*'m'*/);\n    }\n    return output;\n  };\n\n  OutputStyle.green = function <T>(output: Output<T>): Output<T> {\n    if (output.settings.isStyled()) {\n      output = output.write(27).write(91/*'['*/).write(48/*'0'*/).write(59/*';'*/)\n                     .write(51/*'3'*/).write(50/*'2'*/).write(109/*'m'*/);\n    }\n    return output;\n  };\n\n  OutputStyle.yellow = function <T>(output: Output<T>): Output<T> {\n    if (output.settings.isStyled()) {\n      output = output.write(27).write(91/*'['*/).write(48/*'0'*/).write(59/*';'*/)\n                     .write(51/*'3'*/).write(51/*'3'*/).write(109/*'m'*/);\n    }\n    return output;\n  };\n\n  OutputStyle.blue = function <T>(output: Output<T>): Output<T> {\n    if (output.settings.isStyled()) {\n      output = output.write(27).write(91/*'['*/).write(48/*'0'*/).write(59/*';'*/)\n                     .write(51/*'3'*/).write(52/*'4'*/).write(109/*'m'*/);\n    }\n    return output;\n  };\n\n  OutputStyle.magenta = function <T>(output: Output<T>): Output<T> {\n    if (output.settings.isStyled()) {\n      output = output.write(27).write(91/*'['*/).write(48/*'0'*/).write(59/*';'*/)\n                     .write(51/*'3'*/).write(53/*'5'*/).write(109/*'m'*/);\n    }\n    return output;\n  };\n\n  OutputStyle.cyan = function <T>(output: Output<T>): Output<T> {\n    if (output.settings.isStyled()) {\n      output = output.write(27).write(91/*'['*/).write(48/*'0'*/).write(59/*';'*/)\n                     .write(51/*'3'*/).write(54/*'6'*/).write(109/*'m'*/);\n    }\n    return output;\n  };\n\n  OutputStyle.gray = function <T>(output: Output<T>): Output<T> {\n    if (output.settings.isStyled()) {\n      output = output.write(27).write(91/*'['*/).write(48/*'0'*/).write(59/*';'*/)\n                     .write(51/*'3'*/).write(55/*'7'*/).write(109/*'m'*/);\n    }\n    return output;\n  };\n\n  OutputStyle.blackBold = function <T>(output: Output<T>): Output<T> {\n    if (output.settings.isStyled()) {\n      output = output.write(27).write(91/*'['*/).write(49/*'1'*/).write(59/*';'*/)\n                     .write(51/*'3'*/).write(48/*'0'*/).write(109/*'m'*/);\n    }\n    return output;\n  };\n\n  OutputStyle.redBold = function <T>(output: Output<T>): Output<T> {\n    if (output.settings.isStyled()) {\n      output = output.write(27).write(91/*'['*/).write(49/*'1'*/).write(59/*';'*/)\n                     .write(51/*'3'*/).write(49/*'1'*/).write(109/*'m'*/);\n    }\n    return output;\n  };\n\n  OutputStyle.greenBold = function <T>(output: Output<T>): Output<T> {\n    if (output.settings.isStyled()) {\n      output = output.write(27).write(91/*'['*/).write(49/*'1'*/).write(59/*';'*/)\n                     .write(51/*'3'*/).write(50/*'2'*/).write(109/*'m'*/);\n    }\n    return output;\n  };\n\n  OutputStyle.yellowBold = function <T>(output: Output<T>): Output<T> {\n    if (output.settings.isStyled()) {\n      output = output.write(27).write(91/*'['*/).write(49/*'1'*/).write(59/*';'*/)\n                     .write(51/*'3'*/).write(51/*'3'*/).write(109/*'m'*/);\n    }\n    return output;\n  };\n\n  OutputStyle.blueBold = function <T>(output: Output<T>): Output<T> {\n    if (output.settings.isStyled()) {\n      output = output.write(27).write(91/*'['*/).write(49/*'1'*/).write(59/*';'*/)\n                     .write(51/*'3'*/).write(52/*'4'*/).write(109/*'m'*/);\n    }\n    return output;\n  };\n\n  OutputStyle.magentaBold = function <T>(output: Output<T>): Output<T> {\n    if (output.settings.isStyled()) {\n      output = output.write(27).write(91/*'['*/).write(49/*'1'*/).write(59/*';'*/)\n                     .write(51/*'3'*/).write(53/*'5'*/).write(109/*'m'*/);\n    }\n    return output;\n  };\n\n  OutputStyle.cyanBold = function <T>(output: Output<T>): Output<T> {\n    if (output.settings.isStyled()) {\n      output = output.write(27).write(91/*'['*/).write(49/*'1'*/).write(59/*';'*/)\n                     .write(51/*'3'*/).write(54/*'6'*/).write(109/*'m'*/);\n    }\n    return output;\n  };\n\n  OutputStyle.grayBold = function <T>(output: Output<T>): Output<T> {\n    if (output.settings.isStyled()) {\n      output = output.write(27).write(91/*'['*/).write(49/*'1'*/).write(59/*';'*/)\n                     .write(51/*'3'*/).write(55/*'7'*/).write(109/*'m'*/);\n    }\n    return output;\n  };\n\n  return OutputStyle;\n})();\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {Lazy} from \"@swim/util\";\nimport {Murmur3} from \"@swim/util\";\nimport type {HashCode} from \"@swim/util\";\nimport {Booleans} from \"@swim/util\";\nimport {Numbers} from \"@swim/util\";\nimport {Strings} from \"@swim/util\";\nimport {Constructors} from \"@swim/util\";\nimport type {Output} from \"../output/Output\";\nimport type {Debug} from \"../format/Debug\";\nimport {Format} from \"../format/Format\";\n\n/**\n * Either an [[OutputSettings]] instance, or an [[OutputSettingsInit]] object\n * initializer.\n * @public\n */\nexport type OutputSettingsLike = OutputSettings | OutputSettingsInit;\n\n/**\n * [[OutputSettings]] object initializer.\n * @public\n */\nexport interface OutputSettingsInit {\n  lineSeparator?: string;\n  isPretty?: boolean;\n  isStyled?: boolean;\n  precision?: number;\n}\n\n/**\n * [[Output]] production parameters. `OutputSettings` provide contextual\n * configuration parameters to output producers, such as [[Writer Writers]].\n * Uses include enabling pretty printing and styling generated output.\n * Subclasses can provide additional parameters understood by specialized\n * output producers.\n * @public\n */\nexport class OutputSettings implements Debug, HashCode {\n  protected constructor(lineSeparator: string, pretty: boolean,\n                        styled: boolean, precision: number) {\n    Object.defineProperty(this, \"lineSeparator\", {\n      value: lineSeparator,\n      enumerable: true,\n    });\n    Object.defineProperty(this, \"pretty\", {\n      value: pretty,\n      enumerable: true,\n    });\n    Object.defineProperty(this, \"styled\", {\n      value: styled,\n      enumerable: true,\n    });\n    Object.defineProperty(this, \"precision\", {\n      value: precision,\n      enumerable: true,\n    });\n  }\n\n  /**\n   * The Unicode code point sequence used to separate lines of text.\n   * Defaults to the runtime operating system's line separator.\n   */\n  readonly lineSeparator!: string;\n\n  /**\n   * Returns a copy of these settings with the given `lineSeparator`.\n   */\n  withLineSeparator(lineSeparator: string | undefined): string | OutputSettings {\n    return this.copy(lineSeparator, this.pretty, this.styled, this.precision);\n  }\n\n  /** @internal */\n  readonly pretty!: boolean;\n\n  /**\n   * Returns `true` if output producers should pretty print their output,\n   * when possible.\n   */\n  isPretty(): boolean {\n    return this.pretty;\n  }\n\n  /**\n   * Returns a copy of these settings with the given `pretty` flag.\n   */\n  asPretty(pretty: boolean): OutputSettings {\n    return this.copy(this.lineSeparator, pretty, this.styled, this.precision);\n  }\n\n  /** @internal */\n  readonly styled!: boolean;\n\n  /**\n   * Returns `true` if output producers should style their output,\n   * when possible.\n   */\n  isStyled(): boolean {\n    return this.styled;\n  }\n\n  /**\n   * Returns a copy of these settings with the given `styled` flag.\n   */\n  asStyled(styled: boolean): OutputSettings {\n    return this.copy(this.lineSeparator, this.pretty, styled, this.precision);\n  }\n\n  /**\n   * Returns the numeric precision output producers should use\n   * when formatting numbers.\n   */\n  readonly precision!: number;\n\n  /**\n   * Returns a copy of these settings with the given numeric `precision`.\n   */\n  withPrecision(precision: number): OutputSettings {\n    return this.copy(this.lineSeparator, this.pretty, this.styled, precision);\n  }\n\n  protected copy(lineSeparator: string | undefined, pretty: boolean,\n                 styled: boolean, precision: number): OutputSettings {\n    return OutputSettings.create(lineSeparator, pretty, styled, precision);\n  }\n\n  protected canEqual(that: unknown): boolean {\n    return that instanceof OutputSettings;\n  }\n\n  equals(that: unknown): boolean {\n    if (this === that) {\n      return true;\n    } else if (that instanceof OutputSettings) {\n      return that.canEqual(this) && this.lineSeparator === that.lineSeparator\n          && this.pretty === that.pretty && this.styled === that.styled\n          && this.precision === that.precision;\n    }\n    return false;\n  }\n\n  hashCode(): number {\n    return Murmur3.mash(Murmur3.mix(Murmur3.mix(Murmur3.mix(Murmur3.mix(\n        Constructors.hash(OutputSettings), Strings.hash(this.lineSeparator)),\n        Booleans.hash(this.pretty)), Booleans.hash(this.styled)),\n        Numbers.hash(this.precision)));\n  }\n\n  debug<T>(output: Output<T>): Output<T> {\n    output = output.write(\"OutputSettings\").write(46/*'.'*/);\n    if (!this.pretty && !this.styled) {\n      output = output.write(\"standard\");\n    } else if (this.pretty && !this.styled) {\n      output = output.write(\"pretty\");\n    } else if (!this.pretty && this.styled) {\n      output = output.write(\"styled\");\n    } else {\n      output = output.write(\"prettyStyled\");\n    }\n    output = output.write(40/*'('*/).write(41/*')'*/);\n    if (this.lineSeparator !== Format.lineSeparator) {\n      output = output.write(46/*'.'*/).write(\"lineSeparator\").write(40/*'('*/)\n                     .display(this.lineSeparator).write(41/*')'*/);\n    }\n    if (this.precision !== -1) {\n      output = output.write(46/*'.'*/).write(\"precision\").write(40/*'('*/)\n                     .display(this.precision).write(41/*')'*/);\n    }\n    return output;\n  }\n\n  toString(): string {\n    return Format.debug(this);\n  }\n\n  /**\n   * Returns `OutputSettings` configured with the system line separator,\n   * pretty printing disabled, and styling disabled.\n   */\n  @Lazy\n  static standard(): OutputSettings {\n    return new OutputSettings(Format.lineSeparator, false, false, -1);\n  }\n\n  /**\n   * Returns `OutputSettings` configured with the system line separator,\n   * pretty printing enabled, and styling disabled.\n   */\n  @Lazy\n  static pretty(): OutputSettings {\n    return new OutputSettings(Format.lineSeparator, true, false, -1);\n  }\n\n  /**\n   * Returns `OutputSettings` configured with the system line separator,\n   * pretty printing disabled, and styling enabled.\n   */\n  @Lazy\n  static styled(): OutputSettings {\n    return new OutputSettings(Format.lineSeparator, false, true, -1);\n  }\n\n  /**\n   * Returns `OutputSettings` configured with the system line separator,\n   * pretty printing enabled, and styling enabled.\n   */\n  @Lazy\n  static prettyStyled(): OutputSettings {\n    return new OutputSettings(Format.lineSeparator, true, true, -1);\n  }\n\n  /**\n   * Returns `OutputSettings` configured with the given `lineSeparator`, pretty\n   * printing enabled if `isPretty` is `true`, styling enabled if `isStyled`\n   * is `true`, and with the given numeric `precision`.\n   */\n  static create(lineSeparator?: string, pretty?: boolean,\n                styled?: boolean, precision?: number): OutputSettings {\n    if (typeof lineSeparator !== \"string\") {\n      lineSeparator = Format.lineSeparator;\n    }\n    if (typeof pretty !== \"boolean\") {\n      pretty = false;\n    }\n    if (typeof styled !== \"boolean\") {\n      styled = false;\n    }\n    if (typeof precision !== \"number\") {\n      precision = -1;\n    }\n    if (lineSeparator === Format.lineSeparator && precision === -1) {\n      if (!pretty && !styled) {\n        return OutputSettings.standard();\n      } else if (pretty && !styled) {\n        return OutputSettings.pretty();\n      } else if (!pretty && styled) {\n        return OutputSettings.styled();\n      } else {\n        return OutputSettings.prettyStyled();\n      }\n    }\n    return new OutputSettings(lineSeparator, pretty, styled, precision);\n  }\n\n  /**\n   * Converts a settings `init` object to an instance of `OutputSettings`.\n   */\n  static fromInit(init: OutputSettingsInit): OutputSettings {\n    return OutputSettings.create(init.lineSeparator, init.isPretty,\n                                 init.isStyled, init.precision);\n  }\n\n  /**\n   * Converts a loosely typed settings `value` to an instance of `OutputSettings`.\n   */\n  static fromLike(value: OutputSettingsLike | undefined): OutputSettings {\n    if (value instanceof OutputSettings) {\n      return value;\n    } else if (typeof value === \"object\" && value !== null) {\n      return OutputSettings.fromInit(value);\n    }\n    return OutputSettings.standard();\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n/**\n * Thrown when reading invalid [[Input]].\n * @public\n */\nexport class InputException extends Error {\n  constructor(message?: string) {\n    super(message);\n    Object.setPrototypeOf(this, InputException.prototype);\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {Lazy} from \"@swim/util\";\nimport {Murmur3} from \"@swim/util\";\nimport type {HashCode} from \"@swim/util\";\nimport {Booleans} from \"@swim/util\";\nimport {Constructors} from \"@swim/util\";\nimport type {Output} from \"../output/Output\";\nimport type {Debug} from \"../format/Debug\";\nimport {Format} from \"../format/Format\";\n\n/**\n * Either an [[InputSettings]] instance, or an [[InputSettingsInit]] object\n * initializer.\n * @public\n */\nexport type InputSettingsLike = InputSettings | InputSettingsInit;\n\n/**\n * [[InputSettings]] object initializer.\n * @public\n */\nexport interface InputSettingsInit {\n  isStripped?: boolean;\n}\n\n/**\n * [[Input]] consumption parameters. `InputSettings` provide contextual\n * configuration parameters to input consumers, such as [[Parser Parsers]].\n * @public\n */\nexport class InputSettings implements HashCode, Debug {\n  protected constructor(stripped: boolean) {\n    Object.defineProperty(this, \"stripped\", {\n      value: stripped,\n      enumerable: true,\n    });\n  }\n\n  /** @internal */\n  readonly stripped!: boolean;\n\n  /**\n   * Returns `true` if input consumers should not include diagnostic metadata\n   * in generated output.\n   */\n  isStripped(): boolean {\n    return this.stripped;\n  }\n\n  /**\n   * Returns a copy of these settings with the given `stripped` flag.\n   */\n  asStripped(stripped: boolean): InputSettings {\n    return this.copy(stripped);\n  }\n\n  protected copy(stripped: boolean): InputSettings {\n    return InputSettings.create(stripped);\n  }\n\n  protected canEqual(that: unknown): boolean {\n    return that instanceof InputSettings;\n  }\n\n  equals(that: unknown): boolean {\n    if (this === that) {\n      return true;\n    } else if (that instanceof InputSettings) {\n      return that.canEqual(this) && this.stripped === that.stripped;\n    }\n    return false;\n  }\n\n  hashCode(): number {\n    return Murmur3.mash(Murmur3.mix(Constructors.hash(InputSettings),\n        Booleans.hash(this.stripped)));\n  }\n\n  debug<T>(output: Output<T>): Output<T> {\n    output = output.write(\"InputSettings\").write(46/*'.'*/);\n    if (!this.stripped) {\n      output = output.write(\"standard\");\n    } else {\n      output = output.write(\"stripped\");\n    }\n    output = output.write(40/*'('*/).write(41/*')'*/);\n    return output;\n  }\n\n  toString(): string {\n    return Format.debug(this);\n  }\n\n  /**\n   * Returns `InputSettings` configured to include diagnostic metadata in\n   * generated output.\n   */\n  @Lazy\n  static standard(): InputSettings {\n    return new InputSettings(false);\n  }\n\n  /**\n   * Returns `InputSettings` configured to omit diagnostic metadata in\n   * generated output.\n   */\n  @Lazy\n  static stripped(): InputSettings {\n    return new InputSettings(true);\n  }\n\n  /**\n   * Returns `InputSettings` configured to not include diagnostic metadata in\n   * generated output, if `isStripped` is `true`.\n   */\n  static create(isStripped?: boolean): InputSettings {\n    if (isStripped) {\n      return InputSettings.stripped();\n    }\n    return InputSettings.standard();\n  }\n\n  /**\n   * Converts the loosely typed `settings` to an instance of `InputSettings`.\n   */\n  static fromLike(settings: InputSettingsLike | undefined): InputSettings {\n    if (settings instanceof InputSettings) {\n      return settings;\n    } else if (typeof settings === \"object\" && settings !== null) {\n       return InputSettings.create(settings.isStripped);\n    } else {\n      return InputSettings.standard();\n    }\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {Lazy} from \"@swim/util\";\nimport {Mark} from \"../source/Mark\";\nimport {InputException} from \"./InputException\";\nimport type {InputSettingsLike} from \"./InputSettings\";\nimport {InputSettings} from \"./InputSettings\";\nimport {InputEmpty} from \"../\"; // forward import\nimport {InputDone} from \"../\"; // forward import\nimport {InputError} from \"../\"; // forward import\n\n/**\n * Non-blocking token stream reader, with single token lookahead.\n * `Input` enables incremental, interruptible parsing of network protocols and\n * data formats.\n *\n * ### Input tokens\n * Input tokens are modeled as primitive numbers, commonly representing Unicode\n * code points, or raw octets; each `Input` implementation specifies the\n * semantic type of its tokens. The [[head]]  method peeks at the lookahead\n * token, without consuming it, and the [[step]] method advances the input to\n * the next token.\n *\n * ### Input states\n * An `Input` reader is always in one of three states: _cont_​inue, _empty_, or\n * _done_. The _cont_ state indicates that a lookahead token is immediately\n * available; the _empty_ state indicates that no additional tokens are\n * available at this time, but that the stream may logically resume at some\n * point in the future; and the _done_ state indicates that the stream has\n * terminated. [[isCont]] returns `true` when in the _cont_ state; [[isEmpty]]\n * returns `true` when in the _empty_ state; and [[isDone]] returns `true` when\n * in the _done_ state.\n *\n * ### Non-blocking behavior\n * `Input` readers never block. An `Input` reader that would otherwise block\n * awaiting additional input instead enters the _empty_ state, signaling the\n * input consumer to back off processing the input, but to remain prepared to\n * process additional input in the future. An `Input` reader enters the _done_\n * state when it encounters the final end of its input, signaling the input\n * consumer to stop processing. [[Input.empty]] returns an `Input` reader in\n * the _empty_ state. [[Input.done]] returns an `Input` reader in the _done_\n * state.\n *\n * ### Position tracking\n * The logical position of the lookahead token is made available via the\n * [[mark]] method, with optimized callouts for the byte [[offset]], one-based\n * [[line]] number, and one-based [[column]] in the current line. The [[id]]\n * method returns a diagnostic identifier for the token stream.\n *\n * ### Cloning\n * An `Input` reader may be [[clone cloned]] to provide an indepently mutable\n * position into a shared token stream. Not all `Input` implementations\n * support cloning.\n *\n * @see [[InputSettings]]\n * @see [[Parser]]\n * @public\n */\nexport abstract class Input {\n  /**\n   * Returns `true` when a [[head lookahead]] token is immediately available.\n   * i.e. this `Input` is in the _cont_ state.\n   */\n  abstract isCont(): boolean;\n\n  /**\n   * Returns `true` when no lookahead token is currently available, but\n   * additional input may be available at some point in the future, i.e. this\n   * `Input` is in the _empty_ state.\n   */\n  abstract isEmpty(): boolean;\n\n  /**\n   * Returns `true` when no lookahead token is currently available, and no\n   * additional input will ever become available, i.e. this `Input` is in\n   * the _done_ state.\n   */\n  abstract isDone(): boolean;\n\n  /**\n   * Returns `true` when no lookahead token is currently available due to an\n   * error with the token stream. i.e. this `Input` is in the `error` state.\n   * When `true`, `trap()` will return the input error\n   */\n  abstract isError(): boolean;\n\n  /**\n   * Returns `true` if this is a partial `Input` will that enter the _empty_\n   * state after it consumes the last available input token.\n   */\n  abstract isPart(): boolean;\n\n   /**\n    * Returns a partial `Input` equivalent to this `Input`, if `part` is `true`;\n    * returns a final `Input` equivalent to this `Input` if `part` is `false`.\n    * The caller's reference to this `Input` should be replaced by the returned\n    * `Input`\n    */\n  abstract asPart(part: boolean): Input;\n\n  /**\n   * Returns the current lookahead token, if this `Input` is in the\n   * _cont_ state.\n   *\n   * @throws [[InputException]] if this `Input` is not in the _cont_ state.\n   */\n  abstract head(): number;\n\n  /**\n   * Advances to the next token, if this `Input` is in the _cont_ state.\n   *\n   * @throws `Error` if this `Input` is not in the _cont_ state.\n   */\n  abstract step(): Input;\n\n  /**\n   * Sets the position of this `Input` to the given `mark`. Rewinds to the\n   * start of this `Input`, if `mark` is `undefined`.\n   *\n   * @throws [[InputException]] if this `Input` does not support seeking,\n   *         or is unable to reposition to the `mark`.\n   */\n  abstract seek(mark?: Mark): Input;\n\n  /**\n   * Returns the input error when in the _error_ state\n   *\n   * @throws InputException if the `Input` is not the _error_state\n   */\n  trap(): Error {\n    throw new InputException();\n  }\n\n  /**\n   * An informative identifier for this token stream, or `undefined` if this\n   * stream is unidentified.\n   */\n  abstract readonly id: string | undefined;\n\n  /**\n   * Returns an `Input` equivalent to this `Input`, but logically identified\n   * by the given–possibly `undefined`–`id`. The caller's reference to this\n   * `Input` should be replaced by the returned `Input`.\n   */\n  abstract withId(id: string | undefined): Input;\n\n  /**\n   * The position of the current lookahead token, relative to the start\n   * of the stream.\n   */\n  abstract readonly mark: Mark;\n\n  /**\n   * Returns an `Input` equivalent to this `Input`, but logically positioned\n   * at the given `mark`. The physical position in the input stream is not\n   * modified. The caller's reference to this `Input` should be replaced by\n   * the returned `Input`.\n   */\n  abstract withMark(mark: Mark): Input;\n\n  /**\n   * The byte offset of the current lookahead token, relative to the start\n   * of the stream.\n   */\n  abstract readonly offset: number;\n\n  /**\n   * The one-based line number of the current lookahead token, relative to\n   * the start of the stream.\n   */\n  abstract readonly line: number;\n\n  /**\n   * The one-based column number of the current lookahead token, relative to\n   * the current line in the stream.\n   */\n  abstract readonly column: number;\n\n  /**\n   * The `InputSettings` used to configure the behavior of input consumers\n   * that read from this `Input`.\n   */\n  abstract readonly settings: InputSettings;\n\n  /**\n   * Returns a clone of this `Input` with the given `settings`.\n   *\n   * @throws `Error` if this `Input` reader cannot be cloned.\n   */\n  abstract withSettings(settings: InputSettingsLike): Input;\n\n  /**\n   * Returns an independently positioned view into the token stream,\n   * initialized with identical state to this `Input`.\n   *\n   * @throws `Error` if this `Input` reader cannot be cloned.\n   */\n  abstract clone(): Input;\n\n  /**\n   * Returns an `Input` reader in the _empty_ state.\n   */\n  @Lazy\n  static empty(): Input {\n    return new InputEmpty(void 0, Mark.zero, InputSettings.standard());\n  }\n\n  /**\n   * Returns an `Input` reader in the _done_ state.\n   */\n  @Lazy\n  static done(): Input {\n    return new InputDone(void 0, Mark.zero, InputSettings.standard());\n  }\n\n  /**\n   * Returns an `Input` in the _error_ state that traps the given `error`.\n   */\n  static error(error: Error): Input {\n    return new InputError(error, void 0, Mark.zero, InputSettings.standard());\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {Mark} from \"../source/Mark\";\nimport {InputException} from \"./InputException\";\nimport type {InputSettingsLike} from \"./InputSettings\";\nimport {InputSettings} from \"./InputSettings\";\nimport {Input} from \"./Input\";\n\n/** @internal */\nexport class InputError extends Input {\n  /** @internal */\n  readonly error!: Error;\n\n  constructor(error: Error, id: string | undefined, mark: Mark, settings: InputSettings) {\n    super();\n    Object.defineProperty(this, \"error\", {\n      value: error,\n      enumerable: true,\n    });\n    Object.defineProperty(this, \"id\", {\n      value: id,\n      enumerable: true,\n    });\n    Object.defineProperty(this, \"mark\", {\n      value: mark,\n      enumerable: true,\n    });\n    Object.defineProperty(this, \"settings\", {\n      value: settings,\n      enumerable: true,\n    });\n  }\n\n  override isCont(): boolean {\n    return false;\n  }\n\n  override isEmpty(): boolean {\n    return false;\n  }\n\n  override isDone(): boolean {\n    return false;\n  }\n\n  override isError(): boolean {\n    return true;\n  }\n\n  override isPart(): boolean {\n    return false;\n  }\n\n  override asPart(part: boolean): Input {\n    return this;\n  }\n\n  override head(): number {\n    throw new InputException();\n  }\n\n  override step(): Input {\n    const error = new InputException(\"error step\");\n    return new InputError(error, this.id, this.mark, this.settings);\n  }\n\n  override trap(): Error {\n    return this.error;\n  }\n\n  override seek(mark?: Mark): Input {\n    const error = new InputException(\"error seek\");\n    return new InputError(error, this.id, this.mark, this.settings);\n  }\n\n  override readonly id!: string | undefined;\n\n  override withId(id: string | undefined): Input {\n    return new InputError(this.error, id, this.mark, this.settings);\n  }\n\n  override readonly mark!: Mark;\n\n  override withMark(mark: Mark): Input {\n    return new InputError(this.error, this.id, mark, this.settings);\n  }\n\n  override get offset(): number {\n    return this.mark.offset;\n  }\n\n  override get line(): number {\n    return this.mark.line;\n  }\n\n  override get column(): number {\n    return this.mark.column;\n  }\n\n  override readonly settings!: InputSettings;\n\n  override withSettings(settings: InputSettingsLike): Input {\n    settings = InputSettings.fromLike(settings);\n    return new InputError(this.error, this.id, this.mark, settings);\n  }\n\n  override clone(): Input {\n    return this;\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {Mutable} from \"@swim/util\";\nimport {Strings} from \"@swim/util\";\nimport {Mark} from \"../source/Mark\";\nimport {InputException} from \"../input/InputException\";\nimport type {InputSettingsLike} from \"../input/InputSettings\";\nimport {InputSettings} from \"../input/InputSettings\";\nimport {Input} from \"../input/Input\";\nimport {InputError} from \"../input/InputError\";\n\n/** @internal */\nexport class StringInput extends Input {\n  constructor(string: string, id: string | undefined, offset: number,\n              line: number, column: number, settings: InputSettings,\n              index: number, part: boolean) {\n    super();\n    this.string = string;\n    this.index = index;\n    this.part = part;\n    this.id = id;\n    this.offset = offset;\n    this.line = line;\n    this.column = column;\n    this.settings = settings;\n  }\n\n  /** @internal */\n  readonly string: string;\n\n  /** @internal */\n  readonly index: number;\n\n  /** @internal */\n  readonly part: boolean;\n\n  override isCont(): boolean {\n    return this.index < this.string.length;\n  }\n\n  override isEmpty(): boolean {\n    return this.part && this.index >= this.string.length;\n  }\n\n  override isDone(): boolean {\n    return !this.part && this.index >= this.string.length;\n  }\n\n  override isError(): boolean {\n    return false;\n  }\n\n  override isPart(): boolean {\n    return this.part;\n  }\n\n  override asPart(part: boolean): Input {\n    (this as Mutable<this>).part = part;\n    return this;\n  }\n\n  override head(): number {\n    const string = this.string;\n    const index = this.index;\n    if (index < string.length) {\n      const c = string.codePointAt(index);\n      if (c !== void 0) {\n        return c;\n      } else {\n        return string.charCodeAt(index);\n      }\n    }\n    throw new InputException();\n  }\n\n  override step(): Input {\n    const string = this.string;\n    const index = this.index;\n    if (index < string.length) {\n      const c = string.codePointAt(index);\n      (this as Mutable<this>).index = Strings.offsetByCodePoints(string, index, 1);\n      (this as Mutable<this>).offset += this.index - index;\n      if (c === 10/*'\\n'*/) {\n        (this as Mutable<this>).line += 1;\n        (this as Mutable<this>).column = 1;\n      } else {\n        (this as Mutable<this>).column += 1;\n      }\n      return this;\n    } else {\n      const error = new InputException(\"invalid step\");\n      return new InputError(error, this.id, this.mark, this.settings);\n    }\n  }\n\n  override seek(mark?: Mark): Input {\n    if (mark !== void 0) {\n      const index = this.index + (mark.offset - this.offset);\n      if (0 <= index && index <= this.string.length) {\n        (this as Mutable<this>).index = index;\n        (this as Mutable<this>).offset = mark.offset;\n        (this as Mutable<this>).line = mark.line;\n        (this as Mutable<this>).column = mark.column;\n        return this;\n      } else {\n        const error = new InputException(\"invalid seek to \" + mark);\n        return new InputError(error, this.id, this.mark, this.settings);\n      }\n    } else {\n      (this as Mutable<this>).index = 0;\n      (this as Mutable<this>).offset = 0;\n      (this as Mutable<this>).line = 1;\n      (this as Mutable<this>).column = 1;\n      return this;\n    }\n  }\n\n  readonly id: string | undefined;\n\n  override withId(id: string | undefined): Input {\n    (this as Mutable<this>).id = id;\n    return this;\n  }\n\n  override get mark(): Mark {\n    return Mark.at(this.offset, this.line, this.column);\n  }\n\n  override withMark(mark: Mark): Input {\n    (this as Mutable<this>).offset = mark.offset;\n    (this as Mutable<this>).line = mark.line;\n    (this as Mutable<this>).column = mark.column;\n    return this;\n  }\n\n  override readonly offset: number;\n\n  override readonly line: number;\n\n  override readonly column: number;\n\n  override readonly settings: InputSettings;\n\n  override withSettings(settings: InputSettingsLike): Input {\n    settings = InputSettings.fromLike(settings);\n    (this as Mutable<this>).settings = settings;\n    return this;\n  }\n\n  override clone(): Input {\n    return new StringInput(this.string, this.id, this.offset, this.line,\n                           this.column, this.settings, this.index, this.part);\n  }\n\n  static create(string: string): Input {\n    return new StringInput(string, void 0, 0, 1, 1, InputSettings.standard(), 0, false);\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n/**\n * Thrown when writing invalid [[Output]].\n * @public\n */\nexport class OutputException extends Error {\n  constructor(message?: string) {\n    super(message);\n    Object.setPrototypeOf(this, OutputException.prototype);\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {Lazy} from \"@swim/util\";\nimport {OutputException} from \"./OutputException\";\nimport type {OutputSettingsLike} from \"./OutputSettings\";\nimport {OutputSettings} from \"./OutputSettings\";\nimport {OutputFull} from \"../\"; // forward import\nimport {OutputDone} from \"../\"; // forward import\nimport {OutputError} from \"../\"; // forward import\nimport {Format} from \"../\"; // forward import\n\n/**\n * Non-blocking token stream writer. `Output` enables incremental,\n * interruptible writing of network protocols and data formats.\n *\n * ### Output tokens\n * Output tokens are modeled as primitive numbers, commonly representing\n * Unicode code points, or raw octets; each `Output` implementation specifies\n * the semantic type of its tokens.\n *\n * ### Output states\n * An `Output` writer is always in one of three states: _cont_​inue, _full_,\n * or _done_. The _cont_ state indicates that the stream is ready to write a\n * single token; the _full_ state indicates that the stream is unable to write\n * additional tokens at this time, but that the stream may logically resume at\n * some point in the future; and the _done_ state indicates that the stream has\n * terminated, and that [[bind]] will return the output result. [[isCont]]\n * returns `true` when in the _cont_ state; [[isFull]] returns `true` when in\n * the _full_ state; and [[isDone]] returns `true` when in the _done_ state.\n *\n * ### Output results\n * An `Output` writer yields a value of type `T`, obtained via the [[bind]]\n * method, representing some implementation defined result of writing the\n * output. For example, an `Output<string>` implementation may–but is not\n * required to–yield a `string` containing all code points written to the\n * output.\n *\n * ### Non-blocking behavior\n * `Output` writers never block. An `Output` writer that would otherwise block\n * writing additional output instead enters the _full_ state, signaling the\n * output generator to back off producing the output, but to remain prepared to\n * produce additional output in the future. An `Output` writer enters the\n * _done_ state when it encounters the final end of its output, signaling to\n * the output generator to stop producing.\n *\n * ### Output settings\n * An output generator may alter the tokens it produces based on its `Output`\n * writer's [[settings]]. Uses include pretty printing and styling generated\n * output. [[OutputSettings]] subclasses can provide additional parameters\n * understood by specialized output producers.\n *\n * ### Cloning\n * An `Output` writer may be [[clone cloned]] to branch the token stream in an\n * implementation specified manner. Not all `Output` implementations support\n * cloning.\n *\n * @see [[OutputSettings]]\n * @see [[Writer]]\n * @public\n */\nexport abstract class Output<T = unknown> {\n  /**\n   * Returns `true` when the next [[write write(number)]] will succeed.\n   * i.e. this `Output` is in the _cont_ state.\n   */\n  abstract isCont(): boolean;\n\n  /**\n   * Returns `true` when an immediate `write` will fail, but writes may succeed\n   * at some point in the future, i.e. this `Output` is in the _full_ state.\n   */\n  abstract isFull(): boolean;\n\n  /**\n   * Returns `true` when no `write` will ever again succeed.\n   * i.e. this `Output` is in the _done_ state.\n   */\n  abstract isDone(): boolean;\n\n  /**\n   * Returns `true` when an immediate `write` will fail due to an\n   * error with the token stream. i.e. this `Output` is in the `error` state.\n   * When `true`, `trap()` will return the output error.\n   */\n  abstract isError(): boolean;\n\n  /**\n   * Returns `true` if this is a partial `Output` that will enter\n   * the `full` state when it is unable to write additional tokens.\n   */\n  abstract isPart(): boolean;\n\n  /**\n   * Returns a partial `Output` equivalent to this `Output`, if `part` is `true`;\n   * returns a final `Output` equivalent to this `Output` if `part` is `false`.\n   * The caller's reference to this `Output` should be replaced by the returned\n   * `Output`.\n   */\n  abstract asPart(part: boolean): Output<T>;\n\n  /**\n   * Writes a single `token` to the stream, if this `Output` is in the\n   * _cont_ state.\n   *\n   * @returns `this`\n   * @throws [[OutputException]] if this `Output` is not in the _cont_ state.\n   */\n  abstract write(token: number): Output<T>;\n\n  /**\n   * Writes the code points of the given `string`. Assumes this is a Unicode\n   * `Output` writer with sufficient capacity.\n   *\n   * @returns `this`\n   * @throws [[OutputException]] if this `Output` exits the _cont_ state before\n   *         the full `string` has been written.\n   */\n  abstract write(string: string): Output<T>;\n\n  /**\n   * Writes the code points of the given `string`, followed by the code points\n   * of the `settings`' [[OutputSettings.lineSeparator line separator].\n   * Assumes this is a Unicode `Output` writer with sufficient capacity.\n   *\n   * @returns `this`\n   * @throws [[OutputException]] if this `Output` exits the _cont_ state before\n   *         the full `string` and line separator has been written.\n   */\n  writeln(string?: string): Output<T> {\n    if (typeof string === \"string\") {\n      this.write(string);\n    }\n    return this.write(this.settings.lineSeparator);\n  }\n\n  /**\n   * Writes the code points of the human-readable [[Display]] string of the\n   * given `object`. Assumes this is a Unicode `Output` writer with sufficient\n   * capacity.\n   *\n   * @returns the continuation of the `output`.\n   * @throws [[OutputException]] if this `Output` exits the _cont_ state before\n   *         the full display string has been written.\n   */\n  display(object: unknown): Output<T> {\n    return Format.displayAny(this, object);\n  }\n\n  /**\n   * Writes the code points of the developer-readable [[Debug]] string of the\n   * given `object`. Assumes this is a Unicode `Output` writer with sufficient\n   * capacity.\n   *\n   * @returns the continuation of the `output`.\n   * @throws [[OutputException]] if this `Output` exits the _cont_ state before\n   *         the full debug string has been written.\n   */\n  debug(object: unknown): Output<T> {\n    return Format.debugAny(this, object);\n  }\n\n  /**\n   * Writes any internally buffered state to the underlying output stream.\n   */\n  flush(): Output<T> {\n    return this;\n  }\n\n  push(...tokens: number[]): void {\n    const n = tokens.length;\n    for (let i = 0; i < n; i += 1) {\n      this.write(tokens[i]!);\n    }\n  }\n\n  /**\n   * The `OutputSettings` used to configure the behavior of output producers\n   * that write to this `Output`.\n   */\n  abstract readonly settings: OutputSettings;\n\n  /**\n   * Updates the `settings` associated with this `Output`.\n   *\n   * @returns `this`\n   */\n  abstract withSettings(settings: OutputSettingsLike): Output<T>;\n\n  /**\n   * Returns the implementation-defined result of writing the output.\n   */\n  abstract bind(): T;\n\n  /**\n   * Returns the output error. Only guaranteed to return an error when in the\n   * _error_ state.\n   *\n   * @throws OutputException if this `Output` is not in the _error_ state.\n   */\n  trap(): Error {\n    throw new OutputException();\n  }\n\n  /**\n   * Returns an implementation-defined branch of the token stream.\n   *\n   * @throws `Error` if this `Output` writer cannot be cloned.\n   */\n  clone(): Output<T> {\n    throw new Error();\n  }\n\n  /**\n   * Return an `Output` in the _full_ state.\n   */\n  @Lazy\n  static full(): Output<never> {\n    return new OutputFull(OutputSettings.standard());\n  }\n\n  /**\n   * Returns an `Output` in the _done_ state.\n   */\n  @Lazy\n  static done(): Output<never> {\n    return new OutputDone(OutputSettings.standard());\n  }\n\n  /**\n   * Return an `Output` in the _error_ state that traps the given `error`.\n   */\n  static error(error: Error): Output<never> {\n    return new OutputError(error, OutputSettings.standard());\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {Mutable} from \"@swim/util\";\nimport type {OutputSettingsLike} from \"../output/OutputSettings\";\nimport {OutputSettings} from \"../output/OutputSettings\";\nimport {Output} from \"../output/Output\";\n\n/** @internal */\nexport class StringOutput extends Output<string> {\n  constructor(string: string, settings: OutputSettings) {\n    super();\n    this.string = string;\n    this.settings = settings;\n  }\n\n  /** @internal */\n  readonly string: string;\n\n  override isCont(): boolean {\n    return true;\n  }\n\n  override isFull(): boolean {\n    return false;\n  }\n\n  override isDone(): boolean {\n    return false;\n  }\n\n  override isError(): boolean {\n    return false;\n  }\n\n  override isPart(): boolean {\n    return false;\n  }\n\n  override asPart(part: boolean): Output<string> {\n    return this;\n  }\n\n  override write(token: number | string): Output<string> {\n    if (typeof token === \"number\") {\n      if ((token >= 0x0000 && token <= 0xd7ff)\n          || (token >= 0xe000 && token <= 0xffff)) { // U+0000..U+D7FF | U+E000..U+FFFF\n        token = String.fromCharCode(token);\n      } else if (token >= 0x10000 && token <= 0x10ffff) { // U+10000..U+10FFFF\n        const u = token - 0x10000;\n        token = String.fromCharCode(0xd800 | (u >>> 10), 0xdc00 | (u & 0x3ff));\n      } else { // invalid code point\n        token = \"\\ufffd\";\n      }\n    }\n    (this as Mutable<this>).string += token;\n    return this;\n  }\n\n  override writeln(string?: string): Output<string> {\n    if (string !== void 0) {\n      (this as Mutable<this>).string = this.string.concat(string);\n    }\n    (this as Mutable<this>).string = this.string.concat(this.settings.lineSeparator);\n    return this;\n  }\n\n  override readonly settings: OutputSettings;\n\n  override withSettings(settings: OutputSettingsLike): Output<string> {\n    settings = OutputSettings.fromLike(settings);\n    (this as Mutable<this>).settings = settings;\n    return this;\n  }\n\n  override bind(): string {\n    return this.string;\n  }\n\n  override clone(): Output<string> {\n    return new StringOutput(this.string, this.settings);\n  }\n\n  override toString(): string {\n    return this.string;\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n/**\n * Thrown when a [[Writer]] attempts to write invalid syntax.\n * @public\n */\nexport class WriterException extends Error {\n  constructor(message?: string) {\n    super(message);\n    Object.setPrototypeOf(this, WriterException.prototype);\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {Lazy} from \"@swim/util\";\nimport type {Output} from \"../output/Output\";\nimport {WriterException} from \"./WriterException\";\nimport {WriterEnd} from \"../\"; // forward import\nimport {WriterDone} from \"../\"; // forward import\nimport {WriterError} from \"../\"; // forward import\nimport {WriterSequence} from \"../\"; // forward import\n\n/**\n * Continuation of how to write subsequent [[Output]] tokens to a stream.\n * `Writer` enables efficient, interruptible writing of network protocols and\n * data formats, without intermediate buffering.\n *\n * ### Output tokens\n * A `Writer` writes tokens to an `Output` writer. Output tokens are modeled\n * as primitive numbers, commonly representing Unicode code points, or raw\n * octets. Each `Writer` implementation specifies the semantic type of output\n * tokens it produces.\n *\n * ### Writer states\n * A `Writer` is always in one of three states: _cont_​inue, _done_, or _error_.\n * The _cont_ state indicates that [[pull]] is ready to produce `Output`; the\n * _done_ state indicates that writing terminated successfully, and that\n * [[bind]] will return the written result; the _error_ state indicates that\n * writing terminated in failure, and that [[trap]] will return the write error.\n * `Writer` subclasses default to the _cont_ state.\n *\n * ### Feeding input\n * The [[feed]] method returns a `Writer` that represents the continuation\n * of how to write the given input object to subsequent `Output` writers.\n * `feed` can be used to specify an initial object to write, or to change\n * the object to be written.\n *\n * ### Pulling output\n * The [[pull]] method incrementally writes as much `Output` as it can, before\n * returning another `Writer` that represents the continuation of how to write\n * additional `Output`. The `Output` passed to `pull` is only guaranteed to be\n * valid for the duration of the method call; references to the provided\n * `Output` instance must not be stored.\n *\n * ### Writer results\n * A `Writer` produces a written result of type `O`, obtained via the [[bind]]\n * method. `bind` is only guaranteed to return a result when in the _done_\n * state; though `bind` may optionally make available partial results in other\n * states. A failed `Writer` provides a write error via the [[trap]] method.\n * `trap` is only guaranteed to return an error when in the _error_ state.\n *\n * ### Continuations\n * A `Writer` instance represents a continuation of how to write remaining\n * `Output`. Rather than writing a complete output in one go, a `Writer` takes\n * an `Output` chunk and returns another `Writer` instance that knows how to\n * write subsequent `Output` chunks. This enables non-blocking, incremental\n * writing that can be interrupted whenever an `Output` writer runs out of\n * space. A `Writer` terminates by returning a continuation in either the\n * _done_ state, or the _error_ state. [[Writer.done]] returns a `Writer` in\n * the _done_ state. [[Writer.error]] returns a `Writer` in the _error_ state.\n *\n * ### Forking\n * The [[fork]] method passes an out-of-band condition to a `Writer`, yielding\n * a `Writer` continuation whose behavior may be altered by the given condition.\n * For example, a console `Writer` might support a `fork` condition that changes\n * the color and style of printed text. The types of conditions accepted by\n * `fork`, and their intended semantics, are implementation defined.\n *\n * @public\n */\nexport abstract class Writer<I = unknown, O = unknown> {\n  /**\n   * Returns `true` when [[pull]] is able to produce `Output`, i.e. this\n   * `Writer` is in the _cont_ state.\n   */\n  isCont(): boolean {\n    return true;\n  }\n\n  /**\n   * Returns `true` when writing has terminated successfully, and [[bind]] will\n   * return the written result, i.e. this `Writer` is in the _done_ state.\n   */\n  isDone(): boolean {\n    return false;\n  }\n\n  /**\n   * Returns `true` when writing has terminated in failure, and [[trap]] will\n   * return the write error, i.e. this `Writer` is in the _error_ state.\n   */\n  isError(): boolean {\n    return false;\n  }\n\n  /**\n   * Returns a `Writer` that represents the continuation of how to write the\n   * given `input` object.\n   *\n   * @throws `WriterException` if this `Writer` does not know how to write the\n   *         given `input` object.\n   */\n  feed(input: I): Writer<I, O> {\n    throw new WriterException();\n  }\n\n  /**\n   * Incrementally writes as much `output` as possible, and returns another\n   * `Writer` that represents the continuation of how to write additional\n   * `Output`. If `output` enters the _done_ state, `pull` _must_ return a\n   * terminated `Writer`, i.e. a `Writer` in the _done_ state, or in the\n   * _error_ state. The given `output` is only guaranteed to be valid for the\n   * duration of the method call; references to `output` must not be stored.\n   */\n  abstract pull(output: Output): Writer<I, O>;\n\n  /**\n   * Returns a `Writer` continuation whose behavior may be altered by the given\n   * out-of-band `condition`.\n   */\n  fork(condition: unknown): Writer<I, O> {\n    return this;\n  }\n\n  /**\n   * Returns the written result. Only guaranteed to return a result when in\n   * the _done_ state.\n   *\n   * @throws `Error` if this `Writer` is not in the _done_ state.\n   */\n  bind(): O {\n    throw new WriterException();\n  }\n\n  /**\n   * Returns the write error. Only guaranteed to return an error when in the\n   * _error_ state.\n   *\n   * @throws `Error` if this `Writer` is not in the _error_ state.\n   */\n  trap(): Error {\n    throw new WriterException();\n  }\n\n  /**\n   * Casts a done `Writer` to a different input type. A `Writer` in the _done_\n   * state can have any input type.\n   *\n   * @throws `WriterException` if this `Writer` is not in the _done_ state.\n   */\n  asDone<I2>(): Writer<I2, O> {\n    throw new WriterException();\n  }\n\n  /**\n   * Casts an errored `Writer` to different input and output types. A `Writer`\n   * in the _error_ state can have any input type, and any output type.\n   *\n   * @throws `WriterException` if this `Writer` is not in the _error_ state.\n   */\n  asError<I2, O2>(): Writer<I2, O2> {\n    throw new WriterException();\n  }\n\n  /**\n   * Returns a `Writer` that continues writing `that` `Writer`, after it\n   * finishes writing this `Writer`.\n   */\n  andThen<O2>(that: Writer<unknown, O2>): Writer<never, O2> {\n    return new WriterSequence(this, that);\n  }\n\n  /**\n   * Returns a `Writer` in the _done_ state that never binds a value.\n   */\n  @Lazy\n  static end<I>(): Writer<I, never> {\n    return new WriterEnd();\n  }\n\n  /**\n   * Returns a `Writer` in the _done_ state that binds the given written `value`.\n   */\n  static done<I, O>(value: O): Writer<I, O> {\n    return new WriterDone(value);\n  }\n\n  /**\n   * Returns a `Writer` in the _error_ state that traps the given write `error`.\n   */\n  static error<I, O>(error: Error): Writer<I, O> {\n    return new WriterError(error);\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {Strings} from \"@swim/util\";\nimport type {Output} from \"../output/Output\";\nimport {WriterException} from \"../writer/WriterException\";\nimport {Writer} from \"../writer/Writer\";\n\n/** @internal */\nexport class StringWriter extends Writer<unknown, unknown> {\n  /** @internal */\n  readonly value: unknown;\n  /** @internal */\n  readonly input: string;\n  /** @internal */\n  readonly index: number;\n\n  constructor(value: unknown, input: string, index: number = 0) {\n    super();\n    this.value = value;\n    this.input = input;\n    this.index = index;\n  }\n\n  override feed(input: unknown): Writer<unknown, unknown> {\n    return new StringWriter(input, \"\" + input);\n  }\n\n  override pull(output: Output): Writer<unknown, unknown> {\n    return StringWriter.write(output, this.value, this.input, this.index);\n  }\n\n  static write(output: Output, value: unknown, input: string, index: number = 0): Writer<unknown, unknown> {\n    const length = input.length;\n    while (index < length && output.isCont()) {\n      let c = input.codePointAt(index);\n      if (c === void 0) {\n        c = input.charCodeAt(index);\n      }\n      output = output.write(c);\n      index = Strings.offsetByCodePoints(input, index, 1);\n    }\n    if (index === length) {\n      return Writer.done(value);\n    }\n    if (output.isDone()) {\n      return Writer.error(new WriterException(\"truncated\"));\n    } else if (output.isError()) {\n      return Writer.error(output.trap());\n    }\n    return new StringWriter(value, input, index);\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {Input} from \"../input/Input\";\nimport type {OutputSettingsLike} from \"../output/OutputSettings\";\nimport {OutputSettings} from \"../output/OutputSettings\";\nimport type {Output} from \"../output/Output\";\nimport type {Writer} from \"../writer/Writer\";\nimport {StringInput} from \"./StringInput\";\nimport {StringOutput} from \"./StringOutput\";\nimport {StringWriter} from \"./StringWriter\";\n\n/**\n * Unicode code point [[Input]]/[[Output]]/[[Writer]] factory.\n *\n * The `Unicode.stringInput(...)` function returns an `Input` that reads the\n * Unicode code points of a `string`.\n *\n * The `Unicode.stringOutput(...)` function returns an `Output` that writes\n * Unicode code points to an internal buffer, and [[Output.bind binds]] a\n * `string` containing all written code points.\n * @public\n */\nexport const Unicode = (function () {\n  const Unicode = {} as {\n    stringInput(string: string): Input;\n\n    /**\n     * Returns a new `Output` that appends Unicode code points to the given\n     * `string`, using the given output `settings`. The returned `Output`\n     * accepts an unbounded number of code points, remaining permanently in the\n     * _cont_ state, and [[Output.bind binds]] a `string` containing the given\n     * `string`, and all appended code points.\n     */\n    stringOutput(string?: string, settings?: OutputSettingsLike): Output<string>;\n\n    /**\n     * Returns a new `Output` that buffers Unicode code points, using the given\n     * output `settings`. The returned `Output` accepts an unbounded number of\n     * code points, remaining permanently in the _cont_ state, and [[Output.bind\n     * binds]] a `string` containing all written code points.\n     */\n    stringOutput(settings?: OutputSettingsLike): Output<string>;\n\n    stringWriter<I>(): Writer<I, unknown>;\n\n    stringWriter<I, O>(input: O): Writer<I, O>;\n\n    writeString<I>(output: Output, input: unknown): Writer<I, unknown>;\n\n    /** @internal */\n    isAlpha(c: number): boolean;\n\n    /** @internal */\n    isDigit(c: number): boolean;\n\n    /** @internal */\n    isSpace(c: number): boolean;\n\n    /** @internal */\n    isNewline(c: number): boolean;\n\n    /** @internal */\n    isWhitespace(c: number): boolean;\n  };\n\n  Unicode.stringInput = function (string: string): Input {\n    return StringInput.create(string);\n  };\n\n  Unicode.stringOutput = function (string?: string | OutputSettingsLike, settings?: OutputSettingsLike): Output<string> {\n    if (settings === void 0 && typeof string !== \"string\") {\n      settings = string;\n      string = \"\";\n    } else if (typeof string !== \"string\") {\n      string = \"\";\n    }\n    settings = OutputSettings.fromLike(settings);\n    return new StringOutput(string, settings);\n  };\n\n  Unicode.stringWriter = function <I, O>(input?: O): Writer<I, unknown> {\n    if (input === void 0) {\n      return new StringWriter(void 0, \"\");\n    } else {\n      return new StringWriter(input, \"\" + input);\n    }\n  };\n\n  Unicode.writeString = function <I>(output: Output, input: unknown): Writer<I, unknown> {\n    return StringWriter.write(output, void 0, \"\" + input);\n  };\n\n  Unicode.isAlpha = function (c: number): boolean {\n    return c >= 65/*'A'*/ && c <= 90/*'Z'*/\n        || c >= 97/*'a'*/ && c <= 122/*'z'*/;\n  };\n\n  Unicode.isDigit = function (c: number): boolean {\n    return c >= 48/*'0'*/ && c <= 57/*'9'*/;\n  };\n\n  Unicode.isSpace = function (c: number): boolean {\n    return c === 0x20 || c === 0x9;\n  };\n\n  Unicode.isNewline = function (c: number): boolean {\n    return c === 0xa || c === 0xd;\n  };\n\n  Unicode.isWhitespace = function (c: number): boolean {\n    return Unicode.isSpace(c) || Unicode.isNewline(c);\n  };\n\n  return Unicode;\n})();\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport * as OS from \"os\";\nimport type {OutputSettingsLike} from \"../output/OutputSettings\";\nimport type {Output} from \"../output/Output\";\nimport type {Display} from \"./Display\";\nimport type {Debug} from \"./Debug\";\nimport {Unicode} from \"../unicode/Unicode\";\n\n/**\n * utility functions for formatting values.\n * @public\n */\nexport const Format = (function () {\n  const Format = {} as {\n    /**\n     * The operating system specific string used to separate lines of text.\n     */\n    readonly lineSeparator: string;\n\n    /**\n     * Returns the human-readable [[Display]] string for the given `object`,\n     * output using the given `settings`. Delegates to [[Display.display]],\n     * if `object` implements `Display`; otherwise returns the result of\n     * `Object.toString`.\n     */\n    display(object: unknown, settings?: OutputSettingsLike): string;\n\n    /**\n     * Returns the developer-readable [[Debug]] string for the given `object`,\n     * output using the given `settings`. Delegates to [[Debug.debug]], if\n     * `object` implements `Debug`; returns a JavaScript string literal, if\n     * `object` is a `string`, and returns a JavaScript number literal, if\n     * `object` is a `number`; otherwise returns the result of `Object.toString`.\n     */\n    debug(object: unknown, settings?: OutputSettingsLike): string;\n\n    /**\n     * Writes the code points of the human-readable [[Display]] string for the\n     * given `object` to `output`. Assumes `output` is a Unicode `Output` writer\n     * with sufficient capacity. Delegates to [[Display.display]], if `object`\n     * implements `Display`; otherwise writes the result of `Object.toString`.\n     *\n     * @returns the continuation of the `output`.\n     * @throws [[OutputException]] if the `output` exits the _cont_ state before\n     *         the full display string has been written.\n     */\n    displayAny<T>(output: Output<T>, object: unknown): Output<T>;\n\n    /**\n     * Writes the code points of the developer-readable [[Debug]] string for the\n     * given `object` to `output`. Assumes `output` is a Unicode `Output` writer\n     * with sufficient capacity. Delegates to [[Debug.debug]], if `object`\n     * implements `Debug`; writes a JavaScript string literal, if `object` is a\n     * `string`, and writes a JavaScript number literal, if `object` is a\n     * `number`; otherwise writes the result of `Object.toString`.\n     *\n     * @returns the continuation of the `output`.\n     * @throws [[OutputException]] if the `output` exits the _cont_ state before\n     *         the full debug string has been written.\n     */\n    debugAny<T>(output: Output<T>, object: unknown): Output<T>;\n\n    /**\n     * Writes the code points of the numeric string for the given `value`\n     * to `output`.\n     *\n     * @returns the continuation of the `output`.\n     */\n    displayNumber<T>(output: Output<T>, value: number): Output<T>;\n\n    /**\n     * Writes the code points of the JavaScript numeric literal for the given\n     * `value` to `output`.\n     *\n     * @returns the continuation of the `output`.\n     */\n    debugNumber<T>(output: Output<T>, value: number): Output<T>;\n\n    /**\n     * Writes the code points of the JavaScript character literal for the given\n     * `character` to `output`.\n     *\n     * @returns the continuation of the `output`.\n     */\n    debugChar<T>(output: Output<T>, character: number): Output<T>;\n\n    /**\n     * Writes the code points of the JavaScript string literal for the given\n     * `string` to `output`.\n     *\n     * @returns the continuation of the `output`.\n     */\n    debugString<T>(output: Output<T>, string: string): Output<T>;\n\n    /** @internal */\n    encodeHex(x: number): number;\n\n    /**\n     * Returns a string representation of `value` scaled by its SI magnitude,\n     * keeping at most `precision` digits past the decimal place, appended with\n     * the appropriate SI prefix.\n     */\n    prefix(value: number, precision?: number): string;\n\n    decimal(value: number, precision?: number): string;\n\n    /** @internal */\n    trimTrailingZeros(s: string): string;\n\n    /**\n     * Returns a string representation of the duration represented by the given\n     * number of milliseconds.\n     */\n    duration(millis: number, separator?: string): string;\n  };\n\n  Object.defineProperty(Format, \"lineSeparator\", {\n    value: typeof OS !== \"undefined\" && typeof OS.EOL === \"string\" ? OS.EOL : \"\\n\",\n    enumerable: true,\n    configurable: true,\n  });\n\n  Format.display = function (object: unknown, settings?: OutputSettingsLike): string {\n    if (object === void 0) {\n      return \"undefined\";\n    } else if (object === null) {\n      return \"null\";\n    } else if (typeof object === \"number\") {\n      return \"\" + object;\n    } else if (typeof object === \"string\") {\n      return object;\n    } else if (typeof (object as Display).display === \"function\") {\n      let output = Unicode.stringOutput(settings);\n      output = (object as Display).display(output);\n      return output.bind();\n    } else {\n      return \"\" + object;\n    }\n  };\n\n  Format.debug = function (object: unknown, settings?: OutputSettingsLike): string {\n    if (object === void 0) {\n      return \"undefined\";\n    } else if (object === null) {\n      return \"null\";\n    } else if (typeof object === \"number\") {\n      return \"\" + object;\n    } else if (typeof object === \"string\") {\n      let output = Unicode.stringOutput(settings);\n      output = Format.debugString(output, object);\n      return output.bind();\n    } else if (typeof (object as Debug).debug === \"function\") {\n      let output = Unicode.stringOutput(settings);\n      output = (object as Debug).debug(output);\n      return output.bind();\n    } else {\n      return \"\" + object;\n    }\n  };\n\n  Format.displayAny = function <T>(output: Output<T>, object: unknown): Output<T> {\n    if (object === void 0) {\n      output = output.write(\"undefined\");\n    } else if (object === null) {\n      output = output.write(\"null\");\n    } else if (typeof object === \"number\") {\n      output = Format.displayNumber(output, object);\n    } else if (typeof object === \"string\") {\n      output = output.write(object);\n    } else if (typeof (object as Display).display === \"function\") {\n      output = (object as Display).display(output);\n    } else {\n      output = output.write(\"\" + object);\n    }\n    return output;\n  };\n\n  Format.debugAny = function <T>(output: Output<T>, object: unknown): Output<T> {\n    if (object === void 0) {\n      output = output.write(\"undefined\");\n    } else if (object === null) {\n      output = output.write(\"null\");\n    } else if (typeof object === \"number\") {\n      output = Format.debugNumber(output, object);\n    } else if (typeof object === \"string\") {\n      output = Format.debugString(output, object);\n    } else if (typeof (object as Debug).debug === \"function\") {\n      output = (object as Debug).debug(output);\n    } else {\n      output = output.write(\"\" + object);\n    }\n    return output;\n  };\n\n  Format.displayNumber = function <T>(output: Output<T>, value: number): Output<T> {\n    if (isFinite(value) && Math.floor(value) === value && Math.abs(value) < 2147483648) {\n      if (value < 0) {\n        output = output.write(45/*'-'*/);\n      }\n      if (value > -10 && value < 10) {\n        output = output.write(48/*'0'*/ + Math.abs(value));\n      } else {\n        const digits = new Array<number>(19);\n        let x = value;\n        let i = 18;\n        while (x !== 0) {\n          digits[i] = Math.abs((x % 10) | 0);\n          x = (x / 10) | 0;\n          i -= 1;\n        }\n        i += 1;\n        while (i < 19) {\n          output = output.write(48/*'0'*/ + digits[i]!);\n          i += 1;\n        }\n      }\n    } else {\n      output = output.write(Format.decimal(value, output.settings.precision));\n    }\n    return output;\n  };\n\n  Format.debugNumber = function <T>(output: Output<T>, value: number): Output<T> {\n    return Format.displayNumber(output, value);\n  };\n\n  Format.debugChar = function <T>(output: Output<T>, value: number): Output<T> {\n    output = output.write(39/*'\\''*/);\n    switch (value) {\n      case 8/*'\\b'*/: output.write(92/*'\\\\'*/).write(98/*'b'*/); break;\n      case 9/*'\\t'*/: output.write(92/*'\\\\'*/).write(116/*'t'*/); break;\n      case 10/*'\\n'*/: output.write(92/*'\\\\'*/).write(110/*'n'*/); break;\n      case 12/*'\\f'*/: output.write(92/*'\\\\'*/).write(102/*'f'*/); break;\n      case 13/*'\\r'*/: output.write(92/*'\\\\'*/).write(114/*'r'*/); break;\n      case 34/*'\\\"'*/: output.write(92/*'\\\\'*/).write(34/*'\\\"'*/); break;\n      case 39/*'\\\"'*/: output.write(92/*'\\\\'*/).write(39/*'\\''*/); break;\n      case 92/*'\\\\'*/: output.write(92/*'\\\\'*/).write(92/*'\\\\'*/); break;\n      default:\n        if (value >= 0x0000 && value <= 0x001f || value >= 0x007f && value <= 0x009f) {\n          output = output.write(92/*'\\\\'*/).write(117/*'u'*/)\n                         .write(Format.encodeHex(value >>> 12 & 0xf))\n                         .write(Format.encodeHex(value >>>  8 & 0xf))\n                         .write(Format.encodeHex(value >>>  4 & 0xf))\n                         .write(Format.encodeHex(value        & 0xf));\n        } else {\n          output = output.write(value);\n        }\n    }\n    output = output.write(39/*'\\''*/);\n    return output;\n  };\n\n  Format.debugString = function <T>(output: Output<T>, string: string): Output<T> {\n    output = output.write(34/*'\\\"'*/);\n    let input = Unicode.stringInput(string);\n    while (input.isCont()) {\n      const c = input.head();\n      switch (c) {\n        case 8/*'\\b'*/: output.write(92/*'\\\\'*/).write(98/*'b'*/); break;\n        case 9/*'\\t'*/: output.write(92/*'\\\\'*/).write(116/*'t'*/); break;\n        case 10/*'\\n'*/: output.write(92/*'\\\\'*/).write(110/*'n'*/); break;\n        case 12/*'\\f'*/: output.write(92/*'\\\\'*/).write(102/*'f'*/); break;\n        case 13/*'\\r'*/: output.write(92/*'\\\\'*/).write(114/*'r'*/); break;\n        case 34/*'\\\"'*/: output.write(92/*'\\\\'*/).write(34/*'\\\"'*/); break;\n        case 92/*'\\\\'*/: output.write(92/*'\\\\'*/).write(92/*'\\\\'*/); break;\n        default:\n          if (c >= 0x0000 && c <= 0x001f || c >= 0x007f && c <= 0x009f) {\n            output = output.write(92/*'\\\\'*/).write(117/*'u'*/)\n                           .write(Format.encodeHex(c >>> 12 & 0xf))\n                           .write(Format.encodeHex(c >>>  8 & 0xf))\n                           .write(Format.encodeHex(c >>>  4 & 0xf))\n                           .write(Format.encodeHex(c        & 0xf));\n          } else {\n            output = output.write(c);\n          }\n      }\n      input = input.step();\n    }\n    output = output.write(34/*'\\\"'*/);\n    return output;\n  };\n\n  Format.encodeHex = function (x: number): number {\n    if (x < 10) {\n      return 48/*'0'*/ + x;\n    } else {\n      return 65/*'A'*/ + (x - 10);\n    }\n  };\n\n  Format.prefix = (function () {\n    const prefixes: readonly string[] = [\"y\", \"z\", \"a\", \"f\", \"p\", \"n\", String.fromCharCode(0x03BC/*'µ'*/), \"m\", \"\", \"k\", \"M\", \"G\", \"T\", \"P\", \"E\",\" Z\", \"Y\"];\n    return function (value: number, precision: number = 1): string {\n      if (isFinite(value)) {\n        const exponential = Math.abs(value).toExponential();\n        const exponentIndex = exponential.indexOf(\"e\");\n        const exponent = exponentIndex >= 0 ? +exponential.slice(exponentIndex + 1) : NaN;\n        const power = Math.min(Math.max(-8, Math.floor(exponent / 3)), 8) * 3;\n        const scaled = Math.pow(10, -power) * value;\n        let s = Format.trimTrailingZeros(Math.abs(scaled).toFixed(precision));\n        if (scaled < 0 && +s !== 0) {\n          s = \"-\" + s;\n        }\n        s += prefixes[8 + power / 3];\n        return s;\n      } else {\n        return \"\" + value;\n      }\n    };\n  })();\n\n  Format.decimal = function (value: number, precision: number = -1): string {\n    if (precision >= 0) {\n      let s = Format.trimTrailingZeros(Math.abs(value).toFixed(precision));\n      if (value < 0 && +s !== 0) {\n        s = \"-\" + s;\n      }\n      return s;\n    } else {\n      return \"\" + value;\n    }\n  };\n\n  Format.trimTrailingZeros = function (s: string): string {\n    let i0 = -1;\n    let i1: number | undefined;\n    for (let i = 1; i < s.length; i += 1) {\n      const c = s.charCodeAt(i);\n      if (c === 46/*'.'*/) {\n        i0 = i; // candidate start of trailing zeros\n        i1 = i; // candidate end of trailing zeros\n      } else if (c === 48/*'0'*/) {\n        if (i0 === 0) { // if after decimal\n          i0 = i; // new candidate start of trailing zeros\n        }\n        i1 = i; // new candidate end of trailing zeros\n      } else if (c >= 49/*'1'*/ && c <= 57/*'9'*/) {\n        if (i0 > 0) { // if non-zero digit after decimal\n          i0 = 0; // no candidate start of trailing zeros\n        }\n      } else if (i0 > 0) { // if non-numeric character after decimal\n        break; // accept current range of trailing zeros\n      }\n    }\n    if (i0 > 0) {\n      s = s.slice(0, i0) + s.slice(i1! + 1); // cut out trailing zeros\n    }\n    return s;\n  };\n\n  Format.duration = function (millis: number, separator: string = \" \"): string {\n    if (isFinite(millis)) {\n      const SECOND = 1000;\n      const MINUTE = 60 * SECOND;\n      const HOUR = 60 * MINUTE;\n      const DAY = 24 * HOUR;\n      const WEEK = 7 * DAY;\n      let weeks: number | undefined;\n      if (millis > WEEK) {\n        weeks = Math.floor(millis / WEEK);\n        millis %= WEEK;\n      }\n      let days: number | undefined;\n      if (millis > DAY) {\n        days = Math.floor(millis / DAY);\n        millis %= DAY;\n      }\n      let hours: number | undefined;\n      if (millis > HOUR) {\n        hours = Math.floor(millis / HOUR);\n        millis %= HOUR;\n      }\n      let minutes: number | undefined;\n      if (millis > MINUTE) {\n        minutes = Math.floor(millis / MINUTE);\n        millis %= MINUTE;\n      }\n      let seconds: number | undefined;\n      if (millis > SECOND) {\n        seconds = Math.floor(millis / SECOND);\n        millis %= SECOND;\n      }\n      let s = \"\";\n      if (weeks !== void 0) {\n        s += weeks + \"w\";\n      }\n      if (days !== void 0) {\n        s += (s.length !== 0 ? separator : \"\") + days + \"d\";\n      }\n      if (hours !== void 0) {\n        s += (s.length !== 0 ? separator : \"\") + hours + \"h\";\n      }\n      if (minutes !== void 0) {\n        s += (s.length !== 0 ? separator : \"\") + minutes + \"m\";\n      }\n      if (seconds !== void 0 || millis === 0) {\n        s += (s.length !== 0 ? separator : \"\") + (seconds !== void 0 ? seconds : 0) + \"s\";\n      }\n      if (millis !== 0 && s.length === 0) {\n        s += millis + \"ms\";\n      }\n      return s;\n    } else {\n      return \"\" + millis;\n    }\n  };\n\n  return Format;\n})();\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {Input} from \"../input/Input\";\nimport type {Output} from \"../output/Output\";\nimport type {Parser} from \"../parser/Parser\";\nimport type {Writer} from \"../writer/Writer\";\nimport {Format} from \"../format/Format\";\nimport {Unicode} from \"../unicode/Unicode\";\nimport {Base10NumberParser} from \"../\"; // forward import\nimport {Base10IntegerWriter} from \"../\"; // forward import\n\n/**\n * Base-10 (decimal) encoding [[Parser]]/[[Writer]] factory.\n * @public\n */\nexport const Base10 = (function () {\n  const Base10 = {} as {\n    /**\n     * Returns `true` if the Unicode code point `c` is a valid base-10 digit.\n     */\n    isDigit(c: number): boolean;\n\n    /**\n     * Returns the decimal quantity between `0` (inclusive) and `10` (exclusive)\n     * represented by the base-10 digit `c`.\n     *\n     * @throws `Error` if `c` is not a valid base-10 digit.\n     */\n    decodeDigit(c: number): number;\n\n    /**\n     * Returns the Unicode code point of the base-10 digit that encodes the given\n     * decimal quantity between `0` (inclusive) and `10` (exclusive).\n     */\n    encodeDigit(b: number): number;\n\n    /**\n     * Returns the number of whole decimal digits in the given absolute `value`.\n     */\n    countDigits(value: number): number;\n\n    integerParser(): Parser<number>;\n\n    parseInteger(input: Input): Parser<number>;\n\n    decimalParser(): Parser<number>;\n\n    parseDecimal(input: Input): Parser<number>;\n\n    numberParser(): Parser<number>;\n\n    parseNumber(input: Input): Parser<number>;\n\n    /**\n     * Returns a `Writer` that, when fed an input `number` value, returns a\n     * continuation that writes the base-10 (decimal) encoding of the input value.\n     */\n    integerWriter(): Writer<number, unknown>;\n\n    /**\n     * Returns a `Writer` continuation that writes the base-10 (decimal) encoding\n     * of the `input` value.\n     */\n    integerWriter(input: number): Writer<unknown, number>;\n\n    /**\n     * Writes the base-10 (decimal) encoding of the `input` value to the `output`,\n     * returning a `Writer` continuation that knows how to write any remaining\n     * output that couldn't be immediately generated.\n     */\n    writeInteger(output: Output, input: number): Writer;\n  };\n\n  Base10.isDigit = function (c: number): boolean {\n    return c >= 48/*'0'*/ && c <= 57/*'9'*/;\n  };\n\n  Base10.decodeDigit = function (c: number): number {\n    if (c >= 48/*'0'*/ && c <= 57/*'9'*/) {\n      return c - 48/*'0'*/;\n    } else {\n      let message = Unicode.stringOutput();\n      message = message.write(\"Invalid base-10 digit: \");\n      message = Format.debugChar(message, c);\n      throw new Error(message.bind());\n    }\n  };\n\n  Base10.encodeDigit = function (b: number): number {\n    if (b >= 0 && b <= 9) {\n      return 48/*'0'*/ + b;\n    } else {\n      throw new Error(\"\" + b);\n    }\n  };\n\n  Base10.countDigits = function (value: number): number {\n    let size = 0;\n    do {\n      size += 1;\n      value = (value / 10) | 0;\n    } while (value !== 0);\n    return size;\n  };\n\n  Base10.integerParser = function (): Parser<number> {\n    return new Base10NumberParser(void 0, void 0, 0);\n  };\n\n  Base10.parseInteger = function (input: Input): Parser<number> {\n    return Base10NumberParser.parse(input, void 0, void 0, 0);\n  };\n\n  Base10.decimalParser = function (): Parser<number> {\n    return new Base10NumberParser(void 0, void 0, 1);\n  };\n\n  Base10.parseDecimal = function (input: Input): Parser<number> {\n    return Base10NumberParser.parse(input, void 0, void 0, 1);\n  };\n\n  Base10.numberParser = function (): Parser<number> {\n    return new Base10NumberParser();\n  };\n\n  Base10.parseNumber = function (input: Input): Parser<number> {\n    return Base10NumberParser.parse(input);\n  };\n\n  Base10.integerWriter = function (input?: number): Writer {\n    if (input === void 0) {\n      return new Base10IntegerWriter(void 0, 0);\n    } else {\n      return new Base10IntegerWriter(void 0, input);\n    }\n  } as typeof Base10.integerWriter;\n\n  Base10.writeInteger = function (output: Output, input: number): Writer {\n    return Base10IntegerWriter.write(output, void 0, input);\n  };\n\n  return Base10;\n})();\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {Values} from \"@swim/util\";\nimport {Severity} from \"@swim/util\";\nimport type {Tag} from \"./Tag\";\nimport type {Mark} from \"./Mark\";\nimport type {Input} from \"../input/Input\";\nimport type {OutputSettings} from \"../output/OutputSettings\";\nimport type {Output} from \"../output/Output\";\nimport type {Display} from \"../format/Display\";\nimport {OutputStyle} from \"../format/OutputStyle\";\nimport {Format} from \"../format/Format\";\nimport {Unicode} from \"../unicode/Unicode\";\nimport {Base10} from \"../number/Base10\";\n\n/**\n * Informational message attached to an input location.\n * @public\n */\nexport class Diagnostic implements Display {\n  constructor(input: Input, tag: Tag, severity: Severity, message: string | undefined,\n              note: string | undefined, cause: Diagnostic | null) {\n    this.input = input;\n    this.tag = tag;\n    this.severity = severity;\n    this.message = message;\n    this.note = note;\n    this.cause = cause;\n  }\n\n  /** @internal */\n  readonly input: Input;\n\n  /**\n   * The location in the `input` to which this diagnostic is attached.\n   */\n  readonly tag: Tag;\n\n  /**\n   * The level of importance of this diagnostic.\n   */\n  readonly severity: Severity;\n\n  /**\n   * The help message that describes this diagnostic.\n   */\n  readonly message: string | undefined;\n\n  /**\n   * An informative comment on the source context to which this diagnostic is attached.\n   */\n  readonly note: string | undefined;\n\n  /**\n   * The `Diagnostic` cause of this diagnostic, forming a linked chain of\n   * diagnostics, or `null` if this diagnostic has no cause.\n   */\n  readonly cause: Diagnostic | null;\n\n  private lineDigits(): number {\n    let digits = Base10.countDigits(this.tag.end.line);\n    if (this.cause !== null) {\n      digits = Math.max(digits, this.cause.lineDigits());\n    }\n    return digits;\n  }\n\n  display<T>(output: Output<T>): Output<T> {\n    const input = this.input.clone();\n    const start = this.tag.start;\n    const end = this.tag.end;\n    const severity = this.severity;\n    const message = this.message;\n    const note = this.note;\n    const cause = this.cause;\n    const contextLines = 2;\n    const lineDigits = this.lineDigits();\n    output = Diagnostic.display(output, input, start, end, severity, message,\n                                note, cause, contextLines, lineDigits);\n    return output;\n  }\n\n  private static display<T>(output: Output<T>, input: Input, start: Mark, end: Mark,\n                            severity: Severity, message: string | undefined,\n                            note: string | undefined, cause: Diagnostic | null,\n                            contextLines: number, lineDigits: number): Output<T> {\n    do {\n      if (message !== void 0) {\n        output = Diagnostic.displayMessage(output, severity, message);\n        output = output.writeln();\n      }\n      output = Diagnostic.displayAnchor(output, input, start, lineDigits);\n      output = output.writeln();\n      const cont = Diagnostic.displayContext(output, input, start, end, severity,\n                                             note, cause, contextLines, lineDigits);\n      const next = cont[0];\n      output = cont[1];\n      if (next !== null) {\n        output = output.writeln();\n        input = next.input.clone();\n        start = next.tag.start;\n        end = next.tag.end;\n        severity = next.severity;\n        message = next.message;\n        note = next.note;\n        cause = next.cause;\n      } else {\n        break;\n      }\n    } while (true);\n    return output;\n  }\n\n  /** @internal */\n  static displayMessage<T>(output: Output<T>, severity: Severity, message: string | undefined): Output<T> {\n    output = Diagnostic.formatSeverity(output, severity);\n    output = output.write(severity.label);\n    output = OutputStyle.reset(output);\n    output = OutputStyle.bold(output);\n    output = output.write(58/*':'*/);\n    if (message !== void 0) {\n      output = output.write(32/*' '*/).write(message);\n    }\n    output = OutputStyle.reset(output);\n    return output;\n  }\n\n  private static displayAnchor<T>(output: Output<T>, input: Input,\n                                  start: Mark, lineDigits: number): Output<T> {\n    output = Diagnostic.displayLineLeadArrow(output, lineDigits);\n    output = output.write(32/*' '*/);\n    const id = input.id;\n    if (id !== void 0) {\n      output = Format.displayAny(output, id);\n    }\n    output = output.write(58/*':'*/);\n    output = Format.displayNumber(output, start.line);\n    output = output.write(58/*':'*/);\n    output = Format.displayNumber(output, start.column);\n    output = output.writeln();\n\n    output = Diagnostic.displayLineLead(output, lineDigits);\n    return output;\n  }\n\n  private static displayContext<T>(output: Output<T>, input: Input, start: Mark, end: Mark,\n                                   severity: Severity, note: string | undefined,\n                                   cause: Diagnostic | null, contextLines: number,\n                                   lineDigits: number): [Diagnostic | null, Output<T>] {\n    let next = cause;\n    const sameCause = cause !== null && cause.message === void 0 && Values.equal(input.id, cause.input.id);\n    const causeOrder = sameCause ? (start.offset <= cause!.tag.start.offset ? -1 : 1) : 0;\n    if (causeOrder === 1) {\n      const cont = Diagnostic.displayContext(output, cause!.input.clone(), cause!.tag.start,\n                                             cause!.tag.end, cause!.severity, cause!.note,\n                                             cause!.cause, contextLines, lineDigits);\n      next = cont[0];\n      output = cont[1];\n      output = output.writeln();\n      output = Diagnostic.displayLineLeadEllipsis(output, lineDigits);\n      output = output.writeln();\n    }\n    output = Diagnostic.displayLines(output, input, start, end, severity, contextLines, lineDigits);\n    if (note !== void 0) {\n      output = Diagnostic.displayNote(output, note, lineDigits);\n    }\n    if (causeOrder === -1) {\n      output = output.writeln();\n      output = Diagnostic.displayLineLeadEllipsis(output, lineDigits);\n      output = output.writeln();\n      const cont = Diagnostic.displayContext(output, cause!.input.clone(), cause!.tag.start,\n                                             cause!.tag.end, cause!.severity, cause!.note,\n                                             cause!.cause, contextLines, lineDigits);\n      next = cont[0];\n      output = cont[1];\n    }\n    return [next, output];\n  }\n\n  private static displayLines<T>(output: Output<T>, input: Input, start: Mark, end: Mark,\n                                 severity: Severity, contextLines: number,\n                                 lineDigits: number): Output<T> {\n    const startLine = start.line;\n    const endLine = end.line;\n    let line = input.line;\n\n    while (line < startLine) {\n      Diagnostic.consumeLineText(input, line);\n      line += 1;\n    }\n\n    if (endLine - startLine > 2 * contextLines + 2) {\n      while (line <= startLine + contextLines) {\n        output = Diagnostic.displayLine(output, input, start, end, severity, line, lineDigits);\n        line += 1;\n      }\n      output = Diagnostic.displayLineLeadEllipsis(output, lineDigits);\n      output = output.write(32/*' '*/);\n      output = Diagnostic.formatSeverity(output, severity);\n      output = output.write(124/*'|'*/);\n      output = OutputStyle.reset(output);\n      output = output.writeln();\n      while (line < endLine - contextLines) {\n        Diagnostic.consumeLineText(input, line);\n        line += 1;\n      }\n    }\n\n    while (line <= endLine) {\n      output = Diagnostic.displayLine(output, input, start, end, severity, line, lineDigits);\n      line += 1;\n    }\n    return output;\n  }\n\n  private static displayNote<T>(output: Output<T>, note: string | undefined, lineDigits: number): Output<T> {\n    output = output.writeln();\n    output = Diagnostic.displayLineLead(output, lineDigits);\n    output = output.writeln();\n    output = Diagnostic.displayLineComment(output, 'note', note, lineDigits);\n    return output;\n  }\n\n  private static displayLine<T>(output: Output<T>, input: Input, start: Mark, end: Mark,\n                                severity: Severity, line: number, lineDigits: number): Output<T> {\n    if (start.line === line && end.line === line) {\n      output = Diagnostic.displaySingleLine(output, input, start, end, severity, line, lineDigits);\n    } else if (start.line === line) {\n      output = Diagnostic.displayStartLine(output, input, start, severity, line, lineDigits);\n    } else if (end.line === line) {\n      output = Diagnostic.displayEndLine(output, input, end, severity, line, lineDigits);\n    } else {\n      output = Diagnostic.displayMidLine(output, input, severity, line, lineDigits);\n    }\n    return output;\n  }\n\n  private static displaySingleLine<T>(output: Output<T>, input: Input, start: Mark, end: Mark,\n                                      severity: Severity, line: number, lineDigits: number): Output<T> {\n    output = Diagnostic.displayLineLeadNumber(output, line, lineDigits);\n    output = output.write(32/*' '*/);\n    for (let i = 1; i < input.column; i += 1) {\n      output = output.write(32/*' '*/);\n    }\n    output = Diagnostic.displayLineText(output, input, line);\n\n    output = Diagnostic.displayLineLead(output, lineDigits);\n    output = output.write(32/*' '*/);\n    let i = 1;\n    while (i < start.column) {\n      output = output.write(32/*' '*/);\n      i += 1;\n    }\n    output = Diagnostic.formatSeverity(output, severity);\n    while (i <= end.column) {\n      output = output.write(94/*'^'*/);\n      i += 1;\n    }\n    if (end.note !== void 0) {\n      output = output.write(32/*' '*/).write(end.note);\n    }\n    output = OutputStyle.reset(output);\n    return output;\n  }\n\n  private static displayStartLine<T>(output: Output<T>, input: Input, start: Mark,\n                                     severity: Severity, line: number, lineDigits: number): Output<T> {\n    output = Diagnostic.displayLineLeadNumber(output, line, lineDigits);\n    output = output.write(32/*' '*/).write(32/*' '*/).write(32/*' '*/);\n    for (let i = 1; i < input.column; i += 1) {\n      output = output.write(32/*' '*/);\n    }\n    output = Diagnostic.displayLineText(output, input, line);\n\n    output = Diagnostic.displayLineLead(output, lineDigits);\n    output = output.write(32/*' '*/).write(32/*' '*/);\n    output = Diagnostic.formatSeverity(output, severity);\n    output = output.write(95/*'_'*/);\n    let i = 1;\n    while (i < start.column) {\n      output = output.write(95/*'_'*/);\n      i += 1;\n    }\n    output = output.write(94/*'^'*/);\n    if (start.note !== void 0) {\n      output = output.write(32/*' '*/).write(start.note);\n    }\n    output = OutputStyle.reset(output);\n    output = output.writeln();\n    return output;\n  }\n\n  private static displayEndLine<T>(output: Output<T>, input: Input, end: Mark,\n                                   severity: Severity, line: number, lineDigits: number): Output<T> {\n    output = Diagnostic.displayLineLeadNumber(output, line, lineDigits);\n    output = output.write(32/*' '*/);\n    output = Diagnostic.formatSeverity(output, severity);\n    output = output.write(124/*'|'*/);\n    output = OutputStyle.reset(output);\n    output = output.write(32/*' '*/);\n    output = Diagnostic.displayLineText(output, input, line);\n\n    output = Diagnostic.displayLineLead(output, lineDigits);\n    output = output.write(32/*' '*/);\n    output = Diagnostic.formatSeverity(output, severity);\n    output = output.write(124/*'|'*/).write(95/*'_'*/);\n    let i = 1;\n    while (i < end.column) {\n      output = output.write(95/*'_'*/);\n      i += 1;\n    }\n    output = output.write(94/*'^'*/);\n    if (end.note !== void 0) {\n      output = output.write(32/*' '*/).write(end.note);\n    }\n    output = OutputStyle.reset(output);\n    return output;\n  }\n\n  private static displayMidLine<T>(output: Output<T>, input: Input, severity: Severity,\n                                   line: number, lineDigits: number): Output<T> {\n    output = Diagnostic.displayLineLeadNumber(output, line, lineDigits);\n    output = output.write(32/*' '*/);\n    output = Diagnostic.formatSeverity(output, severity);\n    output = output.write(124/*'|'*/);\n    output = OutputStyle.reset(output);\n    output = output.write(32/*' '*/);\n    output = Diagnostic.displayLineText(output, input, line);\n    return output;\n  }\n\n  private static displayLineComment<T>(output: Output<T>, label: string,\n                                       comment: string | undefined, lineDigits: number): Output<T> {\n    output = Diagnostic.displayLineLeadComment(output, lineDigits);\n    output = output.write(32/*' '*/);\n    output = OutputStyle.bold(output);\n    output = output.write(label).write(58/*':'*/);\n    output = OutputStyle.reset(output);\n    if (comment !== void 0) {\n      output = output.write(32/*' '*/).write(comment);\n    }\n    return output;\n  }\n\n  private static displayLineLead<T>(output: Output<T>, lineDigits: number): Output<T> {\n    output = OutputStyle.blueBold(output);\n    const padding = 1 + lineDigits;\n    for (let i = 0; i < padding; i += 1) {\n      output = output.write(32/*' '*/);\n    }\n    output = output.write(124/*'|'*/);\n    output = OutputStyle.reset(output);\n    return output;\n  }\n\n  private static displayLineLeadComment<T>(output: Output<T>, lineDigits: number): Output<T> {\n    output = OutputStyle.blueBold(output);\n    const padding = 1 + lineDigits;\n    for (let i = 0; i < padding; i += 1) {\n      output = output.write(32/*' '*/);\n    }\n    output = output.write(61/*'='*/);\n    output = OutputStyle.reset(output);\n    return output;\n  }\n\n  private static displayLineLeadArrow<T>(output: Output<T>, lineDigits: number): Output<T> {\n    for (let i = 0; i < lineDigits; i += 1) {\n      output = output.write(32/*' '*/);\n    }\n    output = OutputStyle.blueBold(output);\n    output = output.write(45/*'-'*/).write(45/*'-'*/).write(62/*'>'*/);\n    output = OutputStyle.reset(output);\n    return output;\n  }\n\n  private static displayLineLeadEllipsis<T>(output: Output<T>, lineDigits: number): Output<T> {\n    output = OutputStyle.blueBold(output);\n    for (let i = 0; i < lineDigits; i += 1) {\n      output = output.write(46/*'.'*/);\n    }\n    output = OutputStyle.reset(output);\n    output = output.write(32/*' '*/).write(32/*' '*/);\n    return output;\n  }\n\n  private static displayLineLeadNumber<T>(output: Output<T>, line: number, lineDigits: number): Output<T> {\n    const padding = lineDigits - Base10.countDigits(line);\n    for (let i = 0; i < padding; i += 1) {\n      output = output.write(32/*' '*/);\n    }\n    output = OutputStyle.blueBold(output);\n    output = Format.displayNumber(output, line);\n    output = output.write(32/*' '*/).write(124/*'|'*/);\n    output = OutputStyle.reset(output);\n    return output;\n  }\n\n  private static displayLineText<T>(output: Output<T>, input: Input, line: number): Output<T> {\n    while (input.isCont() && input.line === line) {\n      output = output.write(input.head());\n      input = input.step();\n    }\n    if (input.line === line) {\n      output = output.writeln();\n    }\n    return output;\n  }\n\n  private static consumeLineText(input: Input, line: number): void {\n    while (input.isCont() && input.line === line) {\n      input = input.step();\n    }\n  }\n\n  private static formatSeverity<T>(output: Output<T>, severity: Severity): Output<T> {\n    switch (severity.level) {\n      case Severity.FatalLevel:\n      case Severity.AlertLevel:\n      case Severity.ErrorLevel:\n        output = OutputStyle.redBold(output);\n        break;\n      case Severity.WarningLevel:\n        output = OutputStyle.yellowBold(output);\n        break;\n      case Severity.NoteLevel:\n        output = OutputStyle.greenBold(output);\n        break;\n      case Severity.InfoLevel:\n        output = OutputStyle.cyanBold(output);\n        break;\n      case Severity.DebugLevel:\n      case Severity.TraceLevel:\n      default:\n        output = OutputStyle.magentaBold(output);\n    }\n    return output;\n  }\n\n  toString(settings?: OutputSettings): string {\n    return Format.display(this, settings);\n  }\n\n  static create(input: Input, tag: Tag, severity: Severity, cause?: Diagnostic | null): Diagnostic;\n  static create(input: Input, tag: Tag, severity: Severity, message: string | undefined,\n                cause?: Diagnostic | null): Diagnostic;\n  static create(input: Input, tag: Tag, severity: Severity, message: string | undefined,\n                note: string | undefined, cause?: Diagnostic | null): Diagnostic;\n  static create(input: Input, tag: Tag, severity: Severity, message?: Diagnostic | null | string | undefined,\n                note?: Diagnostic | null | string | undefined, cause?: Diagnostic | null): Diagnostic {\n    if (arguments.length === 3) { // (input, tag, severity)\n      cause = null;\n      note = void 0;\n      message = void 0;\n    } else if (arguments.length === 4) {\n      if (message === null || message instanceof Diagnostic) { // (input, tag, severity, cause)\n        cause = message;\n        message = void 0;\n      } else { // (input, tag, severity, message)\n        cause = null;\n      }\n    } else if (arguments.length === 5) {\n      if (note === null || note instanceof Diagnostic) { // (input, tag, severity, message, cause)\n        cause = note;\n        note = void 0;\n      } else { // (input, tag, severity, message, note)\n        cause = null;\n      }\n    } else { // (input, tag, severity, message, note, cause)\n      if (cause === void 0) {\n        cause = null;\n      }\n    }\n    return new Diagnostic(input.clone(), tag, severity, message as string | undefined, note as string | undefined, cause);\n  }\n\n  static message(message: string, input: Input, cause?: Diagnostic | null): Diagnostic;\n  static message(message: string, input: Input, note: string, cause?: Diagnostic | null): Diagnostic;\n  static message(message: string, input: Input, severity: Severity, cause?: Diagnostic | null): Diagnostic;\n  static message(message: string, input: Input, severity?: Severity, note?: string, cause?: Diagnostic | null): Diagnostic;\n  static message(message: string, input: Input, severity?: Diagnostic | null | Severity | string | undefined,\n                 note?: Diagnostic | null | string | undefined, cause?: Diagnostic | null): Diagnostic {\n    if (arguments.length === 2) { // (message, input)\n      cause = null;\n      note = void 0;\n      severity = Severity.error();\n    } else if (arguments.length === 3) {\n      if (severity === null || severity instanceof Diagnostic) { // (message, input, cause)\n        cause = severity;\n        severity = Severity.error();\n      } else if (typeof severity === \"string\") { // (message, input, note)\n        cause = null;\n        note = severity;\n        severity = Severity.error();\n      } else { // (message, input, severity)\n        cause = null;\n      }\n    } else if (arguments.length === 4) {\n      if (typeof severity === \"string\") { // (message, input, note, cause)\n        cause = note as Diagnostic | null;\n        note = severity;\n        severity = Severity.error();\n      } else if (note === null || note instanceof Diagnostic) { // (message, input, severity, cause)\n        cause = note;\n        note = void 0;\n      } else { // (message, input, severity, note)\n        cause = null;\n      }\n    } else { // (message, input, severity, note, cause)\n      if (cause === void 0) {\n        cause = null;\n      }\n    }\n\n    const mark = input.mark;\n    const source = input.clone();\n    source.seek();\n    return new Diagnostic(source, mark, severity as Severity, message, note as string | undefined, cause);\n  }\n\n  static unexpected(input: Input, cause?: Diagnostic | null): Diagnostic;\n  static unexpected(input: Input, note: string, cause?: Diagnostic | null): Diagnostic;\n  static unexpected(input: Input, severity: Severity, cause?: Diagnostic | null): Diagnostic;\n  static unexpected(input: Input, severity?: Severity, note?: string, cause?: Diagnostic | null): Diagnostic;\n  static unexpected(input: Input, severity?: Diagnostic | null | Severity | string | undefined,\n                    note?: Diagnostic | null | string | undefined, cause?: Diagnostic | null): Diagnostic {\n    if (arguments.length === 1) { // (input)\n      cause = null;\n      severity = Severity.error();\n    } else if (arguments.length === 2) {\n      if (severity === null || severity instanceof Diagnostic) { // (input, cause)\n        cause = severity;\n        severity = Severity.error();\n      } else if (typeof severity === \"string\") { // (input, note)\n        cause = null;\n        note = severity;\n        severity = Severity.error();\n      } else { // (input, severity)\n        cause = null;\n      }\n    } else if (arguments.length === 3) {\n      if (typeof severity === \"string\") { // (input, note, cause)\n        cause = note as Diagnostic | null;\n        note = severity;\n        severity = Severity.error();\n      } else if (note === null || note instanceof Diagnostic) { // (input, severity, cause)\n        cause = note;\n        note = void 0;\n      } else { // (input, severity, note)\n        cause = null;\n      }\n    } else { // (input, severity, note, cause)\n      if (cause === void 0) {\n        cause = null;\n      }\n    }\n\n    let message;\n    if (input.isCont()) {\n      let output = Unicode.stringOutput().write(\"unexpected\").write(32/*' '*/);\n      output = Format.debugChar(output, input.head());\n      message = output.bind();\n    } else {\n      message = \"unexpected end of input\";\n    }\n    const mark = input.mark;\n    const source = input.clone();\n    source.seek();\n    return new Diagnostic(source, mark, severity as Severity, message, note as string | undefined, cause);\n  }\n\n  static expected(expected: string | number, input: Input, cause?: Diagnostic | null): Diagnostic;\n  static expected(expected: string | number, input: Input, note: string, cause?: Diagnostic | null): Diagnostic;\n  static expected(expected: string | number, input: Input, severity: Severity, cause?: Diagnostic | null): Diagnostic;\n  static expected(expected: string | number, input: Input, severity?: Severity, note?: string, cause?: Diagnostic | null): Diagnostic;\n  static expected(expected: string | number, input: Input, severity?: Diagnostic | null | Severity | string | undefined,\n                  note?: Diagnostic | null | string | undefined, cause?: Diagnostic | null): Diagnostic {\n    if (arguments.length === 2) { // (excpected, input)\n      cause = null;\n      severity = Severity.error();\n    } else if (arguments.length === 3) {\n      if (severity === null || severity instanceof Diagnostic) { // (excpected, input, cause)\n        cause = severity;\n        severity = Severity.error();\n      } else if (typeof severity === \"string\") { // (excpected, input, note)\n        cause = null;\n        note = severity;\n        severity = Severity.error();\n      } else { // (expected, input, severity)\n        cause = null;\n      }\n    } else if (arguments.length === 4) {\n      if (typeof severity === \"string\") { // (excpected, input, note, cause)\n        cause = note as Diagnostic | null;\n        note = severity;\n        severity = Severity.error();\n      } else if (note === null || note instanceof Diagnostic) { // (excpected, input, severity, cause)\n        cause = note;\n        note = void 0;\n      } else { // (excpected, input, severity, note)\n        cause = null;\n      }\n    } else { // (excpected, input, severity, note, cause)\n      if (cause === void 0) {\n        cause = null;\n      }\n    }\n\n    let output = Unicode.stringOutput().write(\"expected\").write(32/*' '*/);\n    if (typeof expected === \"number\") {\n      output = Format.debugChar(output, expected);\n    } else {\n      output = output.write(expected);\n    }\n    output = output.write(44/*','*/).write(32/*' '*/).write(\"but found\").write(32/*' '*/);\n    if (input.isCont()) {\n      output = Format.debugChar(output, input.head());\n    } else {\n      output = output.write(\"end of input\");\n    }\n    const message = output.bind();\n    const mark = input.mark;\n    const source = input.clone();\n    source.seek();\n    return new Diagnostic(source, mark, severity as Severity, message, note as string | undefined, cause);\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {Mark} from \"../source/Mark\";\nimport {InputException} from \"./InputException\";\nimport type {InputSettingsLike} from \"./InputSettings\";\nimport {InputSettings} from \"./InputSettings\";\nimport {Input} from \"./Input\";\nimport {InputDone} from \"../\"; // forward import\nimport {InputError} from \"../\"; // forward import\n\n/** @internal */\nexport class InputEmpty extends Input {\n  constructor(id: string | undefined, mark: Mark, settings: InputSettings) {\n    super();\n    Object.defineProperty(this, \"id\", {\n      value: id,\n      enumerable: true,\n    });\n    Object.defineProperty(this, \"mark\", {\n      value: mark,\n      enumerable: true,\n    });\n    Object.defineProperty(this, \"settings\", {\n      value: settings,\n      enumerable: true,\n    });\n  }\n\n  override isCont(): boolean {\n    return false;\n  }\n\n  override isEmpty(): boolean {\n    return true;\n  }\n\n  override isDone(): boolean {\n    return false;\n  }\n\n  override isError(): boolean {\n    return false;\n  }\n\n  override isPart(): boolean {\n    return true;\n  }\n\n  override asPart(part: boolean): Input {\n    return part ? this : new InputDone(this.id, this.mark, this.settings);\n  }\n\n  override head(): number {\n    throw new InputException();\n  }\n\n  override step(): Input {\n    const error = new InputException(\"empty step\");\n    return new InputError(error, this.id, this.mark, this.settings);\n  }\n\n  override seek(mark?: Mark): Input {\n    const error = new InputException(\"empty seek\");\n    return new InputError(error, this.id, this.mark, this.settings);\n  }\n\n  override readonly id!: string | undefined;\n\n  override withId(id: string | undefined): Input {\n    return new InputEmpty(id, this.mark, this.settings);\n  }\n\n  override readonly mark!: Mark;\n\n  override withMark(mark: Mark): Input {\n    return new InputEmpty(this.id, mark, this.settings);\n  }\n\n  override get offset(): number {\n    return this.mark.offset;\n  }\n\n  override get line(): number {\n    return this.mark.line;\n  }\n\n  override get column(): number {\n    return this.mark.column;\n  }\n\n  override readonly settings!: InputSettings;\n\n  override withSettings(settings: InputSettingsLike): Input {\n    settings = InputSettings.fromLike(settings);\n    return new InputEmpty(this.id, this.mark, settings);\n  }\n\n  override clone(): Input {\n    return this;\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {Mark} from \"../source/Mark\";\nimport {InputException} from \"./InputException\";\nimport type {InputSettingsLike} from \"./InputSettings\";\nimport {InputSettings} from \"./InputSettings\";\nimport {Input} from \"./Input\";\nimport {InputEmpty} from \"../\"; // forward import\nimport {InputError} from \"../\"; // forward import\n\n/** @internal */\nexport class InputDone extends Input {\n  constructor(id: string | undefined, mark: Mark, settings: InputSettings) {\n    super();\n    Object.defineProperty(this, \"id\", {\n      value: id,\n      enumerable: true,\n    });\n    Object.defineProperty(this, \"mark\", {\n      value: mark,\n      enumerable: true,\n    });\n    Object.defineProperty(this, \"settings\", {\n      value: settings,\n      enumerable: true,\n    });\n  }\n\n  override isCont(): boolean {\n    return false;\n  }\n\n  override isEmpty(): boolean {\n    return false;\n  }\n\n  override isDone(): boolean {\n    return true;\n  }\n\n  override isError(): boolean {\n    return false;\n  }\n\n  override isPart(): boolean {\n    return false;\n  }\n\n  override asPart(part: boolean): Input {\n    return part ? new InputEmpty(this.id, this.mark, this.settings) : this;\n  }\n\n  override head(): number {\n    throw new InputException();\n  }\n\n  override step(): Input {\n    const error = new InputException(\"done step\");\n    return new InputError(error, this.id, this.mark, this.settings);\n  }\n\n  override seek(mark?: Mark): Input {\n    const error = new InputException(\"empty seek\");\n    return new InputError(error, this.id, this.mark, this.settings);\n  }\n\n  override readonly id!: string | undefined;\n\n  override withId(id: string | undefined): Input {\n    return new InputDone(id, this.mark, this.settings);\n  }\n\n  override readonly mark!: Mark;\n\n  override withMark(mark: Mark): Input {\n    return new InputDone(this.id, mark, this.settings);\n  }\n\n  override get offset(): number {\n    return this.mark.offset;\n  }\n\n  override get line(): number {\n    return this.mark.line;\n  }\n\n  override get column(): number {\n    return this.mark.column;\n  }\n\n  override readonly settings!: InputSettings;\n\n  override withSettings(settings: InputSettingsLike): Input {\n    settings = InputSettings.fromLike(settings);\n    return new InputDone(this.id, this.mark, settings);\n  }\n\n  override clone(): Input {\n    return this;\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {Lazy} from \"@swim/util\";\nimport {Mark} from \"../source/Mark\";\nimport type {InputSettingsLike} from \"./InputSettings\";\nimport {InputSettings} from \"./InputSettings\";\nimport {Input} from \"./Input\";\nimport {InputBufferEmpty} from \"../\"; // forward import\nimport {InputBufferDone} from \"../\"; // forward import\nimport {InputBufferError} from \"../\"; // forward import\n\n/**\n * Non-blocking token stream buffer.\n * @public\n */\nexport abstract class InputBuffer extends Input {\n  abstract override asPart(part: boolean): InputBuffer;\n\n  abstract readonly index: number;\n\n  abstract withIndex(index: number): InputBuffer;\n\n  abstract readonly limit: number;\n\n  abstract withLimit(limit: number): InputBuffer;\n\n  abstract readonly capacity: number;\n\n  abstract readonly remaining: number;\n\n  abstract has(index: number): boolean;\n\n  abstract get(index: number): number;\n\n  abstract set(index: number, token: number): void;\n\n  abstract override step(offset?: number): InputBuffer;\n\n  abstract override seek(mark: Mark): InputBuffer;\n\n  abstract override withId(id: string | undefined): InputBuffer;\n\n  abstract override withMark(mark: Mark): InputBuffer;\n\n  abstract override withSettings(settings: InputSettingsLike): InputBuffer;\n\n  abstract override clone(): InputBuffer;\n\n  /**\n   * Returns an `InputBuffer` in the _empty_ state.\n   */\n  @Lazy\n  static override empty(): InputBuffer {\n    return new InputBufferEmpty(void 0, Mark.zero, InputSettings.standard());\n  }\n\n  /**\n   * Returns an `InputBuffer` in the _done_ state.\n   */\n  @Lazy\n  static override done(): InputBuffer {\n    return new InputBufferDone(void 0, Mark.zero, InputSettings.standard());\n  }\n\n  /**\n   * Returns an `InputBuffer` in the _error_ state that traps the given `error`.\n   */\n  static override error(error: Error): InputBuffer {\n    return new InputBufferError(error, void 0, Mark.zero, InputSettings.standard());\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {Mark} from \"../source/Mark\";\nimport {InputException} from \"./InputException\";\nimport type {InputSettingsLike} from \"./InputSettings\";\nimport {InputSettings} from \"./InputSettings\";\nimport {InputBuffer} from \"./InputBuffer\";\nimport {InputBufferDone} from \"../\"; // forward import\nimport {InputBufferError} from \"../\"; // forward import\n\n/** @internal */\nexport class InputBufferEmpty extends InputBuffer {\n  constructor(id: string | undefined, mark: Mark, settings: InputSettings) {\n    super();\n    Object.defineProperty(this, \"id\", {\n      value: id,\n      enumerable: true,\n    });\n    Object.defineProperty(this, \"mark\", {\n      value: mark,\n      enumerable: true,\n    });\n    Object.defineProperty(this, \"settings\", {\n      value: settings,\n      enumerable: true,\n    });\n  }\n\n  override isCont(): boolean {\n    return false;\n  }\n\n  override isEmpty(): boolean {\n    return true;\n  }\n\n  override isDone(): boolean {\n    return false;\n  }\n\n  override isError(): boolean {\n    return false;\n  }\n\n  override isPart(): boolean {\n    return true;\n  }\n\n  override asPart(part: boolean): InputBuffer {\n    return part ? this : new InputBufferDone(this.id, this.mark, this.settings);\n  }\n\n  override get index(): number {\n    return 0;\n  }\n\n  override withIndex(index: number): InputBuffer {\n    if (index === 0) {\n      return this;\n    } else {\n      const error = new InputException(\"invalid index\");\n      return new InputBufferError(error, this.id, this.mark, this.settings);\n    }\n  }\n\n  override get limit(): number {\n    return 0;\n  }\n\n  override withLimit(limit: number): InputBuffer {\n    if (limit === 0) {\n      return this;\n    } else {\n      const error = new InputException(\"invalid limit\");\n      return new InputBufferError(error, this.id, this.mark, this.settings);\n    }\n  }\n\n  override get capacity(): number {\n    return 0;\n  }\n\n  override get remaining(): number {\n    return 0;\n  }\n\n  override has(index: number): boolean {\n    return false;\n  }\n\n  override get(index: number): number {\n    throw new InputException();\n  }\n\n  override set(index: number, token: number): void {\n    throw new InputException();\n  }\n\n  override head(): number {\n    throw new InputException();\n  }\n\n  override step(offset?: number): InputBuffer {\n    const error = new InputException(\"empty step\");\n    return new InputBufferError(error, this.id, this.mark, this.settings);\n  }\n\n  override seek(mark: Mark): InputBuffer {\n    const error = new InputException(\"empty seek\");\n    return new InputBufferError(error, this.id, this.mark, this.settings);\n  }\n\n  override readonly id!: string | undefined;\n\n  override withId(id: string | undefined): InputBuffer {\n    return new InputBufferEmpty(id, this.mark, this.settings);\n  }\n\n  override readonly mark!: Mark;\n\n  override withMark(mark: Mark): InputBuffer {\n    return new InputBufferEmpty(this.id, mark, this.settings);\n  }\n\n  override get offset(): number {\n    return this.mark.offset;\n  }\n\n  override get line(): number {\n    return this.mark.line;\n  }\n\n  override get column(): number {\n    return this.mark.column;\n  }\n\n  override readonly settings!: InputSettings;\n\n  override withSettings(settings: InputSettingsLike): InputBuffer {\n    settings = InputSettings.fromLike(settings);\n    return new InputBufferEmpty(this.id, this.mark, settings);\n  }\n\n  override clone(): InputBuffer {\n    return this;\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {Mark} from \"../source/Mark\";\nimport {InputException} from \"./InputException\";\nimport type {InputSettingsLike} from \"./InputSettings\";\nimport {InputSettings} from \"./InputSettings\";\nimport {InputBuffer} from \"./InputBuffer\";\nimport {InputBufferEmpty} from \"../\"; // forward import\nimport {InputBufferError} from \"../\"; // forward import\n\n/** @internal */\nexport class InputBufferDone extends InputBuffer {\n  constructor(id: string | undefined, mark: Mark, settings: InputSettings) {\n    super();\n    Object.defineProperty(this, \"id\", {\n      value: id,\n      enumerable: true,\n    });\n    Object.defineProperty(this, \"mark\", {\n      value: mark,\n      enumerable: true,\n    });\n    Object.defineProperty(this, \"settings\", {\n      value: settings,\n      enumerable: true,\n    });\n  }\n\n  override isCont(): boolean {\n    return false;\n  }\n\n  override isEmpty(): boolean {\n    return false;\n  }\n\n  override isDone(): boolean {\n    return true;\n  }\n\n  override isError(): boolean {\n    return false;\n  }\n\n  override isPart(): boolean {\n    return false;\n  }\n\n  override asPart(part: boolean): InputBuffer {\n    return part ? new InputBufferEmpty(this.id, this.mark, this.settings) : this;\n  }\n\n  override get index(): number {\n    return 0;\n  }\n\n  override withIndex(index: number): InputBuffer {\n    if (index === 0) {\n      return this;\n    } else {\n      const error = new InputException(\"invalid index\");\n      return new InputBufferError(error, this.id, this.mark, this.settings);\n    }\n  }\n\n  override get limit(): number {\n    return 0;\n  }\n\n  override withLimit(limit: number): InputBuffer {\n    if (limit === 0) {\n      return this;\n    } else {\n      const error = new InputException(\"invalid limit\");\n      return new InputBufferError(error, this.id, this.mark, this.settings);\n    }\n  }\n\n  override get capacity(): number {\n    return 0;\n  }\n\n  override get remaining(): number {\n    return 0;\n  }\n\n  override has(index: number): boolean {\n    return false;\n  }\n\n  override get(index: number): number {\n    throw new InputException();\n  }\n\n  override set(index: number, token: number): void {\n    throw new InputException();\n  }\n\n  override head(): number {\n    throw new InputException();\n  }\n\n  override step(offset?: number): InputBuffer {\n    const error = new InputException(\"done step\");\n    return new InputBufferError(error, this.id, this.mark, this.settings);\n  }\n\n  override seek(mark: Mark): InputBuffer {\n    const error = new InputException(\"done seek\");\n    return new InputBufferError(error, this.id, this.mark, this.settings);\n  }\n\n  override readonly id!: string | undefined;\n\n  override withId(id: string | undefined): InputBuffer {\n    return new InputBufferDone(id, this.mark, this.settings);\n  }\n\n  override readonly mark!: Mark;\n\n  override withMark(mark: Mark): InputBuffer {\n    return new InputBufferDone(this.id, mark, this.settings);\n  }\n\n  override get offset(): number {\n    return this.mark.offset;\n  }\n\n  override get line(): number {\n    return this.mark.line;\n  }\n\n  override get column(): number {\n    return this.mark.column;\n  }\n\n  override readonly settings!: InputSettings;\n\n  override withSettings(settings: InputSettingsLike): InputBuffer {\n    settings = InputSettings.fromLike(settings);\n    return new InputBufferDone(this.id, this.mark, settings);\n  }\n\n  override clone(): InputBuffer {\n    return this;\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {Mark} from \"../source/Mark\";\nimport {InputException} from \"./InputException\";\nimport type {InputSettingsLike} from \"./InputSettings\";\nimport {InputSettings} from \"./InputSettings\";\nimport {InputBuffer} from \"./InputBuffer\";\n\n/** @internal */\nexport class InputBufferError extends InputBuffer {\n  /** @internal */\n  readonly error!: Error;\n\n  constructor(error: Error, id: string | undefined, mark: Mark, settings: InputSettings) {\n    super();\n    Object.defineProperty(this, \"error\", {\n      value: error,\n      enumerable: true,\n    });\n    Object.defineProperty(this, \"id\", {\n      value: id,\n      enumerable: true,\n    });\n    Object.defineProperty(this, \"mark\", {\n      value: mark,\n      enumerable: true,\n    });\n    Object.defineProperty(this, \"settings\", {\n      value: settings,\n      enumerable: true,\n    });\n  }\n\n  override isCont(): boolean {\n    return false;\n  }\n\n  override isEmpty(): boolean {\n    return false;\n  }\n\n  override isDone(): boolean {\n    return false;\n  }\n\n  override isError(): boolean {\n    return true;\n  }\n\n  override isPart(): boolean {\n    return false;\n  }\n\n  override asPart(part: boolean): InputBuffer {\n    return this;\n  }\n\n  override get index(): number {\n    return 0;\n  }\n\n  override withIndex(index: number): InputBuffer {\n    if (index === 0) {\n      return this;\n    } else {\n      const error = new InputException(\"invalid index\");\n      return new InputBufferError(error, this.id, this.mark, this.settings);\n    }\n  }\n\n  override get limit(): number {\n    return 0;\n  }\n\n  override withLimit(limit: number): InputBuffer {\n    if (limit === 0) {\n      return this;\n    } else {\n      const error = new InputException(\"invalid limit\");\n      return new InputBufferError(error, this.id, this.mark, this.settings);\n    }\n  }\n\n  override get capacity(): number {\n    return 0;\n  }\n\n  override get remaining(): number {\n    return 0;\n  }\n\n  override has(index: number): boolean {\n    return false;\n  }\n\n  override get(index: number): number {\n    throw new InputException();\n  }\n\n  override set(index: number, token: number): void {\n    throw new InputException();\n  }\n\n  override head(): number {\n    throw new InputException();\n  }\n\n  override step(offset?: number): InputBuffer {\n    const error = new InputException(\"error step\");\n    return new InputBufferError(error, this.id, this.mark, this.settings);\n  }\n\n  override trap(): Error {\n    return this.error;\n  }\n\n  override seek(mark: Mark): InputBuffer {\n    const error = new InputException(\"error seek\");\n    return new InputBufferError(error, this.id, this.mark, this.settings);\n  }\n\n  override readonly id!: string | undefined;\n\n  withId(id: string | undefined): InputBuffer {\n    return new InputBufferError(this.error, id, this.mark, this.settings);\n  }\n\n  override readonly mark!: Mark;\n\n  override withMark(mark: Mark): InputBuffer {\n    return new InputBufferError(this.error, this.id, mark, this.settings);\n  }\n\n  override get offset(): number {\n    return this.mark.offset;\n  }\n\n  override get line(): number {\n    return this.mark.line;\n  }\n\n  override get column(): number {\n    return this.mark.column;\n  }\n\n  override readonly settings!: InputSettings;\n\n  override withSettings(settings: InputSettingsLike): InputBuffer {\n    settings = InputSettings.fromLike(settings);\n    return new InputBufferError(this.error, this.id, this.mark, settings);\n  }\n\n  override clone(): InputBuffer {\n    return this;\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {OutputException} from \"./OutputException\";\nimport type {OutputSettingsLike} from \"./OutputSettings\";\nimport {OutputSettings} from \"./OutputSettings\";\nimport {Output} from \"./Output\";\nimport {OutputDone} from \"../\"; // forward import\nimport {OutputError} from \"../\"; // forward import\n\n/** @internal */\nexport class OutputFull extends Output<never> {\n  constructor(settings: OutputSettings) {\n    super();\n    Object.defineProperty(this, \"settings\", {\n      value: settings,\n      enumerable: true,\n    });\n  }\n\n  override isCont(): boolean {\n    return false;\n  }\n\n  override isFull(): boolean {\n    return true;\n  }\n\n  override isDone(): boolean {\n    return false;\n  }\n\n  override isError(): boolean {\n    return false;\n  }\n\n  override isPart(): boolean {\n    return true;\n  }\n\n  override asPart(part: boolean): Output<never> {\n    return part ? this : new OutputDone(this.settings);\n  }\n\n  override write(token: number): Output<never>;\n  override write(string: string): Output<never>;\n  override write(tokenOrString: number | string): Output<never> {\n    return new OutputError(new OutputException(\"full\"), this.settings);\n  }\n\n  override writeln(string?: string): Output<never> {\n    return new OutputError(new OutputException(\"full\"), this.settings);\n  }\n\n  override bind(): never {\n    throw new OutputException();\n  }\n\n  override readonly settings!: OutputSettings;\n\n  override withSettings(settings: OutputSettingsLike): Output<never> {\n    settings = OutputSettings.fromLike(settings);\n    return new OutputFull(settings);\n  }\n\n  override clone(): Output<never> {\n    return this;\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {OutputException} from \"./OutputException\";\nimport type {OutputSettingsLike} from \"./OutputSettings\";\nimport {OutputSettings} from \"./OutputSettings\";\nimport {Output} from \"./Output\";\nimport {OutputFull} from \"../\"; // forward import\nimport {OutputError} from \"../\"; // forward import\n\n/** @internal */\nexport class OutputDone extends Output<never> {\n  constructor(settings: OutputSettings) {\n    super();\n    Object.defineProperty(this, \"settings\", {\n      value: settings,\n      enumerable: true,\n    });\n  }\n\n  override isCont(): boolean {\n    return false;\n  }\n\n  override isFull(): boolean {\n    return false;\n  }\n\n  override isDone(): boolean {\n    return true;\n  }\n\n  override isError(): boolean {\n    return false;\n  }\n\n  override isPart(): boolean {\n    return false;\n  }\n\n  override asPart(part: boolean): Output<never> {\n    return part ? new OutputFull(this.settings) : this;\n  }\n\n  override write(token: number): Output<never>;\n  override write(string: string): Output<never>;\n  override write(tokenOrString: number | string): Output<never> {\n    return new OutputError(new OutputException(\"done\"), this.settings);\n  }\n\n  override writeln(string?: string): Output<never> {\n    return new OutputError(new OutputException(\"done\"), this.settings);\n  }\n\n  override bind(): never {\n    throw new OutputException();\n  }\n\n  override readonly settings!: OutputSettings;\n\n  override withSettings(settings: OutputSettingsLike): Output<never> {\n    settings = OutputSettings.fromLike(settings);\n    return new OutputDone(settings);\n  }\n\n  override clone(): Output<never> {\n    return this;\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {OutputException} from \"./OutputException\";\nimport type {OutputSettingsLike} from \"./OutputSettings\";\nimport {OutputSettings} from \"./OutputSettings\";\nimport {Output} from \"./Output\";\n\n/** @internal */\nexport class OutputError extends Output<never> {\n  /** @internal */\n  readonly error!: Error;\n\n  constructor(error: Error, settings: OutputSettings) {\n    super();\n    Object.defineProperty(this, \"error\", {\n      value: error,\n      enumerable: true,\n    });\n    Object.defineProperty(this, \"settings\", {\n      value: settings,\n      enumerable: true,\n    });\n  }\n\n  override isCont(): boolean {\n    return false;\n  }\n\n  override isFull(): boolean {\n    return false;\n  }\n\n  override isDone(): boolean {\n    return false;\n  }\n\n  override isError(): boolean {\n    return true;\n  }\n\n  override isPart(): boolean {\n    return false;\n  }\n\n  override asPart(part: boolean): Output<never> {\n    return this;\n  }\n\n  override write(token: number): Output<never>;\n  override write(string: string): Output<never>;\n  override write(tokenOrString: number | string): Output<never> {\n    return this;\n  }\n\n  override writeln(string?: string): Output<never> {\n    return this;\n  }\n\n  override bind(): never {\n    throw new OutputException();\n  }\n\n  override trap(): Error {\n    return this.error;\n  }\n\n  override readonly settings!: OutputSettings;\n\n  override withSettings(settings: OutputSettingsLike): Output<never> {\n    settings = OutputSettings.fromLike(settings);\n    return new OutputError(this.error, settings);\n  }\n\n  override clone(): Output<never> {\n    return this;\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {Lazy} from \"@swim/util\";\nimport type {OutputSettingsLike} from \"./OutputSettings\";\nimport {OutputSettings} from \"./OutputSettings\";\nimport {Output} from \"./Output\";\nimport {OutputBufferFull} from \"../\"; // forward import\nimport {OutputBufferDone} from \"../\"; // forward import\nimport {OutputBufferError} from \"../\"; // forward import\n\n/**\n * Non-blocking token stream buffer.\n * @public\n */\nexport abstract class OutputBuffer<T = unknown> extends Output<T> {\n  abstract override asPart(part: boolean): OutputBuffer<T>;\n\n  abstract readonly index: number;\n\n  abstract withIndex(index: number): OutputBuffer<T>;\n\n  abstract readonly limit: number;\n\n  abstract withLimit(limit: number): OutputBuffer<T>;\n\n  abstract readonly capacity: number;\n\n  abstract readonly remaining: number;\n\n  abstract has(index: number): boolean;\n\n  abstract get(index: number): number;\n\n  abstract set(index: number, token: number): void;\n\n  abstract override write(token: number): OutputBuffer<T>;\n  abstract override write(string: string): OutputBuffer<T>;\n\n  override writeln(string?: string): OutputBuffer<T> {\n    if (typeof string === \"string\") {\n      this.write(string);\n    }\n    return this.write(this.settings.lineSeparator);\n  }\n\n  abstract step(offset?: number): OutputBuffer<T>;\n\n  override flush(): OutputBuffer<T> {\n    return this;\n  }\n\n  abstract override withSettings(settings: OutputSettingsLike): Output<T>;\n\n  override clone(): OutputBuffer<T> {\n    throw new Error();\n  }\n\n  /**\n   * Returns an `OutputBuffer` in the _full_ state.\n   */\n  @Lazy\n  static override full(): OutputBuffer<never> {\n    return new OutputBufferFull(OutputSettings.standard());\n  }\n\n  /**\n   * Returns an `OutputBuffer` in the _done_ state.\n   */\n  @Lazy\n  static override done(): OutputBuffer<never> {\n    return new OutputBufferDone(OutputSettings.standard());\n  }\n\n  /**\n   * Returns an `OutputBuffer` in the _error_ state that traps the given `error`.\n   */\n  static override error(error: Error): OutputBuffer<never> {\n    return new OutputBufferError(error, OutputSettings.standard());\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {OutputException} from \"./OutputException\";\nimport type {OutputSettingsLike} from \"./OutputSettings\";\nimport {OutputSettings} from \"./OutputSettings\";\nimport {OutputBuffer} from \"./OutputBuffer\";\nimport {OutputBufferDone} from \"../\"; // forward import\nimport {OutputBufferError} from \"../\"; // forward import\n\n/** @internal */\nexport class OutputBufferFull extends OutputBuffer<never> {\n  constructor(settings: OutputSettings) {\n    super();\n    Object.defineProperty(this, \"settings\", {\n      value: settings,\n      enumerable: true,\n    });\n  }\n\n  override isCont(): boolean {\n    return false;\n  }\n\n  override isFull(): boolean {\n    return true;\n  }\n\n  override isDone(): boolean {\n    return false;\n  }\n\n  override isError(): boolean {\n    return false;\n  }\n\n  override isPart(): boolean {\n    return true;\n  }\n\n  override asPart(part: boolean): OutputBuffer<never> {\n    return part ? this : new OutputBufferDone(this.settings);\n  }\n\n  override get index(): number {\n    return 0;\n  }\n\n  override withIndex(index: number): OutputBuffer<never> {\n    if (index === 0) {\n      return this;\n    } else {\n      return new OutputBufferError(new OutputException(\"invalid index\"), this.settings);\n    }\n  }\n\n  override get limit(): number {\n    return 0;\n  }\n\n  override withLimit(limit: number): OutputBuffer<never> {\n    if (limit === 0) {\n      return this;\n    } else {\n      return new OutputBufferError(new OutputException(\"invalid limit\"), this.settings);\n    }\n  }\n\n  override get capacity(): number {\n    return 0;\n  }\n\n  override get remaining(): number {\n    return 0;\n  }\n\n  override has(index: number): boolean {\n    return false;\n  }\n\n  override get(index: number): number {\n    throw new OutputException();\n  }\n\n  override set(index: number, token: number): void {\n    throw new OutputException();\n  }\n\n  override write(token: number): OutputBuffer<never>;\n  override write(string: string): OutputBuffer<never>;\n  override write(tokenOrString: number | string): OutputBuffer<never> {\n    return new OutputBufferError(new OutputException(\"full\"), this.settings);\n  }\n\n  override writeln(string?: string): OutputBuffer<never> {\n    return new OutputBufferError(new OutputException(\"full\"), this.settings);\n  }\n\n  override step(offset: number = 1): OutputBuffer<never> {\n    if (offset === 0) {\n      return this;\n    } else {\n      return new OutputBufferError(new OutputException(\"invalid step\"), this.settings);\n    }\n  }\n\n  override bind(): never {\n    throw new OutputException();\n  }\n\n  override readonly settings!: OutputSettings;\n\n  override withSettings(settings: OutputSettingsLike): OutputBuffer<never> {\n    settings = OutputSettings.fromLike(settings);\n    return new OutputBufferFull(settings);\n  }\n\n  override clone(): OutputBuffer<never> {\n    return this;\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {OutputException} from \"./OutputException\";\nimport type {OutputSettingsLike} from \"./OutputSettings\";\nimport {OutputSettings} from \"./OutputSettings\";\nimport {OutputBuffer} from \"./OutputBuffer\";\nimport {OutputBufferFull} from \"../\"; // forward import\nimport {OutputBufferError} from \"../\"; // forward import\n\n/** @internal */\nexport class OutputBufferDone extends OutputBuffer<never> {\n  constructor(settings: OutputSettings) {\n    super();\n    Object.defineProperty(this, \"settings\", {\n      value: settings,\n      enumerable: true,\n    });\n  }\n\n  override isCont(): boolean {\n    return false;\n  }\n\n  override isFull(): boolean {\n    return false;\n  }\n\n  override isDone(): boolean {\n    return true;\n  }\n\n  override isError(): boolean {\n    return false;\n  }\n\n  override isPart(): boolean {\n    return false;\n  }\n\n  override asPart(part: boolean): OutputBuffer<never> {\n    return part ? new OutputBufferFull(this.settings) : this;\n  }\n\n  override get index(): number {\n    return 0;\n  }\n\n  override withIndex(index: number): OutputBuffer<never> {\n    if (index === 0) {\n      return this;\n    } else {\n      return new OutputBufferError(new OutputException(\"invalid index\"), this.settings);\n    }\n  }\n\n  override get limit(): number {\n    return 0;\n  }\n\n  override withLimit(limit: number): OutputBuffer<never> {\n    if (limit === 0) {\n      return this;\n    } else {\n      return new OutputBufferError(new OutputException(\"invalid limit\"), this.settings);\n    }\n  }\n\n  override get capacity(): number {\n    return 0;\n  }\n\n  override get remaining(): number {\n    return 0;\n  }\n\n  override has(index: number): boolean {\n    return false;\n  }\n\n  override get(index: number): number {\n    throw new OutputException();\n  }\n\n  override set(index: number, token: number): void {\n    throw new OutputException();\n  }\n\n  override write(token: number): OutputBuffer<never>;\n  override write(string: string): OutputBuffer<never>;\n  override write(tokenOrString: number | string): OutputBuffer<never> {\n    return new OutputBufferError(new OutputException(\"done\"), this.settings);\n  }\n\n  override writeln(string?: string): OutputBuffer<never> {\n    return new OutputBufferError(new OutputException(\"done\"), this.settings);\n  }\n\n  override step(offset: number = 1): OutputBuffer<never> {\n    if (offset === 0) {\n      return this;\n    } else {\n      return new OutputBufferError(new OutputException(\"invalid step\"), this.settings);\n    }\n  }\n\n  override bind(): never {\n    throw new OutputException();\n  }\n\n  override readonly settings!: OutputSettings;\n\n  override withSettings(settings: OutputSettingsLike): OutputBuffer<never> {\n    settings = OutputSettings.fromLike(settings);\n    return new OutputBufferDone(settings);\n  }\n\n  override clone(): OutputBuffer<never> {\n    return this;\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {OutputException} from \"./OutputException\";\nimport type {OutputSettingsLike} from \"./OutputSettings\";\nimport {OutputSettings} from \"./OutputSettings\";\nimport {OutputBuffer} from \"./OutputBuffer\";\n\n/** @internal */\nexport class OutputBufferError extends OutputBuffer<never> {\n  /** @internal */\n  readonly error!: Error;\n\n  constructor(error: Error, settings: OutputSettings) {\n    super();\n    Object.defineProperty(this, \"error\", {\n      value: error,\n      enumerable: true,\n    });\n    Object.defineProperty(this, \"settings\", {\n      value: settings,\n      enumerable: true,\n    });\n  }\n\n  override isCont(): boolean {\n    return false;\n  }\n\n  override isFull(): boolean {\n    return false;\n  }\n\n  override isDone(): boolean {\n    return false;\n  }\n\n  override isError(): boolean {\n    return true;\n  }\n\n  override isPart(): boolean {\n    return false;\n  }\n\n  override asPart(part: boolean): OutputBuffer<never> {\n    return this;\n  }\n\n  override get index(): number {\n    return 0;\n  }\n\n  override withIndex(index: number): OutputBuffer<never> {\n    if (index === 0) {\n      return this;\n    } else {\n      return new OutputBufferError(new OutputException(\"invalid index\"), this.settings);\n    }\n  }\n\n  override get limit(): number {\n    return 0;\n  }\n\n  override withLimit(limit: number): OutputBuffer<never> {\n    if (limit === 0) {\n      return this;\n    } else {\n      return new OutputBufferError(new OutputException(\"invalid limit\"), this.settings);\n    }\n  }\n\n  override get capacity(): number {\n    return 0;\n  }\n\n  override get remaining(): number {\n    return 0;\n  }\n\n  override has(index: number): boolean {\n    return false;\n  }\n\n  override get(index: number): number {\n    throw new OutputException();\n  }\n\n  override set(index: number, token: number): void {\n    throw new OutputException();\n  }\n\n  override write(token: number): OutputBuffer<never>;\n  override write(string: string): OutputBuffer<never>;\n  override write(tokenOrString: number | string): OutputBuffer<never> {\n    return this;\n  }\n\n  override writeln(string?: string): OutputBuffer<never> {\n    return this;\n  }\n\n  override step(offset: number = 1): OutputBuffer<never> {\n    if (offset === 0) {\n      return this;\n    } else {\n      return new OutputBufferError(new OutputException(\"invalid step\"), this.settings);\n    }\n  }\n\n  override bind(): never {\n    throw new OutputException();\n  }\n\n  override trap(): Error {\n    return this.error;\n  }\n\n  override readonly settings!: OutputSettings;\n\n  override withSettings(settings: OutputSettingsLike): OutputBuffer<never> {\n    settings = OutputSettings.fromLike(settings);\n    return new OutputBufferError(this.error, settings);\n  }\n\n  override clone(): OutputBuffer<never> {\n    return this;\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {Diagnostic} from \"../source/Diagnostic\";\n\n/**\n * Thrown when a [[Parser]] parses invalid syntax.\n * @public\n */\nexport class ParserException extends Error {\n  constructor(message?: Diagnostic | string) {\n    super(message instanceof Diagnostic ? message.message : message);\n    Object.setPrototypeOf(this, ParserException.prototype);\n    this.diagnostic = message instanceof Diagnostic ? message : null;\n  }\n\n  readonly diagnostic: Diagnostic | null;\n\n  override toString(): string {\n    if (this.diagnostic !== null) {\n      return this.diagnostic.toString();\n    } else {\n      return super.toString();\n    }\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {Diagnostic} from \"../source/Diagnostic\";\nimport type {Input} from \"../input/Input\";\nimport {ParserException} from \"./ParserException\";\nimport {ParserDone} from \"../\"; // forward import\nimport {ParserError} from \"../\"; // forward import\n\n/**\n * Continuation of how to parse subsequent [[Input]] tokens from a stream.\n * `Parser` enables efficient, interruptible parsing of network protocols and\n * data formats, without intermediate buffering.\n *\n * ### Input tokens\n * A `Parser` reads tokens from an `Input` reader. Input tokens are modeled as\n * primitive numbers, commonly representing Unicode code points, or raw octets.\n * Each `Parser` implementation specifies the semantic type of input tokens it\n * consumes.\n *\n * ### Parser states\n * A `Parser` is always in one of three states: _cont_​inue, _done_, or _error_.\n * The _cont_ state indicates that [[feed]] is ready to consume `Input`; the\n * _done_ state indicates that parsing terminated successfully, and that\n * [[bind]] will return the parsed result; the _error_ state indicates that\n * parsing terminated in failure, and that [[trap]] will return the parse error.\n * `Parser` subclasses default to the _cont_ state.\n *\n * ### Feeding input\n * The [[feed]] method incrementally parses as much `Input` as it can, before\n * returning another `Parser` that represents the continuation of how to parse\n * additional `Input`. The `Input` passed to `feed` is only guaranteed to be\n * valid for the duration of the method call; references to the provided `Input`\n * instance must not be stored.\n *\n * ### Parser results\n * A `Parser` produces a parsed result of type `O`, obtained via the [[bind]]\n * method. `bind` is only guaranteed to return a result when in the _done_\n * state; though `bind` may optionally make available partial results in other\n * states. A failed `Parser` provides a parse error via the [[trap]] method.\n * `trap` is only guaranteed to return an error when in the _error_ state.\n *\n * ### Continuations\n * A `Parser` instance represents a continuation of how to parse remaining\n * `Input`. Rather than parsing a complete input in one go, a `Parser` takes\n * an `Input` chunk and returns another `Parser` instance that knows how to\n * parse subsequent `Input` chunks. This enables non-blocking, incremental\n * parsing that can be interrupted whenever an `Input` reader runs out of\n * immediately available data. A `Parser` terminates by returning a\n * continuation in either the _done_ state, or the _error_ state.\n * [[Parser.done]] returns a `Parser` in the _done_ state. [[Parser.error]]\n * returns a `Parser` in the _error_ state.\n *\n * ### Iteratees\n * `Parser` is an [Iteratee](https://en.wikipedia.org/wiki/Iteratee). Though\n * unlike strictly functional iteratees, a `Parser` statefully iterates over\n * its `Input`, rather than allocating an object for each incremental input\n * continutaion. This internal mutability minimizes garbage collector memory\n * pressure, without violating the functional Iteratee abstraction, provided\n * that `feed` logically takes exclusive ownership of its `Input` when invoked,\n * and logically returns ownership of the `Input` in a state that's consistent\n * with the returned `Parser` continuation.\n *\n * ### Immutability\n * A `Parser` should be immutable. Specifically, an invocation of `feed`\n * should not alter the behavior of future calls to `feed` on the same `Parser`\n * instance. A `Parser` should only mutate its internal state if it's essential\n * to do so, such as for critical path performance reasons.\n *\n * ### Backtracking\n * `feed` can internally [[Input.clone clone]] its `Input`, if it might need to\n * backtrack. Keep in mind that, because `Input` is only valid for the duration\n * of a call to `feed`, input must be internally buffered if it needs to be\n * preserved between `feed` invocations.\n *\n * ### Forking\n * The [[fork]] method passes an out-of-band condition to a `Parser`, yielding\n * a `Parser` continuation whose behavior may be altered by the given condition.\n * For example, an HTML `Parser` might `fork` an inner text parser to directly\n * parse an embedded micro format out of an HTML element, based on some\n * out-of-band schema information. The types of conditions accepted by `fork`,\n * and their intended semantics, are implementation defined.\n *\n * @public\n */\nexport abstract class Parser<O> {\n  /**\n   * Returns `true` when [[feed]] is able to consume `Input`, i.e. this\n   * `Parser` is in the _cont_ state.\n   */\n  isCont(): boolean {\n    return true;\n  }\n\n  /**\n   * Returns `true` when parsing has terminated successfully, and [[bind]] will\n   * return the parsed result, i.e. this `Parser` is in the _done_ state.\n   */\n  isDone(): boolean {\n    return false;\n  }\n\n  /**\n   * Returns `true` when parsing has terminated in failure, and [[trap]] will\n   * return the parse error, i.e. this `Parser` is in the _error_ state.\n   */\n  isError(): boolean {\n    return false;\n  }\n\n  /**\n   * Incrementally parses as much `input` as possible, and returns another\n   * `Parser` that represents the continuation of how to parse additional\n   * `Input`. If `input` enters the _done_ state, `feed` _must_ return a\n   * terminated `Parser`, i.e. a `Parser` in the _done_ state, or in the\n   * _error_ state. The given `input` is only guaranteed to be valid for the\n   * duration of the method call; references to `input` must not be stored.\n   */\n  abstract feed(input: Input): Parser<O>;\n\n  /**\n   * Returns a `Parser` continuation whose behavior may be altered by the\n   * given out-of-band `condition`.\n   */\n  fork(condition: unknown): Parser<O> {\n    return this;\n  }\n\n  /**\n   * Returns the parsed result. Only guaranteed to return a result when in the\n   * _done_ state.\n   *\n   * @throws `Error` if this `Parser` is not in the _done_ state.\n   */\n  bind(): O {\n    throw new ParserException();\n  }\n\n  /**\n   * Returns the parse error. Only guaranteed to return an error when in the\n   * _error_ state.\n   *\n   * @throws `Error` if this `Parser` is not in the _error_ state.\n   */\n  trap(): Error {\n    throw new ParserException();\n  }\n\n  /**\n   * Casts an errored `Parser` to a different output type. A `Parser` in the\n   * _error_ state can have any output type.\n   *\n   * @throws `ParserException` if this `Parser` is not in the _error_ state.\n   */\n  asError<O2>(): Parser<O2> {\n    throw new ParserException();\n  }\n\n  /**\n   * Returns a `Parser` in the _done_ state that binds the given parsed `value`.\n   */\n  static done<O>(value: O): Parser<O> {\n    return new ParserDone(value);\n  }\n\n  /**\n   * Returns a `Parser` in the _error_ state that `trap`s the given parse `error`.\n   */\n  static error<O>(error: Error | Diagnostic): Parser<O> {\n    if (error instanceof Error) {\n      return new ParserError(error);\n    } else {\n      return new ParserError(new ParserException(error));\n    }\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {Input} from \"../input/Input\";\nimport {Parser} from \"./Parser\";\n\n/** @internal */\nexport class ParserDone<O> extends Parser<O> {\n  /** @internal */\n  readonly value!: O;\n\n  constructor(value: O) {\n    super();\n    Object.defineProperty(this, \"value\", {\n      value: value,\n      enumerable: true,\n    });\n  }\n\n  override isCont(): boolean {\n    return false;\n  }\n\n  override isDone(): boolean {\n    return true;\n  }\n\n  override feed(input: Input): Parser<O> {\n    return this;\n  }\n\n  override bind(): O {\n    return this.value;\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {Input} from \"../input/Input\";\nimport {Parser} from \"./Parser\";\n\n/** @internal */\nexport class ParserError extends Parser<never> {\n  /** @internal */\n  readonly error!: Error;\n\n  constructor(error: Error) {\n    super();\n    Object.defineProperty(this, \"error\", {\n      value: error,\n      enumerable: true,\n    });\n  }\n\n  override isCont(): boolean {\n    return false;\n  }\n\n  override isError(): boolean {\n    return true;\n  }\n\n  override feed(input: Input): Parser<never> {\n    return this;\n  }\n\n  override bind(): never {\n    throw this.error;\n  }\n\n  override trap(): Error {\n    return this.error;\n  }\n\n  override asError<O2>(): Parser<O2> {\n    return this;\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {Output} from \"../output/Output\";\nimport {WriterException} from \"./WriterException\";\nimport {Writer} from \"./Writer\";\n\n/** @internal */\nexport class WriterEnd extends Writer<unknown, never> {\n  constructor() {\n    super();\n  }\n\n  override isCont(): boolean {\n    return false;\n  }\n\n  override isDone(): boolean {\n    return true;\n  }\n\n  override pull(output: Output): Writer<unknown, never> {\n    return this;\n  }\n\n  override bind(): never {\n    throw new WriterException();\n  }\n\n  override asDone<I2>(): Writer<I2, never> {\n    return this;\n  }\n\n  override andThen<O2>(that: Writer<unknown, O2>): Writer<unknown, O2> {\n    return that;\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {Output} from \"../output/Output\";\nimport {Writer} from \"./Writer\";\n\n/** @internal */\nexport class WriterDone<O> extends Writer<unknown, O> {\n  /** @internal */\n  readonly value!: O;\n\n  constructor(value: O) {\n    super();\n    Object.defineProperty(this, \"value\", {\n      value: value,\n      enumerable: true,\n    });\n  }\n\n  override isCont(): boolean {\n    return false;\n  }\n\n  override isDone(): boolean {\n    return true;\n  }\n\n  override pull(output: Output): Writer<unknown, O> {\n    return this;\n  }\n\n  override bind(): O {\n    return this.value;\n  }\n\n  override asDone<I2>(): Writer<I2, O> {\n    return this;\n  }\n\n  override andThen<O2>(that: Writer<unknown, O2>): Writer<unknown, O2> {\n    return that;\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {Output} from \"../output/Output\";\nimport {Writer} from \"./Writer\";\n\n/** @internal */\nexport class WriterError extends Writer<never, never> {\n  /** @internal */\n  readonly error!: Error;\n\n  constructor(error: Error) {\n    super();\n    Object.defineProperty(this, \"error\", {\n      value: error,\n      enumerable: true,\n    });\n  }\n\n  override isCont(): boolean {\n    return false;\n  }\n\n  override isError(): boolean {\n    return true;\n  }\n\n  override pull(output: Output): Writer<never, never> {\n    return this;\n  }\n\n  override bind(): never {\n    throw this.error;\n  }\n\n  override trap(): Error {\n    return this.error;\n  }\n\n  override asError<I2, O2>(): Writer<I2, O2> {\n    return this;\n  }\n\n  override andThen<O2>(that: Writer<never, O2>): Writer<never, O2> {\n    return this;\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {Output} from \"../output/Output\";\nimport {Writer} from \"./Writer\";\n\n/** @internal */\nexport class WriterSequence<O> extends Writer<never, O> {\n  /** @internal */\n  readonly head: Writer<unknown, unknown>;\n  /** @internal */\n  readonly tail: Writer<unknown, O>;\n\n  constructor(head: Writer<unknown, unknown>, tail: Writer<unknown, O>) {\n    super();\n    this.head = head;\n    this.tail = tail;\n  }\n\n  override pull(output: Output): Writer<never, O> {\n    let head = this.head;\n    if (head.isCont()) {\n      head = head.pull(output);\n    }\n    if (head.isError()) {\n      return head.asError();\n    } else if (head.isDone()) {\n      return this.tail.pull(output);\n    } else {\n      return new WriterSequence(head, this.tail);\n    }\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {Mutable} from \"@swim/util\";\nimport type {OutputSettingsLike} from \"../output/OutputSettings\";\nimport {OutputSettings} from \"../output/OutputSettings\";\nimport {Output} from \"../output/Output\";\n\n/** @internal */\nexport abstract class ByteOutput<T> extends Output<T> {\n  constructor(array: Uint8Array | null, size: number, settings: OutputSettings) {\n    super();\n    this.array = array;\n    this.size = size;\n    this.settings = settings;\n  }\n\n  /** @internal */\n  readonly array: Uint8Array | null;\n\n  /** @internal */\n  readonly size: number;\n\n  override isCont(): boolean {\n    return true;\n  }\n\n  override isFull(): boolean {\n    return false;\n  }\n\n  override isDone(): boolean {\n    return false;\n  }\n\n  override isError(): boolean {\n    return false;\n  }\n\n  override isPart(): boolean {\n    return false;\n  }\n\n  override asPart(part: boolean): Output<T> {\n    return this;\n  }\n\n  override write(b: number | string): Output<T> {\n    if (typeof b === \"number\") {\n      const n = this.size;\n      const oldArray = this.array;\n      let newArray;\n      if (oldArray === null || n + 1 > oldArray.length) {\n        newArray = new Uint8Array(ByteOutput.expand(n + 1));\n        if (oldArray !== null) {\n          newArray.set(oldArray, 0);\n        }\n        (this as Mutable<this>).array = newArray;\n      } else {\n        newArray = oldArray;\n      }\n      newArray[n] = b;\n      (this as Mutable<this>).size = n + 1;\n      return this;\n    } else {\n      throw new TypeError(\"\" + b);\n    }\n  }\n\n  override writeln(string?: string): Output<T> {\n    throw new TypeError(\"\" + string);\n  }\n\n  toUint8Array(): Uint8Array {\n    const n = this.size;\n    const oldArray = this.array;\n    if (oldArray !== null && n === oldArray.length) {\n      return oldArray;\n    } else {\n      const newArray = new Uint8Array(n);\n      if (oldArray !== null) {\n        newArray.set(oldArray.slice(0, n), 0);\n      }\n      (this as Mutable<this>).array = newArray;\n      return newArray;\n    }\n  }\n\n  cloneArray(): Uint8Array | null {\n    const oldArray = this.array;\n    if (oldArray !== null) {\n      return oldArray.slice(0, this.size);\n    } else {\n      return null;\n    }\n  }\n\n  override readonly settings: OutputSettings;\n\n  override withSettings(settings: OutputSettingsLike): Output<T> {\n    settings = OutputSettings.fromLike(settings);\n    (this as Mutable<this>).settings = settings;\n    return this;\n  }\n\n  /** @internal */\n  static expand(n: number): number {\n    n = Math.max(32, n) - 1;\n    n |= n >> 1; n |= n >> 2; n |= n >> 4; n |= n >> 8; n |= n >> 16;\n    return n + 1;\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {OutputSettings} from \"../output/OutputSettings\";\nimport type {Output} from \"../output/Output\";\nimport {ByteOutput} from \"./ByteOutput\";\n\n/** @internal */\nexport class ByteOutputUint8Array extends ByteOutput<Uint8Array> {\n  constructor(array: Uint8Array | null, size: number, settings: OutputSettings) {\n    super(array, size, settings);\n  }\n\n  override bind(): Uint8Array {\n    return this.toUint8Array();\n  }\n\n  override clone(): Output<Uint8Array> {\n    return new ByteOutputUint8Array(this.cloneArray(), this.size, this.settings);\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {Mutable} from \"@swim/util\";\nimport {OutputException} from \"../output/OutputException\";\nimport type {OutputSettingsLike} from \"../output/OutputSettings\";\nimport {OutputSettings} from \"../output/OutputSettings\";\nimport {OutputBuffer} from \"../output/OutputBuffer\";\nimport {OutputBufferError} from \"../output/OutputBufferError\";\n\n/** @internal */\nexport class ByteOutputBuffer extends OutputBuffer<Uint8Array> {\n  constructor(array: Uint8Array, index: number, limit: number,\n              part: boolean, settings: OutputSettings) {\n    super();\n    this.array = array;\n    this.index = index;\n    this.limit = limit;\n    this.part = part;\n    this.settings = settings;\n  }\n\n  /** @internal */\n  readonly array: Uint8Array;\n\n  /** @internal */\n  readonly part: boolean;\n\n  override isCont(): boolean {\n    return this.index < this.limit;\n  }\n\n  override isFull(): boolean {\n    return this.part && this.index >= this.limit;\n  }\n\n  override isDone(): boolean {\n    return !this.part && this.index >= this.limit;\n  }\n\n  override isError(): boolean {\n    return false;\n  }\n\n  override isPart(): boolean {\n    return this.part;\n  }\n\n  override asPart(part: boolean): OutputBuffer<Uint8Array> {\n    (this as Mutable<this>).part = part;\n    return this;\n  }\n\n  readonly index: number;\n\n  override withIndex(index: number): OutputBuffer<Uint8Array> {\n    if (0 <= index && index <= this.limit) {\n      (this as Mutable<this>).index = index;\n      return this;\n    } else {\n      return new OutputBufferError(new OutputException(\"invalid index\"), this.settings);\n    }\n  }\n\n  readonly limit: number;\n\n  override withLimit(limit: number): OutputBuffer<Uint8Array> {\n    if (0 <= limit && limit <= this.array.length) {\n      (this as Mutable<this>).limit = limit;\n      return this;\n    } else {\n      return new OutputBufferError(new OutputException(\"invalid limit\"), this.settings);\n    }\n  }\n\n  override get capacity(): number {\n    return this.array.length;\n  }\n\n  override get remaining(): number {\n    return this.limit - this.index;\n  }\n\n  override has(index: number): boolean {\n    return 0 <= index && index < this.limit;\n  }\n\n  override get(index: number): number {\n    if (0 <= index && index < this.limit) {\n      return this.array[index]!;\n    } else {\n      throw new OutputException();\n    }\n  }\n\n  override set(index: number, token: number): void {\n    if (0 <= index && index < this.limit) {\n      this.array[index] = token;\n    } else {\n      throw new OutputException();\n    }\n  }\n\n  override write(token: number | string): OutputBuffer<Uint8Array> {\n    if (typeof token === \"number\") {\n      const index = this.index;\n      if (index < this.limit) {\n        this.array[index] = token;\n        (this as Mutable<this>).index += 1;\n        return this;\n      } else {\n        return new OutputBufferError(new OutputException(\"full\"), this.settings);\n      }\n    } else {\n      return new OutputBufferError(new OutputException(\"binary output\"), this.settings);\n    }\n  }\n\n  override writeln(string?: string): OutputBuffer<Uint8Array> {\n    return new OutputBufferError(new OutputException(\"binary output\"), this.settings);\n  }\n\n  override step(offset: number): OutputBuffer<Uint8Array> {\n    const index = this.index + offset;\n    if (0 <= index && index <= this.limit) {\n      (this as Mutable<this>).index = index;\n      return this;\n    } else {\n      return new OutputBufferError(new OutputException(\"invalid step\"), this.settings);\n    }\n  }\n\n  override bind(): Uint8Array {\n    return new Uint8Array(this.array.buffer, 0, this.index);\n  }\n\n  override readonly settings: OutputSettings;\n\n  override withSettings(settings: OutputSettingsLike): OutputBuffer<Uint8Array> {\n    settings = OutputSettings.fromLike(settings);\n    (this as Mutable<this>).settings = settings;\n    return this;\n  }\n\n  override clone(): OutputBuffer<Uint8Array> {\n    return new ByteOutputBuffer(this.array, this.index, this.limit, this.part, this.settings);\n  }\n\n  static create(array: Uint8Array, offset?: number, length?: number): OutputBuffer<Uint8Array> {\n    if (offset === void 0) {\n      offset = 0;\n    }\n    if (length === void 0) {\n      length = array.length;\n    }\n    return new ByteOutputBuffer(array, offset, offset + length, false, OutputSettings.standard());\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {OutputSettingsLike} from \"../output/OutputSettings\";\nimport {OutputSettings} from \"../output/OutputSettings\";\nimport type {Output} from \"../output/Output\";\nimport type {OutputBuffer} from \"../output/OutputBuffer\";\nimport {ByteOutputBuffer} from \"./ByteOutputBuffer\";\nimport {ByteOutputUint8Array} from \"./ByteOutputUint8Array\";\n\n/**\n * Byte [[Input]]/[[Output]] factory.\n *\n * The `Binary.outputBuffer(...)` function returns an `Output` that writes\n * bytes to a growable array, and [[Output.bind binds]] a `Uint8Array`\n * containing all written bytes.\n * @public\n */\nexport const Binary = (function () {\n  const Binary = {} as {\n    /**\n     * Returns a new `Output` that appends bytes to a growable array,\n     * pre-allocated with space for `initialCapacity` bytes, if `initialCapacity`\n     * is defined, using the given `settings`, if `settings` is defined. The\n     * returned `Output` accepts an unbounded number of bytes, remaining\n     * permanently in the _cont_ state, and can [[Output.bind bind]] a\n     * `Uint8Array` with the current output state at any time.\n     */\n    output(initialCapacity?: number, settings?: OutputSettingsLike): Output<Uint8Array>;\n\n    /**\n     * Returns a new `Output` that appends bytes to a growable array, using the\n     * given `settings`. The returned `Output` accepts an unbounded number of\n     * bytes, remaining permanently in the _cont_ state, and can [[Output.bind\n     * bind]] a `Uint8Array` array with the current output state at any time.\n     */\n    output(settings: OutputSettingsLike): Output<Uint8Array>;\n\n    outputBuffer(array: Uint8Array, offset?: number, length?: number): OutputBuffer<Uint8Array>;\n  };\n\n  Binary.output = function (initialCapacity?: number | OutputSettingsLike,\n                            settings?: OutputSettingsLike): Output<Uint8Array> {\n    if (settings === void 0 && typeof initialCapacity !== \"number\") {\n      settings = initialCapacity;\n      initialCapacity = void 0;\n    } else if (typeof initialCapacity !== \"number\") {\n      initialCapacity = void 0;\n    }\n    let array: Uint8Array | null;\n    if (typeof initialCapacity === \"number\") {\n      array = new Uint8Array(initialCapacity);\n    } else {\n      array = null;\n    }\n    settings = OutputSettings.fromLike(settings);\n    return new ByteOutputUint8Array(array, 0, settings);\n  };\n\n  Binary.outputBuffer = function (array: Uint8Array, offset?: number,\n                                  length?: number): OutputBuffer<Uint8Array> {\n    return ByteOutputBuffer.create(array, offset, length);\n  };\n\n  return Binary;\n})();\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {Lazy} from \"@swim/util\";\nimport type {HashCode} from \"@swim/util\";\nimport type {Output} from \"../output/Output\";\nimport type {Debug} from \"../format/Debug\";\nimport {Format} from \"../format/Format\";\nimport {UtfErrorModeFatal} from \"../\"; // forward import\nimport {UtfErrorModeReplacement} from \"../\"; // forward import\n\n/**\n * Unicode transformation format error handling mode.\n * @public\n */\nexport abstract class UtfErrorMode implements HashCode, Debug {\n  /**\n   * Returns `true` if a Unicode decoding should abort with an error when an\n   * invalid code unit sequence is encountered.\n   */\n  isFatal(): boolean {\n    return false;\n  }\n\n  /**\n   * Returns `true` if a Unicode decoding should substitute invalid code unit\n   * sequences with a replacement character.\n   */\n  isReplacement(): boolean {\n    return false;\n  }\n\n  /**\n   * The Unicode code point of the replacement character used to substitute\n   * for invalid code unit sequences.\n   */\n  abstract readonly replacementChar: number;\n\n  /**\n   * Returns `true` if Unicode decoding should abort with an error when a\n   * `NUL` byte is encountered.\n   */\n  abstract isNonZero(): boolean;\n\n  /**\n   * Returns a `UtfErrorMode` that, if `isNonZero` is `true`, aborts when\n   * Unicode decoding encounters a `NUL` byte.\n   */\n  abstract asNonZero(isNonZero: boolean): UtfErrorMode;\n\n  abstract equals(that: unknown): boolean;\n\n  abstract hashCode(): number;\n\n  abstract debug<T>(output: Output<T>): Output<T>;\n\n  toString(): string {\n    return Format.debug(this);\n  }\n\n  /**\n   * Returns a `UtfErrorMode` that aborts Unicode decoding with an error when\n   * invalid code unit sequences are encountered.\n   */\n  @Lazy\n  static fatal(): UtfErrorMode {\n    return new UtfErrorModeFatal(false);\n  }\n\n  /**\n   * Returns a `UtfErrorMode` that aborts Unicode decoding with an error when\n   * invalid code unit sequences, and `NUL` bytes, are encountered.\n   */\n  @Lazy\n  static fatalNonZero(): UtfErrorMode {\n    return new UtfErrorModeFatal(true);\n  }\n\n  /**\n   * Returns a `UtfErrorMode` that substitutes invalid code unit sequences\n   * with the replacement character (`U+FFFD`).\n   */\n  @Lazy\n  static replacement(): UtfErrorMode {\n    return new UtfErrorModeReplacement(0xfffd, false);\n  }\n\n  /**\n   * Returns a `UtfErrorMode` that substitutes invalid code unit sequences\n   * with the replacement character (`U+FFFD`), and aborts decoding with an\n   * error when `NUL` bytes are encountered.\n   */\n  @Lazy\n  static replacementNonZero(): UtfErrorMode {\n    return new UtfErrorModeReplacement(0xfffd, true);\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {Murmur3} from \"@swim/util\";\nimport {Booleans} from \"@swim/util\";\nimport {Constructors} from \"@swim/util\";\nimport type {Output} from \"../output/Output\";\nimport {UtfErrorMode} from \"./UtfErrorMode\";\n\n/** @internal */\nexport class UtfErrorModeFatal extends UtfErrorMode {\n  constructor(nonZero: boolean) {\n    super();\n    Object.defineProperty(this, \"nonZero\", {\n      value: nonZero,\n      enumerable: true,\n    });\n  }\n\n  override isFatal(): boolean {\n    return true;\n  }\n\n  override get replacementChar(): number {\n    return 0xfffd;\n  }\n\n  /** @internal */\n  readonly nonZero!: boolean;\n\n  override isNonZero(): boolean {\n    return this.nonZero;\n  }\n\n  override asNonZero(nonZero: boolean): UtfErrorMode {\n    if (nonZero) {\n      return UtfErrorMode.fatalNonZero();\n    } else {\n      return UtfErrorMode.fatal();\n    }\n  }\n\n  override equals(that: unknown): boolean {\n    if (this === that) {\n      return true;\n    } else if (that instanceof UtfErrorModeFatal) {\n      return this.nonZero === that.nonZero;\n    }\n    return false;\n  }\n\n  override hashCode(): number {\n    return Murmur3.mash(Murmur3.mix(Constructors.hash(UtfErrorModeFatal),\n        Booleans.hash(this.nonZero)));\n  }\n\n  override debug<T>(output: Output<T>): Output<T> {\n    output = output.write(\"UtfErrorMode\").write(46/*'.'*/)\n                   .write(this.nonZero ? \"fatalNonZero\" : \"fatal\")\n                   .write(40/*'('*/).write(41/*')'*/);\n    return output;\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {Murmur3} from \"@swim/util\";\nimport {Booleans} from \"@swim/util\";\nimport {Numbers} from \"@swim/util\";\nimport {Constructors} from \"@swim/util\";\nimport type {Output} from \"../output/Output\";\nimport {UtfErrorMode} from \"./UtfErrorMode\";\n\n/** @internal */\nexport class UtfErrorModeReplacement extends UtfErrorMode {\n  constructor(replacementChar: number, nonZero: boolean) {\n    super();\n    Object.defineProperty(this, \"replacementChar\", {\n      value: replacementChar,\n      enumerable: true,\n    });\n    Object.defineProperty(this, \"nonZero\", {\n      value: nonZero,\n      enumerable: true,\n    });\n  }\n\n  override isReplacement(): boolean {\n    return true;\n  }\n\n  override readonly replacementChar!: number;\n\n  /** @internal */\n  readonly nonZero!: boolean;\n\n  override isNonZero(): boolean {\n    return this.nonZero;\n  }\n\n  override asNonZero(nonZero: boolean): UtfErrorMode {\n    if (this.replacementChar === 0xfffd) {\n      if (nonZero) {\n        return UtfErrorMode.replacementNonZero();\n      } else {\n        return UtfErrorMode.replacement();\n      }\n    } else {\n      return new UtfErrorModeReplacement(this.replacementChar, nonZero);\n    }\n  }\n\n  override equals(that: unknown): boolean {\n    if (this === that) {\n      return true;\n    } else if (that instanceof UtfErrorModeReplacement) {\n      return this.replacementChar === that.replacementChar\n          && this.nonZero === that.nonZero;\n    }\n    return false;\n  }\n\n  override hashCode(): number {\n    return Murmur3.mash(Murmur3.mix(Murmur3.mix(Constructors.hash(UtfErrorModeReplacement),\n        Numbers.hash(this.replacementChar)), Booleans.hash(this.nonZero)));\n  }\n\n  override debug<T>(output: Output<T>): Output<T> {\n    output = output.write(\"UtfErrorMode\").write(46/*'.'*/)\n                   .write(this.nonZero ? \"replacementNonZero\" : \"replacement\")\n                   .write(40/*'('*/).write(41/*')'*/);\n    return output;\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {Lazy} from \"@swim/util\";\nimport type {Input} from \"../input/Input\";\nimport type {Output} from \"../output/Output\";\nimport type {Parser} from \"../parser/Parser\";\nimport type {Writer} from \"../writer/Writer\";\nimport {Format} from \"../format/Format\";\nimport {Binary} from \"../binary/Binary\";\nimport {Unicode} from \"../unicode/Unicode\";\nimport {Base16Parser} from \"../\"; // forward import\nimport {Base16Writer} from \"../\"; // forward import\nimport {Base16IntegerWriter} from \"../\"; // forward import\n\n/**\n * Base-16 (hexadecimal) encoding [[Parser]]/[[Writer]] factory.\n * @public\n */\nexport class Base16 {\n  constructor(alphabet: string) {\n    Object.defineProperty(this, \"alphabet\", {\n      value: alphabet,\n      enumerable: true,\n    });\n  }\n\n  /**\n   * Returns a 16 character string, where the character at index `i` is the\n   * encoding of the base-16 digit `i`.\n   */\n  readonly alphabet!: string;\n\n  /**\n   * Returns the Unicode code point of the base-16 digit that encodes the given\n   * 4-bit quantity.\n   */\n  encodeDigit(b: number): number {\n    return this.alphabet.charCodeAt(b);\n  }\n\n  /**\n   * Returns a `Writer` that, when fed an input `Uint8Array`, returns a\n   * continuation that writes the base-16 (hexadecimal) encoding of the input\n   * byte array.\n   */\n  uint8ArrayWriter(): Writer<Uint8Array, unknown>;\n  /**\n   * Returns a `Writer` continuation that writes the base-16 (hexadecimal)\n   * encoding of the `input` `Uint8Array`.\n   */\n  uint8ArrayWriter(input: Uint8Array): Writer<unknown, Uint8Array>;\n  uint8ArrayWriter(input?: Uint8Array): Writer<unknown, unknown> {\n    if (input === void 0) {\n      return new Base16Writer(this, void 0, null);\n    } else {\n      return new Base16Writer(this, input, input);\n    }\n  }\n\n  /**\n   * Writes the base-16 (hexadecimal) encoding of the `input` `Uint8Array` to\n   * the `output`, returning a `Writer` continuation that knows how to write any\n   * remaining output that couldn't be immediately generated.\n   */\n  writeUint8Array(output: Output, input: Uint8Array): Writer<unknown, unknown> {\n    return Base16Writer.write(output, this, void 0, input);\n  }\n\n  writeInteger(output: Output, input: number, width: number = 0): Writer<unknown, unknown> {\n    return Base16IntegerWriter.write(output, this, void 0, input, width);\n  }\n\n  writeIntegerLiteral(output: Output, input: number, width: number = 0): Writer<unknown, unknown> {\n    return Base16IntegerWriter.writeLiteral(output, this, void 0, input, width);\n  }\n\n  /**\n   * Returns the `Base16` encoding with lowercase alphanumeric digits.\n   */\n  @Lazy\n  static get lowercase(): Base16 {\n    return new Base16(\"0123456789abcdef\");\n  }\n\n  /**\n   * Returns the `Base16` encoding with uppercase alphanumeric digits.\n   */\n  @Lazy\n  static get uppercase(): Base16 {\n    return new Base16(\"0123456789ABCDEF\");\n  }\n\n  /**\n   * Returns `true` if the Unicode code point `c` is a valid base-16 digit.\n   */\n  static isDigit(c: number): boolean {\n    return c >= 48/*'0'*/ && c <= 57/*'9'*/\n        || c >= 65/*'A'*/ && c <= 70/*'F'*/\n        || c >= 97/*'a'*/ && c <= 102/*'f'*/;\n  }\n\n  /**\n   * Returns the 4-bit quantity represented by the base-16 digit `c`.\n   *\n   * @throws `Error` if `c` is not a valid base-16 digit.\n   */\n  static decodeDigit(c: number): number {\n    if (c >= 48/*'0'*/ && c <= 57/*'9'*/) {\n      return c - 48/*'0'*/;\n    } else if (c >= 65/*'A'*/ && c <= 70/*'F'*/) {\n      return 10 + (c - 65/*'A'*/);\n    } else if (c >= 97/*'a'*/ && c <= 102/*'f'*/) {\n      return 10 + (c - 97/*'a'*/);\n    } else {\n      let message = Unicode.stringOutput();\n      message = message.write(\"Invalid base-16 digit: \");\n      message = Format.debugChar(message, c);\n      throw new Error(message.bind());\n    }\n  }\n\n  /**\n   * Decodes the base-16 digits `c1` and `c2`, and writes the 8-bit  quantity\n   * they represent to the given `output`.\n   *\n   * @returns the continuation of the `output`.\n   */\n  static writeQuantum<T>(output: Output<T>, c1: number, c2: number): Output<T> {\n    const x = Base16.decodeDigit(c1);\n    const y = Base16.decodeDigit(c2);\n    output = output.write(x << 4 | y);\n    return output;\n  }\n\n  /**\n   * Returns a `Parser` that decodes base-16 (hexadecimal) encoded input, and\n   * writes the decoded bytes to `output`.\n   */\n  static parser<O>(output: Output<O>): Parser<O> {\n    return new Base16Parser<O>(output);\n  }\n\n  /**\n   * Parses the base-16 (hexadecimal) encoded `input`, and writes the decoded\n   * bytes to `output`, returning a `Parser` continuation that knows how to\n   * parse any additional input.\n   */\n  static parse<O>(input: Input, output: Output<O>): Parser<O> {\n    return Base16Parser.parse(input, output);\n  }\n\n  /**\n   * Parses the base-16 (hexadecimal) encoded `input`, and writes the decoded\n   * bytes to a growable array, returning a `Parser` continuation that knows\n   * how to parse any additional input. The returned `Parser` [[Parser.bind\n   * binds]] a `Uint8Array` array containing all parsed base-16 data.\n   */\n  static parseUint8Array(input: Input): Parser<Uint8Array> {\n    return Base16Parser.parse(input, Binary.output());\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {Mutable} from \"@swim/util\";\nimport {OutputException} from \"../output/OutputException\";\nimport type {OutputSettingsLike} from \"../output/OutputSettings\";\nimport type {OutputSettings} from \"../output/OutputSettings\";\nimport {Output} from \"../output/Output\";\nimport {Unicode} from \"./Unicode\";\nimport {UtfErrorMode} from \"./UtfErrorMode\";\nimport {Base16} from \"../number/Base16\";\n\n/** @internal */\nexport class Utf8DecodedOutput<T> extends Output<T> {\n  /** @internal */\n  readonly output: Output<T>;\n  /** @internal */\n  readonly errorMode: UtfErrorMode;\n  /** @internal */\n  c1: number;\n  /** @internal */\n  c2: number;\n  /** @internal */\n  c3: number;\n  /** @internal */\n  have: number;\n\n  constructor(output: Output<T>, errorMode: UtfErrorMode,\n              c1: number, c2: number, c3: number, have: number) {\n    super();\n    this.output = output;\n    this.errorMode = errorMode;\n    this.c1 = c1;\n    this.c2 = c2;\n    this.c3 = c3;\n    this.have = have;\n  }\n\n  override isCont(): boolean {\n    return this.output.isCont();\n  }\n\n  override isFull(): boolean {\n    return this.output.isFull();\n  }\n\n  override isDone(): boolean {\n    return this.output.isDone();\n  }\n\n  override isError(): boolean {\n    return this.output.isError();\n  }\n\n  override isPart(): boolean {\n    return this.output.isPart();\n  }\n\n  override asPart(part: boolean): Output<T> {\n    (this as Mutable<this>).output = this.output.asPart(part);\n    return this;\n  }\n\n  override write(token: number | string): Output<T> {\n    if (typeof token === \"number\") {\n      let c1 = this.c1;\n      let c2 = this.c2;\n      let c3 = this.c3;\n      let c4 = -1;\n      let have = this.have;\n\n      if (token >= 0) {\n        switch (have) {\n          case 0:\n            c1 = token & 0xff;\n            have = 1;\n            break;\n          case 1:\n            c2 = token & 0xff;\n            have = 2;\n            break;\n          case 2:\n            c3 = token & 0xff;\n            have = 3;\n            break;\n          case 3:\n            c4 = token & 0xff;\n            have = 4;\n            break;\n          default:\n            throw new Error(\"unreachable\");\n        }\n      }\n\n      if (c1 === 0 && this.errorMode.isNonZero()) { // invalid NUL byte\n        return Output.error(new OutputException(\"unexpected NUL byte\"));\n      } else if (c1 >= 0 && c1 <= 0x7f) { // U+0000..U+007F\n        (this as Mutable<this>).output = this.output.write(c1);\n        this.have = 0;\n      } else if (c1 >= 0xc2 && c1 <= 0xf4) {\n        if (c1 >= 0xc2 && c1 <= 0xdf && c2 >= 0x80 && c2 <= 0xbf) { // U+0080..U+07FF\n          (this as Mutable<this>).output = this.output.write((c1 & 0x1f) << 6 | c2 & 0x3f);\n          this.c1 = -1;\n          this.have = 0;\n        } else if (c1 === 0xe0 && c2 >= 0xa0 && c2 <= 0xbf // U+0800..U+0FFF\n                || c1 >= 0xe1 && c1 <= 0xec && c2 >= 0x80 && c2 <= 0xbf // U+1000..U+CFFF\n                || c1 === 0xed && c2 >= 0x80 && c2 <= 0x9f // U+D000..U+D7FF\n                || c1 >= 0xee && c1 <= 0xef && c2 >= 0x80 && c2 <= 0xbf) { // U+E000..U+FFFF\n          if (c3 >= 0x80 && c3 <= 0xbf) {\n            (this as Mutable<this>).output = this.output.write((c1 & 0x0f) << 12 | (c2 & 0x3f) << 6 | c3 & 0x3f);\n            this.c1 = -1;\n            this.c2 = -1;\n            this.have = 0;\n          } else if (c3 >= 0) { // invalid c3\n            if (this.errorMode.isFatal()) {\n              return Output.error(new OutputException(Utf8DecodedOutput.invalid(c1, c2, c3)));\n            }\n            (this as Mutable<this>).output = this.output.write(this.errorMode.replacementChar);\n            this.c1 = c3;\n            this.c2 = -1;\n            this.have = 1;\n          } else if (token < 0 || this.output.isDone()) { // incomplete c3\n            return Output.error(new OutputException(Utf8DecodedOutput.invalid(c1, c2)));\n          } else { // awaiting c3\n            this.c2 = c2;\n            this.have = 2;\n          }\n        } else if (c1 === 0xf0 && c2 >= 0x90 && c2 <= 0xbf // U+10000..U+3FFFF\n                || c1 >= 0xf1 && c1 <= 0xf3 && c2 >= 0x80 && c2 <= 0xbf // U+40000..U+FFFFF\n                || c1 === 0xf4 && c2 >= 0x80 && c2 <= 0x8f) { // U+100000..U+10FFFF\n          if (c3 >= 0x80 && c3 <= 0xbf) {\n            if (c4 >= 0x80 && c4 <= 0xbf) {\n              this.have = 4;\n              (this as Mutable<this>).output = this.output.write((c1 & 0x07) << 18 | (c2 & 0x3f) << 12 | (c3 & 0x3f) << 6 | c4 & 0x3f);\n              this.c1 = -1;\n              this.c2 = -1;\n              this.c3 = -1;\n              this.have = 0;\n            } else if (c4 >= 0) { // invalid c4\n              if (this.errorMode.isFatal()) {\n                return Output.error(new OutputException(Utf8DecodedOutput.invalid(c1, c2, c3, c4)));\n              }\n              (this as Mutable<this>).output = this.output.write(this.errorMode.replacementChar);\n              this.c1 = c4;\n              this.c2 = -1;\n              this.c3 = -1;\n              this.have = 1;\n            } else if (token < 0 || this.output.isDone()) { // incomplete c4\n              return Output.error(new OutputException(Utf8DecodedOutput.invalid(c1, c2, c3)));\n            } else { // awaiting c4\n              this.c3 = c3;\n              this.have = 3;\n            }\n          } else if (c3 >= 0) { // invalid c3\n            if (this.errorMode.isFatal()) {\n              return Output.error(new OutputException(Utf8DecodedOutput.invalid(c1, c2, c3)));\n            }\n            (this as Mutable<this>).output = this.output.write(this.errorMode.replacementChar);\n            this.c1 = c3;\n            this.c2 = -1;\n            this.have = 1;\n          } else if (token < 0 || this.output.isDone()) { // incomplete c3\n            return Output.error(new OutputException(Utf8DecodedOutput.invalid(c1, c2)));\n          } else { // awaiting c3\n            this.c2 = c2;\n            this.have = 2;\n          }\n        } else if (c2 >= 0) { // invalid c2\n          if (this.errorMode.isFatal()) {\n            return Output.error(new OutputException(Utf8DecodedOutput.invalid(c1, c2)));\n          }\n          (this as Mutable<this>).output = this.output.write(this.errorMode.replacementChar);\n          this.c1 = c2;\n          this.have = 1;\n        } else if (token < 0 || this.output.isDone()) { // incomplete c2\n          return Output.error(new OutputException(Utf8DecodedOutput.invalid(c1)));\n        } else { // awaiting c2\n          this.c1 = c1;\n          this.have = 1;\n        }\n      } else if (c1 >= 0) { // invalid c1\n        if (this.errorMode.isFatal()) {\n          return Output.error(new OutputException(Utf8DecodedOutput.invalid(c1)));\n        }\n        (this as Mutable<this>).output = this.output.write(this.errorMode.replacementChar);\n        this.have = 0;\n      }\n      if (this.output.isError()) {\n        return this.output;\n      }\n      return this;\n    } else if (typeof token === \"string\") {\n      (this as Mutable<this>).output = this.output.write(token);\n      return this;\n    } else {\n      throw new TypeError(\"\" + token);\n    }\n  }\n\n  private static invalid(c1: number, c2?: number, c3?: number, c4?: number): string {\n    let output = Unicode.stringOutput();\n    output = output.write(\"invalid UTF-8 code unit sequence: \");\n    const base16 = Base16.uppercase;\n    base16.writeIntegerLiteral(output, c1, 2);\n    if (c2 !== void 0) {\n      output = output.write(' ');\n      base16.writeIntegerLiteral(output, c2, 2);\n      if (c3 !== void 0) {\n        output = output.write(' ');\n        base16.writeIntegerLiteral(output, c3, 2);\n        if (c4 !== void 0) {\n          output = output.write(' ');\n          base16.writeIntegerLiteral(output, c4, 2);\n        }\n      }\n    }\n    return output.bind();\n  }\n\n  override get settings(): OutputSettings {\n    return this.output.settings;\n  }\n\n  override withSettings(settings: OutputSettingsLike): Output<T> {\n    (this as Mutable<this>).output = this.output.withSettings(settings);\n    return this;\n  }\n\n  override bind(): T {\n    if (this.have === 0) {\n      return this.output.bind();\n    } else {\n      return this.write(-1).bind();\n    }\n  }\n\n  override trap(): Error {\n    return this.output.trap();\n  }\n\n  override clone(): Output<T> {\n    return new Utf8DecodedOutput(this.output.clone(), this.errorMode,\n                                 this.c1, this.c2, this.c3, this.have);\n  }\n\n  static create<T>(output: Output<T>, errorMode?: UtfErrorMode): Output<T> {\n    if (errorMode === void 0) {\n      errorMode = UtfErrorMode.fatal();\n    }\n    return new Utf8DecodedOutput(output, errorMode, -1, -1, -1, 0);\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {Mutable} from \"@swim/util\";\nimport {OutputException} from \"../output/OutputException\";\nimport type {OutputSettingsLike} from \"../output/OutputSettings\";\nimport type {OutputSettings} from \"../output/OutputSettings\";\nimport {Output} from \"../output/Output\";\nimport {UtfErrorMode} from \"./UtfErrorMode\";\n\n/** @internal */\nexport class Utf8EncodedOutput<T> extends Output<T> {\n  /** @internal */\n  readonly output: Output<T>;\n  /** @internal */\n  readonly errorMode: UtfErrorMode;\n  /** @internal */\n  c2: number;\n  /** @internal */\n  c3: number;\n  /** @internal */\n  c4: number;\n  /** @internal */\n  index: number;\n\n  constructor(output: Output<T>, errorMode: UtfErrorMode, c2: number,\n              c3: number, c4: number, index: number) {\n    super();\n    this.output = output;\n    this.errorMode = errorMode;\n    this.c2 = c2;\n    this.c3 = c3;\n    this.c4 = c4;\n    this.index = index;\n  }\n\n  override isCont(): boolean {\n    return this.output.isCont();\n  }\n\n  override isFull(): boolean {\n    return this.output.isFull();\n  }\n\n  override isDone(): boolean {\n    return this.output.isDone();\n  }\n\n  override isError(): boolean {\n    return false;\n  }\n\n  override isPart(): boolean {\n    return this.output.isPart();\n  }\n\n  override asPart(part: boolean): Output<T> {\n    (this as Mutable<this>).output = this.output.asPart(part);\n    return this;\n  }\n\n  override write(token: number | string): Output<T> {\n    if (typeof token === \"number\") {\n      let c1 = 0;\n      let c2 = this.c2;\n      let c3 = this.c3;\n      let c4 = this.c4;\n      let output = this.output;\n      let index = this.index;\n      while (index < 4) {\n        if (output.isCont()) {\n          switch (index) {\n            case 1: output = output.write(c2); this.c2 = 0; break;\n            case 2: output = output.write(c3); this.c3 = 0; break;\n            case 3: output = output.write(c4); this.c4 = 0; break;\n            default: throw new Error(\"unreachable\");\n          }\n          index += 1;\n        } else {\n          return Output.error(new OutputException(\"unable to flush buffered code units\"));\n        }\n      }\n      if (token >= 0 && token <= 0x7f) { // U+0000..U+007F\n        c4 = token;\n        index = 3;\n      } else if (token >= 0x80 && token <= 0x7ff) { // U+0080..U+07FF\n        c3 = 0xc0 | (token >>> 6);\n        c4 = 0x80 | (token & 0x3f);\n        index = 2;\n      } else if (token >= 0x0800 && token <= 0xffff || // U+0800..U+D7FF\n                 token >= 0xe000 && token <= 0xffff) { // U+E000..U+FFFF\n        c2 = 0xe0 | (token  >>> 12);\n        c3 = 0x80 | ((token >>>  6) & 0x3f);\n        c4 = 0x80 | (token & 0x3f);\n        index = 1;\n      } else if (token >= 0x10000 && token <= 0x10ffff) { // U+10000..U+10FFFF\n        c1 = 0xf0 | (token  >>> 18);\n        c2 = 0x80 | ((token >>> 12) & 0x3f);\n        c3 = 0x80 | ((token >>>  6) & 0x3f);\n        c4 = 0x80 | (token & 0x3f);\n        index = 0;\n      } else { // surrogate or invalid code point\n        if (this.errorMode.isFatal()) {\n          return Output.error(new OutputException(\"invalid code point: \" + token));\n        } else {\n          return this.write(this.errorMode.replacementChar);\n        }\n      }\n      do {\n        switch (index) {\n          case 0: output = output.write(c1); break;\n          case 1: output = output.write(c2); this.c2 = 0; break;\n          case 2: output = output.write(c3); this.c3 = 0; break;\n          case 3: output = output.write(c4); this.c4 = 0; break;\n          default: throw new Error(\"unreachable\");\n        }\n        (this as Mutable<this>).output = output;\n        index += 1;\n      } while (index < 4 && output.isCont());\n      if (index < 4) {\n        if (index < 3) {\n          if (index < 2) {\n            this.c2 = c2;\n          }\n          this.c3 = c3;\n        }\n        this.c4 = c4;\n      }\n      (this as Mutable<this>).output = output;\n      this.index = index;\n      return this;\n    } else if (typeof token === \"string\") {\n      (this as Mutable<this>).output = this.output.write(token);\n      return this;\n    } else {\n      throw new TypeError(\"\" + token);\n    }\n  }\n\n  override flush(): Output<T> {\n    let output = this.output;\n    let index = this.index;\n    while (index < 4) {\n      if (output.isCont()) {\n        switch (index) {\n          case 1: output = output.write(this.c2); this.c2 = 0; break;\n          case 2: output = output.write(this.c3); this.c3 = 0; break;\n          case 3: output = output.write(this.c4); this.c4 = 0; break;\n          default: throw new Error(\"unreachable\");\n        }\n        index += 1;\n      } else {\n        return Output.error(new OutputException(\"unable to flush buffered code units\"));\n      }\n    }\n    (this as Mutable<this>).output = output;\n    this.index = index;\n    return this;\n  }\n\n  override get settings(): OutputSettings {\n    return this.output.settings;\n  }\n\n  override withSettings(settings: OutputSettingsLike): Output<T> {\n    (this as Mutable<this>).output = this.output.withSettings(settings);\n    return this;\n  }\n\n  override bind(): T {\n    return this.output.bind();\n  }\n\n  override clone(): Output<T> {\n    return new Utf8EncodedOutput(this.output.clone(), this.errorMode,\n                                 this.c2, this.c3, this.c4, this.index);\n  }\n\n  static create<T>(output: Output<T>, errorMode?: UtfErrorMode): Output<T> {\n    if (errorMode === void 0) {\n      errorMode = UtfErrorMode.fatal();\n    }\n    return new Utf8EncodedOutput(output, errorMode, 0, 0, 0, 4);\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {Strings} from \"@swim/util\";\nimport type {Output} from \"../output/Output\";\nimport {Unicode} from \"./Unicode\";\nimport type {UtfErrorMode} from \"./UtfErrorMode\";\nimport {Utf8DecodedOutput} from \"./Utf8DecodedOutput\";\nimport {Utf8EncodedOutput} from \"./Utf8EncodedOutput\";\n\n/**\n * UTF-8 [[Input]]/[[Output]] factory.\n * @public\n */\nexport const Utf8 = (function () {\n  const Utf8 = {} as {\n    /**\n     * Returns the number of bytes in the UTF-8 encoding of the Unicode code\n     * point `c`, handling invalid code unit sequences according to the\n     * `errorMode` policy. Returns the size of the\n     * [[UtfErrorMode.replacementChar]] for surrogates and invalid code points,\n     * if [[UtfErrorMode.isReplacement]] is `true`; otherwise returns `0` for\n     * surrogates and invalid code points. Uses the two byte modified UTF-8\n     * encoding of the NUL character (`U+0000`), if [[UtfErrorMode.isNonZero]]\n     * is `true`.\n     */\n    sizeOf(c: number | undefined, errorMode?: UtfErrorMode): number;\n\n    /**\n     * Returns the number of bytes in the UTF-8 encoding of the Unicode code\n     * point `c`; returns the size of the Unicode replacement character (`U+FFFD`)\n     * for surrogates and invalid code points.\n     */\n    sizeOf(c: number | undefined): number;\n\n    /**\n     * Returns the number of bytes in the UTF-8 encoding the given `string`,\n     * handling invalid code unit sequences according to the `errorMode` policy.\n     */\n    sizeOf(string: string, errorMode?: UtfErrorMode): number;\n\n    /**\n     * Returns the number of bytes in the UTF-8 encoding the given `string`,\n     * assuming the Unicode replacement character (`U+FFFD`) replaces unpaired\n     * surrogates and invalid code points.\n     */\n    sizeOf(string: string): number;\n\n    /**\n     * Returns a new `Output` that accepts UTF-8 code unit sequences, and writes\n     * writes decoded Unicode code points to the composed `output`, handling\n     * invalid code unit sequences according to the `errorMode` policy.\n     */\n    decodedOutput<T>(output: Output<T>, errorMode?: UtfErrorMode): Output<T>;\n\n    /**\n     * Returns a new `Output` that accepts Unicode code points, and writes\n     * encoded UTF-8 code unit sequences to the composed `output`, handling\n     * invalid code unit sequences according to the `errorMode` policy.\n     */\n    encodedOutput<T>(output: Output<T>, errorMode?: UtfErrorMode): Output<T>;\n\n    /**\n     * Returns a new `Output` that accepts UTF-8 code unit sequences, and writes\n     * decoded Unicode code points to a growable `string`, handling invalid code\n     * unit sequences according to the [[UtfErrorMode.fatal]] policy. The\n     * returned `Output` accepts an unbounded number of UTF-8 code units,\n     * remaining permanently in the _cont_ state, and [[Output.bind binds]] a\n     * `string` containing all decoded code points.\n     */\n    decodedString(): Output<string>;\n  };\n\n  Utf8.sizeOf = function (u: string | number | undefined, errorMode?: UtfErrorMode): number {\n    if (typeof u === \"number\" || u === void 0) {\n      if (typeof u === \"number\") {\n        if (u === 0x0000 && errorMode !== void 0 && errorMode.isNonZero()) { // Modified UTF-8\n          return 2; // U+0000 encoded as 0xC0, 0x80\n        } else if (u >= 0x0000 && u <= 0x007F) { // U+0000..U+007F\n          return 1;\n        } else if (u >= 0x0080 && u <= 0x07FF) { // U+0080..U+07FF\n          return 2;\n        } else if (u >= 0x0800 && u <= 0xFFFF || // U+0800..U+D7FF\n                   u >= 0xE000 && u <= 0xFFFF) { // U+E000..U+FFFF\n          return 3;\n        } else if (u >= 0x10000 && u <= 0x10FFFF) { // U+10000..U+10FFFF\n          return 4;\n        }\n      }\n      // surrogate or invalid code point\n      if (errorMode === void 0) {\n        return 3;\n      } else if (errorMode.isReplacement()) {\n        return Utf8.sizeOf(errorMode.replacementChar);\n      } else {\n        return 0;\n      }\n    } else if (typeof u === \"string\") {\n      let size = 0;\n      for (let i = 0; i < u.length; i = Strings.offsetByCodePoints(u, i, 1)) {\n        size += Utf8.sizeOf(u.charCodeAt(i), errorMode);\n      }\n      return size;\n    } else {\n      throw new TypeError(\"\" + u);\n    }\n  };\n\n  Utf8.decodedOutput = function <T>(output: Output<T>, errorMode?: UtfErrorMode): Output<T> {\n    return Utf8DecodedOutput.create(output, errorMode);\n  };\n\n  Utf8.encodedOutput = function <T>(output: Output<T>, errorMode?: UtfErrorMode): Output<T> {\n    return Utf8EncodedOutput.create(output, errorMode);\n  };\n\n  Utf8.decodedString = function (): Output<string> {\n    return Utf8.decodedOutput(Unicode.stringOutput());\n  };\n\n  return Utf8;\n})();\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {Diagnostic} from \"../source/Diagnostic\";\nimport type {Input} from \"../input/Input\";\nimport type {Output} from \"../output/Output\";\nimport {Parser} from \"../parser/Parser\";\nimport {Unicode} from \"../unicode/Unicode\";\n\n/** @internal */\nexport class Base10NumberParser extends Parser<number> {\n  /** @internal */\n  readonly sign: number;\n  /** @internal */\n  readonly value: number;\n  /** @internal */\n  readonly mode: number;\n  /** @internal */\n  readonly step: number;\n\n  constructor(sign: number = 1, value: number = 0, mode: number = 2, step: number = 1) {\n    super();\n    this.sign = sign;\n    this.value = value;\n    this.mode = mode;\n    this.step = step;\n  }\n\n  override feed(input: Input): Parser<number> {\n    return Base10NumberParser.parse(input, this.sign, this.value, this.mode, this.step);\n  }\n\n  static parse(input: Input, sign: number = 1, value: number = 0,\n               mode: number = 2, step: number = 1): Parser<number> {\n    let c = 0;\n    if (step === 1) {\n      if (input.isCont()) {\n        c = input.head();\n        if (c === 45/*'-'*/) {\n          input = input.step();\n          sign = -1;\n        } else if (c === 43/*'+'*/) {\n          input = input.step();\n          sign = 1;\n        }\n        step = 2;\n      } else if (input.isDone()) {\n        return Parser.error(Diagnostic.expected(\"number\", input));\n      }\n    }\n    if (step === 2) {\n      if (input.isCont()) {\n        c = input.head();\n        if (c === 48/*'0'*/) {\n          input = input.step();\n          step = 4;\n        } else if (c >= 49/*'1'*/ && c <= 57/*'9'*/) {\n          input = input.step();\n          value = sign * (c - 48/*'0'*/);\n          step = 3;\n        } else if (mode > 0 && c === 46/*'.'*/) {\n          let output = Unicode.stringOutput();\n          if (sign < 0) {\n            output = output.write(45/*'-'*/);\n          }\n          return Base10DecimalParser.parse(input, output, mode);\n        } else {\n          return Parser.error(Diagnostic.expected(\"number\", input));\n        }\n      } else if (input.isDone()) {\n        return Parser.error(Diagnostic.expected(\"number\", input));\n      }\n    }\n    if (step === 3) {\n      while (input.isCont()) {\n        c = input.head();\n        if (c >= 48/*'0'*/ && c <= 57/*'9'*/) {\n          const newValue = 10 * value + sign * (c - 48/*'0'*/);\n          if (-9007199254740991 <= newValue && newValue <= 9007199254740992) {\n            value = newValue;\n            input = input.step();\n          } else {\n            return Parser.error(Diagnostic.message(\"integer overflow\", input));\n          }\n        } else {\n          break;\n        }\n      }\n      if (input.isCont()) {\n        step = 4;\n      } else if (input.isDone()) {\n        return Parser.done(value);\n      }\n    }\n    if (step === 4) {\n      if (input.isCont()) {\n        c = input.head();\n        if (mode > 0 && c === 46/*'.'*/ || mode > 1 && (c === 69/*'E'*/ || c === 101/*'e'*/)) {\n          let output = Unicode.stringOutput();\n          if (sign < 0 && value === 0) {\n            output = output.write(45/*'-'*/).write(48/*'0'*/);\n          } else {\n            output = output.write(\"\" + value);\n          }\n          return Base10DecimalParser.parse(input, output, mode);\n        } else {\n          return Parser.done(value);\n        }\n      } else if (input.isDone()) {\n        return Parser.done(value);\n      }\n    }\n    return new Base10NumberParser(sign, value, mode, step);\n  }\n}\n\n/** @internal */\nclass Base10DecimalParser extends Parser<number> {\n  /** @internal */\n  readonly output: Output<string>;\n  /** @internal */\n  readonly mode: number;\n  /** @internal */\n  readonly step: number;\n\n  constructor(output: Output<string>, mode: number = 2, step: number = 1) {\n    super();\n    this.output = output;\n    this.mode = mode;\n    this.step = step;\n  }\n\n  override feed(input: Input): Parser<number> {\n    return Base10DecimalParser.parse(input, this.output, this.mode, this.step);\n  }\n\n  static parse(input: Input, output: Output<string>, mode: number = 2,\n               step: number = 1): Parser<number> {\n    let c = 0;\n    if (step === 1) {\n      if (input.isCont()) {\n        c = input.head();\n        if (c === 46/*'.'*/) {\n          input = input.step();\n          output = output.write(c);\n          step = 2;\n        } else if (mode > 1 && (c === 69/*'E'*/ || c === 101/*'e'*/)) {\n          input = input.step();\n          output = output.write(c);\n          step = 5;\n        } else {\n          return Parser.error(Diagnostic.expected(\"decimal or exponent\", input));\n        }\n      } else if (input.isDone()) {\n        return Parser.error(Diagnostic.expected(\"decimal or exponent\", input));\n      }\n    }\n    if (step === 2) {\n      if (input.isCont()) {\n        c = input.head();\n        if (c >= 48/*'0'*/ && c <= 57/*'9'*/) {\n          input = input.step();\n          output = output.write(c);\n          step = 3;\n        } else {\n          return Parser.error(Diagnostic.expected(\"digit\", input));\n        }\n      } else if (input.isDone()) {\n        return Parser.error(Diagnostic.expected(\"digit\", input));\n      }\n    }\n    if (step === 3) {\n      while (input.isCont()) {\n        c = input.head();\n        if (c >= 48/*'0'*/ && c <= 57/*'9'*/) {\n          input = input.step();\n          output = output.write(c);\n        } else {\n          break;\n        }\n      }\n      if (input.isCont()) {\n        if (mode > 1) {\n          step = 4;\n        } else {\n          return Parser.done(+output.bind());\n        }\n      } else if (input.isDone()) {\n        return Parser.done(+output.bind());\n      }\n    }\n    if (step === 4) {\n      c = input.head();\n      if (c === 69/*'E'*/ || c === 101/*'e'*/) {\n        input = input.step();\n        output = output.write(c);\n        step = 5;\n      } else {\n        return Parser.done(+output.bind());\n      }\n    }\n    if (step === 5) {\n      if (input.isCont()) {\n        c = input.head();\n        if (c === 43/*'+'*/ || c === 45/*'-'*/) {\n          input = input.step();\n          output = output.write(c);\n        }\n        step = 6;\n      } else if (input.isDone()) {\n        return Parser.error(Diagnostic.unexpected(input));\n      }\n    }\n    if (step === 6) {\n      if (input.isCont()) {\n        c = input.head();\n        if (c >= 48/*'0'*/ && c <= 57/*'9'*/) {\n          input = input.step();\n          output = output.write(c);\n          step = 7;\n        } else {\n          return Parser.error(Diagnostic.expected(\"digit\", input));\n        }\n      } else if (input.isDone()) {\n        return Parser.error(Diagnostic.expected(\"digit\", input));\n      }\n    }\n    if (step === 7) {\n      while (input.isCont()) {\n        c = input.head();\n        if (c >= 48/*'0'*/ && c <= 57/*'9'*/) {\n          input = input.step();\n          output = output.write(c);\n        } else {\n          break;\n        }\n      }\n      if (!input.isEmpty()) {\n        return Parser.done(+output.bind());\n      }\n    }\n    return new Base10DecimalParser(output, mode, step);\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {Output} from \"../output/Output\";\nimport {WriterException} from \"../writer/WriterException\";\nimport {Writer} from \"../writer/Writer\";\nimport {Base10} from \"./Base10\";\n\n/** @internal */\nexport class Base10IntegerWriter extends Writer {\n  /** @internal */\n  readonly value: unknown;\n  /** @internal */\n  readonly input: number;\n  /** @internal */\n  readonly index: number;\n  /** @internal */\n  readonly step: number;\n\n  constructor(value: unknown, input: number, index: number = 0, step: number = 1) {\n    super();\n    this.value = value;\n    this.input = input;\n    this.index = index;\n    this.step = step;\n  }\n\n  override pull(output: Output): Writer {\n    return Base10IntegerWriter.write(output, this.value, this.input, this.index, this.step);\n  }\n\n  static write(output: Output, value: unknown, input: number, index: number = 0,\n               step: number = 1): Writer {\n    if (step === 0) {\n      return Writer.end();\n    }\n    if (step === 1) {\n      if (input < 0) {\n        if (output.isCont()) {\n          output = output.write(45/*'-'*/);\n          step = 2;\n        }\n      } else {\n        step = 2;\n      }\n    }\n    if (step === 2) {\n      if (input > -10 && input < 10) {\n        if (output.isCont()) {\n          output = output.write(Base10.encodeDigit(Math.abs(input | 0)));\n          return Writer.done(value);\n        }\n      } else {\n        const digits = new Array<number>(19);\n        let x = input;\n        let i = 18;\n        while (x !== 0) {\n          digits[i] = Math.abs((x % 10) | 0);\n          x = (x / 10) | 0;\n          i -= 1;\n        }\n        i += 1 + index;\n        while (i < 19 && output.isCont()) {\n          output = output.write(Base10.encodeDigit(digits[i]!));\n          index += 1;\n          i += 1;\n        }\n        if (i === 19) {\n          return Writer.done(value);\n        }\n      }\n    }\n    if (output.isDone()) {\n      return Writer.error(new WriterException(\"truncated\"));\n    } else if (output.isError()) {\n      return Writer.error(output.trap());\n    }\n    return new Base10IntegerWriter(value, input, index, step);\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {Diagnostic} from \"../source/Diagnostic\";\nimport type {Input} from \"../input/Input\";\nimport type {Output} from \"../output/Output\";\nimport {Parser} from \"../parser/Parser\";\nimport {Base16} from \"./Base16\";\n\n/** @internal */\nexport class Base16Parser<O> extends Parser<O> {\n  /** @internal */\n  readonly output: Output<O>;\n  /** @internal */\n  readonly p: number;\n  /** @internal */\n  readonly step: number;\n\n  constructor(output: Output<O>, p: number = 0, step: number = 1) {\n    super();\n    this.output = output;\n    this.p = p;\n    this.step = step;\n  }\n\n  override feed(input: Input): Parser<O> {\n    return Base16Parser.parse(input, this.output.clone(), this.p, this.step);\n  }\n\n  static parse<O>(input: Input, output: Output<O>, p: number = 0, step: number = 1): Parser<O> {\n    let c = 0;\n    while (!input.isEmpty()) {\n      if (step === 1) {\n        if (input.isCont() && (c = input.head(), Base16.isDigit(c))) {\n          input = input.step();\n          p = c;\n          step = 2;\n        } else if (!input.isEmpty()) {\n          return Parser.done(output.bind());\n        }\n      }\n      if (step === 2) {\n        if (input.isCont() && (c = input.head(), Base16.isDigit(c))) {\n          input = input.step();\n          output = Base16.writeQuantum(output, p, c);\n          p = 0;\n          step = 1;\n        } else if (!input.isEmpty()) {\n          return Parser.error(Diagnostic.expected(\"base16 digit\", input));\n        }\n      }\n    }\n    return new Base16Parser<O>(output, p, step);\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {Output} from \"../output/Output\";\nimport {WriterException} from \"../writer/WriterException\";\nimport {Writer} from \"../writer/Writer\";\nimport type {Base16} from \"./Base16\";\n\n/** @internal */\nexport class Base16Writer extends Writer {\n  /** @internal */\n  readonly base16: Base16;\n  /** @internal */\n  readonly value: unknown;\n  /** @internal */\n  readonly input: Uint8Array | null;\n  /** @internal */\n  readonly index: number;\n  /** @internal */\n  readonly step: number;\n\n  constructor(base16: Base16, value: unknown, input: Uint8Array | null,\n              index: number = 0, step: number = 1) {\n    super();\n    this.base16 = base16;\n    this.value = value;\n    this.input = input;\n    this.index = index;\n    this.step = step;\n  }\n\n  override feed(value: unknown): Writer {\n    if (value instanceof Uint8Array) {\n      return new Base16Writer(this.base16, void 0, value);\n    } else {\n      throw new TypeError(\"\" + value);\n    }\n  }\n\n  override pull(output: Output): Writer {\n    if (this.input === null) {\n      throw new WriterException();\n    }\n    return Base16Writer.write(output, this.base16, this.value, this.input,\n                              this.index, this.step);\n  }\n\n  static write(output: Output, base16: Base16, value: unknown, input: Uint8Array,\n               index: number = 0, step: number = 1): Writer {\n    while (index < input.length) {\n      const x = input[index]!;\n      if (step === 1 && output.isCont()) {\n        output = output.write(base16.encodeDigit(x >>> 4));\n        step = 2;\n      }\n      if (step === 2 && output.isCont()) {\n        output = output.write(base16.encodeDigit(x & 0x0f));\n        index += 1;\n        step = 1;\n      }\n    }\n    if (index === input.length) {\n      return Writer.done(value);\n    } else if (output.isDone()) {\n      return Writer.error(new WriterException(\"truncated\"));\n    } else if (output.isError()) {\n      return Writer.error(output.trap());\n    }\n    return new Base16Writer(base16, value, input, index, step);\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {Output} from \"../output/Output\";\nimport {WriterException} from \"../writer/WriterException\";\nimport {Writer} from \"../writer/Writer\";\nimport type {Base16} from \"./Base16\";\n\n/** @internal */\nexport class Base16IntegerWriter extends Writer {\n  /** @internal */\n  readonly base16: Base16;\n  /** @internal */\n  readonly value: unknown;\n  /** @internal */\n  readonly input: number;\n  /** @internal */\n  readonly width: number;\n  /** @internal */\n  readonly index: number;\n  /** @internal */\n  readonly step: number;\n\n  constructor(base16: Base16, value: unknown, input: number,\n              width: number, index: number = 0, step: number = 3) {\n    super();\n    this.base16 = base16;\n    this.value = value;\n    this.input = input;\n    this.width = width;\n    this.index = index;\n    this.step = step;\n  }\n\n  override pull(output: Output): Writer {\n    return Base16IntegerWriter.write(output, this.base16, this.value, this.input,\n                                     this.width, this.index, this.step);\n  }\n\n  static write(output: Output, base16: Base16, value: unknown, input: number,\n               width: number, index: number = 0, step: number = 3): Writer {\n    if (step <= 0) {\n      return Writer.end();\n    }\n    if (step === 1 && output.isCont()) {\n      output = output.write(48/*'0'*/);\n      step = 2;\n    }\n    if (step === 2 && output.isCont()) {\n      output = output.write(120/*'x'*/);\n      step = 3;\n    }\n    if (step === 3) {\n      if (input >= 0 && input < 16 && width <= 1) {\n        if (output.isCont()) {\n          output = output.write(base16.encodeDigit(input));\n          return Writer.done(value);\n        }\n      } else {\n        let i = 15;\n        const digits = new Array<number>(16);\n        let x = input;\n        while (x !== 0 || i >= 16 - width) {\n          digits[i] = x & 0xf;\n          x >>>= 4;\n          i -= 1;\n        }\n        i += 1 + index;\n        while (i < 16 && output.isCont()) {\n          output = output.write(base16.encodeDigit(digits[i]!));\n          index += 1;\n          i += 1;\n        }\n        if (i === 16) {\n          return Writer.done(value);\n        }\n      }\n    }\n    if (output.isDone()) {\n      return Writer.error(new WriterException(\"truncated\"));\n    } else if (output.isError()) {\n      return Writer.error(output.trap());\n    }\n    return new Base16IntegerWriter(base16, value, input, width, index, step);\n  }\n\n  static writeLiteral(output: Output, base16: Base16, value: unknown,\n                      input: number, width: number): Writer {\n    return Base16IntegerWriter.write(output, base16, value, input, width, 0, 1);\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {Lazy} from \"@swim/util\";\nimport type {Input} from \"../input/Input\";\nimport {Output} from \"../output/Output\";\nimport type {Parser} from \"../parser/Parser\";\nimport type {Writer} from \"../writer/Writer\";\nimport {Format} from \"../format/Format\";\nimport {Binary} from \"../binary/Binary\";\nimport {Unicode} from \"../unicode/Unicode\";\nimport {Base64Parser} from \"../\"; // forward import\nimport {Base64Writer} from \"../\"; // forward import\n\n/**\n * Base-64 (7-bit ASCII) encoding [[Parser]]/[[Writer]] factory.\n * @public\n */\nexport abstract class Base64 {\n  /**\n   * The 64 character string, where the character at index `i` is the encoding\n   * of the base-64 digit `i`.\n   */\n  abstract readonly alphabet: string;\n\n  /**\n   * Returns `true` if this base-64 encoding requires padding.\n   */\n  abstract isPadded(): boolean;\n\n  /**\n   * Returns this `Base64` encoding with required padding, if `padded` is `true`.\n   */\n  abstract asPadded(padded: boolean): Base64;\n\n  /**\n   * Returns `true` if the Unicode code point `c` is a valid base-64 digit.\n   */\n  abstract isDigit(c: number): boolean;\n\n  /**\n   * Returns the 7-bit quantity represented by the base-64 digit `c`.\n   *\n   * @throws `Error` if `c` is not a valid base-64 digit.\n   */\n  decodeDigit(c: number): number {\n    if (c >= 65/*'A'*/ && c <= 90/*'Z'*/) {\n      return c - 65/*'A'*/;\n    } else if (c >= 97/*'a'*/ && c <= 122/*'z'*/) {\n      return c + (26 - 97/*'a'*/);\n    } else if (c >= 48/*'0'*/ && c <= 57/*'9'*/) {\n      return c + (52 - 48/*'0'*/);\n    } else if (c === 43/*'+'*/ || c === 45/*'-'*/) {\n      return 62;\n    } else if (c === 47/*'/'*/ || c === 95/*'_'*/) {\n      return 63;\n    } else {\n      let message = Unicode.stringOutput();\n      message = message.write(\"Invalid base-64 digit: \");\n      message = Format.debugChar(message, c);\n      throw new Error(message.bind());\n    }\n  }\n\n  /**\n   * Returns the Unicode code point of the base-64 digit that encodes the given\n   * 7-bit quantity.\n   */\n  encodeDigit(b: number): number {\n    return this.alphabet.charCodeAt(b);\n  }\n\n  /**\n   * Decodes the base-64 digits `c1`, `c2`, `c3`, and `c4`, and writes the 8 to\n   * 24 bit quantity they represent to the given `output`.\n   *\n   * @returns the continuation of the `output`.\n   */\n  writeQuantum<T>(output: Output<T>, c1: number, c2: number, c3: number, c4: number): Output<T> {\n    const x = this.decodeDigit(c1);\n    const y = this.decodeDigit(c2);\n    if (c3 !== 61/*'='*/) {\n      const z = this.decodeDigit(c3);\n      if (c4 !== 61/*'='*/) {\n        const w = this.decodeDigit(c4);\n        output = output.write((x << 2) | (y >>> 4));\n        output = output.write((y << 4) | (z >>> 2));\n        output = output.write((z << 6) | w);\n      } else {\n        output = output.write((x << 2) | (y >>> 4));\n        output = output.write((y << 4) | (z >>> 2));\n      }\n    } else {\n      if (c4 !== 61/*'='*/) {\n        return Output.error(new Error(\"Improperly padded base-64\"));\n      }\n      output = output.write((x << 2) | (y >>> 4));\n    }\n    return output;\n  }\n\n  /**\n   * Returns a `Parser` that decodes base-64 (7-bit ASCII) encoded input, and\n   * writes the decoded bytes to `output`.\n   */\n  parser<O>(output: Output<O>): Parser<O> {\n    return new Base64Parser<O>(this, output);\n  }\n\n  /**\n   * Parses the base-64 (7-bit ASCII) encoded `input`, and writes the decoded\n   * bytes to `output`, returning a `Parser` continuation that knows how to\n   * parse any additional input.\n   */\n  parse<O>(input: Input, output: Output<O>): Parser<O> {\n    return Base64Parser.parse(input, this, output);\n  }\n\n  /**\n   * Parses the base-64 (7-bit ASCII) encoded `input`, and writes the decoded\n   * bytes to a growable array, returning a `Parser` continuation that knows\n   * how to parse any additional input. The returned `Parser` [[Parser.bind\n   * binds]] a `Uint8Array` array containing all parsed base-64 data.\n   */\n  parseUint8Array(input: Input): Parser<Uint8Array> {\n    return Base64Parser.parse(input, this, Binary.output());\n  }\n\n  /**\n   * Returns a `Writer` that, when fed an input `Uint8Array`, returns a\n   * continuation that writes the base-64 (7-bit ASCII) encoding of the input\n   * `Uint8Array`.\n   */\n  uint8ArrayWriter(): Writer<Uint8Array, unknown>;\n  /**\n   * Returns a `Writer` continuation that writes the base-64 (7-bit ASCII)\n   * encoding of the `input` byte array.\n   */\n  uint8ArrayWriter(input: Uint8Array): Writer<unknown, Uint8Array>;\n  uint8ArrayWriter(input?: Uint8Array): Writer {\n    if (input === void 0) {\n      return new Base64Writer(this, void 0, null);\n    } else {\n      return new Base64Writer(this, input, input);\n    }\n  }\n\n  /**\n   * Writes the base-64 (7-bit ASCII) encoding of the `input` `Uint8Array` to\n   * the `output`, returning a `Writer` continuation that knows how to write\n   * any remaining output that couldn't be immediately generated.\n   */\n  writeUint8Array(output: Output, input: Uint8Array): Writer {\n    return Base64Writer.write(output, this, void 0, input);\n  }\n\n  /** @internal */\n  @Lazy\n  static get standardPadded(): Base64 {\n    return new Base64Standard(true);\n  }\n\n  /** @internal */\n  @Lazy\n  static get standardUnpadded(): Base64 {\n    return new Base64Standard(false);\n  }\n\n  /**\n   * Returns the `Base64` encoding with the standard alphabet, and required\n   * padding, if `isPadding` is `true`.\n   */\n  static standard(padded: boolean = true): Base64 {\n    if (padded) {\n      return Base64.standardPadded;\n    } else {\n      return Base64.standardUnpadded;\n    }\n  }\n\n  /** @internal */\n  @Lazy\n  static get urlPadded(): Base64 {\n    return new Base64Url(true);\n  }\n\n  /** @internal */\n  @Lazy\n  static get urlUnpadded(): Base64 {\n    return new Base64Url(false);\n  }\n\n  /**\n   * Returns the `Base64` encoding with the url and filename safe alphabet,\n   * and required padding, if `padded` is `true`.\n   */\n  static url(padded: boolean = true): Base64 {\n    if (padded) {\n      return Base64.urlPadded;\n    } else {\n      return Base64.urlUnpadded;\n    }\n  }\n}\n\n/** @internal */\nclass Base64Standard extends Base64 {\n  constructor(padded: boolean) {\n    super();\n    Object.defineProperty(this, \"padded\", {\n      value: padded,\n      enumerable: true,\n    });\n  }\n\n  get alphabet(): string {\n    return \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n  }\n\n  /** @internal */\n  readonly padded!: boolean;\n\n  isPadded(): boolean {\n    return this.padded;\n  }\n\n  asPadded(padded: boolean): Base64 {\n    if (padded === this.padded) {\n      return this;\n    } else {\n      return Base64.standard(padded);\n    }\n  }\n\n  isDigit(c: number): boolean {\n    return c >= 48/*'0'*/ && c <= 57/*'9'*/\n        || c >= 65/*'A'*/ && c <= 90/*'Z'*/\n        || c >= 97/*'a'*/ && c <= 122/*'z'*/\n        || c === 43/*'+'*/ || c === 47/*'/'*/;\n  }\n}\n\n/** @internal */\nclass Base64Url extends Base64 {\n  constructor(padded: boolean) {\n    super();\n    Object.defineProperty(this, \"padded\", {\n      value: padded,\n      enumerable: true,\n    });\n  }\n\n  get alphabet(): string {\n    return \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_\";\n  }\n\n  /** @internal */\n  readonly padded!: boolean;\n\n  isPadded(): boolean {\n    return this.padded;\n  }\n\n  asPadded(padded: boolean): Base64 {\n    if (padded === this.padded) {\n      return this;\n    } else {\n      return Base64.url(padded);\n    }\n  }\n\n  isDigit(c: number): boolean {\n    return c >= 48/*'0'*/ && c <= 57/*'9'*/\n        || c >= 65/*'A'*/ && c <= 90/*'Z'*/\n        || c >= 97/*'a'*/ && c <= 122/*'z'*/\n        || c === 45/*'-'*/ || c === 95/*'_'*/;\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {Diagnostic} from \"../source/Diagnostic\";\nimport type {Input} from \"../input/Input\";\nimport type {Output} from \"../output/Output\";\nimport {Parser} from \"../parser/Parser\";\nimport type {Base64} from \"./Base64\";\n\n/** @internal */\nexport class Base64Parser<O> extends Parser<O> {\n  /** @internal */\n  readonly base64: Base64;\n  /** @internal */\n  readonly output: Output<O>;\n  /** @internal */\n  readonly p: number;\n  /** @internal */\n  readonly q: number;\n  /** @internal */\n  readonly r: number;\n  /** @internal */\n  readonly step: number;\n\n  constructor(base64: Base64, output: Output<O>, p: number = 0, q: number = 0,\n              r: number = 0, step: number = 1) {\n    super();\n    this.base64 = base64;\n    this.output = output;\n    this.p = p;\n    this.q = q;\n    this.r = r;\n    this.step = step;\n  }\n\n  override feed(input: Input): Parser<O> {\n    return Base64Parser.parse(input, this.base64, this.output.clone(),\n                              this.p, this.q, this.r, this.step);\n  }\n\n  static parse<O>(input: Input, base64: Base64, output: Output<O>, p: number = 0,\n                  q: number = 0, r: number = 0, step: number = 1): Parser<O> {\n    let c = 0;\n    while (!input.isEmpty()) {\n      if (step === 1) {\n        if (input.isCont() && (c = input.head(), base64.isDigit(c))) {\n          input = input.step();\n          p = c;\n          step = 2;\n        } else if (!input.isEmpty()) {\n          return Parser.done(output.bind());\n        }\n      }\n      if (step === 2) {\n        if (input.isCont() && (c = input.head(), base64.isDigit(c))) {\n          input = input.step();\n          q = c;\n          step = 3;\n        } else if (!input.isEmpty()) {\n          return Parser.error(Diagnostic.expected(\"base64 digit\", input));\n        }\n      }\n      if (step === 3) {\n        if (input.isCont() && (c = input.head(), base64.isDigit(c) || c === 61/*'='*/)) {\n          input = input.step();\n          r = c;\n          if (c !== 61/*'='*/) {\n            step = 4;\n          } else {\n            step = 5;\n          }\n        } else if (!input.isEmpty()) {\n          if (!base64.isPadded()) {\n            output = base64.writeQuantum(output, p, q, 61/*'='*/, 61/*'='*/);\n            return Parser.done(output.bind());\n          } else {\n            return Parser.error(Diagnostic.unexpected(input));\n          }\n        }\n      }\n      if (step === 4) {\n        if (input.isCont() && (c = input.head(), base64.isDigit(c) || c === 61/*'='*/)) {\n          input = input.step();\n          output = base64.writeQuantum(output, p, q, r, c);\n          r = 0;\n          q = 0;\n          p = 0;\n          if (c !== 61/*'='*/) {\n            step = 1;\n          } else {\n            return Parser.done(output.bind());\n          }\n        } else if (!input.isEmpty()) {\n          if (!base64.isPadded()) {\n            output = base64.writeQuantum(output, p, q, r, 61/*'='*/);\n            return Parser.done(output.bind());\n          } else {\n            return Parser.error(Diagnostic.unexpected(input));\n          }\n        }\n      } else if (step === 5) {\n        if (input.isCont() && (c = input.head(), c === 61/*'='*/)) {\n          input = input.step();\n          output = base64.writeQuantum(output, p, q, r, c);\n          r = 0;\n          q = 0;\n          p = 0;\n          return Parser.done(output.bind());\n        } else if (!input.isEmpty()) {\n          return Parser.error(Diagnostic.expected(61/*'='*/, input));\n        }\n      }\n    }\n    return new Base64Parser<O>(base64, output, p, q, r, step);\n  }\n}\n","// Copyright 2015-2024 Nstream, inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {Output} from \"../output/Output\";\nimport {WriterException} from \"../writer/WriterException\";\nimport {Writer} from \"../writer/Writer\";\nimport type {Base64} from \"./Base64\";\n\n/** @internal */\nexport class Base64Writer extends Writer {\n  /** @internal */\n  readonly base64: Base64;\n  /** @internal */\n  readonly value: unknown;\n  /** @internal */\n  readonly input: Uint8Array | null;\n  /** @internal */\n  readonly index: number;\n  /** @internal */\n  readonly step: number;\n\n  constructor(base64: Base64, value: unknown, input: Uint8Array | null,\n              index: number = 0, step: number = 1) {\n    super();\n    this.base64 = base64;\n    this.value = value;\n    this.input = input;\n    this.index = index;\n    this.step = step;\n  }\n\n  override feed(value: unknown): Writer {\n    if (value instanceof Uint8Array) {\n      return new Base64Writer(this.base64, null, value);\n    } else {\n      throw new TypeError(\"\" + value);\n    }\n  }\n\n  override pull(output: Output): Writer {\n    if (this.input === null) {\n      throw new WriterException();\n    }\n    return Base64Writer.write(output, this.base64, this.value, this.input,\n                              this.index, this.step);\n  }\n\n  static write(output: Output, base64: Base64, value: unknown, input: Uint8Array,\n               index: number = 0, step: number = 1): Writer {\n    while (index + 2 < input.length && output.isCont()) {\n      const x = input[index]!;\n      const y = input[index + 1]!;\n      const z = input[index + 2]!;\n      if (step === 1 && output.isCont()) {\n        output = output.write(base64.encodeDigit(x >>> 2));\n        step = 2;\n      }\n      if (step === 2 && output.isCont()) {\n        output = output.write(base64.encodeDigit(((x << 4) | (y >>> 4)) & 0x3f));\n        step = 3;\n      }\n      if (step === 3 && output.isCont()) {\n        output = output.write(base64.encodeDigit(((y << 2) | (z >>> 6)) & 0x3f));\n        step = 4;\n      }\n      if (step === 4 && output.isCont()) {\n        output = output.write(base64.encodeDigit(z & 0x3f));\n        index += 3;\n        step = 1;\n      }\n    }\n    if (index + 1 < input.length && output.isCont()) {\n      const x = input[index]!;\n      const y = input[index + 1]!;\n      if (step === 1 && output.isCont()) {\n        output = output.write(base64.encodeDigit(x >>> 2));\n        step = 2;\n      }\n      if (step === 2 && output.isCont()) {\n        output = output.write(base64.encodeDigit(((x << 4) | (y >>> 4)) & 0x3f));\n        step = 3;\n      }\n      if (step === 3 && output.isCont()) {\n        output = output.write(base64.encodeDigit((y << 2) & 0x3f));\n        step = 4;\n      }\n      if (step === 4) {\n        if (!base64.isPadded()) {\n          index += 2;\n        } else if (output.isCont()) {\n          output = output.write(61/*'='*/);\n          index += 2;\n        }\n      }\n    } else if (index < input.length && output.isCont()) {\n      const x = input[index]!;\n      if (step === 1 && output.isCont()) {\n        output = output.write(base64.encodeDigit(x >>> 2));\n        step = 2;\n      }\n      if (step === 2 && output.isCont()) {\n        output = output.write(base64.encodeDigit((x << 4) & 0x3f));\n        step = 3;\n      }\n      if (step === 3) {\n        if (!base64.isPadded()) {\n          index += 1;\n        } else if (output.isCont()) {\n          output = output.write(61/*'='*/);\n          step = 4;\n        }\n      }\n      if (step === 4 && output.isCont()) {\n        output = output.write(61/*'='*/);\n        index += 1;\n      }\n    }\n    if (index === input.length) {\n      return Writer.done(value);\n    } else if (output.isDone()) {\n      return Writer.error(new WriterException(\"truncated\"));\n    } else if (output.isError()) {\n      return Writer.error(output.trap());\n    }\n    return new Base64Writer(base64, value, input, index, step);\n  }\n}\n"],"names":["Tag","Mark","_a","_classSuper","constructor","offset","line","column","note","super","this","withNote","at","min","that","max","start","end","union","Span","from","Error","toString","shift","mark","equals","hashCode","Murmur3","mash","mix","Constructors","hash","Numbers","Strings","display","output","Format","displayNumber","write","debug","debugNumber","debugString","zero","Lazy","__esDecorate","_static_get_zero_decorators","kind","name","static","private","access","has","obj","get","metadata","_metadata","_staticExtraInitializers","__runInitializers","tmp","OutputStyle","reset","settings","isStyled","bold","faint","black","red","green","yellow","blue","magenta","cyan","gray","blackBold","redBold","greenBold","yellowBold","blueBold","magentaBold","cyanBold","grayBold","OutputSettings","lineSeparator","pretty","styled","precision","Object","defineProperty","value","enumerable","withLineSeparator","copy","isPretty","asPretty","asStyled","withPrecision","create","canEqual","Booleans","standard","prettyStyled","fromInit","init","fromLike","_static_standard_decorators","_static_pretty_decorators","_static_styled_decorators","_static_prettyStyled_decorators","InputException","message","setPrototypeOf","prototype","InputSettings","stripped","isStripped","asStripped","_static_stripped_decorators","Input","trap","empty","InputEmpty","done","InputDone","error","InputError","_static_empty_decorators","_static_done_decorators","id","isCont","isEmpty","isDone","isError","isPart","asPart","part","head","step","seek","withId","withMark","withSettings","clone","StringInput","string","index","length","c","codePointAt","charCodeAt","offsetByCodePoints","OutputException","Output","writeln","object","displayAny","debugAny","flush","push","tokens","n","i","full","OutputFull","OutputDone","OutputError","_static_full_decorators","StringOutput","isFull","token","String","fromCharCode","u","concat","bind","WriterException","Writer","feed","input","fork","condition","asDone","asError","andThen","WriterSequence","WriterEnd","WriterDone","WriterError","_static_end_decorators","StringWriter","pull","Unicode","stringInput","stringOutput","stringWriter","writeString","isAlpha","isDigit","isSpace","isNewline","isWhitespace","OS","EOL","configurable","isFinite","Math","floor","abs","digits","Array","x","decimal","debugChar","encodeHex","prefix","prefixes","exponential","toExponential","exponentIndex","indexOf","exponent","slice","NaN","power","scaled","pow","s","trimTrailingZeros","toFixed","i0","i1","duration","millis","separator","SECOND","MINUTE","HOUR","DAY","WEEK","weeks","days","hours","minutes","seconds","Base10","decodeDigit","encodeDigit","b","countDigits","size","integerParser","Base10NumberParser","parseInteger","parse","decimalParser","parseDecimal","numberParser","parseNumber","integerWriter","Base10IntegerWriter","writeInteger","Diagnostic","tag","severity","cause","lineDigits","contextLines","displayMessage","displayAnchor","cont","displayContext","next","formatSeverity","label","displayLineLeadArrow","displayLineLead","sameCause","Values","equal","causeOrder","displayLineLeadEllipsis","displayLines","displayNote","startLine","endLine","consumeLineText","displayLine","displayLineComment","displaySingleLine","displayStartLine","displayEndLine","displayMidLine","displayLineLeadNumber","displayLineText","comment","displayLineLeadComment","padding","level","Severity","FatalLevel","AlertLevel","ErrorLevel","WarningLevel","NoteLevel","InfoLevel","DebugLevel","TraceLevel","arguments","source","unexpected","expected","InputBuffer","InputBufferEmpty","InputBufferDone","InputBufferError","withIndex","limit","withLimit","capacity","remaining","set","tokenOrString","OutputBuffer","OutputBufferFull","OutputBufferDone","OutputBufferError","ParserException","diagnostic","Parser","ParserDone","ParserError","tail","ByteOutput","array","oldArray","newArray","Uint8Array","expand","TypeError","toUint8Array","cloneArray","ByteOutputUint8Array","ByteOutputBuffer","buffer","Binary","initialCapacity","outputBuffer","UtfErrorMode","isFatal","isReplacement","fatal","UtfErrorModeFatal","fatalNonZero","replacement","UtfErrorModeReplacement","replacementNonZero","_static_fatal_decorators","_static_fatalNonZero_decorators","_static_replacement_decorators","_static_replacementNonZero_decorators","nonZero","replacementChar","isNonZero","asNonZero","Base16","alphabet","uint8ArrayWriter","Base16Writer","writeUint8Array","width","Base16IntegerWriter","writeIntegerLiteral","writeLiteral","lowercase","uppercase","writeQuantum","c1","c2","y","parser","Base16Parser","parseUint8Array","_static_get_lowercase_decorators","_static_get_uppercase_decorators","Utf8DecodedOutput","errorMode","c3","have","c4","invalid","base16","Utf8EncodedOutput","Utf8","sizeOf","decodedOutput","encodedOutput","decodedString","sign","mode","Base10DecimalParser","newValue","p","Base64","z","w","Base64Parser","Base64Writer","standardPadded","Base64Standard","standardUnpadded","padded","urlPadded","Base64Url","urlUnpadded","url","_static_get_standardPadded_decorators","_static_get_standardUnpadded_decorators","_static_get_urlPadded_decorators","_static_get_urlUnpadded_decorators","isPadded","asPadded","base64","q","r"],"mappings":";;;;;;;MA4BsBA;;ICCTC,OAAI;;oBAASD;;;EAAb,OAAAE,KAAA,MAAAD,aAAaE;IAExB,WAAAC,CAAYC,QAAgBC,MAAcC,QAAgBC;MACxDC;MACAC,KAAKL,SAASA;MACdK,KAAKJ,OAAOA;MACZI,KAAKH,SAASA;MACdG,KAAKF,OAAOA;AACb;IAuBD,QAAAG,CAASH;MACP,IAAIE,KAAKF,SAASA,MAAM;QACtB,OAAON,GAAKU,GAAGF,KAAKL,QAAQK,KAAKJ,MAAMI,KAAKH,QAAQC;AACrD,aAAM;QACL,OAAOE;AACR;AACF;IAMD,GAAAG,CAAIC;MACF,OAAOJ,KAAKL,UAAUS,KAAKT,SAASK,OAAOI;AAC5C;IAMD,GAAAC,CAAID;MACF,OAAOJ,KAAKL,UAAUS,KAAKT,SAASK,OAAOI;AAC5C;IAED,SAAaE;MACX,OAAON;AACR;IAED,OAAaO;MACX,OAAOP;AACR;IAEQ,KAAAQ,CAAMJ;MACb,IAAIA,gBAAgBZ,IAAM;QACxB,IAAIQ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