UNPKG

@earth-app/shovel

Version:

Kotlin Multiplatform Web Scraping Framework

804 lines (796 loc) 32 kB
(function (factory) { if (typeof define === 'function' && define.amd) define(['exports', './kotlin-kotlin-stdlib.js', './ktor-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-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-core'] === 'undefined') { throw new Error("Error loading module 'com.earth-app.shovel:shovel'. Its dependency 'ktor-ktor-client-core' was not found. Please, check whether 'ktor-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-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.$_$.b; var protoOf = kotlin_kotlin.$_$.j8; var Regex_init_$Create$ = kotlin_kotlin.$_$.u; var emptyList = kotlin_kotlin.$_$.z3; var defineProp = kotlin_kotlin.$_$.l7; var initMetadataForClass = kotlin_kotlin.$_$.t7; var toString = kotlin_kotlin.$_$.m8; var IllegalStateException_init_$Create$ = kotlin_kotlin.$_$.l1; var LinkedHashMap_init_$Create$ = kotlin_kotlin.$_$.o; var ArrayList_init_$Create$ = kotlin_kotlin.$_$.j; var Unit_instance = kotlin_kotlin.$_$.v2; var charSequenceLength = kotlin_kotlin.$_$.i7; var mapCapacity = kotlin_kotlin.$_$.p4; var LinkedHashMap_init_$Create$_0 = kotlin_kotlin.$_$.n; var substringAfter = kotlin_kotlin.$_$.ua; var _Char___init__impl__6a9atx = kotlin_kotlin.$_$.b2; var substringBefore = kotlin_kotlin.$_$.va; var CoroutineImpl = kotlin_kotlin.$_$.h6; 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.$_$.r5; var IOException_init_$Create$ = kotlin_org_jetbrains_kotlinx_kotlinx_io_core.$_$.e; var Charsets_getInstance = kotlin_io_ktor_ktor_io.$_$.k; var bodyAsText = kotlin_io_ktor_ktor_client_core.$_$.a; var isSuccess = kotlin_io_ktor_ktor_http.$_$.h1; var IOException_init_$Create$_0 = kotlin_org_jetbrains_kotlinx_kotlinx_io_core.$_$.c; var initMetadataForCoroutine = kotlin_kotlin.$_$.v7; var ensureNotNull = kotlin_kotlin.$_$.ic; var THROW_CCE = kotlin_kotlin.$_$.bc; var KtMap = kotlin_kotlin.$_$.c3; var isInterface = kotlin_kotlin.$_$.d8; var HttpClient = kotlin_io_ktor_ktor_client_core.$_$.g; var Ksoup_instance = kotlin_com_fleeksoft_ksoup_ksoup.$_$.a; var collectionSizeOrDefault = kotlin_kotlin.$_$.p3; var ArrayList_init_$Create$_0 = kotlin_kotlin.$_$.i; var coerceAtLeast = kotlin_kotlin.$_$.p8; var to = kotlin_kotlin.$_$.qc; var Dispatchers_getInstance = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.d; var Js_instance = kotlin_io_ktor_ktor_client_core.$_$.b; var GlobalScope_instance = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.e; var promise = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.d1; var CoroutineScope = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.t; var initMetadataForLambda = kotlin_kotlin.$_$.y7; //endregion //region block: pre-declaration initMetadataForClass(Element, 'Element'); initMetadataForClass(Document, 'Document'); initMetadataForCoroutine($performRequestCOROUTINE$, CoroutineImpl); initMetadataForCoroutine($fetchDocumentCOROUTINE$, CoroutineImpl); initMetadataForLambda(fetchDocumentAsPromise$slambda, CoroutineImpl, VOID, [1]); //endregion function get_client() { _init_properties_http_kt__yecow8(); return client; } var client; function get_cache() { _init_properties_http_kt__yecow8(); return cache; } var cache; function closeClient() { _init_properties_http_kt__yecow8(); return get_client().w3(); } function clearCache() { _init_properties_http_kt__yecow8(); return get_cache().m2(); } function Element(tagName, innerHTML, outerHTML, textContent, ownTextContent, attributes, children) { ownTextContent = ownTextContent === VOID ? textContent : ownTextContent; this.tagName = tagName; this.innerHTML = innerHTML; this.outerHTML = outerHTML; this.textContent = textContent; this.ownTextContent = ownTextContent; this.attributes = attributes; this.children = children; } protoOf(Element).m4q = function () { return this.tagName; }; protoOf(Element).n4q = function () { return this.innerHTML; }; protoOf(Element).o4q = function () { return this.outerHTML; }; protoOf(Element).p4q = function () { return this.textContent; }; protoOf(Element).q4q = function () { return this.ownTextContent; }; protoOf(Element).y2f = function () { return this.attributes; }; protoOf(Element).r4q = function () { return this.children; }; protoOf(Element).get = function (attribute) { return this.attributes.r2(attribute); }; protoOf(Element).s4q = function () { return this.attributes.r2('id'); }; protoOf(Element).t4q = function () { var tmp0_safe_receiver = this.attributes.r2('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+').xc(tmp0_safe_receiver, 0); } var tmp1_elvis_lhs = tmp; return tmp1_elvis_lhs == null ? emptyList() : tmp1_elvis_lhs; }; protoOf(Element).u4q = function () { return this.attributes.r2('style'); }; function Document(url, html) { this.url = url; this.html = html; } protoOf(Document).g2g = function () { return this.url; }; protoOf(Document).v4q = function () { return this.html; }; protoOf(Document).w4q = function () { var tmp0_elvis_lhs = documentQuerySelector(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).x4q = function () { var tmp0 = this.body.innerHTML; // Inline function 'kotlin.text.replace' call var tmp0_0 = Regex_init_$Create$('<script\\b[^>]*>([\\s\\S]*?)<\/script>').pc(tmp0, ''); // Inline function 'kotlin.text.replace' call return Regex_init_$Create$('<style\\b[^>]*>([\\s\\S]*?)<\/style>').pc(tmp0_0, ''); }; protoOf(Document).y4q = function () { var tmp0_elvis_lhs = documentQuerySelector(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).z4q = function () { var tmp0_safe_receiver = documentQuerySelector(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).a4r = function () { // Inline function 'kotlin.collections.groupBy' call var tmp0 = documentQuerySelectorAll(this, 'meta'); // Inline function 'kotlin.collections.groupByTo' call var destination = LinkedHashMap_init_$Create$(); var _iterator__ex2g4s = tmp0.q(); while (_iterator__ex2g4s.r()) { var element = _iterator__ex2g4s.s(); 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.r2(key); var tmp; if (value == null) { var answer = ArrayList_init_$Create$(); destination.j2(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.y(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.h1().q(); while (_iterator__ex2g4s_0.r()) { var entry = _iterator__ex2g4s_0.s(); // Inline function 'kotlin.text.isNotEmpty' call var this_0 = entry.i1(); if (charSequenceLength(this_0) > 0) { result.j2(entry.i1(), entry.j1()); } } // Inline function 'kotlin.collections.mapValues' call // Inline function 'kotlin.collections.mapValuesTo' call var destination_0 = LinkedHashMap_init_$Create$_0(mapCapacity(result.a1())); // Inline function 'kotlin.collections.associateByTo' call var _iterator__ex2g4s_1 = result.h1().q(); while (_iterator__ex2g4s_1.r()) { var element_0 = _iterator__ex2g4s_1.s(); var tmp_0 = element_0.i1(); // Inline function 'kotlin.collections.filter' call var tmp0_0 = element_0.j1(); // Inline function 'kotlin.collections.filterTo' call var destination_1 = ArrayList_init_$Create$(); var _iterator__ex2g4s_2 = tmp0_0.q(); while (_iterator__ex2g4s_2.r()) { var element_1 = _iterator__ex2g4s_2.s(); // Inline function 'kotlin.text.isNotEmpty' call if (charSequenceLength(element_1) > 0) { destination_1.y(element_1); } } destination_0.j2(tmp_0, destination_1); } return destination_0; }; protoOf(Document).b4r = function () { // Inline function 'kotlin.collections.groupBy' call var tmp0 = documentQuerySelectorAll(this, 'link'); // Inline function 'kotlin.collections.groupByTo' call var destination = LinkedHashMap_init_$Create$(); var _iterator__ex2g4s = tmp0.q(); while (_iterator__ex2g4s.r()) { var element = _iterator__ex2g4s.s(); 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.r2(key); var tmp; if (value == null) { var answer = ArrayList_init_$Create$(); destination.j2(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.y(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.h1().q(); while (_iterator__ex2g4s_0.r()) { var entry = _iterator__ex2g4s_0.s(); // Inline function 'kotlin.text.isNotEmpty' call var this_0 = entry.i1(); if (charSequenceLength(this_0) > 0) { result.j2(entry.i1(), entry.j1()); } } // Inline function 'kotlin.collections.mapValues' call // Inline function 'kotlin.collections.mapValuesTo' call var destination_0 = LinkedHashMap_init_$Create$_0(mapCapacity(result.a1())); // Inline function 'kotlin.collections.associateByTo' call var _iterator__ex2g4s_1 = result.h1().q(); while (_iterator__ex2g4s_1.r()) { var element_0 = _iterator__ex2g4s_1.s(); var tmp_0 = element_0.i1(); // Inline function 'kotlin.collections.filter' call var tmp0_0 = element_0.j1(); // Inline function 'kotlin.collections.filterTo' call var destination_1 = ArrayList_init_$Create$(); var _iterator__ex2g4s_2 = tmp0_0.q(); while (_iterator__ex2g4s_2.r()) { var element_1 = _iterator__ex2g4s_2.s(); // Inline function 'kotlin.text.isNotEmpty' call if (charSequenceLength(element_1) > 0) { destination_1.y(element_1); } } destination_0.j2(tmp_0, destination_1); } return destination_0; }; function documentQuerySelector(_this__u8e3s4, selector, filter) { var tmp; if (filter === VOID) { tmp = querySelector$lambda; } else { tmp = filter; } filter = tmp; _init_properties_http_kt__yecow8(); var tmp0 = documentQuerySelectorAll(_this__u8e3s4, selector); var tmp$ret$0; $l$block: { // Inline function 'kotlin.collections.firstOrNull' call var _iterator__ex2g4s = tmp0.q(); while (_iterator__ex2g4s.r()) { var element = _iterator__ex2g4s.s(); if (filter(element)) { tmp$ret$0 = element; break $l$block; } } tmp$ret$0 = null; } return tmp$ret$0; } function documentGetElementById(_this__u8e3s4, id) { _init_properties_http_kt__yecow8(); return documentQuerySelector(_this__u8e3s4, '#' + id); } function documentGetElementsByClassName(_this__u8e3s4, className) { _init_properties_http_kt__yecow8(); return documentQuerySelectorAll(_this__u8e3s4, '.' + className); } function documentInputValue(_this__u8e3s4, name) { _init_properties_http_kt__yecow8(); var tmp0_elvis_lhs = documentQuerySelector(_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 elementQuerySelector(_this__u8e3s4, selector, filter) { var tmp; if (filter === VOID) { tmp = querySelector$lambda_0; } else { tmp = filter; } filter = tmp; _init_properties_http_kt__yecow8(); var tmp0 = elementQuerySelectorAll(_this__u8e3s4, selector); var tmp$ret$0; $l$block: { // Inline function 'kotlin.collections.firstOrNull' call var _iterator__ex2g4s = tmp0.q(); while (_iterator__ex2g4s.r()) { var element = _iterator__ex2g4s.s(); if (filter(element)) { tmp$ret$0 = element; break $l$block; } } tmp$ret$0 = null; } return tmp$ret$0; } function elementGetElementById(_this__u8e3s4, id) { _init_properties_http_kt__yecow8(); return elementQuerySelector(_this__u8e3s4, '#' + id); } function elementGetElementsByClassName(_this__u8e3s4, className) { _init_properties_http_kt__yecow8(); return elementQuerySelectorAll(_this__u8e3s4, '.' + className); } function elementInputValue(_this__u8e3s4, name) { _init_properties_http_kt__yecow8(); var tmp0_elvis_lhs = elementQuerySelector(_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 performRequest(_this__u8e3s4, request, $completion) { var tmp = new $performRequestCOROUTINE$(_this__u8e3s4, request, $completion); tmp.j8_1 = Unit_instance; tmp.k8_1 = null; return tmp.p8(); } function fetchDocument(_this__u8e3s4, request, $completion) { var tmp; if (request === VOID) { tmp = fetchDocument$lambda; } else { tmp = request; } request = tmp; var tmp_0 = new $fetchDocumentCOROUTINE$(_this__u8e3s4, request, $completion); tmp_0.j8_1 = Unit_instance; tmp_0.k8_1 = null; return tmp_0.p8(); } function client$lambda($this$HttpClient) { _init_properties_http_kt__yecow8(); $this$HttpClient.j2f_1 = false; $this$HttpClient.h2f_1 = true; return Unit_instance; } function querySelector$lambda(it) { _init_properties_http_kt__yecow8(); return true; } function querySelector$lambda_0(it) { _init_properties_http_kt__yecow8(); return true; } function performRequest$lambda($this_performRequest, $request, $$this$get) { return function ($this$headers) { $this$headers.b1p('User-Agent', 'Ktor HTTP Client, @earth-app/shovel'); $this$headers.b1p('Host', substringBefore(substringAfter($this_performRequest, '://'), _Char___init__impl__6a9atx(47))); $this$headers.b1p('Accept-Language', 'en-US,en;q=0.9'); $this$headers.b1p('Connection', 'keep-alive'); $this$headers.b1p('Upgrade-Insecure-Requests', '1'); $request($$this$get); return Unit_instance; }; } function fetchDocument$lambda(_this__u8e3s4) { _init_properties_http_kt__yecow8(); return Unit_instance; } function $performRequestCOROUTINE$(_this__u8e3s4, request, resultContinuation) { CoroutineImpl.call(this, resultContinuation); this.k4r_1 = _this__u8e3s4; this.l4r_1 = request; } protoOf($performRequestCOROUTINE$).p8 = function () { var suspendResult = this.j8_1; $sm: do try { var tmp = this.h8_1; switch (tmp) { case 0: this.i8_1 = 6; this.i8_1 = 2; var tmp0 = get_client(); var urlString = this.k4r_1; var this_0 = new HttpRequestBuilder(); url(this_0, urlString); headers(this_0, performRequest$lambda(this.k4r_1, this.l4r_1, this_0)); this_0.r2e_1 = Companion_getInstance().p1z_1; this.h8_1 = 1; suspendResult = (new HttpStatement(this_0, tmp0)).i3a(this); if (suspendResult === get_COROUTINE_SUSPENDED()) { return suspendResult; } continue $sm; case 1: this.o4r_1 = suspendResult; this.i8_1 = 6; this.h8_1 = 3; continue $sm; case 2: this.i8_1 = 6; var tmp_0 = this.k8_1; if (tmp_0 instanceof Error) { var e = this.k8_1; var tmp_1 = this; throw IOException_init_$Create$("Error happened when trying to fetch '" + this.k4r_1 + "': " + e.message, e); } else { throw this.k8_1; } case 3: this.i8_1 = 6; this.n4r_1 = this.o4r_1; if (!isSuccess(this.n4r_1.n2g())) { this.m4r_1 = this.n4r_1.n2g().toString(); this.h8_1 = 5; suspendResult = bodyAsText(this.n4r_1, Charsets_getInstance().i1j_1, this); if (suspendResult === get_COROUTINE_SUSPENDED()) { return suspendResult; } continue $sm; } else { this.h8_1 = 4; continue $sm; } case 4: return this.n4r_1; case 5: var ARGUMENT = suspendResult; var ARGUMENT_0 = "Failed to fetch '" + this.k4r_1 + "': " + this.m4r_1 + '\n' + ARGUMENT; throw IOException_init_$Create$_0(ARGUMENT_0); case 6: throw this.k8_1; } } catch ($p) { var e_0 = $p; if (this.i8_1 === 6) { throw e_0; } else { this.h8_1 = this.i8_1; this.k8_1 = e_0; } } while (true); }; function $fetchDocumentCOROUTINE$(_this__u8e3s4, request, resultContinuation) { CoroutineImpl.call(this, resultContinuation); this.x4r_1 = _this__u8e3s4; this.y4r_1 = request; } protoOf($fetchDocumentCOROUTINE$).p8 = function () { var suspendResult = this.j8_1; $sm: do try { var tmp = this.h8_1; switch (tmp) { case 0: this.i8_1 = 3; var tmp0 = get_cache(); var key = this.x4r_1; if ((isInterface(tmp0, KtMap) ? tmp0 : THROW_CCE()).p2(key)) return ensureNotNull(get_cache().r2(this.x4r_1)); this.h8_1 = 1; suspendResult = performRequest(this.x4r_1, this.y4r_1, this); if (suspendResult === get_COROUTINE_SUSPENDED()) { return suspendResult; } continue $sm; case 1: var res = suspendResult; this.h8_1 = 2; suspendResult = bodyAsText(res, Charsets_getInstance().i1j_1, this); if (suspendResult === get_COROUTINE_SUSPENDED()) { return suspendResult; } continue $sm; case 2: var text = suspendResult; var tmp0_0 = get_cache(); var tmp2 = this.x4r_1; var value = new Document(this.x4r_1, text); tmp0_0.j2(tmp2, value); return new Document(this.x4r_1, text); case 3: throw this.k8_1; } } catch ($p) { var e = $p; if (this.i8_1 === 3) { throw e; } else { this.h8_1 = this.i8_1; this.k8_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; var tmp = get_engine(); client = HttpClient(tmp, client$lambda); // Inline function 'kotlin.collections.mutableMapOf' call cache = LinkedHashMap_init_$Create$(); } } function get_engine() { _init_properties_http_js_kt__7qsee5(); return engine; } var engine; function documentQuerySelectorAll(_this__u8e3s4, selector) { _init_properties_http_js_kt__7qsee5(); var doc = Ksoup_instance.a3h(_this__u8e3s4.html); // Inline function 'kotlin.collections.map' call var this_0 = doc.g3r(selector); // Inline function 'kotlin.collections.mapTo' call var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10)); var _iterator__ex2g4s = this_0.q(); while (_iterator__ex2g4s.r()) { var item = _iterator__ex2g4s.s(); var tmp$ret$0 = convert(item); destination.y(tmp$ret$0); } return destination; } function elementQuerySelectorAll(_this__u8e3s4, selector) { _init_properties_http_js_kt__7qsee5(); var element = Ksoup_instance.a3h(_this__u8e3s4.outerHTML); // Inline function 'kotlin.collections.map' call var this_0 = element.g3r(selector); // Inline function 'kotlin.collections.mapTo' call var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10)); var _iterator__ex2g4s = this_0.q(); while (_iterator__ex2g4s.r()) { var item = _iterator__ex2g4s.s(); var tmp$ret$0 = convert(item); destination.y(tmp$ret$0); } return destination; } function convert(_this__u8e3s4) { _init_properties_http_js_kt__7qsee5(); var tmp = _this__u8e3s4.y3q(); var tmp_0 = _this__u8e3s4.y3k(); var tmp_1 = _this__u8e3s4.k3o(); var tmp_2 = _this__u8e3s4.q3r(); var tmp_3 = _this__u8e3s4.t3r(); // Inline function 'kotlin.collections.associate' call var this_0 = _this__u8e3s4.f3n(); 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.q(); while (_iterator__ex2g4s.r()) { var element = _iterator__ex2g4s.s(); // Inline function 'kotlin.collections.plusAssign' call var pair = to(element.i1(), element.j1()); destination.j2(pair.kf_1, pair.lf_1); } var tmp_4 = destination; // Inline function 'kotlin.collections.map' call var this_1 = _this__u8e3s4.c3r(); // Inline function 'kotlin.collections.mapTo' call var destination_0 = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_1, 10)); var _iterator__ex2g4s_0 = this_1.q(); while (_iterator__ex2g4s_0.r()) { var item = _iterator__ex2g4s_0.s(); var tmp$ret$4 = convert(item); destination_0.y(tmp$ret$4); } return new Element(tmp, tmp_0, tmp_1, tmp_2, tmp_3, tmp_4, destination_0); } function engine$lambda($this$create) { _init_properties_http_js_kt__7qsee5(); $this$create.z2k_1 = true; $this$create.y2k_1 = Dispatchers_getInstance().gw_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.i3b(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.h4s_1 = $this_fetchDocumentAsPromise; CoroutineImpl.call(this, resultContinuation); } protoOf(fetchDocumentAsPromise$slambda).j4s = function ($this$promise, $completion) { var tmp = this.o1i($this$promise, $completion); tmp.j8_1 = Unit_instance; tmp.k8_1 = null; return tmp.p8(); }; protoOf(fetchDocumentAsPromise$slambda).b9 = function (p1, $completion) { return this.j4s((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $completion); }; protoOf(fetchDocumentAsPromise$slambda).p8 = function () { var suspendResult = this.j8_1; $sm: do try { var tmp = this.h8_1; switch (tmp) { case 0: this.i8_1 = 2; this.h8_1 = 1; suspendResult = fetchDocument(this.h4s_1, VOID, this); if (suspendResult === get_COROUTINE_SUSPENDED()) { return suspendResult; } continue $sm; case 1: return suspendResult; case 2: throw this.k8_1; } } catch ($p) { var e = $p; if (this.i8_1 === 2) { throw e; } else { this.h8_1 = this.i8_1; this.k8_1 = e; } } while (true); }; protoOf(fetchDocumentAsPromise$slambda).o1i = function ($this$promise, completion) { var i = new fetchDocumentAsPromise$slambda(this.h4s_1, completion); i.i4s_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.j4s($this$promise, $completion); }; l.$arity = 1; return l; } //region block: post-declaration defineProp(protoOf(Element), 'id', protoOf(Element).s4q); defineProp(protoOf(Element), 'classes', protoOf(Element).t4q); defineProp(protoOf(Element), 'style', protoOf(Element).u4q); defineProp(protoOf(Document), 'body', protoOf(Document).w4q); defineProp(protoOf(Document), 'bodyElements', protoOf(Document).x4q); defineProp(protoOf(Document), 'head', protoOf(Document).y4q); defineProp(protoOf(Document), 'title', protoOf(Document).z4q); defineProp(protoOf(Document), 'metadata', protoOf(Document).a4r); defineProp(protoOf(Document), 'linkTags', protoOf(Document).b4r); //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.documentQuerySelector = documentQuerySelector; $com$earthapp$shovel.documentGetElementById = documentGetElementById; $com$earthapp$shovel.documentGetElementsByClassName = documentGetElementsByClassName; $com$earthapp$shovel.documentInputValue = documentInputValue; $com$earthapp$shovel.elementQuerySelector = elementQuerySelector; $com$earthapp$shovel.elementGetElementById = elementGetElementById; $com$earthapp$shovel.elementGetElementsByClassName = elementGetElementsByClassName; $com$earthapp$shovel.elementInputValue = elementInputValue; var $com = _.com || (_.com = {}); var $com$earthapp = $com.earthapp || ($com.earthapp = {}); var $com$earthapp$shovel = $com$earthapp.shovel || ($com$earthapp.shovel = {}); $com$earthapp$shovel.documentQuerySelectorAll = documentQuerySelectorAll; $com$earthapp$shovel.elementQuerySelectorAll = elementQuerySelectorAll; _.fetchDocumentAsPromise = fetchDocumentAsPromise; _.fetchAsPromise = fetchAsPromise; } $jsExportAll$(_); kotlin_kotlin.$jsExportAll$(_); kotlin_io_ktor_ktor_client_core.$jsExportAll$(_); //endregion return _; })); //# sourceMappingURL=shovel.js.map