import { computed } from "vue"; import { useState } from "#app"; import { useApi } from "~/lib/auth.js"; import { n as WithdrawDialog_n } from "~/components/WithdrawDialog.vue"; function i(i = ``) { let a = useState( `withdraw-availability:${i ? `recommend` : `credit`}`, () => ({ rule: null, loading: !1, loaded: !1, error: ``, }), ), o = computed(() => WithdrawDialog_n(a.value.rule, i ? `recommend` : ``)), s = computed(() => a.value.loading), c = computed(() => a.value.loaded), l = computed(() => a.value.error); async function u(e = !1) { if (!(a.value.loading || (a.value.loaded && !e))) { ((a.value.loading = !0), (a.value.error = ``)); try { let e = await useApi().get( `/withdraw/rule/credit`, i ? { scene: `recommend`, } : void 0, ); ((a.value.rule = e ?? null), (a.value.loaded = !0)); } catch (e) { ((a.value.rule = null), (a.value.loaded = !1), (a.value.error = e instanceof Error ? e.message : `加载提现设置失败`)); } finally { a.value.loading = !1; } } } return { enabled: o, loading: s, loaded: c, error: l, load: u, }; } export { i as t };