1"use strict";(globalThis.webpackChunk_N_E=globalThis.webpackChunk_N_E||[]).push([[16586],{29640:(e,r,t)=>{t.d(r,{J:()=>i,X:()=>o});var n=t(95155),a=t(12115),c=t(99382),l=t(71291);let s=(0,a.createContext)(void 0);function o({children:e,loadAuthOnMount:r=!1}){let[t,u]=(0,a.useState)(!1),[i,d]=(0,a.useState)(null),[f,h]=(0,a.useState)(!1),[m,g]=(0,a.useState)(!1),[y,b]=(0,a.useState)(r),C=(0,a.useRef)(!0),p=(0,a.useRef)(!1),k=(0,a.useRef)(null),S=(0,a.useRef)(!1);(0,a.useEffect)(()=>{S.current=t},[t]);let w=(0,a.useCallback)(async()=>{let e,r=0;for(;r<=2;){let t=new AbortController,n=null;try{if(n=setTimeout(()=>{t.abort()},1e4),e=await fetch("/api/b2c/auth/status",{signal:t.signal,credentials:"include",headers:{"Cache-Control":"no-cache",Pragma:"no-cache"}}),n&&(clearTimeout(n),n=null),!e.ok){if(!C.current)return;g(!1),u(!1),d(null),h(!1),b(!1);return}break}catch(e){if(n&&(clearTimeout(n),n=null),r++,e instanceof Error&&"AbortError"===e.name){if(r>2){if(!C.current)return;S.current||(g(!1),u(!1),d(null),h(!1)),b(!1);return}await new Promise(e=>setTimeout(e,1e3*r))}else if(e instanceof TypeError&&e.message.includes("Failed to fetch")){if(e.message.includes("CERT_AUTHORITY_INVALID")||e.message.includes("certificate")||e.message.includes("SSL")||e.message.includes("TLS")){if(!C.current)return;console.error("â [B2C Auth] Erreur de certificat SSL d\xe9tect\xe9e. V\xe9rifiez la configuration SSL du serveur."),g(!1),u(!1),d(null),h(!1),b(!1);return}if(r>2){if(!C.current)return;e instanceof Error&&"AbortError"!==e.name&&!(0,c.p)(e)&&console.error("B2C Auth initialization error:",e),g(!1),u(!1),d(null),h(!1),b(!1);return}await new Promise(e=>setTimeout(e,1e3*r))}else if(r>2){if(!C.current)return;e instanceof Error&&"AbortError"!==e.name&&!(0,c.p)(e)&&console.error("B2C Auth initialization error:",e),g(!1),u(!1),d(null),h(!1),b(!1);return}else await new Promise(e=>setTimeout(e,1e3*r))}}if(e&&e.ok)try{let r=await e.json();if(!C.current)return;g(r.dbHealthy||!1),h(r.hasClients||!1),u(r.isAuthenticated||!1),d(r.client||null)}catch(e){console.error("B2C Auth parse error:",e),C.current&&(g(!1),u(!1),d(null),h(!1))}else C.current&&(g(!1),u(!1),d(null),h(!1));C.current&&b(!1)},[]),v=(0,a.useCallback)(async()=>{if(p.current){await k.current,C.current&&b(!1);return}p.current=!0,C.current&&b(!0);let e=w();k.current=e;try{await e}finally{C.current&&b(!1)}},[w]);(0,a.useEffect)(()=>(C.current=!0,(r||(0,l.JK)())&&v(),()=>{C.current=!1,r&&(p.current=!1,k.current=null)}),[r,v]),(0,a.useEffect)(()=>{!y&&p.current&&(0,l.JK)()&&(0,l.eW)("auth.changed",{loggedIn:t})},[t,y]);let E=(0,a.useCallback)(async e=>{let r=e?.silent??!1;if(!r||!S.current){!r&&C.current&&b(!0);try{await w()}finally{r&&C.current&&b(!1)}}},[w]),T=(0,a.useCallback)(async(e,r)=>{p.current||(p.current=!0),C.current&&b(!0);let t=new AbortController,n=null;try{n=setTimeout(()=>t.abort(),12e3);let a=await fetch("/api/b2c/auth/login",{method:"POST",headers:{"Content-Type":"application/json","Cache-Control":"no-cache",Pragma:"no-cache"},credentials:"include",body:JSON.stringify({email:e,password:r}),signal:t.signal});if(n&&(clearTimeout(n),n=null),!a.ok){let e=await a.json().catch(()=>({}));return{success:!1,error:e.error||"\xc9chec de la connexion"}}let c=await a.json();if(c.success)return C.current&&(u(!0),d(c.client),h(!0)),setTimeout(()=>{w()},200),{success:!0};return{success:!1,error:c.error||"loginFailed"}}catch(e){if(n&&(clearTimeout(n),n=null),e instanceof Error&&"AbortError"===e.name)return{success:!1,error:"loginExpired"};return console.error("B2C Login error:",e),{success:!1,error:"connectionErrorRetry"}}finally{C.current&&b(!1)}},[w]),A=(0,a.useCallback)(async()=>{try{await fetch("/api/b2c/auth/logout",{method:"POST",credentials:"include",headers:{"Cache-Control":"no-cache",Pragma:"no-cache"}})}catch(e){console.error("B2C Logout error:",e)}finally{C.current&&(u(!1),d(null))}},[]);return(0,n.jsx)(s.Provider,{value:{isAuthenticated:t,client:i,hasClients:f,dbHealthy:m,login:T,logout:A,refreshAuth:E,ensureAuthLoaded:v,isLoading:y},children:e})}let u={isAuthenticated:!1,client:null,hasClients:!1,dbHealthy:!1,login:async()=>({success:!1,error:"B2CAuthProvider not available"}),logout:()=>{},refreshAuth:async()=>{},ensureAuthLoaded:async()=>{},isLoading:!1};function i(){let e=(0,a.useContext)(s);return void 0===e?u:e}},96776:(e,r,t)=>{t.d(r,{b:()=>h,z:()=>m});var n=t(95155),a=t(12115),c=t(31711),l=t(70760);let s=c.ab,o=c.x$,u=c.dk,i={necessary:!0,analytics:!1,marketing:!1,timestamp:Date.now(),version:s},d=(0,a.createContext)(void 0);function f(){try{let e=localStorage.getItem(o)??sessionStorage.getItem(u);return e?JSON.parse(e):null}catch{return null}}function h({children:e}){let[r,t]=(0,a.useState)(()=>(0,c.d4)()||(0,c.NG)()?null:f()),[m,g]=(0,a.useState)(()=>!(0,c.d4)()&&(0,c.NG)()),[y,b]=(0,a.useState)(()=>!(0,c.d4)()&&(0,c.NG)());(0,a.useEffect)(()=>
1{if((0,c.d4)()){b(!1),g(!1),(0,l.q)(!1);return}try{let e=(0,c.NG)();b(e),(0,l.q)(e),e?(g(!0),t(null),localStorage.getItem(o)&&localStorage.removeItem(o)):(t(f()),g(!1))}catch(e){console.error("Erreur lors du chargement des pr\xe9f\xe9rences RGPD:",e),b(!0),g(!0),(0,l.q)(!0)}},[]);let C=(0,a.useCallback)(e=>{!function(e){let r=JSON.stringify(e);try{return localStorage.setItem(o,r),sessionStorage.removeItem(u),!0}catch{try{return sessionStorage.setItem(u,r),!0}catch{return!1}}}(e)&&console.error("Erreur lors de la sauvegarde des pr\xe9f\xe9rences RGPD: stockage indisponible");try{let r=JSON.stringify({analytics:e.analytics,marketing:e.marketing,version:e.version,locale:document.documentElement.lang||null});navigator.sendBeacon?.("/api/b2c/consent/log",new Blob([r],{type:"application/json"}))||fetch("/api/b2c/consent/log",{method:"POST",headers:{"Content-Type":"application/json"},body:r,keepalive:!0,credentials:"include"}).catch(()=>{})}catch{}t(e),g(!1),b(!1),(0,l.q)(!1)},[]),p=(0,a.useCallback)(()=>{C({...i,necessary:!0,analytics:!0,marketing:!0,timestamp:Date.now(),version:s})},[C]),k=(0,a.useCallback)(()=>{C({...i,necessary:!0,analytics:!1,marketing:!1,timestamp:Date.now(),version:s})},[C]),S=(0,a.useCallback)(e=>{"necessary"===e||C({...r||i,[e]:!0,timestamp:Date.now(),version:s})},[r,C]),w=(0,a.useCallback)(e=>{"necessary"===e||C({...r||i,[e]:!1,timestamp:Date.now(),version:s})},[r,C]),v=(0,a.useCallback)(e=>{C({...r||i,...e,necessary:!0,timestamp:Date.now(),version:s})},[r,C]),E=(0,a.useCallback)(()=>{g(!0)},[]),T=(0,a.useCallback)(()=>{r&&g(!1)},[r]),A=(0,a.useCallback)(e=>"necessary"===e||(r?.[e]??!1),[r]),P=null!==r&&!m,D=a.useMemo(()=>({preferences:r,hasConsented:P,showBanner:m,consentPending:y,acceptAll:p,rejectAll:k,acceptCategory:S,rejectCategory:w,savePreferences:v,openPreferences:E,closeBanner:T,isCategoryAccepted:A}),[r,P,m,y,p,k,S,w,v,E,T,A]);return(0,n.jsx)(d.Provider,{value:D,children:e})}function m(){let e=(0,a.useContext)(d);if(void 0===e)throw Error("useGDPR must be used within a GDPRProvider");return e}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.