import {
    G as F,
    R as I,
    r as f,
    C as q,
    H as A,
    I as m,
    Q as s,
    J as n,
    aB as y,
    P as v,
    O as G,
    K as b,
    M as x,
    ao as H,
    aC as M,
    aD as O,
    N as k,
    u as R
} from "./common.modules-5cfe2cf4.js";
import {
    aE as V,
    as as g,
    at as h,
    A as D,
    aF as T,
    G as J,
    aG as K,
    N as Q
} from "./page-activity-ActivityDetail-a58ec568.js";
const W = l => (M("data-v-887c2eae"), l = l(), O(), l),
    j = {
        class: "download-center"
    },
    z = W(() => n("div", {
        class: "banner"
    }, null, -1)),
    X = ["onClick"],
    Y = ["src"],
    Z = {
        class: "text"
    },
    ae = F({
        __name: "index",
        setup(l) {
            const {
                PWA: _
            } = V(), t = I(), E = () => {
                t.back()
            }, i = f(""), r = f([]), c = f(null), d = f(null), u = "ar048";
            console.log("Entrance Name:", u);
            const p = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream,
                N = () => {
                    if (window.gtag && window.gtag("event", "quick_down_click"), g()) {
                        h(`${window.location.origin}/download/${u}/quick.apk`);
                        return
                    }
                    p ? t.push("/downloadCenter/ios") : _.value.canIUse ? _.value.download && _.value.download() : S()
                },
                S = async () => {
                    const e = `${window.location.origin}/download/${u}/quick.apk`;
                    try {
                        if (!(await fetch(e, {
                                method: "HEAD",
                                cache: "no-store"
                            })).ok) throw new Error("File not found");
                        if (g()) {
                            h(e);
                            return
                        }
                        const o = document.createElement("a");
                        o.href = e, o.download = "quick.apk", document.body.appendChild(o), o.click(), document.body.removeChild(o)
                    } catch (a) {
                        console.error("Download failed:", a), t.push("/downloadCenter/empty")
                    }
                },
                U = async () => {
                    let e = `${window.location.origin}/download/${u}/full.apk`;
                    if (p)
                        if (i.value) {
                            window.open(i.value, "_blank");
                            return
                        } else {
                            t.push("/downloadCenter/empty");
                            return
                        }
                    try {
                        if (!(await fetch(e, {
                                method: "HEAD",
                                cache: "no-store"
                            })).ok) throw new Error("File not found");
                        if (window.gtag && window.gtag("event", "full_down_click"), g()) {
                            h(e);
                            return
                        }
                        const o = document.createElement("a");
                        o.href = e, o.download = "full.apk", document.body.appendChild(o), o.click(), document.body.removeChild(o)
                    } catch (a) {
                        console.error("Download failed:", a), t.push("/downloadCenter/empty")
                    }
                },
                L = async e => {
                    if (!/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) {
                        if (g()) {
                            h(e);
                            return
                        }
                        window.open(e, "_blank");
                        return
                    } else {
                        R(Q.global.t("downloadFileiOSError"));
                        return
                    }
                },
                $ = () => {
                    c.value && d.value && (c.value.classList.toggle("open"), c.value.classList.contains("open") ? d.value.className = "app-list open" : d.value.className = "app-list")
                },
                P = async () => {
                    const e = await D(T());
                    e.data.iosUrl ? i.value = e.data.iosUrl : i.value = ""
                },
                B = async () => {
                    if (!J().getToken) {
                        r.value = [];
                        return
                    }
                    const o = await D(K());
                    o.data && Array.isArray(o.data) && (r.value = o.data)
                };
            return q(() => {
                B(), p && P()
            }), (e, a) => {
                const o = A("NavBar"),
                    w = A("svg-icon");
                return k(), m(b, null, [s(o, {
                    title: e.$t("e1"),
                    "left-arrow": "",
                    onClickLeft: E
                }, null, 8, ["title"]), n("div", j, [z, n("div", {
                    class: "btn1",
                    onClick: N
                }, [s(w, {
                    name: "ac_fast"
                }), y(v(e.$t("e2")), 1)]), n("div", {
                    class: "btn2",
                    onClick: U
                }, [s(w, {
                    name: "ac_download"
                }), y(v(e.$t("e3")), 1)]), !G(p) && r.value.length ? (k(), m(b, {
                    key: 0
                }, [n("div", {
                    class: "btn3 open",
                    ref_key: "btn3",
                    ref: c,
                    onClick: $
                }, [s(w, {
                    name: "ac_private"
                }), y(" " + v(e.$t("e8")) + " ", 1), s(w, {
                    class: "down",
                    name: "ac_down"
                })], 512), n("div", {
                    class: "app-list open",
                    ref_key: "appListDiv",
                    ref: d
                }, [(k(!0), m(b, null, x(r.value, C => (k(), m("div", {
                    class: "app-item",
                    onClick: ee => L(C.downAppURL)
                }, [n("img", {
                    class: "icon",
                    src: C.imgUrl
                }, null, 8, Y), n("div", Z, v(C.appName), 1)], 8, X))), 256))], 512)], 64)) : H("v-if", !0)])], 64)
            }
        }
    });
export {
    ae as _
};