UNPKG

@earth-app/shovel

Version:

Kotlin Multiplatform Web Scraping Framework

2,025 lines 80.3 kB
(function (factory) {
  if (typeof define === 'function' && define.amd)
    define(['exports', './kotlin-kotlin-stdlib.js', './kotlinx-io-kotlinx-io-bytestring.js'], factory);
  else if (typeof exports === 'object')
    factory(module.exports, require('./kotlin-kotlin-stdlib.js'), require('./kotlinx-io-kotlinx-io-bytestring.js'));
  else {
    if (typeof globalThis['kotlin-kotlin-stdlib'] === 'undefined') {
      throw new Error("Error loading module 'kotlinx-io-kotlinx-io-core'. Its dependency 'kotlin-kotlin-stdlib' was not found. Please, check whether 'kotlin-kotlin-stdlib' is loaded prior to 'kotlinx-io-kotlinx-io-core'.");
    }
    if (typeof globalThis['kotlinx-io-kotlinx-io-bytestring'] === 'undefined') {
      throw new Error("Error loading module 'kotlinx-io-kotlinx-io-core'. Its dependency 'kotlinx-io-kotlinx-io-bytestring' was not found. Please, check whether 'kotlinx-io-kotlinx-io-bytestring' is loaded prior to 'kotlinx-io-kotlinx-io-core'.");
    }
    globalThis['kotlinx-io-kotlinx-io-core'] = factory(typeof globalThis['kotlinx-io-kotlinx-io-core'] === 'undefined' ? {} : globalThis['kotlinx-io-kotlinx-io-core'], globalThis['kotlin-kotlin-stdlib'], globalThis['kotlinx-io-kotlinx-io-bytestring']);
  }
}(function (_, kotlin_kotlin, kotlin_org_jetbrains_kotlinx_kotlinx_io_bytestring) {
  'use strict';
  //region block: imports
  var imul = Math.imul;
  var IndexOutOfBoundsException_init_$Create$ = kotlin_kotlin.$_$.v1;
  var Long = kotlin_kotlin.$_$.cb;
  var IllegalArgumentException_init_$Create$ = kotlin_kotlin.$_$.o1;
  var _Char___init__impl__6a9atx = kotlin_kotlin.$_$.h2;
  var charArrayOf = kotlin_kotlin.$_$.t6;
  var protoOf = kotlin_kotlin.$_$.y7;
  var toString = kotlin_kotlin.$_$.c8;
  var Unit_instance = kotlin_kotlin.$_$.a3;
  var toShort = kotlin_kotlin.$_$.b8;
  var ensureNotNull = kotlin_kotlin.$_$.ob;
  var toLong = kotlin_kotlin.$_$.a8;
  var StringBuilder_init_$Create$ = kotlin_kotlin.$_$.c1;
  var initMetadataForClass = kotlin_kotlin.$_$.h7;
  var VOID = kotlin_kotlin.$_$.h;
  var IllegalStateException_init_$Create$ = kotlin_kotlin.$_$.r1;
  var UnsafeByteStringOperations_instance = kotlin_org_jetbrains_kotlinx_kotlinx_io_bytestring.$_$.b;
  var AutoCloseable = kotlin_kotlin.$_$.ra;
  var objectCreate = kotlin_kotlin.$_$.x7;
  var initMetadataForCompanion = kotlin_kotlin.$_$.i7;
  var arrayCopy = kotlin_kotlin.$_$.o3;
  var toByte = kotlin_kotlin.$_$.z7;
  var IllegalArgumentException_init_$Create$_0 = kotlin_kotlin.$_$.m1;
  var initMetadataForObject = kotlin_kotlin.$_$.n7;
  var initMetadataForInterface = kotlin_kotlin.$_$.l7;
  var charSequenceGet = kotlin_kotlin.$_$.v6;
  var Char__toInt_impl_vasixd = kotlin_kotlin.$_$.n2;
  var charArray = kotlin_kotlin.$_$.u6;
  var numberToChar = kotlin_kotlin.$_$.v7;
  var concatToString = kotlin_kotlin.$_$.t8;
  var Exception_init_$Init$ = kotlin_kotlin.$_$.i1;
  var captureStack = kotlin_kotlin.$_$.s6;
  var Exception_init_$Init$_0 = kotlin_kotlin.$_$.j1;
  var Exception_init_$Init$_1 = kotlin_kotlin.$_$.l1;
  var Exception = kotlin_kotlin.$_$.ya;
  //endregion
  //region block: pre-declaration
  initMetadataForInterface(Source, 'Source', VOID, VOID, [AutoCloseable]);
  function write$default(source, startIndex, endIndex, $super) {
    startIndex = startIndex === VOID ? 0 : startIndex;
    endIndex = endIndex === VOID ? source.length : endIndex;
    var tmp;
    if ($super === VOID) {
      this.z17(source, startIndex, endIndex);
      tmp = Unit_instance;
    } else {
      tmp = $super.z17.call(this, source, startIndex, endIndex);
    }
    return tmp;
  }
  initMetadataForInterface(Sink, 'Sink', VOID, VOID, [AutoCloseable]);
  initMetadataForClass(Buffer, 'Buffer', Buffer, VOID, [Source, Sink]);
  initMetadataForClass(PeekSource, 'PeekSource', VOID, VOID, [AutoCloseable]);
  initMetadataForClass(RealSource, 'RealSource', VOID, VOID, [Source]);
  initMetadataForCompanion(Companion);
  initMetadataForClass(Segment, 'Segment');
  initMetadataForClass(SegmentCopyTracker, 'SegmentCopyTracker');
  initMetadataForObject(AlwaysSharedCopyTracker, 'AlwaysSharedCopyTracker', VOID, SegmentCopyTracker);
  initMetadataForObject(UnsafeBufferOperations, 'UnsafeBufferOperations');
  initMetadataForClass(SegmentReadContextImpl$1);
  initMetadataForClass(SegmentWriteContextImpl$1);
  initMetadataForClass(BufferIterationContextImpl$1);
  initMetadataForClass(IOException, 'IOException', IOException_init_$Create$, Exception);
  initMetadataForClass(EOFException, 'EOFException', EOFException_init_$Create$, IOException);
  initMetadataForObject(SegmentPool, 'SegmentPool');
  //endregion
  function get_HEX_DIGIT_CHARS() {
    _init_properties__Util_kt__g8tcl9();
    return HEX_DIGIT_CHARS;
  }
  var HEX_DIGIT_CHARS;
  function checkBounds(size, startIndex, endIndex) {
    _init_properties__Util_kt__g8tcl9();
    if (startIndex.a1(new Long(0, 0)) < 0 || endIndex.a1(size) > 0) {
      throw IndexOutOfBoundsException_init_$Create$('startIndex (' + startIndex.toString() + ') and endIndex (' + endIndex.toString() + ') are not within the range [0..size(' + size.toString() + '))');
    }
    if (startIndex.a1(endIndex) > 0) {
      throw IllegalArgumentException_init_$Create$('startIndex (' + startIndex.toString() + ') > endIndex (' + endIndex.toString() + ')');
    }
  }
  function checkOffsetAndCount(size, offset, byteCount) {
    _init_properties__Util_kt__g8tcl9();
    if (offset.a1(new Long(0, 0)) < 0 || offset.a1(size) > 0 || size.s2(offset).a1(byteCount) < 0 || byteCount.a1(new Long(0, 0)) < 0) {
      throw IllegalArgumentException_init_$Create$('offset (' + offset.toString() + ') and byteCount (' + byteCount.toString() + ') are not within the range [0..size(' + size.toString() + '))');
    }
  }
  var properties_initialized__Util_kt_67kc5b;
  function _init_properties__Util_kt__g8tcl9() {
    if (!properties_initialized__Util_kt_67kc5b) {
      properties_initialized__Util_kt_67kc5b = true;
      // Inline function 'kotlin.charArrayOf' call
      HEX_DIGIT_CHARS = charArrayOf([_Char___init__impl__6a9atx(48), _Char___init__impl__6a9atx(49), _Char___init__impl__6a9atx(50), _Char___init__impl__6a9atx(51), _Char___init__impl__6a9atx(52), _Char___init__impl__6a9atx(53), _Char___init__impl__6a9atx(54), _Char___init__impl__6a9atx(55), _Char___init__impl__6a9atx(56), _Char___init__impl__6a9atx(57), _Char___init__impl__6a9atx(97), _Char___init__impl__6a9atx(98), _Char___init__impl__6a9atx(99), _Char___init__impl__6a9atx(100), _Char___init__impl__6a9atx(101), _Char___init__impl__6a9atx(102)]);
    }
  }
  function throwEof($this, byteCount) {
    throw EOFException_init_$Create$_0("Buffer doesn't contain required number of bytes (size: " + $this.j().toString() + ', required: ' + byteCount.toString() + ')');
  }
  function Buffer() {
    this.m16_1 = null;
    this.n16_1 = null;
    this.o16_1 = new Long(0, 0);
  }
  protoOf(Buffer).j = function () {
    return this.o16_1;
  };
  protoOf(Buffer).p16 = function () {
    return this;
  };
  protoOf(Buffer).q16 = function () {
    return this.j().equals(new Long(0, 0));
  };
  protoOf(Buffer).r16 = function (byteCount) {
    // Inline function 'kotlin.require' call
    if (!(byteCount.a1(new Long(0, 0)) >= 0)) {
      var message = 'byteCount: ' + byteCount.toString();
      throw IllegalArgumentException_init_$Create$(toString(message));
    }
    if (this.j().a1(byteCount) < 0) {
      throw EOFException_init_$Create$_0("Buffer doesn't contain required number of bytes (size: " + this.j().toString() + ', required: ' + byteCount.toString() + ')');
    }
  };
  protoOf(Buffer).s16 = function (byteCount) {
    // Inline function 'kotlin.require' call
    if (!(byteCount.a1(new Long(0, 0)) >= 0)) {
      var message = 'byteCount: ' + byteCount.toString() + ' < 0';
      throw IllegalArgumentException_init_$Create$(toString(message));
    }
    return this.j().a1(byteCount) >= 0;
  };
  protoOf(Buffer).t16 = function () {
    var tmp0_elvis_lhs = this.m16_1;
    var tmp;
    if (tmp0_elvis_lhs == null) {
      throwEof(this, new Long(1, 0));
    } else {
      tmp = tmp0_elvis_lhs;
    }
    var segment = tmp;
    var segmentSize = segment.j();
    if (segmentSize === 0) {
      this.b17();
      return this.t16();
    }
    var v = segment.c17();
    this.o16_1 = this.o16_1.s2(new Long(1, 0));
    if (segmentSize === 1) {
      this.b17();
    }
    return v;
  };
  protoOf(Buffer).d17 = function () {
    var tmp0_elvis_lhs = this.m16_1;
    var tmp;
    if (tmp0_elvis_lhs == null) {
      throwEof(this, new Long(2, 0));
    } else {
      tmp = tmp0_elvis_lhs;
    }
    var segment = tmp;
    var segmentSize = segment.j();
    if (segmentSize < 2) {
      this.r16(new Long(2, 0));
      if (segmentSize === 0) {
        this.b17();
        return this.d17();
      }
      // Inline function 'kotlinx.io.and' call
      var tmp_0 = (this.t16() & 255) << 8;
      // Inline function 'kotlinx.io.and' call
      var tmp$ret$1 = this.t16() & 255;
      return toShort(tmp_0 | tmp$ret$1);
    }
    var v = segment.e17();
    this.o16_1 = this.o16_1.s2(new Long(2, 0));
    if (segmentSize === 2) {
      this.b17();
    }
    return v;
  };
  protoOf(Buffer).f17 = function () {
    return Unit_instance;
  };
  protoOf(Buffer).g17 = function (out, startIndex, endIndex) {
    checkBounds(this.j(), startIndex, endIndex);
    if (startIndex.equals(endIndex))
      return Unit_instance;
    var currentOffset = startIndex;
    var remainingByteCount = endIndex.s2(startIndex);
    out.o16_1 = out.o16_1.r2(remainingByteCount);
    var s = this.m16_1;
    while (currentOffset.a1(toLong(ensureNotNull(s).w16_1 - s.v16_1 | 0)) >= 0) {
      currentOffset = currentOffset.s2(toLong(s.w16_1 - s.v16_1 | 0));
      s = s.z16_1;
    }
    while (remainingByteCount.a1(new Long(0, 0)) > 0) {
      var copy = ensureNotNull(s).h17();
      copy.v16_1 = copy.v16_1 + currentOffset.z() | 0;
      var tmp = copy;
      var tmp0 = copy.v16_1 + remainingByteCount.z() | 0;
      // Inline function 'kotlin.comparisons.minOf' call
      var b = copy.w16_1;
      tmp.w16_1 = Math.min(tmp0, b);
      // Inline function 'kotlinx.io.Buffer.pushSegment' call
      if (out.m16_1 == null) {
        out.m16_1 = copy;
        out.n16_1 = copy;
      } else if (false) {
        out.n16_1 = ensureNotNull(out.n16_1).i17(copy).j17();
        if (ensureNotNull(out.n16_1).a17_1 == null) {
          out.m16_1 = out.n16_1;
        }
      } else {
        out.n16_1 = ensureNotNull(out.n16_1).i17(copy);
      }
      remainingByteCount = remainingByteCount.s2(toLong(copy.w16_1 - copy.v16_1 | 0));
      currentOffset = new Long(0, 0);
      s = s.z16_1;
    }
  };
  protoOf(Buffer).k17 = function () {
    var result = this.j();
    if (result.equals(new Long(0, 0)))
      return new Long(0, 0);
    var tail = ensureNotNull(this.n16_1);
    if (tail.w16_1 < 8192 && tail.y16_1) {
      result = result.s2(toLong(tail.w16_1 - tail.v16_1 | 0));
    }
    return result;
  };
  protoOf(Buffer).l17 = function (position) {
    if (position.a1(new Long(0, 0)) < 0 || position.a1(this.j()) >= 0) {
      throw IndexOutOfBoundsException_init_$Create$('position (' + position.toString() + ') is not within the range [0..size(' + this.j().toString() + '))');
    }
    if (position.equals(new Long(0, 0))) {
      return ensureNotNull(this.m16_1).m17(0);
    }
    // Inline function 'kotlinx.io.seek' call
    if (this.m16_1 == null) {
      var offset = new Long(-1, -1);
      return ensureNotNull(null).m17(position.s2(offset).z());
    }
    if (this.j().s2(position).a1(position) < 0) {
      var s = this.n16_1;
      var offset_0 = this.j();
      $l$loop: while (!(s == null) && offset_0.a1(position) > 0) {
        offset_0 = offset_0.s2(toLong(s.w16_1 - s.v16_1 | 0));
        if (offset_0.a1(position) <= 0)
          break $l$loop;
        s = s.a17_1;
      }
      var tmp4 = s;
      var offset_1 = offset_0;
      return ensureNotNull(tmp4).m17(position.s2(offset_1).z());
    } else {
      var s_0 = this.m16_1;
      var offset_2 = new Long(0, 0);
      $l$loop_0: while (!(s_0 == null)) {
        var tmp0 = offset_2;
        // Inline function 'kotlin.Long.plus' call
        var other = s_0.w16_1 - s_0.v16_1 | 0;
        var nextOffset = tmp0.r2(toLong(other));
        if (nextOffset.a1(position) > 0)
          break $l$loop_0;
        s_0 = s_0.z16_1;
        offset_2 = nextOffset;
      }
      var tmp6 = s_0;
      var offset_3 = offset_2;
      return ensureNotNull(tmp6).m17(position.s2(offset_3).z());
    }
  };
  protoOf(Buffer).y1 = function () {
    return this.n17(this.j());
  };
  protoOf(Buffer).n17 = function (byteCount) {
    // Inline function 'kotlinx.io.checkByteCount' call
    // Inline function 'kotlin.require' call
    if (!(byteCount.a1(new Long(0, 0)) >= 0)) {
      var message = 'byteCount (' + byteCount.toString() + ') < 0';
      throw IllegalArgumentException_init_$Create$(toString(message));
    }
    var remainingByteCount = byteCount;
    while (remainingByteCount.a1(new Long(0, 0)) > 0) {
      var tmp0_elvis_lhs = this.m16_1;
      var tmp;
      if (tmp0_elvis_lhs == null) {
        throw EOFException_init_$Create$_0('Buffer exhausted before skipping ' + byteCount.toString() + ' bytes.');
      } else {
        tmp = tmp0_elvis_lhs;
      }
      var head = tmp;
      var tmp1 = remainingByteCount;
      // Inline function 'kotlinx.io.minOf' call
      var b = head.w16_1 - head.v16_1 | 0;
      // Inline function 'kotlin.comparisons.minOf' call
      var b_0 = toLong(b);
      var toSkip = (tmp1.a1(b_0) <= 0 ? tmp1 : b_0).z();
      this.o16_1 = this.o16_1.s2(toLong(toSkip));
      remainingByteCount = remainingByteCount.s2(toLong(toSkip));
      head.v16_1 = head.v16_1 + toSkip | 0;
      if (head.v16_1 === head.w16_1) {
        this.b17();
      }
    }
  };
  protoOf(Buffer).o17 = function (sink, startIndex, endIndex) {
    // Inline function 'kotlinx.io.checkBounds' call
    var size = sink.length;
    checkBounds(toLong(size), toLong(startIndex), toLong(endIndex));
    var tmp0_elvis_lhs = this.m16_1;
    var tmp;
    if (tmp0_elvis_lhs == null) {
      return -1;
    } else {
      tmp = tmp0_elvis_lhs;
    }
    var s = tmp;
    var tmp3 = endIndex - startIndex | 0;
    // Inline function 'kotlin.comparisons.minOf' call
    var b = s.j();
    var toCopy = Math.min(tmp3, b);
    s.p17(sink, startIndex, startIndex + toCopy | 0);
    this.o16_1 = this.o16_1.s2(toLong(toCopy));
    if (isEmpty(s)) {
      this.b17();
    }
    return toCopy;
  };
  protoOf(Buffer).q17 = function (sink, byteCount) {
    // Inline function 'kotlinx.io.checkByteCount' call
    // Inline function 'kotlin.require' call
    if (!(byteCount.a1(new Long(0, 0)) >= 0)) {
      var message = 'byteCount (' + byteCount.toString() + ') < 0';
      throw IllegalArgumentException_init_$Create$(toString(message));
    }
    if (this.j().equals(new Long(0, 0)))
      return new Long(-1, -1);
    var bytesWritten = byteCount.a1(this.j()) > 0 ? this.j() : byteCount;
    sink.r17(this, bytesWritten);
    return bytesWritten;
  };
  protoOf(Buffer).s17 = function (sink, byteCount) {
    // Inline function 'kotlinx.io.checkByteCount' call
    // Inline function 'kotlin.require' call
    if (!(byteCount.a1(new Long(0, 0)) >= 0)) {
      var message = 'byteCount (' + byteCount.toString() + ') < 0';
      throw IllegalArgumentException_init_$Create$(toString(message));
    }
    if (this.j().a1(byteCount) < 0) {
      sink.r17(this, this.j());
      throw EOFException_init_$Create$_0('Buffer exhausted before writing ' + byteCount.toString() + ' bytes. Only ' + this.j().toString() + ' bytes were written.');
    }
    sink.r17(this, byteCount);
  };
  protoOf(Buffer).t17 = function (sink) {
    var byteCount = this.j();
    if (byteCount.a1(new Long(0, 0)) > 0) {
      sink.r17(this, byteCount);
    }
    return byteCount;
  };
  protoOf(Buffer).u17 = function () {
    return buffered(new PeekSource(this));
  };
  protoOf(Buffer).v17 = function (minimumCapacity) {
    // Inline function 'kotlin.require' call
    if (!(minimumCapacity >= 1 && minimumCapacity <= 8192)) {
      var message = 'unexpected capacity (' + minimumCapacity + '), should be in range [1, 8192]';
      throw IllegalArgumentException_init_$Create$(toString(message));
    }
    if (this.n16_1 == null) {
      var result = SegmentPool_instance.y17();
      this.m16_1 = result;
      this.n16_1 = result;
      return result;
    }
    var t = ensureNotNull(this.n16_1);
    if ((t.w16_1 + minimumCapacity | 0) > 8192 || !t.y16_1) {
      var newTail = t.i17(SegmentPool_instance.y17());
      this.n16_1 = newTail;
      return newTail;
    }
    return t;
  };
  protoOf(Buffer).z17 = function (source, startIndex, endIndex) {
    // Inline function 'kotlinx.io.checkBounds' call
    var size = source.length;
    checkBounds(toLong(size), toLong(startIndex), toLong(endIndex));
    var currentOffset = startIndex;
    while (currentOffset < endIndex) {
      var tail = this.v17(1);
      var tmp3 = endIndex - currentOffset | 0;
      // Inline function 'kotlin.comparisons.minOf' call
      var b = tail.a18();
      var toCopy = Math.min(tmp3, b);
      tail.b18(source, currentOffset, currentOffset + toCopy | 0);
      currentOffset = currentOffset + toCopy | 0;
    }
    var tmp = this;
    var tmp5 = this.o16_1;
    // Inline function 'kotlin.Long.plus' call
    var other = endIndex - startIndex | 0;
    tmp.o16_1 = tmp5.r2(toLong(other));
  };
  protoOf(Buffer).d18 = function (source, byteCount) {
    // Inline function 'kotlinx.io.checkByteCount' call
    // Inline function 'kotlin.require' call
    if (!(byteCount.a1(new Long(0, 0)) >= 0)) {
      var message = 'byteCount (' + byteCount.toString() + ') < 0';
      throw IllegalArgumentException_init_$Create$(toString(message));
    }
    var remainingByteCount = byteCount;
    while (remainingByteCount.a1(new Long(0, 0)) > 0) {
      var read = source.q17(this, remainingByteCount);
      if (read.equals(new Long(-1, -1))) {
        throw EOFException_init_$Create$_0('Source exhausted before reading ' + byteCount.toString() + ' bytes. ' + ('Only ' + byteCount.s2(remainingByteCount).toString() + ' were read.'));
      }
      remainingByteCount = remainingByteCount.s2(read);
    }
  };
  protoOf(Buffer).r17 = function (source, byteCount) {
    // Inline function 'kotlin.require' call
    if (!!(source === this)) {
      var message = 'source == this';
      throw IllegalArgumentException_init_$Create$(toString(message));
    }
    checkOffsetAndCount(source.o16_1, new Long(0, 0), byteCount);
    var remainingByteCount = byteCount;
    while (remainingByteCount.a1(new Long(0, 0)) > 0) {
      if (remainingByteCount.a1(toLong(ensureNotNull(source.m16_1).j())) < 0) {
        var tail = this.n16_1;
        var tmp;
        if (!(tail == null) && tail.y16_1) {
          var tmp1 = remainingByteCount;
          // Inline function 'kotlin.Long.plus' call
          var other = tail.w16_1;
          var tmp3 = tmp1.r2(toLong(other));
          // Inline function 'kotlin.Long.minus' call
          var other_0 = tail.e18() ? 0 : tail.v16_1;
          tmp = tmp3.s2(toLong(other_0)).a1(new Long(8192, 0)) <= 0;
        } else {
          tmp = false;
        }
        if (tmp) {
          ensureNotNull(source.m16_1).g18(tail, remainingByteCount.z());
          source.o16_1 = source.o16_1.s2(remainingByteCount);
          this.o16_1 = this.o16_1.r2(remainingByteCount);
          return Unit_instance;
        } else {
          source.m16_1 = ensureNotNull(source.m16_1).f18(remainingByteCount.z());
        }
      }
      var segmentToMove = ensureNotNull(source.m16_1);
      var movedByteCount = toLong(segmentToMove.j());
      source.m16_1 = segmentToMove.h18();
      if (source.m16_1 == null) {
        source.n16_1 = null;
      }
      // Inline function 'kotlinx.io.Buffer.pushSegment' call
      if (this.m16_1 == null) {
        this.m16_1 = segmentToMove;
        this.n16_1 = segmentToMove;
      } else if (true) {
        this.n16_1 = ensureNotNull(this.n16_1).i17(segmentToMove).j17();
        if (ensureNotNull(this.n16_1).a17_1 == null) {
          this.m16_1 = this.n16_1;
        }
      } else {
        this.n16_1 = ensureNotNull(this.n16_1).i17(segmentToMove);
      }
      source.o16_1 = source.o16_1.s2(movedByteCount);
      this.o16_1 = this.o16_1.r2(movedByteCount);
      remainingByteCount = remainingByteCount.s2(movedByteCount);
    }
  };
  protoOf(Buffer).i18 = function (source) {
    var totalBytesRead = new Long(0, 0);
    $l$loop: while (true) {
      var readCount = source.q17(this, new Long(8192, 0));
      if (readCount.equals(new Long(-1, -1)))
        break $l$loop;
      totalBytesRead = totalBytesRead.r2(readCount);
    }
    return totalBytesRead;
  };
  protoOf(Buffer).j18 = function (byte) {
    this.v17(1).k18(byte);
    this.o16_1 = this.o16_1.r2(new Long(1, 0));
  };
  protoOf(Buffer).l18 = function (short) {
    this.v17(2).m18(short);
    this.o16_1 = this.o16_1.r2(new Long(2, 0));
  };
  protoOf(Buffer).x3 = function () {
    return Unit_instance;
  };
  protoOf(Buffer).toString = function () {
    if (this.j().equals(new Long(0, 0)))
      return 'Buffer(size=0)';
    var maxPrintableBytes = 64;
    // Inline function 'kotlinx.io.minOf' call
    var b = this.j();
    // Inline function 'kotlin.comparisons.minOf' call
    var a = toLong(maxPrintableBytes);
    var len = (a.a1(b) <= 0 ? a : b).z();
    var builder = StringBuilder_init_$Create$(imul(len, 2) + (this.j().a1(toLong(maxPrintableBytes)) > 0 ? 1 : 0) | 0);
    var bytesWritten = 0;
    // Inline function 'kotlinx.io.unsafe.UnsafeBufferOperations.forEachSegment' call
    var curr = this.m16_1;
    while (!(curr == null)) {
      var tmp4 = get_SegmentReadContextImpl();
      var segment = curr;
      var idx = 0;
      while (bytesWritten < len && idx < segment.j()) {
        var _unary__edvuaz = idx;
        idx = _unary__edvuaz + 1 | 0;
        var b_0 = tmp4.n18(segment, _unary__edvuaz);
        bytesWritten = bytesWritten + 1 | 0;
        var tmp = get_HEX_DIGIT_CHARS();
        // Inline function 'kotlinx.io.shr' call
        var tmp$ret$2 = b_0 >> 4;
        var tmp_0 = builder.f8(tmp[tmp$ret$2 & 15]);
        var tmp_1 = get_HEX_DIGIT_CHARS();
        // Inline function 'kotlinx.io.and' call
        var tmp$ret$3 = b_0 & 15;
        tmp_0.f8(tmp_1[tmp$ret$3]);
      }
      curr = curr.z16_1;
    }
    if (this.j().a1(toLong(maxPrintableBytes)) > 0) {
      builder.f8(_Char___init__impl__6a9atx(8230));
    }
    return 'Buffer(size=' + this.j().toString() + ' hex=' + builder.toString() + ')';
  };
  protoOf(Buffer).b17 = function () {
    var oldHead = ensureNotNull(this.m16_1);
    var nextHead = oldHead.z16_1;
    this.m16_1 = nextHead;
    if (nextHead == null) {
      this.n16_1 = null;
    } else {
      nextHead.a17_1 = null;
    }
    oldHead.z16_1 = null;
    SegmentPool_instance.o18(oldHead);
  };
  protoOf(Buffer).p18 = function () {
    var oldTail = ensureNotNull(this.n16_1);
    var newTail = oldTail.a17_1;
    this.n16_1 = newTail;
    if (newTail == null) {
      this.m16_1 = null;
    } else {
      newTail.z16_1 = null;
    }
    oldTail.a17_1 = null;
    SegmentPool_instance.o18(oldTail);
  };
  function indexOf(_this__u8e3s4, byte, startIndex, endIndex) {
    startIndex = startIndex === VOID ? new Long(0, 0) : startIndex;
    endIndex = endIndex === VOID ? _this__u8e3s4.j() : endIndex;
    // Inline function 'kotlin.comparisons.minOf' call
    var b = _this__u8e3s4.j();
    var endOffset = endIndex.a1(b) <= 0 ? endIndex : b;
    checkBounds(_this__u8e3s4.j(), startIndex, endOffset);
    if (startIndex.equals(endOffset))
      return new Long(-1, -1);
    // Inline function 'kotlinx.io.seek' call
    if (_this__u8e3s4.m16_1 == null) {
      var o = new Long(-1, -1);
      if (o.equals(new Long(-1, -1))) {
        return new Long(-1, -1);
      }
      var segment = null;
      var offset = o;
      do {
        // Inline function 'kotlin.check' call
        if (!(endOffset.a1(offset) > 0)) {
          throw IllegalStateException_init_$Create$('Check failed.');
        }
        ensureNotNull(segment);
        var tmp = segment;
        // Inline function 'kotlin.comparisons.maxOf' call
        var a = startIndex.s2(offset).z();
        var tmp_0 = Math.max(a, 0);
        var tmp3 = segment.j();
        // Inline function 'kotlin.comparisons.minOf' call
        var b_0 = endOffset.s2(offset).z();
        var tmp$ret$3 = Math.min(tmp3, b_0);
        var idx = indexOf_0(tmp, byte, tmp_0, tmp$ret$3);
        if (!(idx === -1)) {
          return offset.r2(toLong(idx));
        }
        var tmp5 = offset;
        // Inline function 'kotlin.Long.plus' call
        var other = segment.j();
        offset = tmp5.r2(toLong(other));
        segment = segment.z16_1;
      }
       while (!(segment == null) && offset.a1(endOffset) < 0);
      return new Long(-1, -1);
    }
    if (_this__u8e3s4.j().s2(startIndex).a1(startIndex) < 0) {
      var s = _this__u8e3s4.n16_1;
      var offset_0 = _this__u8e3s4.j();
      $l$loop: while (!(s == null) && offset_0.a1(startIndex) > 0) {
        offset_0 = offset_0.s2(toLong(s.w16_1 - s.v16_1 | 0));
        if (offset_0.a1(startIndex) <= 0)
          break $l$loop;
        s = s.a17_1;
      }
      var tmp6 = s;
      var o_0 = offset_0;
      if (o_0.equals(new Long(-1, -1))) {
        return new Long(-1, -1);
      }
      var segment_0 = tmp6;
      var offset_1 = o_0;
      do {
        // Inline function 'kotlin.check' call
        if (!(endOffset.a1(offset_1) > 0)) {
          throw IllegalStateException_init_$Create$('Check failed.');
        }
        ensureNotNull(segment_0);
        var tmp_1 = segment_0;
        // Inline function 'kotlin.comparisons.maxOf' call
        var a_0 = startIndex.s2(offset_1).z();
        var tmp_2 = Math.max(a_0, 0);
        var tmp3_0 = segment_0.j();
        // Inline function 'kotlin.comparisons.minOf' call
        var b_1 = endOffset.s2(offset_1).z();
        var tmp$ret$8 = Math.min(tmp3_0, b_1);
        var idx_0 = indexOf_0(tmp_1, byte, tmp_2, tmp$ret$8);
        if (!(idx_0 === -1)) {
          return offset_1.r2(toLong(idx_0));
        }
        var tmp5_0 = offset_1;
        // Inline function 'kotlin.Long.plus' call
        var other_0 = segment_0.j();
        offset_1 = tmp5_0.r2(toLong(other_0));
        segment_0 = segment_0.z16_1;
      }
       while (!(segment_0 == null) && offset_1.a1(endOffset) < 0);
      return new Long(-1, -1);
    } else {
      var s_0 = _this__u8e3s4.m16_1;
      var offset_2 = new Long(0, 0);
      $l$loop_0: while (!(s_0 == null)) {
        var tmp0 = offset_2;
        // Inline function 'kotlin.Long.plus' call
        var other_1 = s_0.w16_1 - s_0.v16_1 | 0;
        var nextOffset = tmp0.r2(toLong(other_1));
        if (nextOffset.a1(startIndex) > 0)
          break $l$loop_0;
        s_0 = s_0.z16_1;
        offset_2 = nextOffset;
      }
      var tmp8 = s_0;
      var o_1 = offset_2;
      if (o_1.equals(new Long(-1, -1))) {
        return new Long(-1, -1);
      }
      var segment_1 = tmp8;
      var offset_3 = o_1;
      do {
        // Inline function 'kotlin.check' call
        if (!(endOffset.a1(offset_3) > 0)) {
          throw IllegalStateException_init_$Create$('Check failed.');
        }
        ensureNotNull(segment_1);
        var tmp_3 = segment_1;
        // Inline function 'kotlin.comparisons.maxOf' call
        var a_1 = startIndex.s2(offset_3).z();
        var tmp_4 = Math.max(a_1, 0);
        var tmp3_1 = segment_1.j();
        // Inline function 'kotlin.comparisons.minOf' call
        var b_2 = endOffset.s2(offset_3).z();
        var tmp$ret$13 = Math.min(tmp3_1, b_2);
        var idx_1 = indexOf_0(tmp_3, byte, tmp_4, tmp$ret$13);
        if (!(idx_1 === -1)) {
          return offset_3.r2(toLong(idx_1));
        }
        var tmp5_1 = offset_3;
        // Inline function 'kotlin.Long.plus' call
        var other_2 = segment_1.j();
        offset_3 = tmp5_1.r2(toLong(other_2));
        segment_1 = segment_1.z16_1;
      }
       while (!(segment_1 == null) && offset_3.a1(endOffset) < 0);
      return new Long(-1, -1);
    }
  }
  function readByteString(_this__u8e3s4, byteCount) {
    return UnsafeByteStringOperations_instance.l16(readByteArray_0(_this__u8e3s4, byteCount));
  }
  function buffered(_this__u8e3s4) {
    return new RealSource(_this__u8e3s4);
  }
  function PeekSource(upstream) {
    this.q18_1 = upstream;
    this.r18_1 = this.q18_1.p16();
    this.s18_1 = this.r18_1.m16_1;
    var tmp = this;
    var tmp0_safe_receiver = this.r18_1.m16_1;
    var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.v16_1;
    tmp.t18_1 = tmp1_elvis_lhs == null ? -1 : tmp1_elvis_lhs;
    this.u18_1 = false;
    this.v18_1 = new Long(0, 0);
  }
  protoOf(PeekSource).q17 = function (sink, byteCount) {
    // Inline function 'kotlin.check' call
    if (!!this.u18_1) {
      var message = 'Source is closed.';
      throw IllegalStateException_init_$Create$(toString(message));
    }
    // Inline function 'kotlinx.io.checkByteCount' call
    // Inline function 'kotlin.require' call
    if (!(byteCount.a1(new Long(0, 0)) >= 0)) {
      var message_0 = 'byteCount (' + byteCount.toString() + ') < 0';
      throw IllegalArgumentException_init_$Create$(toString(message_0));
    }
    // Inline function 'kotlin.check' call
    if (!(this.s18_1 == null || (this.s18_1 === this.r18_1.m16_1 && this.t18_1 === ensureNotNull(this.r18_1.m16_1).v16_1))) {
      var message_1 = 'Peek source is invalid because upstream source was used';
      throw IllegalStateException_init_$Create$(toString(message_1));
    }
    if (byteCount.equals(new Long(0, 0)))
      return new Long(0, 0);
    // Inline function 'kotlin.Long.plus' call
    var tmp$ret$7 = this.v18_1.r2(toLong(1));
    if (!this.q18_1.s16(tmp$ret$7))
      return new Long(-1, -1);
    if (this.s18_1 == null && !(this.r18_1.m16_1 == null)) {
      this.s18_1 = this.r18_1.m16_1;
      this.t18_1 = ensureNotNull(this.r18_1.m16_1).v16_1;
    }
    // Inline function 'kotlin.comparisons.minOf' call
    var b = this.r18_1.j().s2(this.v18_1);
    var toCopy = byteCount.a1(b) <= 0 ? byteCount : b;
    this.r18_1.g17(sink, this.v18_1, this.v18_1.r2(toCopy));
    this.v18_1 = this.v18_1.r2(toCopy);
    return toCopy;
  };
  protoOf(PeekSource).x3 = function () {
    this.u18_1 = true;
  };
  function RealSource(source) {
    this.w18_1 = source;
    this.x18_1 = false;
    this.y18_1 = new Buffer();
  }
  protoOf(RealSource).p16 = function () {
    return this.y18_1;
  };
  protoOf(RealSource).q17 = function (sink, byteCount) {
    // Inline function 'kotlinx.io.RealSource.checkNotClosed' call
    // Inline function 'kotlin.check' call
    if (!!this.x18_1) {
      var message = 'Source is closed.';
      throw IllegalStateException_init_$Create$(toString(message));
    }
    // Inline function 'kotlin.require' call
    if (!(byteCount.a1(new Long(0, 0)) >= 0)) {
      var message_0 = 'byteCount: ' + byteCount.toString();
      throw IllegalArgumentException_init_$Create$(toString(message_0));
    }
    if (this.y18_1.j().equals(new Long(0, 0))) {
      var read = this.w18_1.q17(this.y18_1, new Long(8192, 0));
      if (read.equals(new Long(-1, -1)))
        return new Long(-1, -1);
    }
    // Inline function 'kotlin.comparisons.minOf' call
    var b = this.y18_1.j();
    var toRead = byteCount.a1(b) <= 0 ? byteCount : b;
    return this.y18_1.q17(sink, toRead);
  };
  protoOf(RealSource).q16 = function () {
    // Inline function 'kotlinx.io.RealSource.checkNotClosed' call
    // Inline function 'kotlin.check' call
    if (!!this.x18_1) {
      var message = 'Source is closed.';
      throw IllegalStateException_init_$Create$(toString(message));
    }
    return this.y18_1.q16() && this.w18_1.q17(this.y18_1, new Long(8192, 0)).equals(new Long(-1, -1));
  };
  protoOf(RealSource).r16 = function (byteCount) {
    if (!this.s16(byteCount))
      throw EOFException_init_$Create$_0("Source doesn't contain required number of bytes (" + byteCount.toString() + ').');
  };
  protoOf(RealSource).s16 = function (byteCount) {
    // Inline function 'kotlinx.io.RealSource.checkNotClosed' call
    // Inline function 'kotlin.check' call
    if (!!this.x18_1) {
      var message = 'Source is closed.';
      throw IllegalStateException_init_$Create$(toString(message));
    }
    // Inline function 'kotlin.require' call
    if (!(byteCount.a1(new Long(0, 0)) >= 0)) {
      var message_0 = 'byteCount: ' + byteCount.toString();
      throw IllegalArgumentException_init_$Create$(toString(message_0));
    }
    while (this.y18_1.j().a1(byteCount) < 0) {
      if (this.w18_1.q17(this.y18_1, new Long(8192, 0)).equals(new Long(-1, -1)))
        return false;
    }
    return true;
  };
  protoOf(RealSource).t16 = function () {
    this.r16(new Long(1, 0));
    return this.y18_1.t16();
  };
  protoOf(RealSource).o17 = function (sink, startIndex, endIndex) {
    // Inline function 'kotlinx.io.checkBounds' call
    var size = sink.length;
    checkBounds(toLong(size), toLong(startIndex), toLong(endIndex));
    if (this.y18_1.j().equals(new Long(0, 0))) {
      var read = this.w18_1.q17(this.y18_1, new Long(8192, 0));
      if (read.equals(new Long(-1, -1)))
        return -1;
    }
    var tmp3 = endIndex - startIndex | 0;
    // Inline function 'kotlinx.io.minOf' call
    var b = this.y18_1.j();
    // Inline function 'kotlin.comparisons.minOf' call
    var a = toLong(tmp3);
    var toRead = (a.a1(b) <= 0 ? a : b).z();
    return this.y18_1.o17(sink, startIndex, startIndex + toRead | 0);
  };
  protoOf(RealSource).s17 = function (sink, byteCount) {
    try {
      this.r16(byteCount);
    } catch ($p) {
      if ($p instanceof EOFException) {
        var e = $p;
        sink.r17(this.y18_1, this.y18_1.j());
        throw e;
      } else {
        throw $p;
      }
    }
    this.y18_1.s17(sink, byteCount);
  };
  protoOf(RealSource).t17 = function (sink) {
    var totalBytesWritten = new Long(0, 0);
    while (!this.w18_1.q17(this.y18_1, new Long(8192, 0)).equals(new Long(-1, -1))) {
      var emitByteCount = this.y18_1.k17();
      if (emitByteCount.a1(new Long(0, 0)) > 0) {
        totalBytesWritten = totalBytesWritten.r2(emitByteCount);
        sink.r17(this.y18_1, emitByteCount);
      }
    }
    if (this.y18_1.j().a1(new Long(0, 0)) > 0) {
      totalBytesWritten = totalBytesWritten.r2(this.y18_1.j());
      sink.r17(this.y18_1, this.y18_1.j());
    }
    return totalBytesWritten;
  };
  protoOf(RealSource).d17 = function () {
    this.r16(new Long(2, 0));
    return this.y18_1.d17();
  };
  protoOf(RealSource).u17 = function () {
    // Inline function 'kotlinx.io.RealSource.checkNotClosed' call
    // Inline function 'kotlin.check' call
    if (!!this.x18_1) {
      var message = 'Source is closed.';
      throw IllegalStateException_init_$Create$(toString(message));
    }
    return buffered(new PeekSource(this));
  };
  protoOf(RealSource).x3 = function () {
    if (this.x18_1)
      return Unit_instance;
    this.x18_1 = true;
    this.w18_1.x3();
    this.y18_1.y1();
  };
  protoOf(RealSource).toString = function () {
    return 'buffered(' + toString(this.w18_1) + ')';
  };
  function Segment_init_$Init$($this) {
    Segment.call($this);
    $this.u16_1 = new Int8Array(8192);
    $this.y16_1 = true;
    $this.x16_1 = null;
    return $this;
  }
  function Segment_init_$Create$() {
    return Segment_init_$Init$(objectCreate(protoOf(Segment)));
  }
  function Segment_init_$Init$_0(data, pos, limit, shareToken, owner, $this) {
    Segment.call($this);
    $this.u16_1 = data;
    $this.v16_1 = pos;
    $this.w16_1 = limit;
    $this.x16_1 = shareToken;
    $this.y16_1 = owner;
    return $this;
  }
  function Segment_init_$Create$_0(data, pos, limit, shareToken, owner) {
    return Segment_init_$Init$_0(data, pos, limit, shareToken, owner, objectCreate(protoOf(Segment)));
  }
  function Companion() {
    this.z18_1 = 8192;
    this.a19_1 = 1024;
  }
  protoOf(Companion).b19 = function () {
    return Segment_init_$Create$();
  };
  var Companion_instance;
  function Companion_getInstance() {
    return Companion_instance;
  }
  protoOf(Segment).e18 = function () {
    var tmp0_safe_receiver = this.x16_1;
    var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.c19();
    return tmp1_elvis_lhs == null ? false : tmp1_elvis_lhs;
  };
  protoOf(Segment).h17 = function () {
    var tmp0_elvis_lhs = this.x16_1;
    var tmp;
    if (tmp0_elvis_lhs == null) {
      // Inline function 'kotlin.also' call
      var this_0 = SegmentPool_instance.d19();
      this.x16_1 = this_0;
      tmp = this_0;
    } else {
      tmp = tmp0_elvis_lhs;
    }
    var t = tmp;
    var tmp_0 = this.v16_1;
    var tmp_1 = this.w16_1;
    // Inline function 'kotlin.also' call
    t.e19();
    return Segment_init_$Create$_0(this.u16_1, tmp_0, tmp_1, t, false);
  };
  protoOf(Segment).h18 = function () {
    var result = this.z16_1;
    if (!(this.a17_1 == null)) {
      ensureNotNull(this.a17_1).z16_1 = this.z16_1;
    }
    if (!(this.z16_1 == null)) {
      ensureNotNull(this.z16_1).a17_1 = this.a17_1;
    }
    this.z16_1 = null;
    this.a17_1 = null;
    return result;
  };
  protoOf(Segment).i17 = function (segment) {
    segment.a17_1 = this;
    segment.z16_1 = this.z16_1;
    if (!(this.z16_1 == null)) {
      ensureNotNull(this.z16_1).a17_1 = segment;
    }
    this.z16_1 = segment;
    return segment;
  };
  protoOf(Segment).f18 = function (byteCount) {
    // Inline function 'kotlin.require' call
    if (!(byteCount > 0 && byteCount <= (this.w16_1 - this.v16_1 | 0))) {
      var message = 'byteCount out of range';
      throw IllegalArgumentException_init_$Create$(toString(message));
    }
    var prefix;
    if (byteCount >= 1024) {
      prefix = this.h17();
    } else {
      prefix = SegmentPool_instance.y17();
      var tmp1 = this.u16_1;
      var tmp2 = prefix.u16_1;
      var tmp3 = this.v16_1;
      // Inline function 'kotlin.collections.copyInto' call
      var endIndex = this.v16_1 + byteCount | 0;
      // Inline function 'kotlin.js.unsafeCast' call
      // Inline function 'kotlin.js.asDynamic' call
      var tmp = tmp1;
      // Inline function 'kotlin.js.unsafeCast' call
      // Inline function 'kotlin.js.asDynamic' call
      arrayCopy(tmp, tmp2, 0, tmp3, endIndex);
    }
    prefix.w16_1 = prefix.v16_1 + byteCount | 0;
    this.v16_1 = this.v16_1 + byteCount | 0;
    if (!(this.a17_1 == null)) {
      ensureNotNull(this.a17_1).i17(prefix);
    } else {
      prefix.z16_1 = this;
      this.a17_1 = prefix;
    }
    return prefix;
  };
  protoOf(Segment).j17 = function () {
    // Inline function 'kotlin.check' call
    if (!!(this.a17_1 == null)) {
      var message = 'cannot compact';
      throw IllegalStateException_init_$Create$(toString(message));
    }
    if (!ensureNotNull(this.a17_1).y16_1)
      return this;
    var byteCount = this.w16_1 - this.v16_1 | 0;
    var availableByteCount = (8192 - ensureNotNull(this.a17_1).w16_1 | 0) + (ensureNotNull(this.a17_1).e18() ? 0 : ensureNotNull(this.a17_1).v16_1) | 0;
    if (byteCount > availableByteCount)
      return this;
    var predecessor = this.a17_1;
    this.g18(ensureNotNull(predecessor), byteCount);
    var successor = this.h18();
    // Inline function 'kotlin.check' call
    if (!(successor == null)) {
      throw IllegalStateException_init_$Create$('Check failed.');
    }
    SegmentPool_instance.o18(this);
    return predecessor;
  };
  protoOf(Segment).k18 = function (byte) {
    var _unary__edvuaz = this.w16_1;
    this.w16_1 = _unary__edvuaz + 1 | 0;
    this.u16_1[_unary__edvuaz] = byte;
  };
  protoOf(Segment).m18 = function (short) {
    var data = this.u16_1;
    var limit = this.w16_1;
    var _unary__edvuaz = limit;
    limit = _unary__edvuaz + 1 | 0;
    data[_unary__edvuaz] = toByte((short >>> 8 | 0) & 255);
    var _unary__edvuaz_0 = limit;
    limit = _unary__edvuaz_0 + 1 | 0;
    data[_unary__edvuaz_0] = toByte(short & 255);
    this.w16_1 = limit;
  };
  protoOf(Segment).c17 = function () {
    var _unary__edvuaz = this.v16_1;
    this.v16_1 = _unary__edvuaz + 1 | 0;
    return this.u16_1[_unary__edvuaz];
  };
  protoOf(Segment).e17 = function () {
    var data = this.u16_1;
    var pos = this.v16_1;
    var _unary__edvuaz = pos;
    pos = _unary__edvuaz + 1 | 0;
    // Inline function 'kotlinx.io.and' call
    var tmp = (data[_unary__edvuaz] & 255) << 8;
    var _unary__edvuaz_0 = pos;
    pos = _unary__edvuaz_0 + 1 | 0;
    // Inline function 'kotlinx.io.and' call
    var tmp$ret$1 = data[_unary__edvuaz_0] & 255;
    var s = toShort(tmp | tmp$ret$1);
    this.v16_1 = pos;
    return s;
  };
  protoOf(Segment).g18 = function (sink, byteCount) {
    // Inline function 'kotlin.check' call
    if (!sink.y16_1) {
      var message = 'only owner can write';
      throw IllegalStateException_init_$Create$(toString(message));
    }
    if ((sink.w16_1 + byteCount | 0) > 8192) {
      if (sink.e18())
        throw IllegalArgumentException_init_$Create$_0();
      if (((sink.w16_1 + byteCount | 0) - sink.v16_1 | 0) > 8192)
        throw IllegalArgumentException_init_$Create$_0();
      var tmp1 = sink.u16_1;
      var tmp2 = sink.u16_1;
      var tmp3 = sink.v16_1;
      // Inline function 'kotlin.collections.copyInto' call
      var endIndex = sink.w16_1;
      // Inline function 'kotlin.js.unsafeCast' call
      // Inline function 'kotlin.js.asDynamic' call
      var tmp = tmp1;
      // Inline function 'kotlin.js.unsafeCast' call
      // Inline function 'kotlin.js.asDynamic' call
      arrayCopy(tmp, tmp2, 0, tmp3, endIndex);
      sink.w16_1 = sink.w16_1 - sink.v16_1 | 0;
      sink.v16_1 = 0;
    }
    var tmp6 = this.u16_1;
    var tmp7 = sink.u16_1;
    var tmp8 = sink.w16_1;
    var tmp9 = this.v16_1;
    // Inline function 'kotlin.collections.copyInto' call
    var endIndex_0 = this.v16_1 + byteCount | 0;
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    var tmp_0 = tmp6;
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    arrayCopy(tmp_0, tmp7, tmp8, tmp9, endIndex_0);
    sink.w16_1 = sink.w16_1 + byteCount | 0;
    this.v16_1 = this.v16_1 + byteCount | 0;
  };
  protoOf(Segment).p17 = function (dst, dstStartOffset, dstEndOffset) {
    var len = dstEndOffset - dstStartOffset | 0;
    var tmp0 = this.u16_1;
    var tmp3 = this.v16_1;
    // Inline function 'kotlin.collections.copyInto' call
    var endIndex = this.v16_1 + len | 0;
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    var tmp = tmp0;
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    arrayCopy(tmp, dst, dstStartOffset, tmp3, endIndex);
    this.v16_1 = this.v16_1 + len | 0;
  };
  protoOf(Segment).b18 = function (src, srcStartOffset, srcEndOffset) {
    var tmp1 = this.u16_1;
    // Inline function 'kotlin.collections.copyInto' call
    var destinationOffset = this.w16_1;
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    var tmp = src;
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    arrayCopy(tmp, tmp1, destinationOffset, srcStartOffset, srcEndOffset);
    this.w16_1 = this.w16_1 + (srcEndOffset - srcStartOffset | 0) | 0;
  };
  protoOf(Segment).j = function () {
    return this.w16_1 - this.v16_1 | 0;
  };
  protoOf(Segment).a18 = function () {
    return this.u16_1.length - this.w16_1 | 0;
  };
  protoOf(Segment).f19 = function (readOnly) {
    return this.u16_1;
  };
  protoOf(Segment).m17 = function (index) {
    return this.u16_1[this.v16_1 + index | 0];
  };
  protoOf(Segment).g19 = function (index, value) {
    this.u16_1[this.w16_1 + index | 0] = value;
  };
  protoOf(Segment).h19 = function (index, b0, b1) {
    var d = this.u16_1;
    var l = this.w16_1;
    d[l + index | 0] = b0;
    d[(l + index | 0) + 1 | 0] = b1;
  };
  protoOf(Segment).i19 = function (index, b0, b1, b2) {
    var d = this.u16_1;
    var l = this.w16_1;
    d[l + index | 0] = b0;
    d[(l + index | 0) + 1 | 0] = b1;
    d[(l + index | 0) + 2 | 0] = b2;
  };
  protoOf(Segment).j19 = function (index, b0, b1, b2, b3) {
    var d = this.u16_1;
    var l = this.w16_1;
    d[l + index | 0] = b0;
    d[(l + index | 0) + 1 | 0] = b1;
    d[(l + index | 0) + 2 | 0] = b2;
    d[(l + index | 0) + 3 | 0] = b3;
  };
  function Segment() {
    this.v16_1 = 0;
    this.w16_1 = 0;
    this.x16_1 = null;
    this.y16_1 = false;
    this.z16_1 = null;
    this.a17_1 = null;
  }
  function SegmentCopyTracker() {
  }
  function isEmpty(_this__u8e3s4) {
    return _this__u8e3s4.j() === 0;
  }
  function AlwaysSharedCopyTracker() {
    AlwaysSharedCopyTracker_instance = this;
    SegmentCopyTracker.call(this);
  }
  protoOf(AlwaysSharedCopyTracker).c19 = function () {
    return true;
  };
  protoOf(AlwaysSharedCopyTracker).e19 = function () {
    return Unit_instance;
  };
  var AlwaysSharedCopyTracker_instance;
  function AlwaysSharedCopyTracker_getInstance() {
    if (AlwaysSharedCopyTracker_instance == null)
      new AlwaysSharedCopyTracker();
    return AlwaysSharedCopyTracker_instance;
  }
  function indexOf_0(_this__u8e3s4, byte, startOffset, endOffset) {
    // Inline function 'kotlin.require' call
    if (!(0 <= startOffset ? startOffset < _this__u8e3s4.j() : false)) {
      var message = '' + startOffset;
      throw IllegalArgumentException_init_$Create$(toString(message));
    }
    // Inline function 'kotlin.require' call
    if (!(startOffset <= endOffset ? endOffset <= _this__u8e3s4.j() : false)) {
      var message_0 = '' + endOffset;
      throw IllegalArgumentException_init_$Create$(toString(message_0));
    }
    var p = _this__u8e3s4.v16_1;
    var data = _this__u8e3s4.f19(true);
    var inductionVariable = startOffset;
    if (inductionVariable < endOffset)
      do {
        var idx = inductionVariable;
        inductionVariable = inductionVariable + 1 | 0;
        if (data[p + idx | 0] === byte) {
          return idx;
        }
      }
       while (inductionVariable < endOffset);
    return -1;
  }
  function Sink() {
  }
  function Source() {
  }
  function readByteArray(_this__u8e3s4) {
    return readByteArrayImpl(_this__u8e3s4, -1);
  }
  function readByteArrayImpl(_this__u8e3s4, size) {
    var arraySize = size;
    if (size === -1) {
      var fetchSize = new Long(2147483647, 0);
      while (_this__u8e3s4.p16().j().a1(new Long(2147483647, 0)) < 0 && _this__u8e3s4.s16(fetchSize)) {
        // Inline function 'kotlin.Long.times' call
        fetchSize = fetchSize.t2(toLong(2));
      }
      // Inline function 'kotlin.check' call
      if (!(_this__u8e3s4.p16().j().a1(new Long(2147483647, 0)) < 0)) {
        var message = "Can't create an array of size " + _this__u8e3s4.p16().j().toString();
        throw IllegalStateException_init_$Create$(toString(message));
      }
      arraySize = _this__u8e3s4.p16().j().z();
    } else {
      _this__u8e3s4.r16(toLong(size));
    }
    var array = new Int8Array(arraySize);
    readTo(_this__u8e3s4.p16(), array);
    return array;
  }
  function readTo(_this__u8e3s4, sink, startIndex, endIndex) {
    startIndex = startIndex === VOID ? 0 : startIndex;
    endIndex = endIndex === VOID ? sink.length : endIndex;
    // Inline function 'kotlinx.io.checkBounds' call
    var size = sink.length;
    checkBounds(toLong(size), toLong(startIndex), toLong(endIndex));
    var offset = startIndex;
    while (offset < endIndex) {
      var bytesRead = _this__u8e3s4.o17(sink, offset, endIndex);
      if (bytesRead === -1) {
        throw EOFException_init_$Create$_0('Source exhausted before reading ' + (endIndex - startIndex | 0) + ' bytes. ' + ('Only ' + bytesRead + ' bytes were read.'));
      }
      offset = offset + bytesRead | 0;
    }
  }
  function readByteArray_0(_this__u8e3s4, byteCount) {
    // Inline function 'kotlinx.io.checkByteCount' call
    var byteCount_0 = toLong(byteCount);
    // Inline function 'kotlin.require' call
    if (!(byteCount_0.a1(new Long(0, 0)) >= 0)) {
      var message = 'byteCount (' + byteCount_0.toString() + ') < 0';
      throw IllegalArgumentException_init_$Create$(toString(message));
    }
    return readByteArrayImpl(_this__u8e3s4, byteCount);
  }
  function indexOf_1(_this__u8e3s4, byte, startIndex, endIndex) {
    startIndex = startIndex === VOID ? new Long(0, 0) : startIndex;
    endIndex = endIndex === VOID ? new Long(-1, 2147483647) : endIndex;
    // Inline function 'kotlin.require' call
    if (!((new Long(0, 0)).a1(startIndex) <= 0 ? startIndex.a1(endIndex) <= 0 : false)) {
      var tmp;
      if (endIndex.a1(new Long(0, 0)) < 0) {
        tmp = 'startIndex (' + startIndex.toString() + ') and endIndex (' + endIndex.toString() + ') should be non negative';
      } else {
        tmp = 'startIndex (' + startIndex.toString() + ') is not within the range [0..endIndex(' + endIndex.toString() + '))';
      }
      var message = tmp;
      throw IllegalArgumentException_init_$Create$(toString(message));
    }
    if (startIndex.equals(endIndex))
      return new Long(-1, -1);
    var offset = startIndex;
    $l$loop: while (true) {
      var tmp_0;
      if (offset.a1(endIndex) < 0) {
        // Inline function 'kotlin.Long.plus' call
        var tmp$ret$2 = offset.r2(toLong(1));
        tmp_0 = _this__u8e3s4.s16(tmp$ret$2);
      } else {
        tmp_0 = false;
      }
      if (!tmp_0) {
        break $l$loop;
      }
      var tmp_1 = _this__u8e3s4.p16();
      var tmp_2 = offset;
      // Inline function 'kotlin.comparisons.minOf' call
      var b = _this__u8e3s4.p16().j();
      var tmp$ret$3 = endIndex.a1(b) <= 0 ? endIndex : b;
      var idx = indexOf(tmp_1, byte, tmp_2, tmp$ret$3);
      if (!idx.equals(new Long(-1, -1))) {
        return idx;
      }
      offset = _this__u8e3s4.p16().j();
    }
    return new Long(-1, -1);
  }
  function readString(_this__u8e3s4) {
    _this__u8e3s4.s16(new Long(-1, 2147483647));
    return commonReadUtf8(_this__u8e3s4.p16(), _this__u8e3s4.p16().j());
  }
  function readString_0(_this__u8e3s4, byteCount) {
    _this__u8e3s4.r16(byteCount);
    return commonReadUtf8(_this__u8e3s4.p16(), byteCount);
  }
  function readString_1(_this__u8e3s4) {
    return commonReadUtf8(_this__u8e3s4, _this__u8e3s4.j());
  }
  function commonReadUtf8(_this__u8e3s4, byteCount) {
    if (byteCount.equals(new Long(0, 0)))
      return '';
    // Inline function 'kotlinx.io.unsafe.UnsafeBufferOperations.forEachSegment' call
    var curr = _this__u8e3s4.m16_1;
    while (!(curr == null)) {
      get_SegmentReadContextImpl();
      if (toLong(curr.j()).a1(byteCount) >= 0) {
        var result = '';
        // Inline function 'kotlinx.io.unsafe.withData' call
        var tmp2 = curr.f19(true);
        var tmp3 = curr.v16_1;
        var tmp0 = curr.w16_1;
        // Inline function 'kotlin.math.min' call
        var b = tmp3 + byteCount.z() | 0;
        var tmp$ret$0 = Math.min(tmp0, b);
        result = commonToUtf8String(tmp2, tmp3, tmp$ret$0);
        _this__u8e3s4.n17(byteCount);
        return result;
      }
      return commonToUtf8String(readByteArray_0(_this__u8e3s4, byteCount.z()));
    }
    // Inline function 'kotlin.error' call
    var message = 'Unreacheable';
    throw IllegalStateException_init_$Create$(toString(message));
  }
  function writeString(_this__u8e3s4, string, startIndex, endIndex) {
    startIndex = startIndex === VOID ? 0 : startIndex;
    endIndex = endIndex === VOID ? string.length : endIndex;
    // Inline function 'kotlinx.io.checkBounds' call
    var size = string.length;
    checkBounds(toLong(size), toLong(startIndex), toLong(endIndex));
    // Inline function 'kotlinx.io.writeToInternalBuffer' call
    // Inline function 'kotlinx.io.commonWriteUtf8' call
    var this_0 = _this__u8e3s4.p16();
    var i = startIndex;
    while (i < endIndex) {
      var p0 = i;
      // Inline function 'kotlin.code' call
      var this_1 = charSequenceGet(string, p0);
      var c = Char__toInt_impl_vasixd(this_1);
      if (c < 128) {
        $l$block_0: {
          // Inline function 'kotlinx.io.unsafe.UnsafeBufferOperations.writeToTail' call
          var tail = this_0.v17(1);
          var ctx = get_SegmentWriteContextImpl();
          var segmentOffset = -i | 0;
          // Inline function 'kotlin.comparisons.minOf' call
          var b = i + tail.a18() | 0;
          var runLimit = Math.min(endIndex, b);
          var _unary__edvuaz = i;
          i = _unary__edvuaz + 1 | 0;
          ctx.n19(tail, segmentOffset + _unary__edvuaz | 0, toByte(c));
          $l$loop: while (i < runLimit) {
            var p0_0 = i;
            // Inline function 'kotlin.code' call
            var this_2 = charSequenceGet(string, p0_0);
            c = Char__toInt_impl_vasixd(this_2);
            if (c >= 128)
              break $l$loop;
            var _unary__edvuaz_0 = i;
            i = _unary__edvuaz_0 + 1 | 0;
            ctx.n19(tail, segmentOffset + _unary__edvuaz_0 | 0, toByte(c));
          }
          var bytesWritten = i + segmentOffset | 0;
          if (bytesWritten === 1) {
            tail.w16_1 = tail.w16_1 + bytesWritten | 0;
            var tmp = this_0;
            // Inline function 'kotlin.Long.plus' call
            tmp.o16_1 = this_0.o16_1.r2(toLong(bytesWritten));
            break $l$block_0;
          }
          // Inline function 'kotlin.check' call
          if (!(0 <= bytesWritten ? bytesWritten <= tail.a18() : false)) {
            var message = 'Invalid number of bytes written: ' + bytesWritten + '. Should be in 0..' + tail.a18();
            throw IllegalStateException_init_$Create$(toString(message));
          }
          if (!(bytesWritten === 0)) {
            tail.w16_1 = tail.w16_1 + bytesWritten | 0;
            var tmp_0 = this_0;
            // Inline function 'kotlin.Long.plus' call
            tmp_0.o16_1 = this_0.o16_1.r2(toLong(bytesWritten));
            break $l$block_0;
          }
          if (isEmpty(tail)) {
            this_0.p18();
          }
        }
      } else if (c < 2048) {
        $l$block_2: {
          // Inline function 'kotlinx.io.unsafe.UnsafeBufferOperations.writeToTail' call
          var tail_0 = this_0.v17(2);
          get_SegmentWriteContextImpl().m19(tail_0, 0, toByte(c >> 6 | 192), toByte(c & 63 | 128));
          var bytesWritten_0 = 2;
          if (bytesWritten_0 === 2) {
            tail_0.w16_1 = tail_0.w16_1 + bytesWritten_0 | 0;
            var tmp_1 = this_0;
            // Inline function 'kotlin.Long.plus' call
            tmp_1.o16_1 = this_0.o16_1.r2(toLong(bytesWritten_0));
            break $l$block_2;
          }
          // Inline function 'kotlin.check' call
          if (!(0 <= bytesWritten_0 ? bytesWritten_0 <= tail_0.a18() : false)) {
            var message_0 = 'Invalid number of bytes written: ' + bytesWritten_0 + '. Should be in 0..' + tail_0.a18();
            throw IllegalStateException_init_$Create$(toString(message_0));
          }
          if (!(bytesWritten_0 === 0)) {
            tail_0.w16_1 = tail_0.w16_1 + bytesWritten_0 | 0;
            var tmp_2 = this_0;
            // Inline function 'kotlin.Long.plus' call
            tmp_2.o16_1 = this_0.o16_1.r2(toLong(bytesWritten_0));
            break $l$block_2;
          }
          if (isEmpty(tail_0)) {
            this_0.p18();
          }
        }
        i = i + 1 | 0;
      } else if (c < 55296 || c > 57343) {
        $l$block_4: {
          // Inline function 'kotlinx.io.unsafe.UnsafeBufferOperations.writeToTail' call
          var tail_1 = this_0.v17(3);
          get_SegmentWriteContextImpl().l19(tail_1, 0, toByte(c >> 12 | 224), toByte(c >> 6 & 63 | 128), toByte(c & 63 | 128));
          var bytesWritten_1 = 3;
          if (bytesWritten_1 === 3) {
            tail_1.w16_1 = tail_1.w16_1 + bytesWritten_1 | 0;
            var tmp_3 = this_0;
            // Inline function 'kotlin.Long.plus' call
            tmp_3.o16_1 = this_0.o16_1.r2(toLong(bytesWritten_1));
            break $l$block_4;
          }
          // Inline function 'kotlin.check' call
          if (!(0 <= bytesWritten_1 ? bytesWritten_1 <= tail_1.a18() : false)) {
            var message_1 = 'Invalid number of bytes written: ' + bytesWritten_1 + '. Should be in 0..' + tail_1.a18();
            throw IllegalStateException_init_$Create$(toString(message_1));
          }
          if (!(bytesWritten_1 === 0)) {
            tail_1.w16_1 = tail_1.w16_1 + bytesWritten_1 | 0;
            var tmp_4 = this_0;
            // Inline function 'kotlin.Long.plus' call
            tmp_4.o16_1 = this_0.o16_1.r2(toLong(bytesWritten_1));
            break $l$block_4;
          }
          if (isEmpty(tail_1)) {
            this_0.p18();
          }
        }
        i = i + 1 | 0;
      } else {
        var tmp_5;
        if ((i + 1 | 0) < endIndex) {
          var p0_1 = i + 1 | 0;
          // Inline function 'kotlin.code' call
          var this_3 = charSequenceGet(string, p0_1);
          tmp_5 = Char__toInt_impl_vasixd(this_3);
        } else {
          tmp_5 = 0;
        }
        var low = tmp_5;
        if (c > 56319 || !(56320 <= low ? low <= 57343 : false)) {
          // Inline function 'kotlin.code' call
          var this_4 = _Char___init__impl__6a9atx(63);
          var tmp$ret$26 = Char__toInt_impl_vasixd(this_4);
          this_0.j18(toByte(tmp$ret$26));
          i = i + 1 | 0;
        } else {
          var codePoint = 65536 + ((c & 1023) << 10 | low & 1023) | 0;
          $l$block_6: {
            // Inline function 'kotlinx.io.unsafe.UnsafeBufferOperations.writeToTail' call
            var tail_2 = this_0.v17(4);
            get_SegmentWriteContextImpl().k19(tail_2, 0, toByte(codePoint >> 18 | 240), toByte(codePoint >> 12 & 63 | 128), toByte(codePoint >> 6 & 63 | 128), toByte(codePoint & 63 | 128));
            var bytesWritten_2 = 4;
            if (bytesWritten_2 === 4) {
              tail_2.w16_1 = tail_2.w16_1 + bytesWritten_2 | 0;
              var tmp_6 = this_0;
              // Inline function 'kotlin.Long.plus' call
              tmp_6.o16_1 = this_0.o16_1.r2(toLong(bytesWritten_2));
              break $l$block_6;
            }
            // Inline function 'kotlin.check' call
            if (!(0 <= bytesWritten_2 ? bytesWritten_2 <= tail_2.a18() : false)) {
              var message_2 = 'Invalid number of bytes written: ' + bytesWritten_2 + '. Should be in 0..' + tail_2.a18();
              throw IllegalStateException_init_$Create$(toString(message_2));
            }
            if (!(bytesWritten_2 === 0)) {
              tail_2.w16_1 = tail_2.w16_1 + bytesWritten_2 | 0;
              var tmp_7 = this_0;
              // Inline function 'kotlin.Long.plus' call
              tmp_7.o16_1 = this_0.o16_1.r2(toLong(bytesWritten_2));
              break $l$block_6;
            }
            if (isEmpty(tail_2)) {
              this_0.p18();
            }
          }
          i = i + 2 | 0;
        }
      }
    }
    _this__u8e3s4.f17();
  }
  function commonToUtf8String(_this__u8e3s4, beginIndex, endIndex) {
    beginIndex = beginIndex === VOID ? 0 : beginIndex;
    endIndex = endIndex === VOID ? _this__u8e3s4.length : endIndex;
    if (beginIndex < 0 || endIndex > _this__u8e3s4.length || beginIndex > endIndex) {
      throw IndexOutOfBoundsException_init_$Create$('size=' + _this__u8e3s4.length + ' beginIndex=' + beginIndex + ' endIndex=' + endIndex);
    }
    var chars = charArray(endIndex - beginIndex | 0);
    var length = 0;
    // Inline function 'kotlinx.io.internal.processUtf16Chars' call
    var index = beginIndex;
    while (index < endIndex) {
      var b0 = _this__u8e3s4[index];
      if (b0 >= 0) {
        var c = numberToChar(b0);
        var _unary__edvuaz = length;
        length = _unary__edvuaz + 1 | 0;
        chars[_unary__edvuaz] = c;
        index = index + 1 | 0;
        while (index < endIndex && _this__u8e3s4[index] >= 0) {
          var _unary__edvuaz_0 = index;
          index = _unary__edvuaz_0 + 1 | 0;
          var c_0 = numberToChar(_this__u8e3s4[_unary__edvuaz_0]);
          var _unary__edvuaz_1 = length;
          length = _unary__edvuaz_1 + 1 | 0;
          chars[_unary__edvuaz_1] = c_0;
        }
      } else {
        // Inline function 'kotlinx.io.shr' call
        if (b0 >> 5 === -2) {
          var tmp = index;
          var tmp3 = index;
          var tmp$ret$5;
          $l$block_0: {
            // Inline function 'kotlinx.io.internal.process2Utf8Bytes' call
            if (endIndex <= (tmp3 + 1 | 0)) {
              var c_1 = numberToChar(65533);
              var _unary__edvuaz_2 = length;
              length = _unary__edvuaz_2 + 1 | 0;
              chars[_unary__edvuaz_2] = c_1;
              tmp$ret$5 = 1;
              break $l$block_0;
            }
            var b0_0 = _this__u8e3s4[tmp3];
            var b1 = _this__u8e3s4[tmp3 + 1 | 0];
            // Inline function 'kotlinx.io.internal.isUtf8Continuation' call
            // Inline function 'kotlinx.io.and' call
            if (!((b1 & 192) === 128)) {
              var c_2 = numberToChar(65533);
              var _unary__edvuaz_3 = length;
              length = _unary__edvuaz_3 + 1 | 0;
              chars[_unary__edvuaz_3] = c_2;
              tmp$ret$5 = 1;
              break $l$block_0;
            }
            var codePoint = 3968 ^ b1 ^ b0_0 << 6;
            if (codePoint < 128) {
              var c_3 = numberToChar(65533);
              var _unary__edvuaz_4 = length;
              length = _unary__edvuaz_4 + 1 | 0;
              chars[_unary__edvuaz_4] = c_3;
            } else {
              var c_4 = numberToChar(codePoint);
              var _unary__edvuaz_5 = length;
              length = _unary__edvuaz_5 + 1 | 0;
              chars[_unary__edvuaz_5] = c_4;
            }
            tmp$ret$5 = 2;
          }
          index = tmp + tmp$ret$5 | 0;
        } else {
          // Inline function 'kotlinx.io.shr' call
          if (b0 >> 4 === -2) {
            var tmp_0 = index;
            var tmp12 = index;
            var tmp$ret$19;
            $l$block_4: {
              // Inline function 'kotlinx.io.internal.process3Utf8Bytes' call
              if (endIndex <= (tmp12 + 2 | 0)) {
                var c_5 = numberToChar(65533);
                var _unary__edvuaz_6 = length;
                length = _unary__edvuaz_6 + 1 | 0;
                chars[_unary__edvuaz_6] = c_5;
                var tmp_1;
                if (endIndex <= (tmp12 + 1 | 0)) {
                  tmp_1 = true;
                } else {
                  // Inline function 'kotlinx.io.internal.isUtf8Continuation' call
                  // Inline function 'kotlinx.io.and' call
                  tmp_1 = !((_this__u8e3s4[tmp12 + 1 | 0] & 192) === 128);
                }
                if (tmp_1) {
                  tmp$ret$19 = 1;
                  break $l$block_4;
                } else {
                  tmp$ret$19 = 2;
                  break $l$block_4;
                }
              }
              var b0_1 = _this__u8e3s4[tmp12];
              var b1_0 = _this__u8e3s4[tmp12 + 1 | 0];
              // Inline function 'kotlinx.io.internal.isUtf8Continuation' call
              // Inline function 'kotlinx.io.and' call
              if (!((b1_0 & 192) === 128)) {
                var c_6 = numberToChar(65533);
                var _unary__edvuaz_7 = length;
                length = _unary__edvuaz_7 + 1 | 0;
                chars[_unary__edvuaz_7] = c_6;
                tmp$ret$19 = 1;
                break $l$block_4;
              }
              var b2 = _this__u8e3s4[tmp12 + 2 | 0];
              // Inline function 'kotlinx.io.internal.isUtf8Continuation' call
              // Inline function 'kotlinx.io.and' call
              if (!((b2 & 192) === 128)) {
                var c_7 = numberToChar(65533);
                var _unary__edvuaz_8 = length;
                length = _unary__edvuaz_8 + 1 | 0;
                chars[_unary__edvuaz_8] = c_7;
                tmp$ret$19 = 2;
                break $l$block_4;
              }
              var codePoint_0 = -123008 ^ b2 ^ b1_0 << 6 ^ b0_1 << 12;
              if (codePoint_0 < 2048) {
                var c_8 = numberToChar(65533);
                var _unary__edvuaz_9 = length;
                length = _unary__edvuaz_9 + 1 | 0;
                chars[_unary__edvuaz_9] = c_8;
              } else if (55296 <= codePoint_0 ? codePoint_0 <= 57343 : false) {
                var c_9 = numberToChar(65533);
                var _unary__edvuaz_10 = length;
                length = _unary__edvuaz_10 + 1 | 0;
                chars[_unary__edvuaz_10] = c_9;
              } else {
                var c_10 = numberToChar(codePoint_0);
                var _unary__edvuaz_11 = length;
                length = _unary__edvuaz_11 + 1 | 0;
                chars[_unary__edvuaz_11] = c_10;
              }
              tmp$ret$19 = 3;
            }
            index = tmp_0 + tmp$ret$19 | 0;
          } else {
            // Inline function 'kotlinx.io.shr' call
            if (b0 >> 3 === -2) {
              var tmp_2 = index;
              var tmp23 = index;
              var tmp$ret$41;
              $l$block_10: {
                // Inline function 'kotlinx.io.internal.process4Utf8Bytes' call
                if (endIndex <= (tmp23 + 3 | 0)) {
                  if (!(65533 === 65533)) {
                    var c_11 = numberToChar((65533 >>> 10 | 0) + 55232 | 0);
                    var _unary__edvuaz_12 = length;
                    length = _unary__edvuaz_12 + 1 | 0;
                    chars[_unary__edvuaz_12] = c_11;
                    var c_12 = numberToChar((65533 & 1023) + 56320 | 0);
                    var _unary__edvuaz_13 = length;
                    length = _unary__edvuaz_13 + 1 | 0;
                    chars[_unary__edvuaz_13] = c_12;
                  } else {
                    var c_13 = _Char___init__impl__6a9atx(65533);
                    var _unary__edvuaz_14 = length;
                    length = _unary__edvuaz_14 + 1 | 0;
                    chars[_unary__edvuaz_14] = c_13;
                  }
                  var tmp_3;
                  if (endIndex <= (tmp23 + 1 | 0)) {
                    tmp_3 = true;
                  } else {
                    // Inline function 'kotlinx.io.internal.isUtf8Continuation' call
                    // Inline function 'kotlinx.io.and' call
                    tmp_3 = !((_this__u8e3s4[tmp23 + 1 | 0] & 192) === 128);
                  }
                  if (tmp_3) {
                    tmp$ret$41 = 1;
                    break $l$block_10;
                  } else {
                    var tmp_4;
                    if (endIndex <= (tmp23 + 2 | 0)) {
                      tmp_4 = true;
                    } else {
                      // Inline function 'kotlinx.io.internal.isUtf8Continuation' call
                      // Inline function 'kotlinx.io.and' call
                      tmp_4 = !((_this__u8e3s4[tmp23 + 2 | 0] & 192) === 128);
                    }
                    if (tmp_4) {
                      tmp$ret$41 = 2;
                      break $l$block_10;
                    } else {
                      tmp$ret$41 = 3;
                      break $l$block_10;
                    }
                  }
                }
                var b0_2 = _this__u8e3s4[tmp23];
                var b1_1 = _this__u8e3s4[tmp23 + 1 | 0];
                // Inline function 'kotlinx.io.internal.isUtf8Continuation' call
                // Inline function 'kotlinx.io.and' call
                if (!((b1_1 & 192) === 128)) {
                  if (!(65533 === 65533)) {
                    var c_14 = numberToChar((65533 >>> 10 | 0) + 55232 | 0);
                    var _unary__edvuaz_15 = length;
                    length = _unary__edvuaz_15 + 1 | 0;
                    chars[_unary__edvuaz_15] = c_14;
                    var c_15 = numberToChar((65533 & 1023) + 56320 | 0);
                    var _unary__edvuaz_16 = length;
                    length = _unary__edvuaz_16 + 1 | 0;
                    chars[_unary__edvuaz_16] = c_15;
                  } else {
                    var c_16 = _Char___init__impl__6a9atx(65533);
                    var _unary__edvuaz_17 = length;
                    length = _unary__edvuaz_17 + 1 | 0;
                    chars[_unary__edvuaz_17] = c_16;
                  }
                  tmp$ret$41 = 1;
                  break $l$block_10;
                }
                var b2_0 = _this__u8e3s4[tmp23 + 2 | 0];
                // Inline function 'kotlinx.io.internal.isUtf8Continuation' call
                // Inline function 'kotlinx.io.and' call
                if (!((b2_0 & 192) === 128)) {
                  if (!(65533 === 65533)) {
                    var c_17 = numberToChar((65533 >>> 10 | 0) + 55232 | 0);
                    var _unary__edvuaz_18 = length;
                    length = _unary__edvuaz_18 + 1 | 0;
                    chars[_unary__edvuaz_18] = c_17;
                    var c_18 = numberToChar((65533 & 1023) + 56320 | 0);
                    var _unary__edvuaz_19 = length;
                    length = _unary__edvuaz_19 + 1 | 0;
                    chars[_unary__edvuaz_19] = c_18;
                  } else {
                    var c_19 = _Char___init__impl__6a9atx(65533);
                    var _unary__edvuaz_20 = length;
                    length = _unary__edvuaz_20 + 1 | 0;
                    chars[_unary__edvuaz_20] = c_19;
                  }
                  tmp$ret$41 = 2;
                  break $l$block_10;
                }
                var b3 = _this__u8e3s4[tmp23 + 3 | 0];
                // Inline function 'kotlinx.io.internal.isUtf8Continuation' call
                // Inline function 'kotlinx.io.and' call
                if (!((b3 & 192) === 128)) {
                  if (!(65533 === 65533)) {
                    var c_20 = numberToChar((65533 >>> 10 | 0) + 55232 | 0);
                    var _unary__edvuaz_21 = length;
                    length = _unary__edvuaz_21 + 1 | 0;
                    chars[_unary__edvuaz_21] = c_20;
                    var c_21 = numberToChar((65533 & 1023) + 56320 | 0);
                    var _unary__edvuaz_22 = length;
                    length = _unary__edvuaz_22 + 1 | 0;
                    chars[_unary__edvuaz_22] = c_21;
                  } else {
                    var c_22 = _Char___init__impl__6a9atx(65533);
                    var _unary__edvuaz_23 = length;
                    length = _unary__edvuaz_23 + 1 | 0;
                    chars[_unary__edvuaz_23] = c_22;
                  }
                  tmp$ret$41 = 3;
                  break $l$block_10;
                }
                var codePoint_1 = 3678080 ^ b3 ^ b2_0 << 6 ^ b1_1 << 12 ^ b0_2 << 18;
                if (codePoint_1 > 1114111) {
                  if (!(65533 === 65533)) {
                    var c_23 = numberToChar((65533 >>> 10 | 0) + 55232 | 0);
                    var _unary__edvuaz_24 = length;
                    length = _unary__edvuaz_24 + 1 | 0;
                    chars[_unary__edvuaz_24] = c_23;
                    var c_24 = numberToChar((65533 & 1023) + 56320 | 0);
                    var _unary__edvuaz_25 = length;
                    length = _unary__edvuaz_25 + 1 | 0;
                    chars[_unary__edvuaz_25] = c_24;
                  } else {
                    var c_25 = _Char___init__impl__6a9atx(65533);
                    var _unary__edvuaz_26 = length;
                    length = _unary__edvuaz_26 + 1 | 0;
                    chars[_unary__edvuaz_26] = c_25;
                  }
                } else if (55296 <= codePoint_1 ? codePoint_1 <= 57343 : false) {
                  if (!(65533 === 65533)) {
                    var c_26 = numberToChar((65533 >>> 10 | 0) + 55232 | 0);
                    var _unary__edvuaz_27 = length;
                    length = _unary__edvuaz_27 + 1 | 0;
                    chars[_unary__edvuaz_27] = c_26;
                    var c_27 = numberToChar((65533 & 1023) + 56320 | 0);
                    var _unary__edvuaz_28 = length;
                    length = _unary__edvuaz_28 + 1 | 0;
                    chars[_unary__edvuaz_28] = c_27;
                  } else {
                    var c_28 = _Char___init__impl__6a9atx(65533);
                    var _unary__edvuaz_29 = length;
                    length = _unary__edvuaz_29 + 1 | 0;
                    chars[_unary__edvuaz_29] = c_28;
                  }
                } else if (codePoint_1 < 65536) {
                  if (!(65533 === 65533)) {
                    var c_29 = numberToChar((65533 >>> 10 | 0) + 55232 | 0);
                    var _unary__edvuaz_30 = length;
                    length = _unary__edvuaz_30 + 1 | 0;
                    chars[_unary__edvuaz_30] = c_29;
                    var c_30 = numberToChar((65533 & 1023) + 56320 | 0);
                    var _unary__edvuaz_31 = length;
                    length = _unary__edvuaz_31 + 1 | 0;
                    chars[_unary__edvuaz_31] = c_30;
                  } else {
                    var c_31 = _Char___init__impl__6a9atx(65533);
                    var _unary__edvuaz_32 = length;
                    length = _unary__edvuaz_32 + 1 | 0;
                    chars[_unary__edvuaz_32] = c_31;
                  }
                } else {
                  if (!(codePoint_1 === 65533)) {
                    var c_32 = numberToChar((codePoint_1 >>> 10 | 0) + 55232 | 0);
                    var _unary__edvuaz_33 = length;
                    length = _unary__edvuaz_33 + 1 | 0;
                    chars[_unary__edvuaz_33] = c_32;
                    var c_33 = numberToChar((codePoint_1 & 1023) + 56320 | 0);
                    var _unary__edvuaz_34 = length;
                    length = _unary__edvuaz_34 + 1 | 0;
                    chars[_unary__edvuaz_34] = c_33;
                  } else {
                    var c_34 = _Char___init__impl__6a9atx(65533);
                    var _unary__edvuaz_35 = length;
                    length = _unary__edvuaz_35 + 1 | 0;
                    chars[_unary__edvuaz_35] = c_34;
                  }
                }
                tmp$ret$41 = 4;
              }
              index = tmp_2 + tmp$ret$41 | 0;
            } else {
              var c_35 = _Char___init__impl__6a9atx(65533);
              var _unary__edvuaz_36 = length;
              length = _unary__edvuaz_36 + 1 | 0;
              chars[_unary__edvuaz_36] = c_35;
              index = index + 1 | 0;
            }
          }
        }
      }
    }
    return concatToString(chars, 0, length);
  }
  function get_SegmentReadContextImpl() {
    _init_properties_UnsafeBufferOperations_kt__xw75gy();
    return SegmentReadContextImpl;
  }
  var SegmentReadContextImpl;
  function get_SegmentWriteContextImpl() {
    _init_properties_UnsafeBufferOperations_kt__xw75gy();
    return SegmentWriteContextImpl;
  }
  var SegmentWriteContextImpl;
  var BufferIterationContextImpl;
  function UnsafeBufferOperations() {
  }
  var UnsafeBufferOperations_instance;
  function UnsafeBufferOperations_getInstance() {
    return UnsafeBufferOperations_instance;
  }
  function SegmentReadContextImpl$1() {
  }
  protoOf(SegmentReadContextImpl$1).n18 = function (segment, offset) {
    return segment.m17(offset);
  };
  function SegmentWriteContextImpl$1() {
  }
  protoOf(SegmentWriteContextImpl$1).n19 = function (segment, offset, value) {
    segment.g19(offset, value);
  };
  protoOf(SegmentWriteContextImpl$1).m19 = function (segment, offset, b0, b1) {
    segment.h19(offset, b0, b1);
  };
  protoOf(SegmentWriteContextImpl$1).l19 = function (segment, offset, b0, b1, b2) {
    segment.i19(offset, b0, b1, b2);
  };
  protoOf(SegmentWriteContextImpl$1).k19 = function (segment, offset, b0, b1, b2, b3) {
    segment.j19(offset, b0, b1, b2, b3);
  };
  function BufferIterationContextImpl$1() {
  }
  protoOf(BufferIterationContextImpl$1).n18 = function (segment, offset) {
    return get_SegmentReadContextImpl().n18(segment, offset);
  };
  var properties_initialized_UnsafeBufferOperations_kt_2xfgoc;
  function _init_properties_UnsafeBufferOperations_kt__xw75gy() {
    if (!properties_initialized_UnsafeBufferOperations_kt_2xfgoc) {
      properties_initialized_UnsafeBufferOperations_kt_2xfgoc = true;
      SegmentReadContextImpl = new SegmentReadContextImpl$1();
      SegmentWriteContextImpl = new SegmentWriteContextImpl$1();
      BufferIterationContextImpl = new BufferIterationContextImpl$1();
    }
  }
  function IOException_init_$Init$($this) {
    Exception_init_$Init$($this);
    IOException.call($this);
    return $this;
  }
  function IOException_init_$Create$() {
    var tmp = IOException_init_$Init$(objectCreate(protoOf(IOException)));
    captureStack(tmp, IOException_init_$Create$);
    return tmp;
  }
  function IOException_init_$Init$_0(message, $this) {
    Exception_init_$Init$_0(message, $this);
    IOException.call($this);
    return $this;
  }
  function IOException_init_$Create$_0(message) {
    var tmp = IOException_init_$Init$_0(message, objectCreate(protoOf(IOException)));
    captureStack(tmp, IOException_init_$Create$_0);
    return tmp;
  }
  function IOException_init_$Init$_1(message, cause, $this) {
    Exception_init_$Init$_1(message, cause, $this);
    IOException.call($this);
    return $this;
  }
  function IOException_init_$Create$_1(message, cause) {
    var tmp = IOException_init_$Init$_1(message, cause, objectCreate(protoOf(IOException)));
    captureStack(tmp, IOException_init_$Create$_1);
    return tmp;
  }
  function IOException() {
    captureStack(this, IOException);
  }
  function EOFException_init_$Init$($this) {
    IOException_init_$Init$($this);
    EOFException.call($this);
    return $this;
  }
  function EOFException_init_$Create$() {
    var tmp = EOFException_init_$Init$(objectCreate(protoOf(EOFException)));
    captureStack(tmp, EOFException_init_$Create$);
    return tmp;
  }
  function EOFException_init_$Init$_0(message, $this) {
    IOException_init_$Init$_0(message, $this);
    EOFException.call($this);
    return $this;
  }
  function EOFException_init_$Create$_0(message) {
    var tmp = EOFException_init_$Init$_0(message, objectCreate(protoOf(EOFException)));
    captureStack(tmp, EOFException_init_$Create$_0);
    return tmp;
  }
  function EOFException() {
    captureStack(this, EOFException);
  }
  function SegmentPool() {
    this.w17_1 = 0;
    this.x17_1 = 0;
  }
  protoOf(SegmentPool).y17 = function () {
    return Companion_instance.b19();
  };
  protoOf(SegmentPool).o18 = function (segment) {
  };
  protoOf(SegmentPool).d19 = function () {
    return AlwaysSharedCopyTracker_getInstance();
  };
  var SegmentPool_instance;
  function SegmentPool_getInstance() {
    return SegmentPool_instance;
  }
  //region block: post-declaration
  protoOf(Buffer).c18 = write$default;
  //endregion
  //region block: init
  Companion_instance = new Companion();
  UnsafeBufferOperations_instance = new UnsafeBufferOperations();
  SegmentPool_instance = new SegmentPool();
  //endregion
  //region block: exports
  _.$_$ = _.$_$ || {};
  _.$_$.a = EOFException_init_$Create$_0;
  _.$_$.b = IOException_init_$Init$_0;
  _.$_$.c = IOException_init_$Create$_0;
  _.$_$.d = IOException_init_$Init$_1;
  _.$_$.e = IOException_init_$Create$_1;
  _.$_$.f = Buffer;
  _.$_$.g = IOException;
  _.$_$.h = Source;
  _.$_$.i = indexOf_1;
  _.$_$.j = readByteArray_0;
  _.$_$.k = readByteArray;
  _.$_$.l = readByteString;
  _.$_$.m = readString;
  _.$_$.n = readString_0;
  _.$_$.o = readString_1;
  _.$_$.p = writeString;
  //endregion
  return _;
}));

//# sourceMappingURL=kotlinx-io-kotlinx-io-core.js.map