1import{g as m,j as e,bj as x,B as l,bl as h,t as n}from"./app-BI-V7AHb.js";import{A as p}from"./authLayout-D1k5yKLK.js";import{C as f}from"./circle-check-big-BE5uuHpG.js";import{S as g}from"./shield-check-BpPIK315.js";import{L as j}from"./loader-circle-BSMmSzg0.js";import"./Footer-Cm0VvVsT.js";import"./Head-CHF-em7v.js";import"./circle-help-C91eTw58.js";function E({extensionId:o}){const[r,t]=m.useState("idle");async function c(d){d.preventDefault(),t("loading"),console.log("[Extension Auth] Starting authorization flow...");try{console.log("[Extension Auth] Requesting token from server...");const{data:s}=await h.post("/auth/extension");if(console.log("[Extension Auth] Token received:",{extensionId:s.extensionId,hasToken:!!s.token?.token}),typeof chrome>"u"||!chrome.runtime?.sendMessage)throw console.error("[Extension Auth] Chrome API not available"),new Error("Chrome extension API not available");console.log("[Extension Auth] Sending token to extension:",o);let i=!1;const u=setTimeout(()=>{i||(console.error("[Extension Auth] Timeout - extension did not respond"),n.error("L'extension n'a pas répondu. Vérifiez qu'elle est bien installée et active."),t("error"))},5e3);chrome.runtime.sendMessage(o,{type:"FLIPPIX_AUTH_SUCCESS",token:s.token.token,expiresAt:s.token.expiresAt},a=>{if(i=!0,clearTimeout(u),console.log("[Extension Auth] Extension response:",a),console.log("[Extension Auth] Last error:",chrome.runtime?.lastError),chrome.runtime?.lastError){console.error("[Extension Auth] Extension error:",chrome.runtime.lastError.message),n.error(`Erreur extension: ${chrome.runtime.lastError.message}`),t("error");return}a?.success?(console.log("[Extension Auth] Success!"),t("success")):(console.error("[Extension Auth] Extension did not acknowledge"),n.error("L'extension n'a pas confirmé la réception du token"),t("error"))})}catch(s){console.error("[Extension Auth] Error:",s),n.error(s instanceof Error?s.message:"Erreur inconnue"),t("error")}}return r==="success"?e.jsxs("div",{className:"space-y-6 text-center",children:[e.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-full bg-green-100",children:e.jsx(f,{className:"h-8 w-8 text-green-600"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Connexion réussie"}),e.jsx("p",{className:"text-muted-foreground",children:"L'extension a bien reçu l'autorisation. Vous pouvez fermer cet onglet."})]})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2 text-center",children:[e.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-full bg-orange-100",children:e.jsx(x,{className:`h-8 w-8 ${r==="loading"?"animate-spin":""}`,color:"#f97316"})}),e.jsx("h1",{className:"text-2xl font-bold",children:"Autoriser l'extension"}),e.jsx("p",{className:"text-muted-foreground",children:"L'extension Flippix demande l'accès à votre compte"})]}),e.jsx("div",{className:"rounded-lg border bg-muted/50 p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(g,{className:"mt-0.5 h-5 w-5 text-green-600"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"Cette extension pourra :"}),e.jsxs("ul",{className:"list-inside list-disc space-y-1 text-sm text-muted-foreground",children:[e.jsx("li",{children:"Accéder à vos informations de profil"}),e.jsx("li",{children:"Consulter vos catalogues et produits"}),e.jsx("li",{children:"Effectuer des recherches de produits"})]})]})]})}),e.jsx("div",{className:"text-center text-xs text-muted-foreground",children:e.jsx("span",{className:"rounded bg-muted px-2 py-1 font-mono",children:o})}),e.jsxs("form",{onSubmit:c,className:"space-y-3",children:[e.jsxs(l,{type:"submit",className:"w-full bg-orange-500 hover:bg-orange-600",disabled:r==="loading",children:[r==="loading"&&e.jsx(j,{className:"mr-2 h-4 w-4 animate-spin"}),"Autoriser l'accès"]}),e.jsx(l,{type:"button",variant:"outline",className:"w-full",onClick:()=>window.close(),disabled:r==="loading",children:"Annuler"})]})]})}E.layout=o=>e.jsx(p,{component:"auth/extension",children:o});
1export{E as default};
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.