@_solaris/messenger-widget 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),Ge=["connected","message","message_stream","conversation_updated","config_updated","action_status"],le="/client",Ye=5*60*1e3,Qe=10*60*1e3,Xe=5*60*1e3;function _e(t){const n={baseUrl:Je(t.baseUrl||""),widgetId:t.widgetId||"",userId:t.userId||"",userHash:t.userHash||"",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||!n.userId||!n.userHash)throw new Error("[transport] baseUrl, widgetId, userId, userHash are all 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 h=n.listeners.get(c);h&&h.forEach(_=>{try{_(m)}catch(g){console.error("[transport] listener",c,g)}})}function i(c){n.connection!==c&&(n.connection=c,s("connection",c))}function o(){return{"X-User-Id":n.userId,"X-User-Hash":n.userHash,"X-Widget-Id":n.widgetId}}async function a(c,m,h){const _=await fetch(`${n.baseUrl}${le}${m}`,{method:c,headers:{"Content-Type":"application/json",...o()},body:h!==void 0?JSON.stringify(h):void 0});if(!_.ok){const g=await l(_),b=new Error(`HTTP ${_.status} ${c} ${m} :: ${(g==null?void 0:g.error)||_.statusText}`);throw b.status=_.status,b.body=g,b}return _.status===204?null:_.json()}async function l(c){try{return await c.json()}catch{return null}}async function p(){const[c,m]=await Promise.all([fetch(`${n.baseUrl}/widgets/${encodeURIComponent(n.widgetId)}/config`).then(async h=>{if(!h.ok){const _=await l(h);throw new Error(`HTTP ${h.status} GET /widgets/:id/config :: ${(_==null?void 0:_.error)||h.statusText}`)}return h.json()}),a("GET","/customers/me")]);return{config:c,customer:(m==null?void 0:m.customer)??null}}async function y(){const c=await a("GET","/customers/me");return(c==null?void 0:c.customer)??null}async function v(c){const m=await a("PATCH","/customers/me",c);return(m==null?void 0:m.customer)??null}async function E(){const c=await a("GET","/conversations");return(c==null?void 0:c.conversations)??[]}async function N(c={}){return(await a("POST","/conversations",c)).conversation}async function k(c){return(await a("GET",`/conversations/${encodeURIComponent(c)}`)).conversation}async function L(c,m){return(await a("PATCH",`/conversations/${encodeURIComponent(c)}`,m)).conversation}async function w(c,m){return a("PATCH",`/conversations/${encodeURIComponent(c)}/read`,{message_id:m})}async function T(c,m={}){const h=new URLSearchParams;m.before&&h.set("before",m.before),m.since&&h.set("since",m.since),m.limit&&h.set("limit",String(m.limit));const _=h.toString()?`?${h.toString()}`:"";return a("GET",`/conversations/${encodeURIComponent(c)}/messages${_}`)}async function S(c,m){O();const h={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&&(h.payload={type:"content",attachments:m.attachments}),m.metadata&&typeof m.metadata=="object"&&(h.metadata=m.metadata),a("POST",`/conversations/${encodeURIComponent(c)}/messages`,h)}async function x(c,m,h){return O(),a("POST",`/messages/${encodeURIComponent(c)}/callbacks/${encodeURIComponent(m)}`,h?{inputs:h}:{})}async function D(c){const m=c.name||"attachment",h=c.type||"application/octet-stream",_=c.size||0,g=await a("POST","/attachments",{mime_type:h,size_bytes:_,name:m}),b=await fetch(g.upload_url,{method:"PUT",headers:{"Content-Type":h},body:c});if(!b.ok)throw new Error(`HTTP ${b.status} PUT signed upload`);return{type:Ze(h),path:g.path,mime_type:h,size_bytes:_}}async function P(c){return a("GET",`/attachments/sign?path=${encodeURIComponent(c)}`)}function U(){const c=new URLSearchParams({userId:n.userId,userHash:n.userHash,widgetId:n.widgetId}).toString();return`${n.baseUrl}${le}/stream?${c}`}function I(){if(!n.eventSource&&!(typeof document<"u"&&document.hidden))try{const c=new EventSource(U());for(const m of Ge)c.addEventListener(m,h=>R(m,h.data));c.addEventListener("error",()=>s("error",new Error("SSE error"))),n.eventSource=c,i("open")}catch(c){console.error("[transport] SSE open failed",c),s("error",c)}}function R(c,m){try{const h=JSON.parse(m),_=h&&typeof h=="object"&&"data"in h?h.data:h;s(c,_)}catch(h){console.error("[transport] bad SSE payload",c,h)}}function F(){n.eventSource&&(n.eventSource.close(),n.eventSource=null),n.connection!=="paused"&&i("idle")}function O(){clearTimeout(n.burstTimer),I(),n.panelOpen||(n.burstTimer=setTimeout(()=>{n.panelOpen||F()},Qe))}function te(c){n.panelOpen=!!c,n.panelOpen?(clearTimeout(n.burstTimer),I()):O()}async function Y(){try{const c=await E(),m=c.reduce((_,g)=>{const b=g==null?void 0:g.last_message_at;return b&&(!_||b>_)?b:_},null);m&&(!n.lastActivityAt||m>n.lastActivityAt)&&(n.lastActivityAt=m,s("activity",{conversations:c,latestAt:m}),O())}catch(c){console.error("[transport] poll failed",c)}}function Q(){q(),!(typeof document<"u"&&document.hidden)&&(n.pollTimer=setInterval(Y,Ye))}function q(){n.pollTimer&&(clearInterval(n.pollTimer),n.pollTimer=null)}function d(){if(document.hidden)clearTimeout(n.hiddenGraceTimer),n.hiddenGraceTimer=setTimeout(()=>{n.hiddenGraceTimer=null,document.hidden&&(q(),F(),i("paused"))},Xe);else{if(n.hiddenGraceTimer){clearTimeout(n.hiddenGraceTimer),n.hiddenGraceTimer=null;return}i("idle"),Q(),n.panelOpen&&I()}}async function u(){if(n.started)return n.lastBootstrap;n.started=!0;const c=await p();n.lastBootstrap=c;try{const m=await E();n.lastActivityAt=m.reduce((h,_)=>{const g=_==null?void 0:_.last_message_at;return g&&(!h||g>h)?g:h},null)}catch(m){console.error("[transport] initial /conversations failed",m)}return typeof document<"u"&&(n.visibilityHandler=d,document.addEventListener("visibilitychange",n.visibilityHandler)),Q(),c}function f(){q(),clearTimeout(n.burstTimer),clearTimeout(n.hiddenGraceTimer),n.hiddenGraceTimer=null,F(),n.visibilityHandler&&(document.removeEventListener("visibilitychange",n.visibilityHandler),n.visibilityHandler=null),n.started=!1}return{on:r,start:u,stop:f,setPanelOpen:te,bootstrap:p,getCustomer:y,patchCustomer:v,listConversations:E,createConversation:N,getConversation:k,patchConversation:L,markConversationRead:w,listMessages:T,postMessage:S,postCallback:x,uploadAttachment:D,signAttachment:P,get connection(){return n.connection}}}function Je(t){return t.endsWith("/")?t.slice(0,-1):t}function Ze(t){return t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":"file"}function re(){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 ge(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,f=d==null?void 0:d.message;!u||!(f!=null&&f.id)||(R(u,f),f.client_msg_id&&delete n.streamingByMsgId[f.client_msg_id],te(u,f.created_at))})),r.push(t.on("message_stream",d=>{const u=d==null?void 0:d.message_id,f=d==null?void 0:d.token;!u||typeof f!="string"||(n.streamingByMsgId[u]=(n.streamingByMsgId[u]||"")+f)})),r.push(t.on("conversation_updated",d=>{const u=d==null?void 0:d.conversation_id,f=d==null?void 0:d.changes;if(!u||!f)return;const c=n.conversations.findIndex(m=>m.id===u);c!==-1&&(n.conversations[c]={...n.conversations[c],...f})})),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,f=d==null?void 0:d.action_id,c=d==null?void 0:d.action_name;if(!u||!f)return;const m=n.runningActionsByConv[u]||{};d.state==="running"?(m[f]=c||f,n.runningActionsByConv[u]={...m}):d.state==="done"&&(delete m[f],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(){try{const d=new Promise((f,c)=>setTimeout(()=>c(new Error("bootstrap timeout (15s) — check baseUrl, CORS, and network")),15e3)),u=await Promise.race([t.start(),d]);n.config=u.config,n.customer=u.customer,n.conversations=await Promise.race([t.listConversations(),d]),n.ready=!0}catch(d){console.error("[store] start failed",d),n.error=(d==null?void 0:d.message)||String(d)}}function i(){for(const d of r)try{d()}catch{}t.stop()}async function o(d){const u=Q(d);if(!u)return n.customer;try{const f=await t.patchCustomer(u);f&&(n.customer=f)}catch(f){console.error("[store] applyCustomer failed",f)}return n.customer}async function a(d={}){const u=await t.createConversation(d),f=n.conversations.findIndex(c=>c.id===u.id);return f===-1?n.conversations=[u,...n.conversations]:n.conversations[f]=u,u}const l=50;async function p(d){const u=n.paginationByConv[d];if(!(u!=null&&u.loaded||u!=null&&u.loading)){v(d,{nextCursor:null,loading:!0,loaded:!1});try{const f=await t.listMessages(d,{limit:l}),c=(f==null?void 0:f.messages)??[],m=n.messagesByConv[d]||[],h=new Set;for(const g of c)(g==null?void 0:g.id)!=null&&h.add(`id:${String(g.id)}`),g!=null&&g.client_msg_id&&h.add(`c:${g.client_msg_id}`);const _=m.filter(g=>!((g==null?void 0:g.id)!=null&&h.has(`id:${String(g.id)}`)||g!=null&&g.client_msg_id&&h.has(`c:${g.client_msg_id}`)));n.messagesByConv[d]=[...c,..._].sort(Y),v(d,{nextCursor:(f==null?void 0:f.next_cursor)??null,loading:!1,loaded:!0})}catch(f){console.error("[store] openConversation failed",f),v(d,{nextCursor:null,loading:!1,loaded:!1})}}}async function y(d){var m;const u=n.paginationByConv[d];if(!u||u.loading||!u.nextCursor)return;const c=(m=(n.messagesByConv[d]||[]).find(h=>h==null?void 0:h.created_at))==null?void 0:m.created_at;if(c){v(d,{...u,loading:!0});try{const h=await t.listMessages(d,{before:c,limit:l}),_=(h==null?void 0:h.messages)??[],g=n.messagesByConv[d]||[],b=new Set;for(const C of g)(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 V=_.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]=[...V,...g],v(d,{nextCursor:(h==null?void 0:h.next_cursor)??null,loading:!1,loaded:!0})}catch(h){console.error("[store] loadMore failed",h),v(d,{...u,loading:!1})}}}function v(d,u){n.paginationByConv={...n.paginationByConv,[d]:u}}async function E(d,u){const f=await t.patchConversation(d,u),c=n.conversations.findIndex(m=>m.id===d);c!==-1&&(n.conversations[c]=f)}async function N(d){if(!d)return[];const u=n.messagesByConv[d]||[];let f="";for(const c of u)c!=null&&c.created_at&&c.created_at>f&&(f=c.created_at);try{const c=await t.listMessages(d,f?{since:f}:{}),m=(c==null?void 0:c.messages)||[];if(!m.length)return[];const h=new Set,_=new Set;for(const b of u)(b==null?void 0:b.id)!=null&&h.add(String(b.id)),b!=null&&b.client_msg_id&&_.add(b.client_msg_id);const g=[];for(const b of m){const V=(b==null?void 0:b.id)!=null&&h.has(String(b.id))||(b==null?void 0:b.client_msg_id)&&_.has(b.client_msg_id);R(d,b),V||g.push(b)}return g}catch(c){return console.error("[store] fetchSinceLast failed",c),[]}}async function k(d,u){if(!(!d||u==null))try{const f=await t.markConversationRead(d,u),c=(f==null?void 0:f.last_read_message_id)??u,m=n.conversations.findIndex(h=>(h==null?void 0:h.id)===d);m!==-1&&(n.conversations[m]={...n.conversations[m],last_read_message_id:c})}catch(f){console.error("[store] markConversationRead failed",f)}}async function L(d,u,{attachments:f,metadata:c}={}){var V;const m=(u||"").trim(),h=Array.isArray(f)&&f.length>0;if(!d||!m&&!h)return;const _=re(),g=q(d),b={id:_,client_msg_id:_,conversation_id:d,type:"content",text_md:m,author:{type:"user",id:((V=n.customer)==null?void 0:V.external_id)||null},created_at:g,_pending:!0,...h?{payload:{type:"content",attachments:f}}:{},...c&&typeof c=="object"?{metadata:c}:{}};R(d,b);try{await t.postMessage(d,{client_msg_id:_,text_md:m,created_at:g,...h?{attachments:f}:{},...c&&typeof c=="object"?{metadata:c}:{}})}catch(C){console.error("[store] send failed",C),O(d,_,{_failed:!0,_pending:!1})}}async function w(d,u,f){d!=null&&(n.awaitingCallback[d]=!0);try{await t.postCallback(d,u,f)}catch(c){console.error("[store] callback failed",c),d!=null&&delete n.awaitingCallback[d]}}const T=new Map;async function S(d){if(!d)return null;const u=T.get(d);if(u!=null&&u.url){const f=u.expires_at?Date.parse(u.expires_at):0;if(!f||f-Date.now()>6e4)return u.url}try{const f=await t.signAttachment(d);if(f!=null&&f.signed_url)return T.set(d,{url:f.signed_url,expires_at:f.expires_at}),f.signed_url}catch(f){console.error("[store] sign attachment failed",f)}return null}async function x(d,{rating:u,comment:f}={}){const c=n.conversations.find(_=>_.id===d),h={...(c==null?void 0:c.metadata)||{},feedback:{rating:u,comment:f||null,submitted_at:new Date().toISOString()}};await E(d,{metadata:h})}function D(d){var f,c;const u=n.messagesByConv[d]||[];for(let m=u.length-1;m>=0;m--){const h=u[m];if((h==null?void 0:h.type)==="action"&&((f=h==null?void 0:h.payload)==null?void 0:f.type)==="action"&&((c=h==null?void 0:h.payload)==null?void 0:c.state)==="pending"&&Array.isArray(h==null?void 0:h.callbacks)&&h.callbacks.length>0&&!n.awaitingCallback[h.id])return h}return null}function P(d){var f,c,m;const u=n.messagesByConv[d]||[];for(let h=u.length-1;h>=0;h--){const _=u[h];if(((f=_==null?void 0:_.author)==null?void 0:f.type)==="user"||(_==null?void 0:_.type)==="action"&&((c=_==null?void 0:_.payload)==null?void 0:c.state)==="pending")return null;const g=(m=_==null?void 0:_.metadata)==null?void 0:m.form;if(g&&Array.isArray(g.fields)&&g.fields.length>0)return{message:_,form:g}}return null}function U(d){const u=n.runningActionsByConv[d];if(!u)return null;const f=Object.keys(u);if(f.length===0)return null;const c=f[0];return{id:c,payload:{name:u[c]}}}function I(d){var f,c,m,h;const u=n.messagesByConv[d]||[];for(let _=u.length-1;_>=0;_--){const g=u[_];if(((f=g==null?void 0:g.author)==null?void 0:f.type)==="user")return[];if((g==null?void 0:g.type)==="action"&&((c=g==null?void 0:g.payload)==null?void 0:c.state)==="pending")return[];if(((m=g==null?void 0:g.author)==null?void 0:m.type)!=="agent_ia")continue;const b=(h=g==null?void 0:g.metadata)==null?void 0:h.suggested_replies;return Array.isArray(b)&&b.length?b.map(V=>{if(typeof V=="string"){const C=V.trim();return C?{label:C,kind:null}:null}if(V&&typeof V=="object"&&typeof V.label=="string"){const C=V.label.trim();if(!C)return null;const We=V.kind==="cta"||V.kind==="choice"||V.kind==="followup"?V.kind:null;return{label:C,kind:We}}return null}).filter(Boolean).slice(0,4):[]}return[]}function R(d,u){var h;const f=n.messagesByConv[d]||[];let c=-1;u!=null&&u.client_msg_id&&(c=f.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=f.findIndex(_=>F(_==null?void 0:_.id,u.id)));let m;c===-1?m=[...f,u].sort(Y):(m=f.slice(),m[c]={...f[c],...u,_pending:!1,_failed:!1}),n.messagesByConv[d]=m,(u==null?void 0:u.type)==="action"&&((h=u==null?void 0:u.payload)!=null&&h.state)&&u.payload.state!=="pending"&&(u==null?void 0:u.id)!=null&&n.awaitingCallback[u.id]&&delete n.awaitingCallback[u.id]}function F(d,u){return d===u?!0:d==null||u==null?!1:String(d)===String(u)}function O(d,u,f){const c=n.messagesByConv[d];if(!c)return;const m=c.findIndex(_=>_.id===u);if(m===-1)return;const h=c.slice();h[m]={...c[m],...f},n.messagesByConv[d]=h}function te(d,u){const f=n.conversations.findIndex(m=>m.id===d);if(f===-1)return;const c=n.conversations[f];if(u&&(!c.last_message_at||u>c.last_message_at)){const m=n.conversations.slice();m[f]={...c,last_message_at:u},m.sort((h,_)=>(_.last_message_at||"").localeCompare(h.last_message_at||"")),n.conversations=m}}function Y(d,u){return(d.created_at||"").localeCompare(u.created_at||"")}function Q(d){if(!d||typeof d!="object")return null;const u={},f={};for(const[c,m]of Object.entries(d))m!==void 0&&(c==="name"||c==="email"?m!=null&&String(m).trim()!==""&&(u[c]=m):(c==="values"||c==="metadata")&&m&&typeof m=="object"?Object.assign(f,m):f[c]=m);return Object.keys(f).length&&(u.values=f),Object.keys(u).length?u:null}function q(d){const u=n.messagesByConv[d]||[];let f="";for(const h of u)h!=null&&h.created_at&&h.created_at>f&&(f=h.created_at);const c=new Date().toISOString();return!f||c>f?c:new Date(Date.parse(f)+1).toISOString()}return{state:n,start:s,destroy:i,applyCustomer:o,createConversation:a,openConversation:p,loadMore:y,fetchSinceLast:N,patchConversation:E,markConversationRead:k,send:L,clickCallback:w,signAttachment:S,submitFeedback:x,getPendingApproval:D,getActionInFlight:U,getLatestSuggestions:I,getLatestForm:P,setPanelOpen:t.setPanelOpen}}const M={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"},J=["#5B5FEF","#7C3AED","#DB2777","#0891B2","#D97706","#059669"];function oe(t=""){return t?J[t.charCodeAt(0)%J.length]:J[0]}function se(t=""){return t.split(" ").map(n=>n[0]||"").join("").toUpperCase().slice(0,2)}function ae(t=new Date,n="fr-FR"){return t.toLocaleTimeString(n,{hour:"2-digit",minute:"2-digit"})}const ve=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),Qe=["connected","message","message_stream","conversation_updated","config_updated","action_status"],le="/client",Xe=5*60*1e3,Je=10*60*1e3,Ze=5*60*1e3;function _e(t){const n={baseUrl:et(t.baseUrl||""),widgetId:t.widgetId||"",userId:t.userId||"",userHash:t.userHash||"",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||!n.userId||!n.userHash)throw new Error("[transport] baseUrl, widgetId, userId, userHash are all 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 h=n.listeners.get(c);h&&h.forEach(_=>{try{_(m)}catch(g){console.error("[transport] listener",c,g)}})}function s(c){n.connection!==c&&(n.connection=c,a("connection",c))}function o(){return{"X-User-Id":n.userId,"X-User-Hash":n.userHash,"X-Widget-Id":n.widgetId}}async function i(c,m,h){const _=await fetch(`${n.baseUrl}${le}${m}`,{method:c,headers:{"Content-Type":"application/json",...o()},body:h!==void 0?JSON.stringify(h):void 0});if(!_.ok){const g=await l(_),b=new Error(`HTTP ${_.status} ${c} ${m} :: ${(g==null?void 0:g.error)||_.statusText}`);throw b.status=_.status,b.body=g,b}return _.status===204?null:_.json()}async function l(c){try{return await c.json()}catch{return null}}async function p(){const[c,m]=await Promise.all([fetch(`${n.baseUrl}/widgets/${encodeURIComponent(n.widgetId)}/config`).then(async h=>{if(!h.ok){const _=await l(h);throw new Error(`HTTP ${h.status} GET /widgets/:id/config :: ${(_==null?void 0:_.error)||h.statusText}`)}return h.json()}),i("GET","/customers/me")]);return{config:c,customer:(m==null?void 0:m.customer)??null}}async function y(){const c=await i("GET","/customers/me");return(c==null?void 0:c.customer)??null}async function v(c){const m=await i("PATCH","/customers/me",c);return(m==null?void 0:m.customer)??null}async function E(){const c=await i("GET","/conversations");return(c==null?void 0:c.conversations)??[]}async function N(c={}){return(await i("POST","/conversations",c)).conversation}async function k(c){return(await i("GET",`/conversations/${encodeURIComponent(c)}`)).conversation}async function L(c,m){return(await i("PATCH",`/conversations/${encodeURIComponent(c)}`,m)).conversation}async function w(c,m){return i("PATCH",`/conversations/${encodeURIComponent(c)}/read`,{message_id:m})}async function T(c,m={}){const h=new URLSearchParams;m.before&&h.set("before",m.before),m.since&&h.set("since",m.since),m.limit&&h.set("limit",String(m.limit));const _=h.toString()?`?${h.toString()}`:"";return i("GET",`/conversations/${encodeURIComponent(c)}/messages${_}`)}async function S(c,m){O();const h={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&&(h.payload={type:"content",attachments:m.attachments}),m.metadata&&typeof m.metadata=="object"&&(h.metadata=m.metadata),i("POST",`/conversations/${encodeURIComponent(c)}/messages`,h)}async function x(c,m,h){return O(),i("POST",`/messages/${encodeURIComponent(c)}/callbacks/${encodeURIComponent(m)}`,h?{inputs:h}:{})}async function D(c){const m=c.name||"attachment",h=c.type||"application/octet-stream",_=c.size||0,g=await i("POST","/attachments",{mime_type:h,size_bytes:_,name:m}),b=await fetch(g.upload_url,{method:"PUT",headers:{"Content-Type":h},body:c});if(!b.ok)throw new Error(`HTTP ${b.status} PUT signed upload`);return{type:tt(h),path:g.path,mime_type:h,size_bytes:_}}async function P(c){return i("GET",`/attachments/sign?path=${encodeURIComponent(c)}`)}function U(){const c=new URLSearchParams({userId:n.userId,userHash:n.userHash,widgetId:n.widgetId}).toString();return`${n.baseUrl}${le}/stream?${c}`}function I(){if(!n.eventSource&&!(typeof document<"u"&&document.hidden))try{const c=new EventSource(U());for(const m of Qe)c.addEventListener(m,h=>R(m,h.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 R(c,m){try{const h=JSON.parse(m),_=h&&typeof h=="object"&&"data"in h?h.data:h;a(c,_)}catch(h){console.error("[transport] bad SSE payload",c,h)}}function F(){n.eventSource&&(n.eventSource.close(),n.eventSource=null),n.connection!=="paused"&&s("idle")}function O(){clearTimeout(n.burstTimer),I(),n.panelOpen||(n.burstTimer=setTimeout(()=>{n.panelOpen||F()},Je))}function te(c){n.panelOpen=!!c,n.panelOpen?(clearTimeout(n.burstTimer),I()):O()}async function Q(){try{const c=await E(),m=c.reduce((_,g)=>{const b=g==null?void 0:g.last_message_at;return b&&(!_||b>_)?b:_},null);m&&(!n.lastActivityAt||m>n.lastActivityAt)&&(n.lastActivityAt=m,a("activity",{conversations:c,latestAt:m}),O())}catch(c){console.error("[transport] poll failed",c)}}function X(){q(),!(typeof document<"u"&&document.hidden)&&(n.pollTimer=setInterval(Q,Xe))}function q(){n.pollTimer&&(clearInterval(n.pollTimer),n.pollTimer=null)}function d(){if(document.hidden)clearTimeout(n.hiddenGraceTimer),n.hiddenGraceTimer=setTimeout(()=>{n.hiddenGraceTimer=null,document.hidden&&(q(),F(),s("paused"))},Ze);else{if(n.hiddenGraceTimer){clearTimeout(n.hiddenGraceTimer),n.hiddenGraceTimer=null;return}s("idle"),X(),n.panelOpen&&I()}}async function u(){if(n.started)return n.lastBootstrap;n.started=!0;const c=await p();n.lastBootstrap=c;try{const m=await E();n.lastActivityAt=m.reduce((h,_)=>{const g=_==null?void 0:_.last_message_at;return g&&(!h||g>h)?g:h},null)}catch(m){console.error("[transport] initial /conversations failed",m)}return typeof document<"u"&&(n.visibilityHandler=d,document.addEventListener("visibilitychange",n.visibilityHandler)),X(),c}function f(){q(),clearTimeout(n.burstTimer),clearTimeout(n.hiddenGraceTimer),n.hiddenGraceTimer=null,F(),n.visibilityHandler&&(document.removeEventListener("visibilitychange",n.visibilityHandler),n.visibilityHandler=null),n.started=!1}return{on:r,start:u,stop:f,setPanelOpen:te,bootstrap:p,getCustomer:y,patchCustomer:v,listConversations:E,createConversation:N,getConversation:k,patchConversation:L,markConversationRead:w,listMessages:T,postMessage:S,postCallback:x,uploadAttachment:D,signAttachment:P,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 re(){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 ge(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,f=d==null?void 0:d.message;!u||!(f!=null&&f.id)||(R(u,f),f.client_msg_id&&delete n.streamingByMsgId[f.client_msg_id],te(u,f.created_at))})),r.push(t.on("message_stream",d=>{const u=d==null?void 0:d.message_id,f=d==null?void 0:d.token;!u||typeof f!="string"||(n.streamingByMsgId[u]=(n.streamingByMsgId[u]||"")+f)})),r.push(t.on("conversation_updated",d=>{const u=d==null?void 0:d.conversation_id,f=d==null?void 0:d.changes;if(!u||!f)return;const c=n.conversations.findIndex(m=>m.id===u);c!==-1&&(n.conversations[c]={...n.conversations[c],...f})})),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,f=d==null?void 0:d.action_id,c=d==null?void 0:d.action_name;if(!u||!f)return;const m=n.runningActionsByConv[u]||{};d.state==="running"?(m[f]=c||f,n.runningActionsByConv[u]={...m}):d.state==="done"&&(delete m[f],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(){try{const d=new Promise((f,c)=>setTimeout(()=>c(new Error("bootstrap timeout (15s) — check baseUrl, CORS, and network")),15e3)),u=await Promise.race([t.start(),d]);n.config=u.config,n.customer=u.customer,n.conversations=await Promise.race([t.listConversations(),d]),n.ready=!0}catch(d){console.error("[store] start failed",d),n.error=(d==null?void 0:d.message)||String(d)}}function s(){for(const d of r)try{d()}catch{}t.stop()}async function o(d){const u=X(d);if(!u)return n.customer;try{const f=await t.patchCustomer(u);f&&(n.customer=f)}catch(f){console.error("[store] applyCustomer failed",f)}return n.customer}async function i(d={}){const u=await t.createConversation(d),f=n.conversations.findIndex(c=>c.id===u.id);return f===-1?n.conversations=[u,...n.conversations]:n.conversations[f]=u,u}const l=50;async function p(d){const u=n.paginationByConv[d];if(!(u!=null&&u.loaded||u!=null&&u.loading)){v(d,{nextCursor:null,loading:!0,loaded:!1});try{const f=await t.listMessages(d,{limit:l}),c=(f==null?void 0:f.messages)??[],m=n.messagesByConv[d]||[],h=new Set;for(const g of c)(g==null?void 0:g.id)!=null&&h.add(`id:${String(g.id)}`),g!=null&&g.client_msg_id&&h.add(`c:${g.client_msg_id}`);const _=m.filter(g=>!((g==null?void 0:g.id)!=null&&h.has(`id:${String(g.id)}`)||g!=null&&g.client_msg_id&&h.has(`c:${g.client_msg_id}`)));n.messagesByConv[d]=[...c,..._].sort(Q),v(d,{nextCursor:(f==null?void 0:f.next_cursor)??null,loading:!1,loaded:!0})}catch(f){console.error("[store] openConversation failed",f),v(d,{nextCursor:null,loading:!1,loaded:!1})}}}async function y(d){var m;const u=n.paginationByConv[d];if(!u||u.loading||!u.nextCursor)return;const c=(m=(n.messagesByConv[d]||[]).find(h=>h==null?void 0:h.created_at))==null?void 0:m.created_at;if(c){v(d,{...u,loading:!0});try{const h=await t.listMessages(d,{before:c,limit:l}),_=(h==null?void 0:h.messages)??[],g=n.messagesByConv[d]||[],b=new Set;for(const C of g)(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 V=_.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]=[...V,...g],v(d,{nextCursor:(h==null?void 0:h.next_cursor)??null,loading:!1,loaded:!0})}catch(h){console.error("[store] loadMore failed",h),v(d,{...u,loading:!1})}}}function v(d,u){n.paginationByConv={...n.paginationByConv,[d]:u}}async function E(d,u){const f=await t.patchConversation(d,u),c=n.conversations.findIndex(m=>m.id===d);c!==-1&&(n.conversations[c]=f)}async function N(d){if(!d)return[];const u=n.messagesByConv[d]||[];let f="";for(const c of u)c!=null&&c.created_at&&c.created_at>f&&(f=c.created_at);try{const c=await t.listMessages(d,f?{since:f}:{}),m=(c==null?void 0:c.messages)||[];if(!m.length)return[];const h=new Set,_=new Set;for(const b of u)(b==null?void 0:b.id)!=null&&h.add(String(b.id)),b!=null&&b.client_msg_id&&_.add(b.client_msg_id);const g=[];for(const b of m){const V=(b==null?void 0:b.id)!=null&&h.has(String(b.id))||(b==null?void 0:b.client_msg_id)&&_.has(b.client_msg_id);R(d,b),V||g.push(b)}return g}catch(c){return console.error("[store] fetchSinceLast failed",c),[]}}async function k(d,u){if(!(!d||u==null))try{const f=await t.markConversationRead(d,u),c=(f==null?void 0:f.last_read_message_id)??u,m=n.conversations.findIndex(h=>(h==null?void 0:h.id)===d);m!==-1&&(n.conversations[m]={...n.conversations[m],last_read_message_id:c})}catch(f){console.error("[store] markConversationRead failed",f)}}async function L(d,u,{attachments:f,metadata:c}={}){var V;const m=(u||"").trim(),h=Array.isArray(f)&&f.length>0;if(!d||!m&&!h)return;const _=re(),g=q(d),b={id:_,client_msg_id:_,conversation_id:d,type:"content",text_md:m,author:{type:"user",id:((V=n.customer)==null?void 0:V.external_id)||null},created_at:g,_pending:!0,...h?{payload:{type:"content",attachments:f}}:{},...c&&typeof c=="object"?{metadata:c}:{}};R(d,b);try{await t.postMessage(d,{client_msg_id:_,text_md:m,created_at:g,...h?{attachments:f}:{},...c&&typeof c=="object"?{metadata:c}:{}})}catch(C){console.error("[store] send failed",C),O(d,_,{_failed:!0,_pending:!1})}}async function w(d,u,f){d!=null&&(n.awaitingCallback[d]=!0);try{await t.postCallback(d,u,f)}catch(c){console.error("[store] callback failed",c),d!=null&&delete n.awaitingCallback[d]}}const T=new Map;async function S(d){if(!d)return null;const u=T.get(d);if(u!=null&&u.url){const f=u.expires_at?Date.parse(u.expires_at):0;if(!f||f-Date.now()>6e4)return u.url}try{const f=await t.signAttachment(d);if(f!=null&&f.signed_url)return T.set(d,{url:f.signed_url,expires_at:f.expires_at}),f.signed_url}catch(f){console.error("[store] sign attachment failed",f)}return null}async function x(d,{rating:u,comment:f}={}){const c=n.conversations.find(_=>_.id===d),h={...(c==null?void 0:c.metadata)||{},feedback:{rating:u,comment:f||null,submitted_at:new Date().toISOString()}};await E(d,{metadata:h})}function D(d){var f,c;const u=n.messagesByConv[d]||[];for(let m=u.length-1;m>=0;m--){const h=u[m];if((h==null?void 0:h.type)==="action"&&((f=h==null?void 0:h.payload)==null?void 0:f.type)==="action"&&((c=h==null?void 0:h.payload)==null?void 0:c.state)==="pending"&&Array.isArray(h==null?void 0:h.callbacks)&&h.callbacks.length>0&&!n.awaitingCallback[h.id])return h}return null}function P(d){var f,c,m;const u=n.messagesByConv[d]||[];for(let h=u.length-1;h>=0;h--){const _=u[h];if(((f=_==null?void 0:_.author)==null?void 0:f.type)==="user"||(_==null?void 0:_.type)==="action"&&((c=_==null?void 0:_.payload)==null?void 0:c.state)==="pending")return null;const g=(m=_==null?void 0:_.metadata)==null?void 0:m.form;if(g&&Array.isArray(g.fields)&&g.fields.length>0)return{message:_,form:g}}return null}function U(d){const u=n.runningActionsByConv[d];if(!u)return null;const f=Object.keys(u);if(f.length===0)return null;const c=f[0];return{id:c,payload:{name:u[c]}}}function I(d){var f,c,m,h;const u=n.messagesByConv[d]||[];for(let _=u.length-1;_>=0;_--){const g=u[_];if(((f=g==null?void 0:g.author)==null?void 0:f.type)==="user")return[];if((g==null?void 0:g.type)==="action"&&((c=g==null?void 0:g.payload)==null?void 0:c.state)==="pending")return[];if(((m=g==null?void 0:g.author)==null?void 0:m.type)!=="agent_ia")continue;const b=(h=g==null?void 0:g.metadata)==null?void 0:h.suggested_replies;return Array.isArray(b)&&b.length?b.map(V=>{if(typeof V=="string"){const C=V.trim();return C?{label:C,kind:null}:null}if(V&&typeof V=="object"&&typeof V.label=="string"){const C=V.label.trim();if(!C)return null;const Ye=V.kind==="cta"||V.kind==="choice"||V.kind==="followup"?V.kind:null;return{label:C,kind:Ye}}return null}).filter(Boolean).slice(0,4):[]}return[]}function R(d,u){var h;const f=n.messagesByConv[d]||[];let c=-1;u!=null&&u.client_msg_id&&(c=f.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=f.findIndex(_=>F(_==null?void 0:_.id,u.id)));let m;c===-1?m=[...f,u].sort(Q):(m=f.slice(),m[c]={...f[c],...u,_pending:!1,_failed:!1}),n.messagesByConv[d]=m,(u==null?void 0:u.type)==="action"&&((h=u==null?void 0:u.payload)!=null&&h.state)&&u.payload.state!=="pending"&&(u==null?void 0:u.id)!=null&&n.awaitingCallback[u.id]&&delete n.awaitingCallback[u.id]}function F(d,u){return d===u?!0:d==null||u==null?!1:String(d)===String(u)}function O(d,u,f){const c=n.messagesByConv[d];if(!c)return;const m=c.findIndex(_=>_.id===u);if(m===-1)return;const h=c.slice();h[m]={...c[m],...f},n.messagesByConv[d]=h}function te(d,u){const f=n.conversations.findIndex(m=>m.id===d);if(f===-1)return;const c=n.conversations[f];if(u&&(!c.last_message_at||u>c.last_message_at)){const m=n.conversations.slice();m[f]={...c,last_message_at:u},m.sort((h,_)=>(_.last_message_at||"").localeCompare(h.last_message_at||"")),n.conversations=m}}function Q(d,u){return(d.created_at||"").localeCompare(u.created_at||"")}function X(d){if(!d||typeof d!="object")return null;const u={},f={};for(const[c,m]of Object.entries(d))m!==void 0&&(c==="name"||c==="email"?m!=null&&String(m).trim()!==""&&(u[c]=m):(c==="values"||c==="metadata")&&m&&typeof m=="object"?Object.assign(f,m):f[c]=m);return Object.keys(f).length&&(u.values=f),Object.keys(u).length?u:null}function q(d){const u=n.messagesByConv[d]||[];let f="";for(const h of u)h!=null&&h.created_at&&h.created_at>f&&(f=h.created_at);const c=new Date().toISOString();return!f||c>f?c:new Date(Date.parse(f)+1).toISOString()}return{state:n,start:a,destroy:s,applyCustomer:o,createConversation:i,openConversation:p,loadMore:y,fetchSinceLast:N,patchConversation:E,markConversationRead:k,send:L,clickCallback:w,signAttachment:S,submitFeedback:x,getPendingApproval:D,getActionInFlight:U,getLatestSuggestions:I,getLatestForm:P,setPanelOpen:t.setPanelOpen}}const M={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"},J=["#5B5FEF","#7C3AED","#DB2777","#0891B2","#D97706","#059669"];function oe(t=""){return t?J[t.charCodeAt(0)%J.length]:J[0]}function se(t=""){return t.split(" ").map(n=>n[0]||"").join("").toUpperCase().slice(0,2)}function ae(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 {
@@ -46,12 +46,12 @@
46
46
  }
