1import{j as e}from"./vendor-motion-VOv-vRjq.js";import{u as H,r as s}from"./vendor-react-CgwpgauT.js";import{u as L}from"./vendor-i18n-T2j15knT.js";import{c as Z,X as F}from"./index-DFj2BBxO.js";import{L as T}from"./loader-circle-vXUzU19Z.js";import{S as B}from"./send-8D-sWKT9.js";import"./vendor-ui-kSdzIpai.js";import"./vendor-charts-BeJd8Fxm.js";import"./vendor-supabase-DYXPcfum.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const z=Z("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]),K=["/admin","/copilot","/onboarding","/oauth/consent","/verify/benchmark","/widget"],q=[{match:t=>t.startsWith("/workforce-dashboard"),key:"workforce_dashboard",label:"Workforce Dashboard (CEO view: ROI, employés IA, activité live)"},{match:t=>t.startsWith("/ai-workforce"),key:"ai_workforce",label:"AI Workforce Builder (création, mémoire agent, exécution Quad-Fusion)"},{match:t=>t.startsWith("/workforce-marketplace"),key:"workforce_marketplace",label:"Workforce Marketplace (templates d'employés IA préconfigurés)"},{match:t=>t.startsWith("/ai-governance"),key:"ai_governance",label:"AI Governance & Security Center (audit, approbations, policies)"},{match:t=>t.startsWith("/ai-performance"),key:"ai_performance",label:"AI Performance & ROI Center (KPIs, routing analytics)"},{match:t=>t.startsWith("/developers"),key:"developers",label:"Developer Hub (API keys, SDK, webhooks, quickstart)"}],se=()=>{var v;const{t,i18n:R}=L(),{pathname:u}=H(),[c,y]=s.useState(!1),[p,k]=s.useState(""),[a,l]=s.useState([]),[i,w]=s.useState(!1),h=s.useRef(null),f=s.useRef(null),W=K.some(r=>u.startsWith(r)),o=q.find(r=>r.match(u));s.useEffect(()=>{c&&setTimeout(()=>{var r;return(r=f.current)==null?void 0:r.focus()},50)},[c]),s.useEffect(()=>{var r;(r=h.current)==null||r.scrollTo({top:h.current.scrollHeight,behavior:"smooth"})},[a,i]);const I=async()=>{var j,N,C;const r=p.trim();if(!r||i)return;const d=[...a,{role:"user",content:r}];l(d),k(""),w(!0);try{const n=await fetch("https://ikhnpszzlgazzfhvkfsn.supabase.co/functions/v1/platform-copilot",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImlraG5wc3p6bGdhenpmaHZrZnNuIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Njk1OTIwNDUsImV4cCI6MjA4NTE2ODA0NX0.2X8IcqhmBx_el3M5yiBuRrcdbzHNZm_qFq28QSywO5I"},body:JSON.stringify({messages:d,locale:R.language,route:u,routeContext:o==null?void 0:o.label})});if(!n.ok||!n.body)throw new Error(`http ${n.status}`);const J=n.body.getReader(),_=new TextDecoder;let A="";for(l(x=>[...x,{role:"assistant",content:""}]);;){const{done:x,value:M}=await J.read();if(x)break;const P=_.decode(M,{stream:!0});for(const X of P.split(` 7`)){const S=X.trim();if(!S.startsWith("data:"))continue;const O=S.slice(5).trim();if(O!=="[DONE]")try{const b=JSON.parse(O),E=(C=(N=(j=b==null?void 0:b.choices)==null?void 0:j[0])==null?void 0:N.delta)==null?void 0:C.content;E&&(A+=E,l($=>{const g=[...$];return g[g.length-1]={role:"assistant",content:A},g}))}catch{}}}}catch{l(n=>[...n,{role:"assistant",content:t("copilot.error","Sorry, I couldn't reach the server. Please try again or contact /support.")}])}finally{w(!1),setTimeout(()=>{var m;return(m=f.current)==null?void 0:m.focus()},50)}},D=r=>{r.key==="Enter"&&!r.shiftKey&&(r.preventDefault(),I())};return W?null:e.jsxs(e.Fragment,{children:[!c&&e.jsxs("button",{type:"button",onClick:()=>y(!0),"aria-label":t("copilot.open","Open AI Copilot"),className:"fixed bottom-5 right-5 z-[60] flex h-14 w-14 items-center justify-center rounded-full bg-primary text-primary-foreground shadow-2xl shadow-primary/40 transition-transform hover:scale-105",children:[e.jsx(z,{className:"h-6 w-6"}),e.jsx("span",{className:"pointer-events-none absolute -top-1 -right-1 h-3 w-3 rounded-full bg-primary ring-2 ring-background"})]}),c&&e.jsxs("div",{role:"dialog","aria-label":"Infernex AI Copilot",className:"fixed bottom-5 right-5 z-[60] flex h-[560px] max-h-[calc(100vh-2rem)] w-[calc(100vw-2.5rem)] max-w-[400px] flex-col overflow-hidden rounded-2xl border border-border bg-background shadow-2xl",children:[e.jsxs("header",{className:"flex items-center justify-between border-b border-border bg-muted/40 px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-primary/15 text-primary",children:e.jsx(z,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold text-foreground",children:t("copilot.title","Infernex Copilot")}),e.jsx("div",{className:"text-[10px] uppercase tracking-widest text-muted-foreground",children:o?t(`copilot.ctx.${o.key}`,o.label):t("copilot.subtitle","Ask anything â 9 languages")})]})]}),e.jsx("button",{type:"button",onClick:()=>y(!1),className:"rounded-md p-1 text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":t("copilot.close","Close"),children:e.jsx(F,{className:"h-4 w-4"})})]}),e.jsxs("div",{ref:h,className:"flex-1 space-y-3 overflow-y-auto px-4 py-4",children:[a.length===0&&e.jsx("div",{className:"rounded-xl border border-border/60 bg-muted/30 p-3 text-sm text-muted-foreground",children:o?t(`copilot.wel
7come.${o.key}`,`Hi ð I'm the Infernex Copilot. I can help you right here on ${o.label}. Ask me anything.`):t("copilot.welcome","Hi ð I'm the Infernex Copilot. Ask me about pricing, the API, AI Workforce, integrations, security â in your language.")}),a.map((r,d)=>e.jsx("div",{className:`flex ${r.role==="user"?"justify-end":"justify-start"}`,children:e.jsx("div",{className:`max-w-[85%] whitespace-pre-wrap rounded-2xl px-3 py-2 text-sm leading-relaxed ${r.role==="user"?"bg-primary text-primary-foreground":"bg-muted text-foreground"}`,children:r.content||e.jsx("span",{className:"opacity-50",children:"â¦"})})},d)),i&&((v=a[a.length-1])==null?void 0:v.role)!=="assistant"&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(T,{className:"h-3 w-3 animate-spin"}),t("copilot.thinking","Thinkingâ¦")]})]}),e.jsx("div",{className:"border-t border-border bg-background p-2",children:e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("textarea",{ref:f,value:p,onChange:r=>k(r.target.value),onKeyDown:D,rows:1,placeholder:t("copilot.placeholder","Ask me anythingâ¦"),className:"min-h-[40px] max-h-[120px] flex-1 resize-none rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary"}),e.jsx("button",{type:"button",onClick:I,disabled:i||!p.trim(),className:"inline-flex h-10 w-10 items-center justify-center rounded-lg bg-primary text-primary-foreground disabled:opacity-40","aria-label":t("copilot.send","Send"),children:i?e.jsx(T,{className:"h-4 w-4 animate-spin"}):e.jsx(B,{className:"h-4 w-4"})})]})})]})]})};export{se as PlatformCopilot,se 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.