@_solaris/messenger-widget 0.5.1 → 0.5.2

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.
@@ -54,4 +54,4 @@ ${l}`)}return a.join(`
54
54
  `)}function ct(t,n,r=V(),s){if(!t)return;const a=lt(t,n||[],r,W(s)),o=new Blob([a],{type:"text/plain;charset=utf-8"});try{const i=URL.createObjectURL(o),l=document.createElement("a");l.href=i,l.download=`${(t.name||"conversation").replace(/[^a-z0-9-_]+/gi,"_")}.txt`,document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>URL.revokeObjectURL(i),1e3)}catch(i){console.error("[ww-messenger] export failed",i)}}const dt={data(){const t=typeof Notification<"u";return{notifPermission:t?Notification.permission:"denied",soundEnabled:!0,browserNotifEnabled:t&&Notification.permission==="granted",_audioCtx:null}},methods:{teardownNotifications(){var t,n;if(this._audioCtx){try{(n=(t=this._audioCtx).close)==null||n.call(t)}catch{}this._audioCtx=null}},soundStorageKey(){return`wm:notif:sound:${this.widgetId||""}`},browserNotifStorageKey(){return`wm:notif:browser:${this.widgetId||""}`},hydrateNotifPref(){try{if(typeof localStorage>"u")return;const t=localStorage.getItem(this.soundStorageKey());t==="0"?this.soundEnabled=!1:t==="1"&&(this.soundEnabled=!0);const n=localStorage.getItem(this.browserNotifStorageKey());n==="0"?this.browserNotifEnabled=!1:n==="1"&&(this.browserNotifEnabled=typeof Notification<"u"&&Notification.permission==="granted")}catch{}},persistSoundPref(){try{if(typeof localStorage>"u")return;localStorage.setItem(this.soundStorageKey(),this.soundEnabled?"1":"0")}catch{}},persistBrowserNotifPref(){try{if(typeof localStorage>"u")return;localStorage.setItem(this.browserNotifStorageKey(),this.browserNotifEnabled?"1":"0")}catch{}},onSoundToggle(t){this.soundEnabled=!!t,this.persistSoundPref()},async onBrowserNotifToggle(t){if(typeof Notification>"u"){this.browserNotifEnabled=!1,this.persistBrowserNotifPref();return}if(!t){this.browserNotifEnabled=!1,this.persistBrowserNotifPref();return}let n=Notification.permission;if(n==="default"){try{n=await Notification.requestPermission()}catch(r){console.warn("[ww-messenger] notif permission request failed",r),n="denied"}this.notifPermission=n}this.browserNotifEnabled=n==="granted",this.persistBrowserNotifPref()},onMessageRevealed(t,n){var a;if(!this.soundEnabled&&!this.browserNotifEnabled||!n||!t||!J(t))return;const r=typeof document<"u"&&document.hidden;this.isOpen&&!r&&((a=this.currentConv)==null?void 0:a.id)===n||(this.soundEnabled&&this.playNotificationSound(),this.browserNotifEnabled&&this.showBrowserNotification(n,t))},playNotificationSound(){if(typeof window>"u")return;const t=window.AudioContext||window.webkitAudioContext;if(t)try{this._audioCtx||(this._audioCtx=new t);const n=this._audioCtx;if(n.state==="suspended")try{n.resume()}catch{}const r=n.currentTime,s=n.createOscillator(),a=n.createGain();s.connect(a),a.connect(n.destination),s.type="sine",s.frequency.setValueAtTime(880,r),s.frequency.exponentialRampToValueAtTime(1320,r+.08),a.gain.setValueAtTime(0,r),a.gain.linearRampToValueAtTime(.12,r+.02),a.gain.exponentialRampToValueAtTime(1e-4,r+.28),s.start(r),s.stop(r+.32)}catch{}},showBrowserNotification(t,n){if(typeof Notification>"u"||Notification.permission!=="granted")return;const r=n==null?void 0:n.author,s=!r||r.type==="agent_ia",o=((r==null?void 0:r.name)||(s?this.agentName:"")||this.t("launcher.theAgent"))+this.t("launcher.repliedToYou"),i=typeof(n==null?void 0:n.text_md)=="string"?n.text_md.trim():"",l=i?i.slice(0,140):this.t("notification.youHaveNewMessage");try{const f=new Notification(o,{body:l,tag:`wm-${t}`,renotify:!1,silent:!0});f.onclick=()=>{try{window.focus()}catch{}this.draftConv=null,this.showOnboarding=!1,this.activeConvId=t,this.isOpen=!0,this.store&&this.store.setPanelOpen(!0);try{f.close()}catch{}}}catch(f){console.warn("[ww-messenger] notification failed",f)}}}},ut=450,mt=50,ht=900,ft=12e3,pt=300,gt={data(){return{revealedAt:{},nextRevealAt:0,revealTimers:[],_liveRevealOff:null,_liveRevealConvSnapshot:null}},methods:{cancelReveals(){for(const t of this.revealTimers)clearTimeout(t);this.revealTimers=[]},resetRevealQueue(){this.cancelReveals(),this.revealedAt={},this.nextRevealAt=0},setupLiveReveal(){var r;if(!this.transport)return;this.teardownLiveReveal();const t=this.transport.on("message",s=>{const a=s==null?void 0:s.conversation_id,o=s==null?void 0:s.message;a&&o&&this.paceLiveMessage(o,a)});this._liveRevealConvSnapshot=new Map((((r=this.s)==null?void 0:r.conversations)||[]).map(s=>[s.id,(s==null?void 0:s.last_message_at)||""]));const n=this.transport.on("activity",s=>{this.handleLiveActivity(s)});this._liveRevealOff=()=>{try{t()}catch{}try{n()}catch{}}},teardownLiveReveal(){if(this._liveRevealOff){try{this._liveRevealOff()}catch{}this._liveRevealOff=null}this._liveRevealConvSnapshot=null},async handleLiveActivity(t){var a,o;const n=t==null?void 0:t.conversations;if(!Array.isArray(n)||!this.store)return;const r=this._liveRevealConvSnapshot||new Map,s=[];for(const i of n){if(!(i!=null&&i.id))continue;const l=i.last_message_at||"";if(!l)continue;const f=r.get(i.id)||"";l>f&&s.push(i.id)}this._liveRevealConvSnapshot=new Map(n.map(i=>[i.id,(i==null?void 0:i.last_message_at)||""]));for(const i of s)try{const l=await((o=(a=this.store).fetchSinceLast)==null?void 0:o.call(a,i));if(!Array.isArray(l))continue;for(const f of l)this.paceLiveMessage(f,i)}catch(l){console.error("[ww-messenger] activity delta fetch failed",l)}},scheduleReveal(t,n){const r=Date.now(),s=((t==null?void 0:t.text_md)||"").length,a=Math.min(ft,Math.max(ht,s*mt)),i=Math.max(r+ut,this.nextRevealAt+pt)+a;this.nextRevealAt=i;const l=Math.max(0,i-r),f=t.id,_=setTimeout(()=>{this.revealedAt={...this.revealedAt,[f]:Date.now()},this.revealTimers=this.revealTimers.filter(v=>v!==_),typeof this.onMessageRevealed=="function"&&this.onMessageRevealed(t,n)},l);this.revealTimers.push(_)},paceMessages(t,n){var a;if(!Array.isArray(t)||!t.length)return;const r=Date.now(),s={...this.revealedAt};for(const o of t){if((o==null?void 0:o.id)==null||s[o.id]!==void 0)continue;if(!J(o)){s[o.id]=r;continue}const i=o!=null&&o.created_at?Date.parse(o.created_at):NaN;if(!Number.isFinite(i)||i<this.convOpenedAt){s[o.id]=r;continue}const l=typeof(o==null?void 0:o.text_md)=="string"&&o.text_md.trim().length>0,f=Array.isArray((a=o==null?void 0:o.payload)==null?void 0:a.attachments)&&o.payload.attachments.length>0;if(!l&&!f){s[o.id]=r;continue}s[o.id]=0,this.scheduleReveal(o,n)}this.revealedAt=s},paceLiveMessage(t,n){var a;if(!(t!=null&&t.id)||this.revealedAt[t.id]!==void 0)return;if(!J(t)){this.revealedAt={...this.revealedAt,[t.id]:Date.now()};return}const r=typeof(t==null?void 0:t.text_md)=="string"&&t.text_md.trim().length>0,s=Array.isArray((a=t==null?void 0:t.payload)==null?void 0:a.attachments)&&t.payload.attachments.length>0;if(!r&&!s){this.revealedAt={...this.revealedAt,[t.id]:Date.now()};return}this.revealedAt={...this.revealedAt,[t.id]:0},this.scheduleReveal(t,n)}}},_t={data(){return{approvalSettled:!0,approvalSettleTimer:null,approvalLatchId:null}},methods:{resetApprovalPacing(){this.approvalSettleTimer&&(clearTimeout(this.approvalSettleTimer),this.approvalSettleTimer=null),this.approvalSettled=!0,this.approvalLatchId=null},bumpApprovalSettle(t=800){this.approvalSettled=!1,this.approvalSettleTimer&&clearTimeout(this.approvalSettleTimer),this.approvalSettleTimer=setTimeout(()=>{this.approvalSettled=!0,this.approvalSettleTimer=null},t)}}},yt=300,vt={data(){return{unreadAnchorId:null,unreadBoundaryTs:""}},created(){this._readMarkerTimer=null,this._readMarkerPending=null},beforeUnmount(){this._readMarkerTimer&&(clearTimeout(this._readMarkerTimer),this._readMarkerTimer=null),this._readMarkerPending=null},methods:{markConvRead(t){var o,i;if(!(t!=null&&t.id)||t._draft||!this.store)return;const n=((i=(o=this.s)==null?void 0:o.messagesByConv)==null?void 0:i[t.id])||[],r=kt(n);if(r==null)return;const s=F(t.last_read_message_id),a=F(r);a!=null&&(s!=null&&a<=s||(this._readMarkerPending={convId:t.id,messageId:r},!this._readMarkerTimer&&(this._readMarkerTimer=setTimeout(()=>{const l=this._readMarkerPending;this._readMarkerPending=null,this._readMarkerTimer=null,l&&this.store&&this.store.markConversationRead(l.convId,l.messageId)},yt))))}}};function kt(t){for(let n=t.length-1;n>=0;n--){const r=t[n];if(!(!r||r._pending)&&F(r.id)!=null)return r.id}return null}const N=(t,n)=>{const r=t.__vccOpts||t;for(const[s,a]of n)r[s]=a;return r},wt={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":Z(this.name)},initials(){return ee(this.name)}}},bt=["src","alt"];function Et(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-huav",{"wm-huav--tail":r.tail}]),style:e.normalizeStyle({width:r.size+"px",height:r.size+"px","--wm-avr":Math.round(r.size*.32)+"px",background:o.bg})},[r.avatarUrl?(e.openBlock(),e.createElementBlock("img",{key:0,src:r.avatarUrl,alt:r.name||""},null,8,bt)):(e.openBlock(),e.createElementBlock("span",{key:1,style:e.normalizeStyle({fontSize:r.size*.36+"px"})},e.toDisplayString(o.initials),5))],6)}const de=N(wt,[["render",Et],["__scopeId","data-v-14e10c0d"]]),Ct=3,Bt={name:"WmLauncher",components:{HumanAvatar:de},inject:{t:{default:()=>V()}},props:{unreadCount:{type:Number,default:0},peeks:{type:Array,default:()=>[]}},emits:["open","dismiss"],computed:{visiblePeeks(){return this.peeks.slice(0,Ct).reverse()}}},Nt={class:"wm-launcherWrap"},St=["aria-label","onClick","onKeydown"],At=["aria-label","onClick"],Vt={class:"wm-peek__avatar"},Mt=["aria-label"],Tt={class:"wm-peek__body"},xt={class:"wm-peek__head"},Lt={class:"wm-peek__name"},Ot={class:"wm-peek__action"},Dt={class:"wm-peek__text"},It=["onClick"],Rt=["aria-label"],Ft=["aria-label"];function Ut(t,n,r,s,a,o){const i=e.resolveComponent("HumanAvatar");return e.openBlock(),e.createElementBlock("div",Nt,[e.createVNode(e.Transition,{name:"wm-peek"},{default:e.withCtx(()=>[o.visiblePeeks.length?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["wm-peekStack",{"wm-peekStack--multi":o.visiblePeeks.length>1}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.visiblePeeks,(l,f)=>(e.openBlock(),e.createElementBlock("div",{key:l.convId,class:"wm-peek",style:e.normalizeStyle({"--depth":o.visiblePeeks.length-1-f,zIndex:f+1}),role:"button",tabindex:"0","aria-label":o.t("launcher.openConversationWith",{name:l.senderName||o.t("launcher.theAgent")}),onClick:_=>t.$emit("open",l.convId),onKeydown:[e.withKeys(e.withModifiers(_=>t.$emit("open",l.convId),["prevent"]),["enter"]),e.withKeys(e.withModifiers(_=>t.$emit("open",l.convId),["prevent"]),["space"])]},[e.createElementVNode("button",{type:"button",class:"wm-peek__close","aria-label":o.t("launcher.dismiss"),onClick:e.withModifiers(_=>t.$emit("dismiss",l.convId),["stop"])},[...n[1]||(n[1]=[e.createElementVNode("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,At),e.createElementVNode("div",Vt,[e.createVNode(i,{name:l.senderName,"avatar-url":l.senderAvatarUrl,size:34},null,8,["name","avatar-url"]),l.count>1?(e.openBlock(),e.createElementBlock("span",{key:0,class:"wm-peek__avatarBadge","aria-label":o.t("launcher.unreadMessages",{count:l.count})},e.toDisplayString(l.count>9?"9+":l.count),9,Mt)):e.createCommentVNode("",!0)]),e.createElementVNode("div",Tt,[e.createElementVNode("div",xt,[e.createElementVNode("span",Lt,e.toDisplayString(l.senderName||o.t("common.agent")),1),e.createElementVNode("span",Ot,e.toDisplayString(o.t("launcher.repliedToYou")),1)]),e.createElementVNode("p",Dt,e.toDisplayString(l.preview),1)]),e.createElementVNode("button",{type:"button",class:"wm-peek__open",onClick:e.withModifiers(_=>t.$emit("open",l.convId),["stop"])},e.toDisplayString(o.t("common.open")),9,It)],44,St))),128))],2)):e.createCommentVNode("",!0)]),_:1}),e.createElementVNode("button",{type:"button",class:"wm-launcher","aria-label":o.t("launcher.open"),onClick:n[0]||(n[0]=l=>t.$emit("open"))},[n[2]||(n[2]=e.createElementVNode("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.7","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})],-1)),r.unreadCount>0?(e.openBlock(),e.createElementBlock("span",{key:0,class:"wm-launcher__badge","aria-label":r.unreadCount>1?o.t("launcher.unreadConversationsMany",{count:r.unreadCount}):o.t("launcher.unreadConversationsOne",{count:r.unreadCount})},e.toDisplayString(r.unreadCount>9?"9+":r.unreadCount),9,Ft)):e.createCommentVNode("",!0)],8,Rt)])}const Be=N(Bt,[["render",Ut],["__scopeId","data-v-5193a529"]]),Pt={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 ee(this.name)},bgColor(){return Z(this.name)}}},jt={key:0,class:"wm-aiav__pulse"},zt=["src","alt"],qt=["width","height"];function Ht(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-aiav",{"wm-aiav--tail":r.tail}]),style:e.normalizeStyle({width:r.size+"px",height:r.size+"px","--wm-avr":r.size*.32+"px"})},[r.pulse?(e.openBlock(),e.createElementBlock("div",jt)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["wm-aiav__inner",{"wm-aiav__inner--glow":r.pulse,"wm-aiav__inner--img":!!r.imageUrl,"wm-aiav__inner--initials":!r.imageUrl&&!!o.initials}]),style:e.normalizeStyle(!r.imageUrl&&o.initials?{background:o.bgColor}:null)},[r.imageUrl?(e.openBlock(),e.createElementBlock("img",{key:0,src:r.imageUrl,alt:r.name||""},null,8,zt)):o.initials?(e.openBlock(),e.createElementBlock("span",{key:1,style:e.normalizeStyle({fontSize:r.size*.36+"px"})},e.toDisplayString(o.initials),5)):(e.openBlock(),e.createElementBlock("svg",{key:2,width:r.size*.5,height:r.size*.5,viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[...n[0]||(n[0]=[e.createElementVNode("path",{d:"M12 2 L13.5 9 L20 10.5 L13.5 12 L12 19 L10.5 12 L4 10.5 L10.5 9 Z",fill:"white",opacity:"0.92"},null,-1),e.createElementVNode("circle",{cx:"19",cy:"5",r:"1.5",fill:"white",opacity:"0.55"},null,-1),e.createElementVNode("circle",{cx:"5",cy:"18",r:"1",fill:"white",opacity:"0.38"},null,-1)])],8,qt))],6)],6)}const G=N(Pt,[["render",Ht],["__scopeId","data-v-6f7f685d"]]),$t={name:"WmTeamAvatars",props:{members:{type:Array,default:()=>[]},responseLabel:{type:String,default:""}},computed:{visible(){return Array.isArray(this.members)&&this.members.length>0},stackWidth(){return Math.min(this.members.length,3)===1?20:16+Math.min(this.members.length,3)*13}},methods:{colorFor(t){return t.avatar_url?"transparent":Z(t.name||"")},initialsFor(t){return ee(t.name||"")}}},Kt={key:0,class:"wm-team"},Wt=["src","alt"],Gt={key:1},Yt={key:0,class:"wm-team__label"};function Jt(t,n,r,s,a,o){return o.visible?(e.openBlock(),e.createElementBlock("div",Kt,[e.createElementVNode("div",{class:"wm-team__stack",style:e.normalizeStyle({width:o.stackWidth+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.members.slice(0,3),(i,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-team__pill",style:e.normalizeStyle({left:l*13+"px",zIndex:3-l,background:o.colorFor(i)})},[i.avatar_url?(e.openBlock(),e.createElementBlock("img",{key:0,src:i.avatar_url,alt:i.name||""},null,8,Wt)):(e.openBlock(),e.createElementBlock("span",Gt,e.toDisplayString(o.initialsFor(i)),1))],4))),128))],4),r.responseLabel?(e.openBlock(),e.createElementBlock("span",Yt,e.toDisplayString(r.responseLabel),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}const Ne=N($t,[["render",Jt],["__scopeId","data-v-e49a9063"]]),Qt={name:"WmHeader",components:{AIAvatar:G,TeamAvatars:Ne},inject:{t:{default:()=>V()}},props:{title:{type:String,default:"Nouvelle conversation"},showBack:{type:Boolean,default:!1},teamMembers:{type:Array,default:()=>[]},responseLabel:{type:String,default:""},showClose:{type:Boolean,default:!0},showMore:{type:Boolean,default:!0},moreActive:{type:Boolean,default:!1},showIdentity:{type:Boolean,default:!0},agentName:{type:String,default:""},agentAvatarUrl:{type:String,default:null}},emits:["back","close","more"],computed:{hasTeam(){return Array.isArray(this.teamMembers)&&this.teamMembers.length>0},displayedTeamMembers(){const t=Array.isArray(this.teamMembers)?this.teamMembers:[];if(t.length<=3)return t;const n=new Date().getHours()%t.length,r=[];for(let s=0;s<3;s++)r.push(t[(n+s)%t.length]);return r}}},Xt={class:"wm-header"},Zt=["aria-label"],en={key:1,style:{width:"30px",height:"30px","flex-shrink":"0"}},tn={class:"wm-header__avatar"},nn={class:"wm-header__main"},rn={class:"wm-header__title"},on={key:3,class:"wm-header__fill"},an={class:"wm-header__actions"},sn=["aria-label","title"],ln=["aria-label","title"];function cn(t,n,r,s,a,o){const i=e.resolveComponent("AIAvatar"),l=e.resolveComponent("TeamAvatars");return e.openBlock(),e.createElementBlock("div",Xt,[r.showBack?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-header__icon","aria-label":o.t("header.backToHome"),onClick:n[0]||(n[0]=f=>t.$emit("back"))},[...n[3]||(n[3]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M19 12H5M12 5l-7 7 7 7"})],-1)])],8,Zt)):(e.openBlock(),e.createElementBlock("div",en)),r.showIdentity?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createElementVNode("div",tn,[e.createVNode(i,{size:30,name:r.agentName,"image-url":r.agentAvatarUrl},null,8,["name","image-url"])]),e.createElementVNode("div",nn,[e.createElementVNode("div",rn,e.toDisplayString(r.title),1)]),o.hasTeam?(e.openBlock(),e.createBlock(l,{key:0,members:o.displayedTeamMembers,"response-label":""},null,8,["members"])):e.createCommentVNode("",!0)],64)):(e.openBlock(),e.createElementBlock("div",on)),e.createElementVNode("div",an,[r.showMore?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["wm-header__icon",{"wm-header__icon--active":r.moreActive}]),"aria-label":o.t("header.moreOptions"),title:o.t("header.moreOptions"),onClick:n[1]||(n[1]=f=>t.$emit("more"))},[...n[4]||(n[4]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true"},[e.createElementVNode("circle",{cx:"12",cy:"5",r:"1.6"}),e.createElementVNode("circle",{cx:"12",cy:"12",r:"1.6"}),e.createElementVNode("circle",{cx:"12",cy:"19",r:"1.6"})],-1)])],10,sn)):e.createCommentVNode("",!0),r.showClose?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"wm-header__icon","aria-label":o.t("header.closeWidget"),title:o.t("header.closeWidget"),onClick:n[2]||(n[2]=f=>t.$emit("close"))},[...n[5]||(n[5]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,ln)):e.createCommentVNode("",!0)])])}const Se=N(Qt,[["render",cn],["__scopeId","data-v-925c9e94"]]);function Ae(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function dn(t){return/^(https?:\/\/|mailto:|tel:)/i.test(String(t).trim())}const pe="";function Y(t){let n=t;const r=[];return n=n.replace(/`([^`\n]+)`/g,(s,a)=>{const o=r.length;return r.push(a),`${pe}CODE${o}${pe}`}),n=n.replace(/\[([^\]\n]+)\]\(([^)\s]+)\)/g,(s,a,o)=>dn(o)?`<a href="${o}" target="_blank" rel="noopener noreferrer">${a}</a>`:a),n=n.replace(/\*\*([^\n*][^\n]*?)\*\*/g,"<strong>$1</strong>"),n=n.replace(/__([^\n_][^\n]*?)__/g,"<u>$1</u>"),n=n.replace(/~~([^\n~][^\n]*?)~~/g,"<s>$1</s>"),n=n.replace(/(^|[^\w*])\*([^\n*]+?)\*(?!\w)/g,"$1<em>$2</em>"),n=n.replace(/(^|[^\w_])_([^\n_]+?)_(?!\w)/g,"$1<em>$2</em>"),n=n.replace(/CODE(\d+)/g,(s,a)=>`<code class="wm-md-code">${r[+a]}</code>`),n}function Ve(t){if(!t)return"";const n=String(t).replace(/\[([^\]\n]+)\]\([^)\s]+\)/g,"$1");return Y(Ae(n))}function Me(t){if(!t)return"";const n=Ae(t).split(`
55
55
  `),r=[];let s=0;for(;s<n.length;){const o=n[s];if(/^\s*```([\w-]*)\s*$/.exec(o)){s++;const _=[];for(;s<n.length&&!/^\s*```\s*$/.test(n[s]);)_.push(n[s]),s++;s<n.length&&s++,r.push({type:"block",html:`<pre class="wm-md-pre"><code>${_.join(`
56
56
  `)}</code></pre>`});continue}if(/^\s*[-*]\s+/.test(o)){const _=[];for(;s<n.length;){const B=/^\s*[-*]\s+(.*)$/.exec(n[s]);if(!B)break;_.push(B[1]),s++}const v=_.map(B=>`<li>${Y(B)}</li>`).join("");r.push({type:"block",html:`<ul class="wm-md-ul">${v}</ul>`});continue}const l=/^\s*(\d+)\.\s+(.*)$/.exec(o);if(l){const _=parseInt(l[1],10),v=[l[2]];for(s++;s<n.length;){const E=/^\s*\d+\.\s+(.*)$/.exec(n[s]);if(!E)break;v.push(E[1]),s++}const B=v.map(E=>`<li>${Y(E)}</li>`).join(""),S=_!==1?` start="${_}"`:"";r.push({type:"block",html:`<ol class="wm-md-ol"${S}>${B}</ol>`});continue}const f=/^(#{1,6})\s+(.*)$/.exec(o);if(f){const _=f[1].length;r.push({type:"block",html:`<h${_} class="wm-md-h wm-md-h${_}">${Y(f[2])}</h${_}>`}),s++;continue}r.push({type:"text",html:Y(o)}),s++}let a="";for(let o=0;o<r.length;o++){const i=r[o];a+=i.html;const l=r[o+1];l&&i.type!=="block"&&l.type!=="block"&&(a+=`
57
- `)}return a}const ge={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"},un={name:"WmOnboarding",components:{AIAvatar:G},inject:{t:{default:()=>V()},wmLocale:{default:()=>()=>"fr"}},props:{welcomeMessage:{type:String,default:""},subtitle:{type:String,default:""},agentName:{type:String,default:""},defaultIconUrl:{type:String,default:null},quickLinks:{type:Array,default:()=>[]},openThreads:{type:Array,default:()=>[]},busy:{type:Boolean,default:!1}},emits:["start","select","resume"],data(){return{query:""}},computed:{heroTitle(){return this.welcomeMessage?this.welcomeMessage:this.agentName?this.t("onboarding.greetingNamed",{name:this.agentName}):this.t("onboarding.greeting")},heroSub(){return this.subtitle||this.t("onboarding.heroSub")},isOddQuickLinks(){return this.quickLinks.length%2===1},quickLinksLayout(){return this.isOddQuickLinks?"wm-onb__qlist":"wm-onb__grid"},filteredThreads(){const t=this.query.trim().toLowerCase();return t?this.openThreads.filter(n=>(n.title||"").toLowerCase().includes(t)||(n.preview||"").toLowerCase().includes(t)):this.openThreads}},methods:{iconPath(t){return ge[t]||ge.link},renderPreview(t){return Ve(t)},formatTs(t){if(!t)return"";const n=new Date(t);if(Number.isNaN(n.getTime()))return"";const r=W(this.wmLocale()),s=new Date;if(n.toDateString()===s.toDateString())return n.toLocaleTimeString(r,{hour:"2-digit",minute:"2-digit"});if(s.getTime()-n.getTime()<7*864e5){const i=n.toLocaleDateString(r,{weekday:"short"});return i.charAt(0).toUpperCase()+i.slice(1)}return n.toLocaleDateString(r,{day:"2-digit",month:"2-digit"})}}},mn={class:"wm-onb"},hn={class:"wm-onb__hero"},fn={class:"wm-onb__hero-text"},pn={class:"wm-onb__title"},gn={class:"wm-onb__sub"},_n={class:"wm-onb__cta"},yn=["disabled"],vn={key:0,class:"wm-onb__section"},kn={class:"wm-onb__section-title"},wn=["onClick"],bn={class:"wm-onb__card-icon"},En={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"},Cn=["d"],Bn={class:"wm-onb__card-body"},Nn={class:"wm-onb__card-title"},Sn={key:0,class:"wm-onb__card-sub"},An={key:1,class:"wm-onb__section"},Vn={class:"wm-onb__section-title"},Mn={class:"wm-onb__search"},Tn=["placeholder","aria-label"],xn={class:"wm-onb__list"},Ln=["onClick"],On=["aria-label"],Dn={class:"wm-onb__thread-body"},In={class:"wm-onb__thread-title"},Rn=["innerHTML"],Fn={class:"wm-onb__thread-meta"},Un={key:0,class:"wm-onb__thread-time"},Pn={key:0,class:"wm-onb__empty"};function jn(t,n,r,s,a,o){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",mn,[e.createElementVNode("div",hn,[n[2]||(n[2]=e.createElementVNode("svg",{class:"wm-onb__hero-deco",width:"180",height:"180",viewBox:"0 0 180 180",fill:"none","aria-hidden":"true"},[e.createElementVNode("circle",{cx:"170",cy:"10",r:"105",stroke:"#5B5FEF","stroke-width":"1","stroke-dasharray":"1 5",opacity:"0.35"}),e.createElementVNode("circle",{cx:"170",cy:"10",r:"72",stroke:"#5B5FEF","stroke-width":"1","stroke-dasharray":"1 5",opacity:"0.5"}),e.createElementVNode("circle",{cx:"152",cy:"34",r:"2.5",fill:"#5B5FEF",opacity:"0.65"})],-1)),e.createVNode(i,{size:52,"image-url":r.defaultIconUrl},null,8,["image-url"]),e.createElementVNode("div",fn,[e.createElementVNode("div",pn,e.toDisplayString(o.heroTitle),1),e.createElementVNode("div",gn,e.toDisplayString(o.heroSub),1)])]),e.createElementVNode("div",_n,[e.createElementVNode("button",{type:"button",class:"wm-onb__startBtn",disabled:r.busy,onClick:n[0]||(n[0]=l=>t.$emit("start"))},[n[3]||(n[3]=e.createElementVNode("span",{class:"wm-onb__startIcon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M12 5v14M5 12h14"})])],-1)),e.createElementVNode("span",null,e.toDisplayString(r.busy?"…":o.t("onboarding.start")),1)],8,yn)]),r.quickLinks.length?(e.openBlock(),e.createElementBlock("div",vn,[e.createElementVNode("div",kn,e.toDisplayString(o.t("onboarding.quickAccess")),1),e.createElementVNode("div",{class:e.normalizeClass(o.quickLinksLayout)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.quickLinks,(l,f)=>(e.openBlock(),e.createElementBlock("button",{key:f,type:"button",class:e.normalizeClass(["wm-onb__card",{"wm-onb__card--row":o.isOddQuickLinks}]),onClick:_=>t.$emit("select",l)},[e.createElementVNode("span",bn,[(e.openBlock(),e.createElementBlock("svg",En,[e.createElementVNode("path",{d:o.iconPath(l.icon)},null,8,Cn)]))]),e.createElementVNode("span",Bn,[e.createElementVNode("span",Nn,e.toDisplayString(l.label),1),l.description?(e.openBlock(),e.createElementBlock("span",Sn,e.toDisplayString(l.description),1)):e.createCommentVNode("",!0)])],10,wn))),128))],2)])):e.createCommentVNode("",!0),r.openThreads.length?(e.openBlock(),e.createElementBlock("div",An,[e.createElementVNode("div",Vn,e.toDisplayString(o.t("onboarding.recentConversations")),1),e.createElementVNode("div",Mn,[n[4]||(n[4]=e.createElementVNode("span",{class:"wm-onb__searchIcon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 21l-4.35-4.35M11 17a6 6 0 100-12 6 6 0 000 12z"})])],-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":n[1]||(n[1]=l=>a.query=l),type:"text",placeholder:o.t("onboarding.search"),"aria-label":o.t("onboarding.search")},null,8,Tn),[[e.vModelText,a.query]])]),e.createElementVNode("div",xn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.filteredThreads,l=>(e.openBlock(),e.createElementBlock("button",{key:l.id,type:"button",class:"wm-onb__thread",onClick:f=>t.$emit("resume",l)},[e.createElementVNode("span",{class:e.normalizeClass(["wm-onb__thread-icon",{"wm-onb__thread-icon--inverted":!l.unread}])},[n[5]||(n[5]=e.createElementVNode("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[e.createElementVNode("path",{d:"M12 2 L13.5 9 L20 10.5 L13.5 12 L12 19 L10.5 12 L4 10.5 L10.5 9 Z",fill:"currentColor",opacity:"0.92"})],-1)),l.unread?(e.openBlock(),e.createElementBlock("span",{key:0,class:"wm-onb__thread-dot","aria-label":o.t("onboarding.unread")},null,8,On)):e.createCommentVNode("",!0)],2),e.createElementVNode("span",Dn,[e.createElementVNode("span",In,e.toDisplayString(l.title),1),e.createElementVNode("span",{class:"wm-onb__thread-preview",innerHTML:o.renderPreview(l.preview)},null,8,Rn)]),e.createElementVNode("span",Fn,[o.formatTs(l._ts)?(e.openBlock(),e.createElementBlock("span",Un,e.toDisplayString(o.formatTs(l._ts)),1)):e.createCommentVNode("",!0),n[6]||(n[6]=e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round",class:"wm-onb__thread-chev","aria-hidden":"true"},[e.createElementVNode("path",{d:"M5 12h14M13 5l7 7-7 7"})],-1))])],8,Ln))),128)),o.filteredThreads.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Pn,e.toDisplayString(o.t("onboarding.noResults",{query:a.query})),1))])])):e.createCommentVNode("",!0)])}const Te=N(un,[["render",jn],["__scopeId","data-v-28c0780b"]]);function zn(t){return typeof t!="string"?"":t.replace(/`([^`]+)`/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(new RegExp("(?<!\\*)\\*([^*]+)\\*(?!\\*)","g"),"$1").replace(/__([^_]+)__/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\s+/g," ").trim()}const qn={name:"WmActionResult",props:{state:{type:String,default:"success"},label:{type:String,required:!0},detail:{type:String,default:""}},computed:{detailText(){return zn(this.detail)}}},Hn={class:"wm-result__icon","aria-hidden":"true"},$n={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"},Kn={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"},Wn={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"},Gn={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"},Yn={class:"wm-result__body"},Jn={class:"wm-result__label"},Qn={class:"wm-result__detail"};function Xn(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-result",`wm-result--${r.state}`])},[e.createElementVNode("span",Hn,[r.state==="success"?(e.openBlock(),e.createElementBlock("svg",$n,[...n[0]||(n[0]=[e.createElementVNode("path",{d:"M20 6L9 17l-5-5"},null,-1)])])):r.state==="rejected"?(e.openBlock(),e.createElementBlock("svg",Kn,[...n[1]||(n[1]=[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"},null,-1)])])):r.state==="awaiting"?(e.openBlock(),e.createElementBlock("svg",Wn,[...n[2]||(n[2]=[e.createElementVNode("circle",{cx:"12",cy:"12",r:"10"},null,-1),e.createElementVNode("polyline",{points:"12 7 12 12 15 14"},null,-1)])])):(e.openBlock(),e.createElementBlock("svg",Gn,[...n[3]||(n[3]=[e.createElementVNode("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"},null,-1),e.createElementVNode("line",{x1:"12",y1:"9",x2:"12",y2:"13"},null,-1),e.createElementVNode("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"},null,-1)])]))]),e.createElementVNode("span",Yn,[e.createElementVNode("span",Jn,e.toDisplayString(r.label),1),o.detailText?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[n[4]||(n[4]=e.createElementVNode("span",{class:"wm-result__sep","aria-hidden":"true"}," · ",-1)),e.createElementVNode("span",Qn,e.toDisplayString(o.detailText),1)],64)):e.createCommentVNode("",!0)])],2)}const xe=N(qn,[["render",Xn],["__scopeId","data-v-7284acd0"]]),Zn={name:"WmArtifactFormResponse",inject:{t:{default:()=>V()}},props:{data:{type:Object,required:!0}},computed:{fields(){var t;return Array.isArray((t=this.data)==null?void 0:t.fields)?this.data.fields:[]}}},er={class:"wm-art wm-art--formResponse"},tr={class:"wm-art__head"},nr={class:"wm-art__title"},rr={class:"wm-art__badge wm-art__badge--success"},or={class:"wm-art__body"},ar={class:"wm-art__fieldLabel"};function sr(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",er,[e.createElementVNode("div",tr,[e.createElementVNode("div",nr,e.toDisplayString(r.data.title||o.t("form.title")),1),e.createElementVNode("span",rr,[n[0]||(n[0]=e.createElementVNode("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("polyline",{points:"20 6 9 17 4 12"})],-1)),e.createTextVNode(" "+e.toDisplayString(o.t("form.sent")),1)])]),e.createElementVNode("div",or,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.fields,(i,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-art__field"},[e.createElementVNode("div",ar,e.toDisplayString(i.label),1),e.createElementVNode("div",{class:e.normalizeClass(["wm-art__fieldValue",{"wm-art__fieldValue--multi":i.multiline}])},e.toDisplayString(i.value),3)]))),128))])])}const Le=N(Zn,[["render",sr],["__scopeId","data-v-713aecf1"]]),ir={name:"WmArtifactInfoCard",props:{data:{type:Object,required:!0}},computed:{fields(){var t;return Array.isArray((t=this.data)==null?void 0:t.fields)?this.data.fields:[]},hasBody(){var t;return!!((t=this.data)!=null&&t.body)||this.fields.length>0}}},lr={class:"wm-art wm-art--infoCard"},cr={key:0,class:"wm-art__image"},dr=["src","alt"],ur={class:"wm-art__head"},mr={class:"wm-art__headMain"},hr={class:"wm-art__title"},fr={key:0,class:"wm-art__subtitle"},pr={key:1,class:"wm-art__body"},gr={key:0,class:"wm-art__text"},_r={class:"wm-art__fieldLabel"};function yr(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",lr,[r.data.image_url?(e.openBlock(),e.createElementBlock("figure",cr,[e.createElementVNode("img",{src:r.data.image_url,alt:r.data.title||"",loading:"lazy"},null,8,dr)])):e.createCommentVNode("",!0),e.createElementVNode("div",ur,[e.createElementVNode("div",mr,[e.createElementVNode("div",hr,e.toDisplayString(r.data.title),1),r.data.subtitle?(e.openBlock(),e.createElementBlock("div",fr,e.toDisplayString(r.data.subtitle),1)):e.createCommentVNode("",!0)]),r.data.badge&&r.data.badge.label?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(["wm-art__badge",`wm-art__badge--${r.data.badge.tone||"neutral"}`])},e.toDisplayString(r.data.badge.label),3)):e.createCommentVNode("",!0)]),o.hasBody?(e.openBlock(),e.createElementBlock("div",pr,[r.data.body?(e.openBlock(),e.createElementBlock("div",gr,e.toDisplayString(r.data.body),1)):e.createCommentVNode("",!0),o.fields.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(o.fields,(i,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-art__field"},[e.createElementVNode("div",_r,e.toDisplayString(i.label),1),e.createElementVNode("div",{class:e.normalizeClass(["wm-art__fieldValue",{"wm-art__fieldValue--multi":i.multiline}])},e.toDisplayString(i.value),3)]))),128)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])}const Oe=N(ir,[["render",yr],["__scopeId","data-v-7eae0e4a"]]);function vr(t,n,r){if(!t)return"";const s=new Date(t);if(Number.isNaN(s.getTime()))return t;const a=s.toLocaleDateString(n,{day:"numeric",month:"long",year:"numeric"}),o=s.toLocaleTimeString(n,{hour:"2-digit",minute:"2-digit"});return`${a}${r}${o}`}const kr={name:"WmArtifactTicket",inject:{t:{default:()=>V()},wmLocale:{default:()=>()=>"fr"}},props:{data:{type:Object,required:!0}},computed:{fields(){var t;return Array.isArray((t=this.data)==null?void 0:t.fields)?this.data.fields:[]},formattedDate(){var t;return vr((t=this.data)==null?void 0:t.created_at,W(this.wmLocale()),this.t("ticket.dateAt"))}},methods:{isPriority(t){return/priorit|^prio$/i.test(String(t||"").trim())},isDate(t){return/date|échéanc|echeanc|deadline|due|créé|cree/i.test(String(t||"").trim())},priorityLevel(t){const n=String(t||"").toLowerCase();return/high|haute|élev|elev|critic|critiq|urgent/.test(n)?3:/low|basse|faible|minor/.test(n)?1:2}}},wr={class:"wm-art wm-art--ticket"},br={class:"wm-art__head wm-tk__head"},Er={class:"wm-art__title wm-tk__title"},Cr={class:"wm-tk__sub"},Br={class:"wm-tk__ref"},Nr={key:0,class:"wm-tk__text"},Sr={key:0,class:"wm-art__body"},Ar={class:"wm-art__fieldLabel"},Vr=["data-level"],Mr={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"},Tr={key:1,class:"wm-art__footer wm-tk__footer"};function xr(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",wr,[e.createElementVNode("div",br,[e.createElementVNode("div",Er,e.toDisplayString(r.data.title),1),e.createElementVNode("div",Cr,[e.createElementVNode("div",Br,[n[0]||(n[0]=e.createElementVNode("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M20 12a2 2 0 0 1 2-2V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v4a2 2 0 0 1 0 4v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 1-2-2z"}),e.createElementVNode("path",{d:"M13 5v2M13 17v2M13 11v2"})],-1)),e.createElementVNode("span",null,e.toDisplayString(r.data.reference),1)]),e.createElementVNode("span",{class:e.normalizeClass(["wm-art__badge","wm-tk__badge",`wm-art__badge--${r.data.status.tone||"neutral"}`])},[n[1]||(n[1]=e.createElementVNode("span",{class:"wm-tk__dot","aria-hidden":"true"},null,-1)),e.createTextVNode(" "+e.toDisplayString(r.data.status.label),1)],2)]),r.data.body?(e.openBlock(),e.createElementBlock("div",Nr,e.toDisplayString(r.data.body),1)):e.createCommentVNode("",!0)]),o.fields.length?(e.openBlock(),e.createElementBlock("div",Sr,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.fields,(i,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-art__field"},[e.createElementVNode("div",Ar,e.toDisplayString(i.label),1),e.createElementVNode("div",{class:e.normalizeClass(["wm-art__fieldValue",{"wm-art__fieldValue--multi":i.multiline}])},[o.isPriority(i.label)?(e.openBlock(),e.createElementBlock("svg",{key:0,class:"wm-tk__prio","data-level":o.priorityLevel(i.value),width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true"},[...n[2]||(n[2]=[e.createElementVNode("rect",{x:"1",y:"8",width:"2",height:"3",rx:"0.5"},null,-1),e.createElementVNode("rect",{x:"5",y:"5",width:"2",height:"6",rx:"0.5"},null,-1),e.createElementVNode("rect",{x:"9",y:"2",width:"2",height:"9",rx:"0.5"},null,-1)])],8,Vr)):o.isDate(i.label)?(e.openBlock(),e.createElementBlock("svg",Mr,[...n[3]||(n[3]=[e.createElementVNode("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"},null,-1),e.createElementVNode("path",{d:"M16 2v4M8 2v4M3 10h18"},null,-1)])])):e.createCommentVNode("",!0),e.createElementVNode("span",null,e.toDisplayString(i.value),1)],2)]))),128))])):e.createCommentVNode("",!0),r.data.created_at?(e.openBlock(),e.createElementBlock("div",Tr,[n[4]||(n[4]=e.createElementVNode("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),e.createElementVNode("path",{d:"M16 2v4M8 2v4M3 10h18"})],-1)),e.createElementVNode("span",null,e.toDisplayString(o.formattedDate),1)])):e.createCommentVNode("",!0)])}const De=N(kr,[["render",xr],["__scopeId","data-v-5f30c914"]]),Lr={form_response:Le,info_card:Oe,ticket:De},Or={name:"WmArtifactRenderer",props:{artifact:{type:Object,required:!0}},computed:{component(){var n;const t=(n=this.artifact)==null?void 0:n.kind;return t&&Lr[t]||null}}};function Dr(t,n,r,s,a,o){return o.component?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.component),{key:0,data:r.artifact.data},null,8,["data"])):e.createCommentVNode("",!0)}const Ie=N(Or,[["render",Dr]]),Ir={name:"WmAttachmentPreview",inject:{signAttachmentFn:{default:null},t:{default:()=>V()}},props:{attachment:{type:Object,required:!0}},data(){return{url:null,loading:!1}},computed:{kind(){var r,s;const t=(r=this.attachment)==null?void 0:r.type;if(t)return t;const n=(((s=this.attachment)==null?void 0:s.mime_type)||"").toLowerCase();return n.startsWith("image/")?"image":n.startsWith("audio/")?"audio":n.startsWith("video/")?"video":"file"},displayName(){var t,n,r;return((n=(t=this.attachment)==null?void 0:t.metadata)==null?void 0:n.name)||((r=this.attachment)==null?void 0:r.name)||this.guessNameFromPath()||this.t("attachment.fallbackName")},safeHref(){const t=String(this.url||"").trim();return/^(https?:\/\/|blob:|data:image\/)/i.test(t)?t:"#"},sizeLabel(){var n;const t=(n=this.attachment)==null?void 0:n.size_bytes;return t?t<1024?this.t("attachment.bytes",{size:t}):t<1024*1024?this.t("attachment.kilobytes",{size:(t/1024).toFixed(0)}):this.t("attachment.megabytes",{size:(t/(1024*1024)).toFixed(1)}):""}},watch:{"attachment.path":{handler(){this.refresh()},immediate:!0}},methods:{guessNameFromPath(){var r;return((((r=this.attachment)==null?void 0:r.path)||"").split("/").pop()||"").replace(/^[0-9a-f-]{8,}-/,"")},async refresh(){var t;if(!(!((t=this.attachment)!=null&&t.path)||!this.signAttachmentFn)){this.loading=!0;try{this.url=await this.signAttachmentFn(this.attachment.path)}finally{this.loading=!1}}},onFileClick(t){this.safeHref==="#"&&t.preventDefault()}}},Rr=["href"],Fr=["src","alt"],Ur=["src"],Pr=["src"],jr=["href","download"],zr={class:"wm-att__main"},qr={class:"wm-att__name"},Hr={key:0,class:"wm-att__meta"},$r={key:0,class:"wm-att__spin","aria-hidden":"true"};function Kr(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-att",["wm-att--"+(o.kind||"file")]])},[o.kind==="image"&&a.url?(e.openBlock(),e.createElementBlock("a",{key:0,href:o.safeHref,target:"_blank",rel:"noopener",class:"wm-att__imgWrap"},[e.createElementVNode("img",{src:a.url,alt:o.displayName,loading:"lazy"},null,8,Fr)],8,Rr)):o.kind==="audio"&&a.url?(e.openBlock(),e.createElementBlock("audio",{key:1,src:a.url,controls:"",preload:"metadata"},null,8,Ur)):o.kind==="video"&&a.url?(e.openBlock(),e.createElementBlock("video",{key:2,src:a.url,controls:"",preload:"metadata"},null,8,Pr)):(e.openBlock(),e.createElementBlock("a",{key:3,class:"wm-att__file",href:o.safeHref,download:o.displayName,target:"_blank",rel:"noopener",onClick:n[0]||(n[0]=(...i)=>o.onFileClick&&o.onFileClick(...i))},[n[1]||(n[1]=e.createElementVNode("span",{class:"wm-att__icon"},[e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.7","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"}),e.createElementVNode("path",{d:"M14 2v6h6"})])],-1)),e.createElementVNode("span",zr,[e.createElementVNode("span",qr,e.toDisplayString(o.displayName),1),o.sizeLabel?(e.openBlock(),e.createElementBlock("span",Hr,e.toDisplayString(o.sizeLabel),1)):e.createCommentVNode("",!0)]),a.loading?(e.openBlock(),e.createElementBlock("span",$r)):e.createCommentVNode("",!0)],8,jr))],2)}const Re=N(Ir,[["render",Kr],["__scopeId","data-v-0c877a62"]]),Wr={name:"WmBubble",props:{role:{type:String,default:"ai"},text:{type:String,default:""}},computed:{rendered(){return Me(this.text)}}},Gr=["innerHTML"];function Yr(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-bubble","wm-bubble--"+r.role])},[e.renderSlot(t.$slots,"default",{},()=>[e.createElementVNode("span",{innerHTML:o.rendered},null,8,Gr)],!0)],2)}const Fe=N(Wr,[["render",Yr],["__scopeId","data-v-7ab13147"]]),Jr={name:"WmTyping"},Qr={class:"wm-typing"};function Xr(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",Qr,[...n[0]||(n[0]=[e.createElementVNode("span",{style:{"animation-delay":"0s"}},null,-1),e.createElementVNode("span",{style:{"animation-delay":"0.2s"}},null,-1),e.createElementVNode("span",{style:{"animation-delay":"0.4s"}},null,-1)])])}const Ue=N(Jr,[["render",Xr],["__scopeId","data-v-df2447fd"]]);function U(t){return t?t.client_msg_id||t.id:""}const Zr={transferred_to_human:"system.transferredToHuman",assigned:"system.assigned",unassigned:"system.unassigned",resolved:"system.resolved",reopened:"system.reopened",idle:"system.idle"},eo=80,to=200,no={name:"WmMessageList",components:{AIAvatar:G,HumanAvatar:de,Bubble:Fe,Typing:Ue,ActionResult:xe,AttachmentPreview:Re,ArtifactRenderer:Ie},inject:{t:{default:()=>V()},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({})}},computed:{historyExhausted(){return!this.hasMore&&!this.loadingMore&&this.messages.length>=20},groups(){var r,s,a,o;const t=[];for(const i of this.messages){const l=this.roleOf(i);if(l==="system"){if(((r=i==null?void 0:i.payload)==null?void 0:r.event)==="action_admin_pending"){const v=t[t.length-1];v&&v.role==="ai"?v.messages.push(i):t.push({key:`g-${U(i)}`,role:"ai",agentName:"",agentAvatarUrl:null,messages:[i],items:[]});continue}t.push({key:`sys-${U(i)}`,role:l,messages:[i],items:[],systemLabel:this.systemLabel(i)});continue}const f=t[t.length-1];f&&f.role===l&&(l==="ai"||f.agentName===(((s=i==null?void 0:i.author)==null?void 0:s.name)||""))?f.messages.push(i):t.push({key:`g-${U(i)}`,role:l,agentName:((a=i==null?void 0:i.author)==null?void 0:a.name)||"",agentAvatarUrl:((o=i==null?void 0:i.author)==null?void 0:o.avatar_url)||null,messages:[i],items:[]})}for(const i of t){if(i.role==="system")continue;const l=[];for(const f of i.messages)for(const _ of this.itemsOf(f))l.push(_);i.items=l}const n=[];for(const i of t){if(i.role!=="system"&&!i.items.length)continue;const l=n[n.length-1];if(l&&l.role!=="system"&&l.role===i.role&&(i.role==="ai"||l.agentName===i.agentName)){l.messages.push(...i.messages),l.items.push(...i.items);continue}n.push(i)}for(const i of n)i.role!=="system"&&(i.key=this.stableGroupKey(i.messages));return n},unreadGroupKey(){if(this.unreadAnchorId==null)return null;const t=this.unreadAnchorId,n=this.unreadBoundaryTs;for(const r of this.groups){if(r.role==="user"||r.role==="system"||!r.items.length)continue;const s=r.messages[0];if(!s)continue;const a=F(s.id);if(a!=null&&!(a<=t)&&!(n&&s.created_at&&s.created_at>n))return r.key}return null}},watch:{messages:{handler:"snapshotAndRestore",deep:!0},conversationId(t,n){t!==n&&(this._groupIdByMsgKey=null,this.silentFades=!1)},loadingMore(t){t||(this._pendingLoadMore=!1),t&&(this.silentFades=!0),this.snapshotAndRestore()},streamingActive:"snapshotAndRestore"},mounted(){this._lastSeenConvId=this.conversationId,this.scrollToBottom(),this._measureFrame=null,this._ro=new ResizeObserver(()=>this.scheduleMeasure()),this.$refs.scrollEl&&this._ro.observe(this.$refs.scrollEl),this.$nextTick(()=>this.measureRows())},beforeUnmount(){var t;(t=this._ro)==null||t.disconnect(),this._measureFrame&&cancelAnimationFrame(this._measureFrame)},updated(){this.scheduleMeasure()},methods:{messageKey:U,stableGroupKey(t){this._groupIdByMsgKey||(this._groupIdByMsgKey=new Map,this._groupIdCounter=0);const n=this._groupIdByMsgKey;let r=null;for(const s of t){const a=U(s);if(a&&n.has(a)){r=n.get(a);break}}r==null&&(r=++this._groupIdCounter);for(const s of t){const a=U(s);a&&n.set(a,r)}return`g-${r}`},isAtBottom(t){return t.scrollHeight-t.scrollTop-t.clientHeight<=eo},onScroll(){const t=this.$refs.scrollEl;t&&(this.loadingMore||!this.hasMore||this._pendingLoadMore||t.scrollTop<=to&&(this._pendingLoadMore=!0,this.$emit("load-more")))},snapshotAndRestore(){const t=this.$refs.scrollEl;if(!t||this._scrollSnap)return;const n=this._lastSeenConvId!==this.conversationId;this._lastSeenConvId=this.conversationId;const r=this.isAtBottom(t);let s=null;if(!n&&!r){const o=this.pickAnchor(t);if(o!=null&&o.rowKey){const i=this.findRowByKey(t,o.rowKey);if(i){const l=t.getBoundingClientRect().top;s={rowKey:o.rowKey,relY:i.getBoundingClientRect().top-l}}}}const a={forceBottom:n,wasPinned:r,anchor:s};this._scrollSnap=a,this.$nextTick(()=>{if(this._scrollSnap=null,a.forceBottom||a.wasPinned){t.scrollTop=t.scrollHeight;return}if(!a.anchor)return;const o=()=>{const i=a.anchor,l=this.findRowByKey(t,i.rowKey);if(!l)return;const _=l.getBoundingClientRect().top-t.getBoundingClientRect().top-i.relY;Math.abs(_)>.5&&(t.scrollTop+=_)};o(),requestAnimationFrame(()=>{o(),requestAnimationFrame(o)})})},pickAnchor(t){const n=t.getBoundingClientRect().top,r=t.querySelectorAll(".wm-list__row[data-row-key]");let s=null;for(const a of r)if(s||(s=a),a.getBoundingClientRect().bottom>=n)return{rowKey:a.dataset.rowKey};return s?{rowKey:s.dataset.rowKey}:null},findRowByKey(t,n){if(!n)return null;const r=typeof CSS<"u"&&CSS.escape?CSS.escape(n):n.replace(/["\\]/g,"\\$&");return t.querySelector(`.wm-list__row[data-row-key="${r}"]`)},roleOf(t){var r,s;if((t==null?void 0:t.type)==="system"||((r=t==null?void 0:t.payload)==null?void 0:r.type)==="system")return"system";const n=(s=t==null?void 0:t.author)==null?void 0:s.type;return n==="user"?"user":n==="agent_human"?"human":"ai"},roleLabel(t){if(t.role==="human")return t.agentName||this.t("common.agent");const n=this.t("common.aiAssistant");return this.aiAgentName?`${this.aiAgentName} • ${n}`:n},itemsOf(t){var n;if(!t)return[];if(t.type==="system"&&((n=t==null?void 0:t.payload)==null?void 0:n.event)==="action_admin_pending")return[{message:t,partKey:"main",renderAs:"admin-pending",kind:{top:"bubble",bottom:"bubble"}}];if(t.type==="action"&&t.payload&&t.payload.state!=="pending"){const r=[{message:t,partKey:"main",renderAs:"action",kind:{top:"bubble",bottom:"bubble"}}];return this.actionArtifact(t)&&r.push({message:t,partKey:"artifact",renderAs:"artifact-of-action",kind:{top:"card",bottom:"card"}}),r}return this.artifactOf(t)?[{message:t,partKey:"main",renderAs:"artifact",kind:{top:"card",bottom:"card"}}]:t.text_md||this.attachmentsOf(t).length?[{message:t,partKey:"main",renderAs:"bubble",kind:{top:"bubble",bottom:"bubble"}}]:[]},cornersFor(t,n){var P,j,z;const r=t.items,s=(P=r[n])==null?void 0:P.kind,a=(j=r[n-1])==null?void 0:j.kind,o=(z=r[n+1])==null?void 0:z.kind,i=t.role==="user",l=14,f=4,_=a==null?void 0:a.bottom,v=o==null?void 0:o.top,B=this.widthByKey[this.rowKeyOf(t,n)],S=this.widthByKey[this.rowKeyOf(t,n-1)],E=this.widthByKey[this.rowKeyOf(t,n+1)],L=.5,C=(I,q,R)=>I!=null&&B!=null?I+L>=B:q===R||q==="card"&&R==="bubble";let x=l,A=l,O=l,D=l;return i?(_&&(A=f),(v||!o)&&(O=f),_&&C(S,_,s==null?void 0:s.top)&&(x=f),v&&C(E,v,s==null?void 0:s.bottom)&&(D=f)):(_&&(x=f),(v||!o)&&(D=f),_&&C(S,_,s==null?void 0:s.top)&&(A=f),v&&C(E,v,s==null?void 0:s.bottom)&&(O=f)),{tl:x,tr:A,br:O,bl:D}},cornersStyle(t,n){if(t.items.length<2)return null;const r=this.cornersFor(t,n);return{"--wm-r-tl":`${r.tl}px`,"--wm-r-tr":`${r.tr}px`,"--wm-r-br":`${r.br}px`,"--wm-r-bl":`${r.bl}px`}},rowKeyOf(t,n){var s;const r=(s=t==null?void 0:t.items)==null?void 0:s[n];return r?`${U(r.message)}-${r.partKey}`:""},scheduleMeasure(){this._measureFrame||(this._measureFrame=requestAnimationFrame(()=>{this._measureFrame=null,this.measureRows()}))},measureRows(){const t=this.$refs.scrollEl;if(!t)return;const n={};for(const o of t.querySelectorAll(".wm-list__row[data-row-key]")){const i=o.dataset.rowKey;if(!i)continue;const l=o.querySelector(".wm-bubble, .wm-result, .wm-art, .wm-list__body");if(!l)continue;const f=l.getBoundingClientRect().width;f>0&&(n[i]=f)}const r=this.widthByKey,s=Object.keys(r),a=Object.keys(n);if(s.length===a.length){let o=!0;for(const i of a)if(Math.abs((r[i]??0)-n[i])>.5){o=!1;break}if(o)return}this.widthByKey=Object.freeze(n)},lastTimeOf(t){const n=t.items[t.items.length-1],r=(n==null?void 0:n.message)||t.messages[t.messages.length-1];if(!(r!=null&&r.created_at))return"";try{return ce(new Date(r.created_at),W(this.wmLocale()))}catch{return""}},hasTrailingOverlay(t){if(!t.messages.length)return!1;const n=t.messages[t.messages.length-1],r=t.items[t.items.length-1];return!!n&&(r==null?void 0:r.message)!==n},attachmentsOf(t){var r;const n=(r=t==null?void 0:t.payload)==null?void 0:r.attachments;return Array.isArray(n)?n:[]},artifactOf(t){var r;const n=(r=t==null?void 0:t.metadata)==null?void 0:r.artifact;return!n||typeof n!="object"||typeof n.kind!="string"?null:n},actionLabel(t){var n;return((n=t==null?void 0:t.payload)==null?void 0:n.name)||(t==null?void 0:t.text_md)||this.t("common.action")},actionDetail(t){var r,s,a,o,i,l;const n=t==null?void 0:t.payload;return n?n.state==="success"?((r=n.success)==null?void 0:r.summary)||((a=(s=n.success)==null?void 0:s.metadata)==null?void 0:a.description)||"":n.state==="rejected"?((o=n.rejected)==null?void 0:o.reason)||this.t("action.rejectedByUser"):n.state==="failure"&&(((i=n.failure)==null?void 0:i.summary)||((l=n.failure)==null?void 0:l.error))||"":""},actionArtifact(t){var r,s;const n=(s=(r=t==null?void 0:t.payload)==null?void 0:r.success)==null?void 0:s.artifact;return!n||typeof n!="object"||typeof n.kind!="string"?null:n},systemLabel(t){var a,o,i;const n=(a=t==null?void 0:t.payload)==null?void 0:a.event,r=Zr[n],s=((o=t==null?void 0:t.metadata)==null?void 0:o.agent_name)||((i=t==null?void 0:t.author)==null?void 0:i.name)||this.t("messageList.anAgent");return r?this.t(r,{name:s}):(t==null?void 0:t.text_md)||this.t("messageList.conversationUpdate")},scrollToBottom(){const t=this.$refs.scrollEl;t&&(t.scrollTop=t.scrollHeight)}}},ro={key:0,class:"wm-list__loadMore",role:"status","aria-live":"polite"},oo={class:"wm-list__loadMore-lbl"},ao={key:1,class:"wm-list__historyEnd"},so={key:2,class:"wm-list__sep"},io={class:"wm-list__sep-label"},lo={key:0,class:"wm-list__sep wm-list__sep--unread"},co={class:"wm-list__sep-label wm-list__sep-label--unread"},uo={key:0,class:"wm-list__sysep"},mo={class:"wm-list__sysep-label"},ho=["data-row-key"],fo={key:0,class:"wm-list__avatarSlot"},po={key:5,class:"wm-list__body"},go={key:0},_o={key:1,"aria-hidden":"true"},yo={key:2},vo={key:3,class:"wm-list__row wm-list__row--ai fade-up"},ko={class:"wm-list__avatarSlot"};function wo(t,n,r,s,a,o){const i=e.resolveComponent("AIAvatar"),l=e.resolveComponent("HumanAvatar"),f=e.resolveComponent("ActionResult"),_=e.resolveComponent("ArtifactRenderer"),v=e.resolveComponent("Bubble"),B=e.resolveComponent("AttachmentPreview"),S=e.resolveComponent("Typing");return e.openBlock(),e.createElementBlock("div",{ref:"scrollEl",class:e.normalizeClass(["wm-list",{"wm-list--silent":a.silentFades}]),onScrollPassive:n[0]||(n[0]=(...E)=>o.onScroll&&o.onScroll(...E))},[r.loadingMore?(e.openBlock(),e.createElementBlock("div",ro,[n[1]||(n[1]=e.createElementVNode("span",{class:"wm-list__loadMore-spinner","aria-hidden":"true"},null,-1)),e.createElementVNode("span",oo,e.toDisplayString(o.t("messageList.loadingHistory")),1)])):o.historyExhausted?(e.openBlock(),e.createElementBlock("div",ao,e.toDisplayString(o.t("messageList.conversationStart")),1)):e.createCommentVNode("",!0),r.dateLabel?(e.openBlock(),e.createElementBlock("div",so,[n[2]||(n[2]=e.createElementVNode("div",{class:"wm-list__line"},null,-1)),e.createElementVNode("span",io,e.toDisplayString(r.dateLabel),1),n[3]||(n[3]=e.createElementVNode("div",{class:"wm-list__line"},null,-1))])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.groups,(E,L)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:E.key},[E.key===o.unreadGroupKey?(e.openBlock(),e.createElementBlock("div",lo,[n[4]||(n[4]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--unread"},null,-1)),e.createElementVNode("span",co,e.toDisplayString(o.t("messageList.unread")),1),n[5]||(n[5]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--unread"},null,-1))])):e.createCommentVNode("",!0),E.role==="system"||E.items.length?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["wm-list__group","wm-list__group--"+E.role])},[E.role==="system"?(e.openBlock(),e.createElementBlock("div",uo,[n[6]||(n[6]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--strong"},null,-1)),e.createElementVNode("span",mo,e.toDisplayString(E.systemLabel),1),n[7]||(n[7]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--strong"},null,-1))])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(E.items,(C,x)=>(e.openBlock(),e.createElementBlock("div",{key:`${o.messageKey(C.message)}-${C.partKey}`,"data-row-key":`${o.messageKey(C.message)}-${C.partKey}`,class:e.normalizeClass(["wm-list__row fade-up",["wm-list__row--"+E.role,{"is-pending":C.message._pending,"is-failed":C.message._failed}]]),style:e.normalizeStyle(o.cornersStyle(E,x))},[E.role!=="user"?(e.openBlock(),e.createElementBlock("div",fo,[x===E.items.length-1?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[E.role==="ai"?(e.openBlock(),e.createBlock(i,{key:0,size:26,tail:!0,name:r.aiAgentName,"image-url":r.aiAgentAvatarUrl},null,8,["name","image-url"])):(e.openBlock(),e.createBlock(l,{key:1,name:E.agentName,"avatar-url":E.agentAvatarUrl,size:26,tail:!0},null,8,["name","avatar-url"]))],64)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),C.renderAs==="action"?(e.openBlock(),e.createBlock(f,{key:1,state:C.message.payload.state,label:o.actionLabel(C.message),detail:o.actionDetail(C.message)},null,8,["state","label","detail"])):C.renderAs==="admin-pending"?(e.openBlock(),e.createBlock(f,{key:2,state:"awaiting",label:o.t("messageList.approvalRequestSent"),detail:C.message.text_md||""},null,8,["label","detail"])):C.renderAs==="artifact-of-action"?(e.openBlock(),e.createBlock(_,{key:3,artifact:o.actionArtifact(C.message)},null,8,["artifact"])):C.renderAs==="artifact"?(e.openBlock(),e.createBlock(_,{key:4,artifact:o.artifactOf(C.message)},null,8,["artifact"])):(e.openBlock(),e.createElementBlock("div",po,[C.message.text_md?(e.openBlock(),e.createBlock(v,{key:0,role:E.role,text:C.message.text_md},null,8,["role","text"])):e.createCommentVNode("",!0),o.attachmentsOf(C.message).length?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["wm-list__atts",{"wm-list__atts--align-end":E.role==="user"}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.attachmentsOf(C.message),(A,O)=>(e.openBlock(),e.createBlock(B,{key:`${o.messageKey(C.message)}-att-${O}`,attachment:A},null,8,["attachment"]))),128))],2)):e.createCommentVNode("",!0)]))],14,ho))),128)),(E.role!=="user"||o.lastTimeOf(E))&&!o.hasTrailingOverlay(E)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["wm-list__meta",{"wm-list__meta--right":E.role==="user"}])},[E.role!=="user"?(e.openBlock(),e.createElementBlock("span",go,e.toDisplayString(o.roleLabel(E)),1)):e.createCommentVNode("",!0),E.role!=="user"&&o.lastTimeOf(E)?(e.openBlock(),e.createElementBlock("span",_o,"·")):e.createCommentVNode("",!0),o.lastTimeOf(E)?(e.openBlock(),e.createElementBlock("span",yo,e.toDisplayString(o.lastTimeOf(E)),1)):e.createCommentVNode("",!0)],2)):e.createCommentVNode("",!0)],64))],2)):e.createCommentVNode("",!0)],64))),128)),r.streamingActive?(e.openBlock(),e.createElementBlock("div",vo,[e.createElementVNode("div",ko,[e.createVNode(i,{size:26,tail:!0,name:r.aiAgentName,"image-url":r.aiAgentAvatarUrl},null,8,["name","image-url"])]),e.createVNode(S)])):e.createCommentVNode("",!0)],34)}const Pe=N(no,[["render",wo],["__scopeId","data-v-d769b193"]]),Q=typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function",ne=typeof window<"u"&&typeof window.MediaRecorder<"u";function je(){return ne&&["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm","video/mp4"].find(n=>{var r,s;return(s=(r=window.MediaRecorder).isTypeSupported)==null?void 0:s.call(r,n)})||""}function ze({audio:t}){return{video:!0,audio:!!t,selfBrowserSurface:"include",surfaceSwitching:"include",systemAudio:t?"include":"exclude"}}function bo(t){return t?t.startsWith("image/")?"image":t.startsWith("video/")?"video":"file":"file"}async function qe(){if(!Q)return null;let t;try{t=await navigator.mediaDevices.getDisplayMedia(ze({audio:!1}))}catch(n){return(n==null?void 0:n.name)!=="NotAllowedError"&&console.error("[media] screenshot picker",n),null}try{return await Eo(t)}catch(n){return console.error("[media] screenshot capture",n),null}finally{t.getTracks().forEach(n=>{n.stop()})}}async function Eo(t){const n=document.createElement("video");n.muted=!0,n.playsInline=!0,n.srcObject=t,await n.play(),await new Promise(l=>requestAnimationFrame(l));const r=n.videoWidth||1280,s=n.videoHeight||720,a=document.createElement("canvas");a.width=r,a.height=s,a.getContext("2d").drawImage(n,0,0,r,s);const o=await new Promise((l,f)=>{a.toBlob(_=>_?l(_):f(new Error("toBlob failed")),"image/png")}),i=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19);return new File([o],`capture-${i}.png`,{type:"image/png"})}async function He(t={}){var _;if(!Q||!ne)return null;let n;try{n=await navigator.mediaDevices.getDisplayMedia(ze({audio:!0}))}catch(v){return(v==null?void 0:v.name)!=="NotAllowedError"&&console.error("[media] record picker",v),null}const r=je();let s;try{s=r?new window.MediaRecorder(n,{mimeType:r}):new window.MediaRecorder(n)}catch(v){return console.error("[media] recorder init",v),n.getTracks().forEach(B=>{B.stop()}),null}const a=[];let o=null,i=!1;s.addEventListener("dataavailable",v=>{v.data&&v.data.size>0&&a.push(v.data)}),s.addEventListener("stop",()=>{var v,B;if(o&&clearInterval(o),n.getTracks().forEach(S=>{S.stop()}),a.length){const S=s.mimeType||r||"video/webm",E=new Blob(a,{type:S}),L=/mp4/.test(S)?"mp4":"webm",C=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),x=new File([E],`ecran-${C}.${L}`,{type:S});(v=t.onfinalize)==null||v.call(t,x)}else(B=t.oncancel)==null||B.call(t)}),n.getVideoTracks().forEach(v=>{v.addEventListener("ended",()=>l(),{once:!0})});function l(){if(!i&&(i=!0,s.state!=="inactive"))try{s.stop()}catch(v){console.error("[media] recorder stop",v)}}try{s.start(1e3)}catch(v){return console.error("[media] recorder start",v),n.getTracks().forEach(B=>{B.stop()}),null}(_=t.onstart)==null||_.call(t);const f=Date.now();return o=setInterval(()=>{var v;(v=t.ontick)==null||v.call(t,Date.now()-f)},500),{stop:l,get state(){return s.state}}}const Co=[{action:"file",labelKey:"composer.attachFile",path:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"},{action:"screenshot",labelKey:"composer.screenshot",path:"M23 19a2 2 0 01-2 2H3a2 2 0 01-2-2V8a2 2 0 012-2h4l2-3h6l2 3h4a2 2 0 012 2z M12 17a4 4 0 100-8 4 4 0 000 8z"},{action:"record",labelKey:"composer.recordScreen",path:"M23 7l-7 5 7 5V7z M1 5a2 2 0 012-2h12a2 2 0 012 2v14a2 2 0 01-2 2H3a2 2 0 01-2-2V5z"}],Bo={name:"WmComposer",inject:{t:{default:()=>V()}},props:{modelValue:{type:String,default:""},placeholder:{type:String,default:"Écrivez votre message…"},disabled:{type:Boolean,default:!1},attachLabel:{type:String,default:"Joindre"}},emits:["update:modelValue","send","attach"],data(){return{local:this.modelValue,attachOpen:!1,recording:!1,recordingElapsed:0,recorder:null}},computed:{canSend(){return!this.disabled&&!!this.local.trim()},attachItems(){return Co.map(t=>({...t,label:this.t(t.labelKey),disabled:t.action==="screenshot"&&!Q||t.action==="record"&&(!Q||!ne)}))},recordingElapsedLabel(){const t=Math.floor(this.recordingElapsed/1e3),n=Math.floor(t/60),r=t%60;return`${n}:${r.toString().padStart(2,"0")}`}},watch:{modelValue(t){t!==this.local&&(this.local=t,this.$nextTick(()=>this.autosize()))},local(t){this.$emit("update:modelValue",t)}},mounted(){this.autosize()},beforeUnmount(){if(this.recorder)try{this.recorder.stop()}catch{}},methods:{focus(){const t=this.$refs.inputEl;if(!(!t||this.disabled))try{t.focus({preventScroll:!0})}catch{t.focus()}},onSubmit(){if(!this.canSend)return;const t=this.local.trim();this.local="",this.$emit("send",t),this.$nextTick(()=>this.autosize())},onKeydown(t){t.key==="Enter"&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey&&!t.isComposing&&(t.preventDefault(),this.onSubmit())},autosize(){const t=this.$refs.inputEl;t&&(t.style.height="auto",t.style.height=`${t.scrollHeight}px`)},onFile(t){const n=Array.from(t.target.files||[]);for(const r of n)this.$emit("attach",r);t.target.value=""},onAttachAction(t){this.attachOpen=!1,t==="file"?this.pickFile():t==="screenshot"?this.captureScreenshot():t==="record"&&this.startRecording()},pickFile(){var t;(t=this.$refs.fileEl)==null||t.click()},async captureScreenshot(){if(this.disabled)return;const t=await qe();t&&this.$emit("attach",t)},async startRecording(){if(this.recording||this.disabled)return;this.recordingElapsed=0;const t=await He({onstart:()=>{this.recording=!0},ontick:n=>{this.recordingElapsed=n},onfinalize:n=>{this.$emit("attach",n),this.recording=!1,this.recordingElapsed=0,this.recorder=null},oncancel:()=>{this.recording=!1,this.recordingElapsed=0,this.recorder=null}});t&&(this.recorder=t)},stopRecording(){if(this.recorder)try{this.recorder.stop()}catch(t){console.error("[composer] stop recording",t)}}}},No={class:"wm-compose-wrap"},So={key:0,class:"wm-rec"},Ao={class:"wm-rec__lbl"},Vo={key:1,class:"wm-compose__menu",role:"menu"},Mo=["disabled","onClick"],To={class:"wm-compose__menuIcon"},xo={viewBox:"0 0 24 24",width:"14",height:"14","aria-hidden":"true"},Lo=["d"],Oo=["placeholder","disabled"],Do={class:"wm-compose__actions"},Io=["title","aria-label","disabled"],Ro=["disabled","aria-label"];function Fo(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",No,[a.recording?(e.openBlock(),e.createElementBlock("div",So,[n[8]||(n[8]=e.createElementVNode("span",{class:"wm-rec__dot","aria-hidden":"true"},null,-1)),e.createElementVNode("span",Ao,e.toDisplayString(o.t("composer.recording",{time:o.recordingElapsedLabel})),1),e.createElementVNode("button",{type:"button",class:"wm-rec__stop",onClick:n[0]||(n[0]=(...i)=>o.stopRecording&&o.stopRecording(...i))},e.toDisplayString(o.t("composer.stop")),1)])):e.createCommentVNode("",!0),e.createElementVNode("form",{class:e.normalizeClass(["wm-compose",{"has-attach":a.attachOpen}]),onSubmit:n[7]||(n[7]=e.withModifiers((...i)=>o.onSubmit&&o.onSubmit(...i),["prevent"]))},[e.createElementVNode("input",{ref:"fileEl",type:"file",hidden:"",multiple:"",onChange:n[1]||(n[1]=(...i)=>o.onFile&&o.onFile(...i))},null,544),a.attachOpen?(e.openBlock(),e.createElementBlock("div",{key:0,class:"wm-compose__overlay",onClick:n[2]||(n[2]=i=>a.attachOpen=!1)})):e.createCommentVNode("",!0),a.attachOpen?(e.openBlock(),e.createElementBlock("div",Vo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.attachItems,i=>(e.openBlock(),e.createElementBlock("button",{key:i.action,type:"button",class:"wm-compose__menuItem",disabled:i.disabled,onClick:l=>o.onAttachAction(i.action)},[e.createElementVNode("span",To,[(e.openBlock(),e.createElementBlock("svg",xo,[e.createElementVNode("path",{d:i.path,stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round",fill:"none"},null,8,Lo)]))]),e.createElementVNode("span",null,e.toDisplayString(i.label),1)],8,Mo))),128))])):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("textarea",{ref:"inputEl","onUpdate:modelValue":n[3]||(n[3]=i=>a.local=i),class:"wm-compose__input",rows:"3",placeholder:r.placeholder,disabled:r.disabled,onKeydown:n[4]||(n[4]=(...i)=>o.onKeydown&&o.onKeydown(...i)),onInput:n[5]||(n[5]=(...i)=>o.autosize&&o.autosize(...i))},null,40,Oo),[[e.vModelText,a.local]]),e.createElementVNode("div",Do,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["wm-compose__icon",{"is-open":a.attachOpen}]),title:r.attachLabel,"aria-label":r.attachLabel,disabled:a.recording,onClick:n[6]||(n[6]=i=>a.attachOpen=!a.attachOpen)},[...n[9]||(n[9]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"})],-1)])],10,Io),e.createElementVNode("button",{type:"submit",class:e.normalizeClass(["wm-compose__send",{"is-empty":!o.canSend}]),disabled:!o.canSend,"aria-label":o.t("composer.send")},[...n[10]||(n[10]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})],-1)])],10,Ro)])],34)])}const $e=N(Bo,[["render",Fo],["__scopeId","data-v-aa81dbb8"]]),Uo={name:"WmSuggestionChips",props:{items:{type:Array,default:()=>[]},baseDelay:{type:Number,default:360},stepDelay:{type:Number,default:90}},emits:["select"],computed:{batchKey(){return this.items.map(t=>(t==null?void 0:t.label)||(t==null?void 0:t.text)||"").join("§")}}},Po=["onClick"];function jo(t,n,r,s,a,o){return r.items.length?(e.openBlock(),e.createElementBlock("div",{key:o.batchKey,class:"wm-chips"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.items,(i,l)=>(e.openBlock(),e.createElementBlock("button",{key:l,type:"button",class:"wm-chip",style:e.normalizeStyle({animationDelay:r.baseDelay+l*r.stepDelay+"ms"}),onClick:f=>t.$emit("select",i)},e.toDisplayString(i.label),13,Po))),128))])):e.createCommentVNode("",!0)}const Ke=N(Uo,[["render",jo],["__scopeId","data-v-47ad8085"]]),zo={name:"WmApprovalCard",components:{AIAvatar:G},inject:{t:{default:()=>V()}},props:{action:{type:String,required:!0},detail:{type:String,default:""},callbacks:{type:Array,default:()=>[]},agentName:{type:String,default:""},agentAvatarUrl:{type:String,default:null}},emits:["callback"],computed:{approveCallback(){return this.callbacks.find(t=>t.id==="approve"||t.style==="primary")||this.callbacks[0]},rejectCallback(){return this.callbacks.find(t=>t.id==="reject"||t.style==="danger"||t.style==="neutral")||(this.callbacks.length>1?this.callbacks[1]:null)},approveId(){var t;return(t=this.approveCallback)==null?void 0:t.id},rejectId(){var t;return(t=this.rejectCallback)==null?void 0:t.id},approveLabel(){var t;return((t=this.approveCallback)==null?void 0:t.label)||this.t("approval.approve")},rejectLabel(){var t;return((t=this.rejectCallback)==null?void 0:t.label)||this.t("approval.reject")}}},qo={class:"wm-approval"},Ho={class:"wm-approval__head"},$o={class:"wm-approval__icon"},Ko={class:"wm-approval__main"},Wo={class:"wm-approval__title"},Go={key:0,class:"wm-approval__detail"},Yo={class:"wm-approval__actions"};function Jo(t,n,r,s,a,o){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",qo,[e.createElementVNode("div",Ho,[e.createElementVNode("div",$o,[e.createVNode(i,{size:24,name:r.agentName,"image-url":r.agentAvatarUrl},null,8,["name","image-url"])]),e.createElementVNode("div",Ko,[e.createElementVNode("div",Wo,e.toDisplayString(r.action),1),r.detail?(e.openBlock(),e.createElementBlock("div",Go,e.toDisplayString(r.detail),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",Yo,[o.rejectId?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-approval__btn wm-approval__btn--neutral",onClick:n[0]||(n[0]=l=>t.$emit("callback",o.rejectId))},e.toDisplayString(o.rejectLabel),1)):e.createCommentVNode("",!0),o.approveId?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"wm-approval__btn wm-approval__btn--primary",onClick:n[1]||(n[1]=l=>t.$emit("callback",o.approveId))},e.toDisplayString(o.approveLabel),1)):e.createCommentVNode("",!0)])])}const We=N(zo,[["render",Jo],["__scopeId","data-v-a2bed37e"]]);let _e=0;const Qo=new Set(["text","textarea","number","boolean","select","multiselect","date"]),Xo={name:"WmFormCard",components:{AIAvatar:G},inject:{t:{default:()=>V()}},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 _e+=1,{_uid:_e,values:{},busy:!1,error:""}},computed:{normalizedFields(){var n;return(Array.isArray((n=this.form)==null?void 0:n.fields)?this.form.fields:[]).filter(r=>!(!(r!=null&&r.key)||!(r!=null&&r.label)||!Qo.has(r==null?void 0:r.type)||(r.type==="select"||r.type==="multiselect")&&(!Array.isArray(r.options)||r.options.length===0)))}},created(){this.resetValues()},methods:{resetValues(){const t=this.initialValues&&typeof this.initialValues=="object"?this.initialValues:{},n={};for(const r of this.normalizedFields){if(t[r.key]!==void 0){n[r.key]=t[r.key];continue}r.type==="boolean"?n[r.key]=!1:r.type==="multiselect"?n[r.key]=[]:n[r.key]=""}this.values=n,this.error=""},toggleMulti(t,n,r){const s=Array.isArray(this.values[t])?this.values[t].slice():[],a=s.indexOf(n);r&&a===-1?s.push(n):!r&&a!==-1&&s.splice(a,1),this.values={...this.values,[t]:s}},validate(){for(const t of this.normalizedFields){if(!t.required)continue;const n=this.values[t.key];if(t.type!=="boolean"){if(t.type==="multiselect"){if(!Array.isArray(n)||n.length===0)return this.t("form.fieldRequired",{label:t.label});continue}if(n==null||n==="")return this.t("form.fieldRequired",{label:t.label})}}return""},async onSubmit(){if(this.readOnly||this.busy)return;const t=this.validate();if(t){this.error=t;return}this.error="",this.busy=!0;try{await this.$emit("submit",{values:this.values})}finally{this.busy=!1}}}},Zo={class:"wm-form"},ea={class:"wm-form__head"},ta={class:"wm-form__icon"},na={class:"wm-form__main"},ra={class:"wm-form__title"},oa={key:0,class:"wm-form__detail"},aa=["for"],sa={key:0,class:"wm-form__req","aria-hidden":"true"},ia=["id","onUpdate:modelValue","placeholder","required","disabled"],la=["id","onUpdate:modelValue","placeholder","required","disabled"],ca=["id","onUpdate:modelValue","placeholder","required","disabled"],da=["id","onUpdate:modelValue","required","disabled"],ua={key:4,class:"wm-form__bool"},ma=["id","onUpdate:modelValue","disabled"],ha=["id","onUpdate:modelValue","required","disabled"],fa={value:"",disabled:""},pa=["value"],ga={key:6,class:"wm-form__multi"},_a=["value","checked","disabled","onChange"],ya={key:0,class:"wm-form__err"},va=["disabled"],ka={key:0,class:"wm-form__spinner","aria-hidden":"true"},wa={key:2,class:"wm-form__doneLbl"};function ba(t,n,r,s,a,o){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",Zo,[e.createElementVNode("div",ea,[e.createElementVNode("div",ta,[e.createVNode(i,{size:24,name:r.agentName,"image-url":r.agentAvatarUrl},null,8,["name","image-url"])]),e.createElementVNode("div",na,[e.createElementVNode("div",ra,e.toDisplayString(r.form.title||o.t("form.title")),1),r.form.description?(e.openBlock(),e.createElementBlock("div",oa,e.toDisplayString(r.form.description),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("form",{class:"wm-form__body",onSubmit:n[0]||(n[0]=e.withModifiers((...l)=>o.onSubmit&&o.onSubmit(...l),["prevent"]))},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.normalizedFields,l=>(e.openBlock(),e.createElementBlock("div",{key:l.key,class:"wm-form__field"},[e.createElementVNode("label",{for:`wm-f-${a._uid}-${l.key}`,class:"wm-form__label"},[e.createTextVNode(e.toDisplayString(l.label),1),l.required?(e.openBlock(),e.createElementBlock("span",sa,"*")):e.createCommentVNode("",!0)],8,aa),l.type==="text"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":f=>a.values[l.key]=f,type:"text",class:"wm-form__input",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||a.busy},null,8,ia)),[[e.vModelText,a.values[l.key]]]):l.type==="textarea"?e.withDirectives((e.openBlock(),e.createElementBlock("textarea",{key:1,id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":f=>a.values[l.key]=f,class:"wm-form__textarea",rows:"3",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||a.busy},null,8,la)),[[e.vModelText,a.values[l.key]]]):l.type==="number"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:2,id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":f=>a.values[l.key]=f,type:"number",class:"wm-form__input",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||a.busy},null,8,ca)),[[e.vModelText,a.values[l.key],void 0,{number:!0}]]):l.type==="date"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:3,id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":f=>a.values[l.key]=f,type:"date",class:"wm-form__input",required:l.required,disabled:r.readOnly||a.busy},null,8,da)),[[e.vModelText,a.values[l.key]]]):l.type==="boolean"?(e.openBlock(),e.createElementBlock("label",ua,[e.withDirectives(e.createElementVNode("input",{id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":f=>a.values[l.key]=f,type:"checkbox",disabled:r.readOnly||a.busy},null,8,ma),[[e.vModelCheckbox,a.values[l.key]]]),e.createElementVNode("span",null,e.toDisplayString(l.placeholder||o.t("common.yes")),1)])):l.type==="select"?e.withDirectives((e.openBlock(),e.createElementBlock("select",{key:5,id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":f=>a.values[l.key]=f,class:"wm-form__select",required:l.required,disabled:r.readOnly||a.busy},[e.createElementVNode("option",fa,e.toDisplayString(l.placeholder||o.t("form.choose")),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.options,f=>(e.openBlock(),e.createElementBlock("option",{key:f.value,value:f.value},e.toDisplayString(f.label),9,pa))),128))],8,ha)),[[e.vModelSelect,a.values[l.key]]]):l.type==="multiselect"?(e.openBlock(),e.createElementBlock("div",ga,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.options,f=>(e.openBlock(),e.createElementBlock("label",{key:f.value,class:"wm-form__multiItem"},[e.createElementVNode("input",{type:"checkbox",value:f.value,checked:Array.isArray(a.values[l.key])&&a.values[l.key].includes(f.value),disabled:r.readOnly||a.busy,onChange:_=>o.toggleMulti(l.key,f.value,_.target.checked)},null,40,_a),e.createElementVNode("span",null,e.toDisplayString(f.label),1)]))),128))])):e.createCommentVNode("",!0)]))),128)),a.error?(e.openBlock(),e.createElementBlock("div",ya,e.toDisplayString(a.error),1)):e.createCommentVNode("",!0),r.readOnly?(e.openBlock(),e.createElementBlock("div",wa,e.toDisplayString(o.t("form.responseSent")),1)):(e.openBlock(),e.createElementBlock("button",{key:1,type:"submit",class:"wm-form__submit",disabled:a.busy},[a.busy?(e.openBlock(),e.createElementBlock("span",ka)):e.createCommentVNode("",!0),e.createElementVNode("span",null,e.toDisplayString(a.busy?o.t("common.sending"):r.form.submit_label||o.t("common.send")),1)],8,va))],32)])}const Ge=N(Xo,[["render",ba],["__scopeId","data-v-fe65cc56"]]),Ea={name:"WmFeedback",inject:{t:{default:()=>V()}},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})}}},Ca={class:"wm-fb"},Ba={class:"wm-fb__title"},Na={class:"wm-fb__sub"},Sa={class:"wm-fb__row"},Aa=["onClick"],Va={class:"wm-fb__emoji"},Ma={class:"wm-fb__label"},Ta=["disabled"],xa={key:1,class:"wm-fb__done"},La={class:"wm-fb__doneTitle"},Oa={class:"wm-fb__doneSub"};function Da(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",Ca,[r.done?(e.openBlock(),e.createElementBlock("div",xa,[n[1]||(n[1]=e.createElementVNode("div",{class:"wm-fb__check"},[e.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#fff","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M20 6L9 17l-5-5"})])],-1)),e.createElementVNode("div",La,e.toDisplayString(o.t("feedback.doneTitle")),1),e.createElementVNode("div",Oa,e.toDisplayString(o.t("feedback.doneSubtitle")),1)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("div",Ba,e.toDisplayString(o.t("feedback.question")),1),e.createElementVNode("div",Na,e.toDisplayString(o.t("feedback.subtitle")),1),e.createElementVNode("div",Sa,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.options,i=>(e.openBlock(),e.createElementBlock("button",{key:i.v,type:"button",class:e.normalizeClass(["wm-fb__opt",{"is-selected":a.sel===i.v}]),onClick:l=>a.sel=i.v},[e.createElementVNode("span",Va,e.toDisplayString(i.e),1),e.createElementVNode("span",Ma,e.toDisplayString(i.l),1)],10,Aa))),128))]),e.createElementVNode("button",{type:"button",class:"wm-fb__send",disabled:!a.sel||r.busy,onClick:n[0]||(n[0]=(...i)=>o.onSend&&o.onSend(...i))},e.toDisplayString(r.busy?o.t("common.sending"):o.t("feedback.submit")),9,Ta)],64))])}const Ye=N(Ea,[["render",Da],["__scopeId","data-v-9b630564"]]),Ia={name:"WmMoreMenu",inject:{t:{default:()=>V()}},props:{canRename:{type:Boolean,default:!0},canExport:{type:Boolean,default:!0},soundEnabled:{type:Boolean,default:!0},browserNotifEnabled:{type:Boolean,default:!1},statusUrl:{type:String,default:""},helpUrl:{type:String,default:""}},emits:["close","action","sound-toggle","browser-notif-toggle"],data(){return{soundOn:this.soundEnabled,browserNotifOn:this.browserNotifEnabled}},watch:{soundEnabled(t){this.soundOn=!!t},browserNotifEnabled(t){this.browserNotifOn=!!t}},methods:{emit(t){this.$emit("action",t)},toggleSound(){this.soundOn=!this.soundOn,this.$emit("sound-toggle",this.soundOn)},toggleBrowserNotif(){this.browserNotifOn=!this.browserNotifOn,this.$emit("browser-notif-toggle",this.browserNotifOn)}}},Ra={class:"wm-mm"},Fa={class:"wm-mm__pop",role:"menu"},Ua={key:0,class:"wm-mm__section"},Pa={class:"wm-mm__label"},ja={class:"wm-mm__label"},za={key:1,class:"wm-mm__sep"},qa={class:"wm-mm__section"},Ha={class:"wm-mm__label"},$a={class:"wm-mm__label"},Ka={class:"wm-mm__section"},Wa={class:"wm-mm__label"},Ga={class:"wm-mm__label"};function Ya(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",Ra,[e.createElementVNode("div",{class:"wm-mm__scrim",onClick:n[0]||(n[0]=i=>t.$emit("close"))}),e.createElementVNode("div",Fa,[r.canRename||r.canExport?(e.openBlock(),e.createElementBlock("div",Ua,[r.canRename?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-mm__item",onClick:n[1]||(n[1]=i=>o.emit("rename"))},[n[7]||(n[7]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M12 20h9"}),e.createElementVNode("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})])],-1)),e.createElementVNode("span",Pa,e.toDisplayString(o.t("moreMenu.editTitle")),1)])):e.createCommentVNode("",!0),r.canExport?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"wm-mm__item",onClick:n[2]||(n[2]=i=>o.emit("export"))},[n[8]||(n[8]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M4 12v8a2 2 0 002 2h12a2 2 0 002-2v-8M16 6l-4-4-4 4M12 2v13"})])],-1)),e.createElementVNode("span",ja,e.toDisplayString(o.t("moreMenu.exportTranscript")),1),n[9]||(n[9]=e.createElementVNode("span",{class:"wm-mm__hint"},".txt",-1))])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),r.canRename||r.canExport?(e.openBlock(),e.createElementBlock("div",za)):e.createCommentVNode("",!0),e.createElementVNode("div",qa,[e.createElementVNode("button",{type:"button",class:"wm-mm__item",onClick:n[3]||(n[3]=(...i)=>o.toggleSound&&o.toggleSound(...i))},[n[11]||(n[11]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M11 5L6 9H2v6h4l5 4V5z"}),e.createElementVNode("path",{d:"M15.54 8.46a5 5 0 010 7.07M19.07 4.93a10 10 0 010 14.14"})])],-1)),e.createElementVNode("span",Ha,e.toDisplayString(o.t("moreMenu.sound")),1),e.createElementVNode("span",{class:e.normalizeClass(["wm-mm__toggle",{"wm-mm__toggle--on":a.soundOn}])},[...n[10]||(n[10]=[e.createElementVNode("span",{class:"wm-mm__knob"},null,-1)])],2)]),e.createElementVNode("button",{type:"button",class:"wm-mm__item",onClick:n[4]||(n[4]=(...i)=>o.toggleBrowserNotif&&o.toggleBrowserNotif(...i))},[n[13]||(n[13]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M15 17h5l-1.4-1.4A2 2 0 0118 14.2V11a6 6 0 10-12 0v3.2c0 .5-.2 1-.6 1.4L4 17h5m6 0a3 3 0 11-6 0"})])],-1)),e.createElementVNode("span",$a,e.toDisplayString(o.t("moreMenu.browserNotifications")),1),e.createElementVNode("span",{class:e.normalizeClass(["wm-mm__toggle",{"wm-mm__toggle--on":a.browserNotifOn}])},[...n[12]||(n[12]=[e.createElementVNode("span",{class:"wm-mm__knob"},null,-1)])],2)])]),n[16]||(n[16]=e.createElementVNode("div",{class:"wm-mm__sep"},null,-1)),e.createElementVNode("div",Ka,[r.statusUrl?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-mm__item",onClick:n[5]||(n[5]=i=>o.emit("status"))},[n[14]||(n[14]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zM10 6v4l3 2"})])],-1)),e.createElementVNode("span",Wa,e.toDisplayString(o.t("moreMenu.serviceStatus")),1)])):e.createCommentVNode("",!0),r.helpUrl?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"wm-mm__item",onClick:n[6]||(n[6]=i=>o.emit("help"))},[n[15]||(n[15]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M9 11a3 3 0 116 0c0 2-3 2-3 5M12 19h.01M12 22a10 10 0 110-20 10 10 0 010 20z"})])],-1)),e.createElementVNode("span",Ga,e.toDisplayString(o.t("moreMenu.helpCenter")),1)])):e.createCommentVNode("",!0)])])])}const Je=N(Ia,[["render",Ya],["__scopeId","data-v-76281e95"]]),Ja={name:"WmRenameDialog",inject:{t:{default:()=>V()}},props:{title:{type:String,default:""},initialValue:{type:String,default:""},placeholder:{type:String,default:""}},emits:["close","submit"],data(){return{value:this.initialValue||""}},computed:{canSubmit(){const t=(this.value||"").trim();return!!t&&t!==(this.initialValue||"").trim()}},mounted(){this.$nextTick(()=>{const t=this.$refs.input;if(t){t.focus();try{t.select()}catch{}}})},methods:{onSubmit(){this.canSubmit&&this.$emit("submit",this.value.trim())}}},Qa={class:"wm-dialog"},Xa={class:"wm-dialog__card",role:"dialog","aria-modal":"true"},Za={class:"wm-dialog__head"},es={class:"wm-dialog__title"},ts=["aria-label"],ns={class:"wm-dialog__body"},rs=["placeholder"],os={class:"wm-dialog__actions"},as=["disabled"];function ss(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",Qa,[e.createElementVNode("div",{class:"wm-dialog__scrim",onClick:n[0]||(n[0]=i=>t.$emit("close"))}),e.createElementVNode("div",Xa,[e.createElementVNode("div",Za,[e.createElementVNode("div",es,e.toDisplayString(r.title||o.t("rename.title")),1),e.createElementVNode("button",{type:"button",class:"wm-dialog__close","aria-label":o.t("common.close"),onClick:n[1]||(n[1]=i=>t.$emit("close"))},[...n[7]||(n[7]=[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,ts)]),e.createElementVNode("div",ns,[e.withDirectives(e.createElementVNode("input",{ref:"input","onUpdate:modelValue":n[2]||(n[2]=i=>a.value=i),type:"text",class:"wm-dialog__input",placeholder:r.placeholder||o.t("rename.placeholder"),maxlength:120,onKeydown:[n[3]||(n[3]=e.withKeys(e.withModifiers((...i)=>o.onSubmit&&o.onSubmit(...i),["prevent"]),["enter"])),n[4]||(n[4]=e.withKeys(e.withModifiers(i=>t.$emit("close"),["prevent"]),["esc"]))]},null,40,rs),[[e.vModelText,a.value]])]),e.createElementVNode("div",os,[e.createElementVNode("button",{type:"button",class:"wm-dialog__btn",onClick:n[5]||(n[5]=i=>t.$emit("close"))},e.toDisplayString(o.t("common.cancel")),1),e.createElementVNode("button",{type:"button",class:"wm-dialog__btn wm-dialog__btn--primary",disabled:!o.canSubmit,onClick:n[6]||(n[6]=(...i)=>o.onSubmit&&o.onSubmit(...i))},e.toDisplayString(o.t("common.save")),9,as)])])])}const is=N(Ja,[["render",ss],["__scopeId","data-v-6d5f94a8"]]),ye="ww-messenger-tokens",ls={name:"Messenger",components:{Launcher:Be,Header:Se,Onboarding:Te,MessageList:Pe,Composer:$e,SuggestionChips:Ke,ApprovalCard:We,FormCard:Ge,Feedback:Ye,MoreMenu:Je,RenameDialog:is},mixins:[dt,gt,_t,vt],provide(){return{signAttachmentFn:t=>{var n,r;return((r=(n=this.store)==null?void 0:n.signAttachment)==null?void 0:r.call(n,t))||null},t:(t,n)=>this.t(t,n),wmLocale:()=>this.locale}},props:{baseUrl:{type:String,default:be},widgetId:{type:String,default:""},token:{type:String,default:""},context:{type:Object,default:null},displayMode:{type:String,default:"floating"},devtools:{type:Boolean,default:!1},language:{type:String,default:""}},data(){return{transport:null,store:null,isOpen:!1,draft:"",busy:!1,bootError:null,pendingAttachments:[],feedbackBusy:!1,feedbackDone:!1,convOpenedAt:0,moreOpen:!1,renameDialogOpen:!1,draftConv:null,activeConvId:null,showOnboarding:!1,dismissedPeeks:{},floatHeight:0,floatRO:null}},computed:{isEditor(){return!!this.devtools},isEmbedded(){return this.displayMode==="embedded"},customerLanguage(){var r,s,a,o;const t=(r=this.s)==null?void 0:r.customer,n=t&&(t.language||((s=t.values)==null?void 0:s.language));return n||((o=(a=this.context)==null?void 0:a.customer)==null?void 0:o.language)||""},locale(){var t;return te(this.language||this.customerLanguage||((t=this.widget)==null?void 0:t.default_language)||"")},translator(){return V(this.locale)},error(){var t;return this.bootError||((t=this.s)==null?void 0:t.error)||null},canBoot(){return!!(this.baseUrl&&this.widgetId)},s(){var t;return((t=this.store)==null?void 0:t.state)||null},ready(){var t;return!!((t=this.s)!=null&&t.ready)},allConversations(){var n;const t=(n=this.s)==null?void 0:n.conversations;return Array.isArray(t)?t:[]},drawerConversations(){var r;const t=((r=this.s)==null?void 0:r.messagesByConv)||{},n=this.revealedAt;return this.allConversations.map(s=>{var _;const a=t[s.id]||[],o=F(s.last_read_message_id);let i=0,l=null;for(let v=a.length-1;v>=0;v--){const B=a[v];if(!B)continue;if(((_=B.author)==null?void 0:_.type)==="user")break;const S=F(B.id);if(S!=null){if(o!=null&&S<=o)break;n[B.id]!==0&&(!l&&B.author&&(l=B.author),i++)}}const f=a.filter(v=>!((v==null?void 0:v.id)!=null&&n[v.id]===0));return{...s,_preview:st(s,f),_unread:i>0,_unreadCount:i,_lastAuthor:l}})},unreadCount(){return this.drawerConversations.filter(t=>t._unread).length},openThreads(){var n;const t=((n=this.s)==null?void 0:n.messagesByConv)||{};return this.drawerConversations.filter(r=>r.status!=="resolved").map(r=>({id:r.id,title:r.name||this.t("common.newConversation"),preview:r._preview||this.t("onboarding.newMessage"),unread:!!r._unread,_ts:fe(r,t[r.id]||[])})).sort((r,s)=>r._ts<s._ts?1:r._ts>s._ts?-1:0)},latestUnreads(){var r;const t=((r=this.s)==null?void 0:r.messagesByConv)||{},n=[];for(const s of this.drawerConversations){if(!s._unread)continue;const a=fe(s,t[s.id]||[]),o=s._lastAuthor,i=!o||o.type==="agent_ia",l=(o==null?void 0:o.name)||(i?this.agentName:"")||"",f=(o==null?void 0:o.avatar_url)||(i?this.agentAvatarUrl:null);n.push({convId:s.id,preview:s._preview||this.t("notification.youHaveNewMessage"),ts:a,count:s._unreadCount||1,senderName:l,senderAvatarUrl:f})}return n.sort((s,a)=>s.ts<a.ts?1:s.ts>a.ts?-1:0),n},launcherPeeks(){if(this.isOpen||this.isEmbedded)return[];const t=this.dismissedPeeks||{};return this.latestUnreads.filter(n=>t[n.convId]!==n.ts)},isViewingThread(){return(this.isOpen||this.isEmbedded)&&!!this.currentConv},currentConv(){if(this.draftConv)return this.draftConv;if(this.showOnboarding)return null;const t=this.allConversations;if(!t.length)return null;if(this.activeConvId!=null){const n=t.find(r=>r.id===this.activeConvId);if(n)return n}return t[0]||null},canBack(){return!!this.currentConv},statusUrl(){var r;const t=(r=this.widget)==null?void 0:r.quick_links;if(!Array.isArray(t))return"";const n=t.find(s=>s.icon==="status"&&s.url);return(n==null?void 0:n.url)||""},helpUrl(){var r;const t=(r=this.widget)==null?void 0:r.quick_links;if(!Array.isArray(t))return"";const n=t.find(s=>(s.icon==="chat"||s.icon==="help")&&s.url);return(n==null?void 0:n.url)||""},widget(){var t,n;return((n=(t=this.s)==null?void 0:t.config)==null?void 0:n.widget)||null},widgetWelcomeMessage(){var t;return((t=this.widget)==null?void 0:t.welcome_message)||""},widgetSubtitle(){var t;return((t=this.widget)==null?void 0:t.subtitle)||""},defaultIconUrl(){var t;return((t=this.widget)==null?void 0:t.default_icon_url)||null},agentName(){var t,n,r;return((r=(n=(t=this.s)==null?void 0:t.config)==null?void 0:n.agent)==null?void 0:r.name)||""},agentAvatarUrl(){var t,n,r;return((r=(n=(t=this.s)==null?void 0:t.config)==null?void 0:n.agent)==null?void 0:r.avatar_url)||null},quickLinks(){var n;const t=(n=this.widget)==null?void 0:n.quick_links;return Array.isArray(t)?t:[]},teamMembers(){var n;const t=(n=this.widget)==null?void 0:n.team_members;return Array.isArray(t)?t:[]},responseLabel(){var t;return((t=this.widget)==null?void 0:t.response_time_label)||""},humanMessageAuthor(){var n,r,s;if(!this.currentConv)return null;const t=((n=this.s.messagesByConv)==null?void 0:n[this.currentConv.id])||[];for(let a=t.length-1;a>=0;a--)if(((s=(r=t[a])==null?void 0:r.author)==null?void 0:s.type)==="agent_human")return t[a].author;return null},humanAgentName(){var t;return((t=this.humanMessageAuthor)==null?void 0:t.name)||""},humanAgentAvatarUrl(){var t;return((t=this.humanMessageAuthor)==null?void 0:t.avatar_url)||null},isEscalated(){return!!this.humanMessageAuthor},isWaitingHuman(){var n;const t=(n=this.currentConv)==null?void 0:n.status;return t==="waiting"||t==="handled"},headerTitle(){var t,n;return((t=this.currentConv)==null?void 0:t.name)||((n=this.widget)==null?void 0:n.name)||this.t("common.newConversation")},composerPlaceholder(){return this.isEscalated&&this.humanAgentName?this.t("composer.replyTo",{name:this.humanAgentName.split(" ")[0]}):this.isWaitingHuman?this.t("composer.agentTakingOver"):this.t("composer.placeholder")},displayedMessages(){var r,s;const t=this.currentConv;if(!t)return[];if(!t._draft){const a=(s=(r=this.s)==null?void 0:r.paginationByConv)==null?void 0:s[t.id];if(!(a!=null&&a.loaded))return[]}const n=this.revealedAt;return(this.s.messagesByConv[t.id]||[]).filter(a=>{var o,i,l,f,_;return(a==null?void 0:a.type)==="action"&&((o=a==null?void 0:a.payload)==null?void 0:o.state)==="pending"||J(a)&&!(n[a.id]>0)?!1:(a==null?void 0:a.type)==="action"||(a==null?void 0:a.type)==="system"||((i=a==null?void 0:a.payload)==null?void 0:i.type)==="system"||Array.isArray((l=a==null?void 0:a.payload)==null?void 0:l.attachments)&&a.payload.attachments.length||(f=a==null?void 0:a.metadata)!=null&&f.artifact||(_=a==null?void 0:a.metadata)!=null&&_.form?!0:typeof(a==null?void 0:a.text_md)=="string"&&a.text_md.trim().length>0})},streamingActive(){var r,s,a;const t=this.currentConv;return t?Object.keys(((r=this.s)==null?void 0:r.streamingByMsgId)||{}).length>0?!0:this.actionInFlight?!1:(((a=(s=this.s)==null?void 0:s.messagesByConv)==null?void 0:a[t.id])||[]).some(o=>J(o)&&!(this.revealedAt[o.id]>0)):!1},currentConvMessages(){var n,r,s;const t=(n=this.currentConv)==null?void 0:n.id;return t?((s=(r=this.s)==null?void 0:r.messagesByConv)==null?void 0:s[t])||[]:[]},pendingApproval(){return!this.currentConv||!this.store||this.actionInFlight?null:this.store.getPendingApproval(this.currentConv.id)},approvalReady(){return this.pendingApproval?this.pendingApproval.id===this.approvalLatchId?!0:!(this.streamingActive||!this.approvalSettled):!1},approvalTitle(){var t,n,r;return((n=(t=this.pendingApproval)==null?void 0:t.payload)==null?void 0:n.name)||((r=this.pendingApproval)==null?void 0:r.text_md)||this.t("action.title")},approvalDetail(){var s,a,o,i,l,f;const t=(o=(a=(s=this.pendingApproval)==null?void 0:s.payload)==null?void 0:a.pending)==null?void 0:o.user_explanation;if(typeof t=="string"&&t.trim())return t.trim();const n=(f=(l=(i=this.pendingApproval)==null?void 0:i.payload)==null?void 0:l.pending)==null?void 0:f.prepared_params;if(!n||typeof n!="object")return"";const r=Object.entries(n);return r.length?r.slice(0,2).map(([_,v])=>`${_}: ${v}`).join(" · "):""},actionInFlight(){var t,n;return!this.currentConv||!this.store?null:((n=(t=this.store).getActionInFlight)==null?void 0:n.call(t,this.currentConv.id))||null},actionInFlightName(){var n;const t=this.actionInFlight;return t?((n=t.payload)==null?void 0:n.name)||t.text_md||this.t("common.action"):""},suggestions(){return!this.currentConv||!this.store?[]:this.streamingActive?[]:this.pendingForm?[]:this.store.getLatestSuggestions(this.currentConv.id)},pendingForm(){var t,n;return!this.currentConv||!this.store||this.pendingApproval||this.actionInFlight||this.streamingActive||!this.approvalSettled?null:((n=(t=this.store).getLatestForm)==null?void 0:n.call(t,this.currentConv.id))||null},showFeedback(){var n;const t=this.currentConv;return t?this.feedbackDone?!0:t.status!=="resolved"?!1:!((n=t.metadata)!=null&&n.feedback):!1},floatVisible(){return this.approvalReady||!!this.pendingForm||this.showFeedback||this.suggestions.length>0},dateLabel(){var r,s,a;const t=this.currentConv;let n=new Date;if(t){const i=((a=(((s=(r=this.s)==null?void 0:r.messagesByConv)==null?void 0:s[t.id])||[]).find(l=>l==null?void 0:l.created_at))==null?void 0:a.created_at)||t.created_at;if(i){const l=new Date(i);Number.isNaN(l.getTime())||(n=l)}}return this.t("messageList.today",{time:ce(n,W(this.locale))})},paginationState(){var r,s,a;const t=(r=this.currentConv)==null?void 0:r.id,n=t?(a=(s=this.s)==null?void 0:s.paginationByConv)==null?void 0:a[t]:null;return{loading:!!(n!=null&&n.loading),hasMore:!!(n!=null&&n.nextCursor)}}},watch:{latestUnreads:{handler(t){const n=new Set(t.map(i=>i.convId)),r=this.dismissedPeeks||{},s=Object.keys(r);if(!s.length)return;const a={};let o=!1;for(const i of s)n.has(i)?a[i]=r[i]:o=!0;o&&(this.dismissedPeeks=a)},deep:!0},"currentConv.id":{handler(t){var n;this.resetRevealQueue(),this.convOpenedAt=Date.now(),this.moreOpen=!1,this.renameDialogOpen=!1,this.resetApprovalPacing(),this.isViewingThread&&(this.unreadAnchorId=F((n=this.currentConv)==null?void 0:n.last_read_message_id),this.unreadBoundaryTs=t?new Date().toISOString():"")},immediate:!0},isViewingThread(t,n){var r;t&&!n?(this.unreadAnchorId=F((r=this.currentConv)==null?void 0:r.last_read_message_id),this.unreadBoundaryTs=new Date().toISOString()):t||(this.unreadAnchorId=null,this.unreadBoundaryTs="")},pendingApproval:{handler(t,n){if(t&&!n){const r=t!=null&&t.created_at?Date.parse(t.created_at):NaN;if(!(Number.isFinite(r)&&r>=this.convOpenedAt)){this.resetApprovalPacing();return}this.bumpApprovalSettle(2600)}else!t&&n&&this.resetApprovalPacing()},immediate:!1},streamingActive(t,n){t!==n&&this.pendingApproval&&this.pendingApproval.id!==this.approvalLatchId&&this.bumpApprovalSettle()},approvalReady(t){t&&this.pendingApproval&&(this.approvalLatchId=this.pendingApproval.id)},floatVisible:{handler(t){this.$nextTick(()=>this.syncFloatObserver(t))},immediate:!0},currentConvMessages(t){var n;this.paceMessages(t,(n=this.currentConv)==null?void 0:n.id),(this.isOpen||this.isEmbedded)&&this.currentConv&&this.markConvRead(this.currentConv)}},async mounted(){if(typeof document<"u"&&!document.getElementById(ye)){const t=document.createElement("style");t.id=ye,t.textContent=we,document.head.appendChild(t)}this.isEmbedded&&(await this.boot(),this.store&&await this.open())},beforeUnmount(){this.cancelReveals(),this.teardownLiveReveal(),this.disconnectFloatRO(),this.resetApprovalPacing(),this.teardownNotifications(),this.store&&this.store.destroy()},methods:{t(t,n){return this.translator(t,n)},async boot(){var t;if(!this.canBoot){console.warn("[messenger] boot skipped — missing creds");return}try{this.transport=e.markRaw(ve({baseUrl:this.baseUrl,widgetId:this.widgetId,token:this.token||void 0})),this.store=e.markRaw(ke(this.transport)),this.hydrateNotifPref();const n=(t=this.context)==null?void 0:t.customer;n&&typeof n=="object"&&await this.store.applyCustomer(n),await this.store.start(),this.setupLiveReveal()}catch(n){console.error("[ww-messenger] bootstrap failed",n),this.bootError=(n==null?void 0:n.message)||String(n)}},async refresh(){this.store&&this.store.destroy(),this.cancelReveals(),this.teardownLiveReveal(),this.teardownNotifications(),this.convOpenedAt=0,this.transport=null,this.store=null,this.isOpen=!1,this.draft="",this.busy=!1,this.bootError=null,this.pendingAttachments=[],this.feedbackBusy=!1,this.feedbackDone=!1,this.moreOpen=!1,this.renameDialogOpen=!1,this.draftConv=null,this.activeConvId=null,this.showOnboarding=!1,await this.boot(),this.isEmbedded&&this.store&&await this.open()},syncFloatObserver(t){if(this.disconnectFloatRO(),!t){this.floatHeight=0;return}const n=this.$refs.floatEl;if(n){if(typeof ResizeObserver>"u"){this.floatHeight=Math.ceil(n.getBoundingClientRect().height+8);return}this.floatRO=new ResizeObserver(r=>{const s=r[0];if(!s)return;const a=Math.ceil(s.contentRect.height+8);a!==this.floatHeight&&(this.floatHeight=a,this.$nextTick(()=>{var o,i;(i=(o=this.$refs.messageList)==null?void 0:o.scrollToBottom)==null||i.call(o)}))}),this.floatRO.observe(n)}},disconnectFloatRO(){if(this.floatRO){try{this.floatRO.disconnect()}catch{}this.floatRO=null}},async open(){this.isOpen=!0,this.store||await this.boot(),this.store&&this.store.setPanelOpen(!0);const t=this.currentConv;if(t&&!t._draft){this.activeConvId==null&&(this.activeConvId=t.id);try{await this.store.openConversation(t.id)}catch(n){console.error("[ww-messenger] load messages failed",n)}this.markConvRead(t)}},close(){this.isOpen=!1,this.store&&this.store.setPanelOpen(!1)},async openFromPeek(t){var r,s;const n=t||((r=this.latestUnreads[0])==null?void 0:r.convId);n&&n!==((s=this.currentConv)==null?void 0:s.id)&&(this.draftConv=null,this.activeConvId=n,this.showOnboarding=!1),await this.open()},dismissPeek(t){const n=this.latestUnreads.find(r=>r.convId===t);n&&(this.dismissedPeeks={...this.dismissedPeeks,[t]:n.ts})},startConv(){this.draftConv={id:"__draft__",_draft:!0,name:"",created_at:new Date().toISOString()},this.activeConvId=null,this.showOnboarding=!1,this.focusComposer()},async ensureRealConv(){const t=this.currentConv;if(!t)return null;if(!t._draft)return t;if(this.busy)return null;this.busy=!0;try{const n=await this.store.createConversation({});return this.draftConv=null,this.activeConvId=n.id,await this.store.openConversation(n.id),this.markConvRead(n),n}catch(n){return console.error("[ww-messenger] create conv failed",n),this.bootError=(n==null?void 0:n.message)||String(n),null}finally{this.busy=!1}},focusComposer(){this.$nextTick(()=>{var t;return(t=this.$refs.composer)==null?void 0:t.focus()})},toggleMore(){this.moreOpen=!this.moreOpen},goHome(){this.moreOpen=!1,this.draftConv=null,this.activeConvId=null,this.showOnboarding=!0},async onDrawerPick(t){if(!(t!=null&&t.id)||!this.store)return;this.draftConv=null,this.activeConvId=t.id,this.showOnboarding=!1;try{await this.store.openConversation(t.id)}catch(r){console.error("[ww-messenger] open conv failed",r)}const n=this.allConversations.find(r=>r.id===t.id);n&&this.markConvRead(n)},async onMoreAction(t){var n,r;switch(this.moreOpen=!1,t){case"rename":this.openRenameDialog();break;case"export":ct(this.currentConv,this.currentConv?(r=(n=this.s)==null?void 0:n.messagesByConv)==null?void 0:r[this.currentConv.id]:[],this.translator,this.locale);break;case"status":if(this.statusUrl)try{window.open(this.statusUrl,"_blank","noopener")}catch{}break;case"help":if(this.helpUrl)try{window.open(this.helpUrl,"_blank","noopener")}catch{}break}},openRenameDialog(){const t=this.currentConv;!t||t._draft||(this.renameDialogOpen=!0)},async onRenameSubmit(t){const n=this.currentConv;if(this.renameDialogOpen=!1,!n||n._draft||!this.store)return;const r=(t||"").trim();if(!(!r||r===n.name))try{await this.store.patchConversation(n.id,{name:r})}catch(s){console.error("[ww-messenger] rename failed",s)}},async onSend(t){let n=this.currentConv;if(!n&&(this.startConv(),n=this.currentConv,!n)||n._draft&&(n=await this.ensureRealConv(),!n))return;const r=n.id,s=this.pendingAttachments.slice();this.pendingAttachments=[],this.unreadAnchorId=null,this.unreadBoundaryTs="",await this.store.send(r,t,{attachments:s.length?s:void 0})},async onSuggestion(t){const n=t==null?void 0:t.label;n&&await this.onSend(n)},async onLoadMore(){var n;const t=(n=this.currentConv)==null?void 0:n.id;!t||!this.store||await this.store.loadMore(t)},async onApprovalCallback(t){const n=this.pendingApproval;n&&await this.store.clickCallback(n.id,t)},async onFormSubmit({values:t}){const n=this.pendingForm;if(!(n!=null&&n.form))return;const r=ot(n.form,t,this.translator);if(!r)return;let s=this.currentConv;s&&(s._draft&&(s=await this.ensureRealConv(),!s)||await this.store.send(s.id,r,{metadata:{artifact:at(n.form,t,this.translator)}}))},async onAttach(t){if(!(!t||!this.transport))try{const n=await this.transport.uploadAttachment(t);this.pendingAttachments.push({type:n.type||"file",path:n.path,name:t.name||this.t("attachment.fileFallbackName"),mime_type:t.type,size_bytes:t.size})}catch(n){console.error("[ww-messenger] attachment upload failed",n)}},async onQuickLink(t){if(t){if(t.url){try{window.open(t.url,"_blank","noopener")}catch{}return}this.currentConv||this.startConv(),await this.onSend(t.label)}},async onFeedback({rating:t,comment:n}){if(this.currentConv){this.feedbackBusy=!0;try{await this.store.submitFeedback(this.currentConv.id,{rating:t,comment:n}),this.feedbackDone=!0}catch(r){console.error("[ww-messenger] feedback failed",r)}finally{this.feedbackBusy=!1}}}}},cs={key:0,class:"wm-loading","aria-busy":"true","aria-live":"polite"},ds=["aria-label"],us={key:0,class:"wm-state"},ms={class:"wm-state__err"},hs={class:"wm-state__errTitle"},fs={class:"wm-state__errSub"},ps={class:"wm-bottom"},gs={key:0,ref:"floatEl",class:"wm-float"},_s={key:1,class:"wm-actionWait",role:"status","aria-live":"polite"},ys={class:"wm-actionWait__lbl"},vs={key:2,class:"wm-attached"},ks=["aria-label","onClick"];function ws(t,n,r,s,a,o){const i=e.resolveComponent("Launcher"),l=e.resolveComponent("Header"),f=e.resolveComponent("Onboarding"),_=e.resolveComponent("MessageList"),v=e.resolveComponent("ApprovalCard"),B=e.resolveComponent("FormCard"),S=e.resolveComponent("Feedback"),E=e.resolveComponent("SuggestionChips"),L=e.resolveComponent("Composer"),C=e.resolveComponent("MoreMenu"),x=e.resolveComponent("RenameDialog");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-root",`wm-root--${r.displayMode}`])},[!a.isOpen&&!o.isEmbedded?(e.openBlock(),e.createBlock(i,{key:0,"unread-count":o.unreadCount,peeks:o.launcherPeeks,onOpen:o.openFromPeek,onDismiss:o.dismissPeek},null,8,["unread-count","peeks","onOpen","onDismiss"])):e.createCommentVNode("",!0),a.isOpen||o.isEmbedded?(e.openBlock(),e.createElementBlock("section",{key:1,class:e.normalizeClass(["wm-panel",`wm-panel--${r.displayMode}`,{"wm-panel--welcome":o.ready&&!o.error&&!o.currentConv}]),style:e.normalizeStyle(a.floatHeight?{"--wm-float-h":a.floatHeight+"px"}:null),role:"dialog","aria-label":"Messenger"},[!o.ready&&!o.error?(e.openBlock(),e.createElementBlock("div",cs,[o.isEmbedded?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-loading__close","aria-label":o.t("loading.minimize"),onClick:n[0]||(n[0]=(...A)=>o.close&&o.close(...A))},[...n[5]||(n[5]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,ds)),n[6]||(n[6]=e.createElementVNode("div",{class:"wm-loading__spinner","aria-hidden":"true"},null,-1))])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(l,{title:o.headerTitle,"team-members":o.teamMembers,"response-label":o.responseLabel,"show-identity":!!o.currentConv,"show-back":o.canBack,"show-close":!o.isEmbedded,"more-active":a.moreOpen,"agent-name":o.agentName,"agent-avatar-url":o.agentAvatarUrl,onBack:o.goHome,onMore:o.toggleMore,onClose:o.close},null,8,["title","team-members","response-label","show-identity","show-back","show-close","more-active","agent-name","agent-avatar-url","onBack","onMore","onClose"]),o.error?(e.openBlock(),e.createElementBlock("div",us,[e.createElementVNode("div",ms,[n[7]||(n[7]=e.createElementVNode("div",{class:"wm-state__errIcon"},[e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})])],-1)),e.createElementVNode("div",null,[e.createElementVNode("div",hs,e.toDisplayString(o.t("error.connectionFailed")),1),e.createElementVNode("div",fs,e.toDisplayString(o.error),1)])])])):o.currentConv?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createVNode(_,{ref:"messageList",messages:o.displayedMessages,"streaming-active":o.streamingActive,"date-label":o.dateLabel,"conversation-id":o.currentConv?o.currentConv.id:null,"loading-more":o.paginationState.loading,"has-more":o.paginationState.hasMore,"unread-anchor-id":t.unreadAnchorId,"unread-boundary-ts":t.unreadBoundaryTs,"ai-agent-name":o.agentName,"ai-agent-avatar-url":o.agentAvatarUrl,onLoadMore:o.onLoadMore},null,8,["messages","streaming-active","date-label","conversation-id","loading-more","has-more","unread-anchor-id","unread-boundary-ts","ai-agent-name","ai-agent-avatar-url","onLoadMore"]),e.createElementVNode("div",ps,[o.floatVisible?(e.openBlock(),e.createElementBlock("div",gs,[o.approvalReady?(e.openBlock(),e.createBlock(v,{key:0,action:o.approvalTitle,detail:o.approvalDetail,callbacks:o.pendingApproval.callbacks,"agent-name":o.agentName,"agent-avatar-url":o.agentAvatarUrl,onCallback:o.onApprovalCallback},null,8,["action","detail","callbacks","agent-name","agent-avatar-url","onCallback"])):o.pendingForm?(e.openBlock(),e.createBlock(B,{key:o.pendingForm.message&&o.pendingForm.message.id,form:o.pendingForm.form,"agent-name":o.agentName,"agent-avatar-url":o.agentAvatarUrl,onSubmit:o.onFormSubmit},null,8,["form","agent-name","agent-avatar-url","onSubmit"])):o.showFeedback?(e.openBlock(),e.createBlock(S,{key:2,busy:a.feedbackBusy,done:a.feedbackDone,onSubmit:o.onFeedback},null,8,["busy","done","onSubmit"])):(e.openBlock(),e.createBlock(E,{key:3,items:o.suggestions,onSelect:o.onSuggestion},null,8,["items","onSelect"]))],512)):e.createCommentVNode("",!0),o.actionInFlight?(e.openBlock(),e.createElementBlock("div",_s,[n[8]||(n[8]=e.createElementVNode("span",{class:"wm-actionWait__spinner","aria-hidden":"true"},null,-1)),e.createElementVNode("span",ys,e.toDisplayString(o.t("action.inProgress",{name:o.actionInFlightName})),1)])):(e.openBlock(),e.createBlock(L,{key:2,ref:"composer",modelValue:a.draft,"onUpdate:modelValue":n[1]||(n[1]=A=>a.draft=A),placeholder:o.composerPlaceholder,disabled:!!o.pendingApproval,"attach-label":o.t("composer.attachFile"),onSend:o.onSend,onAttach:o.onAttach},null,8,["modelValue","placeholder","disabled","attach-label","onSend","onAttach"]))]),a.moreOpen?(e.openBlock(),e.createBlock(C,{key:0,"can-rename":!!o.currentConv&&!o.currentConv._draft,"can-export":!!o.currentConv&&!o.currentConv._draft,"sound-enabled":t.soundEnabled,"browser-notif-enabled":t.browserNotifEnabled,"status-url":o.statusUrl,"help-url":o.helpUrl,onClose:n[2]||(n[2]=A=>a.moreOpen=!1),onSoundToggle:t.onSoundToggle,onBrowserNotifToggle:t.onBrowserNotifToggle,onAction:o.onMoreAction},null,8,["can-rename","can-export","sound-enabled","browser-notif-enabled","status-url","help-url","onSoundToggle","onBrowserNotifToggle","onAction"])):e.createCommentVNode("",!0),a.renameDialogOpen&&o.currentConv&&!o.currentConv._draft?(e.openBlock(),e.createBlock(x,{key:1,"initial-value":o.currentConv.name||"",title:o.t("rename.dialogTitle"),onClose:n[3]||(n[3]=A=>a.renameDialogOpen=!1),onSubmit:o.onRenameSubmit},null,8,["initial-value","title","onSubmit"])):e.createCommentVNode("",!0),a.pendingAttachments.length?(e.openBlock(),e.createElementBlock("div",vs,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.pendingAttachments,(A,O)=>(e.openBlock(),e.createElementBlock("div",{key:O,class:"wm-attached__chip"},[n[10]||(n[10]=e.createElementVNode("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"})],-1)),e.createElementVNode("span",null,e.toDisplayString(A.name),1),e.createElementVNode("button",{type:"button","aria-label":o.t("attachment.remove"),onClick:D=>a.pendingAttachments.splice(O,1)},[...n[9]||(n[9]=[e.createElementVNode("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,ks)]))),128))])):e.createCommentVNode("",!0)],64)):(e.openBlock(),e.createBlock(f,{key:1,"welcome-message":o.widgetWelcomeMessage,subtitle:o.widgetSubtitle,"agent-name":o.agentName,"default-icon-url":o.defaultIconUrl,"quick-links":o.quickLinks,"open-threads":o.openThreads,busy:a.busy,onStart:o.startConv,onSelect:o.onQuickLink,onResume:o.onDrawerPick},null,8,["welcome-message","subtitle","agent-name","default-icon-url","quick-links","open-threads","busy","onStart","onSelect","onResume"])),a.moreOpen&&!o.currentConv?(e.openBlock(),e.createBlock(C,{key:3,"can-rename":!1,"can-export":!1,"sound-enabled":t.soundEnabled,"browser-notif-enabled":t.browserNotifEnabled,"status-url":o.statusUrl,"help-url":o.helpUrl,onClose:n[4]||(n[4]=A=>a.moreOpen=!1),onSoundToggle:t.onSoundToggle,onBrowserNotifToggle:t.onBrowserNotifToggle,onAction:o.onMoreAction},null,8,["sound-enabled","browser-notif-enabled","status-url","help-url","onSoundToggle","onBrowserNotifToggle","onAction"])):e.createCommentVNode("",!0)],64))],6)):e.createCommentVNode("",!0)],2)}const Qe=N(ls,[["render",ws],["__scopeId","data-v-966f7d8a"]]),bs="0.5.1";exports.AIAvatar=G;exports.AVATAR_COLORS=X;exports.ActionResult=xe;exports.ApprovalCard=We;exports.ArtifactFormResponse=Le;exports.ArtifactInfoCard=Oe;exports.ArtifactRenderer=Ie;exports.ArtifactTicket=De;exports.AttachmentPreview=Re;exports.Bubble=Fe;exports.Composer=$e;exports.DEFAULT_BASE_URL=be;exports.DEFAULT_LANGUAGE=K;exports.Feedback=Ye;exports.FormCard=Ge;exports.Header=Se;exports.HumanAvatar=de;exports.Launcher=Be;exports.MEDIA_RECORDER_SUPPORTED=ne;exports.MessageList=Pe;exports.Messenger=Qe;exports.MoreMenu=Je;exports.Onboarding=Te;exports.SCREEN_CAPTURE_SUPPORTED=Q;exports.SUPPORTED_LANGUAGES=Ee;exports.SuggestionChips=Ke;exports.TeamAvatars=Ne;exports.Typing=Ue;exports.VERSION=bs;exports.avatarColor=Z;exports.avatarInitials=ee;exports.captureScreenshotFile=qe;exports.colors=T;exports.createStore=ke;exports.createTranslator=V;exports.createTransport=ve;exports.dateLocale=W;exports.default=Qe;exports.formatTime=ce;exports.guessAttachmentKind=bo;exports.pickRecorderMime=je;exports.renderInlineMarkdown=Ve;exports.renderMarkdown=Me;exports.resolveLanguage=te;exports.startScreenRecording=He;exports.tokensCss=we;exports.uuid=le;exports.v4=le;
57
+ `)}return a}const ge={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"},un={name:"WmOnboarding",components:{AIAvatar:G},inject:{t:{default:()=>V()},wmLocale:{default:()=>()=>"fr"}},props:{welcomeMessage:{type:String,default:""},subtitle:{type:String,default:""},agentName:{type:String,default:""},defaultIconUrl:{type:String,default:null},quickLinks:{type:Array,default:()=>[]},openThreads:{type:Array,default:()=>[]},busy:{type:Boolean,default:!1}},emits:["start","select","resume"],data(){return{query:""}},computed:{heroTitle(){return this.welcomeMessage?this.welcomeMessage:this.agentName?this.t("onboarding.greetingNamed",{name:this.agentName}):this.t("onboarding.greeting")},heroSub(){return this.subtitle||this.t("onboarding.heroSub")},isOddQuickLinks(){return this.quickLinks.length%2===1},quickLinksLayout(){return this.isOddQuickLinks?"wm-onb__qlist":"wm-onb__grid"},filteredThreads(){const t=this.query.trim().toLowerCase();return t?this.openThreads.filter(n=>(n.title||"").toLowerCase().includes(t)||(n.preview||"").toLowerCase().includes(t)):this.openThreads}},methods:{iconPath(t){return ge[t]||ge.link},renderPreview(t){return Ve(t)},formatTs(t){if(!t)return"";const n=new Date(t);if(Number.isNaN(n.getTime()))return"";const r=W(this.wmLocale()),s=new Date;if(n.toDateString()===s.toDateString())return n.toLocaleTimeString(r,{hour:"2-digit",minute:"2-digit"});if(s.getTime()-n.getTime()<7*864e5){const i=n.toLocaleDateString(r,{weekday:"short"});return i.charAt(0).toUpperCase()+i.slice(1)}return n.toLocaleDateString(r,{day:"2-digit",month:"2-digit"})}}},mn={class:"wm-onb"},hn={class:"wm-onb__hero"},fn={class:"wm-onb__hero-text"},pn={class:"wm-onb__title"},gn={class:"wm-onb__sub"},_n={class:"wm-onb__cta"},yn=["disabled"],vn={key:0,class:"wm-onb__section"},kn={class:"wm-onb__section-title"},wn=["onClick"],bn={class:"wm-onb__card-icon"},En={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"},Cn=["d"],Bn={class:"wm-onb__card-body"},Nn={class:"wm-onb__card-title"},Sn={key:0,class:"wm-onb__card-sub"},An={key:1,class:"wm-onb__section"},Vn={class:"wm-onb__section-title"},Mn={class:"wm-onb__search"},Tn=["placeholder","aria-label"],xn={class:"wm-onb__list"},Ln=["onClick"],On=["aria-label"],Dn={class:"wm-onb__thread-body"},In={class:"wm-onb__thread-title"},Rn=["innerHTML"],Fn={class:"wm-onb__thread-meta"},Un={key:0,class:"wm-onb__thread-time"},Pn={key:0,class:"wm-onb__empty"};function jn(t,n,r,s,a,o){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",mn,[e.createElementVNode("div",hn,[n[2]||(n[2]=e.createElementVNode("svg",{class:"wm-onb__hero-deco",width:"180",height:"180",viewBox:"0 0 180 180",fill:"none","aria-hidden":"true"},[e.createElementVNode("circle",{cx:"170",cy:"10",r:"105",stroke:"#5B5FEF","stroke-width":"1","stroke-dasharray":"1 5",opacity:"0.35"}),e.createElementVNode("circle",{cx:"170",cy:"10",r:"72",stroke:"#5B5FEF","stroke-width":"1","stroke-dasharray":"1 5",opacity:"0.5"}),e.createElementVNode("circle",{cx:"152",cy:"34",r:"2.5",fill:"#5B5FEF",opacity:"0.65"})],-1)),e.createVNode(i,{size:52,"image-url":r.defaultIconUrl},null,8,["image-url"]),e.createElementVNode("div",fn,[e.createElementVNode("div",pn,e.toDisplayString(o.heroTitle),1),e.createElementVNode("div",gn,e.toDisplayString(o.heroSub),1)])]),e.createElementVNode("div",_n,[e.createElementVNode("button",{type:"button",class:"wm-onb__startBtn",disabled:r.busy,onClick:n[0]||(n[0]=l=>t.$emit("start"))},[n[3]||(n[3]=e.createElementVNode("span",{class:"wm-onb__startIcon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M12 5v14M5 12h14"})])],-1)),e.createElementVNode("span",null,e.toDisplayString(r.busy?"…":o.t("onboarding.start")),1)],8,yn)]),r.quickLinks.length?(e.openBlock(),e.createElementBlock("div",vn,[e.createElementVNode("div",kn,e.toDisplayString(o.t("onboarding.quickAccess")),1),e.createElementVNode("div",{class:e.normalizeClass(o.quickLinksLayout)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.quickLinks,(l,f)=>(e.openBlock(),e.createElementBlock("button",{key:f,type:"button",class:e.normalizeClass(["wm-onb__card",{"wm-onb__card--row":o.isOddQuickLinks}]),onClick:_=>t.$emit("select",l)},[e.createElementVNode("span",bn,[(e.openBlock(),e.createElementBlock("svg",En,[e.createElementVNode("path",{d:o.iconPath(l.icon)},null,8,Cn)]))]),e.createElementVNode("span",Bn,[e.createElementVNode("span",Nn,e.toDisplayString(l.label),1),l.description?(e.openBlock(),e.createElementBlock("span",Sn,e.toDisplayString(l.description),1)):e.createCommentVNode("",!0)])],10,wn))),128))],2)])):e.createCommentVNode("",!0),r.openThreads.length?(e.openBlock(),e.createElementBlock("div",An,[e.createElementVNode("div",Vn,e.toDisplayString(o.t("onboarding.recentConversations")),1),e.createElementVNode("div",Mn,[n[4]||(n[4]=e.createElementVNode("span",{class:"wm-onb__searchIcon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 21l-4.35-4.35M11 17a6 6 0 100-12 6 6 0 000 12z"})])],-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":n[1]||(n[1]=l=>a.query=l),type:"text",placeholder:o.t("onboarding.search"),"aria-label":o.t("onboarding.search")},null,8,Tn),[[e.vModelText,a.query]])]),e.createElementVNode("div",xn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.filteredThreads,l=>(e.openBlock(),e.createElementBlock("button",{key:l.id,type:"button",class:"wm-onb__thread",onClick:f=>t.$emit("resume",l)},[e.createElementVNode("span",{class:e.normalizeClass(["wm-onb__thread-icon",{"wm-onb__thread-icon--inverted":!l.unread}])},[n[5]||(n[5]=e.createElementVNode("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[e.createElementVNode("path",{d:"M12 2 L13.5 9 L20 10.5 L13.5 12 L12 19 L10.5 12 L4 10.5 L10.5 9 Z",fill:"currentColor",opacity:"0.92"})],-1)),l.unread?(e.openBlock(),e.createElementBlock("span",{key:0,class:"wm-onb__thread-dot","aria-label":o.t("onboarding.unread")},null,8,On)):e.createCommentVNode("",!0)],2),e.createElementVNode("span",Dn,[e.createElementVNode("span",In,e.toDisplayString(l.title),1),e.createElementVNode("span",{class:"wm-onb__thread-preview",innerHTML:o.renderPreview(l.preview)},null,8,Rn)]),e.createElementVNode("span",Fn,[o.formatTs(l._ts)?(e.openBlock(),e.createElementBlock("span",Un,e.toDisplayString(o.formatTs(l._ts)),1)):e.createCommentVNode("",!0),n[6]||(n[6]=e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round",class:"wm-onb__thread-chev","aria-hidden":"true"},[e.createElementVNode("path",{d:"M5 12h14M13 5l7 7-7 7"})],-1))])],8,Ln))),128)),o.filteredThreads.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Pn,e.toDisplayString(o.t("onboarding.noResults",{query:a.query})),1))])])):e.createCommentVNode("",!0)])}const Te=N(un,[["render",jn],["__scopeId","data-v-28c0780b"]]);function zn(t){return typeof t!="string"?"":t.replace(/`([^`]+)`/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(new RegExp("(?<!\\*)\\*([^*]+)\\*(?!\\*)","g"),"$1").replace(/__([^_]+)__/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\s+/g," ").trim()}const qn={name:"WmActionResult",props:{state:{type:String,default:"success"},label:{type:String,required:!0},detail:{type:String,default:""}},computed:{detailText(){return zn(this.detail)}}},Hn={class:"wm-result__icon","aria-hidden":"true"},$n={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"},Kn={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"},Wn={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"},Gn={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"},Yn={class:"wm-result__body"},Jn={class:"wm-result__label"},Qn={class:"wm-result__detail"};function Xn(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-result",`wm-result--${r.state}`])},[e.createElementVNode("span",Hn,[r.state==="success"?(e.openBlock(),e.createElementBlock("svg",$n,[...n[0]||(n[0]=[e.createElementVNode("path",{d:"M20 6L9 17l-5-5"},null,-1)])])):r.state==="rejected"?(e.openBlock(),e.createElementBlock("svg",Kn,[...n[1]||(n[1]=[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"},null,-1)])])):r.state==="awaiting"?(e.openBlock(),e.createElementBlock("svg",Wn,[...n[2]||(n[2]=[e.createElementVNode("circle",{cx:"12",cy:"12",r:"10"},null,-1),e.createElementVNode("polyline",{points:"12 7 12 12 15 14"},null,-1)])])):(e.openBlock(),e.createElementBlock("svg",Gn,[...n[3]||(n[3]=[e.createElementVNode("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"},null,-1),e.createElementVNode("line",{x1:"12",y1:"9",x2:"12",y2:"13"},null,-1),e.createElementVNode("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"},null,-1)])]))]),e.createElementVNode("span",Yn,[e.createElementVNode("span",Jn,e.toDisplayString(r.label),1),o.detailText?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[n[4]||(n[4]=e.createElementVNode("span",{class:"wm-result__sep","aria-hidden":"true"}," · ",-1)),e.createElementVNode("span",Qn,e.toDisplayString(o.detailText),1)],64)):e.createCommentVNode("",!0)])],2)}const xe=N(qn,[["render",Xn],["__scopeId","data-v-7284acd0"]]),Zn={name:"WmArtifactFormResponse",inject:{t:{default:()=>V()}},props:{data:{type:Object,required:!0}},computed:{fields(){var t;return Array.isArray((t=this.data)==null?void 0:t.fields)?this.data.fields:[]}}},er={class:"wm-art wm-art--formResponse"},tr={class:"wm-art__head"},nr={class:"wm-art__title"},rr={class:"wm-art__badge wm-art__badge--success"},or={class:"wm-art__body"},ar={class:"wm-art__fieldLabel"};function sr(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",er,[e.createElementVNode("div",tr,[e.createElementVNode("div",nr,e.toDisplayString(r.data.title||o.t("form.title")),1),e.createElementVNode("span",rr,[n[0]||(n[0]=e.createElementVNode("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("polyline",{points:"20 6 9 17 4 12"})],-1)),e.createTextVNode(" "+e.toDisplayString(o.t("form.sent")),1)])]),e.createElementVNode("div",or,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.fields,(i,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-art__field"},[e.createElementVNode("div",ar,e.toDisplayString(i.label),1),e.createElementVNode("div",{class:e.normalizeClass(["wm-art__fieldValue",{"wm-art__fieldValue--multi":i.multiline}])},e.toDisplayString(i.value),3)]))),128))])])}const Le=N(Zn,[["render",sr],["__scopeId","data-v-713aecf1"]]),ir={name:"WmArtifactInfoCard",props:{data:{type:Object,required:!0}},computed:{fields(){var t;return Array.isArray((t=this.data)==null?void 0:t.fields)?this.data.fields:[]},hasBody(){var t;return!!((t=this.data)!=null&&t.body)||this.fields.length>0}}},lr={class:"wm-art wm-art--infoCard"},cr={key:0,class:"wm-art__image"},dr=["src","alt"],ur={class:"wm-art__head"},mr={class:"wm-art__headMain"},hr={class:"wm-art__title"},fr={key:0,class:"wm-art__subtitle"},pr={key:1,class:"wm-art__body"},gr={key:0,class:"wm-art__text"},_r={class:"wm-art__fieldLabel"};function yr(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",lr,[r.data.image_url?(e.openBlock(),e.createElementBlock("figure",cr,[e.createElementVNode("img",{src:r.data.image_url,alt:r.data.title||"",loading:"lazy"},null,8,dr)])):e.createCommentVNode("",!0),e.createElementVNode("div",ur,[e.createElementVNode("div",mr,[e.createElementVNode("div",hr,e.toDisplayString(r.data.title),1),r.data.subtitle?(e.openBlock(),e.createElementBlock("div",fr,e.toDisplayString(r.data.subtitle),1)):e.createCommentVNode("",!0)]),r.data.badge&&r.data.badge.label?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(["wm-art__badge",`wm-art__badge--${r.data.badge.tone||"neutral"}`])},e.toDisplayString(r.data.badge.label),3)):e.createCommentVNode("",!0)]),o.hasBody?(e.openBlock(),e.createElementBlock("div",pr,[r.data.body?(e.openBlock(),e.createElementBlock("div",gr,e.toDisplayString(r.data.body),1)):e.createCommentVNode("",!0),o.fields.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(o.fields,(i,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-art__field"},[e.createElementVNode("div",_r,e.toDisplayString(i.label),1),e.createElementVNode("div",{class:e.normalizeClass(["wm-art__fieldValue",{"wm-art__fieldValue--multi":i.multiline}])},e.toDisplayString(i.value),3)]))),128)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])}const Oe=N(ir,[["render",yr],["__scopeId","data-v-7eae0e4a"]]);function vr(t,n,r){if(!t)return"";const s=new Date(t);if(Number.isNaN(s.getTime()))return t;const a=s.toLocaleDateString(n,{day:"numeric",month:"long",year:"numeric"}),o=s.toLocaleTimeString(n,{hour:"2-digit",minute:"2-digit"});return`${a}${r}${o}`}const kr={name:"WmArtifactTicket",inject:{t:{default:()=>V()},wmLocale:{default:()=>()=>"fr"}},props:{data:{type:Object,required:!0}},computed:{fields(){var t;return Array.isArray((t=this.data)==null?void 0:t.fields)?this.data.fields:[]},formattedDate(){var t;return vr((t=this.data)==null?void 0:t.created_at,W(this.wmLocale()),this.t("ticket.dateAt"))}},methods:{isPriority(t){return/priorit|^prio$/i.test(String(t||"").trim())},isDate(t){return/date|échéanc|echeanc|deadline|due|créé|cree/i.test(String(t||"").trim())},priorityLevel(t){const n=String(t||"").toLowerCase();return/high|haute|élev|elev|critic|critiq|urgent/.test(n)?3:/low|basse|faible|minor/.test(n)?1:2}}},wr={class:"wm-art wm-art--ticket"},br={class:"wm-art__head wm-tk__head"},Er={class:"wm-art__title wm-tk__title"},Cr={class:"wm-tk__sub"},Br={class:"wm-tk__ref"},Nr={key:0,class:"wm-tk__text"},Sr={key:0,class:"wm-art__body"},Ar={class:"wm-art__fieldLabel"},Vr=["data-level"],Mr={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"},Tr={key:1,class:"wm-art__footer wm-tk__footer"};function xr(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",wr,[e.createElementVNode("div",br,[e.createElementVNode("div",Er,e.toDisplayString(r.data.title),1),e.createElementVNode("div",Cr,[e.createElementVNode("div",Br,[n[0]||(n[0]=e.createElementVNode("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M20 12a2 2 0 0 1 2-2V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v4a2 2 0 0 1 0 4v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 1-2-2z"}),e.createElementVNode("path",{d:"M13 5v2M13 17v2M13 11v2"})],-1)),e.createElementVNode("span",null,e.toDisplayString(r.data.reference),1)]),e.createElementVNode("span",{class:e.normalizeClass(["wm-art__badge","wm-tk__badge",`wm-art__badge--${r.data.status.tone||"neutral"}`])},[n[1]||(n[1]=e.createElementVNode("span",{class:"wm-tk__dot","aria-hidden":"true"},null,-1)),e.createTextVNode(" "+e.toDisplayString(r.data.status.label),1)],2)]),r.data.body?(e.openBlock(),e.createElementBlock("div",Nr,e.toDisplayString(r.data.body),1)):e.createCommentVNode("",!0)]),o.fields.length?(e.openBlock(),e.createElementBlock("div",Sr,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.fields,(i,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-art__field"},[e.createElementVNode("div",Ar,e.toDisplayString(i.label),1),e.createElementVNode("div",{class:e.normalizeClass(["wm-art__fieldValue",{"wm-art__fieldValue--multi":i.multiline}])},[o.isPriority(i.label)?(e.openBlock(),e.createElementBlock("svg",{key:0,class:"wm-tk__prio","data-level":o.priorityLevel(i.value),width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true"},[...n[2]||(n[2]=[e.createElementVNode("rect",{x:"1",y:"8",width:"2",height:"3",rx:"0.5"},null,-1),e.createElementVNode("rect",{x:"5",y:"5",width:"2",height:"6",rx:"0.5"},null,-1),e.createElementVNode("rect",{x:"9",y:"2",width:"2",height:"9",rx:"0.5"},null,-1)])],8,Vr)):o.isDate(i.label)?(e.openBlock(),e.createElementBlock("svg",Mr,[...n[3]||(n[3]=[e.createElementVNode("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"},null,-1),e.createElementVNode("path",{d:"M16 2v4M8 2v4M3 10h18"},null,-1)])])):e.createCommentVNode("",!0),e.createElementVNode("span",null,e.toDisplayString(i.value),1)],2)]))),128))])):e.createCommentVNode("",!0),r.data.created_at?(e.openBlock(),e.createElementBlock("div",Tr,[n[4]||(n[4]=e.createElementVNode("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),e.createElementVNode("path",{d:"M16 2v4M8 2v4M3 10h18"})],-1)),e.createElementVNode("span",null,e.toDisplayString(o.formattedDate),1)])):e.createCommentVNode("",!0)])}const De=N(kr,[["render",xr],["__scopeId","data-v-5f30c914"]]),Lr={form_response:Le,info_card:Oe,ticket:De},Or={name:"WmArtifactRenderer",props:{artifact:{type:Object,required:!0}},computed:{component(){var n;const t=(n=this.artifact)==null?void 0:n.kind;return t&&Lr[t]||null}}};function Dr(t,n,r,s,a,o){return o.component?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.component),{key:0,data:r.artifact.data},null,8,["data"])):e.createCommentVNode("",!0)}const Ie=N(Or,[["render",Dr]]),Ir={name:"WmAttachmentPreview",inject:{signAttachmentFn:{default:null},t:{default:()=>V()}},props:{attachment:{type:Object,required:!0}},data(){return{url:null,loading:!1}},computed:{kind(){var r,s;const t=(r=this.attachment)==null?void 0:r.type;if(t)return t;const n=(((s=this.attachment)==null?void 0:s.mime_type)||"").toLowerCase();return n.startsWith("image/")?"image":n.startsWith("audio/")?"audio":n.startsWith("video/")?"video":"file"},displayName(){var t,n,r;return((n=(t=this.attachment)==null?void 0:t.metadata)==null?void 0:n.name)||((r=this.attachment)==null?void 0:r.name)||this.guessNameFromPath()||this.t("attachment.fallbackName")},safeHref(){const t=String(this.url||"").trim();return/^(https?:\/\/|blob:|data:image\/)/i.test(t)?t:"#"},sizeLabel(){var n;const t=(n=this.attachment)==null?void 0:n.size_bytes;return t?t<1024?this.t("attachment.bytes",{size:t}):t<1024*1024?this.t("attachment.kilobytes",{size:(t/1024).toFixed(0)}):this.t("attachment.megabytes",{size:(t/(1024*1024)).toFixed(1)}):""}},watch:{"attachment.path":{handler(){this.refresh()},immediate:!0}},methods:{guessNameFromPath(){var r;return((((r=this.attachment)==null?void 0:r.path)||"").split("/").pop()||"").replace(/^[0-9a-f-]{8,}-/,"")},async refresh(){var t;if(!(!((t=this.attachment)!=null&&t.path)||!this.signAttachmentFn)){this.loading=!0;try{this.url=await this.signAttachmentFn(this.attachment.path)}finally{this.loading=!1}}},onFileClick(t){this.safeHref==="#"&&t.preventDefault()}}},Rr=["href"],Fr=["src","alt"],Ur=["src"],Pr=["src"],jr=["href","download"],zr={class:"wm-att__main"},qr={class:"wm-att__name"},Hr={key:0,class:"wm-att__meta"},$r={key:0,class:"wm-att__spin","aria-hidden":"true"};function Kr(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-att",["wm-att--"+(o.kind||"file")]])},[o.kind==="image"&&a.url?(e.openBlock(),e.createElementBlock("a",{key:0,href:o.safeHref,target:"_blank",rel:"noopener",class:"wm-att__imgWrap"},[e.createElementVNode("img",{src:a.url,alt:o.displayName,loading:"lazy"},null,8,Fr)],8,Rr)):o.kind==="audio"&&a.url?(e.openBlock(),e.createElementBlock("audio",{key:1,src:a.url,controls:"",preload:"metadata"},null,8,Ur)):o.kind==="video"&&a.url?(e.openBlock(),e.createElementBlock("video",{key:2,src:a.url,controls:"",preload:"metadata"},null,8,Pr)):(e.openBlock(),e.createElementBlock("a",{key:3,class:"wm-att__file",href:o.safeHref,download:o.displayName,target:"_blank",rel:"noopener",onClick:n[0]||(n[0]=(...i)=>o.onFileClick&&o.onFileClick(...i))},[n[1]||(n[1]=e.createElementVNode("span",{class:"wm-att__icon"},[e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.7","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"}),e.createElementVNode("path",{d:"M14 2v6h6"})])],-1)),e.createElementVNode("span",zr,[e.createElementVNode("span",qr,e.toDisplayString(o.displayName),1),o.sizeLabel?(e.openBlock(),e.createElementBlock("span",Hr,e.toDisplayString(o.sizeLabel),1)):e.createCommentVNode("",!0)]),a.loading?(e.openBlock(),e.createElementBlock("span",$r)):e.createCommentVNode("",!0)],8,jr))],2)}const Re=N(Ir,[["render",Kr],["__scopeId","data-v-0c877a62"]]),Wr={name:"WmBubble",props:{role:{type:String,default:"ai"},text:{type:String,default:""}},computed:{rendered(){return Me(this.text)}}},Gr=["innerHTML"];function Yr(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-bubble","wm-bubble--"+r.role])},[e.renderSlot(t.$slots,"default",{},()=>[e.createElementVNode("span",{innerHTML:o.rendered},null,8,Gr)],!0)],2)}const Fe=N(Wr,[["render",Yr],["__scopeId","data-v-7ab13147"]]),Jr={name:"WmTyping"},Qr={class:"wm-typing"};function Xr(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",Qr,[...n[0]||(n[0]=[e.createElementVNode("span",{style:{"animation-delay":"0s"}},null,-1),e.createElementVNode("span",{style:{"animation-delay":"0.2s"}},null,-1),e.createElementVNode("span",{style:{"animation-delay":"0.4s"}},null,-1)])])}const Ue=N(Jr,[["render",Xr],["__scopeId","data-v-df2447fd"]]);function U(t){return t?t.client_msg_id||t.id:""}const Zr={transferred_to_human:"system.transferredToHuman",assigned:"system.assigned",unassigned:"system.unassigned",resolved:"system.resolved",reopened:"system.reopened",idle:"system.idle"},eo=80,to=200,no={name:"WmMessageList",components:{AIAvatar:G,HumanAvatar:de,Bubble:Fe,Typing:Ue,ActionResult:xe,AttachmentPreview:Re,ArtifactRenderer:Ie},inject:{t:{default:()=>V()},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({})}},computed:{historyExhausted(){return!this.hasMore&&!this.loadingMore&&this.messages.length>=20},groups(){var r,s,a,o;const t=[];for(const i of this.messages){const l=this.roleOf(i);if(l==="system"){if(((r=i==null?void 0:i.payload)==null?void 0:r.event)==="action_admin_pending"){const v=t[t.length-1];v&&v.role==="ai"?v.messages.push(i):t.push({key:`g-${U(i)}`,role:"ai",agentName:"",agentAvatarUrl:null,messages:[i],items:[]});continue}t.push({key:`sys-${U(i)}`,role:l,messages:[i],items:[],systemLabel:this.systemLabel(i)});continue}const f=t[t.length-1];f&&f.role===l&&(l==="ai"||f.agentName===(((s=i==null?void 0:i.author)==null?void 0:s.name)||""))?f.messages.push(i):t.push({key:`g-${U(i)}`,role:l,agentName:((a=i==null?void 0:i.author)==null?void 0:a.name)||"",agentAvatarUrl:((o=i==null?void 0:i.author)==null?void 0:o.avatar_url)||null,messages:[i],items:[]})}for(const i of t){if(i.role==="system")continue;const l=[];for(const f of i.messages)for(const _ of this.itemsOf(f))l.push(_);i.items=l}const n=[];for(const i of t){if(i.role!=="system"&&!i.items.length)continue;const l=n[n.length-1];if(l&&l.role!=="system"&&l.role===i.role&&(i.role==="ai"||l.agentName===i.agentName)){l.messages.push(...i.messages),l.items.push(...i.items);continue}n.push(i)}for(const i of n)i.role!=="system"&&(i.key=this.stableGroupKey(i.messages));return n},unreadGroupKey(){if(this.unreadAnchorId==null)return null;const t=this.unreadAnchorId,n=this.unreadBoundaryTs;for(const r of this.groups){if(r.role==="user"||r.role==="system"||!r.items.length)continue;const s=r.messages[0];if(!s)continue;const a=F(s.id);if(a!=null&&!(a<=t)&&!(n&&s.created_at&&s.created_at>n))return r.key}return null}},watch:{messages:{handler:"snapshotAndRestore",deep:!0},conversationId(t,n){t!==n&&(this._groupIdByMsgKey=null,this.silentFades=!1)},loadingMore(t){t||(this._pendingLoadMore=!1),t&&(this.silentFades=!0),this.snapshotAndRestore()},streamingActive:"snapshotAndRestore"},mounted(){this._lastSeenConvId=this.conversationId,this.scrollToBottom(),this._measureFrame=null,this._ro=new ResizeObserver(()=>this.scheduleMeasure()),this.$refs.scrollEl&&this._ro.observe(this.$refs.scrollEl),this.$nextTick(()=>this.measureRows())},beforeUnmount(){var t;(t=this._ro)==null||t.disconnect(),this._measureFrame&&cancelAnimationFrame(this._measureFrame)},updated(){this.scheduleMeasure()},methods:{messageKey:U,stableGroupKey(t){this._groupIdByMsgKey||(this._groupIdByMsgKey=new Map,this._groupIdCounter=0);const n=this._groupIdByMsgKey;let r=null;for(const s of t){const a=U(s);if(a&&n.has(a)){r=n.get(a);break}}r==null&&(r=++this._groupIdCounter);for(const s of t){const a=U(s);a&&n.set(a,r)}return`g-${r}`},isAtBottom(t){return t.scrollHeight-t.scrollTop-t.clientHeight<=eo},onScroll(){const t=this.$refs.scrollEl;t&&(this.loadingMore||!this.hasMore||this._pendingLoadMore||t.scrollTop<=to&&(this._pendingLoadMore=!0,this.$emit("load-more")))},snapshotAndRestore(){const t=this.$refs.scrollEl;if(!t||this._scrollSnap)return;const n=this._lastSeenConvId!==this.conversationId;this._lastSeenConvId=this.conversationId;const r=this.isAtBottom(t);let s=null;if(!n&&!r){const o=this.pickAnchor(t);if(o!=null&&o.rowKey){const i=this.findRowByKey(t,o.rowKey);if(i){const l=t.getBoundingClientRect().top;s={rowKey:o.rowKey,relY:i.getBoundingClientRect().top-l}}}}const a={forceBottom:n,wasPinned:r,anchor:s};this._scrollSnap=a,this.$nextTick(()=>{if(this._scrollSnap=null,a.forceBottom||a.wasPinned){t.scrollTop=t.scrollHeight;return}if(!a.anchor)return;const o=()=>{const i=a.anchor,l=this.findRowByKey(t,i.rowKey);if(!l)return;const _=l.getBoundingClientRect().top-t.getBoundingClientRect().top-i.relY;Math.abs(_)>.5&&(t.scrollTop+=_)};o(),requestAnimationFrame(()=>{o(),requestAnimationFrame(o)})})},pickAnchor(t){const n=t.getBoundingClientRect().top,r=t.querySelectorAll(".wm-list__row[data-row-key]");let s=null;for(const a of r)if(s||(s=a),a.getBoundingClientRect().bottom>=n)return{rowKey:a.dataset.rowKey};return s?{rowKey:s.dataset.rowKey}:null},findRowByKey(t,n){if(!n)return null;const r=typeof CSS<"u"&&CSS.escape?CSS.escape(n):n.replace(/["\\]/g,"\\$&");return t.querySelector(`.wm-list__row[data-row-key="${r}"]`)},roleOf(t){var r,s;if((t==null?void 0:t.type)==="system"||((r=t==null?void 0:t.payload)==null?void 0:r.type)==="system")return"system";const n=(s=t==null?void 0:t.author)==null?void 0:s.type;return n==="user"?"user":n==="agent_human"?"human":"ai"},roleLabel(t){if(t.role==="human")return t.agentName||this.t("common.agent");const n=this.t("common.aiAssistant");return this.aiAgentName?`${this.aiAgentName} • ${n}`:n},itemsOf(t){var n;if(!t)return[];if(t.type==="system"&&((n=t==null?void 0:t.payload)==null?void 0:n.event)==="action_admin_pending")return[{message:t,partKey:"main",renderAs:"admin-pending",kind:{top:"bubble",bottom:"bubble"}}];if(t.type==="action"&&t.payload&&t.payload.state!=="pending"){const r=[{message:t,partKey:"main",renderAs:"action",kind:{top:"bubble",bottom:"bubble"}}];return this.actionArtifact(t)&&r.push({message:t,partKey:"artifact",renderAs:"artifact-of-action",kind:{top:"card",bottom:"card"}}),r}return this.artifactOf(t)?[{message:t,partKey:"main",renderAs:"artifact",kind:{top:"card",bottom:"card"}}]:t.text_md||this.attachmentsOf(t).length?[{message:t,partKey:"main",renderAs:"bubble",kind:{top:"bubble",bottom:"bubble"}}]:[]},cornersFor(t,n){var P,j,z;const r=t.items,s=(P=r[n])==null?void 0:P.kind,a=(j=r[n-1])==null?void 0:j.kind,o=(z=r[n+1])==null?void 0:z.kind,i=t.role==="user",l=14,f=4,_=a==null?void 0:a.bottom,v=o==null?void 0:o.top,B=this.widthByKey[this.rowKeyOf(t,n)],S=this.widthByKey[this.rowKeyOf(t,n-1)],E=this.widthByKey[this.rowKeyOf(t,n+1)],L=.5,C=(I,q,R)=>I!=null&&B!=null?I+L>=B:q===R||q==="card"&&R==="bubble";let x=l,A=l,O=l,D=l;return i?(_&&(A=f),(v||!o)&&(O=f),_&&C(S,_,s==null?void 0:s.top)&&(x=f),v&&C(E,v,s==null?void 0:s.bottom)&&(D=f)):(_&&(x=f),(v||!o)&&(D=f),_&&C(S,_,s==null?void 0:s.top)&&(A=f),v&&C(E,v,s==null?void 0:s.bottom)&&(O=f)),{tl:x,tr:A,br:O,bl:D}},cornersStyle(t,n){if(t.items.length<2)return null;const r=this.cornersFor(t,n);return{"--wm-r-tl":`${r.tl}px`,"--wm-r-tr":`${r.tr}px`,"--wm-r-br":`${r.br}px`,"--wm-r-bl":`${r.bl}px`}},rowKeyOf(t,n){var s;const r=(s=t==null?void 0:t.items)==null?void 0:s[n];return r?`${U(r.message)}-${r.partKey}`:""},scheduleMeasure(){this._measureFrame||(this._measureFrame=requestAnimationFrame(()=>{this._measureFrame=null,this.measureRows()}))},measureRows(){const t=this.$refs.scrollEl;if(!t)return;const n={};for(const o of t.querySelectorAll(".wm-list__row[data-row-key]")){const i=o.dataset.rowKey;if(!i)continue;const l=o.querySelector(".wm-bubble, .wm-result, .wm-art, .wm-list__body");if(!l)continue;const f=l.getBoundingClientRect().width;f>0&&(n[i]=f)}const r=this.widthByKey,s=Object.keys(r),a=Object.keys(n);if(s.length===a.length){let o=!0;for(const i of a)if(Math.abs((r[i]??0)-n[i])>.5){o=!1;break}if(o)return}this.widthByKey=Object.freeze(n)},lastTimeOf(t){const n=t.items[t.items.length-1],r=(n==null?void 0:n.message)||t.messages[t.messages.length-1];if(!(r!=null&&r.created_at))return"";try{return ce(new Date(r.created_at),W(this.wmLocale()))}catch{return""}},hasTrailingOverlay(t){if(!t.messages.length)return!1;const n=t.messages[t.messages.length-1],r=t.items[t.items.length-1];return!!n&&(r==null?void 0:r.message)!==n},attachmentsOf(t){var r;const n=(r=t==null?void 0:t.payload)==null?void 0:r.attachments;return Array.isArray(n)?n:[]},artifactOf(t){var r;const n=(r=t==null?void 0:t.metadata)==null?void 0:r.artifact;return!n||typeof n!="object"||typeof n.kind!="string"?null:n},actionLabel(t){var n;return((n=t==null?void 0:t.payload)==null?void 0:n.name)||(t==null?void 0:t.text_md)||this.t("common.action")},actionDetail(t){var r,s,a,o,i,l;const n=t==null?void 0:t.payload;return n?n.state==="success"?((r=n.success)==null?void 0:r.summary)||((a=(s=n.success)==null?void 0:s.metadata)==null?void 0:a.description)||"":n.state==="rejected"?((o=n.rejected)==null?void 0:o.reason)||this.t("action.rejectedByUser"):n.state==="failure"&&(((i=n.failure)==null?void 0:i.summary)||((l=n.failure)==null?void 0:l.error))||"":""},actionArtifact(t){var r,s;const n=(s=(r=t==null?void 0:t.payload)==null?void 0:r.success)==null?void 0:s.artifact;return!n||typeof n!="object"||typeof n.kind!="string"?null:n},systemLabel(t){var a,o,i;const n=(a=t==null?void 0:t.payload)==null?void 0:a.event,r=Zr[n],s=((o=t==null?void 0:t.metadata)==null?void 0:o.agent_name)||((i=t==null?void 0:t.author)==null?void 0:i.name)||this.t("messageList.anAgent");return r?this.t(r,{name:s}):(t==null?void 0:t.text_md)||this.t("messageList.conversationUpdate")},scrollToBottom(){const t=this.$refs.scrollEl;t&&(t.scrollTop=t.scrollHeight)}}},ro={key:0,class:"wm-list__loadMore",role:"status","aria-live":"polite"},oo={class:"wm-list__loadMore-lbl"},ao={key:1,class:"wm-list__historyEnd"},so={key:2,class:"wm-list__sep"},io={class:"wm-list__sep-label"},lo={key:0,class:"wm-list__sep wm-list__sep--unread"},co={class:"wm-list__sep-label wm-list__sep-label--unread"},uo={key:0,class:"wm-list__sysep"},mo={class:"wm-list__sysep-label"},ho=["data-row-key"],fo={key:0,class:"wm-list__avatarSlot"},po={key:5,class:"wm-list__body"},go={key:0},_o={key:1,"aria-hidden":"true"},yo={key:2},vo={key:3,class:"wm-list__row wm-list__row--ai fade-up"},ko={class:"wm-list__avatarSlot"};function wo(t,n,r,s,a,o){const i=e.resolveComponent("AIAvatar"),l=e.resolveComponent("HumanAvatar"),f=e.resolveComponent("ActionResult"),_=e.resolveComponent("ArtifactRenderer"),v=e.resolveComponent("Bubble"),B=e.resolveComponent("AttachmentPreview"),S=e.resolveComponent("Typing");return e.openBlock(),e.createElementBlock("div",{ref:"scrollEl",class:e.normalizeClass(["wm-list",{"wm-list--silent":a.silentFades}]),onScrollPassive:n[0]||(n[0]=(...E)=>o.onScroll&&o.onScroll(...E))},[r.loadingMore?(e.openBlock(),e.createElementBlock("div",ro,[n[1]||(n[1]=e.createElementVNode("span",{class:"wm-list__loadMore-spinner","aria-hidden":"true"},null,-1)),e.createElementVNode("span",oo,e.toDisplayString(o.t("messageList.loadingHistory")),1)])):o.historyExhausted?(e.openBlock(),e.createElementBlock("div",ao,e.toDisplayString(o.t("messageList.conversationStart")),1)):e.createCommentVNode("",!0),r.dateLabel?(e.openBlock(),e.createElementBlock("div",so,[n[2]||(n[2]=e.createElementVNode("div",{class:"wm-list__line"},null,-1)),e.createElementVNode("span",io,e.toDisplayString(r.dateLabel),1),n[3]||(n[3]=e.createElementVNode("div",{class:"wm-list__line"},null,-1))])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.groups,(E,L)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:E.key},[E.key===o.unreadGroupKey?(e.openBlock(),e.createElementBlock("div",lo,[n[4]||(n[4]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--unread"},null,-1)),e.createElementVNode("span",co,e.toDisplayString(o.t("messageList.unread")),1),n[5]||(n[5]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--unread"},null,-1))])):e.createCommentVNode("",!0),E.role==="system"||E.items.length?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["wm-list__group","wm-list__group--"+E.role])},[E.role==="system"?(e.openBlock(),e.createElementBlock("div",uo,[n[6]||(n[6]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--strong"},null,-1)),e.createElementVNode("span",mo,e.toDisplayString(E.systemLabel),1),n[7]||(n[7]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--strong"},null,-1))])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(E.items,(C,x)=>(e.openBlock(),e.createElementBlock("div",{key:`${o.messageKey(C.message)}-${C.partKey}`,"data-row-key":`${o.messageKey(C.message)}-${C.partKey}`,class:e.normalizeClass(["wm-list__row fade-up",["wm-list__row--"+E.role,{"is-pending":C.message._pending,"is-failed":C.message._failed}]]),style:e.normalizeStyle(o.cornersStyle(E,x))},[E.role!=="user"?(e.openBlock(),e.createElementBlock("div",fo,[x===E.items.length-1?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[E.role==="ai"?(e.openBlock(),e.createBlock(i,{key:0,size:26,tail:!0,name:r.aiAgentName,"image-url":r.aiAgentAvatarUrl},null,8,["name","image-url"])):(e.openBlock(),e.createBlock(l,{key:1,name:E.agentName,"avatar-url":E.agentAvatarUrl,size:26,tail:!0},null,8,["name","avatar-url"]))],64)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),C.renderAs==="action"?(e.openBlock(),e.createBlock(f,{key:1,state:C.message.payload.state,label:o.actionLabel(C.message),detail:o.actionDetail(C.message)},null,8,["state","label","detail"])):C.renderAs==="admin-pending"?(e.openBlock(),e.createBlock(f,{key:2,state:"awaiting",label:o.t("messageList.approvalRequestSent"),detail:C.message.text_md||""},null,8,["label","detail"])):C.renderAs==="artifact-of-action"?(e.openBlock(),e.createBlock(_,{key:3,artifact:o.actionArtifact(C.message)},null,8,["artifact"])):C.renderAs==="artifact"?(e.openBlock(),e.createBlock(_,{key:4,artifact:o.artifactOf(C.message)},null,8,["artifact"])):(e.openBlock(),e.createElementBlock("div",po,[C.message.text_md?(e.openBlock(),e.createBlock(v,{key:0,role:E.role,text:C.message.text_md},null,8,["role","text"])):e.createCommentVNode("",!0),o.attachmentsOf(C.message).length?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["wm-list__atts",{"wm-list__atts--align-end":E.role==="user"}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.attachmentsOf(C.message),(A,O)=>(e.openBlock(),e.createBlock(B,{key:`${o.messageKey(C.message)}-att-${O}`,attachment:A},null,8,["attachment"]))),128))],2)):e.createCommentVNode("",!0)]))],14,ho))),128)),(E.role!=="user"||o.lastTimeOf(E))&&!o.hasTrailingOverlay(E)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["wm-list__meta",{"wm-list__meta--right":E.role==="user"}])},[E.role!=="user"?(e.openBlock(),e.createElementBlock("span",go,e.toDisplayString(o.roleLabel(E)),1)):e.createCommentVNode("",!0),E.role!=="user"&&o.lastTimeOf(E)?(e.openBlock(),e.createElementBlock("span",_o,"·")):e.createCommentVNode("",!0),o.lastTimeOf(E)?(e.openBlock(),e.createElementBlock("span",yo,e.toDisplayString(o.lastTimeOf(E)),1)):e.createCommentVNode("",!0)],2)):e.createCommentVNode("",!0)],64))],2)):e.createCommentVNode("",!0)],64))),128)),r.streamingActive?(e.openBlock(),e.createElementBlock("div",vo,[e.createElementVNode("div",ko,[e.createVNode(i,{size:26,tail:!0,name:r.aiAgentName,"image-url":r.aiAgentAvatarUrl},null,8,["name","image-url"])]),e.createVNode(S)])):e.createCommentVNode("",!0)],34)}const Pe=N(no,[["render",wo],["__scopeId","data-v-d769b193"]]),Q=typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function",ne=typeof window<"u"&&typeof window.MediaRecorder<"u";function je(){return ne&&["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm","video/mp4"].find(n=>{var r,s;return(s=(r=window.MediaRecorder).isTypeSupported)==null?void 0:s.call(r,n)})||""}function ze({audio:t}){return{video:!0,audio:!!t,selfBrowserSurface:"include",surfaceSwitching:"include",systemAudio:t?"include":"exclude"}}function bo(t){return t?t.startsWith("image/")?"image":t.startsWith("video/")?"video":"file":"file"}async function qe(){if(!Q)return null;let t;try{t=await navigator.mediaDevices.getDisplayMedia(ze({audio:!1}))}catch(n){return(n==null?void 0:n.name)!=="NotAllowedError"&&console.error("[media] screenshot picker",n),null}try{return await Eo(t)}catch(n){return console.error("[media] screenshot capture",n),null}finally{t.getTracks().forEach(n=>{n.stop()})}}async function Eo(t){const n=document.createElement("video");n.muted=!0,n.playsInline=!0,n.srcObject=t,await n.play(),await new Promise(l=>requestAnimationFrame(l));const r=n.videoWidth||1280,s=n.videoHeight||720,a=document.createElement("canvas");a.width=r,a.height=s,a.getContext("2d").drawImage(n,0,0,r,s);const o=await new Promise((l,f)=>{a.toBlob(_=>_?l(_):f(new Error("toBlob failed")),"image/png")}),i=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19);return new File([o],`capture-${i}.png`,{type:"image/png"})}async function He(t={}){var _;if(!Q||!ne)return null;let n;try{n=await navigator.mediaDevices.getDisplayMedia(ze({audio:!0}))}catch(v){return(v==null?void 0:v.name)!=="NotAllowedError"&&console.error("[media] record picker",v),null}const r=je();let s;try{s=r?new window.MediaRecorder(n,{mimeType:r}):new window.MediaRecorder(n)}catch(v){return console.error("[media] recorder init",v),n.getTracks().forEach(B=>{B.stop()}),null}const a=[];let o=null,i=!1;s.addEventListener("dataavailable",v=>{v.data&&v.data.size>0&&a.push(v.data)}),s.addEventListener("stop",()=>{var v,B;if(o&&clearInterval(o),n.getTracks().forEach(S=>{S.stop()}),a.length){const S=s.mimeType||r||"video/webm",E=new Blob(a,{type:S}),L=/mp4/.test(S)?"mp4":"webm",C=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),x=new File([E],`ecran-${C}.${L}`,{type:S});(v=t.onfinalize)==null||v.call(t,x)}else(B=t.oncancel)==null||B.call(t)}),n.getVideoTracks().forEach(v=>{v.addEventListener("ended",()=>l(),{once:!0})});function l(){if(!i&&(i=!0,s.state!=="inactive"))try{s.stop()}catch(v){console.error("[media] recorder stop",v)}}try{s.start(1e3)}catch(v){return console.error("[media] recorder start",v),n.getTracks().forEach(B=>{B.stop()}),null}(_=t.onstart)==null||_.call(t);const f=Date.now();return o=setInterval(()=>{var v;(v=t.ontick)==null||v.call(t,Date.now()-f)},500),{stop:l,get state(){return s.state}}}const Co=[{action:"file",labelKey:"composer.attachFile",path:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"},{action:"screenshot",labelKey:"composer.screenshot",path:"M23 19a2 2 0 01-2 2H3a2 2 0 01-2-2V8a2 2 0 012-2h4l2-3h6l2 3h4a2 2 0 012 2z M12 17a4 4 0 100-8 4 4 0 000 8z"},{action:"record",labelKey:"composer.recordScreen",path:"M23 7l-7 5 7 5V7z M1 5a2 2 0 012-2h12a2 2 0 012 2v14a2 2 0 01-2 2H3a2 2 0 01-2-2V5z"}],Bo={name:"WmComposer",inject:{t:{default:()=>V()}},props:{modelValue:{type:String,default:""},placeholder:{type:String,default:"Écrivez votre message…"},disabled:{type:Boolean,default:!1},attachLabel:{type:String,default:"Joindre"}},emits:["update:modelValue","send","attach"],data(){return{local:this.modelValue,attachOpen:!1,recording:!1,recordingElapsed:0,recorder:null}},computed:{canSend(){return!this.disabled&&!!this.local.trim()},attachItems(){return Co.map(t=>({...t,label:this.t(t.labelKey),disabled:t.action==="screenshot"&&!Q||t.action==="record"&&(!Q||!ne)}))},recordingElapsedLabel(){const t=Math.floor(this.recordingElapsed/1e3),n=Math.floor(t/60),r=t%60;return`${n}:${r.toString().padStart(2,"0")}`}},watch:{modelValue(t){t!==this.local&&(this.local=t,this.$nextTick(()=>this.autosize()))},local(t){this.$emit("update:modelValue",t)}},mounted(){this.autosize()},beforeUnmount(){if(this.recorder)try{this.recorder.stop()}catch{}},methods:{focus(){const t=this.$refs.inputEl;if(!(!t||this.disabled))try{t.focus({preventScroll:!0})}catch{t.focus()}},onSubmit(){if(!this.canSend)return;const t=this.local.trim();this.local="",this.$emit("send",t),this.$nextTick(()=>this.autosize())},onKeydown(t){t.key==="Enter"&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey&&!t.isComposing&&(t.preventDefault(),this.onSubmit())},autosize(){const t=this.$refs.inputEl;t&&(t.style.height="auto",t.style.height=`${t.scrollHeight}px`)},onFile(t){const n=Array.from(t.target.files||[]);for(const r of n)this.$emit("attach",r);t.target.value=""},onAttachAction(t){this.attachOpen=!1,t==="file"?this.pickFile():t==="screenshot"?this.captureScreenshot():t==="record"&&this.startRecording()},pickFile(){var t;(t=this.$refs.fileEl)==null||t.click()},async captureScreenshot(){if(this.disabled)return;const t=await qe();t&&this.$emit("attach",t)},async startRecording(){if(this.recording||this.disabled)return;this.recordingElapsed=0;const t=await He({onstart:()=>{this.recording=!0},ontick:n=>{this.recordingElapsed=n},onfinalize:n=>{this.$emit("attach",n),this.recording=!1,this.recordingElapsed=0,this.recorder=null},oncancel:()=>{this.recording=!1,this.recordingElapsed=0,this.recorder=null}});t&&(this.recorder=t)},stopRecording(){if(this.recorder)try{this.recorder.stop()}catch(t){console.error("[composer] stop recording",t)}}}},No={class:"wm-compose-wrap"},So={key:0,class:"wm-rec"},Ao={class:"wm-rec__lbl"},Vo={key:1,class:"wm-compose__menu",role:"menu"},Mo=["disabled","onClick"],To={class:"wm-compose__menuIcon"},xo={viewBox:"0 0 24 24",width:"14",height:"14","aria-hidden":"true"},Lo=["d"],Oo=["placeholder","disabled"],Do={class:"wm-compose__actions"},Io=["title","aria-label","disabled"],Ro=["disabled","aria-label"];function Fo(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",No,[a.recording?(e.openBlock(),e.createElementBlock("div",So,[n[8]||(n[8]=e.createElementVNode("span",{class:"wm-rec__dot","aria-hidden":"true"},null,-1)),e.createElementVNode("span",Ao,e.toDisplayString(o.t("composer.recording",{time:o.recordingElapsedLabel})),1),e.createElementVNode("button",{type:"button",class:"wm-rec__stop",onClick:n[0]||(n[0]=(...i)=>o.stopRecording&&o.stopRecording(...i))},e.toDisplayString(o.t("composer.stop")),1)])):e.createCommentVNode("",!0),e.createElementVNode("form",{class:e.normalizeClass(["wm-compose",{"has-attach":a.attachOpen}]),onSubmit:n[7]||(n[7]=e.withModifiers((...i)=>o.onSubmit&&o.onSubmit(...i),["prevent"]))},[e.createElementVNode("input",{ref:"fileEl",type:"file",hidden:"",multiple:"",onChange:n[1]||(n[1]=(...i)=>o.onFile&&o.onFile(...i))},null,544),a.attachOpen?(e.openBlock(),e.createElementBlock("div",{key:0,class:"wm-compose__overlay",onClick:n[2]||(n[2]=i=>a.attachOpen=!1)})):e.createCommentVNode("",!0),a.attachOpen?(e.openBlock(),e.createElementBlock("div",Vo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.attachItems,i=>(e.openBlock(),e.createElementBlock("button",{key:i.action,type:"button",class:"wm-compose__menuItem",disabled:i.disabled,onClick:l=>o.onAttachAction(i.action)},[e.createElementVNode("span",To,[(e.openBlock(),e.createElementBlock("svg",xo,[e.createElementVNode("path",{d:i.path,stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round",fill:"none"},null,8,Lo)]))]),e.createElementVNode("span",null,e.toDisplayString(i.label),1)],8,Mo))),128))])):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("textarea",{ref:"inputEl","onUpdate:modelValue":n[3]||(n[3]=i=>a.local=i),class:"wm-compose__input",rows:"3",placeholder:r.placeholder,disabled:r.disabled,onKeydown:n[4]||(n[4]=(...i)=>o.onKeydown&&o.onKeydown(...i)),onInput:n[5]||(n[5]=(...i)=>o.autosize&&o.autosize(...i))},null,40,Oo),[[e.vModelText,a.local]]),e.createElementVNode("div",Do,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["wm-compose__icon",{"is-open":a.attachOpen}]),title:r.attachLabel,"aria-label":r.attachLabel,disabled:a.recording,onClick:n[6]||(n[6]=i=>a.attachOpen=!a.attachOpen)},[...n[9]||(n[9]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"})],-1)])],10,Io),e.createElementVNode("button",{type:"submit",class:e.normalizeClass(["wm-compose__send",{"is-empty":!o.canSend}]),disabled:!o.canSend,"aria-label":o.t("composer.send")},[...n[10]||(n[10]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})],-1)])],10,Ro)])],34)])}const $e=N(Bo,[["render",Fo],["__scopeId","data-v-aa81dbb8"]]),Uo={name:"WmSuggestionChips",props:{items:{type:Array,default:()=>[]},baseDelay:{type:Number,default:360},stepDelay:{type:Number,default:90}},emits:["select"],computed:{batchKey(){return this.items.map(t=>(t==null?void 0:t.label)||(t==null?void 0:t.text)||"").join("§")}}},Po=["onClick"];function jo(t,n,r,s,a,o){return r.items.length?(e.openBlock(),e.createElementBlock("div",{key:o.batchKey,class:"wm-chips"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.items,(i,l)=>(e.openBlock(),e.createElementBlock("button",{key:l,type:"button",class:"wm-chip",style:e.normalizeStyle({animationDelay:r.baseDelay+l*r.stepDelay+"ms"}),onClick:f=>t.$emit("select",i)},e.toDisplayString(i.label),13,Po))),128))])):e.createCommentVNode("",!0)}const Ke=N(Uo,[["render",jo],["__scopeId","data-v-47ad8085"]]),zo={name:"WmApprovalCard",components:{AIAvatar:G},inject:{t:{default:()=>V()}},props:{action:{type:String,required:!0},detail:{type:String,default:""},callbacks:{type:Array,default:()=>[]},agentName:{type:String,default:""},agentAvatarUrl:{type:String,default:null}},emits:["callback"],computed:{approveCallback(){return this.callbacks.find(t=>t.id==="approve"||t.style==="primary")||this.callbacks[0]},rejectCallback(){return this.callbacks.find(t=>t.id==="reject"||t.style==="danger"||t.style==="neutral")||(this.callbacks.length>1?this.callbacks[1]:null)},approveId(){var t;return(t=this.approveCallback)==null?void 0:t.id},rejectId(){var t;return(t=this.rejectCallback)==null?void 0:t.id},approveLabel(){var t;return((t=this.approveCallback)==null?void 0:t.label)||this.t("approval.approve")},rejectLabel(){var t;return((t=this.rejectCallback)==null?void 0:t.label)||this.t("approval.reject")}}},qo={class:"wm-approval"},Ho={class:"wm-approval__head"},$o={class:"wm-approval__icon"},Ko={class:"wm-approval__main"},Wo={class:"wm-approval__title"},Go={key:0,class:"wm-approval__detail"},Yo={class:"wm-approval__actions"};function Jo(t,n,r,s,a,o){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",qo,[e.createElementVNode("div",Ho,[e.createElementVNode("div",$o,[e.createVNode(i,{size:24,name:r.agentName,"image-url":r.agentAvatarUrl},null,8,["name","image-url"])]),e.createElementVNode("div",Ko,[e.createElementVNode("div",Wo,e.toDisplayString(r.action),1),r.detail?(e.openBlock(),e.createElementBlock("div",Go,e.toDisplayString(r.detail),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",Yo,[o.rejectId?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-approval__btn wm-approval__btn--neutral",onClick:n[0]||(n[0]=l=>t.$emit("callback",o.rejectId))},e.toDisplayString(o.rejectLabel),1)):e.createCommentVNode("",!0),o.approveId?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"wm-approval__btn wm-approval__btn--primary",onClick:n[1]||(n[1]=l=>t.$emit("callback",o.approveId))},e.toDisplayString(o.approveLabel),1)):e.createCommentVNode("",!0)])])}const We=N(zo,[["render",Jo],["__scopeId","data-v-a2bed37e"]]);let _e=0;const Qo=new Set(["text","textarea","number","boolean","select","multiselect","date"]),Xo={name:"WmFormCard",components:{AIAvatar:G},inject:{t:{default:()=>V()}},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 _e+=1,{_uid:_e,values:{},busy:!1,error:""}},computed:{normalizedFields(){var n;return(Array.isArray((n=this.form)==null?void 0:n.fields)?this.form.fields:[]).filter(r=>!(!(r!=null&&r.key)||!(r!=null&&r.label)||!Qo.has(r==null?void 0:r.type)||(r.type==="select"||r.type==="multiselect")&&(!Array.isArray(r.options)||r.options.length===0)))}},created(){this.resetValues()},methods:{resetValues(){const t=this.initialValues&&typeof this.initialValues=="object"?this.initialValues:{},n={};for(const r of this.normalizedFields){if(t[r.key]!==void 0){n[r.key]=t[r.key];continue}r.type==="boolean"?n[r.key]=!1:r.type==="multiselect"?n[r.key]=[]:n[r.key]=""}this.values=n,this.error=""},toggleMulti(t,n,r){const s=Array.isArray(this.values[t])?this.values[t].slice():[],a=s.indexOf(n);r&&a===-1?s.push(n):!r&&a!==-1&&s.splice(a,1),this.values={...this.values,[t]:s}},validate(){for(const t of this.normalizedFields){if(!t.required)continue;const n=this.values[t.key];if(t.type!=="boolean"){if(t.type==="multiselect"){if(!Array.isArray(n)||n.length===0)return this.t("form.fieldRequired",{label:t.label});continue}if(n==null||n==="")return this.t("form.fieldRequired",{label:t.label})}}return""},async onSubmit(){if(this.readOnly||this.busy)return;const t=this.validate();if(t){this.error=t;return}this.error="",this.busy=!0;try{await this.$emit("submit",{values:this.values})}finally{this.busy=!1}}}},Zo={class:"wm-form"},ea={class:"wm-form__head"},ta={class:"wm-form__icon"},na={class:"wm-form__main"},ra={class:"wm-form__title"},oa={key:0,class:"wm-form__detail"},aa=["for"],sa={key:0,class:"wm-form__req","aria-hidden":"true"},ia=["id","onUpdate:modelValue","placeholder","required","disabled"],la=["id","onUpdate:modelValue","placeholder","required","disabled"],ca=["id","onUpdate:modelValue","placeholder","required","disabled"],da=["id","onUpdate:modelValue","required","disabled"],ua={key:4,class:"wm-form__bool"},ma=["id","onUpdate:modelValue","disabled"],ha=["id","onUpdate:modelValue","required","disabled"],fa={value:"",disabled:""},pa=["value"],ga={key:6,class:"wm-form__multi"},_a=["value","checked","disabled","onChange"],ya={key:0,class:"wm-form__err"},va=["disabled"],ka={key:0,class:"wm-form__spinner","aria-hidden":"true"},wa={key:2,class:"wm-form__doneLbl"};function ba(t,n,r,s,a,o){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",Zo,[e.createElementVNode("div",ea,[e.createElementVNode("div",ta,[e.createVNode(i,{size:24,name:r.agentName,"image-url":r.agentAvatarUrl},null,8,["name","image-url"])]),e.createElementVNode("div",na,[e.createElementVNode("div",ra,e.toDisplayString(r.form.title||o.t("form.title")),1),r.form.description?(e.openBlock(),e.createElementBlock("div",oa,e.toDisplayString(r.form.description),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("form",{class:"wm-form__body",onSubmit:n[0]||(n[0]=e.withModifiers((...l)=>o.onSubmit&&o.onSubmit(...l),["prevent"]))},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.normalizedFields,l=>(e.openBlock(),e.createElementBlock("div",{key:l.key,class:"wm-form__field"},[e.createElementVNode("label",{for:`wm-f-${a._uid}-${l.key}`,class:"wm-form__label"},[e.createTextVNode(e.toDisplayString(l.label),1),l.required?(e.openBlock(),e.createElementBlock("span",sa,"*")):e.createCommentVNode("",!0)],8,aa),l.type==="text"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":f=>a.values[l.key]=f,type:"text",class:"wm-form__input",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||a.busy},null,8,ia)),[[e.vModelText,a.values[l.key]]]):l.type==="textarea"?e.withDirectives((e.openBlock(),e.createElementBlock("textarea",{key:1,id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":f=>a.values[l.key]=f,class:"wm-form__textarea",rows:"3",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||a.busy},null,8,la)),[[e.vModelText,a.values[l.key]]]):l.type==="number"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:2,id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":f=>a.values[l.key]=f,type:"number",class:"wm-form__input",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||a.busy},null,8,ca)),[[e.vModelText,a.values[l.key],void 0,{number:!0}]]):l.type==="date"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:3,id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":f=>a.values[l.key]=f,type:"date",class:"wm-form__input",required:l.required,disabled:r.readOnly||a.busy},null,8,da)),[[e.vModelText,a.values[l.key]]]):l.type==="boolean"?(e.openBlock(),e.createElementBlock("label",ua,[e.withDirectives(e.createElementVNode("input",{id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":f=>a.values[l.key]=f,type:"checkbox",disabled:r.readOnly||a.busy},null,8,ma),[[e.vModelCheckbox,a.values[l.key]]]),e.createElementVNode("span",null,e.toDisplayString(l.placeholder||o.t("common.yes")),1)])):l.type==="select"?e.withDirectives((e.openBlock(),e.createElementBlock("select",{key:5,id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":f=>a.values[l.key]=f,class:"wm-form__select",required:l.required,disabled:r.readOnly||a.busy},[e.createElementVNode("option",fa,e.toDisplayString(l.placeholder||o.t("form.choose")),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.options,f=>(e.openBlock(),e.createElementBlock("option",{key:f.value,value:f.value},e.toDisplayString(f.label),9,pa))),128))],8,ha)),[[e.vModelSelect,a.values[l.key]]]):l.type==="multiselect"?(e.openBlock(),e.createElementBlock("div",ga,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.options,f=>(e.openBlock(),e.createElementBlock("label",{key:f.value,class:"wm-form__multiItem"},[e.createElementVNode("input",{type:"checkbox",value:f.value,checked:Array.isArray(a.values[l.key])&&a.values[l.key].includes(f.value),disabled:r.readOnly||a.busy,onChange:_=>o.toggleMulti(l.key,f.value,_.target.checked)},null,40,_a),e.createElementVNode("span",null,e.toDisplayString(f.label),1)]))),128))])):e.createCommentVNode("",!0)]))),128)),a.error?(e.openBlock(),e.createElementBlock("div",ya,e.toDisplayString(a.error),1)):e.createCommentVNode("",!0),r.readOnly?(e.openBlock(),e.createElementBlock("div",wa,e.toDisplayString(o.t("form.responseSent")),1)):(e.openBlock(),e.createElementBlock("button",{key:1,type:"submit",class:"wm-form__submit",disabled:a.busy},[a.busy?(e.openBlock(),e.createElementBlock("span",ka)):e.createCommentVNode("",!0),e.createElementVNode("span",null,e.toDisplayString(a.busy?o.t("common.sending"):r.form.submit_label||o.t("common.send")),1)],8,va))],32)])}const Ge=N(Xo,[["render",ba],["__scopeId","data-v-fe65cc56"]]),Ea={name:"WmFeedback",inject:{t:{default:()=>V()}},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})}}},Ca={class:"wm-fb"},Ba={class:"wm-fb__title"},Na={class:"wm-fb__sub"},Sa={class:"wm-fb__row"},Aa=["onClick"],Va={class:"wm-fb__emoji"},Ma={class:"wm-fb__label"},Ta=["disabled"],xa={key:1,class:"wm-fb__done"},La={class:"wm-fb__doneTitle"},Oa={class:"wm-fb__doneSub"};function Da(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",Ca,[r.done?(e.openBlock(),e.createElementBlock("div",xa,[n[1]||(n[1]=e.createElementVNode("div",{class:"wm-fb__check"},[e.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#fff","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M20 6L9 17l-5-5"})])],-1)),e.createElementVNode("div",La,e.toDisplayString(o.t("feedback.doneTitle")),1),e.createElementVNode("div",Oa,e.toDisplayString(o.t("feedback.doneSubtitle")),1)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("div",Ba,e.toDisplayString(o.t("feedback.question")),1),e.createElementVNode("div",Na,e.toDisplayString(o.t("feedback.subtitle")),1),e.createElementVNode("div",Sa,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.options,i=>(e.openBlock(),e.createElementBlock("button",{key:i.v,type:"button",class:e.normalizeClass(["wm-fb__opt",{"is-selected":a.sel===i.v}]),onClick:l=>a.sel=i.v},[e.createElementVNode("span",Va,e.toDisplayString(i.e),1),e.createElementVNode("span",Ma,e.toDisplayString(i.l),1)],10,Aa))),128))]),e.createElementVNode("button",{type:"button",class:"wm-fb__send",disabled:!a.sel||r.busy,onClick:n[0]||(n[0]=(...i)=>o.onSend&&o.onSend(...i))},e.toDisplayString(r.busy?o.t("common.sending"):o.t("feedback.submit")),9,Ta)],64))])}const Ye=N(Ea,[["render",Da],["__scopeId","data-v-9b630564"]]),Ia={name:"WmMoreMenu",inject:{t:{default:()=>V()}},props:{canRename:{type:Boolean,default:!0},canExport:{type:Boolean,default:!0},soundEnabled:{type:Boolean,default:!0},browserNotifEnabled:{type:Boolean,default:!1},statusUrl:{type:String,default:""},helpUrl:{type:String,default:""}},emits:["close","action","sound-toggle","browser-notif-toggle"],data(){return{soundOn:this.soundEnabled,browserNotifOn:this.browserNotifEnabled}},watch:{soundEnabled(t){this.soundOn=!!t},browserNotifEnabled(t){this.browserNotifOn=!!t}},methods:{emit(t){this.$emit("action",t)},toggleSound(){this.soundOn=!this.soundOn,this.$emit("sound-toggle",this.soundOn)},toggleBrowserNotif(){this.browserNotifOn=!this.browserNotifOn,this.$emit("browser-notif-toggle",this.browserNotifOn)}}},Ra={class:"wm-mm"},Fa={class:"wm-mm__pop",role:"menu"},Ua={key:0,class:"wm-mm__section"},Pa={class:"wm-mm__label"},ja={class:"wm-mm__label"},za={key:1,class:"wm-mm__sep"},qa={class:"wm-mm__section"},Ha={class:"wm-mm__label"},$a={class:"wm-mm__label"},Ka={class:"wm-mm__section"},Wa={class:"wm-mm__label"},Ga={class:"wm-mm__label"};function Ya(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",Ra,[e.createElementVNode("div",{class:"wm-mm__scrim",onClick:n[0]||(n[0]=i=>t.$emit("close"))}),e.createElementVNode("div",Fa,[r.canRename||r.canExport?(e.openBlock(),e.createElementBlock("div",Ua,[r.canRename?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-mm__item",onClick:n[1]||(n[1]=i=>o.emit("rename"))},[n[7]||(n[7]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M12 20h9"}),e.createElementVNode("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})])],-1)),e.createElementVNode("span",Pa,e.toDisplayString(o.t("moreMenu.editTitle")),1)])):e.createCommentVNode("",!0),r.canExport?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"wm-mm__item",onClick:n[2]||(n[2]=i=>o.emit("export"))},[n[8]||(n[8]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M4 12v8a2 2 0 002 2h12a2 2 0 002-2v-8M16 6l-4-4-4 4M12 2v13"})])],-1)),e.createElementVNode("span",ja,e.toDisplayString(o.t("moreMenu.exportTranscript")),1),n[9]||(n[9]=e.createElementVNode("span",{class:"wm-mm__hint"},".txt",-1))])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),r.canRename||r.canExport?(e.openBlock(),e.createElementBlock("div",za)):e.createCommentVNode("",!0),e.createElementVNode("div",qa,[e.createElementVNode("button",{type:"button",class:"wm-mm__item",onClick:n[3]||(n[3]=(...i)=>o.toggleSound&&o.toggleSound(...i))},[n[11]||(n[11]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M11 5L6 9H2v6h4l5 4V5z"}),e.createElementVNode("path",{d:"M15.54 8.46a5 5 0 010 7.07M19.07 4.93a10 10 0 010 14.14"})])],-1)),e.createElementVNode("span",Ha,e.toDisplayString(o.t("moreMenu.sound")),1),e.createElementVNode("span",{class:e.normalizeClass(["wm-mm__toggle",{"wm-mm__toggle--on":a.soundOn}])},[...n[10]||(n[10]=[e.createElementVNode("span",{class:"wm-mm__knob"},null,-1)])],2)]),e.createElementVNode("button",{type:"button",class:"wm-mm__item",onClick:n[4]||(n[4]=(...i)=>o.toggleBrowserNotif&&o.toggleBrowserNotif(...i))},[n[13]||(n[13]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M15 17h5l-1.4-1.4A2 2 0 0118 14.2V11a6 6 0 10-12 0v3.2c0 .5-.2 1-.6 1.4L4 17h5m6 0a3 3 0 11-6 0"})])],-1)),e.createElementVNode("span",$a,e.toDisplayString(o.t("moreMenu.browserNotifications")),1),e.createElementVNode("span",{class:e.normalizeClass(["wm-mm__toggle",{"wm-mm__toggle--on":a.browserNotifOn}])},[...n[12]||(n[12]=[e.createElementVNode("span",{class:"wm-mm__knob"},null,-1)])],2)])]),n[16]||(n[16]=e.createElementVNode("div",{class:"wm-mm__sep"},null,-1)),e.createElementVNode("div",Ka,[r.statusUrl?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-mm__item",onClick:n[5]||(n[5]=i=>o.emit("status"))},[n[14]||(n[14]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zM10 6v4l3 2"})])],-1)),e.createElementVNode("span",Wa,e.toDisplayString(o.t("moreMenu.serviceStatus")),1)])):e.createCommentVNode("",!0),r.helpUrl?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"wm-mm__item",onClick:n[6]||(n[6]=i=>o.emit("help"))},[n[15]||(n[15]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M9 11a3 3 0 116 0c0 2-3 2-3 5M12 19h.01M12 22a10 10 0 110-20 10 10 0 010 20z"})])],-1)),e.createElementVNode("span",Ga,e.toDisplayString(o.t("moreMenu.helpCenter")),1)])):e.createCommentVNode("",!0)])])])}const Je=N(Ia,[["render",Ya],["__scopeId","data-v-76281e95"]]),Ja={name:"WmRenameDialog",inject:{t:{default:()=>V()}},props:{title:{type:String,default:""},initialValue:{type:String,default:""},placeholder:{type:String,default:""}},emits:["close","submit"],data(){return{value:this.initialValue||""}},computed:{canSubmit(){const t=(this.value||"").trim();return!!t&&t!==(this.initialValue||"").trim()}},mounted(){this.$nextTick(()=>{const t=this.$refs.input;if(t){t.focus();try{t.select()}catch{}}})},methods:{onSubmit(){this.canSubmit&&this.$emit("submit",this.value.trim())}}},Qa={class:"wm-dialog"},Xa={class:"wm-dialog__card",role:"dialog","aria-modal":"true"},Za={class:"wm-dialog__head"},es={class:"wm-dialog__title"},ts=["aria-label"],ns={class:"wm-dialog__body"},rs=["placeholder"],os={class:"wm-dialog__actions"},as=["disabled"];function ss(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",Qa,[e.createElementVNode("div",{class:"wm-dialog__scrim",onClick:n[0]||(n[0]=i=>t.$emit("close"))}),e.createElementVNode("div",Xa,[e.createElementVNode("div",Za,[e.createElementVNode("div",es,e.toDisplayString(r.title||o.t("rename.title")),1),e.createElementVNode("button",{type:"button",class:"wm-dialog__close","aria-label":o.t("common.close"),onClick:n[1]||(n[1]=i=>t.$emit("close"))},[...n[7]||(n[7]=[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,ts)]),e.createElementVNode("div",ns,[e.withDirectives(e.createElementVNode("input",{ref:"input","onUpdate:modelValue":n[2]||(n[2]=i=>a.value=i),type:"text",class:"wm-dialog__input",placeholder:r.placeholder||o.t("rename.placeholder"),maxlength:120,onKeydown:[n[3]||(n[3]=e.withKeys(e.withModifiers((...i)=>o.onSubmit&&o.onSubmit(...i),["prevent"]),["enter"])),n[4]||(n[4]=e.withKeys(e.withModifiers(i=>t.$emit("close"),["prevent"]),["esc"]))]},null,40,rs),[[e.vModelText,a.value]])]),e.createElementVNode("div",os,[e.createElementVNode("button",{type:"button",class:"wm-dialog__btn",onClick:n[5]||(n[5]=i=>t.$emit("close"))},e.toDisplayString(o.t("common.cancel")),1),e.createElementVNode("button",{type:"button",class:"wm-dialog__btn wm-dialog__btn--primary",disabled:!o.canSubmit,onClick:n[6]||(n[6]=(...i)=>o.onSubmit&&o.onSubmit(...i))},e.toDisplayString(o.t("common.save")),9,as)])])])}const is=N(Ja,[["render",ss],["__scopeId","data-v-6d5f94a8"]]),ye="ww-messenger-tokens",ls={name:"Messenger",components:{Launcher:Be,Header:Se,Onboarding:Te,MessageList:Pe,Composer:$e,SuggestionChips:Ke,ApprovalCard:We,FormCard:Ge,Feedback:Ye,MoreMenu:Je,RenameDialog:is},mixins:[dt,gt,_t,vt],provide(){return{signAttachmentFn:t=>{var n,r;return((r=(n=this.store)==null?void 0:n.signAttachment)==null?void 0:r.call(n,t))||null},t:(t,n)=>this.t(t,n),wmLocale:()=>this.locale}},props:{baseUrl:{type:String,default:be},widgetId:{type:String,default:""},token:{type:String,default:""},context:{type:Object,default:null},displayMode:{type:String,default:"floating"},devtools:{type:Boolean,default:!1},language:{type:String,default:""}},data(){return{transport:null,store:null,isOpen:!1,draft:"",busy:!1,bootError:null,pendingAttachments:[],feedbackBusy:!1,feedbackDone:!1,convOpenedAt:0,moreOpen:!1,renameDialogOpen:!1,draftConv:null,activeConvId:null,showOnboarding:!1,dismissedPeeks:{},floatHeight:0,floatRO:null}},computed:{isEditor(){return!!this.devtools},isEmbedded(){return this.displayMode==="embedded"},customerLanguage(){var r,s,a,o;const t=(r=this.s)==null?void 0:r.customer,n=t&&(t.language||((s=t.values)==null?void 0:s.language));return n||((o=(a=this.context)==null?void 0:a.customer)==null?void 0:o.language)||""},locale(){var t;return te(this.language||this.customerLanguage||((t=this.widget)==null?void 0:t.default_language)||"")},translator(){return V(this.locale)},error(){var t;return this.bootError||((t=this.s)==null?void 0:t.error)||null},canBoot(){return!!(this.baseUrl&&this.widgetId)},s(){var t;return((t=this.store)==null?void 0:t.state)||null},ready(){var t;return!!((t=this.s)!=null&&t.ready)},allConversations(){var n;const t=(n=this.s)==null?void 0:n.conversations;return Array.isArray(t)?t:[]},drawerConversations(){var r;const t=((r=this.s)==null?void 0:r.messagesByConv)||{},n=this.revealedAt;return this.allConversations.map(s=>{var _;const a=t[s.id]||[],o=F(s.last_read_message_id);let i=0,l=null;for(let v=a.length-1;v>=0;v--){const B=a[v];if(!B)continue;if(((_=B.author)==null?void 0:_.type)==="user")break;const S=F(B.id);if(S!=null){if(o!=null&&S<=o)break;n[B.id]!==0&&(!l&&B.author&&(l=B.author),i++)}}const f=a.filter(v=>!((v==null?void 0:v.id)!=null&&n[v.id]===0));return{...s,_preview:st(s,f),_unread:i>0,_unreadCount:i,_lastAuthor:l}})},unreadCount(){return this.drawerConversations.filter(t=>t._unread).length},openThreads(){var n;const t=((n=this.s)==null?void 0:n.messagesByConv)||{};return this.drawerConversations.filter(r=>r.status!=="resolved").map(r=>({id:r.id,title:r.name||this.t("common.newConversation"),preview:r._preview||this.t("onboarding.newMessage"),unread:!!r._unread,_ts:fe(r,t[r.id]||[])})).sort((r,s)=>r._ts<s._ts?1:r._ts>s._ts?-1:0)},latestUnreads(){var r;const t=((r=this.s)==null?void 0:r.messagesByConv)||{},n=[];for(const s of this.drawerConversations){if(!s._unread)continue;const a=fe(s,t[s.id]||[]),o=s._lastAuthor,i=!o||o.type==="agent_ia",l=(o==null?void 0:o.name)||(i?this.agentName:"")||"",f=(o==null?void 0:o.avatar_url)||(i?this.agentAvatarUrl:null);n.push({convId:s.id,preview:s._preview||this.t("notification.youHaveNewMessage"),ts:a,count:s._unreadCount||1,senderName:l,senderAvatarUrl:f})}return n.sort((s,a)=>s.ts<a.ts?1:s.ts>a.ts?-1:0),n},launcherPeeks(){if(this.isOpen||this.isEmbedded)return[];const t=this.dismissedPeeks||{};return this.latestUnreads.filter(n=>t[n.convId]!==n.ts)},isViewingThread(){return(this.isOpen||this.isEmbedded)&&!!this.currentConv},currentConv(){if(this.draftConv)return this.draftConv;if(this.showOnboarding)return null;const t=this.allConversations;if(!t.length)return null;if(this.activeConvId!=null){const n=t.find(r=>r.id===this.activeConvId);if(n)return n}return t[0]||null},canBack(){return!!this.currentConv},statusUrl(){var r;const t=(r=this.widget)==null?void 0:r.quick_links;if(!Array.isArray(t))return"";const n=t.find(s=>s.icon==="status"&&s.url);return(n==null?void 0:n.url)||""},helpUrl(){var r;const t=(r=this.widget)==null?void 0:r.quick_links;if(!Array.isArray(t))return"";const n=t.find(s=>(s.icon==="chat"||s.icon==="help")&&s.url);return(n==null?void 0:n.url)||""},widget(){var t,n;return((n=(t=this.s)==null?void 0:t.config)==null?void 0:n.widget)||null},widgetWelcomeMessage(){var t;return((t=this.widget)==null?void 0:t.welcome_message)||""},widgetSubtitle(){var t;return((t=this.widget)==null?void 0:t.subtitle)||""},defaultIconUrl(){var t;return((t=this.widget)==null?void 0:t.default_icon_url)||null},agentName(){var t,n,r;return((r=(n=(t=this.s)==null?void 0:t.config)==null?void 0:n.agent)==null?void 0:r.name)||""},agentAvatarUrl(){var t,n,r;return((r=(n=(t=this.s)==null?void 0:t.config)==null?void 0:n.agent)==null?void 0:r.avatar_url)||null},quickLinks(){var n;const t=(n=this.widget)==null?void 0:n.quick_links;return Array.isArray(t)?t:[]},teamMembers(){var n;const t=(n=this.widget)==null?void 0:n.team_members;return Array.isArray(t)?t:[]},responseLabel(){var t;return((t=this.widget)==null?void 0:t.response_time_label)||""},humanMessageAuthor(){var n,r,s;if(!this.currentConv)return null;const t=((n=this.s.messagesByConv)==null?void 0:n[this.currentConv.id])||[];for(let a=t.length-1;a>=0;a--)if(((s=(r=t[a])==null?void 0:r.author)==null?void 0:s.type)==="agent_human")return t[a].author;return null},humanAgentName(){var t;return((t=this.humanMessageAuthor)==null?void 0:t.name)||""},humanAgentAvatarUrl(){var t;return((t=this.humanMessageAuthor)==null?void 0:t.avatar_url)||null},isEscalated(){return!!this.humanMessageAuthor},isWaitingHuman(){var n;const t=(n=this.currentConv)==null?void 0:n.status;return t==="waiting"||t==="handled"},headerTitle(){var t,n;return((t=this.currentConv)==null?void 0:t.name)||((n=this.widget)==null?void 0:n.name)||this.t("common.newConversation")},composerPlaceholder(){return this.isEscalated&&this.humanAgentName?this.t("composer.replyTo",{name:this.humanAgentName.split(" ")[0]}):this.isWaitingHuman?this.t("composer.agentTakingOver"):this.t("composer.placeholder")},displayedMessages(){var r,s;const t=this.currentConv;if(!t)return[];if(!t._draft){const a=(s=(r=this.s)==null?void 0:r.paginationByConv)==null?void 0:s[t.id];if(!(a!=null&&a.loaded))return[]}const n=this.revealedAt;return(this.s.messagesByConv[t.id]||[]).filter(a=>{var o,i,l,f,_;return(a==null?void 0:a.type)==="action"&&((o=a==null?void 0:a.payload)==null?void 0:o.state)==="pending"||J(a)&&!(n[a.id]>0)?!1:(a==null?void 0:a.type)==="action"||(a==null?void 0:a.type)==="system"||((i=a==null?void 0:a.payload)==null?void 0:i.type)==="system"||Array.isArray((l=a==null?void 0:a.payload)==null?void 0:l.attachments)&&a.payload.attachments.length||(f=a==null?void 0:a.metadata)!=null&&f.artifact||(_=a==null?void 0:a.metadata)!=null&&_.form?!0:typeof(a==null?void 0:a.text_md)=="string"&&a.text_md.trim().length>0})},streamingActive(){var r,s,a;const t=this.currentConv;return t?Object.keys(((r=this.s)==null?void 0:r.streamingByMsgId)||{}).length>0?!0:this.actionInFlight?!1:(((a=(s=this.s)==null?void 0:s.messagesByConv)==null?void 0:a[t.id])||[]).some(o=>J(o)&&!(this.revealedAt[o.id]>0)):!1},currentConvMessages(){var n,r,s;const t=(n=this.currentConv)==null?void 0:n.id;return t?((s=(r=this.s)==null?void 0:r.messagesByConv)==null?void 0:s[t])||[]:[]},pendingApproval(){return!this.currentConv||!this.store||this.actionInFlight?null:this.store.getPendingApproval(this.currentConv.id)},approvalReady(){return this.pendingApproval?this.pendingApproval.id===this.approvalLatchId?!0:!(this.streamingActive||!this.approvalSettled):!1},approvalTitle(){var t,n,r;return((n=(t=this.pendingApproval)==null?void 0:t.payload)==null?void 0:n.name)||((r=this.pendingApproval)==null?void 0:r.text_md)||this.t("action.title")},approvalDetail(){var s,a,o,i,l,f;const t=(o=(a=(s=this.pendingApproval)==null?void 0:s.payload)==null?void 0:a.pending)==null?void 0:o.user_explanation;if(typeof t=="string"&&t.trim())return t.trim();const n=(f=(l=(i=this.pendingApproval)==null?void 0:i.payload)==null?void 0:l.pending)==null?void 0:f.prepared_params;if(!n||typeof n!="object")return"";const r=Object.entries(n);return r.length?r.slice(0,2).map(([_,v])=>`${_}: ${v}`).join(" · "):""},actionInFlight(){var t,n;return!this.currentConv||!this.store?null:((n=(t=this.store).getActionInFlight)==null?void 0:n.call(t,this.currentConv.id))||null},actionInFlightName(){var n;const t=this.actionInFlight;return t?((n=t.payload)==null?void 0:n.name)||t.text_md||this.t("common.action"):""},suggestions(){return!this.currentConv||!this.store?[]:this.streamingActive?[]:this.pendingForm?[]:this.store.getLatestSuggestions(this.currentConv.id)},pendingForm(){var t,n;return!this.currentConv||!this.store||this.pendingApproval||this.actionInFlight||this.streamingActive||!this.approvalSettled?null:((n=(t=this.store).getLatestForm)==null?void 0:n.call(t,this.currentConv.id))||null},showFeedback(){var n;const t=this.currentConv;return t?this.feedbackDone?!0:t.status!=="resolved"?!1:!((n=t.metadata)!=null&&n.feedback):!1},floatVisible(){return this.approvalReady||!!this.pendingForm||this.showFeedback||this.suggestions.length>0},dateLabel(){var r,s,a;const t=this.currentConv;let n=new Date;if(t){const i=((a=(((s=(r=this.s)==null?void 0:r.messagesByConv)==null?void 0:s[t.id])||[]).find(l=>l==null?void 0:l.created_at))==null?void 0:a.created_at)||t.created_at;if(i){const l=new Date(i);Number.isNaN(l.getTime())||(n=l)}}return this.t("messageList.today",{time:ce(n,W(this.locale))})},paginationState(){var r,s,a;const t=(r=this.currentConv)==null?void 0:r.id,n=t?(a=(s=this.s)==null?void 0:s.paginationByConv)==null?void 0:a[t]:null;return{loading:!!(n!=null&&n.loading),hasMore:!!(n!=null&&n.nextCursor)}}},watch:{latestUnreads:{handler(t){const n=new Set(t.map(i=>i.convId)),r=this.dismissedPeeks||{},s=Object.keys(r);if(!s.length)return;const a={};let o=!1;for(const i of s)n.has(i)?a[i]=r[i]:o=!0;o&&(this.dismissedPeeks=a)},deep:!0},"currentConv.id":{handler(t){var n;this.resetRevealQueue(),this.convOpenedAt=Date.now(),this.moreOpen=!1,this.renameDialogOpen=!1,this.resetApprovalPacing(),this.isViewingThread&&(this.unreadAnchorId=F((n=this.currentConv)==null?void 0:n.last_read_message_id),this.unreadBoundaryTs=t?new Date().toISOString():"")},immediate:!0},isViewingThread(t,n){var r;t&&!n?(this.unreadAnchorId=F((r=this.currentConv)==null?void 0:r.last_read_message_id),this.unreadBoundaryTs=new Date().toISOString()):t||(this.unreadAnchorId=null,this.unreadBoundaryTs="")},pendingApproval:{handler(t,n){if(t&&!n){const r=t!=null&&t.created_at?Date.parse(t.created_at):NaN;if(!(Number.isFinite(r)&&r>=this.convOpenedAt)){this.resetApprovalPacing();return}this.bumpApprovalSettle(2600)}else!t&&n&&this.resetApprovalPacing()},immediate:!1},streamingActive(t,n){t!==n&&this.pendingApproval&&this.pendingApproval.id!==this.approvalLatchId&&this.bumpApprovalSettle()},approvalReady(t){t&&this.pendingApproval&&(this.approvalLatchId=this.pendingApproval.id)},floatVisible:{handler(t){this.$nextTick(()=>this.syncFloatObserver(t))},immediate:!0},currentConvMessages(t){var n;this.paceMessages(t,(n=this.currentConv)==null?void 0:n.id),(this.isOpen||this.isEmbedded)&&this.currentConv&&this.markConvRead(this.currentConv)}},async mounted(){if(typeof document<"u"&&!document.getElementById(ye)){const t=document.createElement("style");t.id=ye,t.textContent=we,document.head.appendChild(t)}this.isEmbedded&&(await this.boot(),this.store&&await this.open())},beforeUnmount(){this.cancelReveals(),this.teardownLiveReveal(),this.disconnectFloatRO(),this.resetApprovalPacing(),this.teardownNotifications(),this.store&&this.store.destroy()},methods:{t(t,n){return this.translator(t,n)},async boot(){var t;if(!this.canBoot){console.warn("[messenger] boot skipped — missing creds");return}try{this.transport=e.markRaw(ve({baseUrl:this.baseUrl,widgetId:this.widgetId,token:this.token||void 0})),this.store=e.markRaw(ke(this.transport)),this.hydrateNotifPref();const n=(t=this.context)==null?void 0:t.customer;n&&typeof n=="object"&&await this.store.applyCustomer(n),await this.store.start(),this.setupLiveReveal()}catch(n){console.error("[ww-messenger] bootstrap failed",n),this.bootError=(n==null?void 0:n.message)||String(n)}},async refresh(){this.store&&this.store.destroy(),this.cancelReveals(),this.teardownLiveReveal(),this.teardownNotifications(),this.convOpenedAt=0,this.transport=null,this.store=null,this.isOpen=!1,this.draft="",this.busy=!1,this.bootError=null,this.pendingAttachments=[],this.feedbackBusy=!1,this.feedbackDone=!1,this.moreOpen=!1,this.renameDialogOpen=!1,this.draftConv=null,this.activeConvId=null,this.showOnboarding=!1,await this.boot(),this.isEmbedded&&this.store&&await this.open()},syncFloatObserver(t){if(this.disconnectFloatRO(),!t){this.floatHeight=0;return}const n=this.$refs.floatEl;if(n){if(typeof ResizeObserver>"u"){this.floatHeight=Math.ceil(n.getBoundingClientRect().height+8);return}this.floatRO=new ResizeObserver(r=>{const s=r[0];if(!s)return;const a=Math.ceil(s.contentRect.height+8);a!==this.floatHeight&&(this.floatHeight=a,this.$nextTick(()=>{var o,i;(i=(o=this.$refs.messageList)==null?void 0:o.scrollToBottom)==null||i.call(o)}))}),this.floatRO.observe(n)}},disconnectFloatRO(){if(this.floatRO){try{this.floatRO.disconnect()}catch{}this.floatRO=null}},async open(){this.isOpen=!0,this.store||await this.boot(),this.store&&this.store.setPanelOpen(!0);const t=this.currentConv;if(t&&!t._draft){this.activeConvId==null&&(this.activeConvId=t.id);try{await this.store.openConversation(t.id)}catch(n){console.error("[ww-messenger] load messages failed",n)}this.markConvRead(t)}},close(){this.isOpen=!1,this.store&&this.store.setPanelOpen(!1)},async openFromPeek(t){var r,s;const n=t||((r=this.latestUnreads[0])==null?void 0:r.convId);n&&n!==((s=this.currentConv)==null?void 0:s.id)&&(this.draftConv=null,this.activeConvId=n,this.showOnboarding=!1),await this.open()},dismissPeek(t){const n=this.latestUnreads.find(r=>r.convId===t);n&&(this.dismissedPeeks={...this.dismissedPeeks,[t]:n.ts})},startConv(){this.draftConv={id:"__draft__",_draft:!0,name:"",created_at:new Date().toISOString()},this.activeConvId=null,this.showOnboarding=!1,this.focusComposer()},async ensureRealConv(){const t=this.currentConv;if(!t)return null;if(!t._draft)return t;if(this.busy)return null;this.busy=!0;try{const n=await this.store.createConversation({});return this.draftConv=null,this.activeConvId=n.id,await this.store.openConversation(n.id),this.markConvRead(n),n}catch(n){return console.error("[ww-messenger] create conv failed",n),this.bootError=(n==null?void 0:n.message)||String(n),null}finally{this.busy=!1}},focusComposer(){this.$nextTick(()=>{var t;return(t=this.$refs.composer)==null?void 0:t.focus()})},toggleMore(){this.moreOpen=!this.moreOpen},goHome(){this.moreOpen=!1,this.draftConv=null,this.activeConvId=null,this.showOnboarding=!0},async onDrawerPick(t){if(!(t!=null&&t.id)||!this.store)return;this.draftConv=null,this.activeConvId=t.id,this.showOnboarding=!1;try{await this.store.openConversation(t.id)}catch(r){console.error("[ww-messenger] open conv failed",r)}const n=this.allConversations.find(r=>r.id===t.id);n&&this.markConvRead(n)},async onMoreAction(t){var n,r;switch(this.moreOpen=!1,t){case"rename":this.openRenameDialog();break;case"export":ct(this.currentConv,this.currentConv?(r=(n=this.s)==null?void 0:n.messagesByConv)==null?void 0:r[this.currentConv.id]:[],this.translator,this.locale);break;case"status":if(this.statusUrl)try{window.open(this.statusUrl,"_blank","noopener")}catch{}break;case"help":if(this.helpUrl)try{window.open(this.helpUrl,"_blank","noopener")}catch{}break}},openRenameDialog(){const t=this.currentConv;!t||t._draft||(this.renameDialogOpen=!0)},async onRenameSubmit(t){const n=this.currentConv;if(this.renameDialogOpen=!1,!n||n._draft||!this.store)return;const r=(t||"").trim();if(!(!r||r===n.name))try{await this.store.patchConversation(n.id,{name:r})}catch(s){console.error("[ww-messenger] rename failed",s)}},async onSend(t){let n=this.currentConv;if(!n&&(this.startConv(),n=this.currentConv,!n)||n._draft&&(n=await this.ensureRealConv(),!n))return;const r=n.id,s=this.pendingAttachments.slice();this.pendingAttachments=[],this.unreadAnchorId=null,this.unreadBoundaryTs="",await this.store.send(r,t,{attachments:s.length?s:void 0})},async onSuggestion(t){const n=t==null?void 0:t.label;n&&await this.onSend(n)},async onLoadMore(){var n;const t=(n=this.currentConv)==null?void 0:n.id;!t||!this.store||await this.store.loadMore(t)},async onApprovalCallback(t){const n=this.pendingApproval;n&&await this.store.clickCallback(n.id,t)},async onFormSubmit({values:t}){const n=this.pendingForm;if(!(n!=null&&n.form))return;const r=ot(n.form,t,this.translator);if(!r)return;let s=this.currentConv;s&&(s._draft&&(s=await this.ensureRealConv(),!s)||await this.store.send(s.id,r,{metadata:{artifact:at(n.form,t,this.translator)}}))},async onAttach(t){if(!(!t||!this.transport))try{const n=await this.transport.uploadAttachment(t);this.pendingAttachments.push({type:n.type||"file",path:n.path,name:t.name||this.t("attachment.fileFallbackName"),mime_type:t.type,size_bytes:t.size})}catch(n){console.error("[ww-messenger] attachment upload failed",n)}},async onQuickLink(t){if(t){if(t.url){try{window.open(t.url,"_blank","noopener")}catch{}return}this.currentConv||this.startConv(),await this.onSend(t.label)}},async onFeedback({rating:t,comment:n}){if(this.currentConv){this.feedbackBusy=!0;try{await this.store.submitFeedback(this.currentConv.id,{rating:t,comment:n}),this.feedbackDone=!0}catch(r){console.error("[ww-messenger] feedback failed",r)}finally{this.feedbackBusy=!1}}}}},cs={key:0,class:"wm-loading","aria-busy":"true","aria-live":"polite"},ds=["aria-label"],us={key:0,class:"wm-state"},ms={class:"wm-state__err"},hs={class:"wm-state__errTitle"},fs={class:"wm-state__errSub"},ps={class:"wm-bottom"},gs={key:0,ref:"floatEl",class:"wm-float"},_s={key:1,class:"wm-actionWait",role:"status","aria-live":"polite"},ys={class:"wm-actionWait__lbl"},vs={key:2,class:"wm-attached"},ks=["aria-label","onClick"];function ws(t,n,r,s,a,o){const i=e.resolveComponent("Launcher"),l=e.resolveComponent("Header"),f=e.resolveComponent("Onboarding"),_=e.resolveComponent("MessageList"),v=e.resolveComponent("ApprovalCard"),B=e.resolveComponent("FormCard"),S=e.resolveComponent("Feedback"),E=e.resolveComponent("SuggestionChips"),L=e.resolveComponent("Composer"),C=e.resolveComponent("MoreMenu"),x=e.resolveComponent("RenameDialog");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-root",`wm-root--${r.displayMode}`])},[!a.isOpen&&!o.isEmbedded?(e.openBlock(),e.createBlock(i,{key:0,"unread-count":o.unreadCount,peeks:o.launcherPeeks,onOpen:o.openFromPeek,onDismiss:o.dismissPeek},null,8,["unread-count","peeks","onOpen","onDismiss"])):e.createCommentVNode("",!0),a.isOpen||o.isEmbedded?(e.openBlock(),e.createElementBlock("section",{key:1,class:e.normalizeClass(["wm-panel",`wm-panel--${r.displayMode}`,{"wm-panel--welcome":o.ready&&!o.error&&!o.currentConv}]),style:e.normalizeStyle(a.floatHeight?{"--wm-float-h":a.floatHeight+"px"}:null),role:"dialog","aria-label":"Messenger"},[!o.ready&&!o.error?(e.openBlock(),e.createElementBlock("div",cs,[o.isEmbedded?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-loading__close","aria-label":o.t("loading.minimize"),onClick:n[0]||(n[0]=(...A)=>o.close&&o.close(...A))},[...n[5]||(n[5]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,ds)),n[6]||(n[6]=e.createElementVNode("div",{class:"wm-loading__spinner","aria-hidden":"true"},null,-1))])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(l,{title:o.headerTitle,"team-members":o.teamMembers,"response-label":o.responseLabel,"show-identity":!!o.currentConv,"show-back":o.canBack,"show-close":!o.isEmbedded,"more-active":a.moreOpen,"agent-name":o.agentName,"agent-avatar-url":o.agentAvatarUrl,onBack:o.goHome,onMore:o.toggleMore,onClose:o.close},null,8,["title","team-members","response-label","show-identity","show-back","show-close","more-active","agent-name","agent-avatar-url","onBack","onMore","onClose"]),o.error?(e.openBlock(),e.createElementBlock("div",us,[e.createElementVNode("div",ms,[n[7]||(n[7]=e.createElementVNode("div",{class:"wm-state__errIcon"},[e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})])],-1)),e.createElementVNode("div",null,[e.createElementVNode("div",hs,e.toDisplayString(o.t("error.connectionFailed")),1),e.createElementVNode("div",fs,e.toDisplayString(o.error),1)])])])):o.currentConv?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createVNode(_,{ref:"messageList",messages:o.displayedMessages,"streaming-active":o.streamingActive,"date-label":o.dateLabel,"conversation-id":o.currentConv?o.currentConv.id:null,"loading-more":o.paginationState.loading,"has-more":o.paginationState.hasMore,"unread-anchor-id":t.unreadAnchorId,"unread-boundary-ts":t.unreadBoundaryTs,"ai-agent-name":o.agentName,"ai-agent-avatar-url":o.agentAvatarUrl,onLoadMore:o.onLoadMore},null,8,["messages","streaming-active","date-label","conversation-id","loading-more","has-more","unread-anchor-id","unread-boundary-ts","ai-agent-name","ai-agent-avatar-url","onLoadMore"]),e.createElementVNode("div",ps,[o.floatVisible?(e.openBlock(),e.createElementBlock("div",gs,[o.approvalReady?(e.openBlock(),e.createBlock(v,{key:0,action:o.approvalTitle,detail:o.approvalDetail,callbacks:o.pendingApproval.callbacks,"agent-name":o.agentName,"agent-avatar-url":o.agentAvatarUrl,onCallback:o.onApprovalCallback},null,8,["action","detail","callbacks","agent-name","agent-avatar-url","onCallback"])):o.pendingForm?(e.openBlock(),e.createBlock(B,{key:o.pendingForm.message&&o.pendingForm.message.id,form:o.pendingForm.form,"agent-name":o.agentName,"agent-avatar-url":o.agentAvatarUrl,onSubmit:o.onFormSubmit},null,8,["form","agent-name","agent-avatar-url","onSubmit"])):o.showFeedback?(e.openBlock(),e.createBlock(S,{key:2,busy:a.feedbackBusy,done:a.feedbackDone,onSubmit:o.onFeedback},null,8,["busy","done","onSubmit"])):(e.openBlock(),e.createBlock(E,{key:3,items:o.suggestions,onSelect:o.onSuggestion},null,8,["items","onSelect"]))],512)):e.createCommentVNode("",!0),o.actionInFlight?(e.openBlock(),e.createElementBlock("div",_s,[n[8]||(n[8]=e.createElementVNode("span",{class:"wm-actionWait__spinner","aria-hidden":"true"},null,-1)),e.createElementVNode("span",ys,e.toDisplayString(o.t("action.inProgress",{name:o.actionInFlightName})),1)])):(e.openBlock(),e.createBlock(L,{key:2,ref:"composer",modelValue:a.draft,"onUpdate:modelValue":n[1]||(n[1]=A=>a.draft=A),placeholder:o.composerPlaceholder,disabled:!!o.pendingApproval,"attach-label":o.t("composer.attachFile"),onSend:o.onSend,onAttach:o.onAttach},null,8,["modelValue","placeholder","disabled","attach-label","onSend","onAttach"]))]),a.moreOpen?(e.openBlock(),e.createBlock(C,{key:0,"can-rename":!!o.currentConv&&!o.currentConv._draft,"can-export":!!o.currentConv&&!o.currentConv._draft,"sound-enabled":t.soundEnabled,"browser-notif-enabled":t.browserNotifEnabled,"status-url":o.statusUrl,"help-url":o.helpUrl,onClose:n[2]||(n[2]=A=>a.moreOpen=!1),onSoundToggle:t.onSoundToggle,onBrowserNotifToggle:t.onBrowserNotifToggle,onAction:o.onMoreAction},null,8,["can-rename","can-export","sound-enabled","browser-notif-enabled","status-url","help-url","onSoundToggle","onBrowserNotifToggle","onAction"])):e.createCommentVNode("",!0),a.renameDialogOpen&&o.currentConv&&!o.currentConv._draft?(e.openBlock(),e.createBlock(x,{key:1,"initial-value":o.currentConv.name||"",title:o.t("rename.dialogTitle"),onClose:n[3]||(n[3]=A=>a.renameDialogOpen=!1),onSubmit:o.onRenameSubmit},null,8,["initial-value","title","onSubmit"])):e.createCommentVNode("",!0),a.pendingAttachments.length?(e.openBlock(),e.createElementBlock("div",vs,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.pendingAttachments,(A,O)=>(e.openBlock(),e.createElementBlock("div",{key:O,class:"wm-attached__chip"},[n[10]||(n[10]=e.createElementVNode("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"})],-1)),e.createElementVNode("span",null,e.toDisplayString(A.name),1),e.createElementVNode("button",{type:"button","aria-label":o.t("attachment.remove"),onClick:D=>a.pendingAttachments.splice(O,1)},[...n[9]||(n[9]=[e.createElementVNode("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,ks)]))),128))])):e.createCommentVNode("",!0)],64)):(e.openBlock(),e.createBlock(f,{key:1,"welcome-message":o.widgetWelcomeMessage,subtitle:o.widgetSubtitle,"agent-name":o.agentName,"default-icon-url":o.defaultIconUrl,"quick-links":o.quickLinks,"open-threads":o.openThreads,busy:a.busy,onStart:o.startConv,onSelect:o.onQuickLink,onResume:o.onDrawerPick},null,8,["welcome-message","subtitle","agent-name","default-icon-url","quick-links","open-threads","busy","onStart","onSelect","onResume"])),a.moreOpen&&!o.currentConv?(e.openBlock(),e.createBlock(C,{key:3,"can-rename":!1,"can-export":!1,"sound-enabled":t.soundEnabled,"browser-notif-enabled":t.browserNotifEnabled,"status-url":o.statusUrl,"help-url":o.helpUrl,onClose:n[4]||(n[4]=A=>a.moreOpen=!1),onSoundToggle:t.onSoundToggle,onBrowserNotifToggle:t.onBrowserNotifToggle,onAction:o.onMoreAction},null,8,["sound-enabled","browser-notif-enabled","status-url","help-url","onSoundToggle","onBrowserNotifToggle","onAction"])):e.createCommentVNode("",!0)],64))],6)):e.createCommentVNode("",!0)],2)}const Qe=N(ls,[["render",ws],["__scopeId","data-v-966f7d8a"]]),bs="0.5.2";exports.AIAvatar=G;exports.AVATAR_COLORS=X;exports.ActionResult=xe;exports.ApprovalCard=We;exports.ArtifactFormResponse=Le;exports.ArtifactInfoCard=Oe;exports.ArtifactRenderer=Ie;exports.ArtifactTicket=De;exports.AttachmentPreview=Re;exports.Bubble=Fe;exports.Composer=$e;exports.DEFAULT_BASE_URL=be;exports.DEFAULT_LANGUAGE=K;exports.Feedback=Ye;exports.FormCard=Ge;exports.Header=Se;exports.HumanAvatar=de;exports.Launcher=Be;exports.MEDIA_RECORDER_SUPPORTED=ne;exports.MessageList=Pe;exports.Messenger=Qe;exports.MoreMenu=Je;exports.Onboarding=Te;exports.SCREEN_CAPTURE_SUPPORTED=Q;exports.SUPPORTED_LANGUAGES=Ee;exports.SuggestionChips=Ke;exports.TeamAvatars=Ne;exports.Typing=Ue;exports.VERSION=bs;exports.avatarColor=Z;exports.avatarInitials=ee;exports.captureScreenshotFile=qe;exports.colors=T;exports.createStore=ke;exports.createTranslator=V;exports.createTransport=ve;exports.dateLocale=W;exports.default=Qe;exports.formatTime=ce;exports.guessAttachmentKind=bo;exports.pickRecorderMime=je;exports.renderInlineMarkdown=Ve;exports.renderMarkdown=Me;exports.resolveLanguage=te;exports.startScreenRecording=He;exports.tokensCss=we;exports.uuid=le;exports.v4=le;
@@ -74,4 +74,4 @@ ${a}`)}return i.join(`
74
74
  `)}function Ic(e,t,n=Ee(),r){if(!e)return;const i=Oc(e,t||[],n,bn(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 Lc={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||!wn(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)}}}},Rc=450,Bc=50,Nc=900,Pc=12e3,Fc=300,Dc={data(){return{revealedAt:{},nextRevealAt:0,revealTimers:[],_liveRevealOff:null,_liveRevealConvSnapshot:null}},methods:{cancelReveals(){for(const e of this.revealTimers)clearTimeout(e);this.revealTimers=[]},resetRevealQueue(){this.cancelReveals(),this.revealedAt={},this.nextRevealAt=0},setupLiveReveal(){var n;if(!this.transport)return;this.teardownLiveReveal();const e=this.transport.on("message",r=>{const i=r==null?void 0:r.conversation_id,s=r==null?void 0:r.message;i&&s&&this.paceLiveMessage(s,i)});this._liveRevealConvSnapshot=new Map((((n=this.s)==null?void 0:n.conversations)||[]).map(r=>[r.id,(r==null?void 0:r.last_message_at)||""]));const t=this.transport.on("activity",r=>{this.handleLiveActivity(r)});this._liveRevealOff=()=>{try{e()}catch{}try{t()}catch{}}},teardownLiveReveal(){if(this._liveRevealOff){try{this._liveRevealOff()}catch{}this._liveRevealOff=null}this._liveRevealConvSnapshot=null},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=Date.now(),r=((e==null?void 0:e.text_md)||"").length,i=Math.min(Pc,Math.max(Nc,r*Bc)),o=Math.max(n+Rc,this.nextRevealAt+Fc)+i;this.nextRevealAt=o;const a=Math.max(0,o-n),l=e.id,d=setTimeout(()=>{this.revealedAt={...this.revealedAt,[l]:Date.now()},this.revealTimers=this.revealTimers.filter(c=>c!==d),typeof this.onMessageRevealed=="function"&&this.onMessageRevealed(e,t)},a);this.revealTimers.push(d)},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(!wn(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 i;if(!(e!=null&&e.id)||this.revealedAt[e.id]!==void 0)return;if(!wn(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((i=e==null?void 0:e.payload)==null?void 0:i.attachments)&&e.payload.attachments.length>0;if(!n&&!r){this.revealedAt={...this.revealedAt,[e.id]:Date.now()};return}this.revealedAt={...this.revealedAt,[e.id]:0},this.scheduleReveal(e,t)}}},jc={data(){return{approvalSettled:!0,approvalSettleTimer:null,approvalLatchId:null}},methods:{resetApprovalPacing(){this.approvalSettleTimer&&(clearTimeout(this.approvalSettleTimer),this.approvalSettleTimer=null),this.approvalSettled=!0,this.approvalLatchId=null},bumpApprovalSettle(e=800){this.approvalSettled=!1,this.approvalSettleTimer&&clearTimeout(this.approvalSettleTimer),this.approvalSettleTimer=setTimeout(()=>{this.approvalSettled=!0,this.approvalSettleTimer=null},e)}}},Uc=300,Hc={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=$c(t);if(n==null)return;const r=Ct(e.last_read_message_id),i=Ct(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)},Uc))))}}};function $c(e){for(let t=e.length-1;t>=0;t--){const n=e[t];if(!(!n||n._pending)&&Ct(n.id)!=null)return n.id}return null}const we=(e,t)=>{const n=e.__vccOpts||e;for(const[r,i]of t)n[r]=i;return n},Vc={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":Gs(this.name)},initials(){return Ys(this.name)}}},Kc=["src","alt"];function qc(e,t,n,r,i,s){return m(),_("div",{class:se(["wm-huav",{"wm-huav--tail":n.tail}]),style:je({width:n.size+"px",height:n.size+"px","--wm-avr":Math.round(n.size*.32)+"px",background:s.bg})},[n.avatarUrl?(m(),_("img",{key:0,src:n.avatarUrl,alt:n.name||""},null,8,Kc)):(m(),_("span",{key:1,style:je({fontSize:n.size*.36+"px"})},L(s.initials),5))],6)}const wo=we(Vc,[["render",qc],["__scopeId","data-v-14e10c0d"]]),Wc=3,zc={name:"WmLauncher",components:{HumanAvatar:wo},inject:{t:{default:()=>Ee()}},props:{unreadCount:{type:Number,default:0},peeks:{type:Array,default:()=>[]}},emits:["open","dismiss"],computed:{visiblePeeks(){return this.peeks.slice(0,Wc).reverse()}}},Gc={class:"wm-launcherWrap"},Yc=["aria-label","onClick","onKeydown"],Jc=["aria-label","onClick"],Xc={class:"wm-peek__avatar"},Qc=["aria-label"],Zc={class:"wm-peek__body"},eu={class:"wm-peek__head"},tu={class:"wm-peek__name"},nu={class:"wm-peek__action"},su={class:"wm-peek__text"},ru=["onClick"],iu=["aria-label"],ou=["aria-label"];function au(e,t,n,r,i,s){const o=_e("HumanAvatar");return m(),_("div",Gc,[ye(Pl,{name:"wm-peek"},{default:Ur(()=>[s.visiblePeeks.length?(m(),_("div",{key:0,class:se(["wm-peekStack",{"wm-peekStack--multi":s.visiblePeeks.length>1}])},[(m(!0),_(te,null,Me(s.visiblePeeks,(a,l)=>(m(),_("div",{key:a.convId,class:"wm-peek",style:je({"--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:[ss(kt(d=>e.$emit("open",a.convId),["prevent"]),["enter"]),ss(kt(d=>e.$emit("open",a.convId),["prevent"]),["space"])]},[u("button",{type:"button",class:"wm-peek__close","aria-label":s.t("launcher.dismiss"),onClick:kt(d=>e.$emit("dismiss",a.convId),["stop"])},[...t[1]||(t[1]=[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,Jc),u("div",Xc,[ye(o,{name:a.senderName,"avatar-url":a.senderAvatarUrl,size:34},null,8,["name","avatar-url"]),a.count>1?(m(),_("span",{key:0,class:"wm-peek__avatarBadge","aria-label":s.t("launcher.unreadMessages",{count:a.count})},L(a.count>9?"9+":a.count),9,Qc)):D("",!0)]),u("div",Zc,[u("div",eu,[u("span",tu,L(a.senderName||s.t("common.agent")),1),u("span",nu,L(s.t("launcher.repliedToYou")),1)]),u("p",su,L(a.preview),1)]),u("button",{type:"button",class:"wm-peek__open",onClick:kt(d=>e.$emit("open",a.convId),["stop"])},L(s.t("common.open")),9,ru)],44,Yc))),128))],2)):D("",!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[2]||(t[2]=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?(m(),_("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})},L(n.unreadCount>9?"9+":n.unreadCount),9,ou)):D("",!0)],8,iu)])}const lu=we(zc,[["render",au],["__scopeId","data-v-5193a529"]]),cu={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 Ys(this.name)},bgColor(){return Gs(this.name)}}},uu={key:0,class:"wm-aiav__pulse"},du=["src","alt"],fu=["width","height"];function hu(e,t,n,r,i,s){return m(),_("div",{class:se(["wm-aiav",{"wm-aiav--tail":n.tail}]),style:je({width:n.size+"px",height:n.size+"px","--wm-avr":n.size*.32+"px"})},[n.pulse?(m(),_("div",uu)):D("",!0),u("div",{class:se(["wm-aiav__inner",{"wm-aiav__inner--glow":n.pulse,"wm-aiav__inner--img":!!n.imageUrl,"wm-aiav__inner--initials":!n.imageUrl&&!!s.initials}]),style:je(!n.imageUrl&&s.initials?{background:s.bgColor}:null)},[n.imageUrl?(m(),_("img",{key:0,src:n.imageUrl,alt:n.name||""},null,8,du)):s.initials?(m(),_("span",{key:1,style:je({fontSize:n.size*.36+"px"})},L(s.initials),5)):(m(),_("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,fu))],6)],6)}const kn=we(cu,[["render",hu],["__scopeId","data-v-6f7f685d"]]),mu={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":Gs(e.name||"")},initialsFor(e){return Ys(e.name||"")}}},pu={key:0,class:"wm-team"},gu=["src","alt"],_u={key:1},yu={key:0,class:"wm-team__label"};function vu(e,t,n,r,i,s){return s.visible?(m(),_("div",pu,[u("div",{class:"wm-team__stack",style:je({width:s.stackWidth+"px"})},[(m(!0),_(te,null,Me(n.members.slice(0,3),(o,a)=>(m(),_("div",{key:a,class:"wm-team__pill",style:je({left:a*13+"px",zIndex:3-a,background:s.colorFor(o)})},[o.avatar_url?(m(),_("img",{key:0,src:o.avatar_url,alt:o.name||""},null,8,gu)):(m(),_("span",_u,L(s.initialsFor(o)),1))],4))),128))],4),n.responseLabel?(m(),_("span",yu,L(n.responseLabel),1)):D("",!0)])):D("",!0)}const bu={name:"WmHeader",components:{AIAvatar:kn,TeamAvatars:we(mu,[["render",vu],["__scopeId","data-v-e49a9063"]])},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}}},wu={class:"wm-header"},ku=["aria-label"],Cu={key:1,style:{width:"30px",height:"30px","flex-shrink":"0"}},Su={class:"wm-header__avatar"},Au={class:"wm-header__main"},xu={class:"wm-header__title"},Tu={key:3,class:"wm-header__fill"},Mu={class:"wm-header__actions"},Eu=["aria-label","title"],Ou=["aria-label","title"];function Iu(e,t,n,r,i,s){const o=_e("AIAvatar"),a=_e("TeamAvatars");return m(),_("div",wu,[n.showBack?(m(),_("button",{key:0,type:"button",class:"wm-header__icon","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,ku)):(m(),_("div",Cu)),n.showIdentity?(m(),_(te,{key:2},[u("div",Su,[ye(o,{size:30,name:n.agentName,"image-url":n.agentAvatarUrl},null,8,["name","image-url"])]),u("div",Au,[u("div",xu,L(n.title),1)]),s.hasTeam?(m(),be(a,{key:0,members:s.displayedTeamMembers,"response-label":""},null,8,["members"])):D("",!0)],64)):(m(),_("div",Tu)),u("div",Mu,[n.showMore?(m(),_("button",{key:0,type:"button",class:se(["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,Eu)):D("",!0),n.showClose?(m(),_("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,Ou)):D("",!0)])])}const Lu=we(bu,[["render",Iu],["__scopeId","data-v-925c9e94"]]);function ko(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Ru(e){return/^(https?:\/\/|mailto:|tel:)/i.test(String(e).trim())}const Co="";function Cn(e){let t=e;const n=[];return t=t.replace(/`([^`\n]+)`/g,(r,i)=>{const s=n.length;return n.push(i),`${Co}CODE${s}${Co}`}),t=t.replace(/\[([^\]\n]+)\]\(([^)\s]+)\)/g,(r,i,s)=>Ru(s)?`<a href="${s}" target="_blank" rel="noopener noreferrer">${i}</a>`:i),t=t.replace(/\*\*([^\n*][^\n]*?)\*\*/g,"<strong>$1</strong>"),t=t.replace(/__([^\n_][^\n]*?)__/g,"<u>$1</u>"),t=t.replace(/~~([^\n~][^\n]*?)~~/g,"<s>$1</s>"),t=t.replace(/(^|[^\w*])\*([^\n*]+?)\*(?!\w)/g,"$1<em>$2</em>"),t=t.replace(/(^|[^\w_])_([^\n_]+?)_(?!\w)/g,"$1<em>$2</em>"),t=t.replace(/CODE(\d+)/g,(r,i)=>`<code class="wm-md-code">${n[+i]}</code>`),t}function Bu(e){if(!e)return"";const t=String(e).replace(/\[([^\]\n]+)\]\([^)\s]+\)/g,"$1");return Cn(ko(t))}function Nu(e){if(!e)return"";const t=ko(e).split(`
75
75
  `),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(`
76
76
  `)}</code></pre>`});continue}if(/^\s*[-*]\s+/.test(s)){const d=[];for(;r<t.length;){const p=/^\s*[-*]\s+(.*)$/.exec(t[r]);if(!p)break;d.push(p[1]),r++}const c=d.map(p=>`<li>${Cn(p)}</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 C=/^\s*\d+\.\s+(.*)$/.exec(t[r]);if(!C)break;c.push(C[1]),r++}const p=c.map(C=>`<li>${Cn(C)}</li>`).join(""),A=d!==1?` start="${d}"`:"";n.push({type:"block",html:`<ol class="wm-md-ol"${A}>${p}</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}">${Cn(l[2])}</h${d}>`}),r++;continue}n.push({type:"text",html:Cn(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+=`
77
- `)}return i}const So={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"},Pu={name:"WmOnboarding",components:{AIAvatar:kn},inject:{t:{default:()=>Ee()},wmLocale:{default:()=>()=>"fr"}},props:{welcomeMessage:{type:String,default:""},subtitle:{type:String,default:""},agentName:{type:String,default:""},defaultIconUrl:{type:String,default:null},quickLinks:{type:Array,default:()=>[]},openThreads:{type:Array,default:()=>[]},busy:{type:Boolean,default:!1}},emits:["start","select","resume"],data(){return{query:""}},computed:{heroTitle(){return this.welcomeMessage?this.welcomeMessage:this.agentName?this.t("onboarding.greetingNamed",{name:this.agentName}):this.t("onboarding.greeting")},heroSub(){return this.subtitle||this.t("onboarding.heroSub")},isOddQuickLinks(){return this.quickLinks.length%2===1},quickLinksLayout(){return this.isOddQuickLinks?"wm-onb__qlist":"wm-onb__grid"},filteredThreads(){const e=this.query.trim().toLowerCase();return e?this.openThreads.filter(t=>(t.title||"").toLowerCase().includes(e)||(t.preview||"").toLowerCase().includes(e)):this.openThreads}},methods:{iconPath(e){return So[e]||So.link},renderPreview(e){return Bu(e)},formatTs(e){if(!e)return"";const t=new Date(e);if(Number.isNaN(t.getTime()))return"";const n=bn(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"})}}},Fu={class:"wm-onb"},Du={class:"wm-onb__hero"},ju={class:"wm-onb__hero-text"},Uu={class:"wm-onb__title"},Hu={class:"wm-onb__sub"},$u={class:"wm-onb__cta"},Vu=["disabled"],Ku={key:0,class:"wm-onb__section"},qu={class:"wm-onb__section-title"},Wu=["onClick"],zu={class:"wm-onb__card-icon"},Gu={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"},Yu=["d"],Ju={class:"wm-onb__card-body"},Xu={class:"wm-onb__card-title"},Qu={key:0,class:"wm-onb__card-sub"},Zu={key:1,class:"wm-onb__section"},ed={class:"wm-onb__section-title"},td={class:"wm-onb__search"},nd=["placeholder","aria-label"],sd={class:"wm-onb__list"},rd=["onClick"],id=["aria-label"],od={class:"wm-onb__thread-body"},ad={class:"wm-onb__thread-title"},ld=["innerHTML"],cd={class:"wm-onb__thread-meta"},ud={key:0,class:"wm-onb__thread-time"},dd={key:0,class:"wm-onb__empty"};function fd(e,t,n,r,i,s){const o=_e("AIAvatar");return m(),_("div",Fu,[u("div",Du,[t[2]||(t[2]=u("svg",{class:"wm-onb__hero-deco",width:"180",height:"180",viewBox:"0 0 180 180",fill:"none","aria-hidden":"true"},[u("circle",{cx:"170",cy:"10",r:"105",stroke:"#5B5FEF","stroke-width":"1","stroke-dasharray":"1 5",opacity:"0.35"}),u("circle",{cx:"170",cy:"10",r:"72",stroke:"#5B5FEF","stroke-width":"1","stroke-dasharray":"1 5",opacity:"0.5"}),u("circle",{cx:"152",cy:"34",r:"2.5",fill:"#5B5FEF",opacity:"0.65"})],-1)),ye(o,{size:52,"image-url":n.defaultIconUrl},null,8,["image-url"]),u("div",ju,[u("div",Uu,L(s.heroTitle),1),u("div",Hu,L(s.heroSub),1)])]),u("div",$u,[u("button",{type:"button",class:"wm-onb__startBtn",disabled:n.busy,onClick:t[0]||(t[0]=a=>e.$emit("start"))},[t[3]||(t[3]=u("span",{class:"wm-onb__startIcon"},[u("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[u("path",{d:"M12 5v14M5 12h14"})])],-1)),u("span",null,L(n.busy?"…":s.t("onboarding.start")),1)],8,Vu)]),n.quickLinks.length?(m(),_("div",Ku,[u("div",qu,L(s.t("onboarding.quickAccess")),1),u("div",{class:se(s.quickLinksLayout)},[(m(!0),_(te,null,Me(n.quickLinks,(a,l)=>(m(),_("button",{key:l,type:"button",class:se(["wm-onb__card",{"wm-onb__card--row":s.isOddQuickLinks}]),onClick:d=>e.$emit("select",a)},[u("span",zu,[(m(),_("svg",Gu,[u("path",{d:s.iconPath(a.icon)},null,8,Yu)]))]),u("span",Ju,[u("span",Xu,L(a.label),1),a.description?(m(),_("span",Qu,L(a.description),1)):D("",!0)])],10,Wu))),128))],2)])):D("",!0),n.openThreads.length?(m(),_("div",Zu,[u("div",ed,L(s.t("onboarding.recentConversations")),1),u("div",td,[t[4]||(t[4]=u("span",{class:"wm-onb__searchIcon"},[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:"M21 21l-4.35-4.35M11 17a6 6 0 100-12 6 6 0 000 12z"})])],-1)),ut(u("input",{"onUpdate:modelValue":t[1]||(t[1]=a=>i.query=a),type:"text",placeholder:s.t("onboarding.search"),"aria-label":s.t("onboarding.search")},null,8,nd),[[Rt,i.query]])]),u("div",sd,[(m(!0),_(te,null,Me(s.filteredThreads,a=>(m(),_("button",{key:a.id,type:"button",class:"wm-onb__thread",onClick:l=>e.$emit("resume",a)},[u("span",{class:se(["wm-onb__thread-icon",{"wm-onb__thread-icon--inverted":!a.unread}])},[t[5]||(t[5]=u("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[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:"currentColor",opacity:"0.92"})],-1)),a.unread?(m(),_("span",{key:0,class:"wm-onb__thread-dot","aria-label":s.t("onboarding.unread")},null,8,id)):D("",!0)],2),u("span",od,[u("span",ad,L(a.title),1),u("span",{class:"wm-onb__thread-preview",innerHTML:s.renderPreview(a.preview)},null,8,ld)]),u("span",cd,[s.formatTs(a._ts)?(m(),_("span",ud,L(s.formatTs(a._ts)),1)):D("",!0),t[6]||(t[6]=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-onb__thread-chev","aria-hidden":"true"},[u("path",{d:"M5 12h14M13 5l7 7-7 7"})],-1))])],8,rd))),128)),s.filteredThreads.length?D("",!0):(m(),_("div",dd,L(s.t("onboarding.noResults",{query:i.query})),1))])])):D("",!0)])}const hd=we(Pu,[["render",fd],["__scopeId","data-v-28c0780b"]]);function md(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 pd={name:"WmActionResult",props:{state:{type:String,default:"success"},label:{type:String,required:!0},detail:{type:String,default:""}},computed:{detailText(){return md(this.detail)}}},gd={class:"wm-result__icon","aria-hidden":"true"},_d={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"},yd={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"},vd={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"},bd={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"},wd={class:"wm-result__body"},kd={class:"wm-result__label"},Cd={class:"wm-result__detail"};function Sd(e,t,n,r,i,s){return m(),_("div",{class:se(["wm-result",`wm-result--${n.state}`])},[u("span",gd,[n.state==="success"?(m(),_("svg",_d,[...t[0]||(t[0]=[u("path",{d:"M20 6L9 17l-5-5"},null,-1)])])):n.state==="rejected"?(m(),_("svg",yd,[...t[1]||(t[1]=[u("path",{d:"M18 6L6 18M6 6l12 12"},null,-1)])])):n.state==="awaiting"?(m(),_("svg",vd,[...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)])])):(m(),_("svg",bd,[...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",wd,[u("span",kd,L(n.label),1),s.detailText?(m(),_(te,{key:0},[t[4]||(t[4]=u("span",{class:"wm-result__sep","aria-hidden":"true"}," · ",-1)),u("span",Cd,L(s.detailText),1)],64)):D("",!0)])],2)}const Ad=we(pd,[["render",Sd],["__scopeId","data-v-7284acd0"]]),xd={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:[]}}},Td={class:"wm-art wm-art--formResponse"},Md={class:"wm-art__head"},Ed={class:"wm-art__title"},Od={class:"wm-art__badge wm-art__badge--success"},Id={class:"wm-art__body"},Ld={class:"wm-art__fieldLabel"};function Rd(e,t,n,r,i,s){return m(),_("div",Td,[u("div",Md,[u("div",Ed,L(n.data.title||s.t("form.title")),1),u("span",Od,[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)),es(" "+L(s.t("form.sent")),1)])]),u("div",Id,[(m(!0),_(te,null,Me(s.fields,(o,a)=>(m(),_("div",{key:a,class:"wm-art__field"},[u("div",Ld,L(o.label),1),u("div",{class:se(["wm-art__fieldValue",{"wm-art__fieldValue--multi":o.multiline}])},L(o.value),3)]))),128))])])}const Bd=we(xd,[["render",Rd],["__scopeId","data-v-713aecf1"]]),Nd={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}}},Pd={class:"wm-art wm-art--infoCard"},Fd={key:0,class:"wm-art__image"},Dd=["src","alt"],jd={class:"wm-art__head"},Ud={class:"wm-art__headMain"},Hd={class:"wm-art__title"},$d={key:0,class:"wm-art__subtitle"},Vd={key:1,class:"wm-art__body"},Kd={key:0,class:"wm-art__text"},qd={class:"wm-art__fieldLabel"};function Wd(e,t,n,r,i,s){return m(),_("div",Pd,[n.data.image_url?(m(),_("figure",Fd,[u("img",{src:n.data.image_url,alt:n.data.title||"",loading:"lazy"},null,8,Dd)])):D("",!0),u("div",jd,[u("div",Ud,[u("div",Hd,L(n.data.title),1),n.data.subtitle?(m(),_("div",$d,L(n.data.subtitle),1)):D("",!0)]),n.data.badge&&n.data.badge.label?(m(),_("span",{key:0,class:se(["wm-art__badge",`wm-art__badge--${n.data.badge.tone||"neutral"}`])},L(n.data.badge.label),3)):D("",!0)]),s.hasBody?(m(),_("div",Vd,[n.data.body?(m(),_("div",Kd,L(n.data.body),1)):D("",!0),s.fields.length?(m(!0),_(te,{key:1},Me(s.fields,(o,a)=>(m(),_("div",{key:a,class:"wm-art__field"},[u("div",qd,L(o.label),1),u("div",{class:se(["wm-art__fieldValue",{"wm-art__fieldValue--multi":o.multiline}])},L(o.value),3)]))),128)):D("",!0)])):D("",!0)])}const zd=we(Nd,[["render",Wd],["__scopeId","data-v-7eae0e4a"]]);function Gd(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 Yd={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 Gd((e=this.data)==null?void 0:e.created_at,bn(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}}},Jd={class:"wm-art wm-art--ticket"},Xd={class:"wm-art__head wm-tk__head"},Qd={class:"wm-art__title wm-tk__title"},Zd={class:"wm-tk__sub"},ef={class:"wm-tk__ref"},tf={key:0,class:"wm-tk__text"},nf={key:0,class:"wm-art__body"},sf={class:"wm-art__fieldLabel"},rf=["data-level"],of={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"},af={key:1,class:"wm-art__footer wm-tk__footer"};function lf(e,t,n,r,i,s){return m(),_("div",Jd,[u("div",Xd,[u("div",Qd,L(n.data.title),1),u("div",Zd,[u("div",ef,[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,L(n.data.reference),1)]),u("span",{class:se(["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)),es(" "+L(n.data.status.label),1)],2)]),n.data.body?(m(),_("div",tf,L(n.data.body),1)):D("",!0)]),s.fields.length?(m(),_("div",nf,[(m(!0),_(te,null,Me(s.fields,(o,a)=>(m(),_("div",{key:a,class:"wm-art__field"},[u("div",sf,L(o.label),1),u("div",{class:se(["wm-art__fieldValue",{"wm-art__fieldValue--multi":o.multiline}])},[s.isPriority(o.label)?(m(),_("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,rf)):s.isDate(o.label)?(m(),_("svg",of,[...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)])])):D("",!0),u("span",null,L(o.value),1)],2)]))),128))])):D("",!0),n.data.created_at?(m(),_("div",af,[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,L(s.formattedDate),1)])):D("",!0)])}const cf={form_response:Bd,info_card:zd,ticket:we(Yd,[["render",lf],["__scopeId","data-v-5f30c914"]])},uf={name:"WmArtifactRenderer",props:{artifact:{type:Object,required:!0}},computed:{component(){var t;const e=(t=this.artifact)==null?void 0:t.kind;return e&&cf[e]||null}}};function df(e,t,n,r,i,s){return s.component?(m(),be(Ha(s.component),{key:0,data:n.artifact.data},null,8,["data"])):D("",!0)}const ff=we(uf,[["render",df]]),hf={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()}}},mf=["href"],pf=["src","alt"],gf=["src"],_f=["src"],yf=["href","download"],vf={class:"wm-att__main"},bf={class:"wm-att__name"},wf={key:0,class:"wm-att__meta"},kf={key:0,class:"wm-att__spin","aria-hidden":"true"};function Cf(e,t,n,r,i,s){return m(),_("div",{class:se(["wm-att",["wm-att--"+(s.kind||"file")]])},[s.kind==="image"&&i.url?(m(),_("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,pf)],8,mf)):s.kind==="audio"&&i.url?(m(),_("audio",{key:1,src:i.url,controls:"",preload:"metadata"},null,8,gf)):s.kind==="video"&&i.url?(m(),_("video",{key:2,src:i.url,controls:"",preload:"metadata"},null,8,_f)):(m(),_("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",vf,[u("span",bf,L(s.displayName),1),s.sizeLabel?(m(),_("span",wf,L(s.sizeLabel),1)):D("",!0)]),i.loading?(m(),_("span",kf)):D("",!0)],8,yf))],2)}const Sf=we(hf,[["render",Cf],["__scopeId","data-v-0c877a62"]]),Af={name:"WmBubble",props:{role:{type:String,default:"ai"},text:{type:String,default:""}},computed:{rendered(){return Nu(this.text)}}},xf=["innerHTML"];function Tf(e,t,n,r,i,s){return m(),_("div",{class:se(["wm-bubble","wm-bubble--"+n.role])},[$a(e.$slots,"default",{},()=>[u("span",{innerHTML:s.rendered},null,8,xf)])],2)}const Mf=we(Af,[["render",Tf],["__scopeId","data-v-7ab13147"]]),Ef={name:"WmTyping"},Of={class:"wm-typing"};function If(e,t,n,r,i,s){return m(),_("div",Of,[...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 Lf=we(Ef,[["render",If],["__scopeId","data-v-df2447fd"]]);function Bt(e){return e?e.client_msg_id||e.id:""}const Rf={transferred_to_human:"system.transferredToHuman",assigned:"system.assigned",unassigned:"system.unassigned",resolved:"system.resolved",reopened:"system.reopened",idle:"system.idle"},Bf=80,Nf=200,Pf={name:"WmMessageList",components:{AIAvatar:kn,HumanAvatar:wo,Bubble:Mf,Typing:Lf,ActionResult:Ad,AttachmentPreview:Sf,ArtifactRenderer:ff},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({})}},computed:{historyExhausted(){return!this.hasMore&&!this.loadingMore&&this.messages.length>=20},groups(){var n,r,i,s;const e=[];for(const o of this.messages){const a=this.roleOf(o);if(a==="system"){if(((n=o==null?void 0:o.payload)==null?void 0:n.event)==="action_admin_pending"){const c=e[e.length-1];c&&c.role==="ai"?c.messages.push(o):e.push({key:`g-${Bt(o)}`,role:"ai",agentName:"",agentAvatarUrl:null,messages:[o],items:[]});continue}e.push({key:`sys-${Bt(o)}`,role:a,messages:[o],items:[],systemLabel:this.systemLabel(o)});continue}const l=e[e.length-1];l&&l.role===a&&(a==="ai"||l.agentName===(((r=o==null?void 0:o.author)==null?void 0:r.name)||""))?l.messages.push(o):e.push({key:`g-${Bt(o)}`,role:a,agentName:((i=o==null?void 0:o.author)==null?void 0:i.name)||"",agentAvatarUrl:((s=o==null?void 0:o.author)==null?void 0:s.avatar_url)||null,messages:[o],items:[]})}for(const o of e){if(o.role==="system")continue;const a=[];for(const l of o.messages)for(const d of this.itemsOf(l))a.push(d);o.items=a}const t=[];for(const o of e){if(o.role!=="system"&&!o.items.length)continue;const a=t[t.length-1];if(a&&a.role!=="system"&&a.role===o.role&&(o.role==="ai"||a.agentName===o.agentName)){a.messages.push(...o.messages),a.items.push(...o.items);continue}t.push(o)}for(const o of t)o.role!=="system"&&(o.key=this.stableGroupKey(o.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=Ct(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)},updated(){this.scheduleMeasure()},methods:{messageKey:Bt,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=Bt(r);if(i&&t.has(i)){n=t.get(i);break}}n==null&&(n=++this._groupIdCounter);for(const r of e){const i=Bt(r);i&&t.set(i,n)}return`g-${n}`},isAtBottom(e){return e.scrollHeight-e.scrollTop-e.clientHeight<=Bf},onScroll(){const e=this.$refs.scrollEl;e&&(this.loadingMore||!this.hasMore||this._pendingLoadMore||e.scrollTop<=Nf&&(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 H,ne,ge;const n=e.items,r=(H=n[t])==null?void 0:H.kind,i=(ne=n[t-1])==null?void 0:ne.kind,s=(ge=n[t+1])==null?void 0:ge.kind,o=e.role==="user",a=14,l=4,d=i==null?void 0:i.bottom,c=s==null?void 0:s.top,p=this.widthByKey[this.rowKeyOf(e,t)],A=this.widthByKey[this.rowKeyOf(e,t-1)],C=this.widthByKey[this.rowKeyOf(e,t+1)],q=.5,R=(ve,ke,J)=>ve!=null&&p!=null?ve+q>=p:ke===J||ke==="card"&&J==="bubble";let Z=a,Y=a,z=a,ee=a;return o?(d&&(Y=l),(c||!s)&&(z=l),d&&R(A,d,r==null?void 0:r.top)&&(Z=l),c&&R(C,c,r==null?void 0:r.bottom)&&(ee=l)):(d&&(Z=l),(c||!s)&&(ee=l),d&&R(A,d,r==null?void 0:r.top)&&(Y=l),c&&R(C,c,r==null?void 0:r.bottom)&&(z=l)),{tl:Z,tr:Y,br:z,bl:ee}},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?`${Bt(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)},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 po(new Date(n.created_at),bn(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;const t=e==null?void 0:e.payload;return t?t.state==="success"?((n=t.success)==null?void 0:n.summary)||((i=(r=t.success)==null?void 0:r.metadata)==null?void 0:i.description)||"":t.state==="rejected"?((s=t.rejected)==null?void 0:s.reason)||this.t("action.rejectedByUser"):t.state==="failure"&&(((o=t.failure)==null?void 0:o.summary)||((a=t.failure)==null?void 0:a.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=Rf[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)}}},Ff={key:0,class:"wm-list__loadMore",role:"status","aria-live":"polite"},Df={class:"wm-list__loadMore-lbl"},jf={key:1,class:"wm-list__historyEnd"},Uf={key:2,class:"wm-list__sep"},Hf={class:"wm-list__sep-label"},$f={key:0,class:"wm-list__sep wm-list__sep--unread"},Vf={class:"wm-list__sep-label wm-list__sep-label--unread"},Kf={key:0,class:"wm-list__sysep"},qf={class:"wm-list__sysep-label"},Wf=["data-row-key"],zf={key:0,class:"wm-list__avatarSlot"},Gf={key:5,class:"wm-list__body"},Yf={key:0},Jf={key:1,"aria-hidden":"true"},Xf={key:2},Qf={key:3,class:"wm-list__row wm-list__row--ai fade-up"},Zf={class:"wm-list__avatarSlot"};function eh(e,t,n,r,i,s){const o=_e("AIAvatar"),a=_e("HumanAvatar"),l=_e("ActionResult"),d=_e("ArtifactRenderer"),c=_e("Bubble"),p=_e("AttachmentPreview"),A=_e("Typing");return m(),_("div",{ref:"scrollEl",class:se(["wm-list",{"wm-list--silent":i.silentFades}]),onScrollPassive:t[0]||(t[0]=(...C)=>s.onScroll&&s.onScroll(...C))},[n.loadingMore?(m(),_("div",Ff,[t[1]||(t[1]=u("span",{class:"wm-list__loadMore-spinner","aria-hidden":"true"},null,-1)),u("span",Df,L(s.t("messageList.loadingHistory")),1)])):s.historyExhausted?(m(),_("div",jf,L(s.t("messageList.conversationStart")),1)):D("",!0),n.dateLabel?(m(),_("div",Uf,[t[2]||(t[2]=u("div",{class:"wm-list__line"},null,-1)),u("span",Hf,L(n.dateLabel),1),t[3]||(t[3]=u("div",{class:"wm-list__line"},null,-1))])):D("",!0),(m(!0),_(te,null,Me(s.groups,(C,q)=>(m(),_(te,{key:C.key},[C.key===s.unreadGroupKey?(m(),_("div",$f,[t[4]||(t[4]=u("div",{class:"wm-list__line wm-list__line--unread"},null,-1)),u("span",Vf,L(s.t("messageList.unread")),1),t[5]||(t[5]=u("div",{class:"wm-list__line wm-list__line--unread"},null,-1))])):D("",!0),C.role==="system"||C.items.length?(m(),_("div",{key:1,class:se(["wm-list__group","wm-list__group--"+C.role])},[C.role==="system"?(m(),_("div",Kf,[t[6]||(t[6]=u("div",{class:"wm-list__line wm-list__line--strong"},null,-1)),u("span",qf,L(C.systemLabel),1),t[7]||(t[7]=u("div",{class:"wm-list__line wm-list__line--strong"},null,-1))])):(m(),_(te,{key:1},[(m(!0),_(te,null,Me(C.items,(R,Z)=>(m(),_("div",{key:`${s.messageKey(R.message)}-${R.partKey}`,"data-row-key":`${s.messageKey(R.message)}-${R.partKey}`,class:se(["wm-list__row fade-up",["wm-list__row--"+C.role,{"is-pending":R.message._pending,"is-failed":R.message._failed}]]),style:je(s.cornersStyle(C,Z))},[C.role!=="user"?(m(),_("div",zf,[Z===C.items.length-1?(m(),_(te,{key:0},[C.role==="ai"?(m(),be(o,{key:0,size:26,tail:!0,name:n.aiAgentName,"image-url":n.aiAgentAvatarUrl},null,8,["name","image-url"])):(m(),be(a,{key:1,name:C.agentName,"avatar-url":C.agentAvatarUrl,size:26,tail:!0},null,8,["name","avatar-url"]))],64)):D("",!0)])):D("",!0),R.renderAs==="action"?(m(),be(l,{key:1,state:R.message.payload.state,label:s.actionLabel(R.message),detail:s.actionDetail(R.message)},null,8,["state","label","detail"])):R.renderAs==="admin-pending"?(m(),be(l,{key:2,state:"awaiting",label:s.t("messageList.approvalRequestSent"),detail:R.message.text_md||""},null,8,["label","detail"])):R.renderAs==="artifact-of-action"?(m(),be(d,{key:3,artifact:s.actionArtifact(R.message)},null,8,["artifact"])):R.renderAs==="artifact"?(m(),be(d,{key:4,artifact:s.artifactOf(R.message)},null,8,["artifact"])):(m(),_("div",Gf,[R.message.text_md?(m(),be(c,{key:0,role:C.role,text:R.message.text_md},null,8,["role","text"])):D("",!0),s.attachmentsOf(R.message).length?(m(),_("div",{key:1,class:se(["wm-list__atts",{"wm-list__atts--align-end":C.role==="user"}])},[(m(!0),_(te,null,Me(s.attachmentsOf(R.message),(Y,z)=>(m(),be(p,{key:`${s.messageKey(R.message)}-att-${z}`,attachment:Y},null,8,["attachment"]))),128))],2)):D("",!0)]))],14,Wf))),128)),(C.role!=="user"||s.lastTimeOf(C))&&!s.hasTrailingOverlay(C)?(m(),_("div",{key:0,class:se(["wm-list__meta",{"wm-list__meta--right":C.role==="user"}])},[C.role!=="user"?(m(),_("span",Yf,L(s.roleLabel(C)),1)):D("",!0),C.role!=="user"&&s.lastTimeOf(C)?(m(),_("span",Jf,"·")):D("",!0),s.lastTimeOf(C)?(m(),_("span",Xf,L(s.lastTimeOf(C)),1)):D("",!0)],2)):D("",!0)],64))],2)):D("",!0)],64))),128)),n.streamingActive?(m(),_("div",Qf,[u("div",Zf,[ye(o,{size:26,tail:!0,name:n.aiAgentName,"image-url":n.aiAgentAvatarUrl},null,8,["name","image-url"])]),ye(A)])):D("",!0)],34)}const th=we(Pf,[["render",eh],["__scopeId","data-v-d769b193"]]),rs=typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function",Qs=typeof window<"u"&&typeof window.MediaRecorder<"u";function nh(){return Qs&&["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 Ao({audio:e}){return{video:!0,audio:!!e,selfBrowserSurface:"include",surfaceSwitching:"include",systemAudio:e?"include":"exclude"}}async function sh(){if(!rs)return null;let e;try{e=await navigator.mediaDevices.getDisplayMedia(Ao({audio:!1}))}catch(t){return(t==null?void 0:t.name)!=="NotAllowedError"&&console.error("[media] screenshot picker",t),null}try{return await rh(e)}catch(t){return console.error("[media] screenshot capture",t),null}finally{e.getTracks().forEach(t=>{t.stop()})}}async function rh(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 ih(e={}){var d;if(!rs||!Qs)return null;let t;try{t=await navigator.mediaDevices.getDisplayMedia(Ao({audio:!0}))}catch(c){return(c==null?void 0:c.name)!=="NotAllowedError"&&console.error("[media] record picker",c),null}const n=nh();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(p=>{p.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,p;if(s&&clearInterval(s),t.getTracks().forEach(A=>{A.stop()}),i.length){const A=r.mimeType||n||"video/webm",C=new Blob(i,{type:A}),q=/mp4/.test(A)?"mp4":"webm",R=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),Z=new File([C],`ecran-${R}.${q}`,{type:A});(c=e.onfinalize)==null||c.call(e,Z)}else(p=e.oncancel)==null||p.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(p=>{p.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 oh=[{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"}],ah={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"}},emits:["update:modelValue","send","attach"],data(){return{local:this.modelValue,attachOpen:!1,recording:!1,recordingElapsed:0,recorder:null}},computed:{canSend(){return!this.disabled&&!!this.local.trim()},attachItems(){return oh.map(e=>({...e,label:this.t(e.labelKey),disabled:e.action==="screenshot"&&!rs||e.action==="record"&&(!rs||!Qs)}))},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()},beforeUnmount(){if(this.recorder)try{this.recorder.stop()}catch{}},methods:{focus(){const e=this.$refs.inputEl;if(!(!e||this.disabled))try{e.focus({preventScroll:!0})}catch{e.focus()}},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;e&&(e.style.height="auto",e.style.height=`${e.scrollHeight}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 sh();e&&this.$emit("attach",e)},async startRecording(){if(this.recording||this.disabled)return;this.recordingElapsed=0;const e=await ih({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)}}}},lh={class:"wm-compose-wrap"},ch={key:0,class:"wm-rec"},uh={class:"wm-rec__lbl"},dh={key:1,class:"wm-compose__menu",role:"menu"},fh=["disabled","onClick"],hh={class:"wm-compose__menuIcon"},mh={viewBox:"0 0 24 24",width:"14",height:"14","aria-hidden":"true"},ph=["d"],gh=["placeholder","disabled"],_h={class:"wm-compose__actions"},yh=["title","aria-label","disabled"],vh=["disabled","aria-label"];function bh(e,t,n,r,i,s){return m(),_("div",lh,[i.recording?(m(),_("div",ch,[t[8]||(t[8]=u("span",{class:"wm-rec__dot","aria-hidden":"true"},null,-1)),u("span",uh,L(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))},L(s.t("composer.stop")),1)])):D("",!0),u("form",{class:se(["wm-compose",{"has-attach":i.attachOpen}]),onSubmit:t[7]||(t[7]=kt((...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?(m(),_("div",{key:0,class:"wm-compose__overlay",onClick:t[2]||(t[2]=o=>i.attachOpen=!1)})):D("",!0),i.attachOpen?(m(),_("div",dh,[(m(!0),_(te,null,Me(s.attachItems,o=>(m(),_("button",{key:o.action,type:"button",class:"wm-compose__menuItem",disabled:o.disabled,onClick:a=>s.onAttachAction(o.action)},[u("span",hh,[(m(),_("svg",mh,[u("path",{d:o.path,stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round",fill:"none"},null,8,ph)]))]),u("span",null,L(o.label),1)],8,fh))),128))])):D("",!0),ut(u("textarea",{ref:"inputEl","onUpdate:modelValue":t[3]||(t[3]=o=>i.local=o),class:"wm-compose__input",rows:"3",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))},null,40,gh),[[Rt,i.local]]),u("div",_h,[u("button",{type:"button",class:se(["wm-compose__icon",{"is-open":i.attachOpen}]),title:n.attachLabel,"aria-label":n.attachLabel,disabled:i.recording,onClick:t[6]||(t[6]=o=>i.attachOpen=!i.attachOpen)},[...t[9]||(t[9]=[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)])],10,yh),u("button",{type:"submit",class:se(["wm-compose__send",{"is-empty":!s.canSend}]),disabled:!s.canSend,"aria-label":s.t("composer.send")},[...t[10]||(t[10]=[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:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})],-1)])],10,vh)])],34)])}const wh=we(ah,[["render",bh],["__scopeId","data-v-aa81dbb8"]]),kh={name:"WmSuggestionChips",props:{items:{type:Array,default:()=>[]},baseDelay:{type:Number,default:360},stepDelay:{type:Number,default:90}},emits:["select"],computed:{batchKey(){return this.items.map(e=>(e==null?void 0:e.label)||(e==null?void 0:e.text)||"").join("§")}}},Ch=["onClick"];function Sh(e,t,n,r,i,s){return n.items.length?(m(),_("div",{key:s.batchKey,class:"wm-chips"},[(m(!0),_(te,null,Me(n.items,(o,a)=>(m(),_("button",{key:a,type:"button",class:"wm-chip",style:je({animationDelay:n.baseDelay+a*n.stepDelay+"ms"}),onClick:l=>e.$emit("select",o)},L(o.label),13,Ch))),128))])):D("",!0)}const Ah=we(kh,[["render",Sh],["__scopeId","data-v-47ad8085"]]),xh={name:"WmApprovalCard",components:{AIAvatar:kn},inject:{t:{default:()=>Ee()}},props:{action:{type:String,required:!0},detail:{type:String,default:""},callbacks:{type:Array,default:()=>[]},agentName:{type:String,default:""},agentAvatarUrl:{type:String,default:null}},emits:["callback"],computed:{approveCallback(){return this.callbacks.find(e=>e.id==="approve"||e.style==="primary")||this.callbacks[0]},rejectCallback(){return this.callbacks.find(e=>e.id==="reject"||e.style==="danger"||e.style==="neutral")||(this.callbacks.length>1?this.callbacks[1]:null)},approveId(){var e;return(e=this.approveCallback)==null?void 0:e.id},rejectId(){var e;return(e=this.rejectCallback)==null?void 0:e.id},approveLabel(){var e;return((e=this.approveCallback)==null?void 0:e.label)||this.t("approval.approve")},rejectLabel(){var e;return((e=this.rejectCallback)==null?void 0:e.label)||this.t("approval.reject")}}},Th={class:"wm-approval"},Mh={class:"wm-approval__head"},Eh={class:"wm-approval__icon"},Oh={class:"wm-approval__main"},Ih={class:"wm-approval__title"},Lh={key:0,class:"wm-approval__detail"},Rh={class:"wm-approval__actions"};function Bh(e,t,n,r,i,s){const o=_e("AIAvatar");return m(),_("div",Th,[u("div",Mh,[u("div",Eh,[ye(o,{size:24,name:n.agentName,"image-url":n.agentAvatarUrl},null,8,["name","image-url"])]),u("div",Oh,[u("div",Ih,L(n.action),1),n.detail?(m(),_("div",Lh,L(n.detail),1)):D("",!0)])]),u("div",Rh,[s.rejectId?(m(),_("button",{key:0,type:"button",class:"wm-approval__btn wm-approval__btn--neutral",onClick:t[0]||(t[0]=a=>e.$emit("callback",s.rejectId))},L(s.rejectLabel),1)):D("",!0),s.approveId?(m(),_("button",{key:1,type:"button",class:"wm-approval__btn wm-approval__btn--primary",onClick:t[1]||(t[1]=a=>e.$emit("callback",s.approveId))},L(s.approveLabel),1)):D("",!0)])])}const Nh=we(xh,[["render",Bh],["__scopeId","data-v-a2bed37e"]]);let xo=0;const Ph=new Set(["text","textarea","number","boolean","select","multiselect","date"]),Fh={name:"WmFormCard",components:{AIAvatar:kn},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 xo+=1,{_uid:xo,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)||!Ph.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}}}},Dh={class:"wm-form"},jh={class:"wm-form__head"},Uh={class:"wm-form__icon"},Hh={class:"wm-form__main"},$h={class:"wm-form__title"},Vh={key:0,class:"wm-form__detail"},Kh=["for"],qh={key:0,class:"wm-form__req","aria-hidden":"true"},Wh=["id","onUpdate:modelValue","placeholder","required","disabled"],zh=["id","onUpdate:modelValue","placeholder","required","disabled"],Gh=["id","onUpdate:modelValue","placeholder","required","disabled"],Yh=["id","onUpdate:modelValue","required","disabled"],Jh={key:4,class:"wm-form__bool"},Xh=["id","onUpdate:modelValue","disabled"],Qh=["id","onUpdate:modelValue","required","disabled"],Zh={value:"",disabled:""},em=["value"],tm={key:6,class:"wm-form__multi"},nm=["value","checked","disabled","onChange"],sm={key:0,class:"wm-form__err"},rm=["disabled"],im={key:0,class:"wm-form__spinner","aria-hidden":"true"},om={key:2,class:"wm-form__doneLbl"};function am(e,t,n,r,i,s){const o=_e("AIAvatar");return m(),_("div",Dh,[u("div",jh,[u("div",Uh,[ye(o,{size:24,name:n.agentName,"image-url":n.agentAvatarUrl},null,8,["name","image-url"])]),u("div",Hh,[u("div",$h,L(n.form.title||s.t("form.title")),1),n.form.description?(m(),_("div",Vh,L(n.form.description),1)):D("",!0)])]),u("form",{class:"wm-form__body",onSubmit:t[0]||(t[0]=kt((...a)=>s.onSubmit&&s.onSubmit(...a),["prevent"]))},[(m(!0),_(te,null,Me(s.normalizedFields,a=>(m(),_("div",{key:a.key,class:"wm-form__field"},[u("label",{for:`wm-f-${i._uid}-${a.key}`,class:"wm-form__label"},[es(L(a.label),1),a.required?(m(),_("span",qh,"*")):D("",!0)],8,Kh),a.type==="text"?ut((m(),_("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,Wh)),[[Rt,i.values[a.key]]]):a.type==="textarea"?ut((m(),_("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,zh)),[[Rt,i.values[a.key]]]):a.type==="number"?ut((m(),_("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,Gh)),[[Rt,i.values[a.key],void 0,{number:!0}]]):a.type==="date"?ut((m(),_("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,Yh)),[[Rt,i.values[a.key]]]):a.type==="boolean"?(m(),_("label",Jh,[ut(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,Xh),[[ic,i.values[a.key]]]),u("span",null,L(a.placeholder||s.t("common.yes")),1)])):a.type==="select"?ut((m(),_("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",Zh,L(a.placeholder||s.t("form.choose")),1),(m(!0),_(te,null,Me(a.options,l=>(m(),_("option",{key:l.value,value:l.value},L(l.label),9,em))),128))],8,Qh)),[[oc,i.values[a.key]]]):a.type==="multiselect"?(m(),_("div",tm,[(m(!0),_(te,null,Me(a.options,l=>(m(),_("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,nm),u("span",null,L(l.label),1)]))),128))])):D("",!0)]))),128)),i.error?(m(),_("div",sm,L(i.error),1)):D("",!0),n.readOnly?(m(),_("div",om,L(s.t("form.responseSent")),1)):(m(),_("button",{key:1,type:"submit",class:"wm-form__submit",disabled:i.busy},[i.busy?(m(),_("span",im)):D("",!0),u("span",null,L(i.busy?s.t("common.sending"):n.form.submit_label||s.t("common.send")),1)],8,rm))],32)])}const lm=we(Fh,[["render",am],["__scopeId","data-v-fe65cc56"]]),cm={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})}}},um={class:"wm-fb"},dm={class:"wm-fb__title"},fm={class:"wm-fb__sub"},hm={class:"wm-fb__row"},mm=["onClick"],pm={class:"wm-fb__emoji"},gm={class:"wm-fb__label"},_m=["disabled"],ym={key:1,class:"wm-fb__done"},vm={class:"wm-fb__doneTitle"},bm={class:"wm-fb__doneSub"};function wm(e,t,n,r,i,s){return m(),_("div",um,[n.done?(m(),_("div",ym,[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",vm,L(s.t("feedback.doneTitle")),1),u("div",bm,L(s.t("feedback.doneSubtitle")),1)])):(m(),_(te,{key:0},[u("div",dm,L(s.t("feedback.question")),1),u("div",fm,L(s.t("feedback.subtitle")),1),u("div",hm,[(m(!0),_(te,null,Me(s.options,o=>(m(),_("button",{key:o.v,type:"button",class:se(["wm-fb__opt",{"is-selected":i.sel===o.v}]),onClick:a=>i.sel=o.v},[u("span",pm,L(o.e),1),u("span",gm,L(o.l),1)],10,mm))),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))},L(n.busy?s.t("common.sending"):s.t("feedback.submit")),9,_m)],64))])}const km=we(cm,[["render",wm],["__scopeId","data-v-9b630564"]]),Cm={name:"WmMoreMenu",inject:{t:{default:()=>Ee()}},props:{canRename:{type:Boolean,default:!0},canExport:{type:Boolean,default:!0},soundEnabled:{type:Boolean,default:!0},browserNotifEnabled:{type:Boolean,default:!1},statusUrl:{type:String,default:""},helpUrl:{type:String,default:""}},emits:["close","action","sound-toggle","browser-notif-toggle"],data(){return{soundOn:this.soundEnabled,browserNotifOn:this.browserNotifEnabled}},watch:{soundEnabled(e){this.soundOn=!!e},browserNotifEnabled(e){this.browserNotifOn=!!e}},methods:{emit(e){this.$emit("action",e)},toggleSound(){this.soundOn=!this.soundOn,this.$emit("sound-toggle",this.soundOn)},toggleBrowserNotif(){this.browserNotifOn=!this.browserNotifOn,this.$emit("browser-notif-toggle",this.browserNotifOn)}}},Sm={class:"wm-mm"},Am={class:"wm-mm__pop",role:"menu"},xm={key:0,class:"wm-mm__section"},Tm={class:"wm-mm__label"},Mm={class:"wm-mm__label"},Em={key:1,class:"wm-mm__sep"},Om={class:"wm-mm__section"},Im={class:"wm-mm__label"},Lm={class:"wm-mm__label"},Rm={class:"wm-mm__section"},Bm={class:"wm-mm__label"},Nm={class:"wm-mm__label"};function Pm(e,t,n,r,i,s){return m(),_("div",Sm,[u("div",{class:"wm-mm__scrim",onClick:t[0]||(t[0]=o=>e.$emit("close"))}),u("div",Am,[n.canRename||n.canExport?(m(),_("div",xm,[n.canRename?(m(),_("button",{key:0,type:"button",class:"wm-mm__item",onClick:t[1]||(t[1]=o=>s.emit("rename"))},[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:"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",Tm,L(s.t("moreMenu.editTitle")),1)])):D("",!0),n.canExport?(m(),_("button",{key:1,type:"button",class:"wm-mm__item",onClick:t[2]||(t[2]=o=>s.emit("export"))},[t[8]||(t[8]=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",Mm,L(s.t("moreMenu.exportTranscript")),1),t[9]||(t[9]=u("span",{class:"wm-mm__hint"},".txt",-1))])):D("",!0)])):D("",!0),n.canRename||n.canExport?(m(),_("div",Em)):D("",!0),u("div",Om,[u("button",{type:"button",class:"wm-mm__item",onClick:t[3]||(t[3]=(...o)=>s.toggleSound&&s.toggleSound(...o))},[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:"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",Im,L(s.t("moreMenu.sound")),1),u("span",{class:se(["wm-mm__toggle",{"wm-mm__toggle--on":i.soundOn}])},[...t[10]||(t[10]=[u("span",{class:"wm-mm__knob"},null,-1)])],2)]),u("button",{type:"button",class:"wm-mm__item",onClick:t[4]||(t[4]=(...o)=>s.toggleBrowserNotif&&s.toggleBrowserNotif(...o))},[t[13]||(t[13]=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:"M15 17h5l-1.4-1.4A2 2 0 0118 14.2V11a6 6 0 10-12 0v3.2c0 .5-.2 1-.6 1.4L4 17h5m6 0a3 3 0 11-6 0"})])],-1)),u("span",Lm,L(s.t("moreMenu.browserNotifications")),1),u("span",{class:se(["wm-mm__toggle",{"wm-mm__toggle--on":i.browserNotifOn}])},[...t[12]||(t[12]=[u("span",{class:"wm-mm__knob"},null,-1)])],2)])]),t[16]||(t[16]=u("div",{class:"wm-mm__sep"},null,-1)),u("div",Rm,[n.statusUrl?(m(),_("button",{key:0,type:"button",class:"wm-mm__item",onClick:t[5]||(t[5]=o=>s.emit("status"))},[t[14]||(t[14]=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",Bm,L(s.t("moreMenu.serviceStatus")),1)])):D("",!0),n.helpUrl?(m(),_("button",{key:1,type:"button",class:"wm-mm__item",onClick:t[6]||(t[6]=o=>s.emit("help"))},[t[15]||(t[15]=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",Nm,L(s.t("moreMenu.helpCenter")),1)])):D("",!0)])])])}const Fm=we(Cm,[["render",Pm],["__scopeId","data-v-76281e95"]]),Dm={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())}}},jm={class:"wm-dialog"},Um={class:"wm-dialog__card",role:"dialog","aria-modal":"true"},Hm={class:"wm-dialog__head"},$m={class:"wm-dialog__title"},Vm=["aria-label"],Km={class:"wm-dialog__body"},qm=["placeholder"],Wm={class:"wm-dialog__actions"},zm=["disabled"];function Gm(e,t,n,r,i,s){return m(),_("div",jm,[u("div",{class:"wm-dialog__scrim",onClick:t[0]||(t[0]=o=>e.$emit("close"))}),u("div",Um,[u("div",Hm,[u("div",$m,L(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,Vm)]),u("div",Km,[ut(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]=ss(kt((...o)=>s.onSubmit&&s.onSubmit(...o),["prevent"]),["enter"])),t[4]||(t[4]=ss(kt(o=>e.$emit("close"),["prevent"]),["esc"]))]},null,40,qm),[[Rt,i.value]])]),u("div",Wm,[u("button",{type:"button",class:"wm-dialog__btn",onClick:t[5]||(t[5]=o=>e.$emit("close"))},L(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))},L(s.t("common.save")),9,zm)])])])}const Ym=we(Dm,[["render",Gm],["__scopeId","data-v-6d5f94a8"]]),To="ww-messenger-tokens",Jm={name:"Messenger",components:{Launcher:lu,Header:Lu,Onboarding:hd,MessageList:th,Composer:wh,SuggestionChips:Ah,ApprovalCard:Nh,FormCard:lm,Feedback:km,MoreMenu:Fm,RenameDialog:Ym},mixins:[Lc,Dc,jc,Hc],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:go},widgetId:{type:String,default:""},token:{type:String,default:""},context:{type:Object,default:null},displayMode:{type:String,default:"floating"},devtools:{type:Boolean,default:!1},language:{type:String,default:""}},data(){return{transport:null,store:null,isOpen:!1,draft:"",busy:!1,bootError:null,pendingAttachments:[],feedbackBusy:!1,feedbackDone:!1,convOpenedAt:0,moreOpen:!1,renameDialogOpen:!1,draftConv:null,activeConvId:null,showOnboarding:!1,dismissedPeeks:{},floatHeight:0,floatRO:null}},computed:{isEditor(){return!!this.devtools},isEmbedded(){return this.displayMode==="embedded"},customerLanguage(){var 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 Xs(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=Ct(r.last_read_message_id);let o=0,a=null;for(let c=i.length-1;c>=0;c--){const p=i[c];if(!p)continue;if(((d=p.author)==null?void 0:d.type)==="user")break;const A=Ct(p.id);if(A!=null){if(s!=null&&A<=s)break;t[p.id]!==0&&(!a&&p.author&&(a=p.author),o++)}}const l=i.filter(c=>!((c==null?void 0:c.id)!=null&&t[c.id]===0));return{...r,_preview:Mc(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=>n.status!=="resolved").map(n=>({id:n.id,title:n.name||this.t("common.newConversation"),preview:n._preview||this.t("onboarding.newMessage"),unread:!!n._unread,_ts:bo(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=bo(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)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},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},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},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(){var t;const e=(t=this.currentConv)==null?void 0:t.status;return e==="waiting"||e==="handled"},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 n,r;const e=this.currentConv;if(!e)return[];if(!e._draft){const i=(r=(n=this.s)==null?void 0:n.paginationByConv)==null?void 0:r[e.id];if(!(i!=null&&i.loaded))return[]}const t=this.revealedAt;return(this.s.messagesByConv[e.id]||[]).filter(i=>{var s,o,a,l,d;return(i==null?void 0:i.type)==="action"&&((s=i==null?void 0:i.payload)==null?void 0:s.state)==="pending"||wn(i)&&!(t[i.id]>0)?!1:(i==null?void 0:i.type)==="action"||(i==null?void 0:i.type)==="system"||((o=i==null?void 0:i.payload)==null?void 0:o.type)==="system"||Array.isArray((a=i==null?void 0:i.payload)==null?void 0:a.attachments)&&i.payload.attachments.length||(l=i==null?void 0:i.metadata)!=null&&l.artifact||(d=i==null?void 0:i.metadata)!=null&&d.form?!0:typeof(i==null?void 0:i.text_md)=="string"&&i.text_md.trim().length>0})},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:(((i=(r=this.s)==null?void 0:r.messagesByConv)==null?void 0:i[e.id])||[]).some(s=>wn(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])||[]:[]},pendingApproval(){return!this.currentConv||!this.store||this.actionInFlight?null:this.store.getPendingApproval(this.currentConv.id)},approvalReady(){return this.pendingApproval?this.pendingApproval.id===this.approvalLatchId?!0:!(this.streamingActive||!this.approvalSettled):!1},approvalTitle(){var e,t,n;return((t=(e=this.pendingApproval)==null?void 0:e.payload)==null?void 0:t.name)||((n=this.pendingApproval)==null?void 0:n.text_md)||this.t("action.title")},approvalDetail(){var r,i,s,o,a,l;const e=(s=(i=(r=this.pendingApproval)==null?void 0:r.payload)==null?void 0:i.pending)==null?void 0:s.user_explanation;if(typeof e=="string"&&e.trim())return e.trim();const t=(l=(a=(o=this.pendingApproval)==null?void 0:o.payload)==null?void 0:a.pending)==null?void 0:l.prepared_params;if(!t||typeof t!="object")return"";const n=Object.entries(t);return n.length?n.slice(0,2).map(([d,c])=>`${d}: ${c}`).join(" · "):""},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.store?[]:this.streamingActive?[]:this.pendingForm?[]:this.store.getLatestSuggestions(this.currentConv.id)},pendingForm(){var e,t;return!this.currentConv||!this.store||this.pendingApproval||this.actionInFlight||this.streamingActive||!this.approvalSettled?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.feedbackDone?!0:e.status!=="resolved"?!1:!((t=e.metadata)!=null&&t.feedback):!1},floatVisible(){return this.approvalReady||!!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:po(t,bn(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.resetApprovalPacing(),this.isViewingThread&&(this.unreadAnchorId=Ct((t=this.currentConv)==null?void 0:t.last_read_message_id),this.unreadBoundaryTs=e?new Date().toISOString():"")},immediate:!0},isViewingThread(e,t){var n;e&&!t?(this.unreadAnchorId=Ct((n=this.currentConv)==null?void 0:n.last_read_message_id),this.unreadBoundaryTs=new Date().toISOString()):e||(this.unreadAnchorId=null,this.unreadBoundaryTs="")},pendingApproval:{handler(e,t){if(e&&!t){const n=e!=null&&e.created_at?Date.parse(e.created_at):NaN;if(!(Number.isFinite(n)&&n>=this.convOpenedAt)){this.resetApprovalPacing();return}this.bumpApprovalSettle(2600)}else!e&&t&&this.resetApprovalPacing()},immediate:!1},streamingActive(e,t){e!==t&&this.pendingApproval&&this.pendingApproval.id!==this.approvalLatchId&&this.bumpApprovalSettle()},approvalReady(e){e&&this.pendingApproval&&(this.approvalLatchId=this.pendingApproval.id)},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(To)){const e=document.createElement("style");e.id=To,e.textContent=Sc,document.head.appendChild(e)}this.isEmbedded&&(await this.boot(),this.store&&await this.open())},beforeUnmount(){this.cancelReveals(),this.teardownLiveReveal(),this.disconnectFloatRO(),this.resetApprovalPacing(),this.teardownNotifications(),this.store&&this.store.destroy()},methods:{t(e,t){return this.translator(e,t)},async boot(){var e;if(!this.canBoot){console.warn("[messenger] boot skipped — missing creds");return}try{this.transport=Ss(vc({baseUrl:this.baseUrl,widgetId:this.widgetId,token:this.token||void 0})),this.store=Ss(Cc(this.transport)),this.hydrateNotifPref();const t=(e=this.context)==null?void 0:e.customer;t&&typeof t=="object"&&await this.store.applyCustomer(t),await this.store.start(),this.setupLiveReveal()}catch(t){console.error("[ww-messenger] bootstrap failed",t),this.bootError=(t==null?void 0:t.message)||String(t)}},async refresh(){this.store&&this.store.destroy(),this.cancelReveals(),this.teardownLiveReveal(),this.teardownNotifications(),this.convOpenedAt=0,this.transport=null,this.store=null,this.isOpen=!1,this.draft="",this.busy=!1,this.bootError=null,this.pendingAttachments=[],this.feedbackBusy=!1,this.feedbackDone=!1,this.moreOpen=!1,this.renameDialogOpen=!1,this.draftConv=null,this.activeConvId=null,this.showOnboarding=!1,await this.boot(),this.isEmbedded&&this.store&&await this.open()},syncFloatObserver(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.scrollToBottom)==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.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)}},close(){this.isOpen=!1,this.store&&this.store.setPanelOpen(!1)},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),await this.open()},dismissPeek(e){const t=this.latestUnreads.find(n=>n.convId===e);t&&(this.dismissedPeeks={...this.dismissedPeeks,[e]:t.ts})},startConv(){this.draftConv={id:"__draft__",_draft:!0,name:"",created_at:new Date().toISOString()},this.activeConvId=null,this.showOnboarding=!1,this.focusComposer()},async ensureRealConv(){const 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({});return 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()})},toggleMore(){this.moreOpen=!this.moreOpen},goHome(){this.moreOpen=!1,this.draftConv=null,this.activeConvId=null,this.showOnboarding=!0},async onDrawerPick(e){if(!(e!=null&&e.id)||!this.store)return;this.draftConv=null,this.activeConvId=e.id,this.showOnboarding=!1;try{await this.store.openConversation(e.id)}catch(n){console.error("[ww-messenger] open conv failed",n)}const t=this.allConversations.find(n=>n.id===e.id);t&&this.markConvRead(t)},async onMoreAction(e){var t,n;switch(this.moreOpen=!1,e){case"rename":this.openRenameDialog();break;case"export":Ic(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(this.statusUrl)try{window.open(this.statusUrl,"_blank","noopener")}catch{}break;case"help":if(this.helpUrl)try{window.open(this.helpUrl,"_blank","noopener")}catch{}break}},openRenameDialog(){const 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="",await this.store.send(n,e,{attachments:r.length?r:void 0})},async onSuggestion(e){const t=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 onApprovalCallback(e){const t=this.pendingApproval;t&&await this.store.clickCallback(t.id,e)},async onFormSubmit({values:e}){const t=this.pendingForm;if(!(t!=null&&t.form))return;const n=xc(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:Tc(t.form,e,this.translator)}}))},async onAttach(e){if(!(!e||!this.transport))try{const t=await this.transport.uploadAttachment(e);this.pendingAttachments.push({type:t.type||"file",path:t.path,name:e.name||this.t("attachment.fileFallbackName"),mime_type:e.type,size_bytes:e.size})}catch(t){console.error("[ww-messenger] attachment upload failed",t)}},async onQuickLink(e){if(e){if(e.url){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=!0}catch(n){console.error("[ww-messenger] feedback failed",n)}finally{this.feedbackBusy=!1}}}}},Xm={key:0,class:"wm-loading","aria-busy":"true","aria-live":"polite"},Qm=["aria-label"],Zm={key:0,class:"wm-state"},ep={class:"wm-state__err"},tp={class:"wm-state__errTitle"},np={class:"wm-state__errSub"},sp={class:"wm-bottom"},rp={key:0,ref:"floatEl",class:"wm-float"},ip={key:1,class:"wm-actionWait",role:"status","aria-live":"polite"},op={class:"wm-actionWait__lbl"},ap={key:2,class:"wm-attached"},lp=["aria-label","onClick"];function cp(e,t,n,r,i,s){const o=_e("Launcher"),a=_e("Header"),l=_e("Onboarding"),d=_e("MessageList"),c=_e("ApprovalCard"),p=_e("FormCard"),A=_e("Feedback"),C=_e("SuggestionChips"),q=_e("Composer"),R=_e("MoreMenu"),Z=_e("RenameDialog");return m(),_("div",{class:se(["wm-root",`wm-root--${n.displayMode}`])},[!i.isOpen&&!s.isEmbedded?(m(),be(o,{key:0,"unread-count":s.unreadCount,peeks:s.launcherPeeks,onOpen:s.openFromPeek,onDismiss:s.dismissPeek},null,8,["unread-count","peeks","onOpen","onDismiss"])):D("",!0),i.isOpen||s.isEmbedded?(m(),_("section",{key:1,class:se(["wm-panel",`wm-panel--${n.displayMode}`,{"wm-panel--welcome":s.ready&&!s.error&&!s.currentConv}]),style:je(i.floatHeight?{"--wm-float-h":i.floatHeight+"px"}:null),role:"dialog","aria-label":"Messenger"},[!s.ready&&!s.error?(m(),_("div",Xm,[s.isEmbedded?D("",!0):(m(),_("button",{key:0,type:"button",class:"wm-loading__close","aria-label":s.t("loading.minimize"),onClick:t[0]||(t[0]=(...Y)=>s.close&&s.close(...Y))},[...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,Qm)),t[6]||(t[6]=u("div",{class:"wm-loading__spinner","aria-hidden":"true"},null,-1))])):(m(),_(te,{key:1},[ye(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"]),s.error?(m(),_("div",Zm,[u("div",ep,[t[7]||(t[7]=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",tp,L(s.t("error.connectionFailed")),1),u("div",np,L(s.error),1)])])])):s.currentConv?(m(),_(te,{key:2},[ye(d,{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",sp,[s.floatVisible?(m(),_("div",rp,[s.approvalReady?(m(),be(c,{key:0,action:s.approvalTitle,detail:s.approvalDetail,callbacks:s.pendingApproval.callbacks,"agent-name":s.agentName,"agent-avatar-url":s.agentAvatarUrl,onCallback:s.onApprovalCallback},null,8,["action","detail","callbacks","agent-name","agent-avatar-url","onCallback"])):s.pendingForm?(m(),be(p,{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?(m(),be(A,{key:2,busy:i.feedbackBusy,done:i.feedbackDone,onSubmit:s.onFeedback},null,8,["busy","done","onSubmit"])):(m(),be(C,{key:3,items:s.suggestions,onSelect:s.onSuggestion},null,8,["items","onSelect"]))],512)):D("",!0),s.actionInFlight?(m(),_("div",ip,[t[8]||(t[8]=u("span",{class:"wm-actionWait__spinner","aria-hidden":"true"},null,-1)),u("span",op,L(s.t("action.inProgress",{name:s.actionInFlightName})),1)])):(m(),be(q,{key:2,ref:"composer",modelValue:i.draft,"onUpdate:modelValue":t[1]||(t[1]=Y=>i.draft=Y),placeholder:s.composerPlaceholder,disabled:!!s.pendingApproval,"attach-label":s.t("composer.attachFile"),onSend:s.onSend,onAttach:s.onAttach},null,8,["modelValue","placeholder","disabled","attach-label","onSend","onAttach"]))]),i.moreOpen?(m(),be(R,{key:0,"can-rename":!!s.currentConv&&!s.currentConv._draft,"can-export":!!s.currentConv&&!s.currentConv._draft,"sound-enabled":e.soundEnabled,"browser-notif-enabled":e.browserNotifEnabled,"status-url":s.statusUrl,"help-url":s.helpUrl,onClose:t[2]||(t[2]=Y=>i.moreOpen=!1),onSoundToggle:e.onSoundToggle,onBrowserNotifToggle:e.onBrowserNotifToggle,onAction:s.onMoreAction},null,8,["can-rename","can-export","sound-enabled","browser-notif-enabled","status-url","help-url","onSoundToggle","onBrowserNotifToggle","onAction"])):D("",!0),i.renameDialogOpen&&s.currentConv&&!s.currentConv._draft?(m(),be(Z,{key:1,"initial-value":s.currentConv.name||"",title:s.t("rename.dialogTitle"),onClose:t[3]||(t[3]=Y=>i.renameDialogOpen=!1),onSubmit:s.onRenameSubmit},null,8,["initial-value","title","onSubmit"])):D("",!0),i.pendingAttachments.length?(m(),_("div",ap,[(m(!0),_(te,null,Me(i.pendingAttachments,(Y,z)=>(m(),_("div",{key:z,class:"wm-attached__chip"},[t[10]||(t[10]=u("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[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)),u("span",null,L(Y.name),1),u("button",{type:"button","aria-label":s.t("attachment.remove"),onClick:ee=>i.pendingAttachments.splice(z,1)},[...t[9]||(t[9]=[u("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[u("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,lp)]))),128))])):D("",!0)],64)):(m(),be(l,{key:1,"welcome-message":s.widgetWelcomeMessage,subtitle:s.widgetSubtitle,"agent-name":s.agentName,"default-icon-url":s.defaultIconUrl,"quick-links":s.quickLinks,"open-threads":s.openThreads,busy:i.busy,onStart:s.startConv,onSelect:s.onQuickLink,onResume:s.onDrawerPick},null,8,["welcome-message","subtitle","agent-name","default-icon-url","quick-links","open-threads","busy","onStart","onSelect","onResume"])),i.moreOpen&&!s.currentConv?(m(),be(R,{key:3,"can-rename":!1,"can-export":!1,"sound-enabled":e.soundEnabled,"browser-notif-enabled":e.browserNotifEnabled,"status-url":s.statusUrl,"help-url":s.helpUrl,onClose:t[4]||(t[4]=Y=>i.moreOpen=!1),onSoundToggle:e.onSoundToggle,onBrowserNotifToggle:e.onBrowserNotifToggle,onAction:s.onMoreAction},null,8,["sound-enabled","browser-notif-enabled","status-url","help-url","onSoundToggle","onBrowserNotifToggle","onAction"])):D("",!0)],64))],6)):D("",!0)],2)}const up=we(Jm,[["render",cp],["__scopeId","data-v-966f7d8a"]]),dp="0.5.1";let St=null,Nt=null,Zs="";function fp(e){if(e instanceof Element)return e;if(typeof e=="string"){const n=document.querySelector(e);if(n)return n}const t=document.createElement("div");return t.setAttribute("data-messenger-root",""),document.body.appendChild(t),t}function hp(e){return{baseUrl:String(e.baseUrl||go).trim(),widgetId:String(e.widgetId||"").trim(),token:String(e.token||"").trim(),displayMode:e.displayMode||"floating",devtools:!!e.devtools,language:String(e.language||"").trim(),target:e.target||null,context:e.context&&typeof e.context=="object"?e.context:null}}function mp(e={}){const t=hp(e);if(!t.baseUrl||!t.widgetId)return er(),null;const n=JSON.stringify({...t,target:typeof t.target=="string"?t.target:!!t.target});return St&&n===Zs||(er(),Nt=fp(t.target),St=fc(up,{baseUrl:t.baseUrl,widgetId:t.widgetId,token:t.token||void 0,displayMode:t.displayMode,devtools:t.devtools,language:t.language,context:t.context}),St.mount(Nt),Zs=n),St}function er(){if(St){try{St.unmount()}catch{}St=null}Nt&&Nt.hasAttribute&&Nt.hasAttribute("data-messenger-root")&&Nt.remove(),Nt=null,Zs=""}return Gt.destroy=er,Gt.init=mp,Gt.version=dp,Object.defineProperty(Gt,Symbol.toStringTag,{value:"Module"}),Gt}({});
77
+ `)}return i}const So={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"},Pu={name:"WmOnboarding",components:{AIAvatar:kn},inject:{t:{default:()=>Ee()},wmLocale:{default:()=>()=>"fr"}},props:{welcomeMessage:{type:String,default:""},subtitle:{type:String,default:""},agentName:{type:String,default:""},defaultIconUrl:{type:String,default:null},quickLinks:{type:Array,default:()=>[]},openThreads:{type:Array,default:()=>[]},busy:{type:Boolean,default:!1}},emits:["start","select","resume"],data(){return{query:""}},computed:{heroTitle(){return this.welcomeMessage?this.welcomeMessage:this.agentName?this.t("onboarding.greetingNamed",{name:this.agentName}):this.t("onboarding.greeting")},heroSub(){return this.subtitle||this.t("onboarding.heroSub")},isOddQuickLinks(){return this.quickLinks.length%2===1},quickLinksLayout(){return this.isOddQuickLinks?"wm-onb__qlist":"wm-onb__grid"},filteredThreads(){const e=this.query.trim().toLowerCase();return e?this.openThreads.filter(t=>(t.title||"").toLowerCase().includes(e)||(t.preview||"").toLowerCase().includes(e)):this.openThreads}},methods:{iconPath(e){return So[e]||So.link},renderPreview(e){return Bu(e)},formatTs(e){if(!e)return"";const t=new Date(e);if(Number.isNaN(t.getTime()))return"";const n=bn(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"})}}},Fu={class:"wm-onb"},Du={class:"wm-onb__hero"},ju={class:"wm-onb__hero-text"},Uu={class:"wm-onb__title"},Hu={class:"wm-onb__sub"},$u={class:"wm-onb__cta"},Vu=["disabled"],Ku={key:0,class:"wm-onb__section"},qu={class:"wm-onb__section-title"},Wu=["onClick"],zu={class:"wm-onb__card-icon"},Gu={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"},Yu=["d"],Ju={class:"wm-onb__card-body"},Xu={class:"wm-onb__card-title"},Qu={key:0,class:"wm-onb__card-sub"},Zu={key:1,class:"wm-onb__section"},ed={class:"wm-onb__section-title"},td={class:"wm-onb__search"},nd=["placeholder","aria-label"],sd={class:"wm-onb__list"},rd=["onClick"],id=["aria-label"],od={class:"wm-onb__thread-body"},ad={class:"wm-onb__thread-title"},ld=["innerHTML"],cd={class:"wm-onb__thread-meta"},ud={key:0,class:"wm-onb__thread-time"},dd={key:0,class:"wm-onb__empty"};function fd(e,t,n,r,i,s){const o=_e("AIAvatar");return m(),_("div",Fu,[u("div",Du,[t[2]||(t[2]=u("svg",{class:"wm-onb__hero-deco",width:"180",height:"180",viewBox:"0 0 180 180",fill:"none","aria-hidden":"true"},[u("circle",{cx:"170",cy:"10",r:"105",stroke:"#5B5FEF","stroke-width":"1","stroke-dasharray":"1 5",opacity:"0.35"}),u("circle",{cx:"170",cy:"10",r:"72",stroke:"#5B5FEF","stroke-width":"1","stroke-dasharray":"1 5",opacity:"0.5"}),u("circle",{cx:"152",cy:"34",r:"2.5",fill:"#5B5FEF",opacity:"0.65"})],-1)),ye(o,{size:52,"image-url":n.defaultIconUrl},null,8,["image-url"]),u("div",ju,[u("div",Uu,L(s.heroTitle),1),u("div",Hu,L(s.heroSub),1)])]),u("div",$u,[u("button",{type:"button",class:"wm-onb__startBtn",disabled:n.busy,onClick:t[0]||(t[0]=a=>e.$emit("start"))},[t[3]||(t[3]=u("span",{class:"wm-onb__startIcon"},[u("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[u("path",{d:"M12 5v14M5 12h14"})])],-1)),u("span",null,L(n.busy?"…":s.t("onboarding.start")),1)],8,Vu)]),n.quickLinks.length?(m(),_("div",Ku,[u("div",qu,L(s.t("onboarding.quickAccess")),1),u("div",{class:se(s.quickLinksLayout)},[(m(!0),_(te,null,Me(n.quickLinks,(a,l)=>(m(),_("button",{key:l,type:"button",class:se(["wm-onb__card",{"wm-onb__card--row":s.isOddQuickLinks}]),onClick:d=>e.$emit("select",a)},[u("span",zu,[(m(),_("svg",Gu,[u("path",{d:s.iconPath(a.icon)},null,8,Yu)]))]),u("span",Ju,[u("span",Xu,L(a.label),1),a.description?(m(),_("span",Qu,L(a.description),1)):D("",!0)])],10,Wu))),128))],2)])):D("",!0),n.openThreads.length?(m(),_("div",Zu,[u("div",ed,L(s.t("onboarding.recentConversations")),1),u("div",td,[t[4]||(t[4]=u("span",{class:"wm-onb__searchIcon"},[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:"M21 21l-4.35-4.35M11 17a6 6 0 100-12 6 6 0 000 12z"})])],-1)),ut(u("input",{"onUpdate:modelValue":t[1]||(t[1]=a=>i.query=a),type:"text",placeholder:s.t("onboarding.search"),"aria-label":s.t("onboarding.search")},null,8,nd),[[Rt,i.query]])]),u("div",sd,[(m(!0),_(te,null,Me(s.filteredThreads,a=>(m(),_("button",{key:a.id,type:"button",class:"wm-onb__thread",onClick:l=>e.$emit("resume",a)},[u("span",{class:se(["wm-onb__thread-icon",{"wm-onb__thread-icon--inverted":!a.unread}])},[t[5]||(t[5]=u("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[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:"currentColor",opacity:"0.92"})],-1)),a.unread?(m(),_("span",{key:0,class:"wm-onb__thread-dot","aria-label":s.t("onboarding.unread")},null,8,id)):D("",!0)],2),u("span",od,[u("span",ad,L(a.title),1),u("span",{class:"wm-onb__thread-preview",innerHTML:s.renderPreview(a.preview)},null,8,ld)]),u("span",cd,[s.formatTs(a._ts)?(m(),_("span",ud,L(s.formatTs(a._ts)),1)):D("",!0),t[6]||(t[6]=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-onb__thread-chev","aria-hidden":"true"},[u("path",{d:"M5 12h14M13 5l7 7-7 7"})],-1))])],8,rd))),128)),s.filteredThreads.length?D("",!0):(m(),_("div",dd,L(s.t("onboarding.noResults",{query:i.query})),1))])])):D("",!0)])}const hd=we(Pu,[["render",fd],["__scopeId","data-v-28c0780b"]]);function md(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 pd={name:"WmActionResult",props:{state:{type:String,default:"success"},label:{type:String,required:!0},detail:{type:String,default:""}},computed:{detailText(){return md(this.detail)}}},gd={class:"wm-result__icon","aria-hidden":"true"},_d={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"},yd={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"},vd={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"},bd={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"},wd={class:"wm-result__body"},kd={class:"wm-result__label"},Cd={class:"wm-result__detail"};function Sd(e,t,n,r,i,s){return m(),_("div",{class:se(["wm-result",`wm-result--${n.state}`])},[u("span",gd,[n.state==="success"?(m(),_("svg",_d,[...t[0]||(t[0]=[u("path",{d:"M20 6L9 17l-5-5"},null,-1)])])):n.state==="rejected"?(m(),_("svg",yd,[...t[1]||(t[1]=[u("path",{d:"M18 6L6 18M6 6l12 12"},null,-1)])])):n.state==="awaiting"?(m(),_("svg",vd,[...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)])])):(m(),_("svg",bd,[...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",wd,[u("span",kd,L(n.label),1),s.detailText?(m(),_(te,{key:0},[t[4]||(t[4]=u("span",{class:"wm-result__sep","aria-hidden":"true"}," · ",-1)),u("span",Cd,L(s.detailText),1)],64)):D("",!0)])],2)}const Ad=we(pd,[["render",Sd],["__scopeId","data-v-7284acd0"]]),xd={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:[]}}},Td={class:"wm-art wm-art--formResponse"},Md={class:"wm-art__head"},Ed={class:"wm-art__title"},Od={class:"wm-art__badge wm-art__badge--success"},Id={class:"wm-art__body"},Ld={class:"wm-art__fieldLabel"};function Rd(e,t,n,r,i,s){return m(),_("div",Td,[u("div",Md,[u("div",Ed,L(n.data.title||s.t("form.title")),1),u("span",Od,[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)),es(" "+L(s.t("form.sent")),1)])]),u("div",Id,[(m(!0),_(te,null,Me(s.fields,(o,a)=>(m(),_("div",{key:a,class:"wm-art__field"},[u("div",Ld,L(o.label),1),u("div",{class:se(["wm-art__fieldValue",{"wm-art__fieldValue--multi":o.multiline}])},L(o.value),3)]))),128))])])}const Bd=we(xd,[["render",Rd],["__scopeId","data-v-713aecf1"]]),Nd={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}}},Pd={class:"wm-art wm-art--infoCard"},Fd={key:0,class:"wm-art__image"},Dd=["src","alt"],jd={class:"wm-art__head"},Ud={class:"wm-art__headMain"},Hd={class:"wm-art__title"},$d={key:0,class:"wm-art__subtitle"},Vd={key:1,class:"wm-art__body"},Kd={key:0,class:"wm-art__text"},qd={class:"wm-art__fieldLabel"};function Wd(e,t,n,r,i,s){return m(),_("div",Pd,[n.data.image_url?(m(),_("figure",Fd,[u("img",{src:n.data.image_url,alt:n.data.title||"",loading:"lazy"},null,8,Dd)])):D("",!0),u("div",jd,[u("div",Ud,[u("div",Hd,L(n.data.title),1),n.data.subtitle?(m(),_("div",$d,L(n.data.subtitle),1)):D("",!0)]),n.data.badge&&n.data.badge.label?(m(),_("span",{key:0,class:se(["wm-art__badge",`wm-art__badge--${n.data.badge.tone||"neutral"}`])},L(n.data.badge.label),3)):D("",!0)]),s.hasBody?(m(),_("div",Vd,[n.data.body?(m(),_("div",Kd,L(n.data.body),1)):D("",!0),s.fields.length?(m(!0),_(te,{key:1},Me(s.fields,(o,a)=>(m(),_("div",{key:a,class:"wm-art__field"},[u("div",qd,L(o.label),1),u("div",{class:se(["wm-art__fieldValue",{"wm-art__fieldValue--multi":o.multiline}])},L(o.value),3)]))),128)):D("",!0)])):D("",!0)])}const zd=we(Nd,[["render",Wd],["__scopeId","data-v-7eae0e4a"]]);function Gd(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 Yd={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 Gd((e=this.data)==null?void 0:e.created_at,bn(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}}},Jd={class:"wm-art wm-art--ticket"},Xd={class:"wm-art__head wm-tk__head"},Qd={class:"wm-art__title wm-tk__title"},Zd={class:"wm-tk__sub"},ef={class:"wm-tk__ref"},tf={key:0,class:"wm-tk__text"},nf={key:0,class:"wm-art__body"},sf={class:"wm-art__fieldLabel"},rf=["data-level"],of={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"},af={key:1,class:"wm-art__footer wm-tk__footer"};function lf(e,t,n,r,i,s){return m(),_("div",Jd,[u("div",Xd,[u("div",Qd,L(n.data.title),1),u("div",Zd,[u("div",ef,[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,L(n.data.reference),1)]),u("span",{class:se(["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)),es(" "+L(n.data.status.label),1)],2)]),n.data.body?(m(),_("div",tf,L(n.data.body),1)):D("",!0)]),s.fields.length?(m(),_("div",nf,[(m(!0),_(te,null,Me(s.fields,(o,a)=>(m(),_("div",{key:a,class:"wm-art__field"},[u("div",sf,L(o.label),1),u("div",{class:se(["wm-art__fieldValue",{"wm-art__fieldValue--multi":o.multiline}])},[s.isPriority(o.label)?(m(),_("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,rf)):s.isDate(o.label)?(m(),_("svg",of,[...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)])])):D("",!0),u("span",null,L(o.value),1)],2)]))),128))])):D("",!0),n.data.created_at?(m(),_("div",af,[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,L(s.formattedDate),1)])):D("",!0)])}const cf={form_response:Bd,info_card:zd,ticket:we(Yd,[["render",lf],["__scopeId","data-v-5f30c914"]])},uf={name:"WmArtifactRenderer",props:{artifact:{type:Object,required:!0}},computed:{component(){var t;const e=(t=this.artifact)==null?void 0:t.kind;return e&&cf[e]||null}}};function df(e,t,n,r,i,s){return s.component?(m(),be(Ha(s.component),{key:0,data:n.artifact.data},null,8,["data"])):D("",!0)}const ff=we(uf,[["render",df]]),hf={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()}}},mf=["href"],pf=["src","alt"],gf=["src"],_f=["src"],yf=["href","download"],vf={class:"wm-att__main"},bf={class:"wm-att__name"},wf={key:0,class:"wm-att__meta"},kf={key:0,class:"wm-att__spin","aria-hidden":"true"};function Cf(e,t,n,r,i,s){return m(),_("div",{class:se(["wm-att",["wm-att--"+(s.kind||"file")]])},[s.kind==="image"&&i.url?(m(),_("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,pf)],8,mf)):s.kind==="audio"&&i.url?(m(),_("audio",{key:1,src:i.url,controls:"",preload:"metadata"},null,8,gf)):s.kind==="video"&&i.url?(m(),_("video",{key:2,src:i.url,controls:"",preload:"metadata"},null,8,_f)):(m(),_("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",vf,[u("span",bf,L(s.displayName),1),s.sizeLabel?(m(),_("span",wf,L(s.sizeLabel),1)):D("",!0)]),i.loading?(m(),_("span",kf)):D("",!0)],8,yf))],2)}const Sf=we(hf,[["render",Cf],["__scopeId","data-v-0c877a62"]]),Af={name:"WmBubble",props:{role:{type:String,default:"ai"},text:{type:String,default:""}},computed:{rendered(){return Nu(this.text)}}},xf=["innerHTML"];function Tf(e,t,n,r,i,s){return m(),_("div",{class:se(["wm-bubble","wm-bubble--"+n.role])},[$a(e.$slots,"default",{},()=>[u("span",{innerHTML:s.rendered},null,8,xf)])],2)}const Mf=we(Af,[["render",Tf],["__scopeId","data-v-7ab13147"]]),Ef={name:"WmTyping"},Of={class:"wm-typing"};function If(e,t,n,r,i,s){return m(),_("div",Of,[...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 Lf=we(Ef,[["render",If],["__scopeId","data-v-df2447fd"]]);function Bt(e){return e?e.client_msg_id||e.id:""}const Rf={transferred_to_human:"system.transferredToHuman",assigned:"system.assigned",unassigned:"system.unassigned",resolved:"system.resolved",reopened:"system.reopened",idle:"system.idle"},Bf=80,Nf=200,Pf={name:"WmMessageList",components:{AIAvatar:kn,HumanAvatar:wo,Bubble:Mf,Typing:Lf,ActionResult:Ad,AttachmentPreview:Sf,ArtifactRenderer:ff},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({})}},computed:{historyExhausted(){return!this.hasMore&&!this.loadingMore&&this.messages.length>=20},groups(){var n,r,i,s;const e=[];for(const o of this.messages){const a=this.roleOf(o);if(a==="system"){if(((n=o==null?void 0:o.payload)==null?void 0:n.event)==="action_admin_pending"){const c=e[e.length-1];c&&c.role==="ai"?c.messages.push(o):e.push({key:`g-${Bt(o)}`,role:"ai",agentName:"",agentAvatarUrl:null,messages:[o],items:[]});continue}e.push({key:`sys-${Bt(o)}`,role:a,messages:[o],items:[],systemLabel:this.systemLabel(o)});continue}const l=e[e.length-1];l&&l.role===a&&(a==="ai"||l.agentName===(((r=o==null?void 0:o.author)==null?void 0:r.name)||""))?l.messages.push(o):e.push({key:`g-${Bt(o)}`,role:a,agentName:((i=o==null?void 0:o.author)==null?void 0:i.name)||"",agentAvatarUrl:((s=o==null?void 0:o.author)==null?void 0:s.avatar_url)||null,messages:[o],items:[]})}for(const o of e){if(o.role==="system")continue;const a=[];for(const l of o.messages)for(const d of this.itemsOf(l))a.push(d);o.items=a}const t=[];for(const o of e){if(o.role!=="system"&&!o.items.length)continue;const a=t[t.length-1];if(a&&a.role!=="system"&&a.role===o.role&&(o.role==="ai"||a.agentName===o.agentName)){a.messages.push(...o.messages),a.items.push(...o.items);continue}t.push(o)}for(const o of t)o.role!=="system"&&(o.key=this.stableGroupKey(o.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=Ct(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)},updated(){this.scheduleMeasure()},methods:{messageKey:Bt,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=Bt(r);if(i&&t.has(i)){n=t.get(i);break}}n==null&&(n=++this._groupIdCounter);for(const r of e){const i=Bt(r);i&&t.set(i,n)}return`g-${n}`},isAtBottom(e){return e.scrollHeight-e.scrollTop-e.clientHeight<=Bf},onScroll(){const e=this.$refs.scrollEl;e&&(this.loadingMore||!this.hasMore||this._pendingLoadMore||e.scrollTop<=Nf&&(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 H,ne,ge;const n=e.items,r=(H=n[t])==null?void 0:H.kind,i=(ne=n[t-1])==null?void 0:ne.kind,s=(ge=n[t+1])==null?void 0:ge.kind,o=e.role==="user",a=14,l=4,d=i==null?void 0:i.bottom,c=s==null?void 0:s.top,p=this.widthByKey[this.rowKeyOf(e,t)],A=this.widthByKey[this.rowKeyOf(e,t-1)],C=this.widthByKey[this.rowKeyOf(e,t+1)],q=.5,R=(ve,ke,J)=>ve!=null&&p!=null?ve+q>=p:ke===J||ke==="card"&&J==="bubble";let Z=a,Y=a,z=a,ee=a;return o?(d&&(Y=l),(c||!s)&&(z=l),d&&R(A,d,r==null?void 0:r.top)&&(Z=l),c&&R(C,c,r==null?void 0:r.bottom)&&(ee=l)):(d&&(Z=l),(c||!s)&&(ee=l),d&&R(A,d,r==null?void 0:r.top)&&(Y=l),c&&R(C,c,r==null?void 0:r.bottom)&&(z=l)),{tl:Z,tr:Y,br:z,bl:ee}},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?`${Bt(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)},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 po(new Date(n.created_at),bn(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;const t=e==null?void 0:e.payload;return t?t.state==="success"?((n=t.success)==null?void 0:n.summary)||((i=(r=t.success)==null?void 0:r.metadata)==null?void 0:i.description)||"":t.state==="rejected"?((s=t.rejected)==null?void 0:s.reason)||this.t("action.rejectedByUser"):t.state==="failure"&&(((o=t.failure)==null?void 0:o.summary)||((a=t.failure)==null?void 0:a.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=Rf[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)}}},Ff={key:0,class:"wm-list__loadMore",role:"status","aria-live":"polite"},Df={class:"wm-list__loadMore-lbl"},jf={key:1,class:"wm-list__historyEnd"},Uf={key:2,class:"wm-list__sep"},Hf={class:"wm-list__sep-label"},$f={key:0,class:"wm-list__sep wm-list__sep--unread"},Vf={class:"wm-list__sep-label wm-list__sep-label--unread"},Kf={key:0,class:"wm-list__sysep"},qf={class:"wm-list__sysep-label"},Wf=["data-row-key"],zf={key:0,class:"wm-list__avatarSlot"},Gf={key:5,class:"wm-list__body"},Yf={key:0},Jf={key:1,"aria-hidden":"true"},Xf={key:2},Qf={key:3,class:"wm-list__row wm-list__row--ai fade-up"},Zf={class:"wm-list__avatarSlot"};function eh(e,t,n,r,i,s){const o=_e("AIAvatar"),a=_e("HumanAvatar"),l=_e("ActionResult"),d=_e("ArtifactRenderer"),c=_e("Bubble"),p=_e("AttachmentPreview"),A=_e("Typing");return m(),_("div",{ref:"scrollEl",class:se(["wm-list",{"wm-list--silent":i.silentFades}]),onScrollPassive:t[0]||(t[0]=(...C)=>s.onScroll&&s.onScroll(...C))},[n.loadingMore?(m(),_("div",Ff,[t[1]||(t[1]=u("span",{class:"wm-list__loadMore-spinner","aria-hidden":"true"},null,-1)),u("span",Df,L(s.t("messageList.loadingHistory")),1)])):s.historyExhausted?(m(),_("div",jf,L(s.t("messageList.conversationStart")),1)):D("",!0),n.dateLabel?(m(),_("div",Uf,[t[2]||(t[2]=u("div",{class:"wm-list__line"},null,-1)),u("span",Hf,L(n.dateLabel),1),t[3]||(t[3]=u("div",{class:"wm-list__line"},null,-1))])):D("",!0),(m(!0),_(te,null,Me(s.groups,(C,q)=>(m(),_(te,{key:C.key},[C.key===s.unreadGroupKey?(m(),_("div",$f,[t[4]||(t[4]=u("div",{class:"wm-list__line wm-list__line--unread"},null,-1)),u("span",Vf,L(s.t("messageList.unread")),1),t[5]||(t[5]=u("div",{class:"wm-list__line wm-list__line--unread"},null,-1))])):D("",!0),C.role==="system"||C.items.length?(m(),_("div",{key:1,class:se(["wm-list__group","wm-list__group--"+C.role])},[C.role==="system"?(m(),_("div",Kf,[t[6]||(t[6]=u("div",{class:"wm-list__line wm-list__line--strong"},null,-1)),u("span",qf,L(C.systemLabel),1),t[7]||(t[7]=u("div",{class:"wm-list__line wm-list__line--strong"},null,-1))])):(m(),_(te,{key:1},[(m(!0),_(te,null,Me(C.items,(R,Z)=>(m(),_("div",{key:`${s.messageKey(R.message)}-${R.partKey}`,"data-row-key":`${s.messageKey(R.message)}-${R.partKey}`,class:se(["wm-list__row fade-up",["wm-list__row--"+C.role,{"is-pending":R.message._pending,"is-failed":R.message._failed}]]),style:je(s.cornersStyle(C,Z))},[C.role!=="user"?(m(),_("div",zf,[Z===C.items.length-1?(m(),_(te,{key:0},[C.role==="ai"?(m(),be(o,{key:0,size:26,tail:!0,name:n.aiAgentName,"image-url":n.aiAgentAvatarUrl},null,8,["name","image-url"])):(m(),be(a,{key:1,name:C.agentName,"avatar-url":C.agentAvatarUrl,size:26,tail:!0},null,8,["name","avatar-url"]))],64)):D("",!0)])):D("",!0),R.renderAs==="action"?(m(),be(l,{key:1,state:R.message.payload.state,label:s.actionLabel(R.message),detail:s.actionDetail(R.message)},null,8,["state","label","detail"])):R.renderAs==="admin-pending"?(m(),be(l,{key:2,state:"awaiting",label:s.t("messageList.approvalRequestSent"),detail:R.message.text_md||""},null,8,["label","detail"])):R.renderAs==="artifact-of-action"?(m(),be(d,{key:3,artifact:s.actionArtifact(R.message)},null,8,["artifact"])):R.renderAs==="artifact"?(m(),be(d,{key:4,artifact:s.artifactOf(R.message)},null,8,["artifact"])):(m(),_("div",Gf,[R.message.text_md?(m(),be(c,{key:0,role:C.role,text:R.message.text_md},null,8,["role","text"])):D("",!0),s.attachmentsOf(R.message).length?(m(),_("div",{key:1,class:se(["wm-list__atts",{"wm-list__atts--align-end":C.role==="user"}])},[(m(!0),_(te,null,Me(s.attachmentsOf(R.message),(Y,z)=>(m(),be(p,{key:`${s.messageKey(R.message)}-att-${z}`,attachment:Y},null,8,["attachment"]))),128))],2)):D("",!0)]))],14,Wf))),128)),(C.role!=="user"||s.lastTimeOf(C))&&!s.hasTrailingOverlay(C)?(m(),_("div",{key:0,class:se(["wm-list__meta",{"wm-list__meta--right":C.role==="user"}])},[C.role!=="user"?(m(),_("span",Yf,L(s.roleLabel(C)),1)):D("",!0),C.role!=="user"&&s.lastTimeOf(C)?(m(),_("span",Jf,"·")):D("",!0),s.lastTimeOf(C)?(m(),_("span",Xf,L(s.lastTimeOf(C)),1)):D("",!0)],2)):D("",!0)],64))],2)):D("",!0)],64))),128)),n.streamingActive?(m(),_("div",Qf,[u("div",Zf,[ye(o,{size:26,tail:!0,name:n.aiAgentName,"image-url":n.aiAgentAvatarUrl},null,8,["name","image-url"])]),ye(A)])):D("",!0)],34)}const th=we(Pf,[["render",eh],["__scopeId","data-v-d769b193"]]),rs=typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function",Qs=typeof window<"u"&&typeof window.MediaRecorder<"u";function nh(){return Qs&&["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 Ao({audio:e}){return{video:!0,audio:!!e,selfBrowserSurface:"include",surfaceSwitching:"include",systemAudio:e?"include":"exclude"}}async function sh(){if(!rs)return null;let e;try{e=await navigator.mediaDevices.getDisplayMedia(Ao({audio:!1}))}catch(t){return(t==null?void 0:t.name)!=="NotAllowedError"&&console.error("[media] screenshot picker",t),null}try{return await rh(e)}catch(t){return console.error("[media] screenshot capture",t),null}finally{e.getTracks().forEach(t=>{t.stop()})}}async function rh(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 ih(e={}){var d;if(!rs||!Qs)return null;let t;try{t=await navigator.mediaDevices.getDisplayMedia(Ao({audio:!0}))}catch(c){return(c==null?void 0:c.name)!=="NotAllowedError"&&console.error("[media] record picker",c),null}const n=nh();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(p=>{p.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,p;if(s&&clearInterval(s),t.getTracks().forEach(A=>{A.stop()}),i.length){const A=r.mimeType||n||"video/webm",C=new Blob(i,{type:A}),q=/mp4/.test(A)?"mp4":"webm",R=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),Z=new File([C],`ecran-${R}.${q}`,{type:A});(c=e.onfinalize)==null||c.call(e,Z)}else(p=e.oncancel)==null||p.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(p=>{p.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 oh=[{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"}],ah={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"}},emits:["update:modelValue","send","attach"],data(){return{local:this.modelValue,attachOpen:!1,recording:!1,recordingElapsed:0,recorder:null}},computed:{canSend(){return!this.disabled&&!!this.local.trim()},attachItems(){return oh.map(e=>({...e,label:this.t(e.labelKey),disabled:e.action==="screenshot"&&!rs||e.action==="record"&&(!rs||!Qs)}))},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()},beforeUnmount(){if(this.recorder)try{this.recorder.stop()}catch{}},methods:{focus(){const e=this.$refs.inputEl;if(!(!e||this.disabled))try{e.focus({preventScroll:!0})}catch{e.focus()}},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;e&&(e.style.height="auto",e.style.height=`${e.scrollHeight}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 sh();e&&this.$emit("attach",e)},async startRecording(){if(this.recording||this.disabled)return;this.recordingElapsed=0;const e=await ih({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)}}}},lh={class:"wm-compose-wrap"},ch={key:0,class:"wm-rec"},uh={class:"wm-rec__lbl"},dh={key:1,class:"wm-compose__menu",role:"menu"},fh=["disabled","onClick"],hh={class:"wm-compose__menuIcon"},mh={viewBox:"0 0 24 24",width:"14",height:"14","aria-hidden":"true"},ph=["d"],gh=["placeholder","disabled"],_h={class:"wm-compose__actions"},yh=["title","aria-label","disabled"],vh=["disabled","aria-label"];function bh(e,t,n,r,i,s){return m(),_("div",lh,[i.recording?(m(),_("div",ch,[t[8]||(t[8]=u("span",{class:"wm-rec__dot","aria-hidden":"true"},null,-1)),u("span",uh,L(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))},L(s.t("composer.stop")),1)])):D("",!0),u("form",{class:se(["wm-compose",{"has-attach":i.attachOpen}]),onSubmit:t[7]||(t[7]=kt((...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?(m(),_("div",{key:0,class:"wm-compose__overlay",onClick:t[2]||(t[2]=o=>i.attachOpen=!1)})):D("",!0),i.attachOpen?(m(),_("div",dh,[(m(!0),_(te,null,Me(s.attachItems,o=>(m(),_("button",{key:o.action,type:"button",class:"wm-compose__menuItem",disabled:o.disabled,onClick:a=>s.onAttachAction(o.action)},[u("span",hh,[(m(),_("svg",mh,[u("path",{d:o.path,stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round",fill:"none"},null,8,ph)]))]),u("span",null,L(o.label),1)],8,fh))),128))])):D("",!0),ut(u("textarea",{ref:"inputEl","onUpdate:modelValue":t[3]||(t[3]=o=>i.local=o),class:"wm-compose__input",rows:"3",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))},null,40,gh),[[Rt,i.local]]),u("div",_h,[u("button",{type:"button",class:se(["wm-compose__icon",{"is-open":i.attachOpen}]),title:n.attachLabel,"aria-label":n.attachLabel,disabled:i.recording,onClick:t[6]||(t[6]=o=>i.attachOpen=!i.attachOpen)},[...t[9]||(t[9]=[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)])],10,yh),u("button",{type:"submit",class:se(["wm-compose__send",{"is-empty":!s.canSend}]),disabled:!s.canSend,"aria-label":s.t("composer.send")},[...t[10]||(t[10]=[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:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})],-1)])],10,vh)])],34)])}const wh=we(ah,[["render",bh],["__scopeId","data-v-aa81dbb8"]]),kh={name:"WmSuggestionChips",props:{items:{type:Array,default:()=>[]},baseDelay:{type:Number,default:360},stepDelay:{type:Number,default:90}},emits:["select"],computed:{batchKey(){return this.items.map(e=>(e==null?void 0:e.label)||(e==null?void 0:e.text)||"").join("§")}}},Ch=["onClick"];function Sh(e,t,n,r,i,s){return n.items.length?(m(),_("div",{key:s.batchKey,class:"wm-chips"},[(m(!0),_(te,null,Me(n.items,(o,a)=>(m(),_("button",{key:a,type:"button",class:"wm-chip",style:je({animationDelay:n.baseDelay+a*n.stepDelay+"ms"}),onClick:l=>e.$emit("select",o)},L(o.label),13,Ch))),128))])):D("",!0)}const Ah=we(kh,[["render",Sh],["__scopeId","data-v-47ad8085"]]),xh={name:"WmApprovalCard",components:{AIAvatar:kn},inject:{t:{default:()=>Ee()}},props:{action:{type:String,required:!0},detail:{type:String,default:""},callbacks:{type:Array,default:()=>[]},agentName:{type:String,default:""},agentAvatarUrl:{type:String,default:null}},emits:["callback"],computed:{approveCallback(){return this.callbacks.find(e=>e.id==="approve"||e.style==="primary")||this.callbacks[0]},rejectCallback(){return this.callbacks.find(e=>e.id==="reject"||e.style==="danger"||e.style==="neutral")||(this.callbacks.length>1?this.callbacks[1]:null)},approveId(){var e;return(e=this.approveCallback)==null?void 0:e.id},rejectId(){var e;return(e=this.rejectCallback)==null?void 0:e.id},approveLabel(){var e;return((e=this.approveCallback)==null?void 0:e.label)||this.t("approval.approve")},rejectLabel(){var e;return((e=this.rejectCallback)==null?void 0:e.label)||this.t("approval.reject")}}},Th={class:"wm-approval"},Mh={class:"wm-approval__head"},Eh={class:"wm-approval__icon"},Oh={class:"wm-approval__main"},Ih={class:"wm-approval__title"},Lh={key:0,class:"wm-approval__detail"},Rh={class:"wm-approval__actions"};function Bh(e,t,n,r,i,s){const o=_e("AIAvatar");return m(),_("div",Th,[u("div",Mh,[u("div",Eh,[ye(o,{size:24,name:n.agentName,"image-url":n.agentAvatarUrl},null,8,["name","image-url"])]),u("div",Oh,[u("div",Ih,L(n.action),1),n.detail?(m(),_("div",Lh,L(n.detail),1)):D("",!0)])]),u("div",Rh,[s.rejectId?(m(),_("button",{key:0,type:"button",class:"wm-approval__btn wm-approval__btn--neutral",onClick:t[0]||(t[0]=a=>e.$emit("callback",s.rejectId))},L(s.rejectLabel),1)):D("",!0),s.approveId?(m(),_("button",{key:1,type:"button",class:"wm-approval__btn wm-approval__btn--primary",onClick:t[1]||(t[1]=a=>e.$emit("callback",s.approveId))},L(s.approveLabel),1)):D("",!0)])])}const Nh=we(xh,[["render",Bh],["__scopeId","data-v-a2bed37e"]]);let xo=0;const Ph=new Set(["text","textarea","number","boolean","select","multiselect","date"]),Fh={name:"WmFormCard",components:{AIAvatar:kn},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 xo+=1,{_uid:xo,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)||!Ph.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}}}},Dh={class:"wm-form"},jh={class:"wm-form__head"},Uh={class:"wm-form__icon"},Hh={class:"wm-form__main"},$h={class:"wm-form__title"},Vh={key:0,class:"wm-form__detail"},Kh=["for"],qh={key:0,class:"wm-form__req","aria-hidden":"true"},Wh=["id","onUpdate:modelValue","placeholder","required","disabled"],zh=["id","onUpdate:modelValue","placeholder","required","disabled"],Gh=["id","onUpdate:modelValue","placeholder","required","disabled"],Yh=["id","onUpdate:modelValue","required","disabled"],Jh={key:4,class:"wm-form__bool"},Xh=["id","onUpdate:modelValue","disabled"],Qh=["id","onUpdate:modelValue","required","disabled"],Zh={value:"",disabled:""},em=["value"],tm={key:6,class:"wm-form__multi"},nm=["value","checked","disabled","onChange"],sm={key:0,class:"wm-form__err"},rm=["disabled"],im={key:0,class:"wm-form__spinner","aria-hidden":"true"},om={key:2,class:"wm-form__doneLbl"};function am(e,t,n,r,i,s){const o=_e("AIAvatar");return m(),_("div",Dh,[u("div",jh,[u("div",Uh,[ye(o,{size:24,name:n.agentName,"image-url":n.agentAvatarUrl},null,8,["name","image-url"])]),u("div",Hh,[u("div",$h,L(n.form.title||s.t("form.title")),1),n.form.description?(m(),_("div",Vh,L(n.form.description),1)):D("",!0)])]),u("form",{class:"wm-form__body",onSubmit:t[0]||(t[0]=kt((...a)=>s.onSubmit&&s.onSubmit(...a),["prevent"]))},[(m(!0),_(te,null,Me(s.normalizedFields,a=>(m(),_("div",{key:a.key,class:"wm-form__field"},[u("label",{for:`wm-f-${i._uid}-${a.key}`,class:"wm-form__label"},[es(L(a.label),1),a.required?(m(),_("span",qh,"*")):D("",!0)],8,Kh),a.type==="text"?ut((m(),_("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,Wh)),[[Rt,i.values[a.key]]]):a.type==="textarea"?ut((m(),_("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,zh)),[[Rt,i.values[a.key]]]):a.type==="number"?ut((m(),_("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,Gh)),[[Rt,i.values[a.key],void 0,{number:!0}]]):a.type==="date"?ut((m(),_("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,Yh)),[[Rt,i.values[a.key]]]):a.type==="boolean"?(m(),_("label",Jh,[ut(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,Xh),[[ic,i.values[a.key]]]),u("span",null,L(a.placeholder||s.t("common.yes")),1)])):a.type==="select"?ut((m(),_("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",Zh,L(a.placeholder||s.t("form.choose")),1),(m(!0),_(te,null,Me(a.options,l=>(m(),_("option",{key:l.value,value:l.value},L(l.label),9,em))),128))],8,Qh)),[[oc,i.values[a.key]]]):a.type==="multiselect"?(m(),_("div",tm,[(m(!0),_(te,null,Me(a.options,l=>(m(),_("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,nm),u("span",null,L(l.label),1)]))),128))])):D("",!0)]))),128)),i.error?(m(),_("div",sm,L(i.error),1)):D("",!0),n.readOnly?(m(),_("div",om,L(s.t("form.responseSent")),1)):(m(),_("button",{key:1,type:"submit",class:"wm-form__submit",disabled:i.busy},[i.busy?(m(),_("span",im)):D("",!0),u("span",null,L(i.busy?s.t("common.sending"):n.form.submit_label||s.t("common.send")),1)],8,rm))],32)])}const lm=we(Fh,[["render",am],["__scopeId","data-v-fe65cc56"]]),cm={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})}}},um={class:"wm-fb"},dm={class:"wm-fb__title"},fm={class:"wm-fb__sub"},hm={class:"wm-fb__row"},mm=["onClick"],pm={class:"wm-fb__emoji"},gm={class:"wm-fb__label"},_m=["disabled"],ym={key:1,class:"wm-fb__done"},vm={class:"wm-fb__doneTitle"},bm={class:"wm-fb__doneSub"};function wm(e,t,n,r,i,s){return m(),_("div",um,[n.done?(m(),_("div",ym,[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",vm,L(s.t("feedback.doneTitle")),1),u("div",bm,L(s.t("feedback.doneSubtitle")),1)])):(m(),_(te,{key:0},[u("div",dm,L(s.t("feedback.question")),1),u("div",fm,L(s.t("feedback.subtitle")),1),u("div",hm,[(m(!0),_(te,null,Me(s.options,o=>(m(),_("button",{key:o.v,type:"button",class:se(["wm-fb__opt",{"is-selected":i.sel===o.v}]),onClick:a=>i.sel=o.v},[u("span",pm,L(o.e),1),u("span",gm,L(o.l),1)],10,mm))),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))},L(n.busy?s.t("common.sending"):s.t("feedback.submit")),9,_m)],64))])}const km=we(cm,[["render",wm],["__scopeId","data-v-9b630564"]]),Cm={name:"WmMoreMenu",inject:{t:{default:()=>Ee()}},props:{canRename:{type:Boolean,default:!0},canExport:{type:Boolean,default:!0},soundEnabled:{type:Boolean,default:!0},browserNotifEnabled:{type:Boolean,default:!1},statusUrl:{type:String,default:""},helpUrl:{type:String,default:""}},emits:["close","action","sound-toggle","browser-notif-toggle"],data(){return{soundOn:this.soundEnabled,browserNotifOn:this.browserNotifEnabled}},watch:{soundEnabled(e){this.soundOn=!!e},browserNotifEnabled(e){this.browserNotifOn=!!e}},methods:{emit(e){this.$emit("action",e)},toggleSound(){this.soundOn=!this.soundOn,this.$emit("sound-toggle",this.soundOn)},toggleBrowserNotif(){this.browserNotifOn=!this.browserNotifOn,this.$emit("browser-notif-toggle",this.browserNotifOn)}}},Sm={class:"wm-mm"},Am={class:"wm-mm__pop",role:"menu"},xm={key:0,class:"wm-mm__section"},Tm={class:"wm-mm__label"},Mm={class:"wm-mm__label"},Em={key:1,class:"wm-mm__sep"},Om={class:"wm-mm__section"},Im={class:"wm-mm__label"},Lm={class:"wm-mm__label"},Rm={class:"wm-mm__section"},Bm={class:"wm-mm__label"},Nm={class:"wm-mm__label"};function Pm(e,t,n,r,i,s){return m(),_("div",Sm,[u("div",{class:"wm-mm__scrim",onClick:t[0]||(t[0]=o=>e.$emit("close"))}),u("div",Am,[n.canRename||n.canExport?(m(),_("div",xm,[n.canRename?(m(),_("button",{key:0,type:"button",class:"wm-mm__item",onClick:t[1]||(t[1]=o=>s.emit("rename"))},[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:"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",Tm,L(s.t("moreMenu.editTitle")),1)])):D("",!0),n.canExport?(m(),_("button",{key:1,type:"button",class:"wm-mm__item",onClick:t[2]||(t[2]=o=>s.emit("export"))},[t[8]||(t[8]=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",Mm,L(s.t("moreMenu.exportTranscript")),1),t[9]||(t[9]=u("span",{class:"wm-mm__hint"},".txt",-1))])):D("",!0)])):D("",!0),n.canRename||n.canExport?(m(),_("div",Em)):D("",!0),u("div",Om,[u("button",{type:"button",class:"wm-mm__item",onClick:t[3]||(t[3]=(...o)=>s.toggleSound&&s.toggleSound(...o))},[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:"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",Im,L(s.t("moreMenu.sound")),1),u("span",{class:se(["wm-mm__toggle",{"wm-mm__toggle--on":i.soundOn}])},[...t[10]||(t[10]=[u("span",{class:"wm-mm__knob"},null,-1)])],2)]),u("button",{type:"button",class:"wm-mm__item",onClick:t[4]||(t[4]=(...o)=>s.toggleBrowserNotif&&s.toggleBrowserNotif(...o))},[t[13]||(t[13]=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:"M15 17h5l-1.4-1.4A2 2 0 0118 14.2V11a6 6 0 10-12 0v3.2c0 .5-.2 1-.6 1.4L4 17h5m6 0a3 3 0 11-6 0"})])],-1)),u("span",Lm,L(s.t("moreMenu.browserNotifications")),1),u("span",{class:se(["wm-mm__toggle",{"wm-mm__toggle--on":i.browserNotifOn}])},[...t[12]||(t[12]=[u("span",{class:"wm-mm__knob"},null,-1)])],2)])]),t[16]||(t[16]=u("div",{class:"wm-mm__sep"},null,-1)),u("div",Rm,[n.statusUrl?(m(),_("button",{key:0,type:"button",class:"wm-mm__item",onClick:t[5]||(t[5]=o=>s.emit("status"))},[t[14]||(t[14]=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",Bm,L(s.t("moreMenu.serviceStatus")),1)])):D("",!0),n.helpUrl?(m(),_("button",{key:1,type:"button",class:"wm-mm__item",onClick:t[6]||(t[6]=o=>s.emit("help"))},[t[15]||(t[15]=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",Nm,L(s.t("moreMenu.helpCenter")),1)])):D("",!0)])])])}const Fm=we(Cm,[["render",Pm],["__scopeId","data-v-76281e95"]]),Dm={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())}}},jm={class:"wm-dialog"},Um={class:"wm-dialog__card",role:"dialog","aria-modal":"true"},Hm={class:"wm-dialog__head"},$m={class:"wm-dialog__title"},Vm=["aria-label"],Km={class:"wm-dialog__body"},qm=["placeholder"],Wm={class:"wm-dialog__actions"},zm=["disabled"];function Gm(e,t,n,r,i,s){return m(),_("div",jm,[u("div",{class:"wm-dialog__scrim",onClick:t[0]||(t[0]=o=>e.$emit("close"))}),u("div",Um,[u("div",Hm,[u("div",$m,L(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,Vm)]),u("div",Km,[ut(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]=ss(kt((...o)=>s.onSubmit&&s.onSubmit(...o),["prevent"]),["enter"])),t[4]||(t[4]=ss(kt(o=>e.$emit("close"),["prevent"]),["esc"]))]},null,40,qm),[[Rt,i.value]])]),u("div",Wm,[u("button",{type:"button",class:"wm-dialog__btn",onClick:t[5]||(t[5]=o=>e.$emit("close"))},L(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))},L(s.t("common.save")),9,zm)])])])}const Ym=we(Dm,[["render",Gm],["__scopeId","data-v-6d5f94a8"]]),To="ww-messenger-tokens",Jm={name:"Messenger",components:{Launcher:lu,Header:Lu,Onboarding:hd,MessageList:th,Composer:wh,SuggestionChips:Ah,ApprovalCard:Nh,FormCard:lm,Feedback:km,MoreMenu:Fm,RenameDialog:Ym},mixins:[Lc,Dc,jc,Hc],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:go},widgetId:{type:String,default:""},token:{type:String,default:""},context:{type:Object,default:null},displayMode:{type:String,default:"floating"},devtools:{type:Boolean,default:!1},language:{type:String,default:""}},data(){return{transport:null,store:null,isOpen:!1,draft:"",busy:!1,bootError:null,pendingAttachments:[],feedbackBusy:!1,feedbackDone:!1,convOpenedAt:0,moreOpen:!1,renameDialogOpen:!1,draftConv:null,activeConvId:null,showOnboarding:!1,dismissedPeeks:{},floatHeight:0,floatRO:null}},computed:{isEditor(){return!!this.devtools},isEmbedded(){return this.displayMode==="embedded"},customerLanguage(){var 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 Xs(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=Ct(r.last_read_message_id);let o=0,a=null;for(let c=i.length-1;c>=0;c--){const p=i[c];if(!p)continue;if(((d=p.author)==null?void 0:d.type)==="user")break;const A=Ct(p.id);if(A!=null){if(s!=null&&A<=s)break;t[p.id]!==0&&(!a&&p.author&&(a=p.author),o++)}}const l=i.filter(c=>!((c==null?void 0:c.id)!=null&&t[c.id]===0));return{...r,_preview:Mc(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=>n.status!=="resolved").map(n=>({id:n.id,title:n.name||this.t("common.newConversation"),preview:n._preview||this.t("onboarding.newMessage"),unread:!!n._unread,_ts:bo(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=bo(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)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},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},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},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(){var t;const e=(t=this.currentConv)==null?void 0:t.status;return e==="waiting"||e==="handled"},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 n,r;const e=this.currentConv;if(!e)return[];if(!e._draft){const i=(r=(n=this.s)==null?void 0:n.paginationByConv)==null?void 0:r[e.id];if(!(i!=null&&i.loaded))return[]}const t=this.revealedAt;return(this.s.messagesByConv[e.id]||[]).filter(i=>{var s,o,a,l,d;return(i==null?void 0:i.type)==="action"&&((s=i==null?void 0:i.payload)==null?void 0:s.state)==="pending"||wn(i)&&!(t[i.id]>0)?!1:(i==null?void 0:i.type)==="action"||(i==null?void 0:i.type)==="system"||((o=i==null?void 0:i.payload)==null?void 0:o.type)==="system"||Array.isArray((a=i==null?void 0:i.payload)==null?void 0:a.attachments)&&i.payload.attachments.length||(l=i==null?void 0:i.metadata)!=null&&l.artifact||(d=i==null?void 0:i.metadata)!=null&&d.form?!0:typeof(i==null?void 0:i.text_md)=="string"&&i.text_md.trim().length>0})},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:(((i=(r=this.s)==null?void 0:r.messagesByConv)==null?void 0:i[e.id])||[]).some(s=>wn(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])||[]:[]},pendingApproval(){return!this.currentConv||!this.store||this.actionInFlight?null:this.store.getPendingApproval(this.currentConv.id)},approvalReady(){return this.pendingApproval?this.pendingApproval.id===this.approvalLatchId?!0:!(this.streamingActive||!this.approvalSettled):!1},approvalTitle(){var e,t,n;return((t=(e=this.pendingApproval)==null?void 0:e.payload)==null?void 0:t.name)||((n=this.pendingApproval)==null?void 0:n.text_md)||this.t("action.title")},approvalDetail(){var r,i,s,o,a,l;const e=(s=(i=(r=this.pendingApproval)==null?void 0:r.payload)==null?void 0:i.pending)==null?void 0:s.user_explanation;if(typeof e=="string"&&e.trim())return e.trim();const t=(l=(a=(o=this.pendingApproval)==null?void 0:o.payload)==null?void 0:a.pending)==null?void 0:l.prepared_params;if(!t||typeof t!="object")return"";const n=Object.entries(t);return n.length?n.slice(0,2).map(([d,c])=>`${d}: ${c}`).join(" · "):""},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.store?[]:this.streamingActive?[]:this.pendingForm?[]:this.store.getLatestSuggestions(this.currentConv.id)},pendingForm(){var e,t;return!this.currentConv||!this.store||this.pendingApproval||this.actionInFlight||this.streamingActive||!this.approvalSettled?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.feedbackDone?!0:e.status!=="resolved"?!1:!((t=e.metadata)!=null&&t.feedback):!1},floatVisible(){return this.approvalReady||!!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:po(t,bn(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.resetApprovalPacing(),this.isViewingThread&&(this.unreadAnchorId=Ct((t=this.currentConv)==null?void 0:t.last_read_message_id),this.unreadBoundaryTs=e?new Date().toISOString():"")},immediate:!0},isViewingThread(e,t){var n;e&&!t?(this.unreadAnchorId=Ct((n=this.currentConv)==null?void 0:n.last_read_message_id),this.unreadBoundaryTs=new Date().toISOString()):e||(this.unreadAnchorId=null,this.unreadBoundaryTs="")},pendingApproval:{handler(e,t){if(e&&!t){const n=e!=null&&e.created_at?Date.parse(e.created_at):NaN;if(!(Number.isFinite(n)&&n>=this.convOpenedAt)){this.resetApprovalPacing();return}this.bumpApprovalSettle(2600)}else!e&&t&&this.resetApprovalPacing()},immediate:!1},streamingActive(e,t){e!==t&&this.pendingApproval&&this.pendingApproval.id!==this.approvalLatchId&&this.bumpApprovalSettle()},approvalReady(e){e&&this.pendingApproval&&(this.approvalLatchId=this.pendingApproval.id)},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(To)){const e=document.createElement("style");e.id=To,e.textContent=Sc,document.head.appendChild(e)}this.isEmbedded&&(await this.boot(),this.store&&await this.open())},beforeUnmount(){this.cancelReveals(),this.teardownLiveReveal(),this.disconnectFloatRO(),this.resetApprovalPacing(),this.teardownNotifications(),this.store&&this.store.destroy()},methods:{t(e,t){return this.translator(e,t)},async boot(){var e;if(!this.canBoot){console.warn("[messenger] boot skipped — missing creds");return}try{this.transport=Ss(vc({baseUrl:this.baseUrl,widgetId:this.widgetId,token:this.token||void 0})),this.store=Ss(Cc(this.transport)),this.hydrateNotifPref();const t=(e=this.context)==null?void 0:e.customer;t&&typeof t=="object"&&await this.store.applyCustomer(t),await this.store.start(),this.setupLiveReveal()}catch(t){console.error("[ww-messenger] bootstrap failed",t),this.bootError=(t==null?void 0:t.message)||String(t)}},async refresh(){this.store&&this.store.destroy(),this.cancelReveals(),this.teardownLiveReveal(),this.teardownNotifications(),this.convOpenedAt=0,this.transport=null,this.store=null,this.isOpen=!1,this.draft="",this.busy=!1,this.bootError=null,this.pendingAttachments=[],this.feedbackBusy=!1,this.feedbackDone=!1,this.moreOpen=!1,this.renameDialogOpen=!1,this.draftConv=null,this.activeConvId=null,this.showOnboarding=!1,await this.boot(),this.isEmbedded&&this.store&&await this.open()},syncFloatObserver(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.scrollToBottom)==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.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)}},close(){this.isOpen=!1,this.store&&this.store.setPanelOpen(!1)},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),await this.open()},dismissPeek(e){const t=this.latestUnreads.find(n=>n.convId===e);t&&(this.dismissedPeeks={...this.dismissedPeeks,[e]:t.ts})},startConv(){this.draftConv={id:"__draft__",_draft:!0,name:"",created_at:new Date().toISOString()},this.activeConvId=null,this.showOnboarding=!1,this.focusComposer()},async ensureRealConv(){const 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({});return 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()})},toggleMore(){this.moreOpen=!this.moreOpen},goHome(){this.moreOpen=!1,this.draftConv=null,this.activeConvId=null,this.showOnboarding=!0},async onDrawerPick(e){if(!(e!=null&&e.id)||!this.store)return;this.draftConv=null,this.activeConvId=e.id,this.showOnboarding=!1;try{await this.store.openConversation(e.id)}catch(n){console.error("[ww-messenger] open conv failed",n)}const t=this.allConversations.find(n=>n.id===e.id);t&&this.markConvRead(t)},async onMoreAction(e){var t,n;switch(this.moreOpen=!1,e){case"rename":this.openRenameDialog();break;case"export":Ic(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(this.statusUrl)try{window.open(this.statusUrl,"_blank","noopener")}catch{}break;case"help":if(this.helpUrl)try{window.open(this.helpUrl,"_blank","noopener")}catch{}break}},openRenameDialog(){const 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="",await this.store.send(n,e,{attachments:r.length?r:void 0})},async onSuggestion(e){const t=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 onApprovalCallback(e){const t=this.pendingApproval;t&&await this.store.clickCallback(t.id,e)},async onFormSubmit({values:e}){const t=this.pendingForm;if(!(t!=null&&t.form))return;const n=xc(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:Tc(t.form,e,this.translator)}}))},async onAttach(e){if(!(!e||!this.transport))try{const t=await this.transport.uploadAttachment(e);this.pendingAttachments.push({type:t.type||"file",path:t.path,name:e.name||this.t("attachment.fileFallbackName"),mime_type:e.type,size_bytes:e.size})}catch(t){console.error("[ww-messenger] attachment upload failed",t)}},async onQuickLink(e){if(e){if(e.url){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=!0}catch(n){console.error("[ww-messenger] feedback failed",n)}finally{this.feedbackBusy=!1}}}}},Xm={key:0,class:"wm-loading","aria-busy":"true","aria-live":"polite"},Qm=["aria-label"],Zm={key:0,class:"wm-state"},ep={class:"wm-state__err"},tp={class:"wm-state__errTitle"},np={class:"wm-state__errSub"},sp={class:"wm-bottom"},rp={key:0,ref:"floatEl",class:"wm-float"},ip={key:1,class:"wm-actionWait",role:"status","aria-live":"polite"},op={class:"wm-actionWait__lbl"},ap={key:2,class:"wm-attached"},lp=["aria-label","onClick"];function cp(e,t,n,r,i,s){const o=_e("Launcher"),a=_e("Header"),l=_e("Onboarding"),d=_e("MessageList"),c=_e("ApprovalCard"),p=_e("FormCard"),A=_e("Feedback"),C=_e("SuggestionChips"),q=_e("Composer"),R=_e("MoreMenu"),Z=_e("RenameDialog");return m(),_("div",{class:se(["wm-root",`wm-root--${n.displayMode}`])},[!i.isOpen&&!s.isEmbedded?(m(),be(o,{key:0,"unread-count":s.unreadCount,peeks:s.launcherPeeks,onOpen:s.openFromPeek,onDismiss:s.dismissPeek},null,8,["unread-count","peeks","onOpen","onDismiss"])):D("",!0),i.isOpen||s.isEmbedded?(m(),_("section",{key:1,class:se(["wm-panel",`wm-panel--${n.displayMode}`,{"wm-panel--welcome":s.ready&&!s.error&&!s.currentConv}]),style:je(i.floatHeight?{"--wm-float-h":i.floatHeight+"px"}:null),role:"dialog","aria-label":"Messenger"},[!s.ready&&!s.error?(m(),_("div",Xm,[s.isEmbedded?D("",!0):(m(),_("button",{key:0,type:"button",class:"wm-loading__close","aria-label":s.t("loading.minimize"),onClick:t[0]||(t[0]=(...Y)=>s.close&&s.close(...Y))},[...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,Qm)),t[6]||(t[6]=u("div",{class:"wm-loading__spinner","aria-hidden":"true"},null,-1))])):(m(),_(te,{key:1},[ye(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"]),s.error?(m(),_("div",Zm,[u("div",ep,[t[7]||(t[7]=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",tp,L(s.t("error.connectionFailed")),1),u("div",np,L(s.error),1)])])])):s.currentConv?(m(),_(te,{key:2},[ye(d,{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",sp,[s.floatVisible?(m(),_("div",rp,[s.approvalReady?(m(),be(c,{key:0,action:s.approvalTitle,detail:s.approvalDetail,callbacks:s.pendingApproval.callbacks,"agent-name":s.agentName,"agent-avatar-url":s.agentAvatarUrl,onCallback:s.onApprovalCallback},null,8,["action","detail","callbacks","agent-name","agent-avatar-url","onCallback"])):s.pendingForm?(m(),be(p,{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?(m(),be(A,{key:2,busy:i.feedbackBusy,done:i.feedbackDone,onSubmit:s.onFeedback},null,8,["busy","done","onSubmit"])):(m(),be(C,{key:3,items:s.suggestions,onSelect:s.onSuggestion},null,8,["items","onSelect"]))],512)):D("",!0),s.actionInFlight?(m(),_("div",ip,[t[8]||(t[8]=u("span",{class:"wm-actionWait__spinner","aria-hidden":"true"},null,-1)),u("span",op,L(s.t("action.inProgress",{name:s.actionInFlightName})),1)])):(m(),be(q,{key:2,ref:"composer",modelValue:i.draft,"onUpdate:modelValue":t[1]||(t[1]=Y=>i.draft=Y),placeholder:s.composerPlaceholder,disabled:!!s.pendingApproval,"attach-label":s.t("composer.attachFile"),onSend:s.onSend,onAttach:s.onAttach},null,8,["modelValue","placeholder","disabled","attach-label","onSend","onAttach"]))]),i.moreOpen?(m(),be(R,{key:0,"can-rename":!!s.currentConv&&!s.currentConv._draft,"can-export":!!s.currentConv&&!s.currentConv._draft,"sound-enabled":e.soundEnabled,"browser-notif-enabled":e.browserNotifEnabled,"status-url":s.statusUrl,"help-url":s.helpUrl,onClose:t[2]||(t[2]=Y=>i.moreOpen=!1),onSoundToggle:e.onSoundToggle,onBrowserNotifToggle:e.onBrowserNotifToggle,onAction:s.onMoreAction},null,8,["can-rename","can-export","sound-enabled","browser-notif-enabled","status-url","help-url","onSoundToggle","onBrowserNotifToggle","onAction"])):D("",!0),i.renameDialogOpen&&s.currentConv&&!s.currentConv._draft?(m(),be(Z,{key:1,"initial-value":s.currentConv.name||"",title:s.t("rename.dialogTitle"),onClose:t[3]||(t[3]=Y=>i.renameDialogOpen=!1),onSubmit:s.onRenameSubmit},null,8,["initial-value","title","onSubmit"])):D("",!0),i.pendingAttachments.length?(m(),_("div",ap,[(m(!0),_(te,null,Me(i.pendingAttachments,(Y,z)=>(m(),_("div",{key:z,class:"wm-attached__chip"},[t[10]||(t[10]=u("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[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)),u("span",null,L(Y.name),1),u("button",{type:"button","aria-label":s.t("attachment.remove"),onClick:ee=>i.pendingAttachments.splice(z,1)},[...t[9]||(t[9]=[u("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[u("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,lp)]))),128))])):D("",!0)],64)):(m(),be(l,{key:1,"welcome-message":s.widgetWelcomeMessage,subtitle:s.widgetSubtitle,"agent-name":s.agentName,"default-icon-url":s.defaultIconUrl,"quick-links":s.quickLinks,"open-threads":s.openThreads,busy:i.busy,onStart:s.startConv,onSelect:s.onQuickLink,onResume:s.onDrawerPick},null,8,["welcome-message","subtitle","agent-name","default-icon-url","quick-links","open-threads","busy","onStart","onSelect","onResume"])),i.moreOpen&&!s.currentConv?(m(),be(R,{key:3,"can-rename":!1,"can-export":!1,"sound-enabled":e.soundEnabled,"browser-notif-enabled":e.browserNotifEnabled,"status-url":s.statusUrl,"help-url":s.helpUrl,onClose:t[4]||(t[4]=Y=>i.moreOpen=!1),onSoundToggle:e.onSoundToggle,onBrowserNotifToggle:e.onBrowserNotifToggle,onAction:s.onMoreAction},null,8,["sound-enabled","browser-notif-enabled","status-url","help-url","onSoundToggle","onBrowserNotifToggle","onAction"])):D("",!0)],64))],6)):D("",!0)],2)}const up=we(Jm,[["render",cp],["__scopeId","data-v-966f7d8a"]]),dp="0.5.2";let St=null,Nt=null,Zs="";function fp(e){if(e instanceof Element)return e;if(typeof e=="string"){const n=document.querySelector(e);if(n)return n}const t=document.createElement("div");return t.setAttribute("data-messenger-root",""),document.body.appendChild(t),t}function hp(e){return{baseUrl:String(e.baseUrl||go).trim(),widgetId:String(e.widgetId||"").trim(),token:String(e.token||"").trim(),displayMode:e.displayMode||"floating",devtools:!!e.devtools,language:String(e.language||"").trim(),target:e.target||null,context:e.context&&typeof e.context=="object"?e.context:null}}function mp(e={}){const t=hp(e);if(!t.baseUrl||!t.widgetId)return er(),null;const n=JSON.stringify({...t,target:typeof t.target=="string"?t.target:!!t.target});return St&&n===Zs||(er(),Nt=fp(t.target),St=fc(up,{baseUrl:t.baseUrl,widgetId:t.widgetId,token:t.token||void 0,displayMode:t.displayMode,devtools:t.devtools,language:t.language,context:t.context}),St.mount(Nt),Zs=n),St}function er(){if(St){try{St.unmount()}catch{}St=null}Nt&&Nt.hasAttribute&&Nt.hasAttribute("data-messenger-root")&&Nt.remove(),Nt=null,Zs=""}return Gt.destroy=er,Gt.init=mp,Gt.version=dp,Object.defineProperty(Gt,Symbol.toStringTag,{value:"Module"}),Gt}({});
package/dist/messenger.js CHANGED
@@ -6125,7 +6125,7 @@ function qa(e, t, n, i, r, s) {
6125
6125
  ], 6)) : k("", !0)
6126
6126
  ], 2);
6127
6127
  }
6128
- const Va = /* @__PURE__ */ E(Oa, [["render", qa], ["__scopeId", "data-v-966f7d8a"]]), Ka = "0.5.1";
6128
+ const Va = /* @__PURE__ */ E(Oa, [["render", qa], ["__scopeId", "data-v-966f7d8a"]]), Ka = "0.5.2";
6129
6129
  export {
6130
6130
  de as AIAvatar,
6131
6131
  pe as AVATAR_COLORS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@_solaris/messenger-widget",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Embeddable chat messenger widget — Vue 3 library + standalone embed build. Wired to the messenger-server (HMAC + widgetId).",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",