import{v as s,K as o,r as l}from"./vendor-CmAScyG3.js";import{i as n,b as f}from"./page-index.tsx-D0oEuWOa.js";import"./page-FortuneWheel.ts-CaqHFvhq.js";import{a as b}from"./page-FortuneWheelWinModalContent.tsx-DESnY6qd.js";import{u as r}from"./page-fortuneWheel.ts-BU2wXqek.js";try{let a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new a.Error().stack;t&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[t]="fdb5fe8e-8836-4b4c-bbf3-af9589b1b6c7",a._sentryDebugIdIdentifier="sentry-dbid-fdb5fe8e-8836-4b4c-bbf3-af9589b1b6c7")}catch{}const y=()=>{const a=s(n),t=o({queryKey:["fortuneWheel","available"],queryFn:async()=>{const e=await f.get(b.config.api.fortuneWheel.availability);if(!e||typeof e!="object")throw new Error("Invalid fortune wheel availability payload");return e},select:e=>({isAvailable:!!e.isAvailable,nextAvailableAt:e.nextAvailableAt??""}),enabled:!!a,staleTime:5*6e4,gcTime:30*6e4,refetchOnWindowFocus:!1,retry:a?2:0});return l.useEffect(()=>{const e=r.getState();if(!a){e.isAvailable!==!1&&e.setAvailable(!1),e.nextAvailableAt!==""&&e.setNextAvailable(""),e.error&&e.setError("");return}const{data:i}=t;i&&(e.isAvailable!==i.isAvailable&&e.setAvailable(i.isAvailable),(e.nextAvailableAt??"")!==i.nextAvailableAt&&e.setNextAvailable(i.nextAvailableAt),e.error&&e.setError(""))},[a,t,t.data]),l.useEffect(()=>{var i;if(!a||!t.isError)return;const e=r.getState();e.isAvailable!==!1&&e.setAvailable(!1),e.nextAvailableAt!==""&&e.setNextAvailable(""),e.setError(((i=t.error)==null?void 0:i.message)||"Failed to fetch availability")},[a,t.isError,t.error]),t};export{y as u};
//# sourceMappingURL=page-useWheelAvailable.tsx-DKmHJibQ.js.map