import {
    G as Q,
    r as l,
    R as Z,
    T as X,
    $ as H,
    aV as Y,
    aW as ee,
    C as ae,
    H as h,
    aA as te,
    I as m,
    Q as T,
    av as p,
    au as b,
    J as s,
    K as L,
    M as x,
    N as n,
    P as d,
    ap as C,
    ax as B,
    aF as se,
    O as f,
    ao as ne
} from "./common.modules-5cfe2cf4.js";
import {
    i as le,
    A as oe,
    aH as ie,
    aI as ue,
    _ as ce
} from "./page-activity-ActivityDetail-a58ec568.js";
import {
    F as re,
    a as me
} from "./page-home-AllGames-47ed4658.js";
import "./page-turntable-assets-d6267459.js";
import "./native/index-2ac88fb8.js";
import "./en-cfd26acf.js";
const ve = {
        class: "onlineGames__container"
    },
    _e = ["placeholder"],
    de = {
        class: "onlineGames__container-list"
    },
    pe = ["onClick"],
    fe = {
        class: "item_img"
    },
    ge = {
        class: "item_name"
    },
    ye = {
        key: 1
    },
    ke = {
        class: "onlineGames__container-list miniGames"
    },
    he = ["onClick"],
    Te = {
        class: "item_img"
    },
    Ce = Q({
        __name: "index",
        setup(Ge) {
            const G = l(!1),
                U = Z(),
                R = X(),
                {
                    onItemClick: $,
                    getAllGame: j,
                    homeState: E
                } = le(),
                S = l(),
                v = l(0),
                g = l([]),
                _ = l(0);
            H(v, t => {
                const a = o.value[t];
                A.value = [], _.value = 0, a && D(a.slotsTypeID)
            });
            const r = l(!1);
            H(r, t => {
                t ? setTimeout(() => {
                    V.value.focus()
                }, 0) : y.value = ""
            });
            const y = l("");
            Y(y, t => {
                if (u.value)
                    if (u.value.key === "fish" || u.value.key === "flash") o.value = o.value.filter(a => a.gameNameEn.toLowerCase().includes(t)), t.length === 0 && (o.value = sessionStorage.getItem("slotGamesList") ? JSON.parse(sessionStorage.getItem("slotGamesList")) : null);
                    else {
                        const a = o.value[v.value];
                        D(a.slotsTypeID, t)
                    }
            }, {
                debounce: 300
            });
            const V = l(null),
                u = l(),
                o = l([]),
                A = l([]),
                q = ee(A, t => r.value ? t.gameNameEn.toLowerCase().includes(y.value.toLowerCase()) : t.customGameType === _.value);

            function P(t) {
                return t ? t.split(/(?=[A-Z])/).join(" ") : ""
            }

            function W() {
                U.go(-1)
            }

            function O(t) {
                r.value = t
            }
            const K = () => !G.value;
            async function D(t, a = "") {
                if (!G.value) {
                    G.value = !0;
                    try {
                        const c = await oe(ie({
                            type: t,
                            gameNameEn: a
                        }));
                        if (c) {
                            if (A.value = c.data.gameLists || [], g.value = c.data.gameCustomTypeLists || [], !g.value.length) return;
                            _.value = g.value[0].customGameType
                        }
                    } catch {} finally {
                        G.value = !1
                    }
                }
            }
            return ae(async () => {
                const t = R.query.game,
                    a = R.query.vendorCode,
                    c = sessionStorage.getItem("gameType") ? JSON.parse(sessionStorage.getItem("gameType")) : null;
                await j(), u.value = t || c, E.allGameList[u.value] && (o.value = E.allGameList[u.value]);
                const N = JSON.parse(sessionStorage.getItem("clickedItem"));
                if (N || a) {
                    const k = o.value.findIndex(w => a ? w.vendorCode === a : w.slotsTypeID === N.slotsTypeID);
                    v.value = k !== -1 ? k : 0
                }
                S.value && S.value.scrollTo(v.value);
                const I = o.value[v.value];
                I && await D(I.slotsTypeID)
            }), (t, a) => {
                var M, J;
                const c = h("svg-icon"),
                    N = h("NavBar"),
                    I = h("van-tab"),
                    k = h("Maintain"),
                    w = h("van-tabs"),
                    F = te("lazy");
                return n(), m("div", ve, [T(N, {
                    class: "white",
                    "left-arrow": "",
                    onClickLeft: W
                }, {
                    center: p(() => {
                        var e;
                        return [s("span", {
                            class: C({
                                active: r.value
                            })
                        }, d((e = u.value) == null ? void 0 : e.title) + d(t.$t("game")), 3), B(s("input", {
                            type: "text",
                            placeholder: t.$t("searchGame"),
                            class: C({
                                active: r.value
                            }),
                            "onUpdate:modelValue": a[0] || (a[0] = i => y.value = i),
                            ref_key: "searchBarRef",
                            ref: V
                        }, null, 10, _e), [
                            [se, y.value]
                        ])]
                    }),
                    right: p(() => [T(c, {
                        name: "SearchTrx",
                        onClick: a[1] || (a[1] = e => O(!0)),
                        class: C({
                            active: r.value
                        })
                    }, null, 8, ["class"]), s("span", {
                        class: C({
                            active: r.value
                        }),
                        onClick: a[2] || (a[2] = e => O(!1))
                    }, d(t.$t("cancel")), 3)]),
                    _: 1
                }), ((M = u.value) == null ? void 0 : M.key) !== "fish" && ((J = u.value) == null ? void 0 : J.key) !== "flash" ? (n(), b(w, {
                    key: 0,
                    class: "onlineGames__container-tabBar",
                    active: v.value,
                    "onUpdate:active": a[4] || (a[4] = e => v.value = e),
                    type: "card",
                    sticky: !0,
                    "offset-top": 46,
                    ref_key: "tabsRef",
                    ref: S,
                    "before-change": K
                }, {
                    default: p(() => [(n(!0), m(L, null, x(o.value, (e, i) => (n(), b(I, {
                        key: i
                    }, {
                        title: p(() => [T(c, {
                            name: e.slotsName,
                            class: "gameIcon"
                        }, null, 8, ["name"]), s("span", null, d(f(ue)(e.slotsName)), 1)]),
                        _: 2
                    }, 1024))), 128)), !r.value || g.value.length === 0 ? (n(), b(f(re), {
                        key: 0,
                        modelValue: _.value,
                        "onUpdate:modelValue": a[3] || (a[3] = e => _.value = e),
                        lineWidth: 0
                    }, {
                        default: p(() => [(n(!0), m(L, null, x(g.value, (e, i) => (n(), b(f(me), {
                            name: i,
                            key: i,
                            class: C([{
                                activeClassName: _.value === e.customGameType
                            }]),
                            onClick: z => _.value = e.customGameType
                        }, {
                            default: p(() => [s("span", null, d(e.customGameTypeName), 1)]),
                            _: 2
                        }, 1032, ["name", "class", "onClick"]))), 128))]),
                        _: 1
                    }, 8, ["modelValue"])) : ne("v-if", !0), s("div", de, [(n(!0), m(L, null, x(f(q), (e, i) => (n(), m("div", {
                        class: "onlineGames__container-list__item",
                        key: i,
                        onClick: z => f($)(e)
                    }, [s("div", fe, [B(s("img", null, null, 512), [
                        [F, e.img]
                    ]), T(k, {
                        item: e
                    }, null, 8, ["item"])]), s("div", ge, [s("span", null, d(P(e.gameNameEn)), 1)])], 8, pe))), 128))])]),
                    _: 1
                }, 8, ["active"])) : (n(), m("div", ye, [s("div", ke, [(n(!0), m(L, null, x(o.value, (e, i) => (n(), m("div", {
                    class: "onlineGames__container-list__item",
                    key: i,
                    onClick: z => f($)(e)
                }, [s("div", Te, [B(s("img", null, null, 512), [
                    [F, e.img]
                ]), T(k, {
                    item: e
                }, null, 8, ["item"])]), s("div", null, [s("span", null, d(e.gameNameEn), 1)])], 8, he))), 128))])]))])
            }
        }
    });
const Se = ce(Ce, [
    ["__scopeId", "data-v-0ffc3892"],
    ["__file", "/usr/local/jenkins-prod/workspace/AR048-Pages-india-91club/src/views/home/AllOnlineGames/index.vue"]
]);
export {
    Se as
    default
};