(function (root, factory) {
if (typeof define === 'function' && define.amd)
define(['exports', './kotlin-kotlin-stdlib-js-ir.js', './kotlinx.coroutines-kotlinx-coroutines-core-js-ir.js', './ktor-ktor-io-js-ir.js', './ktor-ktor-utils-js-ir.js', './88b0986a7186d029-atomicfu-js-ir.js'], factory);
else if (typeof exports === 'object')
factory(module.exports, require('./kotlin-kotlin-stdlib-js-ir.js'), require('./kotlinx.coroutines-kotlinx-coroutines-core-js-ir.js'), require('./ktor-ktor-io-js-ir.js'), require('./ktor-ktor-utils-js-ir.js'), require('./88b0986a7186d029-atomicfu-js-ir.js'));
else {
if (typeof this['kotlin-kotlin-stdlib-js-ir'] === 'undefined') {
throw new Error("Error loading module 'ktor-ktor-websockets-js-ir'. Its dependency 'kotlin-kotlin-stdlib-js-ir' was not found. Please, check whether 'kotlin-kotlin-stdlib-js-ir' is loaded prior to 'ktor-ktor-websockets-js-ir'.");
}
if (typeof this['kotlinx.coroutines-kotlinx-coroutines-core-js-ir'] === 'undefined') {
throw new Error("Error loading module 'ktor-ktor-websockets-js-ir'. Its dependency 'kotlinx.coroutines-kotlinx-coroutines-core-js-ir' was not found. Please, check whether 'kotlinx.coroutines-kotlinx-coroutines-core-js-ir' is loaded prior to 'ktor-ktor-websockets-js-ir'.");
}
if (typeof this['ktor-ktor-io-js-ir'] === 'undefined') {
throw new Error("Error loading module 'ktor-ktor-websockets-js-ir'. Its dependency 'ktor-ktor-io-js-ir' was not found. Please, check whether 'ktor-ktor-io-js-ir' is loaded prior to 'ktor-ktor-websockets-js-ir'.");
}
if (typeof this['ktor-ktor-utils-js-ir'] === 'undefined') {
throw new Error("Error loading module 'ktor-ktor-websockets-js-ir'. Its dependency 'ktor-ktor-utils-js-ir' was not found. Please, check whether 'ktor-ktor-utils-js-ir' is loaded prior to 'ktor-ktor-websockets-js-ir'.");
}
if (typeof this['88b0986a7186d029-atomicfu-js-ir'] === 'undefined') {
throw new Error("Error loading module 'ktor-ktor-websockets-js-ir'. Its dependency '88b0986a7186d029-atomicfu-js-ir' was not found. Please, check whether '88b0986a7186d029-atomicfu-js-ir' is loaded prior to 'ktor-ktor-websockets-js-ir'.");
}
root['ktor-ktor-websockets-js-ir'] = factory(typeof this['ktor-ktor-websockets-js-ir'] === 'undefined' ? {} : this['ktor-ktor-websockets-js-ir'], this['kotlin-kotlin-stdlib-js-ir'], this['kotlinx.coroutines-kotlinx-coroutines-core-js-ir'], this['ktor-ktor-io-js-ir'], this['ktor-ktor-utils-js-ir'], this['88b0986a7186d029-atomicfu-js-ir']);
}
}(this, function (_, kotlin_kotlin, kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core, kotlin_io_ktor_ktor_io, kotlin_io_ktor_ktor_utils, kotlin_org_jetbrains_kotlinx_atomicfu) {
'use strict';
//region block: imports
var imul = Math.imul;
var mapCapacity = kotlin_kotlin.$_$.e9;
var coerceAtLeast = kotlin_kotlin.$_$.me;
var LinkedHashMap_init_$Create$ = kotlin_kotlin.$_$.u1;
var Unit_getInstance = kotlin_kotlin.$_$.k5;
var objectMeta = kotlin_kotlin.$_$.wd;
var Enum = kotlin_kotlin.$_$.sh;
var classMeta = kotlin_kotlin.$_$.pc;
var toString = kotlin_kotlin.$_$.ae;
var getStringHashCode = kotlin_kotlin.$_$.wc;
var THROW_CCE = kotlin_kotlin.$_$.di;
var interfaceMeta = kotlin_kotlin.$_$.yc;
var IllegalArgumentException_init_$Create$ = kotlin_kotlin.$_$.s2;
var isInterface = kotlin_kotlin.$_$.id;
var Dispatchers_getInstance = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.x;
var launch$default = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.s;
var CoroutineStart_UNDISPATCHED_getInstance = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.b;
var launch = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.h2;
var Long = kotlin_kotlin.$_$.xh;
var ChannelResult = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.a1;
var _ChannelResult___get_isSuccess__impl__odq1z9 = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.t;
var CoroutineImpl = kotlin_kotlin.$_$.yb;
var CoroutineScope = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.p1;
var get_COROUTINE_SUSPENDED = kotlin_kotlin.$_$.gb;
var BytePacketBuilder_init_$Create$ = kotlin_io_ktor_ktor_io.$_$.m;
var ensureNotNull = kotlin_kotlin.$_$.ri;
var writeFully$default = kotlin_io_ktor_ktor_io.$_$.i;
var readBytes$default = kotlin_io_ktor_ktor_io.$_$.g;
var cancelConsumed = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.d1;
var ClosedSendChannelException = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.c1;
var CancellationException_init_$Create$ = kotlin_kotlin.$_$.d2;
var ChannelIOException = kotlin_io_ktor_ktor_utils.$_$.f;
var CancellationException = kotlin_kotlin.$_$.fb;
var ClosedReceiveChannelException = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.b1;
var IOException_init_$Create$ = kotlin_io_ktor_ktor_io.$_$.o;
var toLong = kotlin_kotlin.$_$.yd;
var atomic$ref$1 = kotlin_org_jetbrains_kotlinx_atomicfu.$_$.c;
var CompletableDeferred$default = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.j;
var Channel$default = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.i;
var atomic$boolean$1 = kotlin_org_jetbrains_kotlinx_atomicfu.$_$.a;
var Key_getInstance = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.z;
var Job = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.u1;
var ArrayList_init_$Create$ = kotlin_kotlin.$_$.m1;
var CoroutineName = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.n1;
var IllegalStateException_init_$Create$ = kotlin_kotlin.$_$.x2;
var SuspendFunction1 = kotlin_kotlin.$_$.ac;
var Charsets_getInstance = kotlin_io_ktor_ktor_io.$_$.q;
var decode$default = kotlin_io_ktor_ktor_io.$_$.d;
var DisposableHandle = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.t1;
var readShort = kotlin_io_ktor_ktor_io.$_$.e1;
var Exception = kotlin_kotlin.$_$.uh;
var Exception_init_$Init$ = kotlin_kotlin.$_$.m2;
var captureStack = kotlin_kotlin.$_$.jc;
var CopyableThrowable = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.k1;
var get_lastIndex = kotlin_kotlin.$_$.x8;
var compareTo = kotlin_kotlin.$_$.qc;
var fillArrayVal = kotlin_kotlin.$_$.tc;
var Job$default = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.m;
var Factory_getInstance = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.u;
var encodeToByteArray = kotlin_kotlin.$_$.pf;
var encodeToByteArray_0 = kotlin_io_ktor_ktor_io.$_$.t;
var String$default = kotlin_io_ktor_ktor_io.$_$.f;
var getTimeMillis = kotlin_io_ktor_ktor_utils.$_$.h;
var Random = kotlin_kotlin.$_$.je;
var withTimeoutOrNull = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.g;
var hex = kotlin_io_ktor_ktor_utils.$_$.z;
var collectionSizeOrDefault = kotlin_kotlin.$_$.p6;
var ArrayList_init_$Create$_0 = kotlin_kotlin.$_$.l1;
var joinToString$default = kotlin_kotlin.$_$.m;
var split$default = kotlin_kotlin.$_$.c1;
var first = kotlin_kotlin.$_$.g8;
var isCharSequence = kotlin_kotlin.$_$.dd;
var trim = kotlin_kotlin.$_$.kh;
var drop = kotlin_kotlin.$_$.v7;
var writeShort = kotlin_io_ktor_ktor_io.$_$.f1;
var writeText$default = kotlin_io_ktor_ktor_io.$_$.j;
var noWhenBranchMatchedException = kotlin_kotlin.$_$.zi;
//endregion
//region block: pre-declaration
Codes.prototype = Object.create(Enum.prototype);
Codes.prototype.constructor = Codes;
function send(frame, $cont) {
return this.s3d().l2a(frame, $cont);
}
DefaultWebSocketSessionImpl$runIncomingProcessor$slambda.prototype = Object.create(CoroutineImpl.prototype);
DefaultWebSocketSessionImpl$runIncomingProcessor$slambda.prototype.constructor = DefaultWebSocketSessionImpl$runIncomingProcessor$slambda;
DefaultWebSocketSessionImpl$runOutgoingProcessor$slambda.prototype = Object.create(CoroutineImpl.prototype);
DefaultWebSocketSessionImpl$runOutgoingProcessor$slambda.prototype.constructor = DefaultWebSocketSessionImpl$runOutgoingProcessor$slambda;
DefaultWebSocketSessionImpl$runOrCancelPinger$slambda.prototype = Object.create(CoroutineImpl.prototype);
DefaultWebSocketSessionImpl$runOrCancelPinger$slambda.prototype.constructor = DefaultWebSocketSessionImpl$runOrCancelPinger$slambda;
$outgoingProcessorLoopCOROUTINE$0.prototype = Object.create(CoroutineImpl.prototype);
$outgoingProcessorLoopCOROUTINE$0.prototype.constructor = $outgoingProcessorLoopCOROUTINE$0;
$sendCloseSequenceCOROUTINE$1.prototype = Object.create(CoroutineImpl.prototype);
$sendCloseSequenceCOROUTINE$1.prototype.constructor = $sendCloseSequenceCOROUTINE$1;
$checkMaxFrameSizeCOROUTINE$2.prototype = Object.create(CoroutineImpl.prototype);
$checkMaxFrameSizeCOROUTINE$2.prototype.constructor = $checkMaxFrameSizeCOROUTINE$2;
FrameTooBigException.prototype = Object.create(Exception.prototype);
FrameTooBigException.prototype.constructor = FrameTooBigException;
FrameType.prototype = Object.create(Enum.prototype);
FrameType.prototype.constructor = FrameType;
ponger$slambda.prototype = Object.create(CoroutineImpl.prototype);
ponger$slambda.prototype.constructor = ponger$slambda;
pinger$slambda$slambda.prototype = Object.create(CoroutineImpl.prototype);
pinger$slambda$slambda.prototype.constructor = pinger$slambda$slambda;
pinger$slambda$slambda_1.prototype = Object.create(CoroutineImpl.prototype);
pinger$slambda$slambda_1.prototype.constructor = pinger$slambda$slambda_1;
pinger$slambda.prototype = Object.create(CoroutineImpl.prototype);
pinger$slambda.prototype.constructor = pinger$slambda;
$closeCOROUTINE$3.prototype = Object.create(CoroutineImpl.prototype);
$closeCOROUTINE$3.prototype.constructor = $closeCOROUTINE$3;
Binary.prototype = Object.create(Frame.prototype);
Binary.prototype.constructor = Binary;
Text.prototype = Object.create(Frame.prototype);
Text.prototype.constructor = Text;
Close.prototype = Object.create(Frame.prototype);
Close.prototype.constructor = Close;
Ping.prototype = Object.create(Frame.prototype);
Ping.prototype.constructor = Ping;
Pong.prototype = Object.create(Frame.prototype);
Pong.prototype.constructor = Pong;
//endregion
var Codes_NORMAL_instance;
var Codes_GOING_AWAY_instance;
var Codes_PROTOCOL_ERROR_instance;
var Codes_CANNOT_ACCEPT_instance;
var Codes_CLOSED_ABNORMALLY_instance;
var Codes_NOT_CONSISTENT_instance;
var Codes_VIOLATED_POLICY_instance;
var Codes_TOO_BIG_instance;
var Codes_NO_EXTENSION_instance;
var Codes_INTERNAL_ERROR_instance;
var Codes_SERVICE_RESTART_instance;
var Codes_TRY_AGAIN_LATER_instance;
function Companion() {
Companion_instance = this;
var tmp = this;
var tmp$ret$2;
// Inline function 'kotlin.collections.associateBy' call
var tmp0_associateBy = values();
var capacity = coerceAtLeast(mapCapacity(tmp0_associateBy.length), 16);
var tmp$ret$1;
// Inline function 'kotlin.collections.associateByTo' call
var tmp0_associateByTo = LinkedHashMap_init_$Create$(capacity);
var indexedObject = tmp0_associateBy;
var inductionVariable = 0;
var last = indexedObject.length;
while (inductionVariable < last) {
var element = indexedObject[inductionVariable];
inductionVariable = inductionVariable + 1 | 0;
var tmp$ret$0;
// Inline function 'io.ktor.websocket.Companion.byCodeMap.<anonymous>' call
tmp$ret$0 = element.g3d_1;
tmp0_associateByTo.a(tmp$ret$0, element);
}
tmp$ret$1 = tmp0_associateByTo;
tmp$ret$2 = tmp$ret$1;
tmp.h3d_1 = tmp$ret$2;
this.i3d_1 = Codes_INTERNAL_ERROR_getInstance();
}
Companion.prototype.j3d = function (code) {
return this.h3d_1.q(code);
};
Companion.$metadata$ = objectMeta('Companion');
var Companion_instance;
function Companion_getInstance() {
Codes_initEntries();
if (Companion_instance == null)
new Companion();
return Companion_instance;
}
function values() {
return [Codes_NORMAL_getInstance(), Codes_GOING_AWAY_getInstance(), Codes_PROTOCOL_ERROR_getInstance(), Codes_CANNOT_ACCEPT_getInstance(), Codes_CLOSED_ABNORMALLY_getInstance(), Codes_NOT_CONSISTENT_getInstance(), Codes_VIOLATED_POLICY_getInstance(), Codes_TOO_BIG_getInstance(), Codes_NO_EXTENSION_getInstance(), Codes_INTERNAL_ERROR_getInstance(), Codes_SERVICE_RESTART_getInstance(), Codes_TRY_AGAIN_LATER_getInstance()];
}
var Codes_entriesInitialized;
function Codes_initEntries() {
if (Codes_entriesInitialized)
return Unit_getInstance();
Codes_entriesInitialized = true;
Codes_NORMAL_instance = new Codes('NORMAL', 0, 1000);
Codes_GOING_AWAY_instance = new Codes('GOING_AWAY', 1, 1001);
Codes_PROTOCOL_ERROR_instance = new Codes('PROTOCOL_ERROR', 2, 1002);
Codes_CANNOT_ACCEPT_instance = new Codes('CANNOT_ACCEPT', 3, 1003);
Codes_CLOSED_ABNORMALLY_instance = new Codes('CLOSED_ABNORMALLY', 4, 1006);
Codes_NOT_CONSISTENT_instance = new Codes('NOT_CONSISTENT', 5, 1007);
Codes_VIOLATED_POLICY_instance = new Codes('VIOLATED_POLICY', 6, 1008);
Codes_TOO_BIG_instance = new Codes('TOO_BIG', 7, 1009);
Codes_NO_EXTENSION_instance = new Codes('NO_EXTENSION', 8, 1010);
Codes_INTERNAL_ERROR_instance = new Codes('INTERNAL_ERROR', 9, 1011);
Codes_SERVICE_RESTART_instance = new Codes('SERVICE_RESTART', 10, 1012);
Codes_TRY_AGAIN_LATER_instance = new Codes('TRY_AGAIN_LATER', 11, 1013);
Companion_getInstance();
}
function CloseReason_init_$Init$(code, message, $this) {
CloseReason.call($this, code.g3d_1, message);
return $this;
}
function CloseReason_init_$Create$(code, message) {
return CloseReason_init_$Init$(code, message, Object.create(CloseReason.prototype));
}
function Codes(name, ordinal, code) {
Enum.call(this, name, ordinal);
this.g3d_1 = code;
}
Codes.prototype.k3d = function () {
return this.g3d_1;
};
Codes.$metadata$ = classMeta('Codes', undefined, undefined, undefined, undefined, Enum.prototype);
function Codes_NORMAL_getInstance() {
Codes_initEntries();
return Codes_NORMAL_instance;
}
function Codes_GOING_AWAY_getInstance() {
Codes_initEntries();
return Codes_GOING_AWAY_instance;
}
function Codes_PROTOCOL_ERROR_getInstance() {
Codes_initEntries();
return Codes_PROTOCOL_ERROR_instance;
}
function Codes_CANNOT_ACCEPT_getInstance() {
Codes_initEntries();
return Codes_CANNOT_ACCEPT_instance;
}
function Codes_CLOSED_ABNORMALLY_getInstance() {
Codes_initEntries();
return Codes_CLOSED_ABNORMALLY_instance;
}
function Codes_NOT_CONSISTENT_getInstance() {
Codes_initEntries();
return Codes_NOT_CONSISTENT_instance;
}
function Codes_VIOLATED_POLICY_getInstance() {
Codes_initEntries();
return Codes_VIOLATED_POLICY_instance;
}
function Codes_TOO_BIG_getInstance() {
Codes_initEntries();
return Codes_TOO_BIG_instance;
}
function Codes_NO_EXTENSION_getInstance() {
Codes_initEntries();
return Codes_NO_EXTENSION_instance;
}
function Codes_INTERNAL_ERROR_getInstance() {
Codes_initEntries();
return Codes_INTERNAL_ERROR_instance;
}
function Codes_SERVICE_RESTART_getInstance() {
Codes_initEntries();
return Codes_SERVICE_RESTART_instance;
}
function Codes_TRY_AGAIN_LATER_getInstance() {
Codes_initEntries();
return Codes_TRY_AGAIN_LATER_instance;
}
function CloseReason(code, message) {
this.l3d_1 = code;
this.m3d_1 = message;
}
CloseReason.prototype.k3d = function () {
return this.l3d_1;
};
CloseReason.prototype.j2 = function () {
return this.m3d_1;
};
CloseReason.prototype.n3d = function () {
return Companion_getInstance().j3d(this.l3d_1);
};
CloseReason.prototype.toString = function () {
var tmp0_elvis_lhs = this.n3d();
return 'CloseReason(reason=' + toString(tmp0_elvis_lhs == null ? this.l3d_1 : tmp0_elvis_lhs) + ', message=' + this.m3d_1 + ')';
};
CloseReason.prototype.hashCode = function () {
var result = this.l3d_1;
result = imul(result, 31) + getStringHashCode(this.m3d_1) | 0;
return result;
};
CloseReason.prototype.equals = function (other) {
if (this === other)
return true;
if (!(other instanceof CloseReason))
return false;
var tmp0_other_with_cast = other instanceof CloseReason ? other : THROW_CCE();
if (!(this.l3d_1 === tmp0_other_with_cast.l3d_1))
return false;
if (!(this.m3d_1 === tmp0_other_with_cast.m3d_1))
return false;
return true;
};
CloseReason.$metadata$ = classMeta('CloseReason');
function get_IncomingProcessorCoroutineName() {
init_properties_DefaultWebSocketSession_kt_vhpdcs();
return IncomingProcessorCoroutineName;
}
var IncomingProcessorCoroutineName;
function get_OutgoingProcessorCoroutineName() {
init_properties_DefaultWebSocketSession_kt_vhpdcs();
return OutgoingProcessorCoroutineName;
}
var OutgoingProcessorCoroutineName;
function get_NORMAL_CLOSE() {
init_properties_DefaultWebSocketSession_kt_vhpdcs();
return NORMAL_CLOSE;
}
var NORMAL_CLOSE;
function DefaultWebSocketSession() {
}
DefaultWebSocketSession.$metadata$ = interfaceMeta('DefaultWebSocketSession', [WebSocketSession]);
function DefaultWebSocketSession_0(session, pingInterval, timeoutMillis) {
init_properties_DefaultWebSocketSession_kt_vhpdcs();
// Inline function 'kotlin.require' call
// Inline function 'kotlin.contracts.contract' call
if (!!isInterface(session, DefaultWebSocketSession)) {
var tmp$ret$0;
// Inline function 'io.ktor.websocket.DefaultWebSocketSession.<anonymous>' call
tmp$ret$0 = 'Cannot wrap other DefaultWebSocketSession';
var message = tmp$ret$0;
throw IllegalArgumentException_init_$Create$(toString(message));
}
return new DefaultWebSocketSessionImpl(session, pingInterval, timeoutMillis);
}
function runIncomingProcessor($this, ponger) {
var tmp = get_IncomingProcessorCoroutineName().p8(Dispatchers_getInstance().x20_1);
return launch$default($this, tmp, null, DefaultWebSocketSessionImpl$runIncomingProcessor$slambda_0($this, ponger, null), 2, null);
}
function runOutgoingProcessor($this) {
var tmp = get_OutgoingProcessorCoroutineName().p8(Dispatchers_getInstance().x20_1);
var tmp_0 = CoroutineStart_UNDISPATCHED_getInstance();
return launch($this, tmp, tmp_0, DefaultWebSocketSessionImpl$runOutgoingProcessor$slambda_0($this, null));
}
function outgoingProcessorLoop($this, $cont) {
var tmp = new $outgoingProcessorLoopCOROUTINE$0($this, $cont);
tmp.q7_1 = Unit_getInstance();
tmp.r7_1 = null;
return tmp.v7();
}
function sendCloseSequence($this, reason, exception, $cont) {
var tmp = new $sendCloseSequenceCOROUTINE$1($this, reason, exception, $cont);
tmp.q7_1 = Unit_getInstance();
tmp.r7_1 = null;
return tmp.v7();
}
function sendCloseSequence$default($this, reason, exception, $cont, $mask0, $handler) {
if (!(($mask0 & 4) === 0))
exception = null;
return sendCloseSequence($this, reason, exception, $cont);
}
function tryClose($this) {
return $this.b3f_1.atomicfu$compareAndSet(false, true);
}
function runOrCancelPinger($this) {
var interval = $this.g3f_1;
var tmp;
if ($this.b3f_1.o1t_1) {
tmp = null;
} else if (interval.x1(new Long(0, 0)) > 0) {
var tmp_0 = $this.w3e_1.s3d();
var tmp_1 = $this.h3f_1;
tmp = pinger($this, tmp_0, interval, tmp_1, DefaultWebSocketSessionImpl$runOrCancelPinger$slambda_0($this, null));
} else {
tmp = null;
}
var newPinger = tmp;
var tmp0_safe_receiver = $this.x3e_1.atomicfu$getAndSet(newPinger);
if (tmp0_safe_receiver == null)
null;
else {
tmp0_safe_receiver.o2a(null, 1, null);
}
var tmp1_safe_receiver = newPinger;
var tmp2_safe_receiver = tmp1_safe_receiver == null ? null : new ChannelResult(tmp1_safe_receiver.m2a(Companion_getInstance_0().j3f_1));
if (tmp2_safe_receiver == null)
null;
else
_ChannelResult___get_isSuccess__impl__odq1z9(tmp2_safe_receiver.c2c_1);
if ($this.b3f_1.o1t_1 ? !(newPinger == null) : false) {
runOrCancelPinger($this);
}
}
function checkMaxFrameSize($this, packet, frame, $cont) {
var tmp = new $checkMaxFrameSizeCOROUTINE$2($this, packet, frame, $cont);
tmp.q7_1 = Unit_getInstance();
tmp.r7_1 = null;
return tmp.v7();
}
function processIncomingExtensions($this, frame) {
var tmp$ret$1;
// Inline function 'kotlin.collections.fold' call
var tmp0_fold = $this.w3f();
var accumulator = frame;
var tmp0_iterator = tmp0_fold.j();
while (tmp0_iterator.k()) {
var element = tmp0_iterator.l();
var tmp$ret$0;
// Inline function 'io.ktor.websocket.DefaultWebSocketSessionImpl.processIncomingExtensions.<anonymous>' call
var tmp1__anonymous__uwfjfc = accumulator;
tmp$ret$0 = element.x3f(tmp1__anonymous__uwfjfc);
accumulator = tmp$ret$0;
}
tmp$ret$1 = accumulator;
return tmp$ret$1;
}
function processOutgoingExtensions($this, frame) {
var tmp$ret$1;
// Inline function 'kotlin.collections.fold' call
var tmp0_fold = $this.w3f();
var accumulator = frame;
var tmp0_iterator = tmp0_fold.j();
while (tmp0_iterator.k()) {
var element = tmp0_iterator.l();
var tmp$ret$0;
// Inline function 'io.ktor.websocket.DefaultWebSocketSessionImpl.processOutgoingExtensions.<anonymous>' call
var tmp1__anonymous__uwfjfc = accumulator;
tmp$ret$0 = element.y3f(tmp1__anonymous__uwfjfc);
accumulator = tmp$ret$0;
}
tmp$ret$1 = accumulator;
return tmp$ret$1;
}
function Companion_0() {
Companion_instance_0 = this;
this.j3f_1 = new Pong(new Int8Array(0), NonDisposableHandle_getInstance());
}
Companion_0.$metadata$ = objectMeta('Companion');
var Companion_instance_0;
function Companion_getInstance_0() {
if (Companion_instance_0 == null)
new Companion_0();
return Companion_instance_0;
}
function DefaultWebSocketSessionImpl$runIncomingProcessor$slambda(this$0, $ponger, resultContinuation) {
this.h3g_1 = this$0;
this.i3g_1 = $ponger;
CoroutineImpl.call(this, resultContinuation);
}
DefaultWebSocketSessionImpl$runIncomingProcessor$slambda.prototype.h2n = function ($this$launch, $cont) {
var tmp = this.i2n($this$launch, $cont);
tmp.q7_1 = Unit_getInstance();
tmp.r7_1 = null;
return tmp.v7();
};
DefaultWebSocketSessionImpl$runIncomingProcessor$slambda.prototype.w7 = function (p1, $cont) {
return this.h2n((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $cont);
};
DefaultWebSocketSessionImpl$runIncomingProcessor$slambda.prototype.v7 = function () {
var suspendResult = this.q7_1;
$sm: do
try {
var tmp = this.o7_1;
switch (tmp) {
case 0:
this.p7_1 = 37;
this.k3g_1 = null;
this.l3g_1 = false;
this.o7_1 = 1;
continue $sm;
case 1:
this.o7_1 = 2;
continue $sm;
case 2:
this.p7_1 = 31;
this.p7_1 = 30;
var tmp_0 = this;
tmp_0.o3g_1 = this.h3g_1.w3e_1.r3d();
this.o7_1 = 3;
continue $sm;
case 3:
this.q3g_1 = null;
this.o7_1 = 4;
continue $sm;
case 4:
this.o7_1 = 5;
continue $sm;
case 5:
this.o7_1 = 6;
continue $sm;
case 6:
this.p7_1 = 27;
this.p7_1 = 26;
this.t3g_1 = this.o3g_1.j();
this.o7_1 = 7;
continue $sm;
case 7:
this.o7_1 = 8;
suspendResult = this.t3g_1.q28(this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 8:
if (!suspendResult) {
this.o7_1 = 24;
continue $sm;
}
this.u3g_1 = this.t3g_1.l();
this.o7_1 = 9;
continue $sm;
case 9:
this.w3g_1 = this.u3g_1;
var tmp_1 = this.w3g_1;
if (tmp_1 instanceof Close) {
if (!this.h3g_1.s3d().k2a()) {
this.o7_1 = 18;
var tmp_2 = this.h3g_1.s3d();
var tmp1_elvis_lhs = readReason(this.u3g_1);
suspendResult = tmp_2.l2a(Close_init_$Create$(tmp1_elvis_lhs == null ? get_NORMAL_CLOSE() : tmp1_elvis_lhs), this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
} else {
this.o7_1 = 19;
continue $sm;
}
} else {
var tmp_3 = this.w3g_1;
if (tmp_3 instanceof Pong) {
this.x3g_1 = this.h3g_1.x3e_1.k1t_1;
if (this.x3g_1 == null) {
this.y3g_1 = null;
this.o7_1 = 15;
continue $sm;
} else {
this.o7_1 = 14;
suspendResult = this.x3g_1.l2a(this.u3g_1, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
}
} else {
var tmp_4 = this.w3g_1;
if (tmp_4 instanceof Ping) {
this.o7_1 = 13;
suspendResult = this.i3g_1.l2a(this.u3g_1, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
} else {
this.o7_1 = 10;
suspendResult = checkMaxFrameSize(this.h3g_1, this.k3g_1, this.u3g_1, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
}
}
}
break;
case 10:
if (!this.u3g_1.f3h_1) {
if (this.k3g_1 == null) {
var tmp_5 = this;
tmp_5.k3g_1 = BytePacketBuilder_init_$Create$(null, 1, null);
}
var tmp_6 = ensureNotNull(this.k3g_1);
writeFully$default(tmp_6, this.u3g_1.h3h_1, 0, 0, 6, null);
this.v3g_1 = Unit_getInstance();
this.o7_1 = 17;
continue $sm;
} else {
this.o7_1 = 11;
continue $sm;
}
break;
case 11:
var tmp_7 = this;
var tmp3_safe_receiver = this.k3g_1;
var tmp_8;
if (tmp3_safe_receiver == null) {
tmp_8 = null;
} else {
writeFully$default(tmp3_safe_receiver, this.u3g_1.h3h_1, 0, 0, 6, null);
var tmp_9 = Companion_getInstance_2();
var tmp_10 = tmp3_safe_receiver.c4();
tmp_8 = tmp_9.n3h(true, this.u3g_1.g3h_1, readBytes$default(tmp_10, 0, 1, null), this.u3g_1.j3h_1, this.u3g_1.k3h_1, this.u3g_1.l3h_1);
}
var tmp4_elvis_lhs = tmp_8;
tmp_7.z3g_1 = tmp4_elvis_lhs == null ? this.u3g_1 : tmp4_elvis_lhs;
this.k3g_1 = null;
this.o7_1 = 12;
suspendResult = this.h3g_1.z3e_1.l2a(processIncomingExtensions(this.h3g_1, this.z3g_1), this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 12:
this.o7_1 = 16;
continue $sm;
case 13:
this.o7_1 = 16;
continue $sm;
case 14:
var tmp_11 = this;
tmp_11.y3g_1 = Unit_getInstance();
this.o7_1 = 15;
continue $sm;
case 15:
;
this.o7_1 = 16;
continue $sm;
case 16:
if (false) {
this.o7_1 = 9;
continue $sm;
}
this.o7_1 = 17;
continue $sm;
case 17:
this.o7_1 = 7;
continue $sm;
case 18:
this.o7_1 = 19;
continue $sm;
case 19:
this.l3g_1 = true;
this.s3g_1 = Unit_getInstance();
this.o7_1 = 20;
continue $sm;
case 20:
var tmp_12 = this;
cancelConsumed(this.o3g_1, this.q3g_1);
tmp_12.n3g_1 = Unit_getInstance();
this.p7_1 = 37;
this.o7_1 = 21;
continue $sm;
case 21:
this.i3g_1.o2a(null, 1, null);
;
var tmp0_safe_receiver = this.k3g_1;
if (tmp0_safe_receiver == null)
null;
else {
tmp0_safe_receiver.s17();
}
;
this.h3g_1.z3e_1.o2a(null, 1, null);
;
if (!this.l3g_1) {
this.o7_1 = 22;
suspendResult = close(this.h3g_1, CloseReason_init_$Create$(Codes_CLOSED_ABNORMALLY_getInstance(), 'Connection was closed without close frame'), this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
} else {
this.o7_1 = 23;
continue $sm;
}
break;
case 22:
this.o7_1 = 23;
continue $sm;
case 23:
return Unit_getInstance();
case 24:
this.r3g_1 = Unit_getInstance();
this.o7_1 = 25;
var tmp_13 = this;
continue $sm;
case 25:
var tmp_14 = this;
cancelConsumed(this.o3g_1, this.q3g_1);
tmp_14.p3g_1 = Unit_getInstance();
this.o7_1 = 29;
continue $sm;
case 26:
this.p7_1 = 27;
var tmp_15 = this.r7_1;
if (tmp_15 instanceof Error) {
this.a3h_1 = this.r7_1;
var tmp_16 = this;
this.q3g_1 = this.a3h_1;
throw this.a3h_1;
} else {
throw this.r7_1;
}
break;
case 27:
this.p7_1 = 30;
this.b3h_1 = this.r7_1;
cancelConsumed(this.o3g_1, this.q3g_1);
;
throw this.b3h_1;
case 28:
cancelConsumed(this.o3g_1, this.q3g_1);
;
if (false) {
this.o7_1 = 3;
continue $sm;
}
this.o7_1 = 29;
continue $sm;
case 29:
this.m3g_1 = this.p3g_1;
this.p7_1 = 37;
this.o7_1 = 34;
continue $sm;
case 30:
this.p7_1 = 31;
var tmp_17 = this.r7_1;
if (tmp_17 instanceof ClosedSendChannelException) {
this.c3h_1 = this.r7_1;
var tmp_18 = this;
tmp_18.m3g_1 = Unit_getInstance();
this.p7_1 = 37;
this.o7_1 = 34;
continue $sm;
} else {
var tmp_19 = this.r7_1;
if (tmp_19 instanceof Error) {
this.d3h_1 = this.r7_1;
var tmp_20 = this;
this.i3g_1.o2a(null, 1, null);
this.h3g_1.z3e_1.a2a(this.d3h_1);
tmp_20.m3g_1 = Unit_getInstance();
this.p7_1 = 37;
this.o7_1 = 34;
continue $sm;
} else {
throw this.r7_1;
}
}
break;
case 31:
this.p7_1 = 37;
this.e3h_1 = this.r7_1;
this.i3g_1.o2a(null, 1, null);
;
var tmp0_safe_receiver_0 = this.k3g_1;
if (tmp0_safe_receiver_0 == null)
null;
else {
tmp0_safe_receiver_0.s17();
}
;
this.h3g_1.z3e_1.o2a(null, 1, null);
;
if (!this.l3g_1) {
this.o7_1 = 32;
suspendResult = close(this.h3g_1, CloseReason_init_$Create$(Codes_CLOSED_ABNORMALLY_getInstance(), 'Connection was closed without close frame'), this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
} else {
this.o7_1 = 33;
continue $sm;
}
break;
case 32:
this.o7_1 = 33;
continue $sm;
case 33:
throw this.e3h_1;
case 34:
this.i3g_1.o2a(null, 1, null);
;
var tmp0_safe_receiver_1 = this.k3g_1;
if (tmp0_safe_receiver_1 == null)
null;
else {
tmp0_safe_receiver_1.s17();
}
;
this.h3g_1.z3e_1.o2a(null, 1, null);
;
if (!this.l3g_1) {
this.o7_1 = 35;
suspendResult = close(this.h3g_1, CloseReason_init_$Create$(Codes_CLOSED_ABNORMALLY_getInstance(), 'Connection was closed without close frame'), this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
} else {
this.o7_1 = 36;
continue $sm;
}
break;
case 35:
this.o7_1 = 36;
continue $sm;
case 36:
return Unit_getInstance();
case 37:
throw this.r7_1;
}
} catch ($p) {
if (this.p7_1 === 37) {
throw $p;
} else {
this.o7_1 = this.p7_1;
this.r7_1 = $p;
}
}
while (true);
};
DefaultWebSocketSessionImpl$runIncomingProcessor$slambda.prototype.i2n = function ($this$launch, completion) {
var i = new DefaultWebSocketSessionImpl$runIncomingProcessor$slambda(this.h3g_1, this.i3g_1, completion);
i.j3g_1 = $this$launch;
return i;
};
DefaultWebSocketSessionImpl$runIncomingProcessor$slambda.$metadata$ = classMeta('DefaultWebSocketSessionImpl$runIncomingProcessor$slambda', undefined, undefined, undefined, [1], CoroutineImpl.prototype);
function DefaultWebSocketSessionImpl$runIncomingProcessor$slambda_0(this$0, $ponger, resultContinuation) {
var i = new DefaultWebSocketSessionImpl$runIncomingProcessor$slambda(this$0, $ponger, resultContinuation);
var l = function ($this$launch, $cont) {
return i.h2n($this$launch, $cont);
};
l.$arity = 1;
return l;
}
function DefaultWebSocketSessionImpl$runOutgoingProcessor$slambda(this$0, resultContinuation) {
this.w3h_1 = this$0;
CoroutineImpl.call(this, resultContinuation);
}
DefaultWebSocketSessionImpl$runOutgoingProcessor$slambda.prototype.h2n = function ($this$launch, $cont) {
var tmp = this.i2n($this$launch, $cont);
tmp.q7_1 = Unit_getInstance();
tmp.r7_1 = null;
return tmp.v7();
};
DefaultWebSocketSessionImpl$runOutgoingProcessor$slambda.prototype.w7 = function (p1, $cont) {
return this.h2n((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $cont);
};
DefaultWebSocketSessionImpl$runOutgoingProcessor$slambda.prototype.v7 = function () {
var suspendResult = this.q7_1;
$sm: do
try {
var tmp = this.o7_1;
switch (tmp) {
case 0:
this.p7_1 = 9;
this.o7_1 = 1;
continue $sm;
case 1:
this.p7_1 = 5;
this.p7_1 = 3;
this.o7_1 = 2;
suspendResult = outgoingProcessorLoop(this.w3h_1, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 2:
this.y3h_1 = suspendResult;
this.p7_1 = 9;
this.o7_1 = 7;
continue $sm;
case 3:
this.p7_1 = 5;
var tmp_0 = this.r7_1;
if (tmp_0 instanceof ClosedSendChannelException) {
this.z3h_1 = this.r7_1;
var tmp_1 = this;
tmp_1.y3h_1 = Unit_getInstance();
this.p7_1 = 9;
this.o7_1 = 7;
continue $sm;
} else {
var tmp_2 = this.r7_1;
if (tmp_2 instanceof ClosedReceiveChannelException) {
this.a3i_1 = this.r7_1;
var tmp_3 = this;
tmp_3.y3h_1 = Unit_getInstance();
this.p7_1 = 9;
this.o7_1 = 7;
continue $sm;
} else {
var tmp_4 = this.r7_1;
if (tmp_4 instanceof CancellationException) {
this.b3i_1 = this.r7_1;
var tmp_5 = this;
tmp_5.y3h_1 = Unit_getInstance();
this.p7_1 = 9;
this.o7_1 = 7;
continue $sm;
} else {
var tmp_6 = this.r7_1;
if (tmp_6 instanceof ChannelIOException) {
this.c3i_1 = this.r7_1;
var tmp_7 = this;
tmp_7.y3h_1 = Unit_getInstance();
this.p7_1 = 9;
this.o7_1 = 7;
continue $sm;
} else {
var tmp_8 = this.r7_1;
if (tmp_8 instanceof Error) {
this.d3i_1 = this.r7_1;
this.w3h_1.a3f_1.i1v(CancellationException_init_$Create$('Failed to send frame', this.d3i_1));
this.o7_1 = 4;
suspendResult = closeExceptionally(this.w3h_1.w3e_1, this.d3i_1, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
} else {
throw this.r7_1;
}
}
}
}
}
break;
case 4:
this.y3h_1 = suspendResult;
this.p7_1 = 9;
this.o7_1 = 7;
continue $sm;
case 5:
this.p7_1 = 9;
this.e3i_1 = this.r7_1;
this.w3h_1.a3f_1.j1v(null, 1, null);
this.o7_1 = 6;
suspendResult = close$default(this.w3h_1.w3e_1, null, this, 1, null);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 6:
throw this.e3i_1;
case 7:
this.w3h_1.a3f_1.j1v(null, 1, null);
this.o7_1 = 8;
suspendResult = close$default(this.w3h_1.w3e_1, null, this, 1, null);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 8:
return Unit_getInstance();
case 9:
throw this.r7_1;
}
} catch ($p) {
if (this.p7_1 === 9) {
throw $p;
} else {
this.o7_1 = this.p7_1;
this.r7_1 = $p;
}
}
while (true);
};
DefaultWebSocketSessionImpl$runOutgoingProcessor$slambda.prototype.i2n = function ($this$launch, completion) {
var i = new DefaultWebSocketSessionImpl$runOutgoingProcessor$slambda(this.w3h_1, completion);
i.x3h_1 = $this$launch;
return i;
};
DefaultWebSocketSessionImpl$runOutgoingProcessor$slambda.$metadata$ = classMeta('DefaultWebSocketSessionImpl$runOutgoingProcessor$slambda', undefined, undefined, undefined, [1], CoroutineImpl.prototype);
function DefaultWebSocketSessionImpl$runOutgoingProcessor$slambda_0(this$0, resultContinuation) {
var i = new DefaultWebSocketSessionImpl$runOutgoingProcessor$slambda(this$0, resultContinuation);
var l = function ($this$launch, $cont) {
return i.h2n($this$launch, $cont);
};
l.$arity = 1;
return l;
}
function DefaultWebSocketSessionImpl$runOrCancelPinger$slambda(this$0, resultContinuation) {
this.n3i_1 = this$0;
CoroutineImpl.call(this, resultContinuation);
}
DefaultWebSocketSessionImpl$runOrCancelPinger$slambda.prototype.p3i = function (it, $cont) {
var tmp = this.q3i(it, $cont);
tmp.q7_1 = Unit_getInstance();
tmp.r7_1 = null;
return tmp.v7();
};
DefaultWebSocketSessionImpl$runOrCancelPinger$slambda.prototype.w7 = function (p1, $cont) {
return this.p3i(p1 instanceof CloseReason ? p1 : THROW_CCE(), $cont);
};
DefaultWebSocketSessionImpl$runOrCancelPinger$slambda.prototype.v7 = function () {
var suspendResult = this.q7_1;
$sm: do
try {
var tmp = this.o7_1;
switch (tmp) {
case 0:
this.p7_1 = 2;
this.o7_1 = 1;
suspendResult = sendCloseSequence(this.n3i_1, this.o3i_1, IOException_init_$Create$('Ping timeout'), this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 1:
return Unit_getInstance();
case 2:
throw this.r7_1;
}
} catch ($p) {
if (this.p7_1 === 2) {
throw $p;
} else {
this.o7_1 = this.p7_1;
this.r7_1 = $p;
}
}
while (true);
};
DefaultWebSocketSessionImpl$runOrCancelPinger$slambda.prototype.q3i = function (it, completion) {
var i = new DefaultWebSocketSessionImpl$runOrCancelPinger$slambda(this.n3i_1, completion);
i.o3i_1 = it;
return i;
};
DefaultWebSocketSessionImpl$runOrCancelPinger$slambda.$metadata$ = classMeta('DefaultWebSocketSessionImpl$runOrCancelPinger$slambda', undefined, undefined, undefined, [1], CoroutineImpl.prototype);
function DefaultWebSocketSessionImpl$runOrCancelPinger$slambda_0(this$0, resultContinuation) {
var i = new DefaultWebSocketSessionImpl$runOrCancelPinger$slambda(this$0, resultContinuation);
var l = function (it, $cont) {
return i.p3i(it, $cont);
};
l.$arity = 1;
return l;
}
function $outgoingProcessorLoopCOROUTINE$0(_this__u8e3s4, resultContinuation) {
CoroutineImpl.call(this, resultContinuation);
this.d3e_1 = _this__u8e3s4;
}
$outgoingProcessorLoopCOROUTINE$0.prototype.v7 = function () {
var suspendResult = this.q7_1;
$sm: do
try {
var tmp = this.o7_1;
switch (tmp) {
case 0:
this.p7_1 = 7;
this.e3e_1 = this.d3e_1.a3f_1.j();
this.o7_1 = 1;
continue $sm;
case 1:
this.o7_1 = 2;
suspendResult = this.e3e_1.q28(this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 2:
if (!suspendResult) {
this.o7_1 = 6;
continue $sm;
}
this.f3e_1 = this.e3e_1.l();
this.g3e_1 = this.f3e_1;
var tmp_0 = this.g3e_1;
if (tmp_0 instanceof Close) {
this.o7_1 = 3;
var tmp_1 = readReason(this.f3e_1);
suspendResult = sendCloseSequence$default(this.d3e_1, tmp_1, null, this, 4, null);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
} else {
var tmp_2;
var tmp_3 = this.g3e_1;
if (tmp_3 instanceof Text) {
tmp_2 = true;
} else {
var tmp_4 = this.g3e_1;
tmp_2 = tmp_4 instanceof Binary;
}
if (tmp_2) {
this.h3e_1 = processOutgoingExtensions(this.d3e_1, this.f3e_1);
this.o7_1 = 4;
continue $sm;
} else {
this.h3e_1 = this.f3e_1;
this.o7_1 = 4;
continue $sm;
}
}
break;
case 3:
this.o7_1 = 6;
var tmp_5 = this;
continue $sm;
case 4:
this.i3e_1 = this.h3e_1;
this.o7_1 = 5;
suspendResult = this.d3e_1.w3e_1.s3d().l2a(this.i3e_1, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 5:
this.o7_1 = 1;
continue $sm;
case 6:
return Unit_getInstance();
case 7:
throw this.r7_1;
}
} catch ($p) {
if (this.p7_1 === 7) {
throw $p;
} else {
this.o7_1 = this.p7_1;
this.r7_1 = $p;
}
}
while (true);
};
$outgoingProcessorLoopCOROUTINE$0.$metadata$ = classMeta('$outgoingProcessorLoopCOROUTINE$0', undefined, undefined, undefined, undefined, CoroutineImpl.prototype);
function $sendCloseSequenceCOROUTINE$1(_this__u8e3s4, reason, exception, resultContinuation) {
CoroutineImpl.call(this, resultContinuation);
this.r3e_1 = _this__u8e3s4;
this.s3e_1 = reason;
this.t3e_1 = exception;
}
$sendCloseSequenceCOROUTINE$1.prototype.v7 = function () {
var suspendResult = this.q7_1;
$sm: do
try {
var tmp = this.o7_1;
switch (tmp) {
case 0:
this.p7_1 = 6;
if (!tryClose(this.r3e_1))
return Unit_getInstance();
this.r3e_1.c3f_1.l20();
;
var tmp_0 = this;
var tmp0_elvis_lhs = this.s3e_1;
tmp_0.u3e_1 = tmp0_elvis_lhs == null ? CloseReason_init_$Create$(Codes_NORMAL_getInstance(), '') : tmp0_elvis_lhs;
this.o7_1 = 1;
continue $sm;
case 1:
this.p7_1 = 5;
runOrCancelPinger(this.r3e_1);
if (!(this.u3e_1.l3d_1 === Codes_CLOSED_ABNORMALLY_getInstance().g3d_1)) {
this.o7_1 = 2;
suspendResult = this.r3e_1.w3e_1.s3d().l2a(Close_init_$Create$(this.u3e_1), this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
} else {
this.o7_1 = 3;
continue $sm;
}
break;
case 2:
this.o7_1 = 3;
continue $sm;
case 3:
this.v3e_1 = Unit_getInstance();
this.p7_1 = 6;
this.o7_1 = 4;
continue $sm;
case 4:
this.r3e_1.y3e_1.x1z(this.u3e_1);
;
if (!(this.t3e_1 == null)) {
this.r3e_1.a3f_1.a2a(this.t3e_1);
this.r3e_1.z3e_1.a2a(this.t3e_1);
}
return Unit_getInstance();
case 5:
this.p7_1 = 6;
var t = this.r7_1;
this.r3e_1.y3e_1.x1z(this.u3e_1);
;
if (!(this.t3e_1 == null)) {
this.r3e_1.a3f_1.a2a(this.t3e_1);
this.r3e_1.z3e_1.a2a(this.t3e_1);
}
throw t;
case 6:
throw this.r7_1;
}
} catch ($p) {
if (this.p7_1 === 6) {
throw $p;
} else {
this.o7_1 = this.p7_1;
this.r7_1 = $p;
}
}
while (true);
};
$sendCloseSequenceCOROUTINE$1.$metadata$ = classMeta('$sendCloseSequenceCOROUTINE$1', undefined, undefined, undefined, undefined, CoroutineImpl.prototype);
function $checkMaxFrameSizeCOROUTINE$2(_this__u8e3s4, packet, frame, resultContinuation) {
CoroutineImpl.call(this, resultContinuation);
this.s3f_1 = _this__u8e3s4;
this.t3f_1 = packet;
this.u3f_1 = frame;
}
$checkMaxFrameSizeCOROUTINE$2.prototype.v7 = function () {
var suspendResult = this.q7_1;
$sm: do
try {
var tmp = this.o7_1;
switch (tmp) {
case 0:
this.p7_1 = 3;
var tmp_0 = this;
var tmp_1 = this.u3f_1.h3h_1.length;
var tmp0_safe_receiver = this.t3f_1;
var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.i();
tmp_0.v3f_1 = tmp_1 + (tmp1_elvis_lhs == null ? 0 : tmp1_elvis_lhs) | 0;
if (toLong(this.v3f_1).x1(this.s3f_1.q3d()) > 0) {
var tmp2_safe_receiver = this.t3f_1;
if (tmp2_safe_receiver == null)
null;
else {
tmp2_safe_receiver.s17();
}
this.o7_1 = 2;
suspendResult = close(this.s3f_1, CloseReason_init_$Create$(Codes_TOO_BIG_getInstance(), 'Frame is too big: ' + this.v3f_1 + '. Max size is ' + toString(this.s3f_1.q3d())), this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
} else {
this.o7_1 = 1;
continue $sm;
}
break;
case 1:
return Unit_getInstance();
case 2:
throw new FrameTooBigException(toLong(this.v3f_1));
case 3:
throw this.r7_1;
}
} catch ($p) {
if (this.p7_1 === 3) {
throw $p;
} else {
this.o7_1 = this.p7_1;
this.r7_1 = $p;
}
}
while (true);
};
$checkMaxFrameSizeCOROUTINE$2.$metadata$ = classMeta('$checkMaxFrameSizeCOROUTINE$2', undefined, undefined, undefined, undefined, CoroutineImpl.prototype);
function DefaultWebSocketSessionImpl(raw, pingInterval, timeoutMillis) {
Companion_getInstance_0();
this.w3e_1 = raw;
this.x3e_1 = atomic$ref$1(null);
var tmp = this;
tmp.y3e_1 = CompletableDeferred$default(null, 1, null);
var tmp_0 = this;
tmp_0.z3e_1 = Channel$default(8, null, null, 6, null);
var tmp_1 = this;
tmp_1.a3f_1 = Channel$default(8, null, null, 6, null);
this.b3f_1 = atomic$boolean$1(false);
this.c3f_1 = Job(this.w3e_1.b1u().i8(Key_getInstance()));
var tmp_2 = this;
var tmp$ret$0;
// Inline function 'kotlin.collections.mutableListOf' call
tmp$ret$0 = ArrayList_init_$Create$();
tmp_2.d3f_1 = tmp$ret$0;
this.e3f_1 = atomic$boolean$1(false);
this.f3f_1 = this.w3e_1.b1u().p8(this.c3f_1).p8(new CoroutineName('ws-default'));
this.g3f_1 = pingInterval;
this.h3f_1 = timeoutMillis;
this.i3f_1 = this.y3e_1;
}
DefaultWebSocketSessionImpl.prototype.r3d = function () {
return this.z3e_1;
};
DefaultWebSocketSessionImpl.prototype.s3d = function () {
return this.a3f_1;
};
DefaultWebSocketSessionImpl.prototype.w3f = function () {
return this.d3f_1;
};
DefaultWebSocketSessionImpl.prototype.b1u = function () {
return this.f3f_1;
};
DefaultWebSocketSessionImpl.prototype.p3d = function (value) {
this.w3e_1.p3d(value);
};
DefaultWebSocketSessionImpl.prototype.q3d = function () {
return this.w3e_1.q3d();
};
DefaultWebSocketSessionImpl.prototype.o3d = function (negotiatedExtensions) {
if (!this.e3f_1.atomicfu$compareAndSet(false, true)) {
// Inline function 'kotlin.error' call
throw IllegalStateException_init_$Create$('WebSocket session is already started.');
}
this.d3f_1.o(negotiatedExtensions);
runOrCancelPinger(this);
runIncomingProcessor(this, ponger(this, this.s3d()));
runOutgoingProcessor(this);
};
DefaultWebSocketSessionImpl.prototype.u3d = function ($cont) {
return this.w3e_1.u3d($cont);
};
DefaultWebSocketSessionImpl.$metadata$ = classMeta('DefaultWebSocketSessionImpl', [DefaultWebSocketSession, WebSocketSession]);
var properties_initialized_DefaultWebSocketSession_kt_6cjlhc;
function init_properties_DefaultWebSocketSession_kt_vhpdcs() {
if (properties_initialized_DefaultWebSocketSession_kt_6cjlhc) {
} else {
properties_initialized_DefaultWebSocketSession_kt_6cjlhc = true;
IncomingProcessorCoroutineName = new CoroutineName('ws-incoming-processor');
OutgoingProcessorCoroutineName = new CoroutineName('ws-outgoing-processor');
NORMAL_CLOSE = CloseReason_init_$Create$(Codes_NORMAL_getInstance(), 'OK');
}
}
function readText(_this__u8e3s4) {
// Inline function 'kotlin.require' call
var tmp0_require = _this__u8e3s4.f3h_1;
// Inline function 'kotlin.contracts.contract' call
if (!tmp0_require) {
var tmp$ret$0;
// Inline function 'io.ktor.websocket.readText.<anonymous>' call
tmp$ret$0 = 'Text could be only extracted from non-fragmented frame';
var message = tmp$ret$0;
throw IllegalArgumentException_init_$Create$(toString(message));
}
var tmp = Charsets_getInstance().l2r_1.p2r();
var tmp$ret$1;
$l$block: {
// Inline function 'io.ktor.utils.io.core.buildPacket' call
// Inline function 'kotlin.contracts.contract' call
var builder = BytePacketBuilder_init_$Create$(null, 1, null);
try {
// Inline function 'io.ktor.websocket.readText.<anonymous>' call
writeFully$default(builder, _this__u8e3s4.h3h_1, 0, 0, 6, null);
tmp$ret$1 = builder.c4();
break $l$block;
} catch ($p) {
if ($p instanceof Error) {
builder.s17();
throw $p;
} else {
throw $p;
}
}
}
var tmp_0 = tmp$ret$1;
return decode$default(tmp, tmp_0, 0, 2, null);
}
function NonDisposableHandle() {
NonDisposableHandle_instance = this;
}
NonDisposableHandle.prototype.s1x = function () {
};
NonDisposableHandle.prototype.toString = function () {
return 'NonDisposableHandle';
};
NonDisposableHandle.$metadata$ = objectMeta('NonDisposableHandle', [DisposableHandle]);
var NonDisposableHandle_instance;
function NonDisposableHandle_getInstance() {
if (NonDisposableHandle_instance == null)
new NonDisposableHandle();
return NonDisposableHandle_instance;
}
function readReason(_this__u8e3s4) {
if (_this__u8e3s4.h3h_1.length < 2) {
return null;
}
var tmp$ret$0;
$l$block: {
// Inline function 'io.ktor.utils.io.core.buildPacket' call
// Inline function 'kotlin.contracts.contract' call
var builder = BytePacketBuilder_init_$Create$(null, 1, null);
try {
// Inline function 'io.ktor.websocket.readReason.<anonymous>' call
writeFully$default(builder, _this__u8e3s4.h3h_1, 0, 0, 6, null);
tmp$ret$0 = builder.c4();
break $l$block;
} catch ($p) {
if ($p instanceof Error) {
builder.s17();
throw $p;
} else {
throw $p;
}
}
}
var packet = tmp$ret$0;
var code = readShort(packet);
var message = packet.c2r(0, 0, 3, null);
return new CloseReason(code, message);
}
function FrameTooBigException(frameSize) {
Exception_init_$Init$(this);
this.r3i_1 = frameSize;
captureStack(this, FrameTooBigException);
}
FrameTooBigException.prototype.j2 = function () {
return 'Frame is too big: ' + toString(this.r3i_1);
};
FrameTooBigException.$metadata$ = classMeta('FrameTooBigException', [CopyableThrowable], undefined, undefined, undefined, Exception.prototype);
Object.defineProperty(FrameTooBigException.prototype, 'message', {
configurable: true,
get: function () {
return this.j2();
}
});
var FrameType_TEXT_instance;
var FrameType_BINARY_instance;
var FrameType_CLOSE_instance;
var FrameType_PING_instance;
var FrameType_PONG_instance;
function Companion_1() {
Companion_instance_1 = this;
var tmp = this;
var tmp$ret$1;
$l$block_0: {
// Inline function 'kotlin.collections.maxByOrNull' call
var tmp0_maxByOrNull = values_0();
var tmp$ret$0;
// Inline function 'kotlin.collections.isEmpty' call
tmp$ret$0 = tmp0_maxByOrNull.length === 0;
if (tmp$ret$0) {
tmp$ret$1 = null;
break $l$block_0;
}
var maxElem = tmp0_maxByOrNull[0];
var lastIndex = get_lastIndex(tmp0_maxByOrNull);
if (lastIndex === 0) {
tmp$ret$1 = maxElem;
break $l$block_0;
}
var tmp$ret$2;
// Inline function 'io.ktor.websocket.Companion.maxOpcode.<anonymous>' call
var tmp1__anonymous__uwfjfc = maxElem;
tmp$ret$2 = tmp1__anonymous__uwfjfc.v3i_1;
var maxValue = tmp$ret$2;
var inductionVariable = 1;
if (inductionVariable <= lastIndex)
do {
var i = inductionVariable;
inductionVariable = inductionVariable + 1 | 0;
var e = tmp0_maxByOrNull[i];
var tmp$ret$3;
// Inline function 'io.ktor.websocket.Companion.maxOpcode.<anonymous>' call
tmp$ret$3 = e.v3i_1;
var v = tmp$ret$3;
if (compareTo(maxValue, v) < 0) {
maxElem = e;
maxValue = v;
}
}
while (!(i === lastIndex));
tmp$ret$1 = maxElem;
}
tmp.w3i_1 = ensureNotNull(tmp$ret$1).v3i_1;
var tmp_0 = this;
var tmp_1 = 0;
var tmp_2 = this.w3i_1 + 1 | 0;
var tmp$ret$4;
// Inline function 'kotlin.arrayOfNulls' call
tmp$ret$4 = fillArrayVal(Array(tmp_2), null);
var tmp_3 = tmp$ret$4;
while (tmp_1 < tmp_2) {
var tmp_4 = tmp_1;
var tmp$ret$7;
// Inline function 'io.ktor.websocket.Companion.byOpcodeArray.<anonymous>' call
var tmp$ret$6;
$l$block_2: {
// Inline function 'kotlin.collections.singleOrNull' call
var tmp0_singleOrNull = values_0();
var single = null;
var found = false;
var indexedObject = tmp0_singleOrNull;
var inductionVariable_0 = 0;
var last = indexedObject.length;
while (inductionVariable_0 < last) {
var element = indexedObject[inductionVariable_0];
inductionVariable_0 = inductionVariable_0 + 1 | 0;
var tmp$ret$5;
// Inline function 'io.ktor.websocket.Companion.byOpcodeArray.<anonymous>' call
tmp$ret$5 = element.v3i_1 === tmp_4;
if (tmp$ret$5) {
if (found) {
tmp$ret$6 = null;
break $l$block_2;
}
single = element;
found = true;
}
}
if (!found) {
tmp$ret$6 = null;
break $l$block_2;
}
tmp$ret$6 = single;
}
tmp$ret$7 = tmp$ret$6;
tmp_3[tmp_4] = tmp$ret$7;
tmp_1 = tmp_1 + 1 | 0;
}
tmp_0.x3i_1 = tmp_3;
}
Companion_1.$metadata$ = objectMeta('Companion');
var Companion_instance_1;
function Companion_getInstance_1() {
FrameType_initEntries();
if (Companion_instance_1 == null)
new Companion_1();
return Companion_instance_1;
}
function values_0() {
return [FrameType_TEXT_getInstance(), FrameType_BINARY_getInstance(), FrameType_CLOSE_getInstance(), FrameType_PING_getInstance(), FrameType_PONG_getInstance()];
}
var FrameType_entriesInitialized;
function FrameType_initEntries() {
if (FrameType_entriesInitialized)
return Unit_getInstance();
FrameType_entriesInitialized = true;
FrameType_TEXT_instance = new FrameType('TEXT', 0, false, 1);
FrameType_BINARY_instance = new FrameType('BINARY', 1, false, 2);
FrameType_CLOSE_instance = new FrameType('CLOSE', 2, true, 8);
FrameType_PING_instance = new FrameType('PING', 3, true, 9);
FrameType_PONG_instance = new FrameType('PONG', 4, true, 10);
Companion_getInstance_1();
}
function FrameType(name, ordinal, controlFrame, opcode) {
Enum.call(this, name, ordinal);
this.u3i_1 = controlFrame;
this.v3i_1 = opcode;
}
FrameType.prototype.y3i = function () {
return this.v3i_1;
};
FrameType.$metadata$ = classMeta('FrameType', undefined, undefined, undefined, undefined, Enum.prototype);
function FrameType_TEXT_getInstance() {
FrameType_initEntries();
return FrameType_TEXT_instance;
}
function FrameType_BINARY_getInstance() {
FrameType_initEntries();
return FrameType_BINARY_instance;
}
function FrameType_CLOSE_getInstance() {
FrameType_initEntries();
return FrameType_CLOSE_instance;
}
function FrameType_PING_getInstance() {
FrameType_initEntries();
return FrameType_PING_instance;
}
function FrameType_PONG_getInstance() {
FrameType_initEntries();
return FrameType_PONG_instance;
}
function get_PongerCoroutineName() {
init_properties_PingPong_kt_a6xpsg();
return PongerCoroutineName;
}
var PongerCoroutineName;
function get_PingerCoroutineName() {
init_properties_PingPong_kt_a6xpsg();
return PingerCoroutineName;
}
var PingerCoroutineName;
function ponger(_this__u8e3s4, outgoing) {
init_properties_PingPong_kt_a6xpsg();
var channel = Channel$default(5, null, null, 6, null);
var tmp = get_PongerCoroutineName();
launch$default(_this__u8e3s4, tmp, null, ponger$slambda_0(channel, outgoing, null), 2, null);
return channel;
}
function pinger(_this__u8e3s4, outgoing, periodMillis, timeoutMillis, onTimeout) {
init_properties_PingPong_kt_a6xpsg();
var actorJob = Job$default(null, 1, null);
Factory_getInstance();
var channel = Channel$default(2147483647, null, null, 6, null);
var tmp = actorJob.p8(get_PingerCoroutineName());
launch$default(_this__u8e3s4, tmp, null, pinger$slambda_0(periodMillis, timeoutMillis, onTimeout, channel, outgoing, null), 2, null);
var tmp_0 = ensureNotNull(_this__u8e3s4.b1u().i8(Key_getInstance()));
tmp_0.c1v(pinger$lambda(actorJob));
return channel;
}
function ponger$slambda($channel, $outgoing, resultContinuation) {
this.h3j_1 = $channel;
this.i3j_1 = $outgoing;
CoroutineImpl.call(this, resultContinuation);
}
ponger$slambda.prototype.h2n = function ($this$launch, $cont) {
var tmp = this.i2n($this$launch, $cont);
tmp.q7_1 = Unit_getInstance();
tmp.r7_1 = null;
return tmp.v7();
};
ponger$slambda.prototype.w7 = function (p1, $cont) {
return this.h2n((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $cont);
};
ponger$slambda.prototype.v7 = function () {
var suspendResult = this.q7_1;
$sm: do
try {
var tmp = this.o7_1;
switch (tmp) {
case 0:
this.p7_1 = 14;
this.p7_1 = 13;
this.o7_1 = 1;
continue $sm;
case 1:
this.l3j_1 = null;
this.o7_1 = 2;
continue $sm;
case 2:
this.o7_1 = 3;
continue $sm;
case 3:
this.p7_1 = 10;
this.p7_1 = 9;
this.n3j_1 = this.h3j_1.j();
this.o7_1 = 4;
continue $sm;
case 4:
this.o7_1 = 5;
suspendResult = this.n3j_1.q28(this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 5:
if (!suspendResult) {
this.o7_1 = 7;
continue $sm;
}
this.o3j_1 = this.n3j_1.l();
this.o7_1 = 6;
suspendResult = this.i3j_1.l2a(Pong_init_$Create$(this.o3j_1.h3h_1, null, 2, null), this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 6:
this.o7_1 = 4;
continue $sm;
case 7:
this.m3j_1 = Unit_getInstance();
this.o7_1 = 8;
var tmp_0 = this;
continue $sm;
case 8:
var tmp_1 = this;
cancelConsumed(this.h3j_1, this.l3j_1);
tmp_1.k3j_1 = Unit_getInstance();
this.o7_1 = 12;
continue $sm;
case 9:
this.p7_1 = 10;
var tmp_2 = this.r7_1;
if (tmp_2 instanceof Error) {
var e = this.r7_1;
var tmp_3 = this;
this.l3j_1 = e;
throw e;
} else {
throw this.r7_1;
}
break;
case 10:
this.p7_1 = 13;
var t = this.r7_1;
cancelConsumed(this.h3j_1, this.l3j_1);
;
throw t;
case 11:
cancelConsumed(this.h3j_1, this.l3j_1);
;
if (false) {
this.o7_1 = 1;
continue $sm;
}
this.o7_1 = 12;
continue $sm;
case 12:
this.p7_1 = 14;
this.o7_1 = 15;
continue $sm;
case 13:
this.p7_1 = 14;
var tmp_4 = this.r7_1;
if (tmp_4 instanceof ClosedSendChannelException) {
var _ = this.r7_1;
this.o7_1 = 15;
continue $sm;
} else {
throw this.r7_1;
}
break;
case 14:
throw this.r7_1;
case 15:
this.p7_1 = 14;
return Unit_getInstance();
}
} catch ($p) {
if (this.p7_1 === 14) {
throw $p;
} else {
this.o7_1 = this.p7_1;
this.r7_1 = $p;
}
}
while (true);
};
ponger$slambda.prototype.i2n = function ($this$launch, completion) {
var i = new ponger$slambda(this.h3j_1, this.i3j_1, completion);
i.j3j_1 = $this$launch;
return i;
};
ponger$slambda.$metadata$ = classMeta('ponger$slambda', undefined, undefined, undefined, [1], CoroutineImpl.prototype);
function ponger$slambda_0($channel, $outgoing, resultContinuation) {
var i = new ponger$slambda($channel, $outgoing, resultContinuation);
var l = function ($this$launch, $cont) {
return i.h2n($this$launch, $cont);
};
l.$arity = 1;
return l;
}
function pinger$slambda$slambda($channel, resultContinuation) {
this.x3j_1 = $channel;
CoroutineImpl.call(this, resultContinuation);
}
pinger$slambda$slambda.prototype.h2n = function ($this$withTimeoutOrNull, $cont) {
var tmp = this.i2n($this$withTimeoutOrNull, $cont);
tmp.q7_1 = Unit_getInstance();
tmp.r7_1 = null;
return tmp.v7();
};
pinger$slambda$slambda.prototype.w7 = function (p1, $cont) {
return this.h2n((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $cont);
};
pinger$slambda$slambda.prototype.v7 = function () {
var suspendResult = this.q7_1;
$sm: do
try {
var tmp = this.o7_1;
switch (tmp) {
case 0:
this.p7_1 = 3;
this.o7_1 = 1;
continue $sm;
case 1:
if (false) {
this.o7_1 = 4;
continue $sm;
}
this.o7_1 = 2;
suspendResult = this.x3j_1.y29(this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 2:
;
this.o7_1 = 1;
continue $sm;
case 3:
throw this.r7_1;
case 4:
return Unit_getInstance();
}
} catch ($p) {
if (this.p7_1 === 3) {
throw $p;
} else {
this.o7_1 = this.p7_1;
this.r7_1 = $p;
}
}
while (true);
};
pinger$slambda$slambda.prototype.i2n = function ($this$withTimeoutOrNull, completion) {
var i = new pinger$slambda$slambda(this.x3j_1, completion);
i.y3j_1 = $this$withTimeoutOrNull;
return i;
};
pinger$slambda$slambda.$metadata$ = classMeta('pinger$slambda$slambda', undefined, undefined, undefined, [1], CoroutineImpl.prototype);
function pinger$slambda$slambda_0($channel, resultContinuation) {
var i = new pinger$slambda$slambda($channel, resultContinuation);
var l = function ($this$withTimeoutOrNull, $cont) {
return i.h2n($this$withTimeoutOrNull, $cont);
};
l.$arity = 1;
return l;
}
function pinger$slambda$slambda_1($outgoing, $pingMessage, $channel, resultContinuation) {
this.h3k_1 = $outgoing;
this.i3k_1 = $pingMessage;
this.j3k_1 = $channel;
CoroutineImpl.call(this, resultContinuation);
}
pinger$slambda$slambda_1.prototype.h2n = function ($this$withTimeoutOrNull, $cont) {
var tmp = this.i2n($this$withTimeoutOrNull, $cont);
tmp.q7_1 = Unit_getInstance();
tmp.r7_1 = null;
return tmp.v7();
};
pinger$slambda$slambda_1.prototype.w7 = function (p1, $cont) {
return this.h2n((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $cont);
};
pinger$slambda$slambda_1.prototype.v7 = function () {
var suspendResult = this.q7_1;
$sm: do
try {
var tmp = this.o7_1;
switch (tmp) {
case 0:
this.p7_1 = 6;
this.o7_1 = 1;
l$ret$1: do {
var tmp0_toByteArray = Charsets_getInstance().m2r_1;
if (tmp0_toByteArray.equals(Charsets_getInstance().l2r_1)) {
this.l3k_1 = encodeToByteArray(this.i3k_1);
break l$ret$1;
}
this.l3k_1 = encodeToByteArray_0(tmp0_toByteArray.o2r(), this.i3k_1, 0, this.i3k_1.length);
}
while (false);
suspendResult = this.h3k_1.l2a(new Ping(this.l3k_1), this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 1:
this.o7_1 = 2;
continue $sm;
case 2:
if (false) {
this.o7_1 = 5;
continue $sm;
}
this.o7_1 = 3;
suspendResult = this.j3k_1.y29(this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 3:
var msg = suspendResult;
if (String$default(msg.h3h_1, 0, 0, Charsets_getInstance().m2r_1, 6, null) === this.i3k_1) {
this.o7_1 = 5;
continue $sm;
} else {
this.o7_1 = 4;
continue $sm;
}
break;
case 4:
this.o7_1 = 2;
continue $sm;
case 5:
return Unit_getInstance();
case 6:
throw this.r7_1;
}
} catch ($p) {
if (this.p7_1 === 6) {
throw $p;
} else {
this.o7_1 = this.p7_1;
this.r7_1 = $p;
}
}
while (true);
};
pinger$slambda$slambda_1.prototype.i2n = function ($this$withTimeoutOrNull, completion) {
var i = new pinger$slambda$slambda_1(this.h3k_1, this.i3k_1, this.j3k_1, completion);
i.k3k_1 = $this$withTimeoutOrNull;
return i;
};
pinger$slambda$slambda_1.$metadata$ = classMeta('pinger$slambda$slambda', undefined, undefined, undefined, [1], CoroutineImpl.prototype);
function pinger$slambda$slambda_2($outgoing, $pingMessage, $channel, resultContinuation) {
var i = new pinger$slambda$slambda_1($outgoing, $pingMessage, $channel, resultContinuation);
var l = function ($this$withTimeoutOrNull, $cont) {
return i.h2n($this$withTimeoutOrNull, $cont);
};
l.$arity = 1;
return l;
}
function pinger$slambda($periodMillis, $timeoutMillis, $onTimeout, $channel, $outgoing, resultContinuation) {
this.u3k_1 = $periodMillis;
this.v3k_1 = $timeoutMillis;
this.w3k_1 = $onTimeout;
this.x3k_1 = $channel;
this.y3k_1 = $outgoing;
CoroutineImpl.call(this, resultContinuation);
}
pinger$slambda.prototype.h2n = function ($this$launch, $cont) {
var tmp = this.i2n($this$launch, $cont);
tmp.q7_1 = Unit_getInstance();
tmp.r7_1 = null;
return tmp.v7();
};
pinger$slambda.prototype.w7 = function (p1, $cont) {
return this.h2n((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $cont);
};
pinger$slambda.prototype.v7 = function () {
var suspendResult = this.q7_1;
$sm: do
try {
var tmp = this.o7_1;
switch (tmp) {
case 0:
this.p7_1 = 8;
this.a3l_1 = Random(getTimeMillis());
this.b3l_1 = new Int8Array(32);
this.p7_1 = 7;
this.o7_1 = 1;
continue $sm;
case 1:
if (false) {
this.o7_1 = 6;
continue $sm;
}
this.o7_1 = 2;
suspendResult = withTimeoutOrNull(this.u3k_1, pinger$slambda$slambda_0(this.x3k_1, null), this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 2:
;
this.a3l_1.l9(this.b3l_1);
;
this.c3l_1 = '[ping ' + hex(this.b3l_1) + ' ping]';
this.o7_1 = 3;
suspendResult = withTimeoutOrNull(this.v3k_1, pinger$slambda$slambda_2(this.y3k_1, this.c3l_1, this.x3k_1, null), this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 3:
this.d3l_1 = suspendResult;
if (this.d3l_1 == null) {
this.o7_1 = 5;
suspendResult = this.w3k_1(CloseReason_init_$Create$(Codes_INTERNAL_ERROR_getInstance(), 'Ping timeout'), this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
} else {
this.o7_1 = 4;
continue $sm;
}
break;
case 4:
this.o7_1 = 1;
continue $sm;
case 5:
this.o7_1 = 6;
continue $sm;
case 6:
this.p7_1 = 8;
this.o7_1 = 9;
continue $sm;
case 7:
this.p7_1 = 8;
var tmp_0 = this.r7_1;
if (tmp_0 instanceof CancellationException) {
var ignore = this.r7_1;
this.o7_1 = 9;
continue $sm;
} else {
var tmp_1 = this.r7_1;
if (tmp_1 instanceof ClosedReceiveChannelException) {
var ignore_0 = this.r7_1;
this.o7_1 = 9;
continue $sm;
} else {
var tmp_2 = this.r7_1;
if (tmp_2 instanceof ClosedSendChannelException) {
var ignore_1 = this.r7_1;
this.o7_1 = 9;
continue $sm;
} else {
throw this.r7_1;
}
}
}
break;
case 8:
throw this.r7_1;
case 9:
this.p7_1 = 8;
return Unit_getInstance();
}
} catch ($p) {
if (this.p7_1 === 8) {
throw $p;
} else {
this.o7_1 = this.p7_1;
this.r7_1 = $p;
}
}
while (true);
};
pinger$slambda.prototype.i2n = function ($this$launch, completion) {
var i = new pinger$slambda(this.u3k_1, this.v3k_1, this.w3k_1, this.x3k_1, this.y3k_1, completion);
i.z3k_1 = $this$launch;
return i;
};
pinger$slambda.$metadata$ = classMeta('pinger$slambda', undefined, undefined, undefined, [1], CoroutineImpl.prototype);
function pinger$slambda_0($periodMillis, $timeoutMillis, $onTimeout, $channel, $outgoing, resultContinuation) {
var i = new pinger$slambda($periodMillis, $timeoutMillis, $onTimeout, $channel, $outgoing, resultContinuation);
var l = function ($this$launch, $cont) {
return i.h2n($this$launch, $cont);
};
l.$arity = 1;
return l;
}
function pinger$lambda($actorJob) {
return function (it) {
$actorJob.j1v(null, 1, null);
return Unit_getInstance();
};
}
var properties_initialized_PingPong_kt_fbfhmc;
function init_properties_PingPong_kt_a6xpsg() {
if (properties_initialized_PingPong_kt_fbfhmc) {
} else {
properties_initialized_PingPong_kt_fbfhmc = true;
PongerCoroutineName = new CoroutineName('ws-ponger');
PingerCoroutineName = new CoroutineName('ws-pinger');
}
}
function WebSocketExtensionsConfig() {
var tmp = this;
var tmp$ret$0;
// Inline function 'kotlin.collections.mutableListOf' call
tmp$ret$0 = ArrayList_init_$Create$();
tmp.e3l_1 = tmp$ret$0;
var tmp_0 = this;
var tmp$ret$3;
// Inline function 'kotlin.arrayOf' call
var tmp$ret$2;
// Inline function 'kotlin.js.unsafeCast' call
var tmp$ret$1;
// Inline function 'kotlin.js.asDynamic' call
tmp$ret$1 = [false, false, false];
tmp$ret$2 = tmp$ret$1;
tmp$ret$3 = tmp$ret$2;
tmp_0.f3l_1 = tmp$ret$3;
}
WebSocketExtensionsConfig.prototype.c4 = function () {
var tmp$ret$2;
// Inline function 'kotlin.collections.map' call
var tmp0_map = this.e3l_1;
var tmp$ret$1;
// Inline function 'kotlin.collections.mapTo' call
var tmp0_mapTo = ArrayList_init_$Create$_0(collectionSizeOrDefault(tmp0_map, 10));
var tmp0_iterator = tmp0_map.j();
while (tmp0_iterator.k()) {
var item = tmp0_iterator.l();
var tmp$ret$0;
// Inline function 'io.ktor.websocket.WebSocketExtensionsConfig.build.<anonymous>' call
tmp$ret$0 = item();
tmp0_mapTo.c(tmp$ret$0);
}
tmp$ret$1 = tmp0_mapTo;
tmp$ret$2 = tmp$ret$1;
return tmp$ret$2;
};
WebSocketExtensionsConfig.$metadata$ = classMeta('WebSocketExtensionsConfig');
function parametersToString($this) {
var tmp;
if ($this.h3l_1.p()) {
tmp = '';
} else {
tmp = ', ' + joinToString$default($this.h3l_1, ',', null, null, 0, null, null, 62, null);
}
return tmp;
}
function WebSocketExtensionHeader(name, parameters) {
this.g3l_1 = name;
this.h3l_1 = parameters;
}
WebSocketExtensionHeader.prototype.toString = function () {
return this.g3l_1 + ' ' + parametersToString(this);
};
WebSocketExtensionHeader.$metadata$ = classMeta('WebSocketExtensionHeader');
function parseWebSocketExtensions(value) {
var tmp$ret$7;
// Inline function 'kotlin.collections.map' call
var tmp0_map = split$default(value, [','], false, 0, 6, null);
var tmp$ret$6;
// Inline function 'kotlin.collections.mapTo' call
var tmp0_mapTo = ArrayList_init_$Create$_0(collectionSizeOrDefault(tmp0_map, 10));
var tmp0_iterator = tmp0_map.j();
while (tmp0_iterator.k()) {
var item = tmp0_iterator.l();
var tmp$ret$5;
// Inline function 'io.ktor.websocket.parseWebSocketExtensions.<anonymous>' call
var extension = split$default(item, [';'], false, 0, 6, null);
var tmp$ret$0;
// Inline function 'kotlin.text.trim' call
var tmp0_trim = first(extension);
tmp$ret$0 = toString(trim(isCharSequence(tmp0_trim) ? tmp0_trim : THROW_CCE()));
var name = tmp$ret$0;
var tmp$ret$4;
// Inline function 'kotlin.collections.map' call
var tmp1_map = drop(extension, 1);
var tmp$ret$3;
// Inline function 'kotlin.collections.mapTo' call
var tmp0_mapTo_0 = ArrayList_init_$Create$_0(collectionSizeOrDefault(tmp1_map, 10));
var tmp0_iterator_0 = tmp1_map.j();
while (tmp0_iterator_0.k()) {
var item_0 = tmp0_iterator_0.l();
var tmp$ret$2;
// Inline function 'io.ktor.websocket.parseWebSocketExtensions.<anonymous>.<anonymous>' call
var tmp$ret$1;
// Inline function 'kotlin.text.trim' call
tmp$ret$1 = toString(trim(isCharSequence(item_0) ? item_0 : THROW_CCE()));
tmp$ret$2 = tmp$ret$1;
tmp0_mapTo_0.c(tmp$ret$2);
}
tmp$ret$3 = tmp0_mapTo_0;
tmp$ret$4 = tmp$ret$3;
var parameters = tmp$ret$4;
tmp$ret$5 = new WebSocketExtensionHeader(name, parameters);
tmp0_mapTo.c(tmp$ret$5);
}
tmp$ret$6 = tmp0_mapTo;
tmp$ret$7 = tmp$ret$6;
return tmp$ret$7;
}
function WebSocketSession() {
}
WebSocketSession.$metadata$ = interfaceMeta('WebSocketSession', [CoroutineScope]);
function send_0(_this__u8e3s4, content, $cont) {
return _this__u8e3s4.t3d(Text_init_$Create$(content), $cont);
}
function close(_this__u8e3s4, reason, $cont) {
var tmp = new $closeCOROUTINE$3(_this__u8e3s4, reason, $cont);
tmp.q7_1 = Unit_getInstance();
tmp.r7_1 = null;
return tmp.v7();
}
function close$default(_this__u8e3s4, reason, $cont, $mask0, $handler) {
if (!(($mask0 & 1) === 0))
reason = CloseReason_init_$Create$(Codes_NORMAL_getInstance(), '');
return close(_this__u8e3s4, reason, $cont);
}
function closeExceptionally(_this__u8e3s4, cause, $cont) {
var tmp0_subject = cause;
var tmp;
if (tmp0_subject instanceof CancellationException) {
tmp = CloseReason_init_$Create$(Codes_NORMAL_getInstance(), '');
} else {
tmp = CloseReason_init_$Create$(Codes_INTERNAL_ERROR_getInstance(), cause.toString());
}
var reason = tmp;
return close(_this__u8e3s4, reason, $cont);
}
function $closeCOROUTINE$3(_this__u8e3s4, reason, resultContinuation) {
CoroutineImpl.call(this, resultContinuation);
this.q3l_1 = _this__u8e3s4;
this.r3l_1 = reason;
}
$closeCOROUTINE$3.prototype.v7 = function () {
var suspendResult = this.q7_1;
$sm: do
try {
var tmp = this.o7_1;
switch (tmp) {
case 0:
this.p7_1 = 4;
this.p7_1 = 3;
this.o7_1 = 1;
suspendResult = this.q3l_1.t3d(Close_init_$Create$(this.r3l_1), this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 1:
this.o7_1 = 2;
suspendResult = this.q3l_1.u3d(this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 2:
this.p7_1 = 4;
this.o7_1 = 5;
continue $sm;
case 3:
this.p7_1 = 4;
var tmp_0 = this.r7_1;
if (tmp_0 instanceof Error) {
var _ = this.r7_1;
this.o7_1 = 5;
continue $sm;
} else {
throw this.r7_1;
}
break;
case 4:
throw this.r7_1;
case 5:
this.p7_1 = 4;
return Unit_getInstance();
}
} catch ($p) {
if (this.p7_1 === 4) {
throw $p;
} else {
this.o7_1 = this.p7_1;
this.r7_1 = $p;
}
}
while (true);
};
$closeCOROUTINE$3.$metadata$ = classMeta('$closeCOROUTINE$3', undefined, undefined, undefined, undefined, CoroutineImpl.prototype);
function Binary_init_$Init$(fin, data, $this) {
Binary.call($this, fin, data, false, false, false);
return $this;
}
function Binary_init_$Create$(fin, data) {
return Binary_init_$Init$(fin, data, Object.create(Binary.prototype));
}
function Text_init_$Init$(fin, data, $this) {
Text.call($this, fin, data, false, false, false);
return $this;
}
function Text_init_$Init$_0(text, $this) {
var tmp$ret$0;
$l$block: {
// Inline function 'io.ktor.utils.io.core.toByteArray' call
var tmp0_toByteArray = Charsets_getInstance().l2r_1;
if (tmp0_toByteArray.equals(Charsets_getInstance().l2r_1)) {
tmp$ret$0 = encodeToByteArray(text);
break $l$block;
}
tmp$ret$0 = encodeToByteArray_0(tmp0_toByteArray.o2r(), text, 0, text.length);
}
Text_init_$Init$(true, tmp$ret$0, $this);
return $this;
}
function Text_init_$Create$(text) {
return Text_init_$Init$_0(text, Object.create(Text.prototype));
}
function Close_init_$Init$(reason, $this) {
var tmp$ret$0;
$l$block: {
// Inline function 'io.ktor.utils.io.core.buildPacket' call
// Inline function 'kotlin.contracts.contract' call
var builder = BytePacketBuilder_init_$Create$(null, 1, null);
try {
// Inline function 'io.ktor.websocket.Close.<init>.<anonymous>' call
writeShort(builder, reason.l3d_1);
writeText$default(builder, reason.m3d_1, 0, 0, null, 14, null);
tmp$ret$0 = builder.c4();
break $l$block;
} catch ($p) {
if ($p instanceof Error) {
builder.s17();
throw $p;
} else {
throw $p;
}
}
}
Close_init_$Init$_0(tmp$ret$0, $this);
return $this;
}
function Close_init_$Create$(reason) {
return Close_init_$Init$(reason, Object.create(Close.prototype));
}
function Close_init_$Init$_0(packet, $this) {
Close.call($this, readBytes$default(packet, 0, 1, null));
return $this;
}
function Pong_init_$Init$(data, disposableHandle, $mask0, $marker, $this) {
if (!(($mask0 & 2) === 0))
disposableHandle = NonDisposableHandle_getInstance();
Pong.call($this, data, disposableHandle);
return $this;
}
function Pong_init_$Create$(data, disposableHandle, $mask0, $marker) {
return Pong_init_$Init$(data, disposableHandle, $mask0, $marker, Object.create(Pong.prototype));
}
function Binary(fin, data, rsv1, rsv2, rsv3) {
Frame.call(this, fin, FrameType_BINARY_getInstance(), data, NonDisposableHandle_getInstance(), rsv1, rsv2, rsv3);
}
Binary.$metadata$ = classMeta('Binary', undefined, undefined, undefined, undefined, Frame.prototype);
function Text(fin, data, rsv1, rsv2, rsv3) {
Frame.call(this, fin, FrameType_TEXT_getInstance(), data, NonDisposableHandle_getInstance(), rsv1, rsv2, rsv3);
}
Text.$metadata$ = classMeta('Text', undefined, undefined, undefined, undefined, Frame.prototype);
function Close(data) {
Frame.call(this, true, FrameType_CLOSE_getInstance(), data, NonDisposableHandle_getInstance(), false, false, false);
}
Close.$metadata$ = classMeta('Close', undefined, undefined, undefined, undefined, Frame.prototype);
function Ping(data) {
Frame.call(this, true, FrameType_PING_getInstance(), data, NonDisposableHandle_getInstance(), false, false, false);
}
Ping.$metadata$ = classMeta('Ping', undefined, undefined, undefined, undefined, Frame.prototype);
function Pong(data, disposableHandle) {
Frame.call(this, true, FrameType_PONG_getInstance(), data, disposableHandle, false, false, false);
}
Pong.$metadata$ = classMeta('Pong', undefined, undefined, undefined, undefined, Frame.prototype);
function Companion_2() {
Companion_instance_2 = this;
this.m3h_1 = new Int8Array(0);
}
Companion_2.prototype.n3h = function (fin, frameType, data, rsv1, rsv2, rsv3) {
var tmp0_subject = frameType;
var tmp0 = tmp0_subject.q2_1;
var tmp;
switch (tmp0) {
case 1:
tmp = new Binary(fin, data, rsv1, rsv2, rsv3);
break;
case 0:
tmp = new Text(fin, data, rsv1, rsv2, rsv3);
break;
case 2:
tmp = new Close(data);
break;
case 3:
tmp = new Ping(data);
break;
case 4:
tmp = new Pong(data, NonDisposableHandle_getInstance());
break;
default:
noWhenBranchMatchedException();
break;
}
return tmp;
};
Companion_2.$metadata$ = objectMeta('Companion');
var Companion_instance_2;
function Companion_getInstance_2() {
if (Companion_instance_2 == null)
new Companion_2();
return Companion_instance_2;
}
function Frame(fin, frameType, data, disposableHandle, rsv1, rsv2, rsv3) {
Companion_getInstance_2();
this.f3h_1 = fin;
this.g3h_1 = frameType;
this.h3h_1 = data;
this.i3h_1 = disposableHandle;
this.j3h_1 = rsv1;
this.k3h_1 = rsv2;
this.l3h_1 = rsv3;
}
Frame.prototype.s3l = function () {
return this.h3h_1;
};
Frame.prototype.toString = function () {
return 'Frame ' + this.g3h_1 + ' (fin=' + this.f3h_1 + ', buffer len = ' + this.h3h_1.length + ')';
};
Frame.$metadata$ = classMeta('Frame');
//region block: post-declaration
DefaultWebSocketSessionImpl.prototype.t3d = send;
//endregion
//region block: exports
_.$_$ = _.$_$ || {};
_.$_$.a = Codes_CLOSED_ABNORMALLY_getInstance;
_.$_$.b = Codes_INTERNAL_ERROR_getInstance;
_.$_$.c = send;
_.$_$.d = send_0;
_.$_$.e = close$default;
_.$_$.f = Binary_init_$Create$;
_.$_$.g = Close_init_$Create$;
_.$_$.h = Text_init_$Create$;
_.$_$.i = Companion_getInstance;
_.$_$.j = CloseReason;
_.$_$.k = DefaultWebSocketSession_0;
_.$_$.l = DefaultWebSocketSession;
_.$_$.m = Text;
_.$_$.n = WebSocketExtensionsConfig;
_.$_$.o = WebSocketSession;
_.$_$.p = parseWebSocketExtensions;
_.$_$.q = readText;
//endregion
return _;
}));
//# sourceMappingURL=ktor-ktor-websockets-js-ir.js.map