import{l as s,n as i,o as u,p as c}from"./index-C-gKvEDq.js";const r="/currencies",y=async e=>{const{data:a}=await s.get(`${r}/`,{params:e});return a},o=async()=>{const{data:e}=await s.get(`${r}/active/`);return e.data||e.results||e},l=async e=>{const{data:a}=await s.get(`${r}/${e}/`);return a.data||a},d=async e=>{const a=await s.post(`${r}/`,e);return a.data.data||a.data},v=async(e,a)=>{const n=await s.put(`${r}/${e}/`,a);return n.data.data||n.data},q=async e=>{const a=await s.post(`${r}/${e}/set_as_base/`);return a.data.data||a.data},p=async e=>{const a=await s.post(`${r}/${e}/activate/`);return a.data.data||a.data},K=async e=>{const a=await s.post(`${r}/${e}/deactivate/`);return a.data.data||a.data},t={all:["currencies"],lists:()=>[...t.all,"list"],list:e=>[...t.lists(),e],active:()=>[...t.all,"active"],base:()=>[...t.all,"base"],details:()=>[...t.all,"detail"],detail:e=>[...t.details(),e]},Q=e=>i({queryKey:t.list(e),queryFn:()=>y(e),staleTime:300*1e3}),$=()=>i({queryKey:t.active(),queryFn:o,staleTime:600*1e3}),b=(e,a=!0)=>i({queryKey:t.detail(e),queryFn:()=>l(e),enabled:a&&!!e}),m=()=>{const e=u();return c({mutationFn:a=>d(a),onSuccess:a=>{e.invalidateQueries({queryKey:t.lists()}),e.invalidateQueries({queryKey:t.active()}),a.is_base_currency&&e.invalidateQueries({queryKey:t.base()})}})},w=()=>{const e=u();return c({mutationFn:({id:a,data:n})=>v(a,n),onSuccess:(a,n)=>{e.invalidateQueries({queryKey:t.lists()}),e.invalidateQueries({queryKey:t.active()}),e.invalidateQueries({queryKey:t.detail(n.id)}),a.is_base_currency&&e.invalidateQueries({queryKey:t.base()})}})},g=()=>{const e=u();return c({mutationFn:a=>q(a),onSuccess:()=>{e.invalidateQueries({queryKey:t.lists()}),e.invalidateQueries({queryKey:t.active()}),e.invalidateQueries({queryKey:t.base()}),e.invalidateQueries({queryKey:["myPreferences"]})}})};export{$ as a,o as b,p as c,K as d,m as e,w as f,y as g,b as h,g as i,q as s,Q as u};
