import{a}from"./chunk-IIYQPZAL.js";import{a as u,b as d}from"./chunk-KC6GENB3.js";import{C as n,W as c,_ as l,da as h,o}from"./chunk-PEWEDMBK.js";var H=(()=>{let r=class r{getHeaders(){return new u({Accept:"application/json","Content-Type":"application/json","X-CSRFToken":"6EZeWkpQaDPitcgEckosv48y2bLvYlFbv2heOldXY9EbfeGnwLGBjd0uclhLqt0n",Authorization:"Basic "+btoa(`${this.username}:${this.password}`)})}constructor(e){this.http=e,this.username="admin",this.password="admin",this.SUrl=`${a.apiBaseUrl}/services/`,this.baseUrl=`${a.apiBaseUrl}/services`}getServices(){return this.http.get(this.SUrl,{headers:this.getHeaders()})}getServiceById(e){let t=`${this.baseUrl}/${e}`;return this.http.get(t,{headers:this.getHeaders()})}createService(e){let t=JSON.stringify(e);return console.log("service:==>",t),console.log("Donn\xE9es envoy\xE9es pour cr\xE9er le service..."),this.http.post(this.SUrl,t,{headers:this.getHeaders()}).pipe(n(this.errorHandler))}updateService(e){let t={service_id:e.service_id,nom_service:e.nom_service,description:e.description,marchand:e.marchand},p=`${this.baseUrl}/${e.service_id}/`;return this.http.put(p,t,{headers:this.getHeaders()}).pipe(c(s=>{console.log("Service mis \xE0 jour avec succ\xE8s:",s)}),n(s=>(s.status===404?console.error("Service non trouv\xE9. Impossible de mettre \xE0 jour."):s.status===400?console.error("Requ\xEAte invalide. Veuillez v\xE9rifier les donn\xE9es envoy\xE9es."):s.status===500?console.error("Erreur interne du serveur. Veuillez r\xE9essayer ult\xE9rieurement."):console.error("Une erreur inattendue s'est produite:",s),o(s))))}deleteService(e){let t=`${this.baseUrl}/${e}`;return this.http.delete(t,{headers:this.getHeaders()})}errorHandler(e){let t="";return e.error instanceof ErrorEvent?t=`Erreur c\xF4t\xE9 client: ${e.error.message}`:t=`Code d'erreur: ${e.status} Message: ${e.message}`,o(t)}};r.\u0275fac=function(t){return new(t||r)(h(d))},r.\u0275prov=l({token:r,factory:r.\u0275fac,providedIn:"root"});let i=r;return i})();export{H as a};