@_solaris/messenger-widget 0.5.42 → 0.5.43

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.
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),Je=["connected","message","message_stream","conversation_updated","config_updated","action_status"],se="/client",Qe=5*60*1e3,Xe=10*60*1e3,Ze=5*60*1e3;function ge(t){const n={baseUrl:et(t.baseUrl||""),widgetId:t.widgetId||"",userId:"",origin:"",token:"",listeners:new Map,eventSource:null,connection:"idle",visibilityHandler:null,started:!1,panelOpen:!1,pollTimer:null,burstTimer:null,hiddenGraceTimer:null,lastActivityAt:null};if(!n.baseUrl||!n.widgetId)throw new Error("[transport] baseUrl and widgetId are required");function r(c,m){return n.listeners.has(c)||n.listeners.set(c,new Set),n.listeners.get(c).add(m),()=>n.listeners.get(c).delete(m)}function s(c,m){const f=n.listeners.get(c);f&&f.forEach(_=>{try{_(m)}catch(y){console.error("[transport] listener",c,y)}})}function a(c){n.connection!==c&&(n.connection=c,s("connection",c))}function o(){return{"Content-Type":"application/json","X-Widget-Id":n.widgetId,...n.origin?{"X-Parent-Origin":n.origin}:{}}}async function i(c,m,f){const _=await fetch(`${n.baseUrl}${se}${m}`,{method:c,credentials:"include",headers:o(),body:f!==void 0?JSON.stringify(f):void 0});if(!_.ok){const y=await l(_),b=new Error(`HTTP ${_.status} ${c} ${m} :: ${(y==null?void 0:y.error)||_.statusText}`);throw b.status=_.status,b.body=y,b}return _.status===204?null:_.json()}async function l(c){try{return await c.json()}catch{return null}}async function p(c){if(n.started)return n.lastBootstrap;if(!(c!=null&&c.origin))throw new Error("[transport] start requires origin");n.started=!0,n.origin=c.origin,n.token=c.token||"";const m=await fetch(`${n.baseUrl}${se}/session`,{method:"POST",credentials:"include",headers:o(),body:JSON.stringify({origin:n.origin,...n.token?{token:n.token}:{},allowUnauthenticated:c.allowUnauthenticated===!0,...c.customer&&typeof c.customer=="object"?{customer:c.customer}:{}})});if(!m.ok){const N=await l(m),C=new Error(`Session bootstrap failed: HTTP ${m.status} :: ${(N==null?void 0:N.error)||m.statusText}`);throw C.status=m.status,C.body=N,C}const f=await m.json();n.userId=f.external_id;const[_,y]=await Promise.all([fetch(`${n.baseUrl}/widgets/${encodeURIComponent(n.widgetId)}/config`,{credentials:"include"}).then(async N=>{if(!N.ok){const C=await l(N);throw new Error(`HTTP ${N.status} GET /widgets/:id/config :: ${(C==null?void 0:C.error)||N.statusText}`)}return N.json()}),i("GET","/customers/me")]),b={config:_,customer:(y==null?void 0:y.customer)??null};return n.lastBootstrap=b,await v(),typeof document<"u"&&(n.visibilityHandler=u,document.addEventListener("visibilitychange",n.visibilityHandler)),Q(),b}async function v(){try{const c=await S();n.lastActivityAt=c.reduce((m,f)=>{const _=f==null?void 0:f.last_message_at;return _&&(!m||_>m)?_:m},null)}catch(c){console.error("[transport] initial /conversations failed",c)}}async function g(){const c=await i("GET","/customers/me");return(c==null?void 0:c.customer)??null}async function E(c){const m=await i("PATCH","/customers/me",c);return(m==null?void 0:m.customer)??null}async function S(){const c=await i("GET","/conversations");return(c==null?void 0:c.conversations)??[]}async function k(c={}){return(await i("POST","/conversations",c)).conversation}async function x(c){return(await i("GET",`/conversations/${encodeURIComponent(c)}`)).conversation}async function w(c,m){return(await i("PATCH",`/conversations/${encodeURIComponent(c)}`,m)).conversation}async function V(c,m){return i("PATCH",`/conversations/${encodeURIComponent(c)}/read`,{message_id:m})}async function B(c,m={}){const f=new URLSearchParams;m.before&&f.set("before",m.before),m.since&&f.set("since",m.since),m.limit&&f.set("limit",String(m.limit));const _=f.toString()?`?${f.toString()}`:"";return i("GET",`/conversations/${encodeURIComponent(c)}/messages${_}`)}async function L(c,m){q();const f={client_msg_id:m.client_msg_id,type:"content",text_md:m.text_md,author:{id:n.userId,type:"user"},created_at:m.created_at||new Date().toISOString()};return Array.isArray(m.attachments)&&m.attachments.length&&(f.payload={type:"content",attachments:m.attachments}),m.metadata&&typeof m.metadata=="object"&&(f.metadata=m.metadata),i("POST",`/conversations/${encodeURIComponent(c)}/messages`,f)}async function I(c,m,f){return q(),i("POST",`/messages/${encodeURIComponent(c)}/callbacks/${encodeURIComponent(m)}`,f?{inputs:f}:{})}async function U(c){const m=c.name||"attachment",f=c.type||"application/octet-stream",_=c.size||0,y=await i("POST","/attachments",{mime_type:f,size_bytes:_,name:m}),b=await fetch(y.upload_url,{method:"PUT",headers:{"Content-Type":f},body:c});if(!b.ok)throw new Error(`HTTP ${b.status} PUT signed upload`);return{type:tt(f),path:y.path,mime_type:f,size_bytes:_}}async function z(c){return i("GET",`/attachments/sign?path=${encodeURIComponent(c)}`)}function j(){const c=new URLSearchParams({widgetId:n.widgetId}).toString();return`${n.baseUrl}${se}/stream?${c}`}function O(){if(!n.eventSource&&!(typeof document<"u"&&document.hidden)&&n.started)try{const c=new EventSource(j(),{withCredentials:!0});for(const m of Je)c.addEventListener(m,f=>H(m,f.data));c.addEventListener("error",()=>s("error",new Error("SSE error"))),n.eventSource=c,a("open")}catch(c){console.error("[transport] SSE open failed",c),s("error",c)}}function H(c,m){try{const f=JSON.parse(m),_=f&&typeof f=="object"&&"data"in f?f.data:f;s(c,_)}catch(f){console.error("[transport] bad SSE payload",c,f)}}function R(){n.eventSource&&(n.eventSource.close(),n.eventSource=null),n.connection!=="paused"&&a("idle")}function q(){clearTimeout(n.burstTimer),O(),n.panelOpen||(n.burstTimer=setTimeout(()=>{n.panelOpen||R()},Xe))}function J(c){n.panelOpen=!!c,n.panelOpen?(clearTimeout(n.burstTimer),O()):q()}async function ae(){try{const c=await S(),m=c.reduce((_,y)=>{const b=y==null?void 0:y.last_message_at;return b&&(!_||b>_)?b:_},null);m&&(!n.lastActivityAt||m>n.lastActivityAt)&&(n.lastActivityAt=m,s("activity",{conversations:c,latestAt:m}),q())}catch(c){console.error("[transport] poll failed",c)}}function Q(){d(),!(typeof document<"u"&&document.hidden)&&(n.pollTimer=setInterval(ae,Qe))}function d(){n.pollTimer&&(clearInterval(n.pollTimer),n.pollTimer=null)}function u(){if(document.hidden)clearTimeout(n.hiddenGraceTimer),n.hiddenGraceTimer=setTimeout(()=>{n.hiddenGraceTimer=null,document.hidden&&(d(),R(),a("paused"))},Ze);else{if(n.hiddenGraceTimer){clearTimeout(n.hiddenGraceTimer),n.hiddenGraceTimer=null;return}a("idle"),Q(),n.panelOpen&&O()}}function h(){d(),clearTimeout(n.burstTimer),clearTimeout(n.hiddenGraceTimer),n.hiddenGraceTimer=null,R(),n.visibilityHandler&&(document.removeEventListener("visibilitychange",n.visibilityHandler),n.visibilityHandler=null),n.started=!1}return{on:r,start:p,stop:h,setPanelOpen:J,getCustomer:g,patchCustomer:E,listConversations:S,createConversation:k,getConversation:x,patchConversation:w,markConversationRead:V,listMessages:B,postMessage:L,postCallback:I,uploadAttachment:U,signAttachment:z,get connection(){return n.connection}}}function et(t){return t.endsWith("/")?t.slice(0,-1):t}function tt(t){return t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":"file"}function le(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();const t=new Uint8Array(16);if(typeof crypto<"u"&&crypto.getRandomValues)crypto.getRandomValues(t);else for(let r=0;r<16;r++)t[r]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;const n=[...t].map(r=>r.toString(16).padStart(2,"0"));return n.slice(0,4).join("")+"-"+n.slice(4,6).join("")+"-"+n.slice(6,8).join("")+"-"+n.slice(8,10).join("")+"-"+n.slice(10,16).join("")}function _e(t){const n=e.reactive({ready:!1,error:null,config:null,customer:null,conversations:[],messagesByConv:{},paginationByConv:{},streamingByMsgId:{},awaitingCallback:{},runningActionsByConv:{},connection:"idle"}),r=[];r.push(t.on("connection",d=>{n.connection=d})),r.push(t.on("message",d=>{const u=d==null?void 0:d.conversation_id,h=d==null?void 0:d.message;!u||!(h!=null&&h.id)||(O(u,h),h.client_msg_id&&delete n.streamingByMsgId[h.client_msg_id],q(u,h.created_at))})),r.push(t.on("message_stream",d=>{const u=d==null?void 0:d.message_id,h=d==null?void 0:d.token;!u||typeof h!="string"||(n.streamingByMsgId[u]=(n.streamingByMsgId[u]||"")+h)})),r.push(t.on("conversation_updated",d=>{const u=d==null?void 0:d.conversation_id,h=d==null?void 0:d.changes;if(!u||!h)return;const c=n.conversations.findIndex(m=>m.id===u);c!==-1&&(n.conversations[c]={...n.conversations[c],...h})})),r.push(t.on("config_updated",d=>{d!=null&&d.config&&(n.config=d.config)})),r.push(t.on("action_status",d=>{const u=d==null?void 0:d.conversation_id,h=d==null?void 0:d.action_id,c=d==null?void 0:d.action_name;if(!u||!h)return;const m=n.runningActionsByConv[u]||{};d.state==="running"?(m[h]=c||h,n.runningActionsByConv[u]={...m}):d.state==="done"&&(delete m[h],n.runningActionsByConv[u]={...m})})),r.push(t.on("activity",d=>{Array.isArray(d==null?void 0:d.conversations)&&(n.conversations=d.conversations)}));async function s(d){try{const u=new Promise((c,m)=>setTimeout(()=>m(new Error("bootstrap timeout (15s) — check baseUrl, CORS, and network")),15e3)),h=await Promise.race([t.start(d),u]);n.config=h.config,n.customer=h.customer,n.conversations=await Promise.race([t.listConversations(),u]),n.ready=!0}catch(u){console.error("[store] start failed",u),n.error=(u==null?void 0:u.message)||String(u)}}function a(){for(const d of r)try{d()}catch{}t.stop()}async function o(d){const u=ae(d);if(!u)return n.customer;try{const h=await t.patchCustomer(u);h&&(n.customer=h)}catch(h){console.error("[store] applyCustomer failed",h)}return n.customer}async function i(d={}){const u=await t.createConversation(d),h=n.conversations.findIndex(c=>c.id===u.id);return h===-1?n.conversations=[u,...n.conversations]:n.conversations[h]=u,u}const l=50;async function p(d){const u=n.paginationByConv[d];if(!(u!=null&&u.loaded||u!=null&&u.loading)){g(d,{nextCursor:null,loading:!0,loaded:!1});try{const h=await t.listMessages(d,{limit:l}),c=(h==null?void 0:h.messages)??[],m=n.messagesByConv[d]||[],f=new Set;for(const y of c)(y==null?void 0:y.id)!=null&&f.add(`id:${String(y.id)}`),y!=null&&y.client_msg_id&&f.add(`c:${y.client_msg_id}`);const _=m.filter(y=>!((y==null?void 0:y.id)!=null&&f.has(`id:${String(y.id)}`)||y!=null&&y.client_msg_id&&f.has(`c:${y.client_msg_id}`)));n.messagesByConv[d]=[...c,..._].sort(J),g(d,{nextCursor:(h==null?void 0:h.next_cursor)??null,loading:!1,loaded:!0})}catch(h){console.error("[store] openConversation failed",h),g(d,{nextCursor:null,loading:!1,loaded:!1})}}}async function v(d){var m;const u=n.paginationByConv[d];if(!u||u.loading||!u.nextCursor)return;const c=(m=(n.messagesByConv[d]||[]).find(f=>f==null?void 0:f.created_at))==null?void 0:m.created_at;if(c){g(d,{...u,loading:!0});try{const f=await t.listMessages(d,{before:c,limit:l}),_=(f==null?void 0:f.messages)??[],y=n.messagesByConv[d]||[],b=new Set;for(const C of y)(C==null?void 0:C.id)!=null&&b.add(`id:${String(C.id)}`),C!=null&&C.client_msg_id&&b.add(`c:${C.client_msg_id}`);const N=_.filter(C=>!((C==null?void 0:C.id)!=null&&b.has(`id:${String(C.id)}`)||C!=null&&C.client_msg_id&&b.has(`c:${C.client_msg_id}`)));n.messagesByConv[d]=[...N,...y],g(d,{nextCursor:(f==null?void 0:f.next_cursor)??null,loading:!1,loaded:!0})}catch(f){console.error("[store] loadMore failed",f),g(d,{...u,loading:!1})}}}function g(d,u){n.paginationByConv={...n.paginationByConv,[d]:u}}async function E(d,u){const h=await t.patchConversation(d,u),c=n.conversations.findIndex(m=>m.id===d);c!==-1&&(n.conversations[c]=h)}async function S(d){if(!d)return[];const u=n.messagesByConv[d]||[];let h="";for(const c of u)c!=null&&c.created_at&&c.created_at>h&&(h=c.created_at);try{const c=await t.listMessages(d,h?{since:h}:{}),m=(c==null?void 0:c.messages)||[];if(!m.length)return[];const f=new Set,_=new Set;for(const b of u)(b==null?void 0:b.id)!=null&&f.add(String(b.id)),b!=null&&b.client_msg_id&&_.add(b.client_msg_id);const y=[];for(const b of m){const N=(b==null?void 0:b.id)!=null&&f.has(String(b.id))||(b==null?void 0:b.client_msg_id)&&_.has(b.client_msg_id);O(d,b),N||y.push(b)}return y}catch(c){return console.error("[store] fetchSinceLast failed",c),[]}}async function k(d,u){if(!(!d||u==null))try{const h=await t.markConversationRead(d,u),c=(h==null?void 0:h.last_read_message_id)??u,m=n.conversations.findIndex(f=>(f==null?void 0:f.id)===d);m!==-1&&(n.conversations[m]={...n.conversations[m],last_read_message_id:c})}catch(h){console.error("[store] markConversationRead failed",h)}}async function x(d,u,{attachments:h,metadata:c}={}){var N;const m=(u||"").trim(),f=Array.isArray(h)&&h.length>0;if(!d||!m&&!f)return;const _=le(),y=Q(d),b={id:_,client_msg_id:_,conversation_id:d,type:"content",text_md:m,author:{type:"user",id:((N=n.customer)==null?void 0:N.external_id)||null},created_at:y,_pending:!0,...f?{payload:{type:"content",attachments:h}}:{},...c&&typeof c=="object"?{metadata:c}:{}};O(d,b);try{await t.postMessage(d,{client_msg_id:_,text_md:m,created_at:y,...f?{attachments:h}:{},...c&&typeof c=="object"?{metadata:c}:{}})}catch(C){console.error("[store] send failed",C),R(d,_,{_failed:!0,_pending:!1})}}async function w(d,u,h){d!=null&&(n.awaitingCallback[d]=!0);try{await t.postCallback(d,u,h)}catch(c){console.error("[store] callback failed",c),d!=null&&delete n.awaitingCallback[d]}}const V=new Map;async function B(d){if(!d)return null;const u=V.get(d);if(u!=null&&u.url){const h=u.expires_at?Date.parse(u.expires_at):0;if(!h||h-Date.now()>6e4)return u.url}try{const h=await t.signAttachment(d);if(h!=null&&h.signed_url)return V.set(d,{url:h.signed_url,expires_at:h.expires_at}),h.signed_url}catch(h){console.error("[store] sign attachment failed",h)}return null}async function L(d,{rating:u,comment:h}={}){const c=n.conversations.find(_=>_.id===d),f={...(c==null?void 0:c.metadata)||{},feedback:{rating:u,comment:h||null,submitted_at:new Date().toISOString()}};await E(d,{metadata:f})}function I(d){var h,c;const u=n.messagesByConv[d]||[];for(let m=u.length-1;m>=0;m--){const f=u[m];if((f==null?void 0:f.type)==="action"&&((h=f==null?void 0:f.payload)==null?void 0:h.type)==="action"&&((c=f==null?void 0:f.payload)==null?void 0:c.state)==="pending"&&Array.isArray(f==null?void 0:f.callbacks)&&f.callbacks.length>0&&!n.awaitingCallback[f.id])return f}return null}function U(d){var h,c,m;const u=n.messagesByConv[d]||[];for(let f=u.length-1;f>=0;f--){const _=u[f];if(((h=_==null?void 0:_.author)==null?void 0:h.type)==="user"||(_==null?void 0:_.type)==="action"&&((c=_==null?void 0:_.payload)==null?void 0:c.state)==="pending")return null;const y=(m=_==null?void 0:_.metadata)==null?void 0:m.form;if(y&&Array.isArray(y.fields)&&y.fields.length>0)return{message:_,form:y}}return null}function z(d){const u=n.runningActionsByConv[d];if(!u)return null;const h=Object.keys(u);if(h.length===0)return null;const c=h[0];return{id:c,payload:{name:u[c]}}}function j(d){var h,c,m,f;const u=n.messagesByConv[d]||[];for(let _=u.length-1;_>=0;_--){const y=u[_];if(((h=y==null?void 0:y.author)==null?void 0:h.type)==="user")return[];if((y==null?void 0:y.type)==="action"&&((c=y==null?void 0:y.payload)==null?void 0:c.state)==="pending")return[];if(((m=y==null?void 0:y.author)==null?void 0:m.type)!=="agent_ia")continue;const b=(f=y==null?void 0:y.metadata)==null?void 0:f.suggested_replies;return Array.isArray(b)&&b.length?b.map(N=>{if(typeof N=="string"){const C=N.trim();return C?{label:C,kind:null}:null}if(N&&typeof N=="object"&&typeof N.label=="string"){const C=N.label.trim();if(!C)return null;const Ye=N.kind==="cta"||N.kind==="choice"||N.kind==="followup"?N.kind:null;return{label:C,kind:Ye}}return null}).filter(Boolean).slice(0,4):[]}return[]}function O(d,u){var f;const h=n.messagesByConv[d]||[];let c=-1;u!=null&&u.client_msg_id&&(c=h.findIndex(_=>(_==null?void 0:_.client_msg_id)&&_.client_msg_id===u.client_msg_id)),c===-1&&(u==null?void 0:u.id)!==void 0&&(u==null?void 0:u.id)!==null&&(c=h.findIndex(_=>H(_==null?void 0:_.id,u.id)));let m;c===-1?m=[...h,u].sort(J):(m=h.slice(),m[c]={...h[c],...u,_pending:!1,_failed:!1}),n.messagesByConv[d]=m,(u==null?void 0:u.type)==="action"&&((f=u==null?void 0:u.payload)!=null&&f.state)&&u.payload.state!=="pending"&&(u==null?void 0:u.id)!=null&&n.awaitingCallback[u.id]&&delete n.awaitingCallback[u.id]}function H(d,u){return d===u?!0:d==null||u==null?!1:String(d)===String(u)}function R(d,u,h){const c=n.messagesByConv[d];if(!c)return;const m=c.findIndex(_=>_.id===u);if(m===-1)return;const f=c.slice();f[m]={...c[m],...h},n.messagesByConv[d]=f}function q(d,u){const h=n.conversations.findIndex(m=>m.id===d);if(h===-1)return;const c=n.conversations[h];if(u&&(!c.last_message_at||u>c.last_message_at)){const m=n.conversations.slice();m[h]={...c,last_message_at:u},m.sort((f,_)=>(_.last_message_at||"").localeCompare(f.last_message_at||"")),n.conversations=m}}function J(d,u){return(d.created_at||"").localeCompare(u.created_at||"")}function ae(d){if(!d||typeof d!="object")return null;const u={},h={};for(const[c,m]of Object.entries(d))m!==void 0&&(c==="name"||c==="email"||c==="language"?m!=null&&String(m).trim()!==""&&(u[c]=m):(c==="values"||c==="metadata")&&m&&typeof m=="object"?Object.assign(h,m):h[c]=m);return Object.keys(h).length&&(u.values=h),Object.keys(u).length?u:null}function Q(d){const u=n.messagesByConv[d]||[];let h="";for(const f of u)f!=null&&f.created_at&&f.created_at>h&&(h=f.created_at);const c=new Date().toISOString();return!h||c>h?c:new Date(Date.parse(h)+1).toISOString()}return{state:n,start:s,destroy:a,applyCustomer:o,createConversation:i,openConversation:p,loadMore:v,fetchSinceLast:S,patchConversation:E,markConversationRead:k,send:x,clickCallback:w,signAttachment:B,submitFeedback:L,getPendingApproval:I,getActionInFlight:z,getLatestSuggestions:j,getLatestForm:U,setPanelOpen:t.setPanelOpen}}const T={w:"#ffffff",g50:"#F9F9F7",g100:"#F2F1EE",g150:"#E8E6E2",g200:"#D9D6CF",g300:"#B4B0A8",g400:"#888480",g500:"#5A5753",g700:"#2B2926",g900:"#17161A",accent:"#5B5FEF",accentLight:"#EEEFFE",green:"#22C55E",red:"#B91C1C",redBg:"#FDECEC"},X=["#5B5FEF","#7C3AED","#DB2777","#0891B2","#D97706","#059669"];function ee(t=""){return t?X[t.charCodeAt(0)%X.length]:X[0]}function te(t=""){return t.split(" ").map(n=>n[0]||"").join("").toUpperCase().slice(0,2)}function Z(t=new Date,n="fr-FR"){return t.toLocaleTimeString(n,{hour:"2-digit",minute:"2-digit"})}const ve=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),Qe=["connected","message","message_stream","conversation_updated","config_updated","action_status"],le="/client",Xe=5*60*1e3,Ze=10*60*1e3,et=5*60*1e3;function ye(t){const n={baseUrl:tt(t.baseUrl||""),widgetId:t.widgetId||"",userId:"",origin:"",token:"",currentContext:{},listeners:new Map,eventSource:null,connection:"idle",visibilityHandler:null,started:!1,panelOpen:!1,pollTimer:null,burstTimer:null,hiddenGraceTimer:null,lastActivityAt:null};if(!n.baseUrl||!n.widgetId)throw new Error("[transport] baseUrl and widgetId are required");function r(c,h){return n.listeners.has(c)||n.listeners.set(c,new Set),n.listeners.get(c).add(h),()=>n.listeners.get(c).delete(h)}function s(c,h){const p=n.listeners.get(c);p&&p.forEach(w=>{try{w(h)}catch(B){console.error("[transport] listener",c,B)}})}function a(c){n.connection!==c&&(n.connection=c,s("connection",c))}function o(){return{"Content-Type":"application/json","X-Widget-Id":n.widgetId,...n.origin?{"X-Parent-Origin":n.origin}:{}}}async function i(c,h,p){const w=await fetch(`${n.baseUrl}${le}${h}`,{method:c,credentials:"include",headers:o(),body:p!==void 0?JSON.stringify(p):void 0});if(!w.ok){const B=await l(w),E=new Error(`HTTP ${w.status} ${c} ${h} :: ${(B==null?void 0:B.error)||w.statusText}`);throw E.status=w.status,E.body=B,E}return w.status===204?null:w.json()}async function l(c){try{return await c.json()}catch{return null}}async function f(c){if(n.started)return n.lastBootstrap;if(!(c!=null&&c.origin))throw new Error("[transport] start requires origin");n.started=!0,n.origin=c.origin,n.token=c.token||"";const h=await fetch(`${n.baseUrl}${le}/session`,{method:"POST",credentials:"include",headers:o(),body:JSON.stringify({origin:n.origin,...n.token?{token:n.token}:{},allowUnauthenticated:c.allowUnauthenticated===!0,...c.variables&&typeof c.variables=="object"?{variables:c.variables}:{}})});if(!h.ok){const L=await l(h),P=new Error(`Session bootstrap failed: HTTP ${h.status} :: ${(L==null?void 0:L.error)||h.statusText}`);throw P.status=h.status,P.body=L,P}const p=await h.json();n.userId=p.external_id;const[w,B]=await Promise.all([fetch(`${n.baseUrl}/widgets/${encodeURIComponent(n.widgetId)}/config`,{credentials:"include"}).then(async L=>{if(!L.ok){const P=await l(L);throw new Error(`HTTP ${L.status} GET /widgets/:id/config :: ${(P==null?void 0:P.error)||L.statusText}`)}return L.json()}),i("GET","/customers/me")]),E={config:w,customer:(B==null?void 0:B.customer)??null};return n.lastBootstrap=E,await y(),typeof document<"u"&&(n.visibilityHandler=u,document.addEventListener("visibilitychange",n.visibilityHandler)),Z(),E}async function y(){try{const c=await S();n.lastActivityAt=c.reduce((h,p)=>{const w=p==null?void 0:p.last_message_at;return w&&(!h||w>h)?w:h},null)}catch(c){console.error("[transport] initial /conversations failed",c)}}async function _(){const c=await i("GET","/customers/me");return(c==null?void 0:c.customer)??null}async function C(c){const h=await i("PATCH","/customers/me",c);return(h==null?void 0:h.customer)??null}async function S(){const c=await i("GET","/conversations");return(c==null?void 0:c.conversations)??[]}async function k(c={}){return(await i("POST","/conversations",c)).conversation}async function x(c){return(await i("GET",`/conversations/${encodeURIComponent(c)}`)).conversation}async function b(c,h){return(await i("PATCH",`/conversations/${encodeURIComponent(c)}`,h)).conversation}async function V(c,h){return i("PATCH",`/conversations/${encodeURIComponent(c)}/read`,{message_id:h})}async function N(c,h={}){const p=new URLSearchParams;h.before&&p.set("before",h.before),h.since&&p.set("since",h.since),h.limit&&p.set("limit",String(h.limit));const w=p.toString()?`?${p.toString()}`:"";return i("GET",`/conversations/${encodeURIComponent(c)}/messages${w}`)}async function O(c,h){$();const p={client_msg_id:h.client_msg_id,type:"content",text_md:h.text_md,author:{id:n.userId,type:"user"},created_at:h.created_at||new Date().toISOString()};return Array.isArray(h.attachments)&&h.attachments.length&&(p.payload={type:"content",attachments:h.attachments}),h.metadata&&typeof h.metadata=="object"&&(p.metadata=h.metadata),n.currentContext&&Object.keys(n.currentContext).length>0&&(p.context=n.currentContext),i("POST",`/conversations/${encodeURIComponent(c)}/messages`,p)}async function R(c,h,p){return $(),i("POST",`/messages/${encodeURIComponent(c)}/callbacks/${encodeURIComponent(h)}`,p?{inputs:p}:{})}async function j(c){const h=c.name||"attachment",p=c.type||"application/octet-stream",w=c.size||0,B=await i("POST","/attachments",{mime_type:p,size_bytes:w,name:h}),E=await fetch(B.upload_url,{method:"PUT",headers:{"Content-Type":p},body:c});if(!E.ok)throw new Error(`HTTP ${E.status} PUT signed upload`);return{type:nt(p),path:B.path,mime_type:p,size_bytes:w}}async function H(c){return i("GET",`/attachments/sign?path=${encodeURIComponent(c)}`)}function q(){const c=new URLSearchParams({widgetId:n.widgetId}).toString();return`${n.baseUrl}${le}/stream?${c}`}function D(){if(!n.eventSource&&!(typeof document<"u"&&document.hidden)&&n.started)try{const c=new EventSource(q(),{withCredentials:!0});for(const h of Qe)c.addEventListener(h,p=>K(h,p.data));c.addEventListener("error",()=>s("error",new Error("SSE error"))),n.eventSource=c,a("open")}catch(c){console.error("[transport] SSE open failed",c),s("error",c)}}function K(c,h){try{const p=JSON.parse(h),w=p&&typeof p=="object"&&"data"in p?p.data:p;s(c,w)}catch(p){console.error("[transport] bad SSE payload",c,p)}}function F(){n.eventSource&&(n.eventSource.close(),n.eventSource=null),n.connection!=="paused"&&a("idle")}function $(){clearTimeout(n.burstTimer),D(),n.panelOpen||(n.burstTimer=setTimeout(()=>{n.panelOpen||F()},Ze))}function X(c){n.panelOpen=!!c,n.panelOpen?(clearTimeout(n.burstTimer),D()):$()}async function ie(){try{const c=await S(),h=c.reduce((w,B)=>{const E=B==null?void 0:B.last_message_at;return E&&(!w||E>w)?E:w},null);h&&(!n.lastActivityAt||h>n.lastActivityAt)&&(n.lastActivityAt=h,s("activity",{conversations:c,latestAt:h}),$())}catch(c){console.error("[transport] poll failed",c)}}function Z(){d(),!(typeof document<"u"&&document.hidden)&&(n.pollTimer=setInterval(ie,Xe))}function d(){n.pollTimer&&(clearInterval(n.pollTimer),n.pollTimer=null)}function u(){if(document.hidden)clearTimeout(n.hiddenGraceTimer),n.hiddenGraceTimer=setTimeout(()=>{n.hiddenGraceTimer=null,document.hidden&&(d(),F(),a("paused"))},et);else{if(n.hiddenGraceTimer){clearTimeout(n.hiddenGraceTimer),n.hiddenGraceTimer=null;return}a("idle"),Z(),n.panelOpen&&D()}}function m(){d(),clearTimeout(n.burstTimer),clearTimeout(n.hiddenGraceTimer),n.hiddenGraceTimer=null,F(),n.visibilityHandler&&(document.removeEventListener("visibilitychange",n.visibilityHandler),n.visibilityHandler=null),n.started=!1}async function g(c){return!c||typeof c!="object"?null:i("POST","/update",c)}function v(c){if(!(!c||typeof c!="object"))for(const[h,p]of Object.entries(c)){if(p===null){delete n.currentContext[h];continue}typeof p=="object"&&!Array.isArray(p)&&(n.currentContext[h]={...p})}}return{on:r,start:f,stop:m,setPanelOpen:X,update:g,context:v,getCustomer:_,patchCustomer:C,listConversations:S,createConversation:k,getConversation:x,patchConversation:b,markConversationRead:V,listMessages:N,postMessage:O,postCallback:R,uploadAttachment:j,signAttachment:H,get connection(){return n.connection}}}function tt(t){return t.endsWith("/")?t.slice(0,-1):t}function nt(t){return t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":"file"}function de(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();const t=new Uint8Array(16);if(typeof crypto<"u"&&crypto.getRandomValues)crypto.getRandomValues(t);else for(let r=0;r<16;r++)t[r]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;const n=[...t].map(r=>r.toString(16).padStart(2,"0"));return n.slice(0,4).join("")+"-"+n.slice(4,6).join("")+"-"+n.slice(6,8).join("")+"-"+n.slice(8,10).join("")+"-"+n.slice(10,16).join("")}function ve(t){const n=e.reactive({ready:!1,error:null,config:null,customer:null,conversations:[],messagesByConv:{},paginationByConv:{},streamingByMsgId:{},awaitingCallback:{},runningActionsByConv:{},connection:"idle"}),r=[];r.push(t.on("connection",d=>{n.connection=d})),r.push(t.on("message",d=>{const u=d==null?void 0:d.conversation_id,m=d==null?void 0:d.message;!u||!(m!=null&&m.id)||(D(u,m),m.client_msg_id&&delete n.streamingByMsgId[m.client_msg_id],$(u,m.created_at))})),r.push(t.on("message_stream",d=>{const u=d==null?void 0:d.message_id,m=d==null?void 0:d.token;!u||typeof m!="string"||(n.streamingByMsgId[u]=(n.streamingByMsgId[u]||"")+m)})),r.push(t.on("conversation_updated",d=>{const u=d==null?void 0:d.conversation_id,m=d==null?void 0:d.changes;if(!u||!m)return;const g=n.conversations.findIndex(v=>v.id===u);g!==-1&&(n.conversations[g]={...n.conversations[g],...m})})),r.push(t.on("config_updated",d=>{d!=null&&d.config&&(n.config=d.config)})),r.push(t.on("action_status",d=>{const u=d==null?void 0:d.conversation_id,m=d==null?void 0:d.action_id,g=d==null?void 0:d.action_name;if(!u||!m)return;const v=n.runningActionsByConv[u]||{};d.state==="running"?(v[m]=g||m,n.runningActionsByConv[u]={...v}):d.state==="done"&&(delete v[m],n.runningActionsByConv[u]={...v})})),r.push(t.on("activity",d=>{Array.isArray(d==null?void 0:d.conversations)&&(n.conversations=d.conversations)}));async function s(d){try{const u=new Promise((g,v)=>setTimeout(()=>v(new Error("bootstrap timeout (15s) — check baseUrl, CORS, and network")),15e3)),m=await Promise.race([t.start(d),u]);n.config=m.config,n.customer=m.customer,n.conversations=await Promise.race([t.listConversations(),u]),n.ready=!0}catch(u){console.error("[store] start failed",u),n.error=(u==null?void 0:u.message)||String(u)}}function a(){for(const d of r)try{d()}catch{}t.stop()}async function o(d){const u=ie(d);if(!u)return n.customer;try{const m=await t.patchCustomer(u);m&&(n.customer=m)}catch(m){console.error("[store] applyCustomer failed",m)}return n.customer}async function i(d={}){const u=await t.createConversation(d),m=n.conversations.findIndex(g=>g.id===u.id);return m===-1?n.conversations=[u,...n.conversations]:n.conversations[m]=u,u}const l=50;async function f(d){const u=n.paginationByConv[d];if(!(u!=null&&u.loaded||u!=null&&u.loading)){_(d,{nextCursor:null,loading:!0,loaded:!1});try{const m=await t.listMessages(d,{limit:l}),g=(m==null?void 0:m.messages)??[],v=n.messagesByConv[d]||[],c=new Set;for(const p of g)(p==null?void 0:p.id)!=null&&c.add(`id:${String(p.id)}`),p!=null&&p.client_msg_id&&c.add(`c:${p.client_msg_id}`);const h=v.filter(p=>!((p==null?void 0:p.id)!=null&&c.has(`id:${String(p.id)}`)||p!=null&&p.client_msg_id&&c.has(`c:${p.client_msg_id}`)));n.messagesByConv[d]=[...g,...h].sort(X),_(d,{nextCursor:(m==null?void 0:m.next_cursor)??null,loading:!1,loaded:!0})}catch(m){console.error("[store] openConversation failed",m),_(d,{nextCursor:null,loading:!1,loaded:!1})}}}async function y(d){var v;const u=n.paginationByConv[d];if(!u||u.loading||!u.nextCursor)return;const g=(v=(n.messagesByConv[d]||[]).find(c=>c==null?void 0:c.created_at))==null?void 0:v.created_at;if(g){_(d,{...u,loading:!0});try{const c=await t.listMessages(d,{before:g,limit:l}),h=(c==null?void 0:c.messages)??[],p=n.messagesByConv[d]||[],w=new Set;for(const E of p)(E==null?void 0:E.id)!=null&&w.add(`id:${String(E.id)}`),E!=null&&E.client_msg_id&&w.add(`c:${E.client_msg_id}`);const B=h.filter(E=>!((E==null?void 0:E.id)!=null&&w.has(`id:${String(E.id)}`)||E!=null&&E.client_msg_id&&w.has(`c:${E.client_msg_id}`)));n.messagesByConv[d]=[...B,...p],_(d,{nextCursor:(c==null?void 0:c.next_cursor)??null,loading:!1,loaded:!0})}catch(c){console.error("[store] loadMore failed",c),_(d,{...u,loading:!1})}}}function _(d,u){n.paginationByConv={...n.paginationByConv,[d]:u}}async function C(d,u){const m=await t.patchConversation(d,u),g=n.conversations.findIndex(v=>v.id===d);g!==-1&&(n.conversations[g]=m)}async function S(d){if(!d)return[];const u=n.messagesByConv[d]||[];let m="";for(const g of u)g!=null&&g.created_at&&g.created_at>m&&(m=g.created_at);try{const g=await t.listMessages(d,m?{since:m}:{}),v=(g==null?void 0:g.messages)||[];if(!v.length)return[];const c=new Set,h=new Set;for(const w of u)(w==null?void 0:w.id)!=null&&c.add(String(w.id)),w!=null&&w.client_msg_id&&h.add(w.client_msg_id);const p=[];for(const w of v){const B=(w==null?void 0:w.id)!=null&&c.has(String(w.id))||(w==null?void 0:w.client_msg_id)&&h.has(w.client_msg_id);D(d,w),B||p.push(w)}return p}catch(g){return console.error("[store] fetchSinceLast failed",g),[]}}async function k(d,u){if(!(!d||u==null))try{const m=await t.markConversationRead(d,u),g=(m==null?void 0:m.last_read_message_id)??u,v=n.conversations.findIndex(c=>(c==null?void 0:c.id)===d);v!==-1&&(n.conversations[v]={...n.conversations[v],last_read_message_id:g})}catch(m){console.error("[store] markConversationRead failed",m)}}async function x(d,u,{attachments:m,metadata:g}={}){var B;const v=(u||"").trim(),c=Array.isArray(m)&&m.length>0;if(!d||!v&&!c)return;const h=de(),p=Z(d),w={id:h,client_msg_id:h,conversation_id:d,type:"content",text_md:v,author:{type:"user",id:((B=n.customer)==null?void 0:B.external_id)||null},created_at:p,_pending:!0,...c?{payload:{type:"content",attachments:m}}:{},...g&&typeof g=="object"?{metadata:g}:{}};D(d,w);try{await t.postMessage(d,{client_msg_id:h,text_md:v,created_at:p,...c?{attachments:m}:{},...g&&typeof g=="object"?{metadata:g}:{}})}catch(E){console.error("[store] send failed",E),F(d,h,{_failed:!0,_pending:!1})}}async function b(d,u,m){d!=null&&(n.awaitingCallback[d]=!0);try{await t.postCallback(d,u,m)}catch(g){console.error("[store] callback failed",g),d!=null&&delete n.awaitingCallback[d]}}const V=new Map;async function N(d){if(!d)return null;const u=V.get(d);if(u!=null&&u.url){const m=u.expires_at?Date.parse(u.expires_at):0;if(!m||m-Date.now()>6e4)return u.url}try{const m=await t.signAttachment(d);if(m!=null&&m.signed_url)return V.set(d,{url:m.signed_url,expires_at:m.expires_at}),m.signed_url}catch(m){console.error("[store] sign attachment failed",m)}return null}async function O(d,{rating:u,comment:m}={}){const g=n.conversations.find(h=>h.id===d),c={...(g==null?void 0:g.metadata)||{},feedback:{rating:u,comment:m||null,submitted_at:new Date().toISOString()}};await C(d,{metadata:c})}function R(d){var m,g;const u=n.messagesByConv[d]||[];for(let v=u.length-1;v>=0;v--){const c=u[v];if((c==null?void 0:c.type)==="action"&&((m=c==null?void 0:c.payload)==null?void 0:m.type)==="action"&&((g=c==null?void 0:c.payload)==null?void 0:g.state)==="pending"&&Array.isArray(c==null?void 0:c.callbacks)&&c.callbacks.length>0&&!n.awaitingCallback[c.id])return c}return null}function j(d){var m,g,v;const u=n.messagesByConv[d]||[];for(let c=u.length-1;c>=0;c--){const h=u[c];if(((m=h==null?void 0:h.author)==null?void 0:m.type)==="user"||(h==null?void 0:h.type)==="action"&&((g=h==null?void 0:h.payload)==null?void 0:g.state)==="pending")return null;const p=(v=h==null?void 0:h.metadata)==null?void 0:v.form;if(p&&Array.isArray(p.fields)&&p.fields.length>0)return{message:h,form:p}}return null}function H(d){const u=n.runningActionsByConv[d];if(!u)return null;const m=Object.keys(u);if(m.length===0)return null;const g=m[0];return{id:g,payload:{name:u[g]}}}function q(d){var m,g,v,c;const u=n.messagesByConv[d]||[];for(let h=u.length-1;h>=0;h--){const p=u[h];if(((m=p==null?void 0:p.author)==null?void 0:m.type)==="user")return[];if((p==null?void 0:p.type)==="action"&&((g=p==null?void 0:p.payload)==null?void 0:g.state)==="pending")return[];if(((v=p==null?void 0:p.author)==null?void 0:v.type)!=="agent_ia")continue;const w=(c=p==null?void 0:p.metadata)==null?void 0:c.suggested_replies;return Array.isArray(w)&&w.length?w.map(B=>{if(typeof B=="string"){const E=B.trim();return E?{label:E,kind:null}:null}if(B&&typeof B=="object"&&typeof B.label=="string"){const E=B.label.trim();if(!E)return null;const L=B.kind==="cta"||B.kind==="choice"||B.kind==="followup"?B.kind:null;return{label:E,kind:L}}return null}).filter(Boolean).slice(0,4):[]}return[]}function D(d,u){var c;const m=n.messagesByConv[d]||[];let g=-1;u!=null&&u.client_msg_id&&(g=m.findIndex(h=>(h==null?void 0:h.client_msg_id)&&h.client_msg_id===u.client_msg_id)),g===-1&&(u==null?void 0:u.id)!==void 0&&(u==null?void 0:u.id)!==null&&(g=m.findIndex(h=>K(h==null?void 0:h.id,u.id)));let v;g===-1?v=[...m,u].sort(X):(v=m.slice(),v[g]={...m[g],...u,_pending:!1,_failed:!1}),n.messagesByConv[d]=v,(u==null?void 0:u.type)==="action"&&((c=u==null?void 0:u.payload)!=null&&c.state)&&u.payload.state!=="pending"&&(u==null?void 0:u.id)!=null&&n.awaitingCallback[u.id]&&delete n.awaitingCallback[u.id]}function K(d,u){return d===u?!0:d==null||u==null?!1:String(d)===String(u)}function F(d,u,m){const g=n.messagesByConv[d];if(!g)return;const v=g.findIndex(h=>h.id===u);if(v===-1)return;const c=g.slice();c[v]={...g[v],...m},n.messagesByConv[d]=c}function $(d,u){const m=n.conversations.findIndex(v=>v.id===d);if(m===-1)return;const g=n.conversations[m];if(u&&(!g.last_message_at||u>g.last_message_at)){const v=n.conversations.slice();v[m]={...g,last_message_at:u},v.sort((c,h)=>(h.last_message_at||"").localeCompare(c.last_message_at||"")),n.conversations=v}}function X(d,u){return(d.created_at||"").localeCompare(u.created_at||"")}function ie(d){if(!d||typeof d!="object")return null;const u={},m={};for(const[g,v]of Object.entries(d))v!==void 0&&(g==="name"||g==="email"||g==="language"?v!=null&&String(v).trim()!==""&&(u[g]=v):(g==="values"||g==="metadata")&&v&&typeof v=="object"?Object.assign(m,v):m[g]=v);return Object.keys(m).length&&(u.values=m),Object.keys(u).length?u:null}function Z(d){const u=n.messagesByConv[d]||[];let m="";for(const c of u)c!=null&&c.created_at&&c.created_at>m&&(m=c.created_at);const g=new Date().toISOString();return!m||g>m?g:new Date(Date.parse(m)+1).toISOString()}return{state:n,start:s,destroy:a,applyCustomer:o,createConversation:i,openConversation:f,loadMore:y,fetchSinceLast:S,patchConversation:C,markConversationRead:k,send:x,clickCallback:b,signAttachment:N,submitFeedback:O,getPendingApproval:R,getActionInFlight:H,getLatestSuggestions:q,getLatestForm:j,setPanelOpen:t.setPanelOpen}}const T={w:"#ffffff",g50:"#F9F9F7",g100:"#F2F1EE",g150:"#E8E6E2",g200:"#D9D6CF",g300:"#B4B0A8",g400:"#888480",g500:"#5A5753",g700:"#2B2926",g900:"#17161A",accent:"#5B5FEF",accentLight:"#EEEFFE",green:"#22C55E",red:"#B91C1C",redBg:"#FDECEC"},ee=["#5B5FEF","#7C3AED","#DB2777","#0891B2","#D97706","#059669"];function ne(t=""){return t?ee[t.charCodeAt(0)%ee.length]:ee[0]}function re(t=""){return t.split(" ").map(n=>n[0]||"").join("").toUpperCase().slice(0,2)}function te(t=new Date,n="fr-FR"){return t.toLocaleTimeString(n,{hour:"2-digit",minute:"2-digit"})}const ke=`
2
2
  @import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700&family=Geist+Mono:wght@400;500&display=swap');
3
3
 
4
4
  .wm-root {
@@ -45,14 +45,14 @@
45
45
  0% { transform: translateX(110%); opacity: 0; }
46
46
  100% { transform: translateX(0); opacity: 1; }
47
47
  }
48
- `,ye="https://api.messenger.victorc.fr",K="fr",ke=["fr","en"],ce={fr:"fr-FR",en:"en-US"},ie={fr:{"common.newConversation":"Nouvelle conversation","common.conversation":"Conversation","common.agent":"Agent","common.aiAssistant":"Assistant IA","common.system":"Système","common.you":"Vous","common.action":"Action","common.yes":"Oui","common.no":"Non","common.send":"Envoyer","common.sending":"Envoi…","common.cancel":"Annuler","common.save":"Enregistrer","common.close":"Fermer","common.open":"Ouvrir","loading.minimize":"Réduire","error.connectionFailed":"Connexion impossible","header.backToHome":"Retour à l'accueil","header.moreOptions":"Plus d'options","header.closeWidget":"Fermer le widget","launcher.open":"Ouvrir le messenger","launcher.openConversationWith":"Ouvrir la conversation avec {name}","launcher.theAgent":"l'agent","launcher.dismiss":"Ignorer","launcher.repliedToYou":" vous a répondu","launcher.unreadMessages":"{count} messages non lus","launcher.unreadConversationsOne":"{count} conversation non lue","launcher.unreadConversationsMany":"{count} conversations non lues","onboarding.start":"Commencer une conversation","onboarding.quickAccess":"Accès rapide","onboarding.recentConversations":"Conversations récentes","onboarding.search":"Rechercher dans vos messages","onboarding.unread":"Non lu","onboarding.noResults":"Aucun résultat pour « {query} ».","onboarding.greetingNamed":"Bonjour, je suis {name}","onboarding.greeting":"Bonjour, je suis votre assistant","onboarding.heroSub":`Posez-moi n'importe quelle question.
48
+ `,we="https://api.messenger.victorc.fr",W="fr",be=["fr","en"],ue={fr:"fr-FR",en:"en-US"},ce={fr:{"common.newConversation":"Nouvelle conversation","common.conversation":"Conversation","common.agent":"Agent","common.aiAssistant":"Assistant IA","common.system":"Système","common.you":"Vous","common.action":"Action","common.yes":"Oui","common.no":"Non","common.send":"Envoyer","common.sending":"Envoi…","common.cancel":"Annuler","common.save":"Enregistrer","common.close":"Fermer","common.open":"Ouvrir","loading.minimize":"Réduire","error.connectionFailed":"Connexion impossible","header.backToHome":"Retour à l'accueil","header.moreOptions":"Plus d'options","header.closeWidget":"Fermer le widget","launcher.open":"Ouvrir le messenger","launcher.openConversationWith":"Ouvrir la conversation avec {name}","launcher.theAgent":"l'agent","launcher.dismiss":"Ignorer","launcher.repliedToYou":" vous a répondu","launcher.unreadMessages":"{count} messages non lus","launcher.unreadConversationsOne":"{count} conversation non lue","launcher.unreadConversationsMany":"{count} conversations non lues","onboarding.start":"Commencer une conversation","onboarding.quickAccess":"Accès rapide","onboarding.recentConversations":"Conversations récentes","onboarding.search":"Rechercher dans vos messages","onboarding.unread":"Non lu","onboarding.noResults":"Aucun résultat pour « {query} ».","onboarding.greetingNamed":"Bonjour, je suis {name}","onboarding.greeting":"Bonjour, je suis votre assistant","onboarding.heroSub":`Posez-moi n'importe quelle question.
49
49
  Je réponds en quelques secondes.`,"onboarding.newMessage":"Nouveau message","onboarding.statusInProgress":"En cours","onboarding.resume":"Reprendre","onboarding.unreadConversations":"Conversations non lues","composer.placeholder":"Écrivez votre message…","composer.replyTo":"Répondre à {name}…","composer.agentTakingOver":"Un agent prend le relais…","composer.send":"Envoyer","composer.attach":"Joindre","composer.attachFile":"Joindre un fichier","composer.screenshot":"Capture d'écran","composer.recordScreen":"Enregistrer l'écran","composer.recording":"Enregistrement · {time}","composer.stop":"Arrêter","messageList.loadingHistory":"Chargement de l'historique…","messageList.conversationStart":"Début de la conversation","messageList.unread":"Non lus","messageList.today":"Aujourd'hui · {time}","messageList.approvalRequestSent":"Demande d'approbation envoyée","messageList.conversationUpdate":"Mise à jour de la conversation","messageList.anAgent":"Un agent","messageList.scrollToBottom":"Aller en bas","system.transferredToHuman":"Conversation transférée à un humain","system.assigned":"{name} a rejoint la conversation","system.unassigned":"L'agent a quitté la conversation","system.resolved":"Conversation résolue","system.reopened":"Conversation rouverte","system.idle":"Conversation en pause","action.title":"Confirmer l'action","action.inProgress":"{name} en cours, veuillez patienter…","action.rejectedByUser":"Action annulée par l'utilisateur.","approval.approve":"Autoriser","approval.reject":"Refuser","moreMenu.editTitle":"Modifier le titre","moreMenu.exportTranscript":"Exporter la transcription","moreMenu.sound":"Son","moreMenu.browserNotifications":"Notifications navigateur","moreMenu.serviceStatus":"Statut des services","moreMenu.helpCenter":"Centre d'aide","feedback.question":"Comment s'est passée cette conversation ?","feedback.subtitle":"Votre avis nous aide à améliorer l'assistant.","feedback.rating1":"Pas bien","feedback.rating2":"Moyen","feedback.rating3":"Bien","feedback.rating4":"Super","feedback.rating5":"Excellent","feedback.submit":"Envoyer mon avis","feedback.doneTitle":"Merci pour votre retour !","feedback.doneSubtitle":"Votre avis a bien été pris en compte.","rename.dialogTitle":"Modifier le titre de la conversation","rename.title":"Modifier le titre","rename.placeholder":"Titre de la conversation","form.title":"Formulaire","form.choose":"Choisir…","form.responseSent":"Réponse envoyée","form.sent":"Envoyé","form.fieldRequired":"« {label} » est requis.","ticket.dateAt":" à ","attachment.fallbackName":"Pièce jointe","attachment.remove":"Retirer","attachment.fileFallbackName":"fichier","attachment.bytes":"{size} o","attachment.kilobytes":"{size} ko","attachment.megabytes":"{size} Mo","notification.newMessage":"Nouveau message","notification.youHaveNewMessage":"Vous avez un nouveau message","export.createdOn":"Créée le : {date}"},en:{"common.newConversation":"New conversation","common.conversation":"Conversation","common.agent":"Agent","common.aiAssistant":"AI Assistant","common.system":"System","common.you":"You","common.action":"Action","common.yes":"Yes","common.no":"No","common.send":"Send","common.sending":"Sending…","common.cancel":"Cancel","common.save":"Save","common.close":"Close","common.open":"Open","loading.minimize":"Minimize","error.connectionFailed":"Connection failed","header.backToHome":"Back to home","header.moreOptions":"More options","header.closeWidget":"Close widget","launcher.open":"Open the messenger","launcher.openConversationWith":"Open the conversation with {name}","launcher.theAgent":"the agent","launcher.dismiss":"Dismiss","launcher.repliedToYou":" replied to you","launcher.unreadMessages":"{count} unread messages","launcher.unreadConversationsOne":"{count} unread conversation","launcher.unreadConversationsMany":"{count} unread conversations","onboarding.start":"Start a conversation","onboarding.quickAccess":"Quick access","onboarding.recentConversations":"Recent conversations","onboarding.search":"Search your messages","onboarding.unread":"Unread","onboarding.noResults":"No results for “{query}”.","onboarding.greetingNamed":"Hi, I'm {name}","onboarding.greeting":"Hi, I'm your assistant","onboarding.heroSub":`Ask me anything.
50
- I reply within seconds.`,"onboarding.newMessage":"New message","onboarding.statusInProgress":"In progress","onboarding.resume":"Resume","onboarding.unreadConversations":"Unread conversations","composer.placeholder":"Type your message…","composer.replyTo":"Reply to {name}…","composer.agentTakingOver":"An agent is taking over…","composer.send":"Send","composer.attach":"Attach","composer.attachFile":"Attach a file","composer.screenshot":"Screenshot","composer.recordScreen":"Record screen","composer.recording":"Recording · {time}","composer.stop":"Stop","messageList.loadingHistory":"Loading history…","messageList.conversationStart":"Start of the conversation","messageList.unread":"Unread","messageList.today":"Today · {time}","messageList.approvalRequestSent":"Approval request sent","messageList.conversationUpdate":"Conversation update","messageList.anAgent":"An agent","messageList.scrollToBottom":"Scroll to bottom","system.transferredToHuman":"Conversation transferred to a human","system.assigned":"{name} joined the conversation","system.unassigned":"The agent left the conversation","system.resolved":"Conversation resolved","system.reopened":"Conversation reopened","system.idle":"Conversation paused","action.title":"Confirm the action","action.inProgress":"{name} in progress, please wait…","action.rejectedByUser":"Action cancelled by the user.","approval.approve":"Approve","approval.reject":"Decline","moreMenu.editTitle":"Edit title","moreMenu.exportTranscript":"Export transcript","moreMenu.sound":"Sound","moreMenu.browserNotifications":"Browser notifications","moreMenu.serviceStatus":"Service status","moreMenu.helpCenter":"Help center","feedback.question":"How was this conversation?","feedback.subtitle":"Your feedback helps us improve the assistant.","feedback.rating1":"Poor","feedback.rating2":"Okay","feedback.rating3":"Good","feedback.rating4":"Great","feedback.rating5":"Excellent","feedback.submit":"Send my feedback","feedback.doneTitle":"Thanks for your feedback!","feedback.doneSubtitle":"Your feedback has been recorded.","rename.dialogTitle":"Edit conversation title","rename.title":"Edit title","rename.placeholder":"Conversation title","form.title":"Form","form.choose":"Choose…","form.responseSent":"Response sent","form.sent":"Sent","form.fieldRequired":"“{label}” is required.","ticket.dateAt":" at ","attachment.fallbackName":"Attachment","attachment.remove":"Remove","attachment.fileFallbackName":"file","attachment.bytes":"{size} B","attachment.kilobytes":"{size} KB","attachment.megabytes":"{size} MB","notification.newMessage":"New message","notification.youHaveNewMessage":"You have a new message","export.createdOn":"Created on: {date}"}};function ne(t){if(typeof t!="string")return K;const n=t.trim().toLowerCase().slice(0,2);return ke.includes(n)?n:K}function P(t){return ce[ne(t)]||ce[K]}function M(t){const n=ne(t),r=ie[n]||ie[K],s=ie[K];return function(o,i){let l=r[o];return l==null&&(l=s[o]),l==null?o:(i&&(l=l.replace(/\{(\w+)\}/g,(p,v)=>i[v]!=null?String(i[v]):p)),l)}}function de(t,n){if(!Array.isArray(t==null?void 0:t.options))return n;const r=t.options.find(s=>(s==null?void 0:s.value)===n);return(r==null?void 0:r.label)||n}function we(t,n,r){return Array.isArray(n)?n.map(s=>de(t,String(s))).join(", "):typeof n=="boolean"?r(n?"common.yes":"common.no"):de(t,String(n))}function nt(t,n,r=M()){if(!t||!n)return"";const s=Array.isArray(t.fields)?t.fields:[],a=[];for(const o of s){if(!(o!=null&&o.key)||!(o!=null&&o.label))continue;const i=n[o.key];if(i==null||i==="")continue;const l=we(o,i,r);l&&a.push(`${o.label} :
50
+ I reply within seconds.`,"onboarding.newMessage":"New message","onboarding.statusInProgress":"In progress","onboarding.resume":"Resume","onboarding.unreadConversations":"Unread conversations","composer.placeholder":"Type your message…","composer.replyTo":"Reply to {name}…","composer.agentTakingOver":"An agent is taking over…","composer.send":"Send","composer.attach":"Attach","composer.attachFile":"Attach a file","composer.screenshot":"Screenshot","composer.recordScreen":"Record screen","composer.recording":"Recording · {time}","composer.stop":"Stop","messageList.loadingHistory":"Loading history…","messageList.conversationStart":"Start of the conversation","messageList.unread":"Unread","messageList.today":"Today · {time}","messageList.approvalRequestSent":"Approval request sent","messageList.conversationUpdate":"Conversation update","messageList.anAgent":"An agent","messageList.scrollToBottom":"Scroll to bottom","system.transferredToHuman":"Conversation transferred to a human","system.assigned":"{name} joined the conversation","system.unassigned":"The agent left the conversation","system.resolved":"Conversation resolved","system.reopened":"Conversation reopened","system.idle":"Conversation paused","action.title":"Confirm the action","action.inProgress":"{name} in progress, please wait…","action.rejectedByUser":"Action cancelled by the user.","approval.approve":"Approve","approval.reject":"Decline","moreMenu.editTitle":"Edit title","moreMenu.exportTranscript":"Export transcript","moreMenu.sound":"Sound","moreMenu.browserNotifications":"Browser notifications","moreMenu.serviceStatus":"Service status","moreMenu.helpCenter":"Help center","feedback.question":"How was this conversation?","feedback.subtitle":"Your feedback helps us improve the assistant.","feedback.rating1":"Poor","feedback.rating2":"Okay","feedback.rating3":"Good","feedback.rating4":"Great","feedback.rating5":"Excellent","feedback.submit":"Send my feedback","feedback.doneTitle":"Thanks for your feedback!","feedback.doneSubtitle":"Your feedback has been recorded.","rename.dialogTitle":"Edit conversation title","rename.title":"Edit title","rename.placeholder":"Conversation title","form.title":"Form","form.choose":"Choose…","form.responseSent":"Response sent","form.sent":"Sent","form.fieldRequired":"“{label}” is required.","ticket.dateAt":" at ","attachment.fallbackName":"Attachment","attachment.remove":"Remove","attachment.fileFallbackName":"file","attachment.bytes":"{size} B","attachment.kilobytes":"{size} KB","attachment.megabytes":"{size} MB","notification.newMessage":"New message","notification.youHaveNewMessage":"You have a new message","export.createdOn":"Created on: {date}"}};function oe(t){if(typeof t!="string")return W;const n=t.trim().toLowerCase().slice(0,2);return be.includes(n)?n:W}function z(t){return ue[oe(t)]||ue[W]}function M(t){const n=oe(t),r=ce[n]||ce[W],s=ce[W];return function(o,i){let l=r[o];return l==null&&(l=s[o]),l==null?o:(i&&(l=l.replace(/\{(\w+)\}/g,(f,y)=>i[y]!=null?String(i[y]):f)),l)}}function me(t,n){if(!Array.isArray(t==null?void 0:t.options))return n;const r=t.options.find(s=>(s==null?void 0:s.value)===n);return(r==null?void 0:r.label)||n}function Ee(t,n,r){return Array.isArray(n)?n.map(s=>me(t,String(s))).join(", "):typeof n=="boolean"?r(n?"common.yes":"common.no"):me(t,String(n))}function rt(t,n,r=M()){if(!t||!n)return"";const s=Array.isArray(t.fields)?t.fields:[],a=[];for(const o of s){if(!(o!=null&&o.key)||!(o!=null&&o.label))continue;const i=n[o.key];if(i==null||i==="")continue;const l=Ee(o,i,r);l&&a.push(`${o.label} :
51
51
  ${l}`)}return a.join(`
52
52
 
53
- `)}function rt(t,n,r=M()){const s=[],a=Array.isArray(t==null?void 0:t.fields)?t.fields:[];for(const o of a){if(!(o!=null&&o.key)||!(o!=null&&o.label))continue;const i=n==null?void 0:n[o.key];if(i==null||i==="")continue;const l=we(o,i,r);if(!l)continue;const p=o.type==="textarea"||typeof l=="string"&&(l.length>60||l.includes(`
54
- `));s.push({label:o.label,value:l,multiline:p})}return{kind:"form_response",data:{title:(t==null?void 0:t.title)||r("form.title"),fields:s}}}function G(t){var r;const n=(r=t==null?void 0:t.author)==null?void 0:r.type;return n==="agent_ia"||n==="agent_human"}function D(t){if(t==null)return null;const n=typeof t=="number"?t:Number(t);return Number.isFinite(n)?n:null}function ue(t,n){let r=(t==null?void 0:t.last_message_at)||(t==null?void 0:t.updated_at)||(t==null?void 0:t.created_at)||"";for(const s of n)s!=null&&s.created_at&&s.created_at>r&&(r=s.created_at);return r}function ot(t,n){var r,s,a;for(let o=n.length-1;o>=0;o--){const i=n[o];if(!i)continue;const l=typeof i.text_md=="string"?i.text_md.trim():"";if(l)return(((r=i.author)==null?void 0:r.type)==="user"?"Vous : ":"")+l.replace(/\s+/g," ");const p=(s=i.payload)==null?void 0:s.attachments;if(Array.isArray(p)&&p.length)return"📎 Pièce jointe"}return(t==null?void 0:t.last_message_preview)||(t==null?void 0:t.preview)||((a=t==null?void 0:t.metadata)==null?void 0:a.last_preview)||""}function at(t,n){return(t==null?void 0:t.name)||((t==null?void 0:t.type)==="user"?n("common.you"):(t==null?void 0:t.type)==="agent_human"?n("common.agent"):(t==null?void 0:t.type)==="agent_ia"?n("common.aiAssistant"):n("common.system"))}function st(t,n,r,s){const a=[`# ${t.name||r("common.conversation")}`,t.created_at?r("export.createdOn",{date:new Date(t.created_at).toLocaleString(s)}):"",""];for(const o of n){if(!o)continue;const i=(o.text_md||"").trim();if(!i)continue;const l=at(o.author,r),p=o.created_at?new Date(o.created_at).toLocaleString(s):"";a.push(`[${p}] ${l} :`),a.push(i),a.push("")}return a.join(`
55
- `)}function it(t,n,r=M(),s){if(!t)return;const a=st(t,n||[],r,P(s)),o=new Blob([a],{type:"text/plain;charset=utf-8"});try{const i=URL.createObjectURL(o),l=document.createElement("a");l.href=i,l.download=`${(t.name||"conversation").replace(/[^a-z0-9-_]+/gi,"_")}.txt`,document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>URL.revokeObjectURL(i),1e3)}catch(i){console.error("[ww-messenger] export failed",i)}}const lt={data(){const t=typeof Notification<"u";return{notifPermission:t?Notification.permission:"denied",soundEnabled:!0,browserNotifEnabled:t&&Notification.permission==="granted",_audioCtx:null}},methods:{teardownNotifications(){var t,n;if(this._audioCtx){try{(n=(t=this._audioCtx).close)==null||n.call(t)}catch{}this._audioCtx=null}},soundStorageKey(){return`wm:notif:sound:${this.widgetId||""}`},browserNotifStorageKey(){return`wm:notif:browser:${this.widgetId||""}`},hydrateNotifPref(){try{if(typeof localStorage>"u")return;const t=localStorage.getItem(this.soundStorageKey());t==="0"?this.soundEnabled=!1:t==="1"&&(this.soundEnabled=!0);const n=localStorage.getItem(this.browserNotifStorageKey());n==="0"?this.browserNotifEnabled=!1:n==="1"&&(this.browserNotifEnabled=typeof Notification<"u"&&Notification.permission==="granted")}catch{}},persistSoundPref(){try{if(typeof localStorage>"u")return;localStorage.setItem(this.soundStorageKey(),this.soundEnabled?"1":"0")}catch{}},persistBrowserNotifPref(){try{if(typeof localStorage>"u")return;localStorage.setItem(this.browserNotifStorageKey(),this.browserNotifEnabled?"1":"0")}catch{}},onSoundToggle(t){this.soundEnabled=!!t,this.persistSoundPref()},async onBrowserNotifToggle(t){if(typeof Notification>"u"){this.browserNotifEnabled=!1,this.persistBrowserNotifPref();return}if(!t){this.browserNotifEnabled=!1,this.persistBrowserNotifPref();return}let n=Notification.permission;if(n==="default"){try{n=await Notification.requestPermission()}catch(r){console.warn("[ww-messenger] notif permission request failed",r),n="denied"}this.notifPermission=n}this.browserNotifEnabled=n==="granted",this.persistBrowserNotifPref()},onMessageRevealed(t,n){var a;if(!this.soundEnabled&&!this.browserNotifEnabled||!n||!t||!G(t))return;const r=typeof document<"u"&&document.hidden;this.isOpen&&!r&&((a=this.currentConv)==null?void 0:a.id)===n||(this.soundEnabled&&this.playNotificationSound(),this.browserNotifEnabled&&this.showBrowserNotification(n,t))},playNotificationSound(){if(typeof window>"u")return;const t=window.AudioContext||window.webkitAudioContext;if(t)try{this._audioCtx||(this._audioCtx=new t);const n=this._audioCtx;if(n.state==="suspended")try{n.resume()}catch{}const r=n.currentTime,s=n.createOscillator(),a=n.createGain();s.connect(a),a.connect(n.destination),s.type="sine",s.frequency.setValueAtTime(880,r),s.frequency.exponentialRampToValueAtTime(1320,r+.08),a.gain.setValueAtTime(0,r),a.gain.linearRampToValueAtTime(.12,r+.02),a.gain.exponentialRampToValueAtTime(1e-4,r+.28),s.start(r),s.stop(r+.32)}catch{}},showBrowserNotification(t,n){if(typeof Notification>"u"||Notification.permission!=="granted")return;const r=n==null?void 0:n.author,s=!r||r.type==="agent_ia",o=((r==null?void 0:r.name)||(s?this.agentName:"")||this.t("launcher.theAgent"))+this.t("launcher.repliedToYou"),i=typeof(n==null?void 0:n.text_md)=="string"?n.text_md.trim():"",l=i?i.slice(0,140):this.t("notification.youHaveNewMessage");try{const p=new Notification(o,{body:l,tag:`wm-${t}`,renotify:!1,silent:!0});p.onclick=()=>{try{window.focus()}catch{}this.draftConv=null,this.showOnboarding=!1,this.activeConvId=t,this.isOpen=!0,this.store&&this.store.setPanelOpen(!0);try{p.close()}catch{}}}catch(p){console.warn("[ww-messenger] notification failed",p)}}}},ct=450,dt=50,ut=900,mt=12e3,ht=300,ft={data(){return{revealedAt:{},nextRevealAt:0,revealTimers:[],_liveRevealOff:null,_liveRevealConvSnapshot:null}},methods:{cancelReveals(){for(const t of this.revealTimers)clearTimeout(t);this.revealTimers=[]},resetRevealQueue(){this.cancelReveals(),this.revealedAt={},this.nextRevealAt=0},setupLiveReveal(){var r;if(!this.transport)return;this.teardownLiveReveal();const t=this.transport.on("message",s=>{const a=s==null?void 0:s.conversation_id,o=s==null?void 0:s.message;a&&o&&this.paceLiveMessage(o,a)});this._liveRevealConvSnapshot=new Map((((r=this.s)==null?void 0:r.conversations)||[]).map(s=>[s.id,(s==null?void 0:s.last_message_at)||""]));const n=this.transport.on("activity",s=>{this.handleLiveActivity(s)});this._liveRevealOff=()=>{try{t()}catch{}try{n()}catch{}}},teardownLiveReveal(){if(this._liveRevealOff){try{this._liveRevealOff()}catch{}this._liveRevealOff=null}this._liveRevealConvSnapshot=null},async handleLiveActivity(t){var a,o;const n=t==null?void 0:t.conversations;if(!Array.isArray(n)||!this.store)return;const r=this._liveRevealConvSnapshot||new Map,s=[];for(const i of n){if(!(i!=null&&i.id))continue;const l=i.last_message_at||"";if(!l)continue;const p=r.get(i.id)||"";l>p&&s.push(i.id)}this._liveRevealConvSnapshot=new Map(n.map(i=>[i.id,(i==null?void 0:i.last_message_at)||""]));for(const i of s)try{const l=await((o=(a=this.store).fetchSinceLast)==null?void 0:o.call(a,i));if(!Array.isArray(l))continue;for(const p of l)this.paceLiveMessage(p,i)}catch(l){console.error("[ww-messenger] activity delta fetch failed",l)}},scheduleReveal(t,n){const r=Date.now(),s=((t==null?void 0:t.text_md)||"").length,a=Math.min(mt,Math.max(ut,s*dt)),i=Math.max(r+ct,this.nextRevealAt+ht)+a;this.nextRevealAt=i;const l=Math.max(0,i-r),p=t.id,v=setTimeout(()=>{this.revealedAt={...this.revealedAt,[p]:Date.now()},this.revealTimers=this.revealTimers.filter(g=>g!==v),typeof this.onMessageRevealed=="function"&&this.onMessageRevealed(t,n)},l);this.revealTimers.push(v)},paceMessages(t,n){var a;if(!Array.isArray(t)||!t.length)return;const r=Date.now(),s={...this.revealedAt};for(const o of t){if((o==null?void 0:o.id)==null||s[o.id]!==void 0)continue;if(!G(o)){s[o.id]=r;continue}const i=o!=null&&o.created_at?Date.parse(o.created_at):NaN;if(!Number.isFinite(i)||i<this.convOpenedAt){s[o.id]=r;continue}const l=typeof(o==null?void 0:o.text_md)=="string"&&o.text_md.trim().length>0,p=Array.isArray((a=o==null?void 0:o.payload)==null?void 0:a.attachments)&&o.payload.attachments.length>0;if(!l&&!p){s[o.id]=r;continue}s[o.id]=0,this.scheduleReveal(o,n)}this.revealedAt=s},paceLiveMessage(t,n){var a;if(!(t!=null&&t.id)||this.revealedAt[t.id]!==void 0)return;if(!G(t)){this.revealedAt={...this.revealedAt,[t.id]:Date.now()};return}const r=typeof(t==null?void 0:t.text_md)=="string"&&t.text_md.trim().length>0,s=Array.isArray((a=t==null?void 0:t.payload)==null?void 0:a.attachments)&&t.payload.attachments.length>0;if(!r&&!s){this.revealedAt={...this.revealedAt,[t.id]:Date.now()};return}this.revealedAt={...this.revealedAt,[t.id]:0},this.scheduleReveal(t,n)}}},pt={data(){return{approvalSettled:!0,approvalSettleTimer:null,approvalLatchId:null}},methods:{resetApprovalPacing(){this.approvalSettleTimer&&(clearTimeout(this.approvalSettleTimer),this.approvalSettleTimer=null),this.approvalSettled=!0,this.approvalLatchId=null},bumpApprovalSettle(t=800){this.approvalSettled=!1,this.approvalSettleTimer&&clearTimeout(this.approvalSettleTimer),this.approvalSettleTimer=setTimeout(()=>{this.approvalSettled=!0,this.approvalSettleTimer=null},t)}}},gt=300,_t={data(){return{unreadAnchorId:null,unreadBoundaryTs:""}},created(){this._readMarkerTimer=null,this._readMarkerPending=null},beforeUnmount(){this._readMarkerTimer&&(clearTimeout(this._readMarkerTimer),this._readMarkerTimer=null),this._readMarkerPending=null},methods:{markConvRead(t){var o,i;if(!(t!=null&&t.id)||t._draft||!this.store)return;const n=((i=(o=this.s)==null?void 0:o.messagesByConv)==null?void 0:i[t.id])||[],r=vt(n);if(r==null)return;const s=D(t.last_read_message_id),a=D(r);a!=null&&(s!=null&&a<=s||(this._readMarkerPending={convId:t.id,messageId:r},!this._readMarkerTimer&&(this._readMarkerTimer=setTimeout(()=>{const l=this._readMarkerPending;this._readMarkerPending=null,this._readMarkerTimer=null,l&&this.store&&this.store.markConversationRead(l.convId,l.messageId)},gt))))}}};function vt(t){for(let n=t.length-1;n>=0;n--){const r=t[n];if(!(!r||r._pending)&&D(r.id)!=null)return r.id}return null}const A=(t,n)=>{const r=t.__vccOpts||t;for(const[s,a]of n)r[s]=a;return r},yt={name:"WmHumanAvatar",props:{name:{type:String,default:""},avatarUrl:{type:String,default:null},size:{type:Number,default:26},tail:{type:Boolean,default:!1}},computed:{bg(){return this.avatarUrl?"transparent":ee(this.name)},initials(){return te(this.name)}}},kt=["src","alt"];function wt(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-huav",{"wm-huav--tail":r.tail}]),style:e.normalizeStyle({width:r.size+"px",height:r.size+"px","--wm-avr":Math.round(r.size*.32)+"px",background:o.bg})},[r.avatarUrl?(e.openBlock(),e.createElementBlock("img",{key:0,src:r.avatarUrl,alt:r.name||""},null,8,kt)):(e.openBlock(),e.createElementBlock("span",{key:1,style:e.normalizeStyle({fontSize:r.size*.36+"px"})},e.toDisplayString(o.initials),5))],6)}const re=A(yt,[["render",wt],["__scopeId","data-v-14e10c0d"]]),bt=3,Et={name:"WmLauncher",components:{HumanAvatar:re},inject:{t:{default:()=>M()}},props:{unreadCount:{type:Number,default:0},peeks:{type:Array,default:()=>[]}},emits:["open","dismiss"],computed:{visiblePeeks(){return this.peeks.slice(0,bt).reverse()}}},Ct=["aria-label","onClick","onKeydown"],Bt=["aria-label","onClick"],Nt={class:"wm-peek__avatar"},St=["aria-label"],At={class:"wm-peek__body"},Vt={class:"wm-peek__head"},Mt={class:"wm-peek__name"},Tt={class:"wm-peek__action"},xt={class:"wm-peek__text"},Lt=["onClick"],Ot=["aria-label"],Dt=["aria-label"];function It(t,n,r,s,a,o){const i=e.resolveComponent("HumanAvatar");return e.openBlock(),e.createElementBlock("div",{class:"wm-launcherWrap",onMouseenter:n[1]||(n[1]=l=>t.$emit("hover",!0)),onMouseleave:n[2]||(n[2]=l=>t.$emit("hover",!1)),onFocusin:n[3]||(n[3]=l=>t.$emit("hover",!0)),onFocusout:n[4]||(n[4]=l=>t.$emit("hover",!1))},[e.createVNode(e.Transition,{name:"wm-peek"},{default:e.withCtx(()=>[o.visiblePeeks.length?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["wm-peekStack",{"wm-peekStack--multi":o.visiblePeeks.length>1}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.visiblePeeks,(l,p)=>(e.openBlock(),e.createElementBlock("div",{key:l.convId,class:"wm-peek",style:e.normalizeStyle({"--depth":o.visiblePeeks.length-1-p,zIndex:p+1}),role:"button",tabindex:"0","aria-label":o.t("launcher.openConversationWith",{name:l.senderName||o.t("launcher.theAgent")}),onClick:v=>t.$emit("open",l.convId),onKeydown:[e.withKeys(e.withModifiers(v=>t.$emit("open",l.convId),["prevent"]),["enter"]),e.withKeys(e.withModifiers(v=>t.$emit("open",l.convId),["prevent"]),["space"])]},[e.createElementVNode("button",{type:"button",class:"wm-peek__close","aria-label":o.t("launcher.dismiss"),onClick:e.withModifiers(v=>t.$emit("dismiss",l.convId),["stop"])},[...n[5]||(n[5]=[e.createElementVNode("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,Bt),e.createElementVNode("div",Nt,[e.createVNode(i,{name:l.senderName,"avatar-url":l.senderAvatarUrl,size:34},null,8,["name","avatar-url"]),l.count>1?(e.openBlock(),e.createElementBlock("span",{key:0,class:"wm-peek__avatarBadge","aria-label":o.t("launcher.unreadMessages",{count:l.count})},e.toDisplayString(l.count>9?"9+":l.count),9,St)):e.createCommentVNode("",!0)]),e.createElementVNode("div",At,[e.createElementVNode("div",Vt,[e.createElementVNode("span",Mt,e.toDisplayString(l.senderName||o.t("common.agent")),1),e.createElementVNode("span",Tt,e.toDisplayString(o.t("launcher.repliedToYou")),1)]),e.createElementVNode("p",xt,e.toDisplayString(l.preview),1)]),e.createElementVNode("button",{type:"button",class:"wm-peek__open",onClick:e.withModifiers(v=>t.$emit("open",l.convId),["stop"])},e.toDisplayString(o.t("common.open")),9,Lt)],44,Ct))),128))],2)):e.createCommentVNode("",!0)]),_:1}),e.createElementVNode("button",{type:"button",class:"wm-launcher","aria-label":o.t("launcher.open"),onClick:n[0]||(n[0]=l=>t.$emit("open"))},[n[6]||(n[6]=e.createElementVNode("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.7","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})],-1)),r.unreadCount>0?(e.openBlock(),e.createElementBlock("span",{key:0,class:"wm-launcher__badge","aria-label":r.unreadCount>1?o.t("launcher.unreadConversationsMany",{count:r.unreadCount}):o.t("launcher.unreadConversationsOne",{count:r.unreadCount})},e.toDisplayString(r.unreadCount>9?"9+":r.unreadCount),9,Dt)):e.createCommentVNode("",!0)],8,Ot)],32)}const be=A(Et,[["render",It],["__scopeId","data-v-44ddf1a1"]]),Rt={name:"WmAIAvatar",props:{size:{type:Number,default:26},pulse:{type:Boolean,default:!1},tail:{type:Boolean,default:!1},name:{type:String,default:""},imageUrl:{type:String,default:null}},computed:{initials(){return te(this.name)},bgColor(){return ee(this.name)}}},Ft={key:0,class:"wm-aiav__pulse"},Pt=["src","alt"],Ut=["width","height"];function zt(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-aiav",{"wm-aiav--tail":r.tail}]),style:e.normalizeStyle({width:r.size+"px",height:r.size+"px","--wm-avr":r.size*.32+"px"})},[r.pulse?(e.openBlock(),e.createElementBlock("div",Ft)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["wm-aiav__inner",{"wm-aiav__inner--glow":r.pulse,"wm-aiav__inner--img":!!r.imageUrl,"wm-aiav__inner--initials":!r.imageUrl&&!!o.initials}]),style:e.normalizeStyle(!r.imageUrl&&o.initials?{background:o.bgColor}:null)},[r.imageUrl?(e.openBlock(),e.createElementBlock("img",{key:0,src:r.imageUrl,alt:r.name||""},null,8,Pt)):o.initials?(e.openBlock(),e.createElementBlock("span",{key:1,style:e.normalizeStyle({fontSize:r.size*.36+"px"})},e.toDisplayString(o.initials),5)):(e.openBlock(),e.createElementBlock("svg",{key:2,width:r.size*.5,height:r.size*.5,viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[...n[0]||(n[0]=[e.createElementVNode("path",{d:"M12 2 L13.5 9 L20 10.5 L13.5 12 L12 19 L10.5 12 L4 10.5 L10.5 9 Z",fill:"white",opacity:"0.92"},null,-1),e.createElementVNode("circle",{cx:"19",cy:"5",r:"1.5",fill:"white",opacity:"0.55"},null,-1),e.createElementVNode("circle",{cx:"5",cy:"18",r:"1",fill:"white",opacity:"0.38"},null,-1)])],8,Ut))],6)],6)}const $=A(Rt,[["render",zt],["__scopeId","data-v-6f7f685d"]]),jt={name:"WmTeamAvatars",props:{members:{type:Array,default:()=>[]},responseLabel:{type:String,default:""}},computed:{visible(){return Array.isArray(this.members)&&this.members.length>0},stackWidth(){return Math.min(this.members.length,3)===1?20:16+Math.min(this.members.length,3)*13}},methods:{colorFor(t){return t.avatar_url?"transparent":ee(t.name||"")},initialsFor(t){return te(t.name||"")}}},Ht={key:0,class:"wm-team"},qt=["src","alt"],Kt={key:1},$t={key:0,class:"wm-team__label"};function Wt(t,n,r,s,a,o){return o.visible?(e.openBlock(),e.createElementBlock("div",Ht,[e.createElementVNode("div",{class:"wm-team__stack",style:e.normalizeStyle({width:o.stackWidth+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.members.slice(0,3),(i,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-team__pill",style:e.normalizeStyle({left:l*13+"px",zIndex:3-l,background:o.colorFor(i)})},[i.avatar_url?(e.openBlock(),e.createElementBlock("img",{key:0,src:i.avatar_url,alt:i.name||""},null,8,qt)):(e.openBlock(),e.createElementBlock("span",Kt,e.toDisplayString(o.initialsFor(i)),1))],4))),128))],4),r.responseLabel?(e.openBlock(),e.createElementBlock("span",$t,e.toDisplayString(r.responseLabel),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}const Ee=A(jt,[["render",Wt],["__scopeId","data-v-e49a9063"]]),Gt={name:"WmHeader",components:{AIAvatar:$,TeamAvatars:Ee},inject:{t:{default:()=>M()}},props:{title:{type:String,default:"Nouvelle conversation"},showBack:{type:Boolean,default:!1},teamMembers:{type:Array,default:()=>[]},responseLabel:{type:String,default:""},showClose:{type:Boolean,default:!0},showMore:{type:Boolean,default:!0},moreActive:{type:Boolean,default:!1},showIdentity:{type:Boolean,default:!0},agentName:{type:String,default:""},agentAvatarUrl:{type:String,default:null}},emits:["back","close","more"],computed:{hasTeam(){return Array.isArray(this.teamMembers)&&this.teamMembers.length>0},displayedTeamMembers(){const t=Array.isArray(this.teamMembers)?this.teamMembers:[];if(t.length<=3)return t;const n=new Date().getHours()%t.length,r=[];for(let s=0;s<3;s++)r.push(t[(n+s)%t.length]);return r}}},Yt={class:"wm-header"},Jt=["aria-label"],Qt={key:1,style:{width:"30px",height:"30px","flex-shrink":"0"}},Xt={class:"wm-header__avatar"},Zt={class:"wm-header__main"},en={class:"wm-header__title"},tn={key:3,class:"wm-header__fill"},nn={class:"wm-header__actions"},rn=["aria-label","title"],on=["aria-label","title"];function an(t,n,r,s,a,o){const i=e.resolveComponent("AIAvatar"),l=e.resolveComponent("TeamAvatars");return e.openBlock(),e.createElementBlock("div",Yt,[r.showBack?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-header__icon","aria-label":o.t("header.backToHome"),onClick:n[0]||(n[0]=p=>t.$emit("back"))},[...n[3]||(n[3]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M19 12H5M12 5l-7 7 7 7"})],-1)])],8,Jt)):(e.openBlock(),e.createElementBlock("div",Qt)),r.showIdentity?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createElementVNode("div",Xt,[e.createVNode(i,{size:30,name:r.agentName,"image-url":r.agentAvatarUrl},null,8,["name","image-url"])]),e.createElementVNode("div",Zt,[e.createElementVNode("div",en,e.toDisplayString(r.title),1)]),o.hasTeam?(e.openBlock(),e.createBlock(l,{key:0,members:o.displayedTeamMembers,"response-label":""},null,8,["members"])):e.createCommentVNode("",!0)],64)):(e.openBlock(),e.createElementBlock("div",tn)),e.createElementVNode("div",nn,[r.showMore?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["wm-header__icon",{"wm-header__icon--active":r.moreActive}]),"aria-label":o.t("header.moreOptions"),title:o.t("header.moreOptions"),onClick:n[1]||(n[1]=p=>t.$emit("more"))},[...n[4]||(n[4]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true"},[e.createElementVNode("circle",{cx:"12",cy:"5",r:"1.6"}),e.createElementVNode("circle",{cx:"12",cy:"12",r:"1.6"}),e.createElementVNode("circle",{cx:"12",cy:"19",r:"1.6"})],-1)])],10,rn)):e.createCommentVNode("",!0),r.showClose?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"wm-header__icon","aria-label":o.t("header.closeWidget"),title:o.t("header.closeWidget"),onClick:n[2]||(n[2]=p=>t.$emit("close"))},[...n[5]||(n[5]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,on)):e.createCommentVNode("",!0)])])}const Ce=A(Gt,[["render",an],["__scopeId","data-v-7af4c118"]]);function Be(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function sn(t){return/^(https?:\/\/|mailto:|tel:)/i.test(String(t).trim())}const me="";function W(t){let n=t;const r=[];return n=n.replace(/`([^`\n]+)`/g,(s,a)=>{const o=r.length;return r.push(a),`${me}CODE${o}${me}`}),n=n.replace(/\[([^\]\n]+)\]\(([^)\s]+)\)/g,(s,a,o)=>sn(o)?`<a href="${o}" target="_blank" rel="noopener noreferrer">${a}</a>`:a),n=n.replace(/\*\*([^\n*][^\n]*?)\*\*/g,"<strong>$1</strong>"),n=n.replace(/__([^\n_][^\n]*?)__/g,"<u>$1</u>"),n=n.replace(/~~([^\n~][^\n]*?)~~/g,"<s>$1</s>"),n=n.replace(/(^|[^\w*])\*([^\n*]+?)\*(?!\w)/g,"$1<em>$2</em>"),n=n.replace(/(^|[^\w_])_([^\n_]+?)_(?!\w)/g,"$1<em>$2</em>"),n=n.replace(/CODE(\d+)/g,(s,a)=>`<code class="wm-md-code">${r[+a]}</code>`),n}function Ne(t){if(!t)return"";const n=String(t).replace(/\[([^\]\n]+)\]\([^)\s]+\)/g,"$1");return W(Be(n))}function Se(t){if(!t)return"";const n=Be(t).split(`
56
- `),r=[];let s=0;for(;s<n.length;){const o=n[s];if(/^\s*```([\w-]*)\s*$/.exec(o)){s++;const v=[];for(;s<n.length&&!/^\s*```\s*$/.test(n[s]);)v.push(n[s]),s++;s<n.length&&s++,r.push({type:"block",html:`<pre class="wm-md-pre"><code>${v.join(`
57
- `)}</code></pre>`});continue}if(/^\s*[-*]\s+/.test(o)){const v=[];for(;s<n.length;){const E=/^\s*[-*]\s+(.*)$/.exec(n[s]);if(!E)break;v.push(E[1]),s++}const g=v.map(E=>`<li>${W(E)}</li>`).join("");r.push({type:"block",html:`<ul class="wm-md-ul">${g}</ul>`});continue}const l=/^\s*(\d+)\.\s+(.*)$/.exec(o);if(l){const v=parseInt(l[1],10),g=[l[2]];for(s++;s<n.length;){const k=/^\s*\d+\.\s+(.*)$/.exec(n[s]);if(!k)break;g.push(k[1]),s++}const E=g.map(k=>`<li>${W(k)}</li>`).join(""),S=v!==1?` start="${v}"`:"";r.push({type:"block",html:`<ol class="wm-md-ol"${S}>${E}</ol>`});continue}const p=/^(#{1,6})\s+(.*)$/.exec(o);if(p){const v=p[1].length;r.push({type:"block",html:`<h${v} class="wm-md-h wm-md-h${v}">${W(p[2])}</h${v}>`}),s++;continue}r.push({type:"text",html:W(o)}),s++}let a="";for(let o=0;o<r.length;o++){const i=r[o];a+=i.html;const l=r[o+1];l&&i.type!=="block"&&l.type!=="block"&&(a+=`
58
- `)}return a}const he={book:"M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253",changelog:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2",status:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z",chat:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z",link:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"},ln={name:"WmOnboarding",components:{AIAvatar:$,HumanAvatar:re},inject:{t:{default:()=>M()},wmLocale:{default:()=>()=>"fr"}},props:{welcomeMessage:{type:String,default:""},subtitle:{type:String,default:""},agentName:{type:String,default:""},defaultIconUrl:{type:String,default:null},quickLinks:{type:Array,default:()=>[]},openThreads:{type:Array,default:()=>[]},busy:{type:Boolean,default:!1}},emits:["start","select","resume"],data(){return{query:""}},computed:{heroTitle(){return this.welcomeMessage?this.welcomeMessage:this.agentName?this.t("onboarding.greetingNamed",{name:this.agentName}):this.t("onboarding.greeting")},heroSub(){return this.subtitle||this.t("onboarding.heroSub")},isOddQuickLinks(){return this.quickLinks.length%2===1},quickLinksLayout(){return this.isOddQuickLinks?"wm-onb__qlist":"wm-onb__grid"},filteredThreads(){const t=this.query.trim().toLowerCase();return t?this.openThreads.filter(n=>(n.title||"").toLowerCase().includes(t)||(n.preview||"").toLowerCase().includes(t)):this.openThreads},unreadThreads(){return this.openThreads.filter(t=>t.unread)}},methods:{iconPath(t){return he[t]||he.link},isExternalLink(t){const n=t==null?void 0:t.url;return!!n&&!n.startsWith("#")},renderPreview(t){return Ne(t)},avatarComponent(t){var n;return((n=t==null?void 0:t.author)==null?void 0:n.type)==="agent_human"?"HumanAvatar":"AIAvatar"},avatarProps(t){const n=t==null?void 0:t.author;return(n==null?void 0:n.type)==="agent_human"?{size:40,name:n.name||"",avatarUrl:n.avatar_url||null}:{size:40,name:(n==null?void 0:n.name)||"",imageUrl:(n==null?void 0:n.avatar_url)||null}},isDefaultAvatar(t){const n=t==null?void 0:t.author;return!(n!=null&&n.avatar_url||n!=null&&n.name)},avatarWrapperClass(t){return this.isDefaultAvatar(t)&&!(t!=null&&t.unread)?"wm-onb__avatar--muted":null},formatTs(t){if(!t)return"";const n=new Date(t);if(Number.isNaN(n.getTime()))return"";const r=P(this.wmLocale()),s=new Date;if(n.toDateString()===s.toDateString())return n.toLocaleTimeString(r,{hour:"2-digit",minute:"2-digit"});if(s.getTime()-n.getTime()<7*864e5){const i=n.toLocaleDateString(r,{weekday:"short"});return i.charAt(0).toUpperCase()+i.slice(1)}return n.toLocaleDateString(r,{day:"2-digit",month:"2-digit"})}}},cn={class:"wm-onb"},dn={class:"wm-onb__hero"},un={class:"wm-onb__hero-text"},mn={class:"wm-onb__title"},hn={class:"wm-onb__sub"},fn={class:"wm-onb__cta"},pn=["disabled"],gn={class:"wm-onb__startLabel"},_n=["onClick"],vn={class:"wm-onb__card-icon"},yn=["aria-label"],kn={key:1,width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.9","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},wn=["d"],bn={class:"wm-onb__card-body"},En={class:"wm-onb__card-title"},Cn={key:0,class:"wm-onb__card-sub"},Bn={key:0,class:"wm-onb__card-ext",width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},Nn={key:1,class:"wm-onb__section wm-onb__section--card"},Sn={class:"wm-onb__section-title"},An={class:"wm-onb__alertList"},Vn=["onClick"],Mn={key:0,class:"wm-onb__defaultAvatar"},Tn=["aria-label"],xn={class:"wm-onb__alert-body"},Ln={class:"wm-onb__alert-title"},On=["innerHTML"],Dn={class:"wm-onb__alert-meta"},In={key:0,class:"wm-onb__alert-time"},Rn={class:"wm-onb__alert-resume"},Fn={key:2,class:"wm-onb__section wm-onb__section--card"},Pn={class:"wm-onb__section-title"},Un={class:"wm-onb__search"},zn=["placeholder","aria-label"],jn={class:"wm-onb__list"},Hn=["onClick"],qn={key:0,class:"wm-onb__defaultAvatar"},Kn=["aria-label"],$n={class:"wm-onb__thread-body"},Wn={class:"wm-onb__thread-title"},Gn=["innerHTML"],Yn={class:"wm-onb__thread-meta"},Jn={key:0,class:"wm-onb__thread-time"},Qn={key:0,class:"wm-onb__empty"};function Xn(t,n,r,s,a,o){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",cn,[e.createElementVNode("div",dn,[n[2]||(n[2]=e.createElementVNode("svg",{class:"wm-onb__hero-deco",width:"180",height:"180",viewBox:"0 0 180 180",fill:"none","aria-hidden":"true"},[e.createElementVNode("circle",{cx:"170",cy:"10",r:"105",stroke:"#5B5FEF","stroke-width":"1","stroke-dasharray":"1 5",opacity:"0.35"}),e.createElementVNode("circle",{cx:"170",cy:"10",r:"72",stroke:"#5B5FEF","stroke-width":"1","stroke-dasharray":"1 5",opacity:"0.5"}),e.createElementVNode("circle",{cx:"152",cy:"34",r:"2.5",fill:"#5B5FEF",opacity:"0.65"})],-1)),e.createVNode(i,{size:52,"image-url":r.defaultIconUrl},null,8,["image-url"]),e.createElementVNode("div",un,[e.createElementVNode("div",mn,e.toDisplayString(o.heroTitle),1),e.createElementVNode("div",hn,e.toDisplayString(o.heroSub),1)])]),e.createElementVNode("div",fn,[e.createElementVNode("button",{type:"button",class:"wm-onb__startBtn",disabled:r.busy,onClick:n[0]||(n[0]=l=>t.$emit("start"))},[n[3]||(n[3]=e.createElementVNode("span",{class:"wm-onb__startIcon"},[e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.4","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M12 5v14M5 12h14"})])],-1)),e.createElementVNode("span",gn,e.toDisplayString(r.busy?"…":o.t("onboarding.start")),1),n[4]||(n[4]=e.createElementVNode("svg",{class:"wm-onb__startArrow",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M5 12h14M13 5l7 7-7 7"})],-1))],8,pn)]),r.quickLinks.length?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(o.quickLinksLayout)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.quickLinks,(l,p)=>(e.openBlock(),e.createElementBlock("button",{key:p,type:"button",class:e.normalizeClass(["wm-onb__card",{"wm-onb__card--row":o.isOddQuickLinks}]),style:e.normalizeStyle(l.color?{"--card-color":l.color}:null),onClick:v=>t.$emit("select",l)},[e.createElementVNode("span",vn,[l.icon_url?(e.openBlock(),e.createElementBlock("span",{key:0,class:"wm-onb__card-iconImg",style:e.normalizeStyle({"--icon-url":`url('${l.icon_url}')`}),role:"img","aria-label":l.label||""},null,12,yn)):(e.openBlock(),e.createElementBlock("svg",kn,[e.createElementVNode("path",{d:o.iconPath(l.icon)},null,8,wn)]))]),e.createElementVNode("span",bn,[e.createElementVNode("span",En,e.toDisplayString(l.label),1),l.subtitle?(e.openBlock(),e.createElementBlock("span",Cn,e.toDisplayString(l.subtitle),1)):e.createCommentVNode("",!0)]),o.isExternalLink(l)?(e.openBlock(),e.createElementBlock("svg",Bn,[...n[5]||(n[5]=[e.createElementVNode("path",{d:"M7 17L17 7M9 7h8v8"},null,-1)])])):e.createCommentVNode("",!0)],14,_n))),128))],2)):e.createCommentVNode("",!0),o.unreadThreads.length?(e.openBlock(),e.createElementBlock("div",Nn,[e.createElementVNode("div",Sn,e.toDisplayString(o.t("onboarding.unreadConversations")),1),e.createElementVNode("div",An,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.unreadThreads,l=>(e.openBlock(),e.createElementBlock("button",{key:l.id,type:"button",class:"wm-onb__alert",onClick:p=>t.$emit("resume",l)},[e.createElementVNode("span",{class:e.normalizeClass(["wm-onb__alert-avatar",o.avatarWrapperClass(l)])},[o.isDefaultAvatar(l)?(e.openBlock(),e.createElementBlock("span",Mn,[...n[6]||(n[6]=[e.createElementVNode("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.7","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})],-1)])])):(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.avatarComponent(l)),e.mergeProps({key:1,ref_for:!0},o.avatarProps(l)),null,16)),e.createElementVNode("span",{class:"wm-onb__alert-dot","aria-label":o.t("onboarding.unread")},null,8,Tn)],2),e.createElementVNode("span",xn,[e.createElementVNode("span",Ln,e.toDisplayString(l.title),1),e.createElementVNode("span",{class:"wm-onb__alert-preview",innerHTML:o.renderPreview(l.preview)},null,8,On)]),e.createElementVNode("span",Dn,[o.formatTs(l._ts)?(e.openBlock(),e.createElementBlock("span",In,e.toDisplayString(o.formatTs(l._ts)),1)):e.createCommentVNode("",!0),e.createElementVNode("span",Rn,e.toDisplayString(o.t("onboarding.resume")),1)])],8,Vn))),128))])])):e.createCommentVNode("",!0),r.openThreads.length?(e.openBlock(),e.createElementBlock("div",Fn,[e.createElementVNode("div",Pn,e.toDisplayString(o.t("onboarding.recentConversations")),1),e.createElementVNode("div",Un,[n[7]||(n[7]=e.createElementVNode("span",{class:"wm-onb__searchIcon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 21l-4.35-4.35M11 17a6 6 0 100-12 6 6 0 000 12z"})])],-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":n[1]||(n[1]=l=>a.query=l),type:"text",placeholder:o.t("onboarding.search"),"aria-label":o.t("onboarding.search")},null,8,zn),[[e.vModelText,a.query]])]),e.createElementVNode("div",jn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.filteredThreads,l=>(e.openBlock(),e.createElementBlock("button",{key:l.id,type:"button",class:e.normalizeClass(["wm-onb__thread",{"wm-onb__thread--unread":l.unread}]),onClick:p=>t.$emit("resume",l)},[e.createElementVNode("span",{class:e.normalizeClass(["wm-onb__thread-avatar",o.avatarWrapperClass(l)])},[o.isDefaultAvatar(l)?(e.openBlock(),e.createElementBlock("span",qn,[...n[8]||(n[8]=[e.createElementVNode("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.7","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})],-1)])])):(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.avatarComponent(l)),e.mergeProps({key:1,ref_for:!0},o.avatarProps(l)),null,16)),l.unread?(e.openBlock(),e.createElementBlock("span",{key:2,class:"wm-onb__thread-dot","aria-label":o.t("onboarding.unread")},null,8,Kn)):e.createCommentVNode("",!0)],2),e.createElementVNode("span",$n,[e.createElementVNode("span",Wn,e.toDisplayString(l.title),1),e.createElementVNode("span",{class:"wm-onb__thread-preview",innerHTML:o.renderPreview(l.preview)},null,8,Gn)]),e.createElementVNode("span",Yn,[o.formatTs(l._ts)?(e.openBlock(),e.createElementBlock("span",Jn,e.toDisplayString(o.formatTs(l._ts)),1)):e.createCommentVNode("",!0),n[9]||(n[9]=e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round",class:"wm-onb__thread-chev","aria-hidden":"true"},[e.createElementVNode("path",{d:"M5 12h14M13 5l7 7-7 7"})],-1))])],10,Hn))),128)),o.filteredThreads.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Qn,e.toDisplayString(o.t("onboarding.noResults",{query:a.query})),1))])])):e.createCommentVNode("",!0)])}const Ae=A(ln,[["render",Xn],["__scopeId","data-v-37fd5506"]]);function Zn(t){return typeof t!="string"?"":t.replace(/`([^`]+)`/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(new RegExp("(?<!\\*)\\*([^*]+)\\*(?!\\*)","g"),"$1").replace(/__([^_]+)__/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\s+/g," ").trim()}const er={name:"WmActionResult",props:{state:{type:String,default:"success"},label:{type:String,required:!0},detail:{type:String,default:""}},computed:{detailText(){return Zn(this.detail)}}},tr={class:"wm-result__icon","aria-hidden":"true"},nr={key:0,width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.8","stroke-linecap":"round","stroke-linejoin":"round"},rr={key:1,width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.6","stroke-linecap":"round","stroke-linejoin":"round"},or={key:2,width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.4","stroke-linecap":"round","stroke-linejoin":"round"},ar={key:3,width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.2","stroke-linecap":"round","stroke-linejoin":"round"},sr={class:"wm-result__body"},ir={class:"wm-result__label"},lr={class:"wm-result__detail"};function cr(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-result",`wm-result--${r.state}`])},[e.createElementVNode("span",tr,[r.state==="success"?(e.openBlock(),e.createElementBlock("svg",nr,[...n[0]||(n[0]=[e.createElementVNode("path",{d:"M20 6L9 17l-5-5"},null,-1)])])):r.state==="rejected"?(e.openBlock(),e.createElementBlock("svg",rr,[...n[1]||(n[1]=[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"},null,-1)])])):r.state==="awaiting"?(e.openBlock(),e.createElementBlock("svg",or,[...n[2]||(n[2]=[e.createElementVNode("circle",{cx:"12",cy:"12",r:"10"},null,-1),e.createElementVNode("polyline",{points:"12 7 12 12 15 14"},null,-1)])])):(e.openBlock(),e.createElementBlock("svg",ar,[...n[3]||(n[3]=[e.createElementVNode("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"},null,-1),e.createElementVNode("line",{x1:"12",y1:"9",x2:"12",y2:"13"},null,-1),e.createElementVNode("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"},null,-1)])]))]),e.createElementVNode("span",sr,[e.createElementVNode("span",ir,e.toDisplayString(r.label),1),o.detailText?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[n[4]||(n[4]=e.createElementVNode("span",{class:"wm-result__sep","aria-hidden":"true"}," · ",-1)),e.createElementVNode("span",lr,e.toDisplayString(o.detailText),1)],64)):e.createCommentVNode("",!0)])],2)}const Ve=A(er,[["render",cr],["__scopeId","data-v-7284acd0"]]),dr={name:"WmArtifactFormResponse",inject:{t:{default:()=>M()}},props:{data:{type:Object,required:!0}},computed:{fields(){var t;return Array.isArray((t=this.data)==null?void 0:t.fields)?this.data.fields:[]}}},ur={class:"wm-art wm-art--formResponse"},mr={class:"wm-art__head"},hr={class:"wm-art__title"},fr={class:"wm-art__badge wm-art__badge--success"},pr={class:"wm-art__body"},gr={class:"wm-art__fieldLabel"};function _r(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",ur,[e.createElementVNode("div",mr,[e.createElementVNode("div",hr,e.toDisplayString(r.data.title||o.t("form.title")),1),e.createElementVNode("span",fr,[n[0]||(n[0]=e.createElementVNode("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("polyline",{points:"20 6 9 17 4 12"})],-1)),e.createTextVNode(" "+e.toDisplayString(o.t("form.sent")),1)])]),e.createElementVNode("div",pr,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.fields,(i,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-art__field"},[e.createElementVNode("div",gr,e.toDisplayString(i.label),1),e.createElementVNode("div",{class:e.normalizeClass(["wm-art__fieldValue",{"wm-art__fieldValue--multi":i.multiline}])},e.toDisplayString(i.value),3)]))),128))])])}const Me=A(dr,[["render",_r],["__scopeId","data-v-713aecf1"]]),vr={name:"WmArtifactInfoCard",props:{data:{type:Object,required:!0}},computed:{fields(){var t;return Array.isArray((t=this.data)==null?void 0:t.fields)?this.data.fields:[]},hasBody(){var t;return!!((t=this.data)!=null&&t.body)||this.fields.length>0}}},yr={class:"wm-art wm-art--infoCard"},kr={key:0,class:"wm-art__image"},wr=["src","alt"],br={class:"wm-art__head"},Er={class:"wm-art__headMain"},Cr={class:"wm-art__title"},Br={key:0,class:"wm-art__subtitle"},Nr={key:1,class:"wm-art__body"},Sr={key:0,class:"wm-art__text"},Ar={class:"wm-art__fieldLabel"};function Vr(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",yr,[r.data.image_url?(e.openBlock(),e.createElementBlock("figure",kr,[e.createElementVNode("img",{src:r.data.image_url,alt:r.data.title||"",loading:"lazy"},null,8,wr)])):e.createCommentVNode("",!0),e.createElementVNode("div",br,[e.createElementVNode("div",Er,[e.createElementVNode("div",Cr,e.toDisplayString(r.data.title),1),r.data.subtitle?(e.openBlock(),e.createElementBlock("div",Br,e.toDisplayString(r.data.subtitle),1)):e.createCommentVNode("",!0)]),r.data.badge&&r.data.badge.label?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(["wm-art__badge",`wm-art__badge--${r.data.badge.tone||"neutral"}`])},e.toDisplayString(r.data.badge.label),3)):e.createCommentVNode("",!0)]),o.hasBody?(e.openBlock(),e.createElementBlock("div",Nr,[r.data.body?(e.openBlock(),e.createElementBlock("div",Sr,e.toDisplayString(r.data.body),1)):e.createCommentVNode("",!0),o.fields.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(o.fields,(i,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-art__field"},[e.createElementVNode("div",Ar,e.toDisplayString(i.label),1),e.createElementVNode("div",{class:e.normalizeClass(["wm-art__fieldValue",{"wm-art__fieldValue--multi":i.multiline}])},e.toDisplayString(i.value),3)]))),128)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])}const Te=A(vr,[["render",Vr],["__scopeId","data-v-7eae0e4a"]]);function Mr(t,n,r){if(!t)return"";const s=new Date(t);if(Number.isNaN(s.getTime()))return t;const a=s.toLocaleDateString(n,{day:"numeric",month:"long",year:"numeric"}),o=s.toLocaleTimeString(n,{hour:"2-digit",minute:"2-digit"});return`${a}${r}${o}`}const Tr={name:"WmArtifactTicket",inject:{t:{default:()=>M()},wmLocale:{default:()=>()=>"fr"}},props:{data:{type:Object,required:!0}},computed:{fields(){var t;return Array.isArray((t=this.data)==null?void 0:t.fields)?this.data.fields:[]},formattedDate(){var t;return Mr((t=this.data)==null?void 0:t.created_at,P(this.wmLocale()),this.t("ticket.dateAt"))}},methods:{isPriority(t){return/priorit|^prio$/i.test(String(t||"").trim())},isDate(t){return/date|échéanc|echeanc|deadline|due|créé|cree/i.test(String(t||"").trim())},priorityLevel(t){const n=String(t||"").toLowerCase();return/high|haute|élev|elev|critic|critiq|urgent/.test(n)?3:/low|basse|faible|minor/.test(n)?1:2}}},xr={class:"wm-art wm-art--ticket"},Lr={class:"wm-art__head wm-tk__head"},Or={class:"wm-art__title wm-tk__title"},Dr={class:"wm-tk__sub"},Ir={class:"wm-tk__ref"},Rr={key:0,class:"wm-tk__text"},Fr={key:0,class:"wm-art__body"},Pr={class:"wm-art__fieldLabel"},Ur=["data-level"],zr={key:1,class:"wm-tk__date",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},jr={key:1,class:"wm-art__footer wm-tk__footer"};function Hr(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",xr,[e.createElementVNode("div",Lr,[e.createElementVNode("div",Or,e.toDisplayString(r.data.title),1),e.createElementVNode("div",Dr,[e.createElementVNode("div",Ir,[n[0]||(n[0]=e.createElementVNode("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M20 12a2 2 0 0 1 2-2V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v4a2 2 0 0 1 0 4v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 1-2-2z"}),e.createElementVNode("path",{d:"M13 5v2M13 17v2M13 11v2"})],-1)),e.createElementVNode("span",null,e.toDisplayString(r.data.reference),1)]),e.createElementVNode("span",{class:e.normalizeClass(["wm-art__badge","wm-tk__badge",`wm-art__badge--${r.data.status.tone||"neutral"}`])},[n[1]||(n[1]=e.createElementVNode("span",{class:"wm-tk__dot","aria-hidden":"true"},null,-1)),e.createTextVNode(" "+e.toDisplayString(r.data.status.label),1)],2)]),r.data.body?(e.openBlock(),e.createElementBlock("div",Rr,e.toDisplayString(r.data.body),1)):e.createCommentVNode("",!0)]),o.fields.length?(e.openBlock(),e.createElementBlock("div",Fr,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.fields,(i,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-art__field"},[e.createElementVNode("div",Pr,e.toDisplayString(i.label),1),e.createElementVNode("div",{class:e.normalizeClass(["wm-art__fieldValue",{"wm-art__fieldValue--multi":i.multiline}])},[o.isPriority(i.label)?(e.openBlock(),e.createElementBlock("svg",{key:0,class:"wm-tk__prio","data-level":o.priorityLevel(i.value),width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true"},[...n[2]||(n[2]=[e.createElementVNode("rect",{x:"1",y:"8",width:"2",height:"3",rx:"0.5"},null,-1),e.createElementVNode("rect",{x:"5",y:"5",width:"2",height:"6",rx:"0.5"},null,-1),e.createElementVNode("rect",{x:"9",y:"2",width:"2",height:"9",rx:"0.5"},null,-1)])],8,Ur)):o.isDate(i.label)?(e.openBlock(),e.createElementBlock("svg",zr,[...n[3]||(n[3]=[e.createElementVNode("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"},null,-1),e.createElementVNode("path",{d:"M16 2v4M8 2v4M3 10h18"},null,-1)])])):e.createCommentVNode("",!0),e.createElementVNode("span",null,e.toDisplayString(i.value),1)],2)]))),128))])):e.createCommentVNode("",!0),r.data.created_at?(e.openBlock(),e.createElementBlock("div",jr,[n[4]||(n[4]=e.createElementVNode("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),e.createElementVNode("path",{d:"M16 2v4M8 2v4M3 10h18"})],-1)),e.createElementVNode("span",null,e.toDisplayString(o.formattedDate),1)])):e.createCommentVNode("",!0)])}const xe=A(Tr,[["render",Hr],["__scopeId","data-v-5f30c914"]]),qr={form_response:Me,info_card:Te,ticket:xe},Kr={name:"WmArtifactRenderer",props:{artifact:{type:Object,required:!0}},computed:{component(){var n;const t=(n=this.artifact)==null?void 0:n.kind;return t&&qr[t]||null}}};function $r(t,n,r,s,a,o){return o.component?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.component),{key:0,data:r.artifact.data},null,8,["data"])):e.createCommentVNode("",!0)}const Le=A(Kr,[["render",$r]]),Wr={name:"WmAttachmentPreview",inject:{signAttachmentFn:{default:null},t:{default:()=>M()}},props:{attachment:{type:Object,required:!0}},data(){return{url:null,loading:!1}},computed:{kind(){var r,s;const t=(r=this.attachment)==null?void 0:r.type;if(t)return t;const n=(((s=this.attachment)==null?void 0:s.mime_type)||"").toLowerCase();return n.startsWith("image/")?"image":n.startsWith("audio/")?"audio":n.startsWith("video/")?"video":"file"},displayName(){var t,n,r;return((n=(t=this.attachment)==null?void 0:t.metadata)==null?void 0:n.name)||((r=this.attachment)==null?void 0:r.name)||this.guessNameFromPath()||this.t("attachment.fallbackName")},safeHref(){const t=String(this.url||"").trim();return/^(https?:\/\/|blob:|data:image\/)/i.test(t)?t:"#"},sizeLabel(){var n;const t=(n=this.attachment)==null?void 0:n.size_bytes;return t?t<1024?this.t("attachment.bytes",{size:t}):t<1024*1024?this.t("attachment.kilobytes",{size:(t/1024).toFixed(0)}):this.t("attachment.megabytes",{size:(t/(1024*1024)).toFixed(1)}):""}},watch:{"attachment.path":{handler(){this.refresh()},immediate:!0}},methods:{guessNameFromPath(){var r;return((((r=this.attachment)==null?void 0:r.path)||"").split("/").pop()||"").replace(/^[0-9a-f-]{8,}-/,"")},async refresh(){var t;if(!(!((t=this.attachment)!=null&&t.path)||!this.signAttachmentFn)){this.loading=!0;try{this.url=await this.signAttachmentFn(this.attachment.path)}finally{this.loading=!1}}},onFileClick(t){this.safeHref==="#"&&t.preventDefault()}}},Gr=["href"],Yr=["src","alt"],Jr=["src"],Qr=["src"],Xr=["href","download"],Zr={class:"wm-att__main"},eo={class:"wm-att__name"},to={key:0,class:"wm-att__meta"},no={key:0,class:"wm-att__spin","aria-hidden":"true"};function ro(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-att",["wm-att--"+(o.kind||"file")]])},[o.kind==="image"&&a.url?(e.openBlock(),e.createElementBlock("a",{key:0,href:o.safeHref,target:"_blank",rel:"noopener",class:"wm-att__imgWrap"},[e.createElementVNode("img",{src:a.url,alt:o.displayName,loading:"lazy"},null,8,Yr)],8,Gr)):o.kind==="audio"&&a.url?(e.openBlock(),e.createElementBlock("audio",{key:1,src:a.url,controls:"",preload:"metadata"},null,8,Jr)):o.kind==="video"&&a.url?(e.openBlock(),e.createElementBlock("video",{key:2,src:a.url,controls:"",preload:"metadata"},null,8,Qr)):(e.openBlock(),e.createElementBlock("a",{key:3,class:"wm-att__file",href:o.safeHref,download:o.displayName,target:"_blank",rel:"noopener",onClick:n[0]||(n[0]=(...i)=>o.onFileClick&&o.onFileClick(...i))},[n[1]||(n[1]=e.createElementVNode("span",{class:"wm-att__icon"},[e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.7","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"}),e.createElementVNode("path",{d:"M14 2v6h6"})])],-1)),e.createElementVNode("span",Zr,[e.createElementVNode("span",eo,e.toDisplayString(o.displayName),1),o.sizeLabel?(e.openBlock(),e.createElementBlock("span",to,e.toDisplayString(o.sizeLabel),1)):e.createCommentVNode("",!0)]),a.loading?(e.openBlock(),e.createElementBlock("span",no)):e.createCommentVNode("",!0)],8,Xr))],2)}const Oe=A(Wr,[["render",ro],["__scopeId","data-v-0c877a62"]]),oo={name:"WmBubble",props:{role:{type:String,default:"ai"},text:{type:String,default:""}},computed:{rendered(){return Se(this.text)}}},ao=["innerHTML"];function so(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-bubble","wm-bubble--"+r.role])},[e.renderSlot(t.$slots,"default",{},()=>[e.createElementVNode("span",{innerHTML:o.rendered},null,8,ao)],!0)],2)}const De=A(oo,[["render",so],["__scopeId","data-v-7ab13147"]]),io={name:"WmTyping"},lo={class:"wm-typing"};function co(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",lo,[...n[0]||(n[0]=[e.createElementVNode("span",{style:{"animation-delay":"0s"}},null,-1),e.createElementVNode("span",{style:{"animation-delay":"0.2s"}},null,-1),e.createElementVNode("span",{style:{"animation-delay":"0.4s"}},null,-1)])])}const Ie=A(io,[["render",co],["__scopeId","data-v-df2447fd"]]);function F(t){return t?t.client_msg_id||t.id:""}const uo={transferred_to_human:"system.transferredToHuman",assigned:"system.assigned",unassigned:"system.unassigned",resolved:"system.resolved",reopened:"system.reopened",idle:"system.idle"},mo=80,ho=200,fo={name:"WmMessageList",components:{AIAvatar:$,HumanAvatar:re,Bubble:De,Typing:Ie,ActionResult:Ve,AttachmentPreview:Oe,ArtifactRenderer:Le},inject:{t:{default:()=>M()},wmLocale:{default:()=>()=>"fr"}},props:{messages:{type:Array,default:()=>[]},streamingActive:{type:Boolean,default:!1},dateLabel:{type:String,default:""},conversationId:{type:[String,Number],default:null},loadingMore:{type:Boolean,default:!1},hasMore:{type:Boolean,default:!1},unreadAnchorId:{type:Number,default:null},unreadBoundaryTs:{type:String,default:""},aiAgentName:{type:String,default:""},aiAgentAvatarUrl:{type:String,default:null}},emits:["load-more"],data(){return{silentFades:!1,widthByKey:Object.freeze({}),showScrollDown:!1,pressedItemKey:null}},computed:{historyExhausted(){return!this.hasMore&&!this.loadingMore&&this.messages.length>=20},groups(){var r,s,a,o;const t=[];for(const i of this.messages){const l=this.roleOf(i);if(l==="system"){if(((r=i==null?void 0:i.payload)==null?void 0:r.event)==="action_admin_pending"){const g=t[t.length-1];g&&g.role==="ai"?g.messages.push(i):t.push({key:`g-${F(i)}`,role:"ai",agentName:"",agentAvatarUrl:null,messages:[i],items:[]});continue}t.push({key:`sys-${F(i)}`,role:l,messages:[i],items:[],systemLabel:this.systemLabel(i)});continue}const p=t[t.length-1];p&&p.role===l&&(l==="ai"||p.agentName===(((s=i==null?void 0:i.author)==null?void 0:s.name)||""))?p.messages.push(i):t.push({key:`g-${F(i)}`,role:l,agentName:((a=i==null?void 0:i.author)==null?void 0:a.name)||"",agentAvatarUrl:((o=i==null?void 0:i.author)==null?void 0:o.avatar_url)||null,messages:[i],items:[]})}for(const i of t){if(i.role==="system")continue;const l=[];for(const p of i.messages)for(const v of this.itemsOf(p))l.push(v);i.items=l}const n=[];for(const i of t){if(i.role!=="system"&&!i.items.length)continue;const l=n[n.length-1];if(l&&l.role!=="system"&&l.role===i.role&&(i.role==="ai"||l.agentName===i.agentName)){l.messages.push(...i.messages),l.items.push(...i.items);continue}n.push(i)}for(const i of n)i.role!=="system"&&(i.key=this.stableGroupKey(i.messages));return n},unreadGroupKey(){if(this.unreadAnchorId==null)return null;const t=this.unreadAnchorId,n=this.unreadBoundaryTs;for(const r of this.groups){if(r.role==="user"||r.role==="system"||!r.items.length)continue;const s=r.messages[0];if(!s)continue;const a=D(s.id);if(a!=null&&!(a<=t)&&!(n&&s.created_at&&s.created_at>n))return r.key}return null}},watch:{messages:{handler:"snapshotAndRestore",deep:!0},conversationId(t,n){t!==n&&(this._groupIdByMsgKey=null,this.silentFades=!1)},loadingMore(t){t||(this._pendingLoadMore=!1),t&&(this.silentFades=!0),this.snapshotAndRestore()},streamingActive:"snapshotAndRestore"},mounted(){this._lastSeenConvId=this.conversationId,this.scrollToBottom(),this._measureFrame=null,this._ro=new ResizeObserver(()=>this.scheduleMeasure()),this.$refs.scrollEl&&this._ro.observe(this.$refs.scrollEl),this.$nextTick(()=>this.measureRows())},beforeUnmount(){var t;(t=this._ro)==null||t.disconnect(),this._measureFrame&&cancelAnimationFrame(this._measureFrame),this._pressTimer&&clearTimeout(this._pressTimer)},updated(){this.scheduleMeasure()},methods:{messageKey:F,stableGroupKey(t){this._groupIdByMsgKey||(this._groupIdByMsgKey=new Map,this._groupIdCounter=0);const n=this._groupIdByMsgKey;let r=null;for(const s of t){const a=F(s);if(a&&n.has(a)){r=n.get(a);break}}r==null&&(r=++this._groupIdCounter);for(const s of t){const a=F(s);a&&n.set(a,r)}return`g-${r}`},isAtBottom(t){return t.scrollHeight-t.scrollTop-t.clientHeight<=mo},onScroll(){const t=this.$refs.scrollEl;t&&(this.showScrollDown=!this.isAtBottom(t),!(this.loadingMore||!this.hasMore)&&(this._pendingLoadMore||t.scrollTop<=ho&&(this._pendingLoadMore=!0,this.$emit("load-more"))))},snapshotAndRestore(){const t=this.$refs.scrollEl;if(!t||this._scrollSnap)return;const n=this._lastSeenConvId!==this.conversationId;this._lastSeenConvId=this.conversationId;const r=this.isAtBottom(t);let s=null;if(!n&&!r){const o=this.pickAnchor(t);if(o!=null&&o.rowKey){const i=this.findRowByKey(t,o.rowKey);if(i){const l=t.getBoundingClientRect().top;s={rowKey:o.rowKey,relY:i.getBoundingClientRect().top-l}}}}const a={forceBottom:n,wasPinned:r,anchor:s};this._scrollSnap=a,this.$nextTick(()=>{if(this._scrollSnap=null,a.forceBottom||a.wasPinned){t.scrollTop=t.scrollHeight;return}if(!a.anchor)return;const o=()=>{const i=a.anchor,l=this.findRowByKey(t,i.rowKey);if(!l)return;const v=l.getBoundingClientRect().top-t.getBoundingClientRect().top-i.relY;Math.abs(v)>.5&&(t.scrollTop+=v)};o(),requestAnimationFrame(()=>{o(),requestAnimationFrame(o)})})},pickAnchor(t){const n=t.getBoundingClientRect().top,r=t.querySelectorAll(".wm-list__row[data-row-key]");let s=null;for(const a of r)if(s||(s=a),a.getBoundingClientRect().bottom>=n)return{rowKey:a.dataset.rowKey};return s?{rowKey:s.dataset.rowKey}:null},findRowByKey(t,n){if(!n)return null;const r=typeof CSS<"u"&&CSS.escape?CSS.escape(n):n.replace(/["\\]/g,"\\$&");return t.querySelector(`.wm-list__row[data-row-key="${r}"]`)},roleOf(t){var r,s;if((t==null?void 0:t.type)==="system"||((r=t==null?void 0:t.payload)==null?void 0:r.type)==="system")return"system";const n=(s=t==null?void 0:t.author)==null?void 0:s.type;return n==="user"?"user":n==="agent_human"?"human":"ai"},roleLabel(t){if(t.role==="human")return t.agentName||this.t("common.agent");const n=this.t("common.aiAssistant");return this.aiAgentName?`${this.aiAgentName} • ${n}`:n},itemsOf(t){var n;if(!t)return[];if(t.type==="system"&&((n=t==null?void 0:t.payload)==null?void 0:n.event)==="action_admin_pending")return[{message:t,partKey:"main",renderAs:"admin-pending",kind:{top:"bubble",bottom:"bubble"}}];if(t.type==="action"&&t.payload&&t.payload.state!=="pending"){const r=[{message:t,partKey:"main",renderAs:"action",kind:{top:"bubble",bottom:"bubble"}}];return this.actionArtifact(t)&&r.push({message:t,partKey:"artifact",renderAs:"artifact-of-action",kind:{top:"card",bottom:"card"}}),r}return this.artifactOf(t)?[{message:t,partKey:"main",renderAs:"artifact",kind:{top:"card",bottom:"card"}}]:t.text_md||this.attachmentsOf(t).length?[{message:t,partKey:"main",renderAs:"bubble",kind:{top:"bubble",bottom:"bubble"}}]:[]},cornersFor(t,n){var U,z,j;const r=t.items,s=(U=r[n])==null?void 0:U.kind,a=(z=r[n-1])==null?void 0:z.kind,o=(j=r[n+1])==null?void 0:j.kind,i=t.role==="user",l=14,p=4,v=a==null?void 0:a.bottom,g=o==null?void 0:o.top,E=this.widthByKey[this.rowKeyOf(t,n)],S=this.widthByKey[this.rowKeyOf(t,n-1)],k=this.widthByKey[this.rowKeyOf(t,n+1)],x=.5,w=(O,H,R)=>O!=null&&E!=null?O+x>=E:H===R||H==="card"&&R==="bubble";let V=l,B=l,L=l,I=l;return i?(v&&(B=p),(g||!o)&&(L=p),v&&w(S,v,s==null?void 0:s.top)&&(V=p),g&&w(k,g,s==null?void 0:s.bottom)&&(I=p)):(v&&(V=p),(g||!o)&&(I=p),v&&w(S,v,s==null?void 0:s.top)&&(B=p),g&&w(k,g,s==null?void 0:s.bottom)&&(L=p)),{tl:V,tr:B,br:L,bl:I}},cornersStyle(t,n){if(t.items.length<2)return null;const r=this.cornersFor(t,n);return{"--wm-r-tl":`${r.tl}px`,"--wm-r-tr":`${r.tr}px`,"--wm-r-br":`${r.br}px`,"--wm-r-bl":`${r.bl}px`}},rowKeyOf(t,n){var s;const r=(s=t==null?void 0:t.items)==null?void 0:s[n];return r?`${F(r.message)}-${r.partKey}`:""},scheduleMeasure(){this._measureFrame||(this._measureFrame=requestAnimationFrame(()=>{this._measureFrame=null,this.measureRows()}))},measureRows(){const t=this.$refs.scrollEl;if(!t)return;const n={};for(const o of t.querySelectorAll(".wm-list__row[data-row-key]")){const i=o.dataset.rowKey;if(!i)continue;const l=o.querySelector(".wm-bubble, .wm-result, .wm-art, .wm-list__body");if(!l)continue;const p=l.getBoundingClientRect().width;p>0&&(n[i]=p)}const r=this.widthByKey,s=Object.keys(r),a=Object.keys(n);if(s.length===a.length){let o=!0;for(const i of a)if(Math.abs((r[i]??0)-n[i])>.5){o=!1;break}if(o)return}this.widthByKey=Object.freeze(n)},onPressStart(t){this.onPressEnd(),this._pressTimer=setTimeout(()=>{this._pressTimer=null,this.pressedItemKey=t},400)},onPressEnd(){this._pressTimer&&(clearTimeout(this._pressTimer),this._pressTimer=null),this.pressedItemKey!==null&&(this.pressedItemKey=null)},timeOf(t){if(!(t!=null&&t.created_at))return"";try{return Z(new Date(t.created_at),P(this.wmLocale()))}catch{return""}},lastTimeOf(t){const n=t.items[t.items.length-1],r=(n==null?void 0:n.message)||t.messages[t.messages.length-1];if(!(r!=null&&r.created_at))return"";try{return Z(new Date(r.created_at),P(this.wmLocale()))}catch{return""}},hasTrailingOverlay(t){if(!t.messages.length)return!1;const n=t.messages[t.messages.length-1],r=t.items[t.items.length-1];return!!n&&(r==null?void 0:r.message)!==n},attachmentsOf(t){var r;const n=(r=t==null?void 0:t.payload)==null?void 0:r.attachments;return Array.isArray(n)?n:[]},artifactOf(t){var r;const n=(r=t==null?void 0:t.metadata)==null?void 0:r.artifact;return!n||typeof n!="object"||typeof n.kind!="string"?null:n},actionLabel(t){var n;return((n=t==null?void 0:t.payload)==null?void 0:n.name)||(t==null?void 0:t.text_md)||this.t("common.action")},actionDetail(t){var r,s,a,o,i,l;const n=t==null?void 0:t.payload;return n?n.state==="success"?((r=n.success)==null?void 0:r.summary)||((a=(s=n.success)==null?void 0:s.metadata)==null?void 0:a.description)||"":n.state==="rejected"?((o=n.rejected)==null?void 0:o.reason)||this.t("action.rejectedByUser"):n.state==="failure"&&(((i=n.failure)==null?void 0:i.summary)||((l=n.failure)==null?void 0:l.error))||"":""},actionArtifact(t){var r,s;const n=(s=(r=t==null?void 0:t.payload)==null?void 0:r.success)==null?void 0:s.artifact;return!n||typeof n!="object"||typeof n.kind!="string"?null:n},systemLabel(t){var a,o,i;const n=(a=t==null?void 0:t.payload)==null?void 0:a.event,r=uo[n],s=((o=t==null?void 0:t.metadata)==null?void 0:o.agent_name)||((i=t==null?void 0:t.author)==null?void 0:i.name)||this.t("messageList.anAgent");return r?this.t(r,{name:s}):(t==null?void 0:t.text_md)||this.t("messageList.conversationUpdate")},scrollToBottom(){const t=this.$refs.scrollEl;t&&(t.scrollTop=t.scrollHeight),this.showScrollDown=!1},scrollToBottomSmooth(){const t=this.$refs.scrollEl;t&&(typeof t.scrollTo=="function"?t.scrollTo({top:t.scrollHeight,behavior:"smooth"}):t.scrollTop=t.scrollHeight,this.showScrollDown=!1)}}},po={class:"wm-list__wrap"},go={key:0,class:"wm-list__loadMore",role:"status","aria-live":"polite"},_o={class:"wm-list__loadMore-lbl"},vo={key:1,class:"wm-list__historyEnd"},yo={key:2,class:"wm-list__sep"},ko={class:"wm-list__sep-label"},wo={key:0,class:"wm-list__sep wm-list__sep--unread"},bo={class:"wm-list__sep-label wm-list__sep-label--unread"},Eo={key:0,class:"wm-list__sysep"},Co={class:"wm-list__sysep-label"},Bo=["data-row-key","onPointerdown"],No={key:0,class:"wm-list__avatarSlot"},So={key:5,class:"wm-list__body"},Ao={key:0},Vo={key:1,"aria-hidden":"true"},Mo={key:2},To={key:0},xo={key:1,"aria-hidden":"true"},Lo={key:2},Oo={key:3,class:"wm-list__row wm-list__row--ai fade-up"},Do={class:"wm-list__avatarSlot"},Io=["aria-label","title"];function Ro(t,n,r,s,a,o){const i=e.resolveComponent("AIAvatar"),l=e.resolveComponent("HumanAvatar"),p=e.resolveComponent("ActionResult"),v=e.resolveComponent("ArtifactRenderer"),g=e.resolveComponent("Bubble"),E=e.resolveComponent("AttachmentPreview"),S=e.resolveComponent("Typing");return e.openBlock(),e.createElementBlock("div",po,[e.createElementVNode("div",{ref:"scrollEl",class:e.normalizeClass(["wm-list",{"wm-list--silent":a.silentFades}]),onScrollPassive:n[4]||(n[4]=(...k)=>o.onScroll&&o.onScroll(...k))},[r.loadingMore?(e.openBlock(),e.createElementBlock("div",go,[n[6]||(n[6]=e.createElementVNode("span",{class:"wm-list__loadMore-spinner","aria-hidden":"true"},null,-1)),e.createElementVNode("span",_o,e.toDisplayString(o.t("messageList.loadingHistory")),1)])):o.historyExhausted?(e.openBlock(),e.createElementBlock("div",vo,e.toDisplayString(o.t("messageList.conversationStart")),1)):e.createCommentVNode("",!0),r.dateLabel?(e.openBlock(),e.createElementBlock("div",yo,[n[7]||(n[7]=e.createElementVNode("div",{class:"wm-list__line"},null,-1)),e.createElementVNode("span",ko,e.toDisplayString(r.dateLabel),1),n[8]||(n[8]=e.createElementVNode("div",{class:"wm-list__line"},null,-1))])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.groups,(k,x)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:k.key},[k.key===o.unreadGroupKey?(e.openBlock(),e.createElementBlock("div",wo,[n[9]||(n[9]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--unread"},null,-1)),e.createElementVNode("span",bo,e.toDisplayString(o.t("messageList.unread")),1),n[10]||(n[10]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--unread"},null,-1))])):e.createCommentVNode("",!0),k.role==="system"||k.items.length?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["wm-list__group","wm-list__group--"+k.role])},[k.role==="system"?(e.openBlock(),e.createElementBlock("div",Eo,[n[11]||(n[11]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--strong"},null,-1)),e.createElementVNode("span",Co,e.toDisplayString(k.systemLabel),1),n[12]||(n[12]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--strong"},null,-1))])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k.items,(w,V)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`${o.messageKey(w.message)}-${w.partKey}`},[e.createElementVNode("div",{"data-row-key":`${o.messageKey(w.message)}-${w.partKey}`,class:e.normalizeClass(["wm-list__row fade-up",["wm-list__row--"+k.role,{"is-pending":w.message._pending,"is-failed":w.message._failed}]]),style:e.normalizeStyle(o.cornersStyle(k,V)),onPointerdown:B=>o.onPressStart(`${o.messageKey(w.message)}-${w.partKey}`),onPointerup:n[0]||(n[0]=B=>o.onPressEnd()),onPointercancel:n[1]||(n[1]=B=>o.onPressEnd()),onPointerleave:n[2]||(n[2]=B=>o.onPressEnd()),onContextmenu:n[3]||(n[3]=e.withModifiers(()=>{},["prevent"]))},[k.role!=="user"?(e.openBlock(),e.createElementBlock("div",No,[V===k.items.length-1?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[k.role==="ai"?(e.openBlock(),e.createBlock(i,{key:0,size:26,tail:!0,name:r.aiAgentName,"image-url":r.aiAgentAvatarUrl},null,8,["name","image-url"])):(e.openBlock(),e.createBlock(l,{key:1,name:k.agentName,"avatar-url":k.agentAvatarUrl,size:26,tail:!0},null,8,["name","avatar-url"]))],64)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),w.renderAs==="action"?(e.openBlock(),e.createBlock(p,{key:1,state:w.message.payload.state,label:o.actionLabel(w.message),detail:o.actionDetail(w.message)},null,8,["state","label","detail"])):w.renderAs==="admin-pending"?(e.openBlock(),e.createBlock(p,{key:2,state:"awaiting",label:o.t("messageList.approvalRequestSent"),detail:w.message.text_md||""},null,8,["label","detail"])):w.renderAs==="artifact-of-action"?(e.openBlock(),e.createBlock(v,{key:3,artifact:o.actionArtifact(w.message)},null,8,["artifact"])):w.renderAs==="artifact"?(e.openBlock(),e.createBlock(v,{key:4,artifact:o.artifactOf(w.message)},null,8,["artifact"])):(e.openBlock(),e.createElementBlock("div",So,[w.message.text_md?(e.openBlock(),e.createBlock(g,{key:0,role:k.role,text:w.message.text_md},null,8,["role","text"])):e.createCommentVNode("",!0),o.attachmentsOf(w.message).length?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["wm-list__atts",{"wm-list__atts--align-end":k.role==="user"}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.attachmentsOf(w.message),(B,L)=>(e.openBlock(),e.createBlock(E,{key:`${o.messageKey(w.message)}-att-${L}`,attachment:B},null,8,["attachment"]))),128))],2)):e.createCommentVNode("",!0)]))],46,Bo),V<k.items.length-1&&a.pressedItemKey===`${o.messageKey(w.message)}-${w.partKey}`&&(k.role!=="user"||o.timeOf(w.message))?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["wm-list__meta wm-list__meta--press",{"wm-list__meta--right":k.role==="user"}])},[k.role!=="user"?(e.openBlock(),e.createElementBlock("span",Ao,e.toDisplayString(o.roleLabel(k)),1)):e.createCommentVNode("",!0),k.role!=="user"&&o.timeOf(w.message)?(e.openBlock(),e.createElementBlock("span",Vo,"·")):e.createCommentVNode("",!0),o.timeOf(w.message)?(e.openBlock(),e.createElementBlock("span",Mo,e.toDisplayString(o.timeOf(w.message)),1)):e.createCommentVNode("",!0)],2)):e.createCommentVNode("",!0)],64))),128)),(k.role!=="user"||o.lastTimeOf(k))&&!o.hasTrailingOverlay(k)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["wm-list__meta",{"wm-list__meta--right":k.role==="user"}])},[k.role!=="user"?(e.openBlock(),e.createElementBlock("span",To,e.toDisplayString(o.roleLabel(k)),1)):e.createCommentVNode("",!0),k.role!=="user"&&o.lastTimeOf(k)?(e.openBlock(),e.createElementBlock("span",xo,"·")):e.createCommentVNode("",!0),o.lastTimeOf(k)?(e.openBlock(),e.createElementBlock("span",Lo,e.toDisplayString(o.lastTimeOf(k)),1)):e.createCommentVNode("",!0)],2)):e.createCommentVNode("",!0)],64))],2)):e.createCommentVNode("",!0)],64))),128)),r.streamingActive?(e.openBlock(),e.createElementBlock("div",Oo,[e.createElementVNode("div",Do,[e.createVNode(i,{size:26,tail:!0,name:r.aiAgentName,"image-url":r.aiAgentAvatarUrl},null,8,["name","image-url"])]),e.createVNode(S)])):e.createCommentVNode("",!0)],34),e.createVNode(e.Transition,{name:"wm-scrollDown"},{default:e.withCtx(()=>[a.showScrollDown?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-list__scrollDown","aria-label":o.t("messageList.scrollToBottom"),title:o.t("messageList.scrollToBottom"),onClick:n[5]||(n[5]=(...k)=>o.scrollToBottomSmooth&&o.scrollToBottomSmooth(...k))},[...n[13]||(n[13]=[e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M6 9l6 6 6-6"})],-1)])],8,Io)):e.createCommentVNode("",!0)]),_:1})])}const Re=A(fo,[["render",Ro],["__scopeId","data-v-9ddbd0e3"]]),Y=typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function",oe=typeof window<"u"&&typeof window.MediaRecorder<"u";function Fe(){return oe&&["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm","video/mp4"].find(n=>{var r,s;return(s=(r=window.MediaRecorder).isTypeSupported)==null?void 0:s.call(r,n)})||""}function Pe({audio:t}){return{video:!0,audio:!!t,selfBrowserSurface:"include",surfaceSwitching:"include",systemAudio:t?"include":"exclude"}}function Fo(t){return t?t.startsWith("image/")?"image":t.startsWith("video/")?"video":"file":"file"}async function Ue(){if(!Y)return null;let t;try{t=await navigator.mediaDevices.getDisplayMedia(Pe({audio:!1}))}catch(n){return(n==null?void 0:n.name)!=="NotAllowedError"&&console.error("[media] screenshot picker",n),null}try{return await Po(t)}catch(n){return console.error("[media] screenshot capture",n),null}finally{t.getTracks().forEach(n=>{n.stop()})}}async function Po(t){const n=document.createElement("video");n.muted=!0,n.playsInline=!0,n.srcObject=t,await n.play(),await new Promise(l=>requestAnimationFrame(l));const r=n.videoWidth||1280,s=n.videoHeight||720,a=document.createElement("canvas");a.width=r,a.height=s,a.getContext("2d").drawImage(n,0,0,r,s);const o=await new Promise((l,p)=>{a.toBlob(v=>v?l(v):p(new Error("toBlob failed")),"image/png")}),i=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19);return new File([o],`capture-${i}.png`,{type:"image/png"})}async function ze(t={}){var v;if(!Y||!oe)return null;let n;try{n=await navigator.mediaDevices.getDisplayMedia(Pe({audio:!0}))}catch(g){return(g==null?void 0:g.name)!=="NotAllowedError"&&console.error("[media] record picker",g),null}const r=Fe();let s;try{s=r?new window.MediaRecorder(n,{mimeType:r}):new window.MediaRecorder(n)}catch(g){return console.error("[media] recorder init",g),n.getTracks().forEach(E=>{E.stop()}),null}const a=[];let o=null,i=!1;s.addEventListener("dataavailable",g=>{g.data&&g.data.size>0&&a.push(g.data)}),s.addEventListener("stop",()=>{var g,E;if(o&&clearInterval(o),n.getTracks().forEach(S=>{S.stop()}),a.length){const S=s.mimeType||r||"video/webm",k=new Blob(a,{type:S}),x=/mp4/.test(S)?"mp4":"webm",w=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),V=new File([k],`ecran-${w}.${x}`,{type:S});(g=t.onfinalize)==null||g.call(t,V)}else(E=t.oncancel)==null||E.call(t)}),n.getVideoTracks().forEach(g=>{g.addEventListener("ended",()=>l(),{once:!0})});function l(){if(!i&&(i=!0,s.state!=="inactive"))try{s.stop()}catch(g){console.error("[media] recorder stop",g)}}try{s.start(1e3)}catch(g){return console.error("[media] recorder start",g),n.getTracks().forEach(E=>{E.stop()}),null}(v=t.onstart)==null||v.call(t);const p=Date.now();return o=setInterval(()=>{var g;(g=t.ontick)==null||g.call(t,Date.now()-p)},500),{stop:l,get state(){return s.state}}}const Uo=[{action:"file",labelKey:"composer.attachFile",path:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"},{action:"screenshot",labelKey:"composer.screenshot",path:"M23 19a2 2 0 01-2 2H3a2 2 0 01-2-2V8a2 2 0 012-2h4l2-3h6l2 3h4a2 2 0 012 2z M12 17a4 4 0 100-8 4 4 0 000 8z"},{action:"record",labelKey:"composer.recordScreen",path:"M23 7l-7 5 7 5V7z M1 5a2 2 0 012-2h12a2 2 0 012 2v14a2 2 0 01-2 2H3a2 2 0 01-2-2V5z"}],zo={name:"WmComposer",inject:{t:{default:()=>M()}},props:{modelValue:{type:String,default:""},placeholder:{type:String,default:"Écrivez votre message…"},disabled:{type:Boolean,default:!1},attachLabel:{type:String,default:"Joindre"},displayMode:{type:String,default:"floating"}},emits:["update:modelValue","send","attach"],data(){return{local:this.modelValue,attachOpen:!1,recording:!1,recordingElapsed:0,recorder:null,kbOffset:0}},computed:{canSend(){return!this.disabled&&!!this.local.trim()},attachItems(){return Uo.map(t=>({...t,label:this.t(t.labelKey),disabled:t.action==="screenshot"&&!Y||t.action==="record"&&(!Y||!oe)}))},recordingElapsedLabel(){const t=Math.floor(this.recordingElapsed/1e3),n=Math.floor(t/60),r=t%60;return`${n}:${r.toString().padStart(2,"0")}`}},watch:{modelValue(t){t!==this.local&&(this.local=t,this.$nextTick(()=>this.autosize()))},local(t){this.$emit("update:modelValue",t)}},mounted(){this.autosize(),this.displayMode==="sheet"&&this.setupKeyboardTracking()},beforeUnmount(){if(this.recorder)try{this.recorder.stop()}catch{}this.teardownKeyboardTracking()},methods:{focus(){const t=this.$refs.inputEl;if(!(!t||this.disabled))try{t.focus({preventScroll:!0})}catch{t.focus()}},onSubmit(){if(!this.canSend)return;const t=this.local.trim();this.local="",this.$emit("send",t),this.$nextTick(()=>this.autosize())},onKeydown(t){t.key==="Enter"&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey&&!t.isComposing&&(t.preventDefault(),this.onSubmit())},autosize(){const t=this.$refs.inputEl;t&&(t.clientWidth<80||(t.style.height="auto",t.style.height=`${t.scrollHeight}px`))},onFile(t){const n=Array.from(t.target.files||[]);for(const r of n)this.$emit("attach",r);t.target.value=""},onAttachAction(t){this.attachOpen=!1,t==="file"?this.pickFile():t==="screenshot"?this.captureScreenshot():t==="record"&&this.startRecording()},pickFile(){var t;(t=this.$refs.fileEl)==null||t.click()},async captureScreenshot(){if(this.disabled)return;const t=await Ue();t&&this.$emit("attach",t)},async startRecording(){if(this.recording||this.disabled)return;this.recordingElapsed=0;const t=await ze({onstart:()=>{this.recording=!0},ontick:n=>{this.recordingElapsed=n},onfinalize:n=>{this.$emit("attach",n),this.recording=!1,this.recordingElapsed=0,this.recorder=null},oncancel:()=>{this.recording=!1,this.recordingElapsed=0,this.recorder=null}});t&&(this.recorder=t)},stopRecording(){if(this.recorder)try{this.recorder.stop()}catch(t){console.error("[composer] stop recording",t)}},setupKeyboardTracking(){const t=window.visualViewport;t&&(this._vvHandler=()=>{const n=Math.max(0,window.innerHeight-t.height-t.offsetTop);this.kbOffset=n},t.addEventListener("resize",this._vvHandler),t.addEventListener("scroll",this._vvHandler))},teardownKeyboardTracking(){const t=window.visualViewport;!t||!this._vvHandler||(t.removeEventListener("resize",this._vvHandler),t.removeEventListener("scroll",this._vvHandler),this._vvHandler=null)}}},jo={key:0,class:"wm-rec"},Ho={class:"wm-rec__lbl"},qo={key:1,class:"wm-compose__menu",role:"menu"},Ko=["disabled","onClick"],$o={class:"wm-compose__menuIcon"},Wo={viewBox:"0 0 24 24",width:"14",height:"14","aria-hidden":"true"},Go=["d"],Yo=["placeholder","disabled"],Jo={class:"wm-compose__actions"},Qo=["title","aria-label","disabled"],Xo=["disabled","aria-label"];function Zo(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-compose-wrap",{"wm-compose-wrap--sheet":r.displayMode==="sheet"}]),style:e.normalizeStyle(a.kbOffset?{transform:`translateY(-${a.kbOffset}px)`}:null)},[a.recording?(e.openBlock(),e.createElementBlock("div",jo,[n[8]||(n[8]=e.createElementVNode("span",{class:"wm-rec__dot","aria-hidden":"true"},null,-1)),e.createElementVNode("span",Ho,e.toDisplayString(o.t("composer.recording",{time:o.recordingElapsedLabel})),1),e.createElementVNode("button",{type:"button",class:"wm-rec__stop",onClick:n[0]||(n[0]=(...i)=>o.stopRecording&&o.stopRecording(...i))},e.toDisplayString(o.t("composer.stop")),1)])):e.createCommentVNode("",!0),e.createElementVNode("form",{class:e.normalizeClass(["wm-compose",{"has-attach":a.attachOpen}]),onSubmit:n[7]||(n[7]=e.withModifiers((...i)=>o.onSubmit&&o.onSubmit(...i),["prevent"]))},[e.createElementVNode("input",{ref:"fileEl",type:"file",hidden:"",multiple:"",onChange:n[1]||(n[1]=(...i)=>o.onFile&&o.onFile(...i))},null,544),a.attachOpen?(e.openBlock(),e.createElementBlock("div",{key:0,class:"wm-compose__overlay",onClick:n[2]||(n[2]=i=>a.attachOpen=!1)})):e.createCommentVNode("",!0),a.attachOpen?(e.openBlock(),e.createElementBlock("div",qo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.attachItems,i=>(e.openBlock(),e.createElementBlock("button",{key:i.action,type:"button",class:"wm-compose__menuItem",disabled:i.disabled,onClick:l=>o.onAttachAction(i.action)},[e.createElementVNode("span",$o,[(e.openBlock(),e.createElementBlock("svg",Wo,[e.createElementVNode("path",{d:i.path,stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round",fill:"none"},null,8,Go)]))]),e.createElementVNode("span",null,e.toDisplayString(i.label),1)],8,Ko))),128))])):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("textarea",{ref:"inputEl","onUpdate:modelValue":n[3]||(n[3]=i=>a.local=i),class:"wm-compose__input",rows:"3",placeholder:r.placeholder,disabled:r.disabled,onKeydown:n[4]||(n[4]=(...i)=>o.onKeydown&&o.onKeydown(...i)),onInput:n[5]||(n[5]=(...i)=>o.autosize&&o.autosize(...i))},null,40,Yo),[[e.vModelText,a.local]]),e.createElementVNode("div",Jo,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["wm-compose__icon",{"is-open":a.attachOpen}]),title:r.attachLabel,"aria-label":r.attachLabel,disabled:a.recording,onClick:n[6]||(n[6]=i=>a.attachOpen=!a.attachOpen)},[...n[9]||(n[9]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"})],-1)])],10,Qo),e.createElementVNode("button",{type:"submit",class:e.normalizeClass(["wm-compose__send",{"is-empty":!o.canSend}]),disabled:!o.canSend,"aria-label":o.t("composer.send")},[...n[10]||(n[10]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})],-1)])],10,Xo)])],34)],6)}const je=A(zo,[["render",Zo],["__scopeId","data-v-01e81a27"]]),ea={name:"WmSuggestionChips",props:{items:{type:Array,default:()=>[]},baseDelay:{type:Number,default:360},stepDelay:{type:Number,default:90}},emits:["select"],computed:{batchKey(){return this.items.map(t=>(t==null?void 0:t.label)||(t==null?void 0:t.text)||"").join("§")}}},ta=["onClick"];function na(t,n,r,s,a,o){return r.items.length?(e.openBlock(),e.createElementBlock("div",{key:o.batchKey,class:"wm-chips"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.items,(i,l)=>(e.openBlock(),e.createElementBlock("button",{key:l,type:"button",class:"wm-chip",style:e.normalizeStyle({animationDelay:r.baseDelay+l*r.stepDelay+"ms"}),onClick:p=>t.$emit("select",i)},e.toDisplayString(i.label),13,ta))),128))])):e.createCommentVNode("",!0)}const He=A(ea,[["render",na],["__scopeId","data-v-47ad8085"]]),ra={name:"WmApprovalCard",components:{AIAvatar:$},inject:{t:{default:()=>M()}},props:{action:{type:String,required:!0},detail:{type:String,default:""},callbacks:{type:Array,default:()=>[]},agentName:{type:String,default:""},agentAvatarUrl:{type:String,default:null}},emits:["callback"],computed:{approveCallback(){return this.callbacks.find(t=>t.id==="approve"||t.style==="primary")||this.callbacks[0]},rejectCallback(){return this.callbacks.find(t=>t.id==="reject"||t.style==="danger"||t.style==="neutral")||(this.callbacks.length>1?this.callbacks[1]:null)},approveId(){var t;return(t=this.approveCallback)==null?void 0:t.id},rejectId(){var t;return(t=this.rejectCallback)==null?void 0:t.id},approveLabel(){var t;return((t=this.approveCallback)==null?void 0:t.label)||this.t("approval.approve")},rejectLabel(){var t;return((t=this.rejectCallback)==null?void 0:t.label)||this.t("approval.reject")}}},oa={class:"wm-approval"},aa={class:"wm-approval__head"},sa={class:"wm-approval__icon"},ia={class:"wm-approval__main"},la={class:"wm-approval__title"},ca={key:0,class:"wm-approval__detail"},da={class:"wm-approval__actions"};function ua(t,n,r,s,a,o){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",oa,[e.createElementVNode("div",aa,[e.createElementVNode("div",sa,[e.createVNode(i,{size:24,name:r.agentName,"image-url":r.agentAvatarUrl},null,8,["name","image-url"])]),e.createElementVNode("div",ia,[e.createElementVNode("div",la,e.toDisplayString(r.action),1),r.detail?(e.openBlock(),e.createElementBlock("div",ca,e.toDisplayString(r.detail),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",da,[o.rejectId?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-approval__btn wm-approval__btn--neutral",onClick:n[0]||(n[0]=l=>t.$emit("callback",o.rejectId))},e.toDisplayString(o.rejectLabel),1)):e.createCommentVNode("",!0),o.approveId?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"wm-approval__btn wm-approval__btn--primary",onClick:n[1]||(n[1]=l=>t.$emit("callback",o.approveId))},e.toDisplayString(o.approveLabel),1)):e.createCommentVNode("",!0)])])}const qe=A(ra,[["render",ua],["__scopeId","data-v-a2bed37e"]]);let fe=0;const ma=new Set(["text","textarea","number","boolean","select","multiselect","date"]),ha={name:"WmFormCard",components:{AIAvatar:$},inject:{t:{default:()=>M()}},props:{form:{type:Object,required:!0},readOnly:{type:Boolean,default:!1},initialValues:{type:Object,default:null},agentName:{type:String,default:""},agentAvatarUrl:{type:String,default:null}},emits:["submit"],data(){return fe+=1,{_uid:fe,values:{},busy:!1,error:""}},computed:{normalizedFields(){var n;return(Array.isArray((n=this.form)==null?void 0:n.fields)?this.form.fields:[]).filter(r=>!(!(r!=null&&r.key)||!(r!=null&&r.label)||!ma.has(r==null?void 0:r.type)||(r.type==="select"||r.type==="multiselect")&&(!Array.isArray(r.options)||r.options.length===0)))}},created(){this.resetValues()},methods:{resetValues(){const t=this.initialValues&&typeof this.initialValues=="object"?this.initialValues:{},n={};for(const r of this.normalizedFields){if(t[r.key]!==void 0){n[r.key]=t[r.key];continue}r.type==="boolean"?n[r.key]=!1:r.type==="multiselect"?n[r.key]=[]:n[r.key]=""}this.values=n,this.error=""},toggleMulti(t,n,r){const s=Array.isArray(this.values[t])?this.values[t].slice():[],a=s.indexOf(n);r&&a===-1?s.push(n):!r&&a!==-1&&s.splice(a,1),this.values={...this.values,[t]:s}},validate(){for(const t of this.normalizedFields){if(!t.required)continue;const n=this.values[t.key];if(t.type!=="boolean"){if(t.type==="multiselect"){if(!Array.isArray(n)||n.length===0)return this.t("form.fieldRequired",{label:t.label});continue}if(n==null||n==="")return this.t("form.fieldRequired",{label:t.label})}}return""},async onSubmit(){if(this.readOnly||this.busy)return;const t=this.validate();if(t){this.error=t;return}this.error="",this.busy=!0;try{await this.$emit("submit",{values:this.values})}finally{this.busy=!1}}}},fa={class:"wm-form"},pa={class:"wm-form__head"},ga={class:"wm-form__icon"},_a={class:"wm-form__main"},va={class:"wm-form__title"},ya={key:0,class:"wm-form__detail"},ka=["for"],wa={key:0,class:"wm-form__req","aria-hidden":"true"},ba=["id","onUpdate:modelValue","placeholder","required","disabled"],Ea=["id","onUpdate:modelValue","placeholder","required","disabled"],Ca=["id","onUpdate:modelValue","placeholder","required","disabled"],Ba=["id","onUpdate:modelValue","required","disabled"],Na={key:4,class:"wm-form__bool"},Sa=["id","onUpdate:modelValue","disabled"],Aa=["id","onUpdate:modelValue","required","disabled"],Va={value:"",disabled:""},Ma=["value"],Ta={key:6,class:"wm-form__multi"},xa=["value","checked","disabled","onChange"],La={key:0,class:"wm-form__err"},Oa=["disabled"],Da={key:0,class:"wm-form__spinner","aria-hidden":"true"},Ia={key:2,class:"wm-form__doneLbl"};function Ra(t,n,r,s,a,o){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",fa,[e.createElementVNode("div",pa,[e.createElementVNode("div",ga,[e.createVNode(i,{size:24,name:r.agentName,"image-url":r.agentAvatarUrl},null,8,["name","image-url"])]),e.createElementVNode("div",_a,[e.createElementVNode("div",va,e.toDisplayString(r.form.title||o.t("form.title")),1),r.form.description?(e.openBlock(),e.createElementBlock("div",ya,e.toDisplayString(r.form.description),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("form",{class:"wm-form__body",onSubmit:n[0]||(n[0]=e.withModifiers((...l)=>o.onSubmit&&o.onSubmit(...l),["prevent"]))},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.normalizedFields,l=>(e.openBlock(),e.createElementBlock("div",{key:l.key,class:"wm-form__field"},[e.createElementVNode("label",{for:`wm-f-${a._uid}-${l.key}`,class:"wm-form__label"},[e.createTextVNode(e.toDisplayString(l.label),1),l.required?(e.openBlock(),e.createElementBlock("span",wa,"*")):e.createCommentVNode("",!0)],8,ka),l.type==="text"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":p=>a.values[l.key]=p,type:"text",class:"wm-form__input",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||a.busy},null,8,ba)),[[e.vModelText,a.values[l.key]]]):l.type==="textarea"?e.withDirectives((e.openBlock(),e.createElementBlock("textarea",{key:1,id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":p=>a.values[l.key]=p,class:"wm-form__textarea",rows:"3",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||a.busy},null,8,Ea)),[[e.vModelText,a.values[l.key]]]):l.type==="number"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:2,id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":p=>a.values[l.key]=p,type:"number",class:"wm-form__input",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||a.busy},null,8,Ca)),[[e.vModelText,a.values[l.key],void 0,{number:!0}]]):l.type==="date"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:3,id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":p=>a.values[l.key]=p,type:"date",class:"wm-form__input",required:l.required,disabled:r.readOnly||a.busy},null,8,Ba)),[[e.vModelText,a.values[l.key]]]):l.type==="boolean"?(e.openBlock(),e.createElementBlock("label",Na,[e.withDirectives(e.createElementVNode("input",{id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":p=>a.values[l.key]=p,type:"checkbox",disabled:r.readOnly||a.busy},null,8,Sa),[[e.vModelCheckbox,a.values[l.key]]]),e.createElementVNode("span",null,e.toDisplayString(l.placeholder||o.t("common.yes")),1)])):l.type==="select"?e.withDirectives((e.openBlock(),e.createElementBlock("select",{key:5,id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":p=>a.values[l.key]=p,class:"wm-form__select",required:l.required,disabled:r.readOnly||a.busy},[e.createElementVNode("option",Va,e.toDisplayString(l.placeholder||o.t("form.choose")),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.options,p=>(e.openBlock(),e.createElementBlock("option",{key:p.value,value:p.value},e.toDisplayString(p.label),9,Ma))),128))],8,Aa)),[[e.vModelSelect,a.values[l.key]]]):l.type==="multiselect"?(e.openBlock(),e.createElementBlock("div",Ta,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.options,p=>(e.openBlock(),e.createElementBlock("label",{key:p.value,class:"wm-form__multiItem"},[e.createElementVNode("input",{type:"checkbox",value:p.value,checked:Array.isArray(a.values[l.key])&&a.values[l.key].includes(p.value),disabled:r.readOnly||a.busy,onChange:v=>o.toggleMulti(l.key,p.value,v.target.checked)},null,40,xa),e.createElementVNode("span",null,e.toDisplayString(p.label),1)]))),128))])):e.createCommentVNode("",!0)]))),128)),a.error?(e.openBlock(),e.createElementBlock("div",La,e.toDisplayString(a.error),1)):e.createCommentVNode("",!0),r.readOnly?(e.openBlock(),e.createElementBlock("div",Ia,e.toDisplayString(o.t("form.responseSent")),1)):(e.openBlock(),e.createElementBlock("button",{key:1,type:"submit",class:"wm-form__submit",disabled:a.busy},[a.busy?(e.openBlock(),e.createElementBlock("span",Da)):e.createCommentVNode("",!0),e.createElementVNode("span",null,e.toDisplayString(a.busy?o.t("common.sending"):r.form.submit_label||o.t("common.send")),1)],8,Oa))],32)])}const Ke=A(ha,[["render",Ra],["__scopeId","data-v-fe65cc56"]]),Fa={name:"WmFeedback",inject:{t:{default:()=>M()}},props:{busy:{type:Boolean,default:!1},done:{type:Boolean,default:!1}},emits:["submit"],data(){return{sel:null}},computed:{options(){return[{v:1,e:"😞",l:this.t("feedback.rating1")},{v:2,e:"😐",l:this.t("feedback.rating2")},{v:3,e:"🙂",l:this.t("feedback.rating3")},{v:4,e:"😄",l:this.t("feedback.rating4")},{v:5,e:"🤩",l:this.t("feedback.rating5")}]}},methods:{onSend(){!this.sel||this.busy||this.$emit("submit",{rating:this.sel})}}},Pa={class:"wm-fb"},Ua={class:"wm-fb__title"},za={class:"wm-fb__sub"},ja={class:"wm-fb__row"},Ha=["onClick"],qa={class:"wm-fb__emoji"},Ka={class:"wm-fb__label"},$a=["disabled"],Wa={key:1,class:"wm-fb__done"},Ga={class:"wm-fb__doneTitle"},Ya={class:"wm-fb__doneSub"};function Ja(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",Pa,[r.done?(e.openBlock(),e.createElementBlock("div",Wa,[n[1]||(n[1]=e.createElementVNode("div",{class:"wm-fb__check"},[e.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#fff","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M20 6L9 17l-5-5"})])],-1)),e.createElementVNode("div",Ga,e.toDisplayString(o.t("feedback.doneTitle")),1),e.createElementVNode("div",Ya,e.toDisplayString(o.t("feedback.doneSubtitle")),1)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("div",Ua,e.toDisplayString(o.t("feedback.question")),1),e.createElementVNode("div",za,e.toDisplayString(o.t("feedback.subtitle")),1),e.createElementVNode("div",ja,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.options,i=>(e.openBlock(),e.createElementBlock("button",{key:i.v,type:"button",class:e.normalizeClass(["wm-fb__opt",{"is-selected":a.sel===i.v}]),onClick:l=>a.sel=i.v},[e.createElementVNode("span",qa,e.toDisplayString(i.e),1),e.createElementVNode("span",Ka,e.toDisplayString(i.l),1)],10,Ha))),128))]),e.createElementVNode("button",{type:"button",class:"wm-fb__send",disabled:!a.sel||r.busy,onClick:n[0]||(n[0]=(...i)=>o.onSend&&o.onSend(...i))},e.toDisplayString(r.busy?o.t("common.sending"):o.t("feedback.submit")),9,$a)],64))])}const $e=A(Fa,[["render",Ja],["__scopeId","data-v-9b630564"]]),Qa={name:"WmMoreMenu",inject:{t:{default:()=>M()}},props:{canRename:{type:Boolean,default:!0},canExport:{type:Boolean,default:!0},soundEnabled:{type:Boolean,default:!0},browserNotifEnabled:{type:Boolean,default:!1},statusUrl:{type:String,default:""},helpUrl:{type:String,default:""}},emits:["close","action","sound-toggle","browser-notif-toggle"],data(){return{soundOn:this.soundEnabled,browserNotifOn:this.browserNotifEnabled}},watch:{soundEnabled(t){this.soundOn=!!t},browserNotifEnabled(t){this.browserNotifOn=!!t}},methods:{emit(t){this.$emit("action",t)},toggleSound(){this.soundOn=!this.soundOn,this.$emit("sound-toggle",this.soundOn)},toggleBrowserNotif(){this.browserNotifOn=!this.browserNotifOn,this.$emit("browser-notif-toggle",this.browserNotifOn)}}},Xa={class:"wm-mm"},Za={class:"wm-mm__pop",role:"menu"},es={key:0,class:"wm-mm__section"},ts={class:"wm-mm__label"},ns={class:"wm-mm__label"},rs={key:1,class:"wm-mm__sep"},os={class:"wm-mm__section"},as={class:"wm-mm__label"},ss={class:"wm-mm__label"},is={class:"wm-mm__section"},ls={class:"wm-mm__label"},cs={class:"wm-mm__label"};function ds(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",Xa,[e.createElementVNode("div",{class:"wm-mm__scrim",onClick:n[0]||(n[0]=i=>t.$emit("close"))}),e.createElementVNode("div",Za,[r.canRename||r.canExport?(e.openBlock(),e.createElementBlock("div",es,[r.canRename?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-mm__item",onClick:n[1]||(n[1]=i=>o.emit("rename"))},[n[7]||(n[7]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M12 20h9"}),e.createElementVNode("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})])],-1)),e.createElementVNode("span",ts,e.toDisplayString(o.t("moreMenu.editTitle")),1)])):e.createCommentVNode("",!0),r.canExport?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"wm-mm__item",onClick:n[2]||(n[2]=i=>o.emit("export"))},[n[8]||(n[8]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M4 12v8a2 2 0 002 2h12a2 2 0 002-2v-8M16 6l-4-4-4 4M12 2v13"})])],-1)),e.createElementVNode("span",ns,e.toDisplayString(o.t("moreMenu.exportTranscript")),1),n[9]||(n[9]=e.createElementVNode("span",{class:"wm-mm__hint"},".txt",-1))])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),r.canRename||r.canExport?(e.openBlock(),e.createElementBlock("div",rs)):e.createCommentVNode("",!0),e.createElementVNode("div",os,[e.createElementVNode("button",{type:"button",class:"wm-mm__item",onClick:n[3]||(n[3]=(...i)=>o.toggleSound&&o.toggleSound(...i))},[n[11]||(n[11]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M11 5L6 9H2v6h4l5 4V5z"}),e.createElementVNode("path",{d:"M15.54 8.46a5 5 0 010 7.07M19.07 4.93a10 10 0 010 14.14"})])],-1)),e.createElementVNode("span",as,e.toDisplayString(o.t("moreMenu.sound")),1),e.createElementVNode("span",{class:e.normalizeClass(["wm-mm__toggle",{"wm-mm__toggle--on":a.soundOn}])},[...n[10]||(n[10]=[e.createElementVNode("span",{class:"wm-mm__knob"},null,-1)])],2)]),e.createElementVNode("button",{type:"button",class:"wm-mm__item",onClick:n[4]||(n[4]=(...i)=>o.toggleBrowserNotif&&o.toggleBrowserNotif(...i))},[n[13]||(n[13]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M15 17h5l-1.4-1.4A2 2 0 0118 14.2V11a6 6 0 10-12 0v3.2c0 .5-.2 1-.6 1.4L4 17h5m6 0a3 3 0 11-6 0"})])],-1)),e.createElementVNode("span",ss,e.toDisplayString(o.t("moreMenu.browserNotifications")),1),e.createElementVNode("span",{class:e.normalizeClass(["wm-mm__toggle",{"wm-mm__toggle--on":a.browserNotifOn}])},[...n[12]||(n[12]=[e.createElementVNode("span",{class:"wm-mm__knob"},null,-1)])],2)])]),n[16]||(n[16]=e.createElementVNode("div",{class:"wm-mm__sep"},null,-1)),e.createElementVNode("div",is,[r.statusUrl?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-mm__item",onClick:n[5]||(n[5]=i=>o.emit("status"))},[n[14]||(n[14]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zM10 6v4l3 2"})])],-1)),e.createElementVNode("span",ls,e.toDisplayString(o.t("moreMenu.serviceStatus")),1)])):e.createCommentVNode("",!0),r.helpUrl?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"wm-mm__item",onClick:n[6]||(n[6]=i=>o.emit("help"))},[n[15]||(n[15]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M9 11a3 3 0 116 0c0 2-3 2-3 5M12 19h.01M12 22a10 10 0 110-20 10 10 0 010 20z"})])],-1)),e.createElementVNode("span",cs,e.toDisplayString(o.t("moreMenu.helpCenter")),1)])):e.createCommentVNode("",!0)])])])}const We=A(Qa,[["render",ds],["__scopeId","data-v-76281e95"]]),us={name:"WmRenameDialog",inject:{t:{default:()=>M()}},props:{title:{type:String,default:""},initialValue:{type:String,default:""},placeholder:{type:String,default:""}},emits:["close","submit"],data(){return{value:this.initialValue||""}},computed:{canSubmit(){const t=(this.value||"").trim();return!!t&&t!==(this.initialValue||"").trim()}},mounted(){this.$nextTick(()=>{const t=this.$refs.input;if(t){t.focus();try{t.select()}catch{}}})},methods:{onSubmit(){this.canSubmit&&this.$emit("submit",this.value.trim())}}},ms={class:"wm-dialog"},hs={class:"wm-dialog__card",role:"dialog","aria-modal":"true"},fs={class:"wm-dialog__head"},ps={class:"wm-dialog__title"},gs=["aria-label"],_s={class:"wm-dialog__body"},vs=["placeholder"],ys={class:"wm-dialog__actions"},ks=["disabled"];function ws(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",ms,[e.createElementVNode("div",{class:"wm-dialog__scrim",onClick:n[0]||(n[0]=i=>t.$emit("close"))}),e.createElementVNode("div",hs,[e.createElementVNode("div",fs,[e.createElementVNode("div",ps,e.toDisplayString(r.title||o.t("rename.title")),1),e.createElementVNode("button",{type:"button",class:"wm-dialog__close","aria-label":o.t("common.close"),onClick:n[1]||(n[1]=i=>t.$emit("close"))},[...n[7]||(n[7]=[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,gs)]),e.createElementVNode("div",_s,[e.withDirectives(e.createElementVNode("input",{ref:"input","onUpdate:modelValue":n[2]||(n[2]=i=>a.value=i),type:"text",class:"wm-dialog__input",placeholder:r.placeholder||o.t("rename.placeholder"),maxlength:120,onKeydown:[n[3]||(n[3]=e.withKeys(e.withModifiers((...i)=>o.onSubmit&&o.onSubmit(...i),["prevent"]),["enter"])),n[4]||(n[4]=e.withKeys(e.withModifiers(i=>t.$emit("close"),["prevent"]),["esc"]))]},null,40,vs),[[e.vModelText,a.value]])]),e.createElementVNode("div",ys,[e.createElementVNode("button",{type:"button",class:"wm-dialog__btn",onClick:n[5]||(n[5]=i=>t.$emit("close"))},e.toDisplayString(o.t("common.cancel")),1),e.createElementVNode("button",{type:"button",class:"wm-dialog__btn wm-dialog__btn--primary",disabled:!o.canSubmit,onClick:n[6]||(n[6]=(...i)=>o.onSubmit&&o.onSubmit(...i))},e.toDisplayString(o.t("common.save")),9,ks)])])])}const bs=A(us,[["render",ws],["__scopeId","data-v-6d5f94a8"]]),pe="ww-messenger-tokens",Es={name:"Messenger",components:{Launcher:be,Header:Ce,Onboarding:Ae,MessageList:Re,Composer:je,SuggestionChips:He,ApprovalCard:qe,FormCard:Ke,Feedback:$e,MoreMenu:We,RenameDialog:bs},mixins:[lt,ft,pt,_t],provide(){return{signAttachmentFn:t=>{var n,r;return((r=(n=this.store)==null?void 0:n.signAttachment)==null?void 0:r.call(n,t))||null},t:(t,n)=>this.t(t,n),wmLocale:()=>this.locale}},props:{baseUrl:{type:String,default:ye},widgetId:{type:String,default:""},context:{type:Object,default:null},displayMode:{type:String,default:"floating"},devtools:{type:Boolean,default:!1},language:{type:String,default:""}},data(){return{transport:null,store:null,isOpen:!1,launcherHovered:!1,draft:"",busy:!1,bootError:null,pendingAttachments:[],feedbackBusy:!1,feedbackDone:!1,convOpenedAt:0,moreOpen:!1,renameDialogOpen:!1,draftConv:null,activeConvId:null,showOnboarding:!1,dismissedPeeks:{},floatHeight:0,floatRO:null,parentOrigin:"",parentToken:"",parentContext:null,parentAllowUnauthenticated:!1,parentInitReceived:!1,parentInitDeferred:null}},computed:{isEditor(){return!!this.devtools},isEmbedded(){return this.displayMode==="embedded"},customerLanguage(){var r,s,a,o;const t=(r=this.s)==null?void 0:r.customer,n=t&&(t.language||((s=t.values)==null?void 0:s.language));return n||((o=(a=this.context)==null?void 0:a.customer)==null?void 0:o.language)||""},locale(){var t;return ne(this.language||this.customerLanguage||((t=this.widget)==null?void 0:t.default_language)||"")},translator(){return M(this.locale)},error(){var t;return this.bootError||((t=this.s)==null?void 0:t.error)||null},canBoot(){return!!(this.baseUrl&&this.widgetId)},s(){var t;return((t=this.store)==null?void 0:t.state)||null},ready(){var t;return!!((t=this.s)!=null&&t.ready)},allConversations(){var n;const t=(n=this.s)==null?void 0:n.conversations;return Array.isArray(t)?t:[]},drawerConversations(){var r;const t=((r=this.s)==null?void 0:r.messagesByConv)||{},n=this.revealedAt;return this.allConversations.map(s=>{var v;const a=t[s.id]||[],o=D(s.last_read_message_id);let i=0,l=null;for(let g=a.length-1;g>=0;g--){const E=a[g];if(!E)continue;if(((v=E.author)==null?void 0:v.type)==="user")break;const S=D(E.id);if(S!=null){if(o!=null&&S<=o)break;n[E.id]!==0&&(!l&&E.author&&(l=E.author),i++)}}if(!a.length){const g=D(s.last_message_id);g!=null&&(o==null||g>o)&&(i=1,l=s.last_message_author||null)}const p=a.filter(g=>!((g==null?void 0:g.id)!=null&&n[g.id]===0));return{...s,_preview:ot(s,p),_unread:i>0,_unreadCount:i,_lastAuthor:l}})},unreadCount(){return this.drawerConversations.filter(t=>t._unread).length},openThreads(){var n;const t=((n=this.s)==null?void 0:n.messagesByConv)||{};return this.drawerConversations.filter(r=>r.status!=="resolved").map(r=>({id:r.id,title:r.name||this.t("common.newConversation"),preview:r._preview||this.t("onboarding.newMessage"),unread:!!r._unread,author:r._lastAuthor||null,_ts:ue(r,t[r.id]||[])})).sort((r,s)=>r._ts<s._ts?1:r._ts>s._ts?-1:0)},latestUnreads(){var r;const t=((r=this.s)==null?void 0:r.messagesByConv)||{},n=[];for(const s of this.drawerConversations){if(!s._unread)continue;const a=ue(s,t[s.id]||[]),o=s._lastAuthor,i=!o||o.type==="agent_ia",l=(o==null?void 0:o.name)||(i?this.agentName:"")||"",p=(o==null?void 0:o.avatar_url)||(i?this.agentAvatarUrl:null);n.push({convId:s.id,preview:s._preview||this.t("notification.youHaveNewMessage"),ts:a,count:s._unreadCount||1,senderName:l,senderAvatarUrl:p})}return n.sort((s,a)=>s.ts<a.ts?1:s.ts>a.ts?-1:0),n},launcherPeeks(){if(this.isOpen||this.isEmbedded)return[];const t=this.dismissedPeeks||{};return this.latestUnreads.filter(n=>t[n.convId]!==n.ts)},isViewingThread(){return(this.isOpen||this.isEmbedded)&&!!this.currentConv},currentConv(){if(this.draftConv)return this.draftConv;if(this.showOnboarding)return null;const t=this.allConversations;if(!t.length)return null;if(this.activeConvId!=null){const n=t.find(r=>r.id===this.activeConvId);if(n)return n}return t[0]||null},canBack(){return!!this.currentConv},statusUrl(){var r;const t=(r=this.widget)==null?void 0:r.quick_links;if(!Array.isArray(t))return"";const n=t.find(s=>s.icon==="status"&&s.url);return(n==null?void 0:n.url)||""},helpUrl(){var r;const t=(r=this.widget)==null?void 0:r.quick_links;if(!Array.isArray(t))return"";const n=t.find(s=>(s.icon==="chat"||s.icon==="help")&&s.url);return(n==null?void 0:n.url)||""},widget(){var t,n;return((n=(t=this.s)==null?void 0:t.config)==null?void 0:n.widget)||null},rootStyle(){var n;const t=(n=this.widget)==null?void 0:n.primary_color;return t?{"--wm-primary":t}:null},widgetWelcomeMessage(){var t;return((t=this.widget)==null?void 0:t.welcome_message)||""},widgetSubtitle(){var t;return((t=this.widget)==null?void 0:t.subtitle)||""},defaultIconUrl(){var t;return((t=this.widget)==null?void 0:t.default_icon_url)||null},agentName(){var t,n,r;return((r=(n=(t=this.s)==null?void 0:t.config)==null?void 0:n.agent)==null?void 0:r.name)||""},agentAvatarUrl(){var t,n,r;return((r=(n=(t=this.s)==null?void 0:t.config)==null?void 0:n.agent)==null?void 0:r.avatar_url)||null},quickLinks(){var n;const t=(n=this.widget)==null?void 0:n.quick_links;return Array.isArray(t)?t:[]},teamMembers(){var n;const t=(n=this.widget)==null?void 0:n.team_members;return Array.isArray(t)?t:[]},responseLabel(){var t;return((t=this.widget)==null?void 0:t.response_time_label)||""},humanMessageAuthor(){var n,r,s;if(!this.currentConv)return null;const t=((n=this.s.messagesByConv)==null?void 0:n[this.currentConv.id])||[];for(let a=t.length-1;a>=0;a--)if(((s=(r=t[a])==null?void 0:r.author)==null?void 0:s.type)==="agent_human")return t[a].author;return null},humanAgentName(){var t;return((t=this.humanMessageAuthor)==null?void 0:t.name)||""},humanAgentAvatarUrl(){var t;return((t=this.humanMessageAuthor)==null?void 0:t.avatar_url)||null},isEscalated(){return!!this.humanMessageAuthor},isWaitingHuman(){var n;const t=(n=this.currentConv)==null?void 0:n.status;return t==="waiting"||t==="handled"},headerTitle(){var t,n;return((t=this.currentConv)==null?void 0:t.name)||((n=this.widget)==null?void 0:n.name)||this.t("common.newConversation")},composerPlaceholder(){return this.isEscalated&&this.humanAgentName?this.t("composer.replyTo",{name:this.humanAgentName.split(" ")[0]}):this.isWaitingHuman?this.t("composer.agentTakingOver"):this.t("composer.placeholder")},displayedMessages(){var r,s;const t=this.currentConv;if(!t)return[];if(!t._draft){const a=(s=(r=this.s)==null?void 0:r.paginationByConv)==null?void 0:s[t.id];if(!(a!=null&&a.loaded))return[]}const n=this.revealedAt;return(this.s.messagesByConv[t.id]||[]).filter(a=>{var o,i,l,p,v;return(a==null?void 0:a.type)==="action"&&((o=a==null?void 0:a.payload)==null?void 0:o.state)==="pending"||G(a)&&!(n[a.id]>0)?!1:(a==null?void 0:a.type)==="action"||(a==null?void 0:a.type)==="system"||((i=a==null?void 0:a.payload)==null?void 0:i.type)==="system"||Array.isArray((l=a==null?void 0:a.payload)==null?void 0:l.attachments)&&a.payload.attachments.length||(p=a==null?void 0:a.metadata)!=null&&p.artifact||(v=a==null?void 0:a.metadata)!=null&&v.form?!0:typeof(a==null?void 0:a.text_md)=="string"&&a.text_md.trim().length>0})},streamingActive(){var r,s,a;const t=this.currentConv;return t?Object.keys(((r=this.s)==null?void 0:r.streamingByMsgId)||{}).length>0?!0:this.actionInFlight?!1:(((a=(s=this.s)==null?void 0:s.messagesByConv)==null?void 0:a[t.id])||[]).some(o=>G(o)&&!(this.revealedAt[o.id]>0)):!1},currentConvMessages(){var n,r,s;const t=(n=this.currentConv)==null?void 0:n.id;return t?((s=(r=this.s)==null?void 0:r.messagesByConv)==null?void 0:s[t])||[]:[]},pendingApproval(){return!this.currentConv||!this.store||this.actionInFlight?null:this.store.getPendingApproval(this.currentConv.id)},approvalReady(){return this.pendingApproval?this.pendingApproval.id===this.approvalLatchId?!0:!(this.streamingActive||!this.approvalSettled):!1},approvalTitle(){var t,n,r;return((n=(t=this.pendingApproval)==null?void 0:t.payload)==null?void 0:n.name)||((r=this.pendingApproval)==null?void 0:r.text_md)||this.t("action.title")},approvalDetail(){var s,a,o,i,l,p;const t=(o=(a=(s=this.pendingApproval)==null?void 0:s.payload)==null?void 0:a.pending)==null?void 0:o.user_explanation;if(typeof t=="string"&&t.trim())return t.trim();const n=(p=(l=(i=this.pendingApproval)==null?void 0:i.payload)==null?void 0:l.pending)==null?void 0:p.prepared_params;if(!n||typeof n!="object")return"";const r=Object.entries(n);return r.length?r.slice(0,2).map(([v,g])=>`${v}: ${g}`).join(" · "):""},actionInFlight(){var t,n;return!this.currentConv||!this.store?null:((n=(t=this.store).getActionInFlight)==null?void 0:n.call(t,this.currentConv.id))||null},actionInFlightName(){var n;const t=this.actionInFlight;return t?((n=t.payload)==null?void 0:n.name)||t.text_md||this.t("common.action"):""},suggestions(){return!this.currentConv||!this.store?[]:this.streamingActive?[]:this.pendingForm?[]:this.store.getLatestSuggestions(this.currentConv.id)},pendingForm(){var t,n;return!this.currentConv||!this.store||this.pendingApproval||this.actionInFlight||this.streamingActive||!this.approvalSettled?null:((n=(t=this.store).getLatestForm)==null?void 0:n.call(t,this.currentConv.id))||null},showFeedback(){var n;const t=this.currentConv;return t?this.feedbackDone?!0:t.status!=="resolved"?!1:!((n=t.metadata)!=null&&n.feedback):!1},floatVisible(){return this.approvalReady||!!this.pendingForm||this.showFeedback||this.suggestions.length>0},dateLabel(){var r,s,a;const t=this.currentConv;let n=new Date;if(t){const i=((a=(((s=(r=this.s)==null?void 0:r.messagesByConv)==null?void 0:s[t.id])||[]).find(l=>l==null?void 0:l.created_at))==null?void 0:a.created_at)||t.created_at;if(i){const l=new Date(i);Number.isNaN(l.getTime())||(n=l)}}return this.t("messageList.today",{time:Z(n,P(this.locale))})},paginationState(){var r,s,a;const t=(r=this.currentConv)==null?void 0:r.id,n=t?(a=(s=this.s)==null?void 0:s.paginationByConv)==null?void 0:a[t]:null;return{loading:!!(n!=null&&n.loading),hasMore:!!(n!=null&&n.nextCursor)}}},watch:{latestUnreads:{handler(t){const n=new Set(t.map(i=>i.convId)),r=this.dismissedPeeks||{},s=Object.keys(r);if(!s.length)return;const a={};let o=!1;for(const i of s)n.has(i)?a[i]=r[i]:o=!0;o&&(this.dismissedPeeks=a)},deep:!0},"currentConv.id":{handler(t){var n;this.resetRevealQueue(),this.convOpenedAt=Date.now(),this.moreOpen=!1,this.renameDialogOpen=!1,this.resetApprovalPacing(),this.isViewingThread&&(this.unreadAnchorId=D((n=this.currentConv)==null?void 0:n.last_read_message_id),this.unreadBoundaryTs=t?new Date().toISOString():"")},immediate:!0},isViewingThread(t,n){var r;t&&!n?(this.unreadAnchorId=D((r=this.currentConv)==null?void 0:r.last_read_message_id),this.unreadBoundaryTs=new Date().toISOString()):t||(this.unreadAnchorId=null,this.unreadBoundaryTs="")},pendingApproval:{handler(t,n){if(t&&!n){const r=t!=null&&t.created_at?Date.parse(t.created_at):NaN;if(!(Number.isFinite(r)&&r>=this.convOpenedAt)){this.resetApprovalPacing();return}this.bumpApprovalSettle(2600)}else!t&&n&&this.resetApprovalPacing()},immediate:!1},streamingActive(t,n){t!==n&&this.pendingApproval&&this.pendingApproval.id!==this.approvalLatchId&&this.bumpApprovalSettle()},approvalReady(t){t&&this.pendingApproval&&(this.approvalLatchId=this.pendingApproval.id)},floatVisible:{handler(t){this.$nextTick(()=>this.syncFloatObserver(t))},immediate:!0},currentConvMessages(t){var n;this.paceMessages(t,(n=this.currentConv)==null?void 0:n.id),(this.isOpen||this.isEmbedded)&&this.currentConv&&this.markConvRead(this.currentConv)}},async mounted(){if(typeof document<"u"&&!document.getElementById(pe)){const t=document.createElement("style");t.id=pe,t.textContent=ve,document.head.appendChild(t)}this._parentMessageHandler=this.onParentMessage.bind(this),window.addEventListener("message",this._parentMessageHandler),window.parent&&window.parent!==window&&window.parent.postMessage({type:"READY"},"*"),this.isEmbedded?(await this.boot(),this.store&&await this.open()):(await this.$nextTick(),this.sendCurrentLauncherSize(),this.observeLauncherSize())},beforeUnmount(){this._parentMessageHandler&&(window.removeEventListener("message",this._parentMessageHandler),this._parentMessageHandler=null),this._launcherRo&&(this._launcherRo.disconnect(),this._launcherRo=null),this.cancelReveals(),this.teardownLiveReveal(),this.disconnectFloatRO(),this.resetApprovalPacing(),this.teardownNotifications(),this.store&&this.store.destroy()},methods:{t(t,n){return this.translator(t,n)},waitForParentInit(){if(this.parentInitReceived)return Promise.resolve();if(!this.parentInitDeferred){let t;this.parentInitDeferred=new Promise(n=>{t=n}),this.parentInitDeferred._resolve=t}return this.parentInitDeferred},onParentMessage(t){var r;const n=t==null?void 0:t.data;!n||typeof n!="object"||n.type!=="INIT"||(this.parentOrigin=t.origin,this.parentToken=typeof n.token=="string"?n.token:"",this.parentContext=n.context&&typeof n.context=="object"?n.context:null,this.parentAllowUnauthenticated=n.allowUnauthenticated===!0,this.parentInitReceived=!0,(r=this.parentInitDeferred)!=null&&r._resolve&&this.parentInitDeferred._resolve(),!this.isEmbedded&&!this.isOpen&&!this.parentAllowUnauthenticated&&this.parentToken&&this.hasValidSessionMarker()&&this.boot().catch(s=>{console.warn("[messenger] eager boot failed",s)}))},hasValidSessionMarker(){if(typeof document>"u")return!1;const n=(document.cookie||"").match(/(?:^|; )messenger_session_marker=([^;]+)/);if(!n)return!1;const r=parseInt(n[1],10);return Number.isFinite(r)?r>Date.now():!1},async boot(){var t,n;if(!this.canBoot){console.warn("[messenger] boot skipped — missing creds");return}try{await this.waitForParentInit(),this.transport=e.markRaw(ge({baseUrl:this.baseUrl,widgetId:this.widgetId})),this.store=e.markRaw(_e(this.transport)),this.hydrateNotifPref();const r=((t=this.parentContext)==null?void 0:t.customer)||((n=this.context)==null?void 0:n.customer);await this.store.start({origin:this.parentOrigin,token:this.parentToken||void 0,allowUnauthenticated:this.parentAllowUnauthenticated,customer:r&&typeof r=="object"?r:void 0}),this.setupLiveReveal()}catch(r){console.error("[ww-messenger] bootstrap failed",r),this.bootError=(r==null?void 0:r.message)||String(r)}},async refresh(){this.store&&this.store.destroy(),this.cancelReveals(),this.teardownLiveReveal(),this.teardownNotifications(),this.convOpenedAt=0,this.transport=null,this.store=null,this.isOpen=!1,this.draft="",this.busy=!1,this.bootError=null,this.pendingAttachments=[],this.feedbackBusy=!1,this.feedbackDone=!1,this.moreOpen=!1,this.renameDialogOpen=!1,this.draftConv=null,this.activeConvId=null,this.showOnboarding=!1,await this.boot(),this.isEmbedded&&this.store&&await this.open()},syncFloatObserver(t){if(this.disconnectFloatRO(),!t){this.floatHeight=0;return}const n=this.$refs.floatEl;if(n){if(typeof ResizeObserver>"u"){this.floatHeight=Math.ceil(n.getBoundingClientRect().height+8);return}this.floatRO=new ResizeObserver(r=>{const s=r[0];if(!s)return;const a=Math.ceil(s.contentRect.height+8);a!==this.floatHeight&&(this.floatHeight=a,this.$nextTick(()=>{var o,i;(i=(o=this.$refs.messageList)==null?void 0:o.scrollToBottom)==null||i.call(o)}))}),this.floatRO.observe(n)}},disconnectFloatRO(){if(this.floatRO){try{this.floatRO.disconnect()}catch{}this.floatRO=null}},async open(){this.isOpen=!0,this.notifyParentResize("open"),this._launcherRo&&this._launcherRo.disconnect(),this.store||await this.boot(),this.store&&this.store.setPanelOpen(!0);const t=this.currentConv;if(t&&!t._draft){this.activeConvId==null&&(this.activeConvId=t.id);try{await this.store.openConversation(t.id)}catch(n){console.error("[ww-messenger] load messages failed",n)}this.markConvRead(t)}},async close(){this.isOpen=!1,await this.$nextTick(),this.sendCurrentLauncherSize(),this.observeLauncherSize(),this.store&&this.store.setPanelOpen(!1)},notifyParentResize(t,n){if(window.parent&&window.parent!==window)try{window.parent.postMessage({type:"RESIZE",state:t,displayMode:this.displayMode,...n||{}},"*")}catch(r){console.warn("[ww-messenger] notifyParentResize failed",r)}},onLauncherHover(t){this.launcherHovered=t,this.sendCurrentLauncherSize()},sendCurrentLauncherSize(){var g,E,S,k,x,w,V;if(this.isOpen)return;const t=(E=(g=this.$el)==null?void 0:g.querySelector)==null?void 0:E.call(g,".wm-launcherWrap");if(!t)return;const n=t.getBoundingClientRect();if(!n.width||!n.height)return;const r=(((S=this.launcherPeeks)==null?void 0:S.length)??0)>0,s=16,a=Math.ceil(n.width),o=Math.ceil(n.height),i=(x=(k=this.$el)==null?void 0:k.querySelector)==null?void 0:x.call(k,".wm-launcher"),l=(V=(w=this.$el)==null?void 0:w.querySelectorAll)==null?void 0:V.call(w,".wm-peek"),p=l&&l.length?l[l.length-1]:null;let v=null;if(p){const B=p.getBoundingClientRect();v={width:Math.ceil(B.width),height:Math.ceil(B.height),rightOffset:Math.max(0,Math.ceil(n.right-B.right)),bottomOffset:Math.max(0,Math.ceil(n.bottom-B.bottom))}}this.notifyParentResize("closed",{width:a+s,height:o+s,launcherWidth:(i==null?void 0:i.offsetWidth)||null,launcherHeight:(i==null?void 0:i.offsetHeight)||null,launcherHovered:this.launcherHovered,peek:v,peekHovered:this.launcherHovered&&r})},observeLauncherSize(){var r,s;if(typeof ResizeObserver>"u")return;const t=(s=(r=this.$el)==null?void 0:r.querySelector)==null?void 0:s.call(r,".wm-launcherWrap");if(!t)return;this._launcherRo&&this._launcherRo.disconnect();const n=new ResizeObserver(()=>{this.isOpen||this.sendCurrentLauncherSize()});n.observe(t),this._launcherRo=n},async openFromPeek(t){var r,s;const n=t||((r=this.latestUnreads[0])==null?void 0:r.convId);n&&n!==((s=this.currentConv)==null?void 0:s.id)&&(this.draftConv=null,this.activeConvId=n,this.showOnboarding=!1),await this.open()},dismissPeek(t){const n=this.latestUnreads.find(r=>r.convId===t);n&&(this.dismissedPeeks={...this.dismissedPeeks,[t]:n.ts})},startConv(){this.draftConv={id:"__draft__",_draft:!0,name:"",created_at:new Date().toISOString()},this.activeConvId=null,this.showOnboarding=!1,this.focusComposer()},async ensureRealConv(){const t=this.currentConv;if(!t)return null;if(!t._draft)return t;if(this.busy)return null;this.busy=!0;try{const n=await this.store.createConversation({});return this.draftConv=null,this.activeConvId=n.id,await this.store.openConversation(n.id),this.markConvRead(n),n}catch(n){return console.error("[ww-messenger] create conv failed",n),this.bootError=(n==null?void 0:n.message)||String(n),null}finally{this.busy=!1}},focusComposer(){this.$nextTick(()=>{var t;return(t=this.$refs.composer)==null?void 0:t.focus()})},toggleMore(){this.moreOpen=!this.moreOpen},goHome(){this.moreOpen=!1,this.draftConv=null,this.activeConvId=null,this.showOnboarding=!0},async onDrawerPick(t){if(!(t!=null&&t.id)||!this.store)return;this.draftConv=null,this.activeConvId=t.id,this.showOnboarding=!1;try{await this.store.openConversation(t.id)}catch(r){console.error("[ww-messenger] open conv failed",r)}const n=this.allConversations.find(r=>r.id===t.id);n&&this.markConvRead(n)},async onMoreAction(t){var n,r;switch(this.moreOpen=!1,t){case"rename":this.openRenameDialog();break;case"export":it(this.currentConv,this.currentConv?(r=(n=this.s)==null?void 0:n.messagesByConv)==null?void 0:r[this.currentConv.id]:[],this.translator,this.locale);break;case"status":if(this.statusUrl)try{window.open(this.statusUrl,"_blank","noopener")}catch{}break;case"help":if(this.helpUrl)try{window.open(this.helpUrl,"_blank","noopener")}catch{}break}},openRenameDialog(){const t=this.currentConv;!t||t._draft||(this.renameDialogOpen=!0)},async onRenameSubmit(t){const n=this.currentConv;if(this.renameDialogOpen=!1,!n||n._draft||!this.store)return;const r=(t||"").trim();if(!(!r||r===n.name))try{await this.store.patchConversation(n.id,{name:r})}catch(s){console.error("[ww-messenger] rename failed",s)}},async onSend(t){let n=this.currentConv;if(!n&&(this.startConv(),n=this.currentConv,!n)||n._draft&&(n=await this.ensureRealConv(),!n))return;const r=n.id,s=this.pendingAttachments.slice();this.pendingAttachments=[],this.unreadAnchorId=null,this.unreadBoundaryTs="",await this.store.send(r,t,{attachments:s.length?s:void 0})},async onSuggestion(t){const n=t==null?void 0:t.label;n&&await this.onSend(n)},async onLoadMore(){var n;const t=(n=this.currentConv)==null?void 0:n.id;!t||!this.store||await this.store.loadMore(t)},async onApprovalCallback(t){const n=this.pendingApproval;n&&await this.store.clickCallback(n.id,t)},async onFormSubmit({values:t}){const n=this.pendingForm;if(!(n!=null&&n.form))return;const r=nt(n.form,t,this.translator);if(!r)return;let s=this.currentConv;s&&(s._draft&&(s=await this.ensureRealConv(),!s)||await this.store.send(s.id,r,{metadata:{artifact:rt(n.form,t,this.translator)}}))},async onAttach(t){if(!(!t||!this.transport))try{const n=await this.transport.uploadAttachment(t);this.pendingAttachments.push({type:n.type||"file",path:n.path,name:t.name||this.t("attachment.fileFallbackName"),mime_type:t.type,size_bytes:t.size})}catch(n){console.error("[ww-messenger] attachment upload failed",n)}},onPanelClick(t){const n=t.target&&t.target.closest?t.target.closest('a[href^="#"]'):null;n&&(t.preventDefault(),this.openInternalUrl(n.getAttribute("href")))},async openInternalUrl(t){if(typeof t!="string"||!t.startsWith("#"))return!1;const n=t.slice(1);if(n==="new"||n==="new-conversation")return this.isOpen||await this.open(),this.startConv(),!0;if(n.startsWith("conversation/")){const r=n.slice(13);return r&&await this.openFromPeek(r),!0}return console.warn("[messenger] unknown internal url",t),!0},async onQuickLink(t){if(t){if(t.url){if(await this.openInternalUrl(t.url))return;try{window.open(t.url,"_blank","noopener")}catch{}return}this.currentConv||this.startConv(),await this.onSend(t.label)}},async onFeedback({rating:t,comment:n}){if(this.currentConv){this.feedbackBusy=!0;try{await this.store.submitFeedback(this.currentConv.id,{rating:t,comment:n}),this.feedbackDone=!0}catch(r){console.error("[ww-messenger] feedback failed",r)}finally{this.feedbackBusy=!1}}}}},Cs={key:0,class:"wm-loading","aria-busy":"true","aria-live":"polite"},Bs=["aria-label"],Ns={key:0,class:"wm-state"},Ss={class:"wm-state__err"},As={class:"wm-state__errTitle"},Vs={class:"wm-state__errSub"},Ms={class:"wm-bottom"},Ts={key:0,ref:"floatEl",class:"wm-float"},xs={key:1,class:"wm-actionWait",role:"status","aria-live":"polite"},Ls={class:"wm-actionWait__lbl"},Os={key:2,class:"wm-attached"},Ds=["aria-label","onClick"];function Is(t,n,r,s,a,o){const i=e.resolveComponent("Launcher"),l=e.resolveComponent("Header"),p=e.resolveComponent("Onboarding"),v=e.resolveComponent("MessageList"),g=e.resolveComponent("ApprovalCard"),E=e.resolveComponent("FormCard"),S=e.resolveComponent("Feedback"),k=e.resolveComponent("SuggestionChips"),x=e.resolveComponent("Composer"),w=e.resolveComponent("MoreMenu"),V=e.resolveComponent("RenameDialog");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-root",`wm-root--${r.displayMode}`]),style:e.normalizeStyle(o.rootStyle)},[!a.isOpen&&!o.isEmbedded?(e.openBlock(),e.createBlock(i,{key:0,"unread-count":o.unreadCount,peeks:o.launcherPeeks,onOpen:o.openFromPeek,onDismiss:o.dismissPeek,onHover:o.onLauncherHover},null,8,["unread-count","peeks","onOpen","onDismiss","onHover"])):e.createCommentVNode("",!0),a.isOpen||o.isEmbedded?(e.openBlock(),e.createElementBlock("section",{key:1,class:e.normalizeClass(["wm-panel",`wm-panel--${r.displayMode}`,{"wm-panel--welcome":o.ready&&!o.error&&!o.currentConv}]),style:e.normalizeStyle(a.floatHeight?{"--wm-float-h":a.floatHeight+"px"}:null),role:"dialog","aria-label":"Messenger",onClick:n[5]||(n[5]=(...B)=>o.onPanelClick&&o.onPanelClick(...B))},[!o.ready&&!o.error?(e.openBlock(),e.createElementBlock("div",Cs,[o.isEmbedded?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-loading__close","aria-label":o.t("loading.minimize"),onClick:n[0]||(n[0]=(...B)=>o.close&&o.close(...B))},[...n[6]||(n[6]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,Bs)),n[7]||(n[7]=e.createElementVNode("div",{class:"wm-loading__spinner","aria-hidden":"true"},null,-1))])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(l,{title:o.headerTitle,"team-members":o.teamMembers,"response-label":o.responseLabel,"show-identity":!!o.currentConv,"show-back":o.canBack,"show-close":!o.isEmbedded,"more-active":a.moreOpen,"agent-name":o.agentName,"agent-avatar-url":o.agentAvatarUrl,onBack:o.goHome,onMore:o.toggleMore,onClose:o.close},null,8,["title","team-members","response-label","show-identity","show-back","show-close","more-active","agent-name","agent-avatar-url","onBack","onMore","onClose"]),o.error?(e.openBlock(),e.createElementBlock("div",Ns,[e.createElementVNode("div",Ss,[n[8]||(n[8]=e.createElementVNode("div",{class:"wm-state__errIcon"},[e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})])],-1)),e.createElementVNode("div",null,[e.createElementVNode("div",As,e.toDisplayString(o.t("error.connectionFailed")),1),e.createElementVNode("div",Vs,e.toDisplayString(o.error),1)])])])):o.currentConv?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createVNode(v,{ref:"messageList",messages:o.displayedMessages,"streaming-active":o.streamingActive,"date-label":o.dateLabel,"conversation-id":o.currentConv?o.currentConv.id:null,"loading-more":o.paginationState.loading,"has-more":o.paginationState.hasMore,"unread-anchor-id":t.unreadAnchorId,"unread-boundary-ts":t.unreadBoundaryTs,"ai-agent-name":o.agentName,"ai-agent-avatar-url":o.agentAvatarUrl,onLoadMore:o.onLoadMore},null,8,["messages","streaming-active","date-label","conversation-id","loading-more","has-more","unread-anchor-id","unread-boundary-ts","ai-agent-name","ai-agent-avatar-url","onLoadMore"]),e.createElementVNode("div",Ms,[o.floatVisible?(e.openBlock(),e.createElementBlock("div",Ts,[o.approvalReady?(e.openBlock(),e.createBlock(g,{key:0,action:o.approvalTitle,detail:o.approvalDetail,callbacks:o.pendingApproval.callbacks,"agent-name":o.agentName,"agent-avatar-url":o.agentAvatarUrl,onCallback:o.onApprovalCallback},null,8,["action","detail","callbacks","agent-name","agent-avatar-url","onCallback"])):o.pendingForm?(e.openBlock(),e.createBlock(E,{key:o.pendingForm.message&&o.pendingForm.message.id,form:o.pendingForm.form,"agent-name":o.agentName,"agent-avatar-url":o.agentAvatarUrl,onSubmit:o.onFormSubmit},null,8,["form","agent-name","agent-avatar-url","onSubmit"])):o.showFeedback?(e.openBlock(),e.createBlock(S,{key:2,busy:a.feedbackBusy,done:a.feedbackDone,onSubmit:o.onFeedback},null,8,["busy","done","onSubmit"])):(e.openBlock(),e.createBlock(k,{key:3,items:o.suggestions,onSelect:o.onSuggestion},null,8,["items","onSelect"]))],512)):e.createCommentVNode("",!0),o.actionInFlight?(e.openBlock(),e.createElementBlock("div",xs,[n[9]||(n[9]=e.createElementVNode("span",{class:"wm-actionWait__spinner","aria-hidden":"true"},null,-1)),e.createElementVNode("span",Ls,e.toDisplayString(o.t("action.inProgress",{name:o.actionInFlightName})),1)])):(e.openBlock(),e.createBlock(x,{key:2,ref:"composer",modelValue:a.draft,"onUpdate:modelValue":n[1]||(n[1]=B=>a.draft=B),placeholder:o.composerPlaceholder,disabled:!!o.pendingApproval,"attach-label":o.t("composer.attachFile"),"display-mode":r.displayMode,onSend:o.onSend,onAttach:o.onAttach},null,8,["modelValue","placeholder","disabled","attach-label","display-mode","onSend","onAttach"]))]),a.moreOpen?(e.openBlock(),e.createBlock(w,{key:0,"can-rename":!!o.currentConv&&!o.currentConv._draft,"can-export":!!o.currentConv&&!o.currentConv._draft,"sound-enabled":t.soundEnabled,"browser-notif-enabled":t.browserNotifEnabled,"status-url":o.statusUrl,"help-url":o.helpUrl,onClose:n[2]||(n[2]=B=>a.moreOpen=!1),onSoundToggle:t.onSoundToggle,onBrowserNotifToggle:t.onBrowserNotifToggle,onAction:o.onMoreAction},null,8,["can-rename","can-export","sound-enabled","browser-notif-enabled","status-url","help-url","onSoundToggle","onBrowserNotifToggle","onAction"])):e.createCommentVNode("",!0),a.renameDialogOpen&&o.currentConv&&!o.currentConv._draft?(e.openBlock(),e.createBlock(V,{key:1,"initial-value":o.currentConv.name||"",title:o.t("rename.dialogTitle"),onClose:n[3]||(n[3]=B=>a.renameDialogOpen=!1),onSubmit:o.onRenameSubmit},null,8,["initial-value","title","onSubmit"])):e.createCommentVNode("",!0),a.pendingAttachments.length?(e.openBlock(),e.createElementBlock("div",Os,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.pendingAttachments,(B,L)=>(e.openBlock(),e.createElementBlock("div",{key:L,class:"wm-attached__chip"},[n[11]||(n[11]=e.createElementVNode("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"})],-1)),e.createElementVNode("span",null,e.toDisplayString(B.name),1),e.createElementVNode("button",{type:"button","aria-label":o.t("attachment.remove"),onClick:I=>a.pendingAttachments.splice(L,1)},[...n[10]||(n[10]=[e.createElementVNode("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,Ds)]))),128))])):e.createCommentVNode("",!0)],64)):(e.openBlock(),e.createBlock(p,{key:1,"welcome-message":o.widgetWelcomeMessage,subtitle:o.widgetSubtitle,"agent-name":o.agentName,"default-icon-url":o.defaultIconUrl,"quick-links":o.quickLinks,"open-threads":o.openThreads,busy:a.busy,onStart:o.startConv,onSelect:o.onQuickLink,onResume:o.onDrawerPick},null,8,["welcome-message","subtitle","agent-name","default-icon-url","quick-links","open-threads","busy","onStart","onSelect","onResume"])),a.moreOpen&&!o.currentConv?(e.openBlock(),e.createBlock(w,{key:3,"can-rename":!1,"can-export":!1,"sound-enabled":t.soundEnabled,"browser-notif-enabled":t.browserNotifEnabled,"status-url":o.statusUrl,"help-url":o.helpUrl,onClose:n[4]||(n[4]=B=>a.moreOpen=!1),onSoundToggle:t.onSoundToggle,onBrowserNotifToggle:t.onBrowserNotifToggle,onAction:o.onMoreAction},null,8,["sound-enabled","browser-notif-enabled","status-url","help-url","onSoundToggle","onBrowserNotifToggle","onAction"])):e.createCommentVNode("",!0)],64))],6)):e.createCommentVNode("",!0)],6)}const Ge=A(Es,[["render",Is],["__scopeId","data-v-0d59093c"]]),Rs="0.5.42";exports.AIAvatar=$;exports.AVATAR_COLORS=X;exports.ActionResult=Ve;exports.ApprovalCard=qe;exports.ArtifactFormResponse=Me;exports.ArtifactInfoCard=Te;exports.ArtifactRenderer=Le;exports.ArtifactTicket=xe;exports.AttachmentPreview=Oe;exports.Bubble=De;exports.Composer=je;exports.DEFAULT_BASE_URL=ye;exports.DEFAULT_LANGUAGE=K;exports.Feedback=$e;exports.FormCard=Ke;exports.Header=Ce;exports.HumanAvatar=re;exports.Launcher=be;exports.MEDIA_RECORDER_SUPPORTED=oe;exports.MessageList=Re;exports.Messenger=Ge;exports.MoreMenu=We;exports.Onboarding=Ae;exports.SCREEN_CAPTURE_SUPPORTED=Y;exports.SUPPORTED_LANGUAGES=ke;exports.SuggestionChips=He;exports.TeamAvatars=Ee;exports.Typing=Ie;exports.VERSION=Rs;exports.avatarColor=ee;exports.avatarInitials=te;exports.captureScreenshotFile=Ue;exports.colors=T;exports.createStore=_e;exports.createTranslator=M;exports.createTransport=ge;exports.dateLocale=P;exports.default=Ge;exports.formatTime=Z;exports.guessAttachmentKind=Fo;exports.pickRecorderMime=Fe;exports.renderInlineMarkdown=Ne;exports.renderMarkdown=Se;exports.resolveLanguage=ne;exports.startScreenRecording=ze;exports.tokensCss=ve;exports.uuid=le;exports.v4=le;
53
+ `)}function ot(t,n,r=M()){const s=[],a=Array.isArray(t==null?void 0:t.fields)?t.fields:[];for(const o of a){if(!(o!=null&&o.key)||!(o!=null&&o.label))continue;const i=n==null?void 0:n[o.key];if(i==null||i==="")continue;const l=Ee(o,i,r);if(!l)continue;const f=o.type==="textarea"||typeof l=="string"&&(l.length>60||l.includes(`
54
+ `));s.push({label:o.label,value:l,multiline:f})}return{kind:"form_response",data:{title:(t==null?void 0:t.title)||r("form.title"),fields:s}}}function J(t){var r;const n=(r=t==null?void 0:t.author)==null?void 0:r.type;return n==="agent_ia"||n==="agent_human"}function I(t){if(t==null)return null;const n=typeof t=="number"?t:Number(t);return Number.isFinite(n)?n:null}function he(t,n){let r=(t==null?void 0:t.last_message_at)||(t==null?void 0:t.updated_at)||(t==null?void 0:t.created_at)||"";for(const s of n)s!=null&&s.created_at&&s.created_at>r&&(r=s.created_at);return r}function at(t,n){var r,s,a;for(let o=n.length-1;o>=0;o--){const i=n[o];if(!i)continue;const l=typeof i.text_md=="string"?i.text_md.trim():"";if(l)return(((r=i.author)==null?void 0:r.type)==="user"?"Vous : ":"")+l.replace(/\s+/g," ");const f=(s=i.payload)==null?void 0:s.attachments;if(Array.isArray(f)&&f.length)return"📎 Pièce jointe"}return(t==null?void 0:t.last_message_preview)||(t==null?void 0:t.preview)||((a=t==null?void 0:t.metadata)==null?void 0:a.last_preview)||""}function st(t,n){return(t==null?void 0:t.name)||((t==null?void 0:t.type)==="user"?n("common.you"):(t==null?void 0:t.type)==="agent_human"?n("common.agent"):(t==null?void 0:t.type)==="agent_ia"?n("common.aiAssistant"):n("common.system"))}function it(t,n,r,s){const a=[`# ${t.name||r("common.conversation")}`,t.created_at?r("export.createdOn",{date:new Date(t.created_at).toLocaleString(s)}):"",""];for(const o of n){if(!o)continue;const i=(o.text_md||"").trim();if(!i)continue;const l=st(o.author,r),f=o.created_at?new Date(o.created_at).toLocaleString(s):"";a.push(`[${f}] ${l} :`),a.push(i),a.push("")}return a.join(`
55
+ `)}function lt(t,n,r=M(),s){if(!t)return;const a=it(t,n||[],r,z(s)),o=new Blob([a],{type:"text/plain;charset=utf-8"});try{const i=URL.createObjectURL(o),l=document.createElement("a");l.href=i,l.download=`${(t.name||"conversation").replace(/[^a-z0-9-_]+/gi,"_")}.txt`,document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>URL.revokeObjectURL(i),1e3)}catch(i){console.error("[ww-messenger] export failed",i)}}const ct={data(){const t=typeof Notification<"u";return{notifPermission:t?Notification.permission:"denied",soundEnabled:!0,browserNotifEnabled:t&&Notification.permission==="granted",_audioCtx:null}},methods:{teardownNotifications(){var t,n;if(this._audioCtx){try{(n=(t=this._audioCtx).close)==null||n.call(t)}catch{}this._audioCtx=null}},soundStorageKey(){return`wm:notif:sound:${this.widgetId||""}`},browserNotifStorageKey(){return`wm:notif:browser:${this.widgetId||""}`},hydrateNotifPref(){try{if(typeof localStorage>"u")return;const t=localStorage.getItem(this.soundStorageKey());t==="0"?this.soundEnabled=!1:t==="1"&&(this.soundEnabled=!0);const n=localStorage.getItem(this.browserNotifStorageKey());n==="0"?this.browserNotifEnabled=!1:n==="1"&&(this.browserNotifEnabled=typeof Notification<"u"&&Notification.permission==="granted")}catch{}},persistSoundPref(){try{if(typeof localStorage>"u")return;localStorage.setItem(this.soundStorageKey(),this.soundEnabled?"1":"0")}catch{}},persistBrowserNotifPref(){try{if(typeof localStorage>"u")return;localStorage.setItem(this.browserNotifStorageKey(),this.browserNotifEnabled?"1":"0")}catch{}},onSoundToggle(t){this.soundEnabled=!!t,this.persistSoundPref()},async onBrowserNotifToggle(t){if(typeof Notification>"u"){this.browserNotifEnabled=!1,this.persistBrowserNotifPref();return}if(!t){this.browserNotifEnabled=!1,this.persistBrowserNotifPref();return}let n=Notification.permission;if(n==="default"){try{n=await Notification.requestPermission()}catch(r){console.warn("[ww-messenger] notif permission request failed",r),n="denied"}this.notifPermission=n}this.browserNotifEnabled=n==="granted",this.persistBrowserNotifPref()},onMessageRevealed(t,n){var a;if(!this.soundEnabled&&!this.browserNotifEnabled||!n||!t||!J(t))return;const r=typeof document<"u"&&document.hidden;this.isOpen&&!r&&((a=this.currentConv)==null?void 0:a.id)===n||(this.soundEnabled&&this.playNotificationSound(),this.browserNotifEnabled&&this.showBrowserNotification(n,t))},playNotificationSound(){if(typeof window>"u")return;const t=window.AudioContext||window.webkitAudioContext;if(t)try{this._audioCtx||(this._audioCtx=new t);const n=this._audioCtx;if(n.state==="suspended")try{n.resume()}catch{}const r=n.currentTime,s=n.createOscillator(),a=n.createGain();s.connect(a),a.connect(n.destination),s.type="sine",s.frequency.setValueAtTime(880,r),s.frequency.exponentialRampToValueAtTime(1320,r+.08),a.gain.setValueAtTime(0,r),a.gain.linearRampToValueAtTime(.12,r+.02),a.gain.exponentialRampToValueAtTime(1e-4,r+.28),s.start(r),s.stop(r+.32)}catch{}},showBrowserNotification(t,n){if(typeof Notification>"u"||Notification.permission!=="granted")return;const r=n==null?void 0:n.author,s=!r||r.type==="agent_ia",o=((r==null?void 0:r.name)||(s?this.agentName:"")||this.t("launcher.theAgent"))+this.t("launcher.repliedToYou"),i=typeof(n==null?void 0:n.text_md)=="string"?n.text_md.trim():"",l=i?i.slice(0,140):this.t("notification.youHaveNewMessage");try{const f=new Notification(o,{body:l,tag:`wm-${t}`,renotify:!1,silent:!0});f.onclick=()=>{try{window.focus()}catch{}this.draftConv=null,this.showOnboarding=!1,this.activeConvId=t,this.isOpen=!0,this.store&&this.store.setPanelOpen(!0);try{f.close()}catch{}}}catch(f){console.warn("[ww-messenger] notification failed",f)}}}},dt=450,ut=50,mt=900,ht=12e3,ft=300,pt={data(){return{revealedAt:{},nextRevealAt:0,revealTimers:[],_liveRevealOff:null,_liveRevealConvSnapshot:null}},methods:{cancelReveals(){for(const t of this.revealTimers)clearTimeout(t);this.revealTimers=[]},resetRevealQueue(){this.cancelReveals(),this.revealedAt={},this.nextRevealAt=0},setupLiveReveal(){var r;if(!this.transport)return;this.teardownLiveReveal();const t=this.transport.on("message",s=>{const a=s==null?void 0:s.conversation_id,o=s==null?void 0:s.message;a&&o&&this.paceLiveMessage(o,a)});this._liveRevealConvSnapshot=new Map((((r=this.s)==null?void 0:r.conversations)||[]).map(s=>[s.id,(s==null?void 0:s.last_message_at)||""]));const n=this.transport.on("activity",s=>{this.handleLiveActivity(s)});this._liveRevealOff=()=>{try{t()}catch{}try{n()}catch{}}},teardownLiveReveal(){if(this._liveRevealOff){try{this._liveRevealOff()}catch{}this._liveRevealOff=null}this._liveRevealConvSnapshot=null},async handleLiveActivity(t){var a,o;const n=t==null?void 0:t.conversations;if(!Array.isArray(n)||!this.store)return;const r=this._liveRevealConvSnapshot||new Map,s=[];for(const i of n){if(!(i!=null&&i.id))continue;const l=i.last_message_at||"";if(!l)continue;const f=r.get(i.id)||"";l>f&&s.push(i.id)}this._liveRevealConvSnapshot=new Map(n.map(i=>[i.id,(i==null?void 0:i.last_message_at)||""]));for(const i of s)try{const l=await((o=(a=this.store).fetchSinceLast)==null?void 0:o.call(a,i));if(!Array.isArray(l))continue;for(const f of l)this.paceLiveMessage(f,i)}catch(l){console.error("[ww-messenger] activity delta fetch failed",l)}},scheduleReveal(t,n){const r=Date.now(),s=((t==null?void 0:t.text_md)||"").length,a=Math.min(ht,Math.max(mt,s*ut)),i=Math.max(r+dt,this.nextRevealAt+ft)+a;this.nextRevealAt=i;const l=Math.max(0,i-r),f=t.id,y=setTimeout(()=>{this.revealedAt={...this.revealedAt,[f]:Date.now()},this.revealTimers=this.revealTimers.filter(_=>_!==y),typeof this.onMessageRevealed=="function"&&this.onMessageRevealed(t,n)},l);this.revealTimers.push(y)},paceMessages(t,n){var a;if(!Array.isArray(t)||!t.length)return;const r=Date.now(),s={...this.revealedAt};for(const o of t){if((o==null?void 0:o.id)==null||s[o.id]!==void 0)continue;if(!J(o)){s[o.id]=r;continue}const i=o!=null&&o.created_at?Date.parse(o.created_at):NaN;if(!Number.isFinite(i)||i<this.convOpenedAt){s[o.id]=r;continue}const l=typeof(o==null?void 0:o.text_md)=="string"&&o.text_md.trim().length>0,f=Array.isArray((a=o==null?void 0:o.payload)==null?void 0:a.attachments)&&o.payload.attachments.length>0;if(!l&&!f){s[o.id]=r;continue}s[o.id]=0,this.scheduleReveal(o,n)}this.revealedAt=s},paceLiveMessage(t,n){var a;if(!(t!=null&&t.id)||this.revealedAt[t.id]!==void 0)return;if(!J(t)){this.revealedAt={...this.revealedAt,[t.id]:Date.now()};return}const r=typeof(t==null?void 0:t.text_md)=="string"&&t.text_md.trim().length>0,s=Array.isArray((a=t==null?void 0:t.payload)==null?void 0:a.attachments)&&t.payload.attachments.length>0;if(!r&&!s){this.revealedAt={...this.revealedAt,[t.id]:Date.now()};return}this.revealedAt={...this.revealedAt,[t.id]:0},this.scheduleReveal(t,n)}}},gt={data(){return{approvalSettled:!0,approvalSettleTimer:null,approvalLatchId:null}},methods:{resetApprovalPacing(){this.approvalSettleTimer&&(clearTimeout(this.approvalSettleTimer),this.approvalSettleTimer=null),this.approvalSettled=!0,this.approvalLatchId=null},bumpApprovalSettle(t=800){this.approvalSettled=!1,this.approvalSettleTimer&&clearTimeout(this.approvalSettleTimer),this.approvalSettleTimer=setTimeout(()=>{this.approvalSettled=!0,this.approvalSettleTimer=null},t)}}},_t=300,yt={data(){return{unreadAnchorId:null,unreadBoundaryTs:""}},created(){this._readMarkerTimer=null,this._readMarkerPending=null},beforeUnmount(){this._readMarkerTimer&&(clearTimeout(this._readMarkerTimer),this._readMarkerTimer=null),this._readMarkerPending=null},methods:{markConvRead(t){var o,i;if(!(t!=null&&t.id)||t._draft||!this.store)return;const n=((i=(o=this.s)==null?void 0:o.messagesByConv)==null?void 0:i[t.id])||[],r=vt(n);if(r==null)return;const s=I(t.last_read_message_id),a=I(r);a!=null&&(s!=null&&a<=s||(this._readMarkerPending={convId:t.id,messageId:r},!this._readMarkerTimer&&(this._readMarkerTimer=setTimeout(()=>{const l=this._readMarkerPending;this._readMarkerPending=null,this._readMarkerTimer=null,l&&this.store&&this.store.markConversationRead(l.convId,l.messageId)},_t))))}}};function vt(t){for(let n=t.length-1;n>=0;n--){const r=t[n];if(!(!r||r._pending)&&I(r.id)!=null)return r.id}return null}const A=(t,n)=>{const r=t.__vccOpts||t;for(const[s,a]of n)r[s]=a;return r},kt={name:"WmHumanAvatar",props:{name:{type:String,default:""},avatarUrl:{type:String,default:null},size:{type:Number,default:26},tail:{type:Boolean,default:!1}},computed:{bg(){return this.avatarUrl?"transparent":ne(this.name)},initials(){return re(this.name)}}},wt=["src","alt"];function bt(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-huav",{"wm-huav--tail":r.tail}]),style:e.normalizeStyle({width:r.size+"px",height:r.size+"px","--wm-avr":Math.round(r.size*.32)+"px",background:o.bg})},[r.avatarUrl?(e.openBlock(),e.createElementBlock("img",{key:0,src:r.avatarUrl,alt:r.name||""},null,8,wt)):(e.openBlock(),e.createElementBlock("span",{key:1,style:e.normalizeStyle({fontSize:r.size*.36+"px"})},e.toDisplayString(o.initials),5))],6)}const ae=A(kt,[["render",bt],["__scopeId","data-v-14e10c0d"]]),Et=3,Ct={name:"WmLauncher",components:{HumanAvatar:ae},inject:{t:{default:()=>M()}},props:{unreadCount:{type:Number,default:0},peeks:{type:Array,default:()=>[]}},emits:["open","dismiss"],computed:{visiblePeeks(){return this.peeks.slice(0,Et).reverse()}}},Bt=["aria-label","onClick","onKeydown"],Nt=["aria-label","onClick"],St={class:"wm-peek__avatar"},At=["aria-label"],Vt={class:"wm-peek__body"},Mt={class:"wm-peek__head"},Tt={class:"wm-peek__name"},xt={class:"wm-peek__action"},Ot={class:"wm-peek__text"},Lt=["onClick"],Dt=["aria-label"],It=["aria-label"];function Rt(t,n,r,s,a,o){const i=e.resolveComponent("HumanAvatar");return e.openBlock(),e.createElementBlock("div",{class:"wm-launcherWrap",onMouseenter:n[1]||(n[1]=l=>t.$emit("hover",!0)),onMouseleave:n[2]||(n[2]=l=>t.$emit("hover",!1)),onFocusin:n[3]||(n[3]=l=>t.$emit("hover",!0)),onFocusout:n[4]||(n[4]=l=>t.$emit("hover",!1))},[e.createVNode(e.Transition,{name:"wm-peek"},{default:e.withCtx(()=>[o.visiblePeeks.length?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["wm-peekStack",{"wm-peekStack--multi":o.visiblePeeks.length>1}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.visiblePeeks,(l,f)=>(e.openBlock(),e.createElementBlock("div",{key:l.convId,class:"wm-peek",style:e.normalizeStyle({"--depth":o.visiblePeeks.length-1-f,zIndex:f+1}),role:"button",tabindex:"0","aria-label":o.t("launcher.openConversationWith",{name:l.senderName||o.t("launcher.theAgent")}),onClick:y=>t.$emit("open",l.convId),onKeydown:[e.withKeys(e.withModifiers(y=>t.$emit("open",l.convId),["prevent"]),["enter"]),e.withKeys(e.withModifiers(y=>t.$emit("open",l.convId),["prevent"]),["space"])]},[e.createElementVNode("button",{type:"button",class:"wm-peek__close","aria-label":o.t("launcher.dismiss"),onClick:e.withModifiers(y=>t.$emit("dismiss",l.convId),["stop"])},[...n[5]||(n[5]=[e.createElementVNode("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,Nt),e.createElementVNode("div",St,[e.createVNode(i,{name:l.senderName,"avatar-url":l.senderAvatarUrl,size:34},null,8,["name","avatar-url"]),l.count>1?(e.openBlock(),e.createElementBlock("span",{key:0,class:"wm-peek__avatarBadge","aria-label":o.t("launcher.unreadMessages",{count:l.count})},e.toDisplayString(l.count>9?"9+":l.count),9,At)):e.createCommentVNode("",!0)]),e.createElementVNode("div",Vt,[e.createElementVNode("div",Mt,[e.createElementVNode("span",Tt,e.toDisplayString(l.senderName||o.t("common.agent")),1),e.createElementVNode("span",xt,e.toDisplayString(o.t("launcher.repliedToYou")),1)]),e.createElementVNode("p",Ot,e.toDisplayString(l.preview),1)]),e.createElementVNode("button",{type:"button",class:"wm-peek__open",onClick:e.withModifiers(y=>t.$emit("open",l.convId),["stop"])},e.toDisplayString(o.t("common.open")),9,Lt)],44,Bt))),128))],2)):e.createCommentVNode("",!0)]),_:1}),e.createElementVNode("button",{type:"button",class:"wm-launcher","aria-label":o.t("launcher.open"),onClick:n[0]||(n[0]=l=>t.$emit("open"))},[n[6]||(n[6]=e.createElementVNode("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.7","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})],-1)),r.unreadCount>0?(e.openBlock(),e.createElementBlock("span",{key:0,class:"wm-launcher__badge","aria-label":r.unreadCount>1?o.t("launcher.unreadConversationsMany",{count:r.unreadCount}):o.t("launcher.unreadConversationsOne",{count:r.unreadCount})},e.toDisplayString(r.unreadCount>9?"9+":r.unreadCount),9,It)):e.createCommentVNode("",!0)],8,Dt)],32)}const Ce=A(Ct,[["render",Rt],["__scopeId","data-v-44ddf1a1"]]),Ft={name:"WmAIAvatar",props:{size:{type:Number,default:26},pulse:{type:Boolean,default:!1},tail:{type:Boolean,default:!1},name:{type:String,default:""},imageUrl:{type:String,default:null}},computed:{initials(){return re(this.name)},bgColor(){return ne(this.name)}}},Pt={key:0,class:"wm-aiav__pulse"},Ut=["src","alt"],zt=["width","height"];function jt(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-aiav",{"wm-aiav--tail":r.tail}]),style:e.normalizeStyle({width:r.size+"px",height:r.size+"px","--wm-avr":r.size*.32+"px"})},[r.pulse?(e.openBlock(),e.createElementBlock("div",Pt)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["wm-aiav__inner",{"wm-aiav__inner--glow":r.pulse,"wm-aiav__inner--img":!!r.imageUrl,"wm-aiav__inner--initials":!r.imageUrl&&!!o.initials}]),style:e.normalizeStyle(!r.imageUrl&&o.initials?{background:o.bgColor}:null)},[r.imageUrl?(e.openBlock(),e.createElementBlock("img",{key:0,src:r.imageUrl,alt:r.name||""},null,8,Ut)):o.initials?(e.openBlock(),e.createElementBlock("span",{key:1,style:e.normalizeStyle({fontSize:r.size*.36+"px"})},e.toDisplayString(o.initials),5)):(e.openBlock(),e.createElementBlock("svg",{key:2,width:r.size*.5,height:r.size*.5,viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[...n[0]||(n[0]=[e.createElementVNode("path",{d:"M12 2 L13.5 9 L20 10.5 L13.5 12 L12 19 L10.5 12 L4 10.5 L10.5 9 Z",fill:"white",opacity:"0.92"},null,-1),e.createElementVNode("circle",{cx:"19",cy:"5",r:"1.5",fill:"white",opacity:"0.55"},null,-1),e.createElementVNode("circle",{cx:"5",cy:"18",r:"1",fill:"white",opacity:"0.38"},null,-1)])],8,zt))],6)],6)}const G=A(Ft,[["render",jt],["__scopeId","data-v-6f7f685d"]]),Ht={name:"WmTeamAvatars",props:{members:{type:Array,default:()=>[]},responseLabel:{type:String,default:""}},computed:{visible(){return Array.isArray(this.members)&&this.members.length>0},stackWidth(){return Math.min(this.members.length,3)===1?20:16+Math.min(this.members.length,3)*13}},methods:{colorFor(t){return t.avatar_url?"transparent":ne(t.name||"")},initialsFor(t){return re(t.name||"")}}},qt={key:0,class:"wm-team"},Kt=["src","alt"],$t={key:1},Wt={key:0,class:"wm-team__label"};function Gt(t,n,r,s,a,o){return o.visible?(e.openBlock(),e.createElementBlock("div",qt,[e.createElementVNode("div",{class:"wm-team__stack",style:e.normalizeStyle({width:o.stackWidth+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.members.slice(0,3),(i,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-team__pill",style:e.normalizeStyle({left:l*13+"px",zIndex:3-l,background:o.colorFor(i)})},[i.avatar_url?(e.openBlock(),e.createElementBlock("img",{key:0,src:i.avatar_url,alt:i.name||""},null,8,Kt)):(e.openBlock(),e.createElementBlock("span",$t,e.toDisplayString(o.initialsFor(i)),1))],4))),128))],4),r.responseLabel?(e.openBlock(),e.createElementBlock("span",Wt,e.toDisplayString(r.responseLabel),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}const Be=A(Ht,[["render",Gt],["__scopeId","data-v-e49a9063"]]),Yt={name:"WmHeader",components:{AIAvatar:G,TeamAvatars:Be},inject:{t:{default:()=>M()}},props:{title:{type:String,default:"Nouvelle conversation"},showBack:{type:Boolean,default:!1},teamMembers:{type:Array,default:()=>[]},responseLabel:{type:String,default:""},showClose:{type:Boolean,default:!0},showMore:{type:Boolean,default:!0},moreActive:{type:Boolean,default:!1},showIdentity:{type:Boolean,default:!0},agentName:{type:String,default:""},agentAvatarUrl:{type:String,default:null}},emits:["back","close","more"],computed:{hasTeam(){return Array.isArray(this.teamMembers)&&this.teamMembers.length>0},displayedTeamMembers(){const t=Array.isArray(this.teamMembers)?this.teamMembers:[];if(t.length<=3)return t;const n=new Date().getHours()%t.length,r=[];for(let s=0;s<3;s++)r.push(t[(n+s)%t.length]);return r}}},Jt={class:"wm-header"},Qt=["aria-label"],Xt={key:1,style:{width:"30px",height:"30px","flex-shrink":"0"}},Zt={class:"wm-header__avatar"},en={class:"wm-header__main"},tn={class:"wm-header__title"},nn={key:3,class:"wm-header__fill"},rn={class:"wm-header__actions"},on=["aria-label","title"],an=["aria-label","title"];function sn(t,n,r,s,a,o){const i=e.resolveComponent("AIAvatar"),l=e.resolveComponent("TeamAvatars");return e.openBlock(),e.createElementBlock("div",Jt,[r.showBack?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-header__icon","aria-label":o.t("header.backToHome"),onClick:n[0]||(n[0]=f=>t.$emit("back"))},[...n[3]||(n[3]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M19 12H5M12 5l-7 7 7 7"})],-1)])],8,Qt)):(e.openBlock(),e.createElementBlock("div",Xt)),r.showIdentity?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createElementVNode("div",Zt,[e.createVNode(i,{size:30,name:r.agentName,"image-url":r.agentAvatarUrl},null,8,["name","image-url"])]),e.createElementVNode("div",en,[e.createElementVNode("div",tn,e.toDisplayString(r.title),1)]),o.hasTeam?(e.openBlock(),e.createBlock(l,{key:0,members:o.displayedTeamMembers,"response-label":""},null,8,["members"])):e.createCommentVNode("",!0)],64)):(e.openBlock(),e.createElementBlock("div",nn)),e.createElementVNode("div",rn,[r.showMore?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["wm-header__icon",{"wm-header__icon--active":r.moreActive}]),"aria-label":o.t("header.moreOptions"),title:o.t("header.moreOptions"),onClick:n[1]||(n[1]=f=>t.$emit("more"))},[...n[4]||(n[4]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true"},[e.createElementVNode("circle",{cx:"12",cy:"5",r:"1.6"}),e.createElementVNode("circle",{cx:"12",cy:"12",r:"1.6"}),e.createElementVNode("circle",{cx:"12",cy:"19",r:"1.6"})],-1)])],10,on)):e.createCommentVNode("",!0),r.showClose?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"wm-header__icon","aria-label":o.t("header.closeWidget"),title:o.t("header.closeWidget"),onClick:n[2]||(n[2]=f=>t.$emit("close"))},[...n[5]||(n[5]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,an)):e.createCommentVNode("",!0)])])}const Ne=A(Yt,[["render",sn],["__scopeId","data-v-7af4c118"]]);function Se(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ln(t){return/^(https?:\/\/|mailto:|tel:)/i.test(String(t).trim())}const fe="";function Y(t){let n=t;const r=[];return n=n.replace(/`([^`\n]+)`/g,(s,a)=>{const o=r.length;return r.push(a),`${fe}CODE${o}${fe}`}),n=n.replace(/\[([^\]\n]+)\]\(([^)\s]+)\)/g,(s,a,o)=>ln(o)?`<a href="${o}" target="_blank" rel="noopener noreferrer">${a}</a>`:a),n=n.replace(/\*\*([^\n*][^\n]*?)\*\*/g,"<strong>$1</strong>"),n=n.replace(/__([^\n_][^\n]*?)__/g,"<u>$1</u>"),n=n.replace(/~~([^\n~][^\n]*?)~~/g,"<s>$1</s>"),n=n.replace(/(^|[^\w*])\*([^\n*]+?)\*(?!\w)/g,"$1<em>$2</em>"),n=n.replace(/(^|[^\w_])_([^\n_]+?)_(?!\w)/g,"$1<em>$2</em>"),n=n.replace(/CODE(\d+)/g,(s,a)=>`<code class="wm-md-code">${r[+a]}</code>`),n}function Ae(t){if(!t)return"";const n=String(t).replace(/\[([^\]\n]+)\]\([^)\s]+\)/g,"$1");return Y(Se(n))}function Ve(t){if(!t)return"";const n=Se(t).split(`
56
+ `),r=[];let s=0;for(;s<n.length;){const o=n[s];if(/^\s*```([\w-]*)\s*$/.exec(o)){s++;const y=[];for(;s<n.length&&!/^\s*```\s*$/.test(n[s]);)y.push(n[s]),s++;s<n.length&&s++,r.push({type:"block",html:`<pre class="wm-md-pre"><code>${y.join(`
57
+ `)}</code></pre>`});continue}if(/^\s*[-*]\s+/.test(o)){const y=[];for(;s<n.length;){const C=/^\s*[-*]\s+(.*)$/.exec(n[s]);if(!C)break;y.push(C[1]),s++}const _=y.map(C=>`<li>${Y(C)}</li>`).join("");r.push({type:"block",html:`<ul class="wm-md-ul">${_}</ul>`});continue}const l=/^\s*(\d+)\.\s+(.*)$/.exec(o);if(l){const y=parseInt(l[1],10),_=[l[2]];for(s++;s<n.length;){const k=/^\s*\d+\.\s+(.*)$/.exec(n[s]);if(!k)break;_.push(k[1]),s++}const C=_.map(k=>`<li>${Y(k)}</li>`).join(""),S=y!==1?` start="${y}"`:"";r.push({type:"block",html:`<ol class="wm-md-ol"${S}>${C}</ol>`});continue}const f=/^(#{1,6})\s+(.*)$/.exec(o);if(f){const y=f[1].length;r.push({type:"block",html:`<h${y} class="wm-md-h wm-md-h${y}">${Y(f[2])}</h${y}>`}),s++;continue}r.push({type:"text",html:Y(o)}),s++}let a="";for(let o=0;o<r.length;o++){const i=r[o];a+=i.html;const l=r[o+1];l&&i.type!=="block"&&l.type!=="block"&&(a+=`
58
+ `)}return a}const pe={book:"M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253",changelog:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2",status:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z",chat:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z",link:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"},cn={name:"WmOnboarding",components:{AIAvatar:G,HumanAvatar:ae},inject:{t:{default:()=>M()},wmLocale:{default:()=>()=>"fr"}},props:{welcomeMessage:{type:String,default:""},subtitle:{type:String,default:""},agentName:{type:String,default:""},defaultIconUrl:{type:String,default:null},quickLinks:{type:Array,default:()=>[]},openThreads:{type:Array,default:()=>[]},busy:{type:Boolean,default:!1}},emits:["start","select","resume"],data(){return{query:""}},computed:{heroTitle(){return this.welcomeMessage?this.welcomeMessage:this.agentName?this.t("onboarding.greetingNamed",{name:this.agentName}):this.t("onboarding.greeting")},heroSub(){return this.subtitle||this.t("onboarding.heroSub")},isOddQuickLinks(){return this.quickLinks.length%2===1},quickLinksLayout(){return this.isOddQuickLinks?"wm-onb__qlist":"wm-onb__grid"},filteredThreads(){const t=this.query.trim().toLowerCase();return t?this.openThreads.filter(n=>(n.title||"").toLowerCase().includes(t)||(n.preview||"").toLowerCase().includes(t)):this.openThreads},unreadThreads(){return this.openThreads.filter(t=>t.unread)}},methods:{iconPath(t){return pe[t]||pe.link},isExternalLink(t){const n=t==null?void 0:t.url;return!!n&&!n.startsWith("#")},renderPreview(t){return Ae(t)},avatarComponent(t){var n;return((n=t==null?void 0:t.author)==null?void 0:n.type)==="agent_human"?"HumanAvatar":"AIAvatar"},avatarProps(t){const n=t==null?void 0:t.author;return(n==null?void 0:n.type)==="agent_human"?{size:40,name:n.name||"",avatarUrl:n.avatar_url||null}:{size:40,name:(n==null?void 0:n.name)||"",imageUrl:(n==null?void 0:n.avatar_url)||null}},isDefaultAvatar(t){const n=t==null?void 0:t.author;return!(n!=null&&n.avatar_url||n!=null&&n.name)},avatarWrapperClass(t){return this.isDefaultAvatar(t)&&!(t!=null&&t.unread)?"wm-onb__avatar--muted":null},formatTs(t){if(!t)return"";const n=new Date(t);if(Number.isNaN(n.getTime()))return"";const r=z(this.wmLocale()),s=new Date;if(n.toDateString()===s.toDateString())return n.toLocaleTimeString(r,{hour:"2-digit",minute:"2-digit"});if(s.getTime()-n.getTime()<7*864e5){const i=n.toLocaleDateString(r,{weekday:"short"});return i.charAt(0).toUpperCase()+i.slice(1)}return n.toLocaleDateString(r,{day:"2-digit",month:"2-digit"})}}},dn={class:"wm-onb"},un={class:"wm-onb__hero"},mn={class:"wm-onb__hero-text"},hn={class:"wm-onb__title"},fn={class:"wm-onb__sub"},pn={class:"wm-onb__cta"},gn=["disabled"],_n={class:"wm-onb__startLabel"},yn=["onClick"],vn={class:"wm-onb__card-icon"},kn=["aria-label"],wn={key:1,width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.9","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},bn=["d"],En={class:"wm-onb__card-body"},Cn={class:"wm-onb__card-title"},Bn={key:0,class:"wm-onb__card-sub"},Nn={key:0,class:"wm-onb__card-ext",width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},Sn={key:1,class:"wm-onb__section wm-onb__section--card"},An={class:"wm-onb__section-title"},Vn={class:"wm-onb__alertList"},Mn=["onClick"],Tn={key:0,class:"wm-onb__defaultAvatar"},xn=["aria-label"],On={class:"wm-onb__alert-body"},Ln={class:"wm-onb__alert-title"},Dn=["innerHTML"],In={class:"wm-onb__alert-meta"},Rn={key:0,class:"wm-onb__alert-time"},Fn={class:"wm-onb__alert-resume"},Pn={key:2,class:"wm-onb__section wm-onb__section--card"},Un={class:"wm-onb__section-title"},zn={class:"wm-onb__search"},jn=["placeholder","aria-label"],Hn={class:"wm-onb__list"},qn=["onClick"],Kn={key:0,class:"wm-onb__defaultAvatar"},$n=["aria-label"],Wn={class:"wm-onb__thread-body"},Gn={class:"wm-onb__thread-title"},Yn=["innerHTML"],Jn={class:"wm-onb__thread-meta"},Qn={key:0,class:"wm-onb__thread-time"},Xn={key:0,class:"wm-onb__empty"};function Zn(t,n,r,s,a,o){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",dn,[e.createElementVNode("div",un,[n[2]||(n[2]=e.createElementVNode("svg",{class:"wm-onb__hero-deco",width:"180",height:"180",viewBox:"0 0 180 180",fill:"none","aria-hidden":"true"},[e.createElementVNode("circle",{cx:"170",cy:"10",r:"105",stroke:"#5B5FEF","stroke-width":"1","stroke-dasharray":"1 5",opacity:"0.35"}),e.createElementVNode("circle",{cx:"170",cy:"10",r:"72",stroke:"#5B5FEF","stroke-width":"1","stroke-dasharray":"1 5",opacity:"0.5"}),e.createElementVNode("circle",{cx:"152",cy:"34",r:"2.5",fill:"#5B5FEF",opacity:"0.65"})],-1)),e.createVNode(i,{size:52,"image-url":r.defaultIconUrl},null,8,["image-url"]),e.createElementVNode("div",mn,[e.createElementVNode("div",hn,e.toDisplayString(o.heroTitle),1),e.createElementVNode("div",fn,e.toDisplayString(o.heroSub),1)])]),e.createElementVNode("div",pn,[e.createElementVNode("button",{type:"button",class:"wm-onb__startBtn",disabled:r.busy,onClick:n[0]||(n[0]=l=>t.$emit("start"))},[n[3]||(n[3]=e.createElementVNode("span",{class:"wm-onb__startIcon"},[e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.4","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M12 5v14M5 12h14"})])],-1)),e.createElementVNode("span",_n,e.toDisplayString(r.busy?"…":o.t("onboarding.start")),1),n[4]||(n[4]=e.createElementVNode("svg",{class:"wm-onb__startArrow",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M5 12h14M13 5l7 7-7 7"})],-1))],8,gn)]),r.quickLinks.length?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(o.quickLinksLayout)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.quickLinks,(l,f)=>(e.openBlock(),e.createElementBlock("button",{key:f,type:"button",class:e.normalizeClass(["wm-onb__card",{"wm-onb__card--row":o.isOddQuickLinks}]),style:e.normalizeStyle(l.color?{"--card-color":l.color}:null),onClick:y=>t.$emit("select",l)},[e.createElementVNode("span",vn,[l.icon_url?(e.openBlock(),e.createElementBlock("span",{key:0,class:"wm-onb__card-iconImg",style:e.normalizeStyle({"--icon-url":`url('${l.icon_url}')`}),role:"img","aria-label":l.label||""},null,12,kn)):(e.openBlock(),e.createElementBlock("svg",wn,[e.createElementVNode("path",{d:o.iconPath(l.icon)},null,8,bn)]))]),e.createElementVNode("span",En,[e.createElementVNode("span",Cn,e.toDisplayString(l.label),1),l.subtitle?(e.openBlock(),e.createElementBlock("span",Bn,e.toDisplayString(l.subtitle),1)):e.createCommentVNode("",!0)]),o.isExternalLink(l)?(e.openBlock(),e.createElementBlock("svg",Nn,[...n[5]||(n[5]=[e.createElementVNode("path",{d:"M7 17L17 7M9 7h8v8"},null,-1)])])):e.createCommentVNode("",!0)],14,yn))),128))],2)):e.createCommentVNode("",!0),o.unreadThreads.length?(e.openBlock(),e.createElementBlock("div",Sn,[e.createElementVNode("div",An,e.toDisplayString(o.t("onboarding.unreadConversations")),1),e.createElementVNode("div",Vn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.unreadThreads,l=>(e.openBlock(),e.createElementBlock("button",{key:l.id,type:"button",class:"wm-onb__alert",onClick:f=>t.$emit("resume",l)},[e.createElementVNode("span",{class:e.normalizeClass(["wm-onb__alert-avatar",o.avatarWrapperClass(l)])},[o.isDefaultAvatar(l)?(e.openBlock(),e.createElementBlock("span",Tn,[...n[6]||(n[6]=[e.createElementVNode("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.7","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})],-1)])])):(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.avatarComponent(l)),e.mergeProps({key:1,ref_for:!0},o.avatarProps(l)),null,16)),e.createElementVNode("span",{class:"wm-onb__alert-dot","aria-label":o.t("onboarding.unread")},null,8,xn)],2),e.createElementVNode("span",On,[e.createElementVNode("span",Ln,e.toDisplayString(l.title),1),e.createElementVNode("span",{class:"wm-onb__alert-preview",innerHTML:o.renderPreview(l.preview)},null,8,Dn)]),e.createElementVNode("span",In,[o.formatTs(l._ts)?(e.openBlock(),e.createElementBlock("span",Rn,e.toDisplayString(o.formatTs(l._ts)),1)):e.createCommentVNode("",!0),e.createElementVNode("span",Fn,e.toDisplayString(o.t("onboarding.resume")),1)])],8,Mn))),128))])])):e.createCommentVNode("",!0),r.openThreads.length?(e.openBlock(),e.createElementBlock("div",Pn,[e.createElementVNode("div",Un,e.toDisplayString(o.t("onboarding.recentConversations")),1),e.createElementVNode("div",zn,[n[7]||(n[7]=e.createElementVNode("span",{class:"wm-onb__searchIcon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 21l-4.35-4.35M11 17a6 6 0 100-12 6 6 0 000 12z"})])],-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":n[1]||(n[1]=l=>a.query=l),type:"text",placeholder:o.t("onboarding.search"),"aria-label":o.t("onboarding.search")},null,8,jn),[[e.vModelText,a.query]])]),e.createElementVNode("div",Hn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.filteredThreads,l=>(e.openBlock(),e.createElementBlock("button",{key:l.id,type:"button",class:e.normalizeClass(["wm-onb__thread",{"wm-onb__thread--unread":l.unread}]),onClick:f=>t.$emit("resume",l)},[e.createElementVNode("span",{class:e.normalizeClass(["wm-onb__thread-avatar",o.avatarWrapperClass(l)])},[o.isDefaultAvatar(l)?(e.openBlock(),e.createElementBlock("span",Kn,[...n[8]||(n[8]=[e.createElementVNode("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.7","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})],-1)])])):(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.avatarComponent(l)),e.mergeProps({key:1,ref_for:!0},o.avatarProps(l)),null,16)),l.unread?(e.openBlock(),e.createElementBlock("span",{key:2,class:"wm-onb__thread-dot","aria-label":o.t("onboarding.unread")},null,8,$n)):e.createCommentVNode("",!0)],2),e.createElementVNode("span",Wn,[e.createElementVNode("span",Gn,e.toDisplayString(l.title),1),e.createElementVNode("span",{class:"wm-onb__thread-preview",innerHTML:o.renderPreview(l.preview)},null,8,Yn)]),e.createElementVNode("span",Jn,[o.formatTs(l._ts)?(e.openBlock(),e.createElementBlock("span",Qn,e.toDisplayString(o.formatTs(l._ts)),1)):e.createCommentVNode("",!0),n[9]||(n[9]=e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round",class:"wm-onb__thread-chev","aria-hidden":"true"},[e.createElementVNode("path",{d:"M5 12h14M13 5l7 7-7 7"})],-1))])],10,qn))),128)),o.filteredThreads.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Xn,e.toDisplayString(o.t("onboarding.noResults",{query:a.query})),1))])])):e.createCommentVNode("",!0)])}const Me=A(cn,[["render",Zn],["__scopeId","data-v-37fd5506"]]);function er(t){return typeof t!="string"?"":t.replace(/`([^`]+)`/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(new RegExp("(?<!\\*)\\*([^*]+)\\*(?!\\*)","g"),"$1").replace(/__([^_]+)__/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\s+/g," ").trim()}const tr={name:"WmActionResult",props:{state:{type:String,default:"success"},label:{type:String,required:!0},detail:{type:String,default:""}},computed:{detailText(){return er(this.detail)}}},nr={class:"wm-result__icon","aria-hidden":"true"},rr={key:0,width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.8","stroke-linecap":"round","stroke-linejoin":"round"},or={key:1,width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.6","stroke-linecap":"round","stroke-linejoin":"round"},ar={key:2,width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.4","stroke-linecap":"round","stroke-linejoin":"round"},sr={key:3,width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.2","stroke-linecap":"round","stroke-linejoin":"round"},ir={class:"wm-result__body"},lr={class:"wm-result__label"},cr={class:"wm-result__detail"};function dr(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-result",`wm-result--${r.state}`])},[e.createElementVNode("span",nr,[r.state==="success"?(e.openBlock(),e.createElementBlock("svg",rr,[...n[0]||(n[0]=[e.createElementVNode("path",{d:"M20 6L9 17l-5-5"},null,-1)])])):r.state==="rejected"?(e.openBlock(),e.createElementBlock("svg",or,[...n[1]||(n[1]=[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"},null,-1)])])):r.state==="awaiting"?(e.openBlock(),e.createElementBlock("svg",ar,[...n[2]||(n[2]=[e.createElementVNode("circle",{cx:"12",cy:"12",r:"10"},null,-1),e.createElementVNode("polyline",{points:"12 7 12 12 15 14"},null,-1)])])):(e.openBlock(),e.createElementBlock("svg",sr,[...n[3]||(n[3]=[e.createElementVNode("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"},null,-1),e.createElementVNode("line",{x1:"12",y1:"9",x2:"12",y2:"13"},null,-1),e.createElementVNode("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"},null,-1)])]))]),e.createElementVNode("span",ir,[e.createElementVNode("span",lr,e.toDisplayString(r.label),1),o.detailText?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[n[4]||(n[4]=e.createElementVNode("span",{class:"wm-result__sep","aria-hidden":"true"}," · ",-1)),e.createElementVNode("span",cr,e.toDisplayString(o.detailText),1)],64)):e.createCommentVNode("",!0)])],2)}const Te=A(tr,[["render",dr],["__scopeId","data-v-7284acd0"]]),ur={name:"WmArtifactFormResponse",inject:{t:{default:()=>M()}},props:{data:{type:Object,required:!0}},computed:{fields(){var t;return Array.isArray((t=this.data)==null?void 0:t.fields)?this.data.fields:[]}}},mr={class:"wm-art wm-art--formResponse"},hr={class:"wm-art__head"},fr={class:"wm-art__title"},pr={class:"wm-art__badge wm-art__badge--success"},gr={class:"wm-art__body"},_r={class:"wm-art__fieldLabel"};function yr(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",mr,[e.createElementVNode("div",hr,[e.createElementVNode("div",fr,e.toDisplayString(r.data.title||o.t("form.title")),1),e.createElementVNode("span",pr,[n[0]||(n[0]=e.createElementVNode("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("polyline",{points:"20 6 9 17 4 12"})],-1)),e.createTextVNode(" "+e.toDisplayString(o.t("form.sent")),1)])]),e.createElementVNode("div",gr,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.fields,(i,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-art__field"},[e.createElementVNode("div",_r,e.toDisplayString(i.label),1),e.createElementVNode("div",{class:e.normalizeClass(["wm-art__fieldValue",{"wm-art__fieldValue--multi":i.multiline}])},e.toDisplayString(i.value),3)]))),128))])])}const xe=A(ur,[["render",yr],["__scopeId","data-v-713aecf1"]]),vr={name:"WmArtifactInfoCard",props:{data:{type:Object,required:!0}},computed:{fields(){var t;return Array.isArray((t=this.data)==null?void 0:t.fields)?this.data.fields:[]},hasBody(){var t;return!!((t=this.data)!=null&&t.body)||this.fields.length>0}}},kr={class:"wm-art wm-art--infoCard"},wr={key:0,class:"wm-art__image"},br=["src","alt"],Er={class:"wm-art__head"},Cr={class:"wm-art__headMain"},Br={class:"wm-art__title"},Nr={key:0,class:"wm-art__subtitle"},Sr={key:1,class:"wm-art__body"},Ar={key:0,class:"wm-art__text"},Vr={class:"wm-art__fieldLabel"};function Mr(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",kr,[r.data.image_url?(e.openBlock(),e.createElementBlock("figure",wr,[e.createElementVNode("img",{src:r.data.image_url,alt:r.data.title||"",loading:"lazy"},null,8,br)])):e.createCommentVNode("",!0),e.createElementVNode("div",Er,[e.createElementVNode("div",Cr,[e.createElementVNode("div",Br,e.toDisplayString(r.data.title),1),r.data.subtitle?(e.openBlock(),e.createElementBlock("div",Nr,e.toDisplayString(r.data.subtitle),1)):e.createCommentVNode("",!0)]),r.data.badge&&r.data.badge.label?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(["wm-art__badge",`wm-art__badge--${r.data.badge.tone||"neutral"}`])},e.toDisplayString(r.data.badge.label),3)):e.createCommentVNode("",!0)]),o.hasBody?(e.openBlock(),e.createElementBlock("div",Sr,[r.data.body?(e.openBlock(),e.createElementBlock("div",Ar,e.toDisplayString(r.data.body),1)):e.createCommentVNode("",!0),o.fields.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(o.fields,(i,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-art__field"},[e.createElementVNode("div",Vr,e.toDisplayString(i.label),1),e.createElementVNode("div",{class:e.normalizeClass(["wm-art__fieldValue",{"wm-art__fieldValue--multi":i.multiline}])},e.toDisplayString(i.value),3)]))),128)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])}const Oe=A(vr,[["render",Mr],["__scopeId","data-v-7eae0e4a"]]);function Tr(t,n,r){if(!t)return"";const s=new Date(t);if(Number.isNaN(s.getTime()))return t;const a=s.toLocaleDateString(n,{day:"numeric",month:"long",year:"numeric"}),o=s.toLocaleTimeString(n,{hour:"2-digit",minute:"2-digit"});return`${a}${r}${o}`}const xr={name:"WmArtifactTicket",inject:{t:{default:()=>M()},wmLocale:{default:()=>()=>"fr"}},props:{data:{type:Object,required:!0}},computed:{fields(){var t;return Array.isArray((t=this.data)==null?void 0:t.fields)?this.data.fields:[]},formattedDate(){var t;return Tr((t=this.data)==null?void 0:t.created_at,z(this.wmLocale()),this.t("ticket.dateAt"))}},methods:{isPriority(t){return/priorit|^prio$/i.test(String(t||"").trim())},isDate(t){return/date|échéanc|echeanc|deadline|due|créé|cree/i.test(String(t||"").trim())},priorityLevel(t){const n=String(t||"").toLowerCase();return/high|haute|élev|elev|critic|critiq|urgent/.test(n)?3:/low|basse|faible|minor/.test(n)?1:2}}},Or={class:"wm-art wm-art--ticket"},Lr={class:"wm-art__head wm-tk__head"},Dr={class:"wm-art__title wm-tk__title"},Ir={class:"wm-tk__sub"},Rr={class:"wm-tk__ref"},Fr={key:0,class:"wm-tk__text"},Pr={key:0,class:"wm-art__body"},Ur={class:"wm-art__fieldLabel"},zr=["data-level"],jr={key:1,class:"wm-tk__date",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},Hr={key:1,class:"wm-art__footer wm-tk__footer"};function qr(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",Or,[e.createElementVNode("div",Lr,[e.createElementVNode("div",Dr,e.toDisplayString(r.data.title),1),e.createElementVNode("div",Ir,[e.createElementVNode("div",Rr,[n[0]||(n[0]=e.createElementVNode("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M20 12a2 2 0 0 1 2-2V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v4a2 2 0 0 1 0 4v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 1-2-2z"}),e.createElementVNode("path",{d:"M13 5v2M13 17v2M13 11v2"})],-1)),e.createElementVNode("span",null,e.toDisplayString(r.data.reference),1)]),e.createElementVNode("span",{class:e.normalizeClass(["wm-art__badge","wm-tk__badge",`wm-art__badge--${r.data.status.tone||"neutral"}`])},[n[1]||(n[1]=e.createElementVNode("span",{class:"wm-tk__dot","aria-hidden":"true"},null,-1)),e.createTextVNode(" "+e.toDisplayString(r.data.status.label),1)],2)]),r.data.body?(e.openBlock(),e.createElementBlock("div",Fr,e.toDisplayString(r.data.body),1)):e.createCommentVNode("",!0)]),o.fields.length?(e.openBlock(),e.createElementBlock("div",Pr,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.fields,(i,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-art__field"},[e.createElementVNode("div",Ur,e.toDisplayString(i.label),1),e.createElementVNode("div",{class:e.normalizeClass(["wm-art__fieldValue",{"wm-art__fieldValue--multi":i.multiline}])},[o.isPriority(i.label)?(e.openBlock(),e.createElementBlock("svg",{key:0,class:"wm-tk__prio","data-level":o.priorityLevel(i.value),width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true"},[...n[2]||(n[2]=[e.createElementVNode("rect",{x:"1",y:"8",width:"2",height:"3",rx:"0.5"},null,-1),e.createElementVNode("rect",{x:"5",y:"5",width:"2",height:"6",rx:"0.5"},null,-1),e.createElementVNode("rect",{x:"9",y:"2",width:"2",height:"9",rx:"0.5"},null,-1)])],8,zr)):o.isDate(i.label)?(e.openBlock(),e.createElementBlock("svg",jr,[...n[3]||(n[3]=[e.createElementVNode("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"},null,-1),e.createElementVNode("path",{d:"M16 2v4M8 2v4M3 10h18"},null,-1)])])):e.createCommentVNode("",!0),e.createElementVNode("span",null,e.toDisplayString(i.value),1)],2)]))),128))])):e.createCommentVNode("",!0),r.data.created_at?(e.openBlock(),e.createElementBlock("div",Hr,[n[4]||(n[4]=e.createElementVNode("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),e.createElementVNode("path",{d:"M16 2v4M8 2v4M3 10h18"})],-1)),e.createElementVNode("span",null,e.toDisplayString(o.formattedDate),1)])):e.createCommentVNode("",!0)])}const Le=A(xr,[["render",qr],["__scopeId","data-v-5f30c914"]]),Kr={form_response:xe,info_card:Oe,ticket:Le},$r={name:"WmArtifactRenderer",props:{artifact:{type:Object,required:!0}},computed:{component(){var n;const t=(n=this.artifact)==null?void 0:n.kind;return t&&Kr[t]||null}}};function Wr(t,n,r,s,a,o){return o.component?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.component),{key:0,data:r.artifact.data},null,8,["data"])):e.createCommentVNode("",!0)}const De=A($r,[["render",Wr]]),Gr={name:"WmAttachmentPreview",inject:{signAttachmentFn:{default:null},t:{default:()=>M()}},props:{attachment:{type:Object,required:!0}},data(){return{url:null,loading:!1}},computed:{kind(){var r,s;const t=(r=this.attachment)==null?void 0:r.type;if(t)return t;const n=(((s=this.attachment)==null?void 0:s.mime_type)||"").toLowerCase();return n.startsWith("image/")?"image":n.startsWith("audio/")?"audio":n.startsWith("video/")?"video":"file"},displayName(){var t,n,r;return((n=(t=this.attachment)==null?void 0:t.metadata)==null?void 0:n.name)||((r=this.attachment)==null?void 0:r.name)||this.guessNameFromPath()||this.t("attachment.fallbackName")},safeHref(){const t=String(this.url||"").trim();return/^(https?:\/\/|blob:|data:image\/)/i.test(t)?t:"#"},sizeLabel(){var n;const t=(n=this.attachment)==null?void 0:n.size_bytes;return t?t<1024?this.t("attachment.bytes",{size:t}):t<1024*1024?this.t("attachment.kilobytes",{size:(t/1024).toFixed(0)}):this.t("attachment.megabytes",{size:(t/(1024*1024)).toFixed(1)}):""}},watch:{"attachment.path":{handler(){this.refresh()},immediate:!0}},methods:{guessNameFromPath(){var r;return((((r=this.attachment)==null?void 0:r.path)||"").split("/").pop()||"").replace(/^[0-9a-f-]{8,}-/,"")},async refresh(){var t;if(!(!((t=this.attachment)!=null&&t.path)||!this.signAttachmentFn)){this.loading=!0;try{this.url=await this.signAttachmentFn(this.attachment.path)}finally{this.loading=!1}}},onFileClick(t){this.safeHref==="#"&&t.preventDefault()}}},Yr=["href"],Jr=["src","alt"],Qr=["src"],Xr=["src"],Zr=["href","download"],eo={class:"wm-att__main"},to={class:"wm-att__name"},no={key:0,class:"wm-att__meta"},ro={key:0,class:"wm-att__spin","aria-hidden":"true"};function oo(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-att",["wm-att--"+(o.kind||"file")]])},[o.kind==="image"&&a.url?(e.openBlock(),e.createElementBlock("a",{key:0,href:o.safeHref,target:"_blank",rel:"noopener",class:"wm-att__imgWrap"},[e.createElementVNode("img",{src:a.url,alt:o.displayName,loading:"lazy"},null,8,Jr)],8,Yr)):o.kind==="audio"&&a.url?(e.openBlock(),e.createElementBlock("audio",{key:1,src:a.url,controls:"",preload:"metadata"},null,8,Qr)):o.kind==="video"&&a.url?(e.openBlock(),e.createElementBlock("video",{key:2,src:a.url,controls:"",preload:"metadata"},null,8,Xr)):(e.openBlock(),e.createElementBlock("a",{key:3,class:"wm-att__file",href:o.safeHref,download:o.displayName,target:"_blank",rel:"noopener",onClick:n[0]||(n[0]=(...i)=>o.onFileClick&&o.onFileClick(...i))},[n[1]||(n[1]=e.createElementVNode("span",{class:"wm-att__icon"},[e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.7","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"}),e.createElementVNode("path",{d:"M14 2v6h6"})])],-1)),e.createElementVNode("span",eo,[e.createElementVNode("span",to,e.toDisplayString(o.displayName),1),o.sizeLabel?(e.openBlock(),e.createElementBlock("span",no,e.toDisplayString(o.sizeLabel),1)):e.createCommentVNode("",!0)]),a.loading?(e.openBlock(),e.createElementBlock("span",ro)):e.createCommentVNode("",!0)],8,Zr))],2)}const Ie=A(Gr,[["render",oo],["__scopeId","data-v-0c877a62"]]),ao={name:"WmBubble",props:{role:{type:String,default:"ai"},text:{type:String,default:""}},computed:{rendered(){return Ve(this.text)}}},so=["innerHTML"];function io(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-bubble","wm-bubble--"+r.role])},[e.renderSlot(t.$slots,"default",{},()=>[e.createElementVNode("span",{innerHTML:o.rendered},null,8,so)],!0)],2)}const Re=A(ao,[["render",io],["__scopeId","data-v-7ab13147"]]),lo={name:"WmTyping"},co={class:"wm-typing"};function uo(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",co,[...n[0]||(n[0]=[e.createElementVNode("span",{style:{"animation-delay":"0s"}},null,-1),e.createElementVNode("span",{style:{"animation-delay":"0.2s"}},null,-1),e.createElementVNode("span",{style:{"animation-delay":"0.4s"}},null,-1)])])}const Fe=A(lo,[["render",uo],["__scopeId","data-v-df2447fd"]]);function U(t){return t?t.client_msg_id||t.id:""}const mo={transferred_to_human:"system.transferredToHuman",assigned:"system.assigned",unassigned:"system.unassigned",resolved:"system.resolved",reopened:"system.reopened",idle:"system.idle"},ho=80,fo=200,po={name:"WmMessageList",components:{AIAvatar:G,HumanAvatar:ae,Bubble:Re,Typing:Fe,ActionResult:Te,AttachmentPreview:Ie,ArtifactRenderer:De},inject:{t:{default:()=>M()},wmLocale:{default:()=>()=>"fr"}},props:{messages:{type:Array,default:()=>[]},streamingActive:{type:Boolean,default:!1},dateLabel:{type:String,default:""},conversationId:{type:[String,Number],default:null},loadingMore:{type:Boolean,default:!1},hasMore:{type:Boolean,default:!1},unreadAnchorId:{type:Number,default:null},unreadBoundaryTs:{type:String,default:""},aiAgentName:{type:String,default:""},aiAgentAvatarUrl:{type:String,default:null}},emits:["load-more"],data(){return{silentFades:!1,widthByKey:Object.freeze({}),showScrollDown:!1,pressedItemKey:null}},computed:{historyExhausted(){return!this.hasMore&&!this.loadingMore&&this.messages.length>=20},groups(){var r,s,a,o;const t=[];for(const i of this.messages){const l=this.roleOf(i);if(l==="system"){if(((r=i==null?void 0:i.payload)==null?void 0:r.event)==="action_admin_pending"){const _=t[t.length-1];_&&_.role==="ai"?_.messages.push(i):t.push({key:`g-${U(i)}`,role:"ai",agentName:"",agentAvatarUrl:null,messages:[i],items:[]});continue}t.push({key:`sys-${U(i)}`,role:l,messages:[i],items:[],systemLabel:this.systemLabel(i)});continue}const f=t[t.length-1];f&&f.role===l&&(l==="ai"||f.agentName===(((s=i==null?void 0:i.author)==null?void 0:s.name)||""))?f.messages.push(i):t.push({key:`g-${U(i)}`,role:l,agentName:((a=i==null?void 0:i.author)==null?void 0:a.name)||"",agentAvatarUrl:((o=i==null?void 0:i.author)==null?void 0:o.avatar_url)||null,messages:[i],items:[]})}for(const i of t){if(i.role==="system")continue;const l=[];for(const f of i.messages)for(const y of this.itemsOf(f))l.push(y);i.items=l}const n=[];for(const i of t){if(i.role!=="system"&&!i.items.length)continue;const l=n[n.length-1];if(l&&l.role!=="system"&&l.role===i.role&&(i.role==="ai"||l.agentName===i.agentName)){l.messages.push(...i.messages),l.items.push(...i.items);continue}n.push(i)}for(const i of n)i.role!=="system"&&(i.key=this.stableGroupKey(i.messages));return n},unreadGroupKey(){if(this.unreadAnchorId==null)return null;const t=this.unreadAnchorId,n=this.unreadBoundaryTs;for(const r of this.groups){if(r.role==="user"||r.role==="system"||!r.items.length)continue;const s=r.messages[0];if(!s)continue;const a=I(s.id);if(a!=null&&!(a<=t)&&!(n&&s.created_at&&s.created_at>n))return r.key}return null}},watch:{messages:{handler:"snapshotAndRestore",deep:!0},conversationId(t,n){t!==n&&(this._groupIdByMsgKey=null,this.silentFades=!1)},loadingMore(t){t||(this._pendingLoadMore=!1),t&&(this.silentFades=!0),this.snapshotAndRestore()},streamingActive:"snapshotAndRestore"},mounted(){this._lastSeenConvId=this.conversationId,this.scrollToBottom(),this._measureFrame=null,this._ro=new ResizeObserver(()=>this.scheduleMeasure()),this.$refs.scrollEl&&this._ro.observe(this.$refs.scrollEl),this.$nextTick(()=>this.measureRows())},beforeUnmount(){var t;(t=this._ro)==null||t.disconnect(),this._measureFrame&&cancelAnimationFrame(this._measureFrame),this._pressTimer&&clearTimeout(this._pressTimer)},updated(){this.scheduleMeasure()},methods:{messageKey:U,stableGroupKey(t){this._groupIdByMsgKey||(this._groupIdByMsgKey=new Map,this._groupIdCounter=0);const n=this._groupIdByMsgKey;let r=null;for(const s of t){const a=U(s);if(a&&n.has(a)){r=n.get(a);break}}r==null&&(r=++this._groupIdCounter);for(const s of t){const a=U(s);a&&n.set(a,r)}return`g-${r}`},isAtBottom(t){return t.scrollHeight-t.scrollTop-t.clientHeight<=ho},onScroll(){const t=this.$refs.scrollEl;t&&(this.showScrollDown=!this.isAtBottom(t),!(this.loadingMore||!this.hasMore)&&(this._pendingLoadMore||t.scrollTop<=fo&&(this._pendingLoadMore=!0,this.$emit("load-more"))))},snapshotAndRestore(){const t=this.$refs.scrollEl;if(!t||this._scrollSnap)return;const n=this._lastSeenConvId!==this.conversationId;this._lastSeenConvId=this.conversationId;const r=this.isAtBottom(t);let s=null;if(!n&&!r){const o=this.pickAnchor(t);if(o!=null&&o.rowKey){const i=this.findRowByKey(t,o.rowKey);if(i){const l=t.getBoundingClientRect().top;s={rowKey:o.rowKey,relY:i.getBoundingClientRect().top-l}}}}const a={forceBottom:n,wasPinned:r,anchor:s};this._scrollSnap=a,this.$nextTick(()=>{if(this._scrollSnap=null,a.forceBottom||a.wasPinned){t.scrollTop=t.scrollHeight;return}if(!a.anchor)return;const o=()=>{const i=a.anchor,l=this.findRowByKey(t,i.rowKey);if(!l)return;const y=l.getBoundingClientRect().top-t.getBoundingClientRect().top-i.relY;Math.abs(y)>.5&&(t.scrollTop+=y)};o(),requestAnimationFrame(()=>{o(),requestAnimationFrame(o)})})},pickAnchor(t){const n=t.getBoundingClientRect().top,r=t.querySelectorAll(".wm-list__row[data-row-key]");let s=null;for(const a of r)if(s||(s=a),a.getBoundingClientRect().bottom>=n)return{rowKey:a.dataset.rowKey};return s?{rowKey:s.dataset.rowKey}:null},findRowByKey(t,n){if(!n)return null;const r=typeof CSS<"u"&&CSS.escape?CSS.escape(n):n.replace(/["\\]/g,"\\$&");return t.querySelector(`.wm-list__row[data-row-key="${r}"]`)},roleOf(t){var r,s;if((t==null?void 0:t.type)==="system"||((r=t==null?void 0:t.payload)==null?void 0:r.type)==="system")return"system";const n=(s=t==null?void 0:t.author)==null?void 0:s.type;return n==="user"?"user":n==="agent_human"?"human":"ai"},roleLabel(t){if(t.role==="human")return t.agentName||this.t("common.agent");const n=this.t("common.aiAssistant");return this.aiAgentName?`${this.aiAgentName} • ${n}`:n},itemsOf(t){var n;if(!t)return[];if(t.type==="system"&&((n=t==null?void 0:t.payload)==null?void 0:n.event)==="action_admin_pending")return[{message:t,partKey:"main",renderAs:"admin-pending",kind:{top:"bubble",bottom:"bubble"}}];if(t.type==="action"&&t.payload&&t.payload.state!=="pending"){const r=[{message:t,partKey:"main",renderAs:"action",kind:{top:"bubble",bottom:"bubble"}}];return this.actionArtifact(t)&&r.push({message:t,partKey:"artifact",renderAs:"artifact-of-action",kind:{top:"card",bottom:"card"}}),r}return this.artifactOf(t)?[{message:t,partKey:"main",renderAs:"artifact",kind:{top:"card",bottom:"card"}}]:t.text_md||this.attachmentsOf(t).length?[{message:t,partKey:"main",renderAs:"bubble",kind:{top:"bubble",bottom:"bubble"}}]:[]},cornersFor(t,n){var j,H,q;const r=t.items,s=(j=r[n])==null?void 0:j.kind,a=(H=r[n-1])==null?void 0:H.kind,o=(q=r[n+1])==null?void 0:q.kind,i=t.role==="user",l=14,f=4,y=a==null?void 0:a.bottom,_=o==null?void 0:o.top,C=this.widthByKey[this.rowKeyOf(t,n)],S=this.widthByKey[this.rowKeyOf(t,n-1)],k=this.widthByKey[this.rowKeyOf(t,n+1)],x=.5,b=(D,K,F)=>D!=null&&C!=null?D+x>=C:K===F||K==="card"&&F==="bubble";let V=l,N=l,O=l,R=l;return i?(y&&(N=f),(_||!o)&&(O=f),y&&b(S,y,s==null?void 0:s.top)&&(V=f),_&&b(k,_,s==null?void 0:s.bottom)&&(R=f)):(y&&(V=f),(_||!o)&&(R=f),y&&b(S,y,s==null?void 0:s.top)&&(N=f),_&&b(k,_,s==null?void 0:s.bottom)&&(O=f)),{tl:V,tr:N,br:O,bl:R}},cornersStyle(t,n){if(t.items.length<2)return null;const r=this.cornersFor(t,n);return{"--wm-r-tl":`${r.tl}px`,"--wm-r-tr":`${r.tr}px`,"--wm-r-br":`${r.br}px`,"--wm-r-bl":`${r.bl}px`}},rowKeyOf(t,n){var s;const r=(s=t==null?void 0:t.items)==null?void 0:s[n];return r?`${U(r.message)}-${r.partKey}`:""},scheduleMeasure(){this._measureFrame||(this._measureFrame=requestAnimationFrame(()=>{this._measureFrame=null,this.measureRows()}))},measureRows(){const t=this.$refs.scrollEl;if(!t)return;const n={};for(const o of t.querySelectorAll(".wm-list__row[data-row-key]")){const i=o.dataset.rowKey;if(!i)continue;const l=o.querySelector(".wm-bubble, .wm-result, .wm-art, .wm-list__body");if(!l)continue;const f=l.getBoundingClientRect().width;f>0&&(n[i]=f)}const r=this.widthByKey,s=Object.keys(r),a=Object.keys(n);if(s.length===a.length){let o=!0;for(const i of a)if(Math.abs((r[i]??0)-n[i])>.5){o=!1;break}if(o)return}this.widthByKey=Object.freeze(n)},onPressStart(t){this.onPressEnd(),this._pressTimer=setTimeout(()=>{this._pressTimer=null,this.pressedItemKey=t},400)},onPressEnd(){this._pressTimer&&(clearTimeout(this._pressTimer),this._pressTimer=null),this.pressedItemKey!==null&&(this.pressedItemKey=null)},timeOf(t){if(!(t!=null&&t.created_at))return"";try{return te(new Date(t.created_at),z(this.wmLocale()))}catch{return""}},lastTimeOf(t){const n=t.items[t.items.length-1],r=(n==null?void 0:n.message)||t.messages[t.messages.length-1];if(!(r!=null&&r.created_at))return"";try{return te(new Date(r.created_at),z(this.wmLocale()))}catch{return""}},hasTrailingOverlay(t){if(!t.messages.length)return!1;const n=t.messages[t.messages.length-1],r=t.items[t.items.length-1];return!!n&&(r==null?void 0:r.message)!==n},attachmentsOf(t){var r;const n=(r=t==null?void 0:t.payload)==null?void 0:r.attachments;return Array.isArray(n)?n:[]},artifactOf(t){var r;const n=(r=t==null?void 0:t.metadata)==null?void 0:r.artifact;return!n||typeof n!="object"||typeof n.kind!="string"?null:n},actionLabel(t){var n;return((n=t==null?void 0:t.payload)==null?void 0:n.name)||(t==null?void 0:t.text_md)||this.t("common.action")},actionDetail(t){var r,s,a,o,i,l;const n=t==null?void 0:t.payload;return n?n.state==="success"?((r=n.success)==null?void 0:r.summary)||((a=(s=n.success)==null?void 0:s.metadata)==null?void 0:a.description)||"":n.state==="rejected"?((o=n.rejected)==null?void 0:o.reason)||this.t("action.rejectedByUser"):n.state==="failure"&&(((i=n.failure)==null?void 0:i.summary)||((l=n.failure)==null?void 0:l.error))||"":""},actionArtifact(t){var r,s;const n=(s=(r=t==null?void 0:t.payload)==null?void 0:r.success)==null?void 0:s.artifact;return!n||typeof n!="object"||typeof n.kind!="string"?null:n},systemLabel(t){var a,o,i;const n=(a=t==null?void 0:t.payload)==null?void 0:a.event,r=mo[n],s=((o=t==null?void 0:t.metadata)==null?void 0:o.agent_name)||((i=t==null?void 0:t.author)==null?void 0:i.name)||this.t("messageList.anAgent");return r?this.t(r,{name:s}):(t==null?void 0:t.text_md)||this.t("messageList.conversationUpdate")},scrollToBottom(){const t=this.$refs.scrollEl;t&&(t.scrollTop=t.scrollHeight),this.showScrollDown=!1},scrollToBottomSmooth(){const t=this.$refs.scrollEl;t&&(typeof t.scrollTo=="function"?t.scrollTo({top:t.scrollHeight,behavior:"smooth"}):t.scrollTop=t.scrollHeight,this.showScrollDown=!1)}}},go={class:"wm-list__wrap"},_o={key:0,class:"wm-list__loadMore",role:"status","aria-live":"polite"},yo={class:"wm-list__loadMore-lbl"},vo={key:1,class:"wm-list__historyEnd"},ko={key:2,class:"wm-list__sep"},wo={class:"wm-list__sep-label"},bo={key:0,class:"wm-list__sep wm-list__sep--unread"},Eo={class:"wm-list__sep-label wm-list__sep-label--unread"},Co={key:0,class:"wm-list__sysep"},Bo={class:"wm-list__sysep-label"},No=["data-row-key","onPointerdown"],So={key:0,class:"wm-list__avatarSlot"},Ao={key:5,class:"wm-list__body"},Vo={key:0},Mo={key:1,"aria-hidden":"true"},To={key:2},xo={key:0},Oo={key:1,"aria-hidden":"true"},Lo={key:2},Do={key:3,class:"wm-list__row wm-list__row--ai fade-up"},Io={class:"wm-list__avatarSlot"},Ro=["aria-label","title"];function Fo(t,n,r,s,a,o){const i=e.resolveComponent("AIAvatar"),l=e.resolveComponent("HumanAvatar"),f=e.resolveComponent("ActionResult"),y=e.resolveComponent("ArtifactRenderer"),_=e.resolveComponent("Bubble"),C=e.resolveComponent("AttachmentPreview"),S=e.resolveComponent("Typing");return e.openBlock(),e.createElementBlock("div",go,[e.createElementVNode("div",{ref:"scrollEl",class:e.normalizeClass(["wm-list",{"wm-list--silent":a.silentFades}]),onScrollPassive:n[4]||(n[4]=(...k)=>o.onScroll&&o.onScroll(...k))},[r.loadingMore?(e.openBlock(),e.createElementBlock("div",_o,[n[6]||(n[6]=e.createElementVNode("span",{class:"wm-list__loadMore-spinner","aria-hidden":"true"},null,-1)),e.createElementVNode("span",yo,e.toDisplayString(o.t("messageList.loadingHistory")),1)])):o.historyExhausted?(e.openBlock(),e.createElementBlock("div",vo,e.toDisplayString(o.t("messageList.conversationStart")),1)):e.createCommentVNode("",!0),r.dateLabel?(e.openBlock(),e.createElementBlock("div",ko,[n[7]||(n[7]=e.createElementVNode("div",{class:"wm-list__line"},null,-1)),e.createElementVNode("span",wo,e.toDisplayString(r.dateLabel),1),n[8]||(n[8]=e.createElementVNode("div",{class:"wm-list__line"},null,-1))])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.groups,(k,x)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:k.key},[k.key===o.unreadGroupKey?(e.openBlock(),e.createElementBlock("div",bo,[n[9]||(n[9]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--unread"},null,-1)),e.createElementVNode("span",Eo,e.toDisplayString(o.t("messageList.unread")),1),n[10]||(n[10]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--unread"},null,-1))])):e.createCommentVNode("",!0),k.role==="system"||k.items.length?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["wm-list__group","wm-list__group--"+k.role])},[k.role==="system"?(e.openBlock(),e.createElementBlock("div",Co,[n[11]||(n[11]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--strong"},null,-1)),e.createElementVNode("span",Bo,e.toDisplayString(k.systemLabel),1),n[12]||(n[12]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--strong"},null,-1))])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k.items,(b,V)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`${o.messageKey(b.message)}-${b.partKey}`},[e.createElementVNode("div",{"data-row-key":`${o.messageKey(b.message)}-${b.partKey}`,class:e.normalizeClass(["wm-list__row fade-up",["wm-list__row--"+k.role,{"is-pending":b.message._pending,"is-failed":b.message._failed}]]),style:e.normalizeStyle(o.cornersStyle(k,V)),onPointerdown:N=>o.onPressStart(`${o.messageKey(b.message)}-${b.partKey}`),onPointerup:n[0]||(n[0]=N=>o.onPressEnd()),onPointercancel:n[1]||(n[1]=N=>o.onPressEnd()),onPointerleave:n[2]||(n[2]=N=>o.onPressEnd()),onContextmenu:n[3]||(n[3]=e.withModifiers(()=>{},["prevent"]))},[k.role!=="user"?(e.openBlock(),e.createElementBlock("div",So,[V===k.items.length-1?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[k.role==="ai"?(e.openBlock(),e.createBlock(i,{key:0,size:26,tail:!0,name:r.aiAgentName,"image-url":r.aiAgentAvatarUrl},null,8,["name","image-url"])):(e.openBlock(),e.createBlock(l,{key:1,name:k.agentName,"avatar-url":k.agentAvatarUrl,size:26,tail:!0},null,8,["name","avatar-url"]))],64)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),b.renderAs==="action"?(e.openBlock(),e.createBlock(f,{key:1,state:b.message.payload.state,label:o.actionLabel(b.message),detail:o.actionDetail(b.message)},null,8,["state","label","detail"])):b.renderAs==="admin-pending"?(e.openBlock(),e.createBlock(f,{key:2,state:"awaiting",label:o.t("messageList.approvalRequestSent"),detail:b.message.text_md||""},null,8,["label","detail"])):b.renderAs==="artifact-of-action"?(e.openBlock(),e.createBlock(y,{key:3,artifact:o.actionArtifact(b.message)},null,8,["artifact"])):b.renderAs==="artifact"?(e.openBlock(),e.createBlock(y,{key:4,artifact:o.artifactOf(b.message)},null,8,["artifact"])):(e.openBlock(),e.createElementBlock("div",Ao,[b.message.text_md?(e.openBlock(),e.createBlock(_,{key:0,role:k.role,text:b.message.text_md},null,8,["role","text"])):e.createCommentVNode("",!0),o.attachmentsOf(b.message).length?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["wm-list__atts",{"wm-list__atts--align-end":k.role==="user"}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.attachmentsOf(b.message),(N,O)=>(e.openBlock(),e.createBlock(C,{key:`${o.messageKey(b.message)}-att-${O}`,attachment:N},null,8,["attachment"]))),128))],2)):e.createCommentVNode("",!0)]))],46,No),V<k.items.length-1&&a.pressedItemKey===`${o.messageKey(b.message)}-${b.partKey}`&&(k.role!=="user"||o.timeOf(b.message))?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["wm-list__meta wm-list__meta--press",{"wm-list__meta--right":k.role==="user"}])},[k.role!=="user"?(e.openBlock(),e.createElementBlock("span",Vo,e.toDisplayString(o.roleLabel(k)),1)):e.createCommentVNode("",!0),k.role!=="user"&&o.timeOf(b.message)?(e.openBlock(),e.createElementBlock("span",Mo,"·")):e.createCommentVNode("",!0),o.timeOf(b.message)?(e.openBlock(),e.createElementBlock("span",To,e.toDisplayString(o.timeOf(b.message)),1)):e.createCommentVNode("",!0)],2)):e.createCommentVNode("",!0)],64))),128)),(k.role!=="user"||o.lastTimeOf(k))&&!o.hasTrailingOverlay(k)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["wm-list__meta",{"wm-list__meta--right":k.role==="user"}])},[k.role!=="user"?(e.openBlock(),e.createElementBlock("span",xo,e.toDisplayString(o.roleLabel(k)),1)):e.createCommentVNode("",!0),k.role!=="user"&&o.lastTimeOf(k)?(e.openBlock(),e.createElementBlock("span",Oo,"·")):e.createCommentVNode("",!0),o.lastTimeOf(k)?(e.openBlock(),e.createElementBlock("span",Lo,e.toDisplayString(o.lastTimeOf(k)),1)):e.createCommentVNode("",!0)],2)):e.createCommentVNode("",!0)],64))],2)):e.createCommentVNode("",!0)],64))),128)),r.streamingActive?(e.openBlock(),e.createElementBlock("div",Do,[e.createElementVNode("div",Io,[e.createVNode(i,{size:26,tail:!0,name:r.aiAgentName,"image-url":r.aiAgentAvatarUrl},null,8,["name","image-url"])]),e.createVNode(S)])):e.createCommentVNode("",!0)],34),e.createVNode(e.Transition,{name:"wm-scrollDown"},{default:e.withCtx(()=>[a.showScrollDown?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-list__scrollDown","aria-label":o.t("messageList.scrollToBottom"),title:o.t("messageList.scrollToBottom"),onClick:n[5]||(n[5]=(...k)=>o.scrollToBottomSmooth&&o.scrollToBottomSmooth(...k))},[...n[13]||(n[13]=[e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M6 9l6 6 6-6"})],-1)])],8,Ro)):e.createCommentVNode("",!0)]),_:1})])}const Pe=A(po,[["render",Fo],["__scopeId","data-v-9ddbd0e3"]]),Q=typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function",se=typeof window<"u"&&typeof window.MediaRecorder<"u";function Ue(){return se&&["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm","video/mp4"].find(n=>{var r,s;return(s=(r=window.MediaRecorder).isTypeSupported)==null?void 0:s.call(r,n)})||""}function ze({audio:t}){return{video:!0,audio:!!t,selfBrowserSurface:"include",surfaceSwitching:"include",systemAudio:t?"include":"exclude"}}function Po(t){return t?t.startsWith("image/")?"image":t.startsWith("video/")?"video":"file":"file"}async function je(){if(!Q)return null;let t;try{t=await navigator.mediaDevices.getDisplayMedia(ze({audio:!1}))}catch(n){return(n==null?void 0:n.name)!=="NotAllowedError"&&console.error("[media] screenshot picker",n),null}try{return await Uo(t)}catch(n){return console.error("[media] screenshot capture",n),null}finally{t.getTracks().forEach(n=>{n.stop()})}}async function Uo(t){const n=document.createElement("video");n.muted=!0,n.playsInline=!0,n.srcObject=t,await n.play(),await new Promise(l=>requestAnimationFrame(l));const r=n.videoWidth||1280,s=n.videoHeight||720,a=document.createElement("canvas");a.width=r,a.height=s,a.getContext("2d").drawImage(n,0,0,r,s);const o=await new Promise((l,f)=>{a.toBlob(y=>y?l(y):f(new Error("toBlob failed")),"image/png")}),i=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19);return new File([o],`capture-${i}.png`,{type:"image/png"})}async function He(t={}){var y;if(!Q||!se)return null;let n;try{n=await navigator.mediaDevices.getDisplayMedia(ze({audio:!0}))}catch(_){return(_==null?void 0:_.name)!=="NotAllowedError"&&console.error("[media] record picker",_),null}const r=Ue();let s;try{s=r?new window.MediaRecorder(n,{mimeType:r}):new window.MediaRecorder(n)}catch(_){return console.error("[media] recorder init",_),n.getTracks().forEach(C=>{C.stop()}),null}const a=[];let o=null,i=!1;s.addEventListener("dataavailable",_=>{_.data&&_.data.size>0&&a.push(_.data)}),s.addEventListener("stop",()=>{var _,C;if(o&&clearInterval(o),n.getTracks().forEach(S=>{S.stop()}),a.length){const S=s.mimeType||r||"video/webm",k=new Blob(a,{type:S}),x=/mp4/.test(S)?"mp4":"webm",b=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),V=new File([k],`ecran-${b}.${x}`,{type:S});(_=t.onfinalize)==null||_.call(t,V)}else(C=t.oncancel)==null||C.call(t)}),n.getVideoTracks().forEach(_=>{_.addEventListener("ended",()=>l(),{once:!0})});function l(){if(!i&&(i=!0,s.state!=="inactive"))try{s.stop()}catch(_){console.error("[media] recorder stop",_)}}try{s.start(1e3)}catch(_){return console.error("[media] recorder start",_),n.getTracks().forEach(C=>{C.stop()}),null}(y=t.onstart)==null||y.call(t);const f=Date.now();return o=setInterval(()=>{var _;(_=t.ontick)==null||_.call(t,Date.now()-f)},500),{stop:l,get state(){return s.state}}}const zo=[{action:"file",labelKey:"composer.attachFile",path:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"},{action:"screenshot",labelKey:"composer.screenshot",path:"M23 19a2 2 0 01-2 2H3a2 2 0 01-2-2V8a2 2 0 012-2h4l2-3h6l2 3h4a2 2 0 012 2z M12 17a4 4 0 100-8 4 4 0 000 8z"},{action:"record",labelKey:"composer.recordScreen",path:"M23 7l-7 5 7 5V7z M1 5a2 2 0 012-2h12a2 2 0 012 2v14a2 2 0 01-2 2H3a2 2 0 01-2-2V5z"}],jo={name:"WmComposer",inject:{t:{default:()=>M()}},props:{modelValue:{type:String,default:""},placeholder:{type:String,default:"Écrivez votre message…"},disabled:{type:Boolean,default:!1},attachLabel:{type:String,default:"Joindre"},displayMode:{type:String,default:"floating"}},emits:["update:modelValue","send","attach"],data(){return{local:this.modelValue,attachOpen:!1,recording:!1,recordingElapsed:0,recorder:null,kbOffset:0}},computed:{canSend(){return!this.disabled&&!!this.local.trim()},attachItems(){return zo.map(t=>({...t,label:this.t(t.labelKey),disabled:t.action==="screenshot"&&!Q||t.action==="record"&&(!Q||!se)}))},recordingElapsedLabel(){const t=Math.floor(this.recordingElapsed/1e3),n=Math.floor(t/60),r=t%60;return`${n}:${r.toString().padStart(2,"0")}`}},watch:{modelValue(t){t!==this.local&&(this.local=t,this.$nextTick(()=>this.autosize()))},local(t){this.$emit("update:modelValue",t)}},mounted(){this.autosize(),this.displayMode==="sheet"&&this.setupKeyboardTracking()},beforeUnmount(){if(this.recorder)try{this.recorder.stop()}catch{}this.teardownKeyboardTracking()},methods:{focus(){const t=this.$refs.inputEl;if(!(!t||this.disabled))try{t.focus({preventScroll:!0})}catch{t.focus()}},onSubmit(){if(!this.canSend)return;const t=this.local.trim();this.local="",this.$emit("send",t),this.$nextTick(()=>this.autosize())},onKeydown(t){t.key==="Enter"&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey&&!t.isComposing&&(t.preventDefault(),this.onSubmit())},autosize(){const t=this.$refs.inputEl;t&&(t.clientWidth<80||(t.style.height="auto",t.style.height=`${t.scrollHeight}px`))},onFile(t){const n=Array.from(t.target.files||[]);for(const r of n)this.$emit("attach",r);t.target.value=""},onAttachAction(t){this.attachOpen=!1,t==="file"?this.pickFile():t==="screenshot"?this.captureScreenshot():t==="record"&&this.startRecording()},pickFile(){var t;(t=this.$refs.fileEl)==null||t.click()},async captureScreenshot(){if(this.disabled)return;const t=await je();t&&this.$emit("attach",t)},async startRecording(){if(this.recording||this.disabled)return;this.recordingElapsed=0;const t=await He({onstart:()=>{this.recording=!0},ontick:n=>{this.recordingElapsed=n},onfinalize:n=>{this.$emit("attach",n),this.recording=!1,this.recordingElapsed=0,this.recorder=null},oncancel:()=>{this.recording=!1,this.recordingElapsed=0,this.recorder=null}});t&&(this.recorder=t)},stopRecording(){if(this.recorder)try{this.recorder.stop()}catch(t){console.error("[composer] stop recording",t)}},setupKeyboardTracking(){const t=window.visualViewport;t&&(this._vvHandler=()=>{const n=Math.max(0,window.innerHeight-t.height-t.offsetTop);this.kbOffset=n},t.addEventListener("resize",this._vvHandler),t.addEventListener("scroll",this._vvHandler))},teardownKeyboardTracking(){const t=window.visualViewport;!t||!this._vvHandler||(t.removeEventListener("resize",this._vvHandler),t.removeEventListener("scroll",this._vvHandler),this._vvHandler=null)}}},Ho={key:0,class:"wm-rec"},qo={class:"wm-rec__lbl"},Ko={key:1,class:"wm-compose__menu",role:"menu"},$o=["disabled","onClick"],Wo={class:"wm-compose__menuIcon"},Go={viewBox:"0 0 24 24",width:"14",height:"14","aria-hidden":"true"},Yo=["d"],Jo=["placeholder","disabled"],Qo={class:"wm-compose__actions"},Xo=["title","aria-label","disabled"],Zo=["disabled","aria-label"];function ea(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-compose-wrap",{"wm-compose-wrap--sheet":r.displayMode==="sheet"}]),style:e.normalizeStyle(a.kbOffset?{transform:`translateY(-${a.kbOffset}px)`}:null)},[a.recording?(e.openBlock(),e.createElementBlock("div",Ho,[n[8]||(n[8]=e.createElementVNode("span",{class:"wm-rec__dot","aria-hidden":"true"},null,-1)),e.createElementVNode("span",qo,e.toDisplayString(o.t("composer.recording",{time:o.recordingElapsedLabel})),1),e.createElementVNode("button",{type:"button",class:"wm-rec__stop",onClick:n[0]||(n[0]=(...i)=>o.stopRecording&&o.stopRecording(...i))},e.toDisplayString(o.t("composer.stop")),1)])):e.createCommentVNode("",!0),e.createElementVNode("form",{class:e.normalizeClass(["wm-compose",{"has-attach":a.attachOpen}]),onSubmit:n[7]||(n[7]=e.withModifiers((...i)=>o.onSubmit&&o.onSubmit(...i),["prevent"]))},[e.createElementVNode("input",{ref:"fileEl",type:"file",hidden:"",multiple:"",onChange:n[1]||(n[1]=(...i)=>o.onFile&&o.onFile(...i))},null,544),a.attachOpen?(e.openBlock(),e.createElementBlock("div",{key:0,class:"wm-compose__overlay",onClick:n[2]||(n[2]=i=>a.attachOpen=!1)})):e.createCommentVNode("",!0),a.attachOpen?(e.openBlock(),e.createElementBlock("div",Ko,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.attachItems,i=>(e.openBlock(),e.createElementBlock("button",{key:i.action,type:"button",class:"wm-compose__menuItem",disabled:i.disabled,onClick:l=>o.onAttachAction(i.action)},[e.createElementVNode("span",Wo,[(e.openBlock(),e.createElementBlock("svg",Go,[e.createElementVNode("path",{d:i.path,stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round",fill:"none"},null,8,Yo)]))]),e.createElementVNode("span",null,e.toDisplayString(i.label),1)],8,$o))),128))])):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("textarea",{ref:"inputEl","onUpdate:modelValue":n[3]||(n[3]=i=>a.local=i),class:"wm-compose__input",rows:"3",placeholder:r.placeholder,disabled:r.disabled,onKeydown:n[4]||(n[4]=(...i)=>o.onKeydown&&o.onKeydown(...i)),onInput:n[5]||(n[5]=(...i)=>o.autosize&&o.autosize(...i))},null,40,Jo),[[e.vModelText,a.local]]),e.createElementVNode("div",Qo,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["wm-compose__icon",{"is-open":a.attachOpen}]),title:r.attachLabel,"aria-label":r.attachLabel,disabled:a.recording,onClick:n[6]||(n[6]=i=>a.attachOpen=!a.attachOpen)},[...n[9]||(n[9]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"})],-1)])],10,Xo),e.createElementVNode("button",{type:"submit",class:e.normalizeClass(["wm-compose__send",{"is-empty":!o.canSend}]),disabled:!o.canSend,"aria-label":o.t("composer.send")},[...n[10]||(n[10]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})],-1)])],10,Zo)])],34)],6)}const qe=A(jo,[["render",ea],["__scopeId","data-v-01e81a27"]]),ta={name:"WmSuggestionChips",props:{items:{type:Array,default:()=>[]},baseDelay:{type:Number,default:360},stepDelay:{type:Number,default:90}},emits:["select"],computed:{batchKey(){return this.items.map(t=>(t==null?void 0:t.label)||(t==null?void 0:t.text)||"").join("§")}}},na=["onClick"];function ra(t,n,r,s,a,o){return r.items.length?(e.openBlock(),e.createElementBlock("div",{key:o.batchKey,class:"wm-chips"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.items,(i,l)=>(e.openBlock(),e.createElementBlock("button",{key:l,type:"button",class:"wm-chip",style:e.normalizeStyle({animationDelay:r.baseDelay+l*r.stepDelay+"ms"}),onClick:f=>t.$emit("select",i)},e.toDisplayString(i.label),13,na))),128))])):e.createCommentVNode("",!0)}const Ke=A(ta,[["render",ra],["__scopeId","data-v-47ad8085"]]),oa={name:"WmApprovalCard",components:{AIAvatar:G},inject:{t:{default:()=>M()}},props:{action:{type:String,required:!0},detail:{type:String,default:""},callbacks:{type:Array,default:()=>[]},agentName:{type:String,default:""},agentAvatarUrl:{type:String,default:null}},emits:["callback"],computed:{approveCallback(){return this.callbacks.find(t=>t.id==="approve"||t.style==="primary")||this.callbacks[0]},rejectCallback(){return this.callbacks.find(t=>t.id==="reject"||t.style==="danger"||t.style==="neutral")||(this.callbacks.length>1?this.callbacks[1]:null)},approveId(){var t;return(t=this.approveCallback)==null?void 0:t.id},rejectId(){var t;return(t=this.rejectCallback)==null?void 0:t.id},approveLabel(){var t;return((t=this.approveCallback)==null?void 0:t.label)||this.t("approval.approve")},rejectLabel(){var t;return((t=this.rejectCallback)==null?void 0:t.label)||this.t("approval.reject")}}},aa={class:"wm-approval"},sa={class:"wm-approval__head"},ia={class:"wm-approval__icon"},la={class:"wm-approval__main"},ca={class:"wm-approval__title"},da={key:0,class:"wm-approval__detail"},ua={class:"wm-approval__actions"};function ma(t,n,r,s,a,o){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",aa,[e.createElementVNode("div",sa,[e.createElementVNode("div",ia,[e.createVNode(i,{size:24,name:r.agentName,"image-url":r.agentAvatarUrl},null,8,["name","image-url"])]),e.createElementVNode("div",la,[e.createElementVNode("div",ca,e.toDisplayString(r.action),1),r.detail?(e.openBlock(),e.createElementBlock("div",da,e.toDisplayString(r.detail),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",ua,[o.rejectId?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-approval__btn wm-approval__btn--neutral",onClick:n[0]||(n[0]=l=>t.$emit("callback",o.rejectId))},e.toDisplayString(o.rejectLabel),1)):e.createCommentVNode("",!0),o.approveId?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"wm-approval__btn wm-approval__btn--primary",onClick:n[1]||(n[1]=l=>t.$emit("callback",o.approveId))},e.toDisplayString(o.approveLabel),1)):e.createCommentVNode("",!0)])])}const $e=A(oa,[["render",ma],["__scopeId","data-v-a2bed37e"]]);let ge=0;const ha=new Set(["text","textarea","number","boolean","select","multiselect","date"]),fa={name:"WmFormCard",components:{AIAvatar:G},inject:{t:{default:()=>M()}},props:{form:{type:Object,required:!0},readOnly:{type:Boolean,default:!1},initialValues:{type:Object,default:null},agentName:{type:String,default:""},agentAvatarUrl:{type:String,default:null}},emits:["submit"],data(){return ge+=1,{_uid:ge,values:{},busy:!1,error:""}},computed:{normalizedFields(){var n;return(Array.isArray((n=this.form)==null?void 0:n.fields)?this.form.fields:[]).filter(r=>!(!(r!=null&&r.key)||!(r!=null&&r.label)||!ha.has(r==null?void 0:r.type)||(r.type==="select"||r.type==="multiselect")&&(!Array.isArray(r.options)||r.options.length===0)))}},created(){this.resetValues()},methods:{resetValues(){const t=this.initialValues&&typeof this.initialValues=="object"?this.initialValues:{},n={};for(const r of this.normalizedFields){if(t[r.key]!==void 0){n[r.key]=t[r.key];continue}r.type==="boolean"?n[r.key]=!1:r.type==="multiselect"?n[r.key]=[]:n[r.key]=""}this.values=n,this.error=""},toggleMulti(t,n,r){const s=Array.isArray(this.values[t])?this.values[t].slice():[],a=s.indexOf(n);r&&a===-1?s.push(n):!r&&a!==-1&&s.splice(a,1),this.values={...this.values,[t]:s}},validate(){for(const t of this.normalizedFields){if(!t.required)continue;const n=this.values[t.key];if(t.type!=="boolean"){if(t.type==="multiselect"){if(!Array.isArray(n)||n.length===0)return this.t("form.fieldRequired",{label:t.label});continue}if(n==null||n==="")return this.t("form.fieldRequired",{label:t.label})}}return""},async onSubmit(){if(this.readOnly||this.busy)return;const t=this.validate();if(t){this.error=t;return}this.error="",this.busy=!0;try{await this.$emit("submit",{values:this.values})}finally{this.busy=!1}}}},pa={class:"wm-form"},ga={class:"wm-form__head"},_a={class:"wm-form__icon"},ya={class:"wm-form__main"},va={class:"wm-form__title"},ka={key:0,class:"wm-form__detail"},wa=["for"],ba={key:0,class:"wm-form__req","aria-hidden":"true"},Ea=["id","onUpdate:modelValue","placeholder","required","disabled"],Ca=["id","onUpdate:modelValue","placeholder","required","disabled"],Ba=["id","onUpdate:modelValue","placeholder","required","disabled"],Na=["id","onUpdate:modelValue","required","disabled"],Sa={key:4,class:"wm-form__bool"},Aa=["id","onUpdate:modelValue","disabled"],Va=["id","onUpdate:modelValue","required","disabled"],Ma={value:"",disabled:""},Ta=["value"],xa={key:6,class:"wm-form__multi"},Oa=["value","checked","disabled","onChange"],La={key:0,class:"wm-form__err"},Da=["disabled"],Ia={key:0,class:"wm-form__spinner","aria-hidden":"true"},Ra={key:2,class:"wm-form__doneLbl"};function Fa(t,n,r,s,a,o){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",pa,[e.createElementVNode("div",ga,[e.createElementVNode("div",_a,[e.createVNode(i,{size:24,name:r.agentName,"image-url":r.agentAvatarUrl},null,8,["name","image-url"])]),e.createElementVNode("div",ya,[e.createElementVNode("div",va,e.toDisplayString(r.form.title||o.t("form.title")),1),r.form.description?(e.openBlock(),e.createElementBlock("div",ka,e.toDisplayString(r.form.description),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("form",{class:"wm-form__body",onSubmit:n[0]||(n[0]=e.withModifiers((...l)=>o.onSubmit&&o.onSubmit(...l),["prevent"]))},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.normalizedFields,l=>(e.openBlock(),e.createElementBlock("div",{key:l.key,class:"wm-form__field"},[e.createElementVNode("label",{for:`wm-f-${a._uid}-${l.key}`,class:"wm-form__label"},[e.createTextVNode(e.toDisplayString(l.label),1),l.required?(e.openBlock(),e.createElementBlock("span",ba,"*")):e.createCommentVNode("",!0)],8,wa),l.type==="text"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":f=>a.values[l.key]=f,type:"text",class:"wm-form__input",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||a.busy},null,8,Ea)),[[e.vModelText,a.values[l.key]]]):l.type==="textarea"?e.withDirectives((e.openBlock(),e.createElementBlock("textarea",{key:1,id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":f=>a.values[l.key]=f,class:"wm-form__textarea",rows:"3",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||a.busy},null,8,Ca)),[[e.vModelText,a.values[l.key]]]):l.type==="number"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:2,id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":f=>a.values[l.key]=f,type:"number",class:"wm-form__input",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||a.busy},null,8,Ba)),[[e.vModelText,a.values[l.key],void 0,{number:!0}]]):l.type==="date"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:3,id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":f=>a.values[l.key]=f,type:"date",class:"wm-form__input",required:l.required,disabled:r.readOnly||a.busy},null,8,Na)),[[e.vModelText,a.values[l.key]]]):l.type==="boolean"?(e.openBlock(),e.createElementBlock("label",Sa,[e.withDirectives(e.createElementVNode("input",{id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":f=>a.values[l.key]=f,type:"checkbox",disabled:r.readOnly||a.busy},null,8,Aa),[[e.vModelCheckbox,a.values[l.key]]]),e.createElementVNode("span",null,e.toDisplayString(l.placeholder||o.t("common.yes")),1)])):l.type==="select"?e.withDirectives((e.openBlock(),e.createElementBlock("select",{key:5,id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":f=>a.values[l.key]=f,class:"wm-form__select",required:l.required,disabled:r.readOnly||a.busy},[e.createElementVNode("option",Ma,e.toDisplayString(l.placeholder||o.t("form.choose")),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.options,f=>(e.openBlock(),e.createElementBlock("option",{key:f.value,value:f.value},e.toDisplayString(f.label),9,Ta))),128))],8,Va)),[[e.vModelSelect,a.values[l.key]]]):l.type==="multiselect"?(e.openBlock(),e.createElementBlock("div",xa,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.options,f=>(e.openBlock(),e.createElementBlock("label",{key:f.value,class:"wm-form__multiItem"},[e.createElementVNode("input",{type:"checkbox",value:f.value,checked:Array.isArray(a.values[l.key])&&a.values[l.key].includes(f.value),disabled:r.readOnly||a.busy,onChange:y=>o.toggleMulti(l.key,f.value,y.target.checked)},null,40,Oa),e.createElementVNode("span",null,e.toDisplayString(f.label),1)]))),128))])):e.createCommentVNode("",!0)]))),128)),a.error?(e.openBlock(),e.createElementBlock("div",La,e.toDisplayString(a.error),1)):e.createCommentVNode("",!0),r.readOnly?(e.openBlock(),e.createElementBlock("div",Ra,e.toDisplayString(o.t("form.responseSent")),1)):(e.openBlock(),e.createElementBlock("button",{key:1,type:"submit",class:"wm-form__submit",disabled:a.busy},[a.busy?(e.openBlock(),e.createElementBlock("span",Ia)):e.createCommentVNode("",!0),e.createElementVNode("span",null,e.toDisplayString(a.busy?o.t("common.sending"):r.form.submit_label||o.t("common.send")),1)],8,Da))],32)])}const We=A(fa,[["render",Fa],["__scopeId","data-v-fe65cc56"]]),Pa={name:"WmFeedback",inject:{t:{default:()=>M()}},props:{busy:{type:Boolean,default:!1},done:{type:Boolean,default:!1}},emits:["submit"],data(){return{sel:null}},computed:{options(){return[{v:1,e:"😞",l:this.t("feedback.rating1")},{v:2,e:"😐",l:this.t("feedback.rating2")},{v:3,e:"🙂",l:this.t("feedback.rating3")},{v:4,e:"😄",l:this.t("feedback.rating4")},{v:5,e:"🤩",l:this.t("feedback.rating5")}]}},methods:{onSend(){!this.sel||this.busy||this.$emit("submit",{rating:this.sel})}}},Ua={class:"wm-fb"},za={class:"wm-fb__title"},ja={class:"wm-fb__sub"},Ha={class:"wm-fb__row"},qa=["onClick"],Ka={class:"wm-fb__emoji"},$a={class:"wm-fb__label"},Wa=["disabled"],Ga={key:1,class:"wm-fb__done"},Ya={class:"wm-fb__doneTitle"},Ja={class:"wm-fb__doneSub"};function Qa(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",Ua,[r.done?(e.openBlock(),e.createElementBlock("div",Ga,[n[1]||(n[1]=e.createElementVNode("div",{class:"wm-fb__check"},[e.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#fff","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M20 6L9 17l-5-5"})])],-1)),e.createElementVNode("div",Ya,e.toDisplayString(o.t("feedback.doneTitle")),1),e.createElementVNode("div",Ja,e.toDisplayString(o.t("feedback.doneSubtitle")),1)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("div",za,e.toDisplayString(o.t("feedback.question")),1),e.createElementVNode("div",ja,e.toDisplayString(o.t("feedback.subtitle")),1),e.createElementVNode("div",Ha,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.options,i=>(e.openBlock(),e.createElementBlock("button",{key:i.v,type:"button",class:e.normalizeClass(["wm-fb__opt",{"is-selected":a.sel===i.v}]),onClick:l=>a.sel=i.v},[e.createElementVNode("span",Ka,e.toDisplayString(i.e),1),e.createElementVNode("span",$a,e.toDisplayString(i.l),1)],10,qa))),128))]),e.createElementVNode("button",{type:"button",class:"wm-fb__send",disabled:!a.sel||r.busy,onClick:n[0]||(n[0]=(...i)=>o.onSend&&o.onSend(...i))},e.toDisplayString(r.busy?o.t("common.sending"):o.t("feedback.submit")),9,Wa)],64))])}const Ge=A(Pa,[["render",Qa],["__scopeId","data-v-9b630564"]]),Xa={name:"WmMoreMenu",inject:{t:{default:()=>M()}},props:{canRename:{type:Boolean,default:!0},canExport:{type:Boolean,default:!0},soundEnabled:{type:Boolean,default:!0},browserNotifEnabled:{type:Boolean,default:!1},statusUrl:{type:String,default:""},helpUrl:{type:String,default:""}},emits:["close","action","sound-toggle","browser-notif-toggle"],data(){return{soundOn:this.soundEnabled,browserNotifOn:this.browserNotifEnabled}},watch:{soundEnabled(t){this.soundOn=!!t},browserNotifEnabled(t){this.browserNotifOn=!!t}},methods:{emit(t){this.$emit("action",t)},toggleSound(){this.soundOn=!this.soundOn,this.$emit("sound-toggle",this.soundOn)},toggleBrowserNotif(){this.browserNotifOn=!this.browserNotifOn,this.$emit("browser-notif-toggle",this.browserNotifOn)}}},Za={class:"wm-mm"},es={class:"wm-mm__pop",role:"menu"},ts={key:0,class:"wm-mm__section"},ns={class:"wm-mm__label"},rs={class:"wm-mm__label"},os={key:1,class:"wm-mm__sep"},as={class:"wm-mm__section"},ss={class:"wm-mm__label"},is={class:"wm-mm__label"},ls={class:"wm-mm__section"},cs={class:"wm-mm__label"},ds={class:"wm-mm__label"};function us(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",Za,[e.createElementVNode("div",{class:"wm-mm__scrim",onClick:n[0]||(n[0]=i=>t.$emit("close"))}),e.createElementVNode("div",es,[r.canRename||r.canExport?(e.openBlock(),e.createElementBlock("div",ts,[r.canRename?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-mm__item",onClick:n[1]||(n[1]=i=>o.emit("rename"))},[n[7]||(n[7]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M12 20h9"}),e.createElementVNode("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})])],-1)),e.createElementVNode("span",ns,e.toDisplayString(o.t("moreMenu.editTitle")),1)])):e.createCommentVNode("",!0),r.canExport?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"wm-mm__item",onClick:n[2]||(n[2]=i=>o.emit("export"))},[n[8]||(n[8]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M4 12v8a2 2 0 002 2h12a2 2 0 002-2v-8M16 6l-4-4-4 4M12 2v13"})])],-1)),e.createElementVNode("span",rs,e.toDisplayString(o.t("moreMenu.exportTranscript")),1),n[9]||(n[9]=e.createElementVNode("span",{class:"wm-mm__hint"},".txt",-1))])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),r.canRename||r.canExport?(e.openBlock(),e.createElementBlock("div",os)):e.createCommentVNode("",!0),e.createElementVNode("div",as,[e.createElementVNode("button",{type:"button",class:"wm-mm__item",onClick:n[3]||(n[3]=(...i)=>o.toggleSound&&o.toggleSound(...i))},[n[11]||(n[11]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M11 5L6 9H2v6h4l5 4V5z"}),e.createElementVNode("path",{d:"M15.54 8.46a5 5 0 010 7.07M19.07 4.93a10 10 0 010 14.14"})])],-1)),e.createElementVNode("span",ss,e.toDisplayString(o.t("moreMenu.sound")),1),e.createElementVNode("span",{class:e.normalizeClass(["wm-mm__toggle",{"wm-mm__toggle--on":a.soundOn}])},[...n[10]||(n[10]=[e.createElementVNode("span",{class:"wm-mm__knob"},null,-1)])],2)]),e.createElementVNode("button",{type:"button",class:"wm-mm__item",onClick:n[4]||(n[4]=(...i)=>o.toggleBrowserNotif&&o.toggleBrowserNotif(...i))},[n[13]||(n[13]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M15 17h5l-1.4-1.4A2 2 0 0118 14.2V11a6 6 0 10-12 0v3.2c0 .5-.2 1-.6 1.4L4 17h5m6 0a3 3 0 11-6 0"})])],-1)),e.createElementVNode("span",is,e.toDisplayString(o.t("moreMenu.browserNotifications")),1),e.createElementVNode("span",{class:e.normalizeClass(["wm-mm__toggle",{"wm-mm__toggle--on":a.browserNotifOn}])},[...n[12]||(n[12]=[e.createElementVNode("span",{class:"wm-mm__knob"},null,-1)])],2)])]),n[16]||(n[16]=e.createElementVNode("div",{class:"wm-mm__sep"},null,-1)),e.createElementVNode("div",ls,[r.statusUrl?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-mm__item",onClick:n[5]||(n[5]=i=>o.emit("status"))},[n[14]||(n[14]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zM10 6v4l3 2"})])],-1)),e.createElementVNode("span",cs,e.toDisplayString(o.t("moreMenu.serviceStatus")),1)])):e.createCommentVNode("",!0),r.helpUrl?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"wm-mm__item",onClick:n[6]||(n[6]=i=>o.emit("help"))},[n[15]||(n[15]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M9 11a3 3 0 116 0c0 2-3 2-3 5M12 19h.01M12 22a10 10 0 110-20 10 10 0 010 20z"})])],-1)),e.createElementVNode("span",ds,e.toDisplayString(o.t("moreMenu.helpCenter")),1)])):e.createCommentVNode("",!0)])])])}const Ye=A(Xa,[["render",us],["__scopeId","data-v-76281e95"]]),ms={name:"WmRenameDialog",inject:{t:{default:()=>M()}},props:{title:{type:String,default:""},initialValue:{type:String,default:""},placeholder:{type:String,default:""}},emits:["close","submit"],data(){return{value:this.initialValue||""}},computed:{canSubmit(){const t=(this.value||"").trim();return!!t&&t!==(this.initialValue||"").trim()}},mounted(){this.$nextTick(()=>{const t=this.$refs.input;if(t){t.focus();try{t.select()}catch{}}})},methods:{onSubmit(){this.canSubmit&&this.$emit("submit",this.value.trim())}}},hs={class:"wm-dialog"},fs={class:"wm-dialog__card",role:"dialog","aria-modal":"true"},ps={class:"wm-dialog__head"},gs={class:"wm-dialog__title"},_s=["aria-label"],ys={class:"wm-dialog__body"},vs=["placeholder"],ks={class:"wm-dialog__actions"},ws=["disabled"];function bs(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",hs,[e.createElementVNode("div",{class:"wm-dialog__scrim",onClick:n[0]||(n[0]=i=>t.$emit("close"))}),e.createElementVNode("div",fs,[e.createElementVNode("div",ps,[e.createElementVNode("div",gs,e.toDisplayString(r.title||o.t("rename.title")),1),e.createElementVNode("button",{type:"button",class:"wm-dialog__close","aria-label":o.t("common.close"),onClick:n[1]||(n[1]=i=>t.$emit("close"))},[...n[7]||(n[7]=[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,_s)]),e.createElementVNode("div",ys,[e.withDirectives(e.createElementVNode("input",{ref:"input","onUpdate:modelValue":n[2]||(n[2]=i=>a.value=i),type:"text",class:"wm-dialog__input",placeholder:r.placeholder||o.t("rename.placeholder"),maxlength:120,onKeydown:[n[3]||(n[3]=e.withKeys(e.withModifiers((...i)=>o.onSubmit&&o.onSubmit(...i),["prevent"]),["enter"])),n[4]||(n[4]=e.withKeys(e.withModifiers(i=>t.$emit("close"),["prevent"]),["esc"]))]},null,40,vs),[[e.vModelText,a.value]])]),e.createElementVNode("div",ks,[e.createElementVNode("button",{type:"button",class:"wm-dialog__btn",onClick:n[5]||(n[5]=i=>t.$emit("close"))},e.toDisplayString(o.t("common.cancel")),1),e.createElementVNode("button",{type:"button",class:"wm-dialog__btn wm-dialog__btn--primary",disabled:!o.canSubmit,onClick:n[6]||(n[6]=(...i)=>o.onSubmit&&o.onSubmit(...i))},e.toDisplayString(o.t("common.save")),9,ws)])])])}const Es=A(ms,[["render",bs],["__scopeId","data-v-6d5f94a8"]]),_e="ww-messenger-tokens",Cs={name:"Messenger",components:{Launcher:Ce,Header:Ne,Onboarding:Me,MessageList:Pe,Composer:qe,SuggestionChips:Ke,ApprovalCard:$e,FormCard:We,Feedback:Ge,MoreMenu:Ye,RenameDialog:Es},mixins:[ct,pt,gt,yt],provide(){return{signAttachmentFn:t=>{var n,r;return((r=(n=this.store)==null?void 0:n.signAttachment)==null?void 0:r.call(n,t))||null},t:(t,n)=>this.t(t,n),wmLocale:()=>this.locale}},props:{baseUrl:{type:String,default:we},widgetId:{type:String,default:""},context:{type:Object,default:null},displayMode:{type:String,default:"floating"},devtools:{type:Boolean,default:!1},language:{type:String,default:""}},data(){return{transport:null,store:null,isOpen:!1,launcherHovered:!1,draft:"",busy:!1,bootError:null,pendingAttachments:[],feedbackBusy:!1,feedbackDone:!1,convOpenedAt:0,moreOpen:!1,renameDialogOpen:!1,draftConv:null,activeConvId:null,showOnboarding:!1,dismissedPeeks:{},floatHeight:0,floatRO:null,parentOrigin:"",parentToken:"",parentVariables:null,parentAllowUnauthenticated:!1,parentInitReceived:!1,parentInitDeferred:null}},computed:{isEditor(){return!!this.devtools},isEmbedded(){return this.displayMode==="embedded"},customerLanguage(){var r,s,a,o;const t=(r=this.s)==null?void 0:r.customer,n=t&&(t.language||((s=t.values)==null?void 0:s.language));return n||((o=(a=this.context)==null?void 0:a.customer)==null?void 0:o.language)||""},locale(){var t;return oe(this.language||this.customerLanguage||((t=this.widget)==null?void 0:t.default_language)||"")},translator(){return M(this.locale)},error(){var t;return this.bootError||((t=this.s)==null?void 0:t.error)||null},canBoot(){return!!(this.baseUrl&&this.widgetId)},s(){var t;return((t=this.store)==null?void 0:t.state)||null},ready(){var t;return!!((t=this.s)!=null&&t.ready)},allConversations(){var n;const t=(n=this.s)==null?void 0:n.conversations;return Array.isArray(t)?t:[]},drawerConversations(){var r;const t=((r=this.s)==null?void 0:r.messagesByConv)||{},n=this.revealedAt;return this.allConversations.map(s=>{var y;const a=t[s.id]||[],o=I(s.last_read_message_id);let i=0,l=null;for(let _=a.length-1;_>=0;_--){const C=a[_];if(!C)continue;if(((y=C.author)==null?void 0:y.type)==="user")break;const S=I(C.id);if(S!=null){if(o!=null&&S<=o)break;n[C.id]!==0&&(!l&&C.author&&(l=C.author),i++)}}if(!a.length){const _=I(s.last_message_id);_!=null&&(o==null||_>o)&&(i=1,l=s.last_message_author||null)}const f=a.filter(_=>!((_==null?void 0:_.id)!=null&&n[_.id]===0));return{...s,_preview:at(s,f),_unread:i>0,_unreadCount:i,_lastAuthor:l}})},unreadCount(){return this.drawerConversations.filter(t=>t._unread).length},openThreads(){var n;const t=((n=this.s)==null?void 0:n.messagesByConv)||{};return this.drawerConversations.filter(r=>r.status!=="resolved").map(r=>({id:r.id,title:r.name||this.t("common.newConversation"),preview:r._preview||this.t("onboarding.newMessage"),unread:!!r._unread,author:r._lastAuthor||null,_ts:he(r,t[r.id]||[])})).sort((r,s)=>r._ts<s._ts?1:r._ts>s._ts?-1:0)},latestUnreads(){var r;const t=((r=this.s)==null?void 0:r.messagesByConv)||{},n=[];for(const s of this.drawerConversations){if(!s._unread)continue;const a=he(s,t[s.id]||[]),o=s._lastAuthor,i=!o||o.type==="agent_ia",l=(o==null?void 0:o.name)||(i?this.agentName:"")||"",f=(o==null?void 0:o.avatar_url)||(i?this.agentAvatarUrl:null);n.push({convId:s.id,preview:s._preview||this.t("notification.youHaveNewMessage"),ts:a,count:s._unreadCount||1,senderName:l,senderAvatarUrl:f})}return n.sort((s,a)=>s.ts<a.ts?1:s.ts>a.ts?-1:0),n},launcherPeeks(){if(this.isOpen||this.isEmbedded)return[];const t=this.dismissedPeeks||{};return this.latestUnreads.filter(n=>t[n.convId]!==n.ts)},isViewingThread(){return(this.isOpen||this.isEmbedded)&&!!this.currentConv},currentConv(){if(this.draftConv)return this.draftConv;if(this.showOnboarding)return null;const t=this.allConversations;if(!t.length)return null;if(this.activeConvId!=null){const n=t.find(r=>r.id===this.activeConvId);if(n)return n}return t[0]||null},canBack(){return!!this.currentConv},statusUrl(){var r;const t=(r=this.widget)==null?void 0:r.quick_links;if(!Array.isArray(t))return"";const n=t.find(s=>s.icon==="status"&&s.url);return(n==null?void 0:n.url)||""},helpUrl(){var r;const t=(r=this.widget)==null?void 0:r.quick_links;if(!Array.isArray(t))return"";const n=t.find(s=>(s.icon==="chat"||s.icon==="help")&&s.url);return(n==null?void 0:n.url)||""},widget(){var t,n;return((n=(t=this.s)==null?void 0:t.config)==null?void 0:n.widget)||null},rootStyle(){var n;const t=(n=this.widget)==null?void 0:n.primary_color;return t?{"--wm-primary":t}:null},widgetWelcomeMessage(){var t;return((t=this.widget)==null?void 0:t.welcome_message)||""},widgetSubtitle(){var t;return((t=this.widget)==null?void 0:t.subtitle)||""},defaultIconUrl(){var t;return((t=this.widget)==null?void 0:t.default_icon_url)||null},agentName(){var t,n,r;return((r=(n=(t=this.s)==null?void 0:t.config)==null?void 0:n.agent)==null?void 0:r.name)||""},agentAvatarUrl(){var t,n,r;return((r=(n=(t=this.s)==null?void 0:t.config)==null?void 0:n.agent)==null?void 0:r.avatar_url)||null},quickLinks(){var n;const t=(n=this.widget)==null?void 0:n.quick_links;return Array.isArray(t)?t:[]},teamMembers(){var n;const t=(n=this.widget)==null?void 0:n.team_members;return Array.isArray(t)?t:[]},responseLabel(){var t;return((t=this.widget)==null?void 0:t.response_time_label)||""},humanMessageAuthor(){var n,r,s;if(!this.currentConv)return null;const t=((n=this.s.messagesByConv)==null?void 0:n[this.currentConv.id])||[];for(let a=t.length-1;a>=0;a--)if(((s=(r=t[a])==null?void 0:r.author)==null?void 0:s.type)==="agent_human")return t[a].author;return null},humanAgentName(){var t;return((t=this.humanMessageAuthor)==null?void 0:t.name)||""},humanAgentAvatarUrl(){var t;return((t=this.humanMessageAuthor)==null?void 0:t.avatar_url)||null},isEscalated(){return!!this.humanMessageAuthor},isWaitingHuman(){var n;const t=(n=this.currentConv)==null?void 0:n.status;return t==="waiting"||t==="handled"},headerTitle(){var t,n;return((t=this.currentConv)==null?void 0:t.name)||((n=this.widget)==null?void 0:n.name)||this.t("common.newConversation")},composerPlaceholder(){return this.isEscalated&&this.humanAgentName?this.t("composer.replyTo",{name:this.humanAgentName.split(" ")[0]}):this.isWaitingHuman?this.t("composer.agentTakingOver"):this.t("composer.placeholder")},displayedMessages(){var r,s;const t=this.currentConv;if(!t)return[];if(!t._draft){const a=(s=(r=this.s)==null?void 0:r.paginationByConv)==null?void 0:s[t.id];if(!(a!=null&&a.loaded))return[]}const n=this.revealedAt;return(this.s.messagesByConv[t.id]||[]).filter(a=>{var o,i,l,f,y;return(a==null?void 0:a.type)==="action"&&((o=a==null?void 0:a.payload)==null?void 0:o.state)==="pending"||J(a)&&!(n[a.id]>0)?!1:(a==null?void 0:a.type)==="action"||(a==null?void 0:a.type)==="system"||((i=a==null?void 0:a.payload)==null?void 0:i.type)==="system"||Array.isArray((l=a==null?void 0:a.payload)==null?void 0:l.attachments)&&a.payload.attachments.length||(f=a==null?void 0:a.metadata)!=null&&f.artifact||(y=a==null?void 0:a.metadata)!=null&&y.form?!0:typeof(a==null?void 0:a.text_md)=="string"&&a.text_md.trim().length>0})},streamingActive(){var r,s,a;const t=this.currentConv;return t?Object.keys(((r=this.s)==null?void 0:r.streamingByMsgId)||{}).length>0?!0:this.actionInFlight?!1:(((a=(s=this.s)==null?void 0:s.messagesByConv)==null?void 0:a[t.id])||[]).some(o=>J(o)&&!(this.revealedAt[o.id]>0)):!1},currentConvMessages(){var n,r,s;const t=(n=this.currentConv)==null?void 0:n.id;return t?((s=(r=this.s)==null?void 0:r.messagesByConv)==null?void 0:s[t])||[]:[]},pendingApproval(){return!this.currentConv||!this.store||this.actionInFlight?null:this.store.getPendingApproval(this.currentConv.id)},approvalReady(){return this.pendingApproval?this.pendingApproval.id===this.approvalLatchId?!0:!(this.streamingActive||!this.approvalSettled):!1},approvalTitle(){var t,n,r;return((n=(t=this.pendingApproval)==null?void 0:t.payload)==null?void 0:n.name)||((r=this.pendingApproval)==null?void 0:r.text_md)||this.t("action.title")},approvalDetail(){var s,a,o,i,l,f;const t=(o=(a=(s=this.pendingApproval)==null?void 0:s.payload)==null?void 0:a.pending)==null?void 0:o.user_explanation;if(typeof t=="string"&&t.trim())return t.trim();const n=(f=(l=(i=this.pendingApproval)==null?void 0:i.payload)==null?void 0:l.pending)==null?void 0:f.prepared_params;if(!n||typeof n!="object")return"";const r=Object.entries(n);return r.length?r.slice(0,2).map(([y,_])=>`${y}: ${_}`).join(" · "):""},actionInFlight(){var t,n;return!this.currentConv||!this.store?null:((n=(t=this.store).getActionInFlight)==null?void 0:n.call(t,this.currentConv.id))||null},actionInFlightName(){var n;const t=this.actionInFlight;return t?((n=t.payload)==null?void 0:n.name)||t.text_md||this.t("common.action"):""},suggestions(){return!this.currentConv||!this.store?[]:this.streamingActive?[]:this.pendingForm?[]:this.store.getLatestSuggestions(this.currentConv.id)},pendingForm(){var t,n;return!this.currentConv||!this.store||this.pendingApproval||this.actionInFlight||this.streamingActive||!this.approvalSettled?null:((n=(t=this.store).getLatestForm)==null?void 0:n.call(t,this.currentConv.id))||null},showFeedback(){var n;const t=this.currentConv;return t?this.feedbackDone?!0:t.status!=="resolved"?!1:!((n=t.metadata)!=null&&n.feedback):!1},floatVisible(){return this.approvalReady||!!this.pendingForm||this.showFeedback||this.suggestions.length>0},dateLabel(){var r,s,a;const t=this.currentConv;let n=new Date;if(t){const i=((a=(((s=(r=this.s)==null?void 0:r.messagesByConv)==null?void 0:s[t.id])||[]).find(l=>l==null?void 0:l.created_at))==null?void 0:a.created_at)||t.created_at;if(i){const l=new Date(i);Number.isNaN(l.getTime())||(n=l)}}return this.t("messageList.today",{time:te(n,z(this.locale))})},paginationState(){var r,s,a;const t=(r=this.currentConv)==null?void 0:r.id,n=t?(a=(s=this.s)==null?void 0:s.paginationByConv)==null?void 0:a[t]:null;return{loading:!!(n!=null&&n.loading),hasMore:!!(n!=null&&n.nextCursor)}}},watch:{latestUnreads:{handler(t){const n=new Set(t.map(i=>i.convId)),r=this.dismissedPeeks||{},s=Object.keys(r);if(!s.length)return;const a={};let o=!1;for(const i of s)n.has(i)?a[i]=r[i]:o=!0;o&&(this.dismissedPeeks=a)},deep:!0},"currentConv.id":{handler(t){var n;this.resetRevealQueue(),this.convOpenedAt=Date.now(),this.moreOpen=!1,this.renameDialogOpen=!1,this.resetApprovalPacing(),this.isViewingThread&&(this.unreadAnchorId=I((n=this.currentConv)==null?void 0:n.last_read_message_id),this.unreadBoundaryTs=t?new Date().toISOString():"")},immediate:!0},isViewingThread(t,n){var r;t&&!n?(this.unreadAnchorId=I((r=this.currentConv)==null?void 0:r.last_read_message_id),this.unreadBoundaryTs=new Date().toISOString()):t||(this.unreadAnchorId=null,this.unreadBoundaryTs="")},pendingApproval:{handler(t,n){if(t&&!n){const r=t!=null&&t.created_at?Date.parse(t.created_at):NaN;if(!(Number.isFinite(r)&&r>=this.convOpenedAt)){this.resetApprovalPacing();return}this.bumpApprovalSettle(2600)}else!t&&n&&this.resetApprovalPacing()},immediate:!1},streamingActive(t,n){t!==n&&this.pendingApproval&&this.pendingApproval.id!==this.approvalLatchId&&this.bumpApprovalSettle()},approvalReady(t){t&&this.pendingApproval&&(this.approvalLatchId=this.pendingApproval.id)},floatVisible:{handler(t){this.$nextTick(()=>this.syncFloatObserver(t))},immediate:!0},currentConvMessages(t){var n;this.paceMessages(t,(n=this.currentConv)==null?void 0:n.id),(this.isOpen||this.isEmbedded)&&this.currentConv&&this.markConvRead(this.currentConv)}},async mounted(){if(typeof document<"u"&&!document.getElementById(_e)){const t=document.createElement("style");t.id=_e,t.textContent=ke,document.head.appendChild(t)}this._parentMessageHandler=this.onParentMessage.bind(this),window.addEventListener("message",this._parentMessageHandler),window.parent&&window.parent!==window&&window.parent.postMessage({type:"READY"},"*"),this.isEmbedded?(await this.boot(),this.store&&await this.open()):(await this.$nextTick(),this.sendCurrentLauncherSize(),this.observeLauncherSize())},beforeUnmount(){this._parentMessageHandler&&(window.removeEventListener("message",this._parentMessageHandler),this._parentMessageHandler=null),this._launcherRo&&(this._launcherRo.disconnect(),this._launcherRo=null),this.cancelReveals(),this.teardownLiveReveal(),this.disconnectFloatRO(),this.resetApprovalPacing(),this.teardownNotifications(),this.store&&this.store.destroy()},methods:{t(t,n){return this.translator(t,n)},waitForParentInit(){if(this.parentInitReceived)return Promise.resolve();if(!this.parentInitDeferred){let t;this.parentInitDeferred=new Promise(n=>{t=n}),this.parentInitDeferred._resolve=t}return this.parentInitDeferred},onParentMessage(t){var r;const n=t==null?void 0:t.data;if(!(!n||typeof n!="object")){if(n.type==="UPDATE"){this.transport&&n.payload&&this.transport.update(n.payload).catch(s=>{console.warn("[messenger] update failed",s)});return}if(n.type==="CONTEXT"){this.transport&&n.payload&&this.transport.context(n.payload);return}n.type==="INIT"&&(this.parentOrigin=t.origin,this.parentToken=typeof n.token=="string"?n.token:"",this.parentVariables=n.variables&&typeof n.variables=="object"?n.variables:n.context&&typeof n.context=="object"?n.context:null,this.parentAllowUnauthenticated=n.allowUnauthenticated===!0,this.parentInitReceived=!0,(r=this.parentInitDeferred)!=null&&r._resolve&&this.parentInitDeferred._resolve(),!this.isEmbedded&&!this.isOpen&&!this.parentAllowUnauthenticated&&this.parentToken&&this.hasValidSessionMarker()&&this.boot().catch(s=>{console.warn("[messenger] eager boot failed",s)}))}},hasValidSessionMarker(){if(typeof document>"u")return!1;const n=(document.cookie||"").match(/(?:^|; )messenger_session_marker=([^;]+)/);if(!n)return!1;const r=parseInt(n[1],10);return Number.isFinite(r)?r>Date.now():!1},async boot(){if(!this.canBoot){console.warn("[messenger] boot skipped — missing creds");return}try{await this.waitForParentInit(),this.transport=e.markRaw(ye({baseUrl:this.baseUrl,widgetId:this.widgetId})),this.store=e.markRaw(ve(this.transport)),this.hydrateNotifPref();const t=this.parentVariables||this.context||null;if(await this.store.start({origin:this.parentOrigin,token:this.parentToken||void 0,allowUnauthenticated:this.parentAllowUnauthenticated,variables:t&&typeof t=="object"?t:void 0}),t&&typeof t=="object"){const n={};for(const[r,s]of Object.entries(t))r!=="customer"&&s&&typeof s=="object"&&!Array.isArray(s)&&(n[r]=s);Object.keys(n).length>0&&this.transport.context(n)}this.setupLiveReveal()}catch(t){console.error("[ww-messenger] bootstrap failed",t),this.bootError=(t==null?void 0:t.message)||String(t)}},async refresh(){this.store&&this.store.destroy(),this.cancelReveals(),this.teardownLiveReveal(),this.teardownNotifications(),this.convOpenedAt=0,this.transport=null,this.store=null,this.isOpen=!1,this.draft="",this.busy=!1,this.bootError=null,this.pendingAttachments=[],this.feedbackBusy=!1,this.feedbackDone=!1,this.moreOpen=!1,this.renameDialogOpen=!1,this.draftConv=null,this.activeConvId=null,this.showOnboarding=!1,await this.boot(),this.isEmbedded&&this.store&&await this.open()},syncFloatObserver(t){if(this.disconnectFloatRO(),!t){this.floatHeight=0;return}const n=this.$refs.floatEl;if(n){if(typeof ResizeObserver>"u"){this.floatHeight=Math.ceil(n.getBoundingClientRect().height+8);return}this.floatRO=new ResizeObserver(r=>{const s=r[0];if(!s)return;const a=Math.ceil(s.contentRect.height+8);a!==this.floatHeight&&(this.floatHeight=a,this.$nextTick(()=>{var o,i;(i=(o=this.$refs.messageList)==null?void 0:o.scrollToBottom)==null||i.call(o)}))}),this.floatRO.observe(n)}},disconnectFloatRO(){if(this.floatRO){try{this.floatRO.disconnect()}catch{}this.floatRO=null}},async open(){this.isOpen=!0,this.notifyParentResize("open"),this._launcherRo&&this._launcherRo.disconnect(),this.store||await this.boot(),this.store&&this.store.setPanelOpen(!0);const t=this.currentConv;if(t&&!t._draft){this.activeConvId==null&&(this.activeConvId=t.id);try{await this.store.openConversation(t.id)}catch(n){console.error("[ww-messenger] load messages failed",n)}this.markConvRead(t)}},async close(){this.isOpen=!1,await this.$nextTick(),this.sendCurrentLauncherSize(),this.observeLauncherSize(),this.store&&this.store.setPanelOpen(!1)},notifyParentResize(t,n){if(window.parent&&window.parent!==window)try{window.parent.postMessage({type:"RESIZE",state:t,displayMode:this.displayMode,...n||{}},"*")}catch(r){console.warn("[ww-messenger] notifyParentResize failed",r)}},onLauncherHover(t){this.launcherHovered=t,this.sendCurrentLauncherSize()},sendCurrentLauncherSize(){var _,C,S,k,x,b,V;if(this.isOpen)return;const t=(C=(_=this.$el)==null?void 0:_.querySelector)==null?void 0:C.call(_,".wm-launcherWrap");if(!t)return;const n=t.getBoundingClientRect();if(!n.width||!n.height)return;const r=(((S=this.launcherPeeks)==null?void 0:S.length)??0)>0,s=16,a=Math.ceil(n.width),o=Math.ceil(n.height),i=(x=(k=this.$el)==null?void 0:k.querySelector)==null?void 0:x.call(k,".wm-launcher"),l=(V=(b=this.$el)==null?void 0:b.querySelectorAll)==null?void 0:V.call(b,".wm-peek"),f=l&&l.length?l[l.length-1]:null;let y=null;if(f){const N=f.getBoundingClientRect();y={width:Math.ceil(N.width),height:Math.ceil(N.height),rightOffset:Math.max(0,Math.ceil(n.right-N.right)),bottomOffset:Math.max(0,Math.ceil(n.bottom-N.bottom))}}this.notifyParentResize("closed",{width:a+s,height:o+s,launcherWidth:(i==null?void 0:i.offsetWidth)||null,launcherHeight:(i==null?void 0:i.offsetHeight)||null,launcherHovered:this.launcherHovered,peek:y,peekHovered:this.launcherHovered&&r})},observeLauncherSize(){var r,s;if(typeof ResizeObserver>"u")return;const t=(s=(r=this.$el)==null?void 0:r.querySelector)==null?void 0:s.call(r,".wm-launcherWrap");if(!t)return;this._launcherRo&&this._launcherRo.disconnect();const n=new ResizeObserver(()=>{this.isOpen||this.sendCurrentLauncherSize()});n.observe(t),this._launcherRo=n},async openFromPeek(t){var r,s;const n=t||((r=this.latestUnreads[0])==null?void 0:r.convId);n&&n!==((s=this.currentConv)==null?void 0:s.id)&&(this.draftConv=null,this.activeConvId=n,this.showOnboarding=!1),await this.open()},dismissPeek(t){const n=this.latestUnreads.find(r=>r.convId===t);n&&(this.dismissedPeeks={...this.dismissedPeeks,[t]:n.ts})},startConv(){this.draftConv={id:"__draft__",_draft:!0,name:"",created_at:new Date().toISOString()},this.activeConvId=null,this.showOnboarding=!1,this.focusComposer()},async ensureRealConv(){const t=this.currentConv;if(!t)return null;if(!t._draft)return t;if(this.busy)return null;this.busy=!0;try{const n=await this.store.createConversation({});return this.draftConv=null,this.activeConvId=n.id,await this.store.openConversation(n.id),this.markConvRead(n),n}catch(n){return console.error("[ww-messenger] create conv failed",n),this.bootError=(n==null?void 0:n.message)||String(n),null}finally{this.busy=!1}},focusComposer(){this.$nextTick(()=>{var t;return(t=this.$refs.composer)==null?void 0:t.focus()})},toggleMore(){this.moreOpen=!this.moreOpen},goHome(){this.moreOpen=!1,this.draftConv=null,this.activeConvId=null,this.showOnboarding=!0},async onDrawerPick(t){if(!(t!=null&&t.id)||!this.store)return;this.draftConv=null,this.activeConvId=t.id,this.showOnboarding=!1;try{await this.store.openConversation(t.id)}catch(r){console.error("[ww-messenger] open conv failed",r)}const n=this.allConversations.find(r=>r.id===t.id);n&&this.markConvRead(n)},async onMoreAction(t){var n,r;switch(this.moreOpen=!1,t){case"rename":this.openRenameDialog();break;case"export":lt(this.currentConv,this.currentConv?(r=(n=this.s)==null?void 0:n.messagesByConv)==null?void 0:r[this.currentConv.id]:[],this.translator,this.locale);break;case"status":if(this.statusUrl)try{window.open(this.statusUrl,"_blank","noopener")}catch{}break;case"help":if(this.helpUrl)try{window.open(this.helpUrl,"_blank","noopener")}catch{}break}},openRenameDialog(){const t=this.currentConv;!t||t._draft||(this.renameDialogOpen=!0)},async onRenameSubmit(t){const n=this.currentConv;if(this.renameDialogOpen=!1,!n||n._draft||!this.store)return;const r=(t||"").trim();if(!(!r||r===n.name))try{await this.store.patchConversation(n.id,{name:r})}catch(s){console.error("[ww-messenger] rename failed",s)}},async onSend(t){let n=this.currentConv;if(!n&&(this.startConv(),n=this.currentConv,!n)||n._draft&&(n=await this.ensureRealConv(),!n))return;const r=n.id,s=this.pendingAttachments.slice();this.pendingAttachments=[],this.unreadAnchorId=null,this.unreadBoundaryTs="",await this.store.send(r,t,{attachments:s.length?s:void 0})},async onSuggestion(t){const n=t==null?void 0:t.label;n&&await this.onSend(n)},async onLoadMore(){var n;const t=(n=this.currentConv)==null?void 0:n.id;!t||!this.store||await this.store.loadMore(t)},async onApprovalCallback(t){const n=this.pendingApproval;n&&await this.store.clickCallback(n.id,t)},async onFormSubmit({values:t}){const n=this.pendingForm;if(!(n!=null&&n.form))return;const r=rt(n.form,t,this.translator);if(!r)return;let s=this.currentConv;s&&(s._draft&&(s=await this.ensureRealConv(),!s)||await this.store.send(s.id,r,{metadata:{artifact:ot(n.form,t,this.translator)}}))},async onAttach(t){if(!(!t||!this.transport))try{const n=await this.transport.uploadAttachment(t);this.pendingAttachments.push({type:n.type||"file",path:n.path,name:t.name||this.t("attachment.fileFallbackName"),mime_type:t.type,size_bytes:t.size})}catch(n){console.error("[ww-messenger] attachment upload failed",n)}},onPanelClick(t){const n=t.target&&t.target.closest?t.target.closest('a[href^="#"]'):null;n&&(t.preventDefault(),this.openInternalUrl(n.getAttribute("href")))},async openInternalUrl(t){if(typeof t!="string"||!t.startsWith("#"))return!1;const n=t.slice(1);if(n==="new"||n==="new-conversation")return this.isOpen||await this.open(),this.startConv(),!0;if(n.startsWith("conversation/")){const r=n.slice(13);return r&&await this.openFromPeek(r),!0}return console.warn("[messenger] unknown internal url",t),!0},async onQuickLink(t){if(t){if(t.url){if(await this.openInternalUrl(t.url))return;try{window.open(t.url,"_blank","noopener")}catch{}return}this.currentConv||this.startConv(),await this.onSend(t.label)}},async onFeedback({rating:t,comment:n}){if(this.currentConv){this.feedbackBusy=!0;try{await this.store.submitFeedback(this.currentConv.id,{rating:t,comment:n}),this.feedbackDone=!0}catch(r){console.error("[ww-messenger] feedback failed",r)}finally{this.feedbackBusy=!1}}}}},Bs={key:0,class:"wm-loading","aria-busy":"true","aria-live":"polite"},Ns=["aria-label"],Ss={key:0,class:"wm-state"},As={class:"wm-state__err"},Vs={class:"wm-state__errTitle"},Ms={class:"wm-state__errSub"},Ts={class:"wm-bottom"},xs={key:0,ref:"floatEl",class:"wm-float"},Os={key:1,class:"wm-actionWait",role:"status","aria-live":"polite"},Ls={class:"wm-actionWait__lbl"},Ds={key:2,class:"wm-attached"},Is=["aria-label","onClick"];function Rs(t,n,r,s,a,o){const i=e.resolveComponent("Launcher"),l=e.resolveComponent("Header"),f=e.resolveComponent("Onboarding"),y=e.resolveComponent("MessageList"),_=e.resolveComponent("ApprovalCard"),C=e.resolveComponent("FormCard"),S=e.resolveComponent("Feedback"),k=e.resolveComponent("SuggestionChips"),x=e.resolveComponent("Composer"),b=e.resolveComponent("MoreMenu"),V=e.resolveComponent("RenameDialog");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-root",`wm-root--${r.displayMode}`]),style:e.normalizeStyle(o.rootStyle)},[!a.isOpen&&!o.isEmbedded?(e.openBlock(),e.createBlock(i,{key:0,"unread-count":o.unreadCount,peeks:o.launcherPeeks,onOpen:o.openFromPeek,onDismiss:o.dismissPeek,onHover:o.onLauncherHover},null,8,["unread-count","peeks","onOpen","onDismiss","onHover"])):e.createCommentVNode("",!0),a.isOpen||o.isEmbedded?(e.openBlock(),e.createElementBlock("section",{key:1,class:e.normalizeClass(["wm-panel",`wm-panel--${r.displayMode}`,{"wm-panel--welcome":o.ready&&!o.error&&!o.currentConv}]),style:e.normalizeStyle(a.floatHeight?{"--wm-float-h":a.floatHeight+"px"}:null),role:"dialog","aria-label":"Messenger",onClick:n[5]||(n[5]=(...N)=>o.onPanelClick&&o.onPanelClick(...N))},[!o.ready&&!o.error?(e.openBlock(),e.createElementBlock("div",Bs,[o.isEmbedded?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-loading__close","aria-label":o.t("loading.minimize"),onClick:n[0]||(n[0]=(...N)=>o.close&&o.close(...N))},[...n[6]||(n[6]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,Ns)),n[7]||(n[7]=e.createElementVNode("div",{class:"wm-loading__spinner","aria-hidden":"true"},null,-1))])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(l,{title:o.headerTitle,"team-members":o.teamMembers,"response-label":o.responseLabel,"show-identity":!!o.currentConv,"show-back":o.canBack,"show-close":!o.isEmbedded,"more-active":a.moreOpen,"agent-name":o.agentName,"agent-avatar-url":o.agentAvatarUrl,onBack:o.goHome,onMore:o.toggleMore,onClose:o.close},null,8,["title","team-members","response-label","show-identity","show-back","show-close","more-active","agent-name","agent-avatar-url","onBack","onMore","onClose"]),o.error?(e.openBlock(),e.createElementBlock("div",Ss,[e.createElementVNode("div",As,[n[8]||(n[8]=e.createElementVNode("div",{class:"wm-state__errIcon"},[e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})])],-1)),e.createElementVNode("div",null,[e.createElementVNode("div",Vs,e.toDisplayString(o.t("error.connectionFailed")),1),e.createElementVNode("div",Ms,e.toDisplayString(o.error),1)])])])):o.currentConv?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createVNode(y,{ref:"messageList",messages:o.displayedMessages,"streaming-active":o.streamingActive,"date-label":o.dateLabel,"conversation-id":o.currentConv?o.currentConv.id:null,"loading-more":o.paginationState.loading,"has-more":o.paginationState.hasMore,"unread-anchor-id":t.unreadAnchorId,"unread-boundary-ts":t.unreadBoundaryTs,"ai-agent-name":o.agentName,"ai-agent-avatar-url":o.agentAvatarUrl,onLoadMore:o.onLoadMore},null,8,["messages","streaming-active","date-label","conversation-id","loading-more","has-more","unread-anchor-id","unread-boundary-ts","ai-agent-name","ai-agent-avatar-url","onLoadMore"]),e.createElementVNode("div",Ts,[o.floatVisible?(e.openBlock(),e.createElementBlock("div",xs,[o.approvalReady?(e.openBlock(),e.createBlock(_,{key:0,action:o.approvalTitle,detail:o.approvalDetail,callbacks:o.pendingApproval.callbacks,"agent-name":o.agentName,"agent-avatar-url":o.agentAvatarUrl,onCallback:o.onApprovalCallback},null,8,["action","detail","callbacks","agent-name","agent-avatar-url","onCallback"])):o.pendingForm?(e.openBlock(),e.createBlock(C,{key:o.pendingForm.message&&o.pendingForm.message.id,form:o.pendingForm.form,"agent-name":o.agentName,"agent-avatar-url":o.agentAvatarUrl,onSubmit:o.onFormSubmit},null,8,["form","agent-name","agent-avatar-url","onSubmit"])):o.showFeedback?(e.openBlock(),e.createBlock(S,{key:2,busy:a.feedbackBusy,done:a.feedbackDone,onSubmit:o.onFeedback},null,8,["busy","done","onSubmit"])):(e.openBlock(),e.createBlock(k,{key:3,items:o.suggestions,onSelect:o.onSuggestion},null,8,["items","onSelect"]))],512)):e.createCommentVNode("",!0),o.actionInFlight?(e.openBlock(),e.createElementBlock("div",Os,[n[9]||(n[9]=e.createElementVNode("span",{class:"wm-actionWait__spinner","aria-hidden":"true"},null,-1)),e.createElementVNode("span",Ls,e.toDisplayString(o.t("action.inProgress",{name:o.actionInFlightName})),1)])):(e.openBlock(),e.createBlock(x,{key:2,ref:"composer",modelValue:a.draft,"onUpdate:modelValue":n[1]||(n[1]=N=>a.draft=N),placeholder:o.composerPlaceholder,disabled:!!o.pendingApproval,"attach-label":o.t("composer.attachFile"),"display-mode":r.displayMode,onSend:o.onSend,onAttach:o.onAttach},null,8,["modelValue","placeholder","disabled","attach-label","display-mode","onSend","onAttach"]))]),a.moreOpen?(e.openBlock(),e.createBlock(b,{key:0,"can-rename":!!o.currentConv&&!o.currentConv._draft,"can-export":!!o.currentConv&&!o.currentConv._draft,"sound-enabled":t.soundEnabled,"browser-notif-enabled":t.browserNotifEnabled,"status-url":o.statusUrl,"help-url":o.helpUrl,onClose:n[2]||(n[2]=N=>a.moreOpen=!1),onSoundToggle:t.onSoundToggle,onBrowserNotifToggle:t.onBrowserNotifToggle,onAction:o.onMoreAction},null,8,["can-rename","can-export","sound-enabled","browser-notif-enabled","status-url","help-url","onSoundToggle","onBrowserNotifToggle","onAction"])):e.createCommentVNode("",!0),a.renameDialogOpen&&o.currentConv&&!o.currentConv._draft?(e.openBlock(),e.createBlock(V,{key:1,"initial-value":o.currentConv.name||"",title:o.t("rename.dialogTitle"),onClose:n[3]||(n[3]=N=>a.renameDialogOpen=!1),onSubmit:o.onRenameSubmit},null,8,["initial-value","title","onSubmit"])):e.createCommentVNode("",!0),a.pendingAttachments.length?(e.openBlock(),e.createElementBlock("div",Ds,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.pendingAttachments,(N,O)=>(e.openBlock(),e.createElementBlock("div",{key:O,class:"wm-attached__chip"},[n[11]||(n[11]=e.createElementVNode("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"})],-1)),e.createElementVNode("span",null,e.toDisplayString(N.name),1),e.createElementVNode("button",{type:"button","aria-label":o.t("attachment.remove"),onClick:R=>a.pendingAttachments.splice(O,1)},[...n[10]||(n[10]=[e.createElementVNode("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,Is)]))),128))])):e.createCommentVNode("",!0)],64)):(e.openBlock(),e.createBlock(f,{key:1,"welcome-message":o.widgetWelcomeMessage,subtitle:o.widgetSubtitle,"agent-name":o.agentName,"default-icon-url":o.defaultIconUrl,"quick-links":o.quickLinks,"open-threads":o.openThreads,busy:a.busy,onStart:o.startConv,onSelect:o.onQuickLink,onResume:o.onDrawerPick},null,8,["welcome-message","subtitle","agent-name","default-icon-url","quick-links","open-threads","busy","onStart","onSelect","onResume"])),a.moreOpen&&!o.currentConv?(e.openBlock(),e.createBlock(b,{key:3,"can-rename":!1,"can-export":!1,"sound-enabled":t.soundEnabled,"browser-notif-enabled":t.browserNotifEnabled,"status-url":o.statusUrl,"help-url":o.helpUrl,onClose:n[4]||(n[4]=N=>a.moreOpen=!1),onSoundToggle:t.onSoundToggle,onBrowserNotifToggle:t.onBrowserNotifToggle,onAction:o.onMoreAction},null,8,["sound-enabled","browser-notif-enabled","status-url","help-url","onSoundToggle","onBrowserNotifToggle","onAction"])):e.createCommentVNode("",!0)],64))],6)):e.createCommentVNode("",!0)],6)}const Je=A(Cs,[["render",Rs],["__scopeId","data-v-fc80add0"]]),Fs="0.5.43";exports.AIAvatar=G;exports.AVATAR_COLORS=ee;exports.ActionResult=Te;exports.ApprovalCard=$e;exports.ArtifactFormResponse=xe;exports.ArtifactInfoCard=Oe;exports.ArtifactRenderer=De;exports.ArtifactTicket=Le;exports.AttachmentPreview=Ie;exports.Bubble=Re;exports.Composer=qe;exports.DEFAULT_BASE_URL=we;exports.DEFAULT_LANGUAGE=W;exports.Feedback=Ge;exports.FormCard=We;exports.Header=Ne;exports.HumanAvatar=ae;exports.Launcher=Ce;exports.MEDIA_RECORDER_SUPPORTED=se;exports.MessageList=Pe;exports.Messenger=Je;exports.MoreMenu=Ye;exports.Onboarding=Me;exports.SCREEN_CAPTURE_SUPPORTED=Q;exports.SUPPORTED_LANGUAGES=be;exports.SuggestionChips=Ke;exports.TeamAvatars=Be;exports.Typing=Fe;exports.VERSION=Fs;exports.avatarColor=ne;exports.avatarInitials=re;exports.captureScreenshotFile=je;exports.colors=T;exports.createStore=ve;exports.createTranslator=M;exports.createTransport=ye;exports.dateLocale=z;exports.default=Je;exports.formatTime=te;exports.guessAttachmentKind=Po;exports.pickRecorderMime=Ue;exports.renderInlineMarkdown=Ae;exports.renderMarkdown=Ve;exports.resolveLanguage=oe;exports.startScreenRecording=He;exports.tokensCss=ke;exports.uuid=de;exports.v4=de;