(function (_, kotlin_kotlin) { 'use strict'; //region block: imports var imul = Math.imul; var protoOf = kotlin_kotlin.$_$.ed; var setOf = kotlin_kotlin.$_$.o9; var listOf = kotlin_kotlin.$_$.o8; var THROW_CCE = kotlin_kotlin.$_$.si; var getStringHashCode = kotlin_kotlin.$_$.bc; var Map = kotlin_kotlin.$_$.z5; var Entry = kotlin_kotlin.$_$.y5; var classMeta = kotlin_kotlin.$_$.qb; var setMetadataFor = kotlin_kotlin.$_$.fd; var VOID = kotlin_kotlin.$_$.f; var emptyMap = kotlin_kotlin.$_$.o7; var LinkedHashMap_init_$Create$ = kotlin_kotlin.$_$.w; var MutableMap = kotlin_kotlin.$_$.b6; var isInterface = kotlin_kotlin.$_$.mc; var Unit_instance = kotlin_kotlin.$_$.m5; var ArrayList_init_$Create$ = kotlin_kotlin.$_$.m; var IllegalStateException_init_$Create$ = kotlin_kotlin.$_$.a2; var ensureNotNull = kotlin_kotlin.$_$.kj; var last = kotlin_kotlin.$_$.l8; var get_lastIndex = kotlin_kotlin.$_$.i8; //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.j10v_1 = key; this.k10v_1 = value; } protoOf(SingletonStringMap).s2 = function () { return this.j10v_1; }; protoOf(SingletonStringMap).t2 = function () { return this.k10v_1; }; protoOf(SingletonStringMap).q2 = function () { return setOf(this); }; protoOf(SingletonStringMap).o2 = function () { return setOf(this.j10v_1); }; protoOf(SingletonStringMap).u = function () { return 1; }; protoOf(SingletonStringMap).p2 = function () { return listOf(this.k10v_1); }; protoOf(SingletonStringMap).w2m = function (key) { return key === this.j10v_1; }; protoOf(SingletonStringMap).r = function (key) { if (!(!(key == null) ? typeof key === 'string' : false)) return false; return this.w2m((!(key == null) ? typeof key === 'string' : false) ? key : THROW_CCE()); }; protoOf(SingletonStringMap).ca = function (key) { return key === this.j10v_1 ? this.k10v_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.j10v_1 + ', value=' + this.k10v_1 + ')'; }; protoOf(SingletonStringMap).hashCode = function () { var result = getStringHashCode(this.j10v_1); result = imul(result, 31) + getStringHashCode(this.k10v_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.j10v_1 === tmp0_other_with_cast.j10v_1)) return false; if (!(this.k10v_1 === tmp0_other_with_cast.k10v_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.o10v_1) { tmp = $this.n10v_1; } else { $this.o10v_1 = true; $this.n10v_1 = LinkedHashMap_init_$Create$($this.n10v_1); tmp = $this.n10v_1; } var tmp_0 = tmp; return isInterface(tmp_0, MutableMap) ? tmp_0 : THROW_CCE(); } function DelegatingMap(initialValues, tag, consumer) { this.l10v_1 = tag; this.m10v_1 = consumer; this.n10v_1 = initialValues; this.o10v_1 = false; } protoOf(DelegatingMap).u = function () { return this.n10v_1.u(); }; protoOf(DelegatingMap).d1 = function () { return this.n10v_1.d1(); }; protoOf(DelegatingMap).w2m = function (key) { return this.n10v_1.r(key); }; protoOf(DelegatingMap).r = function (key) { if (!(!(key == null) ? typeof key === 'string' : false)) return false; return this.w2m((!(key == null) ? typeof key === 'string' : false) ? key : THROW_CCE()); }; protoOf(DelegatingMap).ca = function (key) { return this.n10v_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).p10v = function (key, value) { var mutable = switchToMutable(this); var old = mutable.s(key, value); if (!(old === value)) { this.m10v_1().q10v(this.l10v_1, key, value); } return old; }; protoOf(DelegatingMap).s = function (key, value) { var tmp = (!(key == null) ? typeof key === 'string' : false) ? key : THROW_CCE(); return this.p10v(tmp, (!(value == null) ? typeof value === 'string' : false) ? value : THROW_CCE()); }; protoOf(DelegatingMap).z2m = 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.m10v_1().q10v(this.l10v_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.z2m((!(key == null) ? typeof key === 'string' : false) ? key : THROW_CCE()); }; protoOf(DelegatingMap).r10v = function (from) { if (from.d1()) return Unit_instance; var consumer = this.m10v_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.q10v(this.l10v_1, element.s2(), element.t2()); } } }; protoOf(DelegatingMap).r2 = function (from) { return this.r10v(from); }; protoOf(DelegatingMap).o1 = function () { // Inline function 'kotlin.collections.forEach' call // Inline function 'kotlin.collections.iterator' call var tmp0_iterator = this.n10v_1.q2().w(); while (tmp0_iterator.f()) { var element = tmp0_iterator.e(); // Inline function 'kotlinx.html.impl.DelegatingMap.clear.' call this.m10v_1().q10v(this.l10v_1, element.s2(), null); } this.n10v_1 = emptyMap(); this.o10v_1 = false; }; protoOf(DelegatingMap).s10v = function () { return this.n10v_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.t10v_1 = downstream; this.u10v_1 = block; this.v10v_1 = 0; } protoOf(FinalizeConsumer).w10v = function (tag) { this.t10v_1.w10v(tag); this.v10v_1 = this.v10v_1 + 1 | 0; }; protoOf(FinalizeConsumer).x10v = function (tag) { this.t10v_1.x10v(tag); this.v10v_1 = this.v10v_1 - 1 | 0; }; protoOf(FinalizeConsumer).q10v = function (tag, attribute, value) { return this.t10v_1.q10v(tag, attribute, value); }; protoOf(FinalizeConsumer).y10v = function () { return this.u10v_1(this.t10v_1.y10v(), this.v10v_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.f10w_1 = consumer; } protoOf(DIV).g10w = function () { return this.f10w_1; }; function HTMLTag$attributes$lambda(this$0) { return function () { return this$0.g10w(); }; } function HTMLTag(tagName, consumer, initialAttributes, namespace, inlineTag, emptyTag) { namespace = namespace === VOID ? null : namespace; this.h10w_1 = tagName; this.i10w_1 = consumer; this.j10w_1 = namespace; this.k10w_1 = inlineTag; this.l10w_1 = emptyTag; var tmp = this; tmp.m10w_1 = new DelegatingMap(initialAttributes, this, HTMLTag$attributes$lambda(this)); } protoOf(HTMLTag).xkz = function () { return this.h10w_1; }; protoOf(HTMLTag).g10w = function () { return this.i10w_1; }; protoOf(HTMLTag).oll = function () { return this.j10w_1; }; protoOf(HTMLTag).u3a = function () { return this.m10w_1; }; protoOf(HTMLTag).n10w = function () { return this.u3a().s10v(); }; 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.o10w_1 = document; var tmp = this; // Inline function 'kotlin.collections.arrayListOf' call tmp.p10w_1 = ArrayList_init_$Create$(); this.q10w_1 = null; } protoOf(JSDOMBuilder).w10v = function (tag) { var tmp; if (!(tag.oll() == null)) { // Inline function 'kotlin.js.asDynamic' call tmp = this.o10w_1.createElementNS(ensureNotNull(tag.oll()), tag.xkz()); } else { var tmp_0 = this.o10w_1.createElement(tag.xkz()); tmp = tmp_0 instanceof HTMLElement ? tmp_0 : THROW_CCE(); } var element = tmp; // Inline function 'kotlin.collections.forEach' call var tmp0_iterator = tag.n10w().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.p10w_1.d1()) { last(this.p10w_1).appendChild(element); } this.p10w_1.j1(element); }; protoOf(JSDOMBuilder).q10v = function (tag, attribute, value) { if (this.p10w_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.p10w_1).tagName.toLowerCase(); // Inline function 'kotlin.text.lowercase' call // Inline function 'kotlin.js.asDynamic' call if (!(tmp === tag.xkz().toLowerCase())) throw IllegalStateException_init_$Create$('Wrong current tag'); else { // Inline function 'kotlin.let' call // Inline function 'kotlin.contracts.contract' call var node = last(this.p10w_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).x10v = function (tag) { var tmp; if (this.p10w_1.d1()) { tmp = true; } else { // Inline function 'kotlin.text.lowercase' call // Inline function 'kotlin.js.asDynamic' call var tmp_0 = last(this.p10w_1).tagName.toLowerCase(); // Inline function 'kotlin.text.lowercase' call // Inline function 'kotlin.js.asDynamic' call tmp = !(tmp_0 === tag.xkz().toLowerCase()); } if (tmp) { throw IllegalStateException_init_$Create$("We haven't entered tag " + tag.xkz() + ' but trying to leave'); } this.q10w_1 = this.p10w_1.t1(get_lastIndex(this.p10w_1)); }; protoOf(JSDOMBuilder).y10v = function () { var tmp0_safe_receiver = this.q10w_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