正在查看: Moneyman v2.316.0.0 应用的 HtmlNormalizer.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Moneyman v2.316.0.0 应用的 HtmlNormalizer.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.exponea.sdk.util;
import B.AbstractC0151g;
import Eh.A;
import Eh.j;
import Eh.l;
import Eh.n;
import Eh.r;
import Eh.y;
import Wf.B;
import Wf.K;
import Wf.x;
import Wf.z;
import android.content.Context;
import android.util.Base64;
import com.exponea.sdk.models.HtmlActionType;
import com.exponea.sdk.repository.DrawableCache;
import com.exponea.sdk.repository.DrawableCacheImpl;
import com.exponea.sdk.repository.FontCache;
import com.exponea.sdk.repository.FontCacheImpl;
import com.exponea.sdk.services.inappcontentblock.ContentBlockCarouselViewController;
import hg.e;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import kg.k;
import kotlin.Metadata;
import kotlin.jvm.internal.d;
import kotlin.jvm.internal.i;
import kotlin.text.Regex;
import kotlin.text.RegexOption;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.nodes.b;
import org.jsoup.select.Elements;
@Metadata(d1 = {"\u0000~\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u001e\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u000b\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0012\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0018\u0002\n\u0002\b\t\u0018\u0000 X2\u00020\u0001:\u0006YXZ[\\]B!\b\u0010\u0012\u0006\u0010\u0003\u001a\u00020\u0002\u0012\u0006\u0010\u0005\u001a\u00020\u0004\u0012\u0006\u0010\u0007\u001a\u00020\u0006¢\u0006\u0004\b\b\u0010\tB\u0019\b\u0016\u0012\u0006\u0010\u000b\u001a\u00020\n\u0012\u0006\u0010\u0007\u001a\u00020\u0006¢\u0006\u0004\b\b\u0010\fJ\u0019\u0010\u0010\u001a\u00020\u000f2\b\b\u0002\u0010\u000e\u001a\u00020\rH\u0007¢\u0006\u0004\b\u0010\u0010\u0011J\u0013\u0010\u0013\u001a\b\u0012\u0004\u0012\u00020\u00060\u0012¢\u0006\u0004\b\u0013\u0010\u0014J\u0013\u0010\u0015\u001a\b\u0012\u0004\u0012\u00020\u00060\u0012¢\u0006\u0004\b\u0015\u0010\u0014J\u000f\u0010\u0017\u001a\u00020\u0016H\u0002¢\u0006\u0004\b\u0017\u0010\u0018J\u0017\u0010\u001a\u001a\u00020\u00162\u0006\u0010\u0019\u001a\u00020\u0006H\u0002¢\u0006\u0004\b\u001a\u0010\u001bJ#\u0010\u001e\u001a\u00020\u00162\u0006\u0010\u001c\u001a\u00020\u00062\n\b\u0002\u0010\u001d\u001a\u0004\u0018\u00010\u0006H\u0002¢\u0006\u0004\b\u001e\u0010\u001fJ\u000f\u0010 \u001a\u00020\u0006H\u0002¢\u0006\u0004\b \u0010!J\u0015\u0010$\u001a\b\u0012\u0004\u0012\u00020#0\"H\u0002¢\u0006\u0004\b$\u0010%J\u000f\u0010&\u001a\u00020\u0016H\u0002¢\u0006\u0004\b&\u0010\u0018J\u0019\u0010)\u001a\u0004\u0018\u00010\u00062\u0006\u0010(\u001a\u00020'H\u0002¢\u0006\u0004\b)\u0010*J\u0017\u0010-\u001a\u00020,2\u0006\u0010+\u001a\u00020\u0006H\u0002¢\u0006\u0004\b-\u0010.J\u0017\u00101\u001a\u00020\u00162\u0006\u00100\u001a\u00020/H\u0002¢\u0006\u0004\b1\u00102J'\u00105\u001a\u00020\u00162\u0006\u00103\u001a\u00020'2\u0006\u0010+\u001a\u00020\u00062\u0006\u00104\u001a\u00020,H\u0002¢\u0006\u0004\b5\u00106J/\u0010:\u001a\u00020\u00162\u0006\u00107\u001a\u00020'2\u0006\u00108\u001a\u00020\u00062\u0006\u00109\u001a\u00020\u00062\u0006\u00104\u001a\u00020,H\u0002¢\u0006\u0004\b:\u0010;J\u000f\u0010<\u001a\u00020\u0016H\u0002¢\u0006\u0004\b<\u0010\u0018J\u000f\u0010=\u001a\u00020\u0016H\u0002¢\u0006\u0004\b=\u0010\u0018J\u0017\u0010?\u001a\u00020\u00062\u0006\u0010>\u001a\u00020\u0006H\u0002¢\u0006\u0004\b?\u0010@J\u001d\u0010C\u001a\b\u0012\u0004\u0012\u00020B0\"2\u0006\u0010A\u001a\u00020\u0006H\u0002¢\u0006\u0004\bC\u0010DJ\u000f\u0010E\u001a\u00020\u0016H\u0002¢\u0006\u0004\bE\u0010\u0018J\u000f\u0010F\u001a\u00020\u0016H\u0002¢\u0006\u0004\bF\u0010\u0018J\u0017\u0010H\u001a\u00020\u00062\u0006\u0010G\u001a\u00020\u0006H\u0002¢\u0006\u0004\bH\u0010@J\u0017\u0010J\u001a\u00020\u00062\u0006\u0010I\u001a\u00020\u0006H\u0002¢\u0006\u0004\bJ\u0010@J\u0019\u0010L\u001a\u0004\u0018\u00010K2\u0006\u0010+\u001a\u00020\u0006H\u0002¢\u0006\u0004\bL\u0010MJ\u0017\u0010N\u001a\u00020K2\u0006\u0010+\u001a\u00020\u0006H\u0002¢\u0006\u0004\bN\u0010MJ\u0017\u0010P\u001a\u00020/2\u0006\u0010O\u001a\u00020\u0006H\u0002¢\u0006\u0004\bP\u0010QR\u0014\u0010\u0003\u001a\u00020\u00028\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0003\u0010RR\u0014\u0010\u0005\u001a\u00020\u00048\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0005\u0010SR\u0014\u0010\u0007\u001a\u00020\u00068\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0007\u0010TR\u0016\u0010V\u001a\u0004\u0018\u00010U8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\bV\u0010W¨\u0006^"}, d2 = {"Lcom/exponea/sdk/util/HtmlNormalizer;", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "Lcom/exponea/sdk/repository/DrawableCache;", "imageCache", "Lcom/exponea/sdk/repository/FontCache;", "fontCache", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "originalHtml", "<init>", "(Lcom/exponea/sdk/repository/DrawableCache;Lcom/exponea/sdk/repository/FontCache;Ljava/lang/String;)V", "Landroid/content/Context;", "context", "(Landroid/content/Context;Ljava/lang/String;)V", "Lcom/exponea/sdk/util/HtmlNormalizer$HtmlNormalizerConfig;", "config", "Lcom/exponea/sdk/util/HtmlNormalizer$NormalizedResult;", "normalize", "(Lcom/exponea/sdk/util/HtmlNormalizer$HtmlNormalizerConfig;)Lcom/exponea/sdk/util/HtmlNormalizer$NormalizedResult;", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "collectImages", "()Ljava/util/Collection;", "collectFonts", "LVf/A;", "cleanHtml", "()V", "selector", "removeElements", "(Ljava/lang/String;)V", "attribute", "skipTag", "removeAttributes", "(Ljava/lang/String;Ljava/lang/String;)V", "exportHtml", "()Ljava/lang/String;", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "Lcom/exponea/sdk/util/HtmlNormalizer$ActionInfo;", "collectAnchorLinkButtons", "()Ljava/util/List;", "normalizeDataLinkButtons", "Lorg/jsoup/nodes/Element;", "actionButton", "readButtonText", "(Lorg/jsoup/nodes/Element;)Ljava/lang/String;", "url", "Lcom/exponea/sdk/models/HtmlActionType;", "determineActionTypeByUrl", "(Ljava/lang/String;)Lcom/exponea/sdk/models/HtmlActionType;", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "ensureCloseButton", "normalizeCloseButtons", "(Z)V", "target", "dataActionType", "applyActionInfo", "(Lorg/jsoup/nodes/Element;Ljava/lang/String;Lcom/exponea/sdk/models/HtmlActionType;)V", "child", HtmlNormalizer.HREF_ATTR, "cssClass", "wrapWithAnchorLink", "(Lorg/jsoup/nodes/Element;Ljava/lang/String;Ljava/lang/String;Lcom/exponea/sdk/models/HtmlActionType;)V", "makeResourcesToBeOffline", "makeStyleAttributesToBeOffline", "styleSource", "downloadOnlineResources", "(Ljava/lang/String;)Ljava/lang/String;", "cssStyle", "Lcom/exponea/sdk/util/HtmlNormalizer$CssOnlineUrl;", "collectOnlineUrlStatements", "(Ljava/lang/String;)Ljava/util/List;", "makeStylesheetsToBeOffline", "makeImageTagsToBeOffline", "imageSource", "asBase64Image", "fontSource", "asBase64Font", "Ljava/io/File;", "getFileFromUrl", "(Ljava/lang/String;)Ljava/io/File;", "getImageFromUrl", "uri", "isBase64Uri", "(Ljava/lang/String;)Z", "Lcom/exponea/sdk/repository/DrawableCache;", "Lcom/exponea/sdk/repository/FontCache;", "Ljava/lang/String;", "Lorg/jsoup/nodes/Document;", "document", "Lorg/jsoup/nodes/Document;", "Companion", "ActionInfo", "CssOnlineUrl", "DefaultConfig", "HtmlNormalizerConfig", "NormalizedResult", "sdk_release"}, k = 1, mv = {1, 9, 0}, xi = 48)
public final class HtmlNormalizer {
private static final String ANCHOR_BUTTON_SELECTOR = "a[href]";
private static final String[] ANCHOR_LINK_ATTRIBUTES;
private static final String ANCHOR_TAG_SELECTOR = "a";
private static final String CLOSE_BUTTON_ATTR_DEF = "data-actiontype='close'";
private static final String CLOSE_BUTTON_SELECTOR = "[data-actiontype='close']";
private static final String CLOSE_URL_PREFIX = "https://exponea.com/close_action_";
public static final Companion INSTANCE = new Companion(null);
private static final String DATA_ACTIONTYPE_ATTR = "data-actiontype";
private static final String DATA_LINK_ATTR = "data-link";
private static final String DATA_LINK_SELECTOR = "[data-link]";
private static final String FONT_MIMETYPE = "application/font";
private static final String HREF_ATTR = "href";
private static final String IFRAME_TAG_SELECTOR = "iframe";
private static final String IMAGE_MIMETYPE = "image/png";
private static final String[] INLINE_SCRIPT_ATTRIBUTES;
private static final String LINK_TAG_SELECTOR = "link";
private static final String META_TAG_SELECTOR = "meta:not([name='viewport'])";
private static final String SCRIPT_TAG_SELECTOR = "script";
private static final String[] SUPPORTED_CSS_URL_PROPERTIES;
private static final String TITLE_TAG_SELECTOR = "title";
private static final Regex cssAttributeRegexp;
private static final String cssDelimiterFormat = "[\\s]*:[\\s]*";
private static final Regex cssImportUrlRegexp;
private static final String cssKeyFormat = "-?[_a-zA-Z]+[_a-zA-Z0-9-]*";
private static final Regex cssUrlRegexp;
private static final String cssValueFormat = "[^;\\n]+";
private static final Set<RegexOption> regExpOptions;
private final Document document;
private final FontCache fontCache;
private final DrawableCache imageCache;
private final String originalHtml;
@Metadata(d1 = {"\u0000\u001a\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0007\u0018\u00002\u00020\u0001B\u001f\u0012\b\u0010\u0002\u001a\u0004\u0018\u00010\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0003\u0012\u0006\u0010\u0005\u001a\u00020\u0006¢\u0006\u0002\u0010\u0007R\u0011\u0010\u0005\u001a\u00020\u0006¢\u0006\b\n\u0000\u001a\u0004\b\b\u0010\tR\u0011\u0010\u0004\u001a\u00020\u0003¢\u0006\b\n\u0000\u001a\u0004\b\n\u0010\u000bR\u0013\u0010\u0002\u001a\u0004\u0018\u00010\u0003¢\u0006\b\n\u0000\u001a\u0004\b\f\u0010\u000b¨\u0006\r"}, d2 = {"Lcom/exponea/sdk/util/HtmlNormalizer$ActionInfo;", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "buttonText", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "actionUrl", "actionType", "Lcom/exponea/sdk/models/HtmlActionType;", "(Ljava/lang/String;Ljava/lang/String;Lcom/exponea/sdk/models/HtmlActionType;)V", "getActionType", "()Lcom/exponea/sdk/models/HtmlActionType;", "getActionUrl", "()Ljava/lang/String;", "getButtonText", "sdk_release"}, k = 1, mv = {1, 9, 0}, xi = 48)
public static final class ActionInfo {
private final HtmlActionType actionType;
private final String actionUrl;
private final String buttonText;
public ActionInfo(String str, String str2, HtmlActionType htmlActionType) {
i.g(str2, "actionUrl");
i.g(htmlActionType, "actionType");
this.buttonText = str;
this.actionUrl = str2;
this.actionType = htmlActionType;
}
public final HtmlActionType getActionType() {
return this.actionType;
}
public final String getActionUrl() {
return this.actionUrl;
}
public final String getButtonText() {
return this.buttonText;
}
}
@Metadata(d1 = {"\u0000,\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\u0011\n\u0002\b\u0016\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0010\"\n\u0002\u0018\u0002\n\u0000\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u0016\u0010\u0005\u001a\b\u0012\u0004\u0012\u00020\u00040\u0006X\u0082\u0004¢\u0006\u0004\n\u0002\u0010\u0007R\u000e\u0010\b\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\t\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\u000b\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\f\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\r\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\u000e\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\u000f\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\u0010\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\u0011\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\u0012\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u001c\u0010\u0013\u001a\b\u0012\u0004\u0012\u00020\u00040\u0006X\u0080\u0004¢\u0006\n\n\u0002\u0010\u0007\u001a\u0004\b\u0014\u0010\u0015R\u000e\u0010\u0016\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\u0017\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\u0018\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u001c\u0010\u0019\u001a\b\u0012\u0004\u0012\u00020\u00040\u0006X\u0080\u0004¢\u0006\n\n\u0002\u0010\u0007\u001a\u0004\b\u001a\u0010\u0015R\u000e\u0010\u001b\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\u001c\u001a\u00020\u001dX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u001e\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\u001f\u001a\u00020\u001dX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010 \u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010!\u001a\u00020\u001dX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\"\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u0014\u0010#\u001a\b\u0012\u0004\u0012\u00020%0$X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006&"}, d2 = {"Lcom/exponea/sdk/util/HtmlNormalizer$Companion;", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "()V", "ANCHOR_BUTTON_SELECTOR", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "ANCHOR_LINK_ATTRIBUTES", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "[Ljava/lang/String;", "ANCHOR_TAG_SELECTOR", "CLOSE_BUTTON_ATTR_DEF", "CLOSE_BUTTON_SELECTOR", "CLOSE_URL_PREFIX", "DATA_ACTIONTYPE_ATTR", "DATA_LINK_ATTR", "DATA_LINK_SELECTOR", "FONT_MIMETYPE", "HREF_ATTR", "IFRAME_TAG_SELECTOR", "IMAGE_MIMETYPE", "INLINE_SCRIPT_ATTRIBUTES", "getINLINE_SCRIPT_ATTRIBUTES$sdk_release", "()[Ljava/lang/String;", "LINK_TAG_SELECTOR", "META_TAG_SELECTOR", "SCRIPT_TAG_SELECTOR", "SUPPORTED_CSS_URL_PROPERTIES", "getSUPPORTED_CSS_URL_PROPERTIES$sdk_release", "TITLE_TAG_SELECTOR", "cssAttributeRegexp", "Lkotlin/text/Regex;", "cssDelimiterFormat", "cssImportUrlRegexp", "cssKeyFormat", "cssUrlRegexp", "cssValueFormat", "regExpOptions", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "Lkotlin/text/RegexOption;", "sdk_release"}, k = 1, mv = {1, 9, 0}, xi = 48)
public static final class Companion {
public Companion(d dVar) {
this();
}
public final String[] getINLINE_SCRIPT_ATTRIBUTES$sdk_release() {
return HtmlNormalizer.INLINE_SCRIPT_ATTRIBUTES;
}
public final String[] getSUPPORTED_CSS_URL_PROPERTIES$sdk_release() {
return HtmlNormalizer.SUPPORTED_CSS_URL_PROPERTIES;
}
private Companion() {
}
}
@Metadata(d1 = {"\u0000\"\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u000e\n\u0002\b\t\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0002\b\u0082\b\u0018\u00002\u00020\u0001B\u0015\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0003¢\u0006\u0002\u0010\u0005J\t\u0010\t\u001a\u00020\u0003HÆ\u0003J\t\u0010\n\u001a\u00020\u0003HÆ\u0003J\u001d\u0010\u000b\u001a\u00020\u00002\b\b\u0002\u0010\u0002\u001a\u00020\u00032\b\b\u0002\u0010\u0004\u001a\u00020\u0003HÆ\u0001J\u0013\u0010\f\u001a\u00020\r2\b\u0010\u000e\u001a\u0004\u0018\u00010\u0001HÖ\u0003J\t\u0010\u000f\u001a\u00020\u0010HÖ\u0001J\t\u0010\u0011\u001a\u00020\u0003HÖ\u0001R\u0011\u0010\u0002\u001a\u00020\u0003¢\u0006\b\n\u0000\u001a\u0004\b\u0006\u0010\u0007R\u0011\u0010\u0004\u001a\u00020\u0003¢\u0006\b\n\u0000\u001a\u0004\b\b\u0010\u0007¨\u0006\u0012"}, d2 = {"Lcom/exponea/sdk/util/HtmlNormalizer$CssOnlineUrl;", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "mimeType", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "url", "(Ljava/lang/String;Ljava/lang/String;)V", "getMimeType", "()Ljava/lang/String;", "getUrl", "component1", "component2", "copy", "equals", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "other", "hashCode", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "toString", "sdk_release"}, k = 1, mv = {1, 9, 0}, xi = 48)
public static final class CssOnlineUrl {
private final String mimeType;
private final String url;
public CssOnlineUrl(String str, String str2) {
i.g(str, "mimeType");
i.g(str2, "url");
this.mimeType = str;
this.url = str2;
}
public static CssOnlineUrl copy$default(CssOnlineUrl cssOnlineUrl, String str, String str2, int i5, Object obj) {
if ((i5 & 1) != 0) {
str = cssOnlineUrl.mimeType;
}
if ((i5 & 2) != 0) {
str2 = cssOnlineUrl.url;
}
return cssOnlineUrl.copy(str, str2);
}
public final String getMimeType() {
return this.mimeType;
}
public final String getUrl() {
return this.url;
}
public final CssOnlineUrl copy(String mimeType, String url) {
i.g(mimeType, "mimeType");
i.g(url, "url");
return new CssOnlineUrl(mimeType, url);
}
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof CssOnlineUrl)) {
return false;
}
CssOnlineUrl cssOnlineUrl = (CssOnlineUrl) other;
return i.b(this.mimeType, cssOnlineUrl.mimeType) && i.b(this.url, cssOnlineUrl.url);
}
public final String getMimeType() {
return this.mimeType;
}
public final String getUrl() {
return this.url;
}
public int hashCode() {
return this.url.hashCode() + (this.mimeType.hashCode() * 31);
}
public String toString() {
return AbstractC0151g.o("CssOnlineUrl(mimeType=", this.mimeType, ", url=", this.url, ")");
}
}
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\b\u0002\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002¨\u0006\u0003"}, d2 = {"Lcom/exponea/sdk/util/HtmlNormalizer$DefaultConfig;", "Lcom/exponea/sdk/util/HtmlNormalizer$HtmlNormalizerConfig;", "()V", "sdk_release"}, k = 1, mv = {1, 9, 0}, xi = 48)
public static final class DefaultConfig extends HtmlNormalizerConfig {
public DefaultConfig() {
super(true, true);
}
}
@Metadata(d1 = {"\u0000\u0012\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0006\b\u0016\u0018\u00002\u00020\u0001B\u0015\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0003¢\u0006\u0002\u0010\u0005R\u0011\u0010\u0004\u001a\u00020\u0003¢\u0006\b\n\u0000\u001a\u0004\b\u0006\u0010\u0007R\u0011\u0010\u0002\u001a\u00020\u0003¢\u0006\b\n\u0000\u001a\u0004\b\b\u0010\u0007¨\u0006\t"}, d2 = {"Lcom/exponea/sdk/util/HtmlNormalizer$HtmlNormalizerConfig;", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "makeResourcesOffline", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "ensureCloseButton", "(ZZ)V", "getEnsureCloseButton", "()Z", "getMakeResourcesOffline", "sdk_release"}, k = 1, mv = {1, 9, 0}, xi = 48)
public static class HtmlNormalizerConfig {
private final boolean ensureCloseButton;
private final boolean makeResourcesOffline;
public HtmlNormalizerConfig(boolean z7, boolean z8) {
this.makeResourcesOffline = z7;
this.ensureCloseButton = z8;
}
public final boolean getEnsureCloseButton() {
return this.ensureCloseButton;
}
public final boolean getMakeResourcesOffline() {
return this.makeResourcesOffline;
}
}
@Metadata(d1 = {"\u0000(\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u000e\n\u0002\b\u0005\n\u0002\u0010\u000b\n\u0002\b\t\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002J\u0010\u0010\u0016\u001a\u0004\u0018\u00010\u00052\u0006\u0010\u0017\u001a\u00020\u000bJ\u000e\u0010\u0018\u001a\u00020\u00112\u0006\u0010\u0017\u001a\u00020\u000bJ\u000e\u0010\u0019\u001a\u00020\u00112\u0006\u0010\u0017\u001a\u00020\u000bR \u0010\u0003\u001a\b\u0012\u0004\u0012\u00020\u00050\u0004X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0006\u0010\u0007\"\u0004\b\b\u0010\tR\u001c\u0010\n\u001a\u0004\u0018\u00010\u000bX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\f\u0010\r\"\u0004\b\u000e\u0010\u000fR\u001a\u0010\u0010\u001a\u00020\u0011X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0012\u0010\u0013\"\u0004\b\u0014\u0010\u0015¨\u0006\u001a"}, d2 = {"Lcom/exponea/sdk/util/HtmlNormalizer$NormalizedResult;", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "()V", "actions", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "Lcom/exponea/sdk/util/HtmlNormalizer$ActionInfo;", "getActions", "()Ljava/util/List;", "setActions", "(Ljava/util/List;)V", "html", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "getHtml", "()Ljava/lang/String;", "setHtml", "(Ljava/lang/String;)V", "valid", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "getValid", "()Z", "setValid", "(Z)V", "findActionInfoByUrl", "url", "isActionUrl", "isCloseAction", "sdk_release"}, k = 1, mv = {1, 9, 0}, xi = 48)
public static final class NormalizedResult {
private String html;
private boolean valid = true;
private List<ActionInfo> actions = new ArrayList();
public final ActionInfo findActionInfoByUrl(String url) {
i.g(url, "url");
List<ActionInfo> list = this.actions;
ArrayList arrayList = new ArrayList();
for (Object obj : list) {
if (URLUtils.INSTANCE.areEqualAsURLs(((ActionInfo) obj).getActionUrl(), url)) {
arrayList.add(obj);
}
}
Object obj2 = null;
if (arrayList.isEmpty()) {
return null;
}
Iterator it = arrayList.iterator();
while (true) {
if (!it.hasNext()) {
break;
}
Object next = it.next();
if (((ActionInfo) next).getActionType() != HtmlActionType.CLOSE) {
obj2 = next;
break;
}
}
ActionInfo actionInfo = (ActionInfo) obj2;
return actionInfo != null ? actionInfo : (ActionInfo) K.N(arrayList);
}
public final List<ActionInfo> getActions() {
return this.actions;
}
public final String getHtml() {
return this.html;
}
public final boolean getValid() {
return this.valid;
}
public final boolean isActionUrl(String url) {
i.g(url, "url");
ActionInfo findActionInfoByUrl = findActionInfoByUrl(url);
return (findActionInfoByUrl == null || findActionInfoByUrl.getActionType() == HtmlActionType.CLOSE) ? false : true;
}
public final boolean isCloseAction(String url) {
i.g(url, "url");
ActionInfo findActionInfoByUrl = findActionInfoByUrl(url);
return findActionInfoByUrl != null && findActionInfoByUrl.getActionType() == HtmlActionType.CLOSE;
}
public final void setActions(List<ActionInfo> list) {
i.g(list, "<set-?>");
this.actions = list;
}
public final void setHtml(String str) {
this.html = str;
}
public final void setValid(boolean z7) {
this.valid = z7;
}
}
static {
Set<RegexOption> R7 = x.R(new RegexOption[]{RegexOption.b, RegexOption.c});
regExpOptions = R7;
cssUrlRegexp = new Regex("url\\((.+?)\\)", R7);
cssImportUrlRegexp = new Regex("@import[\\s]+url\\(.+?\\)", R7);
cssAttributeRegexp = new Regex("(-?[_a-zA-Z]+[_a-zA-Z0-9-]*)[\\s]*:[\\s]*([^;\\n]+)", R7);
INLINE_SCRIPT_ATTRIBUTES = new String[]{"onafterprint", "onbeforeprint", "onbeforeunload", "onerror", "onhashchange", "onload", "onmessage", "onoffline", "ononline", "onpagehide", "onpageshow", "onpopstate", "onresize", "onstorage", "onunload", "onblur", "onchange", "oncontextmenu", "onfocus", "oninput", "oninvalid", "onreset", "onsearch", "onselect", "onsubmit", "onkeydown", "onkeypress", "onkeyup", "onclick", "ondblclick", "onmousedown", "onmousemove", "onmouseout", "onmouseover", "onmouseup", "onmousewheel", "onwheel", "ondrag", "ondragend", "ondragenter", "ondragleave", "ondragover", "ondragstart", "ondrop", "onscroll", "oncopy", "oncut", "onpaste", "onabort", "oncanplay", "oncanplaythrough", "oncuechange", "ondurationchange", "onemptied", "onended", "onerror", "onloadeddata", "onloadedmetadata", "onloadstart", "onpause", "onplay", "onplaying", "onprogress", "onratechange", "onseeked", "onseeking", "onstalled", "onsuspend", "ontimeupdate", "onvolumechange", "onwaiting", "ontoggle"};
ANCHOR_LINK_ATTRIBUTES = new String[]{"download", "ping", "target"};
SUPPORTED_CSS_URL_PROPERTIES = new String[]{"background", "background-image", "border-image", "border-image-source", "content", "cursor", "filter", "list-style", "list-style-image", "mask", "mask-image", "offset-path", "src"};
}
public HtmlNormalizer(DrawableCache drawableCache, FontCache fontCache, String str) {
Document document;
i.g(drawableCache, "imageCache");
i.g(fontCache, "fontCache");
i.g(str, "originalHtml");
this.imageCache = drawableCache;
this.fontCache = fontCache;
this.originalHtml = str;
try {
document = dr.a.a(str);
} catch (Exception unused) {
Logger.INSTANCE.i(this, "[HTML] Unable to parse original HTML source code ".concat(str));
document = null;
}
this.document = document;
}
private final void applyActionInfo(Element target, String url, HtmlActionType dataActionType) {
if (target.O(ANCHOR_TAG_SELECTOR)) {
target.f(HREF_ATTR, url);
}
target.f(DATA_LINK_ATTR, url);
target.f(DATA_ACTIONTYPE_ATTR, dataActionType.getValue());
}
private final String asBase64Font(String fontSource) {
if (isBase64Uri(fontSource)) {
return fontSource;
}
File fileFromUrl = getFileFromUrl(fontSource);
if (fileFromUrl != null) {
return AbstractC0151g.l("data:application/font;charset=utf-8;base64,", Base64.encodeToString(e.d(fileFromUrl), 2));
}
Logger.INSTANCE.e(this, "Unable to load font " + fontSource + " for HTML");
return fontSource;
}
private final String asBase64Image(String imageSource) {
return isBase64Uri(imageSource) ? imageSource : AbstractC0151g.l("data:image/png;base64,", Base64.encodeToString(e.d(getImageFromUrl(imageSource)), 2));
}
private final void cleanHtml() {
removeAttributes(HREF_ATTR, ANCHOR_TAG_SELECTOR);
for (String str : ANCHOR_LINK_ATTRIBUTES) {
removeAttributes$default(this, str, null, 2, null);
}
for (String str2 : INLINE_SCRIPT_ATTRIBUTES) {
removeAttributes$default(this, str2, null, 2, null);
}
removeElements(META_TAG_SELECTOR);
removeElements(SCRIPT_TAG_SELECTOR);
removeElements(TITLE_TAG_SELECTOR);
removeElements(LINK_TAG_SELECTOR);
removeElements(IFRAME_TAG_SELECTOR);
}
private final List<ActionInfo> collectAnchorLinkButtons() {
HashMap hashMap = new HashMap();
Document document = this.document;
if (document == null) {
Logger.INSTANCE.e(this, "[HTML] Original HTML code is invalid, unable to collect buttons");
Collection values = hashMap.values();
i.f(values, "<get-values>(...)");
return K.r0(values);
}
Iterator it = document.S(ANCHOR_BUTTON_SELECTOR).iterator();
while (it.hasNext()) {
Element element = (Element) it.next();
String e4 = element.e(HREF_ATTR);
if (e4 == null || A.F(e4)) {
Logger.INSTANCE.e(this, "[HTML] Action button found but with empty action");
} else {
String readButtonText = readButtonText(element);
HtmlActionType find = HtmlActionType.INSTANCE.find(element.e(DATA_ACTIONTYPE_ATTR));
if (find == null) {
i.d(e4);
find = determineActionTypeByUrl(e4);
}
i.d(e4);
applyActionInfo(element, e4, find);
if (hashMap.containsKey(e4)) {
Logger.INSTANCE.e(this, "[HTML] Action button found but with duplicate action ".concat(e4));
} else {
hashMap.put(e4, new ActionInfo(readButtonText, e4, find));
}
}
}
Collection values2 = hashMap.values();
i.f(values2, "<get-values>(...)");
return K.r0(values2);
}
private final List<CssOnlineUrl> collectOnlineUrlStatements(String cssStyle) {
ArrayList arrayList = new ArrayList();
Dh.i iVar = new Dh.i(Regex.c(cssImportUrlRegexp, cssStyle));
while (iVar.hasNext()) {
Dh.i iVar2 = new Dh.i(Regex.c(cssUrlRegexp, ((l) iVar.next()).c()));
while (iVar2.hasNext()) {
arrayList.add(new CssOnlineUrl(FONT_MIMETYPE, A.d0((String) K.V(((l) iVar2.next()).a()), new char[]{'\'', '\"'})));
}
}
Dh.i iVar3 = new Dh.i(Regex.c(cssAttributeRegexp, cssStyle));
while (iVar3.hasNext()) {
n nVar = ((l) iVar3.next()).c;
if (nVar.c() == 3) {
j f7 = nVar.f(1);
String str = f7 != null ? f7.a : null;
if (str != null) {
String[] strArr = SUPPORTED_CSS_URL_PROPERTIES;
String lowerCase = str.toLowerCase(Locale.ROOT);
i.f(lowerCase, "this as java.lang.String).toLowerCase(Locale.ROOT)");
if (x.s(lowerCase, strArr)) {
j f8 = nVar.f(2);
String str2 = f8 != null ? f8.a : null;
if (str2 != null) {
Dh.i iVar4 = new Dh.i(Regex.c(cssUrlRegexp, str2));
while (iVar4.hasNext()) {
arrayList.add(new CssOnlineUrl(str.equals("src") ? FONT_MIMETYPE : IMAGE_MIMETYPE, A.d0((String) K.V(((l) iVar4.next()).a()), new char[]{'\'', '\"'})));
}
}
}
}
}
}
return arrayList;
}
private final HtmlActionType determineActionTypeByUrl(String url) {
return (y.v(url, "http://", false) || y.v(url, "https://", false)) ? HtmlActionType.BROWSER : HtmlActionType.DEEPLINK;
}
private final String downloadOnlineResources(String styleSource) {
String str;
for (CssOnlineUrl cssOnlineUrl : collectOnlineUrlStatements(styleSource)) {
String mimeType = cssOnlineUrl.getMimeType();
if (i.b(mimeType, FONT_MIMETYPE)) {
str = asBase64Font(cssOnlineUrl.getUrl());
} else if (i.b(mimeType, IMAGE_MIMETYPE)) {
str = asBase64Image(cssOnlineUrl.getUrl());
} else {
Logger.INSTANCE.e(this, "Unsupported mime type " + cssOnlineUrl.getMimeType());
str = null;
}
if (str == null || A.F(str)) {
Logger.INSTANCE.e(this, "Unable to make offline resource " + cssOnlineUrl.getUrl());
} else {
styleSource = y.t(styleSource, cssOnlineUrl.getUrl(), str);
}
}
return styleSource;
}
private final String exportHtml() {
Document document = this.document;
i.d(document);
String M7 = document.M();
i.f(M7, "html(...)");
return M7;
}
private final File getFileFromUrl(String url) {
File fontFile = this.fontCache.getFontFile(url);
if (fontFile == null) {
final CountDownLatch countDownLatch = new CountDownLatch(1);
this.fontCache.preload(z.c(url), new k() {
{
super(1);
}
public Object invoke(Object obj) {
invoke(((Boolean) obj).booleanValue());
return Vf.A.a;
}
public final void invoke(boolean z7) {
countDownLatch.countDown();
}
});
countDownLatch.await(10L, TimeUnit.SECONDS);
fontFile = this.fontCache.getFontFile(url);
}
if (fontFile != null) {
return fontFile;
}
Logger.INSTANCE.e(this, "Unable to load file " + url + " for HTML");
throw new IllegalStateException("File is not preloaded");
}
private final File getImageFromUrl(String url) {
File file = this.imageCache.getFile(url);
if (file == null) {
final CountDownLatch countDownLatch = new CountDownLatch(1);
this.imageCache.preload(z.c(url), new k() {
{
super(1);
}
public Object invoke(Object obj) {
invoke(((Boolean) obj).booleanValue());
return Vf.A.a;
}
public final void invoke(boolean z7) {
countDownLatch.countDown();
}
});
countDownLatch.await(10L, TimeUnit.SECONDS);
file = this.imageCache.getFile(url);
}
if (file != null) {
return file;
}
Logger.INSTANCE.e(this, "Unable to load image " + url + " for HTML");
throw new IllegalStateException("Image is not preloaded");
}
private final boolean isBase64Uri(String uri) {
return y.v(uri, "data:image/", true) && A.w(uri, "base64,", true);
}
private final void makeImageTagsToBeOffline() {
Document document = this.document;
i.d(document);
Iterator it = document.S("img").iterator();
while (it.hasNext()) {
Element element = (Element) it.next();
String e4 = element.e("src");
if (e4 != null && e4.length() != 0) {
try {
element.f("src", asBase64Image(e4));
} catch (Exception e7) {
Logger.INSTANCE.w(this, AbstractC0151g.n("[HTML] Image url ", e4, " has not been preloaded: ", e7.getLocalizedMessage()));
throw e7;
}
}
}
}
private final void makeResourcesToBeOffline() {
makeImageTagsToBeOffline();
makeStylesheetsToBeOffline();
makeStyleAttributesToBeOffline();
}
private final void makeStyleAttributesToBeOffline() {
Document document = this.document;
i.d(document);
Iterator it = document.S("[style]").iterator();
while (it.hasNext()) {
Element element = (Element) it.next();
String e4 = element.e("style");
if (e4 != null && e4.length() != 0) {
element.f("style", downloadOnlineResources(e4));
}
}
}
private final void makeStylesheetsToBeOffline() {
Document document = this.document;
i.d(document);
Iterator it = document.S("style").iterator();
while (it.hasNext()) {
Element element = (Element) it.next();
String J5 = element.J();
i.f(J5, "data(...)");
element.V(downloadOnlineResources(J5));
}
}
public static NormalizedResult normalize$default(HtmlNormalizer htmlNormalizer, HtmlNormalizerConfig htmlNormalizerConfig, int i5, Object obj) {
if ((i5 & 1) != 0) {
htmlNormalizerConfig = new DefaultConfig();
}
return htmlNormalizer.normalize(htmlNormalizerConfig);
}
private final void normalizeCloseButtons(boolean ensureCloseButton) {
Document document = this.document;
if (document == null) {
return;
}
Elements<Element> S5 = document.S(CLOSE_BUTTON_SELECTOR);
if (S5.isEmpty() && ensureCloseButton) {
Logger.INSTANCE.i(this, "[HTML] Adding default close-button");
String str = "close-button-" + UUID.randomUUID();
this.document.X().F("<div data-actiontype='close' class='" + str + "'><div>");
this.document.Y().F(r.b("\n <style>\n ." + str + " {\n display: inline-block;\n position: absolute;\n width: max(min(5vw, 5vh), 16px);\n height: max(min(5vw, 5vh), 16px);\n top: 10px;\n right: 10px;\n cursor: pointer;\n border-radius: 50%;\n background-color: rgba(250, 250, 250, 0.6);\n }\n ." + str + ":before {\n content: '×';\n position: absolute;\n display: flex;\n justify-content: center;\n width: max(min(5vw, 5vh), 16px);\n height: max(min(5vw, 5vh), 16px);\n color: rgb(0, 0, 0);\n font-size: max(min(5vw, 5vh), 16px);\n line-height: max(min(5vw, 5vh), 16px);\n }\n </style>\n "));
S5 = this.document.S(CLOSE_BUTTON_SELECTOR);
}
if (ensureCloseButton && S5.isEmpty()) {
throw new IllegalStateException("Action close cannot be ensured");
}
for (Element element : S5) {
String uuid = UUID.randomUUID().toString();
i.f(uuid, "toString(...)");
String concat = CLOSE_URL_PREFIX.concat(uuid);
if (element.O(ANCHOR_TAG_SELECTOR)) {
Logger.INSTANCE.i(this, "[HTML] Fixing close button as a-href link to close action");
applyActionInfo(element, concat, HtmlActionType.CLOSE);
} else {
Element element2 = ((org.jsoup.nodes.i) element).a;
if (element2 == null || !element2.O(ANCHOR_TAG_SELECTOR)) {
Logger.INSTANCE.i(this, "[HTML] Wrapping Close button with an a-href");
HtmlActionType htmlActionType = HtmlActionType.CLOSE;
applyActionInfo(element, concat, htmlActionType);
wrapWithAnchorLink(element, concat, "close-button-href-".concat(uuid), htmlActionType);
} else {
Logger.INSTANCE.i(this, "[HTML] Fixing parent a-href link to close action");
HtmlActionType htmlActionType2 = HtmlActionType.CLOSE;
applyActionInfo(element, concat, htmlActionType2);
Element element3 = (Element) ((org.jsoup.nodes.i) element).a;
i.d(element3);
applyActionInfo(element3, concat, htmlActionType2);
}
}
}
}
private final void normalizeDataLinkButtons() {
Document document = this.document;
if (document == null) {
return;
}
Iterator it = document.S(DATA_LINK_SELECTOR).iterator();
while (it.hasNext()) {
Element element = (Element) it.next();
String e4 = element.e(DATA_LINK_ATTR);
if (e4 == null || A.F(e4)) {
Logger.INSTANCE.e(this, "[HTML] Action button found but with empty action");
} else {
HtmlActionType find = HtmlActionType.INSTANCE.find(element.e(DATA_ACTIONTYPE_ATTR));
if (find == null) {
i.d(e4);
find = determineActionTypeByUrl(e4);
}
if (element.O(ANCHOR_TAG_SELECTOR)) {
Logger.INSTANCE.v(this, "[HTML] Applying data-link to an a-href link");
i.d(e4);
applyActionInfo(element, e4, find);
} else {
Element element2 = ((org.jsoup.nodes.i) element).a;
if (element2 == null || !element2.O(ANCHOR_TAG_SELECTOR)) {
Logger.INSTANCE.v(this, "[HTML] Wrapping data-link with an a-href");
i.d(e4);
applyActionInfo(element, e4, find);
wrapWithAnchorLink(element, e4, "action-button-href-" + UUID.randomUUID(), find);
} else {
Logger.INSTANCE.v(this, "[HTML] Applying data-link to a parent as an a-href link");
i.d(e4);
applyActionInfo(element, e4, find);
Element element3 = (Element) ((org.jsoup.nodes.i) element).a;
i.d(element3);
applyActionInfo(element3, e4, find);
}
}
}
}
}
private final String readButtonText(Element actionButton) {
String U7 = actionButton.U();
if (U7 == null || U7.length() == 0) {
return null;
}
return U7;
}
private final void removeAttributes(String attribute, String skipTag) {
b g7;
int n7;
Document document = this.document;
i.d(document);
Iterator it = document.S("[" + attribute + "]").iterator();
while (it.hasNext()) {
Element element = (Element) it.next();
if (skipTag == null || !element.O(skipTag)) {
element.getClass();
er.b.A(attribute);
if (element.p() && (n7 = (g7 = element.g()).n(attribute)) != -1) {
g7.v(n7);
}
}
}
}
public static void removeAttributes$default(HtmlNormalizer htmlNormalizer, String str, String str2, int i5, Object obj) {
if ((i5 & 2) != 0) {
str2 = null;
}
htmlNormalizer.removeAttributes(str, str2);
}
private final void removeElements(String selector) {
Document document = this.document;
i.d(document);
Iterator it = document.S(selector).iterator();
while (it.hasNext()) {
((Element) it.next()).B();
}
}
private final void wrapWithAnchorLink(Element child, String href, String cssClass, HtmlActionType dataActionType) {
Document document = this.document;
if (document != null) {
document.Y().F(r.b("\n <style>\n ." + cssClass + " {\n text-decoration: none;\n }\n </style>\n "));
}
String value = dataActionType.getValue();
StringBuilder e4 = ug.z.e("\n <a href='", href, "'\n class='", cssClass, "'\n data-link='");
e4.append(href);
e4.append("'\n data-actiontype='");
e4.append(value);
e4.append("'\n >\n </a>\n ");
String b8 = r.b(e4.toString());
child.getClass();
er.b.y(b8);
org.jsoup.nodes.i iVar = ((org.jsoup.nodes.i) child).a;
List a8 = org.jsoup.nodes.j.a(child).a(b8, (iVar == null || !(iVar instanceof Element)) ? child : (Element) iVar, child.h());
Element element = (org.jsoup.nodes.i) a8.get(0);
if (element instanceof Element) {
Element element2 = element;
Element element3 = element2;
while (element3.H().size() > 0) {
element3 = (Element) element3.H().get(0);
}
org.jsoup.nodes.i iVar2 = ((org.jsoup.nodes.i) child).a;
if (iVar2 != null) {
iVar2.D(child, element2);
}
element3.d(new org.jsoup.nodes.i[]{child});
if (a8.size() > 0) {
for (int i5 = 0; i5 < a8.size(); i5++) {
Element element4 = (org.jsoup.nodes.i) a8.get(i5);
if (element2 != element4) {
org.jsoup.nodes.i iVar3 = ((org.jsoup.nodes.i) element4).a;
if (iVar3 != null) {
iVar3.C(element4);
}
element2.getClass();
er.b.A(((org.jsoup.nodes.i) element2).a);
((org.jsoup.nodes.i) element2).a.b(((org.jsoup.nodes.i) element2).b + 1, new org.jsoup.nodes.i[]{element4});
}
}
}
}
}
public final Collection<String> collectFonts() {
if (this.document == null) {
List list = Collections.EMPTY_LIST;
i.f(list, "emptyList(...)");
return list;
}
ArrayList arrayList = new ArrayList();
Iterator it = this.document.S("style").iterator();
while (it.hasNext()) {
String J5 = ((Element) it.next()).J();
i.d(J5);
List<CssOnlineUrl> collectOnlineUrlStatements = collectOnlineUrlStatements(J5);
ArrayList arrayList2 = new ArrayList();
for (Object obj : collectOnlineUrlStatements) {
if (i.b(((CssOnlineUrl) obj).getMimeType(), FONT_MIMETYPE)) {
arrayList2.add(obj);
}
}
ArrayList arrayList3 = new ArrayList(B.o(arrayList2, 10));
Iterator it2 = arrayList2.iterator();
while (it2.hasNext()) {
arrayList3.add(((CssOnlineUrl) it2.next()).getUrl());
}
ArrayList arrayList4 = new ArrayList();
for (Object obj2 : arrayList3) {
if (!A.F((String) obj2)) {
arrayList4.add(obj2);
}
}
arrayList.addAll(arrayList4);
}
Iterator it3 = this.document.S("[style]").iterator();
while (it3.hasNext()) {
String e4 = ((Element) it3.next()).e("style");
if (e4 != null && !A.F(e4)) {
i.d(e4);
List<CssOnlineUrl> collectOnlineUrlStatements2 = collectOnlineUrlStatements(e4);
ArrayList arrayList5 = new ArrayList();
for (Object obj3 : collectOnlineUrlStatements2) {
if (i.b(((CssOnlineUrl) obj3).getMimeType(), FONT_MIMETYPE)) {
arrayList5.add(obj3);
}
}
ArrayList arrayList6 = new ArrayList(B.o(arrayList5, 10));
Iterator it4 = arrayList5.iterator();
while (it4.hasNext()) {
arrayList6.add(((CssOnlineUrl) it4.next()).getUrl());
}
ArrayList arrayList7 = new ArrayList();
for (Object obj4 : arrayList6) {
if (!A.F((String) obj4)) {
arrayList7.add(obj4);
}
}
arrayList.addAll(arrayList7);
}
}
return arrayList;
}
public final Collection<String> collectImages() {
if (this.document == null) {
List list = Collections.EMPTY_LIST;
i.f(list, "emptyList(...)");
return list;
}
ArrayList arrayList = new ArrayList();
Iterator it = this.document.S("img").iterator();
while (it.hasNext()) {
String e4 = ((Element) it.next()).e("src");
i.d(e4);
if (!A.F(e4) && !isBase64Uri(e4)) {
arrayList.add(e4);
}
}
Iterator it2 = this.document.S("style").iterator();
while (it2.hasNext()) {
String J5 = ((Element) it2.next()).J();
i.d(J5);
List<CssOnlineUrl> collectOnlineUrlStatements = collectOnlineUrlStatements(J5);
ArrayList arrayList2 = new ArrayList();
for (Object obj : collectOnlineUrlStatements) {
if (i.b(((CssOnlineUrl) obj).getMimeType(), IMAGE_MIMETYPE)) {
arrayList2.add(obj);
}
}
ArrayList arrayList3 = new ArrayList(B.o(arrayList2, 10));
Iterator it3 = arrayList2.iterator();
while (it3.hasNext()) {
arrayList3.add(((CssOnlineUrl) it3.next()).getUrl());
}
ArrayList arrayList4 = new ArrayList();
for (Object obj2 : arrayList3) {
if (!A.F((String) obj2)) {
arrayList4.add(obj2);
}
}
arrayList.addAll(arrayList4);
}
Iterator it4 = this.document.S("[style]").iterator();
while (it4.hasNext()) {
String e7 = ((Element) it4.next()).e("style");
if (e7 != null && !A.F(e7)) {
i.d(e7);
List<CssOnlineUrl> collectOnlineUrlStatements2 = collectOnlineUrlStatements(e7);
ArrayList arrayList5 = new ArrayList();
for (Object obj3 : collectOnlineUrlStatements2) {
if (i.b(((CssOnlineUrl) obj3).getMimeType(), IMAGE_MIMETYPE)) {
arrayList5.add(obj3);
}
}
ArrayList arrayList6 = new ArrayList(B.o(arrayList5, 10));
Iterator it5 = arrayList5.iterator();
while (it5.hasNext()) {
arrayList6.add(((CssOnlineUrl) it5.next()).getUrl());
}
ArrayList arrayList7 = new ArrayList();
for (Object obj4 : arrayList6) {
if (!A.F((String) obj4)) {
arrayList7.add(obj4);
}
}
arrayList.addAll(arrayList7);
}
}
return arrayList;
}
public final NormalizedResult normalize(HtmlNormalizerConfig config) {
i.g(config, "config");
NormalizedResult normalizedResult = new NormalizedResult();
if (this.document == null) {
Logger.INSTANCE.i(this, "[HTML] Original HTML code is invalid, unable to normalize");
normalizedResult.setValid(false);
return normalizedResult;
}
try {
cleanHtml();
if (config.getMakeResourcesOffline()) {
makeResourcesToBeOffline();
}
normalizeCloseButtons(config.getEnsureCloseButton());
normalizeDataLinkButtons();
normalizedResult.setActions(collectAnchorLinkButtons());
normalizedResult.setHtml(exportHtml());
normalizedResult.setValid(true);
return normalizedResult;
} catch (Exception e4) {
Logger.INSTANCE.w(this, "[HTML] HTML parsing failed " + e4.getLocalizedMessage());
normalizedResult.setValid(false);
return normalizedResult;
}
}
public HtmlNormalizer(Context context, String str) {
this(new DrawableCacheImpl(context), new FontCacheImpl(context), str);
i.g(context, "context");
i.g(str, "originalHtml");
}
}