@lystech/core 3.0.78 → 3.0.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -90,7 +90,14 @@ jobs:
|
|
|
90
90
|
echo "⏭️ Aucun changement à committer"
|
|
91
91
|
else
|
|
92
92
|
git commit -m "chore: update ${{ github.event.inputs.package_name }} to ${{ github.event.inputs.version }} [skip ci]"
|
|
93
|
-
|
|
93
|
+
# Résiste à un push CONCURRENT arrivé pendant le build : rebase
|
|
94
|
+
# puis jusqu'à 3 tentatives (sinon rejet non-fast-forward et le
|
|
95
|
+
# job échoue alors que le déploiement, lui, est déjà parti).
|
|
96
|
+
for attempt in 1 2 3; do
|
|
97
|
+
git pull --rebase && git push && break
|
|
98
|
+
echo "⚠️ Push rejeté (tentative $attempt/3) — nouveau rebase…"
|
|
99
|
+
sleep 5
|
|
100
|
+
done
|
|
94
101
|
echo "✅ Changements committes et pushés"
|
|
95
102
|
fi
|
|
96
103
|
|
|
@@ -43021,7 +43021,7 @@ const Pf = {
|
|
|
43021
43021
|
padding: 2,
|
|
43022
43022
|
lineHeight: 0,
|
|
43023
43023
|
flexShrink: 0
|
|
43024
|
-
}, SY = "@lystech/core", EY = "lystechcorenpmpackage:last-version", AY = "3.0.
|
|
43024
|
+
}, SY = "@lystech/core", EY = "lystechcorenpmpackage:last-version", AY = "3.0.79";
|
|
43025
43025
|
function OY(e = {}) {
|
|
43026
43026
|
const {
|
|
43027
43027
|
packageName: t = SY,
|
|
@@ -1715,7 +1715,7 @@ html body {
|
|
|
1715
1715
|
.lystech-support-close:hover {
|
|
1716
1716
|
background-color: #f3f4f6 !important;
|
|
1717
1717
|
color: #374151 !important;
|
|
1718
|
-
}`;function fY(){O.useEffect(()=>{if(typeof document>"u"||document.getElementById(EE))return;const e=document.createElement("style");e.id=EE,e.appendChild(document.createTextNode(dY)),document.head.appendChild(e)},[])}const Vv=5,hY=6*1024*1024;function mY(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{const a=String(r.result||""),i=a.indexOf(",");t(i>=0?a.slice(i+1):a)},r.onerror=()=>n(r.error),r.readAsDataURL(e)})}function AE(){const{organizationDetails:e}=Lr(),{isLoggedIn:t,currentUser:n}=ar();fY();const r=!!(t&&(n!=null&&n.email)),a=(n==null?void 0:n.email)??"",i=`${(n==null?void 0:n.firstName)??""} ${(n==null?void 0:n.lastName)??""}`.trim()||a,[o,s]=O.useState(!1),[c,u]=O.useState(""),[d,f]=O.useState(""),[h,v]=O.useState(""),[g,p]=O.useState(""),[m,b]=O.useState("idle"),[C,w]=O.useState(""),[x,A]=O.useState([]),S=O.useRef(null),E=O.useRef(null),P=O.useRef(null);O.useEffect(()=>{if(!o)return;const j=D=>{D.key==="Escape"&&s(!1)};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[o]),O.useEffect(()=>()=>{P.current&&clearTimeout(P.current)},[]);function M(){u(""),f(""),v(""),p(""),b("idle"),w(""),A([])}function N(j){const D=Array.from(j.target.files||[]),z=D.filter(F=>(F.type==="application/pdf"||F.type.startsWith("image/"))&&F.size<=hY);z.length<D.length&&w("PDF et images seulement (max ~6 Mo par fichier)."),A(F=>[...F,...z].slice(0,Vv)),j.target.value=""}function I(){s(!1),P.current&&(clearTimeout(P.current),P.current=null),setTimeout(M,250)}function L(){o?I():(M(),s(!0))}async function T(j){var D;if(j.preventDefault(),m!=="sending"){b("sending"),w("");try{const z=await Promise.all(x.map(async F=>({filename:F.name,contentType:F.type||"application/octet-stream",dataBase64:await mY(F)})));await Nt.post("/support/submit",{name:r?i:c,email:r?a:d,message:h,website:g,attachments:z.length>0?z:void 0}),b("success"),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{I()},2500)}catch(z){const F=(D=z==null?void 0:z.response)==null?void 0:D.status;F===429?(b("error"),w("Trop de messages, réessaie plus tard.")):F===409?I():(b("error"),w("Échec de l'envoi, réessaie."))}}}if(!(e!=null&&e.supportEnabled))return null;const R=m==="sending";return y.jsxs("div",{style:{position:"fixed",bottom:20,right:20,zIndex:cY,pointerEvents:"none",display:"flex",flexDirection:"column",alignItems:"flex-end",gap:12,fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif"},children:[o&&y.jsxs("div",{ref:S,role:"dialog","aria-label":"Formulaire de contact du support",style:{pointerEvents:"auto",width:"min(360px, calc(100vw - 32px))",maxHeight:"calc(100vh - 110px)",overflowY:"auto",backgroundColor:"#ffffff",color:"#1f2937",borderRadius:18,border:"1px solid rgba(15, 118, 110, 0.08)",boxShadow:"0 20px 48px rgba(15, 23, 42, 0.18), 0 4px 12px rgba(15, 23, 42, 0.08)",padding:22,boxSizing:"border-box",animation:"lystech-support-fade-in 0.2s cubic-bezier(0.16, 1, 0.3, 1)"},children:[y.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:12,marginBottom:18},children:[y.jsxs("div",{style:{display:"flex",alignItems:"center",gap:11},children:[y.jsx("span",{"aria-hidden":"true",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:38,height:38,borderRadius:11,backgroundColor:"rgba(15, 118, 110, 0.1)",color:vl,flexShrink:0},children:y.jsx(Lv,{size:22,weight:"fill"})}),y.jsxs("div",{children:[y.jsx("strong",{style:{display:"block",fontSize:16,lineHeight:1.25,color:"#111827"},children:"Contacter le support"}),y.jsx("span",{style:{display:"block",fontSize:12.5,lineHeight:1.4,color:"#6b7280",marginTop:2},children:"On te répond rapidement."})]})]}),y.jsx("button",{type:"button",onClick:I,"aria-label":"Fermer",className:"lystech-support-close",style:{background:"transparent",border:"none",cursor:"pointer",padding:6,display:"inline-flex",color:"#9ca3af",borderRadius:8,lineHeight:0,flexShrink:0,transition:"background-color 0.15s ease, color 0.15s ease"},children:y.jsx(ml,{size:20})})]}),m==="success"?y.jsx("div",{style:{padding:"24px 8px",textAlign:"center",fontSize:15,color:"#047857",fontWeight:600},children:"✓ Message envoyé, merci !"}):y.jsxs("form",{onSubmit:T,noValidate:!0,children:[y.jsx("input",{type:"text",name:"website",value:g,onChange:j=>p(j.target.value),tabIndex:-1,"aria-hidden":"true",autoComplete:"off",style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0}}),r?y.jsxs("div",{style:{fontSize:12.5,color:"#6b7280",marginBottom:14,lineHeight:1.4},children:["Connecté·e en tant que"," ",y.jsx("span",{style:{color:"#374151",fontWeight:600},children:a})]}):y.jsxs(y.Fragment,{children:[y.jsxs("label",{style:Yv,children:["Nom",y.jsx("input",{type:"text",value:c,onChange:j=>u(j.target.value),required:!0,disabled:R,placeholder:"Ton nom",className:"lystech-support-field",style:Wv})]}),y.jsxs("label",{style:Yv,children:["Courriel",y.jsx("input",{type:"email",value:d,onChange:j=>f(j.target.value),required:!0,disabled:R,placeholder:"toi@exemple.com",className:"lystech-support-field",style:Wv})]})]}),y.jsxs("label",{style:Yv,children:["Message",y.jsx("textarea",{value:h,onChange:j=>v(j.target.value),required:!0,disabled:R,rows:4,placeholder:"Comment peut-on t'aider ?",className:"lystech-support-field",style:{...Wv,resize:"vertical",minHeight:96}})]}),y.jsxs("div",{style:{marginBottom:14},children:[y.jsx("input",{ref:E,type:"file",multiple:!0,accept:".pdf,image/*",onChange:N,style:{display:"none"}}),y.jsx("button",{type:"button",onClick:()=>{var j;return(j=E.current)==null?void 0:j.click()},disabled:R||x.length>=Vv,style:{...vY,opacity:R||x.length>=Vv?.6:1},children:"📎 Joindre un fichier (PDF / image)"}),x.length>0&&y.jsx("div",{style:{marginTop:8,display:"flex",flexDirection:"column",gap:6},children:x.map((j,D)=>y.jsxs("div",{style:gY,children:[y.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:j.name}),y.jsx("button",{type:"button",onClick:()=>A(z=>z.filter((F,V)=>V!==D)),"aria-label":"Retirer le fichier",style:pY,children:y.jsx(ml,{size:14})})]},D))})]}),m==="error"&&C&&y.jsx("div",{role:"alert",style:{color:"#b91c1c",fontSize:13,marginBottom:12},children:C}),y.jsx("button",{type:"submit",disabled:R,className:"lystech-support-send-btn",style:{width:"100%",padding:"12px 16px",marginTop:2,backgroundColor:vl,color:"#ffffff",border:"none",borderRadius:11,fontSize:15,fontWeight:600,letterSpacing:.2,cursor:R?"default":"pointer",opacity:R?.7:1,boxShadow:"0 4px 12px rgba(15, 118, 110, 0.24)",transition:"background-color 0.15s ease, box-shadow 0.15s ease"},children:R?"Envoi…":"Envoyer"})]})]}),y.jsx("button",{type:"button",onClick:L,"aria-label":"Contacter le support","aria-expanded":o,className:"lystech-support-fab",style:{pointerEvents:"auto",width:SE,height:SE,borderRadius:"50%",backgroundColor:vl,color:"#ffffff",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 6px 16px rgba(0, 0, 0, 0.24)",transition:"background-color 0.15s ease, transform 0.15s ease"},children:y.jsx(Lv,{size:28,weight:"fill"})})]})}const Yv={display:"block",fontSize:13,fontWeight:600,color:"#374151",marginBottom:14},Wv={display:"block",width:"100%",marginTop:6,padding:"11px 13px",fontSize:14,color:"#1f2937",backgroundColor:"#f9fafb",border:"1px solid #e5e7eb",borderRadius:10,boxSizing:"border-box",fontFamily:"inherit"},vY={display:"inline-flex",alignItems:"center",gap:6,padding:"8px 12px",fontSize:13,fontWeight:600,color:vl,backgroundColor:"rgba(15, 118, 110, 0.08)",border:"1px dashed rgba(15, 118, 110, 0.4)",borderRadius:10,cursor:"pointer",fontFamily:"inherit"},gY={display:"flex",alignItems:"center",gap:8,padding:"6px 10px",fontSize:12.5,color:"#374151",backgroundColor:"#f9fafb",border:"1px solid #e5e7eb",borderRadius:8},pY={display:"inline-flex",alignItems:"center",justifyContent:"center",background:"transparent",border:"none",color:"#9ca3af",cursor:"pointer",padding:2,lineHeight:0,flexShrink:0},bY="@lystech/core",yY="lystechcorenpmpackage:last-version",OE="3.0.78";function ME(e={}){const{packageName:t=bY,storageKey:n=yY,triggerOnFirstInstall:r=!1,onPackageUpdated:a}=e,[i,o]=O.useState(null),[s]=O.useState(OE),[c,u]=O.useState(!1),[d,f]=O.useState(!1),h=O.useCallback(()=>{if(typeof window>"u")return;const v=localStorage.getItem(n),g=!v,p=!!v&&v!==s;if(o(v),u(g),f(p),g||p){const m={packageName:t,previousVersion:v,currentVersion:s,isFirstInstall:g,hasUpdated:p};(p||g&&r)&&(a==null||a(m)),window.dispatchEvent(new CustomEvent("lystechcorenpmpackage:update",{detail:m}))}localStorage.setItem(n,s)},[n,s,t,r,a]);return O.useEffect(()=>{h()},[h]),O.useMemo(()=>({packageName:t,previousVersion:i,currentVersion:s,isFirstInstall:c,hasUpdated:d,checkForUpdate:h}),[t,i,s,c,d,h])}const CY=new K3({defaultOptions:{queries:{staleTime:1e3*60*5,retry:3,refetchOnWindowFocus:!1}}}),PE=O.createContext({}),zi=()=>O.useContext(PE);function wY({children:e,organization:t,shouldRedirectAfterLogin:n,loginRedirectRoute:r,queryClient:a,usePushNotifications:i,useProgressiveWebAppFeatures:o,useThemeProvider:s,quickGoogleLoginButtonStyle:c,enableGoogleQuickLoginButton:u,showGoogleQuickLoginButton:d,useGoogleAutoSelect:f,debugMode:h,showAskPermissionsButtons:v,hideSupportButton:g,onPackageUpdated:p,triggerOnFirstInstallPackageCallback:m,packageVersionStorageKey:b}){const C=a||CY;ME({onPackageUpdated:p,triggerOnFirstInstall:!!m,storageKey:b});const w=y.jsxs(PE.Provider,{value:{debugMode:h,usePushNotifications:i,useProgressiveWebAppFeatures:o},children:[h&&y.jsxs("div",{className:"p-10",children:[y.jsx("h2",{children:"DEBUG MODE"}),y.jsxs("p",{children:["Organization: ",t]})]}),y.jsx(NV,{children:y.jsx(xV,{children:y.jsx(eP,{client:C,children:y.jsx(PV,{usePushNotifications:i,children:y.jsx(AV,{children:y.jsx(SY,{organization:t,children:y.jsx(MY,{shouldRedirectAfterLogin:n,loginRedirectRoute:r,quickGoogleLoginButtonStyle:c,enableGoogleQuickLoginButton:u,showGoogleQuickLoginButton:d,useGoogleAutoSelect:f,children:y.jsxs(Kx,{children:[e,v&&y.jsx(wE,{enableInstallAppButton:v==null?void 0:v.installApp,enablePushNotificationButton:v==null?void 0:v.pushNotifications}),!g&&y.jsx(AE,{})]})})})})})})})})]});return s?y.jsx(RV,{children:w}):w}const NE=O.createContext({});function Lr(){return O.useContext(NE)}function SY({children:e,organization:t}){const n=Of(),{debugMode:r}=zi(),[a,i]=O.useState(t||"");O.useEffect(()=>{if(t){r&&console.log("OrganizationProvider: organization prop utilisée",t),i(t);return}const x=new URLSearchParams(n.search),A=x.get("org");if(A){r&&console.log("OrganizationProvider: paramètre ?org= trouvé dans l'URL",A),x.delete("org");const S=`${n.pathname}${x.toString()?"?"+x.toString():""}`;window.history.replaceState({},"",S),i(A)}else{const S=localStorage.getItem("Organization");S?(r&&console.log("OrganizationProvider: organisation trouvée dans le localStorage",S),i(S)):r&&console.log("OrganizationProvider: aucune organisation trouvée")}},[t,n.search,n.pathname,r]);function o(x){r&&console.log("User logged in:",x),!a&&!t&&x!=null&&x.defaultOrganization&&i(x.defaultOrganization)}const{data:s,isLoading:c,refetch:u}=u1(a),d=yf();function f(){u(),d.invalidateQueries()}O.useEffect(()=>{f()},[a]),O.useEffect(()=>{localStorage.removeItem("invalid-organizations")},[]);const[h,v]=O.useState(""),[g,p]=O.useState({clientId:"",appSecret:"",clientIdSandbox:"",appSecretSandbox:"",enabled:!1});O.useEffect(()=>{localStorage.setItem("Organization",a),r&&(a?console.log("OrganizationProvider: organisation mise à jour dans le localStorage",a):console.warn("OrganizationProvider: organisationState est vide, pas de mise à jour dans le localStorage"))},[a]),O.useEffect(()=>{v((s==null?void 0:s.image)??""),s&&p({clientId:(s==null?void 0:s.paypalClientId)??"",appSecret:(s==null?void 0:s.paypalAppSecret)??"",clientIdSandbox:(s==null?void 0:s.paypalClientIdSandbox)??"",appSecretSandbox:(s==null?void 0:s.paypalAppSecretSandbox)??"",enabled:!!s.paypalEnabled||!1})},[s]);async function m(x){const A=await P3(x);return A!=null&&A.success&&u(),A==null?void 0:A.success}async function b(x){const A=await N3(x);return A!=null&&A.success&&(u(),p(S=>({...S,enabled:x}))),A==null?void 0:A.success}async function C(){await R3(),u()}async function w(x,A,S){const E=await I3(x,A,S);return f(),E}return y.jsx(NE.Provider,{value:{organization:a,organizationImage:h,organizationDetails:s??void 0,areOrganizationDetailsLoading:c,paypalInfo:g,onLoggedIn:o,updateOrganizationDetails:m,updatePaypalConfiguration:w,toggleOrganizationMode:C,updateOrganizationPaypalEnabled:b,refetchOrganizationDetails:f},children:e})}async function xY(){return await Nt.get("/users/roles")}const IE=(e,t)=>mr(["user-role-details",e,t],xY,{enabled:!!e,select:n=>n==null?void 0:n.data,onError:n=>{console.error("Error fetching user role details:",n)}}),EY={apiKey:"AIzaSyCpAeHlt1wZvM5KtYg7X7MDVnWVJT86gvc",authDomain:"lystech.firebaseapp.com",databaseURL:"https://lystech.firebaseio.com",projectId:"lystech",storageBucket:"lystech.appspot.com",messagingSenderId:"237347321732",appId:"1:237347321732:web:7f9586d48e488d73ddcfd1"};async function RE(e){const t=new FormData;t.append("image",e);const n=await Nt.put("users/image",t,{headers:{"Content-Type":"multipart/form-data"},data:t});return n==null?void 0:n.data}async function DE(e,t){const n=await Nt.put("users/image/url",{authKey:e,imageUrl:t});return n==null?void 0:n.data}async function AY(e){const t=await Nt.post("auth/request-reset-password",{email:e});return t==null?void 0:t.data}async function OY(e){const t=await Nt.post(`auth/activate/${e}`);return t==null?void 0:t.data}async function jE(e){return await Nt.post("auth/register",{...e})}const TE=O.createContext({});function ar(){return O.useContext(TE)}function MY({children:e,shouldRedirectAfterLogin:t,loginRedirectRoute:n,quickGoogleLoginButtonStyle:r,enableGoogleQuickLoginButton:a,showGoogleQuickLoginButton:i,useGoogleAutoSelect:o=!0}){var _,te,se,$,fe,oe,ye;const[s,c]=O.useState(n||null),{debugMode:u}=zi();$g(EY);const{organization:d,onLoggedIn:f}=Lr(),h=O.useCallback(()=>{const le=sessionStorage.getItem("username");if(le)return{id:parseInt(sessionStorage.getItem("id")||"-1"),displayName:le,firstName:sessionStorage.getItem("firstName")||"",lastName:sessionStorage.getItem("lastName")||"",birthday:sessionStorage.getItem("birthday")?new Date(sessionStorage.getItem("birthday")):null,email:sessionStorage.getItem("email")||"",UID:sessionStorage.getItem("authKey")||"",profileImage:sessionStorage.getItem("profileImage")||"",notifyCoffee:sessionStorage.getItem("notifyCoffee")?parseInt(sessionStorage.getItem("notifyCoffee")):0,defaultOrganization:sessionStorage.getItem("defaultOrganization")||"",thirdPartyAuthUID:sessionStorage.getItem("thirdPartyAuthUID")||"",roleDetails:{role:"",isOwner:!1,isSuperAdmin:!1,isAdmin:!1,isUser:!1,isSuperAdminOrMore:!1,isAdminOrMore:!1,isUserOrMore:!1,isAdminInAnyOrganization:!1},type:"emailPassword",activatedOn:"",approvedBy:""}},[]),v=O.useCallback(()=>{const ne=h();return ne||{}},[h]);function g(ne){p&&(p.notifyCoffee=ne,m({...p}),sessionStorage.setItem("notifyCoffee",ne.toString()))}const[p,m]=O.useState(v()),b=O.useCallback(async ne=>{const{success:le,url:me}=await RE(ne);return le&&(p.photoURL=me,p.profileImage=me,m({...p}),sessionStorage.setItem("profileImage",me||"")),le},[p,m]),C=O.useCallback(async ne=>{const{success:le,url:me}=await DE(p==null?void 0:p.UID,ne);return le&&(p.photoURL=me,p.profileImage=me,m({...p}),sessionStorage.setItem("profileImage",me||"")),le},[p,m]),w=O.useCallback(ne=>{p.firstName=ne,m({...p}),sessionStorage.setItem("firstName",ne)},[p,m]),x=O.useCallback(ne=>{p.lastName=ne,m({...p}),sessionStorage.setItem("lastName",ne)},[p,m]),A=x1(),S=KO(),E=O.useMemo(()=>{if(p&&p.id!==-1&&p!=null&&p.UID)return{id:p.id,UID:p.UID,thirdPartyAuthUID:p.thirdPartyAuthUID,displayName:p.displayName,firstName:p.firstName,lastName:p.lastName,birthday:p.birthday,profileImage:p.profileImage,defaultOrganization:p.defaultOrganization,email:p.email,roleDetails:p.roleDetails,type:"emailPassword",activatedOn:p.activatedOn,notifyCoffee:p.notifyCoffee,approvedBy:p.approvedBy}},[p]),{data:P,isLoading:M}=IE((E==null?void 0:E.UID)??"",d),N=O.useMemo(()=>({...E,roleDetails:P}),[E,P]),I=O.useMemo(()=>!!(E!=null&&E.UID)&&(E==null?void 0:E.id)!==-1,[E]);O.useEffect(()=>{localStorage.setItem("authKey",(E==null?void 0:E.UID)??"")},[E]);const[L,T]=O.useState(!0),R=O.useRef(!1);O.useEffect(()=>{R.current||(R.current=!0,z().finally(()=>T(!1)))},[]);const j=O.useRef(!1),D=O.useRef(()=>{});O.useEffect(()=>{const ne=Nt.interceptors.response.use(le=>le,le=>{var me;return((me=le==null?void 0:le.response)==null?void 0:me.status)===401&&j.current&&(console.warn("[Auth] 401 reçu alors que connecté — session invalide, déconnexion locale."),D.current()),Promise.reject(le)});return()=>{Nt.interceptors.response.eject(ne)}},[]),O.useEffect(()=>{j.current=I},[I]),O.useEffect(()=>{D.current=()=>ee(null)});async function z(){try{const ne=await Nt.get("/auth/me");return console.log("Validate Me Response",ne),ne.data&&ee(ne==null?void 0:ne.data),ne==null?void 0:ne.data}catch(ne){return console.log("Validate Me Error",ne),null}finally{T(!1)}}O.useEffect(()=>{P&&localStorage.setItem("userRoleDetails",JSON.stringify(P))},[P]);const F=O.useMemo(()=>{if(!I)return"/login";let ne="";return P&&(ne="/past-orders"),ne===""&&(ne="/"),("/"+ne+"/").replace(/\/+/g,"/")},[P,I]);async function V(ne,le,me,ue=()=>{},xe=()=>{},we=0){try{const be={email:ne,password:le},Se=await Nt.get("/auth/login",{headers:be}),Ne=!!Se.data;me({result:Ne,data:Se==null?void 0:Se.data}),we>0?setTimeout(()=>{ee(Se==null?void 0:Se.data),t&&s&&A(s),f&&f(Se==null?void 0:Se.data)},we):(ee(Se==null?void 0:Se.data),f&&f(Se==null?void 0:Se.data),t&&s&&A(s))}catch(be){console.log("Login Error",be),(be==null?void 0:be.status)===403?ue(be):xe(be)}}async function W(ne,le,me){const ue=await Nt.post("/auth/login/third-party",{providerData:ne,token:le,tokenType:me}),xe=ue==null?void 0:ue.data;if(!xe){console.error("No user data returned from third-party login");return}return ee(xe),f&&f(xe),ue}async function k(){var ne,le,me,ue;try{const xe=new ya;xe.setCustomParameters({prompt:"select_account"});const we=await Q0(S,xe);if(((le=(ne=we==null?void 0:we.user)==null?void 0:ne.providerData)==null?void 0:le.length)===0||!((me=we==null?void 0:we.user)!=null&&me.providerData))return;const be=(ue=we==null?void 0:we.user)==null?void 0:ue.providerData[0],Se=await we.user.getIdToken();return await W(be,Se,"firebase")}catch(xe){console.error("Google login failed",xe)}}async function H(){var ne;try{const le=new ba,me=await Q0(S,le),ue=(ne=me==null?void 0:me.user)==null?void 0:ne.providerData[0],xe=await me.user.getIdToken();return await W(ue,xe,"firebase")}catch(le){console.error("Facebook login failed",le)}}async function B(){try{await Nt.post("/auth/logout")}catch(ne){console.warn("Déconnexion serveur échouée",ne)}sessionStorage.clear(),localStorage.clear(),ee(null),L6(S),A("/")}async function U(ne){const le=rM(ne.credential);if(le!=null&&le.email){let me="unknown.com";le!=null&&le.iss.includes("google")?me="google.com":le!=null&&le.iss.includes("facebook")&&(me="facebook.com");const ue={displayName:le==null?void 0:le.given_name,email:le==null?void 0:le.email,phoneNumber:null,photoURL:le==null?void 0:le.picture,providerId:me,uid:le==null?void 0:le.sub};return await W(ue,ne.credential,"google")}}const Y=()=>{console.error("Google login failed")};function X(ne){t&&s&&A(s)}function q(ne){var le;if(!ne){sessionStorage.clear();return}sessionStorage.setItem("username",ne.displayName),sessionStorage.setItem("email",ne.email),sessionStorage.setItem("firstName",ne.firstName??""),sessionStorage.setItem("lastName",ne.lastName??""),sessionStorage.setItem("birthday",((le=ne.birthday)==null?void 0:le.toString())??""),sessionStorage.setItem("defaultOrganization",ne.defaultOrganization),sessionStorage.setItem("id",ne.id.toString()),sessionStorage.setItem("authKey",ne.UID),sessionStorage.setItem("thirdPartyAuthUID",ne.thirdPartyAuthUID),sessionStorage.setItem("profileImage",ne.profileImage),sessionStorage.setItem("notifyCoffee",ne.notifyCoffee.toString())}function ee(ne){m(ne),q(ne),(ne==null?void 0:ne.id)==-1&&(ne==null?void 0:ne.id)!=-1&&X()}const ae=O.useMemo(()=>{var ne,le,me;return I?!1:a!==void 0?a:!((ne=window==null?void 0:window.location)!=null&&ne.pathname.includes("/activate"))&&!((le=window==null?void 0:window.location)!=null&&le.pathname.includes("/account/reset-password"))&&!((me=window==null?void 0:window.location)!=null&&me.pathname.includes("/account/activation"))},[I,a,(_=window==null?void 0:window.location)==null?void 0:_.pathname]),ie=O.useMemo(()=>{var ne;return i!==void 0?i:ae&&!((ne=window==null?void 0:window.location)!=null&&ne.pathname.includes("/login"))},[ae,i,(te=window==null?void 0:window.location)==null?void 0:te.pathname]);return O.useEffect(()=>{u&&(console.log("AuthProvider - user.UID:",E==null?void 0:E.UID),console.log("AuthProvider - isLoggedIn:",I))},[E==null?void 0:E.UID,I]),y.jsx(qO,{clientId:"237347321732-65nra8lcs59qn6dms77ruad01vjdr7ph.apps.googleusercontent.com",children:y.jsxs(TE.Provider,{value:{user:E?{...E,roleDetails:P||{role:"",isOwner:!1,isSuperAdmin:!1,isAdmin:!1,isUser:!1,isSuperAdminOrMore:!1,isAdminOrMore:!1,isUserOrMore:!1,isAdminInAnyOrganization:!1}}:void 0,currentUser:N,auth:S,isLoggedIn:I,isCheckingSession:L,isSuperAdmin:!!((se=N==null?void 0:N.roleDetails)!=null&&se.isSuperAdminOrMore),isAdmin:!!(($=N==null?void 0:N.roleDetails)!=null&&$.isAdminOrMore),isUser:!!((fe=N==null?void 0:N.roleDetails)!=null&&fe.isUserOrMore),isSuperAdminInAnyOrganization:!!((oe=N==null?void 0:N.roleDetails)!=null&&oe.isSuperAdminOrMore),isAdminInAnyOrganization:!!((ye=N==null?void 0:N.roleDetails)!=null&&ye.isAdminInAnyOrganization),areRoleDetailsLoading:M,homeRoute:F,setLoginRedirectRouteState:c,registerNewUser:jE,signInWithEmailAndPassword:V,signInWithGoogle:k,signInWithFacebook:H,logout:B,requestResetPassword:AY,activateUser:OY,updateUserImage:b,updateUserImageUrl:C,updateUserFirstName:w,updateUserLastName:x,updateNotificationState:g},children:[u&&y.jsx("div",{className:"p-10",children:y.jsxs("p",{children:["Login Redirect Route State: ",y.jsx("b",{children:s||"null"})]})}),e,ae&&y.jsx("div",{className:`fixed top-10 right-10 ${ie?"":"hidden"}`,style:r,children:y.jsx(eM,{onSuccess:U,onError:Y,auto_select:o,useOneTap:!0,type:"icon"})})]})})}async function PY(){return(await Nt.get("/politique-and-conditions/9716a5de-02be-4fb2-b9b5-85ad82bfae4f")).data}async function NY(){return(await Nt.get("/politique-and-conditions")).data}const LE=()=>mr({queryKey:["lystech-politique-and-conditions"],queryFn:PY}),FE=e=>mr({queryKey:["politique-and-conditions",e],queryFn:NY,enabled:!!e});async function IY(){const e=await Nt.get("collections/invitation");return(e==null?void 0:e.data)||[]}const Qu=(e,t)=>mr(["invitedToOrders",e,t],IY,{staleTime:1e3*60*2,select:n=>t?n.filter(r=>r.organization.subdomain===t):n,enabled:!!e});async function RY(e,t){const n={code:e,products:t},r=await Nt.post("promo-codes/validate",n);return r==null?void 0:r.data}async function zE(){const e=await Nt.get("promo-codes/user");return e==null?void 0:e.data}const DY=e=>mr(["personal-promo-codes",e],zE,{enabled:!!e,refetchInterval:45*1e3,refetchOnWindowFocus:!0});async function kE(){const e=await Nt.get("images/featured");return e==null?void 0:e.data}const jY=()=>mr(["featured-images"],kE,{onError:e=>{console.error("Error fetching featured images:",e)}});async function HE(e){const t=await Nt.get(`/posts/slug/${e}`);if(t.status!==200)throw new Error(`Error fetching post with ID ${e}: ${t.statusText}`);return t.data}const TY=(e,t)=>mr(["single-post",e,t],()=>HE(e));async function LY(e){const t=await Nt.get(`/shop/collection/${e}`);return t==null?void 0:t.data}async function FY(e,t){const n=await Nt.post("/shop/breakdown",{products:e,promoCodes:t});return n==null?void 0:n.data}async function zY(e){const t=await Nt.post("/shop/save",e);return t==null?void 0:t.data}const BE=(e,t,n)=>mr(["order-details-breakdown",e,t.map(r=>r.UID),t.map(r=>r.quantity),n.map(r=>r.toLowerCase())],async()=>await FY(t,n),{enabled:!!e&&t.length>0}),kY=()=>yf();async function HY(){try{const e=await Nt.get("/shop/collections");return localStorage.setItem("collections",JSON.stringify(e==null?void 0:e.data)),(e==null?void 0:e.data)||[]}catch(e){return console.log(e),[]}}async function VE(e){var n;const t=await Nt.post("stripe/checkout",e);if(t.status===200&&((n=t.data)!=null&&n.url))return t.data;throw new Error("Failed to create Stripe checkout session")}const YE=({onSuccess:e,onAccountNotActivated:t,onAccountNotFound:n,onError:r,className:a="",showTitle:i=!0,title:o="Se connecter",loginButtonText:s="Se connecter",pendingConnexionButtonText:c="Connexion...",passwordFieldLabel:u="Mot de passe",emailFieldLabel:d="Email",emailFieldPlaceholder:f="Votre email",passwordFieldPlaceholder:h="••••••••••••",loginSuccessMessage:v="Connexion réussie",unknownErrorMessage:g="Une erreur inconnue est survenue.",showForgotPassword:p=!1,forgotPasswordText:m="Mot de passe oublié ?",onForgotPassword:b})=>{const C=ar(),w=Qr(),[x,A]=O.useState({email:"",password:""}),[S,E]=O.useState(!1),[P,M]=O.useState(!1),N=(L,T)=>{A(R=>({...R,[L]:T}))},I=async L=>{var T,R,j;L.preventDefault(),E(!0);try{await C.signInWithEmailAndPassword(x.email,x.password,D=>{e?e(D):w.showMessage({type:"success",message:v})},D=>{t?t(D):w.showMessage({type:"warning",message:D==null?void 0:D.message})},D=>{n?n(D):w.showMessage({type:"error",message:D==null?void 0:D.message})})}catch(D){const z=D instanceof Error?D:new Error("Erreur inconnue");if(r)r(z);else{const F=(j=(R=(T=D.error)==null?void 0:T.response)==null?void 0:R.data)==null?void 0:j.message;w.showMessage({type:"error",message:F||g})}}finally{E(!1)}};return y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:`auth-form ${a}`,children:[i&&y.jsx("h2",{children:o}),y.jsx("div",{className:"form-row",children:y.jsxs("div",{className:"form-group",children:[y.jsx("label",{htmlFor:"email",children:d}),y.jsxs("div",{className:"auth-field",children:[y.jsx("span",{className:"auth-field__icon",children:y.jsx(Gu,{size:18})}),y.jsx("input",{type:"email",id:"email",value:x.email,onChange:L=>N("email",L.target.value),required:!0,placeholder:f})]})]})}),y.jsx("div",{className:"form-row",children:y.jsxs("div",{className:"form-group",children:[y.jsx("label",{htmlFor:"password",children:u}),y.jsxs("div",{className:"auth-field",children:[y.jsx("span",{className:"auth-field__icon",children:y.jsx(Ku,{size:18})}),y.jsx("input",{type:P?"text":"password",id:"password",value:x.password,onChange:L=>N("password",L.target.value),required:!0,placeholder:h}),y.jsx("button",{type:"button",className:"auth-field__icon auth-field__eye",onClick:()=>M(L=>!L),"aria-label":P?"Masquer le mot de passe":"Afficher le mot de passe",children:P?y.jsx(oE,{size:18}):y.jsx(iE,{size:18})})]})]})}),p&&b&&y.jsx("div",{className:"auth-form__forgot",children:y.jsx("button",{type:"button",className:"link-button",onClick:b,children:m})}),y.jsx("button",{type:"button",disabled:S||!x.email.trim()||!x.password.trim(),className:"btn btn-primary",onClick:I,children:S?c:s})]}),y.jsx("div",{className:"auth-divider",children:"ou continuer avec"}),y.jsxs("div",{className:"third-party-row",children:[y.jsxs("button",{type:"button",className:"third-party-login-button login-with-google",onClick:()=>C.signInWithGoogle(),children:[y.jsx(cE,{size:20,weight:"bold"})," Google"]}),y.jsxs("button",{type:"button",className:"third-party-login-button login-with-facebook",onClick:()=>C.signInWithFacebook(),children:[y.jsx(sE,{size:20,weight:"fill"})," Facebook"]})]})]})},WE=({onSuccess:e,onEmailAlreadyExists:t,onError:n,className:r="",showTitle:a=!0,title:i="Créer un compte",showBirthdayField:o=!0,firstNameFieldLabel:s="Prénom",firstNameFieldPlaceholder:c="Votre prénom",lastNameFieldLabel:u="Nom",lastNameFieldPlaceholder:d="Votre nom",emailFieldLabel:f="Email",emailFieldPlaceholder:h="Votre email",birthdayFieldLabel:v="Date de naissance",birthdayFieldPlaceholder:g="Votre date de naissance",passwordFieldLabel:p="Mot de passe",passwordFieldPlaceholder:m="••••••••••••",confirmPasswordFieldLabel:b="Confirmation du mot de passe",confirmPasswordFieldPlaceholder:C="••••••••••••",createAccountButtonText:w="Créer le compte",creatingAccountButtonText:x="Création en cours...",accountCreatedMessage:A="Compte créé avec succès !",accountAlreadyExistsMessage:S="Un compte avec cet email existe déjà.",errorMessage:E="Une erreur est survenue lors de la création du compte.",passwordNotMatchMessage:P="Les mots de passe ne correspondent pas.",politiqueAndConditionsConsentTexte:M="En créant un compte, j'accepte les termes et conditions.",seePolitiqueAndConditions:N="Voir les termes et conditions",politiqueAndConditionsRoute:I="/conditions"})=>{const L=ar(),T=Qr(),[R,j]=O.useState({firstName:"",lastName:"",email:"",birthday:"",password:"",confirmPassword:""}),[D,z]=O.useState(!1),F=(W,k)=>{j(H=>({...H,[W]:k}))},V=async W=>{var k,H,B;if(W.preventDefault(),z(!0),R.password!==R.confirmPassword){T.showMessage({type:"error",message:P}),z(!1);return}try{L.registerNewUser?(await L.registerNewUser({username:R.email,email:R.email,password:R.password,firstName:R.firstName,lastName:R.lastName,birthday:R.birthday||void 0}),e?e():T.showMessage({type:"success",message:A})):T.showMessage({type:"error",message:"La méthode d'enregistrement n'est pas disponible."})}catch(U){const Y=U instanceof Error?U:new Error("Erreur inconnue");if(n)console.log("Error in AuthRegisterForm:",Y),n(Y);else{const X=(B=(H=(k=U.error)==null?void 0:k.response)==null?void 0:H.data)==null?void 0:B.message;T.showMessage({type:"error",message:X})}}finally{z(!1)}};return y.jsxs("form",{onSubmit:V,className:`auth-form ${r}`,children:[a&&y.jsx("h2",{children:i}),y.jsx("div",{className:"form-row",children:y.jsxs("div",{className:"form-group",children:[y.jsx("label",{htmlFor:"firstName",children:s}),y.jsxs("div",{className:"auth-field",children:[y.jsx("span",{className:"auth-field__icon",children:y.jsx(Hv,{size:18})}),y.jsx("input",{type:"text",id:"firstName",value:R.firstName,onChange:W=>F("firstName",W.target.value),placeholder:c,required:!0})]})]})}),y.jsx("div",{className:"form-row",children:y.jsxs("div",{className:"form-group",children:[y.jsx("label",{htmlFor:"lastName",children:u}),y.jsxs("div",{className:"auth-field",children:[y.jsx("span",{className:"auth-field__icon",children:y.jsx(Hv,{size:18})}),y.jsx("input",{type:"text",id:"lastName",value:R.lastName,onChange:W=>F("lastName",W.target.value),required:!0,placeholder:d})]})]})}),y.jsx("div",{className:"form-row",children:y.jsxs("div",{className:"form-group",children:[y.jsx("label",{htmlFor:"email",children:f}),y.jsxs("div",{className:"auth-field",children:[y.jsx("span",{className:"auth-field__icon",children:y.jsx(Gu,{size:18})}),y.jsx("input",{type:"email",id:"email",value:R.email,onChange:W=>F("email",W.target.value),required:!0,placeholder:h})]})]})}),o&&y.jsx("div",{className:"form-row",children:y.jsxs("div",{className:"form-group",children:[y.jsx("label",{htmlFor:"birthday",children:v}),y.jsxs("div",{className:"auth-field",children:[y.jsx("span",{className:"auth-field__icon",children:y.jsx($x,{size:18})}),y.jsx("input",{type:"date",id:"birthday",value:R.birthday,onChange:W=>F("birthday",W.target.value)})]})]})}),y.jsx("div",{className:"form-row",children:y.jsxs("div",{className:"form-group",children:[y.jsx("label",{htmlFor:"password",children:p}),y.jsxs("div",{className:"auth-field",children:[y.jsx("span",{className:"auth-field__icon",children:y.jsx(Ku,{size:18})}),y.jsx("input",{type:"password",id:"password",value:R.password,onChange:W=>F("password",W.target.value),required:!0,placeholder:m})]})]})}),y.jsx("div",{className:"form-row",children:y.jsxs("div",{className:"form-group",children:[y.jsx("label",{htmlFor:"confirmPassword",children:b}),y.jsxs("div",{className:"auth-field",children:[y.jsx("span",{className:"auth-field__icon",children:y.jsx(Ku,{size:18})}),y.jsx("input",{type:"password",id:"confirmPassword",value:R.confirmPassword,onChange:W=>F("confirmPassword",W.target.value),required:!0,placeholder:C})]})]})}),y.jsx("div",{className:"form-row",children:y.jsx("div",{className:"form-group",style:{fontSize:"0.95em",color:"#555"},children:y.jsxs("span",{children:[M," ",y.jsx("a",{href:I,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--auth-accent)",textDecoration:"underline"},children:N})]})})}),y.jsx("button",{type:"submit",disabled:D,className:"btn btn-primary",children:D?x:w})]})},UE=({onSuccess:e,onError:t,className:n="",showTitle:r=!0,title:a="Réinitialiser le mot de passe",showDescription:i=!0,description:o="Entrez votre email pour recevoir un lien de réinitialisation.",emailFieldLabel:s="Email",confirmButtonText:c="Envoyer le lien",confirmingButtonText:u="Envoi en cours...",emailFieldPlaceholder:d="votre@email.com",activationMailSentMessage:f="Un email de réinitialisation a été envoyé à votre adresse.",errorMessage:h="Impossible d'envoyer l'email de réinitialisation."})=>{const v=ar(),g=Qr(),[p,m]=O.useState(""),[b,C]=O.useState(""),[w,x]=O.useState(!1),A=async E=>{E.preventDefault(),x(!0);try{const P=await v.requestResetPassword(p);C(p),e?e(p):g.showMessage({type:"success",message:f})}catch(P){const M=P instanceof Error?P:new Error("Erreur inconnue");t?t(M):g.showMessage({type:"error",message:`${h}`})}finally{x(!1)}},S=w||p===b||!p.trim();return y.jsxs("form",{onSubmit:A,className:`auth-form ${n}`,children:[r&&y.jsx("h2",{children:a}),i&&y.jsx("p",{className:"form-description",children:o}),y.jsx("div",{className:"form-row",children:y.jsxs("div",{className:"form-group",children:[y.jsx("label",{htmlFor:"email",children:s}),y.jsxs("div",{className:"auth-field",children:[y.jsx("span",{className:"auth-field__icon",children:y.jsx(Gu,{size:18})}),y.jsx("input",{type:"email",id:"email",value:p,onChange:E=>m(E.target.value),required:!0,placeholder:d})]})]})}),y.jsx("button",{type:"submit",disabled:S,className:"btn btn-primary",children:w?u:c})]})},GE=({onLogout:e,onClose:t,className:n="",showTitle:r=!0,title:a="Profil utilisateur",showCloseButton:i=!1,closeButtonText:o="Fermer",logoutSuccessMessage:s="Déconnexion réussie",logoutErrorMessage:c="Erreur lors de la déconnexion",disconnectedLabel:u="Non connecté",mustBeLoggedInMessage:d="Vous devez être connecté pour voir votre profil.",logoutButtonText:f="Se déconnecter",emailLabel:h="Email",nameLabel:v="Nom",idLabel:g="ID"})=>{var C,w,x;const p=ar(),m=Qr(),b=async()=>{try{await p.logout(),e?e():m.showMessage({type:"success",message:s})}catch(A){console.error("Erreur lors de la déconnexion:",A),m.showMessage({type:"error",message:c})}};return p.isLoggedIn?y.jsxs("div",{className:`user-profile ${n}`,children:[y.jsx("div",{className:"profile-icon",children:"👤"}),r&&y.jsx("h2",{children:a}),y.jsxs("div",{className:"user-info",children:[y.jsxs("div",{className:"info-item",children:[y.jsxs("span",{className:"label",children:[h,":"]}),y.jsx("span",{className:"value",children:((C=p.currentUser)==null?void 0:C.email)||"N/A"})]}),y.jsxs("div",{className:"info-item",children:[y.jsxs("span",{className:"label",children:[v,":"]}),y.jsx("span",{className:"value",children:((w=p.currentUser)==null?void 0:w.displayName)||"N/A"})]}),y.jsxs("div",{className:"info-item",children:[y.jsxs("span",{className:"label",children:[g,":"]}),y.jsx("span",{className:"value",children:((x=p.currentUser)==null?void 0:x.id)||"N/A"})]})]}),y.jsxs("div",{className:"profile-actions",children:[y.jsx("button",{onClick:b,className:"btn btn-logout",children:f}),i&&t&&y.jsx("button",{onClick:t,className:"btn btn-secondary",children:o})]})]}):y.jsxs("div",{className:`user-profile ${n}`,children:[y.jsx("div",{className:"profile-icon",children:"🔒"}),y.jsx("h2",{children:u}),y.jsx("p",{children:d})]})};function KE(){const{organization:e}=Lr(),{data:t,isLoading:n}=LE(),{data:r,isLoading:a}=FE(e),i=O.useMemo(()=>n||a?[]:e!=="lystech"?[...r||[],...t||[]]:r||[],[t,r,n,a,e]);return y.jsx("div",{className:"flex col gap-10",style:{padding:"20px",textAlign:"left"},children:i&&i.map(o=>y.jsxs("div",{className:"p-4 border rounded bg-white",children:[y.jsx("div",{dangerouslySetInnerHTML:{__html:o.content}}),y.jsx("div",{className:"text-xs text-gray-500 mt-2",children:o.updatedOn?`Updated: ${new Date(o.updatedOn).toLocaleString()}`:""})]},o.id))})}function BY(){const{showMessage:e}=Qr(),{activateUser:t}=ar(),{token:n}=PP(),[r,a]=O.useState(!1),[i,o]=O.useState(!1),s=O.useRef(!1),[c,u]=O.useState(null);async function d(f){if(!s.current){s.current=!0,u({type:"info",content:"Activation en cours..."}),a(!0);try{const h=await t(f);return h!=null&&h.success?(e({message:"Votre compte a été activé avec succès.",type:"success",duration:1e4}),o(!0),u({type:"success",content:"Votre compte a été activé avec succès. Redirection..."}),setTimeout(()=>{if(h!=null&&h.redirectionUrl){window.location.href=h.redirectionUrl;return}else window.location.href="/login"},3e3)):(e({message:"L'activation de votre compte a échoué ou ce lien est expiré.",type:"error",duration:1e4}),u({type:"error",content:"L'activation de votre compte a échoué ou ce lien est expiré."})),h}catch{return e({message:"Une erreur s'est produite lors de l'activation de votre compte.",type:"error",duration:1e4}),u({type:"error",content:"Une erreur s'est produite lors de l'activation de votre compte."}),null}finally{a(!1)}}}return O.useEffect(()=>{n&&!i&&!r&&!s.current&&d(n)},[n,i,r]),y.jsx("div",{className:"account-activation auth-theme-container",children:y.jsx("div",{className:"auth-theme-content",children:y.jsx("div",{className:`auth-message ${(c==null?void 0:c.type)||""}`.trim(),children:c==null?void 0:c.content})})})}const VY=({onSuccess:e,onCancel:t,style:n,className:r="",centered:a=!1,showLogo:i=!0,logoSrc:o,appName:s="",defaultMode:c="login",cancelButtonText:u="Annuler",returnToLoginButtonText:d="Retour à la connexion",showTitle:f=!0,title:h="",showLoginForm:v=!0,showRegisterForm:g=!0,showForgotPasswordForm:p=!0,loginButtonText:m="Se connecter",registerButtonText:b="S'inscrire",forgotPasswordButtonText:C="Réinitialiser le mot de passe",loginFormProps:w={},registerFormProps:x={},forgotPasswordFormProps:A={},politiqueAndConditionsConsentTexte:S="En créant un compte, j'ai lu, compris et j'accepte les règles d'utilisation.",seePolitiqueAndConditions:E="Voir les termes et conditions",politiqueAndConditionsRoute:P="/conditions"})=>{const M=ar(),N=Of(),[I,L]=O.useState(c),T=!!P&&(N==null?void 0:N.pathname)===P,R=()=>{e==null||e()},j=()=>{L("login")},D=()=>{L("login")},z=()=>{};return T?y.jsx(KE,{}):M.isLoggedIn?y.jsx("div",{className:`auth-template connected ${r}`,style:{...n,...a?{maxWidth:"400px",margin:"0 auto",padding:"20px"}:{}},children:y.jsxs("div",{className:"auth-container",children:[i&&y.jsxs("div",{className:"auth-header",children:[o&&y.jsx("img",{src:o,alt:s,className:"auth-logo"}),y.jsx("h1",{children:s})]}),y.jsx(GE,{onLogout:z,onClose:t,showCloseButton:!!t})]})}):y.jsx("div",{className:`auth-template ${r}`,style:{...n,...a?{maxWidth:"400px",margin:"0 auto",padding:"20px"}:{}},children:y.jsxs("div",{className:"auth-container",children:[i&&y.jsxs("div",{className:"auth-header",children:[o&&y.jsx("img",{src:o,alt:s,className:"auth-logo"}),y.jsx("h1",{children:s})]}),f&&y.jsx("div",{className:"auth-title",children:y.jsx("h2",{children:h})}),y.jsxs("div",{className:"auth-tabs",children:[v&&y.jsx("button",{className:`tab ${I==="login"?"active":""}`,onClick:()=>L("login"),children:m}),g&&y.jsx("button",{className:`tab ${I==="register"?"active":""}`,onClick:()=>L("register"),children:b})]}),y.jsxs("div",{className:"auth-content",children:[I==="login"&&v&&y.jsx("div",{children:y.jsx(YE,{onSuccess:R,loginButtonText:"Se connecter",className:"auth-login-form",showTitle:!1,showForgotPassword:p,forgotPasswordText:C,onForgotPassword:()=>L("forgot-password"),...w})}),I==="register"&&g&&y.jsx(WE,{onSuccess:j,politiqueAndConditionsConsentTexte:S,seePolitiqueAndConditions:E,politiqueAndConditionsRoute:P,...x}),I==="forgot-password"&&p&&y.jsxs("div",{children:[y.jsx(UE,{onSuccess:D,...A}),y.jsx("div",{className:"auth-links",children:y.jsxs("button",{type:"button",onClick:()=>L("login"),className:"link-button",children:["← ",d]})})]}),I==="activation"&&y.jsx(BY,{})]}),t&&y.jsx("div",{className:"auth-footer",children:y.jsx("button",{onClick:t,className:"btn btn-secondary",children:u})})]})})};function Xu(){const{organizationDetails:e}=Lr();return y.jsxs("div",{style:{width:"100%",minHeight:"400px",display:"flex",justifyContent:"center",alignItems:"center",fontSize:18,color:"#888"},children:[y.jsx("div",{className:"loading-spinner",style:{width:48,height:48,border:"6px solid #eee",borderTop:`6px solid ${(e==null?void 0:e.primaryColor)||"#1677ff"}`,borderRadius:"50%",animation:"spin 1s linear infinite"}}),y.jsx("style",{children:`
|
|
1718
|
+
}`;function fY(){O.useEffect(()=>{if(typeof document>"u"||document.getElementById(EE))return;const e=document.createElement("style");e.id=EE,e.appendChild(document.createTextNode(dY)),document.head.appendChild(e)},[])}const Vv=5,hY=6*1024*1024;function mY(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{const a=String(r.result||""),i=a.indexOf(",");t(i>=0?a.slice(i+1):a)},r.onerror=()=>n(r.error),r.readAsDataURL(e)})}function AE(){const{organizationDetails:e}=Lr(),{isLoggedIn:t,currentUser:n}=ar();fY();const r=!!(t&&(n!=null&&n.email)),a=(n==null?void 0:n.email)??"",i=`${(n==null?void 0:n.firstName)??""} ${(n==null?void 0:n.lastName)??""}`.trim()||a,[o,s]=O.useState(!1),[c,u]=O.useState(""),[d,f]=O.useState(""),[h,v]=O.useState(""),[g,p]=O.useState(""),[m,b]=O.useState("idle"),[C,w]=O.useState(""),[x,A]=O.useState([]),S=O.useRef(null),E=O.useRef(null),P=O.useRef(null);O.useEffect(()=>{if(!o)return;const j=D=>{D.key==="Escape"&&s(!1)};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[o]),O.useEffect(()=>()=>{P.current&&clearTimeout(P.current)},[]);function M(){u(""),f(""),v(""),p(""),b("idle"),w(""),A([])}function N(j){const D=Array.from(j.target.files||[]),z=D.filter(F=>(F.type==="application/pdf"||F.type.startsWith("image/"))&&F.size<=hY);z.length<D.length&&w("PDF et images seulement (max ~6 Mo par fichier)."),A(F=>[...F,...z].slice(0,Vv)),j.target.value=""}function I(){s(!1),P.current&&(clearTimeout(P.current),P.current=null),setTimeout(M,250)}function L(){o?I():(M(),s(!0))}async function T(j){var D;if(j.preventDefault(),m!=="sending"){b("sending"),w("");try{const z=await Promise.all(x.map(async F=>({filename:F.name,contentType:F.type||"application/octet-stream",dataBase64:await mY(F)})));await Nt.post("/support/submit",{name:r?i:c,email:r?a:d,message:h,website:g,attachments:z.length>0?z:void 0}),b("success"),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{I()},2500)}catch(z){const F=(D=z==null?void 0:z.response)==null?void 0:D.status;F===429?(b("error"),w("Trop de messages, réessaie plus tard.")):F===409?I():(b("error"),w("Échec de l'envoi, réessaie."))}}}if(!(e!=null&&e.supportEnabled))return null;const R=m==="sending";return y.jsxs("div",{style:{position:"fixed",bottom:20,right:20,zIndex:cY,pointerEvents:"none",display:"flex",flexDirection:"column",alignItems:"flex-end",gap:12,fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif"},children:[o&&y.jsxs("div",{ref:S,role:"dialog","aria-label":"Formulaire de contact du support",style:{pointerEvents:"auto",width:"min(360px, calc(100vw - 32px))",maxHeight:"calc(100vh - 110px)",overflowY:"auto",backgroundColor:"#ffffff",color:"#1f2937",borderRadius:18,border:"1px solid rgba(15, 118, 110, 0.08)",boxShadow:"0 20px 48px rgba(15, 23, 42, 0.18), 0 4px 12px rgba(15, 23, 42, 0.08)",padding:22,boxSizing:"border-box",animation:"lystech-support-fade-in 0.2s cubic-bezier(0.16, 1, 0.3, 1)"},children:[y.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:12,marginBottom:18},children:[y.jsxs("div",{style:{display:"flex",alignItems:"center",gap:11},children:[y.jsx("span",{"aria-hidden":"true",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:38,height:38,borderRadius:11,backgroundColor:"rgba(15, 118, 110, 0.1)",color:vl,flexShrink:0},children:y.jsx(Lv,{size:22,weight:"fill"})}),y.jsxs("div",{children:[y.jsx("strong",{style:{display:"block",fontSize:16,lineHeight:1.25,color:"#111827"},children:"Contacter le support"}),y.jsx("span",{style:{display:"block",fontSize:12.5,lineHeight:1.4,color:"#6b7280",marginTop:2},children:"On te répond rapidement."})]})]}),y.jsx("button",{type:"button",onClick:I,"aria-label":"Fermer",className:"lystech-support-close",style:{background:"transparent",border:"none",cursor:"pointer",padding:6,display:"inline-flex",color:"#9ca3af",borderRadius:8,lineHeight:0,flexShrink:0,transition:"background-color 0.15s ease, color 0.15s ease"},children:y.jsx(ml,{size:20})})]}),m==="success"?y.jsx("div",{style:{padding:"24px 8px",textAlign:"center",fontSize:15,color:"#047857",fontWeight:600},children:"✓ Message envoyé, merci !"}):y.jsxs("form",{onSubmit:T,noValidate:!0,children:[y.jsx("input",{type:"text",name:"website",value:g,onChange:j=>p(j.target.value),tabIndex:-1,"aria-hidden":"true",autoComplete:"off",style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0}}),r?y.jsxs("div",{style:{fontSize:12.5,color:"#6b7280",marginBottom:14,lineHeight:1.4},children:["Connecté·e en tant que"," ",y.jsx("span",{style:{color:"#374151",fontWeight:600},children:a})]}):y.jsxs(y.Fragment,{children:[y.jsxs("label",{style:Yv,children:["Nom",y.jsx("input",{type:"text",value:c,onChange:j=>u(j.target.value),required:!0,disabled:R,placeholder:"Ton nom",className:"lystech-support-field",style:Wv})]}),y.jsxs("label",{style:Yv,children:["Courriel",y.jsx("input",{type:"email",value:d,onChange:j=>f(j.target.value),required:!0,disabled:R,placeholder:"toi@exemple.com",className:"lystech-support-field",style:Wv})]})]}),y.jsxs("label",{style:Yv,children:["Message",y.jsx("textarea",{value:h,onChange:j=>v(j.target.value),required:!0,disabled:R,rows:4,placeholder:"Comment peut-on t'aider ?",className:"lystech-support-field",style:{...Wv,resize:"vertical",minHeight:96}})]}),y.jsxs("div",{style:{marginBottom:14},children:[y.jsx("input",{ref:E,type:"file",multiple:!0,accept:".pdf,image/*",onChange:N,style:{display:"none"}}),y.jsx("button",{type:"button",onClick:()=>{var j;return(j=E.current)==null?void 0:j.click()},disabled:R||x.length>=Vv,style:{...vY,opacity:R||x.length>=Vv?.6:1},children:"📎 Joindre un fichier (PDF / image)"}),x.length>0&&y.jsx("div",{style:{marginTop:8,display:"flex",flexDirection:"column",gap:6},children:x.map((j,D)=>y.jsxs("div",{style:gY,children:[y.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:j.name}),y.jsx("button",{type:"button",onClick:()=>A(z=>z.filter((F,V)=>V!==D)),"aria-label":"Retirer le fichier",style:pY,children:y.jsx(ml,{size:14})})]},D))})]}),m==="error"&&C&&y.jsx("div",{role:"alert",style:{color:"#b91c1c",fontSize:13,marginBottom:12},children:C}),y.jsx("button",{type:"submit",disabled:R,className:"lystech-support-send-btn",style:{width:"100%",padding:"12px 16px",marginTop:2,backgroundColor:vl,color:"#ffffff",border:"none",borderRadius:11,fontSize:15,fontWeight:600,letterSpacing:.2,cursor:R?"default":"pointer",opacity:R?.7:1,boxShadow:"0 4px 12px rgba(15, 118, 110, 0.24)",transition:"background-color 0.15s ease, box-shadow 0.15s ease"},children:R?"Envoi…":"Envoyer"})]})]}),y.jsx("button",{type:"button",onClick:L,"aria-label":"Contacter le support","aria-expanded":o,className:"lystech-support-fab",style:{pointerEvents:"auto",width:SE,height:SE,borderRadius:"50%",backgroundColor:vl,color:"#ffffff",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 6px 16px rgba(0, 0, 0, 0.24)",transition:"background-color 0.15s ease, transform 0.15s ease"},children:y.jsx(Lv,{size:28,weight:"fill"})})]})}const Yv={display:"block",fontSize:13,fontWeight:600,color:"#374151",marginBottom:14},Wv={display:"block",width:"100%",marginTop:6,padding:"11px 13px",fontSize:14,color:"#1f2937",backgroundColor:"#f9fafb",border:"1px solid #e5e7eb",borderRadius:10,boxSizing:"border-box",fontFamily:"inherit"},vY={display:"inline-flex",alignItems:"center",gap:6,padding:"8px 12px",fontSize:13,fontWeight:600,color:vl,backgroundColor:"rgba(15, 118, 110, 0.08)",border:"1px dashed rgba(15, 118, 110, 0.4)",borderRadius:10,cursor:"pointer",fontFamily:"inherit"},gY={display:"flex",alignItems:"center",gap:8,padding:"6px 10px",fontSize:12.5,color:"#374151",backgroundColor:"#f9fafb",border:"1px solid #e5e7eb",borderRadius:8},pY={display:"inline-flex",alignItems:"center",justifyContent:"center",background:"transparent",border:"none",color:"#9ca3af",cursor:"pointer",padding:2,lineHeight:0,flexShrink:0},bY="@lystech/core",yY="lystechcorenpmpackage:last-version",OE="3.0.79";function ME(e={}){const{packageName:t=bY,storageKey:n=yY,triggerOnFirstInstall:r=!1,onPackageUpdated:a}=e,[i,o]=O.useState(null),[s]=O.useState(OE),[c,u]=O.useState(!1),[d,f]=O.useState(!1),h=O.useCallback(()=>{if(typeof window>"u")return;const v=localStorage.getItem(n),g=!v,p=!!v&&v!==s;if(o(v),u(g),f(p),g||p){const m={packageName:t,previousVersion:v,currentVersion:s,isFirstInstall:g,hasUpdated:p};(p||g&&r)&&(a==null||a(m)),window.dispatchEvent(new CustomEvent("lystechcorenpmpackage:update",{detail:m}))}localStorage.setItem(n,s)},[n,s,t,r,a]);return O.useEffect(()=>{h()},[h]),O.useMemo(()=>({packageName:t,previousVersion:i,currentVersion:s,isFirstInstall:c,hasUpdated:d,checkForUpdate:h}),[t,i,s,c,d,h])}const CY=new K3({defaultOptions:{queries:{staleTime:1e3*60*5,retry:3,refetchOnWindowFocus:!1}}}),PE=O.createContext({}),zi=()=>O.useContext(PE);function wY({children:e,organization:t,shouldRedirectAfterLogin:n,loginRedirectRoute:r,queryClient:a,usePushNotifications:i,useProgressiveWebAppFeatures:o,useThemeProvider:s,quickGoogleLoginButtonStyle:c,enableGoogleQuickLoginButton:u,showGoogleQuickLoginButton:d,useGoogleAutoSelect:f,debugMode:h,showAskPermissionsButtons:v,hideSupportButton:g,onPackageUpdated:p,triggerOnFirstInstallPackageCallback:m,packageVersionStorageKey:b}){const C=a||CY;ME({onPackageUpdated:p,triggerOnFirstInstall:!!m,storageKey:b});const w=y.jsxs(PE.Provider,{value:{debugMode:h,usePushNotifications:i,useProgressiveWebAppFeatures:o},children:[h&&y.jsxs("div",{className:"p-10",children:[y.jsx("h2",{children:"DEBUG MODE"}),y.jsxs("p",{children:["Organization: ",t]})]}),y.jsx(NV,{children:y.jsx(xV,{children:y.jsx(eP,{client:C,children:y.jsx(PV,{usePushNotifications:i,children:y.jsx(AV,{children:y.jsx(SY,{organization:t,children:y.jsx(MY,{shouldRedirectAfterLogin:n,loginRedirectRoute:r,quickGoogleLoginButtonStyle:c,enableGoogleQuickLoginButton:u,showGoogleQuickLoginButton:d,useGoogleAutoSelect:f,children:y.jsxs(Kx,{children:[e,v&&y.jsx(wE,{enableInstallAppButton:v==null?void 0:v.installApp,enablePushNotificationButton:v==null?void 0:v.pushNotifications}),!g&&y.jsx(AE,{})]})})})})})})})})]});return s?y.jsx(RV,{children:w}):w}const NE=O.createContext({});function Lr(){return O.useContext(NE)}function SY({children:e,organization:t}){const n=Of(),{debugMode:r}=zi(),[a,i]=O.useState(t||"");O.useEffect(()=>{if(t){r&&console.log("OrganizationProvider: organization prop utilisée",t),i(t);return}const x=new URLSearchParams(n.search),A=x.get("org");if(A){r&&console.log("OrganizationProvider: paramètre ?org= trouvé dans l'URL",A),x.delete("org");const S=`${n.pathname}${x.toString()?"?"+x.toString():""}`;window.history.replaceState({},"",S),i(A)}else{const S=localStorage.getItem("Organization");S?(r&&console.log("OrganizationProvider: organisation trouvée dans le localStorage",S),i(S)):r&&console.log("OrganizationProvider: aucune organisation trouvée")}},[t,n.search,n.pathname,r]);function o(x){r&&console.log("User logged in:",x),!a&&!t&&x!=null&&x.defaultOrganization&&i(x.defaultOrganization)}const{data:s,isLoading:c,refetch:u}=u1(a),d=yf();function f(){u(),d.invalidateQueries()}O.useEffect(()=>{f()},[a]),O.useEffect(()=>{localStorage.removeItem("invalid-organizations")},[]);const[h,v]=O.useState(""),[g,p]=O.useState({clientId:"",appSecret:"",clientIdSandbox:"",appSecretSandbox:"",enabled:!1});O.useEffect(()=>{localStorage.setItem("Organization",a),r&&(a?console.log("OrganizationProvider: organisation mise à jour dans le localStorage",a):console.warn("OrganizationProvider: organisationState est vide, pas de mise à jour dans le localStorage"))},[a]),O.useEffect(()=>{v((s==null?void 0:s.image)??""),s&&p({clientId:(s==null?void 0:s.paypalClientId)??"",appSecret:(s==null?void 0:s.paypalAppSecret)??"",clientIdSandbox:(s==null?void 0:s.paypalClientIdSandbox)??"",appSecretSandbox:(s==null?void 0:s.paypalAppSecretSandbox)??"",enabled:!!s.paypalEnabled||!1})},[s]);async function m(x){const A=await P3(x);return A!=null&&A.success&&u(),A==null?void 0:A.success}async function b(x){const A=await N3(x);return A!=null&&A.success&&(u(),p(S=>({...S,enabled:x}))),A==null?void 0:A.success}async function C(){await R3(),u()}async function w(x,A,S){const E=await I3(x,A,S);return f(),E}return y.jsx(NE.Provider,{value:{organization:a,organizationImage:h,organizationDetails:s??void 0,areOrganizationDetailsLoading:c,paypalInfo:g,onLoggedIn:o,updateOrganizationDetails:m,updatePaypalConfiguration:w,toggleOrganizationMode:C,updateOrganizationPaypalEnabled:b,refetchOrganizationDetails:f},children:e})}async function xY(){return await Nt.get("/users/roles")}const IE=(e,t)=>mr(["user-role-details",e,t],xY,{enabled:!!e,select:n=>n==null?void 0:n.data,onError:n=>{console.error("Error fetching user role details:",n)}}),EY={apiKey:"AIzaSyCpAeHlt1wZvM5KtYg7X7MDVnWVJT86gvc",authDomain:"lystech.firebaseapp.com",databaseURL:"https://lystech.firebaseio.com",projectId:"lystech",storageBucket:"lystech.appspot.com",messagingSenderId:"237347321732",appId:"1:237347321732:web:7f9586d48e488d73ddcfd1"};async function RE(e){const t=new FormData;t.append("image",e);const n=await Nt.put("users/image",t,{headers:{"Content-Type":"multipart/form-data"},data:t});return n==null?void 0:n.data}async function DE(e,t){const n=await Nt.put("users/image/url",{authKey:e,imageUrl:t});return n==null?void 0:n.data}async function AY(e){const t=await Nt.post("auth/request-reset-password",{email:e});return t==null?void 0:t.data}async function OY(e){const t=await Nt.post(`auth/activate/${e}`);return t==null?void 0:t.data}async function jE(e){return await Nt.post("auth/register",{...e})}const TE=O.createContext({});function ar(){return O.useContext(TE)}function MY({children:e,shouldRedirectAfterLogin:t,loginRedirectRoute:n,quickGoogleLoginButtonStyle:r,enableGoogleQuickLoginButton:a,showGoogleQuickLoginButton:i,useGoogleAutoSelect:o=!0}){var _,te,se,$,fe,oe,ye;const[s,c]=O.useState(n||null),{debugMode:u}=zi();$g(EY);const{organization:d,onLoggedIn:f}=Lr(),h=O.useCallback(()=>{const le=sessionStorage.getItem("username");if(le)return{id:parseInt(sessionStorage.getItem("id")||"-1"),displayName:le,firstName:sessionStorage.getItem("firstName")||"",lastName:sessionStorage.getItem("lastName")||"",birthday:sessionStorage.getItem("birthday")?new Date(sessionStorage.getItem("birthday")):null,email:sessionStorage.getItem("email")||"",UID:sessionStorage.getItem("authKey")||"",profileImage:sessionStorage.getItem("profileImage")||"",notifyCoffee:sessionStorage.getItem("notifyCoffee")?parseInt(sessionStorage.getItem("notifyCoffee")):0,defaultOrganization:sessionStorage.getItem("defaultOrganization")||"",thirdPartyAuthUID:sessionStorage.getItem("thirdPartyAuthUID")||"",roleDetails:{role:"",isOwner:!1,isSuperAdmin:!1,isAdmin:!1,isUser:!1,isSuperAdminOrMore:!1,isAdminOrMore:!1,isUserOrMore:!1,isAdminInAnyOrganization:!1},type:"emailPassword",activatedOn:"",approvedBy:""}},[]),v=O.useCallback(()=>{const ne=h();return ne||{}},[h]);function g(ne){p&&(p.notifyCoffee=ne,m({...p}),sessionStorage.setItem("notifyCoffee",ne.toString()))}const[p,m]=O.useState(v()),b=O.useCallback(async ne=>{const{success:le,url:me}=await RE(ne);return le&&(p.photoURL=me,p.profileImage=me,m({...p}),sessionStorage.setItem("profileImage",me||"")),le},[p,m]),C=O.useCallback(async ne=>{const{success:le,url:me}=await DE(p==null?void 0:p.UID,ne);return le&&(p.photoURL=me,p.profileImage=me,m({...p}),sessionStorage.setItem("profileImage",me||"")),le},[p,m]),w=O.useCallback(ne=>{p.firstName=ne,m({...p}),sessionStorage.setItem("firstName",ne)},[p,m]),x=O.useCallback(ne=>{p.lastName=ne,m({...p}),sessionStorage.setItem("lastName",ne)},[p,m]),A=x1(),S=KO(),E=O.useMemo(()=>{if(p&&p.id!==-1&&p!=null&&p.UID)return{id:p.id,UID:p.UID,thirdPartyAuthUID:p.thirdPartyAuthUID,displayName:p.displayName,firstName:p.firstName,lastName:p.lastName,birthday:p.birthday,profileImage:p.profileImage,defaultOrganization:p.defaultOrganization,email:p.email,roleDetails:p.roleDetails,type:"emailPassword",activatedOn:p.activatedOn,notifyCoffee:p.notifyCoffee,approvedBy:p.approvedBy}},[p]),{data:P,isLoading:M}=IE((E==null?void 0:E.UID)??"",d),N=O.useMemo(()=>({...E,roleDetails:P}),[E,P]),I=O.useMemo(()=>!!(E!=null&&E.UID)&&(E==null?void 0:E.id)!==-1,[E]);O.useEffect(()=>{localStorage.setItem("authKey",(E==null?void 0:E.UID)??"")},[E]);const[L,T]=O.useState(!0),R=O.useRef(!1);O.useEffect(()=>{R.current||(R.current=!0,z().finally(()=>T(!1)))},[]);const j=O.useRef(!1),D=O.useRef(()=>{});O.useEffect(()=>{const ne=Nt.interceptors.response.use(le=>le,le=>{var me;return((me=le==null?void 0:le.response)==null?void 0:me.status)===401&&j.current&&(console.warn("[Auth] 401 reçu alors que connecté — session invalide, déconnexion locale."),D.current()),Promise.reject(le)});return()=>{Nt.interceptors.response.eject(ne)}},[]),O.useEffect(()=>{j.current=I},[I]),O.useEffect(()=>{D.current=()=>ee(null)});async function z(){try{const ne=await Nt.get("/auth/me");return console.log("Validate Me Response",ne),ne.data&&ee(ne==null?void 0:ne.data),ne==null?void 0:ne.data}catch(ne){return console.log("Validate Me Error",ne),null}finally{T(!1)}}O.useEffect(()=>{P&&localStorage.setItem("userRoleDetails",JSON.stringify(P))},[P]);const F=O.useMemo(()=>{if(!I)return"/login";let ne="";return P&&(ne="/past-orders"),ne===""&&(ne="/"),("/"+ne+"/").replace(/\/+/g,"/")},[P,I]);async function V(ne,le,me,ue=()=>{},xe=()=>{},we=0){try{const be={email:ne,password:le},Se=await Nt.get("/auth/login",{headers:be}),Ne=!!Se.data;me({result:Ne,data:Se==null?void 0:Se.data}),we>0?setTimeout(()=>{ee(Se==null?void 0:Se.data),t&&s&&A(s),f&&f(Se==null?void 0:Se.data)},we):(ee(Se==null?void 0:Se.data),f&&f(Se==null?void 0:Se.data),t&&s&&A(s))}catch(be){console.log("Login Error",be),(be==null?void 0:be.status)===403?ue(be):xe(be)}}async function W(ne,le,me){const ue=await Nt.post("/auth/login/third-party",{providerData:ne,token:le,tokenType:me}),xe=ue==null?void 0:ue.data;if(!xe){console.error("No user data returned from third-party login");return}return ee(xe),f&&f(xe),ue}async function k(){var ne,le,me,ue;try{const xe=new ya;xe.setCustomParameters({prompt:"select_account"});const we=await Q0(S,xe);if(((le=(ne=we==null?void 0:we.user)==null?void 0:ne.providerData)==null?void 0:le.length)===0||!((me=we==null?void 0:we.user)!=null&&me.providerData))return;const be=(ue=we==null?void 0:we.user)==null?void 0:ue.providerData[0],Se=await we.user.getIdToken();return await W(be,Se,"firebase")}catch(xe){console.error("Google login failed",xe)}}async function H(){var ne;try{const le=new ba,me=await Q0(S,le),ue=(ne=me==null?void 0:me.user)==null?void 0:ne.providerData[0],xe=await me.user.getIdToken();return await W(ue,xe,"firebase")}catch(le){console.error("Facebook login failed",le)}}async function B(){try{await Nt.post("/auth/logout")}catch(ne){console.warn("Déconnexion serveur échouée",ne)}sessionStorage.clear(),localStorage.clear(),ee(null),L6(S),A("/")}async function U(ne){const le=rM(ne.credential);if(le!=null&&le.email){let me="unknown.com";le!=null&&le.iss.includes("google")?me="google.com":le!=null&&le.iss.includes("facebook")&&(me="facebook.com");const ue={displayName:le==null?void 0:le.given_name,email:le==null?void 0:le.email,phoneNumber:null,photoURL:le==null?void 0:le.picture,providerId:me,uid:le==null?void 0:le.sub};return await W(ue,ne.credential,"google")}}const Y=()=>{console.error("Google login failed")};function X(ne){t&&s&&A(s)}function q(ne){var le;if(!ne){sessionStorage.clear();return}sessionStorage.setItem("username",ne.displayName),sessionStorage.setItem("email",ne.email),sessionStorage.setItem("firstName",ne.firstName??""),sessionStorage.setItem("lastName",ne.lastName??""),sessionStorage.setItem("birthday",((le=ne.birthday)==null?void 0:le.toString())??""),sessionStorage.setItem("defaultOrganization",ne.defaultOrganization),sessionStorage.setItem("id",ne.id.toString()),sessionStorage.setItem("authKey",ne.UID),sessionStorage.setItem("thirdPartyAuthUID",ne.thirdPartyAuthUID),sessionStorage.setItem("profileImage",ne.profileImage),sessionStorage.setItem("notifyCoffee",ne.notifyCoffee.toString())}function ee(ne){m(ne),q(ne),(ne==null?void 0:ne.id)==-1&&(ne==null?void 0:ne.id)!=-1&&X()}const ae=O.useMemo(()=>{var ne,le,me;return I?!1:a!==void 0?a:!((ne=window==null?void 0:window.location)!=null&&ne.pathname.includes("/activate"))&&!((le=window==null?void 0:window.location)!=null&&le.pathname.includes("/account/reset-password"))&&!((me=window==null?void 0:window.location)!=null&&me.pathname.includes("/account/activation"))},[I,a,(_=window==null?void 0:window.location)==null?void 0:_.pathname]),ie=O.useMemo(()=>{var ne;return i!==void 0?i:ae&&!((ne=window==null?void 0:window.location)!=null&&ne.pathname.includes("/login"))},[ae,i,(te=window==null?void 0:window.location)==null?void 0:te.pathname]);return O.useEffect(()=>{u&&(console.log("AuthProvider - user.UID:",E==null?void 0:E.UID),console.log("AuthProvider - isLoggedIn:",I))},[E==null?void 0:E.UID,I]),y.jsx(qO,{clientId:"237347321732-65nra8lcs59qn6dms77ruad01vjdr7ph.apps.googleusercontent.com",children:y.jsxs(TE.Provider,{value:{user:E?{...E,roleDetails:P||{role:"",isOwner:!1,isSuperAdmin:!1,isAdmin:!1,isUser:!1,isSuperAdminOrMore:!1,isAdminOrMore:!1,isUserOrMore:!1,isAdminInAnyOrganization:!1}}:void 0,currentUser:N,auth:S,isLoggedIn:I,isCheckingSession:L,isSuperAdmin:!!((se=N==null?void 0:N.roleDetails)!=null&&se.isSuperAdminOrMore),isAdmin:!!(($=N==null?void 0:N.roleDetails)!=null&&$.isAdminOrMore),isUser:!!((fe=N==null?void 0:N.roleDetails)!=null&&fe.isUserOrMore),isSuperAdminInAnyOrganization:!!((oe=N==null?void 0:N.roleDetails)!=null&&oe.isSuperAdminOrMore),isAdminInAnyOrganization:!!((ye=N==null?void 0:N.roleDetails)!=null&&ye.isAdminInAnyOrganization),areRoleDetailsLoading:M,homeRoute:F,setLoginRedirectRouteState:c,registerNewUser:jE,signInWithEmailAndPassword:V,signInWithGoogle:k,signInWithFacebook:H,logout:B,requestResetPassword:AY,activateUser:OY,updateUserImage:b,updateUserImageUrl:C,updateUserFirstName:w,updateUserLastName:x,updateNotificationState:g},children:[u&&y.jsx("div",{className:"p-10",children:y.jsxs("p",{children:["Login Redirect Route State: ",y.jsx("b",{children:s||"null"})]})}),e,ae&&y.jsx("div",{className:`fixed top-10 right-10 ${ie?"":"hidden"}`,style:r,children:y.jsx(eM,{onSuccess:U,onError:Y,auto_select:o,useOneTap:!0,type:"icon"})})]})})}async function PY(){return(await Nt.get("/politique-and-conditions/9716a5de-02be-4fb2-b9b5-85ad82bfae4f")).data}async function NY(){return(await Nt.get("/politique-and-conditions")).data}const LE=()=>mr({queryKey:["lystech-politique-and-conditions"],queryFn:PY}),FE=e=>mr({queryKey:["politique-and-conditions",e],queryFn:NY,enabled:!!e});async function IY(){const e=await Nt.get("collections/invitation");return(e==null?void 0:e.data)||[]}const Qu=(e,t)=>mr(["invitedToOrders",e,t],IY,{staleTime:1e3*60*2,select:n=>t?n.filter(r=>r.organization.subdomain===t):n,enabled:!!e});async function RY(e,t){const n={code:e,products:t},r=await Nt.post("promo-codes/validate",n);return r==null?void 0:r.data}async function zE(){const e=await Nt.get("promo-codes/user");return e==null?void 0:e.data}const DY=e=>mr(["personal-promo-codes",e],zE,{enabled:!!e,refetchInterval:45*1e3,refetchOnWindowFocus:!0});async function kE(){const e=await Nt.get("images/featured");return e==null?void 0:e.data}const jY=()=>mr(["featured-images"],kE,{onError:e=>{console.error("Error fetching featured images:",e)}});async function HE(e){const t=await Nt.get(`/posts/slug/${e}`);if(t.status!==200)throw new Error(`Error fetching post with ID ${e}: ${t.statusText}`);return t.data}const TY=(e,t)=>mr(["single-post",e,t],()=>HE(e));async function LY(e){const t=await Nt.get(`/shop/collection/${e}`);return t==null?void 0:t.data}async function FY(e,t){const n=await Nt.post("/shop/breakdown",{products:e,promoCodes:t});return n==null?void 0:n.data}async function zY(e){const t=await Nt.post("/shop/save",e);return t==null?void 0:t.data}const BE=(e,t,n)=>mr(["order-details-breakdown",e,t.map(r=>r.UID),t.map(r=>r.quantity),n.map(r=>r.toLowerCase())],async()=>await FY(t,n),{enabled:!!e&&t.length>0}),kY=()=>yf();async function HY(){try{const e=await Nt.get("/shop/collections");return localStorage.setItem("collections",JSON.stringify(e==null?void 0:e.data)),(e==null?void 0:e.data)||[]}catch(e){return console.log(e),[]}}async function VE(e){var n;const t=await Nt.post("stripe/checkout",e);if(t.status===200&&((n=t.data)!=null&&n.url))return t.data;throw new Error("Failed to create Stripe checkout session")}const YE=({onSuccess:e,onAccountNotActivated:t,onAccountNotFound:n,onError:r,className:a="",showTitle:i=!0,title:o="Se connecter",loginButtonText:s="Se connecter",pendingConnexionButtonText:c="Connexion...",passwordFieldLabel:u="Mot de passe",emailFieldLabel:d="Email",emailFieldPlaceholder:f="Votre email",passwordFieldPlaceholder:h="••••••••••••",loginSuccessMessage:v="Connexion réussie",unknownErrorMessage:g="Une erreur inconnue est survenue.",showForgotPassword:p=!1,forgotPasswordText:m="Mot de passe oublié ?",onForgotPassword:b})=>{const C=ar(),w=Qr(),[x,A]=O.useState({email:"",password:""}),[S,E]=O.useState(!1),[P,M]=O.useState(!1),N=(L,T)=>{A(R=>({...R,[L]:T}))},I=async L=>{var T,R,j;L.preventDefault(),E(!0);try{await C.signInWithEmailAndPassword(x.email,x.password,D=>{e?e(D):w.showMessage({type:"success",message:v})},D=>{t?t(D):w.showMessage({type:"warning",message:D==null?void 0:D.message})},D=>{n?n(D):w.showMessage({type:"error",message:D==null?void 0:D.message})})}catch(D){const z=D instanceof Error?D:new Error("Erreur inconnue");if(r)r(z);else{const F=(j=(R=(T=D.error)==null?void 0:T.response)==null?void 0:R.data)==null?void 0:j.message;w.showMessage({type:"error",message:F||g})}}finally{E(!1)}};return y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:`auth-form ${a}`,children:[i&&y.jsx("h2",{children:o}),y.jsx("div",{className:"form-row",children:y.jsxs("div",{className:"form-group",children:[y.jsx("label",{htmlFor:"email",children:d}),y.jsxs("div",{className:"auth-field",children:[y.jsx("span",{className:"auth-field__icon",children:y.jsx(Gu,{size:18})}),y.jsx("input",{type:"email",id:"email",value:x.email,onChange:L=>N("email",L.target.value),required:!0,placeholder:f})]})]})}),y.jsx("div",{className:"form-row",children:y.jsxs("div",{className:"form-group",children:[y.jsx("label",{htmlFor:"password",children:u}),y.jsxs("div",{className:"auth-field",children:[y.jsx("span",{className:"auth-field__icon",children:y.jsx(Ku,{size:18})}),y.jsx("input",{type:P?"text":"password",id:"password",value:x.password,onChange:L=>N("password",L.target.value),required:!0,placeholder:h}),y.jsx("button",{type:"button",className:"auth-field__icon auth-field__eye",onClick:()=>M(L=>!L),"aria-label":P?"Masquer le mot de passe":"Afficher le mot de passe",children:P?y.jsx(oE,{size:18}):y.jsx(iE,{size:18})})]})]})}),p&&b&&y.jsx("div",{className:"auth-form__forgot",children:y.jsx("button",{type:"button",className:"link-button",onClick:b,children:m})}),y.jsx("button",{type:"button",disabled:S||!x.email.trim()||!x.password.trim(),className:"btn btn-primary",onClick:I,children:S?c:s})]}),y.jsx("div",{className:"auth-divider",children:"ou continuer avec"}),y.jsxs("div",{className:"third-party-row",children:[y.jsxs("button",{type:"button",className:"third-party-login-button login-with-google",onClick:()=>C.signInWithGoogle(),children:[y.jsx(cE,{size:20,weight:"bold"})," Google"]}),y.jsxs("button",{type:"button",className:"third-party-login-button login-with-facebook",onClick:()=>C.signInWithFacebook(),children:[y.jsx(sE,{size:20,weight:"fill"})," Facebook"]})]})]})},WE=({onSuccess:e,onEmailAlreadyExists:t,onError:n,className:r="",showTitle:a=!0,title:i="Créer un compte",showBirthdayField:o=!0,firstNameFieldLabel:s="Prénom",firstNameFieldPlaceholder:c="Votre prénom",lastNameFieldLabel:u="Nom",lastNameFieldPlaceholder:d="Votre nom",emailFieldLabel:f="Email",emailFieldPlaceholder:h="Votre email",birthdayFieldLabel:v="Date de naissance",birthdayFieldPlaceholder:g="Votre date de naissance",passwordFieldLabel:p="Mot de passe",passwordFieldPlaceholder:m="••••••••••••",confirmPasswordFieldLabel:b="Confirmation du mot de passe",confirmPasswordFieldPlaceholder:C="••••••••••••",createAccountButtonText:w="Créer le compte",creatingAccountButtonText:x="Création en cours...",accountCreatedMessage:A="Compte créé avec succès !",accountAlreadyExistsMessage:S="Un compte avec cet email existe déjà.",errorMessage:E="Une erreur est survenue lors de la création du compte.",passwordNotMatchMessage:P="Les mots de passe ne correspondent pas.",politiqueAndConditionsConsentTexte:M="En créant un compte, j'accepte les termes et conditions.",seePolitiqueAndConditions:N="Voir les termes et conditions",politiqueAndConditionsRoute:I="/conditions"})=>{const L=ar(),T=Qr(),[R,j]=O.useState({firstName:"",lastName:"",email:"",birthday:"",password:"",confirmPassword:""}),[D,z]=O.useState(!1),F=(W,k)=>{j(H=>({...H,[W]:k}))},V=async W=>{var k,H,B;if(W.preventDefault(),z(!0),R.password!==R.confirmPassword){T.showMessage({type:"error",message:P}),z(!1);return}try{L.registerNewUser?(await L.registerNewUser({username:R.email,email:R.email,password:R.password,firstName:R.firstName,lastName:R.lastName,birthday:R.birthday||void 0}),e?e():T.showMessage({type:"success",message:A})):T.showMessage({type:"error",message:"La méthode d'enregistrement n'est pas disponible."})}catch(U){const Y=U instanceof Error?U:new Error("Erreur inconnue");if(n)console.log("Error in AuthRegisterForm:",Y),n(Y);else{const X=(B=(H=(k=U.error)==null?void 0:k.response)==null?void 0:H.data)==null?void 0:B.message;T.showMessage({type:"error",message:X})}}finally{z(!1)}};return y.jsxs("form",{onSubmit:V,className:`auth-form ${r}`,children:[a&&y.jsx("h2",{children:i}),y.jsx("div",{className:"form-row",children:y.jsxs("div",{className:"form-group",children:[y.jsx("label",{htmlFor:"firstName",children:s}),y.jsxs("div",{className:"auth-field",children:[y.jsx("span",{className:"auth-field__icon",children:y.jsx(Hv,{size:18})}),y.jsx("input",{type:"text",id:"firstName",value:R.firstName,onChange:W=>F("firstName",W.target.value),placeholder:c,required:!0})]})]})}),y.jsx("div",{className:"form-row",children:y.jsxs("div",{className:"form-group",children:[y.jsx("label",{htmlFor:"lastName",children:u}),y.jsxs("div",{className:"auth-field",children:[y.jsx("span",{className:"auth-field__icon",children:y.jsx(Hv,{size:18})}),y.jsx("input",{type:"text",id:"lastName",value:R.lastName,onChange:W=>F("lastName",W.target.value),required:!0,placeholder:d})]})]})}),y.jsx("div",{className:"form-row",children:y.jsxs("div",{className:"form-group",children:[y.jsx("label",{htmlFor:"email",children:f}),y.jsxs("div",{className:"auth-field",children:[y.jsx("span",{className:"auth-field__icon",children:y.jsx(Gu,{size:18})}),y.jsx("input",{type:"email",id:"email",value:R.email,onChange:W=>F("email",W.target.value),required:!0,placeholder:h})]})]})}),o&&y.jsx("div",{className:"form-row",children:y.jsxs("div",{className:"form-group",children:[y.jsx("label",{htmlFor:"birthday",children:v}),y.jsxs("div",{className:"auth-field",children:[y.jsx("span",{className:"auth-field__icon",children:y.jsx($x,{size:18})}),y.jsx("input",{type:"date",id:"birthday",value:R.birthday,onChange:W=>F("birthday",W.target.value)})]})]})}),y.jsx("div",{className:"form-row",children:y.jsxs("div",{className:"form-group",children:[y.jsx("label",{htmlFor:"password",children:p}),y.jsxs("div",{className:"auth-field",children:[y.jsx("span",{className:"auth-field__icon",children:y.jsx(Ku,{size:18})}),y.jsx("input",{type:"password",id:"password",value:R.password,onChange:W=>F("password",W.target.value),required:!0,placeholder:m})]})]})}),y.jsx("div",{className:"form-row",children:y.jsxs("div",{className:"form-group",children:[y.jsx("label",{htmlFor:"confirmPassword",children:b}),y.jsxs("div",{className:"auth-field",children:[y.jsx("span",{className:"auth-field__icon",children:y.jsx(Ku,{size:18})}),y.jsx("input",{type:"password",id:"confirmPassword",value:R.confirmPassword,onChange:W=>F("confirmPassword",W.target.value),required:!0,placeholder:C})]})]})}),y.jsx("div",{className:"form-row",children:y.jsx("div",{className:"form-group",style:{fontSize:"0.95em",color:"#555"},children:y.jsxs("span",{children:[M," ",y.jsx("a",{href:I,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--auth-accent)",textDecoration:"underline"},children:N})]})})}),y.jsx("button",{type:"submit",disabled:D,className:"btn btn-primary",children:D?x:w})]})},UE=({onSuccess:e,onError:t,className:n="",showTitle:r=!0,title:a="Réinitialiser le mot de passe",showDescription:i=!0,description:o="Entrez votre email pour recevoir un lien de réinitialisation.",emailFieldLabel:s="Email",confirmButtonText:c="Envoyer le lien",confirmingButtonText:u="Envoi en cours...",emailFieldPlaceholder:d="votre@email.com",activationMailSentMessage:f="Un email de réinitialisation a été envoyé à votre adresse.",errorMessage:h="Impossible d'envoyer l'email de réinitialisation."})=>{const v=ar(),g=Qr(),[p,m]=O.useState(""),[b,C]=O.useState(""),[w,x]=O.useState(!1),A=async E=>{E.preventDefault(),x(!0);try{const P=await v.requestResetPassword(p);C(p),e?e(p):g.showMessage({type:"success",message:f})}catch(P){const M=P instanceof Error?P:new Error("Erreur inconnue");t?t(M):g.showMessage({type:"error",message:`${h}`})}finally{x(!1)}},S=w||p===b||!p.trim();return y.jsxs("form",{onSubmit:A,className:`auth-form ${n}`,children:[r&&y.jsx("h2",{children:a}),i&&y.jsx("p",{className:"form-description",children:o}),y.jsx("div",{className:"form-row",children:y.jsxs("div",{className:"form-group",children:[y.jsx("label",{htmlFor:"email",children:s}),y.jsxs("div",{className:"auth-field",children:[y.jsx("span",{className:"auth-field__icon",children:y.jsx(Gu,{size:18})}),y.jsx("input",{type:"email",id:"email",value:p,onChange:E=>m(E.target.value),required:!0,placeholder:d})]})]})}),y.jsx("button",{type:"submit",disabled:S,className:"btn btn-primary",children:w?u:c})]})},GE=({onLogout:e,onClose:t,className:n="",showTitle:r=!0,title:a="Profil utilisateur",showCloseButton:i=!1,closeButtonText:o="Fermer",logoutSuccessMessage:s="Déconnexion réussie",logoutErrorMessage:c="Erreur lors de la déconnexion",disconnectedLabel:u="Non connecté",mustBeLoggedInMessage:d="Vous devez être connecté pour voir votre profil.",logoutButtonText:f="Se déconnecter",emailLabel:h="Email",nameLabel:v="Nom",idLabel:g="ID"})=>{var C,w,x;const p=ar(),m=Qr(),b=async()=>{try{await p.logout(),e?e():m.showMessage({type:"success",message:s})}catch(A){console.error("Erreur lors de la déconnexion:",A),m.showMessage({type:"error",message:c})}};return p.isLoggedIn?y.jsxs("div",{className:`user-profile ${n}`,children:[y.jsx("div",{className:"profile-icon",children:"👤"}),r&&y.jsx("h2",{children:a}),y.jsxs("div",{className:"user-info",children:[y.jsxs("div",{className:"info-item",children:[y.jsxs("span",{className:"label",children:[h,":"]}),y.jsx("span",{className:"value",children:((C=p.currentUser)==null?void 0:C.email)||"N/A"})]}),y.jsxs("div",{className:"info-item",children:[y.jsxs("span",{className:"label",children:[v,":"]}),y.jsx("span",{className:"value",children:((w=p.currentUser)==null?void 0:w.displayName)||"N/A"})]}),y.jsxs("div",{className:"info-item",children:[y.jsxs("span",{className:"label",children:[g,":"]}),y.jsx("span",{className:"value",children:((x=p.currentUser)==null?void 0:x.id)||"N/A"})]})]}),y.jsxs("div",{className:"profile-actions",children:[y.jsx("button",{onClick:b,className:"btn btn-logout",children:f}),i&&t&&y.jsx("button",{onClick:t,className:"btn btn-secondary",children:o})]})]}):y.jsxs("div",{className:`user-profile ${n}`,children:[y.jsx("div",{className:"profile-icon",children:"🔒"}),y.jsx("h2",{children:u}),y.jsx("p",{children:d})]})};function KE(){const{organization:e}=Lr(),{data:t,isLoading:n}=LE(),{data:r,isLoading:a}=FE(e),i=O.useMemo(()=>n||a?[]:e!=="lystech"?[...r||[],...t||[]]:r||[],[t,r,n,a,e]);return y.jsx("div",{className:"flex col gap-10",style:{padding:"20px",textAlign:"left"},children:i&&i.map(o=>y.jsxs("div",{className:"p-4 border rounded bg-white",children:[y.jsx("div",{dangerouslySetInnerHTML:{__html:o.content}}),y.jsx("div",{className:"text-xs text-gray-500 mt-2",children:o.updatedOn?`Updated: ${new Date(o.updatedOn).toLocaleString()}`:""})]},o.id))})}function BY(){const{showMessage:e}=Qr(),{activateUser:t}=ar(),{token:n}=PP(),[r,a]=O.useState(!1),[i,o]=O.useState(!1),s=O.useRef(!1),[c,u]=O.useState(null);async function d(f){if(!s.current){s.current=!0,u({type:"info",content:"Activation en cours..."}),a(!0);try{const h=await t(f);return h!=null&&h.success?(e({message:"Votre compte a été activé avec succès.",type:"success",duration:1e4}),o(!0),u({type:"success",content:"Votre compte a été activé avec succès. Redirection..."}),setTimeout(()=>{if(h!=null&&h.redirectionUrl){window.location.href=h.redirectionUrl;return}else window.location.href="/login"},3e3)):(e({message:"L'activation de votre compte a échoué ou ce lien est expiré.",type:"error",duration:1e4}),u({type:"error",content:"L'activation de votre compte a échoué ou ce lien est expiré."})),h}catch{return e({message:"Une erreur s'est produite lors de l'activation de votre compte.",type:"error",duration:1e4}),u({type:"error",content:"Une erreur s'est produite lors de l'activation de votre compte."}),null}finally{a(!1)}}}return O.useEffect(()=>{n&&!i&&!r&&!s.current&&d(n)},[n,i,r]),y.jsx("div",{className:"account-activation auth-theme-container",children:y.jsx("div",{className:"auth-theme-content",children:y.jsx("div",{className:`auth-message ${(c==null?void 0:c.type)||""}`.trim(),children:c==null?void 0:c.content})})})}const VY=({onSuccess:e,onCancel:t,style:n,className:r="",centered:a=!1,showLogo:i=!0,logoSrc:o,appName:s="",defaultMode:c="login",cancelButtonText:u="Annuler",returnToLoginButtonText:d="Retour à la connexion",showTitle:f=!0,title:h="",showLoginForm:v=!0,showRegisterForm:g=!0,showForgotPasswordForm:p=!0,loginButtonText:m="Se connecter",registerButtonText:b="S'inscrire",forgotPasswordButtonText:C="Réinitialiser le mot de passe",loginFormProps:w={},registerFormProps:x={},forgotPasswordFormProps:A={},politiqueAndConditionsConsentTexte:S="En créant un compte, j'ai lu, compris et j'accepte les règles d'utilisation.",seePolitiqueAndConditions:E="Voir les termes et conditions",politiqueAndConditionsRoute:P="/conditions"})=>{const M=ar(),N=Of(),[I,L]=O.useState(c),T=!!P&&(N==null?void 0:N.pathname)===P,R=()=>{e==null||e()},j=()=>{L("login")},D=()=>{L("login")},z=()=>{};return T?y.jsx(KE,{}):M.isLoggedIn?y.jsx("div",{className:`auth-template connected ${r}`,style:{...n,...a?{maxWidth:"400px",margin:"0 auto",padding:"20px"}:{}},children:y.jsxs("div",{className:"auth-container",children:[i&&y.jsxs("div",{className:"auth-header",children:[o&&y.jsx("img",{src:o,alt:s,className:"auth-logo"}),y.jsx("h1",{children:s})]}),y.jsx(GE,{onLogout:z,onClose:t,showCloseButton:!!t})]})}):y.jsx("div",{className:`auth-template ${r}`,style:{...n,...a?{maxWidth:"400px",margin:"0 auto",padding:"20px"}:{}},children:y.jsxs("div",{className:"auth-container",children:[i&&y.jsxs("div",{className:"auth-header",children:[o&&y.jsx("img",{src:o,alt:s,className:"auth-logo"}),y.jsx("h1",{children:s})]}),f&&y.jsx("div",{className:"auth-title",children:y.jsx("h2",{children:h})}),y.jsxs("div",{className:"auth-tabs",children:[v&&y.jsx("button",{className:`tab ${I==="login"?"active":""}`,onClick:()=>L("login"),children:m}),g&&y.jsx("button",{className:`tab ${I==="register"?"active":""}`,onClick:()=>L("register"),children:b})]}),y.jsxs("div",{className:"auth-content",children:[I==="login"&&v&&y.jsx("div",{children:y.jsx(YE,{onSuccess:R,loginButtonText:"Se connecter",className:"auth-login-form",showTitle:!1,showForgotPassword:p,forgotPasswordText:C,onForgotPassword:()=>L("forgot-password"),...w})}),I==="register"&&g&&y.jsx(WE,{onSuccess:j,politiqueAndConditionsConsentTexte:S,seePolitiqueAndConditions:E,politiqueAndConditionsRoute:P,...x}),I==="forgot-password"&&p&&y.jsxs("div",{children:[y.jsx(UE,{onSuccess:D,...A}),y.jsx("div",{className:"auth-links",children:y.jsxs("button",{type:"button",onClick:()=>L("login"),className:"link-button",children:["← ",d]})})]}),I==="activation"&&y.jsx(BY,{})]}),t&&y.jsx("div",{className:"auth-footer",children:y.jsx("button",{onClick:t,className:"btn btn-secondary",children:u})})]})})};function Xu(){const{organizationDetails:e}=Lr();return y.jsxs("div",{style:{width:"100%",minHeight:"400px",display:"flex",justifyContent:"center",alignItems:"center",fontSize:18,color:"#888"},children:[y.jsx("div",{className:"loading-spinner",style:{width:48,height:48,border:"6px solid #eee",borderTop:`6px solid ${(e==null?void 0:e.primaryColor)||"#1677ff"}`,borderRadius:"50%",animation:"spin 1s linear infinite"}}),y.jsx("style",{children:`
|
|
1719
1719
|
@keyframes spin {
|
|
1720
1720
|
0% { transform: rotate(0deg);}
|
|
1721
1721
|
100% { transform: rotate(360deg);}
|