;
! 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] = "6d927c24-8534-ba8c-402a-dd4e64d300b0")
    } catch (e) {}
}();
(globalThis.TURBOPACK || (globalThis.TURBOPACK = [])).push(["object" == typeof document ? document.currentScript : void 0, 168871, e => {
    "use strict";
    var t = e.i(221628),
        r = e.i(999061),
        i = e.i(525962);
    e.i(416340);
    var o = e.i(604777),
        n = e.i(93257);

    function a(e) {
        try {
            let t = JSON.stringify(e);
            return n.Buffer.from(t).toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "")
        } catch (e) {
            throw console.error("Failed to encode share data:", e), Error("Failed to encode share data", {
                cause: e
            })
        }
    }

    function s(e, t) {
        let r = new URLSearchParams({
            position: a(e)
        });
        return t ? .marketTitle && r.set("mt", t.marketTitle), t ? .marketImage && r.set("mi", t.marketImage), t ? .username && r.set("un", t.username), t ? .profileImage && r.set("pi", t.profileImage), t ? .mode && "trade" !== t.mode && r.set("cm", t.mode), `/api/og?${r.toString()}`
    }
    var l = e.i(196593),
        d = e.i(342434),
        c = e.i(463875),
        u = e.i(631222),
        m = e.i(495145),
        g = e.i(699799);

    function f(e, t, r) {
        let {
            maxHeight: i = 1 / 0,
            minFontSize: o = 14,
            maxFontSize: n = 26,
            singleLine: a = !1,
            avgCharWidthRatio: s = .58
        } = r || {}, l = o, d = n, c = o, u = e.split(" ");
        for (; l <= d;) {
            let e = Math.floor((l + d) / 2),
                r = e * s,
                o = .3 * e;
            if (a) {
                let i = 0;
                for (let e = 0; e < u.length; e++) e > 0 && (i += o), i += u[e].length * r;
                i <= t ? (c = e, l = e + 1) : d = e - 1
            } else {
                let n = 1,
                    a = 0;
                for (let e = 0; e < u.length; e++) {
                    let i = u[e].length * r,
                        s = a > 0 ? a + o + i : i;
                    s > t && a > 0 ? (n++, a = i) : a = s
                }
                n * e * 1.23 <= i && n <= 3 ? (c = e, l = e + 1) : d = e - 1
            }
        }
        return c
    }

    function h(e) {
        let i, o, n, a, s, u, g, h, p, y, x, S, I, k, C, b, v, T, M, E, P, w, A, _, O, D, U, j, B, R, L, F, N, W, $, z, q, H, Q, K, G, V, X, Y, Z, J, ee, et, er, ei = (0, r.c)(87),
            {
                position: eo,
                mode: en
            } = e,
            ea = "cashout" === (void 0 === en ? "trade" : en),
            es = parseFloat(eo.valueInit),
            el = parseFloat(eo.maxPayout),
            ed = 100 * parseFloat(eo.priceAvg),
            ec = eo.ownerUsername || "Anonymous",
            eu = ea || 0 === eo.outcomeIndex ? "#00A84D" : "#E33939",
            em = ea ? `Won on ${eo.outcome}` : eo.outcome;
        ei[0] !== eo.market ? (i = f(eo.market, 316, {
            maxHeight: 96,
            minFontSize: 14,
            maxFontSize: 26
        }), ei[0] = eo.market, ei[1] = i) : i = ei[1];
        let eg = i;
        ei[2] !== em ? (o = f(em, 200, {
            singleLine: !0,
            minFontSize: 18,
            maxFontSize: 28,
            avgCharWidthRatio: .65
        }), ei[2] = em, ei[3] = o) : o = ei[3];
        let ef = o;
        ei[4] === Symbol.for("react.memo_cache_sentinel") ? (n = {
            display: "flex",
            flexDirection: "column",
            alignItems: "center",
            justifyContent: "center",
            backgroundColor: "#1352EF",
            fontFamily: "Inter, sans-serif"
        }, ei[4] = n) : n = ei[4], ei[5] === Symbol.for("react.memo_cache_sentinel") ? (a = (0, t.jsx)("img", {
            src: d.REDEEM_BG_PATTERN_SRC,
            alt: "",
            style: {
                position: "absolute",
                width: 800,
                height: 418,
                objectFit: "cover",
                pointerEvents: "none"
            }
        }), s = {
            display: "flex",
            alignItems: "center",
            gap: 8,
            padding: "8px 12px 8px 8px",
            borderRadius: 24,
            backgroundColor: "rgba(0,0,0,0.4)",
            backdropFilter: "blur(20px)",
            position: "absolute",
            top: 16,
            left: "50%",
            transform: "translateX(-50%)"
        }, ei[5] = a, ei[6] = s) : (a = ei[5], s = ei[6]), ei[7] !== eo.ownerProfileImage || ei[8] !== eo.proxyWallet ? (u = eo.ownerProfileImage ? (0, t.jsx)("img", {
            src: eo.ownerProfileImage,
            alt: "",
            style: {
                width: 28,
                height: 28,
                borderRadius: "50%",
                objectFit: "cover"
            }
        }) : (0, t.jsx)("div", {
            style: {
                width: 28,
                height: 28,
                ...(0, c.getCircleAvatarStyles)(eo.proxyWallet || "")
            }
        }), ei[7] = eo.ownerProfileImage, ei[8] = eo.proxyWallet, ei[9] = u) : u = ei[9], ei[10] === Symbol.for("react.memo_cache_sentinel") ? (g = {
            fontWeight: 500,
            fontSize: 18,
            lineHeight: "20px",
            letterSpacing: .15,
            color: "#fff"
        }, ei[10] = g) : g = ei[10], ei[11] !== ec ? (h = (0, t.jsx)("span", {
            style: g,
            children: ec
        }), ei[11] = ec, ei[12] = h) : h = ei[12], ei[13] !== u || ei[14] !== h ? (p = (0, t.jsxs)("div", {
            style: s,
            children: [u, h]
        }), ei[13] = u, ei[14] = h, ei[15] = p) : p = ei[15], ei[16] === Symbol.for("react.memo_cache_sentinel") ? (y = {
            position: "relative",
            width: 600,
            height: 220,
            display: "flex"
        }, x = {
            display: "flex",
            backgroundColor: "#fff",
            borderRadius: 12,
            width: "100%",
            height: "100%",
            padding: 20,
            boxShadow: "0 13px 28px rgba(0,0,0,0.1), 0 50px 50px rgba(0,0,0,0.09), 0 113px 68px rgba(0,0,0,0.05)",
            overflow: "hidden"
        }, S = (0, t.jsx)("div", {
            style: {
                position: "absolute",
                left: 352,
                top: -8,
                width: 16,
                height: 16,
                borderRadius: "50%",
                backgroundColor: "#1352EF"
            }
        }), I = (0, t.jsx)("div", {
            style: {
                position: "absolute",
                left: 352,
                bottom: -8,
                width: 16,
                height: 16,
                borderRadius: "50%",
                backgroundColor: "#1352EF"
            }
        }), k = {
            display: "flex",
            flexDirection: "column",
            flex: 1,
            justifyContent: "space-between"
        }, C = {
            display: "flex",
            justifyContent: "space-between",
            alignItems: "flex-start",
            paddingRight: 18
        }, ei[16] = y, ei[17] = x, ei[18] = S, ei[19] = I, ei[20] = k, ei[21] = C) : (y = ei[16], x = ei[17], S = ei[18], I = ei[19], k = ei[20], C = ei[21]), ei[22] !== eo.icon ? (b = eo.icon ? (0, t.jsx)("img", {
            src: eo.icon,
            alt: "",
            style: {
                width: 52,
                height: 52,
                borderRadius: 12,
                objectFit: "cover"
            }
        }) : (0, t.jsx)("div", {
            style: {
                width: 52,
                height: 52,
                borderRadius: 12,
                backgroundColor: "#E5E7EB"
            }
        }), ei[22] = eo.icon, ei[23] = b) : b = ei[23], ei[24] === Symbol.for("react.memo_cache_sentinel") ? (v = (0, t.jsx)("img", {
            src: d.LOGO_IMG_SRC,
            alt: "",
            style: {
                height: 30,
                filter: "grayscale(1) brightness(0.8)"
            }
        }), ei[24] = v) : v = ei[24], ei[25] !== b ? (T = (0, t.jsxs)("div", {
            style: C,
            children: [b, v]
        }), ei[25] = b, ei[26] = T) : T = ei[26], ei[27] !== eg ? (M = {
            fontWeight: 500,
            fontSize: eg,
            lineHeight: "1.23em",
            letterSpacing: "-0.02em",
            color: "#000",
            margin: 0,
            maxWidth: 316,
            maxHeight: 96,
            overflow: "hidden"
        }, ei[27] = eg, ei[28] = M) : M = ei[28], ei[29] !== eo.market || ei[30] !== M ? (E = (0, t.jsx)("h3", {
            style: M,
            children: eo.market
        }), ei[29] = eo.market, ei[30] = M, ei[31] = E) : E = ei[31], ei[32] !== T || ei[33] !== E ? (P = (0, t.jsxs)("div", {
            style: k,
            children: [T, E]
        }), ei[32] = T, ei[33] = E, ei[34] = P) : P = ei[34], ei[35] === Symbol.for("react.memo_cache_sentinel") ? (w = (0, t.jsx)("div", {
            style: {
                width: 1,
                height: 180,
                borderLeft: "1px dashed #000",
                opacity: .2,
                position: "absolute",
                left: 360,
                top: 20
            }
        }), A = {
            width: 220,
            display: "flex",
            flexDirection: "column",
            justifyContent: "space-between",
            position: "relative",
            paddingLeft: 20
        }, ei[35] = w, ei[36] = A) : (w = ei[35], A = ei[36]), ei[37] !== eu || ei[38] !== ef ? (_ = {
            fontWeight: 500,
            fontSize: ef,
            lineHeight: "1.33em",
            letterSpacing: "-0.01em",
            color: eu,
            whiteSpace: "nowrap",
            overflow: "hidden",
            textOverflow: "ellipsis",
            maxWidth: 200
        }, ei[37] = eu, ei[38] = ef, ei[39] = _) : _ = ei[39], ei[40] !== em || ei[41] !== _ ? (O = (0, t.jsx)("div", {
            style: _,
            children: em
        }), ei[40] = em, ei[41] = _, ei[42] = O) : O = ei[42], ei[43] === Symbol.for("react.memo_cache_sentinel") ? (D = {
            display: "flex",
            flexDirection: "column",
            gap: 8
        }, U = {
            display: "flex",
            justifyContent: "space-between",
            alignItems: "center"
        }, j = (0, t.jsx)("span", {
            style: {
                color: "#000",
                opacity: .4,
                fontWeight: 500,
                fontSize: 14,
                lineHeight: "20px"
            },
            children: "Cost"
        }), B = {
            color: "#000",
            fontWeight: 500,
            fontSize: 14,
            lineHeight: "20px"
        }, ei[43] = D, ei[44] = U, ei[45] = j, ei[46] = B) : (D = ei[43], U = ei[44], j = ei[45], B = ei[46]), ei[47] !== es ? (R = (0, l.formatNumbers)(es.toString()), ei[47] = es, ei[48] = R) : R = ei[48], ei[49] !== R ? (L = (0, t.jsxs)("div", {
            style: U,
            children: [j, (0, t.jsxs)("span", {
                style: B,
                children: ["$", R]
            })]
        }), ei[49] = R, ei[50] = L) : L = ei[50], ei[51] === Symbol.for("react.memo_cache_sentinel") ? (F = {
            display: "flex",
            justifyContent: "space-between",
            alignItems: "center"
        }, N = (0, t.jsx)("span", {
            style: {
                color: "#000",
                opacity: .4,
                fontWeight: 500,
                fontSize: 14,
                lineHeight: "20px"
            },
            children: "Odds"
        }), W = {
            color: "#000",
            fontWeight: 500,
            fontSize: 14,
            lineHeight: "20px"
        }, ei[51] = F, ei[52] = N, ei[53] = W) : (F = ei[51], N = ei[52], W = ei[53]), ei[54] !== ed ? ($ = Number.isFinite(ed) ? ed.toFixed(0) : "0", ei[54] = ed, ei[55] = $) : $ = ei[55], ei[56] !== $ ? (z = (0, t.jsxs)("div", {
            style: F,
            children: [N, (0, t.jsxs)("span", {
                style: W,
                children: [$, "%"]
            })]
        }), ei[56] = $, ei[57] = z) : z = ei[57], ei[58] !== L || ei[59] !== z ? (q = (0, t.jsxs)("div", {
            style: D,
            children: [L, z]
        }), ei[58] = L, ei[59] = z, ei[60] = q) : q = ei[60], ei[61] === Symbol.for("react.memo_cache_sentinel") ? (H = (0, t.jsx)("div", {
            style: {
                width: "100%",
                borderTop: "1.5px dashed #000",
                opacity: .2
            }
        }), Q = {
            display: "flex",
            flexDirection: "column",
            gap: 4
        }, K = {
            color: "#000",
            fontWeight: 500,
            fontSize: 14,
            lineHeight: "20px"
        }, ei[61] = H, ei[62] = Q, ei[63] = K) : (H = ei[61], Q = ei[62], K = ei[63]);
        let eh = ea ? "Cashed Out" : "To win";
        ei[64] !== eh ? (G = (0, t.jsx)("span", {
            style: K,
            children: eh
        }), ei[64] = eh, ei[65] = G) : G = ei[65];
        let ep = ea ? "#27AE60" : "#000";
        return ei[66] !== ep ? (V = {
            color: ep,
            fontWeight: 500,
            fontSize: 32,
            lineHeight: "40px",
            letterSpacing: "-0.03em"
        }, ei[66] = ep, ei[67] = V) : V = ei[67], ei[68] !== el ? (X = (0, l.formatNumbers)(el.toString()), ei[68] = el, ei[69] = X) : X = ei[69], ei[70] !== V || ei[71] !== X ? (Y = (0, t.jsxs)("span", {
            style: V,
            children: ["$", X]
        }), ei[70] = V, ei[71] = X, ei[72] = Y) : Y = ei[72], ei[73] !== G || ei[74] !== Y ? (Z = (0, t.jsxs)("div", {
            style: Q,
            children: [G, Y]
        }), ei[73] = G, ei[74] = Y, ei[75] = Z) : Z = ei[75], ei[76] !== O || ei[77] !== q || ei[78] !== Z ? (J = (0, t.jsxs)("div", {
            style: A,
            children: [O, q, H, Z]
        }), ei[76] = O, ei[77] = q, ei[78] = Z, ei[79] = J) : J = ei[79], ei[80] !== P || ei[81] !== J ? (ee = (0, t.jsx)("div", {
            style: y,
            children: (0, t.jsxs)("div", {
                style: x,
                children: [S, I, P, w, J]
            })
        }), ei[80] = P, ei[81] = J, ei[82] = ee) : ee = ei[82], ei[83] === Symbol.for("react.memo_cache_sentinel") ? (et = (0, t.jsx)("img", {
            src: d.LOGO_IMG_SRC,
            alt: "",
            style: {
                position: "absolute",
                bottom: 16,
                left: "50%",
                transform: "translateX(-50%)",
                height: 48,
                filter: "brightness(0) invert(1)"
            }
        }), ei[83] = et) : et = ei[83], ei[84] !== p || ei[85] !== ee ? (er = (0, t.jsxs)(m.ScaledCardCanvas, {
            innerStyle: n,
            children: [a, p, ee, et]
        }), ei[84] = p, ei[85] = ee, ei[86] = er) : er = ei[86], er
    }
    e.s(["default", 0, function(e) {
        let n, l, d, c, m, f, p, y, x, S, I = (0, r.c)(38),
            {
                open: k,
                onOpenChange: C,
                sharePosition: b,
                thirdPartyShare: v,
                mode: T
            } = e,
            M = void 0 === T ? "trade" : T,
            E = (0, o.useTranslations)();
        if (I[0] !== M || I[1] !== b) n = b.proxyWallet ? s({
            proxyWallet: b.proxyWallet,
            marketSlug: b.slug,
            outcome: b.outcome,
            outcomeIndex: b.outcomeIndex,
            betAmount: b.valueInit,
            toWin: b.maxPayout,
            avgPrice: b.priceAvg
        }, {
            marketTitle: b.market,
            marketImage: b.icon,
            username: b.ownerUsername,
            profileImage: b.ownerProfileImage,
            mode: M
        }) : null, I[0] = M, I[1] = b, I[2] = n;
        else n = I[2];
        let P = n;
        e: {
            let e, t;
            if (!b.proxyWallet) {
                l = "";
                break e
            }
            if (I[3] !== b.maxPayout || I[4] !== b.outcome || I[5] !== b.outcomeIndex || I[6] !== b.priceAvg || I[7] !== b.proxyWallet || I[8] !== b.slug || I[9] !== b.valueInit) {
                let r = {
                    proxyWallet: b.proxyWallet,
                    marketSlug: b.slug,
                    outcome: b.outcome,
                    outcomeIndex: b.outcomeIndex,
                    betAmount: b.valueInit,
                    toWin: b.maxPayout,
                    avgPrice: b.priceAvg
                };
                e = u.CURRENT_ORIGIN, t = a(r), I[3] = b.maxPayout, I[4] = b.outcome, I[5] = b.outcomeIndex, I[6] = b.priceAvg, I[7] = b.proxyWallet, I[8] = b.slug, I[9] = b.valueInit, I[10] = e, I[11] = t
            } else e = I[10],
            t = I[11];l = `${e}/share/${t}`
        }
        let w = l;
        I[12] !== M || I[13] !== E || I[14] !== v ? (d = E("cashout" === M ? "shareCards.cashoutTweetText" : v ? "shareCards.thirdPartyTradeTweetText" : "shareCards.ownTradeTweetText"), I[12] = M, I[13] = E, I[14] = v, I[15] = d) : d = I[15];
        let A = d;
        return I[16] !== M || I[17] !== E ? (c = E("cashout" === M ? "shareCards.shareWin" : "shareCards.shareTrade"), I[16] = M, I[17] = E, I[18] = c) : c = I[18], I[19] !== c ? (m = (0, t.jsx)(i.ModalHeader, {
            children: (0, t.jsx)(i.ModalTitle, {
                children: c
            })
        }), I[19] = c, I[20] = m) : m = I[20], I[21] !== M || I[22] !== b ? (f = (0, t.jsx)("div", {
            className: "w-full",
            children: (0, t.jsx)(h, {
                position: b,
                mode: M
            })
        }), I[21] = M, I[22] = b, I[23] = f) : f = I[23], I[24] !== P || I[25] !== w || I[26] !== A ? (p = (0, t.jsx)(g.default, {
            shareUrl: w,
            ogImageUrl: P,
            tweetText: A
        }), I[24] = P, I[25] = w, I[26] = A, I[27] = p) : p = I[27], I[28] !== f || I[29] !== p ? (y = (0, t.jsxs)("div", {
            className: "flex flex-col items-center gap-4",
            children: [f, p]
        }), I[28] = f, I[29] = p, I[30] = y) : y = I[30], I[31] !== m || I[32] !== y ? (x = (0, t.jsxs)(i.ModalContent, {
            children: [m, y]
        }), I[31] = m, I[32] = y, I[33] = x) : x = I[33], I[34] !== C || I[35] !== k || I[36] !== x ? (S = (0, t.jsx)(i.Modal, {
            open: k,
            onOpenChange: C,
            children: x
        }), I[34] = C, I[35] = k, I[36] = x, I[37] = S) : S = I[37], S
    }, "prefetchShareImage", 0, function(e, t, r) {
        let i = {
            proxyWallet: t,
            marketSlug: e.slug,
            outcome: e.outcome,
            outcomeIndex: e.outcomeIndex,
            betAmount: e.valueInit,
            toWin: e.maxPayout,
            avgPrice: e.priceAvg
        };
        new Image().src = s(i, {
            marketTitle: e.market,
            marketImage: e.icon,
            ...r
        })
    }], 168871)
}, 373898, e => {
    "use strict";
    var t = e.i(318594),
        r = e.i(416340),
        i = e.i(249792),
        o = e.i(606572),
        n = e.i(510954),
        a = e.i(57096),
        s = e.i(527084),
        l = e.i(502980),
        d = e.i(72458),
        c = e.i(817686),
        u = e.i(784521),
        m = e.i(400819),
        g = e.i(660006),
        f = e.i(209246);
    e.s(["default", 0, () => {
        let e = (0, i.useToast)(),
            {
                proxyAddress: h
            } = (0, u.useAccountContext)(["proxyAddress"]),
            p = (0, m.useClob)(),
            y = (0, t.useQueryClient)(),
            {
                setApiErrorMessage: x,
                getApiCredential: S
            } = (0, m.useClobCredentialContext)(),
            I = (0, f.useMutatePositionMarkets)(),
            k = (0, f.useGetCachedPositionMarket)(),
            C = (0, d.useRecoverClobClient)();
        return (0, r.useCallback)(async (t, r, i) => {
            let d = (0, l.getOrderToastPosition)();
            if (!p) return (0, g.handleError)(Error("CLOB client not available"), "cancel_order_no_clob", h, "medium", {
                orderId: t.orderID,
                tokenId: t.tokenID,
                marketId: t.market
            }), null;
            x(null);
            try {
                let l;
                I({
                    market: (0, s.convertMarketToPartialPositionMarket)(r)
                });
                let u = async e => e.cancelOrder({
                        orderID: t.orderID
                    }),
                    m = async () => {
                        let e = await C();
                        if (!e) throw Error("Unable to refresh API credentials");
                        let t = await u(e);
                        if ((0, c.isClobAuthError)(t)) throw Error("Unable to refresh API credentials");
                        return t
                    };
                try {
                    l = await u(p)
                } catch (e) {
                    if (!(0, c.isClobAuthError)(e)) throw e;
                    l = await m()
                }(0, c.isClobAuthError)(l) && (l = await m());
                let g = "canceled" in l && l.canceled.includes(t.orderID),
                    f = h ? S(h) ? .key : void 0;
                return f && g && (y.setQueryData(n.queryKeys[a.QueryKey.OpenOrders].apiKey(f).queryKey, e => (Array.isArray(e) ? e : []).filter(e => e ? .orderID !== t.orderID)), y.invalidateQueries({
                    queryKey: n.queryKeys[a.QueryKey.OpenOrderScoring].tokenId(t.tokenID).queryKey
                })), i || (g ? e.success(new o.ToastBuilder().position({
                    side: d
                }).title("Order cancelled").description(k(h, void 0, t.tokenID, t.market) ? .question ? ? "")) : "not_canceled" in l && "string" == typeof l.not_canceled ? .[t.orderID] ? e.error(new o.ToastBuilder().position({
                    side: d
                }).title("Error cancelling order").description(k(h, void 0, t.tokenID, t.market) ? .question ? ? "").subtext(l.not_canceled[t.orderID])) : e.error(new o.ToastBuilder().position({
                    side: d
                }).title("Error cancelling order").description(k(h, void 0, t.tokenID, t.market) ? .question ? ? "").subtext(JSON.stringify(l)))), l
            } catch (r) {
                return (0, g.handleError)(r, "cancel_order_error", h, "high", {
                    orderId: t.orderID,
                    tokenId: t.tokenID,
                    marketId: t.market,
                    marketInfo: {
                        question: k(h, void 0, t.tokenID, t.market) ? .question
                    },
                    orderDetails: {
                        outcome: t.outcome,
                        side: t.side,
                        price: t.price,
                        size: t.originalSize
                    },
                    suppressToast: i
                }), x(String(r)), i || e.error(new o.ToastBuilder().position({
                    side: d
                }).title("Error cancelling order").description(k(h, void 0, t.tokenID, t.market) ? .question ? ? "").subtext(r ? .message ? ? "unknown error")), null
            }
        }, [p, x, e, k, h, I, C])
    }])
}, 294472, e => {
    "use strict";
    let t = e => 1e3 * ("string" == typeof e ? Number(e) : e),
        r = (e, t, r = !0, i = {}) => {
            if (!e) return i.untilCancelled;
            let o = e - t;
            if (o < 0) return i.dateInPast;
            let n = 0,
                a = "",
                s = "";
            o < 6e4 ? (n = Math.round(o / 1e3), a = i.second, s = i.seconds) : o < 36e5 ? (n = Math.round(o / 6e4), a = i.minute, s = i.minutes) : o < 864e5 ? (n = Math.round(o / 36e5), a = i.hour, s = i.hours) : o < 2592e6 ? (n = Math.round(o / 864e5), a = i.day, s = i.days) : o < 31536e6 ? (n = Math.round(o / 2592e6), a = i.month, s = i.months) : (n = Math.round(o / 31536e6), a = i.year, s = i.years);
            let l = n > 1 ? s : a;
            return `${r?`${i.in} `:""}${n} ${l}`
        },
        i = e => ({
            d: Math.floor(e / 864e5),
            h: Math.floor(e % 864e5 / 36e5),
            m: Math.floor(e % 36e5 / 6e4),
            s: Math.floor(e % 6e4 / 1e3)
        });
    e.s(["formatShortCountdown", 0, function(e, t, r) {
        if (e <= 0) return `0${t.s}`;
        let {
            d: o,
            h: n,
            m: a,
            s
        } = i(1e3 * e);
        return o > 0 ? `${o}${t.d} ${n}${t.h}` : n > 0 ? r ? .includeSeconds ? `${n}${t.h} ${a}${t.m} ${s}${t.s}` : `${n}${t.h} ${a}${t.m}` : `${a}${t.m} ${s}${t.s}`
    }, "fromDateToUnix", 0, e => Math.round(e.getTime() / 1e3), "fromPossibleUnixToRelativeTime", 0, (e, i = !0, o = {}) => r((e => {
        if (e) return t(e)
    })(e), Date.now(), i, o), "fromUnixToMs", 0, t, "getRelativeTime", 0, r, "getTimeBreakdown", 0, i])
}, 632227, e => {
    "use strict";
    var t = e.i(221628),
        r = e.i(999061),
        i = e.i(23128),
        o = e.i(169010),
        n = e.i(208956),
        a = e.i(501527),
        s = e.i(44326),
        l = e.i(604777),
        d = e.i(631222);
    e.s(["default", 0, e => {
        let c, u, m, g, f, h, p, y, x, S = (0, r.c)(21),
            {
                shouldLeftAlign: I,
                className: k
            } = e,
            C = (0, l.useTranslations)(),
            b = `flex items-center gap-2 w-full h-[44px] py-3 px-6 rounded-md text-base text-red-400 bg-red-50 cursor-not-allowed hover:bg-red-50 ${k??""}`;
        S[0] === Symbol.for("react.memo_cache_sentinel") ? (c = (0, t.jsx)(a.IconGlobe2Fill18, {
            className: "size-5"
        }), S[0] = c) : c = S[0], S[1] !== C ? (u = C("trading.geoRestrictions.restrictedRegion"), S[1] = C, S[2] = u) : u = S[2], S[3] !== b || S[4] !== u ? (m = (0, t.jsx)(o.TooltipTrigger, {
            asChild: !0,
            children: (0, t.jsxs)(i.Button, {
                className: b,
                children: [c, "  ", u]
            })
        }), S[3] = b, S[4] = u, S[5] = m) : m = S[5];
        let v = `py-2 ${I?"text-left":""}`;
        return S[6] !== C ? (g = C("trading.geoRestrictions.tradingUnavailableInRegion"), S[6] = C, S[7] = g) : g = S[7], S[8] !== g ? (f = (0, t.jsx)("p", {
            children: g
        }), S[8] = g, S[9] = f) : f = S[9], S[10] !== C ? (h = C("trading.geoRestrictions.availableRegions"), S[10] = C, S[11] = h) : h = S[11], S[12] !== h ? (p = (0, t.jsx)(n.default, {
            href: `${d.POLYMARKET_DOCS_LINK}/api-reference/geoblock#blocked-countries`,
            target: "_blank",
            rel: "noopener noreferrer",
            className: "underline text-brand-500 hover:opacity-80",
            children: h
        }), S[12] = h, S[13] = p) : p = S[13], S[14] !== v || S[15] !== f || S[16] !== p ? (y = (0, t.jsxs)(o.TooltipContent, {
            side: "top",
            align: "center",
            sideOffset: 12,
            className: v,
            children: [f, p]
        }), S[14] = v, S[15] = f, S[16] = p, S[17] = y) : y = S[17], S[18] !== y || S[19] !== m ? (x = (0, t.jsx)(o.TooltipProvider, {
            children: (0, t.jsxs)(s.Tooltip.Root, {
                children: [m, y]
            })
        }), S[18] = y, S[19] = m, S[20] = x) : x = S[20], x
    }])
}, 949447, e => {
    "use strict";
    var t = e.i(416340),
        r = e.i(197994);
    e.s(["IconChevronDownFill18", 0, ({ ...e
    }) => t.default.createElement(r.Icon, {
        size: "18px",
        ...e
    }, t.default.createElement("path", {
        d: "M9,13.5c-.192,0-.384-.073-.53-.22L2.22,7.03c-.293-.293-.293-.768,0-1.061s.768-.293,1.061,0l5.72,5.72,5.72-5.72c.293-.293,.768-.293,1.061,0s.293,.768,0,1.061l-6.25,6.25c-.146,.146-.338,.22-.53,.22Z",
        fill: "currentColor"
    }))])
}, 430849, e => {
    "use strict";
    var t = e.i(999061);
    e.i(416340);
    var r = e.i(269101),
        i = e.i(196593);

    function o(e, t) {
        return 0 === parseInt(t.outcomeIndex, 10) && (t.trackedPositionMetadata ? e[0] = e[0] + t.trackedPositionMetadata.netQuantity.optimistic : e[0] = e[0] + parseFloat((0, i.formatUSDCUnits)(BigInt(t.netQuantity)))), 1 === parseInt(t.outcomeIndex, 10) && (t.trackedPositionMetadata ? e[1] = e[1] + t.trackedPositionMetadata.netQuantity.optimistic : e[1] = e[1] + parseFloat((0, i.formatUSDCUnits)(BigInt(t.netQuantity)))), e
    }

    function n(e) {
        return Math.max(e, 0)
    }
    e.s(["default", 0, e => {
        let i, a, s = (0, t.c)(6);
        s[0] === Symbol.for("react.memo_cache_sentinel") ? (i = ["positions"], s[0] = i) : i = s[0];
        let {
            positions: l
        } = (0, r.useEventPositionsContext)(i);
        if (s[1] !== e || s[2] !== l) {
            let t;
            s[4] !== e ? (t = t => t.market.id.toLowerCase() === e.toLowerCase(), s[4] = e, s[5] = t) : t = s[5], a = (l ? ? []).filter(t).reduce(o, [0, 0]).map(n), s[1] = e, s[2] = l, s[3] = a
        } else a = s[3];
        return a
    }])
}, 732799, e => {
    "use strict";
    var t = e.i(221628),
        r = e.i(999061),
        i = e.i(416340),
        o = e.i(567692),
        n = e.i(339393),
        a = e.i(832655),
        a = a,
        s = e.i(964063),
        l = e.i(328113),
        d = e.i(784521),
        c = e.i(399841),
        u = e.i(695097),
        m = e.i(488549),
        g = e.i(318594),
        f = e.i(552470),
        h = e.i(429411),
        p = e.i(510954),
        y = e.i(57096),
        x = e.i(53950);

    function S(e) {
        return f.proxy(e)
    }
    let I = {
            error: 5,
            warn: 4,
            info: 3,
            debug: 0
        },
        k = I.error,
        C = 0,
        b = i.default.createContext({});
    e.s(["MarketWsContextProvider", 0, e => {
        let f, v, T = (0, r.c)(7),
            {
                children: M,
                markets: E
            } = e,
            {
                connectionState: P,
                resetConnection: w
            } = (e => {
                let t, f, b, v, T, M, E, P, w, A, _, O, D, U, j, B = (0, n.useDeferredMounted)({
                        wait: 2e3
                    }),
                    R = i.default.useRef(null),
                    L = i.default.useRef(null),
                    [F, N] = i.default.useState({
                        subscribedAssetIds: new Set,
                        connected: !1,
                        status: "uninstantiated",
                        readyState: -1
                    }),
                    {
                        authenticated: W
                    } = (0, d.useAccountContext)(["authenticated"]),
                    $ = (0, c.useFeatureFlag)("authenticated_book_ws"),
                    z = i.default.useMemo(() => !$ || W && $, [W, $]),
                    {
                        bookWorkerReady: q,
                        bookWorkerApiRef: H,
                        bookWorkerSetup: Q,
                        setBookWorkerSetup: K,
                        resetBookWorker: G
                    } = (0, u.useBooksContext)(),
                    V = (0, o.useBooksStore)(e => e.applySnapshot),
                    X = (0, s.useDocumentVisibility)(),
                    Y = S((e, t, r) => {
                        if (I[e] >= k) switch (e) {
                            case "error":
                                x.logger.error(t, r);
                                break;
                            case "warn":
                                x.logger.warn(t, r);
                                break;
                            case "info":
                                x.logger.info(t, r);
                                break;
                            default:
                                x.logger.debug(t, r)
                        }
                    }),
                    Z = (f = (0, r.c)(2), b = (0, o.useBoundBookStore)(), f[0] !== b ? (t = e => {
                        b.getState().applyConnectionStatusChanges(e.assetIds.map(t => ({
                            assetId: t,
                            status: e.status
                        })))
                    }, f[0] = b, f[1] = t) : t = f[1], t),
                    J = (e => {
                        let t, i, o = (0, r.c)(5),
                            {
                                setStatus: n
                            } = e,
                            a = (0, g.useQueryClient)();
                        o[0] !== a || o[1] !== n ? (t = e => {
                            if (n(e), "connected" === e.status) {
                                let e = Date.now();
                                if (e - C < 5e3) return void x.logger.info("[useBookWebsocketCallbacks > onWebsocketStateChange > throttled]", {
                                    msSinceLastInvalidation: e - C
                                });
                                C = e, a.invalidateQueries({
                                    queryKey: p.queryKeys[y.QueryKey.Positions].liquidity._def
                                }), a.invalidateQueries({
                                    queryKey: p.queryKeys[y.QueryKey.LimitOrderHistory]._def
                                }), a.invalidateQueries({
                                    queryKey: p.queryKeys[y.QueryKey.MarketOrderHistory]._def
                                }), a.invalidateQueries({
                                    queryKey: p.queryKeys[y.QueryKey.TradeHistory]._def
                                })
                            }
                        }, o[0] = a, o[1] = n, o[2] = t) : t = o[2];
                        let s = t,
                            l = (0, h.useCallbackRef)(s);
                        return o[3] !== l ? (i = S(l), o[3] = l, o[4] = i) : i = o[4], i
                    })({
                        setStatus: N
                    }),
                    ee = (M = (0, r.c)(4), E = (0, o.useBoundBookStore)(), M[0] !== E ? (v = e => {
                        E.getState().applyEvents(e)
                    }, M[0] = E, M[1] = v) : v = M[1], P = v, w = (0, h.useCallbackRef)(P), M[2] !== w ? (T = S(w), M[2] = w, M[3] = T) : T = M[3], T),
                    et = (O = (0, r.c)(4), D = (0, o.useBoundBookStore)(), O[0] !== D ? (A = e => {
                        D.getState().applyFetchStatusChanges(e)
                    }, O[0] = D, O[1] = A) : A = O[1], U = A, j = (0, h.useCallbackRef)(U), O[2] !== j ? (_ = S(j), O[2] = j, O[3] = _) : _ = O[3], _),
                    er = (0, l.useLatest)(e),
                    ei = i.default.useMemo(() => {
                        try {
                            return e.map(e => (0, m.getAssetId)(e)).filter(Boolean).sort().join(",")
                        } catch {
                            return String(e.length)
                        }
                    }, [e]),
                    eo = i.default.useCallback(async e => {
                        if (H.current)
                            for (let t = 0; t < e.length; t++) {
                                let r = e[t].toLowerCase();
                                try {
                                    let e = await H.current.project({
                                        assetId: r
                                    });
                                    e ? .status === "success" && e ? .data && V(r, e.data, "snapshot")
                                } catch {}
                            }
                    }, [H, V]),
                    en = i.default.useCallback(async (e, t = !1) => {
                        H.current && (Z({
                            assetIds: e.map(e => (0, m.getAssetId)(e)),
                            status: "connecting"
                        }), await H.current ? .subscribe({
                            mode: "markets",
                            markets: e,
                            reset: t
                        }))
                    }, []),
                    {
                        run: ea
                    } = (0, a.default)(en, {
                        wait: 10,
                        trailing: !0
                    }),
                    es = i.default.useCallback(async () => {
                        H.current && (H.current.onBookEvents = ee, H.current.logger = Y, H.current.onWebsocketStateChange = J, H.current.onFetchStatusChange = et, await H.current.initialize())
                    }, [H, ee, Y, J, et]),
                    el = i.default.useCallback(async (e = !1) => {
                        H.current && "error" === (await H.current.keepAlive(e)).status && G()
                    }, [G]),
                    ed = i.default.useCallback(() => {
                        R.current && clearInterval(R.current), L.current && clearInterval(L.current)
                    }, []),
                    ec = i.default.useCallback(() => {
                        ed(), R.current = setInterval(() => el(!0), 3e4), L.current = setInterval(() => el(!1), 5e3)
                    }, [el]),
                    eu = i.default.useCallback(async () => {
                        H.current && (await es(), await ea(er.current), await eo(er.current.map(e => (0, m.getAssetId)(e))), ec(), K(!0))
                    }, [es, ea, eo, K]),
                    em = i.default.useCallback(async () => {
                        G()
                    }, [G]),
                    eg = i.default.useCallback(async () => {
                        if (H.current) {
                            let e = await H.current.getState();
                            e ? .transportState ? .connected && er.current.length ? await H.current.resume({
                                mode: "markets",
                                markets: er.current
                            }) : em(), ec()
                        }
                    }, [H, er, em, ec]),
                    ef = i.default.useCallback(async () => {
                        H.current && (await H.current.pause(), ed())
                    }, [H]);
                return i.default.useEffect(() => {
                    q && !Q && H.current && eu()
                }, [q]), i.default.useEffect(() => {
                    Q && z && H.current && (H.current.update({
                        mode: "markets",
                        markets: er.current
                    }), eo(er.current.map(e => (0, m.getAssetId)(e))))
                }, [ei]), i.default.useEffect(() => {
                    B && z && H.current && ("visible" === X ? eg() : "hidden" === X && ef())
                }, [X]), i.default.useEffect(() => () => {
                    ed()
                }, []), {
                    connectionState: F,
                    resetConnection: em
                }
            })(E);
        T[0] !== P || T[1] !== E || T[2] !== w ? (f = {
            connectionState: P,
            resetConnection: w,
            markets: E
        }, T[0] = P, T[1] = E, T[2] = w, T[3] = f) : f = T[3];
        let A = f;
        return T[4] !== M || T[5] !== A ? (v = (0, t.jsx)(b.Provider, {
            value: A,
            children: M
        }), T[4] = M, T[5] = A, T[6] = v) : v = T[6], v
    }, "useMarketWsContext", 0, () => i.default.useContext(b)], 732799)
}, 845923, e => {
    "use strict";
    var t = e.i(502980),
        r = e.i(631222),
        i = e.i(660006),
        o = e.i(196593),
        n = e.i(866192),
        a = e.i(450091);
    let s = BigInt(r.SELL_MAX_DUST),
        l = (e, r) => {
            try {
                let i = (0, t.augmentTrackedPositionOptimistically)(r),
                    s = (0, a.getAveragePricePerShare)(i),
                    l = (0, a.getCurrentSharePrice)(i),
                    d = (0, a.getCurrentValueOfPosition)(i);
                return {
                    icon: e.image,
                    market: e.question.toString(),
                    isClosed: e.closed || !1,
                    outcome: (0, n.outcomeNameFromIndex)(e, parseInt(r.outcomeIndex, 10)),
                    slug: e.slug,
                    eslug: e.events ? .length ? e.events[0].slug : void 0,
                    outcomeIndex: parseInt(i.outcomeIndex, 10),
                    qty: i.trackedPositionMetadata ? Math.max(i.trackedPositionMetadata.netQuantity.optimistic, 0).toString() : (0, o.formatUSDCUnits)(BigInt(i.netQuantity)),
                    priceAvg: s.toString(),
                    priceCurr: l.toString(),
                    currentMarketValue: (0, o.formatUSDCUnits)(d),
                    valueInit: (0, o.formatUSDCUnits)((0, a.getValuePaidForShares)(i)),
                    positive: s < l,
                    nearAvgPrice: .04 > Math.abs(s - l),
                    totalProfit: (0, o.formatUSDCUnits)((0, a.getTotalProfit)(i)),
                    totalProfitPercent: (0, a.getProfitPercent)(i, !0).toString(),
                    realizedProfit: i.trackedPositionMetadata ? i.trackedPositionMetadata.realizedProfit.optimistic.toString() : (0, o.formatUSDCUnits)(BigInt(i.realizedProfit)),
                    profit: (0, o.formatUSDCUnits)((0, a.getCurrentProfit)(i)),
                    loss: (0, a.getProfitPercent)(i).toString(),
                    maxPayout: (0, o.formatUSDCUnits)(BigInt(i.netQuantity)),
                    isPending: i.isPending,
                    groupItemTitle: e.groupItemTitle ? ? "",
                    originalPosition: r
                }
            } catch (e) {
                throw (0, i.handleError)(e, "fromPositionToPortfolioItem"), e
            }
        },
        d = e => {
            try {
                if (e.isPending) {
                    let t = "originalPosition" in e ? e.originalPosition ? .trackedPositionMetadata ? .netQuantity ? .pending : void 0,
                        r = "originalPosition" in e ? e.originalPosition ? .trackedPositionMetadata ? .netQuantity ? .optimistic : void 0;
                    if ("number" == typeof t && t <= 0 && "number" == typeof r && r < .5) return !1;
                    return !0
                }
                let t = Number(10 n ** BigInt(r.USDC_DECIMALS)),
                    i = Number(e.qty) * t,
                    o = Math.round(i);
                return BigInt(o) >= BigInt(Math.round(r.SELL_MAX_DUST * r.DUST_DISPLAY_FACTOR))
            } catch (e) {
                return (0, i.handleError)(e, "filterSharesQty"), !0
            }
        };
    e.s(["filterSharesQty", 0, d, "fromChainToPortfolioItem", 0, (e, t) => {
        try {
            let r = (0, a.getCurrentValueOfPosition)(t),
                i = (0, a.getCurrentSharePrice)(t);
            return {
                icon: e.image,
                market: e.question.toString(),
                isClosed: e.closed || !1,
                outcomeIndex: parseInt(t.outcomeIndex, 10),
                outcome: (0, n.outcomeNameFromIndex)(e, parseInt(t.outcomeIndex, 10)),
                slug: e.events ? .length > 1 ? `${e.events[0].slug}/${e.slug}` : e.slug,
                priceCurr: i.toString(),
                qty: (0, o.formatUSDCUnits)(BigInt(t.netQuantity) - s),
                currentMarketValue: (0, o.formatUSDCUnits)(r),
                maxPayout: (0, o.formatUSDCUnits)(BigInt(t.netQuantity))
            }
        } catch (e) {
            throw (0, i.handleError)(e, "fromChainToPortfolioItem"), e
        }
    }, "fromPositionToPortfolioInjectedPrices", 0, (e, t, r, n, a) => {
        if (!e || !Array.isArray(t) || 0 === t.length) return [];
        try {
            return t.filter(t => t ? .market ? .id ? .toLowerCase() === e ? .conditionId ? .toLowerCase()).map(e => r && n.every(e => Number.isFinite(e)) ? { ...e,
                market: { ...e.market,
                    outcomeTokenPrices: n.map(e => e.toString())
                }
            } : e).map(t => l(e, t)).map(e => a ? ((e, t) => {
                try {
                    let r = e ? .[t ? .outcomeIndex] ? ? 0 n;
                    return { ...t,
                        qty: (0, o.formatUSDCUnits)(r).toString()
                    }
                } catch {
                    return t
                }
            })(a, e) : e).filter(d)
        } catch (e) {
            return (0, i.handleError)(e, "fromPositionToPortfolioItemsUsingInjectedPrices"), []
        }
    }, "fromPositionToPortfolioItem", 0, l])
}, 119738, e => {
    "use strict";
    var t = e.i(221628),
        r = e.i(999061),
        i = e.i(23128),
        o = e.i(525962),
        n = e.i(604777);
    e.s(["CancelOrdersConfirmModal", 0, function(e) {
        let a, s, l, d, c, u, m, g, f, h, p, y, x, S = (0, r.c)(36),
            {
                open: I,
                onOpenChange: k,
                orderCount: C,
                onConfirm: b
            } = e,
            v = (0, n.useTranslations)();
        return S[0] !== C || S[1] !== v ? (a = 1 === C ? v("orders.cancelOneOpenOrder") : v("orders.cancelNOpenOrders", {
            count: String(C)
        }), S[0] = C, S[1] = v, S[2] = a) : a = S[2], S[3] !== a ? (s = (0, t.jsx)(o.ModalTitle, {
            children: a
        }), S[3] = a, S[4] = s) : s = S[4], S[5] !== v ? (l = v("orders.cannotBeUndone"), S[5] = v, S[6] = l) : l = S[6], S[7] !== l ? (d = (0, t.jsx)(o.ModalDescription, {
            children: l
        }), S[7] = l, S[8] = d) : d = S[8], S[9] !== k ? (c = () => k(!1), S[9] = k, S[10] = c) : c = S[10], S[11] !== v ? (u = v("auth.back"), S[11] = v, S[12] = u) : u = S[12], S[13] !== c || S[14] !== u ? (m = (0, t.jsx)(i.Button, {
            variant: "outline",
            onClick: c,
            children: u
        }), S[13] = c, S[14] = u, S[15] = m) : m = S[15], S[16] !== b || S[17] !== k ? (g = () => {
            b(), k(!1)
        }, S[16] = b, S[17] = k, S[18] = g) : g = S[18], S[19] !== C || S[20] !== v ? (f = 1 === C ? v("orders.cancelOneOrder") : v("orders.cancelNOrders", {
            count: String(C)
        }), S[19] = C, S[20] = v, S[21] = f) : f = S[21], S[22] !== g || S[23] !== f ? (h = (0, t.jsx)(i.Button, {
            variant: "destructive",
            onClick: g,
            children: f
        }), S[22] = g, S[23] = f, S[24] = h) : h = S[24], S[25] !== h || S[26] !== m ? (p = (0, t.jsxs)(o.ModalFooter, {
            children: [m, h]
        }), S[25] = h, S[26] = m, S[27] = p) : p = S[27], S[28] !== p || S[29] !== s || S[30] !== d ? (y = (0, t.jsxs)(o.ModalContent, {
            children: [s, d, p]
        }), S[28] = p, S[29] = s, S[30] = d, S[31] = y) : y = S[31], S[32] !== k || S[33] !== I || S[34] !== y ? (x = (0, t.jsx)(o.Modal, {
            open: I,
            onOpenChange: k,
            size: "sm",
            children: y
        }), S[32] = k, S[33] = I, S[34] = y, S[35] = x) : x = S[35], x
    }])
}, 974603, e => {
    "use strict";
    e.i(979983);
    var t = e.i(822315),
        r = e.i(618808),
        i = e.i(415013),
        o = e.i(186897),
        n = e.i(600326),
        a = e.i(502980),
        s = e.i(343999),
        l = e.i(631222);
    e.s(["formatSyntheticMergeTransaction", 0, ({
        conditionId: e,
        amount: t,
        outcomePrices: r,
        proxyAddress: d,
        chainId: c = l.MATIC_CONFIG.chainId
    }) => {
        let u = Date.now(),
            m = (0, i.keccak256)((0, o.toHex)(d + e + u.toString())),
            g = (0, a.computeMergeImpact)(t, r);
        return new s.CTFTxnBuilder(m, n.TxnStatus.PENDING).metadata({
            chainId: c,
            outcome: "",
            outcomeIndex: -1,
            quantity: t,
            usdc: 0 n,
            enqueuedAt: u,
            lastUpdatedAt: u,
            ctfTxnType: n.CTFTxnType.Merge,
            positionChangeData: g
        }).conditionId(e).build()
    }, "getMergePositionsTransaction", 0, ({
        chainId: e,
        chainConfig: i,
        conditionId: o,
        negRisk: n,
        outcomeCount: a,
        amount: s
    }) => {
        let d = i[e].collateral;
        return n ? r.negRiskCollateralAdapterOperations.mergePositions({
            negRiskCollateralAdapterAddress: l.NEG_RISK_COLLATERAL_ADAPTER_ADDRESS,
            collateralTokenAddress: d,
            conditionId: o,
            outcomeSlotCount: a,
            amount: s
        }) : t.collateralAdapterOperations.mergePositions({
            collateralAdapterAddress: l.COLLATERAL_ADAPTER_ADDRESS,
            collateralTokenAddress: d,
            conditionId: o,
            outcomeSlotCount: a,
            amount: s
        })
    }])
}, 97594, 684656, e => {
    "use strict";
    var t = e.i(999061),
        r = e.i(882860),
        i = e.i(63238),
        o = e.i(723823),
        n = e.i(416340),
        a = e.i(5146),
        s = e.i(430849),
        l = e.i(604777),
        d = e.i(784521),
        c = e.i(399336),
        u = e.i(880809),
        m = e.i(196593),
        g = e.i(631222),
        f = e.i(458164),
        h = e.i(30704),
        p = e.i(740594),
        y = e.i(378876);
    let x = (e, t, r) => e === f.OrderType.Limit && r < t,
        S = (e, t) => "" === e && 0 n === t,
        I = (e, t) => ("0" === e || "0.0" === e || "0.00" === e) && 0 n === t,
        k = (e, t, r) => e === f.OrderType.Limit && ("" === t || "00" === t) && 0 n === r,
        C = (e, t, r) => e === f.OrderType.Limit && "0" === t && 0 n === r,
        b = (e, t, r) => {
            if (null == e || null == t || null == r || t <= 0 n || r <= 0 n) return 0 n;
            let o = t - e;
            if (o <= 0 n) return 0 n;
            let n = (0, y.divBigInt)(o, r);
            return (0, i.parseUnits)(n.toString(), 6)
        },
        v = (e, t, r, i) => e === p.Side.BUY && t === f.OrderType.Limit && r < i,
        T = (e, t, r) => null == t || null == r || r <= 0 n || t > r ? 0 n : e === f.OrderType.Limit ? r - t : r,
        M = (e, t, r) => null != r && null != t && e === p.Side.SELL && r > t,
        E = (e, t, r, i) => t === f.OrderType.Market && e === p.Side.BUY && r > i,
        P = (e, t, r, i) => t === f.OrderType.Market && e === p.Side.SELL && r > i,
        w = (e, t, r, i) => (t === f.OrderType.Market || t === f.OrderType.AMM) && e === p.Side.BUY && i > r,
        A = (e, t, i, o, n) => {
            if (e === p.Side.SELL || !n) return !1;
            let a = 10 n ** 6 n;
            return t === f.OrderType.Market ? i < a : !!(t === f.OrderType.Limit && ((e, t) => {
                try {
                    return parseFloat((0, r.formatUnits)(e, 6)) >= t
                } catch {
                    return !1
                }
            })(o, n)) && ((e, t) => {
                try {
                    return e * t / 10 n ** 6 n
                } catch {
                    return 0 n
                }
            })(i, o) < a
        };
    e.s(["areSharesEmpty", 0, S, "areSharesZero", 0, I, "calculateLimitROI", 0, (e, t) => {
        let r = e * t / 10 n ** 6 n,
            i = e > 0 n && r > 0 n ? ((0, y.divBigInt)(e, r) - 1) * 100 : 0;
        return i > 0 ? i : 0
    }, "calculateMarketROI", 0, (e, t) => {
        let r = t.toFixed(6),
            o = (0, i.parseUnits)(r, 6),
            n = e > 0 n && o > 0 n ? ((0, y.divBigInt)(o, e) - 1) * 100 : 0;
        return n > 0 ? n : 0
    }, "getLimitBuyMax", 0, b, "getSellMax", 0, T, "isAmountBelowMin", 0, x, "isBuyLessThanDollar", 0, A, "isMarketBuyBiggerThanBook", 0, E, "isMarketSellBiggerThanBook", 0, P, "isPriceEmpty", 0, k, "isPriceZero", 0, C, "willLimitBuyExceedUserBalance", 0, v, "willMarketBuyExceedBalance", 0, w, "willSellExceedBalance", 0, M], 684656);
    let _ = () => {
        let e = (0, c.useEventActiveMarket)(),
            {
                orderType: t,
                priceUsdc: r,
                selectedOutcomeIdx: i
            } = (0, u.useTradeContext)(["orderType", "priceUsdc", "selectedOutcomeIdx"]),
            o = (0, n.useMemo)(() => e.conditionId, [e.conditionId]),
            l = (0, s.default)(o),
            d = (0, n.useMemo)(() => l.map(e => (0, m.parseUSDCUnits)(e.toFixed(6))), [l]),
            {
                trackedProxyUsdcBalance: g
            } = (0, a.default)(),
            {
                userOpenSellsSizeMap: f,
                userOpenBidsValue: p
            } = (0, h.default)({
                clobTokenIds: e ? .clobTokenIds,
                orderPriceMinTickSize: e ? .orderPriceMinTickSize,
                conditionId: e ? .conditionId
            }),
            y = (0, n.useMemo)(() => b(p, (0, m.parseUSDCUnits)(g.current.toFixed(6)), r), [p, r, g]),
            x = (0, n.useMemo)(() => {
                let r = e.clobTokenIds ? .[i] ? ? "";
                return T(t, f ? .[r] ? ? 0 n, d ? .[i] ? ? 0 n)
            }, [f, i, d, t, e.clobTokenIds]);
        return {
            activeMarket: e,
            limitBuyMax: y,
            marketBuyMax: (0, n.useMemo)(() => (0, m.parseUSDCUnits)(g.current.toFixed(6)) ? ? 0 n, [g]),
            sellMax: x
        }
    };

    function O(e) {
        return !e || e ? .invalid && e ? .disabled ? e : { ...e,
            invalid: !0,
            disabled: !0
        }
    }
    e.s(["MIN_SHARES_DEFAULT", 0, "15", "useOrderLimits", 0, _, "useOrderValidation", 0, () => {
        let e, a, s, c, h, p, y, b, T, D = (0, t.c)(47),
            U = (0, l.useTranslations)();
        D[0] === Symbol.for("react.memo_cache_sentinel") ? (e = ["authenticated"], D[0] = e) : e = D[0];
        let {
            authenticated: j
        } = (0, d.useAccountContext)(e), {
            activeMarket: B,
            limitBuyMax: R,
            marketBuyMax: L,
            sellMax: F
        } = _();
        D[1] === Symbol.for("react.memo_cache_sentinel") ? (a = ["orderError", "orderType", "priceUsdc", "price", "selectedOutcomeIdx", "setOrderError", "shares", "sharesUsdc", "side", "hasClicked", "setHasClicked"], D[1] = a) : a = D[1];
        let {
            orderError: N,
            orderType: W,
            priceUsdc: $,
            price: z,
            selectedOutcomeIdx: q,
            setOrderError: H,
            shares: Q,
            sharesUsdc: K,
            side: G,
            hasClicked: V,
            setHasClicked: X
        } = (0, u.useTradeContext)(a), [Y, Z] = (0, n.useState)(!0), J = (b = (0, o.useBids)(B, q), n.default.useMemo(() => {
            try {
                let e = Math.round(b ? .totalSize ? ? 0);
                if (e > 0) return (0, i.parseUnits)(`${e}`, g.USDC_DECIMALS);
                return 0 n
            } catch {
                return 0 n
            }
        }, [b])), ee = (T = (0, o.useAsks)(B, q), n.default.useMemo(() => {
            try {
                let e = Math.round(T ? .totalValue ? ? 0);
                if (e > 0) return (0, i.parseUnits)(`${e}`, g.USDC_DECIMALS);
                return 0 n
            } catch {
                return 0 n
            }
        }, [T])), et = (0, o.useBestPrice)(B, q, "ask");
        D[2] !== B.orderMinSize || D[3] !== ee || D[4] !== et || D[5] !== J || D[6] !== R || D[7] !== L || D[8] !== W || D[9] !== z || D[10] !== $ || D[11] !== F || D[12] !== X || D[13] !== H || D[14] !== Q || D[15] !== K || D[16] !== G || D[17] !== U ? (s = () => {
            let e = (0, i.parseUnits)(W === f.OrderType.AMM ? "0" : B.orderMinSize ? .toString() ? ? "15", g.USDC_DECIMALS);
            S(Q, K) || I(Q, K) || k(W, z, $) || C(W, z, $) ? (Z(!0), H(void 0)) : x(W, e, K) ? (Z(!0), H({
                field: f.OrderErrorField.SHARES,
                type: f.OrderErrorType.SHARES_BELOW_MIN,
                disabled: !0,
                invalid: !0,
                message: U("trading.errors.minimumShares").replace("{count}", (0, m.formatNum)((0, r.formatUnits)(e, g.USDC_DECIMALS), {
                    decimals: 0
                }))
            })) : M(G, F, K) ? (Z(!0), H({
                field: f.OrderErrorField.SHARES,
                type: f.OrderErrorType.INSUFFICIENT_SHARES,
                disabled: !0,
                invalid: !0,
                message: U("trading.errors.notEnoughShares")
            })) : v(G, W, R, K) || w(G, W, L, K) ? (Z(!0), H({
                field: f.OrderErrorField.SHARES,
                type: f.OrderErrorType.INSUFFICIENT_BALANCE,
                disabled: !0,
                invalid: !0,
                message: U("trading.errors.notEnoughFunds")
            })) : E(G, W, K, ee) || P(G, W, K, J) ? (Z(!0), H({
                field: f.OrderErrorField.SHARES,
                type: f.OrderErrorType.SHARES_ABOVE_MAX,
                disabled: !0,
                invalid: !0,
                message: U("trading.errors.highPriceFluctuation")
            })) : W === f.OrderType.Market && et.valid && A(G, W, K, $, et.value) ? (Z(!0), H({
                field: f.OrderErrorField.SHARES,
                disabled: !0,
                invalid: !0,
                message: U("trading.errors.marketBuyMinimum"),
                type: f.OrderErrorType.SHARES_BELOW_MIN
            })) : (Z(!1), H(void 0), X(!1))
        }, D[2] = B.orderMinSize, D[3] = ee, D[4] = et, D[5] = J, D[6] = R, D[7] = L, D[8] = W, D[9] = z, D[10] = $, D[11] = F, D[12] = X, D[13] = H, D[14] = Q, D[15] = K, D[16] = G, D[17] = U, D[18] = s) : s = D[18], D[19] !== B.orderMinSize || D[20] !== ee || D[21] !== et || D[22] !== J || D[23] !== R || D[24] !== L || D[25] !== W || D[26] !== z || D[27] !== $ || D[28] !== F || D[29] !== Q || D[30] !== K || D[31] !== G || D[32] !== U ? (c = [ee, J, R, B.orderMinSize, W, $, Q, K, G, z, F, et, U, L], D[19] = B.orderMinSize, D[20] = ee, D[21] = et, D[22] = J, D[23] = R, D[24] = L, D[25] = W, D[26] = z, D[27] = $, D[28] = F, D[29] = Q, D[30] = K, D[31] = G, D[32] = U, D[33] = c) : c = D[33], (0, n.useEffect)(s, c), D[34] !== N ? .type || D[35] !== H ? (h = () => {
            let e;
            return N ? .type === f.OrderErrorType.SHARES_BELOW_MIN && (e = setTimeout(() => {
                H(O)
            }, 1e3)), () => clearTimeout(e)
        }, D[34] = N ? .type, D[35] = H, D[36] = h) : h = D[36], D[37] !== N ? (p = [N], D[37] = N, D[38] = p) : p = D[38], (0, n.useEffect)(h, p);
        let er = !!j && Y,
            ei = j ? N : void 0;
        return D[39] !== V || D[40] !== R || D[41] !== L || D[42] !== F || D[43] !== X || D[44] !== er || D[45] !== ei ? (y = {
            isOrderInvalid: er,
            orderError: ei,
            hasClicked: V,
            setHasClicked: X,
            limitBuyMax: R,
            sellMax: F,
            marketBuyMax: L
        }, D[39] = V, D[40] = R, D[41] = L, D[42] = F, D[43] = X, D[44] = er, D[45] = ei, D[46] = y) : y = D[46], y
    }], 97594)
}]);

//# debugId=6d927c24-8534-ba8c-402a-dd4e64d300b0