(function (_, kotlin_kotlin) {
  'use strict';
  //region block: imports
  var split = kotlin_kotlin.$_$.sj;
  var collectionSizeOrDefault = kotlin_kotlin.$_$.b8;
  var ArrayList_init_$Create$ = kotlin_kotlin.$_$.r;
  var THROW_CCE = kotlin_kotlin.$_$.hm;
  var isCharSequence = kotlin_kotlin.$_$.df;
  var trim = kotlin_kotlin.$_$.el;
  var toString = kotlin_kotlin.$_$.cg;
  var VOID = kotlin_kotlin.$_$.g;
  var Pair = kotlin_kotlin.$_$.em;
  var toMap = kotlin_kotlin.$_$.oc;
  //endregion
  //region block: pre-declaration
  //endregion
  function directivesToMap(header) {
    // Inline function 'kotlin.collections.map' call
    var this_0 = split(header, [',']);
    // Inline function 'kotlin.collections.mapTo' call
    var destination = ArrayList_init_$Create$(collectionSizeOrDefault(this_0, 10));
    var tmp0_iterator = this_0.iterator_jk1svi_k$();
    while (tmp0_iterator.hasNext_bitz1p_k$()) {
      var item = tmp0_iterator.next_20eer_k$();
      // Inline function 'com.ustadmobile.ihttp.headers.directives.directivesToMap.<anonymous>' call
      // Inline function 'kotlin.text.trim' call
      // Inline function 'kotlin.text.lowercase' call
      // Inline function 'kotlin.js.asDynamic' call
      var this_1 = item.toLowerCase();
      var tmp$ret$3 = toString(trim(isCharSequence(this_1) ? this_1 : THROW_CCE()));
      destination.add_utx5q5_k$(tmp$ret$3);
    }
    var directives = destination;
    // Inline function 'kotlin.collections.map' call
    // Inline function 'kotlin.collections.mapTo' call
    var destination_0 = ArrayList_init_$Create$(collectionSizeOrDefault(directives, 10));
    var tmp0_iterator_0 = directives.iterator_jk1svi_k$();
    while (tmp0_iterator_0.hasNext_bitz1p_k$()) {
      var item_0 = tmp0_iterator_0.next_20eer_k$();
      // Inline function 'com.ustadmobile.ihttp.headers.directives.directivesToMap.<anonymous>' call
      var directiveSplit = split(item_0, ['='], VOID, 2);
      var tmp;
      if (directiveSplit.get_size_woubt6_k$() === 1) {
        tmp = new Pair(item_0, '');
      } else {
        tmp = new Pair(directiveSplit.get_c1px32_k$(0), directiveSplit.get_c1px32_k$(1));
      }
      var tmp$ret$6 = tmp;
      destination_0.add_utx5q5_k$(tmp$ret$6);
    }
    return toMap(destination_0);
  }
  //region block: exports
  _.$_$ = _.$_$ || {};
  _.$_$.a = directivesToMap;
  //endregion
  return _;
}(module.exports, require('./kotlin-kotlin-stdlib.js')));
