ultisuite-client/out/_next/static/chunks/2646-fe22f55173fc198f.js
R3D347HR4Y d6d18f911b
Some checks failed
E2E / Playwright e2e (push) Has been cancelled
Lots of stuff and mobile app
2026-06-17 00:13:28 +02:00

2 lines
11 KiB
JavaScript

"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2646],{5251:(e,t,s)=>{s.d(t,{Fm:()=>m,Qs:()=>h,cj:()=>i,h:()=>u,kN:()=>l,qp:()=>p});var a=s(4208);s(91356);var n=s(79531),r=s(12551),o=s(58113);function i({...e}){return(0,a.jsx)(n.bL,{"data-slot":"sheet",...e})}function l({...e}){return(0,a.jsx)(n.bm,{"data-slot":"sheet-close",...e})}function c({...e}){return(0,a.jsx)(n.ZL,{"data-slot":"sheet-portal",...e})}function d({className:e,...t}){return(0,a.jsx)(n.hJ,{"data-slot":"sheet-overlay",className:(0,o.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function u({className:e,children:t,side:s="right",overlayClassName:i,hideClose:l=!1,...m}){return(0,a.jsxs)(c,{children:[(0,a.jsx)(d,{className:i}),(0,a.jsxs)(n.UC,{"data-slot":"sheet-content",className:(0,o.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500","right"===s&&"data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm","left"===s&&"data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm","top"===s&&"data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b","bottom"===s&&"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",e),...m,children:[t,l?null:(0,a.jsxs)(n.bm,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none",children:[(0,a.jsx)(r.A,{className:"size-4"}),(0,a.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function m({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"sheet-header",className:(0,o.cn)("flex flex-col gap-1.5 p-4",e),...t})}function p({className:e,...t}){return(0,a.jsx)(n.hE,{"data-slot":"sheet-title",className:(0,o.cn)("text-foreground font-semibold",e),...t})}function h({className:e,...t}){return(0,a.jsx)(n.VY,{"data-slot":"sheet-description",className:(0,o.cn)("text-muted-foreground text-sm",e),...t})}},12646:(e,t,s)=>{s.d(t,{H:()=>m});var a=s(4208),n=s(26362),r=s(12551),o=s(5251),i=s(61554),l=s(65044),c=s(95291),d=s(59352),u=s(40505);function m(){let e=(0,d.b)(e=>e.open),t=(0,d.b)(e=>e.context),s=(0,d.b)(e=>e.closePanel),{data:m}=(0,u.Y7)(),{data:p}=(0,u.Yc)(e&&(m?.enabled??!1));return m?.enabled?(0,a.jsx)(o.cj,{open:e,onOpenChange:e=>!e&&s(),children:(0,a.jsxs)(o.h,{side:"right",className:"flex w-full flex-col gap-0 p-0 sm:max-w-xl",children:[(0,a.jsxs)(o.Fm,{className:"flex flex-row items-center justify-between border-b px-4 py-3",children:[(0,a.jsxs)(o.qp,{className:"flex items-center gap-2 text-base",children:[(0,a.jsx)(n.A,{className:"h-4 w-4 text-[#1a73e8]"}),"UltiAI"]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[p?(0,a.jsx)(c.u,{quota:p,compact:!0,className:"hidden max-w-[180px] sm:block"}):null,(0,a.jsx)(i.$,{variant:"ghost",size:"icon",onClick:s,"aria-label":"Fermer",children:(0,a.jsx)(r.A,{className:"h-4 w-4"})})]})]}),(0,a.jsx)(l.z,{publicPath:m.public_path,context:t,className:"h-full min-h-0 w-full flex-1 border-0"})]})}):null}},40505:(e,t,s)=>{s.d(t,{Y7:()=>l,Yc:()=>c,tR:()=>o,yT:()=>d,zT:()=>i});var a=s(98306),n=s(17745),r=s(94927);function o(e){let t="number"==typeof e&&Number.isFinite(e)?e:0;return new Intl.NumberFormat("fr-FR",{style:"currency",currency:"EUR",minimumFractionDigits:2,maximumFractionDigits:4}).format(t/1e6)}function i(e){let t=e.cost_limit_month_micro_eur;return!t||t<=0?null:Math.min(100,Math.round(e.cost_used_month_micro_eur/t*100))}function l(){return(0,a.I)({queryKey:["ai","config"],queryFn:()=>r.uE.get("/ai/config"),staleTime:6e4})}function c(e=!0){return(0,a.I)({queryKey:["ai","quota"],queryFn:()=>r.uE.get("/ai/quota"),enabled:e,staleTime:3e4})}function d(){return(0,n.n)({mutationFn:e=>r.uE.post("/ai/sessions",{app:e.app,temporary:e.temporary??!0,message_id:e.messageId,account_id:e.accountId,drive_path:e.drivePath,file_id:e.fileId,contact_id:e.contactId,subject:e.subject,snippet:e.snippet})})}},59352:(e,t,s)=>{s.d(t,{b:()=>r});var a=s(46298);let n={app:"standalone",temporary:!0},r=(0,a.v)(e=>({open:!1,context:n,openPanel:t=>e(e=>({open:!0,context:{...e.context,...t,temporary:t?.temporary??!0}})),closePanel:()=>e({open:!1}),setContext:t=>e(e=>({context:{...e.context,...t}}))}))},65044:(e,t,s)=>{s.d(t,{z:()=>c});var a=s(4208),n=s(91356),r=s(29994);function o(e="/ai"){let t=(e||"/ai").replace(/\/$/,"")||"/ai",s=t.startsWith("/")?t:`/${t}`,a=(0,r.PW)()?.trim().replace(/\/$/,"");return a?`${a}${s}`:s}var i=s(40505),l=s(17996);function c({publicPath:e="/ai",context:t,className:s}){let r=(0,n.useRef)(null),{resolvedTheme:d}=(0,l.D)(),{data:u,isSuccess:m}=(0,i.Y7)(),p=(0,i.yT)(),[h,f]=(0,n.useState)(),[x,b]=(0,n.useState)(),_=(0,n.useMemo)(()=>[t.app,t.temporary,t.messageId,t.accountId,t.drivePath,t.fileId,t.contactId].join("|"),[t.app,t.temporary,t.messageId,t.accountId,t.drivePath,t.fileId,t.contactId]),g=(0,n.useMemo)(()=>(function(e="/ai"){let t=o(e);return t.startsWith("http://")||t.startsWith("https://")?new URL(t).origin:window.location.origin})(e),[e]),j=u?.enabled_tools??[],y=u?.mcp_url??"/api/v1/ai/mcp",v=(0,n.useMemo)(()=>{var s;let a,n,r;if(!m||!u?.enabled)return null;let i=(s=u.default_model,a=new URLSearchParams,(n=s?.trim())&&a.set("model",n),!1!==t.temporary&&a.set("temporary-chat","true"),t.app&&a.set("app",t.app),t.messageId&&a.set("message_id",t.messageId),t.accountId&&a.set("account_id",t.accountId),t.drivePath&&a.set("path",t.drivePath),t.fileId&&a.set("file_id",t.fileId),t.contactId&&a.set("contact_id",t.contactId),t.subject&&a.set("subject",t.subject),t.snippet&&a.set("snippet",t.snippet),a.toString());return r=o(e),i?`${r}/?${i}`:`${r}/`},[m,u,e,t]);return((0,n.useEffect)(()=>{if(!g)return;let e=e=>{if(e.origin!==g)return;let t=e.data;t?.type==="ULTI_OPEN_LINK"&&"string"==typeof t.href&&window.open(t.href,"_blank","noopener,noreferrer")};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[g]),(0,n.useEffect)(()=>{if(!u?.enabled)return;let e=!1;return p.mutateAsync(t).then(t=>{e||(f(t.token_secret),b(t.session_id))}).catch(()=>{e||(f(void 0),b(void 0))}),()=>{e=!0}},[u?.enabled,_,t,p.mutateAsync]),(0,n.useEffect)(()=>{let e=r.current;e?.contentWindow&&g&&e.contentWindow.postMessage({type:"ULTI_THEME",theme:"dark"===d?"dark":"light"},g)},[d,g]),(0,n.useEffect)(()=>{let e,s=r.current;if(!s?.contentWindow||!g)return;let a=[(e=["Tu es UltiAI, l'assistant int\xe9gr\xe9 \xe0 la suite Ultimail (mail, drive, contacts, UltiCal).","R\xe9ponds en fran\xe7ais sauf demande contraire. Utilise les tools disponibles pour agir sur les donn\xe9es utilisateur.","Recherche suite (index local) via suite_search ; recherche web publique via web_search si configur\xe9e.","Apr\xe8s chaque appel d'outil, r\xe9ponds toujours en langage naturel : r\xe9sume le r\xe9sultat, cite les sources (sujet, chemin, nom), propose la suite.","Ne termine jamais un tour utilisateur avec uniquement un appel d'outil sans texte explicatif.","Respecte strictement le param\xe8tre limit des tools (ne demande pas plus de r\xe9sultats que n\xe9cessaire)."],"mail"===t.app&&t.subject&&(e.push(`Contexte mail — sujet: ${t.subject}`),t.snippet&&e.push(`Extrait: ${t.snippet}`)),"drive"===t.app&&t.drivePath&&e.push(`Contexte drive — fichier/dossier: ${t.drivePath}`),"contacts"===t.app&&t.contactId&&e.push(`Contexte contacts — fiche: ${t.contactId}`),"docs"===t.app&&(t.documentTitle&&e.push(`Document: ${t.documentTitle}`),t.drivePath&&e.push(`Sidecar: ${t.drivePath}`),t.sourcePath&&e.push(`Source: ${t.sourcePath}`),t.selectionText&&e.push(`S\xe9lection: ${t.selectionText}`),t.documentExcerpt&&e.push(`Contenu:
${t.documentExcerpt}`)),t.systemPromptExtra&&e.push("",t.systemPromptExtra),e.join("\n")),t.systemPromptExtra].filter(Boolean).join("\n\n");s.contentWindow.postMessage({type:"ULTI_CONTEXT_UPDATE",context:t,systemPrompt:a||void 0},g)},[t,g]),(0,n.useEffect)(()=>{let e=r.current;e?.contentWindow&&g&&h&&e.contentWindow.postMessage({type:"ULTI_SESSION",token_secret:h,session_id:x,mcp_url:y,enabled_tools:j,default_model:u?.default_model},g)},[h,x,y,j,u?.default_model,g]),v)?(0,a.jsx)("iframe",{ref:r,title:"UltiAI",src:v,className:s,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-downloads",allow:"clipboard-read; clipboard-write"},v):(0,a.jsx)("div",{className:s,"aria-busy":"true","aria-label":"Chargement UltiAI"})}},95291:(e,t,s)=>{s.d(t,{u:()=>c});var a=s(4208),n=s(35855),r=s.n(n),o=s(40505),i=s(26938),l=s(58113);function c({quota:e,compact:t=!1,className:s}){let n=(0,o.zT)(e),d=e.warn_threshold_pct||80,u=null!=n&&n>=d;if(!e.billing_scope_org){let n=(e.by_provider_keys??[]).reduce((e,t)=>e+t.cost_month_micro_eur,e.cost_used_month_micro_eur);return(0,a.jsxs)("div",{className:(0,l.cn)("space-y-1",s),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground",children:[(0,a.jsx)("span",{children:"Cl\xe9 personnelle"}),(0,a.jsxs)("span",{className:"tabular-nums",children:[(0,o.tR)(n)," / mois"]})]}),!t&&(e.by_provider_keys?.length??0)>0?(0,a.jsx)("div",{className:"space-y-0.5 pl-2 text-[10px] text-muted-foreground",children:e.by_provider_keys.slice(0,3).map(e=>(0,a.jsxs)("div",{className:"flex justify-between gap-2",children:[(0,a.jsx)("span",{className:"truncate",children:e.label}),(0,a.jsx)("span",{className:"tabular-nums shrink-0",children:(0,o.tR)(e.cost_month_micro_eur)})]},e.fingerprint))}):null]})}return(0,a.jsxs)("div",{className:(0,l.cn)("space-y-1",s),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground",children:[(0,a.jsxs)("span",{className:(0,l.cn)(u&&"text-amber-600 dark:text-amber-400"),children:["IA ",u?"\xb7 proche du plafond":""]}),(0,a.jsxs)("span",{className:"tabular-nums",children:[(0,o.tR)(e.cost_used_month_micro_eur),e.cost_limit_month_micro_eur?` / ${(0,o.tR)(e.cost_limit_month_micro_eur)}`:""]})]}),null!=n?(0,a.jsx)("div",{className:"h-1.5 overflow-hidden rounded-full bg-muted",children:(0,a.jsx)("div",{className:(0,l.cn)("h-full rounded-full transition-all",u?"bg-amber-500":"bg-primary"),style:{width:`${n}%`}})}):null,t?null:(0,a.jsx)(r(),{href:`${i.qH}/usage-ia`,className:"text-[10px] text-muted-foreground underline-offset-2 hover:underline",children:"D\xe9tail de consommation"})]})}}}]);