;
! 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] = "bf30d8e2-1b58-6c1e-b274-ef9b46d9a70b")
    } catch (e) {}
}();
(globalThis.TURBOPACK || (globalThis.TURBOPACK = [])).push(["object" == typeof document ? document.currentScript : void 0, 397456, 606231, e => {
            "use strict";
            (t = r || (r = {}))[t.UNINSTANTIATED = -1] = "UNINSTANTIATED", t[t.CONNECTING = 0] = "CONNECTING", t[t.OPEN = 1] = "OPEN", t[t.CLOSING = 2] = "CLOSING", t[t.CLOSED = 3] = "CLOSED", e.s(["DEFAULT_RECONNECT_INTERVAL_MS", 0, 5e3, "ReadyState", 0, r], 397456);
            var t, r, n = e.i(999061),
                a = e.i(249785),
                i = e.i(964063),
                o = e.i(416340);

            function s(e, t, r) {
                var n, a;
                let i = e.current.maxReconnectAttempts;
                if (!i || t.current < i) {
                    let n = "function" == typeof e.current.reconnectInterval ? e.current.reconnectInterval(t.current) : e.current.reconnectInterval;
                    return setTimeout(() => r(), null != n ? n : 5e3)
                }
                null == (a = (n = e.current).onReconnectStop) || a.call(n, i), console.warn(`Max reconnect attempts of ${i} exceeded`)
            }
            async function u(e, t, r = 0) {
                var n, a, i;
                if ("string" == typeof e) return e;
                try {
                    return await e()
                } catch (s) {
                    if (!t.current.retryOnError) return null;
                    let o = t.current.maxReconnectAttempts;
                    if (!o || r < o) {
                        let n = "function" == typeof t.current.reconnectInterval ? t.current.reconnectInterval(r) : t.current.reconnectInterval;
                        return await (i = null != n ? n : 5e3, new Promise(e => setTimeout(e, i))), u(e, t, r + 1)
                    }
                    null == (a = (n = t.current).onReconnectStop) || a.call(n, r)
                }
                return null
            }
            var l = e.i(348320),
                c = e.i(53950);
            let d = e => "string" == typeof e ? e : null == e ? "none" : "dynamic",
                y = e => {
                    try {
                        let {
                            hostname: t,
                            pathname: r
                        } = new URL(e);
                        return `${t}${r}`
                    } catch {
                        return e
                    }
                };
            e.s(["useWebSocket", 0, function(e) {
                let t, p, f, m, h = (0, n.c)(11),
                    g = (0, i.useDocumentVisibility)(),
                    v = "visible" === g && e.connect,
                    b = "visible" === g && e.shouldReconnect;
                return h[0] !== e ? (t = t => {
                        let r = d(e.url),
                            n = y(r);
                        c.logger.warn("WebSocket connection error", {
                            url: r,
                            endpoint: n
                        }), (0, l.sendGroundcoverEvent)("websocket_connection_error", {
                            url: r,
                            endpoint: n,
                            source: "websocket"
                        }), e.onError ? .(t)
                    }, p = t => {
                        if (1e3 !== t.code && 1001 !== t.code && 1005 !== t.code) {
                            let r = d(e.url),
                                n = y(r),
                                a = {
                                    url: r,
                                    endpoint: n,
                                    code: t.code,
                                    reason: t.reason,
                                    wasClean: t.wasClean,
                                    source: "websocket"
                                };
                            c.logger.warn("WebSocket closed abnormally", a), (0, l.sendGroundcoverEvent)("websocket_abnormal_close", a)
                        }
                        e.onClose ? .(t)
                    }, f = t => {
                        let r = d(e.url),
                            n = y(r);
                        c.logger.error("WebSocket reconnection failed", {
                            url: r,
                            endpoint: n,
                            numAttempts: t
                        }), (0, a.captureException)(Error(`WebSocket reconnection failed after ${t} attempts: ${r}`), {
                            tags: {
                                scope: "websocket"
                            },
                            extra: {
                                url: r,
                                numAttempts: t
                            }
                        }), (0, l.captureGroundcoverException)(Error(`WebSocket reconnection failed after ${t} attempts: ${n}`), {
                            url: r,
                            endpoint: n,
                            numAttempts: t,
                            source: "websocket"
                        }), e.onReconnectStop ? .(t)
                    }, h[0] = e, h[1] = t, h[2] = p, h[3] = f) : (t = h[1], p = h[2], f = h[3]), h[4] !== v || h[5] !== e || h[6] !== b || h[7] !== t || h[8] !== p || h[9] !== f ? (m = { ...e,
                        connect: v,
                        shouldReconnect: b,
                        onError: t,
                        onClose: p,
                        onReconnectStop: f
                    }, h[4] = v, h[5] = e, h[6] = b, h[7] = t, h[8] = p, h[9] = f, h[10] = m) : m = h[10],
                    function(e) {
                        let {
                            url: t,
                            connect: n = !0
                        } = e, [a, i] = (0, o.useState)({}), l = (0, o.useRef)(null), c = (0, o.useRef)(null), d = (0, o.useRef)(() => {}), y = (0, o.useRef)(0), p = (0, o.useRef)([]), f = (0, o.useRef)(e);
                        f.current = e;
                        let m = l.current && void 0 !== a[l.current] ? a[l.current] : null != t && n ? r.CONNECTING : r.UNINSTANTIATED,
                            h = (0, o.useCallback)((e, t = !0) => {
                                var n;
                                (null == (n = c.current) ? void 0 : n.readyState) === r.OPEN ? c.current.send(e) : t && p.current.push(e)
                            }, []),
                            g = (0, o.useCallback)(() => c.current, []);
                        return (0, o.useEffect)(() => {
                            if (null != t && n) {
                                let e, n = !0,
                                    a = async () => {
                                        var a, o, p, m;
                                        if (l.current = await u(t, f), null === l.current) {
                                            console.error("Failed to get a valid URL. WebSocket connection aborted."), l.current = "ABORTED", i(e => Object.assign(Object.assign({}, e), {
                                                ABORTED: r.CLOSED
                                            }));
                                            return
                                        }
                                        let h = e => {
                                            n && i(t => l.current && t[l.current] !== e ? Object.assign(Object.assign({}, t), {
                                                [l.current]: e
                                            }) : t)
                                        };
                                        if (n) {
                                            let t, n, i, u;
                                            if (y.current++, null == (o = (a = f.current).onConnectAttempt) || o.call(a, y.current), c.current = new WebSocket(l.current, f.current.protocols), h(r.CONNECTING), !c.current) throw Error("WebSocket failed to be created");
                                            p = c.current, m = d.current, u = !1, p.addEventListener("message", e => {
                                                var r, n;
                                                null == t || t.markMessageReceived(), null == (n = (r = f.current).onMessage) || n.call(r, e)
                                            }), p.addEventListener("open", e => {
                                                var a, i, o, s;
                                                let l;
                                                u = !0, y.current = 0, h(r.OPEN), t = function(e, t, n) {
                                                        function a() {
                                                            var a;
                                                            let i = null == (a = t.current) ? void 0 : a.messageTimeout;
                                                            if (i && !(i < 0)) return setTimeout(() => {
                                                                e.readyState !== WebSocket.CLOSING && e.readyState !== WebSocket.CLOSED && (console.log(`Closed websocket because no messages received for ${i}ms`), n(r.CLOSING), e.close())
                                                            }, i)
                                                        }
                                                        let i = a();
                                                        return {
                                                            markMessageReceived: () => {
                                                                clearTimeout(i), i = a()
                                                            },
                                                            stop: () => {
                                                                clearTimeout(i)
                                                            }
                                                        }
                                                    }(p, f, h), o = p, s = f,
                                                    function e() {
                                                        var t, r;
                                                        let n = null == (r = null == (t = s.current) ? void 0 : t.heartbeat) ? void 0 : r.interval;
                                                        n && (l = setTimeout(() => {
                                                            var t, r;
                                                            if (o.readyState !== WebSocket.CLOSING && o.readyState !== WebSocket.CLOSED) {
                                                                try {
                                                                    let e = null == (r = null == (t = null == s ? void 0 : s.current) ? void 0 : t.heartbeat) ? void 0 : r.message;
                                                                    e && ("function" == typeof e ? o.send(e()) : o.send(e))
                                                                } catch (e) {}
                                                                e()
                                                            }
                                                        }, n))
                                                    }(), n = {
                                                        stop: () => clearTimeout(l)
                                                    }, null == (i = (a = f.current).onOpen) || i.call(a, e)
                                            }), p.addEventListener("close", e => {
                                                var a, o;
                                                if (null == t || t.stop(), null == n || n.stop(), void 0 === i) {
                                                    let t = f.current.shouldReconnect;
                                                    (!0 === t || "function" == typeof t && t(e)) && (i = s(f, y, m))
                                                }
                                                h(i ? r.CONNECTING : r.CLOSED), null == (o = (a = f.current).onClose) || o.call(a, e)
                                            }), p.addEventListener("error", e => {
                                                var t, r;
                                                void 0 === i && f.current.retryOnError && (i = s(f, y, m)), null == (r = (t = f.current).onError) || r.call(t, e)
                                            }), e = () => {
                                                void 0 !== i && (clearTimeout(i), i = void 0), u && (h(r.CLOSING), p.close())
                                            }
                                        }
                                    };
                                return d.current = () => {
                                    n && (null == e || e(), a())
                                }, a(), () => {
                                    n = !1, null == e || e()
                                }
                            }
                            null != t && n || (y.current = 0, i(e => l.current && e[l.current] !== r.CLOSED ? Object.assign(Object.assign({}, e), {
                                [l.current]: r.CLOSED
                            }) : e))
                        }, [t, n, h]), (0, o.useEffect)(() => {
                            m === r.OPEN && p.current.splice(0).forEach(e => {
                                h(e)
                            })
                        }, [m]), {
                            sendMessage: h,
                            readyState: m,
                            getWebSocket: g
                        }
                    }(m)
            }], 606231)
        }, 831089, e => {
            "use strict";
            var t = e.i(416340),
                r = e.i(197994);
            e.s(["IconCircleXmarkFill18", 0, ({ ...e
            }) => t.default.createElement(r.Icon, {
                size: "18px",
                ...e
            }, t.default.createElement("path", {
                d: "M9,1C4.589,1,1,4.589,1,9s3.589,8,8,8,8-3.589,8-8S13.411,1,9,1Zm3.28,10.22c.293,.293,.293,.768,0,1.061-.146,.146-.338,.22-.53,.22s-.384-.073-.53-.22l-2.22-2.22-2.22,2.22c-.146,.146-.338,.22-.53,.22s-.384-.073-.53-.22c-.293-.293-.293-.768,0-1.061l2.22-2.22-2.22-2.22c-.293-.293-.293-.768,0-1.061s.768-.293,1.061,0l2.22,2.22,2.22-2.22c.293-.293,.768-.293,1.061,0s.293,.768,0,1.061l-2.22,2.22,2.22,2.22Z",
                fill: "currentColor"
            }))])
        }, 688589, e => {
            "use strict";
            var t = e.i(416340);
            let r = (0, t.createContext)(null),
                n = {
                    didCatch: !1,
                    error: null
                };
            class a extends t.Component {
                constructor(e) {
                    super(e), this.resetErrorBoundary = this.resetErrorBoundary.bind(this), this.state = n
                }
                static getDerivedStateFromError(e) {
                    return {
                        didCatch: !0,
                        error: e
                    }
                }
                resetErrorBoundary(...e) {
                    let {
                        error: t
                    } = this.state;
                    null !== t && (this.props.onReset ? .({
                        args: e,
                        reason: "imperative-api"
                    }), this.setState(n))
                }
                componentDidCatch(e, t) {
                    this.props.onError ? .(e, t)
                }
                componentDidUpdate(e, t) {
                    let {
                        didCatch: r
                    } = this.state, {
                        resetKeys: a
                    } = this.props;
                    r && null !== t.error && function(e = [], t = []) {
                        return e.length !== t.length || e.some((e, r) => !Object.is(e, t[r]))
                    }(e.resetKeys, a) && (this.props.onReset ? .({
                        next: a,
                        prev: e.resetKeys,
                        reason: "keys"
                    }), this.setState(n))
                }
                render() {
                    let {
                        children: e,
                        fallbackRender: n,
                        FallbackComponent: a,
                        fallback: i
                    } = this.props, {
                        didCatch: o,
                        error: s
                    } = this.state, u = e;
                    if (o) {
                        let e = {
                            error: s,
                            resetErrorBoundary: this.resetErrorBoundary
                        };
                        if ("function" == typeof n) u = n(e);
                        else if (a) u = (0, t.createElement)(a, e);
                        else if (void 0 !== i) u = i;
                        else throw s
                    }
                    return (0, t.createElement)(r.Provider, {
                        value: {
                            didCatch: o,
                            error: s,
                            resetErrorBoundary: this.resetErrorBoundary
                        }
                    }, u)
                }
            }
            e.s(["ErrorBoundary", 0, a])
        }, 529812, e => {
            "use strict";
            var t = e.i(416340),
                r = e.i(149534);
            e.s(["IconRefreshOutline18", 0, ({
                strokeWidth: e = 1.5,
                ...n
            }) => t.default.createElement(r.Icon, {
                size: "18px",
                ...n
            }, t.default.createElement("path", {
                d: "M5.25 9.5L3 7.25L0.75 9.5",
                stroke: "currentColor",
                strokeWidth: e,
                strokeLinecap: "round",
                strokeLinejoin: "round",
                "data-color": "color-2",
                fill: "none"
            }), t.default.createElement("path", {
                d: "M13.495 13.345C12.3587 14.5226 10.7641 15.25 9 15.25C5.548 15.25 2.75 12.45 2.75 9C2.75 8.4 2.834 7.83003 2.99 7.28003",
                stroke: "currentColor",
                strokeWidth: e,
                strokeLinecap: "round",
                strokeLinejoin: "round",
                "data-color": "color-2",
                fill: "none"
            }), t.default.createElement("path", {
                d: "M12.75 8.5L15 10.75L17.25 8.5",
                stroke: "currentColor",
                strokeWidth: e,
                strokeLinecap: "round",
                strokeLinejoin: "round",
                fill: "none"
            }), t.default.createElement("path", {
                d: "M4.50629 4.65564C5.64249 3.48544 7.23658 2.75 8.99998 2.75C12.452 2.75 15.25 5.55 15.25 9C15.25 9.58 15.171 10.14 15.024 10.67",
                stroke: "currentColor",
                strokeWidth: e,
                strokeLinecap: "round",
                strokeLinejoin: "round",
                fill: "none"
            }))])
        }, 30704, e => {
            "use strict";
            var t = e.i(132762),
                r = e.i(122538),
                n = e.i(601550),
                a = e.i(964974),
                i = e.i(318594),
                o = e.i(416340),
                s = e.i(494316),
                u = e.i(510954),
                l = e.i(57096),
                c = e.i(784521),
                d = e.i(400819),
                y = e.i(22026),
                p = e.i(660006),
                f = e.i(196593),
                m = e.i(53950),
                h = e.i(156591),
                g = e.i(436127);
            let v = (e, t, r) => {
                    let n = (0, g.createPriceMapKey)(e.price, e.tokenID, e.side),
                        a = "number" == typeof r ? r : (0, h.getPrecisionFromPrice)(e.price),
                        i = (0, g.getOppositeOrder)(e, t, a);
                    return {
                        key: n,
                        oppKey: (0, g.createPriceMapKey)(i.price, i.tokenID, i.side),
                        order: e,
                        oppOrder: i
                    }
                },
                b = async (e, t) => {
                    if (t && e) try {
                        let r = await t.getOpenOrders({
                            market: e
                        });
                        if (!Array.isArray(r)) return m.logger.error("[useUserOpenOrders getOpenOrdersSingleFetcher]", {
                            orders: r
                        }), [];
                        return r.map(g.fromNewOrderToOld)
                    } catch (e) {
                        return m.logger.error("[useUserOpenOrders getOpenOrdersSingleFetcher]", {
                            error: e
                        }), []
                    }
                },
                T = async (e, t, r) => {
                    let [n, a, i] = e.queryKey;
                    if (i && r && t) try {
                        let e = await r.getOpenOrders();
                        if (!Array.isArray(e)) return m.logger.error("[useUserOpenOrders getOpenOrdersFetcher]", {
                            orders: e
                        }), [];
                        return e.map(g.fromNewOrderToOld)
                    } catch (e) {
                        return m.logger.error("[useUserOpenOrders getOpenOrdersFetcher]", {
                            error: e
                        }), []
                    }
                },
                C = async (e, t, r, n, a) => {
                    let [i, o, s] = e.queryKey;
                    if (!Array.isArray(t) || !r || !n) return {};
                    try {
                        let e = t.map(e => {
                                let {
                                    key: t,
                                    oppKey: n
                                } = v(e, r, a);
                                return {
                                    orderID: e.orderID,
                                    key: t,
                                    oppKey: n
                                }
                            }),
                            i = e.map(e => e.orderID),
                            o = await n.areOrdersScoring({
                                orderIds: i
                            });
                        return e.reduce((e, t) => {
                            let r = o ? .[t.orderID] ? ? !1;
                            return e[t.key] || (e[t.key] = r), e[t.oppKey] || (e[t.oppKey] = r), e
                        }, {})
                    } catch (e) {
                        return (0, p.handleError)(e, "[useUserOpenOrders getIsOrderScoringMapFetcher]"), {}
                    }
                };
            e.s(["default", 0, (e, x = !1) => {
                let w = (0, o.useMemo)(() => !!e && "string" == typeof e.conditionId && Array.isArray(e.clobTokenIds) && !!e.orderPriceMinTickSize, [e]),
                    M = (0, h.getPrecisionFromTickSize)(e ? .orderPriceMinTickSize ? ? .01),
                    k = (0, y.useMarkOpenOrdersFetched)(),
                    E = (0, i.useQueryClient)(),
                    {
                        mutate: O
                    } = (0, s.useTokenIdsForPartialMarketsMutation)(),
                    {
                        authenticated: S,
                        proxyAddress: I
                    } = (0, c.useAccountContext)(["authenticated", "proxyAddress"]),
                    P = (0, d.useClob)(),
                    {
                        getApiCredential: A
                    } = (0, d.useClobCredentialContext)(),
                    N = (0, o.useMemo)(() => {
                        if (I) return A(I)
                    }, [I, A]),
                    _ = (0, o.useMemo)(() => void 0 === e && S && !!P && !!I && !!N ? .key && "" !== N.key, [S, P, N, I, e]),
                    {
                        data: F,
                        isPending: D,
                        isLoading: R
                    } = (0, a.useQuery)({
                        queryKey: u.queryKeys[l.QueryKey.OpenOrders].apiKey(N ? .key ? ? "").queryKey,
                        queryFn: _ || x ? async e => {
                            let t = await T(e, I, P);
                            return Array.isArray(t) && t.length > 0 ? (O({
                                positionIds: t.map(e => e.tokenID)
                            }), k()) : m.logger.debug("[useUserOpenOrders  onSettled]", {
                                orders: t
                            }), t
                        } : r.skipToken,
                        enabled: _,
                        gcTime: 12e4,
                        staleTime: 3e5,
                        refetchOnMount: !1,
                        refetchOnReconnect: !1,
                        refetchOnWindowFocus: !1,
                        refetchInterval: !1,
                        placeholderData: r.keepPreviousData
                    }),
                    L = (0, o.useMemo)(() => w && S && !!P && !!I && !!N ? .key && "" !== N.key && "string" == typeof e ? .conditionId, [S, P, N, I, w, e ? .conditionId]),
                    {
                        data: K,
                        isPending: q,
                        isLoading: B
                    } = (0, a.useQuery)({
                        queryKey: u.queryKeys[l.QueryKey.OpenOrders].apiKeyAndMarket(N ? .key ? ? "", e ? .conditionId ? ? "").queryKey,
                        queryFn: L ? async () => {
                            m.logger.debug("[useUserOpenOrders] Fetching single market orders", {
                                conditionId: e ? .conditionId
                            });
                            let t = await b(e ? .conditionId, P);
                            return m.logger.debug("[useUserOpenOrders] Single market orders fetched", {
                                orderCount: t ? .length ? ? 0
                            }), t
                        } : r.skipToken,
                        enabled: L,
                        gcTime: 12e4,
                        staleTime: 3e5,
                        refetchOnMount: "always",
                        refetchOnReconnect: !1,
                        refetchOnWindowFocus: !1,
                        refetchInterval: !1,
                        placeholderData: r.keepPreviousData
                    }),
                    {
                        mutateAsync: Q
                    } = (0, n.useMutation)({
                        mutationFn: async e => {},
                        onMutate: async e => {
                            let {
                                apiKey: t,
                                order: r
                            } = e, n = u.queryKeys[l.QueryKey.OpenOrders].apiKey(t), a = u.queryKeys[l.QueryKey.OpenOrders].apiKeyAndMarket(t, r.market);
                            await E.cancelQueries({
                                queryKey: n.queryKey
                            }), await E.cancelQueries({
                                queryKey: a.queryKey
                            });
                            let i = E.getQueryData(n.queryKey),
                                o = E.getQueryData(a.queryKey);
                            if (Array.isArray(i)) {
                                let e = (0, g.handleOrdersResponse)(r, i);
                                E.setQueryData(n.queryKey, e)
                            }
                            if (Array.isArray(o)) {
                                let e = (0, g.handleOrdersResponse)(r, o);
                                E.setQueryData(a.queryKey, e)
                            }
                            return {
                                previousAllOrders: i,
                                previousMarketOrders: o
                            }
                        },
                        onError: (e, t, r) => {
                            m.logger.error("userOpenOrdersMutation error", {
                                error: e,
                                data: t,
                                context: r
                            }), t.apiKey && r && Array.isArray(r.previousAllOrders) && E.setQueryData(u.queryKeys[l.QueryKey.OpenOrders].apiKey(t.apiKey).queryKey, r.previousAllOrders), t.apiKey && t.order ? .market && r && Array.isArray(r.previousMarketOrders) && E.setQueryData(u.queryKeys[l.QueryKey.OpenOrders].apiKeyAndMarket(t.apiKey, t.order.market).queryKey, r.previousMarketOrders), (0, p.handleError)(e, "[useUserOpenOrders userOpenOrdersMutation onError]", I)
                        },
                        onSettled: (e, t, r) => {
                            let {
                                invalidate: n = !0,
                                apiKey: a,
                                order: i
                            } = r;
                            n && (E.invalidateQueries({
                                queryKey: u.queryKeys[l.QueryKey.OpenOrders].apiKey(a).queryKey,
                                exact: !0
                            }), i ? .market && E.invalidateQueries({
                                queryKey: u.queryKeys[l.QueryKey.OpenOrders].apiKeyAndMarket(a, i.market).queryKey,
                                exact: !0
                            }))
                        }
                    }),
                    U = (0, o.useMemo)(() => ((e, t, r, n) => {
                        try {
                            if (e && Array.isArray(t)) {
                                m.logger.debug("[useUserOpenOrders] Using single market orders", {
                                    orderCount: t.length,
                                    conditionId: n ? .conditionId
                                });
                                let e = n ? .clobTokenIds;
                                if (Array.isArray(e)) return t.filter(t => e.includes(t.tokenID));
                                return t
                            }
                            if (!Array.isArray(r)) return m.logger.debug("[useUserOpenOrders] response is not array", {
                                allOrders: r
                            }), [];
                            let a = n ? .clobTokenIds;
                            if (!Array.isArray(a)) return r;
                            return r.filter(e => a.includes(e.tokenID))
                        } catch (e) {
                            return (0, p.handleError)(e, "[useUserOpenOrders userOpenOrders]"), []
                        }
                    })(w, K, F, e), [F, K, w, e ? .clobTokenIds, e ? .conditionId]),
                    j = (0, o.useMemo)(() => U && Array.isArray(U) && e ? .clobTokenIds ? U.reduce((t, r) => {
                        let {
                            key: n,
                            oppKey: a,
                            oppOrder: i
                        } = v(r, e.clobTokenIds, M);
                        return t[n] || (t[n] = []), t[n].push(r), t[a] || (t[a] = []), t[a].push(i), t
                    }, {}) : {}, [U, e ? .clobTokenIds, M]),
                    {
                        data: W
                    } = (0, a.useQuery)({
                        queryKey: u.queryKeys[l.QueryKey.OpenOrderScoring].tokenId(e ? .clobTokenIds ? .[0]).queryKey,
                        queryFn: t => C(t, U, e ? .clobTokenIds, P, M),
                        refetchOnReconnect: !1,
                        refetchOnMount: !1,
                        refetchOnWindowFocus: !1,
                        enabled: w && "string" == typeof e ? .clobTokenIds ? .[0] && Array.isArray(U) && U.length > 0 && !!P
                    }),
                    H = (0, o.useMemo)(() => Object.keys(j).reduce((e, t) => {
                        let r = j[t];
                        return !e[t] && Array.isArray(r) && (e[t] = (0, g.calculateOpenOrderBookInfo)(r)), e
                    }, {}), [j]),
                    z = (0, o.useMemo)(() => U && Array.isArray(U) ? U.reduce((e, t) => (e[t.market] || (e[t.market] = 0), e[t.market] = e[t.market] + 1, e), {}) : {}, [U]),
                    V = (0, o.useCallback)(e => Array.isArray(e) ? e.reduce((e, t) => e + (z ? .[t] ? ? 0), 0) ? ? 0 : 0, [z]),
                    $ = (0, o.useMemo)(() => U && Array.isArray(U) ? (0, g.calculateOrdersValue)(U) : 0 n, [U]),
                    G = (0, o.useMemo)(() => U && Array.isArray(U) ? U.filter(e => e.side === t.Side.SELL).reduce((e, t) => {
                        let r = t.tokenID;
                        e[r] || (e[r] = 0 n);
                        try {
                            let n = (0, f.parseUSDCUnitsBigInt)(t.originalSize),
                                a = (0, f.parseUSDCUnitsBigInt)(t.sizeMatched);
                            e[r] = e[r] + (n - a)
                        } catch {}
                        return e
                    }, {}) : {}, [U]);
                return (0, o.useMemo)(() => {
                    let e = w ? B : R,
                        t = w ? q : D;
                    return S ? {
                        areOpenOrdersLoading: e,
                        areOpenOrdersPending: t,
                        userLimitOrderCountMap: z,
                        userOpenOrders: U,
                        userOpenOrdersPriceMap: j,
                        userOpenBidsValue: $,
                        userOpenSellsSizeMap: G,
                        userOpenOrdersMutation: Q,
                        userOrderScoringMap: W,
                        userOpenOrdersPriceTotalsMap: H,
                        getUserLimitOrderCountMap: V
                    } : {
                        areOpenOrdersLoading: e,
                        areOpenOrdersPending: t,
                        userLimitOrderCountMap: {},
                        userOpenOrders: [],
                        userOpenOrdersPriceMap: {},
                        userOpenBidsValue: 0 n,
                        userOpenSellsSizeMap: {},
                        userOpenOrdersMutation: Q,
                        areMarketsLoading: !1,
                        getUserLimitOrderCountMap: V,
                        userOrderScoringMap: {},
                        userOpenOrdersPriceTotalsMap: {}
                    }
                }, [R, D, B, q, z, U, j, $, G, Q, W, H, V, S, w])
            }], 30704)
        }, 885092, e => {
            "use strict";
            var t = e.i(221628),
                r = e.i(274466),
                n = e.i(416340),
                a = e.i(797055);
            let i = function(e, t) {
                (0, n.useEffect)(function() {
                    var t = e(),
                        n = !1;
                    return ! function() {
                            (0, r.__awaiter)(this, void 0, void 0, function() {
                                return (0, r.__generator)(this, function(e) {
                                    switch (e.label) {
                                        case 0:
                                            if (!(0, a.isFunction)(t[Symbol.asyncIterator])) return [3, 4];
                                            e.label = 1;
                                        case 1:
                                            return [4, t.next()];
                                        case 2:
                                            if (e.sent().done || n) return [3, 3];
                                            return [3, 1];
                                        case 3:
                                            return [3, 6];
                                        case 4:
                                            return [4, t];
                                        case 5:
                                            e.sent(), e.label = 6;
                                        case 6:
                                            return [2]
                                    }
                                })
                            })
                        }(),
                        function() {
                            n = !0
                        }
                }, t)
            };
            var o = e.i(328113),
                s = e.i(415013),
                u = e.i(186897),
                l = e.i(805949),
                c = e.i(478088),
                d = e.i(134850),
                y = e.i(635103),
                p = e.i(628684),
                f = e.i(249792),
                m = e.i(606572),
                h = e.i(51800),
                g = e.i(460649),
                v = e.i(964974),
                b = e.i(655740),
                T = e.i(196593);
            let C = async () => b.axios.get("/api/gas/polygon").then(({
                data: e
            }) => e);
            var x = e.i(877284),
                w = e.i(631503),
                M = e.i(600326),
                k = e.i(502980),
                E = e.i(343999),
                O = e.i(660006),
                S = e.i(53950),
                I = e.i(784521),
                P = e.i(305457);
            let A = (0, n.createContext)({
                enqueueTransaction: async (e, t, r, n, a, i, o, s, u, l, c, d, y, p) => {
                    throw Error("TransactionContext must export an `enqueueTransaction` function.")
                }
            });
            e.s(["TransactionContextProvider", 0, ({
                children: e
            }) => {
                let r = (0, P.useGoogleAnalytics)(),
                    a = (0, f.useToast)(),
                    b = (0, g.default)(),
                    N = (0, x.default)(),
                    {
                        connector: _
                    } = (0, l.useConnection)(),
                    F = (0, c.useChainId)(),
                    {
                        authenticationType: D,
                        proxyAddress: R,
                        walletMode: L
                    } = (0, I.useAccountContext)(["authenticationType", "proxyAddress", "walletMode"]),
                    {
                        nonce: K,
                        incrementNonce: q,
                        refreshNonce: B
                    } = (0, p.useSafe)(),
                    {
                        address: Q,
                        nonce: U,
                        incrementNonce: j,
                        refreshNonce: W,
                        isDepositWallet: H
                    } = (0, y.useDepositWallet)(),
                    {
                        accountWalletPreferences: z
                    } = (0, h.default)(),
                    {
                        sendTransaction: V
                    } = (0, w.default)(),
                    {
                        gasPrice: $
                    } = ((e, t, r) => {
                        let {
                            data: a,
                            refetch: i
                        } = (0, v.useQuery)({
                            queryKey: ["/api/gas/polygon", r],
                            queryFn: C,
                            enabled: !!r,
                            refetchOnWindowFocus: !1,
                            refetchOnReconnect: !1,
                            gcTime: 3e5,
                            staleTime: 3e4,
                            retry: !1,
                            meta: {
                                errorContext: {
                                    tag: "useGasPrice"
                                }
                            }
                        });
                        return {
                            gasPrice: (0, n.useMemo)(() => {
                                try {
                                    if (t) return (0, T.toWei)(t).toString();
                                    if (a) {
                                        let t = Math.round(a[e]);
                                        return (10 n ** 9 n * BigInt(Math.ceil(1.5 * t))).toString()
                                    }
                                    return
                                } catch {
                                    return
                                }
                            }, [a, e, t]),
                            refreshGasPrice: i
                        }
                    })(z ? .gasPreference ? ? "0", z ? .gasPreference === "custom" ? z ? .customGasPrice : void 0, "safe" === L && z ? .advancedMode && z ? .gasPreference !== "custom"),
                    G = (0, o.useLatest)($),
                    X = (0, n.useCallback)(async (e, t, r, n, a) => z ? .advancedMode && n ? V(w.TransactionType.CustomEOA, e, t, r, void 0, n, void 0, a) : V(w.TransactionType.EOA, e, t, r, void 0, void 0, K, a), [V, z, K]),
                    Y = (0, n.useCallback)(async (e, t, n, i, o, l, c, y, p, f, h, g, v, C = !0) => {
                        let x = "",
                            I = {
                                trade_market: c.slug,
                                ...null !== h && {
                                    trade_outcome: h
                                },
                                ...f && p && {
                                    trade_gas_pref: p,
                                    trade_gas_price: f
                                }
                            };
                        try {
                            n === M.CTFTxnType.Buy || n === M.CTFTxnType.Sell ? (x = d.GAEventAction.TRADE, I = { ...I,
                                trade_type: "amm",
                                trade_side: n,
                                ...0 === h && {
                                    trade_price: g ? parseFloat(g) : void 0
                                },
                                ...1 === h && {
                                    trade_price: v ? parseFloat(v) : void 0
                                },
                                trade_shares: parseFloat((0, T.formatUSDCUnits)(o)),
                                trade_usdc: (0, T.formatUSDCUnits)(l)
                            }) : (x = d.GAEventAction.TRANSACTION, I = { ...I,
                                trade_type: n,
                                trade_shares: (0, T.formatUSDCUnits)(o),
                                trade_usdc: (0, T.formatUSDCUnits)(l)
                            })
                        } catch {}
                        try {
                            let d;
                            if (!_) throw Error("No connector is active.");
                            if (!R) throw Error("No proxy address is active.");
                            let T = Date.now(),
                                O = (0, s.keccak256)((0, u.toHex)(R + c.conditionId + T.toString())),
                                P = (e => {
                                    switch (e) {
                                        case M.CTFTxnType.AddLiquidity:
                                        case M.CTFTxnType.RemoveLiquidity:
                                            return w.TransactionMetadata.AmmLiquidity;
                                        case M.CTFTxnType.Merge:
                                            return w.TransactionMetadata.Merge;
                                        case M.CTFTxnType.Split:
                                            return w.TransactionMetadata.Split;
                                        case M.CTFTxnType.Redeem:
                                            return w.TransactionMetadata.Redeem;
                                        case M.CTFTxnType.Buy:
                                        case M.CTFTxnType.Sell:
                                            return w.TransactionMetadata.AmmTrade;
                                        default:
                                            return w.TransactionMetadata.Default
                                    }
                                })(n);
                            d = H && Q ? V(w.TransactionType.DepositWallet, e, +(n === M.CTFTxnType.Buy || n === M.CTFTxnType.Sell), t, void 0, void 0, void 0, P, Q) : "magic" === D ? V(w.TransactionType.Magic, e, +(n === M.CTFTxnType.Buy || n === M.CTFTxnType.Sell), t, 0, void 0, void 0, P) : z ? .advancedMode ? X(e, +(n === M.CTFTxnType.Buy || n === M.CTFTxnType.Sell || n === M.CTFTxnType.AddLiquidity), t, G.current ? ? void 0, P) : X(e, +(n === M.CTFTxnType.Buy || n === M.CTFTxnType.Sell), t, G.current ? ? void 0, P);
                            let A = await d;
                            if (!A) throw Error("Transaction response is null.");
                            let N = n === M.CTFTxnType.Split || n === M.CTFTxnType.Merge;
                            if (!A.hash && !N && n !== M.CTFTxnType.Redeem) throw Error("Transaction hash is null.");
                            let L = N || n === M.CTFTxnType.Redeem && !A.hash ? M.TxnStatus.MINED : M.TxnStatus.PENDING;
                            H ? j() : null != K && q();
                            let B = new E.CTFTxnBuilder(O, L).metadata({
                                txns: e,
                                chainId: F ? ? 137,
                                outcome: i,
                                outcomeIndex: h ? ? -1,
                                quantity: o,
                                usdc: l,
                                gasPreference: p,
                                customGasPrice: f,
                                enqueuedAt: T,
                                lastUpdatedAt: T,
                                ctfTxnType: n,
                                zeroLastPrice: g ? ? void 0,
                                oneLastPrice: v ? ? void 0,
                                positionChangeData: y,
                                hash: A.hash
                            }).conditionId(c.conditionId).build();
                            return C && a.success(new m.ToastBuilder().title((0, k.generateToastTitleFromTransaction)(B)).description(c.question)), b(B, c), n === M.CTFTxnType.Redeem && S.logger.info("[TransactionContext] redeem enqueued", {
                                proxyAddress: R,
                                chainId: F ? ? 137,
                                txId: B.txId,
                                conditionId: B.conditionId,
                                hash: A.hash,
                                status: B.status,
                                quantity: o.toString(),
                                usdc: l.toString()
                            }), r.trackEvent(x, { ...I,
                                ...A.hash && {
                                    trade_hash: A.hash
                                },
                                event_status: "success"
                            }), B
                        } catch (e) {
                            throw H ? W() : B(), (0, O.handleError)(e, "[TransactionContext] enqueueTransaction", R), r.trackEvent(x, { ...I,
                                event_status: "error",
                                event_error_msg: JSON.stringify(e)
                            }), e
                        }
                    }, [_, R, D, L, H, Q, j, W, b, F, a, V, z ? .advancedMode, X, G, K, q, B, r]);
                i(async () => {
                    R && 0 === N.filter(e => (0, k.isTxnPending)(e)).length && (H && void 0 !== U ? W() : void 0 !== K && B())
                }, [R, N, B, H, U, W]);
                let Z = (0, n.useMemo)(() => ({
                    enqueueTransaction: Y
                }), [Y]);
                return (0, t.jsx)(A.Provider, {
                    value: Z,
                    children: e
                })
            }, "useTransactionContext", 0, () => (0, n.useContext)(A)], 885092)
        }, 945374, e => {
            "use strict";
            var t = e.i(221628),
                r = e.i(999061),
                n = {};
            ! function e(t, r, n, a) {
                var i, o, s, u, l, c, d, y, p, f, m, h = !!(t.Worker && t.Blob && t.Promise && t.OffscreenCanvas && t.OffscreenCanvasRenderingContext2D && t.HTMLCanvasElement && t.HTMLCanvasElement.prototype.transferControlToOffscreen && t.URL && t.URL.createObjectURL),
                    g = "function" == typeof Path2D && "function" == typeof DOMMatrix;

                function v() {}

                function b(e) {
                    var n = r.exports.Promise,
                        a = void 0 !== n ? n : t.Promise;
                    return "function" == typeof a ? new a(e) : (e(v, v), null)
                }
                var T = (i = function() {
                        if (!t.OffscreenCanvas) return !1;
                        try {
                            var e = new OffscreenCanvas(1, 1),
                                r = e.getContext("2d");
                            r.fillRect(0, 0, 1, 1);
                            var n = e.transferToImageBitmap();
                            r.createPattern(n, "no-repeat")
                        } catch (e) {
                            return !1
                        }
                        return !0
                    }(), o = new Map, {
                        transform: function(e) {
                            if (i) return e;
                            if (o.has(e)) return o.get(e);
                            var t = new OffscreenCanvas(e.width, e.height);
                            return t.getContext("2d").drawImage(e, 0, 0), o.set(e, t), t
                        },
                        clear: function() {
                            o.clear()
                        }
                    }),
                    C = (l = Math.floor(1e3 / 60), c = {}, d = 0, "function" == typeof requestAnimationFrame && "function" == typeof cancelAnimationFrame ? (s = function(e) {
                        var t = Math.random();
                        return c[t] = requestAnimationFrame(function r(n) {
                            d === n || d + l - 1 < n ? (d = n, delete c[t], e()) : c[t] = requestAnimationFrame(r)
                        }), t
                    }, u = function(e) {
                        c[e] && cancelAnimationFrame(c[e])
                    }) : (s = function(e) {
                        return setTimeout(e, l)
                    }, u = function(e) {
                        return clearTimeout(e)
                    }), {
                        frame: s,
                        cancel: u
                    }),
                    x = (f = {}, function() {
                        if (y) return y;
                        if (!n && h) {
                            var t = ["var CONFETTI, SIZE = {}, module = {};", "(" + e.toString() + ")(this, module, true, SIZE);", "onmessage = function(msg) {\n  if (msg.data.options) {\n    CONFETTI(msg.data.options).then(function () {\n      if (msg.data.callback) {\n        postMessage({ callback: msg.data.callback });\n      }\n    });\n  } else if (msg.data.reset) {\n    CONFETTI && CONFETTI.reset();\n  } else if (msg.data.resize) {\n    SIZE.width = msg.data.resize.width;\n    SIZE.height = msg.data.resize.height;\n  } else if (msg.data.canvas) {\n    SIZE.width = msg.data.canvas.width;\n    SIZE.height = msg.data.canvas.height;\n    CONFETTI = module.exports.create(msg.data.canvas);\n  }\n}"].join("\n");
                            try {
                                y = new Worker(URL.createObjectURL(new Blob([t])))
                            } catch (e) {
                                return "u" > typeof console && "function" == typeof console.warn && console.warn("🎊 Could not load worker", e), null
                            }
                            var r = y;

                            function a(e, t) {
                                r.postMessage({
                                    options: e || {},
                                    callback: t
                                })
                            }
                            r.init = function(e) {
                                var t = e.transferControlToOffscreen();
                                r.postMessage({
                                    canvas: t
                                }, [t])
                            }, r.fire = function(e, t, n) {
                                if (p) return a(e, null), p;
                                var i = Math.random().toString(36).slice(2);
                                return p = b(function(t) {
                                    function o(e) {
                                        e.data.callback === i && (delete f[i], r.removeEventListener("message", o), p = null, T.clear(), n(), t())
                                    }
                                    r.addEventListener("message", o), a(e, i), f[i] = o.bind(null, {
                                        data: {
                                            callback: i
                                        }
                                    })
                                })
                            }, r.reset = function() {
                                for (var e in r.postMessage({
                                        reset: !0
                                    }), f) f[e](), delete f[e]
                            }
                        }
                        return y
                    }),
                    w = {
                        particleCount: 50,
                        angle: 90,
                        spread: 45,
                        startVelocity: 45,
                        decay: .9,
                        gravity: 1,
                        drift: 0,
                        ticks: 200,
                        x: .5,
                        y: .5,
                        shapes: ["square", "circle"],
                        zIndex: 100,
                        colors: ["#26ccff", "#a25afd", "#ff5e7e", "#88ff5a", "#fcff42", "#ffa62d", "#ff36ff"],
                        disableForReducedMotion: !1,
                        scalar: 1
                    };

                function M(e, t, r) {
                    var n;
                    return n = e && null != e[t] ? e[t] : w[t], r ? r(n) : n
                }

                function k(e) {
                    return e < 0 ? 0 : Math.floor(e)
                }

                function E(e) {
                    return parseInt(e, 16)
                }

                function O(e) {
                    return e.map(S)
                }

                function S(e) {
                    var t = String(e).replace(/[^0-9a-f]/gi, "");
                    return t.length < 6 && (t = t[0] + t[0] + t[1] + t[1] + t[2] + t[2]), {
                        r: E(t.substring(0, 2)),
                        g: E(t.substring(2, 4)),
                        b: E(t.substring(4, 6))
                    }
                }

                function I(e) {
                    e.width = document.documentElement.clientWidth, e.height = document.documentElement.clientHeight
                }

                function P(e) {
                    var t = e.getBoundingClientRect();
                    e.width = t.width, e.height = t.height
                }

                function A(e, r) {
                    var i, o = !e,
                        s = !!M(r || {}, "resize"),
                        u = !1,
                        l = M(r, "disableForReducedMotion", Boolean),
                        c = h && M(r || {}, "useWorker") ? x() : null,
                        d = o ? I : P,
                        y = !!e && !!c && !!e.__confetti_initialized,
                        p = "function" == typeof matchMedia && matchMedia("(prefers-reduced-motion)").matches;

                    function f(r) {
                        var f, m = l || M(r, "disableForReducedMotion", Boolean),
                            h = M(r, "zIndex", Number);
                        if (m && p) return b(function(e) {
                            e()
                        });
                        o && i ? e = i.canvas : o && !e && ((f = document.createElement("canvas")).style.position = "fixed", f.style.top = "0px", f.style.left = "0px", f.style.pointerEvents = "none", f.style.zIndex = h, e = f, document.body.appendChild(e)), s && !y && d(e);
                        var v = {
                            width: e.width,
                            height: e.height
                        };

                        function x() {
                            if (c) {
                                var t = {
                                    getBoundingClientRect: function() {
                                        if (!o) return e.getBoundingClientRect()
                                    }
                                };
                                d(t), c.postMessage({
                                    resize: {
                                        width: t.width,
                                        height: t.height
                                    }
                                });
                                return
                            }
                            v.width = v.height = null
                        }

                        function w() {
                            i = null, s && (u = !1, t.removeEventListener("resize", x)), o && e && (document.body.contains(e) && document.body.removeChild(e), e = null, y = !1)
                        }
                        return (c && !y && c.init(e), y = !0, c && (e.__confetti_initialized = !0), s && !u && (u = !0, t.addEventListener("resize", x, !1)), c) ? c.fire(r, v, w) : function(t, r, o) {
                            for (var s, u, l, c, y, p, f, m = M(t, "particleCount", k), h = M(t, "angle", Number), v = M(t, "spread", Number), x = M(t, "startVelocity", Number), w = M(t, "decay", Number), E = M(t, "gravity", Number), S = M(t, "drift", Number), I = M(t, "colors", O), P = M(t, "ticks", Number), A = M(t, "shapes"), N = M(t, "scalar"), _ = !!M(t, "flat"), F = ((s = M(t, "origin", Object)).x = M(s, "x", Number), s.y = M(s, "y", Number), s), D = m, R = [], L = e.width * F.x, K = e.height * F.y; D--;) R.push(function(e) {
                                var t = e.angle * (Math.PI / 180),
                                    r = e.spread * (Math.PI / 180);
                                return {
                                    x: e.x,
                                    y: e.y,
                                    wobble: 10 * Math.random(),
                                    wobbleSpeed: Math.min(.11, .1 * Math.random() + .05),
                                    velocity: .5 * e.startVelocity + Math.random() * e.startVelocity,
                                    angle2D: -t + (.5 * r - Math.random() * r),
                                    tiltAngle: (.5 * Math.random() + .25) * Math.PI,
                                    color: e.color,
                                    shape: e.shape,
                                    tick: 0,
                                    totalTicks: e.ticks,
                                    decay: e.decay,
                                    drift: e.drift,
                                    random: Math.random() + 2,
                                    tiltSin: 0,
                                    tiltCos: 0,
                                    wobbleX: 0,
                                    wobbleY: 0,
                                    gravity: 3 * e.gravity,
                                    ovalScalar: .6,
                                    scalar: e.scalar,
                                    flat: e.flat
                                }
                            }({
                                x: L,
                                y: K,
                                angle: h,
                                spread: v,
                                startVelocity: x,
                                color: I[D % I.length],
                                shape: A[Math.floor(Math.random() * (A.length - 0)) + 0],
                                ticks: P,
                                decay: w,
                                gravity: E,
                                drift: S,
                                scalar: N,
                                flat: _
                            }));
                            return i ? i.addFettis(R) : (u = e, y = R.slice(), p = u.getContext("2d"), f = b(function(e) {
                                    function t() {
                                        l = c = null, p.clearRect(0, 0, r.width, r.height), T.clear(), o(), e()
                                    }
                                    l = C.frame(function e() {
                                        n && (r.width !== a.width || r.height !== a.height) && (r.width = u.width = a.width, r.height = u.height = a.height), r.width || r.height || (d(u), r.width = u.width, r.height = u.height), p.clearRect(0, 0, r.width, r.height), (y = y.filter(function(e) {
                                                    return function(e, t) {
                                                        t.x += Math.cos(t.angle2D) * t.velocity + t.drift, t.y += Math.sin(t.angle2D) * t.velocity + t.gravity, t.velocity *= t.decay, t.flat ? (t.wobble = 0, t.wobbleX = t.x + 10 * t.scalar, t.wobbleY = t.y + 10 * t.scalar, t.tiltSin = 0, t.tiltCos = 0, t.random = 1) : (t.wobble += t.wobbleSpeed, t.wobbleX = t.x + 10 * t.scalar * Math.cos(t.wobble), t.wobbleY = t.y + 10 * t.scalar * Math.sin(t.wobble), t.tiltAngle += .1, t.tiltSin = Math.sin(t.tiltAngle), t.tiltCos = Math.cos(t.tiltAngle), t.random = Math.random() + 2);
                                                        var r, n, a, i, o, s, u, l, c, d, y, p, f, m, h, v, b = t.tick++/t.totalTicks,C=t.x+t.random*t.tiltCos,x=t.y+t.random*t.tiltSin,w=t.wobbleX+t.random*t.tiltCos,M=t.wobbleY+t.random*t.tiltSin;if(e.fillStyle="rgba("+t.color.r+", "+t.color.g+", "+t.color.b+", "+(1-b)+")",e.beginPath(),g&&"path"===t.shape.type&&"string"==typeof t.shape.path&&Array.isArray(t.shape.matrix)){e.fill((r=t.shape.path,n=t.shape.matrix,a=t.x,i=t.y,o=.1*Math.abs(w-C),s=.1*Math.abs(M-x),u=Math.PI/
                                                        10 * t.wobble, l = new Path2D(r), (c = new Path2D).addPath(l, new DOMMatrix(n)), (d = new Path2D).addPath(c, new DOMMatrix([Math.cos(u) * o, Math.sin(u) * o, -Math.sin(u) * s, Math.cos(u) * s, a, i])), d))
                                            }
                                            else if ("bitmap" === t.shape.type) {
                                                var k = Math.PI / 10 * t.wobble,
                                                    E = .1 * Math.abs(w - C),
                                                    O = .1 * Math.abs(M - x),
                                                    S = t.shape.bitmap.width * t.scalar,
                                                    I = t.shape.bitmap.height * t.scalar,
                                                    P = new DOMMatrix([Math.cos(k) * E, Math.sin(k) * E, -Math.sin(k) * O, Math.cos(k) * O, t.x, t.y]);
                                                P.multiplySelf(new DOMMatrix(t.shape.matrix));
                                                var A = e.createPattern(T.transform(t.shape.bitmap), "no-repeat");
                                                A.setTransform(P), e.globalAlpha = 1 - b, e.fillStyle = A, e.fillRect(t.x - S / 2, t.y - I / 2, S, I), e.globalAlpha = 1
                                            } else if ("circle" === t.shape) e.ellipse ? e.ellipse(t.x, t.y, Math.abs(w - C) * t.ovalScalar, Math.abs(M - x) * t.ovalScalar, Math.PI / 10 * t.wobble, 0, 2 * Math.PI) : (y = t.x, p = t.y, f = Math.abs(w - C) * t.ovalScalar, m = Math.abs(M - x) * t.ovalScalar, h = Math.PI / 10 * t.wobble, v = 2 * Math.PI, e.save(), e.translate(y, p), e.rotate(h), e.scale(f, m), e.arc(0, 0, 1, 0, v, void 0), e.restore());
                                            else if ("star" === t.shape)
                                                for (var N = Math.PI / 2 * 3, _ = 4 * t.scalar, F = 8 * t.scalar, D = t.x, R = t.y, L = 5, K = Math.PI / 5; L--;) D = t.x + Math.cos(N) * F, R = t.y + Math.sin(N) * F, e.lineTo(D, R), N += K, D = t.x + Math.cos(N) * _, R = t.y + Math.sin(N) * _, e.lineTo(D, R), N += K;
                                            else e.moveTo(Math.floor(t.x), Math.floor(t.y)), e.lineTo(Math.floor(t.wobbleX), Math.floor(x)), e.lineTo(Math.floor(w), Math.floor(M)), e.lineTo(Math.floor(C), Math.floor(t.wobbleY));
                                            return e.closePath(), e.fill(), t.tick < t.totalTicks
                                        }(p, e)
                                    })).length ? l = C.frame(e) : t()
                            }), c = t
                        }), (i = {
                        addFettis: function(e) {
                            return y = y.concat(e), f
                        },
                        canvas: u,
                        promise: f,
                        reset: function() {
                            l && C.cancel(l), c && c()
                        }
                    }).promise)
            }(r, v, w)
        }
        return f.reset = function() {
            c && c.reset(), i && i.reset()
        }, f
    }

    function N() {
        return m || (m = A(null, {
            useWorker: !0,
            resize: !0
        })), m
    }
    r.exports = function() {
        return N().apply(this, arguments)
    }, r.exports.reset = function() {
        N().reset()
    }, r.exports.create = A, r.exports.shapeFromPath = function(e) {
        if (!g) throw Error("path confetti are not supported in this browser");
        "string" == typeof e ? n = e : (n = e.path, a = e.matrix);
        var t = new Path2D(n),
            r = document.createElement("canvas").getContext("2d");
        if (!a) {
            for (var n, a, i, o, s = 1e3, u = 1e3, l = 0, c = 0, d = 0; d < 1e3; d += 2)
                for (var y = 0; y < 1e3; y += 2) r.isPointInPath(t, d, y, "nonzero") && (s = Math.min(s, d), u = Math.min(u, y), l = Math.max(l, d), c = Math.max(c, y));
            i = l - s;
            var p = Math.min(10 / i, 10 / (o = c - u));
            a = [p, 0, 0, p, -Math.round(i / 2 + s) * p, -Math.round(o / 2 + u) * p]
        }
        return {
            type: "path",
            path: n,
            matrix: a
        }
    }, r.exports.shapeFromText = function(e) {
        var t, r = 1,
            n = "#000000",
            a = '"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", "EmojiOne Color", "Android Emoji", "Twemoji Mozilla", "system emoji", sans-serif';
        "string" == typeof e ? t = e : (t = e.text, r = "scalar" in e ? e.scalar : r, a = "fontFamily" in e ? e.fontFamily : a, n = "color" in e ? e.color : n);
        var i = 10 * r,
            o = "" + i + "px " + a,
            s = new OffscreenCanvas(i, i),
            u = s.getContext("2d");
        u.font = o;
        var l = u.measureText(t),
            c = Math.ceil(l.actualBoundingBoxRight + l.actualBoundingBoxLeft),
            d = Math.ceil(l.actualBoundingBoxAscent + l.actualBoundingBoxDescent),
            y = l.actualBoundingBoxLeft + 2,
            p = l.actualBoundingBoxAscent + 2;
        c += 4, d += 4, (u = (s = new OffscreenCanvas(c, d)).getContext("2d")).font = o, u.fillStyle = n, u.fillText(t, y, p);
        var f = 1 / r;
        return {
            type: "bitmap",
            bitmap: s.transferToImageBitmap(),
            matrix: [f, 0, 0, f, -c * f / 2, -d * f / 2]
        }
    }
}(function() {
    return "u" > typeof window ? window : "u" > typeof self ? self : this || {}
}(), n, !1);
let a = n.exports;
n.exports.create;
var i = e.i(416340),
    o = e.i(922445),
    s = e.i(632567);
let u = i.default.createContext({
    rainConfetti: e => null,
    throwDefaultConfetti: () => null
});
e.s(["ConfettiContextProvider", 0, function(e) {
    let n, l, c, d, y, p, f, m, h = (0, r.c)(12),
        {
            children: g
        } = e,
        {
            listenersEnabled: v
        } = (0, s.useHotkeyContext)(),
        b = i.default.useRef(null),
        T = i.default.useRef(null);
    h[0] === Symbol.for("react.memo_cache_sentinel") ? (n = () => (b.current && (T.current = a.create(b.current, {
        resize: !0,
        useWorker: !0
    })), () => {
        T.current ? .reset()
    }), l = [], h[0] = n, h[1] = l) : (n = h[0], l = h[1]), i.default.useEffect(n, l), h[2] === Symbol.for("react.memo_cache_sentinel") ? (c = (e, t, r) => {
        T.current ? .({ ...t,
            particleCount: Math.floor((void 0 === r ? 150 : r) * e)
        })
    }, h[2] = c) : c = h[2];
    let C = c;
    h[3] === Symbol.for("react.memo_cache_sentinel") ? (d = (e, t) => {
        C(.25, {
            spread: 26,
            startVelocity: 55,
            ticks: 120,
            gravity: 1.4,
            ...e
        }, t), C(.2, {
            spread: 60,
            ticks: 120,
            gravity: 1.4,
            ...e
        }, t), C(.35, {
            spread: 100,
            decay: .91,
            scalar: .8,
            ticks: 120,
            gravity: 1.4,
            ...e
        }, t), C(.1, {
            spread: 120,
            startVelocity: 25,
            decay: .92,
            scalar: 1.2,
            ticks: 120,
            gravity: 1.4,
            ...e
        }, t), C(.1, {
            spread: 120,
            startVelocity: 45,
            ticks: 120,
            gravity: 1.4,
            ...e
        }, t)
    }, h[3] = d) : d = h[3];
    let x = d;
    h[4] !== v ? (y = () => {
        !v || (0, o.isNarrowViewport)() || (x({
            origin: {
                x: 0,
                y: 1
            },
            angle: 45
        }, 400), x({
            origin: {
                x: 1,
                y: 1
            },
            angle: 135
        }, 400))
    }, h[4] = v, h[5] = y) : y = h[5];
    let w = y;
    h[6] !== w ? (p = {
        rainConfetti: x,
        throwDefaultConfetti: w
    }, h[6] = w, h[7] = p) : p = h[7];
    let M = p;
    return h[8] === Symbol.for("react.memo_cache_sentinel") ? (f = (0, t.jsx)("canvas", {
        ref: b,
        style: {
            position: "fixed",
            pointerEvents: "none",
            width: "100%",
            height: "100%",
            top: 0,
            left: 0,
            zIndex: 999999
        }
    }), h[8] = f) : f = h[8], h[9] !== g || h[10] !== M ? (m = (0, t.jsxs)(u.Provider, {
        value: M,
        children: [g, f]
    }), h[9] = g, h[10] = M, h[11] = m) : m = h[11], m
}, "useConfettiContext", 0, () => i.default.useContext(u)], 945374)
}, 586034, 934993, e => {
"use strict";
var t = e.i(221628),
r = e.i(740594),
n = e.i(318594),
a = e.i(397456),
i = e.i(606231),
o = e.i(416340),
s = e.i(778983),
u = e.i(502475),
l = e.i(999061),
c = e.i(784521),
d = e.i(631222),
y = e.i(921807),
p = e.i(835893),
f = e.i(600326),
m = e.i(57096),
h = e.i(668122),
g = e.i(99417),
v = e.i(305457),
b = e.i(400819),
T = e.i(249792),
C = e.i(606572),
x = e.i(838900),
w = e.i(660006),
M = e.i(196593),
k = e.i(53950),
E = e.i(450091),
O = e.i(510954),
S = e.i(488549),
I = e.i(772281),
P = e.i(30704);
let A = e => e ? e.slice(0, 8) : "",
N = new Map;

function _(e) {
return "number" == typeof e && Number.isFinite(e) ? e : 0
}

function F() {
return {
    current: 0,
    pending: 0,
    optimistic: 0
}
}
let D = (0, o.createContext)({});

function R(e) {
return !!e && "object" == typeof e && "string" == typeof e.conditionId && "number" == typeof e.outcomeIndex && "number" == typeof e.size
}

function L(e) {
try {
    if (!e || "object" != typeof e) return [];
    if ("order" === e.event_type || "trade" === e.event_type || "auto_redeem" === e.event_type) return [e];
    if ("order" === e.type || "trade" === e.type || "auto_redeem" === e.type) {
        let t = e.type,
            r = e.payload ? ? e.events ? ? e.data;
        if (Array.isArray(r)) return r.map(e => ({ ...e,
            event_type: t
        }));
        if (r && "object" == typeof r) return [{ ...r,
            event_type: t
        }];
        return []
    }
    if (e.payload && "object" == typeof e.payload) {
        let t = e.payload;
        if ("order" === t.type || "trade" === t.type || "auto_redeem" === t.type) {
            let e = t.type,
                r = t.events || t.payload || t;
            if (Array.isArray(r)) return r.map(t => ({ ...t,
                event_type: e
            }));
            if (r && "object" == typeof r) return [{ ...r,
                event_type: e
            }]
        }
    }
    return []
} catch {
    return []
}
}
let K = () => ({
    tradeHistory: !1,
    limitOrderHistory: !1,
    marketOrderHistory: !1
}),
q = e => {
    e.current && (clearTimeout(e.current), e.current = null)
},
B = ({
    startedAt: e,
    quietWindowMs: t,
    maxWaitMs: r
}) => null === e ? t : Math.min(t, Math.max(0, r - (Date.now() - e)));
e.s(["UserWsContextProvider", 0, ({
children: e
}) => {
let Q = (0, n.useQueryClient)(),
    U = (e => {
        let t, r, n = (0, l.c)(5);
        n[0] === Symbol.for("react.memo_cache_sentinel") ? (t = ["proxyAddress"], n[0] = t) : t = n[0];
        let {
            proxyAddress: a
        } = (0, c.useAccountContext)(t), i = (0, y.useTransactionStore)(), o = e ? ? d.MATIC_CONFIG.chainId;
        return n[1] !== o || n[2] !== a || n[3] !== i ? (r = e => {
            if (!a || !o) throw Error("No address or chain ID found");
            return i.doesTransactionExist(a, o, e)
        }, n[1] = o, n[2] = a, n[3] = i, n[4] = r) : r = n[4], r
    })(),
    j = (0, p.default)(),
    {
        userOpenOrdersMutation: W
    } = (0, P.default)(),
    {
        getApiCredential: H
    } = (0, b.useClobCredentialContext)(),
    {
        proxyAddress: z
    } = (0, c.useAccountContext)(["proxyAddress"]),
    V = (0, g.useInvalidatePositions)(),
    $ = (0, y.useTransactionStore)(),
    G = (0, v.useAmplitudeAnalytics)(),
    X = (0, T.useToast)(),
    Y = (0, o.useMemo)(() => {
        if (z) return H(z)
    }, [z, H]),
    Z = (0, o.useRef)(null),
    J = (0, o.useRef)(null),
    ee = (0, o.useRef)(null),
    et = (0, o.useRef)(null),
    er = (0, o.useRef)(null),
    en = (0, o.useRef)(null),
    ea = (0, o.useRef)(K()),
    ei = (0, o.useCallback)(() => {
        z && (q(Z), Z.current = setTimeout(() => {
            V(z), Z.current = null
        }, 1500))
    }, [V, z]),
    eo = (0, o.useCallback)(async () => {
        await Promise.all([Q.invalidateQueries({
            queryKey: O.queryKeys[m.QueryKey.LimitOrderHistory]._def
        }), Q.invalidateQueries({
            queryKey: O.queryKeys[m.QueryKey.MarketOrderHistory]._def
        }), Q.invalidateQueries({
            queryKey: O.queryKeys[m.QueryKey.TradeHistory]._def
        })]), k.logger.debug("[UserWsContext > refreshAllQueries]", {
            proxyAddress: z
        })
    }, [Q, z]),
    es = (0, o.useCallback)(async () => {
        en.current = null;
        let e = ea.current;
        ea.current = K();
        let t = [];
        e.limitOrderHistory && t.push(Q.invalidateQueries({
            queryKey: O.queryKeys[m.QueryKey.LimitOrderHistory]._def
        })), e.marketOrderHistory && t.push(Q.invalidateQueries({
            queryKey: O.queryKeys[m.QueryKey.MarketOrderHistory]._def
        })), e.tradeHistory && t.push(Q.invalidateQueries({
            queryKey: O.queryKeys[m.QueryKey.TradeHistory]._def
        })), t.length && (await Promise.all(t), k.logger.debug("[UserWsContext > flushHistoryRefreshes]", { ...e,
            proxyAddress: z
        }))
    }, [Q, z]),
    eu = (0, o.useCallback)(e => {
        let t;
        t = ea.current, ea.current = {
            tradeHistory: t.tradeHistory || !0 === e.tradeHistory,
            limitOrderHistory: t.limitOrderHistory || !0 === e.limitOrderHistory,
            marketOrderHistory: t.marketOrderHistory || !0 === e.marketOrderHistory
        }, q(en), en.current = setTimeout(() => {
            es()
        }, 500)
    }, [es]),
    el = (0, o.useCallback)(() => {
        eu({
            tradeHistory: !0
        })
    }, [eu]),
    ec = (0, o.useCallback)(() => {
        J.current = null, ee.current = null, Q.invalidateQueries({
            queryKey: O.queryKeys[m.QueryKey.Notifications].clob._def
        })
    }, [Q]),
    ed = (0, o.useCallback)(() => {
        null === ee.current && (ee.current = Date.now()), q(J), J.current = setTimeout(() => {
            ec()
        }, B({
            startedAt: ee.current,
            quietWindowMs: 350,
            maxWaitMs: 1e3
        }))
    }, [ec]),
    ey = (0, o.useCallback)(() => {
        et.current = null, er.current = null, Q.refetchQueries({
            queryKey: [O.queryKeys[m.QueryKey.OpenOrderScoring]._def]
        })
    }, [Q]),
    ep = (0, o.useCallback)(() => {
        null === er.current && (er.current = Date.now()), q(et), et.current = setTimeout(() => {
            ey()
        }, B({
            startedAt: er.current,
            quietWindowMs: 350,
            maxWaitMs: 1e3
        }))
    }, [ey]),
    {
        tradesMutation: ef
    } = (0, I.useFilledOrdersMutation)({
        onTradeHistorySettled: el
    }),
    em = (0, o.useCallback)(() => !!Y ? .key && Y, [Y]),
    eh = (0, o.useRef)(new Map),
    eg = (0, o.useRef)(new Map);
(0, o.useEffect)(() => {
    eh.current = new Map, eg.current = new Map, ea.current = K(), ee.current = null, er.current = null, q(Z), q(J), q(et), q(en), k.logger.debug("[UserWsContext > resetBurstSchedulers]", {
        proxyAddress: z
    })
}, [z]), (0, o.useEffect)(() => () => {
    ee.current = null, er.current = null, q(Z), q(J), q(et), q(en)
}, []);
let {
    sendMessage: ev,
    readyState: eb
} = (0, i.useWebSocket)({
    url: Y ? .key ? d.WEBSOCKET_USER : null,
    onOpen: e => {
        let t = em();
        if (!1 === t) return void k.logger.debug("[UserWsContext > useWebSocket > onOpen]", {
            e,
            apiCred: t,
            proxyAddress: z
        });
        let r = JSON.stringify({
                auth: {
                    apiKey: t.key ? ? "",
                    secret: t.secret ? ? "",
                    passphrase: t.passphrase ? ? ""
                },
                markets: [],
                type: "user"
            }),
            n = ev(r);
        eo(), k.logger.debug("[UserWsContext > useWebSocket > onOpen]", {
            e,
            apiCred: t,
            payload: r,
            b: n,
            proxyAddress: z
        })
    },
    onMessage: e => {
        let t;
        if (e ? .data && ("string" != typeof e.data || "pong" !== e.data.toLowerCase())) {
            try {
                let r = JSON.parse(e.data);
                if (t = Array.isArray(r) ? r.flatMap(e => L(e)) : L(r), 0 === t.length) return
            } catch (e) {
                console.error(e), (0, w.handleError)(e, "[UserWsContext > onMessage > parse]", z);
                return
            }
            if (k.logger.debug("[UserWsContext > message]", {
                    length: "string" == typeof e.data ? e.data.length : 0,
                    proxyAddress: z
                }), !Y || "string" != typeof Y.key || !z) return void k.logger.debug("[UserWsContext > onMessage]", {
                message: "api credential or proxy address not initialized",
                proxyAddress: z
            });
            try {
                t.forEach(e => {
                    let t = (0, S.cleanPrice)(e),
                        n = "trade" === t.event_type ? `trade-${t.id}-${t.status}-${A(t.market)}` : "auto_redeem" === t.event_type ? `auto_redeem-${A(t.txn_hash)}-${A(t.condition_id)}` : `order-${t.id}-${t.type}-${t.timestamp}-${A(t.market)}`;
                    if (k.logger.debug("[UserWsContext > onMessage]", {
                            wsMapKey: n,
                            parsed: e,
                            cleaned: t,
                            proxyAddress: z
                        }), !eh.current.has(n)) {
                        if (eh.current.set(n, !0), eh.current.size > 1e4) {
                            let e = eh.current.keys().next().value;
                            e && eh.current.delete(e)
                        }
                        if ("order" === t.event_type && ("CANCELLATION" === t.type || "PLACEMENT" === t.type || "UPDATE" === t.type)) {
                            if ("CANCELLATION" === t.type && t.id && (0, x.isFallbackOrder)(t.id)) {
                                let e = (0, x.getFallbackOrder)(t.id);
                                (0, x.removeFallbackOrder)(t.id), G.trackEvent(h.Events.FakFallbackOrderCancelled, {
                                    order_id: t.id,
                                    market: t.market ? ? void 0,
                                    side: e ? .side ? ? void 0,
                                    amount: e ? .amount ? ? void 0,
                                    fallback_limit_price: e ? .price ? ? void 0,
                                    fallback_limit_size: e ? .size ? ? void 0
                                }, z), X.error(new C.ToastBuilder().title("Order failed").description(e ? .question ? ? ""))
                            }
                            if ("UPDATE" === t.type) {
                                let e = window.localStorage.getItem("pm.orders.ids"),
                                    r = e ? JSON.parse(e) : [];
                                if (!r.includes(t.id)) try {
                                    window.localStorage.setItem("pm.orders.ids", JSON.stringify([...new Set([...r, t.id])]))
                                } catch {}
                            }
                            W({
                                apiKey: Y.key,
                                order: t,
                                invalidate: !1
                            }), ed(), ep()
                        }
                        if ("trade" === t.event_type && t) {
                            let e, n = (e = [], "string" == typeof t.taker_order_id && e.push(t.taker_order_id), Array.isArray(t.maker_orders) && t.maker_orders.forEach(t => {
                                    t && "string" == typeof t.order_id && e.push(t.order_id)
                                }), [...new Set(e)]),
                                a = new Set(n.map(e => e.toLowerCase())),
                                i = z ? $.getTransactionCacheManager().getCachedTransactions(z, d.MATIC_CONFIG.chainId) ? .txns ? ? [] : [],
                                o = "string" == typeof t.id ? t.id.toLowerCase() : "",
                                l = "string" == typeof t.transaction_hash ? t.transaction_hash.toLowerCase() : "",
                                c = i.find(e => !!(o && (e.tradeIds ? .some(e => e.toLowerCase() === o) || e.txId.toLowerCase() === o) || l && (e.tradeIds ? .some(e => e.toLowerCase() === l) || e.txId.toLowerCase() === l)) || !!(a.has(e.txId.toLowerCase()) || e.tradeIds ? .some(e => a.has(e.toLowerCase())))),
                                y = c ? .metadata ? .enqueuedAt,
                                p = {
                                    trade_id: t.id,
                                    order_id: t.taker_order_id,
                                    status: t.status,
                                    market: t.market,
                                    side: t.side,
                                    size: t.size,
                                    price: t.price,
                                    timestamp: t.timestamp,
                                    time_since_order: "number" == typeof y ? Date.now() - y : void 0
                                },
                                g = (() => {
                                    if ("MINED" !== t.status && "CONFIRMED" !== t.status) return;
                                    if ("string" == typeof t.id && t.id) return t.id.toLowerCase();
                                    if ("string" == typeof t.transaction_hash && t.transaction_hash) return t.transaction_hash.toLowerCase();
                                    let e = n[0];
                                    return "string" == typeof e && e ? e.toLowerCase() : void 0
                                })(),
                                v = g && z ? `${z.toLowerCase()}:${g}` : void 0,
                                b = !!(g && eg.current.has(g)),
                                T = !!(v && N.has(v)),
                                w = b || T;
                            if (g && !w) {
                                if (eg.current.set(g, !0), eg.current.size > 1e4) {
                                    let e = eg.current.keys().next().value;
                                    e && eg.current.delete(e)
                                }
                                if (v && (N.set(v, !0), N.size > 4e4)) {
                                    let e = N.keys().next().value;
                                    e && N.delete(e)
                                }
                            }
                            let k = () => {
                                    let e, n, a = c ? .metadata;
                                    if (!c || a ? .side !== r.Side.SELL) return;
                                    let o = c.conditionId.toLowerCase(),
                                        l = a.outcomeIndex;
                                    if (!Number.isFinite(l)) return;
                                    let d = (() => {
                                            try {
                                                for (let [, e] of Q.getQueriesData({
                                                        predicate: e => e.queryKey[0] === m.QueryKey.Positions
                                                    }))
                                                    if (e) {
                                                        if (Array.isArray(e)) {
                                                            let t = e.find(e => R(e) && e.conditionId.toLowerCase() === o && e.outcomeIndex === l);
                                                            if (t && R(t)) return t
                                                        }
                                                        if ("object" == typeof e && null !== e && "pages" in e) {
                                                            let t = e.pages;
                                                            if (!Array.isArray(t)) continue;
                                                            for (let e of t) {
                                                                if (!Array.isArray(e)) continue;
                                                                let t = e.find(e => R(e) && e.conditionId.toLowerCase() === o && e.outcomeIndex === l);
                                                                if (t && R(t)) return t
                                                            }
                                                        }
                                                    }
                                                return
                                            } catch {
                                                return
                                            }
                                        })(),
                                        y = d ? .size,
                                        p = Number.parseFloat(t.size),
                                        h = (e = a.positionChangeData.shareQty[l], Number.isFinite(e) ? Math.abs(e) : void 0),
                                        g = Number.isFinite(p) ? Math.abs(p) : void 0,
                                        v = "number" == typeof h ? h : "number" == typeof g ? g : void 0;
                                    if ("number" != typeof v || !Number.isFinite(v)) return;
                                    let b = "number" == typeof a.positionQtyBeforeSell && Number.isFinite(a.positionQtyBeforeSell) ? a.positionQtyBeforeSell : void 0,
                                        T = (n = "number" == typeof c.metadata ? .enqueuedAt ? c.metadata.enqueuedAt : void 0, "number" != typeof n ? 0 : i.filter(e => {
                                            if (e.txId === c.txId || e.conditionId.toLowerCase() !== o) return !1;
                                            let t = e.metadata ? .outcomeIndex;
                                            if (!Number.isFinite(t) || t !== l) return !1;
                                            let r = e.metadata ? .enqueuedAt;
                                            return "number" == typeof r && !(r <= n)
                                        }).filter(e => e.status === f.TxnStatus.MINED || e.status === f.TxnStatus.CONFIRMED).reduce((e, t) => {
                                            let r = t.metadata ? .positionChangeData ? .shareQty ? .[l];
                                            return "number" == typeof r && Number.isFinite(r) ? e + r : e
                                        }, 0)),
                                        C = "number" == typeof b ? b + T : void 0,
                                        x = (() => {
                                            if (z) try {
                                                let e = O.queryKeys[m.QueryKey.Positions].optimistic(z).queryKey,
                                                    t = Q.getQueryData(e);
                                                if (!(t instanceof Map)) return;
                                                let r = (0, u.makeOptimisticPositionKey)({
                                                        conditionId: o,
                                                        outcomeIndex: 0 === l ? "0" : "1"
                                                    }),
                                                    n = t.get(r),
                                                    a = n ? .position,
                                                    i = a ? .trackedPositionMetadata ? .netQuantity ? .optimistic;
                                                if ("number" == typeof i && Number.isFinite(i)) return i;
                                                let s = a ? .trackedPositionMetadata ? .netQuantity ? .current;
                                                if ("number" == typeof s && Number.isFinite(s)) return s;
                                                if (!a ? .netQuantity) return;
                                                let c = Number.parseFloat((0, M.formatUSDCUnits)(BigInt(a.netQuantity)));
                                                return Number.isFinite(c) ? c : void 0
                                            } catch {
                                                return
                                            }
                                        })(),
                                        w = "number" == typeof C ? C - v : "number" == typeof x ? x - v : "number" == typeof y && Number.isFinite(y) ? v > y + .1 ? y : y - v : void 0,
                                        k = (() => {
                                            if ("number" == typeof w && Number.isFinite(w)) return Math.max(0, Math.round(1e6 * w))
                                        })(),
                                        S = "number" == typeof k && k <= 1e5,
                                        I = (() => {
                                            if (!d && z) try {
                                                let e = O.queryKeys[m.QueryKey.Positions].optimistic(z).queryKey,
                                                    t = Q.getQueryData(e);
                                                if (!(t instanceof Map)) return;
                                                let r = (0, u.makeOptimisticPositionKey)({
                                                        conditionId: o,
                                                        outcomeIndex: 0 === l ? "0" : "1"
                                                    }),
                                                    n = t.get(r);
                                                return n ? .position
                                            } catch {
                                                return
                                            }
                                        })();
                                    if (!S && z && "number" == typeof k && Number.isFinite(v)) {
                                        if (d) try {
                                            let e = (0, s.formatTrackedMarketPosition)({ ...d,
                                                size: k / 1e6
                                            });
                                            (0, u.updateOptimisticPositions)({
                                                queryClient: Q,
                                                positions: [e],
                                                proxyAddress: z,
                                                source: "UserWsContext.handleTradeSettled.partialSell"
                                            })
                                        } catch {} else if (I ? .trackedPositionMetadata) {
                                            let e = I.trackedPositionMetadata,
                                                t = _(e.netQuantity.pending) + v,
                                                r = "number" == typeof w && Number.isFinite(w) ? Math.max(w, 0) : Math.max(_(e.netQuantity.optimistic), 0),
                                                n = Math.max(r - t, 0),
                                                a = (0, E.getCurrentSharePrice)(I),
                                                i = n * a,
                                                o = t * a,
                                                s = i + o,
                                                l = { ...I,
                                                    isPending: Math.abs(t) > 1e-6,
                                                    netQuantity: (0, M.parseUSDCUnits)(n.toString()).toString(),
                                                    netValue: (0, M.parseUSDCUnits)(s.toString()).toString(),
                                                    trackedPositionMetadata: { ...e,
                                                        netQuantity: {
                                                            current: n,
                                                            pending: t,
                                                            optimistic: r
                                                        },
                                                        netValue: {
                                                            current: i,
                                                            pending: o,
                                                            optimistic: s
                                                        }
                                                    }
                                                };
                                            (0, u.updateOptimisticPositions)({
                                                queryClient: Q,
                                                positions: [l],
                                                proxyAddress: z,
                                                source: "UserWsContext.handleTradeSettled.partialSell.fallback"
                                            })
                                        }
                                    }
                                    if (S && z) try {
                                        let e = O.queryKeys[m.QueryKey.Positions].optimistic(z).queryKey,
                                            t = Q.getQueryData(e);
                                        if (t instanceof Map) {
                                            let e, r = (0, u.makeOptimisticPositionKey)({
                                                    conditionId: o,
                                                    outcomeIndex: 0 === l ? "0" : "1"
                                                }),
                                                n = t.get(r),
                                                i = n ? .position,
                                                c = i ? .trackedPositionMetadata,
                                                y = _(c ? .quantityBought.pending),
                                                p = _(c ? .totalQuantityBought.pending),
                                                f = _(c ? .valueBought.pending),
                                                m = _(c ? .totalValueBought.pending),
                                                h = !0 === a.isDelayedOrder ? _(c ? .netQuantity.pending) : _(c ? .netQuantity.pending) + v,
                                                g = c && i ? h * (0, E.getCurrentSharePrice)(i) : 0,
                                                b = y > 1e-6 || p > 1e-6 || f > 1e-6 || m > 1e-6 || Math.abs(h) > 1e-6,
                                                T = i && c && b ? { ...i,
                                                    isPending: !0,
                                                    pendingSince: i.pendingSince ? ? Date.now(),
                                                    quantityBought: "0",
                                                    netQuantity: "0",
                                                    valueBought: "0",
                                                    netValue: "0",
                                                    totalQuantityBought: "0",
                                                    totalValueBought: "0",
                                                    realizedProfit: "0",
                                                    trackedPositionMetadata: { ...c,
                                                        quantityBought: {
                                                            current: 0,
                                                            pending: y,
                                                            optimistic: y
                                                        },
                                                        totalQuantityBought: {
                                                            current: 0,
                                                            pending: p,
                                                            optimistic: p
                                                        },
                                                        netQuantity: {
                                                            current: 0,
                                                            pending: h,
                                                            optimistic: h
                                                        },
                                                        valueBought: {
                                                            current: 0,
                                                            pending: f,
                                                            optimistic: f
                                                        },
                                                        totalValueBought: {
                                                            current: 0,
                                                            pending: m,
                                                            optimistic: m
                                                        },
                                                        netValue: {
                                                            current: 0,
                                                            pending: g,
                                                            optimistic: g
                                                        },
                                                        realizedProfit: {
                                                            current: _(c.realizedProfit.current),
                                                            pending: 0,
                                                            optimistic: _(c.realizedProfit.current)
                                                        }
                                                    }
                                                } : (e = {
                                                    quantityBought: F(),
                                                    netQuantity: F(),
                                                    valueBought: F(),
                                                    netValue: F(),
                                                    realizedProfit: F(),
                                                    totalQuantityBought: F(),
                                                    totalValueBought: F()
                                                }, i ? { ...i,
                                                    isPending: !1,
                                                    pendingSince: void 0,
                                                    quantityBought: "0",
                                                    netQuantity: "0",
                                                    valueBought: "0",
                                                    netValue: "0",
                                                    totalQuantityBought: "0",
                                                    totalValueBought: "0",
                                                    realizedProfit: "0",
                                                    trackedPositionMetadata: e
                                                } : d ? { ...(0, s.formatTrackedMarketPosition)({ ...d,
                                                        size: 0
                                                    }),
                                                    trackedPositionMetadata: e
                                                } : void 0);
                                            T && (0, u.updateOptimisticPositions)({
                                                queryClient: Q,
                                                positions: [T],
                                                proxyAddress: z,
                                                source: b ? "UserWsContext.handleTradeSettled.fullSell.preservePending" : "UserWsContext.handleTradeSettled.fullSell"
                                            })
                                        }
                                    } catch {}
                                },
                                S = () => {
                                    let e = c ? .metadata;
                                    if (!c || e ? .side !== r.Side.BUY) return;
                                    let t = c.conditionId.toLowerCase(),
                                        n = e.outcomeIndex;
                                    if (!Number.isFinite(n)) return;
                                    let a = e.positionChangeData.shareQty[n],
                                        i = e.positionChangeData.shareValue[n],
                                        o = "number" == typeof a && Number.isFinite(a) ? Math.abs(a) : 0,
                                        s = "number" == typeof i && Number.isFinite(i) ? Math.abs(i) : 0;
                                    if (o && z) try {
                                        let e = O.queryKeys[m.QueryKey.Positions].optimistic(z).queryKey,
                                            r = Q.getQueryData(e);
                                        if (!(r instanceof Map)) return;
                                        let a = (0, u.makeOptimisticPositionKey)({
                                                conditionId: t,
                                                outcomeIndex: 0 === n ? "0" : "1"
                                            }),
                                            i = r.get(a),
                                            l = i ? .position,
                                            c = l ? .trackedPositionMetadata;
                                        if (!l || !c) return;
                                        let d = _(c.quantityBought.pending),
                                            y = Math.min(o, d);
                                        if (y <= 0) return;
                                        let p = o > 0 ? y / o * s : 0,
                                            f = _(c.netQuantity.current) + y,
                                            h = _(c.netQuantity.pending) - y,
                                            g = _(c.quantityBought.current) + y,
                                            v = Math.max(d - y, 0),
                                            b = _(c.totalQuantityBought.current) + y,
                                            T = Math.max(_(c.totalQuantityBought.pending) - y, 0),
                                            C = (0, E.getCurrentSharePrice)(l),
                                            x = f * C,
                                            w = h * C,
                                            M = _(c.valueBought.current) + p,
                                            k = v * C,
                                            S = _(c.totalValueBought.current) + p,
                                            I = T * C,
                                            P = { ...l,
                                                isPending: Math.abs(h) > 1e-6 || v > 1e-6,
                                                trackedPositionMetadata: { ...c,
                                                    quantityBought: {
                                                        current: g,
                                                        pending: v,
                                                        optimistic: g + v
                                                    },
                                                    totalQuantityBought: {
                                                        current: b,
                                                        pending: T,
                                                        optimistic: b + T
                                                    },
                                                    netQuantity: {
                                                        current: f,
                                                        pending: h,
                                                        optimistic: f + h
                                                    },
                                                    valueBought: {
                                                        current: M,
                                                        pending: k,
                                                        optimistic: M + k
                                                    },
                                                    totalValueBought: {
                                                        current: S,
                                                        pending: I,
                                                        optimistic: S + I
                                                    },
                                                    netValue: {
                                                        current: x,
                                                        pending: w,
                                                        optimistic: x + w
                                                    }
                                                }
                                            };
                                        (0, u.updateOptimisticPositions)({
                                            queryClient: Q,
                                            positions: [P],
                                            proxyAddress: z,
                                            source: "UserWsContext.handleTradeSettled.buy"
                                        })
                                    } catch {}
                                };
                            if ("MATCHED" === t.status) {
                                G.trackEvent(h.Events.OrderStatusMatched, p, z);
                                let e = c ? .metadata,
                                    r = c ? .type === "CLOB" && e ? .isDelayedOrder === !0,
                                    n = t.taker_order_id && (0, x.isFallbackOrder)(t.taker_order_id) ? t.taker_order_id : t.maker_orders ? .find(e => e ? .order_id && (0, x.isFallbackOrder)(e.order_id)) ? .order_id;
                                if (n) {
                                    let e = (0, x.getFallbackOrder)(n);
                                    (0, x.removeFallbackOrder)(n);
                                    let r = t.size,
                                        a = Number.parseFloat(t.size),
                                        i = Number.isNaN(a) ? void 0 : a,
                                        o = Number.parseFloat(t.price),
                                        s = "number" != typeof i || Number.isNaN(o) ? void 0 : i * o;
                                    G.trackEvent(h.Events.FakFallbackOrderMatched, {
                                        order_id: n,
                                        trade_id: t.id,
                                        market: t.market,
                                        side: e ? .side ? ? t.side,
                                        matched_shares: i,
                                        matched_shares_raw: r,
                                        matched_price: t.price,
                                        matched_notional_usdc: s,
                                        amount: e ? .amount ? ? void 0,
                                        fallback_limit_price: e ? .price ? ? void 0,
                                        fallback_limit_size: e ? .size ? ? void 0,
                                        match_source: "websocket"
                                    }, z);
                                    let u = s ? ? e ? .amount,
                                        l = i ? ? e ? .size,
                                        c = Number.isNaN(o) ? e ? Math.round(100 * e.price) : void 0 : Math.round(100 * o),
                                        d = e ? `Buy $${"number"==typeof u&&u<1?u.toFixed(2):Math.round(u??0)} on ${e.outcome}` : "Trade filled",
                                        y = "number" == typeof l && "number" == typeof c ? `${l.toFixed(2)} shares @ ${c}\xa2` : void 0,
                                        p = new C.ToastBuilder().title(d).description(e ? .question ? ? "");
                                    y && p.subtext(y), X.success(p)
                                }
                                ed(), ef({
                                    proxyAddress: z,
                                    apiKey: Y.key,
                                    event: t
                                }), r && !w && (k(), S(), ei(), eo()), t.id && (r && c ? j(c.txId, { ...t.transaction_hash && {
                                        hash: t.transaction_hash
                                    },
                                    status: f.TxnStatus.MINED
                                }, void 0, t.id) : U(t.id) && j(t.id, { ...r && t.transaction_hash && {
                                        hash: t.transaction_hash
                                    },
                                    status: r ? f.TxnStatus.MINED : f.TxnStatus.MATCHED
                                }, void 0, t.id))
                            } else "MINED" === t.status ? (G.trackEvent(h.Events.OrderStatusMined, p, z), w || (k(), S(), ei(), eu({
                                tradeHistory: !0,
                                limitOrderHistory: !0,
                                marketOrderHistory: !0
                            })), j(t.transaction_hash, {
                                hash: t.transaction_hash,
                                status: f.TxnStatus.MINED
                            }, void 0, t.id)) : "CONFIRMED" === t.status ? (G.trackEvent(h.Events.OrderStatusConfirmed, p, z), w || (k(), S(), ei(), eu({
                                tradeHistory: !0,
                                limitOrderHistory: !0,
                                marketOrderHistory: !0
                            })), j(t.transaction_hash, {
                                status: f.TxnStatus.CONFIRMED
                            }, void 0, t.id)) : "FAILED" === t.status && (G.trackEvent(h.Events.OrderStatusFailed, p, z), t.id && U(t.id) && j(t.id, {
                                status: f.TxnStatus.FAILED
                            }, void 0, t.id), n.forEach(e => {
                                U(e) && j(e, {
                                    status: f.TxnStatus.FAILED
                                }, void 0, t.id)
                            }), t.transaction_hash && U(t.transaction_hash) && j(t.transaction_hash, {
                                status: f.TxnStatus.FAILED
                            }, void 0, t.id), z && c ? $.handleFailedTransaction(z, d.MATIC_CONFIG.chainId, c) : z && !c && ei())
                        }
                        "auto_redeem" === t.event_type && ed()
                    }
                })
            } catch (e) {
                console.error(e), (0, w.handleError)(e, "[UserWsContext > onMessage]", z)
            }
        }
    }
}), eT = {
    [a.ReadyState.CONNECTING]: "Connecting",
    [a.ReadyState.OPEN]: "Open",
    [a.ReadyState.CLOSING]: "Closing",
    [a.ReadyState.CLOSED]: "Closed",
    [a.ReadyState.UNINSTANTIATED]: "Uninstantiated"
}[eb];
(0, o.useEffect)(() => {
    let e;
    return "Open" === eT ? (e && clearInterval(e), e = setInterval(() => {
        k.logger.debug("[UserWsContext > ping]", {
            proxyAddress: z
        }), ev("PING")
    }, 3e4)) : e && clearInterval(e), () => {
        e && clearInterval(e)
    }
}, [eT, z, ev]);
let eC = (0, o.useMemo)(() => ({
    userConnectionStatus: eT
}), [eT]);
return (0, t.jsx)(D.Provider, {
    value: eC,
    children: e
})
}, "useUserWsContext", 0, () => (0, o.useContext)(D)], 586034);
var Q = e.i(149285),
U = e.i(174617),
j = e.i(78892),
W = e.i(508785),
H = e.i(608652),
z = e.i(538469),
V = e.i(112466),
$ = e.i(169525),
G = e.i(600317),
X = e.i(886449),
Y = e.i(199786),
Z = e.i(723570),
J = e.i(456262),
ee = "ToastProvider",
[et, er, en] = (0, W.createCollection)("Toast"),
[ea, ei] = (0, H.createContextScope)("Toast", [en]),
[eo, es] = ea(ee),
eu = e => {
    let {
        __scopeToast: r,
        label: n = "Notification",
        duration: a = 5e3,
        swipeDirection: i = "right",
        swipeThreshold: s = 50,
        children: u
    } = e, [l, c] = o.useState(null), [d, y] = o.useState(0), p = o.useRef(!1), f = o.useRef(!1);
    return n.trim() || console.error(`Invalid prop \`label\` supplied to \`${ee}\`. Expected non-empty \`string\`.`), (0, t.jsx)(et.Provider, {
        scope: r,
        children: (0, t.jsx)(eo, {
            scope: r,
            label: n,
            duration: a,
            swipeDirection: i,
            swipeThreshold: s,
            toastCount: d,
            viewport: l,
            onViewportChange: c,
            onToastAdd: o.useCallback(() => y(e => e + 1), []),
            onToastRemove: o.useCallback(() => y(e => e - 1), []),
            isFocusedToastEscapeKeyDownRef: p,
            isClosePausedRef: f,
            children: u
        })
    })
};
eu.displayName = ee;
var el = "ToastViewport",
ec = ["F8"],
ed = "toast.viewportPause",
ey = "toast.viewportResume",
ep = o.forwardRef((e, r) => {
    let {
        __scopeToast: n,
        hotkey: a = ec,
        label: i = "Notifications ({hotkey})",
        ...s
    } = e, u = es(el, n), l = er(n), c = o.useRef(null), d = o.useRef(null), y = o.useRef(null), p = o.useRef(null), f = (0, j.useComposedRefs)(r, p, u.onViewportChange), m = a.join("+").replace(/Key/g, "").replace(/Digit/g, ""), h = u.toastCount > 0;
    o.useEffect(() => {
        let e = e => {
            0 !== a.length && a.every(t => e[t] || e.code === t) && p.current ? .focus()
        };
        return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e)
    }, [a]), o.useEffect(() => {
        let e = c.current,
            t = p.current;
        if (h && e && t) {
            let r = () => {
                    if (!u.isClosePausedRef.current) {
                        let e = new CustomEvent(ed);
                        t.dispatchEvent(e), u.isClosePausedRef.current = !0
                    }
                },
                n = () => {
                    if (u.isClosePausedRef.current) {
                        let e = new CustomEvent(ey);
                        t.dispatchEvent(e), u.isClosePausedRef.current = !1
                    }
                },
                a = t => {
                    e.contains(t.relatedTarget) || n()
                },
                i = () => {
                    e.contains(document.activeElement) || n()
                };
            return e.addEventListener("focusin", r), e.addEventListener("focusout", a), e.addEventListener("pointermove", r), e.addEventListener("pointerleave", i), window.addEventListener("blur", r), window.addEventListener("focus", n), () => {
                e.removeEventListener("focusin", r), e.removeEventListener("focusout", a), e.removeEventListener("pointermove", r), e.removeEventListener("pointerleave", i), window.removeEventListener("blur", r), window.removeEventListener("focus", n)
            }
        }
    }, [h, u.isClosePausedRef]);
    let g = o.useCallback(({
        tabbingDirection: e
    }) => {
        let t = l().map(t => {
            let r = t.ref.current,
                n = [r, ... function(e) {
                    let t = [],
                        r = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT, {
                            acceptNode: e => {
                                let t = "INPUT" === e.tagName && "hidden" === e.type;
                                return e.disabled || e.hidden || t ? NodeFilter.FILTER_SKIP : e.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
                            }
                        });
                    for (; r.nextNode();) t.push(r.currentNode);
                    return t
                }(r)];
            return "forwards" === e ? n : n.reverse()
        });
        return ("forwards" === e ? t.reverse() : t).flat()
    }, [l]);
    return o.useEffect(() => {
        let e = p.current;
        if (e) {
            let t = t => {
                let r = t.altKey || t.ctrlKey || t.metaKey;
                if ("Tab" === t.key && !r) {
                    let r = document.activeElement,
                        n = t.shiftKey;
                    if (t.target === e && n) return void d.current ? .focus();
                    let a = g({
                            tabbingDirection: n ? "backwards" : "forwards"
                        }),
                        i = a.findIndex(e => e === r);
                    eA(a.slice(i + 1)) ? t.preventDefault() : n ? d.current ? .focus() : y.current ? .focus()
                }
            };
            return e.addEventListener("keydown", t), () => e.removeEventListener("keydown", t)
        }
    }, [l, g]), (0, t.jsxs)(z.Branch, {
        ref: c,
        role: "region",
        "aria-label": i.replace("{hotkey}", m),
        tabIndex: -1,
        style: {
            pointerEvents: h ? void 0 : "none"
        },
        children: [h && (0, t.jsx)(em, {
            ref: d,
            onFocusFromOutsideViewport: () => {
                eA(g({
                    tabbingDirection: "forwards"
                }))
            }
        }), (0, t.jsx)(et.Slot, {
            scope: n,
            children: (0, t.jsx)(G.Primitive.ol, {
                tabIndex: -1,
                ...s,
                ref: f
            })
        }), h && (0, t.jsx)(em, {
            ref: y,
            onFocusFromOutsideViewport: () => {
                eA(g({
                    tabbingDirection: "backwards"
                }))
            }
        })]
    })
});
ep.displayName = el;
var ef = "ToastFocusProxy",
em = o.forwardRef((e, r) => {
    let {
        __scopeToast: n,
        onFocusFromOutsideViewport: a,
        ...i
    } = e, o = es(ef, n);
    return (0, t.jsx)(J.VisuallyHidden, {
        tabIndex: 0,
        ...i,
        ref: r,
        style: {
            position: "fixed"
        },
        onFocus: e => {
            let t = e.relatedTarget;
            o.viewport ? .contains(t) || a()
        }
    })
});
em.displayName = ef;
var eh = "Toast",
eg = o.forwardRef((e, r) => {
    let {
        forceMount: n,
        open: a,
        defaultOpen: i,
        onOpenChange: o,
        ...s
    } = e, [u, l] = (0, Y.useControllableState)({
        prop: a,
        defaultProp: i ? ? !0,
        onChange: o,
        caller: eh
    });
    return (0, t.jsx)($.Presence, {
        present: n || u,
        children: (0, t.jsx)(eT, {
            open: u,
            ...s,
            ref: r,
            onClose: () => l(!1),
            onPause: (0, X.useCallbackRef)(e.onPause),
            onResume: (0, X.useCallbackRef)(e.onResume),
            onSwipeStart: (0, U.composeEventHandlers)(e.onSwipeStart, e => {
                e.currentTarget.setAttribute("data-swipe", "start")
            }),
            onSwipeMove: (0, U.composeEventHandlers)(e.onSwipeMove, e => {
                let {
                    x: t,
                    y: r
                } = e.detail.delta;
                e.currentTarget.setAttribute("data-swipe", "move"), e.currentTarget.style.setProperty("--radix-toast-swipe-move-x", `${t}px`), e.currentTarget.style.setProperty("--radix-toast-swipe-move-y", `${r}px`)
            }),
            onSwipeCancel: (0, U.composeEventHandlers)(e.onSwipeCancel, e => {
                e.currentTarget.setAttribute("data-swipe", "cancel"), e.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"), e.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"), e.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"), e.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")
            }),
            onSwipeEnd: (0, U.composeEventHandlers)(e.onSwipeEnd, e => {
                let {
                    x: t,
                    y: r
                } = e.detail.delta;
                e.currentTarget.setAttribute("data-swipe", "end"), e.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"), e.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"), e.currentTarget.style.setProperty("--radix-toast-swipe-end-x", `${t}px`), e.currentTarget.style.setProperty("--radix-toast-swipe-end-y", `${r}px`), l(!1)
            })
        })
    })
});
eg.displayName = eh;
var [ev, eb] = ea(eh, {
onClose() {}
}), eT = o.forwardRef((e, r) => {
let {
    __scopeToast: n,
    type: a = "foreground",
    duration: i,
    open: s,
    onClose: u,
    onEscapeKeyDown: l,
    onPause: c,
    onResume: d,
    onSwipeStart: y,
    onSwipeMove: p,
    onSwipeCancel: f,
    onSwipeEnd: m,
    ...h
} = e, g = es(eh, n), [v, b] = o.useState(null), T = (0, j.useComposedRefs)(r, e => b(e)), C = o.useRef(null), x = o.useRef(null), w = i || g.duration, M = o.useRef(0), k = o.useRef(w), E = o.useRef(0), {
    onToastAdd: O,
    onToastRemove: S
} = g, I = (0, X.useCallbackRef)(() => {
    v ? .contains(document.activeElement) && g.viewport ? .focus(), u()
}), P = o.useCallback(e => {
    e && e !== 1 / 0 && (window.clearTimeout(E.current), M.current = new Date().getTime(), E.current = window.setTimeout(I, e))
}, [I]);
o.useEffect(() => {
    let e = g.viewport;
    if (e) {
        let t = () => {
                P(k.current), d ? .()
            },
            r = () => {
                let e = new Date().getTime() - M.current;
                k.current = k.current - e, window.clearTimeout(E.current), c ? .()
            };
        return e.addEventListener(ed, r), e.addEventListener(ey, t), () => {
            e.removeEventListener(ed, r), e.removeEventListener(ey, t)
        }
    }
}, [g.viewport, w, c, d, P]), o.useEffect(() => {
    s && !g.isClosePausedRef.current && P(w)
}, [s, w, g.isClosePausedRef, P]), o.useEffect(() => (O(), () => S()), [O, S]);
let A = o.useMemo(() => v ? function e(t) {
    let r = [];
    return Array.from(t.childNodes).forEach(t => {
        var n;
        if (t.nodeType === t.TEXT_NODE && t.textContent && r.push(t.textContent), (n = t).nodeType === n.ELEMENT_NODE) {
            let n = t.ariaHidden || t.hidden || "none" === t.style.display,
                a = "" === t.dataset.radixToastAnnounceExclude;
            if (!n)
                if (a) {
                    let e = t.dataset.radixToastAnnounceAlt;
                    e && r.push(e)
                } else r.push(...e(t))
        }
    }), r
}(v) : null, [v]);
return g.viewport ? (0, t.jsxs)(t.Fragment, {
    children: [A && (0, t.jsx)(eC, {
        __scopeToast: n,
        role: "status",
        "aria-live": "foreground" === a ? "assertive" : "polite",
        children: A
    }), (0, t.jsx)(ev, {
        scope: n,
        onClose: I,
        children: Q.createPortal((0, t.jsx)(et.ItemSlot, {
            scope: n,
            children: (0, t.jsx)(z.Root, {
                asChild: !0,
                onEscapeKeyDown: (0, U.composeEventHandlers)(l, () => {
                    g.isFocusedToastEscapeKeyDownRef.current || I(), g.isFocusedToastEscapeKeyDownRef.current = !1
                }),
                children: (0, t.jsx)(G.Primitive.li, {
                    tabIndex: 0,
                    "data-state": s ? "open" : "closed",
                    "data-swipe-direction": g.swipeDirection,
                    ...h,
                    ref: T,
                    style: {
                        userSelect: "none",
                        touchAction: "none",
                        ...e.style
                    },
                    onKeyDown: (0, U.composeEventHandlers)(e.onKeyDown, e => {
                        "Escape" === e.key && (l ? .(e.nativeEvent), e.nativeEvent.defaultPrevented || (g.isFocusedToastEscapeKeyDownRef.current = !0, I()))
                    }),
                    onPointerDown: (0, U.composeEventHandlers)(e.onPointerDown, e => {
                        0 === e.button && (C.current = {
                            x: e.clientX,
                            y: e.clientY
                        })
                    }),
                    onPointerMove: (0, U.composeEventHandlers)(e.onPointerMove, e => {
                        if (!C.current) return;
                        let t = e.clientX - C.current.x,
                            r = e.clientY - C.current.y,
                            n = !!x.current,
                            a = ["left", "right"].includes(g.swipeDirection),
                            i = ["left", "up"].includes(g.swipeDirection) ? Math.min : Math.max,
                            o = a ? i(0, t) : 0,
                            s = a ? 0 : i(0, r),
                            u = "touch" === e.pointerType ? 10 : 2,
                            l = {
                                x: o,
                                y: s
                            },
                            c = {
                                originalEvent: e,
                                delta: l
                            };
                        n ? (x.current = l, eI("toast.swipeMove", p, c, {
                            discrete: !1
                        })) : eP(l, g.swipeDirection, u) ? (x.current = l, eI("toast.swipeStart", y, c, {
                            discrete: !1
                        }), e.target.setPointerCapture(e.pointerId)) : (Math.abs(t) > u || Math.abs(r) > u) && (C.current = null)
                    }),
                    onPointerUp: (0, U.composeEventHandlers)(e.onPointerUp, e => {
                        let t = x.current,
                            r = e.target;
                        if (r.hasPointerCapture(e.pointerId) && r.releasePointerCapture(e.pointerId), x.current = null, C.current = null, t) {
                            let r = e.currentTarget,
                                n = {
                                    originalEvent: e,
                                    delta: t
                                };
                            eP(t, g.swipeDirection, g.swipeThreshold) ? eI("toast.swipeEnd", m, n, {
                                discrete: !0
                            }) : eI("toast.swipeCancel", f, n, {
                                discrete: !0
                            }), r.addEventListener("click", e => e.preventDefault(), {
                                once: !0
                            })
                        }
                    })
                })
            })
        }), g.viewport)
    })]
}) : null
}), eC = e => {
let {
    __scopeToast: r,
    children: n,
    ...a
} = e, i = es(eh, r), [s, u] = o.useState(!1), [l, c] = o.useState(!1);
return function(e = () => {}) {
    let t = (0, X.useCallbackRef)(e);
    (0, Z.useLayoutEffect)(() => {
        let e = 0,
            r = 0;
        return e = window.requestAnimationFrame(() => r = window.requestAnimationFrame(t)), () => {
            window.cancelAnimationFrame(e), window.cancelAnimationFrame(r)
        }
    }, [t])
}(() => u(!0)), o.useEffect(() => {
    let e = window.setTimeout(() => c(!0), 1e3);
    return () => window.clearTimeout(e)
}, []), l ? null : (0, t.jsx)(V.Portal, {
    asChild: !0,
    children: (0, t.jsx)(J.VisuallyHidden, { ...a,
        children: s && (0, t.jsxs)(t.Fragment, {
            children: [i.label, " ", n]
        })
    })
})
}, ex = o.forwardRef((e, r) => {
let {
    __scopeToast: n,
    ...a
} = e;
return (0, t.jsx)(G.Primitive.div, { ...a,
    ref: r
})
});
ex.displayName = "ToastTitle";
var ew = o.forwardRef((e, r) => {
let {
    __scopeToast: n,
    ...a
} = e;
return (0, t.jsx)(G.Primitive.div, { ...a,
    ref: r
})
});
ew.displayName = "ToastDescription";
var eM = "ToastAction",
ek = o.forwardRef((e, r) => {
    let {
        altText: n,
        ...a
    } = e;
    return n.trim() ? (0, t.jsx)(eS, {
        altText: n,
        asChild: !0,
        children: (0, t.jsx)(eO, { ...a,
            ref: r
        })
    }) : (console.error(`Invalid prop \`altText\` supplied to \`${eM}\`. Expected non-empty \`string\`.`), null)
});
ek.displayName = eM;
var eE = "ToastClose",
eO = o.forwardRef((e, r) => {
    let {
        __scopeToast: n,
        ...a
    } = e, i = eb(eE, n);
    return (0, t.jsx)(eS, {
        asChild: !0,
        children: (0, t.jsx)(G.Primitive.button, {
            type: "button",
            ...a,
            ref: r,
            onClick: (0, U.composeEventHandlers)(e.onClick, i.onClose)
        })
    })
});
eO.displayName = eE;
var eS = o.forwardRef((e, r) => {
let {
    __scopeToast: n,
    altText: a,
    ...i
} = e;
return (0, t.jsx)(G.Primitive.div, {
    "data-radix-toast-announce-exclude": "",
    "data-radix-toast-announce-alt": a || void 0,
    ...i,
    ref: r
})
});

