import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { TabPane, Tabs } from "../../tab";
import { useEffect, useState } from "react";
import { Withdraw } from "../withdraw";
import { create } from "../../modal/modalHelper";
import { useModal } from "../../modal";
import { Sheet, SheetContent } from "../../sheet";
import { AssetsProvider } from "../../provider/assetsProvider";
import { Dialog, DialogContent } from "../../dialog";
import { DepositSlot } from "./slot";
import { ArrowDownToLineIcon } from "../../icon";
export const DepositAndWithdraw = (props)=>{
    const [value, setValue] = useState(()=>props.activeTab ?? "deposit");
    return /*#__PURE__*/ _jsx(AssetsProvider, {
        children: /*#__PURE__*/ _jsxs(Tabs, {
            id: "orderly-deposit-and-withdraw",
            value: value,
            onTabChange: setValue,
            tabBarClassName: "orderly-border-b-0 orderly-px-0",
            children: [
                /*#__PURE__*/ _jsx(TabPane, {
                    id: "orderly-deposit-pane",
                    title: /*#__PURE__*/ _jsxs("div", {
                        className: "orderly-flex orderly-items-center orderly-gap-1 orderly-text-xs desktop:orderly-text-lg",
                        children: [
                            /*#__PURE__*/ _jsx(ArrowDownToLineIcon, {
                                className: "orderly-w-[10px] orderly-h-[10px] desktop:orderly-w-[16px] desktop:orderly-h-[16px]"
                            }),
                            /*#__PURE__*/ _jsx("span", {
                                children: "Deposit"
                            })
                        ]
                    }),
                    value: "deposit",
                    children: /*#__PURE__*/ _jsx("div", {
                        className: "orderly-py-3 orderly-px-[2px]",
                        children: /*#__PURE__*/ _jsx(DepositSlot, {
                            onOk: props.onOk
                        })
                    })
                }),
                /*#__PURE__*/ _jsx(TabPane, {
                    id: "orderly-withdraw-pane",
                    title: /*#__PURE__*/ _jsxs("div", {
                        className: "orderly-flex orderly-items-center orderly-gap-1 orderly-text-xs desktop:orderly-text-lg",
                        children: [
                            /*#__PURE__*/ _jsx(ArrowDownToLineIcon, {
                                className: "orderly-w-[10px] orderly-h-[10px] desktop:orderly-w-[16px] desktop:orderly-h-[16px] orderly-rotate-180"
                            }),
                            /*#__PURE__*/ _jsx("span", {
                                children: "Withdraw"
                            })
                        ]
                    }),
                    value: "withdraw",
                    children: /*#__PURE__*/ _jsx("div", {
                        className: "orderly-py-3 orderly-px-[2px]",
                        children: /*#__PURE__*/ _jsx(Withdraw, {
                            onOk: props.onOk
                        })
                    })
                })
            ]
        })
    });
};
export const DepositAndWithdrawWithSheet = create((props)=>{
    const { visible, hide, resolve, reject, onOpenChange } = useModal();
    const onOk = (data)=>{
        resolve(data);
        hide();
    };
    return /*#__PURE__*/ _jsx(Sheet, {
        open: visible,
        onOpenChange: onOpenChange,
        children: /*#__PURE__*/ _jsx(SheetContent, {
            children: /*#__PURE__*/ _jsx(DepositAndWithdraw, {
                activeTab: props.activeTab,
                onOk: onOk
            })
        })
    });
});
export const DepositAndWithdrawWithDialog = create((props)=>{
    const { visible, hide, resolve, reject, onOpenChange } = useModal();
    const [top, setTop] = useState("20%");
    const onOk = (data)=>{
        resolve(data);
        hide();
    };
    useEffect(()=>{
        setTop((window.innerHeight - 500) * 0.5);
    }, [
        window.innerHeight
    ]);
    return /*#__PURE__*/ _jsx(Dialog, {
        open: visible,
        onOpenChange: onOpenChange,
        children: /*#__PURE__*/ _jsx(DialogContent, {
            style: {
                top
            },
            className: "orderly-p-5 orderly-top-[20%] orderly-translate-y-0",
            maxWidth: "lg",
            closable: true,
            children: /*#__PURE__*/ _jsx(DepositAndWithdraw, {
                activeTab: props.activeTab,
                onOk: onOk
            })
        })
    });
});

//# sourceMappingURL=depositAndwithdraw.js.map