@_solaris/messenger-widget 0.5.39 → 0.5.41
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.
- package/dist/iframe/iframe.css +1 -1
- package/dist/iframe/iframe.js +25 -24
- package/dist/messenger.cjs +10 -9
- package/dist/messenger.js +1188 -1095
- package/dist/snippet.js +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/messenger.cjs
CHANGED
|
@@ -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"],ae="/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 a(c,m){const f=n.listeners.get(c);f&&f.forEach(_=>{try{_(m)}catch(y){console.error("[transport] listener",c,y)}})}function s(c){n.connection!==c&&(n.connection=c,a("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}${ae}${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}${ae}/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}${ae}/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",()=>a("error",new Error("SSE error"))),n.eventSource=c,s("open")}catch(c){console.error("[transport] SSE open failed",c),a("error",c)}}function H(c,m){try{const f=JSON.parse(m),_=f&&typeof f=="object"&&"data"in f?f.data:f;a(c,_)}catch(f){console.error("[transport] bad SSE payload",c,f)}}function R(){n.eventSource&&(n.eventSource.close(),n.eventSource=null),n.connection!=="paused"&&s("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 se(){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,a("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(se,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(),s("paused"))},Ze);else{if(n.hiddenGraceTimer){clearTimeout(n.hiddenGraceTimer),n.hiddenGraceTimer=null;return}s("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 a(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 s(){for(const d of r)try{d()}catch{}t.stop()}async function o(d){const u=se(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 se(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:a,destroy:s,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"),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=`
|
|
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 {
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
--wm-g900: ${T.g900};
|
|
17
17
|
--wm-a: ${T.accent};
|
|
18
18
|
--wm-al: ${T.accentLight};
|
|
19
|
+
--wm-primary: ${T.accent};
|
|
19
20
|
--wm-green: ${T.green};
|
|
20
21
|
--wm-red: ${T.red};
|
|
21
22
|
--wm-redBg: ${T.redBg};
|
|
@@ -46,12 +47,12 @@
|
|
|
46
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
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.
|
|
49
|
-
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],
|
|
50
|
-
${l}`)}return
|
|
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} :
|
|
51
|
+
${l}`)}return a.join(`
|
|
51
52
|
|
|
52
|
-
`)}function rt(t,n,r=M()){const
|
|
53
|
-
`));
|
|
54
|
-
`)}function it(t,n,r=M(),a){if(!t)return;const s=at(t,n||[],r,P(a)),o=new Blob([s],{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 s;if(!this.soundEnabled&&!this.browserNotifEnabled||!n||!t||!G(t))return;const r=typeof document<"u"&&document.hidden;this.isOpen&&!r&&((s=this.currentConv)==null?void 0:s.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,a=n.createOscillator(),s=n.createGain();a.connect(s),s.connect(n.destination),a.type="sine",a.frequency.setValueAtTime(880,r),a.frequency.exponentialRampToValueAtTime(1320,r+.08),s.gain.setValueAtTime(0,r),s.gain.linearRampToValueAtTime(.12,r+.02),s.gain.exponentialRampToValueAtTime(1e-4,r+.28),a.start(r),a.stop(r+.32)}catch{}},showBrowserNotification(t,n){if(typeof Notification>"u"||Notification.permission!=="granted")return;const r=n==null?void 0:n.author,a=!r||r.type==="agent_ia",o=((r==null?void 0:r.name)||(a?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",a=>{const s=a==null?void 0:a.conversation_id,o=a==null?void 0:a.message;s&&o&&this.paceLiveMessage(o,s)});this._liveRevealConvSnapshot=new Map((((r=this.s)==null?void 0:r.conversations)||[]).map(a=>[a.id,(a==null?void 0:a.last_message_at)||""]));const n=this.transport.on("activity",a=>{this.handleLiveActivity(a)});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 s,o;const n=t==null?void 0:t.conversations;if(!Array.isArray(n)||!this.store)return;const r=this._liveRevealConvSnapshot||new Map,a=[];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&&a.push(i.id)}this._liveRevealConvSnapshot=new Map(n.map(i=>[i.id,(i==null?void 0:i.last_message_at)||""]));for(const i of a)try{const l=await((o=(s=this.store).fetchSinceLast)==null?void 0:o.call(s,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(),a=((t==null?void 0:t.text_md)||"").length,s=Math.min(mt,Math.max(ut,a*dt)),i=Math.max(r+ct,this.nextRevealAt+ht)+s;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 s;if(!Array.isArray(t)||!t.length)return;const r=Date.now(),a={...this.revealedAt};for(const o of t){if((o==null?void 0:o.id)==null||a[o.id]!==void 0)continue;if(!G(o)){a[o.id]=r;continue}const i=o!=null&&o.created_at?Date.parse(o.created_at):NaN;if(!Number.isFinite(i)||i<this.convOpenedAt){a[o.id]=r;continue}const l=typeof(o==null?void 0:o.text_md)=="string"&&o.text_md.trim().length>0,p=Array.isArray((s=o==null?void 0:o.payload)==null?void 0:s.attachments)&&o.payload.attachments.length>0;if(!l&&!p){a[o.id]=r;continue}a[o.id]=0,this.scheduleReveal(o,n)}this.revealedAt=a},paceLiveMessage(t,n){var s;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,a=Array.isArray((s=t==null?void 0:t.payload)==null?void 0:s.attachments)&&t.payload.attachments.length>0;if(!r&&!a){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 a=D(t.last_read_message_id),s=D(r);s!=null&&(a!=null&&s<=a||(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[a,s]of n)r[a]=s;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,a,s,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,a,s,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,a,s,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,a,s,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 a=0;a<3;a++)r.push(t[(n+a)%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 sn(t,n,r,a,s,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",sn],["__scopeId","data-v-0da6fbcd"]]);function Be(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function an(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,(a,s)=>{const o=r.length;return r.push(s),`${me}CODE${o}${me}`}),n=n.replace(/\[([^\]\n]+)\]\(([^)\s]+)\)/g,(a,s,o)=>an(o)?`<a href="${o}" target="_blank" rel="noopener noreferrer">${s}</a>`:s),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,(a,s)=>`<code class="wm-md-code">${r[+s]}</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(`
|
|
55
|
-
`),r=[];let
|
|
56
|
-
`)}</code></pre>`});continue}if(/^\s*[-*]\s+/.test(o)){const v=[];for(;
|
|
57
|
-
`)}return s}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},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}:n!=null&&n.avatar_url||n!=null&&n.name?{size:40,name:n.name||"",imageUrl:n.avatar_url||null}:{size:40,name:"",imageUrl:this.defaultIconUrl}},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()),a=new Date;if(n.toDateString()===a.toDateString())return n.toLocaleTimeString(r,{hour:"2-digit",minute:"2-digit"});if(a.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={key:0,class:"wm-onb__section wm-onb__section--card"},_n={class:"wm-onb__section-title"},vn=["onClick"],yn={class:"wm-onb__card-icon"},kn={width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.7","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:1,class:"wm-onb__section wm-onb__section--card"},Nn={class:"wm-onb__section-title"},Sn={class:"wm-onb__alertList"},An=["onClick"],Vn=["aria-label"],Mn={class:"wm-onb__alert-body"},Tn={class:"wm-onb__alert-title"},xn=["innerHTML"],Ln={class:"wm-onb__alert-meta"},On={key:0,class:"wm-onb__alert-time"},Dn={class:"wm-onb__alert-resume"},In={key:2,class:"wm-onb__section wm-onb__section--card"},Rn={class:"wm-onb__section-title"},Fn={class:"wm-onb__search"},Pn=["placeholder","aria-label"],Un={class:"wm-onb__list"},zn=["onClick"],jn=["aria-label"],Hn={class:"wm-onb__thread-body"},qn={class:"wm-onb__thread-title"},Kn=["innerHTML"],$n={class:"wm-onb__thread-meta"},Wn={key:0,class:"wm-onb__thread-time"},Gn={key:0,class:"wm-onb__empty"};function Yn(t,n,r,a,s,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:"12",height:"12",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:"M12 5v14M5 12h14"})])],-1)),e.createElementVNode("span",null,e.toDisplayString(r.busy?"…":o.t("onboarding.start")),1)],8,pn)]),r.quickLinks.length?(e.openBlock(),e.createElementBlock("div",gn,[e.createElementVNode("div",_n,e.toDisplayString(o.t("onboarding.quickAccess")),1),e.createElementVNode("div",{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}]),onClick:v=>t.$emit("select",l)},[e.createElementVNode("span",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.description?(e.openBlock(),e.createElementBlock("span",Cn,e.toDisplayString(l.description),1)):e.createCommentVNode("",!0)])],10,vn))),128))],2)])):e.createCommentVNode("",!0),o.unreadThreads.length?(e.openBlock(),e.createElementBlock("div",Bn,[e.createElementVNode("div",Nn,e.toDisplayString(o.t("onboarding.unreadConversations")),1),e.createElementVNode("div",Sn,[(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)])},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.avatarComponent(l)),e.mergeProps({ref_for:!0},o.avatarProps(l)),null,16)),e.createElementVNode("span",{class:"wm-onb__alert-dot","aria-label":o.t("onboarding.unread")},null,8,Vn)],2),e.createElementVNode("span",Mn,[e.createElementVNode("span",Tn,e.toDisplayString(l.title),1),e.createElementVNode("span",{class:"wm-onb__alert-preview",innerHTML:o.renderPreview(l.preview)},null,8,xn)]),e.createElementVNode("span",Ln,[o.formatTs(l._ts)?(e.openBlock(),e.createElementBlock("span",On,e.toDisplayString(o.formatTs(l._ts)),1)):e.createCommentVNode("",!0),e.createElementVNode("span",Dn,e.toDisplayString(o.t("onboarding.resume")),1)])],8,An))),128))])])):e.createCommentVNode("",!0),r.openThreads.length?(e.openBlock(),e.createElementBlock("div",In,[e.createElementVNode("div",Rn,e.toDisplayString(o.t("onboarding.recentConversations")),1),e.createElementVNode("div",Fn,[n[4]||(n[4]=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=>s.query=l),type:"text",placeholder:o.t("onboarding.search"),"aria-label":o.t("onboarding.search")},null,8,Pn),[[e.vModelText,s.query]])]),e.createElementVNode("div",Un,[(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)])},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.avatarComponent(l)),e.mergeProps({ref_for:!0},o.avatarProps(l)),null,16)),l.unread?(e.openBlock(),e.createElementBlock("span",{key:0,class:"wm-onb__thread-dot","aria-label":o.t("onboarding.unread")},null,8,jn)):e.createCommentVNode("",!0)],2),e.createElementVNode("span",Hn,[e.createElementVNode("span",qn,e.toDisplayString(l.title),1),e.createElementVNode("span",{class:"wm-onb__thread-preview",innerHTML:o.renderPreview(l.preview)},null,8,Kn)]),e.createElementVNode("span",$n,[o.formatTs(l._ts)?(e.openBlock(),e.createElementBlock("span",Wn,e.toDisplayString(o.formatTs(l._ts)),1)):e.createCommentVNode("",!0),n[5]||(n[5]=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,zn))),128)),o.filteredThreads.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Gn,e.toDisplayString(o.t("onboarding.noResults",{query:s.query})),1))])])):e.createCommentVNode("",!0)])}const Ae=A(ln,[["render",Yn],["__scopeId","data-v-ee89cb1d"]]);function Jn(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 Qn={name:"WmActionResult",props:{state:{type:String,default:"success"},label:{type:String,required:!0},detail:{type:String,default:""}},computed:{detailText(){return Jn(this.detail)}}},Xn={class:"wm-result__icon","aria-hidden":"true"},Zn={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"},er={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"},tr={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"},nr={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"},rr={class:"wm-result__body"},or={class:"wm-result__label"},sr={class:"wm-result__detail"};function ar(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-result",`wm-result--${r.state}`])},[e.createElementVNode("span",Xn,[r.state==="success"?(e.openBlock(),e.createElementBlock("svg",Zn,[...n[0]||(n[0]=[e.createElementVNode("path",{d:"M20 6L9 17l-5-5"},null,-1)])])):r.state==="rejected"?(e.openBlock(),e.createElementBlock("svg",er,[...n[1]||(n[1]=[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"},null,-1)])])):r.state==="awaiting"?(e.openBlock(),e.createElementBlock("svg",tr,[...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",nr,[...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",rr,[e.createElementVNode("span",or,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",sr,e.toDisplayString(o.detailText),1)],64)):e.createCommentVNode("",!0)])],2)}const Ve=A(Qn,[["render",ar],["__scopeId","data-v-7284acd0"]]),ir={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:[]}}},lr={class:"wm-art wm-art--formResponse"},cr={class:"wm-art__head"},dr={class:"wm-art__title"},ur={class:"wm-art__badge wm-art__badge--success"},mr={class:"wm-art__body"},hr={class:"wm-art__fieldLabel"};function fr(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",lr,[e.createElementVNode("div",cr,[e.createElementVNode("div",dr,e.toDisplayString(r.data.title||o.t("form.title")),1),e.createElementVNode("span",ur,[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",mr,[(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",hr,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(ir,[["render",fr],["__scopeId","data-v-713aecf1"]]),pr={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}}},gr={class:"wm-art wm-art--infoCard"},_r={key:0,class:"wm-art__image"},vr=["src","alt"],yr={class:"wm-art__head"},kr={class:"wm-art__headMain"},wr={class:"wm-art__title"},br={key:0,class:"wm-art__subtitle"},Er={key:1,class:"wm-art__body"},Cr={key:0,class:"wm-art__text"},Br={class:"wm-art__fieldLabel"};function Nr(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",gr,[r.data.image_url?(e.openBlock(),e.createElementBlock("figure",_r,[e.createElementVNode("img",{src:r.data.image_url,alt:r.data.title||"",loading:"lazy"},null,8,vr)])):e.createCommentVNode("",!0),e.createElementVNode("div",yr,[e.createElementVNode("div",kr,[e.createElementVNode("div",wr,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",Er,[r.data.body?(e.openBlock(),e.createElementBlock("div",Cr,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",Br,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(pr,[["render",Nr],["__scopeId","data-v-7eae0e4a"]]);function Sr(t,n,r){if(!t)return"";const a=new Date(t);if(Number.isNaN(a.getTime()))return t;const s=a.toLocaleDateString(n,{day:"numeric",month:"long",year:"numeric"}),o=a.toLocaleTimeString(n,{hour:"2-digit",minute:"2-digit"});return`${s}${r}${o}`}const Ar={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 Sr((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}}},Vr={class:"wm-art wm-art--ticket"},Mr={class:"wm-art__head wm-tk__head"},Tr={class:"wm-art__title wm-tk__title"},xr={class:"wm-tk__sub"},Lr={class:"wm-tk__ref"},Or={key:0,class:"wm-tk__text"},Dr={key:0,class:"wm-art__body"},Ir={class:"wm-art__fieldLabel"},Rr=["data-level"],Fr={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"},Pr={key:1,class:"wm-art__footer wm-tk__footer"};function Ur(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",Vr,[e.createElementVNode("div",Mr,[e.createElementVNode("div",Tr,e.toDisplayString(r.data.title),1),e.createElementVNode("div",xr,[e.createElementVNode("div",Lr,[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",Or,e.toDisplayString(r.data.body),1)):e.createCommentVNode("",!0)]),o.fields.length?(e.openBlock(),e.createElementBlock("div",Dr,[(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",Ir,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,Rr)):o.isDate(i.label)?(e.openBlock(),e.createElementBlock("svg",Fr,[...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",Pr,[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(Ar,[["render",Ur],["__scopeId","data-v-5f30c914"]]),zr={form_response:Me,info_card:Te,ticket:xe},jr={name:"WmArtifactRenderer",props:{artifact:{type:Object,required:!0}},computed:{component(){var n;const t=(n=this.artifact)==null?void 0:n.kind;return t&&zr[t]||null}}};function Hr(t,n,r,a,s,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(jr,[["render",Hr]]),qr={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,a;const t=(r=this.attachment)==null?void 0:r.type;if(t)return t;const n=(((a=this.attachment)==null?void 0:a.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()}}},Kr=["href"],$r=["src","alt"],Wr=["src"],Gr=["src"],Yr=["href","download"],Jr={class:"wm-att__main"},Qr={class:"wm-att__name"},Xr={key:0,class:"wm-att__meta"},Zr={key:0,class:"wm-att__spin","aria-hidden":"true"};function eo(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-att",["wm-att--"+(o.kind||"file")]])},[o.kind==="image"&&s.url?(e.openBlock(),e.createElementBlock("a",{key:0,href:o.safeHref,target:"_blank",rel:"noopener",class:"wm-att__imgWrap"},[e.createElementVNode("img",{src:s.url,alt:o.displayName,loading:"lazy"},null,8,$r)],8,Kr)):o.kind==="audio"&&s.url?(e.openBlock(),e.createElementBlock("audio",{key:1,src:s.url,controls:"",preload:"metadata"},null,8,Wr)):o.kind==="video"&&s.url?(e.openBlock(),e.createElementBlock("video",{key:2,src:s.url,controls:"",preload:"metadata"},null,8,Gr)):(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",Jr,[e.createElementVNode("span",Qr,e.toDisplayString(o.displayName),1),o.sizeLabel?(e.openBlock(),e.createElementBlock("span",Xr,e.toDisplayString(o.sizeLabel),1)):e.createCommentVNode("",!0)]),s.loading?(e.openBlock(),e.createElementBlock("span",Zr)):e.createCommentVNode("",!0)],8,Yr))],2)}const Oe=A(qr,[["render",eo],["__scopeId","data-v-0c877a62"]]),to={name:"WmBubble",props:{role:{type:String,default:"ai"},text:{type:String,default:""}},computed:{rendered(){return Se(this.text)}}},no=["innerHTML"];function ro(t,n,r,a,s,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,no)],!0)],2)}const De=A(to,[["render",ro],["__scopeId","data-v-7ab13147"]]),oo={name:"WmTyping"},so={class:"wm-typing"};function ao(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",so,[...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(oo,[["render",ao],["__scopeId","data-v-df2447fd"]]);function F(t){return t?t.client_msg_id||t.id:""}const io={transferred_to_human:"system.transferredToHuman",assigned:"system.assigned",unassigned:"system.unassigned",resolved:"system.resolved",reopened:"system.reopened",idle:"system.idle"},lo=80,co=200,uo={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,a,s,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===(((a=i==null?void 0:i.author)==null?void 0:a.name)||""))?p.messages.push(i):t.push({key:`g-${F(i)}`,role:l,agentName:((s=i==null?void 0:i.author)==null?void 0:s.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 a=r.messages[0];if(!a)continue;const s=D(a.id);if(s!=null&&!(s<=t)&&!(n&&a.created_at&&a.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 a of t){const s=F(a);if(s&&n.has(s)){r=n.get(s);break}}r==null&&(r=++this._groupIdCounter);for(const a of t){const s=F(a);s&&n.set(s,r)}return`g-${r}`},isAtBottom(t){return t.scrollHeight-t.scrollTop-t.clientHeight<=lo},onScroll(){const t=this.$refs.scrollEl;t&&(this.showScrollDown=!this.isAtBottom(t),!(this.loadingMore||!this.hasMore)&&(this._pendingLoadMore||t.scrollTop<=co&&(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 a=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;a={rowKey:o.rowKey,relY:i.getBoundingClientRect().top-l}}}}const s={forceBottom:n,wasPinned:r,anchor:a};this._scrollSnap=s,this.$nextTick(()=>{if(this._scrollSnap=null,s.forceBottom||s.wasPinned){t.scrollTop=t.scrollHeight;return}if(!s.anchor)return;const o=()=>{const i=s.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 a=null;for(const s of r)if(a||(a=s),s.getBoundingClientRect().bottom>=n)return{rowKey:s.dataset.rowKey};return a?{rowKey:a.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,a;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=(a=t==null?void 0:t.author)==null?void 0:a.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,a=(U=r[n])==null?void 0:U.kind,s=(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=s==null?void 0:s.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,a==null?void 0:a.top)&&(V=p),g&&w(k,g,a==null?void 0:a.bottom)&&(I=p)):(v&&(V=p),(g||!o)&&(I=p),v&&w(S,v,a==null?void 0:a.top)&&(B=p),g&&w(k,g,a==null?void 0:a.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 a;const r=(a=t==null?void 0:t.items)==null?void 0:a[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,a=Object.keys(r),s=Object.keys(n);if(a.length===s.length){let o=!0;for(const i of s)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,a,s,o,i,l;const n=t==null?void 0:t.payload;return n?n.state==="success"?((r=n.success)==null?void 0:r.summary)||((s=(a=n.success)==null?void 0:a.metadata)==null?void 0:s.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,a;const n=(a=(r=t==null?void 0:t.payload)==null?void 0:r.success)==null?void 0:a.artifact;return!n||typeof n!="object"||typeof n.kind!="string"?null:n},systemLabel(t){var s,o,i;const n=(s=t==null?void 0:t.payload)==null?void 0:s.event,r=io[n],a=((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:a}):(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)}}},mo={class:"wm-list__wrap"},ho={key:0,class:"wm-list__loadMore",role:"status","aria-live":"polite"},fo={class:"wm-list__loadMore-lbl"},po={key:1,class:"wm-list__historyEnd"},go={key:2,class:"wm-list__sep"},_o={class:"wm-list__sep-label"},vo={key:0,class:"wm-list__sep wm-list__sep--unread"},yo={class:"wm-list__sep-label wm-list__sep-label--unread"},ko={key:0,class:"wm-list__sysep"},wo={class:"wm-list__sysep-label"},bo=["data-row-key","onPointerdown"],Eo={key:0,class:"wm-list__avatarSlot"},Co={key:5,class:"wm-list__body"},Bo={key:0},No={key:1,"aria-hidden":"true"},So={key:2},Ao={key:0},Vo={key:1,"aria-hidden":"true"},Mo={key:2},To={key:3,class:"wm-list__row wm-list__row--ai fade-up"},xo={class:"wm-list__avatarSlot"},Lo=["aria-label","title"];function Oo(t,n,r,a,s,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",mo,[e.createElementVNode("div",{ref:"scrollEl",class:e.normalizeClass(["wm-list",{"wm-list--silent":s.silentFades}]),onScrollPassive:n[4]||(n[4]=(...k)=>o.onScroll&&o.onScroll(...k))},[r.loadingMore?(e.openBlock(),e.createElementBlock("div",ho,[n[6]||(n[6]=e.createElementVNode("span",{class:"wm-list__loadMore-spinner","aria-hidden":"true"},null,-1)),e.createElementVNode("span",fo,e.toDisplayString(o.t("messageList.loadingHistory")),1)])):o.historyExhausted?(e.openBlock(),e.createElementBlock("div",po,e.toDisplayString(o.t("messageList.conversationStart")),1)):e.createCommentVNode("",!0),r.dateLabel?(e.openBlock(),e.createElementBlock("div",go,[n[7]||(n[7]=e.createElementVNode("div",{class:"wm-list__line"},null,-1)),e.createElementVNode("span",_o,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",vo,[n[9]||(n[9]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--unread"},null,-1)),e.createElementVNode("span",yo,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",ko,[n[11]||(n[11]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--strong"},null,-1)),e.createElementVNode("span",wo,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",Eo,[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",Co,[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&&s.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",Bo,e.toDisplayString(o.roleLabel(k)),1)):e.createCommentVNode("",!0),k.role!=="user"&&o.timeOf(w.message)?(e.openBlock(),e.createElementBlock("span",No,"·")):e.createCommentVNode("",!0),o.timeOf(w.message)?(e.openBlock(),e.createElementBlock("span",So,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",Ao,e.toDisplayString(o.roleLabel(k)),1)):e.createCommentVNode("",!0),k.role!=="user"&&o.lastTimeOf(k)?(e.openBlock(),e.createElementBlock("span",Vo,"·")):e.createCommentVNode("",!0),o.lastTimeOf(k)?(e.openBlock(),e.createElementBlock("span",Mo,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",To,[e.createElementVNode("div",xo,[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(()=>[s.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,Lo)):e.createCommentVNode("",!0)]),_:1})])}const Re=A(uo,[["render",Oo],["__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,a;return(a=(r=window.MediaRecorder).isTypeSupported)==null?void 0:a.call(r,n)})||""}function Pe({audio:t}){return{video:!0,audio:!!t,selfBrowserSurface:"include",surfaceSwitching:"include",systemAudio:t?"include":"exclude"}}function Do(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 Io(t)}catch(n){return console.error("[media] screenshot capture",n),null}finally{t.getTracks().forEach(n=>{n.stop()})}}async function Io(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,a=n.videoHeight||720,s=document.createElement("canvas");s.width=r,s.height=a,s.getContext("2d").drawImage(n,0,0,r,a);const o=await new Promise((l,p)=>{s.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 a;try{a=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 s=[];let o=null,i=!1;a.addEventListener("dataavailable",g=>{g.data&&g.data.size>0&&s.push(g.data)}),a.addEventListener("stop",()=>{var g,E;if(o&&clearInterval(o),n.getTracks().forEach(S=>{S.stop()}),s.length){const S=a.mimeType||r||"video/webm",k=new Blob(s,{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,a.state!=="inactive"))try{a.stop()}catch(g){console.error("[media] recorder stop",g)}}try{a.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 a.state}}}const Ro=[{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"}],Fo={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 Ro.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)}}},Po={key:0,class:"wm-rec"},Uo={class:"wm-rec__lbl"},zo={key:1,class:"wm-compose__menu",role:"menu"},jo=["disabled","onClick"],Ho={class:"wm-compose__menuIcon"},qo={viewBox:"0 0 24 24",width:"14",height:"14","aria-hidden":"true"},Ko=["d"],$o=["placeholder","disabled"],Wo={class:"wm-compose__actions"},Go=["title","aria-label","disabled"],Yo=["disabled","aria-label"];function Jo(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-compose-wrap",{"wm-compose-wrap--sheet":r.displayMode==="sheet"}]),style:e.normalizeStyle(s.kbOffset?{transform:`translateY(-${s.kbOffset}px)`}:null)},[s.recording?(e.openBlock(),e.createElementBlock("div",Po,[n[8]||(n[8]=e.createElementVNode("span",{class:"wm-rec__dot","aria-hidden":"true"},null,-1)),e.createElementVNode("span",Uo,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":s.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),s.attachOpen?(e.openBlock(),e.createElementBlock("div",{key:0,class:"wm-compose__overlay",onClick:n[2]||(n[2]=i=>s.attachOpen=!1)})):e.createCommentVNode("",!0),s.attachOpen?(e.openBlock(),e.createElementBlock("div",zo,[(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",Ho,[(e.openBlock(),e.createElementBlock("svg",qo,[e.createElementVNode("path",{d:i.path,stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round",fill:"none"},null,8,Ko)]))]),e.createElementVNode("span",null,e.toDisplayString(i.label),1)],8,jo))),128))])):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("textarea",{ref:"inputEl","onUpdate:modelValue":n[3]||(n[3]=i=>s.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,$o),[[e.vModelText,s.local]]),e.createElementVNode("div",Wo,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["wm-compose__icon",{"is-open":s.attachOpen}]),title:r.attachLabel,"aria-label":r.attachLabel,disabled:s.recording,onClick:n[6]||(n[6]=i=>s.attachOpen=!s.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,Go),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,Yo)])],34)],6)}const je=A(Fo,[["render",Jo],["__scopeId","data-v-01e81a27"]]),Qo={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("§")}}},Xo=["onClick"];function Zo(t,n,r,a,s,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,Xo))),128))])):e.createCommentVNode("",!0)}const He=A(Qo,[["render",Zo],["__scopeId","data-v-47ad8085"]]),es={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")}}},ts={class:"wm-approval"},ns={class:"wm-approval__head"},rs={class:"wm-approval__icon"},os={class:"wm-approval__main"},ss={class:"wm-approval__title"},as={key:0,class:"wm-approval__detail"},is={class:"wm-approval__actions"};function ls(t,n,r,a,s,o){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",ts,[e.createElementVNode("div",ns,[e.createElementVNode("div",rs,[e.createVNode(i,{size:24,name:r.agentName,"image-url":r.agentAvatarUrl},null,8,["name","image-url"])]),e.createElementVNode("div",os,[e.createElementVNode("div",ss,e.toDisplayString(r.action),1),r.detail?(e.openBlock(),e.createElementBlock("div",as,e.toDisplayString(r.detail),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",is,[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(es,[["render",ls],["__scopeId","data-v-a2bed37e"]]);let fe=0;const cs=new Set(["text","textarea","number","boolean","select","multiselect","date"]),ds={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)||!cs.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 a=Array.isArray(this.values[t])?this.values[t].slice():[],s=a.indexOf(n);r&&s===-1?a.push(n):!r&&s!==-1&&a.splice(s,1),this.values={...this.values,[t]:a}},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}}}},us={class:"wm-form"},ms={class:"wm-form__head"},hs={class:"wm-form__icon"},fs={class:"wm-form__main"},ps={class:"wm-form__title"},gs={key:0,class:"wm-form__detail"},_s=["for"],vs={key:0,class:"wm-form__req","aria-hidden":"true"},ys=["id","onUpdate:modelValue","placeholder","required","disabled"],ks=["id","onUpdate:modelValue","placeholder","required","disabled"],ws=["id","onUpdate:modelValue","placeholder","required","disabled"],bs=["id","onUpdate:modelValue","required","disabled"],Es={key:4,class:"wm-form__bool"},Cs=["id","onUpdate:modelValue","disabled"],Bs=["id","onUpdate:modelValue","required","disabled"],Ns={value:"",disabled:""},Ss=["value"],As={key:6,class:"wm-form__multi"},Vs=["value","checked","disabled","onChange"],Ms={key:0,class:"wm-form__err"},Ts=["disabled"],xs={key:0,class:"wm-form__spinner","aria-hidden":"true"},Ls={key:2,class:"wm-form__doneLbl"};function Os(t,n,r,a,s,o){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",us,[e.createElementVNode("div",ms,[e.createElementVNode("div",hs,[e.createVNode(i,{size:24,name:r.agentName,"image-url":r.agentAvatarUrl},null,8,["name","image-url"])]),e.createElementVNode("div",fs,[e.createElementVNode("div",ps,e.toDisplayString(r.form.title||o.t("form.title")),1),r.form.description?(e.openBlock(),e.createElementBlock("div",gs,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-${s._uid}-${l.key}`,class:"wm-form__label"},[e.createTextVNode(e.toDisplayString(l.label),1),l.required?(e.openBlock(),e.createElementBlock("span",vs,"*")):e.createCommentVNode("",!0)],8,_s),l.type==="text"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,id:`wm-f-${s._uid}-${l.key}`,"onUpdate:modelValue":p=>s.values[l.key]=p,type:"text",class:"wm-form__input",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||s.busy},null,8,ys)),[[e.vModelText,s.values[l.key]]]):l.type==="textarea"?e.withDirectives((e.openBlock(),e.createElementBlock("textarea",{key:1,id:`wm-f-${s._uid}-${l.key}`,"onUpdate:modelValue":p=>s.values[l.key]=p,class:"wm-form__textarea",rows:"3",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||s.busy},null,8,ks)),[[e.vModelText,s.values[l.key]]]):l.type==="number"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:2,id:`wm-f-${s._uid}-${l.key}`,"onUpdate:modelValue":p=>s.values[l.key]=p,type:"number",class:"wm-form__input",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||s.busy},null,8,ws)),[[e.vModelText,s.values[l.key],void 0,{number:!0}]]):l.type==="date"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:3,id:`wm-f-${s._uid}-${l.key}`,"onUpdate:modelValue":p=>s.values[l.key]=p,type:"date",class:"wm-form__input",required:l.required,disabled:r.readOnly||s.busy},null,8,bs)),[[e.vModelText,s.values[l.key]]]):l.type==="boolean"?(e.openBlock(),e.createElementBlock("label",Es,[e.withDirectives(e.createElementVNode("input",{id:`wm-f-${s._uid}-${l.key}`,"onUpdate:modelValue":p=>s.values[l.key]=p,type:"checkbox",disabled:r.readOnly||s.busy},null,8,Cs),[[e.vModelCheckbox,s.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-${s._uid}-${l.key}`,"onUpdate:modelValue":p=>s.values[l.key]=p,class:"wm-form__select",required:l.required,disabled:r.readOnly||s.busy},[e.createElementVNode("option",Ns,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,Ss))),128))],8,Bs)),[[e.vModelSelect,s.values[l.key]]]):l.type==="multiselect"?(e.openBlock(),e.createElementBlock("div",As,[(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(s.values[l.key])&&s.values[l.key].includes(p.value),disabled:r.readOnly||s.busy,onChange:v=>o.toggleMulti(l.key,p.value,v.target.checked)},null,40,Vs),e.createElementVNode("span",null,e.toDisplayString(p.label),1)]))),128))])):e.createCommentVNode("",!0)]))),128)),s.error?(e.openBlock(),e.createElementBlock("div",Ms,e.toDisplayString(s.error),1)):e.createCommentVNode("",!0),r.readOnly?(e.openBlock(),e.createElementBlock("div",Ls,e.toDisplayString(o.t("form.responseSent")),1)):(e.openBlock(),e.createElementBlock("button",{key:1,type:"submit",class:"wm-form__submit",disabled:s.busy},[s.busy?(e.openBlock(),e.createElementBlock("span",xs)):e.createCommentVNode("",!0),e.createElementVNode("span",null,e.toDisplayString(s.busy?o.t("common.sending"):r.form.submit_label||o.t("common.send")),1)],8,Ts))],32)])}const Ke=A(ds,[["render",Os],["__scopeId","data-v-fe65cc56"]]),Ds={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})}}},Is={class:"wm-fb"},Rs={class:"wm-fb__title"},Fs={class:"wm-fb__sub"},Ps={class:"wm-fb__row"},Us=["onClick"],zs={class:"wm-fb__emoji"},js={class:"wm-fb__label"},Hs=["disabled"],qs={key:1,class:"wm-fb__done"},Ks={class:"wm-fb__doneTitle"},$s={class:"wm-fb__doneSub"};function Ws(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",Is,[r.done?(e.openBlock(),e.createElementBlock("div",qs,[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",Ks,e.toDisplayString(o.t("feedback.doneTitle")),1),e.createElementVNode("div",$s,e.toDisplayString(o.t("feedback.doneSubtitle")),1)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("div",Rs,e.toDisplayString(o.t("feedback.question")),1),e.createElementVNode("div",Fs,e.toDisplayString(o.t("feedback.subtitle")),1),e.createElementVNode("div",Ps,[(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":s.sel===i.v}]),onClick:l=>s.sel=i.v},[e.createElementVNode("span",zs,e.toDisplayString(i.e),1),e.createElementVNode("span",js,e.toDisplayString(i.l),1)],10,Us))),128))]),e.createElementVNode("button",{type:"button",class:"wm-fb__send",disabled:!s.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,Hs)],64))])}const $e=A(Ds,[["render",Ws],["__scopeId","data-v-9b630564"]]),Gs={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)}}},Ys={class:"wm-mm"},Js={class:"wm-mm__pop",role:"menu"},Qs={key:0,class:"wm-mm__section"},Xs={class:"wm-mm__label"},Zs={class:"wm-mm__label"},ea={key:1,class:"wm-mm__sep"},ta={class:"wm-mm__section"},na={class:"wm-mm__label"},ra={class:"wm-mm__label"},oa={class:"wm-mm__section"},sa={class:"wm-mm__label"},aa={class:"wm-mm__label"};function ia(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",Ys,[e.createElementVNode("div",{class:"wm-mm__scrim",onClick:n[0]||(n[0]=i=>t.$emit("close"))}),e.createElementVNode("div",Js,[r.canRename||r.canExport?(e.openBlock(),e.createElementBlock("div",Qs,[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",Xs,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",Zs,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",ea)):e.createCommentVNode("",!0),e.createElementVNode("div",ta,[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",na,e.toDisplayString(o.t("moreMenu.sound")),1),e.createElementVNode("span",{class:e.normalizeClass(["wm-mm__toggle",{"wm-mm__toggle--on":s.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",ra,e.toDisplayString(o.t("moreMenu.browserNotifications")),1),e.createElementVNode("span",{class:e.normalizeClass(["wm-mm__toggle",{"wm-mm__toggle--on":s.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",oa,[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",sa,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",aa,e.toDisplayString(o.t("moreMenu.helpCenter")),1)])):e.createCommentVNode("",!0)])])])}const We=A(Gs,[["render",ia],["__scopeId","data-v-76281e95"]]),la={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())}}},ca={class:"wm-dialog"},da={class:"wm-dialog__card",role:"dialog","aria-modal":"true"},ua={class:"wm-dialog__head"},ma={class:"wm-dialog__title"},ha=["aria-label"],fa={class:"wm-dialog__body"},pa=["placeholder"],ga={class:"wm-dialog__actions"},_a=["disabled"];function va(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",ca,[e.createElementVNode("div",{class:"wm-dialog__scrim",onClick:n[0]||(n[0]=i=>t.$emit("close"))}),e.createElementVNode("div",da,[e.createElementVNode("div",ua,[e.createElementVNode("div",ma,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,ha)]),e.createElementVNode("div",fa,[e.withDirectives(e.createElementVNode("input",{ref:"input","onUpdate:modelValue":n[2]||(n[2]=i=>s.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,pa),[[e.vModelText,s.value]])]),e.createElementVNode("div",ga,[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,_a)])])])}const ya=A(la,[["render",va],["__scopeId","data-v-6d5f94a8"]]),pe="ww-messenger-tokens",ka={name:"Messenger",components:{Launcher:be,Header:Ce,Onboarding:Ae,MessageList:Re,Composer:je,SuggestionChips:He,ApprovalCard:qe,FormCard:Ke,Feedback:$e,MoreMenu:We,RenameDialog:ya},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,a,s,o;const t=(r=this.s)==null?void 0:r.customer,n=t&&(t.language||((a=t.values)==null?void 0:a.language));return n||((o=(s=this.context)==null?void 0:s.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(a=>{var v;const s=t[a.id]||[],o=D(a.last_read_message_id);let i=0,l=null;for(let g=s.length-1;g>=0;g--){const E=s[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(!s.length){const g=D(a.last_message_id);g!=null&&(o==null||g>o)&&(i=1,l=a.last_message_author||null)}const p=s.filter(g=>!((g==null?void 0:g.id)!=null&&n[g.id]===0));return{...a,_preview:ot(a,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,a)=>r._ts<a._ts?1:r._ts>a._ts?-1:0)},latestUnreads(){var r;const t=((r=this.s)==null?void 0:r.messagesByConv)||{},n=[];for(const a of this.drawerConversations){if(!a._unread)continue;const s=ue(a,t[a.id]||[]),o=a._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:a.id,preview:a._preview||this.t("notification.youHaveNewMessage"),ts:s,count:a._unreadCount||1,senderName:l,senderAvatarUrl:p})}return n.sort((a,s)=>a.ts<s.ts?1:a.ts>s.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(a=>a.icon==="status"&&a.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(a=>(a.icon==="chat"||a.icon==="help")&&a.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},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,a;if(!this.currentConv)return null;const t=((n=this.s.messagesByConv)==null?void 0:n[this.currentConv.id])||[];for(let s=t.length-1;s>=0;s--)if(((a=(r=t[s])==null?void 0:r.author)==null?void 0:a.type)==="agent_human")return t[s].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,a;const t=this.currentConv;if(!t)return[];if(!t._draft){const s=(a=(r=this.s)==null?void 0:r.paginationByConv)==null?void 0:a[t.id];if(!(s!=null&&s.loaded))return[]}const n=this.revealedAt;return(this.s.messagesByConv[t.id]||[]).filter(s=>{var o,i,l,p,v;return(s==null?void 0:s.type)==="action"&&((o=s==null?void 0:s.payload)==null?void 0:o.state)==="pending"||G(s)&&!(n[s.id]>0)?!1:(s==null?void 0:s.type)==="action"||(s==null?void 0:s.type)==="system"||((i=s==null?void 0:s.payload)==null?void 0:i.type)==="system"||Array.isArray((l=s==null?void 0:s.payload)==null?void 0:l.attachments)&&s.payload.attachments.length||(p=s==null?void 0:s.metadata)!=null&&p.artifact||(v=s==null?void 0:s.metadata)!=null&&v.form?!0:typeof(s==null?void 0:s.text_md)=="string"&&s.text_md.trim().length>0})},streamingActive(){var r,a,s;const t=this.currentConv;return t?Object.keys(((r=this.s)==null?void 0:r.streamingByMsgId)||{}).length>0?!0:this.actionInFlight?!1:(((s=(a=this.s)==null?void 0:a.messagesByConv)==null?void 0:s[t.id])||[]).some(o=>G(o)&&!(this.revealedAt[o.id]>0)):!1},currentConvMessages(){var n,r,a;const t=(n=this.currentConv)==null?void 0:n.id;return t?((a=(r=this.s)==null?void 0:r.messagesByConv)==null?void 0:a[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 a,s,o,i,l,p;const t=(o=(s=(a=this.pendingApproval)==null?void 0:a.payload)==null?void 0:s.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,a,s;const t=this.currentConv;let n=new Date;if(t){const i=((s=(((a=(r=this.s)==null?void 0:r.messagesByConv)==null?void 0:a[t.id])||[]).find(l=>l==null?void 0:l.created_at))==null?void 0:s.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,a,s;const t=(r=this.currentConv)==null?void 0:r.id,n=t?(s=(a=this.s)==null?void 0:a.paginationByConv)==null?void 0:s[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||{},a=Object.keys(r);if(!a.length)return;const s={};let o=!1;for(const i of a)n.has(i)?s[i]=r[i]:o=!0;o&&(this.dismissedPeeks=s)},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(a=>{console.warn("[messenger] eager boot failed",a)}))},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 a=r[0];if(!a)return;const s=Math.ceil(a.contentRect.height+8);s!==this.floatHeight&&(this.floatHeight=s,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,a=16,s=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:s+a,height:o+a,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,a;if(typeof ResizeObserver>"u")return;const t=(a=(r=this.$el)==null?void 0:r.querySelector)==null?void 0:a.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,a;const n=t||((r=this.latestUnreads[0])==null?void 0:r.convId);n&&n!==((a=this.currentConv)==null?void 0:a.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(a){console.error("[ww-messenger] rename failed",a)}},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,a=this.pendingAttachments.slice();this.pendingAttachments=[],this.unreadAnchorId=null,this.unreadBoundaryTs="",await this.store.send(r,t,{attachments:a.length?a: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 a=this.currentConv;a&&(a._draft&&(a=await this.ensureRealConv(),!a)||await this.store.send(a.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}}}}},wa={key:0,class:"wm-loading","aria-busy":"true","aria-live":"polite"},ba=["aria-label"],Ea={key:0,class:"wm-state"},Ca={class:"wm-state__err"},Ba={class:"wm-state__errTitle"},Na={class:"wm-state__errSub"},Sa={class:"wm-bottom"},Aa={key:0,ref:"floatEl",class:"wm-float"},Va={key:1,class:"wm-actionWait",role:"status","aria-live":"polite"},Ma={class:"wm-actionWait__lbl"},Ta={key:2,class:"wm-attached"},xa=["aria-label","onClick"];function La(t,n,r,a,s,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}`])},[!s.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),s.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(s.floatHeight?{"--wm-float-h":s.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",wa,[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,ba)),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":s.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",Ea,[e.createElementVNode("div",Ca,[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",Ba,e.toDisplayString(o.t("error.connectionFailed")),1),e.createElementVNode("div",Na,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",Sa,[o.floatVisible?(e.openBlock(),e.createElementBlock("div",Aa,[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:s.feedbackBusy,done:s.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",Va,[n[9]||(n[9]=e.createElementVNode("span",{class:"wm-actionWait__spinner","aria-hidden":"true"},null,-1)),e.createElementVNode("span",Ma,e.toDisplayString(o.t("action.inProgress",{name:o.actionInFlightName})),1)])):(e.openBlock(),e.createBlock(x,{key:2,ref:"composer",modelValue:s.draft,"onUpdate:modelValue":n[1]||(n[1]=B=>s.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"]))]),s.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=>s.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),s.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=>s.renameDialogOpen=!1),onSubmit:o.onRenameSubmit},null,8,["initial-value","title","onSubmit"])):e.createCommentVNode("",!0),s.pendingAttachments.length?(e.openBlock(),e.createElementBlock("div",Ta,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.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=>s.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,xa)]))),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:s.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"])),s.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=>s.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)],2)}const Ge=A(ka,[["render",La],["__scopeId","data-v-9e47cfb4"]]),Oa="0.5.39";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=Oa;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=Do;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 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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}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={key:0,class:"wm-onb__section wm-onb__section--card"},vn={class:"wm-onb__section-title"},yn=["onClick"],kn={class:"wm-onb__card-icon"},wn=["aria-label"],bn={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"},En=["d"],Cn={class:"wm-onb__card-body"},Bn={class:"wm-onb__card-title"},Nn={key:0,class:"wm-onb__card-sub"},Sn={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"},An={key:1,class:"wm-onb__section wm-onb__section--card"},Vn={class:"wm-onb__section-title"},Mn={class:"wm-onb__alertList"},Tn=["onClick"],xn={key:0,class:"wm-onb__defaultAvatar"},Ln=["aria-label"],On={class:"wm-onb__alert-body"},Dn={class:"wm-onb__alert-title"},In=["innerHTML"],Rn={class:"wm-onb__alert-meta"},Fn={key:0,class:"wm-onb__alert-time"},Pn={class:"wm-onb__alert-resume"},Un={key:2,class:"wm-onb__section wm-onb__section--card"},zn={class:"wm-onb__section-title"},jn={class:"wm-onb__search"},Hn=["placeholder","aria-label"],qn={class:"wm-onb__list"},Kn=["onClick"],$n={key:0,class:"wm-onb__defaultAvatar"},Wn=["aria-label"],Gn={class:"wm-onb__thread-body"},Yn={class:"wm-onb__thread-title"},Jn=["innerHTML"],Qn={class:"wm-onb__thread-meta"},Xn={key:0,class:"wm-onb__thread-time"},Zn={key:0,class:"wm-onb__empty"};function er(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",_n,[e.createElementVNode("div",vn,e.toDisplayString(o.t("onboarding.quickAccess")),1),e.createElementVNode("div",{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",kn,[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,wn)):(e.openBlock(),e.createElementBlock("svg",bn,[e.createElementVNode("path",{d:o.iconPath(l.icon)},null,8,En)]))]),e.createElementVNode("span",Cn,[e.createElementVNode("span",Bn,e.toDisplayString(l.label),1),l.subtitle?(e.openBlock(),e.createElementBlock("span",Nn,e.toDisplayString(l.subtitle),1)):e.createCommentVNode("",!0)]),o.isExternalLink(l)?(e.openBlock(),e.createElementBlock("svg",Sn,[...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",An,[e.createElementVNode("div",Vn,e.toDisplayString(o.t("onboarding.unreadConversations")),1),e.createElementVNode("div",Mn,[(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",xn,[...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,Ln)],2),e.createElementVNode("span",On,[e.createElementVNode("span",Dn,e.toDisplayString(l.title),1),e.createElementVNode("span",{class:"wm-onb__alert-preview",innerHTML:o.renderPreview(l.preview)},null,8,In)]),e.createElementVNode("span",Rn,[o.formatTs(l._ts)?(e.openBlock(),e.createElementBlock("span",Fn,e.toDisplayString(o.formatTs(l._ts)),1)):e.createCommentVNode("",!0),e.createElementVNode("span",Pn,e.toDisplayString(o.t("onboarding.resume")),1)])],8,Tn))),128))])])):e.createCommentVNode("",!0),r.openThreads.length?(e.openBlock(),e.createElementBlock("div",Un,[e.createElementVNode("div",zn,e.toDisplayString(o.t("onboarding.recentConversations")),1),e.createElementVNode("div",jn,[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,Hn),[[e.vModelText,a.query]])]),e.createElementVNode("div",qn,[(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",$n,[...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,Wn)):e.createCommentVNode("",!0)],2),e.createElementVNode("span",Gn,[e.createElementVNode("span",Yn,e.toDisplayString(l.title),1),e.createElementVNode("span",{class:"wm-onb__thread-preview",innerHTML:o.renderPreview(l.preview)},null,8,Jn)]),e.createElementVNode("span",Qn,[o.formatTs(l._ts)?(e.openBlock(),e.createElementBlock("span",Xn,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,Kn))),128)),o.filteredThreads.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Zn,e.toDisplayString(o.t("onboarding.noResults",{query:a.query})),1))])])):e.createCommentVNode("",!0)])}const Ae=A(ln,[["render",er],["__scopeId","data-v-369d70df"]]);function tr(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 nr={name:"WmActionResult",props:{state:{type:String,default:"success"},label:{type:String,required:!0},detail:{type:String,default:""}},computed:{detailText(){return tr(this.detail)}}},rr={class:"wm-result__icon","aria-hidden":"true"},or={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"},ar={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"},sr={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"},ir={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"},lr={class:"wm-result__body"},cr={class:"wm-result__label"},dr={class:"wm-result__detail"};function ur(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-result",`wm-result--${r.state}`])},[e.createElementVNode("span",rr,[r.state==="success"?(e.openBlock(),e.createElementBlock("svg",or,[...n[0]||(n[0]=[e.createElementVNode("path",{d:"M20 6L9 17l-5-5"},null,-1)])])):r.state==="rejected"?(e.openBlock(),e.createElementBlock("svg",ar,[...n[1]||(n[1]=[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"},null,-1)])])):r.state==="awaiting"?(e.openBlock(),e.createElementBlock("svg",sr,[...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",ir,[...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",lr,[e.createElementVNode("span",cr,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",dr,e.toDisplayString(o.detailText),1)],64)):e.createCommentVNode("",!0)])],2)}const Ve=A(nr,[["render",ur],["__scopeId","data-v-7284acd0"]]),mr={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:[]}}},hr={class:"wm-art wm-art--formResponse"},fr={class:"wm-art__head"},pr={class:"wm-art__title"},gr={class:"wm-art__badge wm-art__badge--success"},_r={class:"wm-art__body"},vr={class:"wm-art__fieldLabel"};function yr(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",hr,[e.createElementVNode("div",fr,[e.createElementVNode("div",pr,e.toDisplayString(r.data.title||o.t("form.title")),1),e.createElementVNode("span",gr,[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",_r,[(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",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))])])}const Me=A(mr,[["render",yr],["__scopeId","data-v-713aecf1"]]),kr={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}}},wr={class:"wm-art wm-art--infoCard"},br={key:0,class:"wm-art__image"},Er=["src","alt"],Cr={class:"wm-art__head"},Br={class:"wm-art__headMain"},Nr={class:"wm-art__title"},Sr={key:0,class:"wm-art__subtitle"},Ar={key:1,class:"wm-art__body"},Vr={key:0,class:"wm-art__text"},Mr={class:"wm-art__fieldLabel"};function Tr(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",wr,[r.data.image_url?(e.openBlock(),e.createElementBlock("figure",br,[e.createElementVNode("img",{src:r.data.image_url,alt:r.data.title||"",loading:"lazy"},null,8,Er)])):e.createCommentVNode("",!0),e.createElementVNode("div",Cr,[e.createElementVNode("div",Br,[e.createElementVNode("div",Nr,e.toDisplayString(r.data.title),1),r.data.subtitle?(e.openBlock(),e.createElementBlock("div",Sr,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",Ar,[r.data.body?(e.openBlock(),e.createElementBlock("div",Vr,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",Mr,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(kr,[["render",Tr],["__scopeId","data-v-7eae0e4a"]]);function xr(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 Lr={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 xr((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}}},Or={class:"wm-art wm-art--ticket"},Dr={class:"wm-art__head wm-tk__head"},Ir={class:"wm-art__title wm-tk__title"},Rr={class:"wm-tk__sub"},Fr={class:"wm-tk__ref"},Pr={key:0,class:"wm-tk__text"},Ur={key:0,class:"wm-art__body"},zr={class:"wm-art__fieldLabel"},jr=["data-level"],Hr={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"},qr={key:1,class:"wm-art__footer wm-tk__footer"};function Kr(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",Or,[e.createElementVNode("div",Dr,[e.createElementVNode("div",Ir,e.toDisplayString(r.data.title),1),e.createElementVNode("div",Rr,[e.createElementVNode("div",Fr,[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",Pr,e.toDisplayString(r.data.body),1)):e.createCommentVNode("",!0)]),o.fields.length?(e.openBlock(),e.createElementBlock("div",Ur,[(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",zr,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,jr)):o.isDate(i.label)?(e.openBlock(),e.createElementBlock("svg",Hr,[...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",qr,[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(Lr,[["render",Kr],["__scopeId","data-v-5f30c914"]]),$r={form_response:Me,info_card:Te,ticket:xe},Wr={name:"WmArtifactRenderer",props:{artifact:{type:Object,required:!0}},computed:{component(){var n;const t=(n=this.artifact)==null?void 0:n.kind;return t&&$r[t]||null}}};function Gr(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(Wr,[["render",Gr]]),Yr={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()}}},Jr=["href"],Qr=["src","alt"],Xr=["src"],Zr=["src"],eo=["href","download"],to={class:"wm-att__main"},no={class:"wm-att__name"},ro={key:0,class:"wm-att__meta"},oo={key:0,class:"wm-att__spin","aria-hidden":"true"};function ao(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,Qr)],8,Jr)):o.kind==="audio"&&a.url?(e.openBlock(),e.createElementBlock("audio",{key:1,src:a.url,controls:"",preload:"metadata"},null,8,Xr)):o.kind==="video"&&a.url?(e.openBlock(),e.createElementBlock("video",{key:2,src:a.url,controls:"",preload:"metadata"},null,8,Zr)):(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",to,[e.createElementVNode("span",no,e.toDisplayString(o.displayName),1),o.sizeLabel?(e.openBlock(),e.createElementBlock("span",ro,e.toDisplayString(o.sizeLabel),1)):e.createCommentVNode("",!0)]),a.loading?(e.openBlock(),e.createElementBlock("span",oo)):e.createCommentVNode("",!0)],8,eo))],2)}const Oe=A(Yr,[["render",ao],["__scopeId","data-v-0c877a62"]]),so={name:"WmBubble",props:{role:{type:String,default:"ai"},text:{type:String,default:""}},computed:{rendered(){return Se(this.text)}}},io=["innerHTML"];function lo(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,io)],!0)],2)}const De=A(so,[["render",lo],["__scopeId","data-v-7ab13147"]]),co={name:"WmTyping"},uo={class:"wm-typing"};function mo(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",uo,[...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(co,[["render",mo],["__scopeId","data-v-df2447fd"]]);function F(t){return t?t.client_msg_id||t.id:""}const ho={transferred_to_human:"system.transferredToHuman",assigned:"system.assigned",unassigned:"system.unassigned",resolved:"system.resolved",reopened:"system.reopened",idle:"system.idle"},fo=80,po=200,go={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<=fo},onScroll(){const t=this.$refs.scrollEl;t&&(this.showScrollDown=!this.isAtBottom(t),!(this.loadingMore||!this.hasMore)&&(this._pendingLoadMore||t.scrollTop<=po&&(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=ho[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)}}},_o={class:"wm-list__wrap"},vo={key:0,class:"wm-list__loadMore",role:"status","aria-live":"polite"},yo={class:"wm-list__loadMore-lbl"},ko={key:1,class:"wm-list__historyEnd"},wo={key:2,class:"wm-list__sep"},bo={class:"wm-list__sep-label"},Eo={key:0,class:"wm-list__sep wm-list__sep--unread"},Co={class:"wm-list__sep-label wm-list__sep-label--unread"},Bo={key:0,class:"wm-list__sysep"},No={class:"wm-list__sysep-label"},So=["data-row-key","onPointerdown"],Ao={key:0,class:"wm-list__avatarSlot"},Vo={key:5,class:"wm-list__body"},Mo={key:0},To={key:1,"aria-hidden":"true"},xo={key:2},Lo={key:0},Oo={key:1,"aria-hidden":"true"},Do={key:2},Io={key:3,class:"wm-list__row wm-list__row--ai fade-up"},Ro={class:"wm-list__avatarSlot"},Fo=["aria-label","title"];function Po(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",_o,[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",vo,[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",ko,e.toDisplayString(o.t("messageList.conversationStart")),1)):e.createCommentVNode("",!0),r.dateLabel?(e.openBlock(),e.createElementBlock("div",wo,[n[7]||(n[7]=e.createElementVNode("div",{class:"wm-list__line"},null,-1)),e.createElementVNode("span",bo,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",Eo,[n[9]||(n[9]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--unread"},null,-1)),e.createElementVNode("span",Co,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",Bo,[n[11]||(n[11]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--strong"},null,-1)),e.createElementVNode("span",No,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",Ao,[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",Vo,[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,So),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",Mo,e.toDisplayString(o.roleLabel(k)),1)):e.createCommentVNode("",!0),k.role!=="user"&&o.timeOf(w.message)?(e.openBlock(),e.createElementBlock("span",To,"·")):e.createCommentVNode("",!0),o.timeOf(w.message)?(e.openBlock(),e.createElementBlock("span",xo,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",Lo,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",Do,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",Io,[e.createElementVNode("div",Ro,[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,Fo)):e.createCommentVNode("",!0)]),_:1})])}const Re=A(go,[["render",Po],["__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 Uo(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 zo(t)}catch(n){return console.error("[media] screenshot capture",n),null}finally{t.getTracks().forEach(n=>{n.stop()})}}async function zo(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 jo=[{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"}],Ho={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 jo.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)}}},qo={key:0,class:"wm-rec"},Ko={class:"wm-rec__lbl"},$o={key:1,class:"wm-compose__menu",role:"menu"},Wo=["disabled","onClick"],Go={class:"wm-compose__menuIcon"},Yo={viewBox:"0 0 24 24",width:"14",height:"14","aria-hidden":"true"},Jo=["d"],Qo=["placeholder","disabled"],Xo={class:"wm-compose__actions"},Zo=["title","aria-label","disabled"],ea=["disabled","aria-label"];function ta(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",qo,[n[8]||(n[8]=e.createElementVNode("span",{class:"wm-rec__dot","aria-hidden":"true"},null,-1)),e.createElementVNode("span",Ko,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",$o,[(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",Go,[(e.openBlock(),e.createElementBlock("svg",Yo,[e.createElementVNode("path",{d:i.path,stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round",fill:"none"},null,8,Jo)]))]),e.createElementVNode("span",null,e.toDisplayString(i.label),1)],8,Wo))),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,Qo),[[e.vModelText,a.local]]),e.createElementVNode("div",Xo,[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,Zo),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,ea)])],34)],6)}const je=A(Ho,[["render",ta],["__scopeId","data-v-01e81a27"]]),na={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("§")}}},ra=["onClick"];function oa(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,ra))),128))])):e.createCommentVNode("",!0)}const He=A(na,[["render",oa],["__scopeId","data-v-47ad8085"]]),aa={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")}}},sa={class:"wm-approval"},ia={class:"wm-approval__head"},la={class:"wm-approval__icon"},ca={class:"wm-approval__main"},da={class:"wm-approval__title"},ua={key:0,class:"wm-approval__detail"},ma={class:"wm-approval__actions"};function ha(t,n,r,s,a,o){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",sa,[e.createElementVNode("div",ia,[e.createElementVNode("div",la,[e.createVNode(i,{size:24,name:r.agentName,"image-url":r.agentAvatarUrl},null,8,["name","image-url"])]),e.createElementVNode("div",ca,[e.createElementVNode("div",da,e.toDisplayString(r.action),1),r.detail?(e.openBlock(),e.createElementBlock("div",ua,e.toDisplayString(r.detail),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",ma,[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(aa,[["render",ha],["__scopeId","data-v-a2bed37e"]]);let fe=0;const fa=new Set(["text","textarea","number","boolean","select","multiselect","date"]),pa={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)||!fa.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}}}},ga={class:"wm-form"},_a={class:"wm-form__head"},va={class:"wm-form__icon"},ya={class:"wm-form__main"},ka={class:"wm-form__title"},wa={key:0,class:"wm-form__detail"},ba=["for"],Ea={key:0,class:"wm-form__req","aria-hidden":"true"},Ca=["id","onUpdate:modelValue","placeholder","required","disabled"],Ba=["id","onUpdate:modelValue","placeholder","required","disabled"],Na=["id","onUpdate:modelValue","placeholder","required","disabled"],Sa=["id","onUpdate:modelValue","required","disabled"],Aa={key:4,class:"wm-form__bool"},Va=["id","onUpdate:modelValue","disabled"],Ma=["id","onUpdate:modelValue","required","disabled"],Ta={value:"",disabled:""},xa=["value"],La={key:6,class:"wm-form__multi"},Oa=["value","checked","disabled","onChange"],Da={key:0,class:"wm-form__err"},Ia=["disabled"],Ra={key:0,class:"wm-form__spinner","aria-hidden":"true"},Fa={key:2,class:"wm-form__doneLbl"};function Pa(t,n,r,s,a,o){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",ga,[e.createElementVNode("div",_a,[e.createElementVNode("div",va,[e.createVNode(i,{size:24,name:r.agentName,"image-url":r.agentAvatarUrl},null,8,["name","image-url"])]),e.createElementVNode("div",ya,[e.createElementVNode("div",ka,e.toDisplayString(r.form.title||o.t("form.title")),1),r.form.description?(e.openBlock(),e.createElementBlock("div",wa,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",Ea,"*")):e.createCommentVNode("",!0)],8,ba),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,Ca)),[[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,Ba)),[[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,Na)),[[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,Sa)),[[e.vModelText,a.values[l.key]]]):l.type==="boolean"?(e.openBlock(),e.createElementBlock("label",Aa,[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,Va),[[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",Ta,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,xa))),128))],8,Ma)),[[e.vModelSelect,a.values[l.key]]]):l.type==="multiselect"?(e.openBlock(),e.createElementBlock("div",La,[(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,Oa),e.createElementVNode("span",null,e.toDisplayString(p.label),1)]))),128))])):e.createCommentVNode("",!0)]))),128)),a.error?(e.openBlock(),e.createElementBlock("div",Da,e.toDisplayString(a.error),1)):e.createCommentVNode("",!0),r.readOnly?(e.openBlock(),e.createElementBlock("div",Fa,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",Ra)):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,Ia))],32)])}const Ke=A(pa,[["render",Pa],["__scopeId","data-v-fe65cc56"]]),Ua={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})}}},za={class:"wm-fb"},ja={class:"wm-fb__title"},Ha={class:"wm-fb__sub"},qa={class:"wm-fb__row"},Ka=["onClick"],$a={class:"wm-fb__emoji"},Wa={class:"wm-fb__label"},Ga=["disabled"],Ya={key:1,class:"wm-fb__done"},Ja={class:"wm-fb__doneTitle"},Qa={class:"wm-fb__doneSub"};function Xa(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",za,[r.done?(e.openBlock(),e.createElementBlock("div",Ya,[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",Ja,e.toDisplayString(o.t("feedback.doneTitle")),1),e.createElementVNode("div",Qa,e.toDisplayString(o.t("feedback.doneSubtitle")),1)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("div",ja,e.toDisplayString(o.t("feedback.question")),1),e.createElementVNode("div",Ha,e.toDisplayString(o.t("feedback.subtitle")),1),e.createElementVNode("div",qa,[(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",$a,e.toDisplayString(i.e),1),e.createElementVNode("span",Wa,e.toDisplayString(i.l),1)],10,Ka))),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,Ga)],64))])}const $e=A(Ua,[["render",Xa],["__scopeId","data-v-9b630564"]]),Za={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)}}},es={class:"wm-mm"},ts={class:"wm-mm__pop",role:"menu"},ns={key:0,class:"wm-mm__section"},rs={class:"wm-mm__label"},os={class:"wm-mm__label"},as={key:1,class:"wm-mm__sep"},ss={class:"wm-mm__section"},is={class:"wm-mm__label"},ls={class:"wm-mm__label"},cs={class:"wm-mm__section"},ds={class:"wm-mm__label"},us={class:"wm-mm__label"};function ms(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",es,[e.createElementVNode("div",{class:"wm-mm__scrim",onClick:n[0]||(n[0]=i=>t.$emit("close"))}),e.createElementVNode("div",ts,[r.canRename||r.canExport?(e.openBlock(),e.createElementBlock("div",ns,[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",rs,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",os,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",as)):e.createCommentVNode("",!0),e.createElementVNode("div",ss,[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",is,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",ls,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",cs,[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",ds,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",us,e.toDisplayString(o.t("moreMenu.helpCenter")),1)])):e.createCommentVNode("",!0)])])])}const We=A(Za,[["render",ms],["__scopeId","data-v-76281e95"]]),hs={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())}}},fs={class:"wm-dialog"},ps={class:"wm-dialog__card",role:"dialog","aria-modal":"true"},gs={class:"wm-dialog__head"},_s={class:"wm-dialog__title"},vs=["aria-label"],ys={class:"wm-dialog__body"},ks=["placeholder"],ws={class:"wm-dialog__actions"},bs=["disabled"];function Es(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",fs,[e.createElementVNode("div",{class:"wm-dialog__scrim",onClick:n[0]||(n[0]=i=>t.$emit("close"))}),e.createElementVNode("div",ps,[e.createElementVNode("div",gs,[e.createElementVNode("div",_s,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,vs)]),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,ks),[[e.vModelText,a.value]])]),e.createElementVNode("div",ws,[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,bs)])])])}const Cs=A(hs,[["render",Es],["__scopeId","data-v-6d5f94a8"]]),pe="ww-messenger-tokens",Bs={name:"Messenger",components:{Launcher:be,Header:Ce,Onboarding:Ae,MessageList:Re,Composer:je,SuggestionChips:He,ApprovalCard:qe,FormCard:Ke,Feedback:$e,MoreMenu:We,RenameDialog:Cs},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}}}}},Ns={key:0,class:"wm-loading","aria-busy":"true","aria-live":"polite"},Ss=["aria-label"],As={key:0,class:"wm-state"},Vs={class:"wm-state__err"},Ms={class:"wm-state__errTitle"},Ts={class:"wm-state__errSub"},xs={class:"wm-bottom"},Ls={key:0,ref:"floatEl",class:"wm-float"},Os={key:1,class:"wm-actionWait",role:"status","aria-live":"polite"},Ds={class:"wm-actionWait__lbl"},Is={key:2,class:"wm-attached"},Rs=["aria-label","onClick"];function Fs(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",Ns,[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,Ss)),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",As,[e.createElementVNode("div",Vs,[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",Ms,e.toDisplayString(o.t("error.connectionFailed")),1),e.createElementVNode("div",Ts,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",xs,[o.floatVisible?(e.openBlock(),e.createElementBlock("div",Ls,[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",Os,[n[9]||(n[9]=e.createElementVNode("span",{class:"wm-actionWait__spinner","aria-hidden":"true"},null,-1)),e.createElementVNode("span",Ds,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",Is,[(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,Rs)]))),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(Bs,[["render",Fs],["__scopeId","data-v-0d59093c"]]),Ps="0.5.41";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=Ps;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=Uo;exports.pickRecorderMime=Fe;exports.renderInlineMarkdown=Ne;exports.renderMarkdown=Se;exports.resolveLanguage=ne;exports.startScreenRecording=ze;exports.tokensCss=ve;exports.uuid=le;exports.v4=le;
|