import {
  toString1pkumu07cwy4m as toString,
  IllegalArgumentException_init_$Create$sfel9vrfa7w2 as IllegalArgumentException_init_$Create$,
  toByte4i43936u611k as toByte,
  THROW_IAE23kobfj9wdoxr as THROW_IAE,
  getProgressionLastElement2w30kdy2w5nkt as getProgressionLastElement,
  copyOfRange3alro60z4hhf8 as copyOfRange,
  arrayCopytctsywo3h7gj as arrayCopy,
  Unit_instance14hm69wy3kr8u as Unit_instance,
  fillArrayVali8eppxapiek4 as fillArrayVal,
  protoOf180f3jzyo7rfj as protoOf,
  initMetadataForObject1cxne3s9w65el as initMetadataForObject,
  _UInt___get_data__impl__f0vqqw1wfqgh301wggv as _UInt___get_data__impl__f0vqqw,
  ArrayList_init_$Create$3m1kyiqequwm5 as ArrayList_init_$Create$,
  _UInt___init__impl__l7qpdl2x2ja0qtrydmg as _UInt___init__impl__l7qpdl,
  UInt1hthisrv6cndi as UInt,
  ArrayList_init_$Create$2rimpp4x9tjd3 as ArrayList_init_$Create$_0,
  initMetadataForCompanion1wyw17z38v6ac as initMetadataForCompanion,
  initMetadataForClassbxx6q50dy2s7 as initMetadataForClass,
  Default_getInstancexco526sx0ut9 as Default_getInstance,
  nextUInt1vow1dubtiav2 as nextUInt,
  listOf1jh22dvmctj1r as listOf,
  _UByte___get_data__impl__jof9qr1jhbnu489etgz as _UByte___get_data__impl__jof9qr,
  toLongw1zpgk99d84b as toLong,
  encodeToByteArray1onwao0uakjfh as encodeToByteArray,
  primitiveArrayConcatwxgknw08pmlb as primitiveArrayConcat,
  asIterable1h9qf00phdp5h as asIterable,
  chunked1umgsyuj0x9u1 as chunked,
  collectionSizeOrDefault36dulx8yinfqm as collectionSizeOrDefault,
  toByteArray3caw0hip00os as toByteArray,
  plus310ted5e4i90h as plus,
  get_lastIndex1yw0x4k50k51w as get_lastIndex,
  _UShort___get_data__impl__g02453buibbzrpmeid as _UShort___get_data__impl__g0245,
  UShort26xnqty60t7le as UShort,
  UShort__hashCode_impl_ywngrv1x91zfo6cqzyj as UShort__hashCode_impl_ywngrv,
  getBooleanHashCode1bbj3u6b3v0a7 as getBooleanHashCode,
  THROW_CCE2g6jy02ryeudk as THROW_CCE,
  UInt__hashCode_impl_z2mhuw2hl6ws6qmi0af as UInt__hashCode_impl_z2mhuw,
  ULong3f9k7s38t3rfp as ULong,
  ULong__hashCode_impl_6hv2lb2mga9j99vzivo as ULong__hashCode_impl_6hv2lb,
  equals2au1ep9vhcato as equals,
  toString30pk9tzaqopn as toString_0,
  getStringHashCode26igk1bx568vk as getStringHashCode,
  Long2qws0ah9gnpki as Long,
  _ULong___init__impl__c78o9k1neui78jb9mlg as _ULong___init__impl__c78o9k,
  _ULong___get_data__impl__fggpzb77rs34yu2akv as _ULong___get_data__impl__fggpzb,
  numberRangeToNumber25vse2rgp6rs8 as numberRangeToNumber,
  slice8hja4rrl6nj7 as slice,
  until1jbpn0z3f8lbg as until,
  slice2g43wio9c6zdv as slice_0,
  sliceArray2hu2ljigibgmi as sliceArray,
  decodeToString1x4faah2liw2p as decodeToString,
  _UByte___init__impl__g9hnc43i8t7wecfr79w as _UByte___init__impl__g9hnc4,
  CoroutineImpl2sn3kjnwmfr10 as CoroutineImpl,
  get_COROUTINE_SUSPENDED3ujt3p13qm4iy as get_COROUTINE_SUSPENDED,
  Paire9pteg33gng7 as Pair,
  initMetadataForCoroutine1i7lbatuf5bnt as initMetadataForCoroutine,
  withIndex37cl61h9v5txo as withIndex,
  Exceptiondt2hlxn7j7vw as Exception,
  listOfvhqybd2zx248 as listOf_0,
  getOrNull1go7ef9ldk0df as getOrNull,
  emptyList1g2z5xcrvp2zy as emptyList,
  uintToDouble4p0eh9cdfn62 as uintToDouble,
  numberToInt1ygmcfwhs2fkq as numberToInt,
  toShort36kaw0zjdq3ex as toShort,
  _UShort___init__impl__jigrne18f2wrm3i4dpy as _UShort___init__impl__jigrne,
  uintCompare18k97xs29243i as uintCompare,
  mutableListOf6oorvk2mtdmp as mutableListOf,
  noWhenBranchMatchedException2a6r7ubxgky5j as noWhenBranchMatchedException,
  until2gh9v9ogvltkl as until_0,
  VOID7hggqo3abtya as VOID,
  UBytep4j7r1t64gz1 as UByte,
  mapCapacity1h45rc3eh9p2l as mapCapacity,
  coerceAtLeast2bkz8m9ik7hep as coerceAtLeast,
  LinkedHashMap_init_$Create$snys8oz8txtu as LinkedHashMap_init_$Create$,
  enumEntries20mr21zbe3az4 as enumEntries,
  Enum3alwj03lh1n41 as Enum,
  hashCodeq5arwsb9dgti as hashCode,
  UByte__hashCode_impl_mmczcb2bk1orv63vhkp as UByte__hashCode_impl_mmczcb,
  defineProp3hxgpk2knu2px as defineProp,
  initMetadataForInterface1egvbzx539z91 as initMetadataForInterface,
  ULong__toString_impl_f9au7k260qy52yi92xo as ULong__toString_impl_f9au7k,
  isInterface3d6p8outrmvmk as isInterface,
  initMetadataForLambda3af3he42mmnh as initMetadataForLambda,
  numberToLong1a4cndvg6c52s as numberToLong,
} from './kotlin-kotlin-stdlib.mjs';
import {
  delay2673xnmlkmidc as delay,
  Mutex16li1l0asjv17 as Mutex,
  awaitopqeg9l1dqx0 as await_0,
  CoroutineScopefcb5f5dwqcas as CoroutineScope,
  MainScope1gi1r4abhrtmm as MainScope,
  launch1c91vkjzdi9sd as launch,
} from './kotlinx-coroutines-core.mjs';
//region block: imports
var imul = Math.imul;
//endregion
//region block: pre-declaration
initMetadataForObject(AESPlatform, 'AESPlatform');
initMetadataForObject(AESUtil, 'AESUtil');
initMetadataForCompanion(Companion);
initMetadataForClass(ByteArrayBuffer, 'ByteArrayBuffer');
initMetadataForObject(CMD, 'CMD');
initMetadataForClass(ChargeLevel, 'ChargeLevel');
initMetadataForClass(ControlProgress, 'ControlProgress');
initMetadataForClass(Device, 'Device');
initMetadataForClass(DeviceInfo, 'DeviceInfo');
initMetadataForClass(DeviceLog, 'DeviceLog');
initMetadataForCoroutine($callCOROUTINE$0, CoroutineImpl);
initMetadataForCoroutine($transAndCheckResultCOROUTINE$2, CoroutineImpl);
initMetadataForCoroutine($initCOROUTINE$3, CoroutineImpl);
initMetadataForCoroutine($getRssiCOROUTINE$4, CoroutineImpl);
initMetadataForCoroutine($getInfoCOROUTINE$5, CoroutineImpl);
initMetadataForCoroutine($selectCOROUTINE$6, CoroutineImpl);
initMetadataForCoroutine($getVersionCOROUTINE$7, CoroutineImpl);
initMetadataForCoroutine($setKeyCOROUTINE$8, CoroutineImpl);
initMetadataForCoroutine($getChargeLevelCOROUTINE$9, CoroutineImpl);
initMetadataForCoroutine($controlCOROUTINE$10, CoroutineImpl);
initMetadataForCoroutine($getControlProgressCOROUTINE$11, CoroutineImpl);
initMetadataForCoroutine($setParametersCOROUTINE$12, CoroutineImpl);
initMetadataForCoroutine($getLogCOROUTINE$13, CoroutineImpl);
initMetadataForObject(DeviceManager, 'DeviceManager', VOID, VOID, VOID, [5, 2, 1, 3, 4]);
initMetadataForCompanion(Companion_0);
initMetadataForClass(Ctrl, 'Ctrl', VOID, Enum);
initMetadataForCompanion(Companion_1);
initMetadataForClass(UserType, 'UserType', VOID, Enum);
initMetadataForClass(Result, 'Result', VOID, Enum);
initMetadataForCoroutine($startCOROUTINE$14, CoroutineImpl);
initMetadataForCoroutine($getStartAddressCOROUTINE$15, CoroutineImpl);
initMetadataForCoroutine($readCOROUTINE$16, CoroutineImpl);
initMetadataForCoroutine($writeCOROUTINE$17, CoroutineImpl);
initMetadataForObject(NFCUtil, 'NFCUtil', VOID, VOID, VOID, [1, 3, 4]);
initMetadataForClass(CommonTask, 'CommonTask');
initMetadataForClass(ControlTask, 'ControlTask', VOID, CommonTask);
initMetadataForClass(SetKeyTask, 'SetKeyTask', VOID, CommonTask);
initMetadataForClass(SetParametersTask, 'SetParametersTask', VOID, CommonTask);
initMetadataForClass(GetLogTask, 'GetLogTask', VOID, CommonTask);
initMetadataForClass(GetVersionTask, 'GetVersionTask', VOID, CommonTask);
initMetadataForClass(CallFunctionTask, 'CallFunctionTask', VOID, CommonTask);
initMetadataForCoroutine($processCOROUTINE$18, CoroutineImpl);
initMetadataForCoroutine($selectCOROUTINE$19, CoroutineImpl);
initMetadataForCoroutine($chargingCOROUTINE$20, CoroutineImpl);
initMetadataForCoroutine($controlCOROUTINE$21, CoroutineImpl);
initMetadataForCoroutine($controllingCOROUTINE$22, CoroutineImpl);
initMetadataForCoroutine($setKeyCOROUTINE$23, CoroutineImpl);
initMetadataForCoroutine($setParametersCOROUTINE$24, CoroutineImpl);
initMetadataForCoroutine($getLogCOROUTINE$25, CoroutineImpl);
initMetadataForCoroutine($getVersionCOROUTINE$26, CoroutineImpl);
initMetadataForCoroutine($callFunctionCOROUTINE$27, CoroutineImpl);
initMetadataForClass(NFCHelper, 'NFCHelper', VOID, VOID, VOID, [1, 3, 4, 5]);
initMetadataForCompanion(Companion_2);
initMetadataForClass(CustomDataConfig, 'CustomDataConfig', VOID, Enum);
initMetadataForInterface(JsNFCCallbacks, 'JsNFCCallbacks');
initMetadataForClass(JsNFCHelper$nfcHelper$1$getNFCTag$2, VOID, VOID, VOID, VOID, [1]);
initMetadataForCoroutine($getNFCTagCOROUTINE$28, CoroutineImpl);
initMetadataForClass(JsNFCHelper$nfcCallbacks$1);
initMetadataForClass(JsNFCHelper$nfcHelper$1, VOID, VOID, NFCHelper, VOID, [1]);
initMetadataForLambda(JsNFCHelper$process$slambda, CoroutineImpl, VOID, [1]);
initMetadataForClass(JsNFCHelper, 'JsNFCHelper');
initMetadataForClass(WebViewNFCHelper, 'WebViewNFCHelper', VOID, JsNFCHelper);
initMetadataForClass(WxNFCHelper, 'WxNFCHelper', VOID, JsNFCHelper);
//endregion
function xorBytes($this, a, b) {
  // Inline function 'kotlin.require' call
  if (!(a.length === b.length)) {
    // Inline function 'com.lvcheng.lock.shared.nfc.kmp.AESPlatform.xorBytes.<anonymous>' call
    var message = 'Arrays must have the same length';
    throw IllegalArgumentException_init_$Create$(toString(message));
  }
  var tmp = 0;
  var tmp_0 = a.length;
  var tmp_1 = new Int8Array(tmp_0);
  while (tmp < tmp_0) {
    var tmp_2 = tmp;
    tmp_1[tmp_2] = toByte(a[tmp_2] ^ b[tmp_2]);
    tmp = tmp + 1 | 0;
  }
  return tmp_1;
}
function aesCbcEncrypt($this, plaintext, key, iv) {
  var blockSize = 16;
  // Inline function 'kotlin.require' call
  if (!((plaintext.length % blockSize | 0) === 0)) {
    // Inline function 'com.lvcheng.lock.shared.nfc.kmp.AESPlatform.aesCbcEncrypt.<anonymous>' call
    var message = 'Plaintext size must be multiple of 16';
    throw IllegalArgumentException_init_$Create$(toString(message));
  }
  var result = new Int8Array(plaintext.length);
  // Inline function 'kotlin.collections.copyOf' call
  // Inline function 'kotlin.js.asDynamic' call
  var previousBlock = iv.slice();
  var nestedLast = plaintext.length - 1 | 0;
  if (blockSize <= 0)
    THROW_IAE('Step must be positive, was: ' + blockSize + '.');
  var inductionVariable = 0;
  var last = getProgressionLastElement(0, nestedLast, blockSize);
  if (inductionVariable <= last)
    do {
      var i = inductionVariable;
      inductionVariable = inductionVariable + blockSize | 0;
      var block = copyOfRange(plaintext, i, i + blockSize | 0);
      var xored = xorBytes($this, block, previousBlock);
      var encrypted = aesEncryptBlock($this, xored, key);
      // Inline function 'kotlin.collections.copyInto' call
      var destinationOffset = i;
      var endIndex = encrypted.length;
      // Inline function 'kotlin.js.unsafeCast' call
      // Inline function 'kotlin.js.asDynamic' call
      var tmp = encrypted;
      // Inline function 'kotlin.js.unsafeCast' call
      // Inline function 'kotlin.js.asDynamic' call
      arrayCopy(tmp, result, destinationOffset, 0, endIndex);
      previousBlock = encrypted;
    }
     while (!(i === last));
  return result;
}
function aesCbcDecrypt($this, ciphertext, key, iv) {
  var blockSize = 16;
  // Inline function 'kotlin.require' call
  if (!((ciphertext.length % blockSize | 0) === 0)) {
    // Inline function 'com.lvcheng.lock.shared.nfc.kmp.AESPlatform.aesCbcDecrypt.<anonymous>' call
    var message = 'Ciphertext size must be multiple of 16';
    throw IllegalArgumentException_init_$Create$(toString(message));
  }
  var result = new Int8Array(ciphertext.length);
  // Inline function 'kotlin.collections.copyOf' call
  // Inline function 'kotlin.js.asDynamic' call
  var previousBlock = iv.slice();
  var nestedLast = ciphertext.length - 1 | 0;
  if (blockSize <= 0)
    THROW_IAE('Step must be positive, was: ' + blockSize + '.');
  var inductionVariable = 0;
  var last = getProgressionLastElement(0, nestedLast, blockSize);
  if (inductionVariable <= last)
    do {
      var i = inductionVariable;
      inductionVariable = inductionVariable + blockSize | 0;
      var block = copyOfRange(ciphertext, i, i + blockSize | 0);
      var decrypted = aesDecryptBlock($this, block, key);
      var xored = xorBytes($this, decrypted, previousBlock);
      // Inline function 'kotlin.collections.copyInto' call
      var destinationOffset = i;
      var endIndex = xored.length;
      // Inline function 'kotlin.js.unsafeCast' call
      // Inline function 'kotlin.js.asDynamic' call
      var tmp = xored;
      // Inline function 'kotlin.js.unsafeCast' call
      // Inline function 'kotlin.js.asDynamic' call
      arrayCopy(tmp, result, destinationOffset, 0, endIndex);
      previousBlock = block;
    }
     while (!(i === last));
  return result;
}
function aesEncryptBlock($this, block, key) {
  var expandedKey = keyExpansion($this, key);
  var tmp = 0;
  // Inline function 'kotlin.arrayOfNulls' call
  var tmp_0 = fillArrayVal(Array(4), null);
  while (tmp < 4) {
    tmp_0[tmp] = new Int32Array(4);
    tmp = tmp + 1 | 0;
  }
  var state = tmp_0;
  var inductionVariable = 0;
  if (inductionVariable < 4)
    do {
      var i = inductionVariable;
      inductionVariable = inductionVariable + 1 | 0;
      var inductionVariable_0 = 0;
      if (inductionVariable_0 < 4)
        do {
          var j = inductionVariable_0;
          inductionVariable_0 = inductionVariable_0 + 1 | 0;
          state[j][i] = block[imul(i, 4) + j | 0] & 255;
        }
         while (inductionVariable_0 < 4);
    }
     while (inductionVariable < 4);
  addRoundKey($this, state, expandedKey, 0);
  var inductionVariable_1 = 1;
  if (inductionVariable_1 < 10)
    do {
      var round = inductionVariable_1;
      inductionVariable_1 = inductionVariable_1 + 1 | 0;
      subBytes($this, state);
      shiftRows($this, state);
      mixColumns($this, state);
      addRoundKey($this, state, expandedKey, round);
    }
     while (inductionVariable_1 < 10);
  subBytes($this, state);
  shiftRows($this, state);
  addRoundKey($this, state, expandedKey, 10);
  var result = new Int8Array(16);
  var inductionVariable_2 = 0;
  if (inductionVariable_2 < 4)
    do {
      var i_0 = inductionVariable_2;
      inductionVariable_2 = inductionVariable_2 + 1 | 0;
      var inductionVariable_3 = 0;
      if (inductionVariable_3 < 4)
        do {
          var j_0 = inductionVariable_3;
          inductionVariable_3 = inductionVariable_3 + 1 | 0;
          result[imul(i_0, 4) + j_0 | 0] = toByte(state[j_0][i_0]);
        }
         while (inductionVariable_3 < 4);
    }
     while (inductionVariable_2 < 4);
  return result;
}
function aesDecryptBlock($this, block, key) {
  var expandedKey = keyExpansion($this, key);
  var tmp = 0;
  // Inline function 'kotlin.arrayOfNulls' call
  var tmp_0 = fillArrayVal(Array(4), null);
  while (tmp < 4) {
    tmp_0[tmp] = new Int32Array(4);
    tmp = tmp + 1 | 0;
  }
  var state = tmp_0;
  var inductionVariable = 0;
  if (inductionVariable < 4)
    do {
      var i = inductionVariable;
      inductionVariable = inductionVariable + 1 | 0;
      var inductionVariable_0 = 0;
      if (inductionVariable_0 < 4)
        do {
          var j = inductionVariable_0;
          inductionVariable_0 = inductionVariable_0 + 1 | 0;
          state[j][i] = block[imul(i, 4) + j | 0] & 255;
        }
         while (inductionVariable_0 < 4);
    }
     while (inductionVariable < 4);
  addRoundKey($this, state, expandedKey, 10);
  var inductionVariable_1 = 9;
  if (1 <= inductionVariable_1)
    do {
      var round = inductionVariable_1;
      inductionVariable_1 = inductionVariable_1 + -1 | 0;
      invShiftRows($this, state);
      invSubBytes($this, state);
      addRoundKey($this, state, expandedKey, round);
      invMixColumns($this, state);
    }
     while (1 <= inductionVariable_1);
  invShiftRows($this, state);
  invSubBytes($this, state);
  addRoundKey($this, state, expandedKey, 0);
  var result = new Int8Array(16);
  var inductionVariable_2 = 0;
  if (inductionVariable_2 < 4)
    do {
      var i_0 = inductionVariable_2;
      inductionVariable_2 = inductionVariable_2 + 1 | 0;
      var inductionVariable_3 = 0;
      if (inductionVariable_3 < 4)
        do {
          var j_0 = inductionVariable_3;
          inductionVariable_3 = inductionVariable_3 + 1 | 0;
          result[imul(i_0, 4) + j_0 | 0] = toByte(state[j_0][i_0]);
        }
         while (inductionVariable_3 < 4);
    }
     while (inductionVariable_2 < 4);
  return result;
}
function keyExpansion($this, key) {
  var nk = 4;
  var nb = 4;
  var nr = 10;
  var tmp = 0;
  var tmp_0 = imul(nb, nr + 1 | 0);
  // Inline function 'kotlin.arrayOfNulls' call
  var tmp_1 = fillArrayVal(Array(tmp_0), null);
  while (tmp < tmp_0) {
    tmp_1[tmp] = new Int32Array(4);
    tmp = tmp + 1 | 0;
  }
  var w = tmp_1;
  var inductionVariable = 0;
  if (inductionVariable < nk)
    do {
      var i = inductionVariable;
      inductionVariable = inductionVariable + 1 | 0;
      w[i][0] = key[imul(4, i)] & 255;
      w[i][1] = key[imul(4, i) + 1 | 0] & 255;
      w[i][2] = key[imul(4, i) + 2 | 0] & 255;
      w[i][3] = key[imul(4, i) + 3 | 0] & 255;
    }
     while (inductionVariable < nk);
  var inductionVariable_0 = nk;
  var last = imul(nb, nr + 1 | 0);
  if (inductionVariable_0 < last)
    do {
      var i_0 = inductionVariable_0;
      inductionVariable_0 = inductionVariable_0 + 1 | 0;
      // Inline function 'kotlin.collections.copyOf' call
      // Inline function 'kotlin.js.asDynamic' call
      var temp = w[i_0 - 1 | 0].slice();
      if ((i_0 % nk | 0) === 0) {
        var t = temp[0];
        temp[0] = temp[1];
        temp[1] = temp[2];
        temp[2] = temp[3];
        temp[3] = t;
        temp[0] = $this.tq_1[temp[0]];
        temp[1] = $this.tq_1[temp[1]];
        temp[2] = $this.tq_1[temp[2]];
        temp[3] = $this.tq_1[temp[3]];
        temp[0] = temp[0] ^ $this.vq_1[i_0 / nk | 0];
      }
      w[i_0][0] = w[i_0 - nk | 0][0] ^ temp[0];
      w[i_0][1] = w[i_0 - nk | 0][1] ^ temp[1];
      w[i_0][2] = w[i_0 - nk | 0][2] ^ temp[2];
      w[i_0][3] = w[i_0 - nk | 0][3] ^ temp[3];
    }
     while (inductionVariable_0 < last);
  return w;
}
function subBytes($this, state) {
  var inductionVariable = 0;
  if (inductionVariable < 4)
    do {
      var i = inductionVariable;
      inductionVariable = inductionVariable + 1 | 0;
      var inductionVariable_0 = 0;
      if (inductionVariable_0 < 4)
        do {
          var j = inductionVariable_0;
          inductionVariable_0 = inductionVariable_0 + 1 | 0;
          state[i][j] = $this.tq_1[state[i][j]];
        }
         while (inductionVariable_0 < 4);
    }
     while (inductionVariable < 4);
}
function invSubBytes($this, state) {
  var inductionVariable = 0;
  if (inductionVariable < 4)
    do {
      var i = inductionVariable;
      inductionVariable = inductionVariable + 1 | 0;
      var inductionVariable_0 = 0;
      if (inductionVariable_0 < 4)
        do {
          var j = inductionVariable_0;
          inductionVariable_0 = inductionVariable_0 + 1 | 0;
          state[i][j] = $this.uq_1[state[i][j]];
        }
         while (inductionVariable_0 < 4);
    }
     while (inductionVariable < 4);
}
function shiftRows($this, state) {
  var temp = state[1][0];
  state[1][0] = state[1][1];
  state[1][1] = state[1][2];
  state[1][2] = state[1][3];
  state[1][3] = temp;
  temp = state[2][0];
  state[2][0] = state[2][2];
  state[2][2] = temp;
  temp = state[2][1];
  state[2][1] = state[2][3];
  state[2][3] = temp;
  temp = state[3][3];
  state[3][3] = state[3][2];
  state[3][2] = state[3][1];
  state[3][1] = state[3][0];
  state[3][0] = temp;
}
function invShiftRows($this, state) {
  var temp = state[1][3];
  state[1][3] = state[1][2];
  state[1][2] = state[1][1];
  state[1][1] = state[1][0];
  state[1][0] = temp;
  temp = state[2][0];
  state[2][0] = state[2][2];
  state[2][2] = temp;
  temp = state[2][1];
  state[2][1] = state[2][3];
  state[2][3] = temp;
  temp = state[3][0];
  state[3][0] = state[3][1];
  state[3][1] = state[3][2];
  state[3][2] = state[3][3];
  state[3][3] = temp;
}
function gmul($this, a, b) {
  var p = 0;
  var aa = a;
  var bb = b;
  var inductionVariable = 0;
  if (inductionVariable < 8)
    do {
      var i = inductionVariable;
      inductionVariable = inductionVariable + 1 | 0;
      if (!((bb & 1) === 0)) {
        p = p ^ aa;
      }
      var hiBitSet = !((aa & 128) === 0);
      aa = aa << 1;
      if (hiBitSet) {
        aa = aa ^ 27;
      }
      bb = bb >> 1;
    }
     while (inductionVariable < 8);
  return p & 255;
}
function mixColumns($this, state) {
  var inductionVariable = 0;
  if (inductionVariable < 4)
    do {
      var i = inductionVariable;
      inductionVariable = inductionVariable + 1 | 0;
      var s0 = state[0][i];
      var s1 = state[1][i];
      var s2 = state[2][i];
      var s3 = state[3][i];
      state[0][i] = gmul($this, s0, 2) ^ gmul($this, s1, 3) ^ s2 ^ s3;
      state[1][i] = s0 ^ gmul($this, s1, 2) ^ gmul($this, s2, 3) ^ s3;
      state[2][i] = s0 ^ s1 ^ gmul($this, s2, 2) ^ gmul($this, s3, 3);
      state[3][i] = gmul($this, s0, 3) ^ s1 ^ s2 ^ gmul($this, s3, 2);
    }
     while (inductionVariable < 4);
}
function invMixColumns($this, state) {
  var inductionVariable = 0;
  if (inductionVariable < 4)
    do {
      var i = inductionVariable;
      inductionVariable = inductionVariable + 1 | 0;
      var s0 = state[0][i];
      var s1 = state[1][i];
      var s2 = state[2][i];
      var s3 = state[3][i];
      state[0][i] = gmul($this, s0, 14) ^ gmul($this, s1, 11) ^ gmul($this, s2, 13) ^ gmul($this, s3, 9);
      state[1][i] = gmul($this, s0, 9) ^ gmul($this, s1, 14) ^ gmul($this, s2, 11) ^ gmul($this, s3, 13);
      state[2][i] = gmul($this, s0, 13) ^ gmul($this, s1, 9) ^ gmul($this, s2, 14) ^ gmul($this, s3, 11);
      state[3][i] = gmul($this, s0, 11) ^ gmul($this, s1, 13) ^ gmul($this, s2, 9) ^ gmul($this, s3, 14);
    }
     while (inductionVariable < 4);
}
function addRoundKey($this, state, w, round) {
  var inductionVariable = 0;
  if (inductionVariable < 4)
    do {
      var i = inductionVariable;
      inductionVariable = inductionVariable + 1 | 0;
      var inductionVariable_0 = 0;
      if (inductionVariable_0 < 4)
        do {
          var j = inductionVariable_0;
          inductionVariable_0 = inductionVariable_0 + 1 | 0;
          state[j][i] = state[j][i] ^ w[imul(round, 4) + i | 0][j];
        }
         while (inductionVariable_0 < 4);
    }
     while (inductionVariable < 4);
}
function AESPlatform() {
  AESPlatform_instance = this;
  var tmp = this;
  // Inline function 'kotlin.intArrayOf' call
  tmp.tq_1 = new Int32Array([99, 124, 119, 123, 242, 107, 111, 197, 48, 1, 103, 43, 254, 215, 171, 118, 202, 130, 201, 125, 250, 89, 71, 240, 173, 212, 162, 175, 156, 164, 114, 192, 183, 253, 147, 38, 54, 63, 247, 204, 52, 165, 229, 241, 113, 216, 49, 21, 4, 199, 35, 195, 24, 150, 5, 154, 7, 18, 128, 226, 235, 39, 178, 117, 9, 131, 44, 26, 27, 110, 90, 160, 82, 59, 214, 179, 41, 227, 47, 132, 83, 209, 0, 237, 32, 252, 177, 91, 106, 203, 190, 57, 74, 76, 88, 207, 208, 239, 170, 251, 67, 77, 51, 133, 69, 249, 2, 127, 80, 60, 159, 168, 81, 163, 64, 143, 146, 157, 56, 245, 188, 182, 218, 33, 16, 255, 243, 210, 205, 12, 19, 236, 95, 151, 68, 23, 196, 167, 126, 61, 100, 93, 25, 115, 96, 129, 79, 220, 34, 42, 144, 136, 70, 238, 184, 20, 222, 94, 11, 219, 224, 50, 58, 10, 73, 6, 36, 92, 194, 211, 172, 98, 145, 149, 228, 121, 231, 200, 55, 109, 141, 213, 78, 169, 108, 86, 244, 234, 101, 122, 174, 8, 186, 120, 37, 46, 28, 166, 180, 198, 232, 221, 116, 31, 75, 189, 139, 138, 112, 62, 181, 102, 72, 3, 246, 14, 97, 53, 87, 185, 134, 193, 29, 158, 225, 248, 152, 17, 105, 217, 142, 148, 155, 30, 135, 233, 206, 85, 40, 223, 140, 161, 137, 13, 191, 230, 66, 104, 65, 153, 45, 15, 176, 84, 187, 22]);
  var tmp_0 = this;
  // Inline function 'kotlin.intArrayOf' call
  tmp_0.uq_1 = new Int32Array([82, 9, 106, 213, 48, 54, 165, 56, 191, 64, 163, 158, 129, 243, 215, 251, 124, 227, 57, 130, 155, 47, 255, 135, 52, 142, 67, 68, 196, 222, 233, 203, 84, 123, 148, 50, 166, 194, 35, 61, 238, 76, 149, 11, 66, 250, 195, 78, 8, 46, 161, 102, 40, 217, 36, 178, 118, 91, 162, 73, 109, 139, 209, 37, 114, 248, 246, 100, 134, 104, 152, 22, 212, 164, 92, 204, 93, 101, 182, 146, 108, 112, 72, 80, 253, 237, 185, 218, 94, 21, 70, 87, 167, 141, 157, 132, 144, 216, 171, 0, 140, 188, 211, 10, 247, 228, 88, 5, 184, 179, 69, 6, 208, 44, 30, 143, 202, 63, 15, 2, 193, 175, 189, 3, 1, 19, 138, 107, 58, 145, 17, 65, 79, 103, 220, 234, 151, 242, 207, 206, 240, 180, 230, 115, 150, 172, 116, 34, 231, 173, 53, 133, 226, 249, 55, 232, 28, 117, 223, 110, 71, 241, 26, 113, 29, 41, 197, 137, 111, 183, 98, 14, 170, 24, 190, 27, 252, 86, 62, 75, 198, 210, 121, 32, 154, 219, 192, 254, 120, 205, 90, 244, 31, 221, 168, 51, 136, 7, 199, 49, 177, 18, 16, 89, 39, 128, 236, 95, 96, 81, 127, 169, 25, 181, 74, 13, 45, 229, 122, 159, 147, 201, 156, 239, 160, 224, 59, 77, 174, 42, 245, 176, 200, 235, 187, 60, 131, 83, 153, 97, 23, 43, 4, 126, 186, 119, 214, 38, 225, 105, 20, 99, 85, 33, 12, 125]);
  var tmp_1 = this;
  // Inline function 'kotlin.intArrayOf' call
  tmp_1.vq_1 = new Int32Array([141, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54]);
}
protoOf(AESPlatform).wq = function (data, key, iv) {
  return aesCbcEncrypt(this, data, key, iv);
};
protoOf(AESPlatform).xq = function (data, key, iv) {
  return aesCbcDecrypt(this, data, key, iv);
};
var AESPlatform_instance;
function AESPlatform_getInstance() {
  if (AESPlatform_instance == null)
    new AESPlatform();
  return AESPlatform_instance;
}
function AESUtil() {
}
protoOf(AESUtil).wq = function (data, key, iv) {
  // Inline function 'kotlin.require' call
  if (!(key.length === 16)) {
    // Inline function 'com.lvcheng.lock.shared.nfc.kmp.AESUtil.encrypt.<anonymous>' call
    var message = 'Key length must be 16 bytes (128 bits)';
    throw IllegalArgumentException_init_$Create$(toString(message));
  }
  // Inline function 'kotlin.require' call
  if (!(iv.length === 16)) {
    // Inline function 'com.lvcheng.lock.shared.nfc.kmp.AESUtil.encrypt.<anonymous>' call
    var message_0 = 'IV length must be 16 bytes';
    throw IllegalArgumentException_init_$Create$(toString(message_0));
  }
  // Inline function 'kotlin.require' call
  if (!((data.length % 16 | 0) === 0)) {
    // Inline function 'com.lvcheng.lock.shared.nfc.kmp.AESUtil.encrypt.<anonymous>' call
    var message_1 = 'Data length must be a multiple of 16 bytes (NoPadding mode)';
    throw IllegalArgumentException_init_$Create$(toString(message_1));
  }
  return AESPlatform_getInstance().wq(data, key, iv);
};
protoOf(AESUtil).xq = function (encryptedData, key, iv) {
  // Inline function 'kotlin.require' call
  if (!(key.length === 16)) {
    // Inline function 'com.lvcheng.lock.shared.nfc.kmp.AESUtil.decrypt.<anonymous>' call
    var message = 'Key length must be 16 bytes (128 bits)';
    throw IllegalArgumentException_init_$Create$(toString(message));
  }
  // Inline function 'kotlin.require' call
  if (!(iv.length === 16)) {
    // Inline function 'com.lvcheng.lock.shared.nfc.kmp.AESUtil.decrypt.<anonymous>' call
    var message_0 = 'IV length must be 16 bytes';
    throw IllegalArgumentException_init_$Create$(toString(message_0));
  }
  // Inline function 'kotlin.require' call
  if (!((encryptedData.length % 16 | 0) === 0)) {
    // Inline function 'com.lvcheng.lock.shared.nfc.kmp.AESUtil.decrypt.<anonymous>' call
    var message_1 = 'Encrypted data length must be a multiple of 16 bytes (NoPadding mode)';
    throw IllegalArgumentException_init_$Create$(toString(message_1));
  }
  return AESPlatform_getInstance().xq(encryptedData, key, iv);
};
protoOf(AESUtil).yq = function (commandList, fromIndex, toIndex, key, iv) {
  // Inline function 'kotlin.require' call
  if (!(0 <= fromIndex ? fromIndex <= (commandList.n() - 1 | 0) : false)) {
    // Inline function 'com.lvcheng.lock.shared.nfc.kmp.AESUtil.encryptUInt.<anonymous>' call
    var message = 'fromIndex out of bounds';
    throw IllegalArgumentException_init_$Create$(toString(message));
  }
  // Inline function 'kotlin.require' call
  if (!(0 <= toIndex ? toIndex <= (commandList.n() - 1 | 0) : false)) {
    // Inline function 'com.lvcheng.lock.shared.nfc.kmp.AESUtil.encryptUInt.<anonymous>' call
    var message_0 = 'toIndex out of bounds';
    throw IllegalArgumentException_init_$Create$(toString(message_0));
  }
  // Inline function 'kotlin.require' call
  if (!(fromIndex <= toIndex)) {
    // Inline function 'com.lvcheng.lock.shared.nfc.kmp.AESUtil.encryptUInt.<anonymous>' call
    var message_1 = 'fromIndex must be <= toIndex';
    throw IllegalArgumentException_init_$Create$(toString(message_1));
  }
  var rangeSize = (toIndex - fromIndex | 0) + 1 | 0;
  // Inline function 'kotlin.require' call
  if (!((imul(rangeSize, 4) % 16 | 0) === 0)) {
    // Inline function 'com.lvcheng.lock.shared.nfc.kmp.AESUtil.encryptUInt.<anonymous>' call
    var message_2 = 'Byte size of range must be multiple of 16 for AES NoPadding';
    throw IllegalArgumentException_init_$Create$(toString(message_2));
  }
  var buffer = Companion_instance.zq(imul(rangeSize, 4));
  var inductionVariable = fromIndex;
  if (inductionVariable <= toIndex)
    do {
      var i = inductionVariable;
      inductionVariable = inductionVariable + 1 | 0;
      // Inline function 'kotlin.UInt.toInt' call
      var this_0 = commandList.t(i).nd_1;
      var tmp$ret$4 = _UInt___get_data__impl__f0vqqw(this_0);
      buffer.cr(tmp$ret$4);
    }
     while (!(i === toIndex));
  var encrypted = this.wq(buffer.dr(), key, iv);
  var bufferEncrypted = Companion_instance.er(encrypted);
  // Inline function 'kotlin.collections.List' call
  // Inline function 'kotlin.collections.MutableList' call
  var list = ArrayList_init_$Create$(rangeSize);
  // Inline function 'kotlin.repeat' call
  var inductionVariable_0 = 0;
  if (inductionVariable_0 < rangeSize)
    do {
      var index = inductionVariable_0;
      inductionVariable_0 = inductionVariable_0 + 1 | 0;
      // Inline function 'kotlin.collections.MutableList.<anonymous>' call
      // Inline function 'com.lvcheng.lock.shared.nfc.kmp.AESUtil.encryptUInt.<anonymous>' call
      // Inline function 'kotlin.toUInt' call
      var this_1 = bufferEncrypted.fr();
      var tmp$ret$5 = _UInt___init__impl__l7qpdl(this_1);
      var tmp$ret$6 = new UInt(tmp$ret$5);
      list.u(tmp$ret$6);
    }
     while (inductionVariable_0 < rangeSize);
  var encryptedUInts = list;
  // Inline function 'kotlin.collections.buildList' call
  // Inline function 'kotlin.collections.buildListInternal' call
  // Inline function 'kotlin.apply' call
  var this_2 = ArrayList_init_$Create$_0();
  // Inline function 'com.lvcheng.lock.shared.nfc.kmp.AESUtil.encryptUInt.<anonymous>' call
  this_2.r(commandList.s(0, fromIndex));
  this_2.r(encryptedUInts);
  this_2.r(commandList.s(toIndex + 1 | 0, commandList.n()));
  return this_2.s3();
};
protoOf(AESUtil).gr = function (commandList, fromIndex, toIndex, key, iv) {
  // Inline function 'kotlin.require' call
  if (!(0 <= fromIndex ? fromIndex <= (commandList.n() - 1 | 0) : false)) {
    // Inline function 'com.lvcheng.lock.shared.nfc.kmp.AESUtil.decryptUInt.<anonymous>' call
    var message = 'fromIndex out of bounds';
    throw IllegalArgumentException_init_$Create$(toString(message));
  }
  // Inline function 'kotlin.require' call
  if (!(0 <= toIndex ? toIndex <= (commandList.n() - 1 | 0) : false)) {
    // Inline function 'com.lvcheng.lock.shared.nfc.kmp.AESUtil.decryptUInt.<anonymous>' call
    var message_0 = 'toIndex out of bounds';
    throw IllegalArgumentException_init_$Create$(toString(message_0));
  }
  // Inline function 'kotlin.require' call
  if (!(fromIndex <= toIndex)) {
    // Inline function 'com.lvcheng.lock.shared.nfc.kmp.AESUtil.decryptUInt.<anonymous>' call
    var message_1 = 'fromIndex must be <= toIndex';
    throw IllegalArgumentException_init_$Create$(toString(message_1));
  }
  var rangeSize = (toIndex - fromIndex | 0) + 1 | 0;
  // Inline function 'kotlin.require' call
  if (!((imul(rangeSize, 4) % 16 | 0) === 0)) {
    // Inline function 'com.lvcheng.lock.shared.nfc.kmp.AESUtil.decryptUInt.<anonymous>' call
    var message_2 = 'Byte size of range must be multiple of 16 for AES NoPadding';
    throw IllegalArgumentException_init_$Create$(toString(message_2));
  }
  var buffer = Companion_instance.zq(imul(rangeSize, 4));
  var inductionVariable = fromIndex;
  if (inductionVariable <= toIndex)
    do {
      var i = inductionVariable;
      inductionVariable = inductionVariable + 1 | 0;
      // Inline function 'kotlin.UInt.toInt' call
      var this_0 = commandList.t(i).nd_1;
      var tmp$ret$4 = _UInt___get_data__impl__f0vqqw(this_0);
      buffer.cr(tmp$ret$4);
    }
     while (!(i === toIndex));
  var decrypted = this.xq(buffer.dr(), key, iv);
  var bufferDecrypted = Companion_instance.er(decrypted);
  // Inline function 'kotlin.collections.List' call
  // Inline function 'kotlin.collections.MutableList' call
  var list = ArrayList_init_$Create$(rangeSize);
  // Inline function 'kotlin.repeat' call
  var inductionVariable_0 = 0;
  if (inductionVariable_0 < rangeSize)
    do {
      var index = inductionVariable_0;
      inductionVariable_0 = inductionVariable_0 + 1 | 0;
      // Inline function 'kotlin.collections.MutableList.<anonymous>' call
      // Inline function 'com.lvcheng.lock.shared.nfc.kmp.AESUtil.decryptUInt.<anonymous>' call
      // Inline function 'kotlin.toUInt' call
      var this_1 = bufferDecrypted.fr();
      var tmp$ret$5 = _UInt___init__impl__l7qpdl(this_1);
      var tmp$ret$6 = new UInt(tmp$ret$5);
      list.u(tmp$ret$6);
    }
     while (inductionVariable_0 < rangeSize);
  var decryptedUInts = list;
  // Inline function 'kotlin.collections.buildList' call
  // Inline function 'kotlin.collections.buildListInternal' call
  // Inline function 'kotlin.apply' call
  var this_2 = ArrayList_init_$Create$_0();
  // Inline function 'com.lvcheng.lock.shared.nfc.kmp.AESUtil.decryptUInt.<anonymous>' call
  this_2.r(commandList.s(0, fromIndex));
  this_2.r(decryptedUInts);
  this_2.r(commandList.s(toIndex + 1 | 0, commandList.n()));
  return this_2.s3();
};
var AESUtil_instance;
function AESUtil_getInstance() {
  return AESUtil_instance;
}
function Companion() {
}
protoOf(Companion).zq = function (capacity) {
  return new ByteArrayBuffer(new Int8Array(capacity));
};
protoOf(Companion).er = function (bytes) {
  // Inline function 'kotlin.collections.copyOf' call
  // Inline function 'kotlin.js.asDynamic' call
  var tmp$ret$1 = bytes.slice();
  return new ByteArrayBuffer(tmp$ret$1);
};
var Companion_instance;
function Companion_getInstance() {
  return Companion_instance;
}
function ByteArrayBuffer(array) {
  this.ar_1 = array;
  this.br_1 = 0;
}
protoOf(ByteArrayBuffer).n = function () {
  return this.ar_1.length;
};
protoOf(ByteArrayBuffer).hr = function () {
  return this.n() - this.br_1 | 0;
};
protoOf(ByteArrayBuffer).dr = function () {
  // Inline function 'kotlin.collections.copyOf' call
  // Inline function 'kotlin.js.asDynamic' call
  return this.ar_1.slice();
};
protoOf(ByteArrayBuffer).cr = function (value) {
  // Inline function 'kotlin.require' call
  if (!(this.hr() >= 4)) {
    // Inline function 'com.lvcheng.lock.shared.nfc.kmp.ByteArrayBuffer.putInt.<anonymous>' call
    var message = 'Not enough space to put Int';
    throw IllegalArgumentException_init_$Create$(toString(message));
  }
  this.ar_1[this.br_1] = toByte(value >> 24);
  this.ar_1[this.br_1 + 1 | 0] = toByte(value >> 16);
  this.ar_1[this.br_1 + 2 | 0] = toByte(value >> 8);
  this.ar_1[this.br_1 + 3 | 0] = toByte(value);
  this.br_1 = this.br_1 + 4 | 0;
  return this;
};
protoOf(ByteArrayBuffer).fr = function () {
  // Inline function 'kotlin.require' call
  if (!(this.hr() >= 4)) {
    // Inline function 'com.lvcheng.lock.shared.nfc.kmp.ByteArrayBuffer.getInt.<anonymous>' call
    var message = 'Not enough bytes to get Int';
    throw IllegalArgumentException_init_$Create$(toString(message));
  }
  var value = (this.ar_1[this.br_1] & 255) << 24 | (this.ar_1[this.br_1 + 1 | 0] & 255) << 16 | (this.ar_1[this.br_1 + 2 | 0] & 255) << 8 | this.ar_1[this.br_1 + 3 | 0] & 255;
  this.br_1 = this.br_1 + 4 | 0;
  return value;
};
function CMD() {
}
protoOf(CMD).ir = function () {
  return listOf([new UInt(_UInt___init__impl__l7qpdl(524289)), new UInt(nextUInt(Default_getInstance())), new UInt(_UInt___init__impl__l7qpdl(151519237))]);
};
protoOf(CMD).jr = function () {
  return listOf([new UInt(_UInt___init__impl__l7qpdl(524289)), new UInt(nextUInt(Default_getInstance())), new UInt(_UInt___init__impl__l7qpdl(50397232))]);
};
protoOf(CMD).kr = function (type) {
  var tmp = _UInt___init__impl__l7qpdl(786433);
  var tmp_0 = nextUInt(Default_getInstance());
  var tmp_1 = _UInt___init__impl__l7qpdl(-2097080064);
  // Inline function 'kotlin.UByte.toUInt' call
  // Inline function 'kotlin.UInt.shl' call
  var this_0 = _UInt___init__impl__l7qpdl(_UByte___get_data__impl__jof9qr(type) & 255);
  var tmp5 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_0) << 24);
  // Inline function 'kotlin.UInt.shl' call
  var this_1 = _UInt___init__impl__l7qpdl(255);
  // Inline function 'kotlin.UInt.and' call
  var other = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_1) << 24);
  var tmp9 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp5) & _UInt___get_data__impl__f0vqqw(other));
  var tmp7 = nextUInt(Default_getInstance());
  // Inline function 'kotlin.UInt.and' call
  var other_0 = _UInt___init__impl__l7qpdl(16777215);
  // Inline function 'kotlin.UInt.plus' call
  var other_1 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp7) & _UInt___get_data__impl__f0vqqw(other_0));
  var tmp$ret$5 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp9) + _UInt___get_data__impl__f0vqqw(other_1) | 0);
  return listOf([new UInt(tmp), new UInt(tmp_0), new UInt(tmp_1), new UInt(tmp$ret$5)]);
};
protoOf(CMD).lr = function (eKey) {
  var tmp = AESUtil_instance;
  var tmp_0 = listOf([new UInt(_UInt___init__impl__l7qpdl(1081345)), new UInt(nextUInt(Default_getInstance())), new UInt(_UInt___init__impl__l7qpdl(117702657)), new UInt(nextUInt(Default_getInstance())), new UInt(nextUInt(Default_getInstance()))]);
  var tmp_1 = 0;
  var tmp_2 = new Int8Array(16);
  while (tmp_1 < 16) {
    tmp_2[tmp_1] = 0;
    tmp_1 = tmp_1 + 1 | 0;
  }
  return tmp.yq(tmp_0, 1, 4, eKey, tmp_2);
};
protoOf(CMD).mr = function (eKey) {
  var tmp = AESUtil_instance;
  var tmp_0 = _UInt___init__impl__l7qpdl(1081345);
  var tmp_1 = nextUInt(Default_getInstance());
  var tmp_2 = _UInt___init__impl__l7qpdl(-2012735488);
  var tmp_3 = _UInt___init__impl__l7qpdl(0);
  // Inline function 'kotlin.Long.div' call
  // Inline function 'kotlin.toUInt' call
  var this_0 = platformGetCurrentTimestamp().u1(toLong(1000));
  var tmp$ret$1 = _UInt___init__impl__l7qpdl(this_0.g2());
  var tmp_4 = listOf([new UInt(tmp_0), new UInt(tmp_1), new UInt(tmp_2), new UInt(tmp_3), new UInt(tmp$ret$1)]);
  var tmp_5 = 0;
  var tmp_6 = new Int8Array(16);
  while (tmp_5 < 16) {
    tmp_6[tmp_5] = 0;
    tmp_5 = tmp_5 + 1 | 0;
  }
  return tmp.yq(tmp_4, 1, 4, eKey, tmp_6);
};
protoOf(CMD).nr = function (eKey, name) {
  var maxNameLength = 20;
  // Inline function 'kotlin.require' call
  if (!(name.length <= maxNameLength)) {
    // Inline function 'com.lvcheng.lock.shared.nfc.kmp.CMD.USR.<anonymous>' call
    var message = 'Name length must be at most ' + maxNameLength;
    throw IllegalArgumentException_init_$Create$(toString(message));
  }
  var nameBytes = encodeToByteArray(name);
  var nameLength = nameBytes.length;
  var padding = 16 - ((nameLength + 8 | 0) % 16 | 0) | 0;
  var tmp = 0;
  var tmp_0 = new Int8Array(padding);
  while (tmp < padding) {
    tmp_0[tmp] = Default_getInstance().jc(1)[0];
    tmp = tmp + 1 | 0;
  }
  // Inline function 'kotlin.collections.plus' call
  var paddedBytes = primitiveArrayConcat([nameBytes, tmp_0]);
  // Inline function 'kotlin.collections.map' call
  var this_0 = chunked(asIterable(paddedBytes), 4);
  // Inline function 'kotlin.collections.mapTo' call
  var destination = ArrayList_init_$Create$(collectionSizeOrDefault(this_0, 10));
  var _iterator__ex2g4s = this_0.k();
  while (_iterator__ex2g4s.l()) {
    var item = _iterator__ex2g4s.m();
    // Inline function 'com.lvcheng.lock.shared.nfc.kmp.CMD.USR.<anonymous>' call
    // Inline function 'kotlin.toUInt' call
    var this_1 = Companion_instance.er(toByteArray(item)).fr();
    var tmp$ret$3 = _UInt___init__impl__l7qpdl(this_1);
    var tmp$ret$4 = new UInt(tmp$ret$3);
    destination.u(tmp$ret$4);
  }
  var nameUInts = destination;
  var totalDataBytes = 8 + imul(nameUInts.n(), 4) | 0;
  // Inline function 'kotlin.toUInt' call
  var this_2 = totalDataBytes << 16 | 32769;
  var dataLenPrefix = _UInt___init__impl__l7qpdl(this_2);
  // Inline function 'kotlin.toUInt' call
  var this_3 = -1862270976 | nameLength << 16 | 6145;
  var nameLenField = _UInt___init__impl__l7qpdl(this_3);
  var commandList = plus(listOf([new UInt(dataLenPrefix), new UInt(nextUInt(Default_getInstance())), new UInt(nameLenField)]), nameUInts);
  var tmp_1 = AESUtil_instance;
  var tmp_2 = get_lastIndex(commandList);
  var tmp_3 = 0;
  var tmp_4 = new Int8Array(16);
  while (tmp_3 < 16) {
    tmp_4[tmp_3] = 0;
    tmp_3 = tmp_3 + 1 | 0;
  }
  return tmp_1.yq(commandList, 1, tmp_2, eKey, tmp_4);
};
protoOf(CMD).or = function (eKey, key) {
  // Inline function 'kotlin.require' call
  if (!(key.length === 16)) {
    // Inline function 'com.lvcheng.lock.shared.nfc.kmp.CMD.KEY.<anonymous>' call
    var message = 'Key size must be 16';
    throw IllegalArgumentException_init_$Create$(toString(message));
  }
  // Inline function 'kotlin.collections.map' call
  var this_0 = chunked(asIterable(key), 4);
  // Inline function 'kotlin.collections.mapTo' call
  var destination = ArrayList_init_$Create$(collectionSizeOrDefault(this_0, 10));
  var _iterator__ex2g4s = this_0.k();
  while (_iterator__ex2g4s.l()) {
    var item = _iterator__ex2g4s.m();
    // Inline function 'com.lvcheng.lock.shared.nfc.kmp.CMD.KEY.<anonymous>' call
    // Inline function 'kotlin.toUInt' call
    var this_1 = Companion_instance.er(toByteArray(item)).fr();
    var tmp$ret$1 = _UInt___init__impl__l7qpdl(this_1);
    var tmp$ret$2 = new UInt(tmp$ret$1);
    destination.u(tmp$ret$2);
  }
  var keyUInts = destination;
  // Inline function 'kotlin.collections.buildList' call
  // Inline function 'kotlin.collections.buildListInternal' call
  // Inline function 'kotlin.apply' call
  var this_2 = ArrayList_init_$Create$_0();
  // Inline function 'com.lvcheng.lock.shared.nfc.kmp.CMD.KEY.<anonymous>' call
  this_2.u(new UInt(_UInt___init__impl__l7qpdl(2129921)));
  this_2.u(new UInt(nextUInt(Default_getInstance())));
  this_2.u(new UInt(_UInt___init__impl__l7qpdl(-1877993214)));
  this_2.r(keyUInts);
  this_2.u(new UInt(nextUInt(Default_getInstance())));
  this_2.u(new UInt(nextUInt(Default_getInstance())));
  var commandList = this_2.s3();
  var tmp = AESUtil_instance;
  var tmp_0 = get_lastIndex(commandList);
  var tmp_1 = 0;
  var tmp_2 = new Int8Array(16);
  while (tmp_1 < 16) {
    tmp_2[tmp_1] = 0;
    tmp_1 = tmp_1 + 1 | 0;
  }
  return tmp.yq(commandList, 1, tmp_0, eKey, tmp_2);
};
protoOf(CMD).pr = function (eKey) {
  var tmp = AESUtil_instance;
  var tmp_0 = listOf([new UInt(_UInt___init__impl__l7qpdl(1081345)), new UInt(nextUInt(Default_getInstance())), new UInt(_UInt___init__impl__l7qpdl(269490435)), new UInt(nextUInt(Default_getInstance())), new UInt(nextUInt(Default_getInstance()))]);
  var tmp_1 = 0;
  var tmp_2 = new Int8Array(16);
  while (tmp_1 < 16) {
    tmp_2[tmp_1] = 0;
    tmp_1 = tmp_1 + 1 | 0;
  }
  return tmp.yq(tmp_0, 1, 4, eKey, tmp_2);
};
protoOf(CMD).qr = function (eKey) {
  var tmp = AESUtil_instance;
  var tmp_0 = listOf([new UInt(_UInt___init__impl__l7qpdl(1081345)), new UInt(nextUInt(Default_getInstance())), new UInt(_UInt___init__impl__l7qpdl(-2029774591)), new UInt(_UInt___init__impl__l7qpdl(-2100227354)), new UInt(nextUInt(Default_getInstance()))]);
  var tmp_1 = 0;
  var tmp_2 = new Int8Array(16);
  while (tmp_1 < 16) {
    tmp_2[tmp_1] = 0;
    tmp_1 = tmp_1 + 1 | 0;
  }
  return tmp.yq(tmp_0, 1, 4, eKey, tmp_2);
};
protoOf(CMD).rr = function (eKey) {
  var tmp = AESUtil_instance;
  var tmp_0 = listOf([new UInt(_UInt___init__impl__l7qpdl(1081345)), new UInt(nextUInt(Default_getInstance())), new UInt(_UInt___init__impl__l7qpdl(84017169)), new UInt(nextUInt(Default_getInstance())), new UInt(nextUInt(Default_getInstance()))]);
  var tmp_1 = 0;
  var tmp_2 = new Int8Array(16);
  while (tmp_1 < 16) {
    tmp_2[tmp_1] = 0;
    tmp_1 = tmp_1 + 1 | 0;
  }
  return tmp.yq(tmp_0, 1, 4, eKey, tmp_2);
};
protoOf(CMD).sr = function (eKey) {
  var tmp = AESUtil_instance;
  var tmp_0 = listOf([new UInt(_UInt___init__impl__l7qpdl(1081345)), new UInt(nextUInt(Default_getInstance())), new UInt(_UInt___init__impl__l7qpdl(84017168)), new UInt(nextUInt(Default_getInstance())), new UInt(nextUInt(Default_getInstance()))]);
  var tmp_1 = 0;
  var tmp_2 = new Int8Array(16);
  while (tmp_1 < 16) {
    tmp_2[tmp_1] = 0;
    tmp_1 = tmp_1 + 1 | 0;
  }
  return tmp.yq(tmp_0, 1, 4, eKey, tmp_2);
};
protoOf(CMD).tr = function (eKey, ctrl) {
  var tmp = AESUtil_instance;
  var tmp_0 = _UInt___init__impl__l7qpdl(1081345);
  var tmp_1 = nextUInt(Default_getInstance());
  var tmp_2 = _UInt___init__impl__l7qpdl(-2097086175);
  // Inline function 'kotlin.UByte.toUInt' call
  // Inline function 'kotlin.UInt.shl' call
  var this_0 = _UInt___init__impl__l7qpdl(_UByte___get_data__impl__jof9qr(ctrl) & 255);
  var tmp5 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_0) << 24);
  // Inline function 'kotlin.UInt.shl' call
  var this_1 = _UInt___init__impl__l7qpdl(255);
  // Inline function 'kotlin.UInt.and' call
  var other = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_1) << 24);
  var tmp9 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp5) & _UInt___get_data__impl__f0vqqw(other));
  var tmp7 = nextUInt(Default_getInstance());
  // Inline function 'kotlin.UInt.and' call
  var other_0 = _UInt___init__impl__l7qpdl(16777215);
  // Inline function 'kotlin.UInt.plus' call
  var other_1 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp7) & _UInt___get_data__impl__f0vqqw(other_0));
  var tmp$ret$5 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp9) + _UInt___get_data__impl__f0vqqw(other_1) | 0);
  var tmp_3 = listOf([new UInt(tmp_0), new UInt(tmp_1), new UInt(tmp_2), new UInt(tmp$ret$5), new UInt(nextUInt(Default_getInstance()))]);
  var tmp_4 = 0;
  var tmp_5 = new Int8Array(16);
  while (tmp_4 < 16) {
    tmp_5[tmp_4] = 0;
    tmp_4 = tmp_4 + 1 | 0;
  }
  return tmp.yq(tmp_3, 1, 4, eKey, tmp_5);
};
protoOf(CMD).ur = function (eKey, ctrl) {
  var tmp = AESUtil_instance;
  var tmp_0 = _UInt___init__impl__l7qpdl(1081345);
  var tmp_1 = nextUInt(Default_getInstance());
  var tmp_2 = _UInt___init__impl__l7qpdl(-2097086176);
  // Inline function 'kotlin.UByte.toUInt' call
  // Inline function 'kotlin.UInt.shl' call
  var this_0 = _UInt___init__impl__l7qpdl(_UByte___get_data__impl__jof9qr(ctrl) & 255);
  var tmp5 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_0) << 24);
  // Inline function 'kotlin.UInt.shl' call
  var this_1 = _UInt___init__impl__l7qpdl(255);
  // Inline function 'kotlin.UInt.and' call
  var other = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_1) << 24);
  var tmp9 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp5) & _UInt___get_data__impl__f0vqqw(other));
  var tmp7 = nextUInt(Default_getInstance());
  // Inline function 'kotlin.UInt.and' call
  var other_0 = _UInt___init__impl__l7qpdl(16777215);
  // Inline function 'kotlin.UInt.plus' call
  var other_1 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp7) & _UInt___get_data__impl__f0vqqw(other_0));
  var tmp$ret$5 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp9) + _UInt___get_data__impl__f0vqqw(other_1) | 0);
  var tmp_3 = listOf([new UInt(tmp_0), new UInt(tmp_1), new UInt(tmp_2), new UInt(tmp$ret$5), new UInt(nextUInt(Default_getInstance()))]);
  var tmp_4 = 0;
  var tmp_5 = new Int8Array(16);
  while (tmp_4 < 16) {
    tmp_5[tmp_4] = 0;
    tmp_4 = tmp_4 + 1 | 0;
  }
  return tmp.yq(tmp_3, 1, 4, eKey, tmp_5);
};
protoOf(CMD).vr = function (eKey) {
  var tmp = AESUtil_instance;
  var tmp_0 = listOf([new UInt(_UInt___init__impl__l7qpdl(1081345)), new UInt(nextUInt(Default_getInstance())), new UInt(_UInt___init__impl__l7qpdl(50397217)), new UInt(nextUInt(Default_getInstance())), new UInt(nextUInt(Default_getInstance()))]);
  var tmp_1 = 0;
  var tmp_2 = new Int8Array(16);
  while (tmp_1 < 16) {
    tmp_2[tmp_1] = 0;
    tmp_1 = tmp_1 + 1 | 0;
  }
  return tmp.yq(tmp_0, 1, 4, eKey, tmp_2);
};
protoOf(CMD).wr = function (eKey, value) {
  var tmp = AESUtil_instance;
  var tmp_0 = _UInt___init__impl__l7qpdl(1081345);
  var tmp_1 = nextUInt(Default_getInstance());
  var tmp_2 = _UInt___init__impl__l7qpdl(-2097082368);
  // Inline function 'kotlin.UByte.toUInt' call
  // Inline function 'kotlin.UInt.shl' call
  var this_0 = _UInt___init__impl__l7qpdl(_UByte___get_data__impl__jof9qr(value) & 255);
  var tmp5 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_0) << 24);
  // Inline function 'kotlin.UInt.shl' call
  var this_1 = _UInt___init__impl__l7qpdl(255);
  // Inline function 'kotlin.UInt.and' call
  var other = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_1) << 24);
  var tmp9 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp5) & _UInt___get_data__impl__f0vqqw(other));
  var tmp7 = nextUInt(Default_getInstance());
  // Inline function 'kotlin.UInt.and' call
  var other_0 = _UInt___init__impl__l7qpdl(16777215);
  // Inline function 'kotlin.UInt.plus' call
  var other_1 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp7) & _UInt___get_data__impl__f0vqqw(other_0));
  var tmp$ret$5 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp9) + _UInt___get_data__impl__f0vqqw(other_1) | 0);
  var tmp_3 = listOf([new UInt(tmp_0), new UInt(tmp_1), new UInt(tmp_2), new UInt(tmp$ret$5), new UInt(nextUInt(Default_getInstance()))]);
  var tmp_4 = 0;
  var tmp_5 = new Int8Array(16);
  while (tmp_4 < 16) {
    tmp_5[tmp_4] = 0;
    tmp_4 = tmp_4 + 1 | 0;
  }
  return tmp.yq(tmp_3, 1, 4, eKey, tmp_5);
};
protoOf(CMD).xr = function (eKey, value) {
  var tmp = AESUtil_instance;
  var tmp_0 = _UInt___init__impl__l7qpdl(1081345);
  var tmp_1 = nextUInt(Default_getInstance());
  var tmp_2 = _UInt___init__impl__l7qpdl(-2063462399);
  // Inline function 'kotlin.UShort.toUInt' call
  // Inline function 'kotlin.UInt.shl' call
  var this_0 = _UInt___init__impl__l7qpdl(_UShort___get_data__impl__g0245(value) & 65535);
  var tmp5 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_0) << 16);
  // Inline function 'kotlin.UInt.shl' call
  var this_1 = _UInt___init__impl__l7qpdl(65535);
  // Inline function 'kotlin.UInt.and' call
  var other = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_1) << 16);
  var tmp9 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp5) & _UInt___get_data__impl__f0vqqw(other));
  var tmp7 = nextUInt(Default_getInstance());
  // Inline function 'kotlin.UInt.and' call
  var other_0 = _UInt___init__impl__l7qpdl(65535);
  // Inline function 'kotlin.UInt.plus' call
  var other_1 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp7) & _UInt___get_data__impl__f0vqqw(other_0));
  var tmp$ret$5 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp9) + _UInt___get_data__impl__f0vqqw(other_1) | 0);
  var tmp_3 = listOf([new UInt(tmp_0), new UInt(tmp_1), new UInt(tmp_2), new UInt(tmp$ret$5), new UInt(nextUInt(Default_getInstance()))]);
  var tmp_4 = 0;
  var tmp_5 = new Int8Array(16);
  while (tmp_4 < 16) {
    tmp_5[tmp_4] = 0;
    tmp_4 = tmp_4 + 1 | 0;
  }
  return tmp.yq(tmp_3, 1, 4, eKey, tmp_5);
};
protoOf(CMD).yr = function (eKey, value) {
  var tmp = AESUtil_instance;
  var tmp_0 = _UInt___init__impl__l7qpdl(1081345);
  var tmp_1 = nextUInt(Default_getInstance());
  var tmp_2 = _UInt___init__impl__l7qpdl(-2063462393);
  // Inline function 'kotlin.UShort.toUInt' call
  // Inline function 'kotlin.UInt.shl' call
  var this_0 = _UInt___init__impl__l7qpdl(_UShort___get_data__impl__g0245(value) & 65535);
  var tmp5 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_0) << 16);
  // Inline function 'kotlin.UInt.shl' call
  var this_1 = _UInt___init__impl__l7qpdl(65535);
  // Inline function 'kotlin.UInt.and' call
  var other = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_1) << 16);
  var tmp9 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp5) & _UInt___get_data__impl__f0vqqw(other));
  var tmp7 = nextUInt(Default_getInstance());
  // Inline function 'kotlin.UInt.and' call
  var other_0 = _UInt___init__impl__l7qpdl(65535);
  // Inline function 'kotlin.UInt.plus' call
  var other_1 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp7) & _UInt___get_data__impl__f0vqqw(other_0));
  var tmp$ret$5 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp9) + _UInt___get_data__impl__f0vqqw(other_1) | 0);
  var tmp_3 = listOf([new UInt(tmp_0), new UInt(tmp_1), new UInt(tmp_2), new UInt(tmp$ret$5), new UInt(nextUInt(Default_getInstance()))]);
  var tmp_4 = 0;
  var tmp_5 = new Int8Array(16);
  while (tmp_4 < 16) {
    tmp_5[tmp_4] = 0;
    tmp_4 = tmp_4 + 1 | 0;
  }
  return tmp.yq(tmp_3, 1, 4, eKey, tmp_5);
};
protoOf(CMD).zr = function (eKey, value) {
  var tmp = AESUtil_instance;
  var tmp_0 = _UInt___init__impl__l7qpdl(1081345);
  var tmp_1 = nextUInt(Default_getInstance());
  var tmp_2 = _UInt___init__impl__l7qpdl(-2063462394);
  // Inline function 'kotlin.UShort.toUInt' call
  // Inline function 'kotlin.UInt.shl' call
  var this_0 = _UInt___init__impl__l7qpdl(_UShort___get_data__impl__g0245(value) & 65535);
  var tmp5 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_0) << 16);
  // Inline function 'kotlin.UInt.shl' call
  var this_1 = _UInt___init__impl__l7qpdl(65535);
  // Inline function 'kotlin.UInt.and' call
  var other = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_1) << 16);
  var tmp9 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp5) & _UInt___get_data__impl__f0vqqw(other));
  var tmp7 = nextUInt(Default_getInstance());
  // Inline function 'kotlin.UInt.and' call
  var other_0 = _UInt___init__impl__l7qpdl(65535);
  // Inline function 'kotlin.UInt.plus' call
  var other_1 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp7) & _UInt___get_data__impl__f0vqqw(other_0));
  var tmp$ret$5 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp9) + _UInt___get_data__impl__f0vqqw(other_1) | 0);
  var tmp_3 = listOf([new UInt(tmp_0), new UInt(tmp_1), new UInt(tmp_2), new UInt(tmp$ret$5), new UInt(nextUInt(Default_getInstance()))]);
  var tmp_4 = 0;
  var tmp_5 = new Int8Array(16);
  while (tmp_4 < 16) {
    tmp_5[tmp_4] = 0;
    tmp_4 = tmp_4 + 1 | 0;
  }
  return tmp.yq(tmp_3, 1, 4, eKey, tmp_5);
};
protoOf(CMD).as = function (eKey, value) {
  var tmp = AESUtil_instance;
  var tmp_0 = _UInt___init__impl__l7qpdl(1081345);
  var tmp_1 = nextUInt(Default_getInstance());
  var tmp_2 = _UInt___init__impl__l7qpdl(-2063462398);
  // Inline function 'kotlin.UShort.toUInt' call
  // Inline function 'kotlin.UInt.shl' call
  var this_0 = _UInt___init__impl__l7qpdl(_UShort___get_data__impl__g0245(value) & 65535);
  var tmp5 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_0) << 16);
  // Inline function 'kotlin.UInt.shl' call
  var this_1 = _UInt___init__impl__l7qpdl(65535);
  // Inline function 'kotlin.UInt.and' call
  var other = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_1) << 16);
  var tmp9 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp5) & _UInt___get_data__impl__f0vqqw(other));
  var tmp7 = nextUInt(Default_getInstance());
  // Inline function 'kotlin.UInt.and' call
  var other_0 = _UInt___init__impl__l7qpdl(65535);
  // Inline function 'kotlin.UInt.plus' call
  var other_1 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp7) & _UInt___get_data__impl__f0vqqw(other_0));
  var tmp$ret$5 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp9) + _UInt___get_data__impl__f0vqqw(other_1) | 0);
  var tmp_3 = listOf([new UInt(tmp_0), new UInt(tmp_1), new UInt(tmp_2), new UInt(tmp$ret$5), new UInt(nextUInt(Default_getInstance()))]);
  var tmp_4 = 0;
  var tmp_5 = new Int8Array(16);
  while (tmp_4 < 16) {
    tmp_5[tmp_4] = 0;
    tmp_4 = tmp_4 + 1 | 0;
  }
  return tmp.yq(tmp_3, 1, 4, eKey, tmp_5);
};
protoOf(CMD).bs = function (eKey, value) {
  var tmp = AESUtil_instance;
  var tmp_0 = _UInt___init__impl__l7qpdl(1081345);
  var tmp_1 = nextUInt(Default_getInstance());
  var tmp_2 = _UInt___init__impl__l7qpdl(-2063462397);
  // Inline function 'kotlin.UShort.toUInt' call
  // Inline function 'kotlin.UInt.shl' call
  var this_0 = _UInt___init__impl__l7qpdl(_UShort___get_data__impl__g0245(value) & 65535);
  var tmp5 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_0) << 16);
  // Inline function 'kotlin.UInt.shl' call
  var this_1 = _UInt___init__impl__l7qpdl(65535);
  // Inline function 'kotlin.UInt.and' call
  var other = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_1) << 16);
  var tmp9 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp5) & _UInt___get_data__impl__f0vqqw(other));
  var tmp7 = nextUInt(Default_getInstance());
  // Inline function 'kotlin.UInt.and' call
  var other_0 = _UInt___init__impl__l7qpdl(65535);
  // Inline function 'kotlin.UInt.plus' call
  var other_1 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp7) & _UInt___get_data__impl__f0vqqw(other_0));
  var tmp$ret$5 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp9) + _UInt___get_data__impl__f0vqqw(other_1) | 0);
  var tmp_3 = listOf([new UInt(tmp_0), new UInt(tmp_1), new UInt(tmp_2), new UInt(tmp$ret$5), new UInt(nextUInt(Default_getInstance()))]);
  var tmp_4 = 0;
  var tmp_5 = new Int8Array(16);
  while (tmp_4 < 16) {
    tmp_5[tmp_4] = 0;
    tmp_4 = tmp_4 + 1 | 0;
  }
  return tmp.yq(tmp_3, 1, 4, eKey, tmp_5);
};
protoOf(CMD).cs = function (eKey, value) {
  var tmp = AESUtil_instance;
  var tmp_0 = _UInt___init__impl__l7qpdl(1081345);
  var tmp_1 = nextUInt(Default_getInstance());
  var tmp_2 = _UInt___init__impl__l7qpdl(-2063462396);
  // Inline function 'kotlin.UShort.toUInt' call
  // Inline function 'kotlin.UInt.shl' call
  var this_0 = _UInt___init__impl__l7qpdl(_UShort___get_data__impl__g0245(value) & 65535);
  var tmp5 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_0) << 16);
  // Inline function 'kotlin.UInt.shl' call
  var this_1 = _UInt___init__impl__l7qpdl(65535);
  // Inline function 'kotlin.UInt.and' call
  var other = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_1) << 16);
  var tmp9 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp5) & _UInt___get_data__impl__f0vqqw(other));
  var tmp7 = nextUInt(Default_getInstance());
  // Inline function 'kotlin.UInt.and' call
  var other_0 = _UInt___init__impl__l7qpdl(65535);
  // Inline function 'kotlin.UInt.plus' call
  var other_1 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp7) & _UInt___get_data__impl__f0vqqw(other_0));
  var tmp$ret$5 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp9) + _UInt___get_data__impl__f0vqqw(other_1) | 0);
  var tmp_3 = listOf([new UInt(tmp_0), new UInt(tmp_1), new UInt(tmp_2), new UInt(tmp$ret$5), new UInt(nextUInt(Default_getInstance()))]);
  var tmp_4 = 0;
  var tmp_5 = new Int8Array(16);
  while (tmp_4 < 16) {
    tmp_5[tmp_4] = 0;
    tmp_4 = tmp_4 + 1 | 0;
  }
  return tmp.yq(tmp_3, 1, 4, eKey, tmp_5);
};
protoOf(CMD).ds = function (eKey, value) {
  var tmp = AESUtil_instance;
  var tmp_0 = _UInt___init__impl__l7qpdl(1081345);
  var tmp_1 = nextUInt(Default_getInstance());
  var tmp_2 = _UInt___init__impl__l7qpdl(-2063462395);
  // Inline function 'kotlin.UShort.toUInt' call
  // Inline function 'kotlin.UInt.shl' call
  var this_0 = _UInt___init__impl__l7qpdl(_UShort___get_data__impl__g0245(value) & 65535);
  var tmp5 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_0) << 16);
  // Inline function 'kotlin.UInt.shl' call
  var this_1 = _UInt___init__impl__l7qpdl(65535);
  // Inline function 'kotlin.UInt.and' call
  var other = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_1) << 16);
  var tmp9 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp5) & _UInt___get_data__impl__f0vqqw(other));
  var tmp7 = nextUInt(Default_getInstance());
  // Inline function 'kotlin.UInt.and' call
  var other_0 = _UInt___init__impl__l7qpdl(65535);
  // Inline function 'kotlin.UInt.plus' call
  var other_1 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp7) & _UInt___get_data__impl__f0vqqw(other_0));
  var tmp$ret$5 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp9) + _UInt___get_data__impl__f0vqqw(other_1) | 0);
  var tmp_3 = listOf([new UInt(tmp_0), new UInt(tmp_1), new UInt(tmp_2), new UInt(tmp$ret$5), new UInt(nextUInt(Default_getInstance()))]);
  var tmp_4 = 0;
  var tmp_5 = new Int8Array(16);
  while (tmp_4 < 16) {
    tmp_5[tmp_4] = 0;
    tmp_4 = tmp_4 + 1 | 0;
  }
  return tmp.yq(tmp_3, 1, 4, eKey, tmp_5);
};
protoOf(CMD).es = function (eKey) {
  var tmp = AESUtil_instance;
  var tmp_0 = listOf([new UInt(_UInt___init__impl__l7qpdl(1081345)), new UInt(nextUInt(Default_getInstance())), new UInt(_UInt___init__impl__l7qpdl(84023312)), new UInt(nextUInt(Default_getInstance())), new UInt(nextUInt(Default_getInstance()))]);
  var tmp_1 = 0;
  var tmp_2 = new Int8Array(16);
  while (tmp_1 < 16) {
    tmp_2[tmp_1] = 0;
    tmp_1 = tmp_1 + 1 | 0;
  }
  return tmp.yq(tmp_0, 1, 4, eKey, tmp_2);
};
protoOf(CMD).fs = function (eKey, index) {
  var tmp = AESUtil_instance;
  var tmp_0 = _UInt___init__impl__l7qpdl(1081345);
  var tmp_1 = nextUInt(Default_getInstance());
  var tmp_2 = _UInt___init__impl__l7qpdl(-2063460335);
  // Inline function 'kotlin.UShort.toUInt' call
  // Inline function 'kotlin.UInt.shl' call
  var this_0 = _UInt___init__impl__l7qpdl(_UShort___get_data__impl__g0245(index) & 65535);
  var tmp5 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_0) << 16);
  // Inline function 'kotlin.UInt.shl' call
  var this_1 = _UInt___init__impl__l7qpdl(65535);
  // Inline function 'kotlin.UInt.and' call
  var other = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_1) << 16);
  var tmp9 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp5) & _UInt___get_data__impl__f0vqqw(other));
  var tmp7 = nextUInt(Default_getInstance());
  // Inline function 'kotlin.UInt.and' call
  var other_0 = _UInt___init__impl__l7qpdl(65535);
  // Inline function 'kotlin.UInt.plus' call
  var other_1 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp7) & _UInt___get_data__impl__f0vqqw(other_0));
  var tmp$ret$5 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp9) + _UInt___get_data__impl__f0vqqw(other_1) | 0);
  var tmp_3 = listOf([new UInt(tmp_0), new UInt(tmp_1), new UInt(tmp_2), new UInt(tmp$ret$5), new UInt(nextUInt(Default_getInstance()))]);
  var tmp_4 = 0;
  var tmp_5 = new Int8Array(16);
  while (tmp_4 < 16) {
    tmp_5[tmp_4] = 0;
    tmp_4 = tmp_4 + 1 | 0;
  }
  return tmp.yq(tmp_3, 1, 4, eKey, tmp_5);
};
protoOf(CMD).gs = function (eKey) {
  var tmp = AESUtil_instance;
  var tmp_0 = listOf([new UInt(_UInt___init__impl__l7qpdl(1081345)), new UInt(nextUInt(Default_getInstance())), new UInt(_UInt___init__impl__l7qpdl(134748179)), new UInt(nextUInt(Default_getInstance())), new UInt(nextUInt(Default_getInstance()))]);
  var tmp_1 = 0;
  var tmp_2 = new Int8Array(16);
  while (tmp_1 < 16) {
    tmp_2[tmp_1] = 0;
    tmp_1 = tmp_1 + 1 | 0;
  }
  return tmp.yq(tmp_0, 1, 4, eKey, tmp_2);
};
protoOf(CMD).hs = function (eKey) {
  var tmp = AESUtil_instance;
  var tmp_0 = listOf([new UInt(_UInt___init__impl__l7qpdl(1081345)), new UInt(nextUInt(Default_getInstance())), new UInt(_UInt___init__impl__l7qpdl(287840276)), new UInt(nextUInt(Default_getInstance())), new UInt(nextUInt(Default_getInstance()))]);
  var tmp_1 = 0;
  var tmp_2 = new Int8Array(16);
  while (tmp_1 < 16) {
    tmp_2[tmp_1] = 0;
    tmp_1 = tmp_1 + 1 | 0;
  }
  return tmp.yq(tmp_0, 1, 4, eKey, tmp_2);
};
protoOf(CMD).is = function (eKey) {
  var tmp = AESUtil_instance;
  var tmp_0 = listOf([new UInt(_UInt___init__impl__l7qpdl(1081345)), new UInt(nextUInt(Default_getInstance())), new UInt(_UInt___init__impl__l7qpdl(117708818)), new UInt(nextUInt(Default_getInstance())), new UInt(nextUInt(Default_getInstance()))]);
  var tmp_1 = 0;
  var tmp_2 = new Int8Array(16);
  while (tmp_1 < 16) {
    tmp_2[tmp_1] = 0;
    tmp_1 = tmp_1 + 1 | 0;
  }
  return tmp.yq(tmp_0, 1, 4, eKey, tmp_2);
};
var CMD_instance;
function CMD_getInstance() {
  return CMD_instance;
}
function ChargeLevel(level, complete) {
  this.js_1 = level;
  this.ks_1 = complete;
}
protoOf(ChargeLevel).toString = function () {
  return 'ChargeLevel(level=' + new UShort(this.js_1) + ', complete=' + this.ks_1 + ')';
};
protoOf(ChargeLevel).hashCode = function () {
  var result = UShort__hashCode_impl_ywngrv(this.js_1);
  result = imul(result, 31) + getBooleanHashCode(this.ks_1) | 0;
  return result;
};
protoOf(ChargeLevel).equals = function (other) {
  if (this === other)
    return true;
  if (!(other instanceof ChargeLevel))
    return false;
  var tmp0_other_with_cast = other instanceof ChargeLevel ? other : THROW_CCE();
  if (!(this.js_1 === tmp0_other_with_cast.js_1))
    return false;
  if (!(this.ks_1 === tmp0_other_with_cast.ks_1))
    return false;
  return true;
};
function ControlProgress(progress, complete) {
  this.ls_1 = progress;
  this.ms_1 = complete;
}
protoOf(ControlProgress).toString = function () {
  return 'ControlProgress(progress=' + new UShort(this.ls_1) + ', complete=' + this.ms_1 + ')';
};
protoOf(ControlProgress).hashCode = function () {
  var result = UShort__hashCode_impl_ywngrv(this.ls_1);
  result = imul(result, 31) + getBooleanHashCode(this.ms_1) | 0;
  return result;
};
protoOf(ControlProgress).equals = function (other) {
  if (this === other)
    return true;
  if (!(other instanceof ControlProgress))
    return false;
  var tmp0_other_with_cast = other instanceof ControlProgress ? other : THROW_CCE();
  if (!(this.ls_1 === tmp0_other_with_cast.ls_1))
    return false;
  if (!(this.ms_1 === tmp0_other_with_cast.ms_1))
    return false;
  return true;
};
function Device(s) {
  this.ns_1 = s;
}
protoOf(Device).toString = function () {
  return 'Device(s=' + new UInt(this.ns_1) + ')';
};
protoOf(Device).hashCode = function () {
  return UInt__hashCode_impl_z2mhuw(this.ns_1);
};
protoOf(Device).equals = function (other) {
  if (this === other)
    return true;
  if (!(other instanceof Device))
    return false;
  var tmp0_other_with_cast = other instanceof Device ? other : THROW_CCE();
  if (!(this.ns_1 === tmp0_other_with_cast.ns_1))
    return false;
  return true;
};
function DeviceInfo(id, isNew) {
  this.os_1 = id;
  this.ps_1 = isNew;
}
protoOf(DeviceInfo).toString = function () {
  return 'DeviceInfo(id=' + new ULong(this.os_1) + ', isNew=' + this.ps_1 + ')';
};
protoOf(DeviceInfo).hashCode = function () {
  var result = ULong__hashCode_impl_6hv2lb(this.os_1);
  result = imul(result, 31) + getBooleanHashCode(this.ps_1) | 0;
  return result;
};
protoOf(DeviceInfo).equals = function (other) {
  if (this === other)
    return true;
  if (!(other instanceof DeviceInfo))
    return false;
  var tmp0_other_with_cast = other instanceof DeviceInfo ? other : THROW_CCE();
  if (!equals(this.os_1, tmp0_other_with_cast.os_1))
    return false;
  if (!(this.ps_1 === tmp0_other_with_cast.ps_1))
    return false;
  return true;
};
function DeviceLog(timestamp, username, ctrl) {
  this.qs_1 = timestamp;
  this.rs_1 = username;
  this.ss_1 = ctrl;
}
protoOf(DeviceLog).toString = function () {
  return 'DeviceLog(timestamp=' + new ULong(this.qs_1) + ', username=' + this.rs_1 + ', ctrl=' + toString_0(this.ss_1) + ')';
};
protoOf(DeviceLog).hashCode = function () {
  var result = ULong__hashCode_impl_6hv2lb(this.qs_1);
  result = imul(result, 31) + getStringHashCode(this.rs_1) | 0;
  result = imul(result, 31) + (this.ss_1 == null ? 0 : this.ss_1.hashCode()) | 0;
  return result;
};
protoOf(DeviceLog).equals = function (other) {
  if (this === other)
    return true;
  if (!(other instanceof DeviceLog))
    return false;
  var tmp0_other_with_cast = other instanceof DeviceLog ? other : THROW_CCE();
  if (!equals(this.qs_1, tmp0_other_with_cast.qs_1))
    return false;
  if (!(this.rs_1 === tmp0_other_with_cast.rs_1))
    return false;
  if (!equals(this.ss_1, tmp0_other_with_cast.ss_1))
    return false;
  return true;
};
function transAndCheckResult($this, t, d, contents, readSize, callback, $completion) {
  var tmp = new $transAndCheckResultCOROUTINE$2($this, t, d, contents, readSize, callback, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  return tmp.k6();
}
function DeviceManager$getInfo$lambda($id, $isNew) {
  return function (res, idx) {
    var tmp;
    if (idx === 0) {
      // Inline function 'kotlin.UInt.toULong' call
      var this_0 = res.t(2).nd_1;
      // Inline function 'kotlin.uintToULong' call
      // Inline function 'kotlin.uintToLong' call
      var value = _UInt___get_data__impl__f0vqqw(this_0);
      var tmp$ret$0 = toLong(value).c2(new Long(-1, 0));
      // Inline function 'kotlin.ULong.shl' call
      var this_1 = _ULong___init__impl__c78o9k(tmp$ret$0);
      var tmp4 = _ULong___init__impl__c78o9k(_ULong___get_data__impl__fggpzb(this_1).a2(32));
      // Inline function 'kotlin.UInt.toULong' call
      var this_2 = res.t(3).nd_1;
      // Inline function 'kotlin.uintToULong' call
      // Inline function 'kotlin.uintToLong' call
      var value_0 = _UInt___get_data__impl__f0vqqw(this_2);
      var tmp$ret$4 = toLong(value_0).c2(new Long(-1, 0));
      // Inline function 'kotlin.ULong.or' call
      var other = _ULong___init__impl__c78o9k(tmp$ret$4);
      var tmp$ret$7 = _ULong___init__impl__c78o9k(_ULong___get_data__impl__fggpzb(tmp4).d2(_ULong___get_data__impl__fggpzb(other)));
      $id._v = new ULong(tmp$ret$7);
      tmp = Unit_instance;
    } else if (idx === 1) {
      // Inline function 'kotlin.UInt.shr' call
      var this_3 = res.t(2).nd_1;
      var tmp$ret$8 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_3) >>> 24 | 0);
      $isNew._v = tmp$ret$8 === _UInt___init__impl__l7qpdl(0);
      tmp = Unit_instance;
    }
    return true;
  };
}
function DeviceManager$select$lambda(_unused_var__etf5q3, _unused_var__etf5q3_0) {
  return true;
}
function DeviceManager$getVersion$lambda($key, $versionCodeList) {
  return function (res, _unused_var__etf5q3) {
    var tmp = AESUtil_instance;
    var tmp_0 = get_lastIndex(res);
    var tmp_1 = toByteArray(slice($key, numberRangeToNumber(0, 15)));
    var tmp_2 = 0;
    var tmp_3 = new Int8Array(16);
    while (tmp_2 < 16) {
      tmp_3[tmp_2] = 0;
      tmp_2 = tmp_2 + 1 | 0;
    }
    var decrypted = tmp.gr(res, 0, tmp_0, tmp_1, tmp_3);
    var version = decrypted.t(2).nd_1;
    // Inline function 'kotlin.UInt.shr' call
    var v1 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(version) >>> 24 | 0);
    // Inline function 'kotlin.UInt.shl' call
    // Inline function 'kotlin.UInt.shr' call
    var this_0 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(version) << 8);
    var v2 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_0) >>> 24 | 0);
    // Inline function 'kotlin.UInt.shl' call
    // Inline function 'kotlin.UInt.shr' call
    var this_1 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(version) << 16);
    var v3 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_1) >>> 24 | 0);
    // Inline function 'kotlin.UInt.shl' call
    // Inline function 'kotlin.UInt.shr' call
    var this_2 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(version) << 24);
    var v4 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_2) >>> 24 | 0);
    $versionCodeList._v = listOf([new UInt(v1), new UInt(v2), new UInt(v3), new UInt(v4)]);
    return true;
  };
}
function DeviceManager$setKey$lambda($sKey, $key, $info) {
  return function (res, idx) {
    var tmp;
    if (idx === 3) {
      var tmp_0 = AESUtil_instance;
      var tmp_1 = get_lastIndex(res);
      var tmp_2 = toByteArray(slice($sKey, numberRangeToNumber(0, 15)));
      var tmp_3 = 0;
      var tmp_4 = new Int8Array(16);
      while (tmp_3 < 16) {
        tmp_4[tmp_3] = 0;
        tmp_3 = tmp_3 + 1 | 0;
      }
      var decrypted1 = tmp_0.gr(res, 0, tmp_1, tmp_2, tmp_4);
      var tmp_5 = AESUtil_instance;
      var tmp_6 = toByteArray(slice($key, numberRangeToNumber(0, 15)));
      var tmp_7 = 0;
      var tmp_8 = new Int8Array(16);
      while (tmp_7 < 16) {
        tmp_8[tmp_7] = 0;
        tmp_7 = tmp_7 + 1 | 0;
      }
      var decrypted2 = tmp_5.gr(decrypted1, 2, 5, tmp_6, tmp_8);
      // Inline function 'kotlin.UInt.toULong' call
      var this_0 = decrypted2.t(2).nd_1;
      // Inline function 'kotlin.uintToULong' call
      // Inline function 'kotlin.uintToLong' call
      var value = _UInt___get_data__impl__f0vqqw(this_0);
      var tmp$ret$2 = toLong(value).c2(new Long(-1, 0));
      // Inline function 'kotlin.ULong.shl' call
      var this_1 = _ULong___init__impl__c78o9k(tmp$ret$2);
      var tmp4 = _ULong___init__impl__c78o9k(_ULong___get_data__impl__fggpzb(this_1).a2(32));
      // Inline function 'kotlin.UInt.toULong' call
      var this_2 = decrypted2.t(3).nd_1;
      // Inline function 'kotlin.uintToULong' call
      // Inline function 'kotlin.uintToLong' call
      var value_0 = _UInt___get_data__impl__f0vqqw(this_2);
      var tmp$ret$6 = toLong(value_0).c2(new Long(-1, 0));
      // Inline function 'kotlin.ULong.or' call
      var other = _ULong___init__impl__c78o9k(tmp$ret$6);
      var id = _ULong___init__impl__c78o9k(_ULong___get_data__impl__fggpzb(tmp4).d2(_ULong___get_data__impl__fggpzb(other)));
      tmp = equals(id, $info.os_1);
    } else {
      tmp = true;
    }
    return tmp;
  };
}
function DeviceManager$setKey$lambda_0(_unused_var__etf5q3, _unused_var__etf5q3_0) {
  return true;
}
function DeviceManager$getChargeLevel$lambda($key, $threshold, $raw) {
  return function (res, idx) {
    var tmp = AESUtil_instance;
    var tmp_0 = get_lastIndex(res);
    var tmp_1 = toByteArray(slice($key, numberRangeToNumber(0, 15)));
    var tmp_2 = 0;
    var tmp_3 = new Int8Array(16);
    while (tmp_2 < 16) {
      tmp_3[tmp_2] = 0;
      tmp_2 = tmp_2 + 1 | 0;
    }
    var decrypted = tmp.gr(res, 0, tmp_0, tmp_1, tmp_3);
    var tmp_4;
    if (idx === 0) {
      // Inline function 'kotlin.UInt.shr' call
      var this_0 = decrypted.t(2).nd_1;
      var tmp$ret$1 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_0) >>> 16 | 0);
      $threshold._v = new UInt(tmp$ret$1);
      tmp_4 = Unit_instance;
    } else if (idx === 1) {
      // Inline function 'kotlin.UInt.shr' call
      var this_1 = decrypted.t(2).nd_1;
      var tmp$ret$2 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_1) >>> 16 | 0);
      $raw._v = new UInt(tmp$ret$2);
      tmp_4 = Unit_instance;
    }
    return true;
  };
}
function DeviceManager$control$lambda(_unused_var__etf5q3, _unused_var__etf5q3_0) {
  return true;
}
function DeviceManager$getControlProgress$lambda($key, $progress) {
  return function (res, idx) {
    var tmp = AESUtil_instance;
    var tmp_0 = get_lastIndex(res);
    var tmp_1 = toByteArray(slice($key, numberRangeToNumber(0, 15)));
    var tmp_2 = 0;
    var tmp_3 = new Int8Array(16);
    while (tmp_2 < 16) {
      tmp_3[tmp_2] = 0;
      tmp_2 = tmp_2 + 1 | 0;
    }
    var decrypted = tmp.gr(res, 0, tmp_0, tmp_1, tmp_3);
    var tmp_4;
    if (idx === 0) {
      // Inline function 'kotlin.UInt.shr' call
      var this_0 = decrypted.t(2).nd_1;
      var tmp$ret$1 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_0) >>> 24 | 0);
      $progress._v = new UInt(tmp$ret$1);
      tmp_4 = Unit_instance;
    }
    return true;
  };
}
function DeviceManager$setParameters$lambda(_unused_var__etf5q3, _unused_var__etf5q3_0) {
  return true;
}
function DeviceManager$getLog$lambda($key, $count) {
  return function (res, idx) {
    var tmp;
    if (idx === 0) {
      var tmp_0 = AESUtil_instance;
      var tmp_1 = get_lastIndex(res);
      var tmp_2 = toByteArray(slice($key, numberRangeToNumber(0, 15)));
      var tmp_3 = 0;
      var tmp_4 = new Int8Array(16);
      while (tmp_3 < 16) {
        tmp_4[tmp_3] = 0;
        tmp_3 = tmp_3 + 1 | 0;
      }
      var decrypted = tmp_0.gr(res, 0, tmp_1, tmp_2, tmp_4);
      // Inline function 'kotlin.UInt.shr' call
      var this_0 = decrypted.t(2).nd_1;
      var tmp$ret$1 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_0) >>> 16 | 0);
      $count._v = new UInt(tmp$ret$1);
      tmp = Unit_instance;
    }
    return true;
  };
}
function DeviceManager$getLog$lambda_0($key, $timestamp, $username, $ctrl) {
  return function (res, idx) {
    var tmp;
    if (idx > 0) {
      var tmp_0 = AESUtil_instance;
      var tmp_1 = get_lastIndex(res);
      var tmp_2 = toByteArray(slice($key, numberRangeToNumber(0, 15)));
      var tmp_3 = 0;
      var tmp_4 = new Int8Array(16);
      while (tmp_3 < 16) {
        tmp_4[tmp_3] = 0;
        tmp_3 = tmp_3 + 1 | 0;
      }
      var decrypted = tmp_0.gr(res, 0, tmp_1, tmp_2, tmp_4);
      if (idx === 1) {
        // Inline function 'kotlin.UInt.toULong' call
        var this_0 = decrypted.t(2).nd_1;
        // Inline function 'kotlin.uintToULong' call
        // Inline function 'kotlin.uintToLong' call
        var value = _UInt___get_data__impl__f0vqqw(this_0);
        var tmp$ret$1 = toLong(value).c2(new Long(-1, 0));
        // Inline function 'kotlin.ULong.shl' call
        var this_1 = _ULong___init__impl__c78o9k(tmp$ret$1);
        var tmp4 = _ULong___init__impl__c78o9k(_ULong___get_data__impl__fggpzb(this_1).a2(32));
        // Inline function 'kotlin.UInt.toULong' call
        var this_2 = decrypted.t(3).nd_1;
        // Inline function 'kotlin.uintToULong' call
        // Inline function 'kotlin.uintToLong' call
        var value_0 = _UInt___get_data__impl__f0vqqw(this_2);
        var tmp$ret$5 = toLong(value_0).c2(new Long(-1, 0));
        // Inline function 'kotlin.ULong.or' call
        var other = _ULong___init__impl__c78o9k(tmp$ret$5);
        var tmp$ret$8 = _ULong___init__impl__c78o9k(_ULong___get_data__impl__fggpzb(tmp4).d2(_ULong___get_data__impl__fggpzb(other)));
        $timestamp._v = new ULong(tmp$ret$8);
      }
      if (idx === 2) {
        // Inline function 'kotlin.UInt.shl' call
        var this_3 = decrypted.t(1).nd_1;
        // Inline function 'kotlin.UInt.shr' call
        var this_4 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_3) << 8);
        var length = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_4) >>> 24 | 0);
        // Inline function 'kotlin.collections.asIterable' call
        // Inline function 'kotlin.collections.map' call
        var this_5 = slice_0(decrypted, until(2, decrypted.n()));
        // Inline function 'kotlin.collections.mapTo' call
        var destination = ArrayList_init_$Create$(collectionSizeOrDefault(this_5, 10));
        var _iterator__ex2g4s = this_5.k();
        while (_iterator__ex2g4s.l()) {
          var item = _iterator__ex2g4s.m();
          // Inline function 'com.lvcheng.lock.shared.nfc.kmp.DeviceManager.getLog.<anonymous>.<anonymous>' call
          var it = item.nd_1;
          var tmp_5 = Companion_instance.zq(4);
          // Inline function 'kotlin.UInt.toInt' call
          var tmp$ret$12 = _UInt___get_data__impl__f0vqqw(it);
          var tmp$ret$13 = tmp_5.cr(tmp$ret$12).dr();
          destination.u(tmp$ret$13);
        }
        // Inline function 'kotlin.byteArrayOf' call
        // Inline function 'kotlin.collections.fold' call
        var accumulator = new Int8Array([]);
        var _iterator__ex2g4s_0 = destination.k();
        while (_iterator__ex2g4s_0.l()) {
          var element = _iterator__ex2g4s_0.m();
          // Inline function 'com.lvcheng.lock.shared.nfc.kmp.DeviceManager.getLog.<anonymous>.<anonymous>' call
          // Inline function 'kotlin.collections.plus' call
          var this_6 = accumulator;
          accumulator = primitiveArrayConcat([this_6, element]);
        }
        var bytes = accumulator;
        // Inline function 'kotlin.UInt.toInt' call
        var tmp$ret$20 = _UInt___get_data__impl__f0vqqw(length);
        var validBytes = sliceArray(bytes, until(0, tmp$ret$20));
        $username._v = decodeToString(validBytes);
      }
      var tmp_6;
      if (idx === 3) {
        var tmp_7 = Companion_instance_0;
        // Inline function 'kotlin.UInt.toUByte' call
        var this_7 = decrypted.t(2).nd_1;
        // Inline function 'kotlin.toUByte' call
        var this_8 = _UInt___get_data__impl__f0vqqw(this_7);
        var tmp$ret$22 = _UByte___init__impl__g9hnc4(toByte(this_8));
        $ctrl._v = tmp_7.vt(tmp$ret$22);
        tmp_6 = Unit_instance;
      }
      tmp = tmp_6;
    }
    return true;
  };
}
function $callCOROUTINE$0(_this__u8e3s4, t, d, idx, content, readSize, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.eu_1 = _this__u8e3s4;
  this.fu_1 = t;
  this.gu_1 = d;
  this.hu_1 = idx;
  this.iu_1 = content;
  this.ju_1 = readSize;
}
protoOf($callCOROUTINE$0).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 4;
          this.c6_1 = 1;
          suspendResult = NFCUtil_instance.ku(this.fu_1, this.gu_1.ns_1, this.hu_1, this.iu_1, this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 1:
          if (suspendResult) {
            this.c6_1 = 2;
            suspendResult = NFCUtil_instance.lu(this.fu_1, this.gu_1.ns_1, this.ju_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }
            continue $sm;
          } else {
            this.c6_1 = 3;
            continue $sm;
          }

        case 2:
          var res = suspendResult;
          if (!(res == null)) {
            return new Pair(Result_OK_getInstance(), res);
          }

          this.c6_1 = 3;
          continue $sm;
        case 3:
          return new Pair(Result_ERROR_getInstance(), null);
        case 4:
          throw this.f6_1;
      }
    } catch ($p) {
      var e = $p;
      if (this.d6_1 === 4) {
        throw e;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e;
      }
    }
   while (true);
};
function $transAndCheckResultCOROUTINE$2(_this__u8e3s4, t, d, contents, readSize, callback, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.bt_1 = _this__u8e3s4;
  this.ct_1 = t;
  this.dt_1 = d;
  this.et_1 = contents;
  this.ft_1 = readSize;
  this.gt_1 = callback;
}
protoOf($transAndCheckResultCOROUTINE$2).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 5;
          var tmp_0 = this;
          tmp_0.ht_1 = withIndex(this.et_1);
          var tmp_1 = this;
          tmp_1.it_1 = Result_OK_getInstance();
          this.jt_1 = this.ht_1;
          this.kt_1 = this.it_1;
          this.lt_1 = this.kt_1;
          this.mt_1 = this.jt_1.k();
          this.c6_1 = 1;
          continue $sm;
        case 1:
          if (!this.mt_1.l()) {
            this.c6_1 = 4;
            continue $sm;
          }

          this.nt_1 = this.mt_1.m();
          var tmp_2 = this;
          tmp_2.ot_1 = this.lt_1;
          var tmp_3 = this;
          tmp_3.pt_1 = this.nt_1;
          this.qt_1 = this.ot_1;
          this.rt_1 = this.pt_1;
          this.st_1 = this.rt_1.v9();
          this.tt_1 = this.rt_1.w9();
          if (this.qt_1.equals(Result_OK_getInstance())) {
            this.c6_1 = 2;
            var tmp_4 = DeviceManager_instance;
            var tmp_5 = _UByte___init__impl__g9hnc4(0);
            var tmp0 = this.ft_1;
            var other = _UInt___init__impl__l7qpdl(2);
            suspendResult = tmp_4.mu(this.ct_1, this.dt_1, tmp_5, this.tt_1, _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp0) + _UInt___get_data__impl__f0vqqw(other) | 0), this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }
            continue $sm;
          } else {
            var tmp_6 = this;
            tmp_6.ut_1 = this.qt_1;
            this.c6_1 = 3;
            continue $sm;
          }

        case 2:
          var _destruct__k2r9zo = suspendResult;
          var result = _destruct__k2r9zo.v9();
          var data = _destruct__k2r9zo.w9();
          var tmp_7 = this;
          var tmp_8;
          if (result.equals(Result_OK_getInstance()) && !(data == null)) {
            var tmp_9;
            var this_0 = data.t(1).nd_1;
            if (_UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_0) >>> 16 | 0) === _UInt___init__impl__l7qpdl(0)) {
              tmp_9 = Result_UNAUTHORIZED_getInstance();
            } else {
              if (!this.gt_1(slice_0(data, numberRangeToNumber(2, get_lastIndex(data))), this.st_1)) {
                tmp_9 = Result_ERROR_getInstance();
              } else {
                tmp_9 = this.qt_1;
              }
            }
            tmp_8 = tmp_9;
          } else {
            tmp_8 = Result_ERROR_getInstance();
          }

          tmp_7.ut_1 = tmp_8;
          this.c6_1 = 3;
          continue $sm;
        case 3:
          this.lt_1 = this.ut_1;
          this.c6_1 = 1;
          continue $sm;
        case 4:
          return this.lt_1;
        case 5:
          throw this.f6_1;
      }
    } catch ($p) {
      var e = $p;
      if (this.d6_1 === 5) {
        throw e;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e;
      }
    }
   while (true);
};
function $initCOROUTINE$3(_this__u8e3s4, t, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.vu_1 = _this__u8e3s4;
  this.wu_1 = t;
}
protoOf($initCOROUTINE$3).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 7;
          this.d6_1 = 5;
          this.c6_1 = 1;
          suspendResult = NFCUtil_instance.xu(this.wu_1, this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 1:
          if (suspendResult) {
            this.c6_1 = 2;
            suspendResult = NFCUtil_instance.yu(this.wu_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }
            this.c6_1 = 3;
            continue $sm;
          } else {
            this.c6_1 = 4;
            continue $sm;
          }

        case 2:
          var tmp_0 = suspendResult;
          var unboxed = tmp_0 == null ? null : tmp_0.nd_1;
          var tmp_1 = unboxed;
          suspendResult = tmp_1 == null ? null : new UInt(tmp_1);
          this.c6_1 = 3;
          continue $sm;
        case 3:
          var tmp_2 = suspendResult;
          var address = tmp_2 == null ? null : tmp_2.nd_1;
          var tmp_3 = address;
          if ((tmp_3 == null ? null : new UInt(tmp_3)) == null)
            null;
          else {
            var tmp_4 = address;
            var it = (tmp_4 == null ? null : new UInt(tmp_4)).nd_1;
            var device = new Device(it);
            return new Pair(Result_OK_getInstance(), device);
          }

          this.c6_1 = 4;
          continue $sm;
        case 4:
          this.d6_1 = 7;
          this.c6_1 = 6;
          continue $sm;
        case 5:
          this.d6_1 = 7;
          var tmp_5 = this.f6_1;
          if (tmp_5 instanceof Exception) {
            var err = this.f6_1;
            this.c6_1 = 6;
            continue $sm;
          } else {
            throw this.f6_1;
          }

        case 6:
          this.d6_1 = 7;
          return new Pair(Result_ERROR_getInstance(), null);
        case 7:
          throw this.f6_1;
      }
    } catch ($p) {
      var e = $p;
      if (this.d6_1 === 7) {
        throw e;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e;
      }
    }
   while (true);
};
function $getRssiCOROUTINE$4(_this__u8e3s4, t, d, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.hv_1 = _this__u8e3s4;
  this.iv_1 = t;
  this.jv_1 = d;
}
protoOf($getRssiCOROUTINE$4).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 2;
          this.c6_1 = 1;
          suspendResult = this.hv_1.mu(this.iv_1, this.jv_1, _UByte___init__impl__g9hnc4(12), listOf_0(new UInt(_UInt___init__impl__l7qpdl(0))), _UInt___init__impl__l7qpdl(1), this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 1:
          var _destruct__k2r9zo = suspendResult;
          var result = _destruct__k2r9zo.v9();
          var data = _destruct__k2r9zo.w9();
          if (result.equals(Result_OK_getInstance()) && !(data == null)) {
            var tmp_0 = getOrNull(data, 0);
            var firstResult = tmp_0 == null ? null : tmp_0.nd_1;
            var tmp_1 = firstResult;
            if ((tmp_1 == null ? null : new UInt(tmp_1)) == null)
              null;
            else {
              var tmp_2 = firstResult;
              var this_0 = tmp_2 == null ? null : new UInt(tmp_2);
              var it = this_0.nd_1;
              if (_UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(it) >>> 16 | 0) === _UInt___init__impl__l7qpdl(0)) {
                return new Pair(Result_OK_getInstance(), new UInt(it));
              }
              this_0.nd_1;
            }
          }

          return new Pair(Result_ERROR_getInstance(), null);
        case 2:
          throw this.f6_1;
      }
    } catch ($p) {
      var e = $p;
      if (this.d6_1 === 2) {
        throw e;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e;
      }
    }
   while (true);
};
function $getInfoCOROUTINE$5(_this__u8e3s4, t, d, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.sv_1 = _this__u8e3s4;
  this.tv_1 = t;
  this.uv_1 = d;
}
protoOf($getInfoCOROUTINE$5).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 2;
          this.vv_1 = {_v: new ULong(_ULong___init__impl__c78o9k(new Long(0, 0)))};
          this.wv_1 = {_v: false};
          this.xv_1 = listOf([CMD_instance.ir(), CMD_instance.jr()]);
          this.c6_1 = 1;
          var tmp_0 = _UInt___init__impl__l7qpdl(4);
          suspendResult = transAndCheckResult(this.sv_1, this.tv_1, this.uv_1, this.xv_1, tmp_0, DeviceManager$getInfo$lambda(this.vv_1, this.wv_1), this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 1:
          var result = suspendResult;
          return new Pair(result, result.equals(Result_OK_getInstance()) ? new DeviceInfo(this.vv_1._v.ee_1, this.wv_1._v) : null);
        case 2:
          throw this.f6_1;
      }
    } catch ($p) {
      var e = $p;
      if (this.d6_1 === 2) {
        throw e;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e;
      }
    }
   while (true);
};
function $selectCOROUTINE$6(_this__u8e3s4, t, d, type, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.gw_1 = _this__u8e3s4;
  this.hw_1 = t;
  this.iw_1 = d;
  this.jw_1 = type;
}
protoOf($selectCOROUTINE$6).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 2;
          this.kw_1 = listOf_0(CMD_instance.kr(this.jw_1.nw_1));
          this.c6_1 = 1;
          var tmp_0 = _UInt___init__impl__l7qpdl(0);
          suspendResult = transAndCheckResult(this.gw_1, this.hw_1, this.iw_1, this.kw_1, tmp_0, DeviceManager$select$lambda, this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 1:
          var result = suspendResult;
          return result;
        case 2:
          throw this.f6_1;
      }
    } catch ($p) {
      var e = $p;
      if (this.d6_1 === 2) {
        throw e;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e;
      }
    }
   while (true);
};
function $getVersionCOROUTINE$7(_this__u8e3s4, t, d, key, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.ww_1 = _this__u8e3s4;
  this.xw_1 = t;
  this.yw_1 = d;
  this.zw_1 = key;
}
protoOf($getVersionCOROUTINE$7).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 2;
          var tmp_0 = this;
          tmp_0.ax_1 = {_v: emptyList()};
          this.bx_1 = listOf_0(CMD_instance.lr(this.zw_1));
          this.c6_1 = 1;
          var tmp_1 = _UInt___init__impl__l7qpdl(4);
          suspendResult = transAndCheckResult(this.ww_1, this.xw_1, this.yw_1, this.bx_1, tmp_1, DeviceManager$getVersion$lambda(this.zw_1, this.ax_1), this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 1:
          var result = suspendResult;
          return new Pair(result, result.equals(Result_OK_getInstance()) ? this.ax_1._v : null);
        case 2:
          throw this.f6_1;
      }
    } catch ($p) {
      var e = $p;
      if (this.d6_1 === 2) {
        throw e;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e;
      }
    }
   while (true);
};
function $setKeyCOROUTINE$8(_this__u8e3s4, t, d, info, key, sKey, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.kx_1 = _this__u8e3s4;
  this.lx_1 = t;
  this.mx_1 = d;
  this.nx_1 = info;
  this.ox_1 = key;
  this.px_1 = sKey;
}
protoOf($setKeyCOROUTINE$8).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 3;
          this.qx_1 = listOf([CMD_instance.mr(this.px_1), CMD_instance.nr(this.px_1, 'u'), CMD_instance.or(this.px_1, this.ox_1), CMD_instance.pr(this.px_1)]);
          this.rx_1 = listOf_0(CMD_instance.qr(this.px_1));
          this.c6_1 = 1;
          var tmp_0 = _UInt___init__impl__l7qpdl(8);
          suspendResult = transAndCheckResult(this.kx_1, this.lx_1, this.mx_1, this.qx_1, tmp_0, DeviceManager$setKey$lambda(this.px_1, this.ox_1, this.nx_1), this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 1:
          this.sx_1 = suspendResult;
          if (!this.sx_1.equals(Result_OK_getInstance())) {
            return this.sx_1;
          }

          this.c6_1 = 2;
          var tmp_1 = _UInt___init__impl__l7qpdl(0);
          suspendResult = transAndCheckResult(this.kx_1, this.lx_1, this.mx_1, this.rx_1, tmp_1, DeviceManager$setKey$lambda_0, this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 2:
          var result2 = suspendResult;
          return result2;
        case 3:
          throw this.f6_1;
      }
    } catch ($p) {
      var e = $p;
      if (this.d6_1 === 3) {
        throw e;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e;
      }
    }
   while (true);
};
function $getChargeLevelCOROUTINE$9(_this__u8e3s4, t, d, key, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.by_1 = _this__u8e3s4;
  this.cy_1 = t;
  this.dy_1 = d;
  this.ey_1 = key;
}
protoOf($getChargeLevelCOROUTINE$9).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 2;
          this.fy_1 = {_v: new UInt(_UInt___init__impl__l7qpdl(0))};
          this.gy_1 = {_v: new UInt(_UInt___init__impl__l7qpdl(0))};
          this.hy_1 = listOf([CMD_instance.rr(this.ey_1), CMD_instance.sr(this.ey_1)]);
          this.c6_1 = 1;
          var tmp_0 = _UInt___init__impl__l7qpdl(4);
          suspendResult = transAndCheckResult(this.by_1, this.cy_1, this.dy_1, this.hy_1, tmp_0, DeviceManager$getChargeLevel$lambda(this.ey_1, this.fy_1, this.gy_1), this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 1:
          var result = suspendResult;
          var tmp_1;
          if (result.equals(Result_OK_getInstance())) {
            var tmp_2;
            try {
              var this_0 = this.gy_1._v.nd_1;
              var value = _UInt___get_data__impl__f0vqqw(this_0);
              var tmp_3 = uintToDouble(value);
              var this_1 = this.fy_1._v.nd_1;
              var value_0 = _UInt___get_data__impl__f0vqqw(this_1);
              var this_2 = numberToInt(tmp_3 / uintToDouble(value_0) * 100);
              var chargeLevel = _UShort___init__impl__jigrne(toShort(this_2));
              var other = _UInt___init__impl__l7qpdl(100);
              var this_3 = _UInt___init__impl__l7qpdl(_UShort___get_data__impl__g0245(chargeLevel) & 65535);
              tmp_2 = new ChargeLevel(chargeLevel, uintCompare(_UInt___get_data__impl__f0vqqw(this_3), _UInt___get_data__impl__f0vqqw(other)) >= 0);
            } catch ($p) {
              var tmp_4;
              if ($p instanceof Exception) {
                var err = $p;
                tmp_4 = null;
              } else {
                throw $p;
              }
              tmp_2 = tmp_4;
            }
            tmp_1 = tmp_2;
          } else {
            tmp_1 = null;
          }

          return new Pair(result, tmp_1);
        case 2:
          throw this.f6_1;
      }
    } catch ($p) {
      var e = $p;
      if (this.d6_1 === 2) {
        throw e;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e;
      }
    }
   while (true);
};
function $controlCOROUTINE$10(_this__u8e3s4, t, d, key, ctrl, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.qy_1 = _this__u8e3s4;
  this.ry_1 = t;
  this.sy_1 = d;
  this.ty_1 = key;
  this.uy_1 = ctrl;
}
protoOf($controlCOROUTINE$10).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 2;
          this.vy_1 = listOf([CMD_instance.mr(this.ty_1), CMD_instance.nr(this.ty_1, 'u'), CMD_instance.tr(this.ty_1, this.uy_1.yy_1), CMD_instance.ur(this.ty_1, this.uy_1.yy_1)]);
          this.c6_1 = 1;
          var tmp_0 = _UInt___init__impl__l7qpdl(0);
          suspendResult = transAndCheckResult(this.qy_1, this.ry_1, this.sy_1, this.vy_1, tmp_0, DeviceManager$control$lambda, this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 1:
          var result = suspendResult;
          return result;
        case 2:
          throw this.f6_1;
      }
    } catch ($p) {
      var e = $p;
      if (this.d6_1 === 2) {
        throw e;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e;
      }
    }
   while (true);
};
function $getControlProgressCOROUTINE$11(_this__u8e3s4, t, d, key, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.hz_1 = _this__u8e3s4;
  this.iz_1 = t;
  this.jz_1 = d;
  this.kz_1 = key;
}
protoOf($getControlProgressCOROUTINE$11).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 2;
          this.lz_1 = {_v: new UInt(_UInt___init__impl__l7qpdl(0))};
          this.mz_1 = listOf_0(CMD_instance.vr(this.kz_1));
          this.c6_1 = 1;
          var tmp_0 = _UInt___init__impl__l7qpdl(4);
          suspendResult = transAndCheckResult(this.hz_1, this.iz_1, this.jz_1, this.mz_1, tmp_0, DeviceManager$getControlProgress$lambda(this.kz_1, this.lz_1), this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 1:
          var result = suspendResult;
          var tmp_1;
          if (result.equals(Result_OK_getInstance())) {
            var this_0 = this.lz_1._v.nd_1;
            var this_1 = _UInt___get_data__impl__f0vqqw(this_0);
            var tmp_2 = _UShort___init__impl__jigrne(toShort(this_1));
            var tmp1 = this.lz_1._v.nd_1;
            var other = _UInt___init__impl__l7qpdl(100);
            tmp_1 = new ControlProgress(tmp_2, uintCompare(_UInt___get_data__impl__f0vqqw(tmp1), _UInt___get_data__impl__f0vqqw(other)) >= 0);
          } else {
            tmp_1 = null;
          }

          return new Pair(result, tmp_1);
        case 2:
          throw this.f6_1;
      }
    } catch ($p) {
      var e = $p;
      if (this.d6_1 === 2) {
        throw e;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e;
      }
    }
   while (true);
};
function $setParametersCOROUTINE$12(_this__u8e3s4, t, d, key, p, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.vz_1 = _this__u8e3s4;
  this.wz_1 = t;
  this.xz_1 = d;
  this.yz_1 = key;
  this.zz_1 = p;
}
protoOf($setParametersCOROUTINE$12).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 2;
          this.a10_1 = mutableListOf([CMD_instance.wr(this.yz_1, this.zz_1.e10_1.d10_1), CMD_instance.xr(this.yz_1, this.zz_1.f10_1.l10_1), CMD_instance.yr(this.yz_1, this.zz_1.g10_1)]);
          switch (this.zz_1.e10_1.i1_1) {
            case 0:
              this.a10_1.r(listOf_0(CMD_instance.zr(this.yz_1, this.zz_1.h10_1)));
              break;
            case 1:
              this.a10_1.r(listOf([CMD_instance.as(this.yz_1, this.zz_1.h10_1), CMD_instance.bs(this.yz_1, this.zz_1.i10_1)]));
              break;
            case 2:
              this.a10_1.r(listOf([CMD_instance.cs(this.yz_1, this.zz_1.h10_1), CMD_instance.ds(this.yz_1, this.zz_1.i10_1)]));
              break;
            default:
              noWhenBranchMatchedException();
              break;
          }

          this.c6_1 = 1;
          var tmp_0 = _UInt___init__impl__l7qpdl(0);
          suspendResult = transAndCheckResult(this.vz_1, this.wz_1, this.xz_1, this.a10_1, tmp_0, DeviceManager$setParameters$lambda, this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 1:
          var result = suspendResult;
          return result;
        case 2:
          throw this.f6_1;
      }
    } catch ($p) {
      var e = $p;
      if (this.d6_1 === 2) {
        throw e;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e;
      }
    }
   while (true);
};
function $getLogCOROUTINE$13(_this__u8e3s4, t, d, key, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.u10_1 = _this__u8e3s4;
  this.v10_1 = t;
  this.w10_1 = d;
  this.x10_1 = key;
}
protoOf($getLogCOROUTINE$13).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 5;
          this.y10_1 = {_v: new UInt(_UInt___init__impl__l7qpdl(0))};
          var tmp_0 = this;
          tmp_0.z10_1 = ArrayList_init_$Create$_0();
          this.a11_1 = listOf_0(CMD_instance.es(this.x10_1));
          this.c6_1 = 1;
          var tmp_1 = _UInt___init__impl__l7qpdl(4);
          suspendResult = transAndCheckResult(this.u10_1, this.v10_1, this.w10_1, this.a11_1, tmp_1, DeviceManager$getLog$lambda(this.x10_1, this.y10_1), this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 1:
          this.b11_1 = suspendResult;
          if (!this.b11_1.equals(Result_OK_getInstance())) {
            return new Pair(this.b11_1, null);
          }

          this.c11_1 = until_0(_UInt___init__impl__l7qpdl(0), this.y10_1._v.nd_1).k();
          this.c6_1 = 2;
          continue $sm;
        case 2:
          if (!this.c11_1.l()) {
            this.c6_1 = 4;
            continue $sm;
          }

          this.d11_1 = this.c11_1.m().nd_1;
          this.e11_1 = {_v: new ULong(_ULong___init__impl__c78o9k(new Long(0, 0)))};
          this.f11_1 = {_v: ''};
          this.g11_1 = {_v: null};
          var tmp_2 = this;
          var tmp_3 = CMD_instance;
          var this_0 = this.d11_1;
          var this_1 = _UInt___get_data__impl__f0vqqw(this_0);
          tmp_2.h11_1 = listOf([tmp_3.fs(this.x10_1, _UShort___init__impl__jigrne(toShort(this_1))), CMD_instance.gs(this.x10_1), CMD_instance.hs(this.x10_1), CMD_instance.is(this.x10_1)]);
          this.c6_1 = 3;
          var tmp_4 = _UInt___init__impl__l7qpdl(8);
          suspendResult = transAndCheckResult(this.u10_1, this.v10_1, this.w10_1, this.h11_1, tmp_4, DeviceManager$getLog$lambda_0(this.x10_1, this.e11_1, this.f11_1, this.g11_1), this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 3:
          var result2 = suspendResult;
          if (result2.equals(Result_OK_getInstance())) {
            this.z10_1.u(new DeviceLog(this.e11_1._v.ee_1, this.f11_1._v, this.g11_1._v));
          } else {
            return new Pair(result2, null);
          }

          this.c6_1 = 2;
          continue $sm;
        case 4:
          return new Pair(Result_OK_getInstance(), this.z10_1);
        case 5:
          throw this.f6_1;
      }
    } catch ($p) {
      var e = $p;
      if (this.d6_1 === 5) {
        throw e;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e;
      }
    }
   while (true);
};
function DeviceManager() {
}
protoOf(DeviceManager).mu = function (t, d, idx, content, readSize, $completion) {
  var tmp = new $callCOROUTINE$0(this, t, d, idx, content, readSize, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  return tmp.k6();
};
protoOf(DeviceManager).i11 = function (t, d, idx, content, readSize, $completion, $super) {
  readSize = readSize === VOID ? _UInt___init__impl__l7qpdl(16) : readSize;
  return $super === VOID ? this.mu(t, d, idx, content, readSize, $completion) : $super.mu.call(this, t, d, new UByte(idx), content, new UInt(readSize), $completion);
};
protoOf(DeviceManager).j11 = function (t, $completion) {
  var tmp = new $initCOROUTINE$3(this, t, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  return tmp.k6();
};
protoOf(DeviceManager).k11 = function (t, d, $completion) {
  var tmp = new $getRssiCOROUTINE$4(this, t, d, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  return tmp.k6();
};
protoOf(DeviceManager).l11 = function (t, d, $completion) {
  var tmp = new $getInfoCOROUTINE$5(this, t, d, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  return tmp.k6();
};
protoOf(DeviceManager).m11 = function (t, d, type, $completion) {
  var tmp = new $selectCOROUTINE$6(this, t, d, type, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  return tmp.k6();
};
protoOf(DeviceManager).n11 = function (t, d, key, $completion) {
  var tmp = new $getVersionCOROUTINE$7(this, t, d, key, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  return tmp.k6();
};
protoOf(DeviceManager).o11 = function (t, d, info, key, sKey, $completion) {
  var tmp = new $setKeyCOROUTINE$8(this, t, d, info, key, sKey, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  return tmp.k6();
};
protoOf(DeviceManager).p11 = function (t, d, key, $completion) {
  var tmp = new $getChargeLevelCOROUTINE$9(this, t, d, key, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  return tmp.k6();
};
protoOf(DeviceManager).q11 = function (t, d, key, ctrl, $completion) {
  var tmp = new $controlCOROUTINE$10(this, t, d, key, ctrl, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  return tmp.k6();
};
protoOf(DeviceManager).r11 = function (t, d, key, $completion) {
  var tmp = new $getControlProgressCOROUTINE$11(this, t, d, key, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  return tmp.k6();
};
protoOf(DeviceManager).s11 = function (t, d, key, p, $completion) {
  var tmp = new $setParametersCOROUTINE$12(this, t, d, key, p, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  return tmp.k6();
};
protoOf(DeviceManager).t11 = function (t, d, key, $completion) {
  var tmp = new $getLogCOROUTINE$13(this, t, d, key, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  return tmp.k6();
};
protoOf(DeviceManager).u11 = function (input) {
  var bytes = encodeToByteArray(input);
  var tmp;
  if (bytes.length < 16) {
    // Inline function 'kotlin.collections.plus' call
    var elements = new Int8Array(16 - bytes.length | 0);
    tmp = primitiveArrayConcat([bytes, elements]);
  } else if (bytes.length > 16) {
    tmp = copyOfRange(bytes, 0, 16);
  } else {
    tmp = bytes;
  }
  return tmp;
};
protoOf(DeviceManager).v11 = function (key, info) {
  var result = new Int8Array(16);
  var inductionVariable = 0;
  if (inductionVariable < 8)
    do {
      var i = inductionVariable;
      inductionVariable = inductionVariable + 1 | 0;
      var tmp0 = info.os_1;
      // Inline function 'kotlin.ULong.shr' call
      var bitCount = imul(8, 7 - i | 0);
      var tmp2 = _ULong___init__impl__c78o9k(_ULong___get_data__impl__fggpzb(tmp0).b2(bitCount));
      // Inline function 'kotlin.ULong.and' call
      var other = _ULong___init__impl__c78o9k(new Long(255, 0));
      // Inline function 'kotlin.ULong.toByte' call
      var this_0 = _ULong___init__impl__c78o9k(_ULong___get_data__impl__fggpzb(tmp2).c2(_ULong___get_data__impl__fggpzb(other)));
      result[i] = _ULong___get_data__impl__fggpzb(this_0).f2();
      var tmp = i + 8 | 0;
      var tmp5 = info.os_1;
      // Inline function 'kotlin.ULong.shr' call
      var bitCount_0 = imul(8, 7 - i | 0);
      var tmp7 = _ULong___init__impl__c78o9k(_ULong___get_data__impl__fggpzb(tmp5).b2(bitCount_0));
      // Inline function 'kotlin.ULong.and' call
      var other_0 = _ULong___init__impl__c78o9k(new Long(255, 0));
      // Inline function 'kotlin.ULong.toByte' call
      var this_1 = _ULong___init__impl__c78o9k(_ULong___get_data__impl__fggpzb(tmp7).c2(_ULong___get_data__impl__fggpzb(other_0)));
      result[tmp] = _ULong___get_data__impl__fggpzb(this_1).f2();
    }
     while (inductionVariable < 8);
  var tmp_0 = AESUtil_instance;
  var tmp_1 = 0;
  var tmp_2 = new Int8Array(16);
  while (tmp_1 < 16) {
    tmp_2[tmp_1] = 0;
    tmp_1 = tmp_1 + 1 | 0;
  }
  return tmp_0.wq(result, key, tmp_2);
};
var DeviceManager_instance;
function DeviceManager_getInstance() {
  return DeviceManager_instance;
}
var Ctrl_LOCK_instance;
var Ctrl_UNLOCK_instance;
function Companion_0() {
}
protoOf(Companion_0).vt = function (value) {
  // Inline function 'kotlin.collections.associateBy' call
  var this_0 = get_entries();
  var capacity = coerceAtLeast(mapCapacity(collectionSizeOrDefault(this_0, 10)), 16);
  // Inline function 'kotlin.collections.associateByTo' call
  var destination = LinkedHashMap_init_$Create$(capacity);
  var _iterator__ex2g4s = this_0.k();
  while (_iterator__ex2g4s.l()) {
    var element = _iterator__ex2g4s.m();
    // Inline function 'com.lvcheng.lock.shared.nfc.kmp.Companion.fromValue.<anonymous>' call
    var tmp$ret$0 = new UByte(element.yy_1);
    destination.l3(tmp$ret$0, element);
  }
  return destination.f1(new UByte(value));
};
var Companion_instance_0;
function Companion_getInstance_0() {
  return Companion_instance_0;
}
function values() {
  return [Ctrl_LOCK_getInstance(), Ctrl_UNLOCK_getInstance()];
}
function get_entries() {
  if ($ENTRIES == null)
    $ENTRIES = enumEntries(values());
  return $ENTRIES;
}
var Ctrl_entriesInitialized;
function Ctrl_initEntries() {
  if (Ctrl_entriesInitialized)
    return Unit_instance;
  Ctrl_entriesInitialized = true;
  Ctrl_LOCK_instance = new Ctrl('LOCK', 0, _UByte___init__impl__g9hnc4(1));
  Ctrl_UNLOCK_instance = new Ctrl('UNLOCK', 1, _UByte___init__impl__g9hnc4(2));
}
var $ENTRIES;
function Ctrl(name, ordinal, value) {
  Enum.call(this, name, ordinal);
  this.yy_1 = value;
}
var UserType_NORMAL_instance;
var UserType_SUPERVISOR_instance;
function Companion_1() {
}
var Companion_instance_1;
function Companion_getInstance_1() {
  return Companion_instance_1;
}
var UserType_entriesInitialized;
function UserType_initEntries() {
  if (UserType_entriesInitialized)
    return Unit_instance;
  UserType_entriesInitialized = true;
  UserType_NORMAL_instance = new UserType('NORMAL', 0, _UByte___init__impl__g9hnc4(1));
  UserType_SUPERVISOR_instance = new UserType('SUPERVISOR', 1, _UByte___init__impl__g9hnc4(-2));
}
function UserType(name, ordinal, value) {
  Enum.call(this, name, ordinal);
  this.nw_1 = value;
}
var Result_OK_instance;
var Result_ERROR_instance;
var Result_UNAUTHORIZED_instance;
var Result_entriesInitialized;
function Result_initEntries() {
  if (Result_entriesInitialized)
    return Unit_instance;
  Result_entriesInitialized = true;
  Result_OK_instance = new Result('OK', 0);
  Result_ERROR_instance = new Result('ERROR', 1);
  Result_UNAUTHORIZED_instance = new Result('UNAUTHORIZED', 2);
}
function Result(name, ordinal) {
  Enum.call(this, name, ordinal);
}
function Ctrl_LOCK_getInstance() {
  Ctrl_initEntries();
  return Ctrl_LOCK_instance;
}
function Ctrl_UNLOCK_getInstance() {
  Ctrl_initEntries();
  return Ctrl_UNLOCK_instance;
}
function UserType_NORMAL_getInstance() {
  UserType_initEntries();
  return UserType_NORMAL_instance;
}
function UserType_SUPERVISOR_getInstance() {
  UserType_initEntries();
  return UserType_SUPERVISOR_instance;
}
function Result_OK_getInstance() {
  Result_initEntries();
  return Result_OK_instance;
}
function Result_ERROR_getInstance() {
  Result_initEntries();
  return Result_ERROR_instance;
}
function Result_UNAUTHORIZED_getInstance() {
  Result_initEntries();
  return Result_UNAUTHORIZED_instance;
}
function $startCOROUTINE$14(_this__u8e3s4, tag, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.e12_1 = _this__u8e3s4;
  this.f12_1 = tag;
}
protoOf($startCOROUTINE$14).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 3;
          this.d6_1 = 2;
          var tmp_0 = this;
          tmp_0.h12_1 = new Int8Array([71, 17]);
          this.c6_1 = 1;
          suspendResult = this.f12_1.i12(this.h12_1, this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 1:
          var response = suspendResult;
          this.g12_1 = (response.length === 2 && response[0] === 71 && response[1] === 71);
          this.d6_1 = 3;
          this.c6_1 = 4;
          continue $sm;
        case 2:
          this.d6_1 = 3;
          var tmp_1 = this.f6_1;
          if (tmp_1 instanceof Exception) {
            var e = this.f6_1;
            var tmp_2 = this;
            tmp_2.g12_1 = false;
            this.c6_1 = 4;
            continue $sm;
          } else {
            throw this.f6_1;
          }

        case 3:
          throw this.f6_1;
        case 4:
          this.d6_1 = 3;
          return this.g12_1;
      }
    } catch ($p) {
      var e_0 = $p;
      if (this.d6_1 === 3) {
        throw e_0;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e_0;
      }
    }
   while (true);
};
function $getStartAddressCOROUTINE$15(_this__u8e3s4, tag, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.r12_1 = _this__u8e3s4;
  this.s12_1 = tag;
}
protoOf($getStartAddressCOROUTINE$15).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 3;
          this.d6_1 = 2;
          var tmp_0 = this;
          tmp_0.u12_1 = new Int8Array([96, 0, 0, 0, 0]);
          this.c6_1 = 1;
          suspendResult = this.s12_1.i12(this.u12_1, this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 1:
          var response = suspendResult;
          var tmp_1 = this;
          var tmp_2;
          if (response.length === 6 && response[0] === 96 && response[5] === 96) {
            var addressBytes = toByteArray(slice(response, numberRangeToNumber(1, 4)));
            var this_0 = addressBytes[0];
            var this_1 = _UInt___init__impl__l7qpdl(this_0);
            var tmp6 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_1) << 24);
            var this_2 = _UInt___init__impl__l7qpdl(255);
            var other = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_2) << 24);
            var tmp15 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp6) & _UInt___get_data__impl__f0vqqw(other));
            var this_3 = addressBytes[1];
            var this_4 = _UInt___init__impl__l7qpdl(this_3);
            var tmp13 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_4) << 16);
            var this_5 = _UInt___init__impl__l7qpdl(255);
            var other_0 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_5) << 16);
            var other_1 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp13) & _UInt___get_data__impl__f0vqqw(other_0));
            var tmp24 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp15) | _UInt___get_data__impl__f0vqqw(other_1));
            var this_6 = addressBytes[2];
            var this_7 = _UInt___init__impl__l7qpdl(this_6);
            var tmp22 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_7) << 8);
            var this_8 = _UInt___init__impl__l7qpdl(255);
            var other_2 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_8) << 8);
            var other_3 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp22) & _UInt___get_data__impl__f0vqqw(other_2));
            var tmp29 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp24) | _UInt___get_data__impl__f0vqqw(other_3));
            var this_9 = addressBytes[3];
            var tmp27 = _UInt___init__impl__l7qpdl(this_9);
            var other_4 = _UInt___init__impl__l7qpdl(255);
            var other_5 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp27) & _UInt___get_data__impl__f0vqqw(other_4));
            tmp_2 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp29) | _UInt___get_data__impl__f0vqqw(other_5));
          } else {
            tmp_2 = null;
          }

          tmp_1.t12_1 = tmp_2;
          this.d6_1 = 3;
          this.c6_1 = 4;
          continue $sm;
        case 2:
          this.d6_1 = 3;
          var tmp_3 = this.f6_1;
          if (tmp_3 instanceof Exception) {
            var e = this.f6_1;
            var tmp_4 = this;
            tmp_4.t12_1 = null;
            this.c6_1 = 4;
            continue $sm;
          } else {
            throw this.f6_1;
          }

        case 3:
          throw this.f6_1;
        case 4:
          this.d6_1 = 3;
          var tmp_5 = this.t12_1;
          return tmp_5 == null ? null : new UInt(tmp_5);
      }
    } catch ($p) {
      var e_0 = $p;
      if (this.d6_1 === 3) {
        throw e_0;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e_0;
      }
    }
   while (true);
};
function $readCOROUTINE$16(_this__u8e3s4, tag, startAddress, size, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.d13_1 = _this__u8e3s4;
  this.e13_1 = tag;
  this.f13_1 = startAddress;
  this.g13_1 = size;
}
protoOf($readCOROUTINE$16).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 5;
          var tmp_0 = this;
          tmp_0.h13_1 = ArrayList_init_$Create$_0();
          this.d6_1 = 4;
          this.i13_1 = this.f13_1;
          var tmp_1 = this;
          var this_0 = this.g13_1;
          tmp_1.j13_1 = until(0, _UInt___get_data__impl__f0vqqw(this_0)).k();
          this.c6_1 = 1;
          continue $sm;
        case 1:
          if (!this.j13_1.l()) {
            this.c6_1 = 3;
            continue $sm;
          }

          this.k13_1 = this.j13_1.m();
          var tmp_2 = this;
          var this_1 = this.i13_1;
          var tmp3 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_1) >>> 24 | 0);
          var other = _UInt___init__impl__l7qpdl(255);
          var this_2 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp3) & _UInt___get_data__impl__f0vqqw(other));
          var tmp_3 = toByte(_UInt___get_data__impl__f0vqqw(this_2));
          var this_3 = this.i13_1;
          var tmp8 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_3) >>> 16 | 0);
          var other_0 = _UInt___init__impl__l7qpdl(255);
          var this_4 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp8) & _UInt___get_data__impl__f0vqqw(other_0));
          var tmp_4 = toByte(_UInt___get_data__impl__f0vqqw(this_4));
          var this_5 = this.i13_1;
          var tmp13 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_5) >>> 8 | 0);
          var other_1 = _UInt___init__impl__l7qpdl(255);
          var this_6 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp13) & _UInt___get_data__impl__f0vqqw(other_1));
          var tmp_5 = toByte(_UInt___get_data__impl__f0vqqw(this_6));
          var tmp16 = this.i13_1;
          var other_2 = _UInt___init__impl__l7qpdl(255);
          var this_7 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp16) & _UInt___get_data__impl__f0vqqw(other_2));
          tmp_2.l13_1 = new Int8Array([-128, tmp_3, tmp_4, tmp_5, toByte(_UInt___get_data__impl__f0vqqw(this_7))]);
          this.c6_1 = 2;
          suspendResult = this.e13_1.i12(this.l13_1, this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 2:
          var response = suspendResult;
          if (response.length === 6 && response[0] === -128 && response[5] === -128) {
            var dataBytes = toByteArray(slice(response, numberRangeToNumber(1, 4)));
            var this_8 = dataBytes[0];
            var this_9 = _UInt___init__impl__l7qpdl(this_8);
            var tmp25 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_9) << 24);
            var this_10 = _UInt___init__impl__l7qpdl(255);
            var other_3 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_10) << 24);
            var tmp34 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp25) & _UInt___get_data__impl__f0vqqw(other_3));
            var this_11 = dataBytes[1];
            var this_12 = _UInt___init__impl__l7qpdl(this_11);
            var tmp32 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_12) << 16);
            var this_13 = _UInt___init__impl__l7qpdl(255);
            var other_4 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_13) << 16);
            var other_5 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp32) & _UInt___get_data__impl__f0vqqw(other_4));
            var tmp43 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp34) | _UInt___get_data__impl__f0vqqw(other_5));
            var this_14 = dataBytes[2];
            var this_15 = _UInt___init__impl__l7qpdl(this_14);
            var tmp41 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_15) << 8);
            var this_16 = _UInt___init__impl__l7qpdl(255);
            var other_6 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_16) << 8);
            var other_7 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp41) & _UInt___get_data__impl__f0vqqw(other_6));
            var tmp48 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp43) | _UInt___get_data__impl__f0vqqw(other_7));
            var this_17 = dataBytes[3];
            var tmp46 = _UInt___init__impl__l7qpdl(this_17);
            var other_8 = _UInt___init__impl__l7qpdl(255);
            var other_9 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp46) & _UInt___get_data__impl__f0vqqw(other_8));
            this.h13_1.u(new UInt(_UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp48) | _UInt___get_data__impl__f0vqqw(other_9))));
            var tmp_6 = this;
            var tmp50 = this.i13_1;
            var other_10 = _UInt___init__impl__l7qpdl(4);
            tmp_6.i13_1 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp50) + _UInt___get_data__impl__f0vqqw(other_10) | 0);
          } else {
            return null;
          }

          this.c6_1 = 1;
          continue $sm;
        case 3:
          return this.h13_1;
        case 4:
          this.d6_1 = 5;
          var tmp_7 = this.f6_1;
          if (tmp_7 instanceof Exception) {
            var e = this.f6_1;
            return null;
          } else {
            throw this.f6_1;
          }

        case 5:
          throw this.f6_1;
      }
    } catch ($p) {
      var e_0 = $p;
      if (this.d6_1 === 5) {
        throw e_0;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e_0;
      }
    }
   while (true);
};
function $writeCOROUTINE$17(_this__u8e3s4, tag, startAddress, fnIdx, content, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.u13_1 = _this__u8e3s4;
  this.v13_1 = tag;
  this.w13_1 = startAddress;
  this.x13_1 = fnIdx;
  this.y13_1 = content;
}
protoOf($writeCOROUTINE$17).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 6;
          this.d6_1 = 5;
          this.z13_1 = this.w13_1;
          var tmp_0 = this;
          var tmp0 = _UInt___init__impl__l7qpdl(1610612736);
          var this_0 = this.x13_1;
          var other = _UInt___init__impl__l7qpdl(_UByte___get_data__impl__jof9qr(this_0) & 255);
          tmp_0.a14_1 = plus(listOf_0(new UInt(_UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp0) + _UInt___get_data__impl__f0vqqw(other) | 0))), this.y13_1);
          this.b14_1 = this.a14_1.k();
          this.c6_1 = 1;
          continue $sm;
        case 1:
          if (!this.b14_1.l()) {
            this.c6_1 = 3;
            continue $sm;
          }

          this.c14_1 = this.b14_1.m().nd_1;
          var tmp_1 = this;
          var this_1 = this.z13_1;
          var tmp4 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_1) >>> 24 | 0);
          var other_0 = _UInt___init__impl__l7qpdl(255);
          var this_2 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp4) & _UInt___get_data__impl__f0vqqw(other_0));
          var tmp_2 = toByte(_UInt___get_data__impl__f0vqqw(this_2));
          var this_3 = this.z13_1;
          var tmp9 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_3) >>> 16 | 0);
          var other_1 = _UInt___init__impl__l7qpdl(255);
          var this_4 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp9) & _UInt___get_data__impl__f0vqqw(other_1));
          var tmp_3 = toByte(_UInt___get_data__impl__f0vqqw(this_4));
          var this_5 = this.z13_1;
          var tmp14 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_5) >>> 8 | 0);
          var other_2 = _UInt___init__impl__l7qpdl(255);
          var this_6 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp14) & _UInt___get_data__impl__f0vqqw(other_2));
          var tmp_4 = toByte(_UInt___get_data__impl__f0vqqw(this_6));
          var tmp17 = this.z13_1;
          var other_3 = _UInt___init__impl__l7qpdl(255);
          var this_7 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp17) & _UInt___get_data__impl__f0vqqw(other_3));
          var tmp_5 = toByte(_UInt___get_data__impl__f0vqqw(this_7));
          var this_8 = this.c14_1;
          var tmp22 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_8) >>> 24 | 0);
          var other_4 = _UInt___init__impl__l7qpdl(255);
          var this_9 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp22) & _UInt___get_data__impl__f0vqqw(other_4));
          var tmp_6 = toByte(_UInt___get_data__impl__f0vqqw(this_9));
          var this_10 = this.c14_1;
          var tmp27 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_10) >>> 16 | 0);
          var other_5 = _UInt___init__impl__l7qpdl(255);
          var this_11 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp27) & _UInt___get_data__impl__f0vqqw(other_5));
          var tmp_7 = toByte(_UInt___get_data__impl__f0vqqw(this_11));
          var this_12 = this.c14_1;
          var tmp32 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(this_12) >>> 8 | 0);
          var other_6 = _UInt___init__impl__l7qpdl(255);
          var this_13 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp32) & _UInt___get_data__impl__f0vqqw(other_6));
          var tmp_8 = toByte(_UInt___get_data__impl__f0vqqw(this_13));
          var tmp35 = this.c14_1;
          var other_7 = _UInt___init__impl__l7qpdl(255);
          var this_14 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp35) & _UInt___get_data__impl__f0vqqw(other_7));
          tmp_1.d14_1 = new Int8Array([112, tmp_2, tmp_3, tmp_4, tmp_5, tmp_6, tmp_7, tmp_8, toByte(_UInt___get_data__impl__f0vqqw(this_14))]);
          this.c6_1 = 2;
          suspendResult = this.v13_1.i12(this.d14_1, this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 2:
          this.e14_1 = suspendResult;
          if (!(this.e14_1.length === 2 && this.e14_1[0] === 112 && this.e14_1[1] === 112)) {
            return false;
          }

          var tmp_9 = this;
          var tmp39 = this.z13_1;
          var other_8 = _UInt___init__impl__l7qpdl(4);
          tmp_9.z13_1 = _UInt___init__impl__l7qpdl(_UInt___get_data__impl__f0vqqw(tmp39) + _UInt___get_data__impl__f0vqqw(other_8) | 0);
          this.c6_1 = 1;
          continue $sm;
        case 3:
          var tmp_10 = this;
          tmp_10.f14_1 = new Int8Array([96, 2, 0, 0, 0]);
          this.c6_1 = 4;
          suspendResult = this.v13_1.i12(this.f14_1, this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 4:
          var completeResponse = suspendResult;
          var tmp_11;
          var tmp_12;
          if (completeResponse.length === 6 && completeResponse[0] === 96 && completeResponse[1] === 96 && completeResponse[2] === 0 && completeResponse[3] === 0) {
            var tmp_13 = completeResponse[4];
            var this_15 = this.x13_1;
            tmp_12 = tmp_13 === _UByte___get_data__impl__jof9qr(this_15);
          } else {
            tmp_12 = false;
          }

          if (tmp_12) {
            tmp_11 = completeResponse[5] === 96;
          } else {
            tmp_11 = false;
          }

          return tmp_11;
        case 5:
          this.d6_1 = 6;
          var tmp_14 = this.f6_1;
          if (tmp_14 instanceof Exception) {
            var e = this.f6_1;
            return false;
          } else {
            throw this.f6_1;
          }

        case 6:
          throw this.f6_1;
      }
    } catch ($p) {
      var e_0 = $p;
      if (this.d6_1 === 6) {
        throw e_0;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e_0;
      }
    }
   while (true);
};
function NFCUtil() {
}
protoOf(NFCUtil).xu = function (tag, $completion) {
  var tmp = new $startCOROUTINE$14(this, tag, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  return tmp.k6();
};
protoOf(NFCUtil).yu = function (tag, $completion) {
  var tmp = new $getStartAddressCOROUTINE$15(this, tag, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  var tmp_0 = tmp.k6();
  if (tmp_0 === get_COROUTINE_SUSPENDED())
    return tmp_0;
  var tmp_1 = tmp_0;
  var tmp_2 = tmp_1 == null ? null : tmp_1.nd_1;
  return tmp_2 == null ? null : new UInt(tmp_2);
};
protoOf(NFCUtil).lu = function (tag, startAddress, size, $completion) {
  var tmp = new $readCOROUTINE$16(this, tag, startAddress, size, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  return tmp.k6();
};
protoOf(NFCUtil).ku = function (tag, startAddress, fnIdx, content, $completion) {
  var tmp = new $writeCOROUTINE$17(this, tag, startAddress, fnIdx, content, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  return tmp.k6();
};
var NFCUtil_instance;
function NFCUtil_getInstance() {
  return NFCUtil_instance;
}
function CommonTask() {
}
function ControlTask(password, userType, ctrl, ignoreProgress, chargeCallback, controlCallback) {
  userType = userType === VOID ? UserType_NORMAL_getInstance() : userType;
  ignoreProgress = ignoreProgress === VOID ? false : ignoreProgress;
  CommonTask.call(this);
  this.j14_1 = password;
  this.k14_1 = userType;
  this.l14_1 = ctrl;
  this.m14_1 = ignoreProgress;
  this.n14_1 = chargeCallback;
  this.o14_1 = controlCallback;
}
protoOf(ControlTask).g14 = function () {
  return this.j14_1;
};
protoOf(ControlTask).h14 = function () {
  return this.k14_1;
};
protoOf(ControlTask).i14 = function () {
  this.n14_1(Result_ERROR_getInstance(), null);
};
protoOf(ControlTask).toString = function () {
  return 'ControlTask(password=' + this.j14_1 + ', userType=' + toString_0(this.k14_1) + ', ctrl=' + this.l14_1.toString() + ', ignoreProgress=' + this.m14_1 + ', chargeCallback=' + toString(this.n14_1) + ', controlCallback=' + toString(this.o14_1) + ')';
};
protoOf(ControlTask).hashCode = function () {
  var result = getStringHashCode(this.j14_1);
  result = imul(result, 31) + (this.k14_1 == null ? 0 : this.k14_1.hashCode()) | 0;
  result = imul(result, 31) + this.l14_1.hashCode() | 0;
  result = imul(result, 31) + getBooleanHashCode(this.m14_1) | 0;
  result = imul(result, 31) + hashCode(this.n14_1) | 0;
  result = imul(result, 31) + hashCode(this.o14_1) | 0;
  return result;
};
protoOf(ControlTask).equals = function (other) {
  if (this === other)
    return true;
  if (!(other instanceof ControlTask))
    return false;
  var tmp0_other_with_cast = other instanceof ControlTask ? other : THROW_CCE();
  if (!(this.j14_1 === tmp0_other_with_cast.j14_1))
    return false;
  if (!equals(this.k14_1, tmp0_other_with_cast.k14_1))
    return false;
  if (!this.l14_1.equals(tmp0_other_with_cast.l14_1))
    return false;
  if (!(this.m14_1 === tmp0_other_with_cast.m14_1))
    return false;
  if (!equals(this.n14_1, tmp0_other_with_cast.n14_1))
    return false;
  if (!equals(this.o14_1, tmp0_other_with_cast.o14_1))
    return false;
  return true;
};
function SetKeyTask(password, userType, sKey, callback) {
  userType = userType === VOID ? UserType_SUPERVISOR_getInstance() : userType;
  CommonTask.call(this);
  this.p14_1 = password;
  this.q14_1 = userType;
  this.r14_1 = sKey;
  this.s14_1 = callback;
}
protoOf(SetKeyTask).g14 = function () {
  return this.p14_1;
};
protoOf(SetKeyTask).h14 = function () {
  return this.q14_1;
};
protoOf(SetKeyTask).i14 = function () {
  this.s14_1(Result_ERROR_getInstance());
};
protoOf(SetKeyTask).toString = function () {
  return 'SetKeyTask(password=' + this.p14_1 + ', userType=' + toString_0(this.q14_1) + ', sKey=' + this.r14_1 + ', callback=' + toString(this.s14_1) + ')';
};
protoOf(SetKeyTask).hashCode = function () {
  var result = getStringHashCode(this.p14_1);
  result = imul(result, 31) + (this.q14_1 == null ? 0 : this.q14_1.hashCode()) | 0;
  result = imul(result, 31) + getStringHashCode(this.r14_1) | 0;
  result = imul(result, 31) + hashCode(this.s14_1) | 0;
  return result;
};
protoOf(SetKeyTask).equals = function (other) {
  if (this === other)
    return true;
  if (!(other instanceof SetKeyTask))
    return false;
  var tmp0_other_with_cast = other instanceof SetKeyTask ? other : THROW_CCE();
  if (!(this.p14_1 === tmp0_other_with_cast.p14_1))
    return false;
  if (!equals(this.q14_1, tmp0_other_with_cast.q14_1))
    return false;
  if (!(this.r14_1 === tmp0_other_with_cast.r14_1))
    return false;
  if (!equals(this.s14_1, tmp0_other_with_cast.s14_1))
    return false;
  return true;
};
function SetParametersTask() {
}
function GetLogTask() {
}
function GetVersionTask() {
}
function CallFunctionTask(password, userType, data, index, callback) {
  userType = userType === VOID ? null : userType;
  CommonTask.call(this);
  this.t14_1 = password;
  this.u14_1 = userType;
  this.v14_1 = data;
  this.w14_1 = index;
  this.x14_1 = callback;
}
protoOf(CallFunctionTask).g14 = function () {
  return this.t14_1;
};
protoOf(CallFunctionTask).h14 = function () {
  return this.u14_1;
};
protoOf(CallFunctionTask).i14 = function () {
};
protoOf(CallFunctionTask).toString = function () {
  return 'CallFunctionTask(password=' + this.t14_1 + ', userType=' + toString_0(this.u14_1) + ', data=' + toString(this.v14_1) + ', index=' + new UByte(this.w14_1) + ', callback=' + toString(this.x14_1) + ')';
};
protoOf(CallFunctionTask).hashCode = function () {
  var result = getStringHashCode(this.t14_1);
  result = imul(result, 31) + (this.u14_1 == null ? 0 : this.u14_1.hashCode()) | 0;
  result = imul(result, 31) + hashCode(this.v14_1) | 0;
  result = imul(result, 31) + UByte__hashCode_impl_mmczcb(this.w14_1) | 0;
  result = imul(result, 31) + hashCode(this.x14_1) | 0;
  return result;
};
protoOf(CallFunctionTask).equals = function (other) {
  if (this === other)
    return true;
  if (!(other instanceof CallFunctionTask))
    return false;
  var tmp0_other_with_cast = other instanceof CallFunctionTask ? other : THROW_CCE();
  if (!(this.t14_1 === tmp0_other_with_cast.t14_1))
    return false;
  if (!equals(this.u14_1, tmp0_other_with_cast.u14_1))
    return false;
  if (!equals(this.v14_1, tmp0_other_with_cast.v14_1))
    return false;
  if (!(this.w14_1 === tmp0_other_with_cast.w14_1))
    return false;
  if (!equals(this.x14_1, tmp0_other_with_cast.x14_1))
    return false;
  return true;
};
function select($this, t, device, type, $completion) {
  var tmp = new $selectCOROUTINE$19($this, t, device, type, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  return tmp.k6();
}
function charging($this, t, device, key, task, $completion) {
  var tmp = new $chargingCOROUTINE$20($this, t, device, key, task, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  return tmp.k6();
}
function control($this, t, device, key, task, $completion) {
  var tmp = new $controlCOROUTINE$21($this, t, device, key, task, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  return tmp.k6();
}
function controlling($this, t, device, key, task, $completion) {
  var tmp = new $controllingCOROUTINE$22($this, t, device, key, task, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  return tmp.k6();
}
function setKey($this, t, device, key, info, task, $completion) {
  var tmp = new $setKeyCOROUTINE$23($this, t, device, key, info, task, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  return tmp.k6();
}
function setParameters($this, t, device, key, task, $completion) {
  var tmp = new $setParametersCOROUTINE$24($this, t, device, key, task, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  return tmp.k6();
}
function getLog($this, t, device, key, task, $completion) {
  var tmp = new $getLogCOROUTINE$25($this, t, device, key, task, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  return tmp.k6();
}
function getVersion($this, t, device, key, task, $completion) {
  var tmp = new $getVersionCOROUTINE$26($this, t, device, key, task, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  return tmp.k6();
}
function callFunction($this, t, device, task, $completion) {
  var tmp = new $callFunctionCOROUTINE$27($this, t, device, task, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  return tmp.k6();
}
function $processCOROUTINE$18(_this__u8e3s4, parameter, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.t19_1 = _this__u8e3s4;
  this.u19_1 = parameter;
}
protoOf($processCOROUTINE$18).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 34;
          if (!this.t19_1.g1b_1.xn()) {
            return Unit_instance;
          }

          this.v19_1 = Unit_instance;
          this.c6_1 = 1;
          continue $sm;
        case 1:
          this.c6_1 = 2;
          continue $sm;
        case 2:
          this.d6_1 = 30;
          this.d6_1 = 29;
          this.c6_1 = 3;
          suspendResult = this.t19_1.i1b(this.u19_1, this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 3:
          this.x19_1 = suspendResult;
          if (this.x19_1 == null) {
            this.y19_1 = null;
            this.c6_1 = 28;
            continue $sm;
          } else {
            var tmp_0 = this;
            tmp_0.z19_1 = this.x19_1;
            this.a1a_1 = this.z19_1;
            var tmp_1 = this;
            tmp_1.b1a_1 = this.a1a_1;
            this.c1a_1 = this.b1a_1;
            this.c6_1 = 4;
            suspendResult = DeviceManager_instance.j11(this.c1a_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }
            continue $sm;
          }

        case 4:
          this.d1a_1 = suspendResult;
          this.e1a_1 = this.d1a_1.v9();
          this.f1a_1 = this.d1a_1.w9();
          if (!this.e1a_1.equals(Result_OK_getInstance()) || this.f1a_1 == null) {
            this.w19_1 = Unit_instance;
            this.d6_1 = 34;
            this.c6_1 = 26;
            continue $sm;
          } else {
            this.c6_1 = 5;
            continue $sm;
          }

        case 5:
          this.c6_1 = 6;
          suspendResult = DeviceManager_instance.k11(this.c1a_1, this.f1a_1, this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 6:
          this.g1a_1 = suspendResult;
          var tmp_2 = this;
          var tmp_3 = this.g1a_1.w9();
          tmp_2.h1a_1 = tmp_3 == null ? null : tmp_3.nd_1;
          this.i1a_1 = new Long(0, 0);
          this.c6_1 = 7;
          continue $sm;
        case 7:
          if (!true) {
            this.c6_1 = 25;
            continue $sm;
          }

          this.c6_1 = 8;
          suspendResult = DeviceManager_instance.l11(this.c1a_1, this.f1a_1, this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 8:
          this.j1a_1 = suspendResult;
          this.k1a_1 = this.j1a_1.v9();
          this.l1a_1 = this.j1a_1.w9();
          if (!this.k1a_1.equals(Result_OK_getInstance()) || this.l1a_1 == null) {
            this.w19_1 = Unit_instance;
            this.d6_1 = 34;
            this.c6_1 = 26;
            continue $sm;
          } else {
            this.c6_1 = 9;
            continue $sm;
          }

        case 9:
          this.i1a_1 = this.i1a_1.w1();
          if (this.i1a_1.equals(new Long(1, 0))) {
            this.t19_1.f1b_1.j1b(this.l1a_1, this.h1a_1);
          }

          this.m1a_1 = this.t19_1.h1b_1;
          this.t19_1.h1b_1 = null;
          this.n1a_1 = this.m1a_1;
          if (this.n1a_1 == null) {
            this.o1a_1 = null;
            this.c6_1 = 24;
            continue $sm;
          } else {
            var tmp_4 = this;
            tmp_4.p1a_1 = this.n1a_1;
            this.q1a_1 = this.p1a_1;
            var tmp_5 = this;
            tmp_5.r1a_1 = this.q1a_1;
            this.s1a_1 = this.r1a_1;
            this.t1a_1 = DeviceManager_instance.u11(this.s1a_1.g14());
            this.u1a_1 = DeviceManager_instance.v11(this.t1a_1, this.l1a_1);
            this.v1a_1 = this.s1a_1.h14();
            if (!(this.v1a_1 == null)) {
              this.c6_1 = 10;
              suspendResult = select(this.t19_1, this.c1a_1, this.f1a_1, this.v1a_1, this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            } else {
              this.x1a_1 = false;
              this.c6_1 = 11;
              continue $sm;
            }
          }

        case 10:
          this.x1a_1 = suspendResult;
          this.c6_1 = 11;
          continue $sm;
        case 11:
          if (this.x1a_1) {
            this.y1a_1 = this.s1a_1;
            var tmp_6 = this.y1a_1;
            if (tmp_6 instanceof ControlTask) {
              this.c6_1 = 17;
              suspendResult = charging(this.t19_1, this.c1a_1, this.f1a_1, this.u1a_1, this.s1a_1, this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            } else {
              var tmp_7 = this.y1a_1;
              if (tmp_7 instanceof SetKeyTask) {
                this.c6_1 = 16;
                suspendResult = setKey(this.t19_1, this.c1a_1, this.f1a_1, this.u1a_1, this.l1a_1, this.s1a_1, this);
                if (suspendResult === get_COROUTINE_SUSPENDED()) {
                  return suspendResult;
                }
                continue $sm;
              } else {
                var tmp_8 = this.y1a_1;
                if (tmp_8 instanceof SetParametersTask) {
                  this.c6_1 = 15;
                  suspendResult = setParameters(this.t19_1, this.c1a_1, this.f1a_1, this.u1a_1, this.s1a_1, this);
                  if (suspendResult === get_COROUTINE_SUSPENDED()) {
                    return suspendResult;
                  }
                  continue $sm;
                } else {
                  var tmp_9 = this.y1a_1;
                  if (tmp_9 instanceof GetLogTask) {
                    this.c6_1 = 14;
                    suspendResult = getLog(this.t19_1, this.c1a_1, this.f1a_1, this.u1a_1, this.s1a_1, this);
                    if (suspendResult === get_COROUTINE_SUSPENDED()) {
                      return suspendResult;
                    }
                    continue $sm;
                  } else {
                    var tmp_10 = this.y1a_1;
                    if (tmp_10 instanceof GetVersionTask) {
                      this.c6_1 = 13;
                      suspendResult = getVersion(this.t19_1, this.c1a_1, this.f1a_1, this.u1a_1, this.s1a_1, this);
                      if (suspendResult === get_COROUTINE_SUSPENDED()) {
                        return suspendResult;
                      }
                      continue $sm;
                    } else {
                      var tmp_11 = this.y1a_1;
                      if (tmp_11 instanceof CallFunctionTask) {
                        this.c6_1 = 12;
                        suspendResult = callFunction(this.t19_1, this.c1a_1, this.f1a_1, this.s1a_1, this);
                        if (suspendResult === get_COROUTINE_SUSPENDED()) {
                          return suspendResult;
                        }
                        continue $sm;
                      } else {
                        var tmp_12 = this;
                        noWhenBranchMatchedException();
                      }
                    }
                  }
                }
              }
            }
          } else {
            var tmp_13 = this;
            this.s1a_1.i14();
            tmp_13.w1a_1 = Unit_instance;
            this.c6_1 = 23;
            continue $sm;
          }

          break;
        case 12:
          this.z1a_1 = suspendResult;
          this.c6_1 = 22;
          continue $sm;
        case 13:
          this.z1a_1 = suspendResult;
          this.c6_1 = 22;
          continue $sm;
        case 14:
          this.z1a_1 = suspendResult;
          this.c6_1 = 22;
          continue $sm;
        case 15:
          this.z1a_1 = suspendResult;
          this.c6_1 = 22;
          continue $sm;
        case 16:
          this.z1a_1 = suspendResult;
          this.c6_1 = 22;
          continue $sm;
        case 17:
          if (suspendResult) {
            this.c6_1 = 18;
            suspendResult = control(this.t19_1, this.c1a_1, this.f1a_1, this.u1a_1, this.s1a_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }
            continue $sm;
          } else {
            this.b1b_1 = false;
            this.c6_1 = 19;
            continue $sm;
          }

        case 18:
          this.b1b_1 = suspendResult;
          this.c6_1 = 19;
          continue $sm;
        case 19:
          if (this.b1b_1) {
            this.c6_1 = 20;
            suspendResult = controlling(this.t19_1, this.c1a_1, this.f1a_1, this.u1a_1, this.s1a_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }
            continue $sm;
          } else {
            this.a1b_1 = false;
            this.c6_1 = 21;
            continue $sm;
          }

        case 20:
          this.a1b_1 = suspendResult;
          this.c6_1 = 21;
          continue $sm;
        case 21:
          this.z1a_1 = this.a1b_1;
          this.c6_1 = 22;
          continue $sm;
        case 22:
          this.w1a_1 = this.z1a_1;
          this.c6_1 = 23;
          continue $sm;
        case 23:
          this.w19_1 = Unit_instance;
          this.d6_1 = 34;
          this.c6_1 = 26;
          continue $sm;
        case 24:
          this.c6_1 = 7;
          continue $sm;
        case 25:
          this.y19_1 = this.a1a_1;
          this.c6_1 = 28;
          continue $sm;
        case 26:
          this.d6_1 = 34;
          this.c6_1 = 27;
          suspendResult = delay(new Long(2000, 0), this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 27:
          this.t19_1.f1b_1.k1b();
          this.t19_1.h1b_1 = null;
          var tmp_14 = this;
          this.t19_1.g1b_1.zn();
          return Unit_instance;
        case 28:
          this.v19_1 = this.y19_1;
          this.d6_1 = 34;
          this.c6_1 = 32;
          continue $sm;
        case 29:
          this.d6_1 = 30;
          var tmp_15 = this.f6_1;
          if (tmp_15 instanceof Exception) {
            this.c1b_1 = this.f6_1;
            var tmp_16 = this;
            tmp_16.v19_1 = Unit_instance;
            this.d6_1 = 34;
            this.c6_1 = 32;
            continue $sm;
          } else {
            throw this.f6_1;
          }

        case 30:
          this.d6_1 = 34;
          this.d1b_1 = this.f6_1;
          this.c6_1 = 31;
          suspendResult = delay(new Long(2000, 0), this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 31:
          this.t19_1.f1b_1.k1b();
          this.t19_1.h1b_1 = null;
          this.t19_1.g1b_1.zn();
          throw this.d1b_1;
        case 32:
          this.e1b_1 = this.v19_1;
          this.d6_1 = 34;
          this.c6_1 = 33;
          suspendResult = delay(new Long(2000, 0), this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 33:
          this.t19_1.f1b_1.k1b();
          this.t19_1.h1b_1 = null;
          this.t19_1.g1b_1.zn();
          return Unit_instance;
        case 34:
          throw this.f6_1;
      }
    } catch ($p) {
      var e = $p;
      if (this.d6_1 === 34) {
        throw e;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e;
      }
    }
   while (true);
};
function $selectCOROUTINE$19(_this__u8e3s4, t, device, type, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.g15_1 = _this__u8e3s4;
  this.h15_1 = t;
  this.i15_1 = device;
  this.j15_1 = type;
}
protoOf($selectCOROUTINE$19).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 2;
          this.c6_1 = 1;
          suspendResult = DeviceManager_instance.m11(this.h15_1, this.i15_1, this.j15_1, this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 1:
          var res = suspendResult;
          return res.equals(Result_OK_getInstance());
        case 2:
          throw this.f6_1;
      }
    } catch ($p) {
      var e = $p;
      if (this.d6_1 === 2) {
        throw e;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e;
      }
    }
   while (true);
};
function $chargingCOROUTINE$20(_this__u8e3s4, t, device, key, task, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.s15_1 = _this__u8e3s4;
  this.t15_1 = t;
  this.u15_1 = device;
  this.v15_1 = key;
  this.w15_1 = task;
}
protoOf($chargingCOROUTINE$20).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 3;
          this.c6_1 = 1;
          continue $sm;
        case 1:
          if (!true) {
            this.c6_1 = 4;
            continue $sm;
          }

          this.c6_1 = 2;
          suspendResult = DeviceManager_instance.p11(this.t15_1, this.u15_1, this.v15_1, this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 2:
          var _destruct__k2r9zo = suspendResult;
          var res = _destruct__k2r9zo.v9();
          var level = _destruct__k2r9zo.w9();
          this.w15_1.n14_1(res, level);
          if (!res.equals(Result_OK_getInstance()) || level == null) {
            return false;
          } else if (level.ks_1) {
            return true;
          }

          this.c6_1 = 1;
          continue $sm;
        case 3:
          throw this.f6_1;
        case 4:
          return Unit_instance;
      }
    } catch ($p) {
      var e = $p;
      if (this.d6_1 === 3) {
        throw e;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e;
      }
    }
   while (true);
};
function $controlCOROUTINE$21(_this__u8e3s4, t, device, key, task, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.f16_1 = _this__u8e3s4;
  this.g16_1 = t;
  this.h16_1 = device;
  this.i16_1 = key;
  this.j16_1 = task;
}
protoOf($controlCOROUTINE$21).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 2;
          this.c6_1 = 1;
          suspendResult = DeviceManager_instance.q11(this.g16_1, this.h16_1, this.i16_1, this.j16_1.l14_1, this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 1:
          var res = suspendResult;
          this.j16_1.o14_1(res, null);
          return res.equals(Result_OK_getInstance());
        case 2:
          throw this.f6_1;
      }
    } catch ($p) {
      var e = $p;
      if (this.d6_1 === 2) {
        throw e;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e;
      }
    }
   while (true);
};
function $controllingCOROUTINE$22(_this__u8e3s4, t, device, key, task, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.s16_1 = _this__u8e3s4;
  this.t16_1 = t;
  this.u16_1 = device;
  this.v16_1 = key;
  this.w16_1 = task;
}
protoOf($controllingCOROUTINE$22).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 3;
          this.c6_1 = 1;
          continue $sm;
        case 1:
          if (!true) {
            this.c6_1 = 4;
            continue $sm;
          }

          this.c6_1 = 2;
          suspendResult = DeviceManager_instance.r11(this.t16_1, this.u16_1, this.v16_1, this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 2:
          var _destruct__k2r9zo = suspendResult;
          var res = _destruct__k2r9zo.v9();
          var progress = _destruct__k2r9zo.w9();
          if (!this.w16_1.m14_1) {
            this.w16_1.o14_1(res, progress);
          }

          if (!res.equals(Result_OK_getInstance()) || progress == null) {
            return false;
          } else if (progress.ms_1) {
            return true;
          }

          this.c6_1 = 1;
          continue $sm;
        case 3:
          throw this.f6_1;
        case 4:
          return Unit_instance;
      }
    } catch ($p) {
      var e = $p;
      if (this.d6_1 === 3) {
        throw e;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e;
      }
    }
   while (true);
};
function $setKeyCOROUTINE$23(_this__u8e3s4, t, device, key, info, task, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.f17_1 = _this__u8e3s4;
  this.g17_1 = t;
  this.h17_1 = device;
  this.i17_1 = key;
  this.j17_1 = info;
  this.k17_1 = task;
}
protoOf($setKeyCOROUTINE$23).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 2;
          this.l17_1 = DeviceManager_instance.u11(this.k17_1.r14_1);
          this.c6_1 = 1;
          suspendResult = DeviceManager_instance.o11(this.g17_1, this.h17_1, this.j17_1, this.i17_1, this.l17_1, this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 1:
          var res = suspendResult;
          this.k17_1.s14_1(res);
          return res.equals(Result_OK_getInstance());
        case 2:
          throw this.f6_1;
      }
    } catch ($p) {
      var e = $p;
      if (this.d6_1 === 2) {
        throw e;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e;
      }
    }
   while (true);
};
function $setParametersCOROUTINE$24(_this__u8e3s4, t, device, key, task, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.u17_1 = _this__u8e3s4;
  this.v17_1 = t;
  this.w17_1 = device;
  this.x17_1 = key;
  this.y17_1 = task;
}
protoOf($setParametersCOROUTINE$24).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 2;
          this.c6_1 = 1;
          suspendResult = DeviceManager_instance.s11(this.v17_1, this.w17_1, this.x17_1, this.y17_1.l1b_1, this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 1:
          var res = suspendResult;
          this.y17_1.m1b_1(res);
          return res.equals(Result_OK_getInstance());
        case 2:
          throw this.f6_1;
      }
    } catch ($p) {
      var e = $p;
      if (this.d6_1 === 2) {
        throw e;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e;
      }
    }
   while (true);
};
function $getLogCOROUTINE$25(_this__u8e3s4, t, device, key, task, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.h18_1 = _this__u8e3s4;
  this.i18_1 = t;
  this.j18_1 = device;
  this.k18_1 = key;
  this.l18_1 = task;
}
protoOf($getLogCOROUTINE$25).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 2;
          this.c6_1 = 1;
          suspendResult = DeviceManager_instance.t11(this.i18_1, this.j18_1, this.k18_1, this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 1:
          var _destruct__k2r9zo = suspendResult;
          var res = _destruct__k2r9zo.v9();
          var logs = _destruct__k2r9zo.w9();
          this.l18_1.n1b_1(res, logs);
          return res.equals(Result_OK_getInstance());
        case 2:
          throw this.f6_1;
      }
    } catch ($p) {
      var e = $p;
      if (this.d6_1 === 2) {
        throw e;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e;
      }
    }
   while (true);
};
function $getVersionCOROUTINE$26(_this__u8e3s4, t, device, key, task, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.u18_1 = _this__u8e3s4;
  this.v18_1 = t;
  this.w18_1 = device;
  this.x18_1 = key;
  this.y18_1 = task;
}
protoOf($getVersionCOROUTINE$26).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 2;
          this.c6_1 = 1;
          suspendResult = DeviceManager_instance.n11(this.v18_1, this.w18_1, this.x18_1, this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 1:
          var _destruct__k2r9zo = suspendResult;
          var res = _destruct__k2r9zo.v9();
          var version = _destruct__k2r9zo.w9();
          this.y18_1.o1b_1(res, version);
          return res.equals(Result_OK_getInstance());
        case 2:
          throw this.f6_1;
      }
    } catch ($p) {
      var e = $p;
      if (this.d6_1 === 2) {
        throw e;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e;
      }
    }
   while (true);
};
function $callFunctionCOROUTINE$27(_this__u8e3s4, t, device, task, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.h19_1 = _this__u8e3s4;
  this.i19_1 = t;
  this.j19_1 = device;
  this.k19_1 = task;
}
protoOf($callFunctionCOROUTINE$27).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 2;
          this.c6_1 = 1;
          suspendResult = DeviceManager_instance.i11(this.i19_1, this.j19_1, this.k19_1.w14_1, this.k19_1.v14_1, VOID, this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 1:
          var _destruct__k2r9zo = suspendResult;
          var res = _destruct__k2r9zo.v9();
          var data = _destruct__k2r9zo.w9();
          this.k19_1.x14_1(res, data);
          return res.equals(Result_OK_getInstance());
        case 2:
          throw this.f6_1;
      }
    } catch ($p) {
      var e = $p;
      if (this.d6_1 === 2) {
        throw e;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e;
      }
    }
   while (true);
};
function NFCHelper(callback) {
  this.f1b_1 = callback;
  this.g1b_1 = Mutex();
  this.h1b_1 = null;
}
protoOf(NFCHelper).p1b = function (task) {
  this.h1b_1 = task;
};
protoOf(NFCHelper).q1b = function (parameter, $completion) {
  var tmp = new $processCOROUTINE$18(this, parameter, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  return tmp.k6();
};
var CustomDataConfig_WRITE_instance;
var CustomDataConfig_READ_instance;
function Companion_2() {
}
protoOf(Companion_2).fromName = function (name) {
  // Inline function 'kotlin.collections.find' call
  var tmp0 = get_entries_0();
  var tmp$ret$1;
  $l$block: {
    // Inline function 'kotlin.collections.firstOrNull' call
    var _iterator__ex2g4s = tmp0.k();
    while (_iterator__ex2g4s.l()) {
      var element = _iterator__ex2g4s.m();
      // Inline function 'com.lvcheng.lock.shared.nfc.kmp.Companion.fromName.<anonymous>' call
      if (element.h1_1 === name) {
        tmp$ret$1 = element;
        break $l$block;
      }
    }
    tmp$ret$1 = null;
  }
  return tmp$ret$1;
};
var Companion_instance_2;
function Companion_getInstance_2() {
  return Companion_instance_2;
}
function values_0() {
  return [CustomDataConfig_WRITE_getInstance(), CustomDataConfig_READ_getInstance()];
}
function valueOf(value) {
  switch (value) {
    case 'WRITE':
      return CustomDataConfig_WRITE_getInstance();
    case 'READ':
      return CustomDataConfig_READ_getInstance();
    default:
      CustomDataConfig_initEntries();
      THROW_IAE('No enum constant value.');
      break;
  }
}
function get_entries_0() {
  if ($ENTRIES_0 == null)
    $ENTRIES_0 = enumEntries(values_0());
  return $ENTRIES_0;
}
var CustomDataConfig_entriesInitialized;
function CustomDataConfig_initEntries() {
  if (CustomDataConfig_entriesInitialized)
    return Unit_instance;
  CustomDataConfig_entriesInitialized = true;
  CustomDataConfig_WRITE_instance = new CustomDataConfig('WRITE', 0, _UInt___init__impl__l7qpdl(1));
  CustomDataConfig_READ_instance = new CustomDataConfig('READ', 1, _UInt___init__impl__l7qpdl(2));
}
var $ENTRIES_0;
function CustomDataConfig(name, ordinal, value) {
  Enum.call(this, name, ordinal);
  this.value = value;
}
protoOf(CustomDataConfig).t1b = function () {
  return this.value;
};
function CustomDataConfig_WRITE_getInstance() {
  CustomDataConfig_initEntries();
  return CustomDataConfig_WRITE_instance;
}
function CustomDataConfig_READ_getInstance() {
  CustomDataConfig_initEntries();
  return CustomDataConfig_READ_instance;
}
function JsNFCCallbacks() {
}
function JsNFCHelper$nfcHelper$1$getNFCTag$2(this$0) {
  this.u1b_1 = this$0;
}
protoOf(JsNFCHelper$nfcHelper$1$getNFCTag$2).i12 = function (data, $completion) {
  return await_0(this.u1b_1.y1b(data), $completion);
};
function $getNFCTagCOROUTINE$28(_this__u8e3s4, parameter, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.h1c_1 = _this__u8e3s4;
  this.i1c_1 = parameter;
}
protoOf($getNFCTagCOROUTINE$28).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 2;
          this.c6_1 = 1;
          suspendResult = await_0(this.h1c_1.m1c_1.n1c(), this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 1:
          var tmp0_elvis_lhs = (!(suspendResult == null) ? typeof suspendResult === 'boolean' : false) ? suspendResult : null;
          var result = tmp0_elvis_lhs == null ? false : tmp0_elvis_lhs;
          var tmp_0;
          if (result) {
            tmp_0 = new JsNFCHelper$nfcHelper$1$getNFCTag$2(this.h1c_1.m1c_1);
          } else {
            tmp_0 = null;
          }

          return tmp_0;
        case 2:
          throw this.f6_1;
      }
    } catch ($p) {
      var e = $p;
      if (this.d6_1 === 2) {
        throw e;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e;
      }
    }
   while (true);
};
function control_0($this, password, ctrl) {
  var tmp = JsNFCHelper$control$lambda($this);
  $this.x1b_1.p1b(new ControlTask(password, VOID, ctrl, true, tmp, JsNFCHelper$control$lambda_0($this, ctrl)));
}
function JsNFCHelper$nfcCallbacks$1(this$0) {
  this.o1c_1 = this$0;
}
protoOf(JsNFCHelper$nfcCallbacks$1).j1b = function (info, rssi) {
  var tmp = ULong__toString_impl_f9au7k(info.os_1);
  var tmp_0;
  var tmp_1 = rssi;
  if ((tmp_1 == null ? null : new UInt(tmp_1)) == null) {
    tmp_0 = null;
  } else {
    // Inline function 'kotlin.UInt.toInt' call
    tmp_0 = _UInt___get_data__impl__f0vqqw(rssi);
  }
  this.o1c_1.v1b_1.discovered(tmp, info.ps_1, tmp_0);
};
protoOf(JsNFCHelper$nfcCallbacks$1).k1b = function () {
  this.o1c_1.v1b_1.finished();
};
function JsNFCHelper$nfcHelper$1(this$0) {
  this.m1c_1 = this$0;
  NFCHelper.call(this, this$0.w1b_1);
}
protoOf(JsNFCHelper$nfcHelper$1).i1b = function (parameter, $completion) {
  var tmp = new $getNFCTagCOROUTINE$28(this, parameter, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  return tmp.k6();
};
function JsNFCHelper$process$slambda(this$0, resultContinuation) {
  this.x1c_1 = this$0;
  CoroutineImpl.call(this, resultContinuation);
}
protoOf(JsNFCHelper$process$slambda).z1c = function ($this$launch, $completion) {
  var tmp = this.a1d($this$launch, $completion);
  tmp.e6_1 = Unit_instance;
  tmp.f6_1 = null;
  return tmp.k6();
};
protoOf(JsNFCHelper$process$slambda).u6 = function (p1, $completion) {
  return this.z1c((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $completion);
};
protoOf(JsNFCHelper$process$slambda).k6 = function () {
  var suspendResult = this.e6_1;
  $sm: do
    try {
      var tmp = this.c6_1;
      switch (tmp) {
        case 0:
          this.d6_1 = 2;
          this.c6_1 = 1;
          suspendResult = this.x1c_1.x1b_1.q1b(null, this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 1:
          return Unit_instance;
        case 2:
          throw this.f6_1;
      }
    } catch ($p) {
      var e = $p;
      if (this.d6_1 === 2) {
        throw e;
      } else {
        this.c6_1 = this.d6_1;
        this.f6_1 = e;
      }
    }
   while (true);
};
protoOf(JsNFCHelper$process$slambda).a1d = function ($this$launch, completion) {
  var i = new JsNFCHelper$process$slambda(this.x1c_1, completion);
  i.y1c_1 = $this$launch;
  return i;
};
function JsNFCHelper$process$slambda_0(this$0, resultContinuation) {
  var i = new JsNFCHelper$process$slambda(this$0, resultContinuation);
  var l = function ($this$launch, $completion) {
    return i.z1c($this$launch, $completion);
  };
  l.$arity = 1;
  return l;
}
function JsNFCHelper$control$lambda(this$0) {
  return function (res, level) {
    var tmp1_safe_receiver = level == null ? null : level.js_1;
    var tmp;
    var tmp_0 = tmp1_safe_receiver;
    if ((tmp_0 == null ? null : new UShort(tmp_0)) == null) {
      tmp = null;
    } else {
      // Inline function 'kotlin.UShort.toInt' call
      tmp = _UShort___get_data__impl__g0245(tmp1_safe_receiver) & 65535;
    }
    this$0.v1b_1.charging(res.h1_1, tmp);
    return Unit_instance;
  };
}
function JsNFCHelper$control$lambda_0(this$0, $ctrl) {
  return function (res, progress) {
    var tmp1_safe_receiver = progress == null ? null : progress.ls_1;
    var tmp;
    var tmp_0 = tmp1_safe_receiver;
    if ((tmp_0 == null ? null : new UShort(tmp_0)) == null) {
      tmp = null;
    } else {
      // Inline function 'kotlin.UShort.toInt' call
      tmp = _UShort___get_data__impl__g0245(tmp1_safe_receiver) & 65535;
    }
    this$0.v1b_1.controlling(res.h1_1, tmp, $ctrl.h1_1);
    return Unit_instance;
  };
}
function JsNFCHelper$setKey$lambda(this$0, $password) {
  return function (res) {
    this$0.v1b_1.setKey(res.h1_1, $password);
    return Unit_instance;
  };
}
function JsNFCHelper$customDataOperation$lambda($config, $customData, this$0) {
  return function (res, data) {
    var tmp;
    if (res.equals(Result_OK_getInstance()) && !(data == null)) {
      var tmp_0;
      switch ($config.i1_1) {
        case 0:
          tmp_0 = $customData;
          break;
        case 1:
          // Inline function 'kotlin.collections.asIterable' call

          // Inline function 'kotlin.collections.map' call

          var this_0 = slice_0(data, until(2, data.n()));
          // Inline function 'kotlin.collections.mapTo' call

          var destination = ArrayList_init_$Create$(collectionSizeOrDefault(this_0, 10));
          var _iterator__ex2g4s = this_0.k();
          while (_iterator__ex2g4s.l()) {
            var item = _iterator__ex2g4s.m();
            // Inline function 'com.lvcheng.lock.shared.nfc.kmp.JsNFCHelper.customDataOperation.<anonymous>.<anonymous>' call
            var it = item.nd_1;
            var tmp_1 = Companion_instance.zq(4);
            // Inline function 'kotlin.UInt.toInt' call
            var tmp$ret$1 = _UInt___get_data__impl__f0vqqw(it);
            var tmp$ret$2 = tmp_1.cr(tmp$ret$1).dr();
            destination.u(tmp$ret$2);
          }

          // Inline function 'kotlin.byteArrayOf' call

          // Inline function 'kotlin.collections.fold' call

          var accumulator = new Int8Array([]);
          var _iterator__ex2g4s_0 = destination.k();
          while (_iterator__ex2g4s_0.l()) {
            var element = _iterator__ex2g4s_0.m();
            // Inline function 'com.lvcheng.lock.shared.nfc.kmp.JsNFCHelper.customDataOperation.<anonymous>.<anonymous>' call
            // Inline function 'kotlin.collections.plus' call
            var this_1 = accumulator;
            accumulator = primitiveArrayConcat([this_1, element]);
          }

          tmp_0 = accumulator;
          break;
        default:
          noWhenBranchMatchedException();
          break;
      }
      var returnData = tmp_0;
      this$0.v1b_1.customData(res.h1_1, $config, returnData);
      tmp = Unit_instance;
    } else {
      this$0.v1b_1.customData('ERROR', $config, null);
      tmp = Unit_instance;
    }
    return Unit_instance;
  };
}
function JsNFCHelper(callback) {
  this.v1b_1 = callback;
  var tmp = this;
  tmp.w1b_1 = new JsNFCHelper$nfcCallbacks$1(this);
  var tmp_0 = this;
  tmp_0.x1b_1 = new JsNFCHelper$nfcHelper$1(this);
}
protoOf(JsNFCHelper).mp = function () {
  var tmp = MainScope();
  launch(tmp, VOID, VOID, JsNFCHelper$process$slambda_0(this, null));
};
protoOf(JsNFCHelper).cancel = function () {
  this.x1b_1.p1b(null);
};
protoOf(JsNFCHelper).lock = function (password) {
  control_0(this, password, Ctrl_LOCK_getInstance());
};
protoOf(JsNFCHelper).unlock = function (password) {
  control_0(this, password, Ctrl_UNLOCK_getInstance());
};
protoOf(JsNFCHelper).setKey = function (password, sKey) {
  this.x1b_1.p1b(new SetKeyTask(password, VOID, sKey, JsNFCHelper$setKey$lambda(this, password)));
};
protoOf(JsNFCHelper).customDataOperation = function (config, customData) {
  var fixedCustomDataSize = 56;
  var tmp;
  if (customData == null) {
    var tmp_0 = 0;
    var tmp_1 = new Int8Array(fixedCustomDataSize);
    while (tmp_0 < fixedCustomDataSize) {
      tmp_1[tmp_0] = 0;
      tmp_0 = tmp_0 + 1 | 0;
    }
    tmp = tmp_1;
  } else {
    tmp = customData;
  }
  var customData0 = tmp;
  // Inline function 'kotlin.require' call
  if (!(customData0.length === fixedCustomDataSize)) {
    // Inline function 'com.lvcheng.lock.shared.nfc.kmp.JsNFCHelper.customDataOperation.<anonymous>' call
    var message = 'Custom data size must be ' + fixedCustomDataSize;
    throw IllegalArgumentException_init_$Create$(toString(message));
  }
  // Inline function 'kotlin.collections.map' call
  var this_0 = chunked(asIterable(customData0), 4);
  // Inline function 'kotlin.collections.mapTo' call
  var destination = ArrayList_init_$Create$(collectionSizeOrDefault(this_0, 10));
  var _iterator__ex2g4s = this_0.k();
  while (_iterator__ex2g4s.l()) {
    var item = _iterator__ex2g4s.m();
    // Inline function 'com.lvcheng.lock.shared.nfc.kmp.JsNFCHelper.customDataOperation.<anonymous>' call
    // Inline function 'kotlin.toUInt' call
    var this_1 = Companion_instance.er(toByteArray(item)).fr();
    var tmp$ret$2 = _UInt___init__impl__l7qpdl(this_1);
    var tmp$ret$3 = new UInt(tmp$ret$2);
    destination.u(tmp$ret$3);
  }
  var dataUInts = destination;
  var tmp_2 = UserType_NORMAL_getInstance();
  // Inline function 'kotlin.collections.buildList' call
  // Inline function 'kotlin.collections.buildListInternal' call
  // Inline function 'kotlin.apply' call
  var this_2 = ArrayList_init_$Create$_0();
  // Inline function 'com.lvcheng.lock.shared.nfc.kmp.JsNFCHelper.customDataOperation.<anonymous>' call
  this_2.u(new UInt(config.value));
  this_2.r(dataUInts);
  var tmp_3 = this_2.s3();
  var tmp_4 = _UByte___init__impl__g9hnc4(4);
  this.x1b_1.p1b(new CallFunctionTask('', tmp_2, tmp_3, tmp_4, JsNFCHelper$customDataOperation$lambda(config, customData, this)));
};
function platformGetCurrentTimestamp() {
  return numberToLong(Date.now());
}
function WebViewNFCHelper(callback) {
  JsNFCHelper.call(this, callback);
}
protoOf(WebViewNFCHelper).tagDetected = function () {
  this.mp();
};
protoOf(WebViewNFCHelper).vf = function () {
  return Promise.resolve(true);
};
protoOf(WebViewNFCHelper).start = function () {
  return this.vf();
};
protoOf(WebViewNFCHelper).e1d = function () {
  return Promise.resolve(true);
};
protoOf(WebViewNFCHelper).stop = function () {
  return this.e1d();
};
protoOf(WebViewNFCHelper).n1c = function () {
  return Promise.resolve(true);
};
protoOf(WebViewNFCHelper).y1b = function (data) {
  var tmp = new Promise(function (resolve) {
    globalThis.nTransceive({data: new Int8Array(data), success: function (res) {
      resolve(new Int8Array(res));
    }, fail: function (err) {
      console.error(err);
      resolve(new Int8Array([]));
    }});
  });
  return tmp instanceof Promise ? tmp : THROW_CCE();
};
function WxNFCHelper$start$lambda(this$0) {
  return function () {
    this$0.mp();
    return Unit_instance;
  };
}
function WxNFCHelper(callback) {
  JsNFCHelper.call(this, callback);
}
protoOf(WxNFCHelper).vf = function () {
  var discoveredCb = WxNFCHelper$start$lambda(this);
  var adapter = wx.getNFCAdapter();
  var tmp = function () {
    adapter.onDiscovered(function () {
      discoveredCb();
    });
    return new Promise(function (resolve) {
      adapter.startDiscovery({success: function () {
        resolve(true);
      }, fail: function (err) {
        resolve(err);
      }});
    });
  }.call(this);
  return tmp instanceof Promise ? tmp : THROW_CCE();
};
protoOf(WxNFCHelper).start = function () {
  return this.vf();
};
protoOf(WxNFCHelper).e1d = function () {
  return Promise.resolve(true);
};
protoOf(WxNFCHelper).stop = function () {
  return this.e1d();
};
protoOf(WxNFCHelper).n1c = function () {
  var adapter = wx.getNFCAdapter();
  var nfcA = adapter.getNfcA();
  var tmp = new Promise(function (resolve) {
    nfcA.connect({success: function () {
      resolve(true);
    }, fail: function (err) {
      resolve(err);
    }});
  });
  return tmp instanceof Promise ? tmp : THROW_CCE();
};
protoOf(WxNFCHelper).y1b = function (data) {
  var adapter = wx.getNFCAdapter();
  var nfcA = adapter.getNfcA();
  var tmp = new Promise(function (resolve) {
    nfcA.transceive({data: (new Int8Array(data)).buffer, success: function (res) {
      resolve(new Int8Array(res.data));
    }, fail: function (err) {
      console.error(err);
      resolve(new Int8Array([]));
    }});
  });
  return tmp instanceof Promise ? tmp : THROW_CCE();
};
//region block: post-declaration
defineProp(protoOf(CustomDataConfig), 'name', protoOf(CustomDataConfig).j1);
defineProp(protoOf(CustomDataConfig), 'ordinal', protoOf(CustomDataConfig).k1);
//endregion
//region block: init
AESUtil_instance = new AESUtil();
Companion_instance = new Companion();
CMD_instance = new CMD();
DeviceManager_instance = new DeviceManager();
Companion_instance_0 = new Companion_0();
Companion_instance_1 = new Companion_1();
NFCUtil_instance = new NFCUtil();
Companion_instance_2 = new Companion_2();
//endregion
//region block: exports
CustomDataConfig.values = values_0;
CustomDataConfig.valueOf = valueOf;
defineProp(CustomDataConfig, 'WRITE', CustomDataConfig_WRITE_getInstance);
defineProp(CustomDataConfig, 'READ', CustomDataConfig_READ_getInstance);
defineProp(CustomDataConfig, 'Companion', Companion_getInstance_2);
export {
  CustomDataConfig as CustomDataConfig,
  WebViewNFCHelper as WebViewNFCHelper,
  WxNFCHelper as WxNFCHelper,
};
//endregion

//# sourceMappingURL=NFCSDK-shared-nfc-kmp.mjs.map
