import{t as e}from"./api-rGh4pPta.js";import{i as t,n,o as r,s as i}from"./Helper-CgZLd8U2.js";var a=e=>{let t=e?.data??e;return Array.isArray(t)?t:t?.results||[]},{useGetCurrenciesQuery:o,useCreateCurrencyMutation:s,useUpdateCurrencyMutation:c,useDeleteCurrencyMutation:l}=e.injectEndpoints({endpoints:e=>({getCurrencies:e.query({queryFn:async e=>{try{return{data:a(await n(`/currency/currencies/`,e||{}))}}catch(e){return{error:{status:500,data:e?.message||`Failed to fetch currencies`}}}},providesTags:[`Masters`]}),createCurrency:e.mutation({queryFn:async e=>{try{return{data:(await r(`/currency/currencies/`,e)).data}}catch(e){return{error:{status:e?.response?.status||500,data:e?.response?.data||e?.message}}}},invalidatesTags:[`Masters`]}),updateCurrency:e.mutation({queryFn:async({id:e,data:n})=>{try{return{data:(await t(`/currency/currencies/${e}/`,n)).data}}catch(e){return{error:{status:e?.response?.status||500,data:e?.response?.data||e?.message}}}},invalidatesTags:[`Masters`]}),deleteCurrency:e.mutation({queryFn:async e=>{try{return await i(`/currency/currencies/${e}/`),{data:void 0}}catch(e){return{error:{status:e?.response?.status||500,data:e?.response?.data||e?.message}}}},invalidatesTags:[`Masters`]})}),overrideExisting:!1});export{c as i,l as n,o as r,s as t};