function eI(e, t, r, {
discrete: n
}) {
let a = r.originalEvent.currentTarget,
    i = new CustomEvent(e, {
        bubbles: !0,
        cancelable: !0,
        detail: r
    });
t && a.addEventListener(e, t, {
    once: !0
}), n ? (0, G.dispatchDiscreteCustomEvent)(a, i) : a.dispatchEvent(i)
}
var eP = (e, t, r = 0) => {
let n = Math.abs(e.x),
    a = Math.abs(e.y),
    i = n > a;
return "left" === t || "right" === t ? i && n > r : !i && a > r
};

function eA(e) {
let t = document.activeElement;
return e.some(e => e === t || (e.focus(), document.activeElement !== t))
}
e.s(["Action", 0, ek, "Close", 0, eO, "Description", 0, ew, "Provider", 0, eu, "Root", 0, eg, "Title", 0, ex, "Toast", 0, eg, "ToastAction", 0, ek, "ToastClose", 0, eO, "ToastDescription", 0, ew, "ToastProvider", 0, eu, "ToastTitle", 0, ex, "ToastViewport", 0, ep, "Viewport", 0, ep, "createToastScope", 0, ei], 406450);
var eN = e.i(406450);
e.s(["Toast", 0, eN], 934993)
}]);

//# debugId=bf30d8e2-1b58-6c1e-b274-ef9b46d9a70b