UNPKG

@earth-app/shovel

Version:

Kotlin Multiplatform Web Scraping Framework

702 lines (695 loc) 28.5 kB
(function (factory) { if (typeof define === 'function' && define.amd) define(['exports', './kotlin-kotlin-stdlib.js', './ktor-ktor-client-ktor-client-core.js', './ktor-ktor-http.js', './kotlinx-io-kotlinx-io-core.js', './ktor-ktor-io.js', './ksoup-ksoup.js', './kotlinx-coroutines-core.js'], factory); else if (typeof exports === 'object') factory(module.exports, require('./kotlin-kotlin-stdlib.js'), require('./ktor-ktor-client-ktor-client-core.js'), require('./ktor-ktor-http.js'), require('./kotlinx-io-kotlinx-io-core.js'), require('./ktor-ktor-io.js'), require('./ksoup-ksoup.js'), require('./kotlinx-coroutines-core.js')); else { if (typeof globalThis['kotlin-kotlin-stdlib'] === 'undefined') { throw new Error("Error loading module 'com.earth-app.shovel:shovel'. Its dependency 'kotlin-kotlin-stdlib' was not found. Please, check whether 'kotlin-kotlin-stdlib' is loaded prior to 'com.earth-app.shovel:shovel'."); } if (typeof globalThis['ktor-ktor-client-ktor-client-core'] === 'undefined') { throw new Error("Error loading module 'com.earth-app.shovel:shovel'. Its dependency 'ktor-ktor-client-ktor-client-core' was not found. Please, check whether 'ktor-ktor-client-ktor-client-core' is loaded prior to 'com.earth-app.shovel:shovel'."); } if (typeof globalThis['ktor-ktor-http'] === 'undefined') { throw new Error("Error loading module 'com.earth-app.shovel:shovel'. Its dependency 'ktor-ktor-http' was not found. Please, check whether 'ktor-ktor-http' is loaded prior to 'com.earth-app.shovel:shovel'."); } if (typeof globalThis['kotlinx-io-kotlinx-io-core'] === 'undefined') { throw new Error("Error loading module 'com.earth-app.shovel:shovel'. Its dependency 'kotlinx-io-kotlinx-io-core' was not found. Please, check whether 'kotlinx-io-kotlinx-io-core' is loaded prior to 'com.earth-app.shovel:shovel'."); } if (typeof globalThis['ktor-ktor-io'] === 'undefined') { throw new Error("Error loading module 'com.earth-app.shovel:shovel'. Its dependency 'ktor-ktor-io' was not found. Please, check whether 'ktor-ktor-io' is loaded prior to 'com.earth-app.shovel:shovel'."); } if (typeof globalThis['ksoup-ksoup'] === 'undefined') { throw new Error("Error loading module 'com.earth-app.shovel:shovel'. Its dependency 'ksoup-ksoup' was not found. Please, check whether 'ksoup-ksoup' is loaded prior to 'com.earth-app.shovel:shovel'."); } if (typeof globalThis['kotlinx-coroutines-core'] === 'undefined') { throw new Error("Error loading module 'com.earth-app.shovel:shovel'. Its dependency 'kotlinx-coroutines-core' was not found. Please, check whether 'kotlinx-coroutines-core' is loaded prior to 'com.earth-app.shovel:shovel'."); } globalThis['com.earth-app.shovel:shovel'] = factory(typeof globalThis['com.earth-app.shovel:shovel'] === 'undefined' ? {} : globalThis['com.earth-app.shovel:shovel'], globalThis['kotlin-kotlin-stdlib'], globalThis['ktor-ktor-client-ktor-client-core'], globalThis['ktor-ktor-http'], globalThis['kotlinx-io-kotlinx-io-core'], globalThis['ktor-ktor-io'], globalThis['ksoup-ksoup'], globalThis['kotlinx-coroutines-core']); } }(function (_, kotlin_kotlin, kotlin_io_ktor_ktor_client_core, kotlin_io_ktor_ktor_http, kotlin_org_jetbrains_kotlinx_kotlinx_io_core, kotlin_io_ktor_ktor_io, kotlin_com_fleeksoft_ksoup_ksoup, kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core) { 'use strict'; //region block: imports var VOID = kotlin_kotlin.$_$.h; var protoOf = kotlin_kotlin.$_$.y7; var Regex_init_$Create$ = kotlin_kotlin.$_$.a1; var emptyList = kotlin_kotlin.$_$.e4; var defineProp = kotlin_kotlin.$_$.z6; var initMetadataForClass = kotlin_kotlin.$_$.h7; var toString = kotlin_kotlin.$_$.c8; var IllegalStateException_init_$Create$ = kotlin_kotlin.$_$.r1; var LinkedHashMap_init_$Create$ = kotlin_kotlin.$_$.u; var ArrayList_init_$Create$ = kotlin_kotlin.$_$.p; var Unit_instance = kotlin_kotlin.$_$.a3; var charSequenceLength = kotlin_kotlin.$_$.w6; var mapCapacity = kotlin_kotlin.$_$.u4; var LinkedHashMap_init_$Create$_0 = kotlin_kotlin.$_$.t; var HttpClient = kotlin_io_ktor_ktor_client_core.$_$.g; var substringAfter = kotlin_kotlin.$_$.ca; var _Char___init__impl__6a9atx = kotlin_kotlin.$_$.h2; var substringBefore = kotlin_kotlin.$_$.da; var CoroutineImpl = kotlin_kotlin.$_$.m6; var ensureNotNull = kotlin_kotlin.$_$.ob; var THROW_CCE = kotlin_kotlin.$_$.hb; var KtMap = kotlin_kotlin.$_$.h3; var isInterface = kotlin_kotlin.$_$.r7; var HttpRequestBuilder = kotlin_io_ktor_ktor_client_core.$_$.c; var url = kotlin_io_ktor_ktor_client_core.$_$.e; var headers = kotlin_io_ktor_ktor_client_core.$_$.d; var Companion_getInstance = kotlin_io_ktor_ktor_http.$_$.h; var HttpStatement = kotlin_io_ktor_ktor_client_core.$_$.f; var get_COROUTINE_SUSPENDED = kotlin_kotlin.$_$.w5; var IOException_init_$Create$ = kotlin_org_jetbrains_kotlinx_kotlinx_io_core.$_$.e; var Charsets_getInstance = kotlin_io_ktor_ktor_io.$_$.l; var bodyAsText = kotlin_io_ktor_ktor_client_core.$_$.a; var isSuccess = kotlin_io_ktor_ktor_http.$_$.g1; var IOException_init_$Create$_0 = kotlin_org_jetbrains_kotlinx_kotlinx_io_core.$_$.c; var initMetadataForCoroutine = kotlin_kotlin.$_$.j7; var Ksoup_instance = kotlin_com_fleeksoft_ksoup_ksoup.$_$.a; var collectionSizeOrDefault = kotlin_kotlin.$_$.u3; var ArrayList_init_$Create$_0 = kotlin_kotlin.$_$.o; var coerceAtLeast = kotlin_kotlin.$_$.f8; var to = kotlin_kotlin.$_$.xb; var Dispatchers_getInstance = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.c; var Js_instance = kotlin_io_ktor_ktor_client_core.$_$.b; var GlobalScope_instance = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.d; var promise = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.c1; var CoroutineScope = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.s; var initMetadataForLambda = kotlin_kotlin.$_$.m7; //endregion //region block: pre-declaration initMetadataForClass(Element, 'Element'); initMetadataForClass(Document, 'Document'); initMetadataForCoroutine($fetchDocumentCOROUTINE$0, CoroutineImpl); initMetadataForLambda(fetchDocumentAsPromise$slambda, CoroutineImpl, VOID, [1]); //endregion function get_cache() { _init_properties_http_kt__yecow8(); return cache; } var cache; function closeClient() { _init_properties_http_kt__yecow8(); return get_client().x3(); } function clearCache() { _init_properties_http_kt__yecow8(); return get_cache().y1(); } function Element(tagName, innerHTML, textContent, ownTextContent, attributes, children) { ownTextContent = ownTextContent === VOID ? textContent : ownTextContent; this.tagName = tagName; this.innerHTML = innerHTML; this.textContent = textContent; this.ownTextContent = ownTextContent; this.attributes = attributes; this.children = children; } protoOf(Element).v4t = function () { return this.tagName; }; protoOf(Element).w4t = function () { return this.innerHTML; }; protoOf(Element).x4t = function () { return this.textContent; }; protoOf(Element).y4t = function () { return this.ownTextContent; }; protoOf(Element).t2i = function () { return this.attributes; }; protoOf(Element).z4t = function () { return this.children; }; protoOf(Element).get = function (attribute) { return this.attributes.e2(attribute); }; protoOf(Element).a4u = function () { return this.attributes.e2('id'); }; protoOf(Element).b4u = function () { var tmp0_safe_receiver = this.attributes.e2('class'); var tmp; if (tmp0_safe_receiver == null) { tmp = null; } else { // Inline function 'kotlin.text.toRegex' call // Inline function 'kotlin.text.split' call tmp = Regex_init_$Create$('\\s+').jd(tmp0_safe_receiver, 0); } var tmp1_elvis_lhs = tmp; return tmp1_elvis_lhs == null ? emptyList() : tmp1_elvis_lhs; }; protoOf(Element).c4u = function () { return this.attributes.e2('style'); }; function Document(url, html) { this.url = url; this.html = html; } protoOf(Document).x2j = function () { return this.url; }; protoOf(Document).d4u = function () { return this.html; }; protoOf(Document).e4u = function () { var tmp0_elvis_lhs = querySelector(this, 'body'); var tmp; if (tmp0_elvis_lhs == null) { var message = 'Document does not have a body element'; throw IllegalStateException_init_$Create$(toString(message)); } else { tmp = tmp0_elvis_lhs; } return tmp; }; protoOf(Document).f4u = function () { var tmp0 = this.body.innerHTML; // Inline function 'kotlin.text.replace' call var tmp3 = Regex_init_$Create$('<script\\b[^>]*>([\\s\\S]*?)<\/script>').bd(tmp0, ''); // Inline function 'kotlin.text.replace' call return Regex_init_$Create$('<style\\b[^>]*>([\\s\\S]*?)<\/style>').bd(tmp3, ''); }; protoOf(Document).g4u = function () { var tmp0_elvis_lhs = querySelector(this, 'head'); var tmp; if (tmp0_elvis_lhs == null) { var message = 'Document does not have a head element'; throw IllegalStateException_init_$Create$(toString(message)); } else { tmp = tmp0_elvis_lhs; } return tmp; }; protoOf(Document).h4u = function () { var tmp0_safe_receiver = querySelector(this, 'title'); var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.textContent; var tmp; if (tmp1_elvis_lhs == null) { var message = 'Document does not have a title element'; throw IllegalStateException_init_$Create$(toString(message)); } else { tmp = tmp1_elvis_lhs; } return tmp; }; protoOf(Document).i4u = function () { // Inline function 'kotlin.collections.groupBy' call var tmp0 = querySelectorAll(this, 'meta'); // Inline function 'kotlin.collections.groupByTo' call var destination = LinkedHashMap_init_$Create$(); var _iterator__ex2g4s = tmp0.g(); while (_iterator__ex2g4s.h()) { var element = _iterator__ex2g4s.i(); var tmp0_elvis_lhs = element.get('name'); var tmp1_elvis_lhs = tmp0_elvis_lhs == null ? element.get('property') : tmp0_elvis_lhs; var key = tmp1_elvis_lhs == null ? '' : tmp1_elvis_lhs; // Inline function 'kotlin.collections.getOrPut' call var value = destination.e2(key); var tmp; if (value == null) { var answer = ArrayList_init_$Create$(); destination.h2(key, answer); tmp = answer; } else { tmp = value; } var list = tmp; var tmp0_elvis_lhs_0 = element.get('content'); var tmp$ret$3 = tmp0_elvis_lhs_0 == null ? '' : tmp0_elvis_lhs_0; list.e(tmp$ret$3); } // Inline function 'kotlin.collections.filterKeys' call var result = LinkedHashMap_init_$Create$(); // Inline function 'kotlin.collections.iterator' call var _iterator__ex2g4s_0 = destination.r().g(); while (_iterator__ex2g4s_0.h()) { var entry = _iterator__ex2g4s_0.i(); // Inline function 'kotlin.text.isNotEmpty' call var this_0 = entry.s(); if (charSequenceLength(this_0) > 0) { result.h2(entry.s(), entry.t()); } } // Inline function 'kotlin.collections.mapValues' call // Inline function 'kotlin.collections.mapValuesTo' call var destination_0 = LinkedHashMap_init_$Create$_0(mapCapacity(result.j())); // Inline function 'kotlin.collections.associateByTo' call var _iterator__ex2g4s_1 = result.r().g(); while (_iterator__ex2g4s_1.h()) { var element_0 = _iterator__ex2g4s_1.i(); var tmp_0 = element_0.s(); // Inline function 'kotlin.collections.filter' call var tmp0_0 = element_0.t(); // Inline function 'kotlin.collections.filterTo' call var destination_1 = ArrayList_init_$Create$(); var _iterator__ex2g4s_2 = tmp0_0.g(); while (_iterator__ex2g4s_2.h()) { var element_1 = _iterator__ex2g4s_2.i(); // Inline function 'kotlin.text.isNotEmpty' call if (charSequenceLength(element_1) > 0) { destination_1.e(element_1); } } destination_0.h2(tmp_0, destination_1); } return destination_0; }; protoOf(Document).j4u = function () { // Inline function 'kotlin.collections.groupBy' call var tmp0 = querySelectorAll(this, 'link'); // Inline function 'kotlin.collections.groupByTo' call var destination = LinkedHashMap_init_$Create$(); var _iterator__ex2g4s = tmp0.g(); while (_iterator__ex2g4s.h()) { var element = _iterator__ex2g4s.i(); var tmp0_elvis_lhs = element.get('rel'); var key = tmp0_elvis_lhs == null ? '' : tmp0_elvis_lhs; // Inline function 'kotlin.collections.getOrPut' call var value = destination.e2(key); var tmp; if (value == null) { var answer = ArrayList_init_$Create$(); destination.h2(key, answer); tmp = answer; } else { tmp = value; } var list = tmp; var tmp0_elvis_lhs_0 = element.get('href'); var tmp$ret$3 = tmp0_elvis_lhs_0 == null ? '' : tmp0_elvis_lhs_0; list.e(tmp$ret$3); } // Inline function 'kotlin.collections.filterKeys' call var result = LinkedHashMap_init_$Create$(); // Inline function 'kotlin.collections.iterator' call var _iterator__ex2g4s_0 = destination.r().g(); while (_iterator__ex2g4s_0.h()) { var entry = _iterator__ex2g4s_0.i(); // Inline function 'kotlin.text.isNotEmpty' call var this_0 = entry.s(); if (charSequenceLength(this_0) > 0) { result.h2(entry.s(), entry.t()); } } // Inline function 'kotlin.collections.mapValues' call // Inline function 'kotlin.collections.mapValuesTo' call var destination_0 = LinkedHashMap_init_$Create$_0(mapCapacity(result.j())); // Inline function 'kotlin.collections.associateByTo' call var _iterator__ex2g4s_1 = result.r().g(); while (_iterator__ex2g4s_1.h()) { var element_0 = _iterator__ex2g4s_1.i(); var tmp_0 = element_0.s(); // Inline function 'kotlin.collections.filter' call var tmp0_0 = element_0.t(); // Inline function 'kotlin.collections.filterTo' call var destination_1 = ArrayList_init_$Create$(); var _iterator__ex2g4s_2 = tmp0_0.g(); while (_iterator__ex2g4s_2.h()) { var element_1 = _iterator__ex2g4s_2.i(); // Inline function 'kotlin.text.isNotEmpty' call if (charSequenceLength(element_1) > 0) { destination_1.e(element_1); } } destination_0.h2(tmp_0, destination_1); } return destination_0; }; function querySelector(_this__u8e3s4, selector, filter) { var tmp; if (filter === VOID) { tmp = querySelector$lambda; } else { tmp = filter; } filter = tmp; _init_properties_http_kt__yecow8(); var tmp0 = querySelectorAll(_this__u8e3s4, selector); var tmp$ret$0; $l$block: { // Inline function 'kotlin.collections.firstOrNull' call var _iterator__ex2g4s = tmp0.g(); while (_iterator__ex2g4s.h()) { var element = _iterator__ex2g4s.i(); if (filter(element)) { tmp$ret$0 = element; break $l$block; } } tmp$ret$0 = null; } return tmp$ret$0; } function getElementById(_this__u8e3s4, id) { _init_properties_http_kt__yecow8(); return querySelector(_this__u8e3s4, '#' + id); } function getElementsByClassName(_this__u8e3s4, className) { _init_properties_http_kt__yecow8(); return querySelectorAll(_this__u8e3s4, '.' + className); } function inputValue(_this__u8e3s4, name) { _init_properties_http_kt__yecow8(); var tmp0_elvis_lhs = querySelector(_this__u8e3s4, 'input[name=' + name + ']'); var tmp; if (tmp0_elvis_lhs == null) { return null; } else { tmp = tmp0_elvis_lhs; } var input = tmp; var tmp1_elvis_lhs = input.get('value'); return tmp1_elvis_lhs == null ? input.get('checked') : tmp1_elvis_lhs; } function get_client() { _init_properties_http_kt__yecow8(); var tmp = get_engine(); return HttpClient(tmp, _get_client_$lambda_y278ej); } function fetchDocument(_this__u8e3s4, request, $completion) { var tmp; if (request === VOID) { tmp = fetchDocument$lambda; } else { tmp = request; } request = tmp; var tmp_0 = new $fetchDocumentCOROUTINE$0(_this__u8e3s4, request, $completion); tmp_0.o8_1 = Unit_instance; tmp_0.p8_1 = null; return tmp_0.u8(); } function querySelector$lambda(it) { _init_properties_http_kt__yecow8(); return true; } function _get_client_$lambda_y278ej($this$HttpClient) { _init_properties_http_kt__yecow8(); $this$HttpClient.f2i_1 = false; $this$HttpClient.d2i_1 = false; return Unit_instance; } function fetchDocument$lambda(_this__u8e3s4) { _init_properties_http_kt__yecow8(); return Unit_instance; } function fetchDocument$lambda_0($this_fetchDocument, $request, $$this$get) { return function ($this$headers) { $this$headers.q1r('User-Agent', 'Ktor HTTP Client, Tabroom API v1'); $this$headers.q1r('Host', substringBefore(substringAfter($this_fetchDocument, '://'), _Char___init__impl__6a9atx(47))); $this$headers.q1r('Accept-Language', 'en-US,en;q=0.9'); $this$headers.q1r('Connection', 'keep-alive'); $this$headers.q1r('Upgrade-Insecure-Requests', '1'); $request($$this$get); return Unit_instance; }; } function $fetchDocumentCOROUTINE$0(_this__u8e3s4, request, resultContinuation) { CoroutineImpl.call(this, resultContinuation); this.s4u_1 = _this__u8e3s4; this.t4u_1 = request; } protoOf($fetchDocumentCOROUTINE$0).u8 = function () { var suspendResult = this.o8_1; $sm: do try { var tmp = this.m8_1; switch (tmp) { case 0: this.n8_1 = 7; var tmp0 = get_cache(); var key = this.s4u_1; if ((isInterface(tmp0, KtMap) ? tmp0 : THROW_CCE()).c2(key)) return ensureNotNull(get_cache().e2(this.s4u_1)); this.n8_1 = 2; var tmp_0 = this; tmp_0.v4u_1 = get_client(); var tmp_1 = this; tmp_1.w4u_1 = this.s4u_1; this.x4u_1 = this.v4u_1; this.y4u_1 = this.w4u_1; var tmp_2 = this; tmp_2.z4u_1 = this.x4u_1; this.a4v_1 = this.z4u_1; var tmp_3 = this; tmp_3.b4v_1 = this.a4v_1; var tmp_4 = this; var this_0 = new HttpRequestBuilder(); url(this_0, this.y4u_1); headers(this_0, fetchDocument$lambda_0(this.s4u_1, this.t4u_1, this_0)); tmp_4.c4v_1 = this_0; this.d4v_1 = this.b4v_1; this.e4v_1 = this.c4v_1; this.e4v_1.n2h_1 = Companion_getInstance().b22_1; var tmp_5 = this; tmp_5.f4v_1 = this.d4v_1; var tmp_6 = this; tmp_6.g4v_1 = this.e4v_1; this.h4v_1 = this.f4v_1; this.i4v_1 = this.g4v_1; this.m8_1 = 1; suspendResult = (new HttpStatement(this.i4v_1, this.h4v_1)).d3d(this); if (suspendResult === get_COROUTINE_SUSPENDED()) { return suspendResult; } continue $sm; case 1: this.u4u_1 = suspendResult; this.n8_1 = 7; this.m8_1 = 3; continue $sm; case 2: this.n8_1 = 7; var tmp_7 = this.p8_1; if (tmp_7 instanceof Error) { this.j4v_1 = this.p8_1; var tmp_8 = this; throw IOException_init_$Create$("Error happened when trying to fetch document '" + this.s4u_1 + "': " + this.j4v_1.message, this.j4v_1); } else { throw this.p8_1; } case 3: this.n8_1 = 7; this.k4v_1 = this.u4u_1; if (!isSuccess(this.k4v_1.y2j())) { this.l4v_1 = this.k4v_1.y2j().toString(); this.m8_1 = 6; suspendResult = bodyAsText(this.k4v_1, Charsets_getInstance().x1l_1, this); if (suspendResult === get_COROUTINE_SUSPENDED()) { return suspendResult; } continue $sm; } else { this.m8_1 = 4; continue $sm; } case 4: this.m8_1 = 5; suspendResult = bodyAsText(this.k4v_1, Charsets_getInstance().x1l_1, this); if (suspendResult === get_COROUTINE_SUSPENDED()) { return suspendResult; } continue $sm; case 5: var text = suspendResult; var tmp5 = get_cache(); var tmp6 = this.s4u_1; var value = new Document(this.s4u_1, text); tmp5.h2(tmp6, value); return new Document(this.s4u_1, text); case 6: var ARGUMENT = suspendResult; var ARGUMENT_0 = "Failed to fetch document '" + this.s4u_1 + "': " + this.l4v_1 + '\n' + ARGUMENT; throw IOException_init_$Create$_0(ARGUMENT_0); case 7: throw this.p8_1; } } catch ($p) { var e = $p; if (this.n8_1 === 7) { throw e; } else { this.m8_1 = this.n8_1; this.p8_1 = e; } } while (true); }; var properties_initialized_http_kt_3zhpnu; function _init_properties_http_kt__yecow8() { if (!properties_initialized_http_kt_3zhpnu) { properties_initialized_http_kt_3zhpnu = true; // Inline function 'kotlin.collections.mutableMapOf' call cache = LinkedHashMap_init_$Create$(); } } function get_engine() { _init_properties_http_js_kt__7qsee5(); return engine; } var engine; function querySelectorAll(_this__u8e3s4, selector) { _init_properties_http_js_kt__7qsee5(); var doc = Ksoup_instance.j3k(_this__u8e3s4.html); // Inline function 'kotlin.collections.map' call var this_0 = doc.p3u(selector); // Inline function 'kotlin.collections.mapTo' call var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10)); var _iterator__ex2g4s = this_0.g(); while (_iterator__ex2g4s.h()) { var item = _iterator__ex2g4s.i(); var tmp$ret$0 = convert(item); destination.e(tmp$ret$0); } return destination; } function convert(_this__u8e3s4) { _init_properties_http_js_kt__7qsee5(); var tmp = _this__u8e3s4.h3u(); var tmp_0 = _this__u8e3s4.h3o(); var tmp_1 = _this__u8e3s4.z3u(); var tmp_2 = _this__u8e3s4.c3v(); // Inline function 'kotlin.collections.associate' call var this_0 = _this__u8e3s4.o3q(); var capacity = coerceAtLeast(mapCapacity(collectionSizeOrDefault(this_0, 10)), 16); // Inline function 'kotlin.collections.associateTo' call var destination = LinkedHashMap_init_$Create$_0(capacity); var _iterator__ex2g4s = this_0.g(); while (_iterator__ex2g4s.h()) { var element = _iterator__ex2g4s.i(); // Inline function 'kotlin.collections.plusAssign' call var pair = to(element.s(), element.t()); destination.h2(pair.wf_1, pair.xf_1); } var tmp_3 = destination; // Inline function 'kotlin.collections.map' call var this_1 = _this__u8e3s4.l3u(); // Inline function 'kotlin.collections.mapTo' call var destination_0 = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_1, 10)); var _iterator__ex2g4s_0 = this_1.g(); while (_iterator__ex2g4s_0.h()) { var item = _iterator__ex2g4s_0.i(); var tmp$ret$4 = convert(item); destination_0.e(tmp$ret$4); } return new Element(tmp, tmp_0, tmp_1, tmp_2, tmp_3, destination_0); } function engine$lambda($this$create) { _init_properties_http_js_kt__7qsee5(); $this$create.y2n_1 = true; $this$create.x2n_1 = Dispatchers_getInstance().rw_1; return Unit_instance; } var properties_initialized_http_js_kt_k0xa5d; function _init_properties_http_js_kt__7qsee5() { if (!properties_initialized_http_js_kt_k0xa5d) { properties_initialized_http_js_kt_k0xa5d = true; var tmp = Js_instance; engine = tmp.f3e(engine$lambda); } } function fetchDocumentAsPromise(_this__u8e3s4) { var tmp = GlobalScope_instance; return promise(tmp, VOID, VOID, fetchDocumentAsPromise$slambda_0(_this__u8e3s4, null)); } function fetchAsPromise(url) { return fetchDocumentAsPromise(url); } function fetchDocumentAsPromise$slambda($this_fetchDocumentAsPromise, resultContinuation) { this.u4v_1 = $this_fetchDocumentAsPromise; CoroutineImpl.call(this, resultContinuation); } protoOf(fetchDocumentAsPromise$slambda).w4v = function ($this$promise, $completion) { var tmp = this.d1l($this$promise, $completion); tmp.o8_1 = Unit_instance; tmp.p8_1 = null; return tmp.u8(); }; protoOf(fetchDocumentAsPromise$slambda).i9 = function (p1, $completion) { return this.w4v((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $completion); }; protoOf(fetchDocumentAsPromise$slambda).u8 = function () { var suspendResult = this.o8_1; $sm: do try { var tmp = this.m8_1; switch (tmp) { case 0: this.n8_1 = 2; this.m8_1 = 1; suspendResult = fetchDocument(this.u4v_1, VOID, this); if (suspendResult === get_COROUTINE_SUSPENDED()) { return suspendResult; } continue $sm; case 1: return suspendResult; case 2: throw this.p8_1; } } catch ($p) { var e = $p; if (this.n8_1 === 2) { throw e; } else { this.m8_1 = this.n8_1; this.p8_1 = e; } } while (true); }; protoOf(fetchDocumentAsPromise$slambda).d1l = function ($this$promise, completion) { var i = new fetchDocumentAsPromise$slambda(this.u4v_1, completion); i.v4v_1 = $this$promise; return i; }; function fetchDocumentAsPromise$slambda_0($this_fetchDocumentAsPromise, resultContinuation) { var i = new fetchDocumentAsPromise$slambda($this_fetchDocumentAsPromise, resultContinuation); var l = function ($this$promise, $completion) { return i.w4v($this$promise, $completion); }; l.$arity = 1; return l; } //region block: post-declaration defineProp(protoOf(Element), 'id', protoOf(Element).a4u); defineProp(protoOf(Element), 'classes', protoOf(Element).b4u); defineProp(protoOf(Element), 'style', protoOf(Element).c4u); defineProp(protoOf(Document), 'body', protoOf(Document).e4u); defineProp(protoOf(Document), 'bodyElements', protoOf(Document).f4u); defineProp(protoOf(Document), 'head', protoOf(Document).g4u); defineProp(protoOf(Document), 'title', protoOf(Document).h4u); defineProp(protoOf(Document), 'metadata', protoOf(Document).i4u); defineProp(protoOf(Document), 'linkTags', protoOf(Document).j4u); //endregion //region block: exports function $jsExportAll$(_) { var $com = _.com || (_.com = {}); var $com$earthapp = $com.earthapp || ($com.earthapp = {}); var $com$earthapp$shovel = $com$earthapp.shovel || ($com$earthapp.shovel = {}); $com$earthapp$shovel.closeClient = closeClient; $com$earthapp$shovel.clearCache = clearCache; $com$earthapp$shovel.Element = Element; $com$earthapp$shovel.Document = Document; $com$earthapp$shovel.querySelector = querySelector; $com$earthapp$shovel.getElementById = getElementById; $com$earthapp$shovel.getElementsByClassName = getElementsByClassName; $com$earthapp$shovel.inputValue = inputValue; var $com = _.com || (_.com = {}); var $com$earthapp = $com.earthapp || ($com.earthapp = {}); var $com$earthapp$shovel = $com$earthapp.shovel || ($com$earthapp.shovel = {}); $com$earthapp$shovel.querySelectorAll = querySelectorAll; _.fetchDocumentAsPromise = fetchDocumentAsPromise; _.fetchAsPromise = fetchAsPromise; } $jsExportAll$(_); kotlin_kotlin.$jsExportAll$(_); kotlin_io_ktor_ktor_client_core.$jsExportAll$(_); //endregion return _; })); //# sourceMappingURL=shovel.js.map