47
47
  `,ye="https://api.messenger.victorc.fr",z="fr",ke=["fr","en"],ce={fr:"fr-FR",en:"en-US"},ne={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
48
  Je réponds en quelques secondes.`,"onboarding.newMessage":"Nouveau message","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","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","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","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 Z(t){if(typeof t!="string")return z;const n=t.trim().toLowerCase().slice(0,2);return ke.includes(n)?n:z}function $(t){return ce[Z(t)]||ce[z]}function A(t){const n=Z(t),r=ne[n]||ne[z],s=ne[z];return function(o,a){let l=r[o];return l==null&&(l=s[o]),l==null?o:(a&&(l=l.replace(/\{(\w+)\}/g,(p,y)=>a[y]!=null?String(a[y]):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 be(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 et(t,n,r=A()){if(!t||!n)return"";const s=Array.isArray(t.fields)?t.fields:[],i=[];for(const o of s){if(!(o!=null&&o.key)||!(o!=null&&o.label))continue;const a=n[o.key];if(a==null||a==="")continue;const l=be(o,a,r);l&&i.push(`${o.label} :
50
- ${l}`)}return i.join(`
49
+ I reply within seconds.`,"onboarding.newMessage":"New message","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","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 Z(t){if(typeof t!="string")return z;const n=t.trim().toLowerCase().slice(0,2);return ke.includes(n)?n:z}function $(t){return ce[Z(t)]||ce[z]}function A(t){const n=Z(t),r=ne[n]||ne[z],a=ne[z];return function(o,i){let l=r[o];return l==null&&(l=a[o]),l==null?o:(i&&(l=l.replace(/\{(\w+)\}/g,(p,y)=>i[y]!=null?String(i[y]):p)),l)}}function de(t,n){if(!Array.isArray(t==null?void 0:t.options))return n;const r=t.options.find(a=>(a==null?void 0:a.value)===n);return(r==null?void 0:r.label)||n}function be(t,n,r){return Array.isArray(n)?n.map(a=>de(t,String(a))).join(", "):typeof n=="boolean"?r(n?"common.yes":"common.no"):de(t,String(n))}function nt(t,n,r=A()){if(!t||!n)return"";const a=Array.isArray(t.fields)?t.fields:[],s=[];for(const o of a){if(!(o!=null&&o.key)||!(o!=null&&o.label))continue;const i=n[o.key];if(i==null||i==="")continue;const l=be(o,i,r);l&&s.push(`${o.label} :
50
+ ${l}`)}return s.join(`
51
51
 
