;
! function() {
    try {
        var e = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof global ? global : "undefined" != typeof window ? window : "undefined" != typeof self ? self : {},
            n = (new e.Error).stack;
        n && ((e._debugIds || (e._debugIds = {}))[n] = "68bb7c53-a988-446f-b711-9b2bc52b3891")
    } catch (e) {}
}();
(globalThis.TURBOPACK || (globalThis.TURBOPACK = [])).push(["object" == typeof document ? document.currentScript : void 0, 640793, e => {
    "use strict";
    var t = e.i(293039),
        n = e.i(556800);
    e.s(["throttle", 0, function(e, s, o) {
        var i = !0,
            r = !0;
        if ("function" != typeof e) throw TypeError("Expected a function");
        return (0, n.default)(o) && (i = "leading" in o ? !!o.leading : i, r = "trailing" in o ? !!o.trailing : r), (0, t.default)(e, s, {
            leading: i,
            maxWait: s,
            trailing: r
        })
    }], 640793)
}, 260536, 930896, 282750, e => {
    "use strict";
    var t = e.i(93257),
        n = null;
    let s = n = "u" > typeof WebSocket ? WebSocket : "u" > typeof MozWebSocket ? MozWebSocket : e.g.WebSocket || e.g.MozWebSocket,
        o = {
            Uninstantiated: -1,
            Connecting: s.CONNECTING,
            Connected: s.OPEN,
            Disconnecting: s.CLOSING,
            Disconnected: s.CLOSED
        };
    e.s(["WebsocketReadyStates", 0, o], 930896);
    let i = e => {
            switch (e) {
                case o.Uninstantiated:
                    return "disconnected";
                case o.Connecting:
                    return "connecting";
                case o.Connected:
                    return "connected";
                case o.Disconnecting:
                    return "disconnecting";
                case o.Disconnected:
                    return "disconnected"
            }
        },
        r = e => {
            try {
                return JSON.parse(e)
            } catch {
                return
            }
        };
    e.s(["parseConnectionStatus", 0, i, "parseMessageEvent", 0, e => {
        try {
            if ("PING" === e.data || "ping" === e.data) return {
                type: "ping"
            };
            if ("PONG" === e.data || "pong" === e.data) return {
                type: "pong"
            };
            if ("string" == typeof e.data) {
                let t = r(e.data);
                if (!t) return {
                    type: "string",
                    data: e.data
                };
                return {
                    type: "message",
                    data: t
                }
            }
            if (t.Buffer.isBuffer(e.data)) {
                let t = e.data.toString("utf8"),
                    n = r(t);
                if (!n) return {
                    type: "string",
                    data: t
                };
                return {
                    type: "message",
                    data: n
                }
            }
            if (e.data instanceof ArrayBuffer) {
                let n = t.Buffer.from(e.data).toString("utf8"),
                    s = r(n);
                if (!s) return {
                    type: "string",
                    data: n
                };
                return {
                    type: "message",
                    data: s
                }
            }
            if (Array.isArray(e.data) && e.data.every(t.Buffer.isBuffer)) {
                let n = t.Buffer.concat(e.data.map(e => Uint8Array.from(e))).toString("utf8"),
                    s = r(n);
                if (!s) return {
                    type: "string",
                    data: n
                };
                return {
                    type: "message",
                    data: s
                }
            }
            return {
                type: "error",
                error: Error("Invalid message data"),
                event: e
            }
        } catch (t) {
            return {
                type: "error",
                error: t,
                event: e
            }
        }
    }], 260536);
    class a {#
        e = new Map;
        constructor() {
            this.#e = new Map
        }
        add(e, t) {
            let n = {
                once: t.once,
                filter: t.filter ? e => t.filter(e) : void 0,
                callback: e => t.callback(e)
            };
            return this.#e.set(e, n), () => this.remove(e)
        }
        remove(e) {
            this.#e.delete(e)
        }
        emit(e) {
            (Array.isArray(e) ? e : [e]).forEach(e => {
                for (let [t, n] of this.#e)(n.filter ? ? (() => !0))(e) && (n.callback(e), n.once && this.#e.delete(t))
            })
        }
        reset() {
            this.#e.clear()
        }
    }
    e.s(["WebsocketClient", 0, class {
        url;
        autoReconnect;
        preventAutoReconnect;#
        t;#
        n;
        socket;
        logger;#
        s;#
        o;#
        i;#
        r;#
        a;#
        c;#
        g;#
        h;
        constructor({
            url: e,
            ping: t,
            pong: n,
            autoReconnect: s = !0,
            logger: o,
            callbacks: i
        }) {
            this.url = e, this.#t = this.parsePingPongConfig("ping", t), this.#n = this.parsePingPongConfig("pong", n), this.autoReconnect = s, this.preventAutoReconnect = !1, this.logger = o, this.#o = i ? .onOpen, this.#i = i ? .onClose, this.#r = i ? .onError, this.#a = i ? .onMessage, this.#c = i ? .onSubscribe, this.#g = i ? .onUnsubscribe, this.#h = i ? .onStatusChange, this.#s = new a, this.socket = this.createSocket()
        }
        connect() {
            this.onStatusChange("connecting"), this.#s.emit({
                type: "status",
                state: "connecting"
            }), this.#t.once && this.ping(), this.#n.once && this.pong()
        }
        disconnect() {
            this.#s.emit({
                type: "status",
                state: "disconnecting"
            }), this.preventAutoReconnect = !0, "function" == typeof this.socket.terminate ? this.socket.terminate() : this.socket.close(), this.delay(5e3).then(() => {
                this.preventAutoReconnect && (this.preventAutoReconnect = !1)
            })
        }
        send(e) {
            this.socket.send(e)
        }
        subscribe(e) {
            this.#c && this.#c({
                subscription: e,
                client: this
            }), this.socket.readyState !== s.OPEN ? this.connect() : this.#u(e)
        }
        unsubscribe(e) {
            this.socket.readyState === s.OPEN && (this.#g && this.#g({
                subscription: e,
                client: this
            }), this.#d(e))
        }
        ping() {
            if (!this.connected) return console.warn("Socket not connected. Ready state is:", this.socket.readyState);
            this.socket.send(this.#t.message, e => {
                e && console.error("ping error", e)
            })
        }
        pong() {
            if (!this.connected) return console.warn("Socket not connected. Ready state is:", this.socket.readyState);
            this.socket.send(this.#n.message, e => {
                e && console.error("pong error", e)
            })
        }
        configure(e) {
            let {
                callbacks: t,
                listeners: n,
                options: s
            } = e;
            t && (t.onOpen && (this.#o = t.onOpen), t.onClose && (this.#i = t.onClose), t.onError && (this.#r = t.onError), t.onMessage && (this.#a = t.onMessage), t.onSubscribe && (this.#c = t.onSubscribe), t.onUnsubscribe && (this.#g = t.onUnsubscribe), t.onStatusChange && (this.#h = t.onStatusChange)), s && (s.ping && (this.#t = this.parsePingPongConfig("ping", s.ping)), s.pong && (this.#n = this.parsePingPongConfig("pong", s.pong)), s.autoReconnect && (this.autoReconnect = s.autoReconnect)), n && n.forEach(e => {
                this.#s.add(e.key, e.listener)
            })
        }
        get state() {
            return {
                readyState: this.socket.readyState,
                status: i(this.socket.readyState),
                connected: this.socket.readyState === s.OPEN
            }
        }
        get connected() {
            return this.socket.readyState === s.OPEN
        }
        listen(e, t) {
            return this.#s.add(e, t)
        }#
        u(e, t) {
            let n = [];
            return t ? .listeners && t.listeners.forEach(e => {
                n.push(this.#s.add(e.key, e.listener))
            }), this.send(e), () => n.forEach(e => {
                e ? .()
            })
        }#
        d(e) {
            this.send(e)
        }
        onOpen(e) {
            this.onStatusChange("connected"), this.#o && this.#o({
                event: e,
                client: this
            }), this.#s.emit({
                type: "status",
                state: "connected",
                event: e
            }), this.logger && this.logger.debug({
                title: "WebSocket opened",
                message: "WebSocket opened",
                context: {
                    url: this.url,
                    ...e
                }
            })
        }
        onClose(e) {
            this.onStatusChange("disconnected"), this.#i && this.#i({
                event: e,
                client: this
            }), this.#s.emit({
                type: "status",
                state: "disconnected",
                event: e
            }), this.logger && this.logger.debug({
                title: "WebSocket closed",
                message: "WebSocket closed",
                context: {
                    url: this.url,
                    ...e
                }
            })
        }
        onError(e) {
            this.#r && this.#r({
                event: e,
                client: this
            }), this.autoReconnect && (this.preventAutoReconnect || this.connect(), this.preventAutoReconnect = !1), this.#s.emit({
                type: "error",
                event: e
            }), this.logger && this.logger.error({
                title: "WebSocket error",
                message: "WebSocket error",
                context: { ...e
                }
            })
        }
        onMessage(e) {
            this.#a && this.#a({
                event: e,
                client: this
            }), this.#s.emit({
                type: "message",
                event: e
            }), this.isPing(e) && this.onPing(), this.isPong(e) && this.onPong(), this.logger && this.logger.debug({
                title: "WebSocket message",
                message: "WebSocket message",
                context: { ...e
                }
            })
        }
        onStatusChange(e) {
            this.#h && this.#h({
                status: e,
                client: this
            })
        }
        onPong() {
            this.#n.respond && this.delay(this.#n.delay).then(() => this.ping()), this.logger && this.logger.debug({
                title: "WebSocket pong",
                message: "WebSocket pong"
            })
        }
        onPing() {
            this.#t.respond && this.delay(this.#t.delay).then(() => this.pong()), this.logger && this.logger.debug({
                title: "WebSocket pong",
                message: "WebSocket pong"
            })
        }
        isPing(e) {
            return "PING" === e.data || "ping" === e.data || this.#t.message === e.data
        }
        isPong(e) {
            return "PONG" === e.data || "pong" === e.data || this.#n.message === e.data
        }
        parsePingPongConfig(e, t) {
            return t ? t.respond ? {
                once: t.once ? ? !1,
                message: t.message ? ? ("ping" === e ? "PING" : "PONG"),
                respond: !0,
                response: t.response ? ? ("ping" === e ? "PONG" : "PING"),
                delay: t.delay
            } : {
                once: t.once ? ? !1,
                message: t.message ? ? ("ping" === e ? "PING" : "PONG"),
                respond: !1,
                response: "",
                delay: 3e4
            } : {
                once: !1,
                message: "ping" === e ? "PING" : "PONG",
                respond: !1,
                response: "ping" === e ? "PONG" : "PING",
                delay: 3e4
            }
        }
        createSocket() {
            let e = new s(this.url);
            return e.addEventListener("open", e => this.onOpen(e)), e.addEventListener("close", e => this.onClose(e)), e.addEventListener("error", e => this.onError(e)), e.addEventListener("message", e => this.onMessage(e)), e
        }
        delay(e) {
            return new Promise(t => setTimeout(t, e))
        }
    }], 282750)
}]);

//# debugId=68bb7c53-a988-446f-b711-9b2bc52b3891