@_solaris/messenger-widget 0.6.28 โ 0.6.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/iframe/iframe.css +1 -1
- package/dist/iframe/iframe.js +1 -1
- package/dist/messenger.cjs +4 -4
- package/dist/messenger.js +4 -4
- package/dist/snippet.js +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/iframe/iframe.js
CHANGED
|
@@ -71,4 +71,4 @@ ${a}`)}return i.join(`
|
|
|
71
71
|
`),n=[];let r=0;for(;r<t.length;){const s=t[r];if(/^\s*```([\w-]*)\s*$/.exec(s)){r++;const d=[];for(;r<t.length&&!/^\s*```\s*$/.test(t[r]);)d.push(t[r]),r++;r<t.length&&r++,n.push({type:"block",html:`<pre class="wm-md-pre"><code>${d.join(`
|
|
72
72
|
`)}</code></pre>`});continue}if(/^\s*[-*]\s+/.test(s)){const d=[];for(;r<t.length;){const m=/^\s*[-*]\s+(.*)$/.exec(t[r]);if(!m)break;d.push(m[1]),r++}const c=d.map(m=>`<li>${nn(m)}</li>`).join("");n.push({type:"block",html:`<ul class="wm-md-ul">${c}</ul>`});continue}const a=/^\s*(\d+)\.\s+(.*)$/.exec(s);if(a){const d=parseInt(a[1],10),c=[a[2]];for(r++;r<t.length;){const b=/^\s*\d+\.\s+(.*)$/.exec(t[r]);if(!b)break;c.push(b[1]),r++}const m=c.map(b=>`<li>${nn(b)}</li>`).join(""),C=d!==1?` start="${d}"`:"";n.push({type:"block",html:`<ol class="wm-md-ol"${C}>${m}</ol>`});continue}const l=/^(#{1,6})\s+(.*)$/.exec(s);if(l){const d=l[1].length;n.push({type:"block",html:`<h${d} class="wm-md-h wm-md-h${d}">${nn(l[2])}</h${d}>`}),r++;continue}n.push({type:"text",html:nn(s)}),r++}let i="";for(let s=0;s<n.length;s++){const o=n[s];i+=o.html;const a=n[s+1];a&&o.type!=="block"&&a.type!=="block"&&(i+=`
|
|
73
73
|
`)}return i}function bn(e){var n;const t=(n=e==null?void 0:e.author)==null?void 0:n.type;return t==="agent_ia"||t==="agent_human"}function ht(e){if(e==null)return null;const t=typeof e=="number"?e:Number(e);return Number.isFinite(t)?t:null}function Qr(e,t){let n=(e==null?void 0:e.last_message_at)||(e==null?void 0:e.updated_at)||(e==null?void 0:e.created_at)||"";for(const r of t)r!=null&&r.created_at&&r.created_at>n&&(n=r.created_at);return n}function Ac(e,t){var n,r,i;for(let s=t.length-1;s>=0;s--){const o=t[s];if(!o)continue;const a=typeof o.text_md=="string"?o.text_md.trim():"";if(a)return(((n=o.author)==null?void 0:n.type)==="user"?"Vous : ":"")+a.replace(/\s+/g," ");const l=(r=o.payload)==null?void 0:r.attachments;if(Array.isArray(l)&&l.length)return"๐ Piรจce jointe"}return(e==null?void 0:e.last_message_preview)||(e==null?void 0:e.preview)||((i=e==null?void 0:e.metadata)==null?void 0:i.last_preview)||""}function xc(e,t){return(e==null?void 0:e.name)||((e==null?void 0:e.type)==="user"?t("common.you"):(e==null?void 0:e.type)==="agent_human"?t("common.agent"):(e==null?void 0:e.type)==="agent_ia"?t("common.aiAssistant"):t("common.system"))}function Tc(e,t,n,r){const i=[`# ${e.name||n("common.conversation")}`,e.created_at?n("export.createdOn",{date:new Date(e.created_at).toLocaleString(r)}):"",""];for(const s of t){if(!s)continue;const o=(s.text_md||"").trim();if(!o)continue;const a=xc(s.author,n),l=s.created_at?new Date(s.created_at).toLocaleString(r):"";i.push(`[${l}] ${a} :`),i.push(o),i.push("")}return i.join(`
|
|
74
|
-
`)}function Mc(e,t,n=Ee(),r){if(!e)return;const i=Tc(e,t||[],n,Bt(r)),s=new Blob([i],{type:"text/plain;charset=utf-8"});try{const o=URL.createObjectURL(s),a=document.createElement("a");a.href=o,a.download=`${(e.name||"conversation").replace(/[^a-z0-9-_]+/gi,"_")}.txt`,document.body.appendChild(a),a.click(),document.body.removeChild(a),setTimeout(()=>URL.revokeObjectURL(o),1e3)}catch(o){console.error("[ww-messenger] export failed",o)}}const Ec={data(){const e=typeof Notification<"u";return{notifPermission:e?Notification.permission:"denied",soundEnabled:!0,browserNotifEnabled:e&&Notification.permission==="granted",_audioCtx:null}},methods:{teardownNotifications(){var e,t;if(this._audioCtx){try{(t=(e=this._audioCtx).close)==null||t.call(e)}catch{}this._audioCtx=null}},soundStorageKey(){return`wm:notif:sound:${this.widgetId||""}`},browserNotifStorageKey(){return`wm:notif:browser:${this.widgetId||""}`},hydrateNotifPref(){try{if(typeof localStorage>"u")return;const e=localStorage.getItem(this.soundStorageKey());e==="0"?this.soundEnabled=!1:e==="1"&&(this.soundEnabled=!0);const t=localStorage.getItem(this.browserNotifStorageKey());t==="0"?this.browserNotifEnabled=!1:t==="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(e){this.soundEnabled=!!e,this.persistSoundPref()},async onBrowserNotifToggle(e){if(typeof Notification>"u"){this.browserNotifEnabled=!1,this.persistBrowserNotifPref();return}if(!e){this.browserNotifEnabled=!1,this.persistBrowserNotifPref();return}let t=Notification.permission;if(t==="default"){try{t=await Notification.requestPermission()}catch(n){console.warn("[ww-messenger] notif permission request failed",n),t="denied"}this.notifPermission=t}this.browserNotifEnabled=t==="granted",this.persistBrowserNotifPref()},onMessageRevealed(e,t){var i;if(!this.soundEnabled&&!this.browserNotifEnabled||!t||!e||!bn(e))return;const n=typeof document<"u"&&document.hidden;this.isOpen&&!n&&((i=this.currentConv)==null?void 0:i.id)===t||(this.soundEnabled&&this.playNotificationSound(),this.browserNotifEnabled&&this.showBrowserNotification(t,e))},playNotificationSound(){if(typeof window>"u")return;const e=window.AudioContext||window.webkitAudioContext;if(e)try{this._audioCtx||(this._audioCtx=new e);const t=this._audioCtx;if(t.state==="suspended")try{t.resume()}catch{}const n=t.currentTime,r=t.createOscillator(),i=t.createGain();r.connect(i),i.connect(t.destination),r.type="sine",r.frequency.setValueAtTime(880,n),r.frequency.exponentialRampToValueAtTime(1320,n+.08),i.gain.setValueAtTime(0,n),i.gain.linearRampToValueAtTime(.12,n+.02),i.gain.exponentialRampToValueAtTime(1e-4,n+.28),r.start(n),r.stop(n+.32)}catch{}},showBrowserNotification(e,t){if(typeof Notification>"u"||Notification.permission!=="granted")return;const n=t==null?void 0:t.author,r=!n||n.type==="agent_ia",s=((n==null?void 0:n.name)||(r?this.agentName:"")||this.t("launcher.theAgent"))+this.t("launcher.repliedToYou"),o=typeof(t==null?void 0:t.text_md)=="string"?t.text_md.trim():"",a=o?o.slice(0,140):this.t("notification.youHaveNewMessage");try{const l=new Notification(s,{body:a,tag:`wm-${e}`,renotify:!1,silent:!0});l.onclick=()=>{try{window.focus()}catch{}this.draftConv=null,this.showOnboarding=!1,this.activeConvId=e,this.isOpen=!0,this.store&&this.store.setPanelOpen(!0);try{l.close()}catch{}}}catch(l){console.warn("[ww-messenger] notification failed",l)}}}},Qt=Object.freeze({firstRevealDelayMs:450,msPerChar:50,minTypingMs:900,maxTypingMs:12e3,pauseBetweenMs:300}),Zt=(e,t)=>Number.isFinite(e)?e:t,Oc={computed:{revealPacing(){var t;const e=((t=this.widget)==null?void 0:t.reveal_pacing)||{};return{firstRevealDelayMs:Zt(e.first_reveal_delay_ms,Qt.firstRevealDelayMs),msPerChar:Zt(e.ms_per_char,Qt.msPerChar),minTypingMs:Zt(e.min_typing_ms,Qt.minTypingMs),maxTypingMs:Zt(e.max_typing_ms,Qt.maxTypingMs),pauseBetweenMs:Zt(e.pause_between_ms,Qt.pauseBetweenMs)}}},data(){return{revealedAt:{},nextRevealAt:0,revealTimers:[],_liveRevealOff:null,_liveRevealConvSnapshot:null,_liveHwm:{}}},methods:{cancelReveals(){for(const e of this.revealTimers)clearTimeout(e);this.revealTimers=[]},resetRevealQueue(){this.cancelReveals(),this.revealedAt={},this.nextRevealAt=0},setupLiveReveal(){var n,r;if(!this.transport)return;this.teardownLiveReveal();const e=this.transport.on("message",i=>{const s=i==null?void 0:i.conversation_id,o=i==null?void 0:i.message;s&&o&&this.paceLiveMessage(o,s)});this._liveRevealConvSnapshot=new Map((((n=this.s)==null?void 0:n.conversations)||[]).map(i=>[i.id,(i==null?void 0:i.last_message_at)||""])),this._liveHwm=Object.fromEntries((((r=this.s)==null?void 0:r.conversations)||[]).map(i=>[i.id,(i==null?void 0:i.last_message_at)||""]));const t=this.transport.on("activity",i=>{this.handleLiveActivity(i)});this._liveRevealOff=()=>{try{e()}catch{}try{t()}catch{}}},teardownLiveReveal(){if(this._liveRevealOff){try{this._liveRevealOff()}catch{}this._liveRevealOff=null}this._liveRevealConvSnapshot=null,this._liveHwm={}},async handleLiveActivity(e){var i,s;const t=e==null?void 0:e.conversations;if(!Array.isArray(t)||!this.store)return;const n=this._liveRevealConvSnapshot||new Map,r=[];for(const o of t){if(!(o!=null&&o.id))continue;const a=o.last_message_at||"";if(!a)continue;const l=n.get(o.id)||"";a>l&&r.push(o.id)}this._liveRevealConvSnapshot=new Map(t.map(o=>[o.id,(o==null?void 0:o.last_message_at)||""]));for(const o of r)try{const a=await((s=(i=this.store).fetchSinceLast)==null?void 0:s.call(i,o));if(!Array.isArray(a))continue;for(const l of a)this.paceLiveMessage(l,o)}catch(a){console.error("[ww-messenger] activity delta fetch failed",a)}},scheduleReveal(e,t){const n=this.revealPacing,r=Date.now(),i=((e==null?void 0:e.text_md)||"").length,s=Math.min(n.maxTypingMs,Math.max(n.minTypingMs,i*n.msPerChar)),a=Math.max(r+n.firstRevealDelayMs,this.nextRevealAt+n.pauseBetweenMs)+s;this.nextRevealAt=a;const l=Math.max(0,a-r),d=e.id,c=setTimeout(()=>{this.revealedAt={...this.revealedAt,[d]:Date.now()},this.revealTimers=this.revealTimers.filter(m=>m!==c),typeof this.onMessageRevealed=="function"&&this.onMessageRevealed(e,t)},l);this.revealTimers.push(c)},paceMessages(e,t){var i;if(!Array.isArray(e)||!e.length)return;const n=Date.now(),r={...this.revealedAt};for(const s of e){if((s==null?void 0:s.id)==null||r[s.id]!==void 0)continue;if(!bn(s)){r[s.id]=n;continue}const o=s!=null&&s.created_at?Date.parse(s.created_at):NaN;if(!Number.isFinite(o)||o<this.convOpenedAt){r[s.id]=n;continue}const a=typeof(s==null?void 0:s.text_md)=="string"&&s.text_md.trim().length>0,l=Array.isArray((i=s==null?void 0:s.payload)==null?void 0:i.attachments)&&s.payload.attachments.length>0;if(!a&&!l){r[s.id]=n;continue}r[s.id]=0,this.scheduleReveal(s,t)}this.revealedAt=r},paceLiveMessage(e,t){var a;if(!(e!=null&&e.id)||this.revealedAt[e.id]!==void 0)return;if(!bn(e)){this.revealedAt={...this.revealedAt,[e.id]:Date.now()};return}const n=typeof(e==null?void 0:e.text_md)=="string"&&e.text_md.trim().length>0,r=Array.isArray((a=e==null?void 0:e.payload)==null?void 0:a.attachments)&&e.payload.attachments.length>0;if(!n&&!r){this.revealedAt={...this.revealedAt,[e.id]:Date.now()};return}const i=this._liveHwm[t],s=(e==null?void 0:e.created_at)||"";if(s&&(i===void 0||s>i)&&(this._liveHwm={...this._liveHwm,[t]:s}),!(i!==void 0&&s&&s>i)){this.revealedAt={...this.revealedAt,[e.id]:Date.now()};return}this.revealedAt={...this.revealedAt,[e.id]:0},this.scheduleReveal(e,t)}}},Rc=300,Ic={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(e){var s,o;if(!(e!=null&&e.id)||e._draft||!this.store)return;const t=((o=(s=this.s)==null?void 0:s.messagesByConv)==null?void 0:o[e.id])||[],n=Lc(t);if(n==null)return;const r=ht(e.last_read_message_id),i=ht(n);i!=null&&(r!=null&&i<=r||(this._readMarkerPending={convId:e.id,messageId:n},!this._readMarkerTimer&&(this._readMarkerTimer=setTimeout(()=>{const a=this._readMarkerPending;this._readMarkerPending=null,this._readMarkerTimer=null,a&&this.store&&this.store.markConversationRead(a.convId,a.messageId)},Rc))))}}};function Lc(e){for(let t=e.length-1;t>=0;t--){const n=e[t];if(!(!n||n._pending)&&ht(n.id)!=null)return n.id}return null}const be=(e,t)=>{const n=e.__vccOpts||e;for(const[r,i]of t)n[r]=i;return n},Pc={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":Zs(this.name)},initials(){return er(this.name)}}},Bc=["src","alt"];function Fc(e,t,n,r,i,s){return h(),p("div",{class:te(["wm-huav",{"wm-huav--tail":n.tail}]),style:Ce({width:n.size+"px",height:n.size+"px","--wm-avr":Math.round(n.size*.32)+"px",background:s.bg})},[n.avatarUrl?(h(),p("img",{key:0,src:n.avatarUrl,alt:n.name||""},null,8,Bc)):(h(),p("span",{key:1,style:Ce({fontSize:n.size*.36+"px"})},R(s.initials),5))],6)}const rs=be(Pc,[["render",Fc],["__scopeId","data-v-14e10c0d"]]),Dc=3,Nc={name:"WmLauncher",components:{HumanAvatar:rs},inject:{t:{default:()=>Ee()}},props:{unreadCount:{type:Number,default:0},peeks:{type:Array,default:()=>[]}},emits:["open","dismiss"],computed:{visiblePeeks(){return this.peeks.slice(0,Dc).reverse()}}},Hc=["aria-label","onClick","onKeydown"],Uc=["aria-label","onClick"],jc={class:"wm-peek__avatar"},Vc=["aria-label"],Kc={class:"wm-peek__body"},zc={class:"wm-peek__head"},Wc={class:"wm-peek__name"},$c={class:"wm-peek__action"},qc={class:"wm-peek__text"},Gc=["onClick"],Yc=["aria-label"],Jc=["aria-label"];function Xc(e,t,n,r,i,s){const o=ve("HumanAvatar");return h(),p("div",{class:"wm-launcherWrap",onMouseenter:t[1]||(t[1]=a=>e.$emit("hover",!0)),onMouseleave:t[2]||(t[2]=a=>e.$emit("hover",!1)),onFocusin:t[3]||(t[3]=a=>e.$emit("hover",!0)),onFocusout:t[4]||(t[4]=a=>e.$emit("hover",!1))},[pe(Qs,{name:"wm-peek"},{default:Xn(()=>[s.visiblePeeks.length?(h(),p("div",{key:0,class:te(["wm-peekStack",{"wm-peekStack--multi":s.visiblePeeks.length>1}])},[(h(!0),p(Z,null,Se(s.visiblePeeks,(a,l)=>(h(),p("div",{key:a.convId,class:"wm-peek",style:Ce({"--depth":s.visiblePeeks.length-1-l,zIndex:l+1}),role:"button",tabindex:"0","aria-label":s.t("launcher.openConversationWith",{name:a.senderName||s.t("launcher.theAgent")}),onClick:d=>e.$emit("open",a.convId),onKeydown:[Un(We(d=>e.$emit("open",a.convId),["prevent"]),["enter"]),Un(We(d=>e.$emit("open",a.convId),["prevent"]),["space"])]},[u("button",{type:"button",class:"wm-peek__close","aria-label":s.t("launcher.dismiss"),onClick:We(d=>e.$emit("dismiss",a.convId),["stop"])},[...t[5]||(t[5]=[u("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"},[u("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,Uc),u("div",jc,[pe(o,{name:a.senderName,"avatar-url":a.senderAvatarUrl,size:34},null,8,["name","avatar-url"]),a.count>1?(h(),p("span",{key:0,class:"wm-peek__avatarBadge","aria-label":s.t("launcher.unreadMessages",{count:a.count})},R(a.count>9?"9+":a.count),9,Vc)):F("",!0)]),u("div",Kc,[u("div",zc,[u("span",Wc,R(a.senderName||s.t("common.agent")),1),u("span",$c,R(s.t("launcher.repliedToYou")),1)]),u("p",qc,R(a.preview),1)]),u("button",{type:"button",class:"wm-peek__open",onClick:We(d=>e.$emit("open",a.convId),["stop"])},R(s.t("common.open")),9,Gc)],44,Hc))),128))],2)):F("",!0)]),_:1}),u("button",{type:"button",class:"wm-launcher","aria-label":s.t("launcher.open"),onClick:t[0]||(t[0]=a=>e.$emit("open"))},[t[6]||(t[6]=u("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"},[u("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)),n.unreadCount>0?(h(),p("span",{key:0,class:"wm-launcher__badge","aria-label":n.unreadCount>1?s.t("launcher.unreadConversationsMany",{count:n.unreadCount}):s.t("launcher.unreadConversationsOne",{count:n.unreadCount})},R(n.unreadCount>9?"9+":n.unreadCount),9,Jc)):F("",!0)],8,Yc)],32)}const Qc=be(Nc,[["render",Xc],["__scopeId","data-v-d81459bc"]]),Zc={name:"WmAIAvatar",props:{size:{type:Number,default:26},pulse:{type:Boolean,default:!1},tail:{type:Boolean,default:!1},name:{type:String,default:""},imageUrl:{type:String,default:null}},computed:{initials(){return er(this.name)},bgColor(){return Zs(this.name)}}},eu={key:0,class:"wm-aiav__pulse"},tu=["src","alt"],nu=["width","height"];function su(e,t,n,r,i,s){return h(),p("div",{class:te(["wm-aiav",{"wm-aiav--tail":n.tail}]),style:Ce({width:n.size+"px",height:n.size+"px","--wm-avr":n.size*.32+"px"})},[n.pulse?(h(),p("div",eu)):F("",!0),u("div",{class:te(["wm-aiav__inner",{"wm-aiav__inner--glow":n.pulse,"wm-aiav__inner--img":!!n.imageUrl,"wm-aiav__inner--initials":!n.imageUrl&&!!s.initials}]),style:Ce(!n.imageUrl&&s.initials?{background:s.bgColor}:null)},[n.imageUrl?(h(),p("img",{key:0,src:n.imageUrl,alt:n.name||""},null,8,tu)):s.initials?(h(),p("span",{key:1,style:Ce({fontSize:n.size*.36+"px"})},R(s.initials),5)):(h(),p("svg",{key:2,width:n.size*.5,height:n.size*.5,viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[...t[0]||(t[0]=[u("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),u("circle",{cx:"19",cy:"5",r:"1.5",fill:"white",opacity:"0.55"},null,-1),u("circle",{cx:"5",cy:"18",r:"1",fill:"white",opacity:"0.38"},null,-1)])],8,nu))],6)],6)}const Sn=be(Zc,[["render",su],["__scopeId","data-v-6f7f685d"]]),ru={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(e){return e.avatar_url?"transparent":Zs(e.name||"")},initialsFor(e){return er(e.name||"")}}},iu={key:0,class:"wm-team"},ou=["src","alt"],au={key:1},lu={key:0,class:"wm-team__label"};function cu(e,t,n,r,i,s){return s.visible?(h(),p("div",iu,[u("div",{class:"wm-team__stack",style:Ce({width:s.stackWidth+"px"})},[(h(!0),p(Z,null,Se(n.members.slice(0,3),(o,a)=>(h(),p("div",{key:a,class:"wm-team__pill",style:Ce({left:a*13+"px",zIndex:3-a,background:s.colorFor(o)})},[o.avatar_url?(h(),p("img",{key:0,src:o.avatar_url,alt:o.name||""},null,8,ou)):(h(),p("span",au,R(s.initialsFor(o)),1))],4))),128))],4),n.responseLabel?(h(),p("span",lu,R(n.responseLabel),1)):F("",!0)])):F("",!0)}const uu=be(ru,[["render",cu],["__scopeId","data-v-e49a9063"]]),du={name:"WmHeader",components:{AIAvatar:Sn,TeamAvatars:uu},inject:{t:{default:()=>Ee()}},props:{title:{type:String,default:"Nouvelle conversation"},showBack:{type:Boolean,default:!1},teamMembers:{type:Array,default:()=>[]},responseLabel:{type:String,default:""},showClose:{type:Boolean,default:!0},showMore:{type:Boolean,default:!0},moreActive:{type:Boolean,default:!1},showIdentity:{type:Boolean,default:!0},agentName:{type:String,default:""},agentAvatarUrl:{type:String,default:null}},emits:["back","close","more"],computed:{hasTeam(){return Array.isArray(this.teamMembers)&&this.teamMembers.length>0},displayedTeamMembers(){const e=Array.isArray(this.teamMembers)?this.teamMembers:[];if(e.length<=3)return e;const t=new Date().getHours()%e.length,n=[];for(let r=0;r<3;r++)n.push(e[(t+r)%e.length]);return n}}},fu={class:"wm-header"},hu=["aria-label"],mu={key:1,style:{width:"30px",height:"30px","flex-shrink":"0"}},gu={class:"wm-header__avatar"},pu={class:"wm-header__main"},_u={class:"wm-header__title"},yu={key:3,class:"wm-header__fill"},vu={class:"wm-header__actions"},bu=["aria-label","title"],wu=["aria-label","title"];function ku(e,t,n,r,i,s){const o=ve("AIAvatar"),a=ve("TeamAvatars");return h(),p("div",fu,[n.showBack?(h(),p("button",{key:0,type:"button",class:"wm-header__icon wm-header__back","aria-label":s.t("header.backToHome"),onClick:t[0]||(t[0]=l=>e.$emit("back"))},[...t[3]||(t[3]=[u("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"},[u("path",{d:"M19 12H5M12 5l-7 7 7 7"})],-1)])],8,hu)):(h(),p("div",mu)),n.showIdentity?(h(),p(Z,{key:2},[u("div",gu,[pe(o,{size:30,name:n.agentName,"image-url":n.agentAvatarUrl},null,8,["name","image-url"])]),u("div",pu,[u("div",_u,R(n.title),1)]),s.hasTeam?(h(),fe(a,{key:0,members:s.displayedTeamMembers,"response-label":""},null,8,["members"])):F("",!0)],64)):(h(),p("div",yu)),u("div",vu,[n.showMore?(h(),p("button",{key:0,type:"button",class:te(["wm-header__icon",{"wm-header__icon--active":n.moreActive}]),"aria-label":s.t("header.moreOptions"),title:s.t("header.moreOptions"),onClick:t[1]||(t[1]=l=>e.$emit("more"))},[...t[4]||(t[4]=[u("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true"},[u("circle",{cx:"12",cy:"5",r:"1.6"}),u("circle",{cx:"12",cy:"12",r:"1.6"}),u("circle",{cx:"12",cy:"19",r:"1.6"})],-1)])],10,bu)):F("",!0),n.showClose?(h(),p("button",{key:1,type:"button",class:"wm-header__icon","aria-label":s.t("header.closeWidget"),title:s.t("header.closeWidget"),onClick:t[2]||(t[2]=l=>e.$emit("close"))},[...t[5]||(t[5]=[u("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"},[u("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,wu)):F("",!0)])])}const Cu=be(du,[["render",ku],["__scopeId","data-v-27232009"]]),Zr={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"},Su={name:"WmOnboarding",components:{AIAvatar:Sn,HumanAvatar:rs},inject:{t:{default:()=>Ee()},wmLocale:{default:()=>()=>"fr"}},props:{title:{type:String,default:""},subtitle:{type:String,default:""},agentName:{type:String,default:""},defaultIconUrl:{type:String,default:null},coverImageUrl:{type:String,default:null},quickLinks:{type:Array,default:()=>[]},openThreads:{type:Array,default:()=>[]},busy:{type:Boolean,default:!1},launching:{type:Boolean,default:!1},welcomeMessage:{type:String,default:""}},emits:["start","launched","select","resume","view-history"],data(){return{launchPhase:"idle",inputFocused:!1,launchDone:!1,starterText:""}},watch:{launching(e){e&&this.runLaunch()}},computed:{canStart(){return!this.busy&&!!this.starterText.trim()},typing(){return this.inputFocused&&!!this.starterText.trim()},heroTitle(){return this.title?this.title:this.agentName?this.t("onboarding.greetingNamed",{name:this.agentName}):this.t("onboarding.greeting")},heroSub(){return this.subtitle||this.t("onboarding.heroSub")},unreadThreads(){return this.openThreads.filter(e=>e.unread)},safeCoverUrl(){return Gr(this.coverImageUrl)},hasCover(){return!!this.safeCoverUrl},coverStyle(){return this.safeCoverUrl?{backgroundImage:`url("${this.safeCoverUrl}")`}:null}},methods:{submitStarter(){this.canStart&&this.$emit("start",this.starterText.trim())},onStarterKeydown(e){e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),this.submitStarter())},onInputFocus(){this.launchPhase==="idle"&&(this.inputFocused=!0,this.$nextTick(()=>this.autosize()))},onInputBlur(){this.launchPhase==="idle"&&(this.inputFocused=!1,this.$nextTick(()=>this.autosize()))},autosize(){const e=this.$refs.starterInput;if(!e||e.clientWidth<40)return;e.style.height="auto",e.style.minHeight="0px";const t=e.scrollHeight;e.style.minHeight="",e.style.height=t>62?`${Math.min(t,120)}px`:""},async runLaunch(){const e=this.$refs.starterForm,t=typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;if(!e||t){this.launchPhase="fade",await this.wait(t?120:0),this.finishLaunch();return}this.launchPhase="fade",await this.wait(320);const n=e.getBoundingClientRect();this.launchPhase="slide",await this.$nextTick();const r=e.getBoundingClientRect(),i=n.left-r.left,s=n.top-r.top;e.style.transition="none",e.style.transform=`translate(${i}px, ${s}px)`,e.offsetWidth,e.style.transition="transform 0.44s cubic-bezier(0.32, 0.72, 0, 1)",e.style.transform="translate(0, 0)";const o=()=>{e.removeEventListener("transitionend",o),this.finishLaunch()};e.addEventListener("transitionend",o),this.wait(520).then(()=>this.finishLaunch())},finishLaunch(){this.launchDone||(this.launchDone=!0,this.$emit("launched"))},wait(e){return new Promise(t=>window.setTimeout(t,e))},iconPath(e){return Zr[e]||Zr.link},isExternalLink(e){const t=e==null?void 0:e.url;return!!t&&!t.startsWith("#")},safeIconUrl(e){return Gr(e==null?void 0:e.icon_url)},iconUrlStyle(e){const t=this.safeIconUrl(e);return t?{"--icon-url":`url("${t}")`}:null},renderPreview(e){return Mo(e)},avatarComponent(e){var t;return((t=e==null?void 0:e.author)==null?void 0:t.type)==="agent_human"?"HumanAvatar":"AIAvatar"},avatarProps(e){const t=e==null?void 0:e.author;return(t==null?void 0:t.type)==="agent_human"?{size:40,name:t.name||"",avatarUrl:t.avatar_url||null}:{size:40,name:(t==null?void 0:t.name)||"",imageUrl:(t==null?void 0:t.avatar_url)||null}},isDefaultAvatar(e){const t=e==null?void 0:e.author;return!(t!=null&&t.avatar_url||t!=null&&t.name)},avatarWrapperClass(e){return this.isDefaultAvatar(e)&&!(e!=null&&e.unread)?"wm-onb__avatar--muted":null},senderLabel(e){var t;return((t=e==null?void 0:e.author)==null?void 0:t.name)||""},formatTs(e){if(!e)return"";const t=new Date(e);if(Number.isNaN(t.getTime()))return"";const n=Bt(this.wmLocale()),r=new Date;if(t.toDateString()===r.toDateString())return t.toLocaleTimeString(n,{hour:"2-digit",minute:"2-digit"});if(r.getTime()-t.getTime()<7*864e5){const o=t.toLocaleDateString(n,{weekday:"short"});return o.charAt(0).toUpperCase()+o.slice(1)}return t.toLocaleDateString(n,{day:"2-digit",month:"2-digit"})}}},Au=["aria-label"],xu={key:1,class:"wm-onb__hero-deco",width:"180",height:"180",viewBox:"0 0 180 180",fill:"none","aria-hidden":"true"},Tu={class:"wm-onb__hero-text"},Mu={class:"wm-onb__hero-default"},Eu={class:"wm-onb__title"},Ou={class:"wm-onb__sub"},Ru={key:0,class:"wm-onb__welcome"},Iu={key:0,class:"wm-onb__alertList"},Lu=["onClick"],Pu={key:0,class:"wm-onb__defaultAvatar"},Bu=["aria-label"],Fu={class:"wm-onb__alert-body"},Du={class:"wm-onb__alert-title"},Nu={class:"wm-onb__alert-preview"},Hu={key:0,class:"wm-onb__alert-sender"},Uu=["innerHTML"],ju={class:"wm-onb__alert-meta"},Vu={key:0,class:"wm-onb__alert-time"},Ku={class:"wm-onb__alert-resume"},zu={class:"wm-onb__actions"},Wu=["onClick"],$u={class:"wm-onb__btn-icon"},qu=["aria-label"],Gu={key:1,width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.9","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},Yu=["d"],Ju={class:"wm-onb__btn-label"},Xu={key:0,class:"wm-onb__btn-trail",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"},Qu={class:"wm-onb__btn-icon"},Zu={width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},ed=["d"],td={class:"wm-onb__btn-label"},nd={class:"wm-onb__btn-count"},sd=["placeholder","disabled","aria-label"],rd=["disabled","aria-label"],id={key:0,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},od={key:1,class:"wm-onb__starter-spinner","aria-hidden":"true"};function ad(e,t,n,r,i,s){const o=ve("AIAvatar");return h(),p("div",{class:te(["wm-onb",{"wm-onb--launching":i.launchPhase!=="idle","wm-onb--sliding":i.launchPhase==="slide","wm-onb--focused":i.inputFocused,"wm-onb--typing":s.typing}])},[u("div",{class:te(["wm-onb__hero",{"wm-onb__hero--cover":s.hasCover}])},[s.hasCover?(h(),p("div",{key:0,class:"wm-onb__cover",style:Ce(s.coverStyle),role:"img","aria-label":s.heroTitle},null,12,Au)):F("",!0),s.hasCover?F("",!0):(h(),p("svg",xu,[...t[7]||(t[7]=[u("circle",{cx:"170",cy:"10",r:"105",stroke:"#5B5FEF","stroke-width":"1","stroke-dasharray":"1 5",opacity:"0.35"},null,-1),u("circle",{cx:"170",cy:"10",r:"72",stroke:"#5B5FEF","stroke-width":"1","stroke-dasharray":"1 5",opacity:"0.5"},null,-1),u("circle",{cx:"152",cy:"34",r:"2.5",fill:"#5B5FEF",opacity:"0.65"},null,-1)])])),pe(o,{size:52,"image-url":n.defaultIconUrl},null,8,["image-url"]),u("div",Tu,[u("div",Mu,[u("div",Eu,R(s.heroTitle),1),u("div",Ou,R(s.heroSub),1)]),n.welcomeMessage?(h(),p("div",Ru,R(n.welcomeMessage),1)):F("",!0)])],2),s.unreadThreads.length?(h(),p("div",Iu,[(h(!0),p(Z,null,Se(s.unreadThreads,a=>(h(),p("button",{key:a.id,type:"button",class:"wm-onb__alert",onClick:l=>e.$emit("resume",a)},[u("span",{class:te(["wm-onb__alert-avatar",s.avatarWrapperClass(a)])},[s.isDefaultAvatar(a)?(h(),p("span",Pu,[...t[8]||(t[8]=[u("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"},[u("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)])])):(h(),fe(qs(s.avatarComponent(a)),Xs({key:1,ref_for:!0},s.avatarProps(a)),null,16)),u("span",{class:"wm-onb__alert-dot","aria-label":s.t("onboarding.unread")},null,8,Bu)],2),u("span",Fu,[u("span",Du,R(a.title),1),u("span",Nu,[s.senderLabel(a)?(h(),p("span",Hu,R(s.senderLabel(a))+" ยท ",1)):F("",!0),u("span",{innerHTML:s.renderPreview(a.preview)},null,8,Uu)])]),u("span",ju,[s.formatTs(a._ts)?(h(),p("span",Vu,R(s.formatTs(a._ts)),1)):F("",!0),u("span",Ku,R(s.t("onboarding.resume")),1)])],8,Lu))),128))])):F("",!0),u("div",zu,[(h(!0),p(Z,null,Se(n.quickLinks,(a,l)=>(h(),p("button",{key:"ql-"+l,type:"button",class:"wm-onb__btn",onClick:d=>e.$emit("select",a)},[u("span",$u,[s.safeIconUrl(a)?(h(),p("span",{key:0,class:"wm-onb__btn-iconImg",style:Ce(s.iconUrlStyle(a)),role:"img","aria-label":a.label||""},null,12,qu)):(h(),p("svg",Gu,[u("path",{d:s.iconPath(a.icon)},null,8,Yu)]))]),u("span",Ju,R(a.label),1),s.isExternalLink(a)?(h(),p("svg",Xu,[...t[9]||(t[9]=[u("path",{d:"M7 17L17 7M9 7h8v8"},null,-1)])])):F("",!0)],8,Wu))),128)),n.openThreads.length?(h(),p("button",{key:0,type:"button",class:"wm-onb__btn",onClick:t[0]||(t[0]=a=>e.$emit("view-history"))},[u("span",Qu,[(h(),p("svg",Zu,[u("path",{d:s.iconPath("chat")},null,8,ed)]))]),u("span",td,R(s.t("onboarding.allConversations")),1),u("span",nd,R(n.openThreads.length),1),t[10]||(t[10]=u("svg",{class:"wm-onb__btn-trail",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"},[u("path",{d:"M9 18l6-6-6-6"})],-1))])):F("",!0),u("form",{ref:"starterForm",class:te(["wm-onb__starter",{"is-active":!!i.starterText.trim(),"is-expanded":i.inputFocused,"wm-onb__starter--toBottom":i.launchPhase==="slide"}]),onSubmit:t[6]||(t[6]=We((...a)=>s.submitStarter&&s.submitStarter(...a),["prevent"]))},[st(u("textarea",{ref:"starterInput","onUpdate:modelValue":t[1]||(t[1]=a=>i.starterText=a),class:"wm-onb__starter-input",rows:"1",placeholder:s.t("onboarding.starterPlaceholder"),disabled:n.busy,"aria-label":s.t("onboarding.start"),enterkeyhint:"send",onKeydown:t[2]||(t[2]=(...a)=>s.onStarterKeydown&&s.onStarterKeydown(...a)),onInput:t[3]||(t[3]=(...a)=>s.autosize&&s.autosize(...a)),onFocus:t[4]||(t[4]=(...a)=>s.onInputFocus&&s.onInputFocus(...a)),onBlur:t[5]||(t[5]=(...a)=>s.onInputBlur&&s.onInputBlur(...a))},null,40,sd),[[kt,i.starterText]]),u("button",{type:"submit",class:te(["wm-onb__starter-send",{"is-empty":!s.canStart}]),disabled:n.busy||!s.canStart,"aria-label":s.t("composer.send")},[n.busy?(h(),p("span",od)):(h(),p("svg",id,[...t[11]||(t[11]=[u("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"},null,-1)])]))],10,rd)],34)])],2)}const ld=be(Su,[["render",ad],["__scopeId","data-v-cfaffcfa"]]),cd={name:"WmHistory",components:{AIAvatar:Sn,HumanAvatar:rs},inject:{t:{default:()=>Ee()},wmLocale:{default:()=>()=>"fr"}},props:{threads:{type:Array,default:()=>[]}},emits:["resume"],data(){return{query:""}},computed:{filteredThreads(){const e=this.query.trim().toLowerCase();return e?this.threads.filter(t=>(t.title||"").toLowerCase().includes(e)||(t.preview||"").toLowerCase().includes(e)):this.threads}},methods:{renderPreview(e){return Mo(e)},avatarComponent(e){var t;return((t=e==null?void 0:e.author)==null?void 0:t.type)==="agent_human"?"HumanAvatar":"AIAvatar"},avatarProps(e){const t=e==null?void 0:e.author;return(t==null?void 0:t.type)==="agent_human"?{size:40,name:t.name||"",avatarUrl:t.avatar_url||null}:{size:40,name:(t==null?void 0:t.name)||"",imageUrl:(t==null?void 0:t.avatar_url)||null}},isDefaultAvatar(e){const t=e==null?void 0:e.author;return!(t!=null&&t.avatar_url||t!=null&&t.name)},avatarWrapperClass(e){return this.isDefaultAvatar(e)&&!(e!=null&&e.unread)?"wm-hist__avatar--muted":null},formatTs(e){if(!e)return"";const t=new Date(e);if(Number.isNaN(t.getTime()))return"";const n=Bt(this.wmLocale()),r=new Date;if(t.toDateString()===r.toDateString())return t.toLocaleTimeString(n,{hour:"2-digit",minute:"2-digit"});if(r.getTime()-t.getTime()<7*864e5){const o=t.toLocaleDateString(n,{weekday:"short"});return o.charAt(0).toUpperCase()+o.slice(1)}return t.toLocaleDateString(n,{day:"2-digit",month:"2-digit"})}}},ud={class:"wm-hist"},dd={class:"wm-hist__search"},fd=["placeholder","aria-label"],hd={class:"wm-hist__list"},md=["onClick"],gd={key:0,class:"wm-hist__defaultAvatar"},pd=["aria-label"],_d={class:"wm-hist__thread-body"},yd={class:"wm-hist__thread-title"},vd=["innerHTML"],bd={class:"wm-hist__thread-meta"},wd={key:0,class:"wm-hist__thread-time"},kd={key:0,class:"wm-hist__empty"};function Cd(e,t,n,r,i,s){return h(),p("div",ud,[u("div",dd,[t[1]||(t[1]=u("span",{class:"wm-hist__searchIcon"},[u("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"},[u("path",{d:"M21 21l-4.35-4.35M11 17a6 6 0 100-12 6 6 0 000 12z"})])],-1)),st(u("input",{"onUpdate:modelValue":t[0]||(t[0]=o=>i.query=o),type:"text",placeholder:s.t("onboarding.search"),"aria-label":s.t("onboarding.search")},null,8,fd),[[kt,i.query]])]),u("div",hd,[(h(!0),p(Z,null,Se(s.filteredThreads,o=>(h(),p("button",{key:o.id,type:"button",class:te(["wm-hist__thread",{"wm-hist__thread--unread":o.unread}]),onClick:a=>e.$emit("resume",o)},[u("span",{class:te(["wm-hist__thread-avatar",s.avatarWrapperClass(o)])},[s.isDefaultAvatar(o)?(h(),p("span",gd,[...t[2]||(t[2]=[u("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[u("path",{d:"M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"})],-1)])])):(h(),fe(qs(s.avatarComponent(o)),Xs({key:1,ref_for:!0},s.avatarProps(o)),null,16)),o.unread?(h(),p("span",{key:2,class:"wm-hist__thread-dot","aria-label":s.t("onboarding.unread")},null,8,pd)):F("",!0)],2),u("span",_d,[u("span",yd,R(o.title),1),u("span",{class:"wm-hist__thread-preview",innerHTML:s.renderPreview(o.preview)},null,8,vd)]),u("span",bd,[s.formatTs(o._ts)?(h(),p("span",wd,R(s.formatTs(o._ts)),1)):F("",!0),t[3]||(t[3]=u("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-hist__thread-chev","aria-hidden":"true"},[u("path",{d:"M5 12h14M13 5l7 7-7 7"})],-1))])],10,md))),128)),s.filteredThreads.length?F("",!0):(h(),p("div",kd,R(i.query?s.t("onboarding.noResults",{query:i.query}):s.t("onboarding.noConversations")),1))])])}const Sd=be(cd,[["render",Cd],["__scopeId","data-v-6bf35ef1"]]);function Ad(e){return typeof e!="string"?"":e.replace(/`([^`]+)`/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(new RegExp("(?<!\\*)\\*([^*]+)\\*(?!\\*)","g"),"$1").replace(/__([^_]+)__/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\s+/g," ").trim()}const xd={name:"WmActionResult",props:{state:{type:String,default:"success"},label:{type:String,required:!0},detail:{type:String,default:""}},computed:{detailText(){return Ad(this.detail)}}},Td={class:"wm-result__icon","aria-hidden":"true"},Md={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"},Ed={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"},Od={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"},Rd={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"},Id={class:"wm-result__body"},Ld={class:"wm-result__label"},Pd={class:"wm-result__detail"};function Bd(e,t,n,r,i,s){return h(),p("div",{class:te(["wm-result",`wm-result--${n.state}`])},[u("span",Td,[n.state==="success"?(h(),p("svg",Md,[...t[0]||(t[0]=[u("path",{d:"M20 6L9 17l-5-5"},null,-1)])])):n.state==="rejected"?(h(),p("svg",Ed,[...t[1]||(t[1]=[u("path",{d:"M18 6L6 18M6 6l12 12"},null,-1)])])):n.state==="awaiting"?(h(),p("svg",Od,[...t[2]||(t[2]=[u("circle",{cx:"12",cy:"12",r:"10"},null,-1),u("polyline",{points:"12 7 12 12 15 14"},null,-1)])])):(h(),p("svg",Rd,[...t[3]||(t[3]=[u("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),u("line",{x1:"12",y1:"9",x2:"12",y2:"13"},null,-1),u("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"},null,-1)])]))]),u("span",Id,[u("span",Ld,R(n.label),1),s.detailText?(h(),p(Z,{key:0},[t[4]||(t[4]=u("span",{class:"wm-result__sep","aria-hidden":"true"}," ยท ",-1)),u("span",Pd,R(s.detailText),1)],64)):F("",!0)])],2)}const Fd=be(xd,[["render",Bd],["__scopeId","data-v-7284acd0"]]),Dd={name:"WmArtifactFormResponse",inject:{t:{default:()=>Ee()}},props:{data:{type:Object,required:!0}},computed:{fields(){var e;return Array.isArray((e=this.data)==null?void 0:e.fields)?this.data.fields:[]}}},Nd={class:"wm-art wm-art--formResponse"},Hd={class:"wm-art__head"},Ud={class:"wm-art__title"},jd={class:"wm-art__badge wm-art__badge--success"},Vd={class:"wm-art__body"},Kd={class:"wm-art__fieldLabel"};function zd(e,t,n,r,i,s){return h(),p("div",Nd,[u("div",Hd,[u("div",Ud,R(n.data.title||s.t("form.title")),1),u("span",jd,[t[0]||(t[0]=u("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"},[u("polyline",{points:"20 6 9 17 4 12"})],-1)),ns(" "+R(s.t("form.sent")),1)])]),u("div",Vd,[(h(!0),p(Z,null,Se(s.fields,(o,a)=>(h(),p("div",{key:a,class:"wm-art__field"},[u("div",Kd,R(o.label),1),u("div",{class:te(["wm-art__fieldValue",{"wm-art__fieldValue--multi":o.multiline}])},R(o.value),3)]))),128))])])}const Wd=be(Dd,[["render",zd],["__scopeId","data-v-713aecf1"]]),$d={name:"WmArtifactInfoCard",props:{data:{type:Object,required:!0}},computed:{fields(){var e;return Array.isArray((e=this.data)==null?void 0:e.fields)?this.data.fields:[]},hasBody(){var e;return!!((e=this.data)!=null&&e.body)||this.fields.length>0}}},qd={class:"wm-art wm-art--infoCard"},Gd={key:0,class:"wm-art__image"},Yd=["src","alt"],Jd={class:"wm-art__head"},Xd={class:"wm-art__headMain"},Qd={class:"wm-art__title"},Zd={key:0,class:"wm-art__subtitle"},ef={key:1,class:"wm-art__body"},tf={key:0,class:"wm-art__text"},nf={class:"wm-art__fieldLabel"};function sf(e,t,n,r,i,s){return h(),p("div",qd,[n.data.image_url?(h(),p("figure",Gd,[u("img",{src:n.data.image_url,alt:n.data.title||"",loading:"lazy"},null,8,Yd)])):F("",!0),u("div",Jd,[u("div",Xd,[u("div",Qd,R(n.data.title),1),n.data.subtitle?(h(),p("div",Zd,R(n.data.subtitle),1)):F("",!0)]),n.data.badge&&n.data.badge.label?(h(),p("span",{key:0,class:te(["wm-art__badge",`wm-art__badge--${n.data.badge.tone||"neutral"}`])},R(n.data.badge.label),3)):F("",!0)]),s.hasBody?(h(),p("div",ef,[n.data.body?(h(),p("div",tf,R(n.data.body),1)):F("",!0),s.fields.length?(h(!0),p(Z,{key:1},Se(s.fields,(o,a)=>(h(),p("div",{key:a,class:"wm-art__field"},[u("div",nf,R(o.label),1),u("div",{class:te(["wm-art__fieldValue",{"wm-art__fieldValue--multi":o.multiline}])},R(o.value),3)]))),128)):F("",!0)])):F("",!0)])}const rf=be($d,[["render",sf],["__scopeId","data-v-7eae0e4a"]]);function of(e,t,n){if(!e)return"";const r=new Date(e);if(Number.isNaN(r.getTime()))return e;const i=r.toLocaleDateString(t,{day:"numeric",month:"long",year:"numeric"}),s=r.toLocaleTimeString(t,{hour:"2-digit",minute:"2-digit"});return`${i}${n}${s}`}const af={name:"WmArtifactTicket",inject:{t:{default:()=>Ee()},wmLocale:{default:()=>()=>"fr"}},props:{data:{type:Object,required:!0}},computed:{fields(){var e;return Array.isArray((e=this.data)==null?void 0:e.fields)?this.data.fields:[]},formattedDate(){var e;return of((e=this.data)==null?void 0:e.created_at,Bt(this.wmLocale()),this.t("ticket.dateAt"))}},methods:{isPriority(e){return/priorit|^prio$/i.test(String(e||"").trim())},isDate(e){return/date|รฉchรฉanc|echeanc|deadline|due|crรฉรฉ|cree/i.test(String(e||"").trim())},priorityLevel(e){const t=String(e||"").toLowerCase();return/high|haute|รฉlev|elev|critic|critiq|urgent/.test(t)?3:/low|basse|faible|minor/.test(t)?1:2}}},lf={class:"wm-art wm-art--ticket"},cf={class:"wm-art__head wm-tk__head"},uf={class:"wm-art__title wm-tk__title"},df={class:"wm-tk__sub"},ff={class:"wm-tk__ref"},hf={key:0,class:"wm-tk__text"},mf={key:0,class:"wm-art__body"},gf={class:"wm-art__fieldLabel"},pf=["data-level"],_f={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"},yf={key:1,class:"wm-art__footer wm-tk__footer"};function vf(e,t,n,r,i,s){return h(),p("div",lf,[u("div",cf,[u("div",uf,R(n.data.title),1),u("div",df,[u("div",ff,[t[0]||(t[0]=u("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"},[u("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"}),u("path",{d:"M13 5v2M13 17v2M13 11v2"})],-1)),u("span",null,R(n.data.reference),1)]),u("span",{class:te(["wm-art__badge","wm-tk__badge",`wm-art__badge--${n.data.status.tone||"neutral"}`])},[t[1]||(t[1]=u("span",{class:"wm-tk__dot","aria-hidden":"true"},null,-1)),ns(" "+R(n.data.status.label),1)],2)]),n.data.body?(h(),p("div",hf,R(n.data.body),1)):F("",!0)]),s.fields.length?(h(),p("div",mf,[(h(!0),p(Z,null,Se(s.fields,(o,a)=>(h(),p("div",{key:a,class:"wm-art__field"},[u("div",gf,R(o.label),1),u("div",{class:te(["wm-art__fieldValue",{"wm-art__fieldValue--multi":o.multiline}])},[s.isPriority(o.label)?(h(),p("svg",{key:0,class:"wm-tk__prio","data-level":s.priorityLevel(o.value),width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true"},[...t[2]||(t[2]=[u("rect",{x:"1",y:"8",width:"2",height:"3",rx:"0.5"},null,-1),u("rect",{x:"5",y:"5",width:"2",height:"6",rx:"0.5"},null,-1),u("rect",{x:"9",y:"2",width:"2",height:"9",rx:"0.5"},null,-1)])],8,pf)):s.isDate(o.label)?(h(),p("svg",_f,[...t[3]||(t[3]=[u("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"},null,-1),u("path",{d:"M16 2v4M8 2v4M3 10h18"},null,-1)])])):F("",!0),u("span",null,R(o.value),1)],2)]))),128))])):F("",!0),n.data.created_at?(h(),p("div",yf,[t[4]||(t[4]=u("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"},[u("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),u("path",{d:"M16 2v4M8 2v4M3 10h18"})],-1)),u("span",null,R(s.formattedDate),1)])):F("",!0)])}const bf=be(af,[["render",vf],["__scopeId","data-v-5f30c914"]]),wf={form_response:Wd,info_card:rf,ticket:bf},kf={name:"WmArtifactRenderer",props:{artifact:{type:Object,required:!0}},computed:{component(){var t;const e=(t=this.artifact)==null?void 0:t.kind;return e&&wf[e]||null}}};function Cf(e,t,n,r,i,s){return s.component?(h(),fe(qs(s.component),{key:0,data:n.artifact.data},null,8,["data"])):F("",!0)}const Sf=be(kf,[["render",Cf]]),Af={name:"WmAttachmentPreview",inject:{signAttachmentFn:{default:null},t:{default:()=>Ee()}},props:{attachment:{type:Object,required:!0}},data(){return{url:null,loading:!1}},computed:{kind(){var n,r;const e=(n=this.attachment)==null?void 0:n.type;if(e)return e;const t=(((r=this.attachment)==null?void 0:r.mime_type)||"").toLowerCase();return t.startsWith("image/")?"image":t.startsWith("audio/")?"audio":t.startsWith("video/")?"video":"file"},displayName(){var e,t,n;return((t=(e=this.attachment)==null?void 0:e.metadata)==null?void 0:t.name)||((n=this.attachment)==null?void 0:n.name)||this.guessNameFromPath()||this.t("attachment.fallbackName")},safeHref(){const e=String(this.url||"").trim();return/^(https?:\/\/|blob:|data:image\/)/i.test(e)?e:"#"},sizeLabel(){var t;const e=(t=this.attachment)==null?void 0:t.size_bytes;return e?e<1024?this.t("attachment.bytes",{size:e}):e<1024*1024?this.t("attachment.kilobytes",{size:(e/1024).toFixed(0)}):this.t("attachment.megabytes",{size:(e/(1024*1024)).toFixed(1)}):""}},watch:{"attachment.path":{handler(){this.refresh()},immediate:!0}},methods:{guessNameFromPath(){var n;return((((n=this.attachment)==null?void 0:n.path)||"").split("/").pop()||"").replace(/^[0-9a-f-]{8,}-/,"")},async refresh(){var e;if(!(!((e=this.attachment)!=null&&e.path)||!this.signAttachmentFn)){this.loading=!0;try{this.url=await this.signAttachmentFn(this.attachment.path)}finally{this.loading=!1}}},onFileClick(e){this.safeHref==="#"&&e.preventDefault()}}},xf=["href"],Tf=["src","alt"],Mf=["src"],Ef=["src"],Of=["href","download"],Rf={class:"wm-att__main"},If={class:"wm-att__name"},Lf={key:0,class:"wm-att__meta"},Pf={key:0,class:"wm-att__spin","aria-hidden":"true"};function Bf(e,t,n,r,i,s){return h(),p("div",{class:te(["wm-att",["wm-att--"+(s.kind||"file")]])},[s.kind==="image"&&i.url?(h(),p("a",{key:0,href:s.safeHref,target:"_blank",rel:"noopener",class:"wm-att__imgWrap"},[u("img",{src:i.url,alt:s.displayName,loading:"lazy"},null,8,Tf)],8,xf)):s.kind==="audio"&&i.url?(h(),p("audio",{key:1,src:i.url,controls:"",preload:"metadata"},null,8,Mf)):s.kind==="video"&&i.url?(h(),p("video",{key:2,src:i.url,controls:"",playsinline:"",preload:"auto"},null,8,Ef)):(h(),p("a",{key:3,class:"wm-att__file",href:s.safeHref,download:s.displayName,target:"_blank",rel:"noopener",onClick:t[0]||(t[0]=(...o)=>s.onFileClick&&s.onFileClick(...o))},[t[1]||(t[1]=u("span",{class:"wm-att__icon"},[u("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"},[u("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"}),u("path",{d:"M14 2v6h6"})])],-1)),u("span",Rf,[u("span",If,R(s.displayName),1),s.sizeLabel?(h(),p("span",Lf,R(s.sizeLabel),1)):F("",!0)]),i.loading?(h(),p("span",Pf)):F("",!0)],8,Of))],2)}const Ff=be(Af,[["render",Bf],["__scopeId","data-v-b207a8bd"]]),Df={name:"WmBubble",props:{role:{type:String,default:"ai"},text:{type:String,default:""}},computed:{rendered(){return Sc(this.text)}}},Nf=["innerHTML"];function Hf(e,t,n,r,i,s){return h(),p("div",{class:te(["wm-bubble","wm-bubble--"+n.role])},[Fa(e.$slots,"default",{},()=>[u("span",{innerHTML:s.rendered},null,8,Nf)])],2)}const Uf=be(Df,[["render",Hf],["__scopeId","data-v-7ab13147"]]),jf={name:"WmTyping"},Vf={class:"wm-typing"};function Kf(e,t,n,r,i,s){return h(),p("div",Vf,[...t[0]||(t[0]=[u("span",{style:{"animation-delay":"0s"}},null,-1),u("span",{style:{"animation-delay":"0.2s"}},null,-1),u("span",{style:{"animation-delay":"0.4s"}},null,-1)])])}const zf=be(jf,[["render",Kf],["__scopeId","data-v-df2447fd"]]);function Ot(e){return e?e.client_msg_id||e.id:""}const Wf={transferred_to_human:"system.transferredToHuman",assigned:"system.assigned",unassigned:"system.unassigned",resolved:"system.resolved",closed:"system.closed",reopened:"system.reopened",idle:"system.idle"},$f=80,qf=200,Gf={name:"WmMessageList",components:{AIAvatar:Sn,HumanAvatar:rs,Bubble:Uf,Typing:zf,ActionResult:Fd,AttachmentPreview:Ff,ArtifactRenderer:Sf},inject:{t:{default:()=>Ee()},wmLocale:{default:()=>()=>"fr"}},props:{messages:{type:Array,default:()=>[]},streamingActive:{type:Boolean,default:!1},dateLabel:{type:String,default:""},conversationId:{type:[String,Number],default:null},loadingMore:{type:Boolean,default:!1},hasMore:{type:Boolean,default:!1},unreadAnchorId:{type:Number,default:null},unreadBoundaryTs:{type:String,default:""},aiAgentName:{type:String,default:""},aiAgentAvatarUrl:{type:String,default:null}},emits:["load-more"],data(){return{silentFades:!1,widthByKey:Object.freeze({}),showScrollDown:!1,pressedItemKey:null}},computed:{historyExhausted(){return!this.hasMore&&!this.loadingMore&&this.messages.length>=20},groups(){var n,r,i,s,o;const e=[];for(const a of this.messages){if((n=a==null?void 0:a.metadata)!=null&&n.resolution_request)continue;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 m=e[e.length-1];m&&m.role==="ai"?m.messages.push(a):e.push({key:`g-${Ot(a)}`,role:"ai",agentName:"",agentAvatarUrl:null,messages:[a],items:[]});continue}e.push({key:`sys-${Ot(a)}`,role:l,messages:[a],items:[],systemLabel:this.systemLabel(a)});continue}const d=e[e.length-1];d&&d.role===l&&(l==="ai"||d.agentName===(((i=a==null?void 0:a.author)==null?void 0:i.name)||""))?d.messages.push(a):e.push({key:`g-${Ot(a)}`,role:l,agentName:((s=a==null?void 0:a.author)==null?void 0:s.name)||"",agentAvatarUrl:((o=a==null?void 0:a.author)==null?void 0:o.avatar_url)||null,messages:[a],items:[]})}for(const a of e){if(a.role==="system")continue;const l=[];for(const d of a.messages)for(const c of this.itemsOf(d))l.push(c);a.items=l}const t=[];for(const a of e){if(a.role!=="system"&&!a.items.length)continue;const l=t[t.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}t.push(a)}for(const a of t)a.role!=="system"&&(a.key=this.stableGroupKey(a.messages));return t},unreadGroupKey(){if(this.unreadAnchorId==null)return null;const e=this.unreadAnchorId,t=this.unreadBoundaryTs;for(const n of this.groups){if(n.role==="user"||n.role==="system"||!n.items.length)continue;const r=n.messages[0];if(!r)continue;const i=ht(r.id);if(i!=null&&!(i<=e)&&!(t&&r.created_at&&r.created_at>t))return n.key}return null}},watch:{messages:{handler:"snapshotAndRestore",deep:!0},conversationId(e,t){e!==t&&(this._groupIdByMsgKey=null,this.silentFades=!1)},loadingMore(e){e||(this._pendingLoadMore=!1),e&&(this.silentFades=!0),this.snapshotAndRestore()},streamingActive:"snapshotAndRestore"},mounted(){this._lastSeenConvId=this.conversationId,this.scrollToBottom(),this._measureFrame=null,this._ro=new ResizeObserver(()=>this.scheduleMeasure()),this.$refs.scrollEl&&this._ro.observe(this.$refs.scrollEl),this.$nextTick(()=>this.measureRows())},beforeUnmount(){var e;(e=this._ro)==null||e.disconnect(),this._measureFrame&&cancelAnimationFrame(this._measureFrame),this._pinFrame&&cancelAnimationFrame(this._pinFrame),this._pressTimer&&clearTimeout(this._pressTimer)},updated(){this.scheduleMeasure()},methods:{messageKey:Ot,stableGroupKey(e){this._groupIdByMsgKey||(this._groupIdByMsgKey=new Map,this._groupIdCounter=0);const t=this._groupIdByMsgKey;let n=null;for(const r of e){const i=Ot(r);if(i&&t.has(i)){n=t.get(i);break}}n==null&&(n=++this._groupIdCounter);for(const r of e){const i=Ot(r);i&&t.set(i,n)}return`g-${n}`},isAtBottom(e){return e.scrollHeight-e.scrollTop-e.clientHeight<=$f},onScroll(){const e=this.$refs.scrollEl;e&&(this.showScrollDown=!this.isAtBottom(e),!(this.loadingMore||!this.hasMore)&&(this._pendingLoadMore||e.scrollTop<=qf&&(this._pendingLoadMore=!0,this.$emit("load-more"))))},snapshotAndRestore(){const e=this.$refs.scrollEl;if(!e||this._scrollSnap)return;const t=this._lastSeenConvId!==this.conversationId;this._lastSeenConvId=this.conversationId;const n=this.isAtBottom(e);let r=null;if(!t&&!n){const s=this.pickAnchor(e);if(s!=null&&s.rowKey){const o=this.findRowByKey(e,s.rowKey);if(o){const a=e.getBoundingClientRect().top;r={rowKey:s.rowKey,relY:o.getBoundingClientRect().top-a}}}}const i={forceBottom:t,wasPinned:n,anchor:r};this._scrollSnap=i,this.$nextTick(()=>{if(this._scrollSnap=null,i.forceBottom||i.wasPinned){e.scrollTop=e.scrollHeight;return}if(!i.anchor)return;const s=()=>{const o=i.anchor,a=this.findRowByKey(e,o.rowKey);if(!a)return;const d=a.getBoundingClientRect().top-e.getBoundingClientRect().top-o.relY;Math.abs(d)>.5&&(e.scrollTop+=d)};s(),requestAnimationFrame(()=>{s(),requestAnimationFrame(s)})})},pickAnchor(e){const t=e.getBoundingClientRect().top,n=e.querySelectorAll(".wm-list__row[data-row-key]");let r=null;for(const i of n)if(r||(r=i),i.getBoundingClientRect().bottom>=t)return{rowKey:i.dataset.rowKey};return r?{rowKey:r.dataset.rowKey}:null},findRowByKey(e,t){if(!t)return null;const n=typeof CSS<"u"&&CSS.escape?CSS.escape(t):t.replace(/["\\]/g,"\\$&");return e.querySelector(`.wm-list__row[data-row-key="${n}"]`)},roleOf(e){var n,r;if((e==null?void 0:e.type)==="system"||((n=e==null?void 0:e.payload)==null?void 0:n.type)==="system")return"system";const t=(r=e==null?void 0:e.author)==null?void 0:r.type;return t==="user"?"user":t==="agent_human"?"human":"ai"},roleLabel(e){if(e.role==="human")return e.agentName||this.t("common.agent");const t=this.t("common.aiAssistant");return this.aiAgentName?`${this.aiAgentName} โข ${t}`:t},itemsOf(e){var t;if(!e)return[];if(e.type==="system"&&((t=e==null?void 0:e.payload)==null?void 0:t.event)==="action_admin_pending")return[{message:e,partKey:"main",renderAs:"admin-pending",kind:{top:"bubble",bottom:"bubble"}}];if(e.type==="action"&&e.payload&&e.payload.state!=="pending"){const n=[{message:e,partKey:"main",renderAs:"action",kind:{top:"bubble",bottom:"bubble"}}];return this.actionArtifact(e)&&n.push({message:e,partKey:"artifact",renderAs:"artifact-of-action",kind:{top:"card",bottom:"card"}}),n}return this.artifactOf(e)?[{message:e,partKey:"main",renderAs:"artifact",kind:{top:"card",bottom:"card"}}]:e.text_md||this.attachmentsOf(e).length?[{message:e,partKey:"main",renderAs:"bubble",kind:{top:"bubble",bottom:"bubble"}}]:[]},cornersFor(e,t){var V,re,ce;const n=e.items,r=(V=n[t])==null?void 0:V.kind,i=(re=n[t-1])==null?void 0:re.kind,s=(ce=n[t+1])==null?void 0:ce.kind,o=e.role==="user",a=14,l=4,d=i==null?void 0:i.bottom,c=s==null?void 0:s.top,m=this.widthByKey[this.rowKeyOf(e,t)],C=this.widthByKey[this.rowKeyOf(e,t-1)],b=this.widthByKey[this.rowKeyOf(e,t+1)],K=.5,S=(_e,we,G)=>_e!=null&&m!=null?_e+K>=m:we===G||we==="card"&&G==="bubble";let J=a,U=a,$=a,ne=a;return o?(d&&(U=l),(c||!s)&&($=l),d&&S(C,d,r==null?void 0:r.top)&&(J=l),c&&S(b,c,r==null?void 0:r.bottom)&&(ne=l)):(d&&(J=l),(c||!s)&&(ne=l),d&&S(C,d,r==null?void 0:r.top)&&(U=l),c&&S(b,c,r==null?void 0:r.bottom)&&($=l)),{tl:J,tr:U,br:$,bl:ne}},mosaicGridStyle(e){return!e||e<2?null:{"grid-template-columns":`repeat(${Math.min(e,4)}, 1fr)`}},mosaicCornerStyle(e,t,n){if(!t||t<2)return null;const r=Math.min(t,4),i=Math.floor(e/r),s=e%r,o=s>0,a=s<r-1&&e+1<t,l=i>0,d=e+r<t,c="4px",m={};return(o||l)&&(m["--wm-r-tl"]=c),(a||l)&&(m["--wm-r-tr"]=c),(o||d)&&(m["--wm-r-bl"]=c),(a||d)&&(m["--wm-r-br"]=c),n&&(m["--wm-r-tl"]=c,m["--wm-r-tr"]=c),Object.keys(m).length?m:null},cornersStyle(e,t){if(e.items.length<2)return null;const n=this.cornersFor(e,t);return{"--wm-r-tl":`${n.tl}px`,"--wm-r-tr":`${n.tr}px`,"--wm-r-br":`${n.br}px`,"--wm-r-bl":`${n.bl}px`}},rowKeyOf(e,t){var r;const n=(r=e==null?void 0:e.items)==null?void 0:r[t];return n?`${Ot(n.message)}-${n.partKey}`:""},scheduleMeasure(){this._measureFrame||(this._measureFrame=requestAnimationFrame(()=>{this._measureFrame=null,this.measureRows()}))},measureRows(){const e=this.$refs.scrollEl;if(!e)return;const t={};for(const s of e.querySelectorAll(".wm-list__row[data-row-key]")){const o=s.dataset.rowKey;if(!o)continue;const a=s.querySelector(".wm-bubble, .wm-result, .wm-art, .wm-list__body");if(!a)continue;const l=a.getBoundingClientRect().width;l>0&&(t[o]=l)}const n=this.widthByKey,r=Object.keys(n),i=Object.keys(t);if(r.length===i.length){let s=!0;for(const o of i)if(Math.abs((n[o]??0)-t[o])>.5){s=!1;break}if(s)return}this.widthByKey=Object.freeze(t)},onPressStart(e){this.onPressEnd(),this._pressTimer=setTimeout(()=>{this._pressTimer=null,this.pressedItemKey=e},400)},onPressEnd(){this._pressTimer&&(clearTimeout(this._pressTimer),this._pressTimer=null),this.pressedItemKey!==null&&(this.pressedItemKey=null)},timeOf(e){if(!(e!=null&&e.created_at))return"";try{return Bs(new Date(e.created_at),Bt(this.wmLocale()))}catch{return""}},lastTimeOf(e){const t=e.items[e.items.length-1],n=(t==null?void 0:t.message)||e.messages[e.messages.length-1];if(!(n!=null&&n.created_at))return"";try{return Bs(new Date(n.created_at),Bt(this.wmLocale()))}catch{return""}},hasTrailingOverlay(e){if(!e.messages.length)return!1;const t=e.messages[e.messages.length-1],n=e.items[e.items.length-1];return!!t&&(n==null?void 0:n.message)!==t},attachmentsOf(e){var n;const t=(n=e==null?void 0:e.payload)==null?void 0:n.attachments;return Array.isArray(t)?t:[]},artifactOf(e){var n;const t=(n=e==null?void 0:e.metadata)==null?void 0:n.artifact;return!t||typeof t!="object"||typeof t.kind!="string"?null:t},actionLabel(e){var t;return((t=e==null?void 0:e.payload)==null?void 0:t.name)||(e==null?void 0:e.text_md)||this.t("common.action")},actionDetail(e){var n,r,i,s,o,a,l,d;const t=e==null?void 0:e.payload;if(!t)return"";if(t.state==="success")return((n=t.success)==null?void 0:n.summary)||((i=(r=t.success)==null?void 0:r.metadata)==null?void 0:i.description)||"";if(t.state==="rejected"){if((s=t.rejected)!=null&&s.reason)return t.rejected.reason;const c=(a=(o=t.rejected)==null?void 0:o.metadata)==null?void 0:a.resolution,m=typeof c=="string"&&c.startsWith("admin")?"action.rejectedByAdmin":"action.rejectedByUser";return this.t(m)}return t.state==="failure"&&(((l=t.failure)==null?void 0:l.summary)||((d=t.failure)==null?void 0:d.error))||""},actionArtifact(e){var n,r;const t=(r=(n=e==null?void 0:e.payload)==null?void 0:n.success)==null?void 0:r.artifact;return!t||typeof t!="object"||typeof t.kind!="string"?null:t},systemLabel(e){var i,s,o;const t=(i=e==null?void 0:e.payload)==null?void 0:i.event,n=Wf[t],r=((s=e==null?void 0:e.metadata)==null?void 0:s.agent_name)||((o=e==null?void 0:e.author)==null?void 0:o.name)||this.t("messageList.anAgent");return n?this.t(n,{name:r}):(e==null?void 0:e.text_md)||this.t("messageList.conversationUpdate")},scrollToBottom(){const e=this.$refs.scrollEl;e&&(e.scrollTop=e.scrollHeight),this.showScrollDown=!1},keepPinnedToBottom(e=320){const t=this.$refs.scrollEl;if(!t)return;this._pinFrame&&cancelAnimationFrame(this._pinFrame);let n=null;const r=i=>{n===null&&(n=i),t.scrollTop=t.scrollHeight,i-n<e?this._pinFrame=requestAnimationFrame(r):this._pinFrame=null};this._pinFrame=requestAnimationFrame(r),this.showScrollDown=!1},scrollToBottomSmooth(){const e=this.$refs.scrollEl;e&&(typeof e.scrollTo=="function"?e.scrollTo({top:e.scrollHeight,behavior:"smooth"}):e.scrollTop=e.scrollHeight,this.showScrollDown=!1)}}},Yf={class:"wm-list__wrap"},Jf={key:0,class:"wm-list__loadMore",role:"status","aria-live":"polite"},Xf={class:"wm-list__loadMore-lbl"},Qf={key:1,class:"wm-list__historyEnd"},Zf={key:2,class:"wm-list__sep"},eh={class:"wm-list__sep-label"},th={key:0,class:"wm-list__sep wm-list__sep--unread"},nh={class:"wm-list__sep-label wm-list__sep-label--unread"},sh={key:0,class:"wm-list__sysep"},rh={class:"wm-list__sysep-label"},ih=["data-row-key","onPointerdown"],oh={key:0,class:"wm-list__avatarSlot"},ah={key:0},lh={key:1,"aria-hidden":"true"},ch={key:2},uh={key:0},dh={key:1,"aria-hidden":"true"},fh={key:2},hh={key:3,class:"wm-list__row wm-list__row--ai fade-up"},mh={class:"wm-list__avatarSlot"},gh=["aria-label","title"];function ph(e,t,n,r,i,s){const o=ve("AIAvatar"),a=ve("HumanAvatar"),l=ve("ActionResult"),d=ve("ArtifactRenderer"),c=ve("Bubble"),m=ve("AttachmentPreview"),C=ve("Typing");return h(),p("div",Yf,[u("div",{ref:"scrollEl",class:te(["wm-list",{"wm-list--silent":i.silentFades}]),onScrollPassive:t[4]||(t[4]=(...b)=>s.onScroll&&s.onScroll(...b))},[n.loadingMore?(h(),p("div",Jf,[t[6]||(t[6]=u("span",{class:"wm-list__loadMore-spinner","aria-hidden":"true"},null,-1)),u("span",Xf,R(s.t("messageList.loadingHistory")),1)])):s.historyExhausted?(h(),p("div",Qf,R(s.t("messageList.conversationStart")),1)):F("",!0),n.dateLabel?(h(),p("div",Zf,[t[7]||(t[7]=u("div",{class:"wm-list__line"},null,-1)),u("span",eh,R(n.dateLabel),1),t[8]||(t[8]=u("div",{class:"wm-list__line"},null,-1))])):F("",!0),(h(!0),p(Z,null,Se(s.groups,(b,K)=>(h(),p(Z,{key:b.key},[b.key===s.unreadGroupKey?(h(),p("div",th,[t[9]||(t[9]=u("div",{class:"wm-list__line wm-list__line--unread"},null,-1)),u("span",nh,R(s.t("messageList.unread")),1),t[10]||(t[10]=u("div",{class:"wm-list__line wm-list__line--unread"},null,-1))])):F("",!0),b.role==="system"||b.items.length?(h(),p("div",{key:1,class:te(["wm-list__group","wm-list__group--"+b.role])},[b.role==="system"?(h(),p("div",sh,[t[11]||(t[11]=u("div",{class:"wm-list__line wm-list__line--strong"},null,-1)),u("span",rh,R(b.systemLabel),1),t[12]||(t[12]=u("div",{class:"wm-list__line wm-list__line--strong"},null,-1))])):(h(),p(Z,{key:1},[(h(!0),p(Z,null,Se(b.items,(S,J)=>(h(),p(Z,{key:`${s.messageKey(S.message)}-${S.partKey}`},[u("div",{"data-row-key":`${s.messageKey(S.message)}-${S.partKey}`,class:te(["wm-list__row fade-up",["wm-list__row--"+b.role,{"is-pending":S.message._pending,"is-failed":S.message._failed}]]),style:Ce(s.cornersStyle(b,J)),onPointerdown:U=>s.onPressStart(`${s.messageKey(S.message)}-${S.partKey}`),onPointerup:t[0]||(t[0]=U=>s.onPressEnd()),onPointercancel:t[1]||(t[1]=U=>s.onPressEnd()),onPointerleave:t[2]||(t[2]=U=>s.onPressEnd()),onContextmenu:t[3]||(t[3]=We(()=>{},["prevent"]))},[b.role!=="user"?(h(),p("div",oh,[J===b.items.length-1?(h(),p(Z,{key:0},[b.role==="ai"?(h(),fe(o,{key:0,size:26,tail:!0,name:n.aiAgentName,"image-url":n.aiAgentAvatarUrl},null,8,["name","image-url"])):(h(),fe(a,{key:1,name:b.agentName,"avatar-url":b.agentAvatarUrl,size:26,tail:!0},null,8,["name","avatar-url"]))],64)):F("",!0)])):F("",!0),S.renderAs==="action"?(h(),fe(l,{key:1,state:S.message.payload.state,label:s.actionLabel(S.message),detail:s.actionDetail(S.message)},null,8,["state","label","detail"])):S.renderAs==="admin-pending"?(h(),fe(l,{key:2,state:"awaiting",label:s.t("messageList.approvalRequestSent"),detail:S.message.text_md||""},null,8,["label","detail"])):S.renderAs==="artifact-of-action"?(h(),fe(d,{key:3,artifact:s.actionArtifact(S.message)},null,8,["artifact"])):S.renderAs==="artifact"?(h(),fe(d,{key:4,artifact:s.artifactOf(S.message)},null,8,["artifact"])):(h(),p("div",{key:5,class:te(["wm-list__body",{"wm-list__body--mixed":!!S.message.text_md&&s.attachmentsOf(S.message).length>0}])},[S.message.text_md?(h(),fe(c,{key:0,role:b.role,text:S.message.text_md},null,8,["role","text"])):F("",!0),s.attachmentsOf(S.message).length?(h(),p("div",{key:1,class:te(["wm-list__atts",{"wm-list__atts--align-end":b.role==="user","wm-list__atts--mosaic":s.attachmentsOf(S.message).length>=2}]),style:Ce(s.mosaicGridStyle(s.attachmentsOf(S.message).length))},[(h(!0),p(Z,null,Se(s.attachmentsOf(S.message),(U,$)=>(h(),fe(m,{key:`${s.messageKey(S.message)}-att-${$}`,attachment:U,style:Ce(s.mosaicCornerStyle($,s.attachmentsOf(S.message).length,!!S.message.text_md))},null,8,["attachment","style"]))),128))],6)):F("",!0)],2))],46,ih),J<b.items.length-1&&i.pressedItemKey===`${s.messageKey(S.message)}-${S.partKey}`&&(b.role!=="user"||s.timeOf(S.message))?(h(),p("div",{key:0,class:te(["wm-list__meta wm-list__meta--press",{"wm-list__meta--right":b.role==="user"}])},[b.role!=="user"?(h(),p("span",ah,R(s.roleLabel(b)),1)):F("",!0),b.role!=="user"&&s.timeOf(S.message)?(h(),p("span",lh,"โข")):F("",!0),s.timeOf(S.message)?(h(),p("span",ch,R(s.timeOf(S.message)),1)):F("",!0)],2)):F("",!0)],64))),128)),(b.role!=="user"||s.lastTimeOf(b))&&!s.hasTrailingOverlay(b)?(h(),p("div",{key:0,class:te(["wm-list__meta",{"wm-list__meta--right":b.role==="user"}])},[b.role!=="user"?(h(),p("span",uh,R(s.roleLabel(b)),1)):F("",!0),b.role!=="user"&&s.lastTimeOf(b)?(h(),p("span",dh,"โข")):F("",!0),s.lastTimeOf(b)?(h(),p("span",fh,R(s.lastTimeOf(b)),1)):F("",!0)],2)):F("",!0)],64))],2)):F("",!0)],64))),128)),n.streamingActive?(h(),p("div",hh,[u("div",mh,[pe(o,{size:26,tail:!0,name:n.aiAgentName,"image-url":n.aiAgentAvatarUrl},null,8,["name","image-url"])]),pe(C)])):F("",!0)],34),pe(Qs,{name:"wm-scrollDown"},{default:Xn(()=>[i.showScrollDown?(h(),p("button",{key:0,type:"button",class:"wm-list__scrollDown","aria-label":s.t("messageList.scrollToBottom"),title:s.t("messageList.scrollToBottom"),onClick:t[5]||(t[5]=(...b)=>s.scrollToBottomSmooth&&s.scrollToBottomSmooth(...b))},[...t[13]||(t[13]=[u("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[u("path",{d:"M6 9l6 6 6-6"})],-1)])],8,gh)):F("",!0)]),_:1})])}const _h=be(Gf,[["render",ph],["__scopeId","data-v-1a6f0182"]]),jn=typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function",nr=typeof window<"u"&&typeof window.MediaRecorder<"u";function yh(){return nr&&["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm","video/mp4"].find(t=>{var n,r;return(r=(n=window.MediaRecorder).isTypeSupported)==null?void 0:r.call(n,t)})||""}function Eo({audio:e}){return{video:!0,audio:!!e,selfBrowserSurface:"include",surfaceSwitching:"include",systemAudio:e?"include":"exclude"}}async function vh(){if(!jn)return null;let e;try{e=await navigator.mediaDevices.getDisplayMedia(Eo({audio:!1}))}catch(t){return(t==null?void 0:t.name)!=="NotAllowedError"&&console.error("[media] screenshot picker",t),null}try{return await bh(e)}catch(t){return console.error("[media] screenshot capture",t),null}finally{e.getTracks().forEach(t=>{t.stop()})}}async function bh(e){const t=document.createElement("video");t.muted=!0,t.playsInline=!0,t.srcObject=e,await t.play(),await new Promise(a=>requestAnimationFrame(a));const n=t.videoWidth||1280,r=t.videoHeight||720,i=document.createElement("canvas");i.width=n,i.height=r,i.getContext("2d").drawImage(t,0,0,n,r);const s=await new Promise((a,l)=>{i.toBlob(d=>d?a(d):l(new Error("toBlob failed")),"image/png")}),o=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19);return new File([s],`capture-${o}.png`,{type:"image/png"})}async function wh(e={}){var d;if(!jn||!nr)return null;let t;try{t=await navigator.mediaDevices.getDisplayMedia(Eo({audio:!0}))}catch(c){return(c==null?void 0:c.name)!=="NotAllowedError"&&console.error("[media] record picker",c),null}const n=yh();let r;try{r=n?new window.MediaRecorder(t,{mimeType:n}):new window.MediaRecorder(t)}catch(c){return console.error("[media] recorder init",c),t.getTracks().forEach(m=>{m.stop()}),null}const i=[];let s=null,o=!1;r.addEventListener("dataavailable",c=>{c.data&&c.data.size>0&&i.push(c.data)}),r.addEventListener("stop",()=>{var c,m;if(s&&clearInterval(s),t.getTracks().forEach(C=>{C.stop()}),i.length){const C=r.mimeType||n||"video/webm",b=new Blob(i,{type:C}),K=/mp4/.test(C)?"mp4":"webm",S=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),J=new File([b],`ecran-${S}.${K}`,{type:C});(c=e.onfinalize)==null||c.call(e,J)}else(m=e.oncancel)==null||m.call(e)}),t.getVideoTracks().forEach(c=>{c.addEventListener("ended",()=>a(),{once:!0})});function a(){if(!o&&(o=!0,r.state!=="inactive"))try{r.stop()}catch(c){console.error("[media] recorder stop",c)}}try{r.start(1e3)}catch(c){return console.error("[media] recorder start",c),t.getTracks().forEach(m=>{m.stop()}),null}(d=e.onstart)==null||d.call(e);const l=Date.now();return s=setInterval(()=>{var c;(c=e.ontick)==null||c.call(e,Date.now()-l)},500),{stop:a,get state(){return r.state}}}const kh=[{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"}],Ch={name:"WmComposer",inject:{t:{default:()=>Ee()}},props:{modelValue:{type:String,default:""},placeholder:{type:String,default:"รcrivez votre messageโฆ"},disabled:{type:Boolean,default:!1},attachLabel:{type:String,default:"Joindre"},displayMode:{type:String,default:"floating"}},emits:["update:modelValue","send","attach","focus","blur"],data(){return{local:this.modelValue,focused:!1,attachOpen:!1,recording:!1,recordingElapsed:0,recorder:null,kbOffset:0}},computed:{canSend(){return!this.disabled&&!!this.local.trim()},expanded(){return this.focused||!!this.local.trim()||this.attachOpen||this.recording},attachItems(){return kh.map(e=>({...e,label:this.t(e.labelKey),disabled:e.action==="screenshot"&&!jn||e.action==="record"&&(!jn||!nr)}))},recordingElapsedLabel(){const e=Math.floor(this.recordingElapsed/1e3),t=Math.floor(e/60),n=e%60;return`${t}:${n.toString().padStart(2,"0")}`}},watch:{modelValue(e){e!==this.local&&(this.local=e,this.$nextTick(()=>this.autosize()))},local(e){this.$emit("update:modelValue",e)}},mounted(){this.autosize(),this.displayMode==="sheet"&&this.setupKeyboardTracking()},beforeUnmount(){if(this.recorder)try{this.recorder.stop()}catch{}this.teardownKeyboardTracking()},methods:{focus(){const e=this.$refs.inputEl;if(!(!e||this.disabled))try{e.focus({preventScroll:!0})}catch{e.focus()}},onFocus(){this.focused=!0,this.$emit("focus"),this.$nextTick(()=>this.autosize())},onBlur(){this.focused=!1,this.$emit("blur"),this.$nextTick(()=>this.autosize())},onSubmit(){if(!this.canSend)return;const e=this.local.trim();this.local="",this.$emit("send",e),this.$nextTick(()=>this.autosize())},onKeydown(e){e.key==="Enter"&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.isComposing&&(e.preventDefault(),this.onSubmit())},autosize(){const e=this.$refs.inputEl;if(!e||e.clientWidth<80)return;e.style.height="auto",e.style.minHeight="0px";const t=e.scrollHeight;e.style.minHeight="",e.style.height=t>62?`${Math.min(t,120)}px`:""},onFile(e){const t=Array.from(e.target.files||[]);for(const n of t)this.$emit("attach",n);e.target.value=""},onAttachAction(e){this.attachOpen=!1,e==="file"?this.pickFile():e==="screenshot"?this.captureScreenshot():e==="record"&&this.startRecording()},pickFile(){var e;(e=this.$refs.fileEl)==null||e.click()},async captureScreenshot(){if(this.disabled)return;const e=await vh();e&&this.$emit("attach",e)},async startRecording(){if(this.recording||this.disabled)return;this.recordingElapsed=0;const e=await wh({onstart:()=>{this.recording=!0},ontick:t=>{this.recordingElapsed=t},onfinalize:t=>{this.$emit("attach",t),this.recording=!1,this.recordingElapsed=0,this.recorder=null},oncancel:()=>{this.recording=!1,this.recordingElapsed=0,this.recorder=null}});e&&(this.recorder=e)},stopRecording(){if(this.recorder)try{this.recorder.stop()}catch(e){console.error("[composer] stop recording",e)}},setupKeyboardTracking(){const e=window.visualViewport;e&&(this._vvHandler=()=>{const t=Math.max(0,window.innerHeight-e.height-e.offsetTop);this.kbOffset=t},e.addEventListener("resize",this._vvHandler),e.addEventListener("scroll",this._vvHandler))},teardownKeyboardTracking(){const e=window.visualViewport;!e||!this._vvHandler||(e.removeEventListener("resize",this._vvHandler),e.removeEventListener("scroll",this._vvHandler),this._vvHandler=null)}}},Sh={key:0,class:"wm-rec"},Ah={class:"wm-rec__lbl"},xh={key:1,class:"wm-compose__menu",role:"menu"},Th=["disabled","onClick"],Mh={class:"wm-compose__menuIcon"},Eh={viewBox:"0 0 24 24",width:"14",height:"14","aria-hidden":"true"},Oh=["d"],Rh=["placeholder","disabled"],Ih={class:"wm-compose__actions"},Lh=["title","aria-label","disabled"],Ph=["disabled","aria-label"];function Bh(e,t,n,r,i,s){return h(),p("div",{class:te(["wm-compose-wrap",{"wm-compose-wrap--sheet":n.displayMode==="sheet"}]),style:Ce(i.kbOffset?{transform:`translateY(-${i.kbOffset}px)`}:null)},[i.recording?(h(),p("div",Sh,[t[11]||(t[11]=u("span",{class:"wm-rec__dot","aria-hidden":"true"},null,-1)),u("span",Ah,R(s.t("composer.recording",{time:s.recordingElapsedLabel})),1),u("button",{type:"button",class:"wm-rec__stop",onClick:t[0]||(t[0]=(...o)=>s.stopRecording&&s.stopRecording(...o))},R(s.t("composer.stop")),1)])):F("",!0),u("form",{class:te(["wm-compose",{"has-attach":i.attachOpen,"is-expanded":s.expanded}]),onSubmit:t[10]||(t[10]=We((...o)=>s.onSubmit&&s.onSubmit(...o),["prevent"]))},[u("input",{ref:"fileEl",type:"file",hidden:"",multiple:"",onChange:t[1]||(t[1]=(...o)=>s.onFile&&s.onFile(...o))},null,544),i.attachOpen?(h(),p("div",{key:0,class:"wm-compose__overlay",onClick:t[2]||(t[2]=o=>i.attachOpen=!1)})):F("",!0),i.attachOpen?(h(),p("div",xh,[(h(!0),p(Z,null,Se(s.attachItems,o=>(h(),p("button",{key:o.action,type:"button",class:"wm-compose__menuItem",disabled:o.disabled,onClick:a=>s.onAttachAction(o.action)},[u("span",Mh,[(h(),p("svg",Eh,[u("path",{d:o.path,stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round",fill:"none"},null,8,Oh)]))]),u("span",null,R(o.label),1)],8,Th))),128))])):F("",!0),st(u("textarea",{ref:"inputEl","onUpdate:modelValue":t[3]||(t[3]=o=>i.local=o),class:"wm-compose__input",rows:"1",placeholder:n.placeholder,disabled:n.disabled,onKeydown:t[4]||(t[4]=(...o)=>s.onKeydown&&s.onKeydown(...o)),onInput:t[5]||(t[5]=(...o)=>s.autosize&&s.autosize(...o)),onFocus:t[6]||(t[6]=(...o)=>s.onFocus&&s.onFocus(...o)),onBlur:t[7]||(t[7]=(...o)=>s.onBlur&&s.onBlur(...o))},null,40,Rh),[[kt,i.local]]),u("div",Ih,[u("button",{type:"button",class:te(["wm-compose__icon",{"is-open":i.attachOpen}]),title:n.attachLabel,"aria-label":n.attachLabel,disabled:i.recording,onMousedown:t[8]||(t[8]=We(()=>{},["prevent"])),onClick:t[9]||(t[9]=o=>i.attachOpen=!i.attachOpen)},[...t[12]||(t[12]=[u("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"},[u("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)])],42,Lh),u("button",{type:"submit",class:te(["wm-compose__send",{"is-empty":!s.canSend}]),disabled:!s.canSend,"aria-label":s.t("composer.send")},[...t[13]||(t[13]=[u("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[u("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})],-1)])],10,Ph)])],34)],6)}const Fh=be(Ch,[["render",Bh],["__scopeId","data-v-a9738520"]]),Dh={name:"WmInlineCallbacks",props:{items:{type:Array,default:()=>[]},variant:{type:String,default:"chips",validator:e=>e==="chips"||e==="buttons"},baseDelay:{type:Number,default:360},stepDelay:{type:Number,default:90}},emits:["select"],computed:{batchKey(){return this.items.map(e=>(e==null?void 0:e.label)||(e==null?void 0:e.text)||"").join("ยง")},headerTitle(){if(this.variant!=="buttons")return"";const e=this.items.find(t=>typeof(t==null?void 0:t.title)=="string"&&t.title.trim());return e?e.title.trim():""}},methods:{btnClass(e){return this.variant==="chips"?"wm-icb__btn--chip":["wm-icb__btn--action",`wm-icb__btn--${(e==null?void 0:e.style)||"neutral"}`]}}},Nh=["onClick"],Hh={key:0,class:"wm-icb__title"},Uh={class:"wm-icb__row"},jh=["onClick"];function Vh(e,t,n,r,i,s){return n.items.length?(h(),p("div",{key:s.batchKey,class:te(["wm-icb",`wm-icb--${n.variant}`])},[n.variant==="chips"?(h(!0),p(Z,{key:0},Se(n.items,(o,a)=>(h(),p("button",{key:o.id!=null?o.id:a,type:"button",class:"wm-icb__btn wm-icb__btn--chip",style:Ce({animationDelay:n.baseDelay+a*n.stepDelay+"ms"}),onClick:l=>e.$emit("select",o)},R(o.label),13,Nh))),128)):(h(),p(Z,{key:1},[s.headerTitle?(h(),p("div",Hh,R(s.headerTitle),1)):F("",!0),u("div",Uh,[(h(!0),p(Z,null,Se(n.items,(o,a)=>(h(),p("button",{key:o.id!=null?o.id:a,type:"button",class:te(["wm-icb__btn",s.btnClass(o)]),onClick:l=>e.$emit("select",o)},R(o.label),11,jh))),128))])],64))],2)):F("",!0)}const Kh=be(Dh,[["render",Vh],["__scopeId","data-v-c8cc8cbf"]]);let ei=0;const zh=new Set(["text","textarea","number","boolean","select","multiselect","date"]),Wh={name:"WmFormCard",components:{AIAvatar:Sn},inject:{t:{default:()=>Ee()}},props:{form:{type:Object,required:!0},readOnly:{type:Boolean,default:!1},initialValues:{type:Object,default:null},agentName:{type:String,default:""},agentAvatarUrl:{type:String,default:null}},emits:["submit"],data(){return ei+=1,{_uid:ei,values:{},busy:!1,error:""}},computed:{normalizedFields(){var t;return(Array.isArray((t=this.form)==null?void 0:t.fields)?this.form.fields:[]).filter(n=>!(!(n!=null&&n.key)||!(n!=null&&n.label)||!zh.has(n==null?void 0:n.type)||(n.type==="select"||n.type==="multiselect")&&(!Array.isArray(n.options)||n.options.length===0)))}},created(){this.resetValues()},methods:{resetValues(){const e=this.initialValues&&typeof this.initialValues=="object"?this.initialValues:{},t={};for(const n of this.normalizedFields){if(e[n.key]!==void 0){t[n.key]=e[n.key];continue}n.type==="boolean"?t[n.key]=!1:n.type==="multiselect"?t[n.key]=[]:t[n.key]=""}this.values=t,this.error=""},toggleMulti(e,t,n){const r=Array.isArray(this.values[e])?this.values[e].slice():[],i=r.indexOf(t);n&&i===-1?r.push(t):!n&&i!==-1&&r.splice(i,1),this.values={...this.values,[e]:r}},validate(){for(const e of this.normalizedFields){if(!e.required)continue;const t=this.values[e.key];if(e.type!=="boolean"){if(e.type==="multiselect"){if(!Array.isArray(t)||t.length===0)return this.t("form.fieldRequired",{label:e.label});continue}if(t==null||t==="")return this.t("form.fieldRequired",{label:e.label})}}return""},async onSubmit(){if(this.readOnly||this.busy)return;const e=this.validate();if(e){this.error=e;return}this.error="",this.busy=!0;try{await this.$emit("submit",{values:this.values})}finally{this.busy=!1}}}},$h={class:"wm-form"},qh={class:"wm-form__head"},Gh={class:"wm-form__icon"},Yh={class:"wm-form__main"},Jh={class:"wm-form__title"},Xh={key:0,class:"wm-form__detail"},Qh=["for"],Zh={key:0,class:"wm-form__req","aria-hidden":"true"},em=["id","onUpdate:modelValue","placeholder","required","disabled"],tm=["id","onUpdate:modelValue","placeholder","required","disabled"],nm=["id","onUpdate:modelValue","placeholder","required","disabled"],sm=["id","onUpdate:modelValue","required","disabled"],rm={key:4,class:"wm-form__bool"},im=["id","onUpdate:modelValue","disabled"],om=["id","onUpdate:modelValue","required","disabled"],am={value:"",disabled:""},lm=["value"],cm={key:6,class:"wm-form__multi"},um=["value","checked","disabled","onChange"],dm={key:0,class:"wm-form__err"},fm=["disabled"],hm={key:0,class:"wm-form__spinner","aria-hidden":"true"},mm={key:2,class:"wm-form__doneLbl"};function gm(e,t,n,r,i,s){const o=ve("AIAvatar");return h(),p("div",$h,[u("div",qh,[u("div",Gh,[pe(o,{size:24,name:n.agentName,"image-url":n.agentAvatarUrl},null,8,["name","image-url"])]),u("div",Yh,[u("div",Jh,R(n.form.title||s.t("form.title")),1),n.form.description?(h(),p("div",Xh,R(n.form.description),1)):F("",!0)])]),u("form",{class:"wm-form__body",onSubmit:t[0]||(t[0]=We((...a)=>s.onSubmit&&s.onSubmit(...a),["prevent"]))},[(h(!0),p(Z,null,Se(s.normalizedFields,a=>(h(),p("div",{key:a.key,class:"wm-form__field"},[u("label",{for:`wm-f-${i._uid}-${a.key}`,class:"wm-form__label"},[ns(R(a.label),1),a.required?(h(),p("span",Zh,"*")):F("",!0)],8,Qh),a.type==="text"?st((h(),p("input",{key:0,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,type:"text",class:"wm-form__input",placeholder:a.placeholder||"",required:a.required,disabled:n.readOnly||i.busy},null,8,em)),[[kt,i.values[a.key]]]):a.type==="textarea"?st((h(),p("textarea",{key:1,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,class:"wm-form__textarea",rows:"3",placeholder:a.placeholder||"",required:a.required,disabled:n.readOnly||i.busy},null,8,tm)),[[kt,i.values[a.key]]]):a.type==="number"?st((h(),p("input",{key:2,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,type:"number",class:"wm-form__input",placeholder:a.placeholder||"",required:a.required,disabled:n.readOnly||i.busy},null,8,nm)),[[kt,i.values[a.key],void 0,{number:!0}]]):a.type==="date"?st((h(),p("input",{key:3,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,type:"date",class:"wm-form__input",required:a.required,disabled:n.readOnly||i.busy},null,8,sm)),[[kt,i.values[a.key]]]):a.type==="boolean"?(h(),p("label",rm,[st(u("input",{id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,type:"checkbox",disabled:n.readOnly||i.busy},null,8,im),[[Jl,i.values[a.key]]]),u("span",null,R(a.placeholder||s.t("common.yes")),1)])):a.type==="select"?st((h(),p("select",{key:5,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,class:"wm-form__select",required:a.required,disabled:n.readOnly||i.busy},[u("option",am,R(a.placeholder||s.t("form.choose")),1),(h(!0),p(Z,null,Se(a.options,l=>(h(),p("option",{key:l.value,value:l.value},R(l.label),9,lm))),128))],8,om)),[[Xl,i.values[a.key]]]):a.type==="multiselect"?(h(),p("div",cm,[(h(!0),p(Z,null,Se(a.options,l=>(h(),p("label",{key:l.value,class:"wm-form__multiItem"},[u("input",{type:"checkbox",value:l.value,checked:Array.isArray(i.values[a.key])&&i.values[a.key].includes(l.value),disabled:n.readOnly||i.busy,onChange:d=>s.toggleMulti(a.key,l.value,d.target.checked)},null,40,um),u("span",null,R(l.label),1)]))),128))])):F("",!0)]))),128)),i.error?(h(),p("div",dm,R(i.error),1)):F("",!0),n.readOnly?(h(),p("div",mm,R(s.t("form.responseSent")),1)):(h(),p("button",{key:1,type:"submit",class:"wm-form__submit",disabled:i.busy},[i.busy?(h(),p("span",hm)):F("",!0),u("span",null,R(i.busy?s.t("common.sending"):n.form.submit_label||s.t("common.send")),1)],8,fm))],32)])}const pm=be(Wh,[["render",gm],["__scopeId","data-v-fe65cc56"]]),_m={name:"WmFeedback",inject:{t:{default:()=>Ee()}},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})}}},ym={class:"wm-fb"},vm={class:"wm-fb__title"},bm={class:"wm-fb__sub"},wm={class:"wm-fb__row"},km=["onClick"],Cm={class:"wm-fb__emoji"},Sm={class:"wm-fb__label"},Am=["disabled"],xm={key:1,class:"wm-fb__done"},Tm={class:"wm-fb__doneTitle"},Mm={class:"wm-fb__doneSub"};function Em(e,t,n,r,i,s){return h(),p("div",ym,[n.done?(h(),p("div",xm,[t[1]||(t[1]=u("div",{class:"wm-fb__check"},[u("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"},[u("path",{d:"M20 6L9 17l-5-5"})])],-1)),u("div",Tm,R(s.t("feedback.doneTitle")),1),u("div",Mm,R(s.t("feedback.doneSubtitle")),1)])):(h(),p(Z,{key:0},[u("div",vm,R(s.t("feedback.question")),1),u("div",bm,R(s.t("feedback.subtitle")),1),u("div",wm,[(h(!0),p(Z,null,Se(s.options,o=>(h(),p("button",{key:o.v,type:"button",class:te(["wm-fb__opt",{"is-selected":i.sel===o.v}]),onClick:a=>i.sel=o.v},[u("span",Cm,R(o.e),1),u("span",Sm,R(o.l),1)],10,km))),128))]),u("button",{type:"button",class:"wm-fb__send",disabled:!i.sel||n.busy,onClick:t[0]||(t[0]=(...o)=>s.onSend&&s.onSend(...o))},R(n.busy?s.t("common.sending"):s.t("feedback.submit")),9,Am)],64))])}const Om=be(_m,[["render",Em],["__scopeId","data-v-9b630564"]]),Rm={name:"WmMoreMenu",inject:{t:{default:()=>Ee()}},props:{canRename:{type:Boolean,default:!0},canExport:{type:Boolean,default:!0},soundEnabled:{type:Boolean,default:!0},statusUrl:{type:String,default:""},helpUrl:{type:String,default:""}},emits:["close","action","sound-toggle"],data(){return{soundOn:this.soundEnabled}},watch:{soundEnabled(e){this.soundOn=!!e}},methods:{emit(e){this.$emit("action",e)},toggleSound(){this.soundOn=!this.soundOn,this.$emit("sound-toggle",this.soundOn)}}},Im={class:"wm-mm"},Lm={class:"wm-mm__pop",role:"menu"},Pm={key:0,class:"wm-mm__section"},Bm={class:"wm-mm__label"},Fm={class:"wm-mm__label"},Dm={key:1,class:"wm-mm__sep"},Nm={class:"wm-mm__section"},Hm={class:"wm-mm__label"},Um={class:"wm-mm__section"},jm={class:"wm-mm__label"},Vm={class:"wm-mm__label"};function Km(e,t,n,r,i,s){return h(),p("div",Im,[u("div",{class:"wm-mm__scrim",onClick:t[0]||(t[0]=o=>e.$emit("close"))}),u("div",Lm,[n.canRename||n.canExport?(h(),p("div",Pm,[n.canRename?(h(),p("button",{key:0,type:"button",class:"wm-mm__item",onClick:t[1]||(t[1]=o=>s.emit("rename"))},[t[6]||(t[6]=u("span",{class:"wm-mm__icon"},[u("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"},[u("path",{d:"M12 20h9"}),u("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})])],-1)),u("span",Bm,R(s.t("moreMenu.editTitle")),1)])):F("",!0),n.canExport?(h(),p("button",{key:1,type:"button",class:"wm-mm__item",onClick:t[2]||(t[2]=o=>s.emit("export"))},[t[7]||(t[7]=u("span",{class:"wm-mm__icon"},[u("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"},[u("path",{d:"M4 12v8a2 2 0 002 2h12a2 2 0 002-2v-8M16 6l-4-4-4 4M12 2v13"})])],-1)),u("span",Fm,R(s.t("moreMenu.exportTranscript")),1),t[8]||(t[8]=u("span",{class:"wm-mm__hint"},".txt",-1))])):F("",!0)])):F("",!0),n.canRename||n.canExport?(h(),p("div",Dm)):F("",!0),u("div",Nm,[u("button",{type:"button",class:"wm-mm__item",onClick:t[3]||(t[3]=(...o)=>s.toggleSound&&s.toggleSound(...o))},[t[10]||(t[10]=u("span",{class:"wm-mm__icon"},[u("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"},[u("path",{d:"M11 5L6 9H2v6h4l5 4V5z"}),u("path",{d:"M15.54 8.46a5 5 0 010 7.07M19.07 4.93a10 10 0 010 14.14"})])],-1)),u("span",Hm,R(s.t("moreMenu.sound")),1),u("span",{class:te(["wm-mm__toggle",{"wm-mm__toggle--on":i.soundOn}])},[...t[9]||(t[9]=[u("span",{class:"wm-mm__knob"},null,-1)])],2)])]),t[13]||(t[13]=u("div",{class:"wm-mm__sep"},null,-1)),u("div",Um,[n.statusUrl?(h(),p("button",{key:0,type:"button",class:"wm-mm__item",onClick:t[4]||(t[4]=o=>s.emit("status"))},[t[11]||(t[11]=u("span",{class:"wm-mm__icon"},[u("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"},[u("path",{d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zM10 6v4l3 2"})])],-1)),u("span",jm,R(s.t("moreMenu.serviceStatus")),1)])):F("",!0),n.helpUrl?(h(),p("button",{key:1,type:"button",class:"wm-mm__item",onClick:t[5]||(t[5]=o=>s.emit("help"))},[t[12]||(t[12]=u("span",{class:"wm-mm__icon"},[u("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"},[u("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)),u("span",Vm,R(s.t("moreMenu.helpCenter")),1)])):F("",!0)])])])}const zm=be(Rm,[["render",Km],["__scopeId","data-v-4cf6d578"]]),Wm={name:"WmRenameDialog",inject:{t:{default:()=>Ee()}},props:{title:{type:String,default:""},initialValue:{type:String,default:""},placeholder:{type:String,default:""}},emits:["close","submit"],data(){return{value:this.initialValue||""}},computed:{canSubmit(){const e=(this.value||"").trim();return!!e&&e!==(this.initialValue||"").trim()}},mounted(){this.$nextTick(()=>{const e=this.$refs.input;if(e){e.focus();try{e.select()}catch{}}})},methods:{onSubmit(){this.canSubmit&&this.$emit("submit",this.value.trim())}}},$m={class:"wm-dialog"},qm={class:"wm-dialog__card",role:"dialog","aria-modal":"true"},Gm={class:"wm-dialog__head"},Ym={class:"wm-dialog__title"},Jm=["aria-label"],Xm={class:"wm-dialog__body"},Qm=["placeholder"],Zm={class:"wm-dialog__actions"},eg=["disabled"];function tg(e,t,n,r,i,s){return h(),p("div",$m,[u("div",{class:"wm-dialog__scrim",onClick:t[0]||(t[0]=o=>e.$emit("close"))}),u("div",qm,[u("div",Gm,[u("div",Ym,R(n.title||s.t("rename.title")),1),u("button",{type:"button",class:"wm-dialog__close","aria-label":s.t("common.close"),onClick:t[1]||(t[1]=o=>e.$emit("close"))},[...t[7]||(t[7]=[u("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"},[u("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,Jm)]),u("div",Xm,[st(u("input",{ref:"input","onUpdate:modelValue":t[2]||(t[2]=o=>i.value=o),type:"text",class:"wm-dialog__input",placeholder:n.placeholder||s.t("rename.placeholder"),maxlength:120,onKeydown:[t[3]||(t[3]=Un(We((...o)=>s.onSubmit&&s.onSubmit(...o),["prevent"]),["enter"])),t[4]||(t[4]=Un(We(o=>e.$emit("close"),["prevent"]),["esc"]))]},null,40,Qm),[[kt,i.value]])]),u("div",Zm,[u("button",{type:"button",class:"wm-dialog__btn",onClick:t[5]||(t[5]=o=>e.$emit("close"))},R(s.t("common.cancel")),1),u("button",{type:"button",class:"wm-dialog__btn wm-dialog__btn--primary",disabled:!s.canSubmit,onClick:t[6]||(t[6]=(...o)=>s.onSubmit&&s.onSubmit(...o))},R(s.t("common.save")),9,eg)])])])}const ng=be(Wm,[["render",tg],["__scopeId","data-v-6d5f94a8"]]),ti="ww-messenger-tokens",sg={name:"Messenger",components:{Launcher:Qc,Header:Cu,Onboarding:ld,History:Sd,MessageList:_h,Composer:Fh,InlineCallbacks:Kh,FormCard:pm,Feedback:Om,MoreMenu:zm,RenameDialog:ng},mixins:[Ec,Oc,Ic],provide(){return{signAttachmentFn:e=>{var t,n;return((n=(t=this.store)==null?void 0:t.signAttachment)==null?void 0:n.call(t,e))||null},t:(e,t)=>this.t(e,t),wmLocale:()=>this.locale}},props:{baseUrl:{type:String,default:pc},widgetId:{type:String,default:""},context:{type:Object,default:null},displayMode:{type:String,default:"floating"},devtools:{type:Boolean,default:!1},language:{type:String,default:""}},data(){return{transport:null,store:null,isOpen:!1,launcherHovered:!1,draft:"",busy:!1,bootError:null,pendingAttachments:[],feedbackBusy:!1,feedbackDone:{},convOpenedAt:0,moreOpen:!1,renameDialogOpen:!1,draftConv:null,launching:!1,launchStage:"idle",pendingLaunchText:"",reopenedLocally:{},activeConvId:null,showOnboarding:!1,showHistory:!1,backToHistory:!1,welcomeRevealedAt:{},welcomeRevealTimers:{},dismissedPeeks:{},floatHeight:0,floatRO:null,parentOrigin:"",parentToken:"",parentVariables:null,parentAllowUnauthenticated:!1,parentInitReceived:!1,parentInitDeferred:null}},computed:{isEditor(){return!!this.devtools},isEmbedded(){return this.displayMode==="embedded"},customerLanguage(){var n,r,i,s;const e=(n=this.s)==null?void 0:n.customer,t=e&&(e.language||((r=e.values)==null?void 0:r.language));return t||((s=(i=this.context)==null?void 0:i.customer)==null?void 0:s.language)||""},locale(){var e;return tr(this.language||this.customerLanguage||((e=this.widget)==null?void 0:e.default_language)||"")},translator(){return Ee(this.locale)},error(){var e;return this.bootError||((e=this.s)==null?void 0:e.error)||null},canBoot(){return!!(this.baseUrl&&this.widgetId)},s(){var e;return((e=this.store)==null?void 0:e.state)||null},ready(){var e;return!!((e=this.s)!=null&&e.ready)},allConversations(){var t;const e=(t=this.s)==null?void 0:t.conversations;return Array.isArray(e)?e:[]},drawerConversations(){var n;const e=((n=this.s)==null?void 0:n.messagesByConv)||{},t=this.revealedAt;return this.allConversations.map(r=>{var d;const i=e[r.id]||[],s=ht(r.last_read_message_id);let o=0,a=null;for(let c=i.length-1;c>=0;c--){const m=i[c];if(!m)continue;if(((d=m.author)==null?void 0:d.type)==="user")break;const C=ht(m.id);if(C!=null){if(s!=null&&C<=s)break;t[m.id]!==0&&(!a&&m.author&&(a=m.author),o++)}}if(!i.length){const c=ht(r.last_message_id);c!=null&&(s==null||c>s)&&(o=1,a=r.last_message_author||null)}const l=i.filter(c=>!((c==null?void 0:c.id)!=null&&t[c.id]===0));return{...r,_preview:Ac(r,l),_unread:o>0,_unreadCount:o,_lastAuthor:a}})},unreadCount(){return this.drawerConversations.filter(e=>e._unread).length},openThreads(){var t;const e=((t=this.s)==null?void 0:t.messagesByConv)||{};return this.drawerConversations.filter(n=>{const r=this.convStatus(n);return r!=="resolved"&&r!=="closed"}).map(n=>({id:n.id,title:n.name||this.t("common.newConversation"),preview:n._preview||this.t("onboarding.newMessage"),unread:!!n._unread,author:n._lastAuthor||null,_ts:Qr(n,e[n.id]||[])})).sort((n,r)=>n._ts<r._ts?1:n._ts>r._ts?-1:0)},latestUnreads(){var n;const e=((n=this.s)==null?void 0:n.messagesByConv)||{},t=[];for(const r of this.drawerConversations){if(!r._unread)continue;const i=Qr(r,e[r.id]||[]),s=r._lastAuthor,o=!s||s.type==="agent_ia",a=(s==null?void 0:s.name)||(o?this.agentName:"")||"",l=(s==null?void 0:s.avatar_url)||(o?this.agentAvatarUrl:null);t.push({convId:r.id,preview:r._preview||this.t("notification.youHaveNewMessage"),ts:i,count:r._unreadCount||1,senderName:a,senderAvatarUrl:l})}return t.sort((r,i)=>r.ts<i.ts?1:r.ts>i.ts?-1:0),t},launcherPeeks(){if(this.isOpen||this.isEmbedded)return[];const e=this.dismissedPeeks||{};return this.latestUnreads.filter(t=>e[t.convId]!==t.ts)},isViewingThread(){return(this.isOpen||this.isEmbedded)&&!!this.currentConv},currentConv(){if(this.draftConv)return this.draftConv;if(this.showOnboarding||this.showHistory)return null;const e=this.allConversations;if(!e.length)return null;if(this.activeConvId!=null){const t=e.find(n=>n.id===this.activeConvId);if(t)return t}return e[0]||null},canBack(){return!!this.currentConv||this.showHistory},statusUrl(){var n;const e=(n=this.widget)==null?void 0:n.quick_links;if(!Array.isArray(e))return"";const t=e.find(r=>r.icon==="status"&&r.url);return(t==null?void 0:t.url)||""},helpUrl(){var n;const e=(n=this.widget)==null?void 0:n.quick_links;if(!Array.isArray(e))return"";const t=e.find(r=>(r.icon==="chat"||r.icon==="help")&&r.url);return(t==null?void 0:t.url)||""},widget(){var e,t;return((t=(e=this.s)==null?void 0:e.config)==null?void 0:t.widget)||null},rootStyle(){var t;const e=(t=this.widget)==null?void 0:t.primary_color;return e&&bc(e)?{"--wm-primary":e}:null},widgetTitle(){var e;return((e=this.widget)==null?void 0:e.title)||""},widgetWelcomeMessage(){var e;return((e=this.widget)==null?void 0:e.welcome_message)||""},widgetSubtitle(){var e;return((e=this.widget)==null?void 0:e.subtitle)||""},defaultIconUrl(){var e;return((e=this.widget)==null?void 0:e.default_icon_url)||null},coverImageUrl(){var e;return((e=this.widget)==null?void 0:e.cover_image_url)||null},agentName(){var e,t,n;return((n=(t=(e=this.s)==null?void 0:e.config)==null?void 0:t.agent)==null?void 0:n.name)||""},agentAvatarUrl(){var e,t,n;return((n=(t=(e=this.s)==null?void 0:e.config)==null?void 0:t.agent)==null?void 0:n.avatar_url)||null},quickLinks(){var t;const e=(t=this.widget)==null?void 0:t.quick_links;return Array.isArray(e)?e:[]},teamMembers(){var t;const e=(t=this.widget)==null?void 0:t.team_members;return Array.isArray(e)?e:[]},responseLabel(){var e;return((e=this.widget)==null?void 0:e.response_time_label)||""},humanMessageAuthor(){var t,n,r;if(!this.currentConv)return null;const e=((t=this.s.messagesByConv)==null?void 0:t[this.currentConv.id])||[];for(let i=e.length-1;i>=0;i--)if(((r=(n=e[i])==null?void 0:n.author)==null?void 0:r.type)==="agent_human")return e[i].author;return null},humanAgentName(){var e;return((e=this.humanMessageAuthor)==null?void 0:e.name)||""},humanAgentAvatarUrl(){var e;return((e=this.humanMessageAuthor)==null?void 0:e.avatar_url)||null},isEscalated(){return!!this.humanMessageAuthor},isWaitingHuman(){return this.currentStatus==="waiting_human_response"},isTerminal(){return this.currentStatus==="resolved"||this.currentStatus==="closed"},isClosed(){return this.currentStatus==="closed"},endedBlockVisible(){var e;return!(!this.isTerminal||this.isClosed&&this.reopenedLocally[(e=this.currentConv)==null?void 0:e.id])},headerTitle(){var e,t;return((e=this.currentConv)==null?void 0:e.name)||((t=this.widget)==null?void 0:t.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 i,s;const e=this.currentConv;if(!e)return[];const t=this.welcomeRevealedAt[e.id]>0?this.buildWelcomePrefix(e):[];if(!e._draft){const o=(s=(i=this.s)==null?void 0:i.paginationByConv)==null?void 0:s[e.id];if(!(o!=null&&o.loaded))return t}const n=this.revealedAt,r=(this.s.messagesByConv[e.id]||[]).filter(o=>{var a,l,d,c,m;return(o==null?void 0:o.type)==="action"&&((a=o==null?void 0:o.payload)==null?void 0:a.state)==="pending"||bn(o)&&!(n[o.id]>0)?!1:(o==null?void 0:o.type)==="action"||(o==null?void 0:o.type)==="system"||((l=o==null?void 0:o.payload)==null?void 0:l.type)==="system"||Array.isArray((d=o==null?void 0:o.payload)==null?void 0:d.attachments)&&o.payload.attachments.length||(c=o==null?void 0:o.metadata)!=null&&c.artifact||(m=o==null?void 0:o.metadata)!=null&&m.form||Array.isArray(o==null?void 0:o.callbacks)&&o.callbacks.some(C=>(C==null?void 0:C.intent)==="submit_form")?!0:typeof(o==null?void 0:o.text_md)=="string"&&o.text_md.trim().length>0});return t.length?[...t,...r]:r},streamingActive(){var n,r,i;const e=this.currentConv;return e?Object.keys(((n=this.s)==null?void 0:n.streamingByMsgId)||{}).length>0?!0:this.actionInFlight?!1:this.widgetWelcomeMessage&&this.welcomeRevealedAt[e.id]===0?!0:(((i=(r=this.s)==null?void 0:r.messagesByConv)==null?void 0:i[e.id])||[]).some(s=>bn(s)&&!(this.revealedAt[s.id]>0)):!1},currentConvMessages(){var t,n,r;const e=(t=this.currentConv)==null?void 0:t.id;return e?((r=(n=this.s)==null?void 0:n.messagesByConv)==null?void 0:r[e])||[]:[]},pendingResolution(){var t,n,r,i,s;if(!this.currentConv)return null;const e=((n=(t=this.s)==null?void 0:t.messagesByConv)==null?void 0:n[this.currentConv.id])||[];for(let o=e.length-1;o>=0;o--){const a=e[o];if((r=a==null?void 0:a.metadata)!=null&&r.resolution_request)return!Array.isArray(a.callbacks)||!a.callbacks.length||(s=(i=this.s)==null?void 0:i.awaitingCallback)!=null&&s[a.id]?null:a}return null},resolutionCallbacks(){const e=this.pendingResolution;if(!e||!Array.isArray(e.callbacks))return[];const t={resolve_confirm:this.t("resolution.confirm"),resolve_decline:this.t("resolution.decline")};return e.callbacks.map(n=>({...n,label:t[n.id]||n.label}))},pendingApproval(){var t,n,r,i;if(!this.currentConv)return null;const e=((n=(t=this.s)==null?void 0:t.messagesByConv)==null?void 0:n[this.currentConv.id])||[];for(let s=e.length-1;s>=0;s--){const o=e[s];if(!(!Array.isArray(o==null?void 0:o.callbacks)||!o.callbacks.length||!o.callbacks.some(l=>(l==null?void 0:l.intent)==="approve"&&(l.audience??"customer")==="customer")))return(i=(r=this.s)==null?void 0:r.awaitingCallback)!=null&&i[o.id]?null:o}return null},approvalCallbacks(){const e=this.pendingApproval;return!e||!Array.isArray(e.callbacks)?[]:e.callbacks.filter(t=>(t==null?void 0:t.intent)==="approve"||(t==null?void 0:t.intent)==="reject")},currentStatus(){return this.convStatus(this.currentConv)},actionInFlight(){var e,t;return!this.currentConv||!this.store?null:((t=(e=this.store).getActionInFlight)==null?void 0:t.call(e,this.currentConv.id))||null},actionInFlightName(){var t;const e=this.actionInFlight;return e?((t=e.payload)==null?void 0:t.name)||e.text_md||this.t("common.action"):""},suggestions(){return this.currentConv?this.isTerminal?[]:this.streamingActive?[]:this.pendingForm?[]:this.conversationIsEmpty?this.starterPrompts:this.store?this.store.getLatestSuggestions(this.currentConv.id):[]:[]},conversationIsEmpty(){var n,r;const e=this.currentConv;return e?e._draft?!0:(((r=(n=this.s)==null?void 0:n.messagesByConv)==null?void 0:r[e.id])||[]).length===0:!1},starterPrompts(){var n;const e=(n=this.widget)==null?void 0:n.starter_prompts;if(!Array.isArray(e))return[];const t=[];for(const r of e){if(!r||typeof r!="object")continue;const i=typeof r.title=="string"?r.title.trim():"";if(!i)continue;const s=typeof r.message=="string"?r.message.trim():"";t.push({label:i,text:s||i,kind:"starter"})}return t},pendingForm(){var e,t;return!this.currentConv||!this.store||this.actionInFlight||this.streamingActive?null:((t=(e=this.store).getLatestForm)==null?void 0:t.call(e,this.currentConv.id))||null},showFeedback(){var t;const e=this.currentConv;return!e||this.currentStatus!=="resolved"?!1:this.feedbackDone[e.id]?!0:!((t=e.metadata)!=null&&t.feedback)},floatVisible(){return!!this.pendingApproval||!!this.pendingResolution||!!this.pendingForm||this.showFeedback||this.suggestions.length>0},dateLabel(){var n,r,i;const e=this.currentConv;let t=new Date;if(e){const o=((i=(((r=(n=this.s)==null?void 0:n.messagesByConv)==null?void 0:r[e.id])||[]).find(a=>a==null?void 0:a.created_at))==null?void 0:i.created_at)||e.created_at;if(o){const a=new Date(o);Number.isNaN(a.getTime())||(t=a)}}return this.t("messageList.today",{time:Bs(t,Bt(this.locale))})},paginationState(){var n,r,i;const e=(n=this.currentConv)==null?void 0:n.id,t=e?(i=(r=this.s)==null?void 0:r.paginationByConv)==null?void 0:i[e]:null;return{loading:!!(t!=null&&t.loading),hasMore:!!(t!=null&&t.nextCursor)}}},watch:{latestUnreads:{handler(e){const t=new Set(e.map(o=>o.convId)),n=this.dismissedPeeks||{},r=Object.keys(n);if(!r.length)return;const i={};let s=!1;for(const o of r)t.has(o)?i[o]=n[o]:s=!0;s&&(this.dismissedPeeks=i)},deep:!0},"currentConv.id":{handler(e){var t;this.resetRevealQueue(),this.convOpenedAt=Date.now(),this.moreOpen=!1,this.renameDialogOpen=!1,this.isViewingThread&&(this.unreadAnchorId=ht((t=this.currentConv)==null?void 0:t.last_read_message_id),this.unreadBoundaryTs=e?new Date().toISOString():""),e&&this.scheduleWelcomeReveal(e)},immediate:!0},isViewingThread(e,t){var n;e&&!t?(this.unreadAnchorId=ht((n=this.currentConv)==null?void 0:n.last_read_message_id),this.unreadBoundaryTs=new Date().toISOString()):e||(this.unreadAnchorId=null,this.unreadBoundaryTs="")},floatVisible:{handler(e){this.$nextTick(()=>this.syncFloatObserver(e))},immediate:!0},currentConvMessages(e){var t;this.paceMessages(e,(t=this.currentConv)==null?void 0:t.id),(this.isOpen||this.isEmbedded)&&this.currentConv&&this.markConvRead(this.currentConv)}},async mounted(){if(typeof document<"u"&&!document.getElementById(ti)){const e=document.createElement("style");e.id=ti,e.textContent=Ao,document.head.appendChild(e)}this._parentMessageHandler=this.onParentMessage.bind(this),window.addEventListener("message",this._parentMessageHandler),window.parent&&window.parent!==window&&window.parent.postMessage({type:"READY"},"*"),this.isEmbedded?(await this.boot(),this.store&&await this.open()):(await this.$nextTick(),this.sendCurrentLauncherSize(),this.observeLauncherSize())},beforeUnmount(){this._parentMessageHandler&&(window.removeEventListener("message",this._parentMessageHandler),this._parentMessageHandler=null),this._launcherRo&&(this._launcherRo.disconnect(),this._launcherRo=null),this.cancelReveals(),this.cancelWelcomeTimers(),this.teardownLiveReveal(),this.disconnectFloatRO(),this.teardownNotifications(),this.store&&this.store.destroy()},methods:{convStatus(e){var n,r,i,s;if(!e)return"open";const t=((r=(n=this.s)==null?void 0:n.messagesByConv)==null?void 0:r[e.id])||[];for(let o=t.length-1;o>=0;o--){const a=(s=(i=t[o])==null?void 0:i.metadata)==null?void 0:s.conversation_status;if(a)return a}return e.status||"open"},t(e,t){return this.translator(e,t)},waitForParentInit(){if(this.parentInitReceived)return Promise.resolve();if(!this.parentInitDeferred){let e;this.parentInitDeferred=new Promise(t=>{e=t}),this.parentInitDeferred._resolve=e}return this.parentInitDeferred},onParentMessage(e){var n;const t=e==null?void 0:e.data;if(!(!t||typeof t!="object")){if(t.type==="UPDATE"){this.transport&&t.payload&&this.transport.update(t.payload).catch(r=>{console.warn("[messenger] update failed",r)});return}if(t.type==="CONTEXT"){this.transport&&t.payload&&this.transport.context(t.payload);return}t.type==="INIT"&&(this.parentOrigin=e.origin,this.parentToken=typeof t.token=="string"?t.token:"",this.parentVariables=t.variables&&typeof t.variables=="object"?t.variables:t.context&&typeof t.context=="object"?t.context:null,this.parentAllowUnauthenticated=t.allowUnauthenticated===!0,this.parentInitReceived=!0,(n=this.parentInitDeferred)!=null&&n._resolve&&this.parentInitDeferred._resolve(),!this.isEmbedded&&!this.isOpen&&!this.parentAllowUnauthenticated&&this.parentToken&&this.hasValidSessionMarker()&&this.boot().catch(r=>{console.warn("[messenger] eager boot failed",r)}))}},hasValidSessionMarker(){if(typeof document>"u")return!1;const t=(document.cookie||"").match(/(?:^|; )messenger_session_marker=([^;]+)/);if(!t)return!1;const n=parseInt(t[1],10);return Number.isFinite(n)?n>Date.now():!1},async boot(){if(!this.canBoot){console.warn("[messenger] boot skipped โ missing creds");return}try{await this.waitForParentInit(),this.transport=Ts(dc({baseUrl:this.baseUrl,widgetId:this.widgetId})),this.store=Ts(gc(this.transport)),this.hydrateNotifPref();const e=this.parentVariables||this.context||null;if(await this.store.start({origin:this.parentOrigin,token:this.parentToken||void 0,allowUnauthenticated:this.parentAllowUnauthenticated,variables:e&&typeof e=="object"?e:void 0}),e&&typeof e=="object"){const t={};for(const[n,r]of Object.entries(e))n!=="customer"&&r&&typeof r=="object"&&!Array.isArray(r)&&(t[n]=r);Object.keys(t).length>0&&this.transport.context(t)}this.setupLiveReveal()}catch(e){console.error("[ww-messenger] bootstrap failed",e),this.bootError=(e==null?void 0:e.message)||String(e)}},async refresh(){this.store&&this.store.destroy(),this.cancelReveals(),this.cancelWelcomeTimers(),this.welcomeRevealedAt={},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={},this.moreOpen=!1,this.renameDialogOpen=!1,this.draftConv=null,this.activeConvId=null,this.showOnboarding=!1,this.showHistory=!1,this.backToHistory=!1,await this.boot(),this.isEmbedded&&this.store&&await this.open()},syncFloatObserver(e){if(this.disconnectFloatRO(),!e){this.floatHeight=0;return}const t=this.$refs.floatEl;if(t){if(typeof ResizeObserver>"u"){this.floatHeight=Math.ceil(t.getBoundingClientRect().height+8);return}this.floatRO=new ResizeObserver(n=>{const r=n[0];if(!r)return;const i=Math.ceil(r.contentRect.height+8);i!==this.floatHeight&&(this.floatHeight=i,this.$nextTick(()=>{var s,o;(o=(s=this.$refs.messageList)==null?void 0:s.keepPinnedToBottom)==null||o.call(s)}))}),this.floatRO.observe(t)}},disconnectFloatRO(){if(this.floatRO){try{this.floatRO.disconnect()}catch{}this.floatRO=null}},async open(){this.isOpen=!0,this.notifyParentResize("open"),this._launcherRo&&this._launcherRo.disconnect(),this.store||await this.boot(),this.store&&this.store.setPanelOpen(!0);const e=this.currentConv;if(e&&!e._draft){this.activeConvId==null&&(this.activeConvId=e.id);try{await this.store.openConversation(e.id)}catch(t){console.error("[ww-messenger] load messages failed",t)}this.markConvRead(e)}},async close(){this.isOpen=!1,await this.$nextTick(),this.sendCurrentLauncherSize(),this.observeLauncherSize(),this.store&&this.store.setPanelOpen(!1)},notifyParentResize(e,t){if(window.parent&&window.parent!==window)try{window.parent.postMessage({type:"RESIZE",state:e,displayMode:this.displayMode,...t||{}},"*")}catch(n){console.warn("[ww-messenger] notifyParentResize failed",n)}},onLauncherHover(e){this.launcherHovered=e,this.sendCurrentLauncherSize()},sendCurrentLauncherSize(){var c,m,C,b,K,S,J;if(this.isOpen)return;const e=(m=(c=this.$el)==null?void 0:c.querySelector)==null?void 0:m.call(c,".wm-launcherWrap");if(!e)return;const t=e.getBoundingClientRect();if(!t.width||!t.height)return;const n=(((C=this.launcherPeeks)==null?void 0:C.length)??0)>0,r=16,i=Math.ceil(t.width),s=Math.ceil(t.height),o=(K=(b=this.$el)==null?void 0:b.querySelector)==null?void 0:K.call(b,".wm-launcher"),a=(J=(S=this.$el)==null?void 0:S.querySelectorAll)==null?void 0:J.call(S,".wm-peek"),l=a&&a.length?a[a.length-1]:null;let d=null;if(l){const U=l.getBoundingClientRect();d={width:Math.ceil(U.width),height:Math.ceil(U.height),rightOffset:Math.max(0,Math.ceil(t.right-U.right)),bottomOffset:Math.max(0,Math.ceil(t.bottom-U.bottom))}}this.notifyParentResize("closed",{width:i+r,height:s+r,launcherWidth:(o==null?void 0:o.offsetWidth)||null,launcherHeight:(o==null?void 0:o.offsetHeight)||null,launcherHovered:this.launcherHovered,peek:d,peekHovered:this.launcherHovered&&n})},observeLauncherSize(){var n,r;if(typeof ResizeObserver>"u")return;const e=(r=(n=this.$el)==null?void 0:n.querySelector)==null?void 0:r.call(n,".wm-launcherWrap");if(!e)return;this._launcherRo&&this._launcherRo.disconnect();const t=new ResizeObserver(()=>{this.isOpen||this.sendCurrentLauncherSize()});t.observe(e),this._launcherRo=t},async openFromPeek(e){var n,r;const t=e||((n=this.latestUnreads[0])==null?void 0:n.convId);t&&t!==((r=this.currentConv)==null?void 0:r.id)&&(this.draftConv=null,this.activeConvId=t,this.showOnboarding=!1,this.showHistory=!1,this.backToHistory=!1),await this.open()},dismissPeek(e){const t=this.latestUnreads.find(n=>n.convId===e);t&&(this.dismissedPeeks={...this.dismissedPeeks,[e]:t.ts})},onOnboardingStart(e){this.pendingLaunchText=(e||"").trim(),this.launching=!0,this.launchStage="whiteslide"},onHomeLaunched(){const e=this.pendingLaunchText;this.pendingLaunchText="",this.startConv(),e&&this.$nextTick(()=>this.onSend(e)),this.launchStage="header",window.setTimeout(()=>{this.launching&&(this.launchStage="messages")},520),window.setTimeout(()=>{this.launching=!1,this.launchStage="idle"},1160)},startConv(){this.draftConv={id:"__draft__",_draft:!0,name:"",created_at:new Date().toISOString()},this.activeConvId=null,this.showOnboarding=!1,this.showHistory=!1,this.backToHistory=!1,this.focusComposer()},onReopen(){var t;const e=(t=this.currentConv)==null?void 0:t.id;e&&(this.reopenedLocally={...this.reopenedLocally,[e]:!0},this.focusComposer())},async ensureRealConv(){const e=this.currentConv;if(!e)return null;if(!e._draft)return e;if(this.busy)return null;this.busy=!0;try{const t=await this.store.createConversation({}),n=this.welcomeRevealedAt.__draft__;return n!==void 0&&(this.welcomeRevealedAt={...this.welcomeRevealedAt,[t.id]:n>0?n:Date.now()}),this.draftConv=null,this.activeConvId=t.id,await this.store.openConversation(t.id),this.markConvRead(t),t}catch(t){return console.error("[ww-messenger] create conv failed",t),this.bootError=(t==null?void 0:t.message)||String(t),null}finally{this.busy=!1}},focusComposer(){this.$nextTick(()=>{var e;return(e=this.$refs.composer)==null?void 0:e.focus()})},buildWelcomePrefix(e){const t=this.widgetWelcomeMessage;return!t||typeof t!="string"||!t.trim()?[]:[{id:"__welcome__",text_md:t.trim(),author:{type:"agent_ia",name:this.agentName,avatar_url:this.agentAvatarUrl},created_at:(e==null?void 0:e.created_at)||new Date(0).toISOString()}]},scheduleWelcomeReveal(e){if(!e)return;const t=this.widgetWelcomeMessage;if(!t||typeof t!="string"||!t.trim()||this.welcomeRevealedAt[e]!==void 0)return;const n=this.currentConv;if(!((n==null?void 0:n._draft)||!(n!=null&&n.last_message_id))){this.welcomeRevealedAt={...this.welcomeRevealedAt,[e]:Date.now()};return}this.welcomeRevealedAt={...this.welcomeRevealedAt,[e]:0};const i=this.revealPacing,s=t.trim().length,o=Math.min(i.maxTypingMs,Math.max(i.minTypingMs,s*i.msPerChar)),a=i.firstRevealDelayMs+o,l=setTimeout(()=>{this.welcomeRevealedAt={...this.welcomeRevealedAt,[e]:Date.now()};const d={...this.welcomeRevealTimers};delete d[e],this.welcomeRevealTimers=d},a);this.welcomeRevealTimers={...this.welcomeRevealTimers,[e]:l}},cancelWelcomeTimers(){for(const e of Object.values(this.welcomeRevealTimers))try{clearTimeout(e)}catch{}this.welcomeRevealTimers={}},toggleMore(){this.moreOpen=!this.moreOpen},goHome(){this.moreOpen=!1,this.draftConv=null,this.activeConvId=null,this.backToHistory?(this.showOnboarding=!1,this.showHistory=!0,this.backToHistory=!1):(this.showOnboarding=!0,this.showHistory=!1)},async onDrawerPick(e){if(!(e!=null&&e.id)||!this.store)return;const t=this.showHistory;this.draftConv=null,this.activeConvId=e.id,this.showOnboarding=!1,this.showHistory=!1,this.backToHistory=t;try{await this.store.openConversation(e.id)}catch(r){console.error("[ww-messenger] open conv failed",r)}const n=this.allConversations.find(r=>r.id===e.id);n&&this.markConvRead(n)},async onMoreAction(e){var t,n;switch(this.moreOpen=!1,e){case"rename":this.openRenameDialog();break;case"export":Mc(this.currentConv,this.currentConv?(n=(t=this.s)==null?void 0:t.messagesByConv)==null?void 0:n[this.currentConv.id]:[],this.translator,this.locale);break;case"status":if(In(this.statusUrl))try{window.open(this.statusUrl,"_blank","noopener")}catch{}break;case"help":if(In(this.helpUrl))try{window.open(this.helpUrl,"_blank","noopener")}catch{}break}},openRenameDialog(){const e=this.currentConv;!e||e._draft||(this.renameDialogOpen=!0)},async onRenameSubmit(e){const t=this.currentConv;if(this.renameDialogOpen=!1,!t||t._draft||!this.store)return;const n=(e||"").trim();if(!(!n||n===t.name))try{await this.store.patchConversation(t.id,{name:n})}catch(r){console.error("[ww-messenger] rename failed",r)}},async onSend(e){let t=this.currentConv;if(!t&&(this.startConv(),t=this.currentConv,!t)||t._draft&&(t=await this.ensureRealConv(),!t))return;const n=t.id,r=this.pendingAttachments.slice();this.pendingAttachments=[],this.unreadAnchorId=null,this.unreadBoundaryTs="";const i=r.map(s=>{const{previewUrl:o,...a}=s;return a});await this.store.send(n,e,{attachments:i.length?i:void 0})},async onSuggestion(e){const t=(e==null?void 0:e.text)||(e==null?void 0:e.label);t&&await this.onSend(t)},async onLoadMore(){var t;const e=(t=this.currentConv)==null?void 0:t.id;!e||!this.store||await this.store.loadMore(e)},async onResolutionSelect(e){const t=this.pendingResolution;!t||!(e!=null&&e.id)||await this.store.clickCallback(t.id,e.id)},async onApprovalSelect(e){const t=this.pendingApproval;!t||!(e!=null&&e.id)||await this.store.clickCallback(t.id,e.id)},async onFormSubmit({values:e}){const t=this.pendingForm;if(!(t!=null&&t.form))return;const n=kc(t.form,e,this.translator);if(!n)return;let r=this.currentConv;r&&(r._draft&&(r=await this.ensureRealConv(),!r)||await this.store.send(r.id,n,{metadata:{artifact:Cc(t.form,e,this.translator)}}))},formatAttachmentSize(e){return e?e<1024?this.t("attachment.bytes",{size:e}):e<1024*1024?this.t("attachment.kilobytes",{size:(e/1024).toFixed(0)}):this.t("attachment.megabytes",{size:(e/(1024*1024)).toFixed(1)}):""},removePendingAttachment(e){this.pendingAttachments.splice(e,1)},async onAttach(e){var t,n;if(!(!e||!this.transport))try{const r=await this.transport.uploadAttachment(e),i=(r==null?void 0:r.type)==="image"||(e.type||"").toLowerCase().startsWith("image/")||((r==null?void 0:r.mime_type)||"").toLowerCase().startsWith("image/");let s=null;if(i)try{s=await((n=(t=this.store)==null?void 0:t.signAttachment)==null?void 0:n.call(t,r.path))||null}catch{}this.pendingAttachments.push({type:r.type||"file",path:r.path,name:e.name||this.t("attachment.fileFallbackName"),mime_type:e.type,size_bytes:e.size,previewUrl:s})}catch(r){console.error("[ww-messenger] attachment upload failed",r)}},onPanelClick(e){const t=e.target&&e.target.closest?e.target.closest('a[href^="#"]'):null;t&&(e.preventDefault(),this.openInternalUrl(t.getAttribute("href")))},async openInternalUrl(e){if(typeof e!="string"||!e.startsWith("#"))return!1;const t=e.slice(1);if(t==="new"||t==="new-conversation")return this.isOpen||await this.open(),this.startConv(),!0;if(t.startsWith("conversation/")){const n=t.slice(13);return n&&await this.openFromPeek(n),!0}return console.warn("[messenger] unknown internal url",e),!0},async onQuickLink(e){if(e){if(e.url){if(await this.openInternalUrl(e.url))return;if(!In(e.url)){console.warn("[messenger] refusing unsafe quick-link url",e.url);return}try{window.open(e.url,"_blank","noopener")}catch{}return}this.currentConv||this.startConv(),await this.onSend(e.label)}},async onFeedback({rating:e,comment:t}){if(this.currentConv){this.feedbackBusy=!0;try{await this.store.submitFeedback(this.currentConv.id,{rating:e,comment:t}),this.feedbackDone={...this.feedbackDone,[this.currentConv.id]:!0}}catch(n){console.error("[ww-messenger] feedback failed",n)}finally{this.feedbackBusy=!1}}}}},rg={key:0,class:"wm-loading","aria-busy":"true","aria-live":"polite"},ig=["aria-label"],og={class:"wm-screens"},ag={key:"error",class:"wm-screen wm-state"},lg={class:"wm-state__err"},cg={class:"wm-state__errTitle"},ug={class:"wm-state__errSub"},dg={key:"chat",class:"wm-screen wm-screen--chat"},fg={class:"wm-bottom"},hg={key:0,ref:"floatEl",class:"wm-float"},mg={key:1,class:"wm-actionWait",role:"status","aria-live":"polite"},gg={class:"wm-actionWait__lbl"},pg={key:2,class:"wm-attached"},_g=["src","alt"],yg={key:1,class:"wm-attached__file"},vg={class:"wm-attached__fileMeta"},bg={class:"wm-attached__fileName"},wg={key:0,class:"wm-attached__fileSize"},kg=["aria-label","onClick"],Cg={key:3,class:"wm-ended",role:"status","aria-live":"polite"},Sg={class:"wm-ended__lbl"};function Ag(e,t,n,r,i,s){const o=ve("Launcher"),a=ve("Header"),l=ve("History"),d=ve("Onboarding"),c=ve("MessageList"),m=ve("InlineCallbacks"),C=ve("FormCard"),b=ve("Feedback"),K=ve("Composer"),S=ve("MoreMenu"),J=ve("RenameDialog");return h(),p("div",{class:te(["wm-root",`wm-root--${n.displayMode}`]),style:Ce(s.rootStyle)},[!i.isOpen&&!s.isEmbedded?(h(),fe(o,{key:0,"unread-count":s.unreadCount,peeks:s.launcherPeeks,onOpen:s.openFromPeek,onDismiss:s.dismissPeek,onHover:s.onLauncherHover},null,8,["unread-count","peeks","onOpen","onDismiss","onHover"])):F("",!0),i.isOpen||s.isEmbedded?(h(),p("section",{key:1,class:te(["wm-panel",`wm-panel--${n.displayMode}`,{"wm-panel--welcome":s.ready&&!s.error&&!s.currentConv},i.launching?`wm-launch-${i.launchStage}`:""]),style:Ce(i.floatHeight?{"--wm-float-h":i.floatHeight+"px"}:null),role:"dialog","aria-label":"Messenger",onClick:t[7]||(t[7]=(...U)=>s.onPanelClick&&s.onPanelClick(...U))},[!s.ready&&!s.error?(h(),p("div",rg,[s.isEmbedded?F("",!0):(h(),p("button",{key:0,type:"button",class:"wm-loading__close","aria-label":s.t("loading.minimize"),onClick:t[0]||(t[0]=(...U)=>s.close&&s.close(...U))},[...t[8]||(t[8]=[u("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"},[u("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,ig)),t[9]||(t[9]=u("div",{class:"wm-loading__spinner","aria-hidden":"true"},null,-1))])):(h(),p(Z,{key:1},[pe(a,{title:s.headerTitle,"team-members":s.teamMembers,"response-label":s.responseLabel,"show-identity":!!s.currentConv,"show-back":s.canBack,"show-close":!s.isEmbedded,"more-active":i.moreOpen,"agent-name":s.agentName,"agent-avatar-url":s.agentAvatarUrl,onBack:s.goHome,onMore:s.toggleMore,onClose:s.close},null,8,["title","team-members","response-label","show-identity","show-back","show-close","more-active","agent-name","agent-avatar-url","onBack","onMore","onClose"]),u("div",og,[pe(Qs,{name:"wm-none"},{default:Xn(()=>[s.error?(h(),p("div",ag,[u("div",lg,[t[10]||(t[10]=u("div",{class:"wm-state__errIcon"},[u("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"},[u("path",{d:"M18 6L6 18M6 6l12 12"})])],-1)),u("div",null,[u("div",cg,R(s.t("error.connectionFailed")),1),u("div",ug,R(s.error),1)])])])):!s.currentConv&&i.showHistory?(h(),fe(l,{key:"history",class:"wm-screen",threads:s.openThreads,onResume:s.onDrawerPick},null,8,["threads","onResume"])):s.currentConv?(h(),p("div",dg,[pe(c,{ref:"messageList",messages:s.displayedMessages,"streaming-active":s.streamingActive,"date-label":s.dateLabel,"conversation-id":s.currentConv?s.currentConv.id:null,"loading-more":s.paginationState.loading,"has-more":s.paginationState.hasMore,"unread-anchor-id":e.unreadAnchorId,"unread-boundary-ts":e.unreadBoundaryTs,"ai-agent-name":s.agentName,"ai-agent-avatar-url":s.agentAvatarUrl,onLoadMore:s.onLoadMore},null,8,["messages","streaming-active","date-label","conversation-id","loading-more","has-more","unread-anchor-id","unread-boundary-ts","ai-agent-name","ai-agent-avatar-url","onLoadMore"]),u("div",fg,[s.floatVisible?(h(),p("div",hg,[s.pendingApproval?(h(),fe(m,{key:`appr-${s.pendingApproval.id}`,variant:"buttons",items:s.approvalCallbacks,onSelect:s.onApprovalSelect},null,8,["items","onSelect"])):s.pendingResolution?(h(),fe(m,{key:`res-${s.pendingResolution.id}`,variant:"buttons",items:s.resolutionCallbacks,onSelect:s.onResolutionSelect},null,8,["items","onSelect"])):s.pendingForm?(h(),fe(C,{key:s.pendingForm.message&&s.pendingForm.message.id,form:s.pendingForm.form,"agent-name":s.agentName,"agent-avatar-url":s.agentAvatarUrl,onSubmit:s.onFormSubmit},null,8,["form","agent-name","agent-avatar-url","onSubmit"])):s.showFeedback?(h(),fe(b,{key:3,busy:i.feedbackBusy,done:!!(s.currentConv&&i.feedbackDone[s.currentConv.id]),onSubmit:s.onFeedback},null,8,["busy","done","onSubmit"])):(h(),fe(m,{key:4,items:s.suggestions,onSelect:s.onSuggestion},null,8,["items","onSelect"]))],512)):F("",!0),s.actionInFlight?(h(),p("div",mg,[t[11]||(t[11]=u("span",{class:"wm-actionWait__spinner","aria-hidden":"true"},null,-1)),u("span",gg,R(s.t("action.inProgress",{name:s.actionInFlightName})),1)])):F("",!0),i.pendingAttachments.length?(h(),p("div",pg,[(h(!0),p(Z,null,Se(i.pendingAttachments,(U,$)=>(h(),p("div",{key:U.path||$,class:"wm-attached__item"},[U.previewUrl?(h(),p("img",{key:0,class:"wm-attached__thumb",src:U.previewUrl,alt:U.name},null,8,_g)):(h(),p("div",yg,[t[12]||(t[12]=u("span",{class:"wm-attached__fileIcon"},[u("svg",{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"},[u("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"}),u("path",{d:"M14 2v6h6"})])],-1)),u("span",vg,[u("span",bg,R(U.name),1),s.formatAttachmentSize(U.size_bytes)?(h(),p("span",wg,R(s.formatAttachmentSize(U.size_bytes)),1)):F("",!0)])])),u("button",{type:"button",class:"wm-attached__remove","aria-label":s.t("attachment.remove"),onClick:ne=>s.removePendingAttachment($)},[...t[13]||(t[13]=[u("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.4","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[u("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,kg)]))),128))])):F("",!0),s.endedBlockVisible?(h(),p("div",Cg,[u("span",Sg,R(s.isClosed?s.t("composer.conversationClosed"):s.t("composer.conversationEnded")),1),u("button",{type:"button",class:"wm-ended__btn",onClick:t[2]||(t[2]=U=>s.isClosed?s.onReopen():s.startConv())},R(s.isClosed?s.t("composer.reopen"):s.t("composer.newConversation")),1)])):s.actionInFlight?F("",!0):(h(),fe(K,{key:4,ref:"composer",modelValue:i.draft,"onUpdate:modelValue":t[3]||(t[3]=U=>i.draft=U),placeholder:s.composerPlaceholder,"attach-label":s.t("composer.attachFile"),"display-mode":n.displayMode,onSend:s.onSend,onAttach:s.onAttach},null,8,["modelValue","placeholder","attach-label","display-mode","onSend","onAttach"]))]),i.moreOpen?(h(),fe(S,{key:0,"can-rename":!!s.currentConv&&!s.currentConv._draft,"can-export":!!s.currentConv&&!s.currentConv._draft,"sound-enabled":e.soundEnabled,"status-url":s.statusUrl,"help-url":s.helpUrl,onClose:t[4]||(t[4]=U=>i.moreOpen=!1),onSoundToggle:e.onSoundToggle,onAction:s.onMoreAction},null,8,["can-rename","can-export","sound-enabled","status-url","help-url","onSoundToggle","onAction"])):F("",!0),i.renameDialogOpen&&s.currentConv&&!s.currentConv._draft?(h(),fe(J,{key:1,"initial-value":s.currentConv.name||"",title:s.t("rename.dialogTitle"),onClose:t[5]||(t[5]=U=>i.renameDialogOpen=!1),onSubmit:s.onRenameSubmit},null,8,["initial-value","title","onSubmit"])):F("",!0)])):(h(),fe(d,{key:"home",class:"wm-screen",title:s.widgetTitle,subtitle:s.widgetSubtitle,"agent-name":s.agentName,"default-icon-url":s.defaultIconUrl,"cover-image-url":s.coverImageUrl,"quick-links":s.quickLinks,"open-threads":s.openThreads,busy:i.busy,launching:i.launching,"welcome-message":s.widgetWelcomeMessage,onStart:s.onOnboardingStart,onLaunched:s.onHomeLaunched,onSelect:s.onQuickLink,onResume:s.onDrawerPick,onViewHistory:t[1]||(t[1]=U=>i.showHistory=!0)},null,8,["title","subtitle","agent-name","default-icon-url","cover-image-url","quick-links","open-threads","busy","launching","welcome-message","onStart","onLaunched","onSelect","onResume"]))]),_:1})]),i.moreOpen&&!s.currentConv?(h(),fe(S,{key:0,"can-rename":!1,"can-export":!1,"sound-enabled":e.soundEnabled,"status-url":s.statusUrl,"help-url":s.helpUrl,onClose:t[6]||(t[6]=U=>i.moreOpen=!1),onSoundToggle:e.onSoundToggle,onAction:s.onMoreAction},null,8,["sound-enabled","status-url","help-url","onSoundToggle","onAction"])):F("",!0)],64))],6)):F("",!0)],6)}const xg=be(sg,[["render",Ag],["__scopeId","data-v-801581ca"]]),ni=window.__WIDGET_ID,si=window.__BASE_URL,Tg=window.__DISPLAY_MODE||"floating",ri=window.__LANGUAGE||"";window.__MESSENGER_IFRAME_VERSION="0.6.28";if(!ni||!si)console.error("[messenger-iframe] missing __WIDGET_ID or __BASE_URL globals");else{if(!document.getElementById("wm-tokens")){const e=document.createElement("style");e.id="wm-tokens",e.textContent=Ao,document.head.appendChild(e)}sc({render:()=>wo(xg,{baseUrl:si,widgetId:ni,displayMode:Tg,...ri?{language:ri}:{}})}).mount("#app")}
|
|
74
|
+
`)}function Mc(e,t,n=Ee(),r){if(!e)return;const i=Tc(e,t||[],n,Bt(r)),s=new Blob([i],{type:"text/plain;charset=utf-8"});try{const o=URL.createObjectURL(s),a=document.createElement("a");a.href=o,a.download=`${(e.name||"conversation").replace(/[^a-z0-9-_]+/gi,"_")}.txt`,document.body.appendChild(a),a.click(),document.body.removeChild(a),setTimeout(()=>URL.revokeObjectURL(o),1e3)}catch(o){console.error("[ww-messenger] export failed",o)}}const Ec={data(){const e=typeof Notification<"u";return{notifPermission:e?Notification.permission:"denied",soundEnabled:!0,browserNotifEnabled:e&&Notification.permission==="granted",_audioCtx:null}},methods:{teardownNotifications(){var e,t;if(this._audioCtx){try{(t=(e=this._audioCtx).close)==null||t.call(e)}catch{}this._audioCtx=null}},soundStorageKey(){return`wm:notif:sound:${this.widgetId||""}`},browserNotifStorageKey(){return`wm:notif:browser:${this.widgetId||""}`},hydrateNotifPref(){try{if(typeof localStorage>"u")return;const e=localStorage.getItem(this.soundStorageKey());e==="0"?this.soundEnabled=!1:e==="1"&&(this.soundEnabled=!0);const t=localStorage.getItem(this.browserNotifStorageKey());t==="0"?this.browserNotifEnabled=!1:t==="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(e){this.soundEnabled=!!e,this.persistSoundPref()},async onBrowserNotifToggle(e){if(typeof Notification>"u"){this.browserNotifEnabled=!1,this.persistBrowserNotifPref();return}if(!e){this.browserNotifEnabled=!1,this.persistBrowserNotifPref();return}let t=Notification.permission;if(t==="default"){try{t=await Notification.requestPermission()}catch(n){console.warn("[ww-messenger] notif permission request failed",n),t="denied"}this.notifPermission=t}this.browserNotifEnabled=t==="granted",this.persistBrowserNotifPref()},onMessageRevealed(e,t){var i;if(!this.soundEnabled&&!this.browserNotifEnabled||!t||!e||!bn(e))return;const n=typeof document<"u"&&document.hidden;this.isOpen&&!n&&((i=this.currentConv)==null?void 0:i.id)===t||(this.soundEnabled&&this.playNotificationSound(),this.browserNotifEnabled&&this.showBrowserNotification(t,e))},playNotificationSound(){if(typeof window>"u")return;const e=window.AudioContext||window.webkitAudioContext;if(e)try{this._audioCtx||(this._audioCtx=new e);const t=this._audioCtx;if(t.state==="suspended")try{t.resume()}catch{}const n=t.currentTime,r=t.createOscillator(),i=t.createGain();r.connect(i),i.connect(t.destination),r.type="sine",r.frequency.setValueAtTime(880,n),r.frequency.exponentialRampToValueAtTime(1320,n+.08),i.gain.setValueAtTime(0,n),i.gain.linearRampToValueAtTime(.12,n+.02),i.gain.exponentialRampToValueAtTime(1e-4,n+.28),r.start(n),r.stop(n+.32)}catch{}},showBrowserNotification(e,t){if(typeof Notification>"u"||Notification.permission!=="granted")return;const n=t==null?void 0:t.author,r=!n||n.type==="agent_ia",s=((n==null?void 0:n.name)||(r?this.agentName:"")||this.t("launcher.theAgent"))+this.t("launcher.repliedToYou"),o=typeof(t==null?void 0:t.text_md)=="string"?t.text_md.trim():"",a=o?o.slice(0,140):this.t("notification.youHaveNewMessage");try{const l=new Notification(s,{body:a,tag:`wm-${e}`,renotify:!1,silent:!0});l.onclick=()=>{try{window.focus()}catch{}this.draftConv=null,this.showOnboarding=!1,this.activeConvId=e,this.isOpen=!0,this.store&&this.store.setPanelOpen(!0);try{l.close()}catch{}}}catch(l){console.warn("[ww-messenger] notification failed",l)}}}},Qt=Object.freeze({firstRevealDelayMs:450,msPerChar:50,minTypingMs:900,maxTypingMs:12e3,pauseBetweenMs:300}),Zt=(e,t)=>Number.isFinite(e)?e:t,Oc={computed:{revealPacing(){var t;const e=((t=this.widget)==null?void 0:t.reveal_pacing)||{};return{firstRevealDelayMs:Zt(e.first_reveal_delay_ms,Qt.firstRevealDelayMs),msPerChar:Zt(e.ms_per_char,Qt.msPerChar),minTypingMs:Zt(e.min_typing_ms,Qt.minTypingMs),maxTypingMs:Zt(e.max_typing_ms,Qt.maxTypingMs),pauseBetweenMs:Zt(e.pause_between_ms,Qt.pauseBetweenMs)}}},data(){return{revealedAt:{},nextRevealAt:0,revealTimers:[],_liveRevealOff:null,_liveRevealConvSnapshot:null,_liveHwm:{}}},methods:{cancelReveals(){for(const e of this.revealTimers)clearTimeout(e);this.revealTimers=[]},resetRevealQueue(){this.cancelReveals(),this.revealedAt={},this.nextRevealAt=0},setupLiveReveal(){var n,r;if(!this.transport)return;this.teardownLiveReveal();const e=this.transport.on("message",i=>{const s=i==null?void 0:i.conversation_id,o=i==null?void 0:i.message;s&&o&&this.paceLiveMessage(o,s)});this._liveRevealConvSnapshot=new Map((((n=this.s)==null?void 0:n.conversations)||[]).map(i=>[i.id,(i==null?void 0:i.last_message_at)||""])),this._liveHwm=Object.fromEntries((((r=this.s)==null?void 0:r.conversations)||[]).map(i=>[i.id,(i==null?void 0:i.last_message_at)||""]));const t=this.transport.on("activity",i=>{this.handleLiveActivity(i)});this._liveRevealOff=()=>{try{e()}catch{}try{t()}catch{}}},teardownLiveReveal(){if(this._liveRevealOff){try{this._liveRevealOff()}catch{}this._liveRevealOff=null}this._liveRevealConvSnapshot=null,this._liveHwm={}},async handleLiveActivity(e){var i,s;const t=e==null?void 0:e.conversations;if(!Array.isArray(t)||!this.store)return;const n=this._liveRevealConvSnapshot||new Map,r=[];for(const o of t){if(!(o!=null&&o.id))continue;const a=o.last_message_at||"";if(!a)continue;const l=n.get(o.id)||"";a>l&&r.push(o.id)}this._liveRevealConvSnapshot=new Map(t.map(o=>[o.id,(o==null?void 0:o.last_message_at)||""]));for(const o of r)try{const a=await((s=(i=this.store).fetchSinceLast)==null?void 0:s.call(i,o));if(!Array.isArray(a))continue;for(const l of a)this.paceLiveMessage(l,o)}catch(a){console.error("[ww-messenger] activity delta fetch failed",a)}},scheduleReveal(e,t){const n=this.revealPacing,r=Date.now(),i=((e==null?void 0:e.text_md)||"").length,s=Math.min(n.maxTypingMs,Math.max(n.minTypingMs,i*n.msPerChar)),a=Math.max(r+n.firstRevealDelayMs,this.nextRevealAt+n.pauseBetweenMs)+s;this.nextRevealAt=a;const l=Math.max(0,a-r),d=e.id,c=setTimeout(()=>{this.revealedAt={...this.revealedAt,[d]:Date.now()},this.revealTimers=this.revealTimers.filter(m=>m!==c),typeof this.onMessageRevealed=="function"&&this.onMessageRevealed(e,t)},l);this.revealTimers.push(c)},paceMessages(e,t){var i;if(!Array.isArray(e)||!e.length)return;const n=Date.now(),r={...this.revealedAt};for(const s of e){if((s==null?void 0:s.id)==null||r[s.id]!==void 0)continue;if(!bn(s)){r[s.id]=n;continue}const o=s!=null&&s.created_at?Date.parse(s.created_at):NaN;if(!Number.isFinite(o)||o<this.convOpenedAt){r[s.id]=n;continue}const a=typeof(s==null?void 0:s.text_md)=="string"&&s.text_md.trim().length>0,l=Array.isArray((i=s==null?void 0:s.payload)==null?void 0:i.attachments)&&s.payload.attachments.length>0;if(!a&&!l){r[s.id]=n;continue}r[s.id]=0,this.scheduleReveal(s,t)}this.revealedAt=r},paceLiveMessage(e,t){var a;if(!(e!=null&&e.id)||this.revealedAt[e.id]!==void 0)return;if(!bn(e)){this.revealedAt={...this.revealedAt,[e.id]:Date.now()};return}const n=typeof(e==null?void 0:e.text_md)=="string"&&e.text_md.trim().length>0,r=Array.isArray((a=e==null?void 0:e.payload)==null?void 0:a.attachments)&&e.payload.attachments.length>0;if(!n&&!r){this.revealedAt={...this.revealedAt,[e.id]:Date.now()};return}const i=this._liveHwm[t],s=(e==null?void 0:e.created_at)||"";if(s&&(i===void 0||s>i)&&(this._liveHwm={...this._liveHwm,[t]:s}),!(i!==void 0&&s&&s>i)){this.revealedAt={...this.revealedAt,[e.id]:Date.now()};return}this.revealedAt={...this.revealedAt,[e.id]:0},this.scheduleReveal(e,t)}}},Rc=300,Ic={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(e){var s,o;if(!(e!=null&&e.id)||e._draft||!this.store)return;const t=((o=(s=this.s)==null?void 0:s.messagesByConv)==null?void 0:o[e.id])||[],n=Lc(t);if(n==null)return;const r=ht(e.last_read_message_id),i=ht(n);i!=null&&(r!=null&&i<=r||(this._readMarkerPending={convId:e.id,messageId:n},!this._readMarkerTimer&&(this._readMarkerTimer=setTimeout(()=>{const a=this._readMarkerPending;this._readMarkerPending=null,this._readMarkerTimer=null,a&&this.store&&this.store.markConversationRead(a.convId,a.messageId)},Rc))))}}};function Lc(e){for(let t=e.length-1;t>=0;t--){const n=e[t];if(!(!n||n._pending)&&ht(n.id)!=null)return n.id}return null}const be=(e,t)=>{const n=e.__vccOpts||e;for(const[r,i]of t)n[r]=i;return n},Pc={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":Zs(this.name)},initials(){return er(this.name)}}},Bc=["src","alt"];function Fc(e,t,n,r,i,s){return h(),p("div",{class:te(["wm-huav",{"wm-huav--tail":n.tail}]),style:Ce({width:n.size+"px",height:n.size+"px","--wm-avr":Math.round(n.size*.32)+"px",background:s.bg})},[n.avatarUrl?(h(),p("img",{key:0,src:n.avatarUrl,alt:n.name||""},null,8,Bc)):(h(),p("span",{key:1,style:Ce({fontSize:n.size*.36+"px"})},R(s.initials),5))],6)}const rs=be(Pc,[["render",Fc],["__scopeId","data-v-14e10c0d"]]),Dc=3,Nc={name:"WmLauncher",components:{HumanAvatar:rs},inject:{t:{default:()=>Ee()}},props:{unreadCount:{type:Number,default:0},peeks:{type:Array,default:()=>[]}},emits:["open","dismiss"],computed:{visiblePeeks(){return this.peeks.slice(0,Dc).reverse()}}},Hc=["aria-label","onClick","onKeydown"],Uc=["aria-label","onClick"],jc={class:"wm-peek__avatar"},Vc=["aria-label"],Kc={class:"wm-peek__body"},zc={class:"wm-peek__head"},Wc={class:"wm-peek__name"},$c={class:"wm-peek__action"},qc={class:"wm-peek__text"},Gc=["onClick"],Yc=["aria-label"],Jc=["aria-label"];function Xc(e,t,n,r,i,s){const o=ve("HumanAvatar");return h(),p("div",{class:"wm-launcherWrap",onMouseenter:t[1]||(t[1]=a=>e.$emit("hover",!0)),onMouseleave:t[2]||(t[2]=a=>e.$emit("hover",!1)),onFocusin:t[3]||(t[3]=a=>e.$emit("hover",!0)),onFocusout:t[4]||(t[4]=a=>e.$emit("hover",!1))},[pe(Qs,{name:"wm-peek"},{default:Xn(()=>[s.visiblePeeks.length?(h(),p("div",{key:0,class:te(["wm-peekStack",{"wm-peekStack--multi":s.visiblePeeks.length>1}])},[(h(!0),p(Z,null,Se(s.visiblePeeks,(a,l)=>(h(),p("div",{key:a.convId,class:"wm-peek",style:Ce({"--depth":s.visiblePeeks.length-1-l,zIndex:l+1}),role:"button",tabindex:"0","aria-label":s.t("launcher.openConversationWith",{name:a.senderName||s.t("launcher.theAgent")}),onClick:d=>e.$emit("open",a.convId),onKeydown:[Un(We(d=>e.$emit("open",a.convId),["prevent"]),["enter"]),Un(We(d=>e.$emit("open",a.convId),["prevent"]),["space"])]},[u("button",{type:"button",class:"wm-peek__close","aria-label":s.t("launcher.dismiss"),onClick:We(d=>e.$emit("dismiss",a.convId),["stop"])},[...t[5]||(t[5]=[u("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"},[u("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,Uc),u("div",jc,[pe(o,{name:a.senderName,"avatar-url":a.senderAvatarUrl,size:34},null,8,["name","avatar-url"]),a.count>1?(h(),p("span",{key:0,class:"wm-peek__avatarBadge","aria-label":s.t("launcher.unreadMessages",{count:a.count})},R(a.count>9?"9+":a.count),9,Vc)):F("",!0)]),u("div",Kc,[u("div",zc,[u("span",Wc,R(a.senderName||s.t("common.agent")),1),u("span",$c,R(s.t("launcher.repliedToYou")),1)]),u("p",qc,R(a.preview),1)]),u("button",{type:"button",class:"wm-peek__open",onClick:We(d=>e.$emit("open",a.convId),["stop"])},R(s.t("common.open")),9,Gc)],44,Hc))),128))],2)):F("",!0)]),_:1}),u("button",{type:"button",class:"wm-launcher","aria-label":s.t("launcher.open"),onClick:t[0]||(t[0]=a=>e.$emit("open"))},[t[6]||(t[6]=u("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"},[u("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)),n.unreadCount>0?(h(),p("span",{key:0,class:"wm-launcher__badge","aria-label":n.unreadCount>1?s.t("launcher.unreadConversationsMany",{count:n.unreadCount}):s.t("launcher.unreadConversationsOne",{count:n.unreadCount})},R(n.unreadCount>9?"9+":n.unreadCount),9,Jc)):F("",!0)],8,Yc)],32)}const Qc=be(Nc,[["render",Xc],["__scopeId","data-v-d81459bc"]]),Zc={name:"WmAIAvatar",props:{size:{type:Number,default:26},pulse:{type:Boolean,default:!1},tail:{type:Boolean,default:!1},name:{type:String,default:""},imageUrl:{type:String,default:null}},computed:{initials(){return er(this.name)},bgColor(){return Zs(this.name)}}},eu={key:0,class:"wm-aiav__pulse"},tu=["src","alt"],nu=["width","height"];function su(e,t,n,r,i,s){return h(),p("div",{class:te(["wm-aiav",{"wm-aiav--tail":n.tail}]),style:Ce({width:n.size+"px",height:n.size+"px","--wm-avr":n.size*.32+"px"})},[n.pulse?(h(),p("div",eu)):F("",!0),u("div",{class:te(["wm-aiav__inner",{"wm-aiav__inner--glow":n.pulse,"wm-aiav__inner--img":!!n.imageUrl,"wm-aiav__inner--initials":!n.imageUrl&&!!s.initials}]),style:Ce(!n.imageUrl&&s.initials?{background:s.bgColor}:null)},[n.imageUrl?(h(),p("img",{key:0,src:n.imageUrl,alt:n.name||""},null,8,tu)):s.initials?(h(),p("span",{key:1,style:Ce({fontSize:n.size*.36+"px"})},R(s.initials),5)):(h(),p("svg",{key:2,width:n.size*.5,height:n.size*.5,viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[...t[0]||(t[0]=[u("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),u("circle",{cx:"19",cy:"5",r:"1.5",fill:"white",opacity:"0.55"},null,-1),u("circle",{cx:"5",cy:"18",r:"1",fill:"white",opacity:"0.38"},null,-1)])],8,nu))],6)],6)}const Sn=be(Zc,[["render",su],["__scopeId","data-v-6f7f685d"]]),ru={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(e){return e.avatar_url?"transparent":Zs(e.name||"")},initialsFor(e){return er(e.name||"")}}},iu={key:0,class:"wm-team"},ou=["src","alt"],au={key:1},lu={key:0,class:"wm-team__label"};function cu(e,t,n,r,i,s){return s.visible?(h(),p("div",iu,[u("div",{class:"wm-team__stack",style:Ce({width:s.stackWidth+"px"})},[(h(!0),p(Z,null,Se(n.members.slice(0,3),(o,a)=>(h(),p("div",{key:a,class:"wm-team__pill",style:Ce({left:a*13+"px",zIndex:3-a,background:s.colorFor(o)})},[o.avatar_url?(h(),p("img",{key:0,src:o.avatar_url,alt:o.name||""},null,8,ou)):(h(),p("span",au,R(s.initialsFor(o)),1))],4))),128))],4),n.responseLabel?(h(),p("span",lu,R(n.responseLabel),1)):F("",!0)])):F("",!0)}const uu=be(ru,[["render",cu],["__scopeId","data-v-e49a9063"]]),du={name:"WmHeader",components:{AIAvatar:Sn,TeamAvatars:uu},inject:{t:{default:()=>Ee()}},props:{title:{type:String,default:"Nouvelle conversation"},showBack:{type:Boolean,default:!1},teamMembers:{type:Array,default:()=>[]},responseLabel:{type:String,default:""},showClose:{type:Boolean,default:!0},showMore:{type:Boolean,default:!0},moreActive:{type:Boolean,default:!1},showIdentity:{type:Boolean,default:!0},agentName:{type:String,default:""},agentAvatarUrl:{type:String,default:null}},emits:["back","close","more"],computed:{hasTeam(){return Array.isArray(this.teamMembers)&&this.teamMembers.length>0},displayedTeamMembers(){const e=Array.isArray(this.teamMembers)?this.teamMembers:[];if(e.length<=3)return e;const t=new Date().getHours()%e.length,n=[];for(let r=0;r<3;r++)n.push(e[(t+r)%e.length]);return n}}},fu={class:"wm-header"},hu=["aria-label"],mu={key:1,style:{width:"30px",height:"30px","flex-shrink":"0"}},gu={class:"wm-header__avatar"},pu={class:"wm-header__main"},_u={class:"wm-header__title"},yu={key:3,class:"wm-header__fill"},vu={class:"wm-header__actions"},bu=["aria-label","title"],wu=["aria-label","title"];function ku(e,t,n,r,i,s){const o=ve("AIAvatar"),a=ve("TeamAvatars");return h(),p("div",fu,[n.showBack?(h(),p("button",{key:0,type:"button",class:"wm-header__icon wm-header__back","aria-label":s.t("header.backToHome"),onClick:t[0]||(t[0]=l=>e.$emit("back"))},[...t[3]||(t[3]=[u("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"},[u("path",{d:"M19 12H5M12 5l-7 7 7 7"})],-1)])],8,hu)):(h(),p("div",mu)),n.showIdentity?(h(),p(Z,{key:2},[u("div",gu,[pe(o,{size:30,name:n.agentName,"image-url":n.agentAvatarUrl},null,8,["name","image-url"])]),u("div",pu,[u("div",_u,R(n.title),1)]),s.hasTeam?(h(),fe(a,{key:0,members:s.displayedTeamMembers,"response-label":""},null,8,["members"])):F("",!0)],64)):(h(),p("div",yu)),u("div",vu,[n.showMore?(h(),p("button",{key:0,type:"button",class:te(["wm-header__icon",{"wm-header__icon--active":n.moreActive}]),"aria-label":s.t("header.moreOptions"),title:s.t("header.moreOptions"),onClick:t[1]||(t[1]=l=>e.$emit("more"))},[...t[4]||(t[4]=[u("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true"},[u("circle",{cx:"12",cy:"5",r:"1.6"}),u("circle",{cx:"12",cy:"12",r:"1.6"}),u("circle",{cx:"12",cy:"19",r:"1.6"})],-1)])],10,bu)):F("",!0),n.showClose?(h(),p("button",{key:1,type:"button",class:"wm-header__icon","aria-label":s.t("header.closeWidget"),title:s.t("header.closeWidget"),onClick:t[2]||(t[2]=l=>e.$emit("close"))},[...t[5]||(t[5]=[u("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"},[u("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,wu)):F("",!0)])])}const Cu=be(du,[["render",ku],["__scopeId","data-v-27232009"]]),Zr={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"},Su={name:"WmOnboarding",components:{AIAvatar:Sn,HumanAvatar:rs},inject:{t:{default:()=>Ee()},wmLocale:{default:()=>()=>"fr"}},props:{title:{type:String,default:""},subtitle:{type:String,default:""},agentName:{type:String,default:""},defaultIconUrl:{type:String,default:null},coverImageUrl:{type:String,default:null},quickLinks:{type:Array,default:()=>[]},openThreads:{type:Array,default:()=>[]},busy:{type:Boolean,default:!1},launching:{type:Boolean,default:!1},welcomeMessage:{type:String,default:""}},emits:["start","launched","select","resume","view-history"],data(){return{launchPhase:"idle",inputFocused:!1,launchDone:!1,starterText:""}},watch:{launching(e){e&&this.runLaunch()}},computed:{canStart(){return!this.busy&&!!this.starterText.trim()},typing(){return this.inputFocused&&!!this.starterText.trim()},heroTitle(){return this.title?this.title:this.agentName?this.t("onboarding.greetingNamed",{name:this.agentName}):this.t("onboarding.greeting")},heroSub(){return this.subtitle||this.t("onboarding.heroSub")},unreadThreads(){return this.openThreads.filter(e=>e.unread)},safeCoverUrl(){return Gr(this.coverImageUrl)},hasCover(){return!!this.safeCoverUrl},coverStyle(){return this.safeCoverUrl?{backgroundImage:`url("${this.safeCoverUrl}")`}:null}},methods:{submitStarter(){this.canStart&&this.$emit("start",this.starterText.trim())},onStarterKeydown(e){e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),this.submitStarter())},onInputFocus(){this.launchPhase==="idle"&&(this.inputFocused=!0,this.$nextTick(()=>this.autosize()))},onInputBlur(){this.launchPhase==="idle"&&(this.inputFocused=!1,this.$nextTick(()=>this.autosize()))},autosize(){const e=this.$refs.starterInput;if(!e||e.clientWidth<40)return;e.style.height="auto",e.style.minHeight="0px";const t=e.scrollHeight;e.style.minHeight="",e.style.height=t>62?`${Math.min(t,120)}px`:""},async runLaunch(){const e=this.$refs.starterForm,t=typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;if(!e||t){this.launchPhase="fade",await this.wait(t?120:0),this.finishLaunch();return}this.launchPhase="fade",await this.wait(320);const n=e.getBoundingClientRect();this.launchPhase="slide",await this.$nextTick();const r=e.getBoundingClientRect(),i=n.left-r.left,s=n.top-r.top;e.style.transition="none",e.style.transform=`translate(${i}px, ${s}px)`,e.offsetWidth,e.style.transition="transform 0.44s cubic-bezier(0.32, 0.72, 0, 1)",e.style.transform="translate(0, 0)";const o=()=>{e.removeEventListener("transitionend",o),this.finishLaunch()};e.addEventListener("transitionend",o),this.wait(520).then(()=>this.finishLaunch())},finishLaunch(){this.launchDone||(this.launchDone=!0,this.$emit("launched"))},wait(e){return new Promise(t=>window.setTimeout(t,e))},iconPath(e){return Zr[e]||Zr.link},isExternalLink(e){const t=e==null?void 0:e.url;return!!t&&!t.startsWith("#")},safeIconUrl(e){return Gr(e==null?void 0:e.icon_url)},iconUrlStyle(e){const t=this.safeIconUrl(e);return t?{"--icon-url":`url("${t}")`}:null},renderPreview(e){return Mo(e)},avatarComponent(e){var t;return((t=e==null?void 0:e.author)==null?void 0:t.type)==="agent_human"?"HumanAvatar":"AIAvatar"},avatarProps(e){const t=e==null?void 0:e.author;return(t==null?void 0:t.type)==="agent_human"?{size:40,name:t.name||"",avatarUrl:t.avatar_url||null}:{size:40,name:(t==null?void 0:t.name)||"",imageUrl:(t==null?void 0:t.avatar_url)||null}},isDefaultAvatar(e){const t=e==null?void 0:e.author;return!(t!=null&&t.avatar_url||t!=null&&t.name)},avatarWrapperClass(e){return this.isDefaultAvatar(e)&&!(e!=null&&e.unread)?"wm-onb__avatar--muted":null},senderLabel(e){var t;return((t=e==null?void 0:e.author)==null?void 0:t.name)||""},formatTs(e){if(!e)return"";const t=new Date(e);if(Number.isNaN(t.getTime()))return"";const n=Bt(this.wmLocale()),r=new Date;if(t.toDateString()===r.toDateString())return t.toLocaleTimeString(n,{hour:"2-digit",minute:"2-digit"});if(r.getTime()-t.getTime()<7*864e5){const o=t.toLocaleDateString(n,{weekday:"short"});return o.charAt(0).toUpperCase()+o.slice(1)}return t.toLocaleDateString(n,{day:"2-digit",month:"2-digit"})}}},Au=["aria-label"],xu={key:1,class:"wm-onb__hero-deco",width:"180",height:"180",viewBox:"0 0 180 180",fill:"none","aria-hidden":"true"},Tu={class:"wm-onb__hero-text"},Mu={class:"wm-onb__hero-default"},Eu={class:"wm-onb__title"},Ou={class:"wm-onb__sub"},Ru={key:0,class:"wm-onb__welcome"},Iu={key:0,class:"wm-onb__alertList"},Lu=["onClick"],Pu={key:0,class:"wm-onb__defaultAvatar"},Bu=["aria-label"],Fu={class:"wm-onb__alert-body"},Du={class:"wm-onb__alert-title"},Nu={class:"wm-onb__alert-preview"},Hu={key:0,class:"wm-onb__alert-sender"},Uu=["innerHTML"],ju={class:"wm-onb__alert-meta"},Vu={key:0,class:"wm-onb__alert-time"},Ku={class:"wm-onb__alert-resume"},zu={class:"wm-onb__actions"},Wu=["onClick"],$u={class:"wm-onb__btn-icon"},qu=["aria-label"],Gu={key:1,width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.9","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},Yu=["d"],Ju={class:"wm-onb__btn-label"},Xu={key:0,class:"wm-onb__btn-trail",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"},Qu={class:"wm-onb__btn-icon"},Zu={width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},ed=["d"],td={class:"wm-onb__btn-label"},nd={class:"wm-onb__btn-count"},sd=["placeholder","disabled","aria-label"],rd=["disabled","aria-label"],id={key:0,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},od={key:1,class:"wm-onb__starter-spinner","aria-hidden":"true"};function ad(e,t,n,r,i,s){const o=ve("AIAvatar");return h(),p("div",{class:te(["wm-onb",{"wm-onb--launching":i.launchPhase!=="idle","wm-onb--sliding":i.launchPhase==="slide","wm-onb--focused":i.inputFocused,"wm-onb--typing":s.typing}])},[u("div",{class:te(["wm-onb__hero",{"wm-onb__hero--cover":s.hasCover}])},[s.hasCover?(h(),p("div",{key:0,class:"wm-onb__cover",style:Ce(s.coverStyle),role:"img","aria-label":s.heroTitle},null,12,Au)):F("",!0),s.hasCover?F("",!0):(h(),p("svg",xu,[...t[7]||(t[7]=[u("circle",{cx:"170",cy:"10",r:"105",stroke:"#5B5FEF","stroke-width":"1","stroke-dasharray":"1 5",opacity:"0.35"},null,-1),u("circle",{cx:"170",cy:"10",r:"72",stroke:"#5B5FEF","stroke-width":"1","stroke-dasharray":"1 5",opacity:"0.5"},null,-1),u("circle",{cx:"152",cy:"34",r:"2.5",fill:"#5B5FEF",opacity:"0.65"},null,-1)])])),pe(o,{size:52,"image-url":n.defaultIconUrl},null,8,["image-url"]),u("div",Tu,[u("div",Mu,[u("div",Eu,R(s.heroTitle),1),u("div",Ou,R(s.heroSub),1)]),n.welcomeMessage?(h(),p("div",Ru,R(n.welcomeMessage),1)):F("",!0)])],2),s.unreadThreads.length?(h(),p("div",Iu,[(h(!0),p(Z,null,Se(s.unreadThreads,a=>(h(),p("button",{key:a.id,type:"button",class:"wm-onb__alert",onClick:l=>e.$emit("resume",a)},[u("span",{class:te(["wm-onb__alert-avatar",s.avatarWrapperClass(a)])},[s.isDefaultAvatar(a)?(h(),p("span",Pu,[...t[8]||(t[8]=[u("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"},[u("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)])])):(h(),fe(qs(s.avatarComponent(a)),Xs({key:1,ref_for:!0},s.avatarProps(a)),null,16)),u("span",{class:"wm-onb__alert-dot","aria-label":s.t("onboarding.unread")},null,8,Bu)],2),u("span",Fu,[u("span",Du,R(a.title),1),u("span",Nu,[s.senderLabel(a)?(h(),p("span",Hu,R(s.senderLabel(a))+" ยท ",1)):F("",!0),u("span",{innerHTML:s.renderPreview(a.preview)},null,8,Uu)])]),u("span",ju,[s.formatTs(a._ts)?(h(),p("span",Vu,R(s.formatTs(a._ts)),1)):F("",!0),u("span",Ku,R(s.t("onboarding.resume")),1)])],8,Lu))),128))])):F("",!0),u("div",zu,[(h(!0),p(Z,null,Se(n.quickLinks,(a,l)=>(h(),p("button",{key:"ql-"+l,type:"button",class:"wm-onb__btn",onClick:d=>e.$emit("select",a)},[u("span",$u,[s.safeIconUrl(a)?(h(),p("span",{key:0,class:"wm-onb__btn-iconImg",style:Ce(s.iconUrlStyle(a)),role:"img","aria-label":a.label||""},null,12,qu)):(h(),p("svg",Gu,[u("path",{d:s.iconPath(a.icon)},null,8,Yu)]))]),u("span",Ju,R(a.label),1),s.isExternalLink(a)?(h(),p("svg",Xu,[...t[9]||(t[9]=[u("path",{d:"M7 17L17 7M9 7h8v8"},null,-1)])])):F("",!0)],8,Wu))),128)),n.openThreads.length?(h(),p("button",{key:0,type:"button",class:"wm-onb__btn",onClick:t[0]||(t[0]=a=>e.$emit("view-history"))},[u("span",Qu,[(h(),p("svg",Zu,[u("path",{d:s.iconPath("chat")},null,8,ed)]))]),u("span",td,R(s.t("onboarding.allConversations")),1),u("span",nd,R(n.openThreads.length),1),t[10]||(t[10]=u("svg",{class:"wm-onb__btn-trail",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"},[u("path",{d:"M9 18l6-6-6-6"})],-1))])):F("",!0),u("form",{ref:"starterForm",class:te(["wm-onb__starter",{"is-active":!!i.starterText.trim(),"is-expanded":i.inputFocused,"wm-onb__starter--toBottom":i.launchPhase==="slide"}]),onSubmit:t[6]||(t[6]=We((...a)=>s.submitStarter&&s.submitStarter(...a),["prevent"]))},[st(u("textarea",{ref:"starterInput","onUpdate:modelValue":t[1]||(t[1]=a=>i.starterText=a),class:"wm-onb__starter-input",rows:"1",placeholder:s.t("onboarding.starterPlaceholder"),disabled:n.busy,"aria-label":s.t("onboarding.start"),enterkeyhint:"send",onKeydown:t[2]||(t[2]=(...a)=>s.onStarterKeydown&&s.onStarterKeydown(...a)),onInput:t[3]||(t[3]=(...a)=>s.autosize&&s.autosize(...a)),onFocus:t[4]||(t[4]=(...a)=>s.onInputFocus&&s.onInputFocus(...a)),onBlur:t[5]||(t[5]=(...a)=>s.onInputBlur&&s.onInputBlur(...a))},null,40,sd),[[kt,i.starterText]]),u("button",{type:"submit",class:te(["wm-onb__starter-send",{"is-empty":!s.canStart}]),disabled:n.busy||!s.canStart,"aria-label":s.t("composer.send")},[n.busy?(h(),p("span",od)):(h(),p("svg",id,[...t[11]||(t[11]=[u("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"},null,-1)])]))],10,rd)],34)])],2)}const ld=be(Su,[["render",ad],["__scopeId","data-v-cfaffcfa"]]),cd={name:"WmHistory",components:{AIAvatar:Sn,HumanAvatar:rs},inject:{t:{default:()=>Ee()},wmLocale:{default:()=>()=>"fr"}},props:{threads:{type:Array,default:()=>[]}},emits:["resume"],data(){return{query:""}},computed:{filteredThreads(){const e=this.query.trim().toLowerCase();return e?this.threads.filter(t=>(t.title||"").toLowerCase().includes(e)||(t.preview||"").toLowerCase().includes(e)):this.threads}},methods:{renderPreview(e){return Mo(e)},avatarComponent(e){var t;return((t=e==null?void 0:e.author)==null?void 0:t.type)==="agent_human"?"HumanAvatar":"AIAvatar"},avatarProps(e){const t=e==null?void 0:e.author;return(t==null?void 0:t.type)==="agent_human"?{size:40,name:t.name||"",avatarUrl:t.avatar_url||null}:{size:40,name:(t==null?void 0:t.name)||"",imageUrl:(t==null?void 0:t.avatar_url)||null}},isDefaultAvatar(e){const t=e==null?void 0:e.author;return!(t!=null&&t.avatar_url||t!=null&&t.name)},avatarWrapperClass(e){return this.isDefaultAvatar(e)&&!(e!=null&&e.unread)?"wm-hist__avatar--muted":null},formatTs(e){if(!e)return"";const t=new Date(e);if(Number.isNaN(t.getTime()))return"";const n=Bt(this.wmLocale()),r=new Date;if(t.toDateString()===r.toDateString())return t.toLocaleTimeString(n,{hour:"2-digit",minute:"2-digit"});if(r.getTime()-t.getTime()<7*864e5){const o=t.toLocaleDateString(n,{weekday:"short"});return o.charAt(0).toUpperCase()+o.slice(1)}return t.toLocaleDateString(n,{day:"2-digit",month:"2-digit"})}}},ud={class:"wm-hist"},dd={class:"wm-hist__search"},fd=["placeholder","aria-label"],hd={class:"wm-hist__list"},md=["onClick"],gd={key:0,class:"wm-hist__defaultAvatar"},pd=["aria-label"],_d={class:"wm-hist__thread-body"},yd={class:"wm-hist__thread-title"},vd=["innerHTML"],bd={class:"wm-hist__thread-meta"},wd={key:0,class:"wm-hist__thread-time"},kd={key:0,class:"wm-hist__empty"};function Cd(e,t,n,r,i,s){return h(),p("div",ud,[u("div",dd,[t[1]||(t[1]=u("span",{class:"wm-hist__searchIcon"},[u("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"},[u("path",{d:"M21 21l-4.35-4.35M11 17a6 6 0 100-12 6 6 0 000 12z"})])],-1)),st(u("input",{"onUpdate:modelValue":t[0]||(t[0]=o=>i.query=o),type:"text",placeholder:s.t("onboarding.search"),"aria-label":s.t("onboarding.search")},null,8,fd),[[kt,i.query]])]),u("div",hd,[(h(!0),p(Z,null,Se(s.filteredThreads,o=>(h(),p("button",{key:o.id,type:"button",class:te(["wm-hist__thread",{"wm-hist__thread--unread":o.unread}]),onClick:a=>e.$emit("resume",o)},[u("span",{class:te(["wm-hist__thread-avatar",s.avatarWrapperClass(o)])},[s.isDefaultAvatar(o)?(h(),p("span",gd,[...t[2]||(t[2]=[u("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[u("path",{d:"M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"})],-1)])])):(h(),fe(qs(s.avatarComponent(o)),Xs({key:1,ref_for:!0},s.avatarProps(o)),null,16)),o.unread?(h(),p("span",{key:2,class:"wm-hist__thread-dot","aria-label":s.t("onboarding.unread")},null,8,pd)):F("",!0)],2),u("span",_d,[u("span",yd,R(o.title),1),u("span",{class:"wm-hist__thread-preview",innerHTML:s.renderPreview(o.preview)},null,8,vd)]),u("span",bd,[s.formatTs(o._ts)?(h(),p("span",wd,R(s.formatTs(o._ts)),1)):F("",!0),t[3]||(t[3]=u("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-hist__thread-chev","aria-hidden":"true"},[u("path",{d:"M5 12h14M13 5l7 7-7 7"})],-1))])],10,md))),128)),s.filteredThreads.length?F("",!0):(h(),p("div",kd,R(i.query?s.t("onboarding.noResults",{query:i.query}):s.t("onboarding.noConversations")),1))])])}const Sd=be(cd,[["render",Cd],["__scopeId","data-v-6bf35ef1"]]);function Ad(e){return typeof e!="string"?"":e.replace(/`([^`]+)`/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(new RegExp("(?<!\\*)\\*([^*]+)\\*(?!\\*)","g"),"$1").replace(/__([^_]+)__/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\s+/g," ").trim()}const xd={name:"WmActionResult",props:{state:{type:String,default:"success"},label:{type:String,required:!0},detail:{type:String,default:""}},computed:{detailText(){return Ad(this.detail)}}},Td={class:"wm-result__icon","aria-hidden":"true"},Md={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"},Ed={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"},Od={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"},Rd={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"},Id={class:"wm-result__body"},Ld={class:"wm-result__label"},Pd={class:"wm-result__detail"};function Bd(e,t,n,r,i,s){return h(),p("div",{class:te(["wm-result",`wm-result--${n.state}`])},[u("span",Td,[n.state==="success"?(h(),p("svg",Md,[...t[0]||(t[0]=[u("path",{d:"M20 6L9 17l-5-5"},null,-1)])])):n.state==="rejected"?(h(),p("svg",Ed,[...t[1]||(t[1]=[u("path",{d:"M18 6L6 18M6 6l12 12"},null,-1)])])):n.state==="awaiting"?(h(),p("svg",Od,[...t[2]||(t[2]=[u("circle",{cx:"12",cy:"12",r:"10"},null,-1),u("polyline",{points:"12 7 12 12 15 14"},null,-1)])])):(h(),p("svg",Rd,[...t[3]||(t[3]=[u("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),u("line",{x1:"12",y1:"9",x2:"12",y2:"13"},null,-1),u("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"},null,-1)])]))]),u("span",Id,[u("span",Ld,R(n.label),1),s.detailText?(h(),p(Z,{key:0},[t[4]||(t[4]=u("span",{class:"wm-result__sep","aria-hidden":"true"}," ยท ",-1)),u("span",Pd,R(s.detailText),1)],64)):F("",!0)])],2)}const Fd=be(xd,[["render",Bd],["__scopeId","data-v-7284acd0"]]),Dd={name:"WmArtifactFormResponse",inject:{t:{default:()=>Ee()}},props:{data:{type:Object,required:!0}},computed:{fields(){var e;return Array.isArray((e=this.data)==null?void 0:e.fields)?this.data.fields:[]}}},Nd={class:"wm-art wm-art--formResponse"},Hd={class:"wm-art__head"},Ud={class:"wm-art__title"},jd={class:"wm-art__badge wm-art__badge--success"},Vd={class:"wm-art__body"},Kd={class:"wm-art__fieldLabel"};function zd(e,t,n,r,i,s){return h(),p("div",Nd,[u("div",Hd,[u("div",Ud,R(n.data.title||s.t("form.title")),1),u("span",jd,[t[0]||(t[0]=u("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"},[u("polyline",{points:"20 6 9 17 4 12"})],-1)),ns(" "+R(s.t("form.sent")),1)])]),u("div",Vd,[(h(!0),p(Z,null,Se(s.fields,(o,a)=>(h(),p("div",{key:a,class:"wm-art__field"},[u("div",Kd,R(o.label),1),u("div",{class:te(["wm-art__fieldValue",{"wm-art__fieldValue--multi":o.multiline}])},R(o.value),3)]))),128))])])}const Wd=be(Dd,[["render",zd],["__scopeId","data-v-713aecf1"]]),$d={name:"WmArtifactInfoCard",props:{data:{type:Object,required:!0}},computed:{fields(){var e;return Array.isArray((e=this.data)==null?void 0:e.fields)?this.data.fields:[]},hasBody(){var e;return!!((e=this.data)!=null&&e.body)||this.fields.length>0}}},qd={class:"wm-art wm-art--infoCard"},Gd={key:0,class:"wm-art__image"},Yd=["src","alt"],Jd={class:"wm-art__head"},Xd={class:"wm-art__headMain"},Qd={class:"wm-art__title"},Zd={key:0,class:"wm-art__subtitle"},ef={key:1,class:"wm-art__body"},tf={key:0,class:"wm-art__text"},nf={class:"wm-art__fieldLabel"};function sf(e,t,n,r,i,s){return h(),p("div",qd,[n.data.image_url?(h(),p("figure",Gd,[u("img",{src:n.data.image_url,alt:n.data.title||"",loading:"lazy"},null,8,Yd)])):F("",!0),u("div",Jd,[u("div",Xd,[u("div",Qd,R(n.data.title),1),n.data.subtitle?(h(),p("div",Zd,R(n.data.subtitle),1)):F("",!0)]),n.data.badge&&n.data.badge.label?(h(),p("span",{key:0,class:te(["wm-art__badge",`wm-art__badge--${n.data.badge.tone||"neutral"}`])},R(n.data.badge.label),3)):F("",!0)]),s.hasBody?(h(),p("div",ef,[n.data.body?(h(),p("div",tf,R(n.data.body),1)):F("",!0),s.fields.length?(h(!0),p(Z,{key:1},Se(s.fields,(o,a)=>(h(),p("div",{key:a,class:"wm-art__field"},[u("div",nf,R(o.label),1),u("div",{class:te(["wm-art__fieldValue",{"wm-art__fieldValue--multi":o.multiline}])},R(o.value),3)]))),128)):F("",!0)])):F("",!0)])}const rf=be($d,[["render",sf],["__scopeId","data-v-7eae0e4a"]]);function of(e,t,n){if(!e)return"";const r=new Date(e);if(Number.isNaN(r.getTime()))return e;const i=r.toLocaleDateString(t,{day:"numeric",month:"long",year:"numeric"}),s=r.toLocaleTimeString(t,{hour:"2-digit",minute:"2-digit"});return`${i}${n}${s}`}const af={name:"WmArtifactTicket",inject:{t:{default:()=>Ee()},wmLocale:{default:()=>()=>"fr"}},props:{data:{type:Object,required:!0}},computed:{fields(){var e;return Array.isArray((e=this.data)==null?void 0:e.fields)?this.data.fields:[]},formattedDate(){var e;return of((e=this.data)==null?void 0:e.created_at,Bt(this.wmLocale()),this.t("ticket.dateAt"))}},methods:{isPriority(e){return/priorit|^prio$/i.test(String(e||"").trim())},isDate(e){return/date|รฉchรฉanc|echeanc|deadline|due|crรฉรฉ|cree/i.test(String(e||"").trim())},priorityLevel(e){const t=String(e||"").toLowerCase();return/high|haute|รฉlev|elev|critic|critiq|urgent/.test(t)?3:/low|basse|faible|minor/.test(t)?1:2}}},lf={class:"wm-art wm-art--ticket"},cf={class:"wm-art__head wm-tk__head"},uf={class:"wm-art__title wm-tk__title"},df={class:"wm-tk__sub"},ff={class:"wm-tk__ref"},hf={key:0,class:"wm-tk__text"},mf={key:0,class:"wm-art__body"},gf={class:"wm-art__fieldLabel"},pf=["data-level"],_f={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"},yf={key:1,class:"wm-art__footer wm-tk__footer"};function vf(e,t,n,r,i,s){return h(),p("div",lf,[u("div",cf,[u("div",uf,R(n.data.title),1),u("div",df,[u("div",ff,[t[0]||(t[0]=u("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"},[u("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"}),u("path",{d:"M13 5v2M13 17v2M13 11v2"})],-1)),u("span",null,R(n.data.reference),1)]),u("span",{class:te(["wm-art__badge","wm-tk__badge",`wm-art__badge--${n.data.status.tone||"neutral"}`])},[t[1]||(t[1]=u("span",{class:"wm-tk__dot","aria-hidden":"true"},null,-1)),ns(" "+R(n.data.status.label),1)],2)]),n.data.body?(h(),p("div",hf,R(n.data.body),1)):F("",!0)]),s.fields.length?(h(),p("div",mf,[(h(!0),p(Z,null,Se(s.fields,(o,a)=>(h(),p("div",{key:a,class:"wm-art__field"},[u("div",gf,R(o.label),1),u("div",{class:te(["wm-art__fieldValue",{"wm-art__fieldValue--multi":o.multiline}])},[s.isPriority(o.label)?(h(),p("svg",{key:0,class:"wm-tk__prio","data-level":s.priorityLevel(o.value),width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true"},[...t[2]||(t[2]=[u("rect",{x:"1",y:"8",width:"2",height:"3",rx:"0.5"},null,-1),u("rect",{x:"5",y:"5",width:"2",height:"6",rx:"0.5"},null,-1),u("rect",{x:"9",y:"2",width:"2",height:"9",rx:"0.5"},null,-1)])],8,pf)):s.isDate(o.label)?(h(),p("svg",_f,[...t[3]||(t[3]=[u("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"},null,-1),u("path",{d:"M16 2v4M8 2v4M3 10h18"},null,-1)])])):F("",!0),u("span",null,R(o.value),1)],2)]))),128))])):F("",!0),n.data.created_at?(h(),p("div",yf,[t[4]||(t[4]=u("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"},[u("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),u("path",{d:"M16 2v4M8 2v4M3 10h18"})],-1)),u("span",null,R(s.formattedDate),1)])):F("",!0)])}const bf=be(af,[["render",vf],["__scopeId","data-v-5f30c914"]]),wf={form_response:Wd,info_card:rf,ticket:bf},kf={name:"WmArtifactRenderer",props:{artifact:{type:Object,required:!0}},computed:{component(){var t;const e=(t=this.artifact)==null?void 0:t.kind;return e&&wf[e]||null}}};function Cf(e,t,n,r,i,s){return s.component?(h(),fe(qs(s.component),{key:0,data:n.artifact.data},null,8,["data"])):F("",!0)}const Sf=be(kf,[["render",Cf]]),Af={name:"WmAttachmentPreview",inject:{signAttachmentFn:{default:null},t:{default:()=>Ee()}},props:{attachment:{type:Object,required:!0}},data(){return{url:null,loading:!1}},computed:{kind(){var n,r;const e=(n=this.attachment)==null?void 0:n.type;if(e)return e;const t=(((r=this.attachment)==null?void 0:r.mime_type)||"").toLowerCase();return t.startsWith("image/")?"image":t.startsWith("audio/")?"audio":t.startsWith("video/")?"video":"file"},displayName(){var e,t,n;return((t=(e=this.attachment)==null?void 0:e.metadata)==null?void 0:t.name)||((n=this.attachment)==null?void 0:n.name)||this.guessNameFromPath()||this.t("attachment.fallbackName")},safeHref(){const e=String(this.url||"").trim();return/^(https?:\/\/|blob:|data:image\/)/i.test(e)?e:"#"},sizeLabel(){var t;const e=(t=this.attachment)==null?void 0:t.size_bytes;return e?e<1024?this.t("attachment.bytes",{size:e}):e<1024*1024?this.t("attachment.kilobytes",{size:(e/1024).toFixed(0)}):this.t("attachment.megabytes",{size:(e/(1024*1024)).toFixed(1)}):""}},watch:{"attachment.path":{handler(){this.refresh()},immediate:!0}},methods:{guessNameFromPath(){var n;return((((n=this.attachment)==null?void 0:n.path)||"").split("/").pop()||"").replace(/^[0-9a-f-]{8,}-/,"")},async refresh(){var e;if(!(!((e=this.attachment)!=null&&e.path)||!this.signAttachmentFn)){this.loading=!0;try{this.url=await this.signAttachmentFn(this.attachment.path)}finally{this.loading=!1}}},onFileClick(e){this.safeHref==="#"&&e.preventDefault()}}},xf=["href"],Tf=["src","alt"],Mf=["src"],Ef=["src"],Of=["href","download"],Rf={class:"wm-att__main"},If={class:"wm-att__name"},Lf={key:0,class:"wm-att__meta"},Pf={key:0,class:"wm-att__spin","aria-hidden":"true"};function Bf(e,t,n,r,i,s){return h(),p("div",{class:te(["wm-att",["wm-att--"+(s.kind||"file")]])},[s.kind==="image"&&i.url?(h(),p("a",{key:0,href:s.safeHref,target:"_blank",rel:"noopener",class:"wm-att__imgWrap"},[u("img",{src:i.url,alt:s.displayName,loading:"lazy"},null,8,Tf)],8,xf)):s.kind==="audio"&&i.url?(h(),p("audio",{key:1,src:i.url,controls:"",preload:"metadata"},null,8,Mf)):s.kind==="video"&&i.url?(h(),p("video",{key:2,src:i.url,controls:"",playsinline:"",preload:"auto"},null,8,Ef)):(h(),p("a",{key:3,class:"wm-att__file",href:s.safeHref,download:s.displayName,target:"_blank",rel:"noopener",onClick:t[0]||(t[0]=(...o)=>s.onFileClick&&s.onFileClick(...o))},[t[1]||(t[1]=u("span",{class:"wm-att__icon"},[u("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"},[u("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"}),u("path",{d:"M14 2v6h6"})])],-1)),u("span",Rf,[u("span",If,R(s.displayName),1),s.sizeLabel?(h(),p("span",Lf,R(s.sizeLabel),1)):F("",!0)]),i.loading?(h(),p("span",Pf)):F("",!0)],8,Of))],2)}const Ff=be(Af,[["render",Bf],["__scopeId","data-v-b207a8bd"]]),Df={name:"WmBubble",props:{role:{type:String,default:"ai"},text:{type:String,default:""}},computed:{rendered(){return Sc(this.text)}}},Nf=["innerHTML"];function Hf(e,t,n,r,i,s){return h(),p("div",{class:te(["wm-bubble","wm-bubble--"+n.role])},[Fa(e.$slots,"default",{},()=>[u("span",{innerHTML:s.rendered},null,8,Nf)])],2)}const Uf=be(Df,[["render",Hf],["__scopeId","data-v-7ab13147"]]),jf={name:"WmTyping"},Vf={class:"wm-typing"};function Kf(e,t,n,r,i,s){return h(),p("div",Vf,[...t[0]||(t[0]=[u("span",{style:{"animation-delay":"0s"}},null,-1),u("span",{style:{"animation-delay":"0.2s"}},null,-1),u("span",{style:{"animation-delay":"0.4s"}},null,-1)])])}const zf=be(jf,[["render",Kf],["__scopeId","data-v-df2447fd"]]);function Ot(e){return e?e.client_msg_id||e.id:""}const Wf={transferred_to_human:"system.transferredToHuman",assigned:"system.assigned",unassigned:"system.unassigned",resolved:"system.resolved",closed:"system.closed",reopened:"system.reopened",idle:"system.idle"},$f=80,qf=200,Gf={name:"WmMessageList",components:{AIAvatar:Sn,HumanAvatar:rs,Bubble:Uf,Typing:zf,ActionResult:Fd,AttachmentPreview:Ff,ArtifactRenderer:Sf},inject:{t:{default:()=>Ee()},wmLocale:{default:()=>()=>"fr"}},props:{messages:{type:Array,default:()=>[]},streamingActive:{type:Boolean,default:!1},dateLabel:{type:String,default:""},conversationId:{type:[String,Number],default:null},loadingMore:{type:Boolean,default:!1},hasMore:{type:Boolean,default:!1},unreadAnchorId:{type:Number,default:null},unreadBoundaryTs:{type:String,default:""},aiAgentName:{type:String,default:""},aiAgentAvatarUrl:{type:String,default:null}},emits:["load-more"],data(){return{silentFades:!1,widthByKey:Object.freeze({}),showScrollDown:!1,pressedItemKey:null}},computed:{historyExhausted(){return!this.hasMore&&!this.loadingMore&&this.messages.length>=20},groups(){var n,r,i,s,o;const e=[];for(const a of this.messages){if((n=a==null?void 0:a.metadata)!=null&&n.resolution_request)continue;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 m=e[e.length-1];m&&m.role==="ai"?m.messages.push(a):e.push({key:`g-${Ot(a)}`,role:"ai",agentName:"",agentAvatarUrl:null,messages:[a],items:[]});continue}e.push({key:`sys-${Ot(a)}`,role:l,messages:[a],items:[],systemLabel:this.systemLabel(a)});continue}const d=e[e.length-1];d&&d.role===l&&(l==="ai"||d.agentName===(((i=a==null?void 0:a.author)==null?void 0:i.name)||""))?d.messages.push(a):e.push({key:`g-${Ot(a)}`,role:l,agentName:((s=a==null?void 0:a.author)==null?void 0:s.name)||"",agentAvatarUrl:((o=a==null?void 0:a.author)==null?void 0:o.avatar_url)||null,messages:[a],items:[]})}for(const a of e){if(a.role==="system")continue;const l=[];for(const d of a.messages)for(const c of this.itemsOf(d))l.push(c);a.items=l}const t=[];for(const a of e){if(a.role!=="system"&&!a.items.length)continue;const l=t[t.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}t.push(a)}for(const a of t)a.role!=="system"&&(a.key=this.stableGroupKey(a.messages));return t},unreadGroupKey(){if(this.unreadAnchorId==null)return null;const e=this.unreadAnchorId,t=this.unreadBoundaryTs;for(const n of this.groups){if(n.role==="user"||n.role==="system"||!n.items.length)continue;const r=n.messages[0];if(!r)continue;const i=ht(r.id);if(i!=null&&!(i<=e)&&!(t&&r.created_at&&r.created_at>t))return n.key}return null}},watch:{messages:{handler:"snapshotAndRestore",deep:!0},conversationId(e,t){e!==t&&(this._groupIdByMsgKey=null,this.silentFades=!1)},loadingMore(e){e||(this._pendingLoadMore=!1),e&&(this.silentFades=!0),this.snapshotAndRestore()},streamingActive:"snapshotAndRestore"},mounted(){this._lastSeenConvId=this.conversationId,this.scrollToBottom(),this._measureFrame=null,this._ro=new ResizeObserver(()=>this.scheduleMeasure()),this.$refs.scrollEl&&this._ro.observe(this.$refs.scrollEl),this.$nextTick(()=>this.measureRows())},beforeUnmount(){var e;(e=this._ro)==null||e.disconnect(),this._measureFrame&&cancelAnimationFrame(this._measureFrame),this._pinFrame&&cancelAnimationFrame(this._pinFrame),this._pressTimer&&clearTimeout(this._pressTimer)},updated(){this.scheduleMeasure()},methods:{messageKey:Ot,stableGroupKey(e){this._groupIdByMsgKey||(this._groupIdByMsgKey=new Map,this._groupIdCounter=0);const t=this._groupIdByMsgKey;let n=null;for(const r of e){const i=Ot(r);if(i&&t.has(i)){n=t.get(i);break}}n==null&&(n=++this._groupIdCounter);for(const r of e){const i=Ot(r);i&&t.set(i,n)}return`g-${n}`},isAtBottom(e){return e.scrollHeight-e.scrollTop-e.clientHeight<=$f},onScroll(){const e=this.$refs.scrollEl;e&&(this.showScrollDown=!this.isAtBottom(e),!(this.loadingMore||!this.hasMore)&&(this._pendingLoadMore||e.scrollTop<=qf&&(this._pendingLoadMore=!0,this.$emit("load-more"))))},snapshotAndRestore(){const e=this.$refs.scrollEl;if(!e||this._scrollSnap)return;const t=this._lastSeenConvId!==this.conversationId;this._lastSeenConvId=this.conversationId;const n=this.isAtBottom(e);let r=null;if(!t&&!n){const s=this.pickAnchor(e);if(s!=null&&s.rowKey){const o=this.findRowByKey(e,s.rowKey);if(o){const a=e.getBoundingClientRect().top;r={rowKey:s.rowKey,relY:o.getBoundingClientRect().top-a}}}}const i={forceBottom:t,wasPinned:n,anchor:r};this._scrollSnap=i,this.$nextTick(()=>{if(this._scrollSnap=null,i.forceBottom||i.wasPinned){e.scrollTop=e.scrollHeight;return}if(!i.anchor)return;const s=()=>{const o=i.anchor,a=this.findRowByKey(e,o.rowKey);if(!a)return;const d=a.getBoundingClientRect().top-e.getBoundingClientRect().top-o.relY;Math.abs(d)>.5&&(e.scrollTop+=d)};s(),requestAnimationFrame(()=>{s(),requestAnimationFrame(s)})})},pickAnchor(e){const t=e.getBoundingClientRect().top,n=e.querySelectorAll(".wm-list__row[data-row-key]");let r=null;for(const i of n)if(r||(r=i),i.getBoundingClientRect().bottom>=t)return{rowKey:i.dataset.rowKey};return r?{rowKey:r.dataset.rowKey}:null},findRowByKey(e,t){if(!t)return null;const n=typeof CSS<"u"&&CSS.escape?CSS.escape(t):t.replace(/["\\]/g,"\\$&");return e.querySelector(`.wm-list__row[data-row-key="${n}"]`)},roleOf(e){var n,r;if((e==null?void 0:e.type)==="system"||((n=e==null?void 0:e.payload)==null?void 0:n.type)==="system")return"system";const t=(r=e==null?void 0:e.author)==null?void 0:r.type;return t==="user"?"user":t==="agent_human"?"human":"ai"},roleLabel(e){if(e.role==="human")return e.agentName||this.t("common.agent");const t=this.t("common.aiAssistant");return this.aiAgentName?`${this.aiAgentName} โข ${t}`:t},itemsOf(e){var t;if(!e)return[];if(e.type==="system"&&((t=e==null?void 0:e.payload)==null?void 0:t.event)==="action_admin_pending")return[{message:e,partKey:"main",renderAs:"admin-pending",kind:{top:"bubble",bottom:"bubble"}}];if(e.type==="action"&&e.payload&&e.payload.state!=="pending"){const n=[{message:e,partKey:"main",renderAs:"action",kind:{top:"bubble",bottom:"bubble"}}];return this.actionArtifact(e)&&n.push({message:e,partKey:"artifact",renderAs:"artifact-of-action",kind:{top:"card",bottom:"card"}}),n}return this.artifactOf(e)?[{message:e,partKey:"main",renderAs:"artifact",kind:{top:"card",bottom:"card"}}]:e.text_md||this.attachmentsOf(e).length?[{message:e,partKey:"main",renderAs:"bubble",kind:{top:"bubble",bottom:"bubble"}}]:[]},cornersFor(e,t){var V,re,ce;const n=e.items,r=(V=n[t])==null?void 0:V.kind,i=(re=n[t-1])==null?void 0:re.kind,s=(ce=n[t+1])==null?void 0:ce.kind,o=e.role==="user",a=14,l=4,d=i==null?void 0:i.bottom,c=s==null?void 0:s.top,m=this.widthByKey[this.rowKeyOf(e,t)],C=this.widthByKey[this.rowKeyOf(e,t-1)],b=this.widthByKey[this.rowKeyOf(e,t+1)],K=.5,S=(_e,we,G)=>_e!=null&&m!=null?_e+K>=m:we===G||we==="card"&&G==="bubble";let J=a,U=a,$=a,ne=a;return o?(d&&(U=l),(c||!s)&&($=l),d&&S(C,d,r==null?void 0:r.top)&&(J=l),c&&S(b,c,r==null?void 0:r.bottom)&&(ne=l)):(d&&(J=l),(c||!s)&&(ne=l),d&&S(C,d,r==null?void 0:r.top)&&(U=l),c&&S(b,c,r==null?void 0:r.bottom)&&($=l)),{tl:J,tr:U,br:$,bl:ne}},mosaicGridStyle(e){return!e||e<2?null:{"grid-template-columns":`repeat(${Math.min(e,4)}, 1fr)`}},mosaicCornerStyle(e,t,n){if(!t||t<2)return null;const r=Math.min(t,4),i=Math.floor(e/r),s=e%r,o=s>0,a=s<r-1&&e+1<t,l=i>0,d=e+r<t,c="4px",m={};return(o||l)&&(m["--wm-r-tl"]=c),(a||l)&&(m["--wm-r-tr"]=c),(o||d)&&(m["--wm-r-bl"]=c),(a||d)&&(m["--wm-r-br"]=c),n&&(m["--wm-r-tl"]=c,m["--wm-r-tr"]=c),Object.keys(m).length?m:null},cornersStyle(e,t){if(e.items.length<2)return null;const n=this.cornersFor(e,t);return{"--wm-r-tl":`${n.tl}px`,"--wm-r-tr":`${n.tr}px`,"--wm-r-br":`${n.br}px`,"--wm-r-bl":`${n.bl}px`}},rowKeyOf(e,t){var r;const n=(r=e==null?void 0:e.items)==null?void 0:r[t];return n?`${Ot(n.message)}-${n.partKey}`:""},scheduleMeasure(){this._measureFrame||(this._measureFrame=requestAnimationFrame(()=>{this._measureFrame=null,this.measureRows()}))},measureRows(){const e=this.$refs.scrollEl;if(!e)return;const t={};for(const s of e.querySelectorAll(".wm-list__row[data-row-key]")){const o=s.dataset.rowKey;if(!o)continue;const a=s.querySelector(".wm-bubble, .wm-result, .wm-art, .wm-list__body");if(!a)continue;const l=a.getBoundingClientRect().width;l>0&&(t[o]=l)}const n=this.widthByKey,r=Object.keys(n),i=Object.keys(t);if(r.length===i.length){let s=!0;for(const o of i)if(Math.abs((n[o]??0)-t[o])>.5){s=!1;break}if(s)return}this.widthByKey=Object.freeze(t)},onPressStart(e){this.onPressEnd(),this._pressTimer=setTimeout(()=>{this._pressTimer=null,this.pressedItemKey=e},400)},onPressEnd(){this._pressTimer&&(clearTimeout(this._pressTimer),this._pressTimer=null),this.pressedItemKey!==null&&(this.pressedItemKey=null)},timeOf(e){if(!(e!=null&&e.created_at))return"";try{return Bs(new Date(e.created_at),Bt(this.wmLocale()))}catch{return""}},lastTimeOf(e){const t=e.items[e.items.length-1],n=(t==null?void 0:t.message)||e.messages[e.messages.length-1];if(!(n!=null&&n.created_at))return"";try{return Bs(new Date(n.created_at),Bt(this.wmLocale()))}catch{return""}},hasTrailingOverlay(e){if(!e.messages.length)return!1;const t=e.messages[e.messages.length-1],n=e.items[e.items.length-1];return!!t&&(n==null?void 0:n.message)!==t},attachmentsOf(e){var n;const t=(n=e==null?void 0:e.payload)==null?void 0:n.attachments;return Array.isArray(t)?t:[]},artifactOf(e){var n;const t=(n=e==null?void 0:e.metadata)==null?void 0:n.artifact;return!t||typeof t!="object"||typeof t.kind!="string"?null:t},actionLabel(e){var t;return((t=e==null?void 0:e.payload)==null?void 0:t.name)||(e==null?void 0:e.text_md)||this.t("common.action")},actionDetail(e){var n,r,i,s,o,a,l,d;const t=e==null?void 0:e.payload;if(!t)return"";if(t.state==="success")return((n=t.success)==null?void 0:n.summary)||((i=(r=t.success)==null?void 0:r.metadata)==null?void 0:i.description)||"";if(t.state==="rejected"){if((s=t.rejected)!=null&&s.reason)return t.rejected.reason;const c=(a=(o=t.rejected)==null?void 0:o.metadata)==null?void 0:a.resolution,m=typeof c=="string"&&c.startsWith("admin")?"action.rejectedByAdmin":"action.rejectedByUser";return this.t(m)}return t.state==="failure"&&(((l=t.failure)==null?void 0:l.summary)||((d=t.failure)==null?void 0:d.error))||""},actionArtifact(e){var n,r;const t=(r=(n=e==null?void 0:e.payload)==null?void 0:n.success)==null?void 0:r.artifact;return!t||typeof t!="object"||typeof t.kind!="string"?null:t},systemLabel(e){var i,s,o;const t=(i=e==null?void 0:e.payload)==null?void 0:i.event,n=Wf[t],r=((s=e==null?void 0:e.metadata)==null?void 0:s.agent_name)||((o=e==null?void 0:e.author)==null?void 0:o.name)||this.t("messageList.anAgent");return n?this.t(n,{name:r}):(e==null?void 0:e.text_md)||this.t("messageList.conversationUpdate")},scrollToBottom(){const e=this.$refs.scrollEl;e&&(e.scrollTop=e.scrollHeight),this.showScrollDown=!1},keepPinnedToBottom(e=320){const t=this.$refs.scrollEl;if(!t)return;this._pinFrame&&cancelAnimationFrame(this._pinFrame);let n=null;const r=i=>{n===null&&(n=i),t.scrollTop=t.scrollHeight,i-n<e?this._pinFrame=requestAnimationFrame(r):this._pinFrame=null};this._pinFrame=requestAnimationFrame(r),this.showScrollDown=!1},scrollToBottomSmooth(){const e=this.$refs.scrollEl;e&&(typeof e.scrollTo=="function"?e.scrollTo({top:e.scrollHeight,behavior:"smooth"}):e.scrollTop=e.scrollHeight,this.showScrollDown=!1)}}},Yf={class:"wm-list__wrap"},Jf={key:0,class:"wm-list__loadMore",role:"status","aria-live":"polite"},Xf={class:"wm-list__loadMore-lbl"},Qf={key:1,class:"wm-list__historyEnd"},Zf={key:2,class:"wm-list__sep"},eh={class:"wm-list__sep-label"},th={key:0,class:"wm-list__sep wm-list__sep--unread"},nh={class:"wm-list__sep-label wm-list__sep-label--unread"},sh={key:0,class:"wm-list__sysep"},rh={class:"wm-list__sysep-label"},ih=["data-row-key","onPointerdown"],oh={key:0,class:"wm-list__avatarSlot"},ah={key:0},lh={key:1,"aria-hidden":"true"},ch={key:2},uh={key:0},dh={key:1,"aria-hidden":"true"},fh={key:2},hh={key:3,class:"wm-list__row wm-list__row--ai fade-up"},mh={class:"wm-list__avatarSlot"},gh=["aria-label","title"];function ph(e,t,n,r,i,s){const o=ve("AIAvatar"),a=ve("HumanAvatar"),l=ve("ActionResult"),d=ve("ArtifactRenderer"),c=ve("Bubble"),m=ve("AttachmentPreview"),C=ve("Typing");return h(),p("div",Yf,[u("div",{ref:"scrollEl",class:te(["wm-list",{"wm-list--silent":i.silentFades}]),onScrollPassive:t[4]||(t[4]=(...b)=>s.onScroll&&s.onScroll(...b))},[n.loadingMore?(h(),p("div",Jf,[t[6]||(t[6]=u("span",{class:"wm-list__loadMore-spinner","aria-hidden":"true"},null,-1)),u("span",Xf,R(s.t("messageList.loadingHistory")),1)])):s.historyExhausted?(h(),p("div",Qf,R(s.t("messageList.conversationStart")),1)):F("",!0),n.dateLabel?(h(),p("div",Zf,[t[7]||(t[7]=u("div",{class:"wm-list__line"},null,-1)),u("span",eh,R(n.dateLabel),1),t[8]||(t[8]=u("div",{class:"wm-list__line"},null,-1))])):F("",!0),(h(!0),p(Z,null,Se(s.groups,(b,K)=>(h(),p(Z,{key:b.key},[b.key===s.unreadGroupKey?(h(),p("div",th,[t[9]||(t[9]=u("div",{class:"wm-list__line wm-list__line--unread"},null,-1)),u("span",nh,R(s.t("messageList.unread")),1),t[10]||(t[10]=u("div",{class:"wm-list__line wm-list__line--unread"},null,-1))])):F("",!0),b.role==="system"||b.items.length?(h(),p("div",{key:1,class:te(["wm-list__group","wm-list__group--"+b.role])},[b.role==="system"?(h(),p("div",sh,[t[11]||(t[11]=u("div",{class:"wm-list__line wm-list__line--strong"},null,-1)),u("span",rh,R(b.systemLabel),1),t[12]||(t[12]=u("div",{class:"wm-list__line wm-list__line--strong"},null,-1))])):(h(),p(Z,{key:1},[(h(!0),p(Z,null,Se(b.items,(S,J)=>(h(),p(Z,{key:`${s.messageKey(S.message)}-${S.partKey}`},[u("div",{"data-row-key":`${s.messageKey(S.message)}-${S.partKey}`,class:te(["wm-list__row fade-up",["wm-list__row--"+b.role,{"is-pending":S.message._pending,"is-failed":S.message._failed}]]),style:Ce(s.cornersStyle(b,J)),onPointerdown:U=>s.onPressStart(`${s.messageKey(S.message)}-${S.partKey}`),onPointerup:t[0]||(t[0]=U=>s.onPressEnd()),onPointercancel:t[1]||(t[1]=U=>s.onPressEnd()),onPointerleave:t[2]||(t[2]=U=>s.onPressEnd()),onContextmenu:t[3]||(t[3]=We(()=>{},["prevent"]))},[b.role!=="user"?(h(),p("div",oh,[J===b.items.length-1?(h(),p(Z,{key:0},[b.role==="ai"?(h(),fe(o,{key:0,size:26,tail:!0,name:n.aiAgentName,"image-url":n.aiAgentAvatarUrl},null,8,["name","image-url"])):(h(),fe(a,{key:1,name:b.agentName,"avatar-url":b.agentAvatarUrl,size:26,tail:!0},null,8,["name","avatar-url"]))],64)):F("",!0)])):F("",!0),S.renderAs==="action"?(h(),fe(l,{key:1,state:S.message.payload.state,label:s.actionLabel(S.message),detail:s.actionDetail(S.message)},null,8,["state","label","detail"])):S.renderAs==="admin-pending"?(h(),fe(l,{key:2,state:"awaiting",label:s.t("messageList.approvalRequestSent"),detail:S.message.text_md||""},null,8,["label","detail"])):S.renderAs==="artifact-of-action"?(h(),fe(d,{key:3,artifact:s.actionArtifact(S.message)},null,8,["artifact"])):S.renderAs==="artifact"?(h(),fe(d,{key:4,artifact:s.artifactOf(S.message)},null,8,["artifact"])):(h(),p("div",{key:5,class:te(["wm-list__body",{"wm-list__body--mixed":!!S.message.text_md&&s.attachmentsOf(S.message).length>0}])},[S.message.text_md?(h(),fe(c,{key:0,role:b.role,text:S.message.text_md},null,8,["role","text"])):F("",!0),s.attachmentsOf(S.message).length?(h(),p("div",{key:1,class:te(["wm-list__atts",{"wm-list__atts--align-end":b.role==="user","wm-list__atts--mosaic":s.attachmentsOf(S.message).length>=2}]),style:Ce(s.mosaicGridStyle(s.attachmentsOf(S.message).length))},[(h(!0),p(Z,null,Se(s.attachmentsOf(S.message),(U,$)=>(h(),fe(m,{key:`${s.messageKey(S.message)}-att-${$}`,attachment:U,style:Ce(s.mosaicCornerStyle($,s.attachmentsOf(S.message).length,!!S.message.text_md))},null,8,["attachment","style"]))),128))],6)):F("",!0)],2))],46,ih),J<b.items.length-1&&i.pressedItemKey===`${s.messageKey(S.message)}-${S.partKey}`&&(b.role!=="user"||s.timeOf(S.message))?(h(),p("div",{key:0,class:te(["wm-list__meta wm-list__meta--press",{"wm-list__meta--right":b.role==="user"}])},[b.role!=="user"?(h(),p("span",ah,R(s.roleLabel(b)),1)):F("",!0),b.role!=="user"&&s.timeOf(S.message)?(h(),p("span",lh,"โข")):F("",!0),s.timeOf(S.message)?(h(),p("span",ch,R(s.timeOf(S.message)),1)):F("",!0)],2)):F("",!0)],64))),128)),i.pressedItemKey===s.rowKeyOf(b,b.items.length-1)&&(b.role!=="user"||s.lastTimeOf(b))&&!s.hasTrailingOverlay(b)?(h(),p("div",{key:0,class:te(["wm-list__meta wm-list__meta--press",{"wm-list__meta--right":b.role==="user"}])},[b.role!=="user"?(h(),p("span",uh,R(s.roleLabel(b)),1)):F("",!0),b.role!=="user"&&s.lastTimeOf(b)?(h(),p("span",dh,"โข")):F("",!0),s.lastTimeOf(b)?(h(),p("span",fh,R(s.lastTimeOf(b)),1)):F("",!0)],2)):F("",!0)],64))],2)):F("",!0)],64))),128)),n.streamingActive?(h(),p("div",hh,[u("div",mh,[pe(o,{size:26,tail:!0,name:n.aiAgentName,"image-url":n.aiAgentAvatarUrl},null,8,["name","image-url"])]),pe(C)])):F("",!0)],34),pe(Qs,{name:"wm-scrollDown"},{default:Xn(()=>[i.showScrollDown?(h(),p("button",{key:0,type:"button",class:"wm-list__scrollDown","aria-label":s.t("messageList.scrollToBottom"),title:s.t("messageList.scrollToBottom"),onClick:t[5]||(t[5]=(...b)=>s.scrollToBottomSmooth&&s.scrollToBottomSmooth(...b))},[...t[13]||(t[13]=[u("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[u("path",{d:"M6 9l6 6 6-6"})],-1)])],8,gh)):F("",!0)]),_:1})])}const _h=be(Gf,[["render",ph],["__scopeId","data-v-5a563f2b"]]),jn=typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function",nr=typeof window<"u"&&typeof window.MediaRecorder<"u";function yh(){return nr&&["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm","video/mp4"].find(t=>{var n,r;return(r=(n=window.MediaRecorder).isTypeSupported)==null?void 0:r.call(n,t)})||""}function Eo({audio:e}){return{video:!0,audio:!!e,selfBrowserSurface:"include",surfaceSwitching:"include",systemAudio:e?"include":"exclude"}}async function vh(){if(!jn)return null;let e;try{e=await navigator.mediaDevices.getDisplayMedia(Eo({audio:!1}))}catch(t){return(t==null?void 0:t.name)!=="NotAllowedError"&&console.error("[media] screenshot picker",t),null}try{return await bh(e)}catch(t){return console.error("[media] screenshot capture",t),null}finally{e.getTracks().forEach(t=>{t.stop()})}}async function bh(e){const t=document.createElement("video");t.muted=!0,t.playsInline=!0,t.srcObject=e,await t.play(),await new Promise(a=>requestAnimationFrame(a));const n=t.videoWidth||1280,r=t.videoHeight||720,i=document.createElement("canvas");i.width=n,i.height=r,i.getContext("2d").drawImage(t,0,0,n,r);const s=await new Promise((a,l)=>{i.toBlob(d=>d?a(d):l(new Error("toBlob failed")),"image/png")}),o=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19);return new File([s],`capture-${o}.png`,{type:"image/png"})}async function wh(e={}){var d;if(!jn||!nr)return null;let t;try{t=await navigator.mediaDevices.getDisplayMedia(Eo({audio:!0}))}catch(c){return(c==null?void 0:c.name)!=="NotAllowedError"&&console.error("[media] record picker",c),null}const n=yh();let r;try{r=n?new window.MediaRecorder(t,{mimeType:n}):new window.MediaRecorder(t)}catch(c){return console.error("[media] recorder init",c),t.getTracks().forEach(m=>{m.stop()}),null}const i=[];let s=null,o=!1;r.addEventListener("dataavailable",c=>{c.data&&c.data.size>0&&i.push(c.data)}),r.addEventListener("stop",()=>{var c,m;if(s&&clearInterval(s),t.getTracks().forEach(C=>{C.stop()}),i.length){const C=r.mimeType||n||"video/webm",b=new Blob(i,{type:C}),K=/mp4/.test(C)?"mp4":"webm",S=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),J=new File([b],`ecran-${S}.${K}`,{type:C});(c=e.onfinalize)==null||c.call(e,J)}else(m=e.oncancel)==null||m.call(e)}),t.getVideoTracks().forEach(c=>{c.addEventListener("ended",()=>a(),{once:!0})});function a(){if(!o&&(o=!0,r.state!=="inactive"))try{r.stop()}catch(c){console.error("[media] recorder stop",c)}}try{r.start(1e3)}catch(c){return console.error("[media] recorder start",c),t.getTracks().forEach(m=>{m.stop()}),null}(d=e.onstart)==null||d.call(e);const l=Date.now();return s=setInterval(()=>{var c;(c=e.ontick)==null||c.call(e,Date.now()-l)},500),{stop:a,get state(){return r.state}}}const kh=[{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"}],Ch={name:"WmComposer",inject:{t:{default:()=>Ee()}},props:{modelValue:{type:String,default:""},placeholder:{type:String,default:"รcrivez votre messageโฆ"},disabled:{type:Boolean,default:!1},attachLabel:{type:String,default:"Joindre"},displayMode:{type:String,default:"floating"}},emits:["update:modelValue","send","attach","focus","blur"],data(){return{local:this.modelValue,focused:!1,attachOpen:!1,recording:!1,recordingElapsed:0,recorder:null,kbOffset:0}},computed:{canSend(){return!this.disabled&&!!this.local.trim()},expanded(){return this.focused||!!this.local.trim()||this.attachOpen||this.recording},attachItems(){return kh.map(e=>({...e,label:this.t(e.labelKey),disabled:e.action==="screenshot"&&!jn||e.action==="record"&&(!jn||!nr)}))},recordingElapsedLabel(){const e=Math.floor(this.recordingElapsed/1e3),t=Math.floor(e/60),n=e%60;return`${t}:${n.toString().padStart(2,"0")}`}},watch:{modelValue(e){e!==this.local&&(this.local=e,this.$nextTick(()=>this.autosize()))},local(e){this.$emit("update:modelValue",e)}},mounted(){this.autosize(),this.displayMode==="sheet"&&this.setupKeyboardTracking()},beforeUnmount(){if(this.recorder)try{this.recorder.stop()}catch{}this.teardownKeyboardTracking()},methods:{focus(){const e=this.$refs.inputEl;if(!(!e||this.disabled))try{e.focus({preventScroll:!0})}catch{e.focus()}},onFocus(){this.focused=!0,this.$emit("focus"),this.$nextTick(()=>this.autosize())},onBlur(){this.focused=!1,this.$emit("blur"),this.$nextTick(()=>this.autosize())},onSubmit(){if(!this.canSend)return;const e=this.local.trim();this.local="",this.$emit("send",e),this.$nextTick(()=>this.autosize())},onKeydown(e){e.key==="Enter"&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.isComposing&&(e.preventDefault(),this.onSubmit())},autosize(){const e=this.$refs.inputEl;if(!e||e.clientWidth<80)return;e.style.height="auto",e.style.minHeight="0px";const t=e.scrollHeight;e.style.minHeight="",e.style.height=t>62?`${Math.min(t,120)}px`:""},onFile(e){const t=Array.from(e.target.files||[]);for(const n of t)this.$emit("attach",n);e.target.value=""},onAttachAction(e){this.attachOpen=!1,e==="file"?this.pickFile():e==="screenshot"?this.captureScreenshot():e==="record"&&this.startRecording()},pickFile(){var e;(e=this.$refs.fileEl)==null||e.click()},async captureScreenshot(){if(this.disabled)return;const e=await vh();e&&this.$emit("attach",e)},async startRecording(){if(this.recording||this.disabled)return;this.recordingElapsed=0;const e=await wh({onstart:()=>{this.recording=!0},ontick:t=>{this.recordingElapsed=t},onfinalize:t=>{this.$emit("attach",t),this.recording=!1,this.recordingElapsed=0,this.recorder=null},oncancel:()=>{this.recording=!1,this.recordingElapsed=0,this.recorder=null}});e&&(this.recorder=e)},stopRecording(){if(this.recorder)try{this.recorder.stop()}catch(e){console.error("[composer] stop recording",e)}},setupKeyboardTracking(){const e=window.visualViewport;e&&(this._vvHandler=()=>{const t=Math.max(0,window.innerHeight-e.height-e.offsetTop);this.kbOffset=t},e.addEventListener("resize",this._vvHandler),e.addEventListener("scroll",this._vvHandler))},teardownKeyboardTracking(){const e=window.visualViewport;!e||!this._vvHandler||(e.removeEventListener("resize",this._vvHandler),e.removeEventListener("scroll",this._vvHandler),this._vvHandler=null)}}},Sh={key:0,class:"wm-rec"},Ah={class:"wm-rec__lbl"},xh={key:1,class:"wm-compose__menu",role:"menu"},Th=["disabled","onClick"],Mh={class:"wm-compose__menuIcon"},Eh={viewBox:"0 0 24 24",width:"14",height:"14","aria-hidden":"true"},Oh=["d"],Rh=["placeholder","disabled"],Ih={class:"wm-compose__actions"},Lh=["title","aria-label","disabled"],Ph=["disabled","aria-label"];function Bh(e,t,n,r,i,s){return h(),p("div",{class:te(["wm-compose-wrap",{"wm-compose-wrap--sheet":n.displayMode==="sheet"}]),style:Ce(i.kbOffset?{transform:`translateY(-${i.kbOffset}px)`}:null)},[i.recording?(h(),p("div",Sh,[t[11]||(t[11]=u("span",{class:"wm-rec__dot","aria-hidden":"true"},null,-1)),u("span",Ah,R(s.t("composer.recording",{time:s.recordingElapsedLabel})),1),u("button",{type:"button",class:"wm-rec__stop",onClick:t[0]||(t[0]=(...o)=>s.stopRecording&&s.stopRecording(...o))},R(s.t("composer.stop")),1)])):F("",!0),u("form",{class:te(["wm-compose",{"has-attach":i.attachOpen,"is-expanded":s.expanded}]),onSubmit:t[10]||(t[10]=We((...o)=>s.onSubmit&&s.onSubmit(...o),["prevent"]))},[u("input",{ref:"fileEl",type:"file",hidden:"",multiple:"",onChange:t[1]||(t[1]=(...o)=>s.onFile&&s.onFile(...o))},null,544),i.attachOpen?(h(),p("div",{key:0,class:"wm-compose__overlay",onClick:t[2]||(t[2]=o=>i.attachOpen=!1)})):F("",!0),i.attachOpen?(h(),p("div",xh,[(h(!0),p(Z,null,Se(s.attachItems,o=>(h(),p("button",{key:o.action,type:"button",class:"wm-compose__menuItem",disabled:o.disabled,onClick:a=>s.onAttachAction(o.action)},[u("span",Mh,[(h(),p("svg",Eh,[u("path",{d:o.path,stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round",fill:"none"},null,8,Oh)]))]),u("span",null,R(o.label),1)],8,Th))),128))])):F("",!0),st(u("textarea",{ref:"inputEl","onUpdate:modelValue":t[3]||(t[3]=o=>i.local=o),class:"wm-compose__input",rows:"1",placeholder:n.placeholder,disabled:n.disabled,onKeydown:t[4]||(t[4]=(...o)=>s.onKeydown&&s.onKeydown(...o)),onInput:t[5]||(t[5]=(...o)=>s.autosize&&s.autosize(...o)),onFocus:t[6]||(t[6]=(...o)=>s.onFocus&&s.onFocus(...o)),onBlur:t[7]||(t[7]=(...o)=>s.onBlur&&s.onBlur(...o))},null,40,Rh),[[kt,i.local]]),u("div",Ih,[u("button",{type:"button",class:te(["wm-compose__icon",{"is-open":i.attachOpen}]),title:n.attachLabel,"aria-label":n.attachLabel,disabled:i.recording,onMousedown:t[8]||(t[8]=We(()=>{},["prevent"])),onClick:t[9]||(t[9]=o=>i.attachOpen=!i.attachOpen)},[...t[12]||(t[12]=[u("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"},[u("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)])],42,Lh),u("button",{type:"submit",class:te(["wm-compose__send",{"is-empty":!s.canSend}]),disabled:!s.canSend,"aria-label":s.t("composer.send")},[...t[13]||(t[13]=[u("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[u("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})],-1)])],10,Ph)])],34)],6)}const Fh=be(Ch,[["render",Bh],["__scopeId","data-v-a9738520"]]),Dh={name:"WmInlineCallbacks",props:{items:{type:Array,default:()=>[]},variant:{type:String,default:"chips",validator:e=>e==="chips"||e==="buttons"},baseDelay:{type:Number,default:360},stepDelay:{type:Number,default:90}},emits:["select"],computed:{batchKey(){return this.items.map(e=>(e==null?void 0:e.label)||(e==null?void 0:e.text)||"").join("ยง")},headerTitle(){if(this.variant!=="buttons")return"";const e=this.items.find(t=>typeof(t==null?void 0:t.title)=="string"&&t.title.trim());return e?e.title.trim():""}},methods:{btnClass(e){return this.variant==="chips"?"wm-icb__btn--chip":["wm-icb__btn--action",`wm-icb__btn--${(e==null?void 0:e.style)||"neutral"}`]}}},Nh=["onClick"],Hh={key:0,class:"wm-icb__title"},Uh={class:"wm-icb__row"},jh=["onClick"];function Vh(e,t,n,r,i,s){return n.items.length?(h(),p("div",{key:s.batchKey,class:te(["wm-icb",`wm-icb--${n.variant}`])},[n.variant==="chips"?(h(!0),p(Z,{key:0},Se(n.items,(o,a)=>(h(),p("button",{key:o.id!=null?o.id:a,type:"button",class:"wm-icb__btn wm-icb__btn--chip",style:Ce({animationDelay:n.baseDelay+a*n.stepDelay+"ms"}),onClick:l=>e.$emit("select",o)},R(o.label),13,Nh))),128)):(h(),p(Z,{key:1},[s.headerTitle?(h(),p("div",Hh,R(s.headerTitle),1)):F("",!0),u("div",Uh,[(h(!0),p(Z,null,Se(n.items,(o,a)=>(h(),p("button",{key:o.id!=null?o.id:a,type:"button",class:te(["wm-icb__btn",s.btnClass(o)]),onClick:l=>e.$emit("select",o)},R(o.label),11,jh))),128))])],64))],2)):F("",!0)}const Kh=be(Dh,[["render",Vh],["__scopeId","data-v-c8cc8cbf"]]);let ei=0;const zh=new Set(["text","textarea","number","boolean","select","multiselect","date"]),Wh={name:"WmFormCard",components:{AIAvatar:Sn},inject:{t:{default:()=>Ee()}},props:{form:{type:Object,required:!0},readOnly:{type:Boolean,default:!1},initialValues:{type:Object,default:null},agentName:{type:String,default:""},agentAvatarUrl:{type:String,default:null}},emits:["submit"],data(){return ei+=1,{_uid:ei,values:{},busy:!1,error:""}},computed:{normalizedFields(){var t;return(Array.isArray((t=this.form)==null?void 0:t.fields)?this.form.fields:[]).filter(n=>!(!(n!=null&&n.key)||!(n!=null&&n.label)||!zh.has(n==null?void 0:n.type)||(n.type==="select"||n.type==="multiselect")&&(!Array.isArray(n.options)||n.options.length===0)))}},created(){this.resetValues()},methods:{resetValues(){const e=this.initialValues&&typeof this.initialValues=="object"?this.initialValues:{},t={};for(const n of this.normalizedFields){if(e[n.key]!==void 0){t[n.key]=e[n.key];continue}n.type==="boolean"?t[n.key]=!1:n.type==="multiselect"?t[n.key]=[]:t[n.key]=""}this.values=t,this.error=""},toggleMulti(e,t,n){const r=Array.isArray(this.values[e])?this.values[e].slice():[],i=r.indexOf(t);n&&i===-1?r.push(t):!n&&i!==-1&&r.splice(i,1),this.values={...this.values,[e]:r}},validate(){for(const e of this.normalizedFields){if(!e.required)continue;const t=this.values[e.key];if(e.type!=="boolean"){if(e.type==="multiselect"){if(!Array.isArray(t)||t.length===0)return this.t("form.fieldRequired",{label:e.label});continue}if(t==null||t==="")return this.t("form.fieldRequired",{label:e.label})}}return""},async onSubmit(){if(this.readOnly||this.busy)return;const e=this.validate();if(e){this.error=e;return}this.error="",this.busy=!0;try{await this.$emit("submit",{values:this.values})}finally{this.busy=!1}}}},$h={class:"wm-form"},qh={class:"wm-form__head"},Gh={class:"wm-form__icon"},Yh={class:"wm-form__main"},Jh={class:"wm-form__title"},Xh={key:0,class:"wm-form__detail"},Qh=["for"],Zh={key:0,class:"wm-form__req","aria-hidden":"true"},em=["id","onUpdate:modelValue","placeholder","required","disabled"],tm=["id","onUpdate:modelValue","placeholder","required","disabled"],nm=["id","onUpdate:modelValue","placeholder","required","disabled"],sm=["id","onUpdate:modelValue","required","disabled"],rm={key:4,class:"wm-form__bool"},im=["id","onUpdate:modelValue","disabled"],om=["id","onUpdate:modelValue","required","disabled"],am={value:"",disabled:""},lm=["value"],cm={key:6,class:"wm-form__multi"},um=["value","checked","disabled","onChange"],dm={key:0,class:"wm-form__err"},fm=["disabled"],hm={key:0,class:"wm-form__spinner","aria-hidden":"true"},mm={key:2,class:"wm-form__doneLbl"};function gm(e,t,n,r,i,s){const o=ve("AIAvatar");return h(),p("div",$h,[u("div",qh,[u("div",Gh,[pe(o,{size:24,name:n.agentName,"image-url":n.agentAvatarUrl},null,8,["name","image-url"])]),u("div",Yh,[u("div",Jh,R(n.form.title||s.t("form.title")),1),n.form.description?(h(),p("div",Xh,R(n.form.description),1)):F("",!0)])]),u("form",{class:"wm-form__body",onSubmit:t[0]||(t[0]=We((...a)=>s.onSubmit&&s.onSubmit(...a),["prevent"]))},[(h(!0),p(Z,null,Se(s.normalizedFields,a=>(h(),p("div",{key:a.key,class:"wm-form__field"},[u("label",{for:`wm-f-${i._uid}-${a.key}`,class:"wm-form__label"},[ns(R(a.label),1),a.required?(h(),p("span",Zh,"*")):F("",!0)],8,Qh),a.type==="text"?st((h(),p("input",{key:0,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,type:"text",class:"wm-form__input",placeholder:a.placeholder||"",required:a.required,disabled:n.readOnly||i.busy},null,8,em)),[[kt,i.values[a.key]]]):a.type==="textarea"?st((h(),p("textarea",{key:1,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,class:"wm-form__textarea",rows:"3",placeholder:a.placeholder||"",required:a.required,disabled:n.readOnly||i.busy},null,8,tm)),[[kt,i.values[a.key]]]):a.type==="number"?st((h(),p("input",{key:2,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,type:"number",class:"wm-form__input",placeholder:a.placeholder||"",required:a.required,disabled:n.readOnly||i.busy},null,8,nm)),[[kt,i.values[a.key],void 0,{number:!0}]]):a.type==="date"?st((h(),p("input",{key:3,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,type:"date",class:"wm-form__input",required:a.required,disabled:n.readOnly||i.busy},null,8,sm)),[[kt,i.values[a.key]]]):a.type==="boolean"?(h(),p("label",rm,[st(u("input",{id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,type:"checkbox",disabled:n.readOnly||i.busy},null,8,im),[[Jl,i.values[a.key]]]),u("span",null,R(a.placeholder||s.t("common.yes")),1)])):a.type==="select"?st((h(),p("select",{key:5,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,class:"wm-form__select",required:a.required,disabled:n.readOnly||i.busy},[u("option",am,R(a.placeholder||s.t("form.choose")),1),(h(!0),p(Z,null,Se(a.options,l=>(h(),p("option",{key:l.value,value:l.value},R(l.label),9,lm))),128))],8,om)),[[Xl,i.values[a.key]]]):a.type==="multiselect"?(h(),p("div",cm,[(h(!0),p(Z,null,Se(a.options,l=>(h(),p("label",{key:l.value,class:"wm-form__multiItem"},[u("input",{type:"checkbox",value:l.value,checked:Array.isArray(i.values[a.key])&&i.values[a.key].includes(l.value),disabled:n.readOnly||i.busy,onChange:d=>s.toggleMulti(a.key,l.value,d.target.checked)},null,40,um),u("span",null,R(l.label),1)]))),128))])):F("",!0)]))),128)),i.error?(h(),p("div",dm,R(i.error),1)):F("",!0),n.readOnly?(h(),p("div",mm,R(s.t("form.responseSent")),1)):(h(),p("button",{key:1,type:"submit",class:"wm-form__submit",disabled:i.busy},[i.busy?(h(),p("span",hm)):F("",!0),u("span",null,R(i.busy?s.t("common.sending"):n.form.submit_label||s.t("common.send")),1)],8,fm))],32)])}const pm=be(Wh,[["render",gm],["__scopeId","data-v-fe65cc56"]]),_m={name:"WmFeedback",inject:{t:{default:()=>Ee()}},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})}}},ym={class:"wm-fb"},vm={class:"wm-fb__title"},bm={class:"wm-fb__sub"},wm={class:"wm-fb__row"},km=["onClick"],Cm={class:"wm-fb__emoji"},Sm={class:"wm-fb__label"},Am=["disabled"],xm={key:1,class:"wm-fb__done"},Tm={class:"wm-fb__doneTitle"},Mm={class:"wm-fb__doneSub"};function Em(e,t,n,r,i,s){return h(),p("div",ym,[n.done?(h(),p("div",xm,[t[1]||(t[1]=u("div",{class:"wm-fb__check"},[u("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"},[u("path",{d:"M20 6L9 17l-5-5"})])],-1)),u("div",Tm,R(s.t("feedback.doneTitle")),1),u("div",Mm,R(s.t("feedback.doneSubtitle")),1)])):(h(),p(Z,{key:0},[u("div",vm,R(s.t("feedback.question")),1),u("div",bm,R(s.t("feedback.subtitle")),1),u("div",wm,[(h(!0),p(Z,null,Se(s.options,o=>(h(),p("button",{key:o.v,type:"button",class:te(["wm-fb__opt",{"is-selected":i.sel===o.v}]),onClick:a=>i.sel=o.v},[u("span",Cm,R(o.e),1),u("span",Sm,R(o.l),1)],10,km))),128))]),u("button",{type:"button",class:"wm-fb__send",disabled:!i.sel||n.busy,onClick:t[0]||(t[0]=(...o)=>s.onSend&&s.onSend(...o))},R(n.busy?s.t("common.sending"):s.t("feedback.submit")),9,Am)],64))])}const Om=be(_m,[["render",Em],["__scopeId","data-v-9b630564"]]),Rm={name:"WmMoreMenu",inject:{t:{default:()=>Ee()}},props:{canRename:{type:Boolean,default:!0},canExport:{type:Boolean,default:!0},soundEnabled:{type:Boolean,default:!0},statusUrl:{type:String,default:""},helpUrl:{type:String,default:""}},emits:["close","action","sound-toggle"],data(){return{soundOn:this.soundEnabled}},watch:{soundEnabled(e){this.soundOn=!!e}},methods:{emit(e){this.$emit("action",e)},toggleSound(){this.soundOn=!this.soundOn,this.$emit("sound-toggle",this.soundOn)}}},Im={class:"wm-mm"},Lm={class:"wm-mm__pop",role:"menu"},Pm={key:0,class:"wm-mm__section"},Bm={class:"wm-mm__label"},Fm={class:"wm-mm__label"},Dm={key:1,class:"wm-mm__sep"},Nm={class:"wm-mm__section"},Hm={class:"wm-mm__label"},Um={class:"wm-mm__section"},jm={class:"wm-mm__label"},Vm={class:"wm-mm__label"};function Km(e,t,n,r,i,s){return h(),p("div",Im,[u("div",{class:"wm-mm__scrim",onClick:t[0]||(t[0]=o=>e.$emit("close"))}),u("div",Lm,[n.canRename||n.canExport?(h(),p("div",Pm,[n.canRename?(h(),p("button",{key:0,type:"button",class:"wm-mm__item",onClick:t[1]||(t[1]=o=>s.emit("rename"))},[t[6]||(t[6]=u("span",{class:"wm-mm__icon"},[u("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"},[u("path",{d:"M12 20h9"}),u("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})])],-1)),u("span",Bm,R(s.t("moreMenu.editTitle")),1)])):F("",!0),n.canExport?(h(),p("button",{key:1,type:"button",class:"wm-mm__item",onClick:t[2]||(t[2]=o=>s.emit("export"))},[t[7]||(t[7]=u("span",{class:"wm-mm__icon"},[u("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"},[u("path",{d:"M4 12v8a2 2 0 002 2h12a2 2 0 002-2v-8M16 6l-4-4-4 4M12 2v13"})])],-1)),u("span",Fm,R(s.t("moreMenu.exportTranscript")),1),t[8]||(t[8]=u("span",{class:"wm-mm__hint"},".txt",-1))])):F("",!0)])):F("",!0),n.canRename||n.canExport?(h(),p("div",Dm)):F("",!0),u("div",Nm,[u("button",{type:"button",class:"wm-mm__item",onClick:t[3]||(t[3]=(...o)=>s.toggleSound&&s.toggleSound(...o))},[t[10]||(t[10]=u("span",{class:"wm-mm__icon"},[u("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"},[u("path",{d:"M11 5L6 9H2v6h4l5 4V5z"}),u("path",{d:"M15.54 8.46a5 5 0 010 7.07M19.07 4.93a10 10 0 010 14.14"})])],-1)),u("span",Hm,R(s.t("moreMenu.sound")),1),u("span",{class:te(["wm-mm__toggle",{"wm-mm__toggle--on":i.soundOn}])},[...t[9]||(t[9]=[u("span",{class:"wm-mm__knob"},null,-1)])],2)])]),t[13]||(t[13]=u("div",{class:"wm-mm__sep"},null,-1)),u("div",Um,[n.statusUrl?(h(),p("button",{key:0,type:"button",class:"wm-mm__item",onClick:t[4]||(t[4]=o=>s.emit("status"))},[t[11]||(t[11]=u("span",{class:"wm-mm__icon"},[u("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"},[u("path",{d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zM10 6v4l3 2"})])],-1)),u("span",jm,R(s.t("moreMenu.serviceStatus")),1)])):F("",!0),n.helpUrl?(h(),p("button",{key:1,type:"button",class:"wm-mm__item",onClick:t[5]||(t[5]=o=>s.emit("help"))},[t[12]||(t[12]=u("span",{class:"wm-mm__icon"},[u("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"},[u("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)),u("span",Vm,R(s.t("moreMenu.helpCenter")),1)])):F("",!0)])])])}const zm=be(Rm,[["render",Km],["__scopeId","data-v-4cf6d578"]]),Wm={name:"WmRenameDialog",inject:{t:{default:()=>Ee()}},props:{title:{type:String,default:""},initialValue:{type:String,default:""},placeholder:{type:String,default:""}},emits:["close","submit"],data(){return{value:this.initialValue||""}},computed:{canSubmit(){const e=(this.value||"").trim();return!!e&&e!==(this.initialValue||"").trim()}},mounted(){this.$nextTick(()=>{const e=this.$refs.input;if(e){e.focus();try{e.select()}catch{}}})},methods:{onSubmit(){this.canSubmit&&this.$emit("submit",this.value.trim())}}},$m={class:"wm-dialog"},qm={class:"wm-dialog__card",role:"dialog","aria-modal":"true"},Gm={class:"wm-dialog__head"},Ym={class:"wm-dialog__title"},Jm=["aria-label"],Xm={class:"wm-dialog__body"},Qm=["placeholder"],Zm={class:"wm-dialog__actions"},eg=["disabled"];function tg(e,t,n,r,i,s){return h(),p("div",$m,[u("div",{class:"wm-dialog__scrim",onClick:t[0]||(t[0]=o=>e.$emit("close"))}),u("div",qm,[u("div",Gm,[u("div",Ym,R(n.title||s.t("rename.title")),1),u("button",{type:"button",class:"wm-dialog__close","aria-label":s.t("common.close"),onClick:t[1]||(t[1]=o=>e.$emit("close"))},[...t[7]||(t[7]=[u("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"},[u("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,Jm)]),u("div",Xm,[st(u("input",{ref:"input","onUpdate:modelValue":t[2]||(t[2]=o=>i.value=o),type:"text",class:"wm-dialog__input",placeholder:n.placeholder||s.t("rename.placeholder"),maxlength:120,onKeydown:[t[3]||(t[3]=Un(We((...o)=>s.onSubmit&&s.onSubmit(...o),["prevent"]),["enter"])),t[4]||(t[4]=Un(We(o=>e.$emit("close"),["prevent"]),["esc"]))]},null,40,Qm),[[kt,i.value]])]),u("div",Zm,[u("button",{type:"button",class:"wm-dialog__btn",onClick:t[5]||(t[5]=o=>e.$emit("close"))},R(s.t("common.cancel")),1),u("button",{type:"button",class:"wm-dialog__btn wm-dialog__btn--primary",disabled:!s.canSubmit,onClick:t[6]||(t[6]=(...o)=>s.onSubmit&&s.onSubmit(...o))},R(s.t("common.save")),9,eg)])])])}const ng=be(Wm,[["render",tg],["__scopeId","data-v-6d5f94a8"]]),ti="ww-messenger-tokens",sg={name:"Messenger",components:{Launcher:Qc,Header:Cu,Onboarding:ld,History:Sd,MessageList:_h,Composer:Fh,InlineCallbacks:Kh,FormCard:pm,Feedback:Om,MoreMenu:zm,RenameDialog:ng},mixins:[Ec,Oc,Ic],provide(){return{signAttachmentFn:e=>{var t,n;return((n=(t=this.store)==null?void 0:t.signAttachment)==null?void 0:n.call(t,e))||null},t:(e,t)=>this.t(e,t),wmLocale:()=>this.locale}},props:{baseUrl:{type:String,default:pc},widgetId:{type:String,default:""},context:{type:Object,default:null},displayMode:{type:String,default:"floating"},devtools:{type:Boolean,default:!1},language:{type:String,default:""}},data(){return{transport:null,store:null,isOpen:!1,launcherHovered:!1,draft:"",busy:!1,bootError:null,pendingAttachments:[],feedbackBusy:!1,feedbackDone:{},convOpenedAt:0,moreOpen:!1,renameDialogOpen:!1,draftConv:null,launching:!1,launchStage:"idle",pendingLaunchText:"",reopenedLocally:{},activeConvId:null,showOnboarding:!1,showHistory:!1,backToHistory:!1,welcomeRevealedAt:{},welcomeRevealTimers:{},dismissedPeeks:{},floatHeight:0,floatRO:null,parentOrigin:"",parentToken:"",parentVariables:null,parentAllowUnauthenticated:!1,parentInitReceived:!1,parentInitDeferred:null}},computed:{isEditor(){return!!this.devtools},isEmbedded(){return this.displayMode==="embedded"},customerLanguage(){var n,r,i,s;const e=(n=this.s)==null?void 0:n.customer,t=e&&(e.language||((r=e.values)==null?void 0:r.language));return t||((s=(i=this.context)==null?void 0:i.customer)==null?void 0:s.language)||""},locale(){var e;return tr(this.language||this.customerLanguage||((e=this.widget)==null?void 0:e.default_language)||"")},translator(){return Ee(this.locale)},error(){var e;return this.bootError||((e=this.s)==null?void 0:e.error)||null},canBoot(){return!!(this.baseUrl&&this.widgetId)},s(){var e;return((e=this.store)==null?void 0:e.state)||null},ready(){var e;return!!((e=this.s)!=null&&e.ready)},allConversations(){var t;const e=(t=this.s)==null?void 0:t.conversations;return Array.isArray(e)?e:[]},drawerConversations(){var n;const e=((n=this.s)==null?void 0:n.messagesByConv)||{},t=this.revealedAt;return this.allConversations.map(r=>{var d;const i=e[r.id]||[],s=ht(r.last_read_message_id);let o=0,a=null;for(let c=i.length-1;c>=0;c--){const m=i[c];if(!m)continue;if(((d=m.author)==null?void 0:d.type)==="user")break;const C=ht(m.id);if(C!=null){if(s!=null&&C<=s)break;t[m.id]!==0&&(!a&&m.author&&(a=m.author),o++)}}if(!i.length){const c=ht(r.last_message_id);c!=null&&(s==null||c>s)&&(o=1,a=r.last_message_author||null)}const l=i.filter(c=>!((c==null?void 0:c.id)!=null&&t[c.id]===0));return{...r,_preview:Ac(r,l),_unread:o>0,_unreadCount:o,_lastAuthor:a}})},unreadCount(){return this.drawerConversations.filter(e=>e._unread).length},openThreads(){var t;const e=((t=this.s)==null?void 0:t.messagesByConv)||{};return this.drawerConversations.filter(n=>{const r=this.convStatus(n);return r!=="resolved"&&r!=="closed"}).map(n=>({id:n.id,title:n.name||this.t("common.newConversation"),preview:n._preview||this.t("onboarding.newMessage"),unread:!!n._unread,author:n._lastAuthor||null,_ts:Qr(n,e[n.id]||[])})).sort((n,r)=>n._ts<r._ts?1:n._ts>r._ts?-1:0)},latestUnreads(){var n;const e=((n=this.s)==null?void 0:n.messagesByConv)||{},t=[];for(const r of this.drawerConversations){if(!r._unread)continue;const i=Qr(r,e[r.id]||[]),s=r._lastAuthor,o=!s||s.type==="agent_ia",a=(s==null?void 0:s.name)||(o?this.agentName:"")||"",l=(s==null?void 0:s.avatar_url)||(o?this.agentAvatarUrl:null);t.push({convId:r.id,preview:r._preview||this.t("notification.youHaveNewMessage"),ts:i,count:r._unreadCount||1,senderName:a,senderAvatarUrl:l})}return t.sort((r,i)=>r.ts<i.ts?1:r.ts>i.ts?-1:0),t},launcherPeeks(){if(this.isOpen||this.isEmbedded)return[];const e=this.dismissedPeeks||{};return this.latestUnreads.filter(t=>e[t.convId]!==t.ts)},isViewingThread(){return(this.isOpen||this.isEmbedded)&&!!this.currentConv},currentConv(){if(this.draftConv)return this.draftConv;if(this.showOnboarding||this.showHistory)return null;const e=this.allConversations;if(!e.length)return null;if(this.activeConvId!=null){const t=e.find(n=>n.id===this.activeConvId);if(t)return t}return e[0]||null},canBack(){return!!this.currentConv||this.showHistory},statusUrl(){var n;const e=(n=this.widget)==null?void 0:n.quick_links;if(!Array.isArray(e))return"";const t=e.find(r=>r.icon==="status"&&r.url);return(t==null?void 0:t.url)||""},helpUrl(){var n;const e=(n=this.widget)==null?void 0:n.quick_links;if(!Array.isArray(e))return"";const t=e.find(r=>(r.icon==="chat"||r.icon==="help")&&r.url);return(t==null?void 0:t.url)||""},widget(){var e,t;return((t=(e=this.s)==null?void 0:e.config)==null?void 0:t.widget)||null},rootStyle(){var t;const e=(t=this.widget)==null?void 0:t.primary_color;return e&&bc(e)?{"--wm-primary":e}:null},widgetTitle(){var e;return((e=this.widget)==null?void 0:e.title)||""},widgetWelcomeMessage(){var e;return((e=this.widget)==null?void 0:e.welcome_message)||""},widgetSubtitle(){var e;return((e=this.widget)==null?void 0:e.subtitle)||""},defaultIconUrl(){var e;return((e=this.widget)==null?void 0:e.default_icon_url)||null},coverImageUrl(){var e;return((e=this.widget)==null?void 0:e.cover_image_url)||null},agentName(){var e,t,n;return((n=(t=(e=this.s)==null?void 0:e.config)==null?void 0:t.agent)==null?void 0:n.name)||""},agentAvatarUrl(){var e,t,n;return((n=(t=(e=this.s)==null?void 0:e.config)==null?void 0:t.agent)==null?void 0:n.avatar_url)||null},quickLinks(){var t;const e=(t=this.widget)==null?void 0:t.quick_links;return Array.isArray(e)?e:[]},teamMembers(){var t;const e=(t=this.widget)==null?void 0:t.team_members;return Array.isArray(e)?e:[]},responseLabel(){var e;return((e=this.widget)==null?void 0:e.response_time_label)||""},humanMessageAuthor(){var t,n,r;if(!this.currentConv)return null;const e=((t=this.s.messagesByConv)==null?void 0:t[this.currentConv.id])||[];for(let i=e.length-1;i>=0;i--)if(((r=(n=e[i])==null?void 0:n.author)==null?void 0:r.type)==="agent_human")return e[i].author;return null},humanAgentName(){var e;return((e=this.humanMessageAuthor)==null?void 0:e.name)||""},humanAgentAvatarUrl(){var e;return((e=this.humanMessageAuthor)==null?void 0:e.avatar_url)||null},isEscalated(){return!!this.humanMessageAuthor},isWaitingHuman(){return this.currentStatus==="waiting_human_response"},isTerminal(){return this.currentStatus==="resolved"||this.currentStatus==="closed"},isClosed(){return this.currentStatus==="closed"},endedBlockVisible(){var e;return!(!this.isTerminal||this.isClosed&&this.reopenedLocally[(e=this.currentConv)==null?void 0:e.id])},headerTitle(){var e,t;return((e=this.currentConv)==null?void 0:e.name)||((t=this.widget)==null?void 0:t.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 i,s;const e=this.currentConv;if(!e)return[];const t=this.welcomeRevealedAt[e.id]>0?this.buildWelcomePrefix(e):[];if(!e._draft){const o=(s=(i=this.s)==null?void 0:i.paginationByConv)==null?void 0:s[e.id];if(!(o!=null&&o.loaded))return t}const n=this.revealedAt,r=(this.s.messagesByConv[e.id]||[]).filter(o=>{var a,l,d,c,m;return(o==null?void 0:o.type)==="action"&&((a=o==null?void 0:o.payload)==null?void 0:a.state)==="pending"||bn(o)&&!(n[o.id]>0)?!1:(o==null?void 0:o.type)==="action"||(o==null?void 0:o.type)==="system"||((l=o==null?void 0:o.payload)==null?void 0:l.type)==="system"||Array.isArray((d=o==null?void 0:o.payload)==null?void 0:d.attachments)&&o.payload.attachments.length||(c=o==null?void 0:o.metadata)!=null&&c.artifact||(m=o==null?void 0:o.metadata)!=null&&m.form||Array.isArray(o==null?void 0:o.callbacks)&&o.callbacks.some(C=>(C==null?void 0:C.intent)==="submit_form")?!0:typeof(o==null?void 0:o.text_md)=="string"&&o.text_md.trim().length>0});return t.length?[...t,...r]:r},streamingActive(){var n,r,i;const e=this.currentConv;return e?Object.keys(((n=this.s)==null?void 0:n.streamingByMsgId)||{}).length>0?!0:this.actionInFlight?!1:this.widgetWelcomeMessage&&this.welcomeRevealedAt[e.id]===0?!0:(((i=(r=this.s)==null?void 0:r.messagesByConv)==null?void 0:i[e.id])||[]).some(s=>bn(s)&&!(this.revealedAt[s.id]>0)):!1},currentConvMessages(){var t,n,r;const e=(t=this.currentConv)==null?void 0:t.id;return e?((r=(n=this.s)==null?void 0:n.messagesByConv)==null?void 0:r[e])||[]:[]},pendingResolution(){var t,n,r,i,s;if(!this.currentConv)return null;const e=((n=(t=this.s)==null?void 0:t.messagesByConv)==null?void 0:n[this.currentConv.id])||[];for(let o=e.length-1;o>=0;o--){const a=e[o];if((r=a==null?void 0:a.metadata)!=null&&r.resolution_request)return!Array.isArray(a.callbacks)||!a.callbacks.length||(s=(i=this.s)==null?void 0:i.awaitingCallback)!=null&&s[a.id]?null:a}return null},resolutionCallbacks(){const e=this.pendingResolution;if(!e||!Array.isArray(e.callbacks))return[];const t={resolve_confirm:this.t("resolution.confirm"),resolve_decline:this.t("resolution.decline")};return e.callbacks.map(n=>({...n,label:t[n.id]||n.label}))},pendingApproval(){var t,n,r,i;if(!this.currentConv)return null;const e=((n=(t=this.s)==null?void 0:t.messagesByConv)==null?void 0:n[this.currentConv.id])||[];for(let s=e.length-1;s>=0;s--){const o=e[s];if(!(!Array.isArray(o==null?void 0:o.callbacks)||!o.callbacks.length||!o.callbacks.some(l=>(l==null?void 0:l.intent)==="approve"&&(l.audience??"customer")==="customer")))return(i=(r=this.s)==null?void 0:r.awaitingCallback)!=null&&i[o.id]?null:o}return null},approvalCallbacks(){const e=this.pendingApproval;return!e||!Array.isArray(e.callbacks)?[]:e.callbacks.filter(t=>(t==null?void 0:t.intent)==="approve"||(t==null?void 0:t.intent)==="reject")},currentStatus(){return this.convStatus(this.currentConv)},actionInFlight(){var e,t;return!this.currentConv||!this.store?null:((t=(e=this.store).getActionInFlight)==null?void 0:t.call(e,this.currentConv.id))||null},actionInFlightName(){var t;const e=this.actionInFlight;return e?((t=e.payload)==null?void 0:t.name)||e.text_md||this.t("common.action"):""},suggestions(){return this.currentConv?this.isTerminal?[]:this.streamingActive?[]:this.pendingForm?[]:this.conversationIsEmpty?this.starterPrompts:this.store?this.store.getLatestSuggestions(this.currentConv.id):[]:[]},conversationIsEmpty(){var n,r;const e=this.currentConv;return e?e._draft?!0:(((r=(n=this.s)==null?void 0:n.messagesByConv)==null?void 0:r[e.id])||[]).length===0:!1},starterPrompts(){var n;const e=(n=this.widget)==null?void 0:n.starter_prompts;if(!Array.isArray(e))return[];const t=[];for(const r of e){if(!r||typeof r!="object")continue;const i=typeof r.title=="string"?r.title.trim():"";if(!i)continue;const s=typeof r.message=="string"?r.message.trim():"";t.push({label:i,text:s||i,kind:"starter"})}return t},pendingForm(){var e,t;return!this.currentConv||!this.store||this.actionInFlight||this.streamingActive?null:((t=(e=this.store).getLatestForm)==null?void 0:t.call(e,this.currentConv.id))||null},showFeedback(){var t;const e=this.currentConv;return!e||this.currentStatus!=="resolved"?!1:this.feedbackDone[e.id]?!0:!((t=e.metadata)!=null&&t.feedback)},floatVisible(){return!!this.pendingApproval||!!this.pendingResolution||!!this.pendingForm||this.showFeedback||this.suggestions.length>0},dateLabel(){var n,r,i;const e=this.currentConv;let t=new Date;if(e){const o=((i=(((r=(n=this.s)==null?void 0:n.messagesByConv)==null?void 0:r[e.id])||[]).find(a=>a==null?void 0:a.created_at))==null?void 0:i.created_at)||e.created_at;if(o){const a=new Date(o);Number.isNaN(a.getTime())||(t=a)}}return this.t("messageList.today",{time:Bs(t,Bt(this.locale))})},paginationState(){var n,r,i;const e=(n=this.currentConv)==null?void 0:n.id,t=e?(i=(r=this.s)==null?void 0:r.paginationByConv)==null?void 0:i[e]:null;return{loading:!!(t!=null&&t.loading),hasMore:!!(t!=null&&t.nextCursor)}}},watch:{latestUnreads:{handler(e){const t=new Set(e.map(o=>o.convId)),n=this.dismissedPeeks||{},r=Object.keys(n);if(!r.length)return;const i={};let s=!1;for(const o of r)t.has(o)?i[o]=n[o]:s=!0;s&&(this.dismissedPeeks=i)},deep:!0},"currentConv.id":{handler(e){var t;this.resetRevealQueue(),this.convOpenedAt=Date.now(),this.moreOpen=!1,this.renameDialogOpen=!1,this.isViewingThread&&(this.unreadAnchorId=ht((t=this.currentConv)==null?void 0:t.last_read_message_id),this.unreadBoundaryTs=e?new Date().toISOString():""),e&&this.scheduleWelcomeReveal(e)},immediate:!0},isViewingThread(e,t){var n;e&&!t?(this.unreadAnchorId=ht((n=this.currentConv)==null?void 0:n.last_read_message_id),this.unreadBoundaryTs=new Date().toISOString()):e||(this.unreadAnchorId=null,this.unreadBoundaryTs="")},floatVisible:{handler(e){this.$nextTick(()=>this.syncFloatObserver(e))},immediate:!0},currentConvMessages(e){var t;this.paceMessages(e,(t=this.currentConv)==null?void 0:t.id),(this.isOpen||this.isEmbedded)&&this.currentConv&&this.markConvRead(this.currentConv)}},async mounted(){if(typeof document<"u"&&!document.getElementById(ti)){const e=document.createElement("style");e.id=ti,e.textContent=Ao,document.head.appendChild(e)}this._parentMessageHandler=this.onParentMessage.bind(this),window.addEventListener("message",this._parentMessageHandler),window.parent&&window.parent!==window&&window.parent.postMessage({type:"READY"},"*"),this.isEmbedded?(await this.boot(),this.store&&await this.open()):(await this.$nextTick(),this.sendCurrentLauncherSize(),this.observeLauncherSize())},beforeUnmount(){this._parentMessageHandler&&(window.removeEventListener("message",this._parentMessageHandler),this._parentMessageHandler=null),this._launcherRo&&(this._launcherRo.disconnect(),this._launcherRo=null),this.cancelReveals(),this.cancelWelcomeTimers(),this.teardownLiveReveal(),this.disconnectFloatRO(),this.teardownNotifications(),this.store&&this.store.destroy()},methods:{convStatus(e){var n,r,i,s;if(!e)return"open";const t=((r=(n=this.s)==null?void 0:n.messagesByConv)==null?void 0:r[e.id])||[];for(let o=t.length-1;o>=0;o--){const a=(s=(i=t[o])==null?void 0:i.metadata)==null?void 0:s.conversation_status;if(a)return a}return e.status||"open"},t(e,t){return this.translator(e,t)},waitForParentInit(){if(this.parentInitReceived)return Promise.resolve();if(!this.parentInitDeferred){let e;this.parentInitDeferred=new Promise(t=>{e=t}),this.parentInitDeferred._resolve=e}return this.parentInitDeferred},onParentMessage(e){var n;const t=e==null?void 0:e.data;if(!(!t||typeof t!="object")){if(t.type==="UPDATE"){this.transport&&t.payload&&this.transport.update(t.payload).catch(r=>{console.warn("[messenger] update failed",r)});return}if(t.type==="CONTEXT"){this.transport&&t.payload&&this.transport.context(t.payload);return}t.type==="INIT"&&(this.parentOrigin=e.origin,this.parentToken=typeof t.token=="string"?t.token:"",this.parentVariables=t.variables&&typeof t.variables=="object"?t.variables:t.context&&typeof t.context=="object"?t.context:null,this.parentAllowUnauthenticated=t.allowUnauthenticated===!0,this.parentInitReceived=!0,(n=this.parentInitDeferred)!=null&&n._resolve&&this.parentInitDeferred._resolve(),!this.isEmbedded&&!this.isOpen&&!this.parentAllowUnauthenticated&&this.parentToken&&this.hasValidSessionMarker()&&this.boot().catch(r=>{console.warn("[messenger] eager boot failed",r)}))}},hasValidSessionMarker(){if(typeof document>"u")return!1;const t=(document.cookie||"").match(/(?:^|; )messenger_session_marker=([^;]+)/);if(!t)return!1;const n=parseInt(t[1],10);return Number.isFinite(n)?n>Date.now():!1},async boot(){if(!this.canBoot){console.warn("[messenger] boot skipped โ missing creds");return}try{await this.waitForParentInit(),this.transport=Ts(dc({baseUrl:this.baseUrl,widgetId:this.widgetId})),this.store=Ts(gc(this.transport)),this.hydrateNotifPref();const e=this.parentVariables||this.context||null;if(await this.store.start({origin:this.parentOrigin,token:this.parentToken||void 0,allowUnauthenticated:this.parentAllowUnauthenticated,variables:e&&typeof e=="object"?e:void 0}),e&&typeof e=="object"){const t={};for(const[n,r]of Object.entries(e))n!=="customer"&&r&&typeof r=="object"&&!Array.isArray(r)&&(t[n]=r);Object.keys(t).length>0&&this.transport.context(t)}this.setupLiveReveal()}catch(e){console.error("[ww-messenger] bootstrap failed",e),this.bootError=(e==null?void 0:e.message)||String(e)}},async refresh(){this.store&&this.store.destroy(),this.cancelReveals(),this.cancelWelcomeTimers(),this.welcomeRevealedAt={},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={},this.moreOpen=!1,this.renameDialogOpen=!1,this.draftConv=null,this.activeConvId=null,this.showOnboarding=!1,this.showHistory=!1,this.backToHistory=!1,await this.boot(),this.isEmbedded&&this.store&&await this.open()},syncFloatObserver(e){if(this.disconnectFloatRO(),!e){this.floatHeight=0;return}const t=this.$refs.floatEl;if(t){if(typeof ResizeObserver>"u"){this.floatHeight=Math.ceil(t.getBoundingClientRect().height+8);return}this.floatRO=new ResizeObserver(n=>{const r=n[0];if(!r)return;const i=Math.ceil(r.contentRect.height+8);i!==this.floatHeight&&(this.floatHeight=i,this.$nextTick(()=>{var s,o;(o=(s=this.$refs.messageList)==null?void 0:s.keepPinnedToBottom)==null||o.call(s)}))}),this.floatRO.observe(t)}},disconnectFloatRO(){if(this.floatRO){try{this.floatRO.disconnect()}catch{}this.floatRO=null}},async open(){this.isOpen=!0,this.notifyParentResize("open"),this._launcherRo&&this._launcherRo.disconnect(),this.store||await this.boot(),this.store&&this.store.setPanelOpen(!0);const e=this.currentConv;if(e&&!e._draft){this.activeConvId==null&&(this.activeConvId=e.id);try{await this.store.openConversation(e.id)}catch(t){console.error("[ww-messenger] load messages failed",t)}this.markConvRead(e)}},async close(){this.isOpen=!1,await this.$nextTick(),this.sendCurrentLauncherSize(),this.observeLauncherSize(),this.store&&this.store.setPanelOpen(!1)},notifyParentResize(e,t){if(window.parent&&window.parent!==window)try{window.parent.postMessage({type:"RESIZE",state:e,displayMode:this.displayMode,...t||{}},"*")}catch(n){console.warn("[ww-messenger] notifyParentResize failed",n)}},onLauncherHover(e){this.launcherHovered=e,this.sendCurrentLauncherSize()},sendCurrentLauncherSize(){var c,m,C,b,K,S,J;if(this.isOpen)return;const e=(m=(c=this.$el)==null?void 0:c.querySelector)==null?void 0:m.call(c,".wm-launcherWrap");if(!e)return;const t=e.getBoundingClientRect();if(!t.width||!t.height)return;const n=(((C=this.launcherPeeks)==null?void 0:C.length)??0)>0,r=16,i=Math.ceil(t.width),s=Math.ceil(t.height),o=(K=(b=this.$el)==null?void 0:b.querySelector)==null?void 0:K.call(b,".wm-launcher"),a=(J=(S=this.$el)==null?void 0:S.querySelectorAll)==null?void 0:J.call(S,".wm-peek"),l=a&&a.length?a[a.length-1]:null;let d=null;if(l){const U=l.getBoundingClientRect();d={width:Math.ceil(U.width),height:Math.ceil(U.height),rightOffset:Math.max(0,Math.ceil(t.right-U.right)),bottomOffset:Math.max(0,Math.ceil(t.bottom-U.bottom))}}this.notifyParentResize("closed",{width:i+r,height:s+r,launcherWidth:(o==null?void 0:o.offsetWidth)||null,launcherHeight:(o==null?void 0:o.offsetHeight)||null,launcherHovered:this.launcherHovered,peek:d,peekHovered:this.launcherHovered&&n})},observeLauncherSize(){var n,r;if(typeof ResizeObserver>"u")return;const e=(r=(n=this.$el)==null?void 0:n.querySelector)==null?void 0:r.call(n,".wm-launcherWrap");if(!e)return;this._launcherRo&&this._launcherRo.disconnect();const t=new ResizeObserver(()=>{this.isOpen||this.sendCurrentLauncherSize()});t.observe(e),this._launcherRo=t},async openFromPeek(e){var n,r;const t=e||((n=this.latestUnreads[0])==null?void 0:n.convId);t&&t!==((r=this.currentConv)==null?void 0:r.id)&&(this.draftConv=null,this.activeConvId=t,this.showOnboarding=!1,this.showHistory=!1,this.backToHistory=!1),await this.open()},dismissPeek(e){const t=this.latestUnreads.find(n=>n.convId===e);t&&(this.dismissedPeeks={...this.dismissedPeeks,[e]:t.ts})},onOnboardingStart(e){this.pendingLaunchText=(e||"").trim(),this.launching=!0,this.launchStage="whiteslide"},onHomeLaunched(){const e=this.pendingLaunchText;this.pendingLaunchText="",this.startConv(),e&&this.$nextTick(()=>this.onSend(e)),this.launchStage="header",window.setTimeout(()=>{this.launching&&(this.launchStage="messages")},520),window.setTimeout(()=>{this.launching=!1,this.launchStage="idle"},1160)},startConv(){this.draftConv={id:"__draft__",_draft:!0,name:"",created_at:new Date().toISOString()},this.activeConvId=null,this.showOnboarding=!1,this.showHistory=!1,this.backToHistory=!1,this.focusComposer()},onReopen(){var t;const e=(t=this.currentConv)==null?void 0:t.id;e&&(this.reopenedLocally={...this.reopenedLocally,[e]:!0},this.focusComposer())},async ensureRealConv(){const e=this.currentConv;if(!e)return null;if(!e._draft)return e;if(this.busy)return null;this.busy=!0;try{const t=await this.store.createConversation({}),n=this.welcomeRevealedAt.__draft__;return n!==void 0&&(this.welcomeRevealedAt={...this.welcomeRevealedAt,[t.id]:n>0?n:Date.now()}),this.draftConv=null,this.activeConvId=t.id,await this.store.openConversation(t.id),this.markConvRead(t),t}catch(t){return console.error("[ww-messenger] create conv failed",t),this.bootError=(t==null?void 0:t.message)||String(t),null}finally{this.busy=!1}},focusComposer(){this.$nextTick(()=>{var e;return(e=this.$refs.composer)==null?void 0:e.focus()})},buildWelcomePrefix(e){const t=this.widgetWelcomeMessage;return!t||typeof t!="string"||!t.trim()?[]:[{id:"__welcome__",text_md:t.trim(),author:{type:"agent_ia",name:this.agentName,avatar_url:this.agentAvatarUrl},created_at:(e==null?void 0:e.created_at)||new Date(0).toISOString()}]},scheduleWelcomeReveal(e){if(!e)return;const t=this.widgetWelcomeMessage;if(!t||typeof t!="string"||!t.trim()||this.welcomeRevealedAt[e]!==void 0)return;const n=this.currentConv;if(!((n==null?void 0:n._draft)||!(n!=null&&n.last_message_id))){this.welcomeRevealedAt={...this.welcomeRevealedAt,[e]:Date.now()};return}this.welcomeRevealedAt={...this.welcomeRevealedAt,[e]:0};const i=this.revealPacing,s=t.trim().length,o=Math.min(i.maxTypingMs,Math.max(i.minTypingMs,s*i.msPerChar)),a=i.firstRevealDelayMs+o,l=setTimeout(()=>{this.welcomeRevealedAt={...this.welcomeRevealedAt,[e]:Date.now()};const d={...this.welcomeRevealTimers};delete d[e],this.welcomeRevealTimers=d},a);this.welcomeRevealTimers={...this.welcomeRevealTimers,[e]:l}},cancelWelcomeTimers(){for(const e of Object.values(this.welcomeRevealTimers))try{clearTimeout(e)}catch{}this.welcomeRevealTimers={}},toggleMore(){this.moreOpen=!this.moreOpen},goHome(){this.moreOpen=!1,this.draftConv=null,this.activeConvId=null,this.backToHistory?(this.showOnboarding=!1,this.showHistory=!0,this.backToHistory=!1):(this.showOnboarding=!0,this.showHistory=!1)},async onDrawerPick(e){if(!(e!=null&&e.id)||!this.store)return;const t=this.showHistory;this.draftConv=null,this.activeConvId=e.id,this.showOnboarding=!1,this.showHistory=!1,this.backToHistory=t;try{await this.store.openConversation(e.id)}catch(r){console.error("[ww-messenger] open conv failed",r)}const n=this.allConversations.find(r=>r.id===e.id);n&&this.markConvRead(n)},async onMoreAction(e){var t,n;switch(this.moreOpen=!1,e){case"rename":this.openRenameDialog();break;case"export":Mc(this.currentConv,this.currentConv?(n=(t=this.s)==null?void 0:t.messagesByConv)==null?void 0:n[this.currentConv.id]:[],this.translator,this.locale);break;case"status":if(In(this.statusUrl))try{window.open(this.statusUrl,"_blank","noopener")}catch{}break;case"help":if(In(this.helpUrl))try{window.open(this.helpUrl,"_blank","noopener")}catch{}break}},openRenameDialog(){const e=this.currentConv;!e||e._draft||(this.renameDialogOpen=!0)},async onRenameSubmit(e){const t=this.currentConv;if(this.renameDialogOpen=!1,!t||t._draft||!this.store)return;const n=(e||"").trim();if(!(!n||n===t.name))try{await this.store.patchConversation(t.id,{name:n})}catch(r){console.error("[ww-messenger] rename failed",r)}},async onSend(e){let t=this.currentConv;if(!t&&(this.startConv(),t=this.currentConv,!t)||t._draft&&(t=await this.ensureRealConv(),!t))return;const n=t.id,r=this.pendingAttachments.slice();this.pendingAttachments=[],this.unreadAnchorId=null,this.unreadBoundaryTs="";const i=r.map(s=>{const{previewUrl:o,...a}=s;return a});await this.store.send(n,e,{attachments:i.length?i:void 0})},async onSuggestion(e){const t=(e==null?void 0:e.text)||(e==null?void 0:e.label);t&&await this.onSend(t)},async onLoadMore(){var t;const e=(t=this.currentConv)==null?void 0:t.id;!e||!this.store||await this.store.loadMore(e)},async onResolutionSelect(e){const t=this.pendingResolution;!t||!(e!=null&&e.id)||await this.store.clickCallback(t.id,e.id)},async onApprovalSelect(e){const t=this.pendingApproval;!t||!(e!=null&&e.id)||await this.store.clickCallback(t.id,e.id)},async onFormSubmit({values:e}){const t=this.pendingForm;if(!(t!=null&&t.form))return;const n=kc(t.form,e,this.translator);if(!n)return;let r=this.currentConv;r&&(r._draft&&(r=await this.ensureRealConv(),!r)||await this.store.send(r.id,n,{metadata:{artifact:Cc(t.form,e,this.translator)}}))},formatAttachmentSize(e){return e?e<1024?this.t("attachment.bytes",{size:e}):e<1024*1024?this.t("attachment.kilobytes",{size:(e/1024).toFixed(0)}):this.t("attachment.megabytes",{size:(e/(1024*1024)).toFixed(1)}):""},removePendingAttachment(e){this.pendingAttachments.splice(e,1)},async onAttach(e){var t,n;if(!(!e||!this.transport))try{const r=await this.transport.uploadAttachment(e),i=(r==null?void 0:r.type)==="image"||(e.type||"").toLowerCase().startsWith("image/")||((r==null?void 0:r.mime_type)||"").toLowerCase().startsWith("image/");let s=null;if(i)try{s=await((n=(t=this.store)==null?void 0:t.signAttachment)==null?void 0:n.call(t,r.path))||null}catch{}this.pendingAttachments.push({type:r.type||"file",path:r.path,name:e.name||this.t("attachment.fileFallbackName"),mime_type:e.type,size_bytes:e.size,previewUrl:s})}catch(r){console.error("[ww-messenger] attachment upload failed",r)}},onPanelClick(e){const t=e.target&&e.target.closest?e.target.closest('a[href^="#"]'):null;t&&(e.preventDefault(),this.openInternalUrl(t.getAttribute("href")))},async openInternalUrl(e){if(typeof e!="string"||!e.startsWith("#"))return!1;const t=e.slice(1);if(t==="new"||t==="new-conversation")return this.isOpen||await this.open(),this.startConv(),!0;if(t.startsWith("conversation/")){const n=t.slice(13);return n&&await this.openFromPeek(n),!0}return console.warn("[messenger] unknown internal url",e),!0},async onQuickLink(e){if(e){if(e.url){if(await this.openInternalUrl(e.url))return;if(!In(e.url)){console.warn("[messenger] refusing unsafe quick-link url",e.url);return}try{window.open(e.url,"_blank","noopener")}catch{}return}this.currentConv||this.startConv(),await this.onSend(e.label)}},async onFeedback({rating:e,comment:t}){if(this.currentConv){this.feedbackBusy=!0;try{await this.store.submitFeedback(this.currentConv.id,{rating:e,comment:t}),this.feedbackDone={...this.feedbackDone,[this.currentConv.id]:!0}}catch(n){console.error("[ww-messenger] feedback failed",n)}finally{this.feedbackBusy=!1}}}}},rg={key:0,class:"wm-loading","aria-busy":"true","aria-live":"polite"},ig=["aria-label"],og={class:"wm-screens"},ag={key:"error",class:"wm-screen wm-state"},lg={class:"wm-state__err"},cg={class:"wm-state__errTitle"},ug={class:"wm-state__errSub"},dg={key:"chat",class:"wm-screen wm-screen--chat"},fg={class:"wm-bottom"},hg={key:0,ref:"floatEl",class:"wm-float"},mg={key:1,class:"wm-actionWait",role:"status","aria-live":"polite"},gg={class:"wm-actionWait__lbl"},pg={key:2,class:"wm-attached"},_g=["src","alt"],yg={key:1,class:"wm-attached__file"},vg={class:"wm-attached__fileMeta"},bg={class:"wm-attached__fileName"},wg={key:0,class:"wm-attached__fileSize"},kg=["aria-label","onClick"],Cg={key:3,class:"wm-ended",role:"status","aria-live":"polite"},Sg={class:"wm-ended__lbl"};function Ag(e,t,n,r,i,s){const o=ve("Launcher"),a=ve("Header"),l=ve("History"),d=ve("Onboarding"),c=ve("MessageList"),m=ve("InlineCallbacks"),C=ve("FormCard"),b=ve("Feedback"),K=ve("Composer"),S=ve("MoreMenu"),J=ve("RenameDialog");return h(),p("div",{class:te(["wm-root",`wm-root--${n.displayMode}`]),style:Ce(s.rootStyle)},[!i.isOpen&&!s.isEmbedded?(h(),fe(o,{key:0,"unread-count":s.unreadCount,peeks:s.launcherPeeks,onOpen:s.openFromPeek,onDismiss:s.dismissPeek,onHover:s.onLauncherHover},null,8,["unread-count","peeks","onOpen","onDismiss","onHover"])):F("",!0),i.isOpen||s.isEmbedded?(h(),p("section",{key:1,class:te(["wm-panel",`wm-panel--${n.displayMode}`,{"wm-panel--welcome":s.ready&&!s.error&&!s.currentConv},i.launching?`wm-launch-${i.launchStage}`:""]),style:Ce(i.floatHeight?{"--wm-float-h":i.floatHeight+"px"}:null),role:"dialog","aria-label":"Messenger",onClick:t[7]||(t[7]=(...U)=>s.onPanelClick&&s.onPanelClick(...U))},[!s.ready&&!s.error?(h(),p("div",rg,[s.isEmbedded?F("",!0):(h(),p("button",{key:0,type:"button",class:"wm-loading__close","aria-label":s.t("loading.minimize"),onClick:t[0]||(t[0]=(...U)=>s.close&&s.close(...U))},[...t[8]||(t[8]=[u("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"},[u("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,ig)),t[9]||(t[9]=u("div",{class:"wm-loading__spinner","aria-hidden":"true"},null,-1))])):(h(),p(Z,{key:1},[pe(a,{title:s.headerTitle,"team-members":s.teamMembers,"response-label":s.responseLabel,"show-identity":!!s.currentConv,"show-back":s.canBack,"show-close":!s.isEmbedded,"more-active":i.moreOpen,"agent-name":s.agentName,"agent-avatar-url":s.agentAvatarUrl,onBack:s.goHome,onMore:s.toggleMore,onClose:s.close},null,8,["title","team-members","response-label","show-identity","show-back","show-close","more-active","agent-name","agent-avatar-url","onBack","onMore","onClose"]),u("div",og,[pe(Qs,{name:"wm-none"},{default:Xn(()=>[s.error?(h(),p("div",ag,[u("div",lg,[t[10]||(t[10]=u("div",{class:"wm-state__errIcon"},[u("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"},[u("path",{d:"M18 6L6 18M6 6l12 12"})])],-1)),u("div",null,[u("div",cg,R(s.t("error.connectionFailed")),1),u("div",ug,R(s.error),1)])])])):!s.currentConv&&i.showHistory?(h(),fe(l,{key:"history",class:"wm-screen",threads:s.openThreads,onResume:s.onDrawerPick},null,8,["threads","onResume"])):s.currentConv?(h(),p("div",dg,[pe(c,{ref:"messageList",messages:s.displayedMessages,"streaming-active":s.streamingActive,"date-label":s.dateLabel,"conversation-id":s.currentConv?s.currentConv.id:null,"loading-more":s.paginationState.loading,"has-more":s.paginationState.hasMore,"unread-anchor-id":e.unreadAnchorId,"unread-boundary-ts":e.unreadBoundaryTs,"ai-agent-name":s.agentName,"ai-agent-avatar-url":s.agentAvatarUrl,onLoadMore:s.onLoadMore},null,8,["messages","streaming-active","date-label","conversation-id","loading-more","has-more","unread-anchor-id","unread-boundary-ts","ai-agent-name","ai-agent-avatar-url","onLoadMore"]),u("div",fg,[s.floatVisible?(h(),p("div",hg,[s.pendingApproval?(h(),fe(m,{key:`appr-${s.pendingApproval.id}`,variant:"buttons",items:s.approvalCallbacks,onSelect:s.onApprovalSelect},null,8,["items","onSelect"])):s.pendingResolution?(h(),fe(m,{key:`res-${s.pendingResolution.id}`,variant:"buttons",items:s.resolutionCallbacks,onSelect:s.onResolutionSelect},null,8,["items","onSelect"])):s.pendingForm?(h(),fe(C,{key:s.pendingForm.message&&s.pendingForm.message.id,form:s.pendingForm.form,"agent-name":s.agentName,"agent-avatar-url":s.agentAvatarUrl,onSubmit:s.onFormSubmit},null,8,["form","agent-name","agent-avatar-url","onSubmit"])):s.showFeedback?(h(),fe(b,{key:3,busy:i.feedbackBusy,done:!!(s.currentConv&&i.feedbackDone[s.currentConv.id]),onSubmit:s.onFeedback},null,8,["busy","done","onSubmit"])):(h(),fe(m,{key:4,items:s.suggestions,onSelect:s.onSuggestion},null,8,["items","onSelect"]))],512)):F("",!0),s.actionInFlight?(h(),p("div",mg,[t[11]||(t[11]=u("span",{class:"wm-actionWait__spinner","aria-hidden":"true"},null,-1)),u("span",gg,R(s.t("action.inProgress",{name:s.actionInFlightName})),1)])):F("",!0),i.pendingAttachments.length?(h(),p("div",pg,[(h(!0),p(Z,null,Se(i.pendingAttachments,(U,$)=>(h(),p("div",{key:U.path||$,class:"wm-attached__item"},[U.previewUrl?(h(),p("img",{key:0,class:"wm-attached__thumb",src:U.previewUrl,alt:U.name},null,8,_g)):(h(),p("div",yg,[t[12]||(t[12]=u("span",{class:"wm-attached__fileIcon"},[u("svg",{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"},[u("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"}),u("path",{d:"M14 2v6h6"})])],-1)),u("span",vg,[u("span",bg,R(U.name),1),s.formatAttachmentSize(U.size_bytes)?(h(),p("span",wg,R(s.formatAttachmentSize(U.size_bytes)),1)):F("",!0)])])),u("button",{type:"button",class:"wm-attached__remove","aria-label":s.t("attachment.remove"),onClick:ne=>s.removePendingAttachment($)},[...t[13]||(t[13]=[u("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.4","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[u("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,kg)]))),128))])):F("",!0),s.endedBlockVisible?(h(),p("div",Cg,[u("span",Sg,R(s.isClosed?s.t("composer.conversationClosed"):s.t("composer.conversationEnded")),1),u("button",{type:"button",class:"wm-ended__btn",onClick:t[2]||(t[2]=U=>s.isClosed?s.onReopen():s.startConv())},R(s.isClosed?s.t("composer.reopen"):s.t("composer.newConversation")),1)])):s.actionInFlight?F("",!0):(h(),fe(K,{key:4,ref:"composer",modelValue:i.draft,"onUpdate:modelValue":t[3]||(t[3]=U=>i.draft=U),placeholder:s.composerPlaceholder,"attach-label":s.t("composer.attachFile"),"display-mode":n.displayMode,onSend:s.onSend,onAttach:s.onAttach},null,8,["modelValue","placeholder","attach-label","display-mode","onSend","onAttach"]))]),i.moreOpen?(h(),fe(S,{key:0,"can-rename":!!s.currentConv&&!s.currentConv._draft,"can-export":!!s.currentConv&&!s.currentConv._draft,"sound-enabled":e.soundEnabled,"status-url":s.statusUrl,"help-url":s.helpUrl,onClose:t[4]||(t[4]=U=>i.moreOpen=!1),onSoundToggle:e.onSoundToggle,onAction:s.onMoreAction},null,8,["can-rename","can-export","sound-enabled","status-url","help-url","onSoundToggle","onAction"])):F("",!0),i.renameDialogOpen&&s.currentConv&&!s.currentConv._draft?(h(),fe(J,{key:1,"initial-value":s.currentConv.name||"",title:s.t("rename.dialogTitle"),onClose:t[5]||(t[5]=U=>i.renameDialogOpen=!1),onSubmit:s.onRenameSubmit},null,8,["initial-value","title","onSubmit"])):F("",!0)])):(h(),fe(d,{key:"home",class:"wm-screen",title:s.widgetTitle,subtitle:s.widgetSubtitle,"agent-name":s.agentName,"default-icon-url":s.defaultIconUrl,"cover-image-url":s.coverImageUrl,"quick-links":s.quickLinks,"open-threads":s.openThreads,busy:i.busy,launching:i.launching,"welcome-message":s.widgetWelcomeMessage,onStart:s.onOnboardingStart,onLaunched:s.onHomeLaunched,onSelect:s.onQuickLink,onResume:s.onDrawerPick,onViewHistory:t[1]||(t[1]=U=>i.showHistory=!0)},null,8,["title","subtitle","agent-name","default-icon-url","cover-image-url","quick-links","open-threads","busy","launching","welcome-message","onStart","onLaunched","onSelect","onResume"]))]),_:1})]),i.moreOpen&&!s.currentConv?(h(),fe(S,{key:0,"can-rename":!1,"can-export":!1,"sound-enabled":e.soundEnabled,"status-url":s.statusUrl,"help-url":s.helpUrl,onClose:t[6]||(t[6]=U=>i.moreOpen=!1),onSoundToggle:e.onSoundToggle,onAction:s.onMoreAction},null,8,["sound-enabled","status-url","help-url","onSoundToggle","onAction"])):F("",!0)],64))],6)):F("",!0)],6)}const xg=be(sg,[["render",Ag],["__scopeId","data-v-801581ca"]]),ni=window.__WIDGET_ID,si=window.__BASE_URL,Tg=window.__DISPLAY_MODE||"floating",ri=window.__LANGUAGE||"";window.__MESSENGER_IFRAME_VERSION="0.6.29";if(!ni||!si)console.error("[messenger-iframe] missing __WIDGET_ID or __BASE_URL globals");else{if(!document.getElementById("wm-tokens")){const e=document.createElement("style");e.id="wm-tokens",e.textContent=Ao,document.head.appendChild(e)}sc({render:()=>wo(xg,{baseUrl:si,widgetId:ni,displayMode:Tg,...ri?{language:ri}:{}})}).mount("#app")}
|