52
- `)}function tt(t,n,r=A()){const s=[],i=Array.isArray(t==null?void 0:t.fields)?t.fields:[];for(const o of i){if(!(o!=null&&o.key)||!(o!=null&&o.label))continue;const a=n==null?void 0:n[o.key];if(a==null||a==="")continue;const l=be(o,a,r);if(!l)continue;const p=o.type==="textarea"||typeof l=="string"&&(l.length>60||l.includes(`
53
- `));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 W(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 j(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 nt(t,n){var r,s,i;for(let o=n.length-1;o>=0;o--){const a=n[o];if(!a)continue;const l=typeof a.text_md=="string"?a.text_md.trim():"";if(l)return(((r=a.author)==null?void 0:r.type)==="user"?"Vous : ":"")+l.replace(/\s+/g," ");const p=(s=a.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)||((i=t==null?void 0:t.metadata)==null?void 0:i.last_preview)||""}function rt(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 ot(t,n,r,s){const i=[`# ${t.name||r("common.conversation")}`,t.created_at?r("export.createdOn",{date:t.created_at}):"",""];for(const o of n){if(!o)continue;const a=(o.text_md||"").trim();if(!a)continue;const l=rt(o.author,r),p=o.created_at?new Date(o.created_at).toLocaleString(s):"";i.push(`[${p}] ${l} :`),i.push(a),i.push("")}return i.join(`
54
- `)}function st(t,n,r=A(),s){if(!t)return;const i=ot(t,n||[],r,$(s)),o=new Blob([i],{type:"text/plain;charset=utf-8"});try{const a=URL.createObjectURL(o),l=document.createElement("a");l.href=a,l.download=`${(t.name||"conversation").replace(/[^a-z0-9-_]+/gi,"_")}.txt`,document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>URL.revokeObjectURL(a),1e3)}catch(a){console.error("[ww-messenger] export failed",a)}}const at={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||""}:${this.userId||""}`},browserNotifStorageKey(){return`wm:notif:browser:${this.widgetId||""}:${this.userId||""}`},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 i;if(!this.soundEnabled&&!this.browserNotifEnabled||!n||!t||!W(t))return;const r=typeof document<"u"&&document.hidden;this.isOpen&&!r&&((i=this.currentConv)==null?void 0:i.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(),i=n.createGain();s.connect(i),i.connect(n.destination),s.type="sine",s.frequency.setValueAtTime(880,r),s.frequency.exponentialRampToValueAtTime(1320,r+.08),i.gain.setValueAtTime(0,r),i.gain.linearRampToValueAtTime(.12,r+.02),i.gain.exponentialRampToValueAtTime(1e-4,r+.28),s.start(r),s.stop(r+.32)}catch{}},showBrowserNotification(t,n){var a;if(typeof Notification>"u"||Notification.permission!=="granted")return;const r=this.allConversations.find(l=>(l==null?void 0:l.id)===t),s=(r==null?void 0:r.name)||((a=this.widget)==null?void 0:a.name)||this.t("notification.newMessage"),i=typeof(n==null?void 0:n.text_md)=="string"?n.text_md.trim():"",o=i?i.slice(0,140):this.t("notification.youHaveNewMessage");try{const l=new Notification(s,{body:o,tag:`wm-${t}`,renotify:!1,silent:!0});l.onclick=()=>{try{window.focus()}catch{}this.draftConv=null,this.showOnboarding=!1,this.activeConvId=t,this.isOpen=!0,this.store&&this.store.setPanelOpen(!0);try{l.close()}catch{}}}catch(l){console.warn("[ww-messenger] notification failed",l)}}}},it=450,lt=50,ct=900,dt=12e3,ut=300,mt={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 i=s==null?void 0:s.conversation_id,o=s==null?void 0:s.message;i&&o&&this.paceLiveMessage(o,i)});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 i,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 a of n){if(!(a!=null&&a.id))continue;const l=a.last_message_at||"";if(!l)continue;const p=r.get(a.id)||"";l>p&&s.push(a.id)}this._liveRevealConvSnapshot=new Map(n.map(a=>[a.id,(a==null?void 0:a.last_message_at)||""]));for(const a of s)try{const l=await((o=(i=this.store).fetchSinceLast)==null?void 0:o.call(i,a));if(!Array.isArray(l))continue;for(const p of l)this.paceLiveMessage(p,a)}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,i=Math.min(dt,Math.max(ct,s*lt)),a=Math.max(r+it,this.nextRevealAt+ut)+i;this.nextRevealAt=a;const l=Math.max(0,a-r),p=t.id,y=setTimeout(()=>{this.revealedAt={...this.revealedAt,[p]:Date.now()},this.revealTimers=this.revealTimers.filter(v=>v!==y),typeof this.onMessageRevealed=="function"&&this.onMessageRevealed(t,n)},l);this.revealTimers.push(y)},paceMessages(t,n){var i;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(!W(o)){s[o.id]=r;continue}const a=o!=null&&o.created_at?Date.parse(o.created_at):NaN;if(!Number.isFinite(a)||a<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((i=o==null?void 0:o.payload)==null?void 0:i.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 i;if(!(t!=null&&t.id)||this.revealedAt[t.id]!==void 0)return;if(!W(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((i=t==null?void 0:t.payload)==null?void 0:i.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)}}},ht={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)}}},ft=300,pt={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,a;if(!(t!=null&&t.id)||t._draft||!this.store)return;const n=((a=(o=this.s)==null?void 0:o.messagesByConv)==null?void 0:a[t.id])||[],r=_t(n);if(r==null)return;const s=j(t.last_read_message_id),i=j(r);i!=null&&(s!=null&&i<=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)},ft))))}}};function _t(t){for(let n=t.length-1;n>=0;n--){const r=t[n];if(!(!r||r._pending)&&j(r.id)!=null)return r.id}return null}const B=(t,n)=>{const r=t.__vccOpts||t;for(const[s,i]of n)r[s]=i;return r},gt={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":oe(this.name)},initials(){return se(this.name)}}},vt=["src","alt"];function yt(t,n,r,s,i,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,vt)):(e.openBlock(),e.createElementBlock("span",{key:1,style:e.normalizeStyle({fontSize:r.size*.36+"px"})},e.toDisplayString(o.initials),5))],6)}const ie=B(gt,[["render",yt],["__scopeId","data-v-14e10c0d"]]),kt=3,bt={name:"WmLauncher",components:{HumanAvatar:ie},inject:{t:{default:()=>A()}},props:{unreadCount:{type:Number,default:0},peeks:{type:Array,default:()=>[]}},emits:["open","dismiss"],computed:{visiblePeeks(){return this.peeks.slice(0,kt).reverse()}}},wt={class:"wm-launcherWrap"},Et=["aria-label","onClick","onKeydown"],Ct=["aria-label","onClick"],Bt={class:"wm-peek__avatar"},Nt=["aria-label"],St={class:"wm-peek__body"},At={class:"wm-peek__head"},Vt={class:"wm-peek__name"},Mt={class:"wm-peek__action"},Tt={class:"wm-peek__text"},xt=["onClick"],Lt=["aria-label"],Ot=["aria-label"];function Dt(t,n,r,s,i,o){const a=e.resolveComponent("HumanAvatar");return e.openBlock(),e.createElementBlock("div",wt,[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:y=>t.$emit("open",l.convId),onKeydown:[e.withKeys(e.withModifiers(y=>t.$emit("open",l.convId),["prevent"]),["enter"]),e.withKeys(e.withModifiers(y=>t.$emit("open",l.convId),["prevent"]),["space"])]},[e.createElementVNode("button",{type:"button",class:"wm-peek__close","aria-label":o.t("launcher.dismiss"),onClick:e.withModifiers(y=>t.$emit("dismiss",l.convId),["stop"])},[...n[1]||(n[1]=[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,Ct),e.createElementVNode("div",Bt,[e.createVNode(a,{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,Nt)):e.createCommentVNode("",!0)]),e.createElementVNode("div",St,[e.createElementVNode("div",At,[e.createElementVNode("span",Vt,e.toDisplayString(l.senderName||o.t("common.agent")),1),e.createElementVNode("span",Mt,e.toDisplayString(o.t("launcher.repliedToYou")),1)]),e.createElementVNode("p",Tt,e.toDisplayString(l.preview),1)]),e.createElementVNode("button",{type:"button",class:"wm-peek__open",onClick:e.withModifiers(y=>t.$emit("open",l.convId),["stop"])},e.toDisplayString(o.t("common.open")),9,xt)],44,Et))),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[2]||(n[2]=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,Ot)):e.createCommentVNode("",!0)],8,Lt)])}const we=B(bt,[["render",Dt],["__scopeId","data-v-5193a529"]]),It={name:"WmAIAvatar",props:{size:{type:Number,default:26},pulse:{type:Boolean,default:!1},tail:{type:Boolean,default:!1}}},Rt={key:0,class:"wm-aiav__pulse"},Ft=["width","height"];function jt(t,n,r,s,i,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",Rt)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["wm-aiav__inner",{"wm-aiav__inner--glow":r.pulse}])},[(e.openBlock(),e.createElementBlock("svg",{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,Ft))],2)],6)}const H=B(It,[["render",jt],["__scopeId","data-v-d621a129"]]),Pt={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":oe(t.name||"")},initialsFor(t){return se(t.name||"")}}},Ut={key:0,class:"wm-team"},zt=["src","alt"],$t={key:1},Ht={key:0,class:"wm-team__label"};function qt(t,n,r,s,i,o){return o.visible?(e.openBlock(),e.createElementBlock("div",Ut,[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),(a,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(a)})},[a.avatar_url?(e.openBlock(),e.createElementBlock("img",{key:0,src:a.avatar_url,alt:a.name||""},null,8,zt)):(e.openBlock(),e.createElementBlock("span",$t,e.toDisplayString(o.initialsFor(a)),1))],4))),128))],4),r.responseLabel?(e.openBlock(),e.createElementBlock("span",Ht,e.toDisplayString(r.responseLabel),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}const Ee=B(Pt,[["render",qt],["__scopeId","data-v-e49a9063"]]),Kt={name:"WmHeader",components:{AIAvatar:H,TeamAvatars:Ee},inject:{t:{default:()=>A()}},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}},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}}},Wt={class:"wm-header"},Gt=["aria-label"],Yt={key:1,style:{width:"30px",height:"30px","flex-shrink":"0"}},Qt={class:"wm-header__avatar"},Xt={class:"wm-header__main"},Jt={class:"wm-header__title"},Zt={key:3,class:"wm-header__fill"},en={class:"wm-header__actions"},tn=["aria-label","title"],nn=["aria-label","title"];function rn(t,n,r,s,i,o){const a=e.resolveComponent("AIAvatar"),l=e.resolveComponent("TeamAvatars");return e.openBlock(),e.createElementBlock("div",Wt,[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,Gt)):(e.openBlock(),e.createElementBlock("div",Yt)),r.showIdentity?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createElementVNode("div",Qt,[e.createVNode(a,{size:30})]),e.createElementVNode("div",Xt,[e.createElementVNode("div",Jt,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",Zt)),e.createElementVNode("div",en,[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,tn)):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,nn)):e.createCommentVNode("",!0)])])}const Ce=B(Kt,[["render",rn],["__scopeId","data-v-e5ed4931"]]),me={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"},on={name:"WmOnboarding",components:{AIAvatar:H},inject:{t:{default:()=>A()},wmLocale:{default:()=>()=>"fr"}},props:{welcomeMessage:{type:String,default:""},agentName:{type:String,default:""},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.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}},methods:{iconPath(t){return me[t]||me.link},formatTs(t){if(!t)return"";const n=new Date(t);if(Number.isNaN(n.getTime()))return"";const r=$(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 a=n.toLocaleDateString(r,{weekday:"short"});return a.charAt(0).toUpperCase()+a.slice(1)}return n.toLocaleDateString(r,{day:"2-digit",month:"2-digit"})}}},sn={class:"wm-onb"},an={class:"wm-onb__hero"},ln={class:"wm-onb__title"},cn={class:"wm-onb__sub"},dn={class:"wm-onb__cta"},un=["disabled"],mn={key:0,class:"wm-onb__section"},hn={class:"wm-onb__section-title"},fn=["onClick"],pn={class:"wm-onb__card-icon"},_n={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"},gn=["d"],vn={class:"wm-onb__card-body"},yn={class:"wm-onb__card-title"},kn={key:0,class:"wm-onb__card-sub"},bn={key:1,class:"wm-onb__section"},wn={class:"wm-onb__section-title"},En={class:"wm-onb__search"},Cn=["placeholder","aria-label"],Bn={class:"wm-onb__list"},Nn=["onClick"],Sn=["aria-label"],An={class:"wm-onb__thread-body"},Vn={class:"wm-onb__thread-title"},Mn={class:"wm-onb__thread-preview"},Tn={class:"wm-onb__thread-meta"},xn={key:0,class:"wm-onb__thread-time"},Ln={key:0,class:"wm-onb__empty"};function On(t,n,r,s,i,o){const a=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",sn,[e.createElementVNode("div",an,[e.createVNode(a,{size:56,pulse:!0}),e.createElementVNode("div",ln,e.toDisplayString(o.heroTitle),1),e.createElementVNode("div",cn,e.toDisplayString(o.heroSub),1)]),e.createElementVNode("div",dn,[e.createElementVNode("button",{type:"button",class:"wm-onb__startBtn",disabled:r.busy,onClick:n[0]||(n[0]=l=>t.$emit("start"))},[n[2]||(n[2]=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,un)]),r.quickLinks.length?(e.openBlock(),e.createElementBlock("div",mn,[e.createElementVNode("div",hn,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:y=>t.$emit("select",l)},[e.createElementVNode("span",pn,[(e.openBlock(),e.createElementBlock("svg",_n,[e.createElementVNode("path",{d:o.iconPath(l.icon)},null,8,gn)]))]),e.createElementVNode("span",vn,[e.createElementVNode("span",yn,e.toDisplayString(l.label),1),l.description?(e.openBlock(),e.createElementBlock("span",kn,e.toDisplayString(l.description),1)):e.createCommentVNode("",!0)])],10,fn))),128))],2)])):e.createCommentVNode("",!0),r.openThreads.length?(e.openBlock(),e.createElementBlock("div",bn,[e.createElementVNode("div",wn,e.toDisplayString(o.t("onboarding.recentConversations")),1),e.createElementVNode("div",En,[n[3]||(n[3]=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=>i.query=l),type:"text",placeholder:o.t("onboarding.search"),"aria-label":o.t("onboarding.search")},null,8,Cn),[[e.vModelText,i.query]])]),e.createElementVNode("div",Bn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.filteredThreads,l=>(e.openBlock(),e.createElementBlock("button",{key:l.id,type:"button",class:"wm-onb__thread",onClick:p=>t.$emit("resume",l)},[e.createElementVNode("span",{class:e.normalizeClass(["wm-onb__thread-icon",{"wm-onb__thread-icon--inverted":!l.unread}])},[n[4]||(n[4]=e.createElementVNode("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[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:"currentColor",opacity:"0.92"})],-1)),l.unread?(e.openBlock(),e.createElementBlock("span",{key:0,class:"wm-onb__thread-dot","aria-label":o.t("onboarding.unread")},null,8,Sn)):e.createCommentVNode("",!0)],2),e.createElementVNode("span",An,[e.createElementVNode("span",Vn,e.toDisplayString(l.title),1),e.createElementVNode("span",Mn,e.toDisplayString(l.preview),1)]),e.createElementVNode("span",Tn,[o.formatTs(l._ts)?(e.openBlock(),e.createElementBlock("span",xn,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))])],8,Nn))),128)),o.filteredThreads.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Ln,e.toDisplayString(o.t("onboarding.noResults",{query:i.query})),1))])])):e.createCommentVNode("",!0)])}const Be=B(on,[["render",On],["__scopeId","data-v-755a509c"]]);function Dn(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 In={name:"WmActionResult",props:{state:{type:String,default:"success"},label:{type:String,required:!0},detail:{type:String,default:""}},computed:{detailText(){return Dn(this.detail)}}},Rn={class:"wm-result__icon","aria-hidden":"true"},Fn={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"},jn={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"},Pn={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"},Un={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"},zn={class:"wm-result__body"},$n={class:"wm-result__label"},Hn={class:"wm-result__detail"};function qn(t,n,r,s,i,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-result",`wm-result--${r.state}`])},[e.createElementVNode("span",Rn,[r.state==="success"?(e.openBlock(),e.createElementBlock("svg",Fn,[...n[0]||(n[0]=[e.createElementVNode("path",{d:"M20 6L9 17l-5-5"},null,-1)])])):r.state==="rejected"?(e.openBlock(),e.createElementBlock("svg",jn,[...n[1]||(n[1]=[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"},null,-1)])])):r.state==="awaiting"?(e.openBlock(),e.createElementBlock("svg",Pn,[...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",Un,[...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",zn,[e.createElementVNode("span",$n,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",Hn,e.toDisplayString(o.detailText),1)],64)):e.createCommentVNode("",!0)])],2)}const Ne=B(In,[["render",qn],["__scopeId","data-v-7284acd0"]]),Kn={name:"WmArtifactFormResponse",inject:{t:{default:()=>A()}},props:{data:{type:Object,required:!0}},computed:{fields(){var t;return Array.isArray((t=this.data)==null?void 0:t.fields)?this.data.fields:[]}}},Wn={class:"wm-art wm-art--formResponse"},Gn={class:"wm-art__head"},Yn={class:"wm-art__title"},Qn={class:"wm-art__badge wm-art__badge--success"},Xn={class:"wm-art__body"},Jn={class:"wm-art__fieldLabel"};function Zn(t,n,r,s,i,o){return e.openBlock(),e.createElementBlock("div",Wn,[e.createElementVNode("div",Gn,[e.createElementVNode("div",Yn,e.toDisplayString(r.data.title||o.t("form.title")),1),e.createElementVNode("span",Qn,[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",Xn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.fields,(a,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-art__field"},[e.createElementVNode("div",Jn,e.toDisplayString(a.label),1),e.createElementVNode("div",{class:e.normalizeClass(["wm-art__fieldValue",{"wm-art__fieldValue--multi":a.multiline}])},e.toDisplayString(a.value),3)]))),128))])])}const Se=B(Kn,[["render",Zn],["__scopeId","data-v-713aecf1"]]),er={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}}},tr={class:"wm-art wm-art--infoCard"},nr={key:0,class:"wm-art__image"},rr=["src","alt"],or={class:"wm-art__head"},sr={class:"wm-art__headMain"},ar={class:"wm-art__title"},ir={key:0,class:"wm-art__subtitle"},lr={key:1,class:"wm-art__body"},cr={key:0,class:"wm-art__text"},dr={class:"wm-art__fieldLabel"};function ur(t,n,r,s,i,o){return e.openBlock(),e.createElementBlock("div",tr,[r.data.image_url?(e.openBlock(),e.createElementBlock("figure",nr,[e.createElementVNode("img",{src:r.data.image_url,alt:r.data.title||"",loading:"lazy"},null,8,rr)])):e.createCommentVNode("",!0),e.createElementVNode("div",or,[e.createElementVNode("div",sr,[e.createElementVNode("div",ar,e.toDisplayString(r.data.title),1),r.data.subtitle?(e.openBlock(),e.createElementBlock("div",ir,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",lr,[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,(a,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-art__field"},[e.createElementVNode("div",dr,e.toDisplayString(a.label),1),e.createElementVNode("div",{class:e.normalizeClass(["wm-art__fieldValue",{"wm-art__fieldValue--multi":a.multiline}])},e.toDisplayString(a.value),3)]))),128)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])}const Ae=B(er,[["render",ur],["__scopeId","data-v-7eae0e4a"]]);function mr(t,n,r){if(!t)return"";const s=new Date(t);if(Number.isNaN(s.getTime()))return t;const i=s.toLocaleDateString(n,{day:"numeric",month:"long",year:"numeric"}),o=s.toLocaleTimeString(n,{hour:"2-digit",minute:"2-digit"});return`${i}${r}${o}`}const hr={name:"WmArtifactTicket",inject:{t:{default:()=>A()},wmLocale:{default:()=>()=>"fr"}},props:{data:{type:Object,required:!0}},computed:{fields(){var t;return Array.isArray((t=this.data)==null?void 0:t.fields)?this.data.fields:[]},formattedDate(){var t;return mr((t=this.data)==null?void 0:t.created_at,$(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}}},fr={class:"wm-art wm-art--ticket"},pr={class:"wm-art__head wm-tk__head"},_r={class:"wm-art__title wm-tk__title"},gr={class:"wm-tk__sub"},vr={class:"wm-tk__ref"},yr={key:0,class:"wm-tk__text"},kr={key:0,class:"wm-art__body"},br={class:"wm-art__fieldLabel"},wr=["data-level"],Er={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"},Cr={key:1,class:"wm-art__footer wm-tk__footer"};function Br(t,n,r,s,i,o){return e.openBlock(),e.createElementBlock("div",fr,[e.createElementVNode("div",pr,[e.createElementVNode("div",_r,e.toDisplayString(r.data.title),1),e.createElementVNode("div",gr,[e.createElementVNode("div",vr,[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",yr,e.toDisplayString(r.data.body),1)):e.createCommentVNode("",!0)]),o.fields.length?(e.openBlock(),e.createElementBlock("div",kr,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.fields,(a,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-art__field"},[e.createElementVNode("div",br,e.toDisplayString(a.label),1),e.createElementVNode("div",{class:e.normalizeClass(["wm-art__fieldValue",{"wm-art__fieldValue--multi":a.multiline}])},[o.isPriority(a.label)?(e.openBlock(),e.createElementBlock("svg",{key:0,class:"wm-tk__prio","data-level":o.priorityLevel(a.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,wr)):o.isDate(a.label)?(e.openBlock(),e.createElementBlock("svg",Er,[...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(a.value),1)],2)]))),128))])):e.createCommentVNode("",!0),r.data.created_at?(e.openBlock(),e.createElementBlock("div",Cr,[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 Ve=B(hr,[["render",Br],["__scopeId","data-v-5f30c914"]]),Nr={form_response:Se,info_card:Ae,ticket:Ve},Sr={name:"WmArtifactRenderer",props:{artifact:{type:Object,required:!0}},computed:{component(){var n;const t=(n=this.artifact)==null?void 0:n.kind;return t&&Nr[t]||null}}};function Ar(t,n,r,s,i,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 Me=B(Sr,[["render",Ar]]),Vr={name:"WmAttachmentPreview",inject:{signAttachmentFn:{default:null},t:{default:()=>A()}},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")},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.url||t.preventDefault()}}},Mr=["href"],Tr=["src","alt"],xr=["src"],Lr=["src"],Or=["href","download"],Dr={class:"wm-att__main"},Ir={class:"wm-att__name"},Rr={key:0,class:"wm-att__meta"},Fr={key:0,class:"wm-att__spin","aria-hidden":"true"};function jr(t,n,r,s,i,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-att",["wm-att--"+(o.kind||"file")]])},[o.kind==="image"&&i.url?(e.openBlock(),e.createElementBlock("a",{key:0,href:i.url,target:"_blank",rel:"noopener",class:"wm-att__imgWrap"},[e.createElementVNode("img",{src:i.url,alt:o.displayName,loading:"lazy"},null,8,Tr)],8,Mr)):o.kind==="audio"&&i.url?(e.openBlock(),e.createElementBlock("audio",{key:1,src:i.url,controls:"",preload:"metadata"},null,8,xr)):o.kind==="video"&&i.url?(e.openBlock(),e.createElementBlock("video",{key:2,src:i.url,controls:"",preload:"metadata"},null,8,Lr)):(e.openBlock(),e.createElementBlock("a",{key:3,class:"wm-att__file",href:i.url||"#",download:o.displayName,target:"_blank",rel:"noopener",onClick:n[0]||(n[0]=(...a)=>o.onFileClick&&o.onFileClick(...a))},[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",Dr,[e.createElementVNode("span",Ir,e.toDisplayString(o.displayName),1),o.sizeLabel?(e.openBlock(),e.createElementBlock("span",Rr,e.toDisplayString(o.sizeLabel),1)):e.createCommentVNode("",!0)]),i.loading?(e.openBlock(),e.createElementBlock("span",Fr)):e.createCommentVNode("",!0)],8,Or))],2)}const Te=B(Vr,[["render",jr],["__scopeId","data-v-afc7b0d3"]]);function Pr(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Ur(t){return/^(https?:\/\/|mailto:|tel:)/i.test(String(t).trim())}const he="";function X(t){let n=t;const r=[];return n=n.replace(/`([^`\n]+)`/g,(s,i)=>{const o=r.length;return r.push(i),`${he}CODE${o}${he}`}),n=n.replace(/\[([^\]\n]+)\]\(([^)\s]+)\)/g,(s,i,o)=>Ur(o)?`<a href="${o}" target="_blank" rel="noopener noreferrer">${i}</a>`:i),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,i)=>`<code class="wm-md-code">${r[+i]}</code>`),n}function xe(t){if(!t)return"";const n=Pr(t).split(`
55
- `),r=[];let s=0;for(;s<n.length;){const o=n[s];if(/^\s*```([\w-]*)\s*$/.exec(o)){s++;const y=[];for(;s<n.length&&!/^\s*```\s*$/.test(n[s]);)y.push(n[s]),s++;s<n.length&&s++,r.push({type:"block",html:`<pre class="wm-md-pre"><code>${y.join(`
56
- `)}</code></pre>`});continue}if(/^\s*[-*]\s+/.test(o)){const y=[];for(;s<n.length;){const E=/^\s*[-*]\s+(.*)$/.exec(n[s]);if(!E)break;y.push(E[1]),s++}const v=y.map(E=>`<li>${X(E)}</li>`).join("");r.push({type:"block",html:`<ul class="wm-md-ul">${v}</ul>`});continue}const l=/^\s*(\d+)\.\s+(.*)$/.exec(o);if(l){const y=parseInt(l[1],10),v=[l[2]];for(s++;s<n.length;){const k=/^\s*\d+\.\s+(.*)$/.exec(n[s]);if(!k)break;v.push(k[1]),s++}const E=v.map(k=>`<li>${X(k)}</li>`).join(""),N=y!==1?` start="${y}"`:"";r.push({type:"block",html:`<ol class="wm-md-ol"${N}>${E}</ol>`});continue}const p=/^(#{1,6})\s+(.*)$/.exec(o);if(p){const y=p[1].length;r.push({type:"block",html:`<h${y} class="wm-md-h wm-md-h${y}">${X(p[2])}</h${y}>`}),s++;continue}r.push({type:"text",html:X(o)}),s++}let i="";for(let o=0;o<r.length;o++){const a=r[o];i+=a.html;const l=r[o+1];l&&a.type!=="block"&&l.type!=="block"&&(i+=`
57
- `)}return i}const zr={name:"WmBubble",props:{role:{type:String,default:"ai"},text:{type:String,default:""}},computed:{rendered(){return xe(this.text)}}},$r=["innerHTML"];function Hr(t,n,r,s,i,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,$r)],!0)],2)}const Le=B(zr,[["render",Hr],["__scopeId","data-v-7ab13147"]]),qr={name:"WmTyping"},Kr={class:"wm-typing"};function Wr(t,n,r,s,i,o){return e.openBlock(),e.createElementBlock("div",Kr,[...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 Oe=B(qr,[["render",Wr],["__scopeId","data-v-df2447fd"]]);function K(t){return t?t.client_msg_id||t.id:""}const Gr={transferred_to_human:"system.transferredToHuman",assigned:"system.assigned",unassigned:"system.unassigned",resolved:"system.resolved",reopened:"system.reopened",idle:"system.idle"},Yr=80,Qr=200,Xr={name:"WmMessageList",components:{AIAvatar:H,HumanAvatar:ie,Bubble:Le,Typing:Oe,ActionResult:Ne,AttachmentPreview:Te,ArtifactRenderer:Me},inject:{t:{default:()=>A()},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:""}},emits:["load-more"],data(){return{silentFades:!1,widthByKey:Object.freeze({})}},computed:{historyExhausted(){return!this.hasMore&&!this.loadingMore&&this.messages.length>=20},groups(){var r,s,i,o;const t=[];for(const a of this.messages){const l=this.roleOf(a);if(l==="system"){if(((r=a==null?void 0:a.payload)==null?void 0:r.event)==="action_admin_pending"){const v=t[t.length-1];v&&v.role==="ai"?v.messages.push(a):t.push({key:`g-${K(a)}`,role:"ai",agentName:"",agentAvatarUrl:null,messages:[a],items:[]});continue}t.push({key:`sys-${K(a)}`,role:l,messages:[a],items:[],systemLabel:this.systemLabel(a)});continue}const p=t[t.length-1];p&&p.role===l&&(l==="ai"||p.agentName===(((s=a==null?void 0:a.author)==null?void 0:s.name)||""))?p.messages.push(a):t.push({key:`g-${K(a)}`,role:l,agentName:((i=a==null?void 0:a.author)==null?void 0:i.name)||"",agentAvatarUrl:((o=a==null?void 0:a.author)==null?void 0:o.avatar_url)||null,messages:[a],items:[]})}for(const a of t){if(a.role==="system")continue;const l=[];for(const p of a.messages)for(const y of this.itemsOf(p))l.push(y);a.items=l}const n=[];for(const a of t){if(a.role!=="system"&&!a.items.length)continue;const l=n[n.length-1];if(l&&l.role!=="system"&&l.role===a.role&&(a.role==="ai"||l.agentName===a.agentName)){l.messages.push(...a.messages),l.items.push(...a.items);continue}n.push(a)}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 i=j(s.id);if(i!=null&&!(i<=t)&&!(n&&s.created_at&&s.created_at>n))return r.key}return null}},watch:{messages:{handler:"snapshotAndRestore",deep:!0},loadingMore(t){t||(this._pendingLoadMore=!1),this.silentFades=!0,clearTimeout(this._silenceTimer),t||(this._silenceTimer=setTimeout(()=>{this.silentFades=!1},250)),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),clearTimeout(this._silenceTimer)},updated(){this.scheduleMeasure()},methods:{messageKey:K,isAtBottom(t){return t.scrollHeight-t.scrollTop-t.clientHeight<=Yr},onScroll(){const t=this.$refs.scrollEl;t&&(this.loadingMore||!this.hasMore||this._pendingLoadMore||t.scrollTop<=Qr&&(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.el){const a=t.getBoundingClientRect().top;s={el:o.el,relY:o.el.getBoundingClientRect().top-a}}}const i={forceBottom:n,wasPinned:r,anchor:s};this._scrollSnap=i,this.$nextTick(()=>{if(this._scrollSnap=null,i.forceBottom||i.wasPinned){t.scrollTop=t.scrollHeight;return}if(!i.anchor)return;const o=()=>{var y;const a=i.anchor;if(!((y=a.el)!=null&&y.isConnected))return;const p=a.el.getBoundingClientRect().top-t.getBoundingClientRect().top-a.relY;Math.abs(p)>.5&&(t.scrollTop+=p)};o(),requestAnimationFrame(()=>{o(),requestAnimationFrame(o)})})},pickAnchor(t){const n=t.scrollTop;let r=null;for(const s of t.children)if(s.classList.contains("wm-list__group")&&(r||(r=s),s.offsetTop+s.offsetHeight>=n))return{el:s,offsetTop:s.offsetTop};return r?{el:r,offsetTop:r.offsetTop}:null},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){return t.role==="human"?t.agentName||this.t("common.agent"):this.t("common.aiAssistant")},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 P,U,I;const r=t.items,s=(P=r[n])==null?void 0:P.kind,i=(U=r[n-1])==null?void 0:U.kind,o=(I=r[n+1])==null?void 0:I.kind,a=t.role==="user",l=14,p=4,y=i==null?void 0:i.bottom,v=o==null?void 0:o.top,E=this.widthByKey[this.rowKeyOf(t,n)],N=this.widthByKey[this.rowKeyOf(t,n-1)],k=this.widthByKey[this.rowKeyOf(t,n+1)],L=.5,w=(R,F,O)=>R!=null&&E!=null?R+L>=E:F===O||F==="card"&&O==="bubble";let T=l,S=l,x=l,D=l;return a?(y&&(S=p),(v||!o)&&(x=p),y&&w(N,y,s==null?void 0:s.top)&&(T=p),v&&w(k,v,s==null?void 0:s.bottom)&&(D=p)):(y&&(T=p),(v||!o)&&(D=p),y&&w(N,y,s==null?void 0:s.top)&&(S=p),v&&w(k,v,s==null?void 0:s.bottom)&&(x=p)),{tl:T,tr:S,br:x,bl:D}},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?`${K(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 a=o.dataset.rowKey;if(!a)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[a]=p)}const r=this.widthByKey,s=Object.keys(r),i=Object.keys(n);if(s.length===i.length){let o=!0;for(const a of i)if(Math.abs((r[a]??0)-n[a])>.5){o=!1;break}if(o)return}this.widthByKey=Object.freeze(n)},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 ae(new Date(r.created_at),$(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,i,o,a,l;const n=t==null?void 0:t.payload;return n?n.state==="success"?((r=n.success)==null?void 0:r.summary)||((i=(s=n.success)==null?void 0:s.metadata)==null?void 0:i.description)||"":n.state==="rejected"?((o=n.rejected)==null?void 0:o.reason)||this.t("action.rejectedByUser"):n.state==="failure"&&(((a=n.failure)==null?void 0:a.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 i,o,a;const n=(i=t==null?void 0:t.payload)==null?void 0:i.event,r=Gr[n],s=((o=t==null?void 0:t.metadata)==null?void 0:o.agent_name)||((a=t==null?void 0:t.author)==null?void 0:a.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)}}},Jr={key:0,class:"wm-list__loadMore",role:"status","aria-live":"polite"},Zr={class:"wm-list__loadMore-lbl"},eo={key:1,class:"wm-list__historyEnd"},to={key:2,class:"wm-list__sep"},no={class:"wm-list__sep-label"},ro={key:0,class:"wm-list__sep wm-list__sep--unread"},oo={class:"wm-list__sep-label wm-list__sep-label--unread"},so={key:0,class:"wm-list__sysep"},ao={class:"wm-list__sysep-label"},io=["data-row-key"],lo={key:0,class:"wm-list__avatarSlot"},co={key:5,class:"wm-list__body"},uo={key:0},mo={key:1,"aria-hidden":"true"},ho={key:2},fo={key:3,class:"wm-list__row wm-list__row--ai fade-up"},po={class:"wm-list__avatarSlot"};function _o(t,n,r,s,i,o){const a=e.resolveComponent("AIAvatar"),l=e.resolveComponent("HumanAvatar"),p=e.resolveComponent("ActionResult"),y=e.resolveComponent("ArtifactRenderer"),v=e.resolveComponent("Bubble"),E=e.resolveComponent("AttachmentPreview"),N=e.resolveComponent("Typing");return e.openBlock(),e.createElementBlock("div",{ref:"scrollEl",class:e.normalizeClass(["wm-list",{"wm-list--silent":i.silentFades}]),onScrollPassive:n[0]||(n[0]=(...k)=>o.onScroll&&o.onScroll(...k))},[r.loadingMore?(e.openBlock(),e.createElementBlock("div",Jr,[n[1]||(n[1]=e.createElementVNode("span",{class:"wm-list__loadMore-spinner","aria-hidden":"true"},null,-1)),e.createElementVNode("span",Zr,e.toDisplayString(o.t("messageList.loadingHistory")),1)])):o.historyExhausted?(e.openBlock(),e.createElementBlock("div",eo,e.toDisplayString(o.t("messageList.conversationStart")),1)):e.createCommentVNode("",!0),r.dateLabel?(e.openBlock(),e.createElementBlock("div",to,[n[2]||(n[2]=e.createElementVNode("div",{class:"wm-list__line"},null,-1)),e.createElementVNode("span",no,e.toDisplayString(r.dateLabel),1),n[3]||(n[3]=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,L)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:k.key},[k.key===o.unreadGroupKey?(e.openBlock(),e.createElementBlock("div",ro,[n[4]||(n[4]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--unread"},null,-1)),e.createElementVNode("span",oo,e.toDisplayString(o.t("messageList.unread")),1),n[5]||(n[5]=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",so,[n[6]||(n[6]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--strong"},null,-1)),e.createElementVNode("span",ao,e.toDisplayString(k.systemLabel),1),n[7]||(n[7]=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,T)=>(e.openBlock(),e.createElementBlock("div",{key:`${o.messageKey(w.message)}-${w.partKey}`,"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,T))},[k.role!=="user"?(e.openBlock(),e.createElementBlock("div",lo,[T===k.items.length-1?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[k.role==="ai"?(e.openBlock(),e.createBlock(a,{key:0,size:26,tail:!0})):(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(y,{key:3,artifact:o.actionArtifact(w.message)},null,8,["artifact"])):w.renderAs==="artifact"?(e.openBlock(),e.createBlock(y,{key:4,artifact:o.artifactOf(w.message)},null,8,["artifact"])):(e.openBlock(),e.createElementBlock("div",co,[w.message.text_md?(e.openBlock(),e.createBlock(v,{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),(S,x)=>(e.openBlock(),e.createBlock(E,{key:`${o.messageKey(w.message)}-att-${x}`,attachment:S},null,8,["attachment"]))),128))],2)):e.createCommentVNode("",!0)]))],14,io))),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",uo,e.toDisplayString(o.roleLabel(k)),1)):e.createCommentVNode("",!0),k.role!=="user"&&o.lastTimeOf(k)?(e.openBlock(),e.createElementBlock("span",mo,"·")):e.createCommentVNode("",!0),o.lastTimeOf(k)?(e.openBlock(),e.createElementBlock("span",ho,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",fo,[e.createElementVNode("div",po,[e.createVNode(a,{size:26,tail:!0})]),e.createVNode(N)])):e.createCommentVNode("",!0)],34)}const De=B(Xr,[["render",_o],["__scopeId","data-v-ced149e1"]]),G=typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function",ee=typeof window<"u"&&typeof window.MediaRecorder<"u";function Ie(){return ee&&["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 Re({audio:t}){return{video:!0,audio:!!t,selfBrowserSurface:"include",surfaceSwitching:"include",systemAudio:t?"include":"exclude"}}function go(t){return t?t.startsWith("image/")?"image":t.startsWith("video/")?"video":"file":"file"}async function Fe(){if(!G)return null;let t;try{t=await navigator.mediaDevices.getDisplayMedia(Re({audio:!1}))}catch(n){return(n==null?void 0:n.name)!=="NotAllowedError"&&console.error("[media] screenshot picker",n),null}try{return await vo(t)}catch(n){return console.error("[media] screenshot capture",n),null}finally{t.getTracks().forEach(n=>{n.stop()})}}async function vo(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,i=document.createElement("canvas");i.width=r,i.height=s,i.getContext("2d").drawImage(n,0,0,r,s);const o=await new Promise((l,p)=>{i.toBlob(y=>y?l(y):p(new Error("toBlob failed")),"image/png")}),a=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19);return new File([o],`capture-${a}.png`,{type:"image/png"})}async function je(t={}){var y;if(!G||!ee)return null;let n;try{n=await navigator.mediaDevices.getDisplayMedia(Re({audio:!0}))}catch(v){return(v==null?void 0:v.name)!=="NotAllowedError"&&console.error("[media] record picker",v),null}const r=Ie();let s;try{s=r?new window.MediaRecorder(n,{mimeType:r}):new window.MediaRecorder(n)}catch(v){return console.error("[media] recorder init",v),n.getTracks().forEach(E=>{E.stop()}),null}const i=[];let o=null,a=!1;s.addEventListener("dataavailable",v=>{v.data&&v.data.size>0&&i.push(v.data)}),s.addEventListener("stop",()=>{var v,E;if(o&&clearInterval(o),n.getTracks().forEach(N=>{N.stop()}),i.length){const N=s.mimeType||r||"video/webm",k=new Blob(i,{type:N}),L=/mp4/.test(N)?"mp4":"webm",w=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),T=new File([k],`ecran-${w}.${L}`,{type:N});(v=t.onfinalize)==null||v.call(t,T)}else(E=t.oncancel)==null||E.call(t)}),n.getVideoTracks().forEach(v=>{v.addEventListener("ended",()=>l(),{once:!0})});function l(){if(!a&&(a=!0,s.state!=="inactive"))try{s.stop()}catch(v){console.error("[media] recorder stop",v)}}try{s.start(1e3)}catch(v){return console.error("[media] recorder start",v),n.getTracks().forEach(E=>{E.stop()}),null}(y=t.onstart)==null||y.call(t);const p=Date.now();return o=setInterval(()=>{var v;(v=t.ontick)==null||v.call(t,Date.now()-p)},500),{stop:l,get state(){return s.state}}}const yo=[{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"}],ko={name:"WmComposer",inject:{t:{default:()=>A()}},props:{modelValue:{type:String,default:""},placeholder:{type:String,default:"Écrivez votre message…"},disabled:{type:Boolean,default:!1},attachLabel:{type:String,default:"Joindre"}},emits:["update:modelValue","send","attach"],data(){return{local:this.modelValue,attachOpen:!1,recording:!1,recordingElapsed:0,recorder:null}},computed:{canSend(){return!this.disabled&&!!this.local.trim()},attachItems(){return yo.map(t=>({...t,label:this.t(t.labelKey),disabled:t.action==="screenshot"&&!G||t.action==="record"&&(!G||!ee)}))},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()},beforeUnmount(){if(this.recorder)try{this.recorder.stop()}catch{}},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.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 Fe();t&&this.$emit("attach",t)},async startRecording(){if(this.recording||this.disabled)return;this.recordingElapsed=0;const t=await je({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)}}}},bo={class:"wm-compose-wrap"},wo={key:0,class:"wm-rec"},Eo={class:"wm-rec__lbl"},Co={key:1,class:"wm-compose__menu",role:"menu"},Bo=["disabled","onClick"],No={class:"wm-compose__menuIcon"},So={viewBox:"0 0 24 24",width:"14",height:"14","aria-hidden":"true"},Ao=["d"],Vo=["placeholder","disabled"],Mo={class:"wm-compose__actions"},To=["title","aria-label","disabled"],xo=["disabled","aria-label"];function Lo(t,n,r,s,i,o){return e.openBlock(),e.createElementBlock("div",bo,[i.recording?(e.openBlock(),e.createElementBlock("div",wo,[n[8]||(n[8]=e.createElementVNode("span",{class:"wm-rec__dot","aria-hidden":"true"},null,-1)),e.createElementVNode("span",Eo,e.toDisplayString(o.t("composer.recording",{time:o.recordingElapsedLabel})),1),e.createElementVNode("button",{type:"button",class:"wm-rec__stop",onClick:n[0]||(n[0]=(...a)=>o.stopRecording&&o.stopRecording(...a))},e.toDisplayString(o.t("composer.stop")),1)])):e.createCommentVNode("",!0),e.createElementVNode("form",{class:e.normalizeClass(["wm-compose",{"has-attach":i.attachOpen}]),onSubmit:n[7]||(n[7]=e.withModifiers((...a)=>o.onSubmit&&o.onSubmit(...a),["prevent"]))},[e.createElementVNode("input",{ref:"fileEl",type:"file",hidden:"",multiple:"",onChange:n[1]||(n[1]=(...a)=>o.onFile&&o.onFile(...a))},null,544),i.attachOpen?(e.openBlock(),e.createElementBlock("div",{key:0,class:"wm-compose__overlay",onClick:n[2]||(n[2]=a=>i.attachOpen=!1)})):e.createCommentVNode("",!0),i.attachOpen?(e.openBlock(),e.createElementBlock("div",Co,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.attachItems,a=>(e.openBlock(),e.createElementBlock("button",{key:a.action,type:"button",class:"wm-compose__menuItem",disabled:a.disabled,onClick:l=>o.onAttachAction(a.action)},[e.createElementVNode("span",No,[(e.openBlock(),e.createElementBlock("svg",So,[e.createElementVNode("path",{d:a.path,stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round",fill:"none"},null,8,Ao)]))]),e.createElementVNode("span",null,e.toDisplayString(a.label),1)],8,Bo))),128))])):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("textarea",{ref:"inputEl","onUpdate:modelValue":n[3]||(n[3]=a=>i.local=a),class:"wm-compose__input",rows:"3",placeholder:r.placeholder,disabled:r.disabled,onKeydown:n[4]||(n[4]=(...a)=>o.onKeydown&&o.onKeydown(...a)),onInput:n[5]||(n[5]=(...a)=>o.autosize&&o.autosize(...a))},null,40,Vo),[[e.vModelText,i.local]]),e.createElementVNode("div",Mo,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["wm-compose__icon",{"is-open":i.attachOpen}]),title:r.attachLabel,"aria-label":r.attachLabel,disabled:i.recording,onClick:n[6]||(n[6]=a=>i.attachOpen=!i.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,To),e.createElementVNode("button",{type:"submit",class:e.normalizeClass(["wm-compose__send",{"is-empty":!o.canSend}]),disabled:!o.canSend,"aria-label":o.t("composer.send")},[...n[10]||(n[10]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})],-1)])],10,xo)])],34)])}const Pe=B(ko,[["render",Lo],["__scopeId","data-v-aa81dbb8"]]),Oo={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("§")}}},Do=["onClick"];function Io(t,n,r,s,i,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,(a,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",a)},e.toDisplayString(a.label),13,Do))),128))])):e.createCommentVNode("",!0)}const Ue=B(Oo,[["render",Io],["__scopeId","data-v-47ad8085"]]),Ro={name:"WmApprovalCard",components:{AIAvatar:H},inject:{t:{default:()=>A()}},props:{action:{type:String,required:!0},detail:{type:String,default:""},callbacks:{type:Array,default:()=>[]}},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")}}},Fo={class:"wm-approval"},jo={class:"wm-approval__head"},Po={class:"wm-approval__icon"},Uo={class:"wm-approval__main"},zo={class:"wm-approval__title"},$o={key:0,class:"wm-approval__detail"},Ho={class:"wm-approval__actions"};function qo(t,n,r,s,i,o){const a=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",Fo,[e.createElementVNode("div",jo,[e.createElementVNode("div",Po,[e.createVNode(a,{size:24})]),e.createElementVNode("div",Uo,[e.createElementVNode("div",zo,e.toDisplayString(r.action),1),r.detail?(e.openBlock(),e.createElementBlock("div",$o,e.toDisplayString(r.detail),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",Ho,[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 ze=B(Ro,[["render",qo],["__scopeId","data-v-53ddf2b2"]]);let fe=0;const Ko=new Set(["text","textarea","number","boolean","select","multiselect","date"]),Wo={name:"WmFormCard",components:{AIAvatar:H},inject:{t:{default:()=>A()}},props:{form:{type:Object,required:!0},readOnly:{type:Boolean,default:!1},initialValues:{type:Object,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)||!Ko.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():[],i=s.indexOf(n);r&&i===-1?s.push(n):!r&&i!==-1&&s.splice(i,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}}}},Go={class:"wm-form"},Yo={class:"wm-form__head"},Qo={class:"wm-form__icon"},Xo={class:"wm-form__main"},Jo={class:"wm-form__title"},Zo={key:0,class:"wm-form__detail"},es=["for"],ts={key:0,class:"wm-form__req","aria-hidden":"true"},ns=["id","onUpdate:modelValue","placeholder","required","disabled"],rs=["id","onUpdate:modelValue","placeholder","required","disabled"],os=["id","onUpdate:modelValue","placeholder","required","disabled"],ss=["id","onUpdate:modelValue","required","disabled"],as={key:4,class:"wm-form__bool"},is=["id","onUpdate:modelValue","disabled"],ls=["id","onUpdate:modelValue","required","disabled"],cs={value:"",disabled:""},ds=["value"],us={key:6,class:"wm-form__multi"},ms=["value","checked","disabled","onChange"],hs={key:0,class:"wm-form__err"},fs=["disabled"],ps={key:0,class:"wm-form__spinner","aria-hidden":"true"},_s={key:2,class:"wm-form__doneLbl"};function gs(t,n,r,s,i,o){const a=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",Go,[e.createElementVNode("div",Yo,[e.createElementVNode("div",Qo,[e.createVNode(a,{size:24})]),e.createElementVNode("div",Xo,[e.createElementVNode("div",Jo,e.toDisplayString(r.form.title||o.t("form.title")),1),r.form.description?(e.openBlock(),e.createElementBlock("div",Zo,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-${i._uid}-${l.key}`,class:"wm-form__label"},[e.createTextVNode(e.toDisplayString(l.label),1),l.required?(e.openBlock(),e.createElementBlock("span",ts,"*")):e.createCommentVNode("",!0)],8,es),l.type==="text"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,id:`wm-f-${i._uid}-${l.key}`,"onUpdate:modelValue":p=>i.values[l.key]=p,type:"text",class:"wm-form__input",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||i.busy},null,8,ns)),[[e.vModelText,i.values[l.key]]]):l.type==="textarea"?e.withDirectives((e.openBlock(),e.createElementBlock("textarea",{key:1,id:`wm-f-${i._uid}-${l.key}`,"onUpdate:modelValue":p=>i.values[l.key]=p,class:"wm-form__textarea",rows:"3",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||i.busy},null,8,rs)),[[e.vModelText,i.values[l.key]]]):l.type==="number"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:2,id:`wm-f-${i._uid}-${l.key}`,"onUpdate:modelValue":p=>i.values[l.key]=p,type:"number",class:"wm-form__input",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||i.busy},null,8,os)),[[e.vModelText,i.values[l.key],void 0,{number:!0}]]):l.type==="date"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:3,id:`wm-f-${i._uid}-${l.key}`,"onUpdate:modelValue":p=>i.values[l.key]=p,type:"date",class:"wm-form__input",required:l.required,disabled:r.readOnly||i.busy},null,8,ss)),[[e.vModelText,i.values[l.key]]]):l.type==="boolean"?(e.openBlock(),e.createElementBlock("label",as,[e.withDirectives(e.createElementVNode("input",{id:`wm-f-${i._uid}-${l.key}`,"onUpdate:modelValue":p=>i.values[l.key]=p,type:"checkbox",disabled:r.readOnly||i.busy},null,8,is),[[e.vModelCheckbox,i.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-${i._uid}-${l.key}`,"onUpdate:modelValue":p=>i.values[l.key]=p,class:"wm-form__select",required:l.required,disabled:r.readOnly||i.busy},[e.createElementVNode("option",cs,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,ds))),128))],8,ls)),[[e.vModelSelect,i.values[l.key]]]):l.type==="multiselect"?(e.openBlock(),e.createElementBlock("div",us,[(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(i.values[l.key])&&i.values[l.key].includes(p.value),disabled:r.readOnly||i.busy,onChange:y=>o.toggleMulti(l.key,p.value,y.target.checked)},null,40,ms),e.createElementVNode("span",null,e.toDisplayString(p.label),1)]))),128))])):e.createCommentVNode("",!0)]))),128)),i.error?(e.openBlock(),e.createElementBlock("div",hs,e.toDisplayString(i.error),1)):e.createCommentVNode("",!0),r.readOnly?(e.openBlock(),e.createElementBlock("div",_s,e.toDisplayString(o.t("form.responseSent")),1)):(e.openBlock(),e.createElementBlock("button",{key:1,type:"submit",class:"wm-form__submit",disabled:i.busy},[i.busy?(e.openBlock(),e.createElementBlock("span",ps)):e.createCommentVNode("",!0),e.createElementVNode("span",null,e.toDisplayString(i.busy?o.t("common.sending"):r.form.submit_label||o.t("common.send")),1)],8,fs))],32)])}const $e=B(Wo,[["render",gs],["__scopeId","data-v-75332dad"]]),vs={name:"WmFeedback",inject:{t:{default:()=>A()}},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})}}},ys={class:"wm-fb"},ks={class:"wm-fb__title"},bs={class:"wm-fb__sub"},ws={class:"wm-fb__row"},Es=["onClick"],Cs={class:"wm-fb__emoji"},Bs={class:"wm-fb__label"},Ns=["disabled"],Ss={key:1,class:"wm-fb__done"},As={class:"wm-fb__doneTitle"},Vs={class:"wm-fb__doneSub"};function Ms(t,n,r,s,i,o){return e.openBlock(),e.createElementBlock("div",ys,[r.done?(e.openBlock(),e.createElementBlock("div",Ss,[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",As,e.toDisplayString(o.t("feedback.doneTitle")),1),e.createElementVNode("div",Vs,e.toDisplayString(o.t("feedback.doneSubtitle")),1)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("div",ks,e.toDisplayString(o.t("feedback.question")),1),e.createElementVNode("div",bs,e.toDisplayString(o.t("feedback.subtitle")),1),e.createElementVNode("div",ws,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.options,a=>(e.openBlock(),e.createElementBlock("button",{key:a.v,type:"button",class:e.normalizeClass(["wm-fb__opt",{"is-selected":i.sel===a.v}]),onClick:l=>i.sel=a.v},[e.createElementVNode("span",Cs,e.toDisplayString(a.e),1),e.createElementVNode("span",Bs,e.toDisplayString(a.l),1)],10,Es))),128))]),e.createElementVNode("button",{type:"button",class:"wm-fb__send",disabled:!i.sel||r.busy,onClick:n[0]||(n[0]=(...a)=>o.onSend&&o.onSend(...a))},e.toDisplayString(r.busy?o.t("common.sending"):o.t("feedback.submit")),9,Ns)],64))])}const He=B(vs,[["render",Ms],["__scopeId","data-v-9b630564"]]),Ts={name:"WmMoreMenu",inject:{t:{default:()=>A()}},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)}}},xs={class:"wm-mm"},Ls={class:"wm-mm__pop",role:"menu"},Os={key:0,class:"wm-mm__section"},Ds={class:"wm-mm__label"},Is={class:"wm-mm__label"},Rs={key:1,class:"wm-mm__sep"},Fs={class:"wm-mm__section"},js={class:"wm-mm__label"},Ps={class:"wm-mm__label"},Us={class:"wm-mm__section"},zs={class:"wm-mm__label"},$s={class:"wm-mm__label"};function Hs(t,n,r,s,i,o){return e.openBlock(),e.createElementBlock("div",xs,[e.createElementVNode("div",{class:"wm-mm__scrim",onClick:n[0]||(n[0]=a=>t.$emit("close"))}),e.createElementVNode("div",Ls,[r.canRename||r.canExport?(e.openBlock(),e.createElementBlock("div",Os,[r.canRename?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-mm__item",onClick:n[1]||(n[1]=a=>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",Ds,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]=a=>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",Is,e.toDisplayString(o.t("moreMenu.exportTranscript")),1),n[9]||(n[9]=e.createElementVNode("span",{class:"wm-mm__hint"},".txt",-1))])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),r.canRename||r.canExport?(e.openBlock(),e.createElementBlock("div",Rs)):e.createCommentVNode("",!0),e.createElementVNode("div",Fs,[e.createElementVNode("button",{type:"button",class:"wm-mm__item",onClick:n[3]||(n[3]=(...a)=>o.toggleSound&&o.toggleSound(...a))},[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",js,e.toDisplayString(o.t("moreMenu.sound")),1),e.createElementVNode("span",{class:e.normalizeClass(["wm-mm__toggle",{"wm-mm__toggle--on":i.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]=(...a)=>o.toggleBrowserNotif&&o.toggleBrowserNotif(...a))},[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",Ps,e.toDisplayString(o.t("moreMenu.browserNotifications")),1),e.createElementVNode("span",{class:e.normalizeClass(["wm-mm__toggle",{"wm-mm__toggle--on":i.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",Us,[r.statusUrl?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-mm__item",onClick:n[5]||(n[5]=a=>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",zs,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]=a=>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",$s,e.toDisplayString(o.t("moreMenu.helpCenter")),1)])):e.createCommentVNode("",!0)])])])}const qe=B(Ts,[["render",Hs],["__scopeId","data-v-76281e95"]]),qs={name:"WmRenameDialog",inject:{t:{default:()=>A()}},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())}}},Ks={class:"wm-dialog"},Ws={class:"wm-dialog__card",role:"dialog","aria-modal":"true"},Gs={class:"wm-dialog__head"},Ys={class:"wm-dialog__title"},Qs=["aria-label"],Xs={class:"wm-dialog__body"},Js=["placeholder"],Zs={class:"wm-dialog__actions"},ea=["disabled"];function ta(t,n,r,s,i,o){return e.openBlock(),e.createElementBlock("div",Ks,[e.createElementVNode("div",{class:"wm-dialog__scrim",onClick:n[0]||(n[0]=a=>t.$emit("close"))}),e.createElementVNode("div",Ws,[e.createElementVNode("div",Gs,[e.createElementVNode("div",Ys,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]=a=>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,Qs)]),e.createElementVNode("div",Xs,[e.withDirectives(e.createElementVNode("input",{ref:"input","onUpdate:modelValue":n[2]||(n[2]=a=>i.value=a),type:"text",class:"wm-dialog__input",placeholder:r.placeholder||o.t("rename.placeholder"),maxlength:120,onKeydown:[n[3]||(n[3]=e.withKeys(e.withModifiers((...a)=>o.onSubmit&&o.onSubmit(...a),["prevent"]),["enter"])),n[4]||(n[4]=e.withKeys(e.withModifiers(a=>t.$emit("close"),["prevent"]),["esc"]))]},null,40,Js),[[e.vModelText,i.value]])]),e.createElementVNode("div",Zs,[e.createElementVNode("button",{type:"button",class:"wm-dialog__btn",onClick:n[5]||(n[5]=a=>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]=(...a)=>o.onSubmit&&o.onSubmit(...a))},e.toDisplayString(o.t("common.save")),9,ea)])])])}const na=B(qs,[["render",ta],["__scopeId","data-v-6d5f94a8"]]),pe="ww-messenger-tokens",ra={name:"Messenger",components:{Launcher:we,Header:Ce,Onboarding:Be,MessageList:De,Composer:Pe,SuggestionChips:Ue,ApprovalCard:ze,FormCard:$e,Feedback:He,MoreMenu:qe,RenameDialog:na},mixins:[at,mt,ht,pt],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:""},userId:{type:String,default:""},userHash:{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,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}},computed:{isEditor(){return!!this.devtools},isEmbedded(){return this.displayMode==="embedded"},customerLanguage(){var r,s,i,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=(i=this.context)==null?void 0:i.customer)==null?void 0:o.language)||""},locale(){var t;return Z(this.language||this.customerLanguage||((t=this.widget)==null?void 0:t.default_language)||"")},translator(){return A(this.locale)},error(){var t;return this.bootError||((t=this.s)==null?void 0:t.error)||null},canBoot(){return!!(this.baseUrl&&this.widgetId&&this.userId&&this.userHash)},s(){var t;return((t=this.store)==null?void 0:t.state)||null},ready(){var t;return!!((t=this.s)!=null&&t.ready)},allConversations(){var n;const t=(n=this.s)==null?void 0:n.conversations;return Array.isArray(t)?t:[]},drawerConversations(){var r;const t=((r=this.s)==null?void 0:r.messagesByConv)||{},n=this.revealedAt;return this.allConversations.map(s=>{var y;const i=t[s.id]||[],o=j(s.last_read_message_id);let a=0,l=null;for(let v=i.length-1;v>=0;v--){const E=i[v];if(!E)continue;if(((y=E.author)==null?void 0:y.type)==="user")break;const N=j(E.id);if(N!=null){if(o!=null&&N<=o)break;n[E.id]!==0&&(!l&&E.author&&(l=E.author),a++)}}const p=i.filter(v=>!((v==null?void 0:v.id)!=null&&n[v.id]===0));return{...s,_preview:nt(s,p),_unread:a>0,_unreadCount:a,_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,_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 i=ue(s,t[s.id]||[]),o=s._lastAuthor,a=!o||o.type==="agent_ia",l=(o==null?void 0:o.name)||(a?this.agentName:"")||"",p=(o==null?void 0:o.avatar_url)||(a?this.agentAvatarUrl:null);n.push({convId:s.id,preview:s._preview||this.t("notification.youHaveNewMessage"),ts:i,count:s._unreadCount||1,senderName:l,senderAvatarUrl:p})}return n.sort((s,i)=>s.ts<i.ts?1:s.ts>i.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},widgetWelcomeMessage(){var t;return((t=this.widget)==null?void 0:t.welcome_message)||""},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 i=t.length-1;i>=0;i--)if(((s=(r=t[i])==null?void 0:r.author)==null?void 0:s.type)==="agent_human")return t[i].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(){const t=this.currentConv;if(!t)return[];const n=this.revealedAt;return(this.s.messagesByConv[t.id]||[]).filter(r=>{var s,i,o,a,l;return(r==null?void 0:r.type)==="action"&&((s=r==null?void 0:r.payload)==null?void 0:s.state)==="pending"||W(r)&&!(n[r.id]>0)?!1:(r==null?void 0:r.type)==="action"||(r==null?void 0:r.type)==="system"||((i=r==null?void 0:r.payload)==null?void 0:i.type)==="system"||Array.isArray((o=r==null?void 0:r.payload)==null?void 0:o.attachments)&&r.payload.attachments.length||(a=r==null?void 0:r.metadata)!=null&&a.artifact||(l=r==null?void 0:r.metadata)!=null&&l.form?!0:typeof(r==null?void 0:r.text_md)=="string"&&r.text_md.trim().length>0})},streamingActive(){var r,s,i;const t=this.currentConv;return t?Object.keys(((r=this.s)==null?void 0:r.streamingByMsgId)||{}).length>0?!0:this.actionInFlight?!1:(((i=(s=this.s)==null?void 0:s.messagesByConv)==null?void 0:i[t.id])||[]).some(o=>W(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,i,o,a,l,p;const t=(o=(i=(s=this.pendingApproval)==null?void 0:s.payload)==null?void 0:i.pending)==null?void 0:o.user_explanation;if(typeof t=="string"&&t.trim())return t.trim();const n=(p=(l=(a=this.pendingApproval)==null?void 0:a.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(([y,v])=>`${y}: ${v}`).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,i;const t=this.currentConv;let n=new Date;if(t){const a=((i=(((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:i.created_at)||t.created_at;if(a){const l=new Date(a);Number.isNaN(l.getTime())||(n=l)}}return this.t("messageList.today",{time:ae(n,$(this.locale))})},paginationState(){var r,s,i;const t=(r=this.currentConv)==null?void 0:r.id,n=t?(i=(s=this.s)==null?void 0:s.paginationByConv)==null?void 0:i[t]:null;return{loading:!!(n!=null&&n.loading),hasMore:!!(n!=null&&n.nextCursor)}}},watch:{latestUnreads:{handler(t){const n=new Set(t.map(a=>a.convId)),r=this.dismissedPeeks||{},s=Object.keys(r);if(!s.length)return;const i={};let o=!1;for(const a of s)n.has(a)?i[a]=r[a]:o=!0;o&&(this.dismissedPeeks=i)},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=j((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=j((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)}await this.boot(),this.isEmbedded&&this.store&&await this.open()},beforeUnmount(){this.cancelReveals(),this.teardownLiveReveal(),this.disconnectFloatRO(),this.resetApprovalPacing(),this.teardownNotifications(),this.store&&this.store.destroy()},methods:{t(t,n){return this.translator(t,n)},async boot(){var t;if(!this.canBoot){console.warn("[messenger] boot skipped — missing creds");return}try{this.transport=e.markRaw(_e({baseUrl:this.baseUrl,widgetId:this.widgetId,userId:this.userId,userHash:this.userHash})),this.store=e.markRaw(ge(this.transport)),this.hydrateNotifPref(),await this.store.start(),this.setupLiveReveal();const n=(t=this.context)==null?void 0:t.customer;n&&typeof n=="object"&&await this.store.applyCustomer(n)}catch(n){console.error("[ww-messenger] bootstrap failed",n),this.bootError=(n==null?void 0:n.message)||String(n)}},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 i=Math.ceil(s.contentRect.height+8);i!==this.floatHeight&&(this.floatHeight=i,this.$nextTick(()=>{var o,a;(a=(o=this.$refs.messageList)==null?void 0:o.scrollToBottom)==null||a.call(o)}))}),this.floatRO.observe(n)}},disconnectFloatRO(){if(this.floatRO){try{this.floatRO.disconnect()}catch{}this.floatRO=null}},async open(){this.isOpen=!0,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)}},close(){this.isOpen=!1,this.store&&this.store.setPanelOpen(!1)},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":st(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=et(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:tt(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)}},async onQuickLink(t){if(t){if(t.url){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}}}}},oa={key:0,class:"wm-loading","aria-busy":"true","aria-live":"polite"},sa=["aria-label"],aa={key:0,class:"wm-state"},ia={class:"wm-state__err"},la={class:"wm-state__errTitle"},ca={class:"wm-state__errSub"},da={class:"wm-bottom"},ua={key:0,ref:"floatEl",class:"wm-float"},ma={key:1,class:"wm-actionWait",role:"status","aria-live":"polite"},ha={class:"wm-actionWait__lbl"},fa={key:2,class:"wm-attached"},pa=["aria-label","onClick"];function _a(t,n,r,s,i,o){const a=e.resolveComponent("Launcher"),l=e.resolveComponent("Header"),p=e.resolveComponent("Onboarding"),y=e.resolveComponent("MessageList"),v=e.resolveComponent("ApprovalCard"),E=e.resolveComponent("FormCard"),N=e.resolveComponent("Feedback"),k=e.resolveComponent("SuggestionChips"),L=e.resolveComponent("Composer"),w=e.resolveComponent("MoreMenu"),T=e.resolveComponent("RenameDialog");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-root",`wm-root--${r.displayMode}`])},[!i.isOpen&&!o.isEmbedded?(e.openBlock(),e.createBlock(a,{key:0,"unread-count":o.unreadCount,peeks:o.launcherPeeks,onOpen:o.openFromPeek,onDismiss:o.dismissPeek},null,8,["unread-count","peeks","onOpen","onDismiss"])):e.createCommentVNode("",!0),i.isOpen||o.isEmbedded?(e.openBlock(),e.createElementBlock("section",{key:1,class:e.normalizeClass(["wm-panel",`wm-panel--${r.displayMode}`]),style:e.normalizeStyle(i.floatHeight?{"--wm-float-h":i.floatHeight+"px"}:null),role:"dialog","aria-label":"Messenger"},[!o.ready&&!o.error?(e.openBlock(),e.createElementBlock("div",oa,[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]=(...S)=>o.close&&o.close(...S))},[...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,sa)),n[6]||(n[6]=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":i.moreOpen,onBack:o.goHome,onMore:o.toggleMore,onClose:o.close},null,8,["title","team-members","response-label","show-identity","show-back","show-close","more-active","onBack","onMore","onClose"]),o.error?(e.openBlock(),e.createElementBlock("div",aa,[e.createElementVNode("div",ia,[n[7]||(n[7]=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",la,e.toDisplayString(o.t("error.connectionFailed")),1),e.createElementVNode("div",ca,e.toDisplayString(o.error),1)])])])):o.currentConv?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createVNode(y,{ref:"messageList",messages:o.displayedMessages,"streaming-active":o.streamingActive,"date-label":o.dateLabel,"conversation-id":o.currentConv?o.currentConv.id:null,"loading-more":o.paginationState.loading,"has-more":o.paginationState.hasMore,"unread-anchor-id":t.unreadAnchorId,"unread-boundary-ts":t.unreadBoundaryTs,onLoadMore:o.onLoadMore},null,8,["messages","streaming-active","date-label","conversation-id","loading-more","has-more","unread-anchor-id","unread-boundary-ts","onLoadMore"]),e.createElementVNode("div",da,[o.floatVisible?(e.openBlock(),e.createElementBlock("div",ua,[o.approvalReady?(e.openBlock(),e.createBlock(v,{key:0,action:o.approvalTitle,detail:o.approvalDetail,callbacks:o.pendingApproval.callbacks,onCallback:o.onApprovalCallback},null,8,["action","detail","callbacks","onCallback"])):o.pendingForm?(e.openBlock(),e.createBlock(E,{key:o.pendingForm.message&&o.pendingForm.message.id,form:o.pendingForm.form,onSubmit:o.onFormSubmit},null,8,["form","onSubmit"])):o.showFeedback?(e.openBlock(),e.createBlock(N,{key:2,busy:i.feedbackBusy,done:i.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",ma,[n[8]||(n[8]=e.createElementVNode("span",{class:"wm-actionWait__spinner","aria-hidden":"true"},null,-1)),e.createElementVNode("span",ha,e.toDisplayString(o.t("action.inProgress",{name:o.actionInFlightName})),1)])):(e.openBlock(),e.createBlock(L,{key:2,ref:"composer",modelValue:i.draft,"onUpdate:modelValue":n[1]||(n[1]=S=>i.draft=S),placeholder:o.composerPlaceholder,disabled:!!o.pendingApproval,"attach-label":o.t("composer.attachFile"),onSend:o.onSend,onAttach:o.onAttach},null,8,["modelValue","placeholder","disabled","attach-label","onSend","onAttach"]))]),i.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]=S=>i.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),i.renameDialogOpen&&o.currentConv&&!o.currentConv._draft?(e.openBlock(),e.createBlock(T,{key:1,"initial-value":o.currentConv.name||"",title:o.t("rename.dialogTitle"),onClose:n[3]||(n[3]=S=>i.renameDialogOpen=!1),onSubmit:o.onRenameSubmit},null,8,["initial-value","title","onSubmit"])):e.createCommentVNode("",!0),i.pendingAttachments.length?(e.openBlock(),e.createElementBlock("div",fa,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.pendingAttachments,(S,x)=>(e.openBlock(),e.createElementBlock("div",{key:x,class:"wm-attached__chip"},[n[10]||(n[10]=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(S.name),1),e.createElementVNode("button",{type:"button","aria-label":o.t("attachment.remove"),onClick:D=>i.pendingAttachments.splice(x,1)},[...n[9]||(n[9]=[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,pa)]))),128))])):e.createCommentVNode("",!0)],64)):(e.openBlock(),e.createBlock(p,{key:1,"welcome-message":o.widgetWelcomeMessage,"agent-name":o.agentName,"quick-links":o.quickLinks,"open-threads":o.openThreads,busy:i.busy,onStart:o.startConv,onSelect:o.onQuickLink,onResume:o.onDrawerPick},null,8,["welcome-message","agent-name","quick-links","open-threads","busy","onStart","onSelect","onResume"])),i.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]=S=>i.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 Ke=B(ra,[["render",_a],["__scopeId","data-v-38e86a3b"]]),ga="0.4.0";exports.AIAvatar=H;exports.AVATAR_COLORS=J;exports.ActionResult=Ne;exports.ApprovalCard=ze;exports.ArtifactFormResponse=Se;exports.ArtifactInfoCard=Ae;exports.ArtifactRenderer=Me;exports.ArtifactTicket=Ve;exports.AttachmentPreview=Te;exports.Bubble=Le;exports.Composer=Pe;exports.DEFAULT_BASE_URL=ye;exports.DEFAULT_LANGUAGE=z;exports.Feedback=He;exports.FormCard=$e;exports.Header=Ce;exports.HumanAvatar=ie;exports.Launcher=we;exports.MEDIA_RECORDER_SUPPORTED=ee;exports.MessageList=De;exports.Messenger=Ke;exports.MoreMenu=qe;exports.Onboarding=Be;exports.SCREEN_CAPTURE_SUPPORTED=G;exports.SUPPORTED_LANGUAGES=ke;exports.SuggestionChips=Ue;exports.TeamAvatars=Ee;exports.Typing=Oe;exports.VERSION=ga;exports.avatarColor=oe;exports.avatarInitials=se;exports.captureScreenshotFile=Fe;exports.colors=M;exports.createStore=ge;exports.createTranslator=A;exports.createTransport=_e;exports.dateLocale=$;exports.default=Ke;exports.formatTime=ae;exports.guessAttachmentKind=go;exports.pickRecorderMime=Ie;exports.renderMarkdown=xe;exports.resolveLanguage=Z;exports.startScreenRecording=je;exports.tokensCss=ve;exports.uuid=re;exports.v4=re;
52
+ `)}function rt(t,n,r=A()){const a=[],s=Array.isArray(t==null?void 0:t.fields)?t.fields:[];for(const o of s){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=be(o,i,r);if(!l)continue;const p=o.type==="textarea"||typeof l=="string"&&(l.length>60||l.includes(`
53
+ `));a.push({label:o.label,value:l,multiline:p})}return{kind:"form_response",data:{title:(t==null?void 0:t.title)||r("form.title"),fields:a}}}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 j(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 a of n)a!=null&&a.created_at&&a.created_at>r&&(r=a.created_at);return r}function ot(t,n){var r,a,s;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=(a=i.payload)==null?void 0:a.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)||((s=t==null?void 0:t.metadata)==null?void 0:s.last_preview)||""}function st(t,n){return(t==null?void 0:t.name)||((t==null?void 0:t.type)==="user"?n("common.you"):(t==null?void 0:t.type)==="agent_human"?n("common.agent"):(t==null?void 0:t.type)==="agent_ia"?n("common.aiAssistant"):n("common.system"))}function at(t,n,r,a){const s=[`# ${t.name||r("common.conversation")}`,t.created_at?r("export.createdOn",{date:new Date(t.created_at).toLocaleString(a)}):"",""];for(const o of n){if(!o)continue;const i=(o.text_md||"").trim();if(!i)continue;const l=st(o.author,r),p=o.created_at?new Date(o.created_at).toLocaleString(a):"";s.push(`[${p}] ${l} :`),s.push(i),s.push("")}return s.join(`
54
+ `)}function it(t,n,r=A(),a){if(!t)return;const s=at(t,n||[],r,$(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||""}:${this.userId||""}`},browserNotifStorageKey(){return`wm:notif:browser:${this.widgetId||""}:${this.userId||""}`},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,y=setTimeout(()=>{this.revealedAt={...this.revealedAt,[p]:Date.now()},this.revealTimers=this.revealTimers.filter(v=>v!==y),typeof this.onMessageRevealed=="function"&&this.onMessageRevealed(t,n)},l);this.revealTimers.push(y)},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)}}},_t=300,gt={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=j(t.last_read_message_id),s=j(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)},_t))))}}};function vt(t){for(let n=t.length-1;n>=0;n--){const r=t[n];if(!(!r||r._pending)&&j(r.id)!=null)return r.id}return null}const B=(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":oe(this.name)},initials(){return se(this.name)}}},kt=["src","alt"];function bt(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 ie=B(yt,[["render",bt],["__scopeId","data-v-14e10c0d"]]),wt=3,Et={name:"WmLauncher",components:{HumanAvatar:ie},inject:{t:{default:()=>A()}},props:{unreadCount:{type:Number,default:0},peeks:{type:Array,default:()=>[]}},emits:["open","dismiss"],computed:{visiblePeeks(){return this.peeks.slice(0,wt).reverse()}}},Ct={class:"wm-launcherWrap"},Bt=["aria-label","onClick","onKeydown"],Nt=["aria-label","onClick"],St={class:"wm-peek__avatar"},At=["aria-label"],Vt={class:"wm-peek__body"},Mt={class:"wm-peek__head"},Tt={class:"wm-peek__name"},xt={class:"wm-peek__action"},Lt={class:"wm-peek__text"},Ot=["onClick"],Dt=["aria-label"],It=["aria-label"];function Rt(t,n,r,a,s,o){const i=e.resolveComponent("HumanAvatar");return e.openBlock(),e.createElementBlock("div",Ct,[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:y=>t.$emit("open",l.convId),onKeydown:[e.withKeys(e.withModifiers(y=>t.$emit("open",l.convId),["prevent"]),["enter"]),e.withKeys(e.withModifiers(y=>t.$emit("open",l.convId),["prevent"]),["space"])]},[e.createElementVNode("button",{type:"button",class:"wm-peek__close","aria-label":o.t("launcher.dismiss"),onClick:e.withModifiers(y=>t.$emit("dismiss",l.convId),["stop"])},[...n[1]||(n[1]=[e.createElementVNode("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,Nt),e.createElementVNode("div",St,[e.createVNode(i,{name:l.senderName,"avatar-url":l.senderAvatarUrl,size:34},null,8,["name","avatar-url"]),l.count>1?(e.openBlock(),e.createElementBlock("span",{key:0,class:"wm-peek__avatarBadge","aria-label":o.t("launcher.unreadMessages",{count:l.count})},e.toDisplayString(l.count>9?"9+":l.count),9,At)):e.createCommentVNode("",!0)]),e.createElementVNode("div",Vt,[e.createElementVNode("div",Mt,[e.createElementVNode("span",Tt,e.toDisplayString(l.senderName||o.t("common.agent")),1),e.createElementVNode("span",xt,e.toDisplayString(o.t("launcher.repliedToYou")),1)]),e.createElementVNode("p",Lt,e.toDisplayString(l.preview),1)]),e.createElementVNode("button",{type:"button",class:"wm-peek__open",onClick:e.withModifiers(y=>t.$emit("open",l.convId),["stop"])},e.toDisplayString(o.t("common.open")),9,Ot)],44,Bt))),128))],2)):e.createCommentVNode("",!0)]),_:1}),e.createElementVNode("button",{type:"button",class:"wm-launcher","aria-label":o.t("launcher.open"),onClick:n[0]||(n[0]=l=>t.$emit("open"))},[n[2]||(n[2]=e.createElementVNode("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.7","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})],-1)),r.unreadCount>0?(e.openBlock(),e.createElementBlock("span",{key:0,class:"wm-launcher__badge","aria-label":r.unreadCount>1?o.t("launcher.unreadConversationsMany",{count:r.unreadCount}):o.t("launcher.unreadConversationsOne",{count:r.unreadCount})},e.toDisplayString(r.unreadCount>9?"9+":r.unreadCount),9,It)):e.createCommentVNode("",!0)],8,Dt)])}const we=B(Et,[["render",Rt],["__scopeId","data-v-5193a529"]]),Ft={name:"WmAIAvatar",props:{size:{type:Number,default:26},pulse:{type:Boolean,default:!1},tail:{type:Boolean,default:!1}}},jt={key:0,class:"wm-aiav__pulse"},Pt=["width","height"];function Ut(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",jt)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["wm-aiav__inner",{"wm-aiav__inner--glow":r.pulse}])},[(e.openBlock(),e.createElementBlock("svg",{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,Pt))],2)],6)}const H=B(Ft,[["render",Ut],["__scopeId","data-v-d621a129"]]),zt={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":oe(t.name||"")},initialsFor(t){return se(t.name||"")}}},$t={key:0,class:"wm-team"},Ht=["src","alt"],qt={key:1},Kt={key:0,class:"wm-team__label"};function Wt(t,n,r,a,s,o){return o.visible?(e.openBlock(),e.createElementBlock("div",$t,[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,Ht)):(e.openBlock(),e.createElementBlock("span",qt,e.toDisplayString(o.initialsFor(i)),1))],4))),128))],4),r.responseLabel?(e.openBlock(),e.createElementBlock("span",Kt,e.toDisplayString(r.responseLabel),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}const Ee=B(zt,[["render",Wt],["__scopeId","data-v-e49a9063"]]),Gt={name:"WmHeader",components:{AIAvatar:H,TeamAvatars:Ee},inject:{t:{default:()=>A()}},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}},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"},Qt=["aria-label"],Xt={key:1,style:{width:"30px",height:"30px","flex-shrink":"0"}},Jt={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,Qt)):(e.openBlock(),e.createElementBlock("div",Xt)),r.showIdentity?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createElementVNode("div",Jt,[e.createVNode(i,{size:30})]),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=B(Gt,[["render",sn],["__scopeId","data-v-e5ed4931"]]);function Be(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}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 a=0;for(;a<n.length;){const o=n[a];if(/^\s*```([\w-]*)\s*$/.exec(o)){a++;const y=[];for(;a<n.length&&!/^\s*```\s*$/.test(n[a]);)y.push(n[a]),a++;a<n.length&&a++,r.push({type:"block",html:`<pre class="wm-md-pre"><code>${y.join(`
56
+ `)}</code></pre>`});continue}if(/^\s*[-*]\s+/.test(o)){const y=[];for(;a<n.length;){const E=/^\s*[-*]\s+(.*)$/.exec(n[a]);if(!E)break;y.push(E[1]),a++}const v=y.map(E=>`<li>${W(E)}</li>`).join("");r.push({type:"block",html:`<ul class="wm-md-ul">${v}</ul>`});continue}const l=/^\s*(\d+)\.\s+(.*)$/.exec(o);if(l){const y=parseInt(l[1],10),v=[l[2]];for(a++;a<n.length;){const k=/^\s*\d+\.\s+(.*)$/.exec(n[a]);if(!k)break;v.push(k[1]),a++}const E=v.map(k=>`<li>${W(k)}</li>`).join(""),N=y!==1?` start="${y}"`:"";r.push({type:"block",html:`<ol class="wm-md-ol"${N}>${E}</ol>`});continue}const p=/^(#{1,6})\s+(.*)$/.exec(o);if(p){const y=p[1].length;r.push({type:"block",html:`<h${y} class="wm-md-h wm-md-h${y}">${W(p[2])}</h${y}>`}),a++;continue}r.push({type:"text",html:W(o)}),a++}let s="";for(let o=0;o<r.length;o++){const i=r[o];s+=i.html;const l=r[o+1];l&&i.type!=="block"&&l.type!=="block"&&(s+=`
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:H},inject:{t:{default:()=>A()},wmLocale:{default:()=>()=>"fr"}},props:{welcomeMessage:{type:String,default:""},agentName:{type:String,default:""},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.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}},methods:{iconPath(t){return he[t]||he.link},renderPreview(t){return Ne(t)},formatTs(t){if(!t)return"";const n=new Date(t);if(Number.isNaN(n.getTime()))return"";const r=$(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__title"},mn={class:"wm-onb__sub"},hn={class:"wm-onb__cta"},fn=["disabled"],pn={key:0,class:"wm-onb__section"},_n={class:"wm-onb__section-title"},gn=["onClick"],vn={class:"wm-onb__card-icon"},yn={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"},kn=["d"],bn={class:"wm-onb__card-body"},wn={class:"wm-onb__card-title"},En={key:0,class:"wm-onb__card-sub"},Cn={key:1,class:"wm-onb__section"},Bn={class:"wm-onb__section-title"},Nn={class:"wm-onb__search"},Sn=["placeholder","aria-label"],An={class:"wm-onb__list"},Vn=["onClick"],Mn=["aria-label"],Tn={class:"wm-onb__thread-body"},xn={class:"wm-onb__thread-title"},Ln=["innerHTML"],On={class:"wm-onb__thread-meta"},Dn={key:0,class:"wm-onb__thread-time"},In={key:0,class:"wm-onb__empty"};function Rn(t,n,r,a,s,o){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",cn,[e.createElementVNode("div",dn,[e.createVNode(i,{size:56,pulse:!0}),e.createElementVNode("div",un,e.toDisplayString(o.heroTitle),1),e.createElementVNode("div",mn,e.toDisplayString(o.heroSub),1)]),e.createElementVNode("div",hn,[e.createElementVNode("button",{type:"button",class:"wm-onb__startBtn",disabled:r.busy,onClick:n[0]||(n[0]=l=>t.$emit("start"))},[n[2]||(n[2]=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,fn)]),r.quickLinks.length?(e.openBlock(),e.createElementBlock("div",pn,[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:y=>t.$emit("select",l)},[e.createElementVNode("span",vn,[(e.openBlock(),e.createElementBlock("svg",yn,[e.createElementVNode("path",{d:o.iconPath(l.icon)},null,8,kn)]))]),e.createElementVNode("span",bn,[e.createElementVNode("span",wn,e.toDisplayString(l.label),1),l.description?(e.openBlock(),e.createElementBlock("span",En,e.toDisplayString(l.description),1)):e.createCommentVNode("",!0)])],10,gn))),128))],2)])):e.createCommentVNode("",!0),r.openThreads.length?(e.openBlock(),e.createElementBlock("div",Cn,[e.createElementVNode("div",Bn,e.toDisplayString(o.t("onboarding.recentConversations")),1),e.createElementVNode("div",Nn,[n[3]||(n[3]=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,Sn),[[e.vModelText,s.query]])]),e.createElementVNode("div",An,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.filteredThreads,l=>(e.openBlock(),e.createElementBlock("button",{key:l.id,type:"button",class:"wm-onb__thread",onClick:p=>t.$emit("resume",l)},[e.createElementVNode("span",{class:e.normalizeClass(["wm-onb__thread-icon",{"wm-onb__thread-icon--inverted":!l.unread}])},[n[4]||(n[4]=e.createElementVNode("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[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:"currentColor",opacity:"0.92"})],-1)),l.unread?(e.openBlock(),e.createElementBlock("span",{key:0,class:"wm-onb__thread-dot","aria-label":o.t("onboarding.unread")},null,8,Mn)):e.createCommentVNode("",!0)],2),e.createElementVNode("span",Tn,[e.createElementVNode("span",xn,e.toDisplayString(l.title),1),e.createElementVNode("span",{class:"wm-onb__thread-preview",innerHTML:o.renderPreview(l.preview)},null,8,Ln)]),e.createElementVNode("span",On,[o.formatTs(l._ts)?(e.openBlock(),e.createElementBlock("span",Dn,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))])],8,Vn))),128)),o.filteredThreads.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",In,e.toDisplayString(o.t("onboarding.noResults",{query:s.query})),1))])])):e.createCommentVNode("",!0)])}const Ae=B(ln,[["render",Rn],["__scopeId","data-v-d0d5f5b1"]]);function Fn(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 jn={name:"WmActionResult",props:{state:{type:String,default:"success"},label:{type:String,required:!0},detail:{type:String,default:""}},computed:{detailText(){return Fn(this.detail)}}},Pn={class:"wm-result__icon","aria-hidden":"true"},Un={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"},zn={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"},$n={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"},Hn={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"},qn={class:"wm-result__body"},Kn={class:"wm-result__label"},Wn={class:"wm-result__detail"};function Gn(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-result",`wm-result--${r.state}`])},[e.createElementVNode("span",Pn,[r.state==="success"?(e.openBlock(),e.createElementBlock("svg",Un,[...n[0]||(n[0]=[e.createElementVNode("path",{d:"M20 6L9 17l-5-5"},null,-1)])])):r.state==="rejected"?(e.openBlock(),e.createElementBlock("svg",zn,[...n[1]||(n[1]=[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"},null,-1)])])):r.state==="awaiting"?(e.openBlock(),e.createElementBlock("svg",$n,[...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",Hn,[...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",qn,[e.createElementVNode("span",Kn,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",Wn,e.toDisplayString(o.detailText),1)],64)):e.createCommentVNode("",!0)])],2)}const Ve=B(jn,[["render",Gn],["__scopeId","data-v-7284acd0"]]),Yn={name:"WmArtifactFormResponse",inject:{t:{default:()=>A()}},props:{data:{type:Object,required:!0}},computed:{fields(){var t;return Array.isArray((t=this.data)==null?void 0:t.fields)?this.data.fields:[]}}},Qn={class:"wm-art wm-art--formResponse"},Xn={class:"wm-art__head"},Jn={class:"wm-art__title"},Zn={class:"wm-art__badge wm-art__badge--success"},er={class:"wm-art__body"},tr={class:"wm-art__fieldLabel"};function nr(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",Qn,[e.createElementVNode("div",Xn,[e.createElementVNode("div",Jn,e.toDisplayString(r.data.title||o.t("form.title")),1),e.createElementVNode("span",Zn,[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",er,[(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",tr,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=B(Yn,[["render",nr],["__scopeId","data-v-713aecf1"]]),rr={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}}},or={class:"wm-art wm-art--infoCard"},sr={key:0,class:"wm-art__image"},ar=["src","alt"],ir={class:"wm-art__head"},lr={class:"wm-art__headMain"},cr={class:"wm-art__title"},dr={key:0,class:"wm-art__subtitle"},ur={key:1,class:"wm-art__body"},mr={key:0,class:"wm-art__text"},hr={class:"wm-art__fieldLabel"};function fr(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",or,[r.data.image_url?(e.openBlock(),e.createElementBlock("figure",sr,[e.createElementVNode("img",{src:r.data.image_url,alt:r.data.title||"",loading:"lazy"},null,8,ar)])):e.createCommentVNode("",!0),e.createElementVNode("div",ir,[e.createElementVNode("div",lr,[e.createElementVNode("div",cr,e.toDisplayString(r.data.title),1),r.data.subtitle?(e.openBlock(),e.createElementBlock("div",dr,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",ur,[r.data.body?(e.openBlock(),e.createElementBlock("div",mr,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",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)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])}const Te=B(rr,[["render",fr],["__scopeId","data-v-7eae0e4a"]]);function pr(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 _r={name:"WmArtifactTicket",inject:{t:{default:()=>A()},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 pr((t=this.data)==null?void 0:t.created_at,$(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}}},gr={class:"wm-art wm-art--ticket"},vr={class:"wm-art__head wm-tk__head"},yr={class:"wm-art__title wm-tk__title"},kr={class:"wm-tk__sub"},br={class:"wm-tk__ref"},wr={key:0,class:"wm-tk__text"},Er={key:0,class:"wm-art__body"},Cr={class:"wm-art__fieldLabel"},Br=["data-level"],Nr={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"},Sr={key:1,class:"wm-art__footer wm-tk__footer"};function Ar(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",gr,[e.createElementVNode("div",vr,[e.createElementVNode("div",yr,e.toDisplayString(r.data.title),1),e.createElementVNode("div",kr,[e.createElementVNode("div",br,[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",wr,e.toDisplayString(r.data.body),1)):e.createCommentVNode("",!0)]),o.fields.length?(e.openBlock(),e.createElementBlock("div",Er,[(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",Cr,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,Br)):o.isDate(i.label)?(e.openBlock(),e.createElementBlock("svg",Nr,[...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",Sr,[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=B(_r,[["render",Ar],["__scopeId","data-v-5f30c914"]]),Vr={form_response:Me,info_card:Te,ticket:xe},Mr={name:"WmArtifactRenderer",props:{artifact:{type:Object,required:!0}},computed:{component(){var n;const t=(n=this.artifact)==null?void 0:n.kind;return t&&Vr[t]||null}}};function Tr(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=B(Mr,[["render",Tr]]),xr={name:"WmAttachmentPreview",inject:{signAttachmentFn:{default:null},t:{default:()=>A()}},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")},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.url||t.preventDefault()}}},Lr=["href"],Or=["src","alt"],Dr=["src"],Ir=["src"],Rr=["href","download"],Fr={class:"wm-att__main"},jr={class:"wm-att__name"},Pr={key:0,class:"wm-att__meta"},Ur={key:0,class:"wm-att__spin","aria-hidden":"true"};function zr(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:s.url,target:"_blank",rel:"noopener",class:"wm-att__imgWrap"},[e.createElementVNode("img",{src:s.url,alt:o.displayName,loading:"lazy"},null,8,Or)],8,Lr)):o.kind==="audio"&&s.url?(e.openBlock(),e.createElementBlock("audio",{key:1,src:s.url,controls:"",preload:"metadata"},null,8,Dr)):o.kind==="video"&&s.url?(e.openBlock(),e.createElementBlock("video",{key:2,src:s.url,controls:"",preload:"metadata"},null,8,Ir)):(e.openBlock(),e.createElementBlock("a",{key:3,class:"wm-att__file",href:s.url||"#",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",Fr,[e.createElementVNode("span",jr,e.toDisplayString(o.displayName),1),o.sizeLabel?(e.openBlock(),e.createElementBlock("span",Pr,e.toDisplayString(o.sizeLabel),1)):e.createCommentVNode("",!0)]),s.loading?(e.openBlock(),e.createElementBlock("span",Ur)):e.createCommentVNode("",!0)],8,Rr))],2)}const Oe=B(xr,[["render",zr],["__scopeId","data-v-afc7b0d3"]]),$r={name:"WmBubble",props:{role:{type:String,default:"ai"},text:{type:String,default:""}},computed:{rendered(){return Se(this.text)}}},Hr=["innerHTML"];function qr(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,Hr)],!0)],2)}const De=B($r,[["render",qr],["__scopeId","data-v-7ab13147"]]),Kr={name:"WmTyping"},Wr={class:"wm-typing"};function Gr(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",Wr,[...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=B(Kr,[["render",Gr],["__scopeId","data-v-df2447fd"]]);function K(t){return t?t.client_msg_id||t.id:""}const Yr={transferred_to_human:"system.transferredToHuman",assigned:"system.assigned",unassigned:"system.unassigned",resolved:"system.resolved",reopened:"system.reopened",idle:"system.idle"},Qr=80,Xr=200,Jr={name:"WmMessageList",components:{AIAvatar:H,HumanAvatar:ie,Bubble:De,Typing:Ie,ActionResult:Ve,AttachmentPreview:Oe,ArtifactRenderer:Le},inject:{t:{default:()=>A()},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:""}},emits:["load-more"],data(){return{silentFades:!1,widthByKey:Object.freeze({})}},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 v=t[t.length-1];v&&v.role==="ai"?v.messages.push(i):t.push({key:`g-${K(i)}`,role:"ai",agentName:"",agentAvatarUrl:null,messages:[i],items:[]});continue}t.push({key:`sys-${K(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-${K(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 y of this.itemsOf(p))l.push(y);i.items=l}const n=[];for(const i of t){if(i.role!=="system"&&!i.items.length)continue;const l=n[n.length-1];if(l&&l.role!=="system"&&l.role===i.role&&(i.role==="ai"||l.agentName===i.agentName)){l.messages.push(...i.messages),l.items.push(...i.items);continue}n.push(i)}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=j(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},loadingMore(t){t||(this._pendingLoadMore=!1),this.silentFades=!0,clearTimeout(this._silenceTimer),t||(this._silenceTimer=setTimeout(()=>{this.silentFades=!1},250)),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),clearTimeout(this._silenceTimer)},updated(){this.scheduleMeasure()},methods:{messageKey:K,isAtBottom(t){return t.scrollHeight-t.scrollTop-t.clientHeight<=Qr},onScroll(){const t=this.$refs.scrollEl;t&&(this.loadingMore||!this.hasMore||this._pendingLoadMore||t.scrollTop<=Xr&&(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.el){const i=t.getBoundingClientRect().top;a={el:o.el,relY:o.el.getBoundingClientRect().top-i}}}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=()=>{var y;const i=s.anchor;if(!((y=i.el)!=null&&y.isConnected))return;const p=i.el.getBoundingClientRect().top-t.getBoundingClientRect().top-i.relY;Math.abs(p)>.5&&(t.scrollTop+=p)};o(),requestAnimationFrame(()=>{o(),requestAnimationFrame(o)})})},pickAnchor(t){const n=t.scrollTop;let r=null;for(const a of t.children)if(a.classList.contains("wm-list__group")&&(r||(r=a),a.offsetTop+a.offsetHeight>=n))return{el:a,offsetTop:a.offsetTop};return r?{el:r,offsetTop:r.offsetTop}:null},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){return t.role==="human"?t.agentName||this.t("common.agent"):this.t("common.aiAssistant")},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 P,U,I;const r=t.items,a=(P=r[n])==null?void 0:P.kind,s=(U=r[n-1])==null?void 0:U.kind,o=(I=r[n+1])==null?void 0:I.kind,i=t.role==="user",l=14,p=4,y=s==null?void 0:s.bottom,v=o==null?void 0:o.top,E=this.widthByKey[this.rowKeyOf(t,n)],N=this.widthByKey[this.rowKeyOf(t,n-1)],k=this.widthByKey[this.rowKeyOf(t,n+1)],L=.5,w=(R,F,O)=>R!=null&&E!=null?R+L>=E:F===O||F==="card"&&O==="bubble";let T=l,S=l,x=l,D=l;return i?(y&&(S=p),(v||!o)&&(x=p),y&&w(N,y,a==null?void 0:a.top)&&(T=p),v&&w(k,v,a==null?void 0:a.bottom)&&(D=p)):(y&&(T=p),(v||!o)&&(D=p),y&&w(N,y,a==null?void 0:a.top)&&(S=p),v&&w(k,v,a==null?void 0:a.bottom)&&(x=p)),{tl:T,tr:S,br:x,bl:D}},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?`${K(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)},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 ae(new Date(r.created_at),$(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=Yr[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)}}},Zr={key:0,class:"wm-list__loadMore",role:"status","aria-live":"polite"},eo={class:"wm-list__loadMore-lbl"},to={key:1,class:"wm-list__historyEnd"},no={key:2,class:"wm-list__sep"},ro={class:"wm-list__sep-label"},oo={key:0,class:"wm-list__sep wm-list__sep--unread"},so={class:"wm-list__sep-label wm-list__sep-label--unread"},ao={key:0,class:"wm-list__sysep"},io={class:"wm-list__sysep-label"},lo=["data-row-key"],co={key:0,class:"wm-list__avatarSlot"},uo={key:5,class:"wm-list__body"},mo={key:0},ho={key:1,"aria-hidden":"true"},fo={key:2},po={key:3,class:"wm-list__row wm-list__row--ai fade-up"},_o={class:"wm-list__avatarSlot"};function go(t,n,r,a,s,o){const i=e.resolveComponent("AIAvatar"),l=e.resolveComponent("HumanAvatar"),p=e.resolveComponent("ActionResult"),y=e.resolveComponent("ArtifactRenderer"),v=e.resolveComponent("Bubble"),E=e.resolveComponent("AttachmentPreview"),N=e.resolveComponent("Typing");return e.openBlock(),e.createElementBlock("div",{ref:"scrollEl",class:e.normalizeClass(["wm-list",{"wm-list--silent":s.silentFades}]),onScrollPassive:n[0]||(n[0]=(...k)=>o.onScroll&&o.onScroll(...k))},[r.loadingMore?(e.openBlock(),e.createElementBlock("div",Zr,[n[1]||(n[1]=e.createElementVNode("span",{class:"wm-list__loadMore-spinner","aria-hidden":"true"},null,-1)),e.createElementVNode("span",eo,e.toDisplayString(o.t("messageList.loadingHistory")),1)])):o.historyExhausted?(e.openBlock(),e.createElementBlock("div",to,e.toDisplayString(o.t("messageList.conversationStart")),1)):e.createCommentVNode("",!0),r.dateLabel?(e.openBlock(),e.createElementBlock("div",no,[n[2]||(n[2]=e.createElementVNode("div",{class:"wm-list__line"},null,-1)),e.createElementVNode("span",ro,e.toDisplayString(r.dateLabel),1),n[3]||(n[3]=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,L)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:k.key},[k.key===o.unreadGroupKey?(e.openBlock(),e.createElementBlock("div",oo,[n[4]||(n[4]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--unread"},null,-1)),e.createElementVNode("span",so,e.toDisplayString(o.t("messageList.unread")),1),n[5]||(n[5]=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",ao,[n[6]||(n[6]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--strong"},null,-1)),e.createElementVNode("span",io,e.toDisplayString(k.systemLabel),1),n[7]||(n[7]=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,T)=>(e.openBlock(),e.createElementBlock("div",{key:`${o.messageKey(w.message)}-${w.partKey}`,"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,T))},[k.role!=="user"?(e.openBlock(),e.createElementBlock("div",co,[T===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})):(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(y,{key:3,artifact:o.actionArtifact(w.message)},null,8,["artifact"])):w.renderAs==="artifact"?(e.openBlock(),e.createBlock(y,{key:4,artifact:o.artifactOf(w.message)},null,8,["artifact"])):(e.openBlock(),e.createElementBlock("div",uo,[w.message.text_md?(e.openBlock(),e.createBlock(v,{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),(S,x)=>(e.openBlock(),e.createBlock(E,{key:`${o.messageKey(w.message)}-att-${x}`,attachment:S},null,8,["attachment"]))),128))],2)):e.createCommentVNode("",!0)]))],14,lo))),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",mo,e.toDisplayString(o.roleLabel(k)),1)):e.createCommentVNode("",!0),k.role!=="user"&&o.lastTimeOf(k)?(e.openBlock(),e.createElementBlock("span",ho,"·")):e.createCommentVNode("",!0),o.lastTimeOf(k)?(e.openBlock(),e.createElementBlock("span",fo,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",po,[e.createElementVNode("div",_o,[e.createVNode(i,{size:26,tail:!0})]),e.createVNode(N)])):e.createCommentVNode("",!0)],34)}const Re=B(Jr,[["render",go],["__scopeId","data-v-ced149e1"]]),Y=typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function",ee=typeof window<"u"&&typeof window.MediaRecorder<"u";function Fe(){return ee&&["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 je({audio:t}){return{video:!0,audio:!!t,selfBrowserSurface:"include",surfaceSwitching:"include",systemAudio:t?"include":"exclude"}}function vo(t){return t?t.startsWith("image/")?"image":t.startsWith("video/")?"video":"file":"file"}async function Pe(){if(!Y)return null;let t;try{t=await navigator.mediaDevices.getDisplayMedia(je({audio:!1}))}catch(n){return(n==null?void 0:n.name)!=="NotAllowedError"&&console.error("[media] screenshot picker",n),null}try{return await yo(t)}catch(n){return console.error("[media] screenshot capture",n),null}finally{t.getTracks().forEach(n=>{n.stop()})}}async function yo(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(y=>y?l(y):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 Ue(t={}){var y;if(!Y||!ee)return null;let n;try{n=await navigator.mediaDevices.getDisplayMedia(je({audio:!0}))}catch(v){return(v==null?void 0:v.name)!=="NotAllowedError"&&console.error("[media] record picker",v),null}const r=Fe();let a;try{a=r?new window.MediaRecorder(n,{mimeType:r}):new window.MediaRecorder(n)}catch(v){return console.error("[media] recorder init",v),n.getTracks().forEach(E=>{E.stop()}),null}const s=[];let o=null,i=!1;a.addEventListener("dataavailable",v=>{v.data&&v.data.size>0&&s.push(v.data)}),a.addEventListener("stop",()=>{var v,E;if(o&&clearInterval(o),n.getTracks().forEach(N=>{N.stop()}),s.length){const N=a.mimeType||r||"video/webm",k=new Blob(s,{type:N}),L=/mp4/.test(N)?"mp4":"webm",w=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),T=new File([k],`ecran-${w}.${L}`,{type:N});(v=t.onfinalize)==null||v.call(t,T)}else(E=t.oncancel)==null||E.call(t)}),n.getVideoTracks().forEach(v=>{v.addEventListener("ended",()=>l(),{once:!0})});function l(){if(!i&&(i=!0,a.state!=="inactive"))try{a.stop()}catch(v){console.error("[media] recorder stop",v)}}try{a.start(1e3)}catch(v){return console.error("[media] recorder start",v),n.getTracks().forEach(E=>{E.stop()}),null}(y=t.onstart)==null||y.call(t);const p=Date.now();return o=setInterval(()=>{var v;(v=t.ontick)==null||v.call(t,Date.now()-p)},500),{stop:l,get state(){return a.state}}}const ko=[{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"}],bo={name:"WmComposer",inject:{t:{default:()=>A()}},props:{modelValue:{type:String,default:""},placeholder:{type:String,default:"Écrivez votre message…"},disabled:{type:Boolean,default:!1},attachLabel:{type:String,default:"Joindre"}},emits:["update:modelValue","send","attach"],data(){return{local:this.modelValue,attachOpen:!1,recording:!1,recordingElapsed:0,recorder:null}},computed:{canSend(){return!this.disabled&&!!this.local.trim()},attachItems(){return ko.map(t=>({...t,label:this.t(t.labelKey),disabled:t.action==="screenshot"&&!Y||t.action==="record"&&(!Y||!ee)}))},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()},beforeUnmount(){if(this.recorder)try{this.recorder.stop()}catch{}},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.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 Pe();t&&this.$emit("attach",t)},async startRecording(){if(this.recording||this.disabled)return;this.recordingElapsed=0;const t=await Ue({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)}}}},wo={class:"wm-compose-wrap"},Eo={key:0,class:"wm-rec"},Co={class:"wm-rec__lbl"},Bo={key:1,class:"wm-compose__menu",role:"menu"},No=["disabled","onClick"],So={class:"wm-compose__menuIcon"},Ao={viewBox:"0 0 24 24",width:"14",height:"14","aria-hidden":"true"},Vo=["d"],Mo=["placeholder","disabled"],To={class:"wm-compose__actions"},xo=["title","aria-label","disabled"],Lo=["disabled","aria-label"];function Oo(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",wo,[s.recording?(e.openBlock(),e.createElementBlock("div",Eo,[n[8]||(n[8]=e.createElementVNode("span",{class:"wm-rec__dot","aria-hidden":"true"},null,-1)),e.createElementVNode("span",Co,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",Bo,[(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",So,[(e.openBlock(),e.createElementBlock("svg",Ao,[e.createElementVNode("path",{d:i.path,stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round",fill:"none"},null,8,Vo)]))]),e.createElementVNode("span",null,e.toDisplayString(i.label),1)],8,No))),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,Mo),[[e.vModelText,s.local]]),e.createElementVNode("div",To,[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,xo),e.createElementVNode("button",{type:"submit",class:e.normalizeClass(["wm-compose__send",{"is-empty":!o.canSend}]),disabled:!o.canSend,"aria-label":o.t("composer.send")},[...n[10]||(n[10]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})],-1)])],10,Lo)])],34)])}const ze=B(bo,[["render",Oo],["__scopeId","data-v-aa81dbb8"]]),Do={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("§")}}},Io=["onClick"];function Ro(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,Io))),128))])):e.createCommentVNode("",!0)}const $e=B(Do,[["render",Ro],["__scopeId","data-v-47ad8085"]]),Fo={name:"WmApprovalCard",components:{AIAvatar:H},inject:{t:{default:()=>A()}},props:{action:{type:String,required:!0},detail:{type:String,default:""},callbacks:{type:Array,default:()=>[]}},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")}}},jo={class:"wm-approval"},Po={class:"wm-approval__head"},Uo={class:"wm-approval__icon"},zo={class:"wm-approval__main"},$o={class:"wm-approval__title"},Ho={key:0,class:"wm-approval__detail"},qo={class:"wm-approval__actions"};function Ko(t,n,r,a,s,o){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",jo,[e.createElementVNode("div",Po,[e.createElementVNode("div",Uo,[e.createVNode(i,{size:24})]),e.createElementVNode("div",zo,[e.createElementVNode("div",$o,e.toDisplayString(r.action),1),r.detail?(e.openBlock(),e.createElementBlock("div",Ho,e.toDisplayString(r.detail),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",qo,[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 He=B(Fo,[["render",Ko],["__scopeId","data-v-53ddf2b2"]]);let fe=0;const Wo=new Set(["text","textarea","number","boolean","select","multiselect","date"]),Go={name:"WmFormCard",components:{AIAvatar:H},inject:{t:{default:()=>A()}},props:{form:{type:Object,required:!0},readOnly:{type:Boolean,default:!1},initialValues:{type:Object,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)||!Wo.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}}}},Yo={class:"wm-form"},Qo={class:"wm-form__head"},Xo={class:"wm-form__icon"},Jo={class:"wm-form__main"},Zo={class:"wm-form__title"},es={key:0,class:"wm-form__detail"},ts=["for"],ns={key:0,class:"wm-form__req","aria-hidden":"true"},rs=["id","onUpdate:modelValue","placeholder","required","disabled"],os=["id","onUpdate:modelValue","placeholder","required","disabled"],ss=["id","onUpdate:modelValue","placeholder","required","disabled"],as=["id","onUpdate:modelValue","required","disabled"],is={key:4,class:"wm-form__bool"},ls=["id","onUpdate:modelValue","disabled"],cs=["id","onUpdate:modelValue","required","disabled"],ds={value:"",disabled:""},us=["value"],ms={key:6,class:"wm-form__multi"},hs=["value","checked","disabled","onChange"],fs={key:0,class:"wm-form__err"},ps=["disabled"],_s={key:0,class:"wm-form__spinner","aria-hidden":"true"},gs={key:2,class:"wm-form__doneLbl"};function vs(t,n,r,a,s,o){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",Yo,[e.createElementVNode("div",Qo,[e.createElementVNode("div",Xo,[e.createVNode(i,{size:24})]),e.createElementVNode("div",Jo,[e.createElementVNode("div",Zo,e.toDisplayString(r.form.title||o.t("form.title")),1),r.form.description?(e.openBlock(),e.createElementBlock("div",es,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",ns,"*")):e.createCommentVNode("",!0)],8,ts),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,rs)),[[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,os)),[[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,ss)),[[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,as)),[[e.vModelText,s.values[l.key]]]):l.type==="boolean"?(e.openBlock(),e.createElementBlock("label",is,[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,ls),[[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",ds,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,us))),128))],8,cs)),[[e.vModelSelect,s.values[l.key]]]):l.type==="multiselect"?(e.openBlock(),e.createElementBlock("div",ms,[(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:y=>o.toggleMulti(l.key,p.value,y.target.checked)},null,40,hs),e.createElementVNode("span",null,e.toDisplayString(p.label),1)]))),128))])):e.createCommentVNode("",!0)]))),128)),s.error?(e.openBlock(),e.createElementBlock("div",fs,e.toDisplayString(s.error),1)):e.createCommentVNode("",!0),r.readOnly?(e.openBlock(),e.createElementBlock("div",gs,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",_s)):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,ps))],32)])}const qe=B(Go,[["render",vs],["__scopeId","data-v-75332dad"]]),ys={name:"WmFeedback",inject:{t:{default:()=>A()}},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})}}},ks={class:"wm-fb"},bs={class:"wm-fb__title"},ws={class:"wm-fb__sub"},Es={class:"wm-fb__row"},Cs=["onClick"],Bs={class:"wm-fb__emoji"},Ns={class:"wm-fb__label"},Ss=["disabled"],As={key:1,class:"wm-fb__done"},Vs={class:"wm-fb__doneTitle"},Ms={class:"wm-fb__doneSub"};function Ts(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",ks,[r.done?(e.openBlock(),e.createElementBlock("div",As,[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",Vs,e.toDisplayString(o.t("feedback.doneTitle")),1),e.createElementVNode("div",Ms,e.toDisplayString(o.t("feedback.doneSubtitle")),1)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("div",bs,e.toDisplayString(o.t("feedback.question")),1),e.createElementVNode("div",ws,e.toDisplayString(o.t("feedback.subtitle")),1),e.createElementVNode("div",Es,[(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",Bs,e.toDisplayString(i.e),1),e.createElementVNode("span",Ns,e.toDisplayString(i.l),1)],10,Cs))),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,Ss)],64))])}const Ke=B(ys,[["render",Ts],["__scopeId","data-v-9b630564"]]),xs={name:"WmMoreMenu",inject:{t:{default:()=>A()}},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)}}},Ls={class:"wm-mm"},Os={class:"wm-mm__pop",role:"menu"},Ds={key:0,class:"wm-mm__section"},Is={class:"wm-mm__label"},Rs={class:"wm-mm__label"},Fs={key:1,class:"wm-mm__sep"},js={class:"wm-mm__section"},Ps={class:"wm-mm__label"},Us={class:"wm-mm__label"},zs={class:"wm-mm__section"},$s={class:"wm-mm__label"},Hs={class:"wm-mm__label"};function qs(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",Ls,[e.createElementVNode("div",{class:"wm-mm__scrim",onClick:n[0]||(n[0]=i=>t.$emit("close"))}),e.createElementVNode("div",Os,[r.canRename||r.canExport?(e.openBlock(),e.createElementBlock("div",Ds,[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",Is,e.toDisplayString(o.t("moreMenu.editTitle")),1)])):e.createCommentVNode("",!0),r.canExport?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"wm-mm__item",onClick:n[2]||(n[2]=i=>o.emit("export"))},[n[8]||(n[8]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M4 12v8a2 2 0 002 2h12a2 2 0 002-2v-8M16 6l-4-4-4 4M12 2v13"})])],-1)),e.createElementVNode("span",Rs,e.toDisplayString(o.t("moreMenu.exportTranscript")),1),n[9]||(n[9]=e.createElementVNode("span",{class:"wm-mm__hint"},".txt",-1))])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),r.canRename||r.canExport?(e.openBlock(),e.createElementBlock("div",Fs)):e.createCommentVNode("",!0),e.createElementVNode("div",js,[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",Ps,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",Us,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",zs,[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",$s,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",Hs,e.toDisplayString(o.t("moreMenu.helpCenter")),1)])):e.createCommentVNode("",!0)])])])}const We=B(xs,[["render",qs],["__scopeId","data-v-76281e95"]]),Ks={name:"WmRenameDialog",inject:{t:{default:()=>A()}},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())}}},Ws={class:"wm-dialog"},Gs={class:"wm-dialog__card",role:"dialog","aria-modal":"true"},Ys={class:"wm-dialog__head"},Qs={class:"wm-dialog__title"},Xs=["aria-label"],Js={class:"wm-dialog__body"},Zs=["placeholder"],ea={class:"wm-dialog__actions"},ta=["disabled"];function na(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",Ws,[e.createElementVNode("div",{class:"wm-dialog__scrim",onClick:n[0]||(n[0]=i=>t.$emit("close"))}),e.createElementVNode("div",Gs,[e.createElementVNode("div",Ys,[e.createElementVNode("div",Qs,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,Xs)]),e.createElementVNode("div",Js,[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,Zs),[[e.vModelText,s.value]])]),e.createElementVNode("div",ea,[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,ta)])])])}const ra=B(Ks,[["render",na],["__scopeId","data-v-6d5f94a8"]]),pe="ww-messenger-tokens",oa={name:"Messenger",components:{Launcher:we,Header:Ce,Onboarding:Ae,MessageList:Re,Composer:ze,SuggestionChips:$e,ApprovalCard:He,FormCard:qe,Feedback:Ke,MoreMenu:We,RenameDialog:ra},mixins:[lt,ft,pt,gt],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:""},userId:{type:String,default:""},userHash:{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,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}},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 Z(this.language||this.customerLanguage||((t=this.widget)==null?void 0:t.default_language)||"")},translator(){return A(this.locale)},error(){var t;return this.bootError||((t=this.s)==null?void 0:t.error)||null},canBoot(){return!!(this.baseUrl&&this.widgetId&&this.userId&&this.userHash)},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 y;const s=t[a.id]||[],o=j(a.last_read_message_id);let i=0,l=null;for(let v=s.length-1;v>=0;v--){const E=s[v];if(!E)continue;if(((y=E.author)==null?void 0:y.type)==="user")break;const N=j(E.id);if(N!=null){if(o!=null&&N<=o)break;n[E.id]!==0&&(!l&&E.author&&(l=E.author),i++)}}const p=s.filter(v=>!((v==null?void 0:v.id)!=null&&n[v.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,_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)||""},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,y;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||(y=s==null?void 0:s.metadata)!=null&&y.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(([y,v])=>`${y}: ${v}`).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:ae(n,$(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=j((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=j((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)}await this.boot(),this.isEmbedded&&this.store&&await this.open()},beforeUnmount(){this.cancelReveals(),this.teardownLiveReveal(),this.disconnectFloatRO(),this.resetApprovalPacing(),this.teardownNotifications(),this.store&&this.store.destroy()},methods:{t(t,n){return this.translator(t,n)},async boot(){var t;if(!this.canBoot){console.warn("[messenger] boot skipped — missing creds");return}try{this.transport=e.markRaw(_e({baseUrl:this.baseUrl,widgetId:this.widgetId,userId:this.userId,userHash:this.userHash})),this.store=e.markRaw(ge(this.transport)),this.hydrateNotifPref(),await this.store.start(),this.setupLiveReveal();const n=(t=this.context)==null?void 0:t.customer;n&&typeof n=="object"&&await this.store.applyCustomer(n)}catch(n){console.error("[ww-messenger] bootstrap failed",n),this.bootError=(n==null?void 0:n.message)||String(n)}},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.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)}},close(){this.isOpen=!1,this.store&&this.store.setPanelOpen(!1)},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)}},async onQuickLink(t){if(t){if(t.url){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}}}}},sa={key:0,class:"wm-loading","aria-busy":"true","aria-live":"polite"},aa=["aria-label"],ia={key:0,class:"wm-state"},la={class:"wm-state__err"},ca={class:"wm-state__errTitle"},da={class:"wm-state__errSub"},ua={class:"wm-bottom"},ma={key:0,ref:"floatEl",class:"wm-float"},ha={key:1,class:"wm-actionWait",role:"status","aria-live":"polite"},fa={class:"wm-actionWait__lbl"},pa={key:2,class:"wm-attached"},_a=["aria-label","onClick"];function ga(t,n,r,a,s,o){const i=e.resolveComponent("Launcher"),l=e.resolveComponent("Header"),p=e.resolveComponent("Onboarding"),y=e.resolveComponent("MessageList"),v=e.resolveComponent("ApprovalCard"),E=e.resolveComponent("FormCard"),N=e.resolveComponent("Feedback"),k=e.resolveComponent("SuggestionChips"),L=e.resolveComponent("Composer"),w=e.resolveComponent("MoreMenu"),T=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},null,8,["unread-count","peeks","onOpen","onDismiss"])):e.createCommentVNode("",!0),s.isOpen||o.isEmbedded?(e.openBlock(),e.createElementBlock("section",{key:1,class:e.normalizeClass(["wm-panel",`wm-panel--${r.displayMode}`]),style:e.normalizeStyle(s.floatHeight?{"--wm-float-h":s.floatHeight+"px"}:null),role:"dialog","aria-label":"Messenger"},[!o.ready&&!o.error?(e.openBlock(),e.createElementBlock("div",sa,[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]=(...S)=>o.close&&o.close(...S))},[...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,aa)),n[6]||(n[6]=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,onBack:o.goHome,onMore:o.toggleMore,onClose:o.close},null,8,["title","team-members","response-label","show-identity","show-back","show-close","more-active","onBack","onMore","onClose"]),o.error?(e.openBlock(),e.createElementBlock("div",ia,[e.createElementVNode("div",la,[n[7]||(n[7]=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",ca,e.toDisplayString(o.t("error.connectionFailed")),1),e.createElementVNode("div",da,e.toDisplayString(o.error),1)])])])):o.currentConv?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createVNode(y,{ref:"messageList",messages:o.displayedMessages,"streaming-active":o.streamingActive,"date-label":o.dateLabel,"conversation-id":o.currentConv?o.currentConv.id:null,"loading-more":o.paginationState.loading,"has-more":o.paginationState.hasMore,"unread-anchor-id":t.unreadAnchorId,"unread-boundary-ts":t.unreadBoundaryTs,onLoadMore:o.onLoadMore},null,8,["messages","streaming-active","date-label","conversation-id","loading-more","has-more","unread-anchor-id","unread-boundary-ts","onLoadMore"]),e.createElementVNode("div",ua,[o.floatVisible?(e.openBlock(),e.createElementBlock("div",ma,[o.approvalReady?(e.openBlock(),e.createBlock(v,{key:0,action:o.approvalTitle,detail:o.approvalDetail,callbacks:o.pendingApproval.callbacks,onCallback:o.onApprovalCallback},null,8,["action","detail","callbacks","onCallback"])):o.pendingForm?(e.openBlock(),e.createBlock(E,{key:o.pendingForm.message&&o.pendingForm.message.id,form:o.pendingForm.form,onSubmit:o.onFormSubmit},null,8,["form","onSubmit"])):o.showFeedback?(e.openBlock(),e.createBlock(N,{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",ha,[n[8]||(n[8]=e.createElementVNode("span",{class:"wm-actionWait__spinner","aria-hidden":"true"},null,-1)),e.createElementVNode("span",fa,e.toDisplayString(o.t("action.inProgress",{name:o.actionInFlightName})),1)])):(e.openBlock(),e.createBlock(L,{key:2,ref:"composer",modelValue:s.draft,"onUpdate:modelValue":n[1]||(n[1]=S=>s.draft=S),placeholder:o.composerPlaceholder,disabled:!!o.pendingApproval,"attach-label":o.t("composer.attachFile"),onSend:o.onSend,onAttach:o.onAttach},null,8,["modelValue","placeholder","disabled","attach-label","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]=S=>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(T,{key:1,"initial-value":o.currentConv.name||"",title:o.t("rename.dialogTitle"),onClose:n[3]||(n[3]=S=>s.renameDialogOpen=!1),onSubmit:o.onRenameSubmit},null,8,["initial-value","title","onSubmit"])):e.createCommentVNode("",!0),s.pendingAttachments.length?(e.openBlock(),e.createElementBlock("div",pa,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.pendingAttachments,(S,x)=>(e.openBlock(),e.createElementBlock("div",{key:x,class:"wm-attached__chip"},[n[10]||(n[10]=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(S.name),1),e.createElementVNode("button",{type:"button","aria-label":o.t("attachment.remove"),onClick:D=>s.pendingAttachments.splice(x,1)},[...n[9]||(n[9]=[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,_a)]))),128))])):e.createCommentVNode("",!0)],64)):(e.openBlock(),e.createBlock(p,{key:1,"welcome-message":o.widgetWelcomeMessage,"agent-name":o.agentName,"quick-links":o.quickLinks,"open-threads":o.openThreads,busy:s.busy,onStart:o.startConv,onSelect:o.onQuickLink,onResume:o.onDrawerPick},null,8,["welcome-message","agent-name","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]=S=>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=B(oa,[["render",ga],["__scopeId","data-v-d9dce1ad"]]),va="0.4.1";exports.AIAvatar=H;exports.AVATAR_COLORS=J;exports.ActionResult=Ve;exports.ApprovalCard=He;exports.ArtifactFormResponse=Me;exports.ArtifactInfoCard=Te;exports.ArtifactRenderer=Le;exports.ArtifactTicket=xe;exports.AttachmentPreview=Oe;exports.Bubble=De;exports.Composer=ze;exports.DEFAULT_BASE_URL=ye;exports.DEFAULT_LANGUAGE=z;exports.Feedback=Ke;exports.FormCard=qe;exports.Header=Ce;exports.HumanAvatar=ie;exports.Launcher=we;exports.MEDIA_RECORDER_SUPPORTED=ee;exports.MessageList=Re;exports.Messenger=Ge;exports.MoreMenu=We;exports.Onboarding=Ae;exports.SCREEN_CAPTURE_SUPPORTED=Y;exports.SUPPORTED_LANGUAGES=ke;exports.SuggestionChips=$e;exports.TeamAvatars=Ee;exports.Typing=Ie;exports.VERSION=va;exports.avatarColor=oe;exports.avatarInitials=se;exports.captureScreenshotFile=Pe;exports.colors=M;exports.createStore=ge;exports.createTranslator=A;exports.createTransport=_e;exports.dateLocale=$;exports.default=Ge;exports.formatTime=ae;exports.guessAttachmentKind=vo;exports.pickRecorderMime=Fe;exports.renderInlineMarkdown=Ne;exports.renderMarkdown=Se;exports.resolveLanguage=Z;exports.startScreenRecording=Ue;exports.tokensCss=ve;exports.uuid=re;exports.v4=re;