import{a as e,c as t,i as n,r}from"./api-CqQWIBIg.js";import{n as i,t as a}from"./vendor-redux-CPC4Y6OK.js";var o=e=>{if(!e||typeof e!=`object`)return null;let t=e.data;if(!t)return null;if(t.errors&&typeof t.errors==`object`){let e=t.errors,n=e.non_field_errors;if(Array.isArray(n)&&n[0])return String(n[0]);let r=Object.values(e)[0];if(Array.isArray(r)&&r[0])return String(r[0])}return typeof t.detail==`string`?t.detail:typeof t.message==`string`?t.message:null},s=i({baseUrl:`https://api.salesapp.tenalidoublehorse.com/api/v1`,prepareHeaders:e=>{let t=n();return t&&e.set(`Authorization`,`Bearer ${t}`),e}}),c=a({reducerPath:`api`,baseQuery:async(n,i,a)=>{let c=await s(n,i,a);if(c.error){let l=c.error.status;if(l===401){if(await e())c=await s(n,i,a);else{r();let e=window.location.pathname.startsWith(`/distributor`)?`/distributor/login`:`/admin/login`;window.location.href=e}return c}if(l===400){let e=o(c.error);t.error(e||`Invalid request — please check your input`)}else if(l===404){let e=o(c.error);t.error(e||`The requested resource was not found`)}else if(l===422){let e=o(c.error);t.error(e||`Validation error — please check your input`)}else l>=500&&t.error(`Server error — please try again later`)}return c},tagTypes:`User.Role.Notification.Setting.DocumentNumbering.AIProvider.AuditLog.Master.Category.Subcategory.Uom.UomConversion.ProductGroup.Product.Warehouse.Location.Customer.CustomerContact.CustomerBankAccount.Company.Restriction.Quota.Return.Country.GeoState.District.Mandal.City.Pincode.Zone.ServiceArea.TaxRate.HsnCode.Brand.CustomerType.Agent.Order.DispatchLoad.Dispatch.DispatchQueue.DispatchConfig.Transporter.Vehicle.Driver.DeliveryRoute.DispatchReason.VehicleDocument.DriverDocument.OrderAttachment.DispatchAttachment.POD.PODAttachment.CustomerCredit.CustomerLedger.CreditAgeing.CreditConfig.Company.Maintenance.SalesExecutive.Payment.PaymentTransaction.BankAccount.PaymentGateway.PaymentSettings.Banner.RateCard.RateCardAssignment.RateCardItem.PriceSlab.PriceHistory.PricingWorkbench.PricingBatch.PricingConfig.Pricebook.Scheme.SchemeAccrual.SchemeBenefit.SchemesConfig.Stock.StockSyncRun.ErpConnection.SyncEntity.FieldMapping.SyncRun.LoanProduct.LoanScheme.VehicleMake.VehicleModel.VehicleVariant.ApiKey.Customer.CustomerAddress.CustomerGuarantor.Lead.Estimation.LeadConfig.LoanConfig.LoanApplication.LoanApplicationParty.Workflow.WorkflowStep.WorkflowTransition.WorkflowInstance.WorkflowHistory.ApprovalRequest.WorkflowTask.Escalation.WorkflowConfig.Surepass.Eligibility.EligibilityPolicy.EligibilityConfig.LoanAccount.Disbursement.RepaymentSchedule.LoanPayment.LoanCharge.ReportCatalog.CollectionDisposition.CollectionCase.CollectionAttempt.CollectionPTP.CollectionsConfig.CollectionsDashboard.VonageProvider.CallSession.WaFlow.WaFlowVersion.WaConversation.WaCampaign.WaNodeType.WaAnalytics`.split(`.`),endpoints:()=>({})});export{c as t};