(function (_, kotlin_kotlin) { 'use strict'; //region block: imports var imul = Math.imul; var protoOf = kotlin_kotlin.$_$.hd; var setOf = kotlin_kotlin.$_$.r9; var listOf = kotlin_kotlin.$_$.r8; var THROW_CCE = kotlin_kotlin.$_$.wi; var getStringHashCode = kotlin_kotlin.$_$.ec; var Map = kotlin_kotlin.$_$.b6; var Entry = kotlin_kotlin.$_$.a6; var classMeta = kotlin_kotlin.$_$.tb; var setMetadataFor = kotlin_kotlin.$_$.id; var VOID = kotlin_kotlin.$_$.f; var emptyMap = kotlin_kotlin.$_$.q7; var LinkedHashMap_init_$Create$ = kotlin_kotlin.$_$.y; var MutableMap = kotlin_kotlin.$_$.d6; var isInterface = kotlin_kotlin.$_$.pc; var Unit_instance = kotlin_kotlin.$_$.o5; var ArrayList_init_$Create$ = kotlin_kotlin.$_$.o; var IllegalStateException_init_$Create$ = kotlin_kotlin.$_$.c2; var ensureNotNull = kotlin_kotlin.$_$.oj; var last = kotlin_kotlin.$_$.o8; var get_lastIndex = kotlin_kotlin.$_$.l8; //endregion //region block: pre-declaration setMetadataFor(SingletonStringMap, 'SingletonStringMap', classMeta, VOID, [Map, Entry]); setMetadataFor(DelegatingMap, 'DelegatingMap', classMeta, VOID, [MutableMap]); setMetadataFor(FinalizeConsumer, 'FinalizeConsumer', classMeta); setMetadataFor(HTMLTag, 'HTMLTag', classMeta); setMetadataFor(DIV, 'DIV', classMeta, HTMLTag); setMetadataFor(JSDOMBuilder, 'JSDOMBuilder', classMeta); //endregion function get_emptyMap() { _init_properties_api_kt__c2p01k(); return emptyMap_0; } var emptyMap_0; function attributesMapOf(key, value) { _init_properties_api_kt__c2p01k(); return value == null ? get_emptyMap() : singletonMapOf(key, value); } function singletonMapOf(key, value) { _init_properties_api_kt__c2p01k(); return new SingletonStringMap(key, value); } function SingletonStringMap(key, value) { this.u135_1 = key; this.v135_1 = value; } protoOf(SingletonStringMap).s2 = function () { return this.u135_1; }; protoOf(SingletonStringMap).t2 = function () { return this.v135_1; }; protoOf(SingletonStringMap).q2 = function () { return setOf(this); }; protoOf(SingletonStringMap).o2 = function () { return setOf(this.u135_1); }; protoOf(SingletonStringMap).u = function () { return 1; }; protoOf(SingletonStringMap).p2 = function () { return listOf(this.v135_1); }; protoOf(SingletonStringMap).z2m = function (key) { return key === this.u135_1; }; protoOf(SingletonStringMap).r = function (key) { if (!(!(key == null) ? typeof key === 'string' : false)) return false; return this.z2m((!(key == null) ? typeof key === 'string' : false) ? key : THROW_CCE()); }; protoOf(SingletonStringMap).ca = function (key) { return key === this.u135_1 ? this.v135_1 : null; }; protoOf(SingletonStringMap).q = function (key) { if (!(!(key == null) ? typeof key === 'string' : false)) return null; return this.ca((!(key == null) ? typeof key === 'string' : false) ? key : THROW_CCE()); }; protoOf(SingletonStringMap).d1 = function () { return false; }; protoOf(SingletonStringMap).toString = function () { return 'SingletonStringMap(key=' + this.u135_1 + ', value=' + this.v135_1 + ')'; }; protoOf(SingletonStringMap).hashCode = function () { var result = getStringHashCode(this.u135_1); result = imul(result, 31) + getStringHashCode(this.v135_1) | 0; return result; }; protoOf(SingletonStringMap).equals = function (other) { if (this === other) return true; if (!(other instanceof SingletonStringMap)) return false; var tmp0_other_with_cast = other instanceof SingletonStringMap ? other : THROW_CCE(); if (!(this.u135_1 === tmp0_other_with_cast.u135_1)) return false; if (!(this.v135_1 === tmp0_other_with_cast.v135_1)) return false; return true; }; var properties_initialized_api_kt_zfwuc6; function _init_properties_api_kt__c2p01k() { if (!properties_initialized_api_kt_zfwuc6) { properties_initialized_api_kt_zfwuc6 = true; emptyMap_0 = emptyMap(); } } function switchToMutable($this) { var tmp; if ($this.z135_1) { tmp = $this.y135_1; } else { $this.z135_1 = true; $this.y135_1 = LinkedHashMap_init_$Create$($this.y135_1); tmp = $this.y135_1; } var tmp_0 = tmp; return isInterface(tmp_0, MutableMap) ? tmp_0 : THROW_CCE(); } function DelegatingMap(initialValues, tag, consumer) { this.w135_1 = tag; this.x135_1 = consumer; this.y135_1 = initialValues; this.z135_1 = false; } protoOf(DelegatingMap).u = function () { return this.y135_1.u(); }; protoOf(DelegatingMap).d1 = function () { return this.y135_1.d1(); }; protoOf(DelegatingMap).z2m = function (key) { return this.y135_1.r(key); }; protoOf(DelegatingMap).r = function (key) { if (!(!(key == null) ? typeof key === 'string' : false)) return false; return this.z2m((!(key == null) ? typeof key === 'string' : false) ? key : THROW_CCE()); }; protoOf(DelegatingMap).ca = function (key) { return this.y135_1.q(key); }; protoOf(DelegatingMap).q = function (key) { if (!(!(key == null) ? typeof key === 'string' : false)) return null; return this.ca((!(key == null) ? typeof key === 'string' : false) ? key : THROW_CCE()); }; protoOf(DelegatingMap).a136 = function (key, value) { var mutable = switchToMutable(this); var old = mutable.s(key, value); if (!(old === value)) { this.x135_1().b136(this.w135_1, key, value); } return old; }; protoOf(DelegatingMap).s = function (key, value) { var tmp = (!(key == null) ? typeof key === 'string' : false) ? key : THROW_CCE(); return this.a136(tmp, (!(value == null) ? typeof value === 'string' : false) ? value : THROW_CCE()); }; protoOf(DelegatingMap).c2n = function (key) { var mutable = switchToMutable(this); var tmp0_safe_receiver = mutable.u2(key); var tmp; if (tmp0_safe_receiver == null) { tmp = null; } else { // Inline function 'kotlin.let' call // Inline function 'kotlin.contracts.contract' call // Inline function 'kotlinx.html.impl.DelegatingMap.remove.' call this.x135_1().b136(this.w135_1, key, null); tmp = tmp0_safe_receiver; } return tmp; }; protoOf(DelegatingMap).u2 = function (key) { if (!(!(key == null) ? typeof key === 'string' : false)) return null; return this.c2n((!(key == null) ? typeof key === 'string' : false) ? key : THROW_CCE()); }; protoOf(DelegatingMap).c136 = function (from) { if (from.d1()) return Unit_instance; var consumer = this.x135_1(); var mutable = switchToMutable(this); // Inline function 'kotlin.collections.forEach' call var tmp0_iterator = from.q2().w(); while (tmp0_iterator.f()) { var element = tmp0_iterator.e(); // Inline function 'kotlinx.html.impl.DelegatingMap.putAll.' call if (!(mutable.s(element.s2(), element.t2()) === element.t2())) { consumer.b136(this.w135_1, element.s2(), element.t2()); } } }; protoOf(DelegatingMap).r2 = function (from) { return this.c136(from); }; protoOf(DelegatingMap).o1 = function () { // Inline function 'kotlin.collections.forEach' call // Inline function 'kotlin.collections.iterator' call var tmp0_iterator = this.y135_1.q2().w(); while (tmp0_iterator.f()) { var element = tmp0_iterator.e(); // Inline function 'kotlinx.html.impl.DelegatingMap.clear.' call this.x135_1().b136(this.w135_1, element.s2(), null); } this.y135_1 = emptyMap(); this.z135_1 = false; }; protoOf(DelegatingMap).d136 = function () { return this.y135_1.q2(); }; protoOf(DelegatingMap).o2 = function () { return switchToMutable(this).o2(); }; protoOf(DelegatingMap).p2 = function () { return switchToMutable(this).p2(); }; protoOf(DelegatingMap).q2 = function () { return switchToMutable(this).q2(); }; function onFinalize(_this__u8e3s4, block) { return new FinalizeConsumer(_this__u8e3s4, onFinalize$lambda(block)); } function FinalizeConsumer(downstream, block) { this.e136_1 = downstream; this.f136_1 = block; this.g136_1 = 0; } protoOf(FinalizeConsumer).h136 = function (tag) { this.e136_1.h136(tag); this.g136_1 = this.g136_1 + 1 | 0; }; protoOf(FinalizeConsumer).i136 = function (tag) { this.e136_1.i136(tag); this.g136_1 = this.g136_1 - 1 | 0; }; protoOf(FinalizeConsumer).b136 = function (tag, attribute, value) { return this.e136_1.b136(tag, attribute, value); }; protoOf(FinalizeConsumer).j136 = function () { return this.f136_1(this.e136_1.j136(), this.g136_1 > 0); }; function onFinalize$lambda($block) { return function (to, partial) { $block(to, partial); return to; }; } function DIV(initialAttributes, consumer) { HTMLTag.call(this, 'div', consumer, initialAttributes, null, false, false); this.q136_1 = consumer; } protoOf(DIV).r136 = function () { return this.q136_1; }; function HTMLTag$attributes$lambda(this$0) { return function () { return this$0.r136(); }; } function HTMLTag(tagName, consumer, initialAttributes, namespace, inlineTag, emptyTag) { namespace = namespace === VOID ? null : namespace; this.s136_1 = tagName; this.t136_1 = consumer; this.u136_1 = namespace; this.v136_1 = inlineTag; this.w136_1 = emptyTag; var tmp = this; tmp.x136_1 = new DelegatingMap(initialAttributes, this, HTMLTag$attributes$lambda(this)); } protoOf(HTMLTag).llp = function () { return this.s136_1; }; protoOf(HTMLTag).r136 = function () { return this.t136_1; }; protoOf(HTMLTag).cmb = function () { return this.u136_1; }; protoOf(HTMLTag).x3a = function () { return this.x136_1; }; protoOf(HTMLTag).y136 = function () { return this.x3a().d136(); }; function append(_this__u8e3s4, block) { // Inline function 'kotlin.let' call // Inline function 'kotlin.contracts.contract' call // Inline function 'kotlinx.html.dom.append.' call var result = ArrayList_init_$Create$(); var tmp = createTree(get_ownerDocumentExt(_this__u8e3s4)); block(onFinalize(tmp, append$lambda(result, _this__u8e3s4))); return result; } function createTree(_this__u8e3s4) { return new JSDOMBuilder(_this__u8e3s4); } function get_ownerDocumentExt(_this__u8e3s4) { var tmp; if (_this__u8e3s4 instanceof Document) { tmp = _this__u8e3s4; } else { var tmp0_elvis_lhs = _this__u8e3s4.ownerDocument; var tmp_0; if (tmp0_elvis_lhs == null) { throw IllegalStateException_init_$Create$('Node has no ownerDocument'); } else { tmp_0 = tmp0_elvis_lhs; } tmp = tmp_0; } return tmp; } function asR(_this__u8e3s4, $this) { // Inline function 'kotlin.js.asDynamic' call return _this__u8e3s4; } function JSDOMBuilder(document) { this.z136_1 = document; var tmp = this; // Inline function 'kotlin.collections.arrayListOf' call tmp.a137_1 = ArrayList_init_$Create$(); this.b137_1 = null; } protoOf(JSDOMBuilder).h136 = function (tag) { var tmp; if (!(tag.cmb() == null)) { // Inline function 'kotlin.js.asDynamic' call tmp = this.z136_1.createElementNS(ensureNotNull(tag.cmb()), tag.llp()); } else { var tmp_0 = this.z136_1.createElement(tag.llp()); tmp = tmp_0 instanceof HTMLElement ? tmp_0 : THROW_CCE(); } var element = tmp; // Inline function 'kotlin.collections.forEach' call var tmp0_iterator = tag.y136().w(); while (tmp0_iterator.f()) { var element_0 = tmp0_iterator.e(); // Inline function 'kotlinx.html.dom.JSDOMBuilder.onTagStart.' call element.setAttribute(element_0.s2(), element_0.t2()); } // Inline function 'kotlin.collections.isNotEmpty' call if (!this.a137_1.d1()) { last(this.a137_1).appendChild(element); } this.a137_1.j1(element); }; protoOf(JSDOMBuilder).b136 = function (tag, attribute, value) { if (this.a137_1.d1()) throw IllegalStateException_init_$Create$('No current tag'); else { // Inline function 'kotlin.text.lowercase' call // Inline function 'kotlin.js.asDynamic' call var tmp = last(this.a137_1).tagName.toLowerCase(); // Inline function 'kotlin.text.lowercase' call // Inline function 'kotlin.js.asDynamic' call if (!(tmp === tag.llp().toLowerCase())) throw IllegalStateException_init_$Create$('Wrong current tag'); else { // Inline function 'kotlin.let' call // Inline function 'kotlin.contracts.contract' call var node = last(this.a137_1); var tmp_0; if (value == null) { node.removeAttribute(attribute); tmp_0 = Unit_instance; } else { node.setAttribute(attribute, value); tmp_0 = Unit_instance; } } } }; protoOf(JSDOMBuilder).i136 = function (tag) { var tmp; if (this.a137_1.d1()) { tmp = true; } else { // Inline function 'kotlin.text.lowercase' call // Inline function 'kotlin.js.asDynamic' call var tmp_0 = last(this.a137_1).tagName.toLowerCase(); // Inline function 'kotlin.text.lowercase' call // Inline function 'kotlin.js.asDynamic' call tmp = !(tmp_0 === tag.llp().toLowerCase()); } if (tmp) { throw IllegalStateException_init_$Create$("We haven't entered tag " + tag.llp() + ' but trying to leave'); } this.b137_1 = this.a137_1.t1(get_lastIndex(this.a137_1)); }; protoOf(JSDOMBuilder).j136 = function () { var tmp0_safe_receiver = this.b137_1; var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : asR(tmp0_safe_receiver, this); var tmp; if (tmp1_elvis_lhs == null) { throw IllegalStateException_init_$Create$("We can't finalize as there was no tags"); } else { tmp = tmp1_elvis_lhs; } return tmp; }; function append$lambda($result, $this_append) { return function (it, partial) { var tmp; if (!partial) { $result.j1(it); $this_append.appendChild(it); tmp = Unit_instance; } return Unit_instance; }; } //region block: exports _.$_$ = _.$_$ || {}; _.$_$.a = append; _.$_$.b = DIV; _.$_$.c = attributesMapOf; //endregion return _; }(module.exports, require('./kotlin-kotlin-stdlib.js'))); //# sourceMappingURL=kotlinx-html.js.map