@_solaris/messenger-widget 0.5.24 → 0.5.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/iframe/iframe.js +2 -2
- package/dist/messenger.cjs +2 -2
- package/dist/messenger.js +2 -2
- package/dist/snippet.js +1 -1
- package/package.json +1 -1
package/dist/iframe/iframe.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* @vue/runtime-dom v3.5.34
|
|
15
15
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
16
16
|
* @license MIT
|
|
17
|
-
**/let Es;const _r=typeof window<"u"&&window.trustedTypes;if(_r)try{Es=_r.createPolicy("vue",{createHTML:e=>e})}catch{}const ho=Es?e=>Es.createHTML(e):e=>e,_l="http://www.w3.org/2000/svg",yl="http://www.w3.org/1998/Math/MathML",rt=typeof document<"u"?document:null,yr=rt&&rt.createElement("template"),vl={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{const t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,r)=>{const i=t==="svg"?rt.createElementNS(_l,e):t==="mathml"?rt.createElementNS(yl,e):n?rt.createElement(e,{is:n}):rt.createElement(e);return e==="select"&&r&&r.multiple!=null&&i.setAttribute("multiple",r.multiple),i},createText:e=>rt.createTextNode(e),createComment:e=>rt.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>rt.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},insertStaticContent(e,t,n,r,i,s){const o=n?n.previousSibling:t.lastChild;if(i&&(i===s||i.nextSibling))for(;t.insertBefore(i.cloneNode(!0),n),!(i===s||!(i=i.nextSibling)););else{yr.innerHTML=ho(r==="svg"?`<svg>${e}</svg>`:r==="mathml"?`<math>${e}</math>`:e);const a=yr.content;if(r==="svg"||r==="mathml"){const l=a.firstChild;for(;l.firstChild;)a.appendChild(l.firstChild);a.removeChild(l)}t.insertBefore(a,n)}return[o?o.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}},gt="transition",Yt="animation",hn=Symbol("_vtc"),mo={name:String,type:String,css:{type:Boolean,default:!0},duration:[String,Number,Object],enterFromClass:String,enterActiveClass:String,enterToClass:String,appearFromClass:String,appearActiveClass:String,appearToClass:String,leaveFromClass:String,leaveActiveClass:String,leaveToClass:String},bl=Se({},Ei,mo),wl=e=>(e.displayName="Transition",e.props=bl,e),kl=wl((e,{slots:t})=>fo(_a,Cl(e),t)),At=(e,t=[])=>{q(e)?e.forEach(n=>n(...t)):e&&e(...t)},vr=e=>e?q(e)?e.some(t=>t.length>1):e.length>1:!1;function Cl(e){const t={};for(const j in e)j in mo||(t[j]=e[j]);if(e.css===!1)return t;const{name:n="v",type:r,duration:i,enterFromClass:s=`${n}-enter-from`,enterActiveClass:o=`${n}-enter-active`,enterToClass:a=`${n}-enter-to`,appearFromClass:l=s,appearActiveClass:f=o,appearToClass:c=a,leaveFromClass:g=`${n}-leave-from`,leaveActiveClass:A=`${n}-leave-active`,leaveToClass:S=`${n}-leave-to`}=e,H=Sl(i),O=H&&H[0],J=H&&H[1],{onBeforeEnter:z,onEnter:$,onEnterCancelled:Q,onLeave:U,onLeaveCancelled:ne,onBeforeAppear:ge=z,onAppear:he=$,onAppearCancelled:ke=Q}=t,G=(j,le,y,b)=>{j._enterCancelled=b,xt(j,le?c:a),xt(j,le?f:o),y&&y()},ee=(j,le)=>{j._isLeaving=!1,xt(j,g),xt(j,S),xt(j,A),le&&le()},ue=j=>(le,y)=>{const b=j?he:$,w=()=>G(le,j,y);At(b,[le,w]),br(()=>{xt(le,j?l:s),st(le,j?c:a),vr(b)||wr(le,r,O,w)})};return Se(t,{onBeforeEnter(j){At(z,[j]),st(j,s),st(j,o)},onBeforeAppear(j){At(ge,[j]),st(j,l),st(j,f)},onEnter:ue(!1),onAppear:ue(!0),onLeave(j,le){j._isLeaving=!0;const y=()=>ee(j,le);st(j,g),j._enterCancelled?(st(j,A),Sr(j)):(Sr(j),st(j,A)),br(()=>{j._isLeaving&&(xt(j,g),st(j,S),vr(U)||wr(j,r,J,y))}),At(U,[j,y])},onEnterCancelled(j){G(j,!1,void 0,!0),At(Q,[j])},onAppearCancelled(j){G(j,!0,void 0,!0),At(ke,[j])},onLeaveCancelled(j){ee(j),At(ne,[j])}})}function Sl(e){if(e==null)return null;if(ae(e))return[ds(e.enter),ds(e.leave)];{const t=ds(e);return[t,t]}}function ds(e){return xo(e)}function st(e,t){t.split(/\s+/).forEach(n=>n&&e.classList.add(n)),(e[hn]||(e[hn]=new Set)).add(t)}function xt(e,t){t.split(/\s+/).forEach(r=>r&&e.classList.remove(r));const n=e[hn];n&&(n.delete(t),n.size||(e[hn]=void 0))}function br(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}let Al=0;function wr(e,t,n,r){const i=e._endId=++Al,s=()=>{i===e._endId&&r()};if(n!=null)return setTimeout(s,n);const{type:o,timeout:a,propCount:l}=xl(e,t);if(!o)return r();const f=o+"end";let c=0;const g=()=>{e.removeEventListener(f,A),s()},A=S=>{S.target===e&&++c>=l&&g()};setTimeout(()=>{c<l&&g()},a+1),e.addEventListener(f,A)}function xl(e,t){const n=window.getComputedStyle(e),r=H=>(n[H]||"").split(", "),i=r(`${gt}Delay`),s=r(`${gt}Duration`),o=kr(i,s),a=r(`${Yt}Delay`),l=r(`${Yt}Duration`),f=kr(a,l);let c=null,g=0,A=0;t===gt?o>0&&(c=gt,g=o,A=s.length):t===Yt?f>0&&(c=Yt,g=f,A=l.length):(g=Math.max(o,f),c=g>0?o>f?gt:Yt:null,A=c?c===gt?s.length:l.length:0);const S=c===gt&&/\b(?:transform|all)(?:,|$)/.test(r(`${gt}Property`).toString());return{type:c,timeout:g,propCount:A,hasTransform:S}}function kr(e,t){for(;e.length<t.length;)e=e.concat(e);return Math.max(...t.map((n,r)=>Cr(n)+Cr(e[r])))}function Cr(e){return e==="auto"?0:Number(e.slice(0,-1).replace(",","."))*1e3}function Sr(e){return(e?e.ownerDocument:document).body.offsetHeight}function Tl(e,t,n){const r=e[hn];r&&(t=(t?[t,...r]:[...r]).join(" ")),t==null?e.removeAttribute("class"):n?e.setAttribute("class",t):e.className=t}const Ar=Symbol("_vod"),Ml=Symbol("_vsh"),El=Symbol(""),Ol=/(?:^|;)\s*display\s*:/;function Il(e,t,n){const r=e.style,i=ve(n);let s=!1;if(n&&!i){if(t)if(ve(t))for(const o of t.split(";")){const a=o.slice(0,o.indexOf(":")).trim();n[a]==null&&Xt(r,a,"")}else for(const o in t)n[o]==null&&Xt(r,o,"");for(const o in n){o==="display"&&(s=!0);const a=n[o];a!=null?Ll(e,o,!ve(t)&&t?t[o]:void 0,a)||Xt(r,o,a):Xt(r,o,"")}}else if(i){if(t!==n){const o=r[El];o&&(n+=";"+o),r.cssText=n,s=Ol.test(n)}}else t&&e.removeAttribute("style");Ar in e&&(e[Ar]=s?r.display:"",e[Ml]&&(r.display="none"))}const xr=/\s*!important$/;function Xt(e,t,n){if(q(n))n.forEach(r=>Xt(e,t,r));else if(n==null&&(n=""),t.startsWith("--"))e.setProperty(t,n);else{const r=Rl(e,t);xr.test(n)?e.setProperty(kt(r),n.replace(xr,""),"important"):e[r]=n}}const Tr=["Webkit","Moz","ms"],fs={};function Rl(e,t){const n=fs[t];if(n)return n;let r=Pe(t);if(r!=="filter"&&r in e)return fs[t]=r;r=Hn(r);for(let i=0;i<Tr.length;i++){const s=Tr[i]+r;if(s in e)return fs[t]=s}return t}function Ll(e,t,n,r){return e.tagName==="TEXTAREA"&&(t==="width"||t==="height")&&ve(r)&&n===r}const Mr="http://www.w3.org/1999/xlink";function Er(e,t,n,r,i,s=Ro(t)){r&&t.startsWith("xlink:")?n==null?e.removeAttributeNS(Mr,t.slice(6,t.length)):e.setAttributeNS(Mr,t,n):n==null||s&&!ei(n)?e.removeAttribute(t):e.setAttribute(t,s?"":qe(n)?String(n):n)}function Or(e,t,n,r,i){if(t==="innerHTML"||t==="textContent"){n!=null&&(e[t]=t==="innerHTML"?ho(n):n);return}const s=e.tagName;if(t==="value"&&s!=="PROGRESS"&&!s.includes("-")){const a=s==="OPTION"?e.getAttribute("value")||"":e.value,l=n==null?e.type==="checkbox"?"on":"":String(n);(a!==l||!("_value"in e))&&(e.value=l),n==null&&e.removeAttribute(t),e._value=n;return}let o=!1;if(n===""||n==null){const a=typeof e[t];a==="boolean"?n=ei(n):n==null&&a==="string"?(n="",o=!0):a==="number"&&(n=0,o=!0)}try{e[t]=n}catch{}o&&e.removeAttribute(i||t)}function yt(e,t,n,r){e.addEventListener(t,n,r)}function Nl(e,t,n,r){e.removeEventListener(t,n,r)}const Ir=Symbol("_vei");function Bl(e,t,n,r,i=null){const s=e[Ir]||(e[Ir]={}),o=s[t];if(r&&o)o.value=r;else{const[a,l]=Pl(t);if(r){const f=s[t]=jl(r,i);yt(e,a,f,l)}else o&&(Nl(e,a,o,l),s[t]=void 0)}}const Rr=/(?:Once|Passive|Capture)$/;function Pl(e){let t;if(Rr.test(e)){t={};let r;for(;r=e.match(Rr);)e=e.slice(0,e.length-r[0].length),t[r[0].toLowerCase()]=!0}return[e[2]===":"?e.slice(3):kt(e.slice(2)),t]}let hs=0;const Fl=Promise.resolve(),Dl=()=>hs||(Fl.then(()=>hs=0),hs=Date.now());function jl(e,t){const n=r=>{if(!r._vts)r._vts=Date.now();else if(r._vts<=n.attached)return;ze(Ul(r,n.value),t,5,[r])};return n.value=e,n.attached=Dl(),n}function Ul(e,t){if(q(t)){const n=e.stopImmediatePropagation;return e.stopImmediatePropagation=()=>{n.call(e),e._stopped=!0},t.map(r=>i=>!i._stopped&&r&&r(i))}else return t}const Lr=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,Hl=(e,t,n,r,i,s)=>{const o=i==="svg";t==="class"?Tl(e,r,o):t==="style"?Il(e,n,r):Dn(t)?jn(t)||Bl(e,t,n,r,s):(t[0]==="."?(t=t.slice(1),!0):t[0]==="^"?(t=t.slice(1),!1):$l(e,t,r,o))?(Or(e,t,r),!e.tagName.includes("-")&&(t==="value"||t==="checked"||t==="selected")&&Er(e,t,r,o,s,t!=="value")):e._isVueCE&&(Vl(e,t)||e._def.__asyncLoader&&(/[A-Z]/.test(t)||!ve(r)))?Or(e,Pe(t),r,s,t):(t==="true-value"?e._trueValue=r:t==="false-value"&&(e._falseValue=r),Er(e,t,r,o))};function $l(e,t,n,r){if(r)return!!(t==="innerHTML"||t==="textContent"||t in e&&Lr(t)&&X(n));if(t==="spellcheck"||t==="draggable"||t==="translate"||t==="autocorrect"||t==="sandbox"&&e.tagName==="IFRAME"||t==="form"||t==="list"&&e.tagName==="INPUT"||t==="type"&&e.tagName==="TEXTAREA")return!1;if(t==="width"||t==="height"){const i=e.tagName;if(i==="IMG"||i==="VIDEO"||i==="CANVAS"||i==="SOURCE")return!1}return Lr(t)&&ve(n)?!1:t in e}function Vl(e,t){const n=e._def.props;if(!n)return!1;const r=Pe(t);return Array.isArray(n)?n.some(i=>Pe(i)===r):Object.keys(n).some(i=>Pe(i)===r)}const Ht=e=>{const t=e.props["onUpdate:modelValue"]||!1;return q(t)?n=>xn(t,n):t};function Kl(e){e.target.composing=!0}function Nr(e){const t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event("input")))}const dt=Symbol("_assign");function Br(e,t,n){return t&&(e=e.trim()),n&&(e=$n(e)),e}const Ot={created(e,{modifiers:{lazy:t,trim:n,number:r}},i){e[dt]=Ht(i);const s=r||i.props&&i.props.type==="number";yt(e,t?"change":"input",o=>{o.target.composing||e[dt](Br(e.value,n,s))}),(n||s)&&yt(e,"change",()=>{e.value=Br(e.value,n,s)}),t||(yt(e,"compositionstart",Kl),yt(e,"compositionend",Nr),yt(e,"change",Nr))},mounted(e,{value:t}){e.value=t??""},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:r,trim:i,number:s}},o){if(e[dt]=Ht(o),e.composing)return;const a=(s||e.type==="number")&&!/^0\d/.test(e.value)?$n(e.value):e.value,l=t??"";if(a===l)return;const f=e.getRootNode();(f instanceof Document||f instanceof ShadowRoot)&&f.activeElement===e&&e.type!=="range"&&(r&&t===n||i&&e.value.trim()===l)||(e.value=l)}},ql={deep:!0,created(e,t,n){e[dt]=Ht(n),yt(e,"change",()=>{const r=e._modelValue,i=mn(e),s=e.checked,o=e[dt];if(q(r)){const a=Ls(r,i),l=a!==-1;if(s&&!l)o(r.concat(i));else if(!s&&l){const f=[...r];f.splice(a,1),o(f)}}else if($t(r)){const a=new Set(r);s?a.add(i):a.delete(i),o(a)}else o(po(e,s))})},mounted:Pr,beforeUpdate(e,t,n){e[dt]=Ht(n),Pr(e,t,n)}};function Pr(e,{value:t,oldValue:n},r){e._modelValue=t;let i;if(q(t))i=Ls(t,r.props.value)>-1;else if($t(t))i=t.has(r.props.value);else{if(t===n)return;i=Vt(t,po(e,!0))}e.checked!==i&&(e.checked=i)}const zl={deep:!0,created(e,{value:t,modifiers:{number:n}},r){const i=$t(t);yt(e,"change",()=>{const s=Array.prototype.filter.call(e.options,o=>o.selected).map(o=>n?$n(mn(o)):mn(o));e[dt](e.multiple?i?new Set(s):s:s[0]),e._assigning=!0,bi(()=>{e._assigning=!1})}),e[dt]=Ht(r)},mounted(e,{value:t}){Fr(e,t)},beforeUpdate(e,t,n){e[dt]=Ht(n)},updated(e,{value:t}){e._assigning||Fr(e,t)}};function Fr(e,t){const n=e.multiple,r=q(t);if(!(n&&!r&&!$t(t))){for(let i=0,s=e.options.length;i<s;i++){const o=e.options[i],a=mn(o);if(n)if(r){const l=typeof a;l==="string"||l==="number"?o.selected=t.some(f=>String(f)===String(a)):o.selected=Ls(t,a)>-1}else o.selected=t.has(a);else if(Vt(mn(o),t)){e.selectedIndex!==i&&(e.selectedIndex=i);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function mn(e){return"_value"in e?e._value:e.value}function po(e,t){const n=t?"_trueValue":"_falseValue";return n in e?e[n]:t}const Wl=["ctrl","shift","alt","meta"],Gl={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>"button"in e&&e.button!==0,middle:e=>"button"in e&&e.button!==1,right:e=>"button"in e&&e.button!==2,exact:(e,t)=>Wl.some(n=>e[`${n}Key`]&&!t.includes(n))},vt=(e,t)=>{if(!e)return e;const n=e._withMods||(e._withMods={}),r=t.join(".");return n[r]||(n[r]=(i,...s)=>{for(let o=0;o<t.length;o++){const a=Gl[t[o]];if(a&&a(i,t))return}return e(i,...s)})},Yl={esc:"escape",space:" ",up:"arrow-up",left:"arrow-left",right:"arrow-right",down:"arrow-down",delete:"backspace"},Pn=(e,t)=>{const n=e._withKeys||(e._withKeys={}),r=t.join(".");return n[r]||(n[r]=i=>{if(!("key"in i))return;const s=kt(i.key);if(t.some(o=>o===s||Yl[o]===s))return e(i)})},Jl=Se({patchProp:Hl},vl);let Dr;function Xl(){return Dr||(Dr=Xa(Jl))}const Ql=(...e)=>{const t=Xl().createApp(...e),{mount:n}=t;return t.mount=r=>{const i=ec(r);if(!i)return;const s=t._component;!X(s)&&!s.render&&!s.template&&(s.template=i.innerHTML),i.nodeType===1&&(i.textContent="");const o=n(i,!1,Zl(i));return i instanceof Element&&(i.removeAttribute("v-cloak"),i.setAttribute("data-v-app","")),o},t};function Zl(e){if(e instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&e instanceof MathMLElement)return"mathml"}function ec(e){return ve(e)?document.querySelector(e):e}const tc=["connected","message","message_stream","conversation_updated","config_updated","action_status"],ms="/client",nc=5*60*1e3,sc=10*60*1e3,rc=5*60*1e3;function ic(e){const t={baseUrl:oc(e.baseUrl||""),widgetId:e.widgetId||"",userId:"",origin:"",token:"",listeners:new Map,eventSource:null,connection:"idle",visibilityHandler:null,started:!1,panelOpen:!1,pollTimer:null,burstTimer:null,hiddenGraceTimer:null,lastActivityAt:null};if(!t.baseUrl||!t.widgetId)throw new Error("[transport] baseUrl and widgetId are required");function n(h,v){return t.listeners.has(h)||t.listeners.set(h,new Set),t.listeners.get(h).add(v),()=>t.listeners.get(h).delete(v)}function r(h,v){const C=t.listeners.get(h);C&&C.forEach(N=>{try{N(v)}catch(B){console.error("[transport] listener",h,B)}})}function i(h){t.connection!==h&&(t.connection=h,r("connection",h))}function s(){return{"Content-Type":"application/json","X-Widget-Id":t.widgetId,...t.origin?{"X-Parent-Origin":t.origin}:{}}}async function o(h,v,C){const N=await fetch(`${t.baseUrl}${ms}${v}`,{method:h,credentials:"include",headers:s(),body:C!==void 0?JSON.stringify(C):void 0});if(!N.ok){const B=await a(N),V=new Error(`HTTP ${N.status} ${h} ${v} :: ${(B==null?void 0:B.error)||N.statusText}`);throw V.status=N.status,V.body=B,V}return N.status===204?null:N.json()}async function a(h){try{return await h.json()}catch{return null}}async function l(h){if(t.started)return t.lastBootstrap;if(!(h!=null&&h.origin))throw new Error("[transport] start requires origin");t.started=!0,t.origin=h.origin,t.token=h.token||"";const v=await fetch(`${t.baseUrl}${ms}/session`,{method:"POST",credentials:"include",headers:s(),body:JSON.stringify({origin:t.origin,...t.token?{token:t.token}:{},allowUnauthenticated:h.allowUnauthenticated===!0})});if(!v.ok){const ie=await a(v),te=new Error(`Session bootstrap failed: HTTP ${v.status} :: ${(ie==null?void 0:ie.error)||v.statusText}`);throw te.status=v.status,te.body=ie,te}const C=await v.json();t.userId=C.external_id;const[N,B]=await Promise.all([fetch(`${t.baseUrl}/widgets/${encodeURIComponent(t.widgetId)}/config`,{credentials:"include"}).then(async ie=>{if(!ie.ok){const te=await a(ie);throw new Error(`HTTP ${ie.status} GET /widgets/:id/config :: ${(te==null?void 0:te.error)||ie.statusText}`)}return ie.json()}),o("GET","/customers/me")]),V={config:N,customer:(B==null?void 0:B.customer)??null};return t.lastBootstrap=V,await f(),typeof document<"u"&&(t.visibilityHandler=b,document.addEventListener("visibilitychange",t.visibilityHandler)),le(),V}async function f(){try{const h=await A();t.lastActivityAt=h.reduce((v,C)=>{const N=C==null?void 0:C.last_message_at;return N&&(!v||N>v)?N:v},null)}catch(h){console.error("[transport] initial /conversations failed",h)}}async function c(){const h=await o("GET","/customers/me");return(h==null?void 0:h.customer)??null}async function g(h){const v=await o("PATCH","/customers/me",h);return(v==null?void 0:v.customer)??null}async function A(){const h=await o("GET","/conversations");return(h==null?void 0:h.conversations)??[]}async function S(h={}){return(await o("POST","/conversations",h)).conversation}async function H(h){return(await o("GET",`/conversations/${encodeURIComponent(h)}`)).conversation}async function O(h,v){return(await o("PATCH",`/conversations/${encodeURIComponent(h)}`,v)).conversation}async function J(h,v){return o("PATCH",`/conversations/${encodeURIComponent(h)}/read`,{message_id:v})}async function z(h,v={}){const C=new URLSearchParams;v.before&&C.set("before",v.before),v.since&&C.set("since",v.since),v.limit&&C.set("limit",String(v.limit));const N=C.toString()?`?${C.toString()}`:"";return o("GET",`/conversations/${encodeURIComponent(h)}/messages${N}`)}async function $(h,v){ee();const C={client_msg_id:v.client_msg_id,type:"content",text_md:v.text_md,author:{id:t.userId,type:"user"},created_at:v.created_at||new Date().toISOString()};return Array.isArray(v.attachments)&&v.attachments.length&&(C.payload={type:"content",attachments:v.attachments}),v.metadata&&typeof v.metadata=="object"&&(C.metadata=v.metadata),o("POST",`/conversations/${encodeURIComponent(h)}/messages`,C)}async function Q(h,v,C){return ee(),o("POST",`/messages/${encodeURIComponent(h)}/callbacks/${encodeURIComponent(v)}`,C?{inputs:C}:{})}async function U(h){const v=h.name||"attachment",C=h.type||"application/octet-stream",N=h.size||0,B=await o("POST","/attachments",{mime_type:C,size_bytes:N,name:v}),V=await fetch(B.upload_url,{method:"PUT",headers:{"Content-Type":C},body:h});if(!V.ok)throw new Error(`HTTP ${V.status} PUT signed upload`);return{type:ac(C),path:B.path,mime_type:C,size_bytes:N}}async function ne(h){return o("GET",`/attachments/sign?path=${encodeURIComponent(h)}`)}function ge(){const h=new URLSearchParams({widgetId:t.widgetId}).toString();return`${t.baseUrl}${ms}/stream?${h}`}function he(){if(!t.eventSource&&!(typeof document<"u"&&document.hidden)&&t.started)try{const h=new EventSource(ge(),{withCredentials:!0});for(const v of tc)h.addEventListener(v,C=>ke(v,C.data));h.addEventListener("error",()=>r("error",new Error("SSE error"))),t.eventSource=h,i("open")}catch(h){console.error("[transport] SSE open failed",h),r("error",h)}}function ke(h,v){try{const C=JSON.parse(v),N=C&&typeof C=="object"&&"data"in C?C.data:C;r(h,N)}catch(C){console.error("[transport] bad SSE payload",h,C)}}function G(){t.eventSource&&(t.eventSource.close(),t.eventSource=null),t.connection!=="paused"&&i("idle")}function ee(){clearTimeout(t.burstTimer),he(),t.panelOpen||(t.burstTimer=setTimeout(()=>{t.panelOpen||G()},sc))}function ue(h){t.panelOpen=!!h,t.panelOpen?(clearTimeout(t.burstTimer),he()):ee()}async function j(){try{const h=await A(),v=h.reduce((N,B)=>{const V=B==null?void 0:B.last_message_at;return V&&(!N||V>N)?V:N},null);v&&(!t.lastActivityAt||v>t.lastActivityAt)&&(t.lastActivityAt=v,r("activity",{conversations:h,latestAt:v}),ee())}catch(h){console.error("[transport] poll failed",h)}}function le(){y(),!(typeof document<"u"&&document.hidden)&&(t.pollTimer=setInterval(j,nc))}function y(){t.pollTimer&&(clearInterval(t.pollTimer),t.pollTimer=null)}function b(){if(document.hidden)clearTimeout(t.hiddenGraceTimer),t.hiddenGraceTimer=setTimeout(()=>{t.hiddenGraceTimer=null,document.hidden&&(y(),G(),i("paused"))},rc);else{if(t.hiddenGraceTimer){clearTimeout(t.hiddenGraceTimer),t.hiddenGraceTimer=null;return}i("idle"),le(),t.panelOpen&&he()}}function w(){y(),clearTimeout(t.burstTimer),clearTimeout(t.hiddenGraceTimer),t.hiddenGraceTimer=null,G(),t.visibilityHandler&&(document.removeEventListener("visibilitychange",t.visibilityHandler),t.visibilityHandler=null),t.started=!1}return{on:n,start:l,stop:w,setPanelOpen:ue,getCustomer:c,patchCustomer:g,listConversations:A,createConversation:S,getConversation:H,patchConversation:O,markConversationRead:J,listMessages:z,postMessage:$,postCallback:Q,uploadAttachment:U,signAttachment:ne,get connection(){return t.connection}}}function oc(e){return e.endsWith("/")?e.slice(0,-1):e}function ac(e){return e.startsWith("image/")?"image":e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":"file"}function lc(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();const e=new Uint8Array(16);if(typeof crypto<"u"&&crypto.getRandomValues)crypto.getRandomValues(e);else for(let n=0;n<16;n++)e[n]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;const t=[...e].map(n=>n.toString(16).padStart(2,"0"));return t.slice(0,4).join("")+"-"+t.slice(4,6).join("")+"-"+t.slice(6,8).join("")+"-"+t.slice(8,10).join("")+"-"+t.slice(10,16).join("")}function cc(e){const t=qn({ready:!1,error:null,config:null,customer:null,conversations:[],messagesByConv:{},paginationByConv:{},streamingByMsgId:{},awaitingCallback:{},runningActionsByConv:{},connection:"idle"}),n=[];n.push(e.on("connection",y=>{t.connection=y})),n.push(e.on("message",y=>{const b=y==null?void 0:y.conversation_id,w=y==null?void 0:y.message;!b||!(w!=null&&w.id)||(he(b,w),w.client_msg_id&&delete t.streamingByMsgId[w.client_msg_id],ee(b,w.created_at))})),n.push(e.on("message_stream",y=>{const b=y==null?void 0:y.message_id,w=y==null?void 0:y.token;!b||typeof w!="string"||(t.streamingByMsgId[b]=(t.streamingByMsgId[b]||"")+w)})),n.push(e.on("conversation_updated",y=>{const b=y==null?void 0:y.conversation_id,w=y==null?void 0:y.changes;if(!b||!w)return;const h=t.conversations.findIndex(v=>v.id===b);h!==-1&&(t.conversations[h]={...t.conversations[h],...w})})),n.push(e.on("config_updated",y=>{y!=null&&y.config&&(t.config=y.config)})),n.push(e.on("action_status",y=>{const b=y==null?void 0:y.conversation_id,w=y==null?void 0:y.action_id,h=y==null?void 0:y.action_name;if(!b||!w)return;const v=t.runningActionsByConv[b]||{};y.state==="running"?(v[w]=h||w,t.runningActionsByConv[b]={...v}):y.state==="done"&&(delete v[w],t.runningActionsByConv[b]={...v})})),n.push(e.on("activity",y=>{Array.isArray(y==null?void 0:y.conversations)&&(t.conversations=y.conversations)}));async function r(y){try{const b=new Promise((h,v)=>setTimeout(()=>v(new Error("bootstrap timeout (15s) — check baseUrl, CORS, and network")),15e3)),w=await Promise.race([e.start(y),b]);t.config=w.config,t.customer=w.customer,t.conversations=await Promise.race([e.listConversations(),b]),t.ready=!0}catch(b){console.error("[store] start failed",b),t.error=(b==null?void 0:b.message)||String(b)}}function i(){for(const y of n)try{y()}catch{}e.stop()}async function s(y){const b=j(y);if(!b)return t.customer;try{const w=await e.patchCustomer(b);w&&(t.customer=w)}catch(w){console.error("[store] applyCustomer failed",w)}return t.customer}async function o(y={}){const b=await e.createConversation(y),w=t.conversations.findIndex(h=>h.id===b.id);return w===-1?t.conversations=[b,...t.conversations]:t.conversations[w]=b,b}const a=50;async function l(y){const b=t.paginationByConv[y];if(!(b!=null&&b.loaded||b!=null&&b.loading)){c(y,{nextCursor:null,loading:!0,loaded:!1});try{const w=await e.listMessages(y,{limit:a}),h=(w==null?void 0:w.messages)??[],v=t.messagesByConv[y]||[],C=new Set;for(const B of h)(B==null?void 0:B.id)!=null&&C.add(`id:${String(B.id)}`),B!=null&&B.client_msg_id&&C.add(`c:${B.client_msg_id}`);const N=v.filter(B=>!((B==null?void 0:B.id)!=null&&C.has(`id:${String(B.id)}`)||B!=null&&B.client_msg_id&&C.has(`c:${B.client_msg_id}`)));t.messagesByConv[y]=[...h,...N].sort(ue),c(y,{nextCursor:(w==null?void 0:w.next_cursor)??null,loading:!1,loaded:!0})}catch(w){console.error("[store] openConversation failed",w),c(y,{nextCursor:null,loading:!1,loaded:!1})}}}async function f(y){var v;const b=t.paginationByConv[y];if(!b||b.loading||!b.nextCursor)return;const h=(v=(t.messagesByConv[y]||[]).find(C=>C==null?void 0:C.created_at))==null?void 0:v.created_at;if(h){c(y,{...b,loading:!0});try{const C=await e.listMessages(y,{before:h,limit:a}),N=(C==null?void 0:C.messages)??[],B=t.messagesByConv[y]||[],V=new Set;for(const te of B)(te==null?void 0:te.id)!=null&&V.add(`id:${String(te.id)}`),te!=null&&te.client_msg_id&&V.add(`c:${te.client_msg_id}`);const ie=N.filter(te=>!((te==null?void 0:te.id)!=null&&V.has(`id:${String(te.id)}`)||te!=null&&te.client_msg_id&&V.has(`c:${te.client_msg_id}`)));t.messagesByConv[y]=[...ie,...B],c(y,{nextCursor:(C==null?void 0:C.next_cursor)??null,loading:!1,loaded:!0})}catch(C){console.error("[store] loadMore failed",C),c(y,{...b,loading:!1})}}}function c(y,b){t.paginationByConv={...t.paginationByConv,[y]:b}}async function g(y,b){const w=await e.patchConversation(y,b),h=t.conversations.findIndex(v=>v.id===y);h!==-1&&(t.conversations[h]=w)}async function A(y){if(!y)return[];const b=t.messagesByConv[y]||[];let w="";for(const h of b)h!=null&&h.created_at&&h.created_at>w&&(w=h.created_at);try{const h=await e.listMessages(y,w?{since:w}:{}),v=(h==null?void 0:h.messages)||[];if(!v.length)return[];const C=new Set,N=new Set;for(const V of b)(V==null?void 0:V.id)!=null&&C.add(String(V.id)),V!=null&&V.client_msg_id&&N.add(V.client_msg_id);const B=[];for(const V of v){const ie=(V==null?void 0:V.id)!=null&&C.has(String(V.id))||(V==null?void 0:V.client_msg_id)&&N.has(V.client_msg_id);he(y,V),ie||B.push(V)}return B}catch(h){return console.error("[store] fetchSinceLast failed",h),[]}}async function S(y,b){if(!(!y||b==null))try{const w=await e.markConversationRead(y,b),h=(w==null?void 0:w.last_read_message_id)??b,v=t.conversations.findIndex(C=>(C==null?void 0:C.id)===y);v!==-1&&(t.conversations[v]={...t.conversations[v],last_read_message_id:h})}catch(w){console.error("[store] markConversationRead failed",w)}}async function H(y,b,{attachments:w,metadata:h}={}){var ie;const v=(b||"").trim(),C=Array.isArray(w)&&w.length>0;if(!y||!v&&!C)return;const N=lc(),B=le(y),V={id:N,client_msg_id:N,conversation_id:y,type:"content",text_md:v,author:{type:"user",id:((ie=t.customer)==null?void 0:ie.external_id)||null},created_at:B,_pending:!0,...C?{payload:{type:"content",attachments:w}}:{},...h&&typeof h=="object"?{metadata:h}:{}};he(y,V);try{await e.postMessage(y,{client_msg_id:N,text_md:v,created_at:B,...C?{attachments:w}:{},...h&&typeof h=="object"?{metadata:h}:{}})}catch(te){console.error("[store] send failed",te),G(y,N,{_failed:!0,_pending:!1})}}async function O(y,b,w){y!=null&&(t.awaitingCallback[y]=!0);try{await e.postCallback(y,b,w)}catch(h){console.error("[store] callback failed",h),y!=null&&delete t.awaitingCallback[y]}}const J=new Map;async function z(y){if(!y)return null;const b=J.get(y);if(b!=null&&b.url){const w=b.expires_at?Date.parse(b.expires_at):0;if(!w||w-Date.now()>6e4)return b.url}try{const w=await e.signAttachment(y);if(w!=null&&w.signed_url)return J.set(y,{url:w.signed_url,expires_at:w.expires_at}),w.signed_url}catch(w){console.error("[store] sign attachment failed",w)}return null}async function $(y,{rating:b,comment:w}={}){const h=t.conversations.find(N=>N.id===y),C={...(h==null?void 0:h.metadata)||{},feedback:{rating:b,comment:w||null,submitted_at:new Date().toISOString()}};await g(y,{metadata:C})}function Q(y){var w,h;const b=t.messagesByConv[y]||[];for(let v=b.length-1;v>=0;v--){const C=b[v];if((C==null?void 0:C.type)==="action"&&((w=C==null?void 0:C.payload)==null?void 0:w.type)==="action"&&((h=C==null?void 0:C.payload)==null?void 0:h.state)==="pending"&&Array.isArray(C==null?void 0:C.callbacks)&&C.callbacks.length>0&&!t.awaitingCallback[C.id])return C}return null}function U(y){var w,h,v;const b=t.messagesByConv[y]||[];for(let C=b.length-1;C>=0;C--){const N=b[C];if(((w=N==null?void 0:N.author)==null?void 0:w.type)==="user"||(N==null?void 0:N.type)==="action"&&((h=N==null?void 0:N.payload)==null?void 0:h.state)==="pending")return null;const B=(v=N==null?void 0:N.metadata)==null?void 0:v.form;if(B&&Array.isArray(B.fields)&&B.fields.length>0)return{message:N,form:B}}return null}function ne(y){const b=t.runningActionsByConv[y];if(!b)return null;const w=Object.keys(b);if(w.length===0)return null;const h=w[0];return{id:h,payload:{name:b[h]}}}function ge(y){var w,h,v,C;const b=t.messagesByConv[y]||[];for(let N=b.length-1;N>=0;N--){const B=b[N];if(((w=B==null?void 0:B.author)==null?void 0:w.type)==="user")return[];if((B==null?void 0:B.type)==="action"&&((h=B==null?void 0:B.payload)==null?void 0:h.state)==="pending")return[];if(((v=B==null?void 0:B.author)==null?void 0:v.type)!=="agent_ia")continue;const V=(C=B==null?void 0:B.metadata)==null?void 0:C.suggested_replies;return Array.isArray(V)&&V.length?V.map(ie=>{if(typeof ie=="string"){const te=ie.trim();return te?{label:te,kind:null}:null}if(ie&&typeof ie=="object"&&typeof ie.label=="string"){const te=ie.label.trim();if(!te)return null;const Zn=ie.kind==="cta"||ie.kind==="choice"||ie.kind==="followup"?ie.kind:null;return{label:te,kind:Zn}}return null}).filter(Boolean).slice(0,4):[]}return[]}function he(y,b){var C;const w=t.messagesByConv[y]||[];let h=-1;b!=null&&b.client_msg_id&&(h=w.findIndex(N=>(N==null?void 0:N.client_msg_id)&&N.client_msg_id===b.client_msg_id)),h===-1&&(b==null?void 0:b.id)!==void 0&&(b==null?void 0:b.id)!==null&&(h=w.findIndex(N=>ke(N==null?void 0:N.id,b.id)));let v;h===-1?v=[...w,b].sort(ue):(v=w.slice(),v[h]={...w[h],...b,_pending:!1,_failed:!1}),t.messagesByConv[y]=v,(b==null?void 0:b.type)==="action"&&((C=b==null?void 0:b.payload)!=null&&C.state)&&b.payload.state!=="pending"&&(b==null?void 0:b.id)!=null&&t.awaitingCallback[b.id]&&delete t.awaitingCallback[b.id]}function ke(y,b){return y===b?!0:y==null||b==null?!1:String(y)===String(b)}function G(y,b,w){const h=t.messagesByConv[y];if(!h)return;const v=h.findIndex(N=>N.id===b);if(v===-1)return;const C=h.slice();C[v]={...h[v],...w},t.messagesByConv[y]=C}function ee(y,b){const w=t.conversations.findIndex(v=>v.id===y);if(w===-1)return;const h=t.conversations[w];if(b&&(!h.last_message_at||b>h.last_message_at)){const v=t.conversations.slice();v[w]={...h,last_message_at:b},v.sort((C,N)=>(N.last_message_at||"").localeCompare(C.last_message_at||"")),t.conversations=v}}function ue(y,b){return(y.created_at||"").localeCompare(b.created_at||"")}function j(y){if(!y||typeof y!="object")return null;const b={},w={};for(const[h,v]of Object.entries(y))v!==void 0&&(h==="name"||h==="email"?v!=null&&String(v).trim()!==""&&(b[h]=v):(h==="values"||h==="metadata")&&v&&typeof v=="object"?Object.assign(w,v):w[h]=v);return Object.keys(w).length&&(b.values=w),Object.keys(b).length?b:null}function le(y){const b=t.messagesByConv[y]||[];let w="";for(const C of b)C!=null&&C.created_at&&C.created_at>w&&(w=C.created_at);const h=new Date().toISOString();return!w||h>w?h:new Date(Date.parse(w)+1).toISOString()}return{state:t,start:r,destroy:i,applyCustomer:s,createConversation:o,openConversation:l,loadMore:f,fetchSinceLast:A,patchConversation:g,markConversationRead:S,send:H,clickCallback:O,signAttachment:z,submitFeedback:$,getPendingApproval:Q,getActionInFlight:ne,getLatestSuggestions:ge,getLatestForm:U,setPanelOpen:e.setPanelOpen}}const Le={w:"#ffffff",g50:"#F9F9F7",g100:"#F2F1EE",g150:"#E8E6E2",g200:"#D9D6CF",g300:"#B4B0A8",g400:"#888480",g500:"#5A5753",g700:"#2B2926",g900:"#17161A",accent:"#5B5FEF",accentLight:"#EEEFFE",green:"#22C55E",red:"#B91C1C",redBg:"#FDECEC"},ps=["#5B5FEF","#7C3AED","#DB2777","#0891B2","#D97706","#059669"];function Ks(e=""){return e?ps[e.charCodeAt(0)%ps.length]:ps[0]}function qs(e=""){return e.split(" ").map(t=>t[0]||"").join("").toUpperCase().slice(0,2)}function go(e=new Date,t="fr-FR"){return e.toLocaleTimeString(t,{hour:"2-digit",minute:"2-digit"})}const _o=`
|
|
17
|
+
**/let Es;const _r=typeof window<"u"&&window.trustedTypes;if(_r)try{Es=_r.createPolicy("vue",{createHTML:e=>e})}catch{}const ho=Es?e=>Es.createHTML(e):e=>e,_l="http://www.w3.org/2000/svg",yl="http://www.w3.org/1998/Math/MathML",rt=typeof document<"u"?document:null,yr=rt&&rt.createElement("template"),vl={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{const t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,r)=>{const i=t==="svg"?rt.createElementNS(_l,e):t==="mathml"?rt.createElementNS(yl,e):n?rt.createElement(e,{is:n}):rt.createElement(e);return e==="select"&&r&&r.multiple!=null&&i.setAttribute("multiple",r.multiple),i},createText:e=>rt.createTextNode(e),createComment:e=>rt.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>rt.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},insertStaticContent(e,t,n,r,i,s){const o=n?n.previousSibling:t.lastChild;if(i&&(i===s||i.nextSibling))for(;t.insertBefore(i.cloneNode(!0),n),!(i===s||!(i=i.nextSibling)););else{yr.innerHTML=ho(r==="svg"?`<svg>${e}</svg>`:r==="mathml"?`<math>${e}</math>`:e);const a=yr.content;if(r==="svg"||r==="mathml"){const l=a.firstChild;for(;l.firstChild;)a.appendChild(l.firstChild);a.removeChild(l)}t.insertBefore(a,n)}return[o?o.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}},gt="transition",Yt="animation",hn=Symbol("_vtc"),mo={name:String,type:String,css:{type:Boolean,default:!0},duration:[String,Number,Object],enterFromClass:String,enterActiveClass:String,enterToClass:String,appearFromClass:String,appearActiveClass:String,appearToClass:String,leaveFromClass:String,leaveActiveClass:String,leaveToClass:String},bl=Se({},Ei,mo),wl=e=>(e.displayName="Transition",e.props=bl,e),kl=wl((e,{slots:t})=>fo(_a,Cl(e),t)),At=(e,t=[])=>{q(e)?e.forEach(n=>n(...t)):e&&e(...t)},vr=e=>e?q(e)?e.some(t=>t.length>1):e.length>1:!1;function Cl(e){const t={};for(const j in e)j in mo||(t[j]=e[j]);if(e.css===!1)return t;const{name:n="v",type:r,duration:i,enterFromClass:s=`${n}-enter-from`,enterActiveClass:o=`${n}-enter-active`,enterToClass:a=`${n}-enter-to`,appearFromClass:l=s,appearActiveClass:f=o,appearToClass:c=a,leaveFromClass:g=`${n}-leave-from`,leaveActiveClass:A=`${n}-leave-active`,leaveToClass:S=`${n}-leave-to`}=e,H=Sl(i),O=H&&H[0],J=H&&H[1],{onBeforeEnter:z,onEnter:$,onEnterCancelled:Q,onLeave:U,onLeaveCancelled:ne,onBeforeAppear:ge=z,onAppear:he=$,onAppearCancelled:ke=Q}=t,G=(j,le,y,b)=>{j._enterCancelled=b,xt(j,le?c:a),xt(j,le?f:o),y&&y()},ee=(j,le)=>{j._isLeaving=!1,xt(j,g),xt(j,S),xt(j,A),le&&le()},ue=j=>(le,y)=>{const b=j?he:$,w=()=>G(le,j,y);At(b,[le,w]),br(()=>{xt(le,j?l:s),st(le,j?c:a),vr(b)||wr(le,r,O,w)})};return Se(t,{onBeforeEnter(j){At(z,[j]),st(j,s),st(j,o)},onBeforeAppear(j){At(ge,[j]),st(j,l),st(j,f)},onEnter:ue(!1),onAppear:ue(!0),onLeave(j,le){j._isLeaving=!0;const y=()=>ee(j,le);st(j,g),j._enterCancelled?(st(j,A),Sr(j)):(Sr(j),st(j,A)),br(()=>{j._isLeaving&&(xt(j,g),st(j,S),vr(U)||wr(j,r,J,y))}),At(U,[j,y])},onEnterCancelled(j){G(j,!1,void 0,!0),At(Q,[j])},onAppearCancelled(j){G(j,!0,void 0,!0),At(ke,[j])},onLeaveCancelled(j){ee(j),At(ne,[j])}})}function Sl(e){if(e==null)return null;if(ae(e))return[ds(e.enter),ds(e.leave)];{const t=ds(e);return[t,t]}}function ds(e){return xo(e)}function st(e,t){t.split(/\s+/).forEach(n=>n&&e.classList.add(n)),(e[hn]||(e[hn]=new Set)).add(t)}function xt(e,t){t.split(/\s+/).forEach(r=>r&&e.classList.remove(r));const n=e[hn];n&&(n.delete(t),n.size||(e[hn]=void 0))}function br(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}let Al=0;function wr(e,t,n,r){const i=e._endId=++Al,s=()=>{i===e._endId&&r()};if(n!=null)return setTimeout(s,n);const{type:o,timeout:a,propCount:l}=xl(e,t);if(!o)return r();const f=o+"end";let c=0;const g=()=>{e.removeEventListener(f,A),s()},A=S=>{S.target===e&&++c>=l&&g()};setTimeout(()=>{c<l&&g()},a+1),e.addEventListener(f,A)}function xl(e,t){const n=window.getComputedStyle(e),r=H=>(n[H]||"").split(", "),i=r(`${gt}Delay`),s=r(`${gt}Duration`),o=kr(i,s),a=r(`${Yt}Delay`),l=r(`${Yt}Duration`),f=kr(a,l);let c=null,g=0,A=0;t===gt?o>0&&(c=gt,g=o,A=s.length):t===Yt?f>0&&(c=Yt,g=f,A=l.length):(g=Math.max(o,f),c=g>0?o>f?gt:Yt:null,A=c?c===gt?s.length:l.length:0);const S=c===gt&&/\b(?:transform|all)(?:,|$)/.test(r(`${gt}Property`).toString());return{type:c,timeout:g,propCount:A,hasTransform:S}}function kr(e,t){for(;e.length<t.length;)e=e.concat(e);return Math.max(...t.map((n,r)=>Cr(n)+Cr(e[r])))}function Cr(e){return e==="auto"?0:Number(e.slice(0,-1).replace(",","."))*1e3}function Sr(e){return(e?e.ownerDocument:document).body.offsetHeight}function Tl(e,t,n){const r=e[hn];r&&(t=(t?[t,...r]:[...r]).join(" ")),t==null?e.removeAttribute("class"):n?e.setAttribute("class",t):e.className=t}const Ar=Symbol("_vod"),Ml=Symbol("_vsh"),El=Symbol(""),Ol=/(?:^|;)\s*display\s*:/;function Il(e,t,n){const r=e.style,i=ve(n);let s=!1;if(n&&!i){if(t)if(ve(t))for(const o of t.split(";")){const a=o.slice(0,o.indexOf(":")).trim();n[a]==null&&Xt(r,a,"")}else for(const o in t)n[o]==null&&Xt(r,o,"");for(const o in n){o==="display"&&(s=!0);const a=n[o];a!=null?Ll(e,o,!ve(t)&&t?t[o]:void 0,a)||Xt(r,o,a):Xt(r,o,"")}}else if(i){if(t!==n){const o=r[El];o&&(n+=";"+o),r.cssText=n,s=Ol.test(n)}}else t&&e.removeAttribute("style");Ar in e&&(e[Ar]=s?r.display:"",e[Ml]&&(r.display="none"))}const xr=/\s*!important$/;function Xt(e,t,n){if(q(n))n.forEach(r=>Xt(e,t,r));else if(n==null&&(n=""),t.startsWith("--"))e.setProperty(t,n);else{const r=Rl(e,t);xr.test(n)?e.setProperty(kt(r),n.replace(xr,""),"important"):e[r]=n}}const Tr=["Webkit","Moz","ms"],fs={};function Rl(e,t){const n=fs[t];if(n)return n;let r=Pe(t);if(r!=="filter"&&r in e)return fs[t]=r;r=Hn(r);for(let i=0;i<Tr.length;i++){const s=Tr[i]+r;if(s in e)return fs[t]=s}return t}function Ll(e,t,n,r){return e.tagName==="TEXTAREA"&&(t==="width"||t==="height")&&ve(r)&&n===r}const Mr="http://www.w3.org/1999/xlink";function Er(e,t,n,r,i,s=Ro(t)){r&&t.startsWith("xlink:")?n==null?e.removeAttributeNS(Mr,t.slice(6,t.length)):e.setAttributeNS(Mr,t,n):n==null||s&&!ei(n)?e.removeAttribute(t):e.setAttribute(t,s?"":qe(n)?String(n):n)}function Or(e,t,n,r,i){if(t==="innerHTML"||t==="textContent"){n!=null&&(e[t]=t==="innerHTML"?ho(n):n);return}const s=e.tagName;if(t==="value"&&s!=="PROGRESS"&&!s.includes("-")){const a=s==="OPTION"?e.getAttribute("value")||"":e.value,l=n==null?e.type==="checkbox"?"on":"":String(n);(a!==l||!("_value"in e))&&(e.value=l),n==null&&e.removeAttribute(t),e._value=n;return}let o=!1;if(n===""||n==null){const a=typeof e[t];a==="boolean"?n=ei(n):n==null&&a==="string"?(n="",o=!0):a==="number"&&(n=0,o=!0)}try{e[t]=n}catch{}o&&e.removeAttribute(i||t)}function yt(e,t,n,r){e.addEventListener(t,n,r)}function Nl(e,t,n,r){e.removeEventListener(t,n,r)}const Ir=Symbol("_vei");function Bl(e,t,n,r,i=null){const s=e[Ir]||(e[Ir]={}),o=s[t];if(r&&o)o.value=r;else{const[a,l]=Pl(t);if(r){const f=s[t]=jl(r,i);yt(e,a,f,l)}else o&&(Nl(e,a,o,l),s[t]=void 0)}}const Rr=/(?:Once|Passive|Capture)$/;function Pl(e){let t;if(Rr.test(e)){t={};let r;for(;r=e.match(Rr);)e=e.slice(0,e.length-r[0].length),t[r[0].toLowerCase()]=!0}return[e[2]===":"?e.slice(3):kt(e.slice(2)),t]}let hs=0;const Fl=Promise.resolve(),Dl=()=>hs||(Fl.then(()=>hs=0),hs=Date.now());function jl(e,t){const n=r=>{if(!r._vts)r._vts=Date.now();else if(r._vts<=n.attached)return;ze(Ul(r,n.value),t,5,[r])};return n.value=e,n.attached=Dl(),n}function Ul(e,t){if(q(t)){const n=e.stopImmediatePropagation;return e.stopImmediatePropagation=()=>{n.call(e),e._stopped=!0},t.map(r=>i=>!i._stopped&&r&&r(i))}else return t}const Lr=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,Hl=(e,t,n,r,i,s)=>{const o=i==="svg";t==="class"?Tl(e,r,o):t==="style"?Il(e,n,r):Dn(t)?jn(t)||Bl(e,t,n,r,s):(t[0]==="."?(t=t.slice(1),!0):t[0]==="^"?(t=t.slice(1),!1):$l(e,t,r,o))?(Or(e,t,r),!e.tagName.includes("-")&&(t==="value"||t==="checked"||t==="selected")&&Er(e,t,r,o,s,t!=="value")):e._isVueCE&&(Vl(e,t)||e._def.__asyncLoader&&(/[A-Z]/.test(t)||!ve(r)))?Or(e,Pe(t),r,s,t):(t==="true-value"?e._trueValue=r:t==="false-value"&&(e._falseValue=r),Er(e,t,r,o))};function $l(e,t,n,r){if(r)return!!(t==="innerHTML"||t==="textContent"||t in e&&Lr(t)&&X(n));if(t==="spellcheck"||t==="draggable"||t==="translate"||t==="autocorrect"||t==="sandbox"&&e.tagName==="IFRAME"||t==="form"||t==="list"&&e.tagName==="INPUT"||t==="type"&&e.tagName==="TEXTAREA")return!1;if(t==="width"||t==="height"){const i=e.tagName;if(i==="IMG"||i==="VIDEO"||i==="CANVAS"||i==="SOURCE")return!1}return Lr(t)&&ve(n)?!1:t in e}function Vl(e,t){const n=e._def.props;if(!n)return!1;const r=Pe(t);return Array.isArray(n)?n.some(i=>Pe(i)===r):Object.keys(n).some(i=>Pe(i)===r)}const Ht=e=>{const t=e.props["onUpdate:modelValue"]||!1;return q(t)?n=>xn(t,n):t};function Kl(e){e.target.composing=!0}function Nr(e){const t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event("input")))}const dt=Symbol("_assign");function Br(e,t,n){return t&&(e=e.trim()),n&&(e=$n(e)),e}const Ot={created(e,{modifiers:{lazy:t,trim:n,number:r}},i){e[dt]=Ht(i);const s=r||i.props&&i.props.type==="number";yt(e,t?"change":"input",o=>{o.target.composing||e[dt](Br(e.value,n,s))}),(n||s)&&yt(e,"change",()=>{e.value=Br(e.value,n,s)}),t||(yt(e,"compositionstart",Kl),yt(e,"compositionend",Nr),yt(e,"change",Nr))},mounted(e,{value:t}){e.value=t??""},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:r,trim:i,number:s}},o){if(e[dt]=Ht(o),e.composing)return;const a=(s||e.type==="number")&&!/^0\d/.test(e.value)?$n(e.value):e.value,l=t??"";if(a===l)return;const f=e.getRootNode();(f instanceof Document||f instanceof ShadowRoot)&&f.activeElement===e&&e.type!=="range"&&(r&&t===n||i&&e.value.trim()===l)||(e.value=l)}},ql={deep:!0,created(e,t,n){e[dt]=Ht(n),yt(e,"change",()=>{const r=e._modelValue,i=mn(e),s=e.checked,o=e[dt];if(q(r)){const a=Ls(r,i),l=a!==-1;if(s&&!l)o(r.concat(i));else if(!s&&l){const f=[...r];f.splice(a,1),o(f)}}else if($t(r)){const a=new Set(r);s?a.add(i):a.delete(i),o(a)}else o(po(e,s))})},mounted:Pr,beforeUpdate(e,t,n){e[dt]=Ht(n),Pr(e,t,n)}};function Pr(e,{value:t,oldValue:n},r){e._modelValue=t;let i;if(q(t))i=Ls(t,r.props.value)>-1;else if($t(t))i=t.has(r.props.value);else{if(t===n)return;i=Vt(t,po(e,!0))}e.checked!==i&&(e.checked=i)}const zl={deep:!0,created(e,{value:t,modifiers:{number:n}},r){const i=$t(t);yt(e,"change",()=>{const s=Array.prototype.filter.call(e.options,o=>o.selected).map(o=>n?$n(mn(o)):mn(o));e[dt](e.multiple?i?new Set(s):s:s[0]),e._assigning=!0,bi(()=>{e._assigning=!1})}),e[dt]=Ht(r)},mounted(e,{value:t}){Fr(e,t)},beforeUpdate(e,t,n){e[dt]=Ht(n)},updated(e,{value:t}){e._assigning||Fr(e,t)}};function Fr(e,t){const n=e.multiple,r=q(t);if(!(n&&!r&&!$t(t))){for(let i=0,s=e.options.length;i<s;i++){const o=e.options[i],a=mn(o);if(n)if(r){const l=typeof a;l==="string"||l==="number"?o.selected=t.some(f=>String(f)===String(a)):o.selected=Ls(t,a)>-1}else o.selected=t.has(a);else if(Vt(mn(o),t)){e.selectedIndex!==i&&(e.selectedIndex=i);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function mn(e){return"_value"in e?e._value:e.value}function po(e,t){const n=t?"_trueValue":"_falseValue";return n in e?e[n]:t}const Wl=["ctrl","shift","alt","meta"],Gl={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>"button"in e&&e.button!==0,middle:e=>"button"in e&&e.button!==1,right:e=>"button"in e&&e.button!==2,exact:(e,t)=>Wl.some(n=>e[`${n}Key`]&&!t.includes(n))},vt=(e,t)=>{if(!e)return e;const n=e._withMods||(e._withMods={}),r=t.join(".");return n[r]||(n[r]=(i,...s)=>{for(let o=0;o<t.length;o++){const a=Gl[t[o]];if(a&&a(i,t))return}return e(i,...s)})},Yl={esc:"escape",space:" ",up:"arrow-up",left:"arrow-left",right:"arrow-right",down:"arrow-down",delete:"backspace"},Pn=(e,t)=>{const n=e._withKeys||(e._withKeys={}),r=t.join(".");return n[r]||(n[r]=i=>{if(!("key"in i))return;const s=kt(i.key);if(t.some(o=>o===s||Yl[o]===s))return e(i)})},Jl=Se({patchProp:Hl},vl);let Dr;function Xl(){return Dr||(Dr=Xa(Jl))}const Ql=(...e)=>{const t=Xl().createApp(...e),{mount:n}=t;return t.mount=r=>{const i=ec(r);if(!i)return;const s=t._component;!X(s)&&!s.render&&!s.template&&(s.template=i.innerHTML),i.nodeType===1&&(i.textContent="");const o=n(i,!1,Zl(i));return i instanceof Element&&(i.removeAttribute("v-cloak"),i.setAttribute("data-v-app","")),o},t};function Zl(e){if(e instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&e instanceof MathMLElement)return"mathml"}function ec(e){return ve(e)?document.querySelector(e):e}const tc=["connected","message","message_stream","conversation_updated","config_updated","action_status"],ms="/client",nc=5*60*1e3,sc=10*60*1e3,rc=5*60*1e3;function ic(e){const t={baseUrl:oc(e.baseUrl||""),widgetId:e.widgetId||"",userId:"",origin:"",token:"",listeners:new Map,eventSource:null,connection:"idle",visibilityHandler:null,started:!1,panelOpen:!1,pollTimer:null,burstTimer:null,hiddenGraceTimer:null,lastActivityAt:null};if(!t.baseUrl||!t.widgetId)throw new Error("[transport] baseUrl and widgetId are required");function n(h,v){return t.listeners.has(h)||t.listeners.set(h,new Set),t.listeners.get(h).add(v),()=>t.listeners.get(h).delete(v)}function r(h,v){const C=t.listeners.get(h);C&&C.forEach(N=>{try{N(v)}catch(B){console.error("[transport] listener",h,B)}})}function i(h){t.connection!==h&&(t.connection=h,r("connection",h))}function s(){return{"Content-Type":"application/json","X-Widget-Id":t.widgetId,...t.origin?{"X-Parent-Origin":t.origin}:{}}}async function o(h,v,C){const N=await fetch(`${t.baseUrl}${ms}${v}`,{method:h,credentials:"include",headers:s(),body:C!==void 0?JSON.stringify(C):void 0});if(!N.ok){const B=await a(N),V=new Error(`HTTP ${N.status} ${h} ${v} :: ${(B==null?void 0:B.error)||N.statusText}`);throw V.status=N.status,V.body=B,V}return N.status===204?null:N.json()}async function a(h){try{return await h.json()}catch{return null}}async function l(h){if(t.started)return t.lastBootstrap;if(!(h!=null&&h.origin))throw new Error("[transport] start requires origin");t.started=!0,t.origin=h.origin,t.token=h.token||"";const v=await fetch(`${t.baseUrl}${ms}/session`,{method:"POST",credentials:"include",headers:s(),body:JSON.stringify({origin:t.origin,...t.token?{token:t.token}:{},allowUnauthenticated:h.allowUnauthenticated===!0})});if(!v.ok){const ie=await a(v),te=new Error(`Session bootstrap failed: HTTP ${v.status} :: ${(ie==null?void 0:ie.error)||v.statusText}`);throw te.status=v.status,te.body=ie,te}const C=await v.json();t.userId=C.external_id;const[N,B]=await Promise.all([fetch(`${t.baseUrl}/widgets/${encodeURIComponent(t.widgetId)}/config`,{credentials:"include"}).then(async ie=>{if(!ie.ok){const te=await a(ie);throw new Error(`HTTP ${ie.status} GET /widgets/:id/config :: ${(te==null?void 0:te.error)||ie.statusText}`)}return ie.json()}),o("GET","/customers/me")]),V={config:N,customer:(B==null?void 0:B.customer)??null};return t.lastBootstrap=V,await f(),typeof document<"u"&&(t.visibilityHandler=b,document.addEventListener("visibilitychange",t.visibilityHandler)),le(),V}async function f(){try{const h=await A();t.lastActivityAt=h.reduce((v,C)=>{const N=C==null?void 0:C.last_message_at;return N&&(!v||N>v)?N:v},null)}catch(h){console.error("[transport] initial /conversations failed",h)}}async function c(){const h=await o("GET","/customers/me");return(h==null?void 0:h.customer)??null}async function g(h){const v=await o("PATCH","/customers/me",h);return(v==null?void 0:v.customer)??null}async function A(){const h=await o("GET","/conversations");return(h==null?void 0:h.conversations)??[]}async function S(h={}){return(await o("POST","/conversations",h)).conversation}async function H(h){return(await o("GET",`/conversations/${encodeURIComponent(h)}`)).conversation}async function O(h,v){return(await o("PATCH",`/conversations/${encodeURIComponent(h)}`,v)).conversation}async function J(h,v){return o("PATCH",`/conversations/${encodeURIComponent(h)}/read`,{message_id:v})}async function z(h,v={}){const C=new URLSearchParams;v.before&&C.set("before",v.before),v.since&&C.set("since",v.since),v.limit&&C.set("limit",String(v.limit));const N=C.toString()?`?${C.toString()}`:"";return o("GET",`/conversations/${encodeURIComponent(h)}/messages${N}`)}async function $(h,v){ee();const C={client_msg_id:v.client_msg_id,type:"content",text_md:v.text_md,author:{id:t.userId,type:"user"},created_at:v.created_at||new Date().toISOString()};return Array.isArray(v.attachments)&&v.attachments.length&&(C.payload={type:"content",attachments:v.attachments}),v.metadata&&typeof v.metadata=="object"&&(C.metadata=v.metadata),o("POST",`/conversations/${encodeURIComponent(h)}/messages`,C)}async function Q(h,v,C){return ee(),o("POST",`/messages/${encodeURIComponent(h)}/callbacks/${encodeURIComponent(v)}`,C?{inputs:C}:{})}async function U(h){const v=h.name||"attachment",C=h.type||"application/octet-stream",N=h.size||0,B=await o("POST","/attachments",{mime_type:C,size_bytes:N,name:v}),V=await fetch(B.upload_url,{method:"PUT",headers:{"Content-Type":C},body:h});if(!V.ok)throw new Error(`HTTP ${V.status} PUT signed upload`);return{type:ac(C),path:B.path,mime_type:C,size_bytes:N}}async function ne(h){return o("GET",`/attachments/sign?path=${encodeURIComponent(h)}`)}function ge(){const h=new URLSearchParams({widgetId:t.widgetId}).toString();return`${t.baseUrl}${ms}/stream?${h}`}function he(){if(!t.eventSource&&!(typeof document<"u"&&document.hidden)&&t.started)try{const h=new EventSource(ge(),{withCredentials:!0});for(const v of tc)h.addEventListener(v,C=>ke(v,C.data));h.addEventListener("error",()=>r("error",new Error("SSE error"))),t.eventSource=h,i("open")}catch(h){console.error("[transport] SSE open failed",h),r("error",h)}}function ke(h,v){try{const C=JSON.parse(v),N=C&&typeof C=="object"&&"data"in C?C.data:C;r(h,N)}catch(C){console.error("[transport] bad SSE payload",h,C)}}function G(){t.eventSource&&(t.eventSource.close(),t.eventSource=null),t.connection!=="paused"&&i("idle")}function ee(){clearTimeout(t.burstTimer),he(),t.panelOpen||(t.burstTimer=setTimeout(()=>{t.panelOpen||G()},sc))}function ue(h){t.panelOpen=!!h,t.panelOpen?(clearTimeout(t.burstTimer),he()):ee()}async function j(){try{const h=await A(),v=h.reduce((N,B)=>{const V=B==null?void 0:B.last_message_at;return V&&(!N||V>N)?V:N},null);v&&(!t.lastActivityAt||v>t.lastActivityAt)&&(t.lastActivityAt=v,r("activity",{conversations:h,latestAt:v}),ee())}catch(h){console.error("[transport] poll failed",h)}}function le(){y(),!(typeof document<"u"&&document.hidden)&&(t.pollTimer=setInterval(j,nc))}function y(){t.pollTimer&&(clearInterval(t.pollTimer),t.pollTimer=null)}function b(){if(document.hidden)clearTimeout(t.hiddenGraceTimer),t.hiddenGraceTimer=setTimeout(()=>{t.hiddenGraceTimer=null,document.hidden&&(y(),G(),i("paused"))},rc);else{if(t.hiddenGraceTimer){clearTimeout(t.hiddenGraceTimer),t.hiddenGraceTimer=null;return}i("idle"),le(),t.panelOpen&&he()}}function w(){y(),clearTimeout(t.burstTimer),clearTimeout(t.hiddenGraceTimer),t.hiddenGraceTimer=null,G(),t.visibilityHandler&&(document.removeEventListener("visibilitychange",t.visibilityHandler),t.visibilityHandler=null),t.started=!1}return{on:n,start:l,stop:w,setPanelOpen:ue,getCustomer:c,patchCustomer:g,listConversations:A,createConversation:S,getConversation:H,patchConversation:O,markConversationRead:J,listMessages:z,postMessage:$,postCallback:Q,uploadAttachment:U,signAttachment:ne,get connection(){return t.connection}}}function oc(e){return e.endsWith("/")?e.slice(0,-1):e}function ac(e){return e.startsWith("image/")?"image":e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":"file"}function lc(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();const e=new Uint8Array(16);if(typeof crypto<"u"&&crypto.getRandomValues)crypto.getRandomValues(e);else for(let n=0;n<16;n++)e[n]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;const t=[...e].map(n=>n.toString(16).padStart(2,"0"));return t.slice(0,4).join("")+"-"+t.slice(4,6).join("")+"-"+t.slice(6,8).join("")+"-"+t.slice(8,10).join("")+"-"+t.slice(10,16).join("")}function cc(e){const t=qn({ready:!1,error:null,config:null,customer:null,conversations:[],messagesByConv:{},paginationByConv:{},streamingByMsgId:{},awaitingCallback:{},runningActionsByConv:{},connection:"idle"}),n=[];n.push(e.on("connection",y=>{t.connection=y})),n.push(e.on("message",y=>{const b=y==null?void 0:y.conversation_id,w=y==null?void 0:y.message;!b||!(w!=null&&w.id)||(he(b,w),w.client_msg_id&&delete t.streamingByMsgId[w.client_msg_id],ee(b,w.created_at))})),n.push(e.on("message_stream",y=>{const b=y==null?void 0:y.message_id,w=y==null?void 0:y.token;!b||typeof w!="string"||(t.streamingByMsgId[b]=(t.streamingByMsgId[b]||"")+w)})),n.push(e.on("conversation_updated",y=>{const b=y==null?void 0:y.conversation_id,w=y==null?void 0:y.changes;if(!b||!w)return;const h=t.conversations.findIndex(v=>v.id===b);h!==-1&&(t.conversations[h]={...t.conversations[h],...w})})),n.push(e.on("config_updated",y=>{y!=null&&y.config&&(t.config=y.config)})),n.push(e.on("action_status",y=>{const b=y==null?void 0:y.conversation_id,w=y==null?void 0:y.action_id,h=y==null?void 0:y.action_name;if(!b||!w)return;const v=t.runningActionsByConv[b]||{};y.state==="running"?(v[w]=h||w,t.runningActionsByConv[b]={...v}):y.state==="done"&&(delete v[w],t.runningActionsByConv[b]={...v})})),n.push(e.on("activity",y=>{Array.isArray(y==null?void 0:y.conversations)&&(t.conversations=y.conversations)}));async function r(y){try{const b=new Promise((h,v)=>setTimeout(()=>v(new Error("bootstrap timeout (15s) — check baseUrl, CORS, and network")),15e3)),w=await Promise.race([e.start(y),b]);t.config=w.config,t.customer=w.customer,t.conversations=await Promise.race([e.listConversations(),b]),t.ready=!0}catch(b){console.error("[store] start failed",b),t.error=(b==null?void 0:b.message)||String(b)}}function i(){for(const y of n)try{y()}catch{}e.stop()}async function s(y){const b=j(y);if(!b)return t.customer;try{const w=await e.patchCustomer(b);w&&(t.customer=w)}catch(w){console.error("[store] applyCustomer failed",w)}return t.customer}async function o(y={}){const b=await e.createConversation(y),w=t.conversations.findIndex(h=>h.id===b.id);return w===-1?t.conversations=[b,...t.conversations]:t.conversations[w]=b,b}const a=50;async function l(y){const b=t.paginationByConv[y];if(!(b!=null&&b.loaded||b!=null&&b.loading)){c(y,{nextCursor:null,loading:!0,loaded:!1});try{const w=await e.listMessages(y,{limit:a}),h=(w==null?void 0:w.messages)??[],v=t.messagesByConv[y]||[],C=new Set;for(const B of h)(B==null?void 0:B.id)!=null&&C.add(`id:${String(B.id)}`),B!=null&&B.client_msg_id&&C.add(`c:${B.client_msg_id}`);const N=v.filter(B=>!((B==null?void 0:B.id)!=null&&C.has(`id:${String(B.id)}`)||B!=null&&B.client_msg_id&&C.has(`c:${B.client_msg_id}`)));t.messagesByConv[y]=[...h,...N].sort(ue),c(y,{nextCursor:(w==null?void 0:w.next_cursor)??null,loading:!1,loaded:!0})}catch(w){console.error("[store] openConversation failed",w),c(y,{nextCursor:null,loading:!1,loaded:!1})}}}async function f(y){var v;const b=t.paginationByConv[y];if(!b||b.loading||!b.nextCursor)return;const h=(v=(t.messagesByConv[y]||[]).find(C=>C==null?void 0:C.created_at))==null?void 0:v.created_at;if(h){c(y,{...b,loading:!0});try{const C=await e.listMessages(y,{before:h,limit:a}),N=(C==null?void 0:C.messages)??[],B=t.messagesByConv[y]||[],V=new Set;for(const te of B)(te==null?void 0:te.id)!=null&&V.add(`id:${String(te.id)}`),te!=null&&te.client_msg_id&&V.add(`c:${te.client_msg_id}`);const ie=N.filter(te=>!((te==null?void 0:te.id)!=null&&V.has(`id:${String(te.id)}`)||te!=null&&te.client_msg_id&&V.has(`c:${te.client_msg_id}`)));t.messagesByConv[y]=[...ie,...B],c(y,{nextCursor:(C==null?void 0:C.next_cursor)??null,loading:!1,loaded:!0})}catch(C){console.error("[store] loadMore failed",C),c(y,{...b,loading:!1})}}}function c(y,b){t.paginationByConv={...t.paginationByConv,[y]:b}}async function g(y,b){const w=await e.patchConversation(y,b),h=t.conversations.findIndex(v=>v.id===y);h!==-1&&(t.conversations[h]=w)}async function A(y){if(!y)return[];const b=t.messagesByConv[y]||[];let w="";for(const h of b)h!=null&&h.created_at&&h.created_at>w&&(w=h.created_at);try{const h=await e.listMessages(y,w?{since:w}:{}),v=(h==null?void 0:h.messages)||[];if(!v.length)return[];const C=new Set,N=new Set;for(const V of b)(V==null?void 0:V.id)!=null&&C.add(String(V.id)),V!=null&&V.client_msg_id&&N.add(V.client_msg_id);const B=[];for(const V of v){const ie=(V==null?void 0:V.id)!=null&&C.has(String(V.id))||(V==null?void 0:V.client_msg_id)&&N.has(V.client_msg_id);he(y,V),ie||B.push(V)}return B}catch(h){return console.error("[store] fetchSinceLast failed",h),[]}}async function S(y,b){if(!(!y||b==null))try{const w=await e.markConversationRead(y,b),h=(w==null?void 0:w.last_read_message_id)??b,v=t.conversations.findIndex(C=>(C==null?void 0:C.id)===y);v!==-1&&(t.conversations[v]={...t.conversations[v],last_read_message_id:h})}catch(w){console.error("[store] markConversationRead failed",w)}}async function H(y,b,{attachments:w,metadata:h}={}){var ie;const v=(b||"").trim(),C=Array.isArray(w)&&w.length>0;if(!y||!v&&!C)return;const N=lc(),B=le(y),V={id:N,client_msg_id:N,conversation_id:y,type:"content",text_md:v,author:{type:"user",id:((ie=t.customer)==null?void 0:ie.external_id)||null},created_at:B,_pending:!0,...C?{payload:{type:"content",attachments:w}}:{},...h&&typeof h=="object"?{metadata:h}:{}};he(y,V);try{await e.postMessage(y,{client_msg_id:N,text_md:v,created_at:B,...C?{attachments:w}:{},...h&&typeof h=="object"?{metadata:h}:{}})}catch(te){console.error("[store] send failed",te),G(y,N,{_failed:!0,_pending:!1})}}async function O(y,b,w){y!=null&&(t.awaitingCallback[y]=!0);try{await e.postCallback(y,b,w)}catch(h){console.error("[store] callback failed",h),y!=null&&delete t.awaitingCallback[y]}}const J=new Map;async function z(y){if(!y)return null;const b=J.get(y);if(b!=null&&b.url){const w=b.expires_at?Date.parse(b.expires_at):0;if(!w||w-Date.now()>6e4)return b.url}try{const w=await e.signAttachment(y);if(w!=null&&w.signed_url)return J.set(y,{url:w.signed_url,expires_at:w.expires_at}),w.signed_url}catch(w){console.error("[store] sign attachment failed",w)}return null}async function $(y,{rating:b,comment:w}={}){const h=t.conversations.find(N=>N.id===y),C={...(h==null?void 0:h.metadata)||{},feedback:{rating:b,comment:w||null,submitted_at:new Date().toISOString()}};await g(y,{metadata:C})}function Q(y){var w,h;const b=t.messagesByConv[y]||[];for(let v=b.length-1;v>=0;v--){const C=b[v];if((C==null?void 0:C.type)==="action"&&((w=C==null?void 0:C.payload)==null?void 0:w.type)==="action"&&((h=C==null?void 0:C.payload)==null?void 0:h.state)==="pending"&&Array.isArray(C==null?void 0:C.callbacks)&&C.callbacks.length>0&&!t.awaitingCallback[C.id])return C}return null}function U(y){var w,h,v;const b=t.messagesByConv[y]||[];for(let C=b.length-1;C>=0;C--){const N=b[C];if(((w=N==null?void 0:N.author)==null?void 0:w.type)==="user"||(N==null?void 0:N.type)==="action"&&((h=N==null?void 0:N.payload)==null?void 0:h.state)==="pending")return null;const B=(v=N==null?void 0:N.metadata)==null?void 0:v.form;if(B&&Array.isArray(B.fields)&&B.fields.length>0)return{message:N,form:B}}return null}function ne(y){const b=t.runningActionsByConv[y];if(!b)return null;const w=Object.keys(b);if(w.length===0)return null;const h=w[0];return{id:h,payload:{name:b[h]}}}function ge(y){var w,h,v,C;const b=t.messagesByConv[y]||[];for(let N=b.length-1;N>=0;N--){const B=b[N];if(((w=B==null?void 0:B.author)==null?void 0:w.type)==="user")return[];if((B==null?void 0:B.type)==="action"&&((h=B==null?void 0:B.payload)==null?void 0:h.state)==="pending")return[];if(((v=B==null?void 0:B.author)==null?void 0:v.type)!=="agent_ia")continue;const V=(C=B==null?void 0:B.metadata)==null?void 0:C.suggested_replies;return Array.isArray(V)&&V.length?V.map(ie=>{if(typeof ie=="string"){const te=ie.trim();return te?{label:te,kind:null}:null}if(ie&&typeof ie=="object"&&typeof ie.label=="string"){const te=ie.label.trim();if(!te)return null;const Zn=ie.kind==="cta"||ie.kind==="choice"||ie.kind==="followup"?ie.kind:null;return{label:te,kind:Zn}}return null}).filter(Boolean).slice(0,4):[]}return[]}function he(y,b){var C;const w=t.messagesByConv[y]||[];let h=-1;b!=null&&b.client_msg_id&&(h=w.findIndex(N=>(N==null?void 0:N.client_msg_id)&&N.client_msg_id===b.client_msg_id)),h===-1&&(b==null?void 0:b.id)!==void 0&&(b==null?void 0:b.id)!==null&&(h=w.findIndex(N=>ke(N==null?void 0:N.id,b.id)));let v;h===-1?v=[...w,b].sort(ue):(v=w.slice(),v[h]={...w[h],...b,_pending:!1,_failed:!1}),t.messagesByConv[y]=v,(b==null?void 0:b.type)==="action"&&((C=b==null?void 0:b.payload)!=null&&C.state)&&b.payload.state!=="pending"&&(b==null?void 0:b.id)!=null&&t.awaitingCallback[b.id]&&delete t.awaitingCallback[b.id]}function ke(y,b){return y===b?!0:y==null||b==null?!1:String(y)===String(b)}function G(y,b,w){const h=t.messagesByConv[y];if(!h)return;const v=h.findIndex(N=>N.id===b);if(v===-1)return;const C=h.slice();C[v]={...h[v],...w},t.messagesByConv[y]=C}function ee(y,b){const w=t.conversations.findIndex(v=>v.id===y);if(w===-1)return;const h=t.conversations[w];if(b&&(!h.last_message_at||b>h.last_message_at)){const v=t.conversations.slice();v[w]={...h,last_message_at:b},v.sort((C,N)=>(N.last_message_at||"").localeCompare(C.last_message_at||"")),t.conversations=v}}function ue(y,b){return(y.created_at||"").localeCompare(b.created_at||"")}function j(y){if(!y||typeof y!="object")return null;const b={},w={};for(const[h,v]of Object.entries(y))v!==void 0&&(h==="name"||h==="email"||h==="language"?v!=null&&String(v).trim()!==""&&(b[h]=v):(h==="values"||h==="metadata")&&v&&typeof v=="object"?Object.assign(w,v):w[h]=v);return Object.keys(w).length&&(b.values=w),Object.keys(b).length?b:null}function le(y){const b=t.messagesByConv[y]||[];let w="";for(const C of b)C!=null&&C.created_at&&C.created_at>w&&(w=C.created_at);const h=new Date().toISOString();return!w||h>w?h:new Date(Date.parse(w)+1).toISOString()}return{state:t,start:r,destroy:i,applyCustomer:s,createConversation:o,openConversation:l,loadMore:f,fetchSinceLast:A,patchConversation:g,markConversationRead:S,send:H,clickCallback:O,signAttachment:z,submitFeedback:$,getPendingApproval:Q,getActionInFlight:ne,getLatestSuggestions:ge,getLatestForm:U,setPanelOpen:e.setPanelOpen}}const Le={w:"#ffffff",g50:"#F9F9F7",g100:"#F2F1EE",g150:"#E8E6E2",g200:"#D9D6CF",g300:"#B4B0A8",g400:"#888480",g500:"#5A5753",g700:"#2B2926",g900:"#17161A",accent:"#5B5FEF",accentLight:"#EEEFFE",green:"#22C55E",red:"#B91C1C",redBg:"#FDECEC"},ps=["#5B5FEF","#7C3AED","#DB2777","#0891B2","#D97706","#059669"];function Ks(e=""){return e?ps[e.charCodeAt(0)%ps.length]:ps[0]}function qs(e=""){return e.split(" ").map(t=>t[0]||"").join("").toUpperCase().slice(0,2)}function go(e=new Date,t="fr-FR"){return e.toLocaleTimeString(t,{hour:"2-digit",minute:"2-digit"})}const _o=`
|
|
18
18
|
@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700&family=Geist+Mono:wght@400;500&display=swap');
|
|
19
19
|
|
|
20
20
|
.wm-root {
|
|
@@ -70,4 +70,4 @@ ${a}`)}return i.join(`
|
|
|
70
70
|
`)}function _c(e,t,n=Ee(),r){if(!e)return;const i=gc(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 yc={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||!gn(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)}}}},vc=450,bc=50,wc=900,kc=12e3,Cc=300,Sc={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(kc,Math.max(wc,r*bc)),o=Math.max(n+vc,this.nextRevealAt+Cc)+i;this.nextRevealAt=o;const a=Math.max(0,o-n),l=e.id,f=setTimeout(()=>{this.revealedAt={...this.revealedAt,[l]:Date.now()},this.revealTimers=this.revealTimers.filter(c=>c!==f),typeof this.onMessageRevealed=="function"&&this.onMessageRevealed(e,t)},a);this.revealTimers.push(f)},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(!gn(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(!gn(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)}}},Ac={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)}}},xc=300,Tc={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=Mc(t);if(n==null)return;const r=ut(e.last_read_message_id),i=ut(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)},xc))))}}};function Mc(e){for(let t=e.length-1;t>=0;t--){const n=e[t];if(!(!n||n._pending)&&ut(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},Ec={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":Ks(this.name)},initials(){return qs(this.name)}}},Oc=["src","alt"];function Ic(e,t,n,r,i,s){return p(),_("div",{class:re(["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?(p(),_("img",{key:0,src:n.avatarUrl,alt:n.name||""},null,8,Oc)):(p(),_("span",{key:1,style:je({fontSize:n.size*.36+"px"})},I(s.initials),5))],6)}const vo=we(Ec,[["render",Ic],["__scopeId","data-v-14e10c0d"]]),Rc=3,Lc={name:"WmLauncher",components:{HumanAvatar:vo},inject:{t:{default:()=>Ee()}},props:{unreadCount:{type:Number,default:0},peeks:{type:Array,default:()=>[]}},emits:["open","dismiss"],computed:{visiblePeeks(){return this.peeks.slice(0,Rc).reverse()}}},Nc=["aria-label","onClick","onKeydown"],Bc=["aria-label","onClick"],Pc={class:"wm-peek__avatar"},Fc=["aria-label"],Dc={class:"wm-peek__body"},jc={class:"wm-peek__head"},Uc={class:"wm-peek__name"},Hc={class:"wm-peek__action"},$c={class:"wm-peek__text"},Vc=["onClick"],Kc=["aria-label"],qc=["aria-label"];function zc(e,t,n,r,i,s){const o=_e("HumanAvatar");return p(),_("div",{class:"wm-launcherWrap",onMouseenter:t[1]||(t[1]=a=>e.$emit("hover",!0)),onMouseleave:t[2]||(t[2]=a=>e.$emit("hover",!1)),onFocusin:t[3]||(t[3]=a=>e.$emit("hover",!0)),onFocusout:t[4]||(t[4]=a=>e.$emit("hover",!1))},[ye(kl,{name:"wm-peek"},{default:Ai(()=>[s.visiblePeeks.length?(p(),_("div",{key:0,class:re(["wm-peekStack",{"wm-peekStack--multi":s.visiblePeeks.length>1}])},[(p(!0),_(Z,null,Me(s.visiblePeeks,(a,l)=>(p(),_("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:f=>e.$emit("open",a.convId),onKeydown:[Pn(vt(f=>e.$emit("open",a.convId),["prevent"]),["enter"]),Pn(vt(f=>e.$emit("open",a.convId),["prevent"]),["space"])]},[u("button",{type:"button",class:"wm-peek__close","aria-label":s.t("launcher.dismiss"),onClick:vt(f=>e.$emit("dismiss",a.convId),["stop"])},[...t[5]||(t[5]=[u("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[u("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,Bc),u("div",Pc,[ye(o,{name:a.senderName,"avatar-url":a.senderAvatarUrl,size:34},null,8,["name","avatar-url"]),a.count>1?(p(),_("span",{key:0,class:"wm-peek__avatarBadge","aria-label":s.t("launcher.unreadMessages",{count:a.count})},I(a.count>9?"9+":a.count),9,Fc)):D("",!0)]),u("div",Dc,[u("div",jc,[u("span",Uc,I(a.senderName||s.t("common.agent")),1),u("span",Hc,I(s.t("launcher.repliedToYou")),1)]),u("p",$c,I(a.preview),1)]),u("button",{type:"button",class:"wm-peek__open",onClick:vt(f=>e.$emit("open",a.convId),["stop"])},I(s.t("common.open")),9,Vc)],44,Nc))),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[6]||(t[6]=u("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.7","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[u("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})],-1)),n.unreadCount>0?(p(),_("span",{key:0,class:"wm-launcher__badge","aria-label":n.unreadCount>1?s.t("launcher.unreadConversationsMany",{count:n.unreadCount}):s.t("launcher.unreadConversationsOne",{count:n.unreadCount})},I(n.unreadCount>9?"9+":n.unreadCount),9,qc)):D("",!0)],8,Kc)],32)}const Wc=we(Lc,[["render",zc],["__scopeId","data-v-44ddf1a1"]]),Gc={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 qs(this.name)},bgColor(){return Ks(this.name)}}},Yc={key:0,class:"wm-aiav__pulse"},Jc=["src","alt"],Xc=["width","height"];function Qc(e,t,n,r,i,s){return p(),_("div",{class:re(["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?(p(),_("div",Yc)):D("",!0),u("div",{class:re(["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?(p(),_("img",{key:0,src:n.imageUrl,alt:n.name||""},null,8,Jc)):s.initials?(p(),_("span",{key:1,style:je({fontSize:n.size*.36+"px"})},I(s.initials),5)):(p(),_("svg",{key:2,width:n.size*.5,height:n.size*.5,viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[...t[0]||(t[0]=[u("path",{d:"M12 2 L13.5 9 L20 10.5 L13.5 12 L12 19 L10.5 12 L4 10.5 L10.5 9 Z",fill:"white",opacity:"0.92"},null,-1),u("circle",{cx:"19",cy:"5",r:"1.5",fill:"white",opacity:"0.55"},null,-1),u("circle",{cx:"5",cy:"18",r:"1",fill:"white",opacity:"0.38"},null,-1)])],8,Xc))],6)],6)}const wn=we(Gc,[["render",Qc],["__scopeId","data-v-6f7f685d"]]),Zc={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":Ks(e.name||"")},initialsFor(e){return qs(e.name||"")}}},eu={key:0,class:"wm-team"},tu=["src","alt"],nu={key:1},su={key:0,class:"wm-team__label"};function ru(e,t,n,r,i,s){return s.visible?(p(),_("div",eu,[u("div",{class:"wm-team__stack",style:je({width:s.stackWidth+"px"})},[(p(!0),_(Z,null,Me(n.members.slice(0,3),(o,a)=>(p(),_("div",{key:a,class:"wm-team__pill",style:je({left:a*13+"px",zIndex:3-a,background:s.colorFor(o)})},[o.avatar_url?(p(),_("img",{key:0,src:o.avatar_url,alt:o.name||""},null,8,tu)):(p(),_("span",nu,I(s.initialsFor(o)),1))],4))),128))],4),n.responseLabel?(p(),_("span",su,I(n.responseLabel),1)):D("",!0)])):D("",!0)}const iu=we(Zc,[["render",ru],["__scopeId","data-v-e49a9063"]]),ou={name:"WmHeader",components:{AIAvatar:wn,TeamAvatars:iu},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}}},au={class:"wm-header"},lu=["aria-label"],cu={key:1,style:{width:"30px",height:"30px","flex-shrink":"0"}},uu={class:"wm-header__avatar"},du={class:"wm-header__main"},fu={class:"wm-header__title"},hu={key:3,class:"wm-header__fill"},mu={class:"wm-header__actions"},pu=["aria-label","title"],gu=["aria-label","title"];function _u(e,t,n,r,i,s){const o=_e("AIAvatar"),a=_e("TeamAvatars");return p(),_("div",au,[n.showBack?(p(),_("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,lu)):(p(),_("div",cu)),n.showIdentity?(p(),_(Z,{key:2},[u("div",uu,[ye(o,{size:30,name:n.agentName,"image-url":n.agentAvatarUrl},null,8,["name","image-url"])]),u("div",du,[u("div",fu,I(n.title),1)]),s.hasTeam?(p(),be(a,{key:0,members:s.displayedTeamMembers,"response-label":""},null,8,["members"])):D("",!0)],64)):(p(),_("div",hu)),u("div",mu,[n.showMore?(p(),_("button",{key:0,type:"button",class:re(["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,pu)):D("",!0),n.showClose?(p(),_("button",{key:1,type:"button",class:"wm-header__icon","aria-label":s.t("header.closeWidget"),title:s.t("header.closeWidget"),onClick:t[2]||(t[2]=l=>e.$emit("close"))},[...t[5]||(t[5]=[u("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[u("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,gu)):D("",!0)])])}const yu=we(ou,[["render",_u],["__scopeId","data-v-925c9e94"]]);function bo(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function vu(e){return/^(https?:\/\/|mailto:|tel:)/i.test(String(e).trim())}const $r="";function Qt(e){let t=e;const n=[];return t=t.replace(/`([^`\n]+)`/g,(r,i)=>{const s=n.length;return n.push(i),`${$r}CODE${s}${$r}`}),t=t.replace(/\[([^\]\n]+)\]\(([^)\s]+)\)/g,(r,i,s)=>vu(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 Qt(bo(t))}function wu(e){if(!e)return"";const t=bo(e).split(`
|
|
71
71
|
`),n=[];let r=0;for(;r<t.length;){const s=t[r];if(/^\s*```([\w-]*)\s*$/.exec(s)){r++;const f=[];for(;r<t.length&&!/^\s*```\s*$/.test(t[r]);)f.push(t[r]),r++;r<t.length&&r++,n.push({type:"block",html:`<pre class="wm-md-pre"><code>${f.join(`
|
|
72
72
|
`)}</code></pre>`});continue}if(/^\s*[-*]\s+/.test(s)){const f=[];for(;r<t.length;){const g=/^\s*[-*]\s+(.*)$/.exec(t[r]);if(!g)break;f.push(g[1]),r++}const c=f.map(g=>`<li>${Qt(g)}</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 f=parseInt(a[1],10),c=[a[2]];for(r++;r<t.length;){const S=/^\s*\d+\.\s+(.*)$/.exec(t[r]);if(!S)break;c.push(S[1]),r++}const g=c.map(S=>`<li>${Qt(S)}</li>`).join(""),A=f!==1?` start="${f}"`:"";n.push({type:"block",html:`<ol class="wm-md-ol"${A}>${g}</ol>`});continue}const l=/^(#{1,6})\s+(.*)$/.exec(s);if(l){const f=l[1].length;n.push({type:"block",html:`<h${f} class="wm-md-h wm-md-h${f}">${Qt(l[2])}</h${f}>`}),r++;continue}n.push({type:"text",html:Qt(s)}),r++}let i="";for(let s=0;s<n.length;s++){const o=n[s];i+=o.html;const a=n[s+1];a&&o.type!=="block"&&a.type!=="block"&&(i+=`
|
|
73
|
-
`)}return i}const Vr={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"},ku={name:"WmOnboarding",components:{AIAvatar:wn},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 Vr[e]||Vr.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"})}}},Cu={class:"wm-onb"},Su={class:"wm-onb__hero"},Au={class:"wm-onb__hero-text"},xu={class:"wm-onb__title"},Tu={class:"wm-onb__sub"},Mu={class:"wm-onb__cta"},Eu=["disabled"],Ou={key:0,class:"wm-onb__section"},Iu={class:"wm-onb__section-title"},Ru=["onClick"],Lu={class:"wm-onb__card-icon"},Nu={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"},Bu=["d"],Pu={class:"wm-onb__card-body"},Fu={class:"wm-onb__card-title"},Du={key:0,class:"wm-onb__card-sub"},ju={key:1,class:"wm-onb__section"},Uu={class:"wm-onb__section-title"},Hu={class:"wm-onb__search"},$u=["placeholder","aria-label"],Vu={class:"wm-onb__list"},Ku=["onClick"],qu=["aria-label"],zu={class:"wm-onb__thread-body"},Wu={class:"wm-onb__thread-title"},Gu=["innerHTML"],Yu={class:"wm-onb__thread-meta"},Ju={key:0,class:"wm-onb__thread-time"},Xu={key:0,class:"wm-onb__empty"};function Qu(e,t,n,r,i,s){const o=_e("AIAvatar");return p(),_("div",Cu,[u("div",Su,[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",Au,[u("div",xu,I(s.heroTitle),1),u("div",Tu,I(s.heroSub),1)])]),u("div",Mu,[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,I(n.busy?"…":s.t("onboarding.start")),1)],8,Eu)]),n.quickLinks.length?(p(),_("div",Ou,[u("div",Iu,I(s.t("onboarding.quickAccess")),1),u("div",{class:re(s.quickLinksLayout)},[(p(!0),_(Z,null,Me(n.quickLinks,(a,l)=>(p(),_("button",{key:l,type:"button",class:re(["wm-onb__card",{"wm-onb__card--row":s.isOddQuickLinks}]),onClick:f=>e.$emit("select",a)},[u("span",Lu,[(p(),_("svg",Nu,[u("path",{d:s.iconPath(a.icon)},null,8,Bu)]))]),u("span",Pu,[u("span",Fu,I(a.label),1),a.description?(p(),_("span",Du,I(a.description),1)):D("",!0)])],10,Ru))),128))],2)])):D("",!0),n.openThreads.length?(p(),_("div",ju,[u("div",Uu,I(s.t("onboarding.recentConversations")),1),u("div",Hu,[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)),it(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,$u),[[Ot,i.query]])]),u("div",Vu,[(p(!0),_(Z,null,Me(s.filteredThreads,a=>(p(),_("button",{key:a.id,type:"button",class:"wm-onb__thread",onClick:l=>e.$emit("resume",a)},[u("span",{class:re(["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?(p(),_("span",{key:0,class:"wm-onb__thread-dot","aria-label":s.t("onboarding.unread")},null,8,qu)):D("",!0)],2),u("span",zu,[u("span",Wu,I(a.title),1),u("span",{class:"wm-onb__thread-preview",innerHTML:s.renderPreview(a.preview)},null,8,Gu)]),u("span",Yu,[s.formatTs(a._ts)?(p(),_("span",Ju,I(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,Ku))),128)),s.filteredThreads.length?D("",!0):(p(),_("div",Xu,I(s.t("onboarding.noResults",{query:i.query})),1))])])):D("",!0)])}const Zu=we(ku,[["render",Qu],["__scopeId","data-v-28c0780b"]]);function ed(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 td={name:"WmActionResult",props:{state:{type:String,default:"success"},label:{type:String,required:!0},detail:{type:String,default:""}},computed:{detailText(){return ed(this.detail)}}},nd={class:"wm-result__icon","aria-hidden":"true"},sd={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"},rd={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"},id={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"},od={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"},ad={class:"wm-result__body"},ld={class:"wm-result__label"},cd={class:"wm-result__detail"};function ud(e,t,n,r,i,s){return p(),_("div",{class:re(["wm-result",`wm-result--${n.state}`])},[u("span",nd,[n.state==="success"?(p(),_("svg",sd,[...t[0]||(t[0]=[u("path",{d:"M20 6L9 17l-5-5"},null,-1)])])):n.state==="rejected"?(p(),_("svg",rd,[...t[1]||(t[1]=[u("path",{d:"M18 6L6 18M6 6l12 12"},null,-1)])])):n.state==="awaiting"?(p(),_("svg",id,[...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)])])):(p(),_("svg",od,[...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",ad,[u("span",ld,I(n.label),1),s.detailText?(p(),_(Z,{key:0},[t[4]||(t[4]=u("span",{class:"wm-result__sep","aria-hidden":"true"}," · ",-1)),u("span",cd,I(s.detailText),1)],64)):D("",!0)])],2)}const dd=we(td,[["render",ud],["__scopeId","data-v-7284acd0"]]),fd={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:[]}}},hd={class:"wm-art wm-art--formResponse"},md={class:"wm-art__head"},pd={class:"wm-art__title"},gd={class:"wm-art__badge wm-art__badge--success"},_d={class:"wm-art__body"},yd={class:"wm-art__fieldLabel"};function vd(e,t,n,r,i,s){return p(),_("div",hd,[u("div",md,[u("div",pd,I(n.data.title||s.t("form.title")),1),u("span",gd,[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)),Xn(" "+I(s.t("form.sent")),1)])]),u("div",_d,[(p(!0),_(Z,null,Me(s.fields,(o,a)=>(p(),_("div",{key:a,class:"wm-art__field"},[u("div",yd,I(o.label),1),u("div",{class:re(["wm-art__fieldValue",{"wm-art__fieldValue--multi":o.multiline}])},I(o.value),3)]))),128))])])}const bd=we(fd,[["render",vd],["__scopeId","data-v-713aecf1"]]),wd={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}}},kd={class:"wm-art wm-art--infoCard"},Cd={key:0,class:"wm-art__image"},Sd=["src","alt"],Ad={class:"wm-art__head"},xd={class:"wm-art__headMain"},Td={class:"wm-art__title"},Md={key:0,class:"wm-art__subtitle"},Ed={key:1,class:"wm-art__body"},Od={key:0,class:"wm-art__text"},Id={class:"wm-art__fieldLabel"};function Rd(e,t,n,r,i,s){return p(),_("div",kd,[n.data.image_url?(p(),_("figure",Cd,[u("img",{src:n.data.image_url,alt:n.data.title||"",loading:"lazy"},null,8,Sd)])):D("",!0),u("div",Ad,[u("div",xd,[u("div",Td,I(n.data.title),1),n.data.subtitle?(p(),_("div",Md,I(n.data.subtitle),1)):D("",!0)]),n.data.badge&&n.data.badge.label?(p(),_("span",{key:0,class:re(["wm-art__badge",`wm-art__badge--${n.data.badge.tone||"neutral"}`])},I(n.data.badge.label),3)):D("",!0)]),s.hasBody?(p(),_("div",Ed,[n.data.body?(p(),_("div",Od,I(n.data.body),1)):D("",!0),s.fields.length?(p(!0),_(Z,{key:1},Me(s.fields,(o,a)=>(p(),_("div",{key:a,class:"wm-art__field"},[u("div",Id,I(o.label),1),u("div",{class:re(["wm-art__fieldValue",{"wm-art__fieldValue--multi":o.multiline}])},I(o.value),3)]))),128)):D("",!0)])):D("",!0)])}const Ld=we(wd,[["render",Rd],["__scopeId","data-v-7eae0e4a"]]);function Nd(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 Bd={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 Nd((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}}},Pd={class:"wm-art wm-art--ticket"},Fd={class:"wm-art__head wm-tk__head"},Dd={class:"wm-art__title wm-tk__title"},jd={class:"wm-tk__sub"},Ud={class:"wm-tk__ref"},Hd={key:0,class:"wm-tk__text"},$d={key:0,class:"wm-art__body"},Vd={class:"wm-art__fieldLabel"},Kd=["data-level"],qd={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"},zd={key:1,class:"wm-art__footer wm-tk__footer"};function Wd(e,t,n,r,i,s){return p(),_("div",Pd,[u("div",Fd,[u("div",Dd,I(n.data.title),1),u("div",jd,[u("div",Ud,[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,I(n.data.reference),1)]),u("span",{class:re(["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)),Xn(" "+I(n.data.status.label),1)],2)]),n.data.body?(p(),_("div",Hd,I(n.data.body),1)):D("",!0)]),s.fields.length?(p(),_("div",$d,[(p(!0),_(Z,null,Me(s.fields,(o,a)=>(p(),_("div",{key:a,class:"wm-art__field"},[u("div",Vd,I(o.label),1),u("div",{class:re(["wm-art__fieldValue",{"wm-art__fieldValue--multi":o.multiline}])},[s.isPriority(o.label)?(p(),_("svg",{key:0,class:"wm-tk__prio","data-level":s.priorityLevel(o.value),width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true"},[...t[2]||(t[2]=[u("rect",{x:"1",y:"8",width:"2",height:"3",rx:"0.5"},null,-1),u("rect",{x:"5",y:"5",width:"2",height:"6",rx:"0.5"},null,-1),u("rect",{x:"9",y:"2",width:"2",height:"9",rx:"0.5"},null,-1)])],8,Kd)):s.isDate(o.label)?(p(),_("svg",qd,[...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,I(o.value),1)],2)]))),128))])):D("",!0),n.data.created_at?(p(),_("div",zd,[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,I(s.formattedDate),1)])):D("",!0)])}const Gd=we(Bd,[["render",Wd],["__scopeId","data-v-5f30c914"]]),Yd={form_response:bd,info_card:Ld,ticket:Gd},Jd={name:"WmArtifactRenderer",props:{artifact:{type:Object,required:!0}},computed:{component(){var t;const e=(t=this.artifact)==null?void 0:t.kind;return e&&Yd[e]||null}}};function Xd(e,t,n,r,i,s){return s.component?(p(),be(Ma(s.component),{key:0,data:n.artifact.data},null,8,["data"])):D("",!0)}const Qd=we(Jd,[["render",Xd]]),Zd={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()}}},ef=["href"],tf=["src","alt"],nf=["src"],sf=["src"],rf=["href","download"],of={class:"wm-att__main"},af={class:"wm-att__name"},lf={key:0,class:"wm-att__meta"},cf={key:0,class:"wm-att__spin","aria-hidden":"true"};function uf(e,t,n,r,i,s){return p(),_("div",{class:re(["wm-att",["wm-att--"+(s.kind||"file")]])},[s.kind==="image"&&i.url?(p(),_("a",{key:0,href:s.safeHref,target:"_blank",rel:"noopener",class:"wm-att__imgWrap"},[u("img",{src:i.url,alt:s.displayName,loading:"lazy"},null,8,tf)],8,ef)):s.kind==="audio"&&i.url?(p(),_("audio",{key:1,src:i.url,controls:"",preload:"metadata"},null,8,nf)):s.kind==="video"&&i.url?(p(),_("video",{key:2,src:i.url,controls:"",preload:"metadata"},null,8,sf)):(p(),_("a",{key:3,class:"wm-att__file",href:s.safeHref,download:s.displayName,target:"_blank",rel:"noopener",onClick:t[0]||(t[0]=(...o)=>s.onFileClick&&s.onFileClick(...o))},[t[1]||(t[1]=u("span",{class:"wm-att__icon"},[u("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.7","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[u("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"}),u("path",{d:"M14 2v6h6"})])],-1)),u("span",of,[u("span",af,I(s.displayName),1),s.sizeLabel?(p(),_("span",lf,I(s.sizeLabel),1)):D("",!0)]),i.loading?(p(),_("span",cf)):D("",!0)],8,rf))],2)}const df=we(Zd,[["render",uf],["__scopeId","data-v-0c877a62"]]),ff={name:"WmBubble",props:{role:{type:String,default:"ai"},text:{type:String,default:""}},computed:{rendered(){return wu(this.text)}}},hf=["innerHTML"];function mf(e,t,n,r,i,s){return p(),_("div",{class:re(["wm-bubble","wm-bubble--"+n.role])},[Ea(e.$slots,"default",{},()=>[u("span",{innerHTML:s.rendered},null,8,hf)])],2)}const pf=we(ff,[["render",mf],["__scopeId","data-v-7ab13147"]]),gf={name:"WmTyping"},_f={class:"wm-typing"};function yf(e,t,n,r,i,s){return p(),_("div",_f,[...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 vf=we(gf,[["render",yf],["__scopeId","data-v-df2447fd"]]);function Tt(e){return e?e.client_msg_id||e.id:""}const bf={transferred_to_human:"system.transferredToHuman",assigned:"system.assigned",unassigned:"system.unassigned",resolved:"system.resolved",reopened:"system.reopened",idle:"system.idle"},wf=80,kf=200,Cf={name:"WmMessageList",components:{AIAvatar:wn,HumanAvatar:vo,Bubble:pf,Typing:vf,ActionResult:dd,AttachmentPreview:df,ArtifactRenderer:Qd},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-${Tt(o)}`,role:"ai",agentName:"",agentAvatarUrl:null,messages:[o],items:[]});continue}e.push({key:`sys-${Tt(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-${Tt(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 f of this.itemsOf(l))a.push(f);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=ut(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:Tt,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=Tt(r);if(i&&t.has(i)){n=t.get(i);break}}n==null&&(n=++this._groupIdCounter);for(const r of e){const i=Tt(r);i&&t.set(i,n)}return`g-${n}`},isAtBottom(e){return e.scrollHeight-e.scrollTop-e.clientHeight<=wf},onScroll(){const e=this.$refs.scrollEl;e&&(this.loadingMore||!this.hasMore||this._pendingLoadMore||e.scrollTop<=kf&&(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 f=a.getBoundingClientRect().top-e.getBoundingClientRect().top-o.relY;Math.abs(f)>.5&&(e.scrollTop+=f)};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 U,ne,ge;const n=e.items,r=(U=n[t])==null?void 0:U.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,f=i==null?void 0:i.bottom,c=s==null?void 0:s.top,g=this.widthByKey[this.rowKeyOf(e,t)],A=this.widthByKey[this.rowKeyOf(e,t-1)],S=this.widthByKey[this.rowKeyOf(e,t+1)],H=.5,O=(he,ke,G)=>he!=null&&g!=null?he+H>=g:ke===G||ke==="card"&&G==="bubble";let J=a,z=a,$=a,Q=a;return o?(f&&(z=l),(c||!s)&&($=l),f&&O(A,f,r==null?void 0:r.top)&&(J=l),c&&O(S,c,r==null?void 0:r.bottom)&&(Q=l)):(f&&(J=l),(c||!s)&&(Q=l),f&&O(A,f,r==null?void 0:r.top)&&(z=l),c&&O(S,c,r==null?void 0:r.bottom)&&($=l)),{tl:J,tr:z,br:$,bl:Q}},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?`${Tt(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 go(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=bf[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)}}},Sf={key:0,class:"wm-list__loadMore",role:"status","aria-live":"polite"},Af={class:"wm-list__loadMore-lbl"},xf={key:1,class:"wm-list__historyEnd"},Tf={key:2,class:"wm-list__sep"},Mf={class:"wm-list__sep-label"},Ef={key:0,class:"wm-list__sep wm-list__sep--unread"},Of={class:"wm-list__sep-label wm-list__sep-label--unread"},If={key:0,class:"wm-list__sysep"},Rf={class:"wm-list__sysep-label"},Lf=["data-row-key"],Nf={key:0,class:"wm-list__avatarSlot"},Bf={key:5,class:"wm-list__body"},Pf={key:0},Ff={key:1,"aria-hidden":"true"},Df={key:2},jf={key:3,class:"wm-list__row wm-list__row--ai fade-up"},Uf={class:"wm-list__avatarSlot"};function Hf(e,t,n,r,i,s){const o=_e("AIAvatar"),a=_e("HumanAvatar"),l=_e("ActionResult"),f=_e("ArtifactRenderer"),c=_e("Bubble"),g=_e("AttachmentPreview"),A=_e("Typing");return p(),_("div",{ref:"scrollEl",class:re(["wm-list",{"wm-list--silent":i.silentFades}]),onScrollPassive:t[0]||(t[0]=(...S)=>s.onScroll&&s.onScroll(...S))},[n.loadingMore?(p(),_("div",Sf,[t[1]||(t[1]=u("span",{class:"wm-list__loadMore-spinner","aria-hidden":"true"},null,-1)),u("span",Af,I(s.t("messageList.loadingHistory")),1)])):s.historyExhausted?(p(),_("div",xf,I(s.t("messageList.conversationStart")),1)):D("",!0),n.dateLabel?(p(),_("div",Tf,[t[2]||(t[2]=u("div",{class:"wm-list__line"},null,-1)),u("span",Mf,I(n.dateLabel),1),t[3]||(t[3]=u("div",{class:"wm-list__line"},null,-1))])):D("",!0),(p(!0),_(Z,null,Me(s.groups,(S,H)=>(p(),_(Z,{key:S.key},[S.key===s.unreadGroupKey?(p(),_("div",Ef,[t[4]||(t[4]=u("div",{class:"wm-list__line wm-list__line--unread"},null,-1)),u("span",Of,I(s.t("messageList.unread")),1),t[5]||(t[5]=u("div",{class:"wm-list__line wm-list__line--unread"},null,-1))])):D("",!0),S.role==="system"||S.items.length?(p(),_("div",{key:1,class:re(["wm-list__group","wm-list__group--"+S.role])},[S.role==="system"?(p(),_("div",If,[t[6]||(t[6]=u("div",{class:"wm-list__line wm-list__line--strong"},null,-1)),u("span",Rf,I(S.systemLabel),1),t[7]||(t[7]=u("div",{class:"wm-list__line wm-list__line--strong"},null,-1))])):(p(),_(Z,{key:1},[(p(!0),_(Z,null,Me(S.items,(O,J)=>(p(),_("div",{key:`${s.messageKey(O.message)}-${O.partKey}`,"data-row-key":`${s.messageKey(O.message)}-${O.partKey}`,class:re(["wm-list__row fade-up",["wm-list__row--"+S.role,{"is-pending":O.message._pending,"is-failed":O.message._failed}]]),style:je(s.cornersStyle(S,J))},[S.role!=="user"?(p(),_("div",Nf,[J===S.items.length-1?(p(),_(Z,{key:0},[S.role==="ai"?(p(),be(o,{key:0,size:26,tail:!0,name:n.aiAgentName,"image-url":n.aiAgentAvatarUrl},null,8,["name","image-url"])):(p(),be(a,{key:1,name:S.agentName,"avatar-url":S.agentAvatarUrl,size:26,tail:!0},null,8,["name","avatar-url"]))],64)):D("",!0)])):D("",!0),O.renderAs==="action"?(p(),be(l,{key:1,state:O.message.payload.state,label:s.actionLabel(O.message),detail:s.actionDetail(O.message)},null,8,["state","label","detail"])):O.renderAs==="admin-pending"?(p(),be(l,{key:2,state:"awaiting",label:s.t("messageList.approvalRequestSent"),detail:O.message.text_md||""},null,8,["label","detail"])):O.renderAs==="artifact-of-action"?(p(),be(f,{key:3,artifact:s.actionArtifact(O.message)},null,8,["artifact"])):O.renderAs==="artifact"?(p(),be(f,{key:4,artifact:s.artifactOf(O.message)},null,8,["artifact"])):(p(),_("div",Bf,[O.message.text_md?(p(),be(c,{key:0,role:S.role,text:O.message.text_md},null,8,["role","text"])):D("",!0),s.attachmentsOf(O.message).length?(p(),_("div",{key:1,class:re(["wm-list__atts",{"wm-list__atts--align-end":S.role==="user"}])},[(p(!0),_(Z,null,Me(s.attachmentsOf(O.message),(z,$)=>(p(),be(g,{key:`${s.messageKey(O.message)}-att-${$}`,attachment:z},null,8,["attachment"]))),128))],2)):D("",!0)]))],14,Lf))),128)),(S.role!=="user"||s.lastTimeOf(S))&&!s.hasTrailingOverlay(S)?(p(),_("div",{key:0,class:re(["wm-list__meta",{"wm-list__meta--right":S.role==="user"}])},[S.role!=="user"?(p(),_("span",Pf,I(s.roleLabel(S)),1)):D("",!0),S.role!=="user"&&s.lastTimeOf(S)?(p(),_("span",Ff,"·")):D("",!0),s.lastTimeOf(S)?(p(),_("span",Df,I(s.lastTimeOf(S)),1)):D("",!0)],2)):D("",!0)],64))],2)):D("",!0)],64))),128)),n.streamingActive?(p(),_("div",jf,[u("div",Uf,[ye(o,{size:26,tail:!0,name:n.aiAgentName,"image-url":n.aiAgentAvatarUrl},null,8,["name","image-url"])]),ye(A)])):D("",!0)],34)}const $f=we(Cf,[["render",Hf],["__scopeId","data-v-d769b193"]]),Fn=typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function",Ws=typeof window<"u"&&typeof window.MediaRecorder<"u";function Vf(){return Ws&&["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 wo({audio:e}){return{video:!0,audio:!!e,selfBrowserSurface:"include",surfaceSwitching:"include",systemAudio:e?"include":"exclude"}}async function Kf(){if(!Fn)return null;let e;try{e=await navigator.mediaDevices.getDisplayMedia(wo({audio:!1}))}catch(t){return(t==null?void 0:t.name)!=="NotAllowedError"&&console.error("[media] screenshot picker",t),null}try{return await qf(e)}catch(t){return console.error("[media] screenshot capture",t),null}finally{e.getTracks().forEach(t=>{t.stop()})}}async function qf(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(f=>f?a(f):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 zf(e={}){var f;if(!Fn||!Ws)return null;let t;try{t=await navigator.mediaDevices.getDisplayMedia(wo({audio:!0}))}catch(c){return(c==null?void 0:c.name)!=="NotAllowedError"&&console.error("[media] record picker",c),null}const n=Vf();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(g=>{g.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,g;if(s&&clearInterval(s),t.getTracks().forEach(A=>{A.stop()}),i.length){const A=r.mimeType||n||"video/webm",S=new Blob(i,{type:A}),H=/mp4/.test(A)?"mp4":"webm",O=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),J=new File([S],`ecran-${O}.${H}`,{type:A});(c=e.onfinalize)==null||c.call(e,J)}else(g=e.oncancel)==null||g.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(g=>{g.stop()}),null}(f=e.onstart)==null||f.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 Wf=[{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"}],Gf={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 Wf.map(e=>({...e,label:this.t(e.labelKey),disabled:e.action==="screenshot"&&!Fn||e.action==="record"&&(!Fn||!Ws)}))},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.clientWidth<80||(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 Kf();e&&this.$emit("attach",e)},async startRecording(){if(this.recording||this.disabled)return;this.recordingElapsed=0;const e=await zf({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)}}}},Yf={class:"wm-compose-wrap"},Jf={key:0,class:"wm-rec"},Xf={class:"wm-rec__lbl"},Qf={key:1,class:"wm-compose__menu",role:"menu"},Zf=["disabled","onClick"],eh={class:"wm-compose__menuIcon"},th={viewBox:"0 0 24 24",width:"14",height:"14","aria-hidden":"true"},nh=["d"],sh=["placeholder","disabled"],rh={class:"wm-compose__actions"},ih=["title","aria-label","disabled"],oh=["disabled","aria-label"];function ah(e,t,n,r,i,s){return p(),_("div",Yf,[i.recording?(p(),_("div",Jf,[t[8]||(t[8]=u("span",{class:"wm-rec__dot","aria-hidden":"true"},null,-1)),u("span",Xf,I(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))},I(s.t("composer.stop")),1)])):D("",!0),u("form",{class:re(["wm-compose",{"has-attach":i.attachOpen}]),onSubmit:t[7]||(t[7]=vt((...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?(p(),_("div",{key:0,class:"wm-compose__overlay",onClick:t[2]||(t[2]=o=>i.attachOpen=!1)})):D("",!0),i.attachOpen?(p(),_("div",Qf,[(p(!0),_(Z,null,Me(s.attachItems,o=>(p(),_("button",{key:o.action,type:"button",class:"wm-compose__menuItem",disabled:o.disabled,onClick:a=>s.onAttachAction(o.action)},[u("span",eh,[(p(),_("svg",th,[u("path",{d:o.path,stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round",fill:"none"},null,8,nh)]))]),u("span",null,I(o.label),1)],8,Zf))),128))])):D("",!0),it(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,sh),[[Ot,i.local]]),u("div",rh,[u("button",{type:"button",class:re(["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,ih),u("button",{type:"submit",class:re(["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,oh)])],34)])}const lh=we(Gf,[["render",ah],["__scopeId","data-v-b88b1cbb"]]),ch={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("§")}}},uh=["onClick"];function dh(e,t,n,r,i,s){return n.items.length?(p(),_("div",{key:s.batchKey,class:"wm-chips"},[(p(!0),_(Z,null,Me(n.items,(o,a)=>(p(),_("button",{key:a,type:"button",class:"wm-chip",style:je({animationDelay:n.baseDelay+a*n.stepDelay+"ms"}),onClick:l=>e.$emit("select",o)},I(o.label),13,uh))),128))])):D("",!0)}const fh=we(ch,[["render",dh],["__scopeId","data-v-47ad8085"]]),hh={name:"WmApprovalCard",components:{AIAvatar:wn},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")}}},mh={class:"wm-approval"},ph={class:"wm-approval__head"},gh={class:"wm-approval__icon"},_h={class:"wm-approval__main"},yh={class:"wm-approval__title"},vh={key:0,class:"wm-approval__detail"},bh={class:"wm-approval__actions"};function wh(e,t,n,r,i,s){const o=_e("AIAvatar");return p(),_("div",mh,[u("div",ph,[u("div",gh,[ye(o,{size:24,name:n.agentName,"image-url":n.agentAvatarUrl},null,8,["name","image-url"])]),u("div",_h,[u("div",yh,I(n.action),1),n.detail?(p(),_("div",vh,I(n.detail),1)):D("",!0)])]),u("div",bh,[s.rejectId?(p(),_("button",{key:0,type:"button",class:"wm-approval__btn wm-approval__btn--neutral",onClick:t[0]||(t[0]=a=>e.$emit("callback",s.rejectId))},I(s.rejectLabel),1)):D("",!0),s.approveId?(p(),_("button",{key:1,type:"button",class:"wm-approval__btn wm-approval__btn--primary",onClick:t[1]||(t[1]=a=>e.$emit("callback",s.approveId))},I(s.approveLabel),1)):D("",!0)])])}const kh=we(hh,[["render",wh],["__scopeId","data-v-a2bed37e"]]);let Kr=0;const Ch=new Set(["text","textarea","number","boolean","select","multiselect","date"]),Sh={name:"WmFormCard",components:{AIAvatar:wn},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 Kr+=1,{_uid:Kr,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)||!Ch.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}}}},Ah={class:"wm-form"},xh={class:"wm-form__head"},Th={class:"wm-form__icon"},Mh={class:"wm-form__main"},Eh={class:"wm-form__title"},Oh={key:0,class:"wm-form__detail"},Ih=["for"],Rh={key:0,class:"wm-form__req","aria-hidden":"true"},Lh=["id","onUpdate:modelValue","placeholder","required","disabled"],Nh=["id","onUpdate:modelValue","placeholder","required","disabled"],Bh=["id","onUpdate:modelValue","placeholder","required","disabled"],Ph=["id","onUpdate:modelValue","required","disabled"],Fh={key:4,class:"wm-form__bool"},Dh=["id","onUpdate:modelValue","disabled"],jh=["id","onUpdate:modelValue","required","disabled"],Uh={value:"",disabled:""},Hh=["value"],$h={key:6,class:"wm-form__multi"},Vh=["value","checked","disabled","onChange"],Kh={key:0,class:"wm-form__err"},qh=["disabled"],zh={key:0,class:"wm-form__spinner","aria-hidden":"true"},Wh={key:2,class:"wm-form__doneLbl"};function Gh(e,t,n,r,i,s){const o=_e("AIAvatar");return p(),_("div",Ah,[u("div",xh,[u("div",Th,[ye(o,{size:24,name:n.agentName,"image-url":n.agentAvatarUrl},null,8,["name","image-url"])]),u("div",Mh,[u("div",Eh,I(n.form.title||s.t("form.title")),1),n.form.description?(p(),_("div",Oh,I(n.form.description),1)):D("",!0)])]),u("form",{class:"wm-form__body",onSubmit:t[0]||(t[0]=vt((...a)=>s.onSubmit&&s.onSubmit(...a),["prevent"]))},[(p(!0),_(Z,null,Me(s.normalizedFields,a=>(p(),_("div",{key:a.key,class:"wm-form__field"},[u("label",{for:`wm-f-${i._uid}-${a.key}`,class:"wm-form__label"},[Xn(I(a.label),1),a.required?(p(),_("span",Rh,"*")):D("",!0)],8,Ih),a.type==="text"?it((p(),_("input",{key:0,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,type:"text",class:"wm-form__input",placeholder:a.placeholder||"",required:a.required,disabled:n.readOnly||i.busy},null,8,Lh)),[[Ot,i.values[a.key]]]):a.type==="textarea"?it((p(),_("textarea",{key:1,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,class:"wm-form__textarea",rows:"3",placeholder:a.placeholder||"",required:a.required,disabled:n.readOnly||i.busy},null,8,Nh)),[[Ot,i.values[a.key]]]):a.type==="number"?it((p(),_("input",{key:2,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,type:"number",class:"wm-form__input",placeholder:a.placeholder||"",required:a.required,disabled:n.readOnly||i.busy},null,8,Bh)),[[Ot,i.values[a.key],void 0,{number:!0}]]):a.type==="date"?it((p(),_("input",{key:3,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,type:"date",class:"wm-form__input",required:a.required,disabled:n.readOnly||i.busy},null,8,Ph)),[[Ot,i.values[a.key]]]):a.type==="boolean"?(p(),_("label",Fh,[it(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,Dh),[[ql,i.values[a.key]]]),u("span",null,I(a.placeholder||s.t("common.yes")),1)])):a.type==="select"?it((p(),_("select",{key:5,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,class:"wm-form__select",required:a.required,disabled:n.readOnly||i.busy},[u("option",Uh,I(a.placeholder||s.t("form.choose")),1),(p(!0),_(Z,null,Me(a.options,l=>(p(),_("option",{key:l.value,value:l.value},I(l.label),9,Hh))),128))],8,jh)),[[zl,i.values[a.key]]]):a.type==="multiselect"?(p(),_("div",$h,[(p(!0),_(Z,null,Me(a.options,l=>(p(),_("label",{key:l.value,class:"wm-form__multiItem"},[u("input",{type:"checkbox",value:l.value,checked:Array.isArray(i.values[a.key])&&i.values[a.key].includes(l.value),disabled:n.readOnly||i.busy,onChange:f=>s.toggleMulti(a.key,l.value,f.target.checked)},null,40,Vh),u("span",null,I(l.label),1)]))),128))])):D("",!0)]))),128)),i.error?(p(),_("div",Kh,I(i.error),1)):D("",!0),n.readOnly?(p(),_("div",Wh,I(s.t("form.responseSent")),1)):(p(),_("button",{key:1,type:"submit",class:"wm-form__submit",disabled:i.busy},[i.busy?(p(),_("span",zh)):D("",!0),u("span",null,I(i.busy?s.t("common.sending"):n.form.submit_label||s.t("common.send")),1)],8,qh))],32)])}const Yh=we(Sh,[["render",Gh],["__scopeId","data-v-fe65cc56"]]),Jh={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})}}},Xh={class:"wm-fb"},Qh={class:"wm-fb__title"},Zh={class:"wm-fb__sub"},em={class:"wm-fb__row"},tm=["onClick"],nm={class:"wm-fb__emoji"},sm={class:"wm-fb__label"},rm=["disabled"],im={key:1,class:"wm-fb__done"},om={class:"wm-fb__doneTitle"},am={class:"wm-fb__doneSub"};function lm(e,t,n,r,i,s){return p(),_("div",Xh,[n.done?(p(),_("div",im,[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",om,I(s.t("feedback.doneTitle")),1),u("div",am,I(s.t("feedback.doneSubtitle")),1)])):(p(),_(Z,{key:0},[u("div",Qh,I(s.t("feedback.question")),1),u("div",Zh,I(s.t("feedback.subtitle")),1),u("div",em,[(p(!0),_(Z,null,Me(s.options,o=>(p(),_("button",{key:o.v,type:"button",class:re(["wm-fb__opt",{"is-selected":i.sel===o.v}]),onClick:a=>i.sel=o.v},[u("span",nm,I(o.e),1),u("span",sm,I(o.l),1)],10,tm))),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))},I(n.busy?s.t("common.sending"):s.t("feedback.submit")),9,rm)],64))])}const cm=we(Jh,[["render",lm],["__scopeId","data-v-9b630564"]]),um={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)}}},dm={class:"wm-mm"},fm={class:"wm-mm__pop",role:"menu"},hm={key:0,class:"wm-mm__section"},mm={class:"wm-mm__label"},pm={class:"wm-mm__label"},gm={key:1,class:"wm-mm__sep"},_m={class:"wm-mm__section"},ym={class:"wm-mm__label"},vm={class:"wm-mm__label"},bm={class:"wm-mm__section"},wm={class:"wm-mm__label"},km={class:"wm-mm__label"};function Cm(e,t,n,r,i,s){return p(),_("div",dm,[u("div",{class:"wm-mm__scrim",onClick:t[0]||(t[0]=o=>e.$emit("close"))}),u("div",fm,[n.canRename||n.canExport?(p(),_("div",hm,[n.canRename?(p(),_("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",mm,I(s.t("moreMenu.editTitle")),1)])):D("",!0),n.canExport?(p(),_("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",pm,I(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?(p(),_("div",gm)):D("",!0),u("div",_m,[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",ym,I(s.t("moreMenu.sound")),1),u("span",{class:re(["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",vm,I(s.t("moreMenu.browserNotifications")),1),u("span",{class:re(["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",bm,[n.statusUrl?(p(),_("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",wm,I(s.t("moreMenu.serviceStatus")),1)])):D("",!0),n.helpUrl?(p(),_("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",km,I(s.t("moreMenu.helpCenter")),1)])):D("",!0)])])])}const Sm=we(um,[["render",Cm],["__scopeId","data-v-76281e95"]]),Am={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())}}},xm={class:"wm-dialog"},Tm={class:"wm-dialog__card",role:"dialog","aria-modal":"true"},Mm={class:"wm-dialog__head"},Em={class:"wm-dialog__title"},Om=["aria-label"],Im={class:"wm-dialog__body"},Rm=["placeholder"],Lm={class:"wm-dialog__actions"},Nm=["disabled"];function Bm(e,t,n,r,i,s){return p(),_("div",xm,[u("div",{class:"wm-dialog__scrim",onClick:t[0]||(t[0]=o=>e.$emit("close"))}),u("div",Tm,[u("div",Mm,[u("div",Em,I(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,Om)]),u("div",Im,[it(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]=Pn(vt((...o)=>s.onSubmit&&s.onSubmit(...o),["prevent"]),["enter"])),t[4]||(t[4]=Pn(vt(o=>e.$emit("close"),["prevent"]),["esc"]))]},null,40,Rm),[[Ot,i.value]])]),u("div",Lm,[u("button",{type:"button",class:"wm-dialog__btn",onClick:t[5]||(t[5]=o=>e.$emit("close"))},I(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))},I(s.t("common.save")),9,Nm)])])])}const Pm=we(Am,[["render",Bm],["__scopeId","data-v-6d5f94a8"]]),qr="ww-messenger-tokens",Fm={name:"Messenger",components:{Launcher:Wc,Header:yu,Onboarding:Zu,MessageList:$f,Composer:lh,SuggestionChips:fh,ApprovalCard:kh,FormCard:Yh,Feedback:cm,MoreMenu:Sm,RenameDialog:Pm},mixins:[yc,Sc,Ac,Tc],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:uc},widgetId:{type:String,default:""},context:{type:Object,default:null},displayMode:{type:String,default:"floating"},devtools:{type:Boolean,default:!1},language:{type:String,default:""}},data(){return{transport:null,store:null,isOpen:!1,launcherHovered:!1,draft:"",busy:!1,bootError:null,pendingAttachments:[],feedbackBusy:!1,feedbackDone:!1,convOpenedAt:0,moreOpen:!1,renameDialogOpen:!1,draftConv:null,activeConvId:null,showOnboarding:!1,dismissedPeeks:{},floatHeight:0,floatRO:null,parentOrigin:"",parentToken:"",parentContext:null,parentAllowUnauthenticated:!1,parentInitReceived:!1,parentInitDeferred:null}},computed:{isEditor(){return!!this.devtools},isEmbedded(){return this.displayMode==="embedded"},customerLanguage(){var 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 zs(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 f;const i=e[r.id]||[],s=ut(r.last_read_message_id);let o=0,a=null;for(let c=i.length-1;c>=0;c--){const g=i[c];if(!g)continue;if(((f=g.author)==null?void 0:f.type)==="user")break;const A=ut(g.id);if(A!=null){if(s!=null&&A<=s)break;t[g.id]!==0&&(!a&&g.author&&(a=g.author),o++)}}if(!i.length){const c=ut(r.last_message_id);c!=null&&(s==null||c>s)&&(o=1,a=r.last_message_author||null)}const l=i.filter(c=>!((c==null?void 0:c.id)!=null&&t[c.id]===0));return{...r,_preview: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:Hr(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=Hr(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,f;return(i==null?void 0:i.type)==="action"&&((s=i==null?void 0:i.payload)==null?void 0:s.state)==="pending"||gn(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||(f=i==null?void 0:i.metadata)!=null&&f.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=>gn(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(([f,c])=>`${f}: ${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:go(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=ut((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=ut((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(qr)){const e=document.createElement("style");e.id=qr,e.textContent=_o,document.head.appendChild(e)}this._parentMessageHandler=this.onParentMessage.bind(this),window.addEventListener("message",this._parentMessageHandler),window.parent&&window.parent!==window&&window.parent.postMessage({type:"READY"},"*"),this.isEmbedded?(await this.boot(),this.store&&await this.open()):(await this.$nextTick(),this.sendCurrentLauncherSize(),this.observeLauncherSize())},beforeUnmount(){this._parentMessageHandler&&(window.removeEventListener("message",this._parentMessageHandler),this._parentMessageHandler=null),this._launcherRo&&(this._launcherRo.disconnect(),this._launcherRo=null),this.cancelReveals(),this.teardownLiveReveal(),this.disconnectFloatRO(),this.resetApprovalPacing(),this.teardownNotifications(),this.store&&this.store.destroy()},methods:{t(e,t){return this.translator(e,t)},waitForParentInit(){if(this.parentInitReceived)return Promise.resolve();if(!this.parentInitDeferred){let e;this.parentInitDeferred=new Promise(t=>{e=t}),this.parentInitDeferred._resolve=e}return this.parentInitDeferred},onParentMessage(e){var n;const t=e==null?void 0:e.data;!t||typeof t!="object"||t.type!=="INIT"||(this.parentOrigin=e.origin,this.parentToken=typeof t.token=="string"?t.token:"",this.parentContext=t.context&&typeof t.context=="object"?t.context:null,this.parentAllowUnauthenticated=t.allowUnauthenticated===!0,this.parentInitReceived=!0,(n=this.parentInitDeferred)!=null&&n._resolve&&this.parentInitDeferred._resolve(),!this.isEmbedded&&!this.isOpen&&!this.parentAllowUnauthenticated&&this.hasValidSessionMarker()&&this.boot().catch(r=>{console.warn("[messenger] eager boot failed",r)}))},hasValidSessionMarker(){if(typeof document>"u")return!1;const t=(document.cookie||"").match(/(?:^|; )messenger_session_marker=([^;]+)/);if(!t)return!1;const n=parseInt(t[1],10);return Number.isFinite(n)?n>Date.now():!1},async boot(){var e,t;if(!this.canBoot){console.warn("[messenger] boot skipped — missing creds");return}try{await this.waitForParentInit(),this.transport=ks(ic({baseUrl:this.baseUrl,widgetId:this.widgetId})),this.store=ks(cc(this.transport)),this.hydrateNotifPref();const n=((e=this.parentContext)==null?void 0:e.customer)||((t=this.context)==null?void 0:t.customer);n&&typeof n=="object"&&await this.store.applyCustomer(n),await this.store.start({origin:this.parentOrigin,token:this.parentToken||void 0,allowUnauthenticated:this.parentAllowUnauthenticated}),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(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.notifyParentResize("open"),this._launcherRo&&this._launcherRo.disconnect(),this.store||await this.boot(),this.store&&this.store.setPanelOpen(!0);const e=this.currentConv;if(e&&!e._draft){this.activeConvId==null&&(this.activeConvId=e.id);try{await this.store.openConversation(e.id)}catch(t){console.error("[ww-messenger] load messages failed",t)}this.markConvRead(e)}},async close(){this.isOpen=!1,await this.$nextTick(),this.sendCurrentLauncherSize(),this.observeLauncherSize(),this.store&&this.store.setPanelOpen(!1)},notifyParentResize(e,t){if(window.parent&&window.parent!==window)try{window.parent.postMessage({type:"RESIZE",state:e,displayMode:this.displayMode,...t||{}},"*")}catch(n){console.warn("[ww-messenger] notifyParentResize failed",n)}},onLauncherHover(e){this.launcherHovered=e,this.sendCurrentLauncherSize()},sendCurrentLauncherSize(){var g,A,S,H,O,J,z;if(this.isOpen)return;const e=(A=(g=this.$el)==null?void 0:g.querySelector)==null?void 0:A.call(g,".wm-launcherWrap");if(!e)return;const t=e.getBoundingClientRect();if(!t.width||!t.height)return;const n=(((S=this.launcherPeeks)==null?void 0:S.length)??0)>0,r=this.launcherHovered?28:16,i=Math.ceil(t.width),s=Math.ceil(t.height),o=(O=(H=this.$el)==null?void 0:H.querySelector)==null?void 0:O.call(H,".wm-launcher"),a=o==null?void 0:o.getBoundingClientRect(),l=(z=(J=this.$el)==null?void 0:J.querySelectorAll)==null?void 0:z.call(J,".wm-peek"),f=l&&l.length?l[l.length-1]:null;let c=null;if(f){const $=f.getBoundingClientRect();c={width:Math.ceil($.width),height:Math.ceil($.height),rightOffset:Math.max(0,Math.ceil(t.right-$.right)),bottomOffset:Math.max(0,Math.ceil(t.bottom-$.bottom))}}this.notifyParentResize("closed",{width:i+r,height:s+r,launcherWidth:a?Math.ceil(a.width):null,launcherHeight:a?Math.ceil(a.height):null,launcherHovered:this.launcherHovered,peek:c,peekHovered:this.launcherHovered&&n})},observeLauncherSize(){var n,r;if(typeof ResizeObserver>"u")return;const e=(r=(n=this.$el)==null?void 0:n.querySelector)==null?void 0:r.call(n,".wm-launcherWrap");if(!e)return;this._launcherRo&&this._launcherRo.disconnect();const t=new ResizeObserver(()=>{this.isOpen||this.sendCurrentLauncherSize()});t.observe(e),this._launcherRo=t},async openFromPeek(e){var n,r;const t=e||((n=this.latestUnreads[0])==null?void 0:n.convId);t&&t!==((r=this.currentConv)==null?void 0:r.id)&&(this.draftConv=null,this.activeConvId=t,this.showOnboarding=!1),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":_c(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=fc(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:hc(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}}}}},Dm={key:0,class:"wm-loading","aria-busy":"true","aria-live":"polite"},jm=["aria-label"],Um={key:0,class:"wm-state"},Hm={class:"wm-state__err"},$m={class:"wm-state__errTitle"},Vm={class:"wm-state__errSub"},Km={class:"wm-bottom"},qm={key:0,ref:"floatEl",class:"wm-float"},zm={key:1,class:"wm-actionWait",role:"status","aria-live":"polite"},Wm={class:"wm-actionWait__lbl"},Gm={key:2,class:"wm-attached"},Ym=["aria-label","onClick"];function Jm(e,t,n,r,i,s){const o=_e("Launcher"),a=_e("Header"),l=_e("Onboarding"),f=_e("MessageList"),c=_e("ApprovalCard"),g=_e("FormCard"),A=_e("Feedback"),S=_e("SuggestionChips"),H=_e("Composer"),O=_e("MoreMenu"),J=_e("RenameDialog");return p(),_("div",{class:re(["wm-root",`wm-root--${n.displayMode}`])},[!i.isOpen&&!s.isEmbedded?(p(),be(o,{key:0,"unread-count":s.unreadCount,peeks:s.launcherPeeks,onOpen:s.openFromPeek,onDismiss:s.dismissPeek,onHover:s.onLauncherHover},null,8,["unread-count","peeks","onOpen","onDismiss","onHover"])):D("",!0),i.isOpen||s.isEmbedded?(p(),_("section",{key:1,class:re(["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?(p(),_("div",Dm,[s.isEmbedded?D("",!0):(p(),_("button",{key:0,type:"button",class:"wm-loading__close","aria-label":s.t("loading.minimize"),onClick:t[0]||(t[0]=(...z)=>s.close&&s.close(...z))},[...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,jm)),t[6]||(t[6]=u("div",{class:"wm-loading__spinner","aria-hidden":"true"},null,-1))])):(p(),_(Z,{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?(p(),_("div",Um,[u("div",Hm,[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",$m,I(s.t("error.connectionFailed")),1),u("div",Vm,I(s.error),1)])])])):s.currentConv?(p(),_(Z,{key:2},[ye(f,{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",Km,[s.floatVisible?(p(),_("div",qm,[s.approvalReady?(p(),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?(p(),be(g,{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?(p(),be(A,{key:2,busy:i.feedbackBusy,done:i.feedbackDone,onSubmit:s.onFeedback},null,8,["busy","done","onSubmit"])):(p(),be(S,{key:3,items:s.suggestions,onSelect:s.onSuggestion},null,8,["items","onSelect"]))],512)):D("",!0),s.actionInFlight?(p(),_("div",zm,[t[8]||(t[8]=u("span",{class:"wm-actionWait__spinner","aria-hidden":"true"},null,-1)),u("span",Wm,I(s.t("action.inProgress",{name:s.actionInFlightName})),1)])):(p(),be(H,{key:2,ref:"composer",modelValue:i.draft,"onUpdate:modelValue":t[1]||(t[1]=z=>i.draft=z),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?(p(),be(O,{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]=z=>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?(p(),be(J,{key:1,"initial-value":s.currentConv.name||"",title:s.t("rename.dialogTitle"),onClose:t[3]||(t[3]=z=>i.renameDialogOpen=!1),onSubmit:s.onRenameSubmit},null,8,["initial-value","title","onSubmit"])):D("",!0),i.pendingAttachments.length?(p(),_("div",Gm,[(p(!0),_(Z,null,Me(i.pendingAttachments,(z,$)=>(p(),_("div",{key:$,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,I(z.name),1),u("button",{type:"button","aria-label":s.t("attachment.remove"),onClick:Q=>i.pendingAttachments.splice($,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,Ym)]))),128))])):D("",!0)],64)):(p(),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?(p(),be(O,{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]=z=>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 Xm=we(Fm,[["render",Jm],["__scopeId","data-v-608c117b"]]),zr=window.__WIDGET_ID,Wr=window.__BASE_URL,Qm=window.__DISPLAY_MODE||"floating",Gr=window.__LANGUAGE||"";window.__MESSENGER_IFRAME_VERSION="0.5.24";if(!zr||!Wr)console.error("[messenger-iframe] missing __WIDGET_ID or __BASE_URL globals");else{if(!document.getElementById("wm-tokens")){const e=document.createElement("style");e.id="wm-tokens",e.textContent=_o,document.head.appendChild(e)}Ql({render:()=>fo(Xm,{baseUrl:Wr,widgetId:zr,displayMode:Qm,...Gr?{language:Gr}:{}})}).mount("#app")}
|
|
73
|
+
`)}return i}const Vr={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"},ku={name:"WmOnboarding",components:{AIAvatar:wn},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 Vr[e]||Vr.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"})}}},Cu={class:"wm-onb"},Su={class:"wm-onb__hero"},Au={class:"wm-onb__hero-text"},xu={class:"wm-onb__title"},Tu={class:"wm-onb__sub"},Mu={class:"wm-onb__cta"},Eu=["disabled"],Ou={key:0,class:"wm-onb__section"},Iu={class:"wm-onb__section-title"},Ru=["onClick"],Lu={class:"wm-onb__card-icon"},Nu={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"},Bu=["d"],Pu={class:"wm-onb__card-body"},Fu={class:"wm-onb__card-title"},Du={key:0,class:"wm-onb__card-sub"},ju={key:1,class:"wm-onb__section"},Uu={class:"wm-onb__section-title"},Hu={class:"wm-onb__search"},$u=["placeholder","aria-label"],Vu={class:"wm-onb__list"},Ku=["onClick"],qu=["aria-label"],zu={class:"wm-onb__thread-body"},Wu={class:"wm-onb__thread-title"},Gu=["innerHTML"],Yu={class:"wm-onb__thread-meta"},Ju={key:0,class:"wm-onb__thread-time"},Xu={key:0,class:"wm-onb__empty"};function Qu(e,t,n,r,i,s){const o=_e("AIAvatar");return p(),_("div",Cu,[u("div",Su,[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",Au,[u("div",xu,I(s.heroTitle),1),u("div",Tu,I(s.heroSub),1)])]),u("div",Mu,[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,I(n.busy?"…":s.t("onboarding.start")),1)],8,Eu)]),n.quickLinks.length?(p(),_("div",Ou,[u("div",Iu,I(s.t("onboarding.quickAccess")),1),u("div",{class:re(s.quickLinksLayout)},[(p(!0),_(Z,null,Me(n.quickLinks,(a,l)=>(p(),_("button",{key:l,type:"button",class:re(["wm-onb__card",{"wm-onb__card--row":s.isOddQuickLinks}]),onClick:f=>e.$emit("select",a)},[u("span",Lu,[(p(),_("svg",Nu,[u("path",{d:s.iconPath(a.icon)},null,8,Bu)]))]),u("span",Pu,[u("span",Fu,I(a.label),1),a.description?(p(),_("span",Du,I(a.description),1)):D("",!0)])],10,Ru))),128))],2)])):D("",!0),n.openThreads.length?(p(),_("div",ju,[u("div",Uu,I(s.t("onboarding.recentConversations")),1),u("div",Hu,[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)),it(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,$u),[[Ot,i.query]])]),u("div",Vu,[(p(!0),_(Z,null,Me(s.filteredThreads,a=>(p(),_("button",{key:a.id,type:"button",class:"wm-onb__thread",onClick:l=>e.$emit("resume",a)},[u("span",{class:re(["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?(p(),_("span",{key:0,class:"wm-onb__thread-dot","aria-label":s.t("onboarding.unread")},null,8,qu)):D("",!0)],2),u("span",zu,[u("span",Wu,I(a.title),1),u("span",{class:"wm-onb__thread-preview",innerHTML:s.renderPreview(a.preview)},null,8,Gu)]),u("span",Yu,[s.formatTs(a._ts)?(p(),_("span",Ju,I(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,Ku))),128)),s.filteredThreads.length?D("",!0):(p(),_("div",Xu,I(s.t("onboarding.noResults",{query:i.query})),1))])])):D("",!0)])}const Zu=we(ku,[["render",Qu],["__scopeId","data-v-28c0780b"]]);function ed(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 td={name:"WmActionResult",props:{state:{type:String,default:"success"},label:{type:String,required:!0},detail:{type:String,default:""}},computed:{detailText(){return ed(this.detail)}}},nd={class:"wm-result__icon","aria-hidden":"true"},sd={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"},rd={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"},id={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"},od={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"},ad={class:"wm-result__body"},ld={class:"wm-result__label"},cd={class:"wm-result__detail"};function ud(e,t,n,r,i,s){return p(),_("div",{class:re(["wm-result",`wm-result--${n.state}`])},[u("span",nd,[n.state==="success"?(p(),_("svg",sd,[...t[0]||(t[0]=[u("path",{d:"M20 6L9 17l-5-5"},null,-1)])])):n.state==="rejected"?(p(),_("svg",rd,[...t[1]||(t[1]=[u("path",{d:"M18 6L6 18M6 6l12 12"},null,-1)])])):n.state==="awaiting"?(p(),_("svg",id,[...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)])])):(p(),_("svg",od,[...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",ad,[u("span",ld,I(n.label),1),s.detailText?(p(),_(Z,{key:0},[t[4]||(t[4]=u("span",{class:"wm-result__sep","aria-hidden":"true"}," · ",-1)),u("span",cd,I(s.detailText),1)],64)):D("",!0)])],2)}const dd=we(td,[["render",ud],["__scopeId","data-v-7284acd0"]]),fd={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:[]}}},hd={class:"wm-art wm-art--formResponse"},md={class:"wm-art__head"},pd={class:"wm-art__title"},gd={class:"wm-art__badge wm-art__badge--success"},_d={class:"wm-art__body"},yd={class:"wm-art__fieldLabel"};function vd(e,t,n,r,i,s){return p(),_("div",hd,[u("div",md,[u("div",pd,I(n.data.title||s.t("form.title")),1),u("span",gd,[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)),Xn(" "+I(s.t("form.sent")),1)])]),u("div",_d,[(p(!0),_(Z,null,Me(s.fields,(o,a)=>(p(),_("div",{key:a,class:"wm-art__field"},[u("div",yd,I(o.label),1),u("div",{class:re(["wm-art__fieldValue",{"wm-art__fieldValue--multi":o.multiline}])},I(o.value),3)]))),128))])])}const bd=we(fd,[["render",vd],["__scopeId","data-v-713aecf1"]]),wd={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}}},kd={class:"wm-art wm-art--infoCard"},Cd={key:0,class:"wm-art__image"},Sd=["src","alt"],Ad={class:"wm-art__head"},xd={class:"wm-art__headMain"},Td={class:"wm-art__title"},Md={key:0,class:"wm-art__subtitle"},Ed={key:1,class:"wm-art__body"},Od={key:0,class:"wm-art__text"},Id={class:"wm-art__fieldLabel"};function Rd(e,t,n,r,i,s){return p(),_("div",kd,[n.data.image_url?(p(),_("figure",Cd,[u("img",{src:n.data.image_url,alt:n.data.title||"",loading:"lazy"},null,8,Sd)])):D("",!0),u("div",Ad,[u("div",xd,[u("div",Td,I(n.data.title),1),n.data.subtitle?(p(),_("div",Md,I(n.data.subtitle),1)):D("",!0)]),n.data.badge&&n.data.badge.label?(p(),_("span",{key:0,class:re(["wm-art__badge",`wm-art__badge--${n.data.badge.tone||"neutral"}`])},I(n.data.badge.label),3)):D("",!0)]),s.hasBody?(p(),_("div",Ed,[n.data.body?(p(),_("div",Od,I(n.data.body),1)):D("",!0),s.fields.length?(p(!0),_(Z,{key:1},Me(s.fields,(o,a)=>(p(),_("div",{key:a,class:"wm-art__field"},[u("div",Id,I(o.label),1),u("div",{class:re(["wm-art__fieldValue",{"wm-art__fieldValue--multi":o.multiline}])},I(o.value),3)]))),128)):D("",!0)])):D("",!0)])}const Ld=we(wd,[["render",Rd],["__scopeId","data-v-7eae0e4a"]]);function Nd(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 Bd={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 Nd((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}}},Pd={class:"wm-art wm-art--ticket"},Fd={class:"wm-art__head wm-tk__head"},Dd={class:"wm-art__title wm-tk__title"},jd={class:"wm-tk__sub"},Ud={class:"wm-tk__ref"},Hd={key:0,class:"wm-tk__text"},$d={key:0,class:"wm-art__body"},Vd={class:"wm-art__fieldLabel"},Kd=["data-level"],qd={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"},zd={key:1,class:"wm-art__footer wm-tk__footer"};function Wd(e,t,n,r,i,s){return p(),_("div",Pd,[u("div",Fd,[u("div",Dd,I(n.data.title),1),u("div",jd,[u("div",Ud,[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,I(n.data.reference),1)]),u("span",{class:re(["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)),Xn(" "+I(n.data.status.label),1)],2)]),n.data.body?(p(),_("div",Hd,I(n.data.body),1)):D("",!0)]),s.fields.length?(p(),_("div",$d,[(p(!0),_(Z,null,Me(s.fields,(o,a)=>(p(),_("div",{key:a,class:"wm-art__field"},[u("div",Vd,I(o.label),1),u("div",{class:re(["wm-art__fieldValue",{"wm-art__fieldValue--multi":o.multiline}])},[s.isPriority(o.label)?(p(),_("svg",{key:0,class:"wm-tk__prio","data-level":s.priorityLevel(o.value),width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true"},[...t[2]||(t[2]=[u("rect",{x:"1",y:"8",width:"2",height:"3",rx:"0.5"},null,-1),u("rect",{x:"5",y:"5",width:"2",height:"6",rx:"0.5"},null,-1),u("rect",{x:"9",y:"2",width:"2",height:"9",rx:"0.5"},null,-1)])],8,Kd)):s.isDate(o.label)?(p(),_("svg",qd,[...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,I(o.value),1)],2)]))),128))])):D("",!0),n.data.created_at?(p(),_("div",zd,[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,I(s.formattedDate),1)])):D("",!0)])}const Gd=we(Bd,[["render",Wd],["__scopeId","data-v-5f30c914"]]),Yd={form_response:bd,info_card:Ld,ticket:Gd},Jd={name:"WmArtifactRenderer",props:{artifact:{type:Object,required:!0}},computed:{component(){var t;const e=(t=this.artifact)==null?void 0:t.kind;return e&&Yd[e]||null}}};function Xd(e,t,n,r,i,s){return s.component?(p(),be(Ma(s.component),{key:0,data:n.artifact.data},null,8,["data"])):D("",!0)}const Qd=we(Jd,[["render",Xd]]),Zd={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()}}},ef=["href"],tf=["src","alt"],nf=["src"],sf=["src"],rf=["href","download"],of={class:"wm-att__main"},af={class:"wm-att__name"},lf={key:0,class:"wm-att__meta"},cf={key:0,class:"wm-att__spin","aria-hidden":"true"};function uf(e,t,n,r,i,s){return p(),_("div",{class:re(["wm-att",["wm-att--"+(s.kind||"file")]])},[s.kind==="image"&&i.url?(p(),_("a",{key:0,href:s.safeHref,target:"_blank",rel:"noopener",class:"wm-att__imgWrap"},[u("img",{src:i.url,alt:s.displayName,loading:"lazy"},null,8,tf)],8,ef)):s.kind==="audio"&&i.url?(p(),_("audio",{key:1,src:i.url,controls:"",preload:"metadata"},null,8,nf)):s.kind==="video"&&i.url?(p(),_("video",{key:2,src:i.url,controls:"",preload:"metadata"},null,8,sf)):(p(),_("a",{key:3,class:"wm-att__file",href:s.safeHref,download:s.displayName,target:"_blank",rel:"noopener",onClick:t[0]||(t[0]=(...o)=>s.onFileClick&&s.onFileClick(...o))},[t[1]||(t[1]=u("span",{class:"wm-att__icon"},[u("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.7","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[u("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"}),u("path",{d:"M14 2v6h6"})])],-1)),u("span",of,[u("span",af,I(s.displayName),1),s.sizeLabel?(p(),_("span",lf,I(s.sizeLabel),1)):D("",!0)]),i.loading?(p(),_("span",cf)):D("",!0)],8,rf))],2)}const df=we(Zd,[["render",uf],["__scopeId","data-v-0c877a62"]]),ff={name:"WmBubble",props:{role:{type:String,default:"ai"},text:{type:String,default:""}},computed:{rendered(){return wu(this.text)}}},hf=["innerHTML"];function mf(e,t,n,r,i,s){return p(),_("div",{class:re(["wm-bubble","wm-bubble--"+n.role])},[Ea(e.$slots,"default",{},()=>[u("span",{innerHTML:s.rendered},null,8,hf)])],2)}const pf=we(ff,[["render",mf],["__scopeId","data-v-7ab13147"]]),gf={name:"WmTyping"},_f={class:"wm-typing"};function yf(e,t,n,r,i,s){return p(),_("div",_f,[...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 vf=we(gf,[["render",yf],["__scopeId","data-v-df2447fd"]]);function Tt(e){return e?e.client_msg_id||e.id:""}const bf={transferred_to_human:"system.transferredToHuman",assigned:"system.assigned",unassigned:"system.unassigned",resolved:"system.resolved",reopened:"system.reopened",idle:"system.idle"},wf=80,kf=200,Cf={name:"WmMessageList",components:{AIAvatar:wn,HumanAvatar:vo,Bubble:pf,Typing:vf,ActionResult:dd,AttachmentPreview:df,ArtifactRenderer:Qd},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-${Tt(o)}`,role:"ai",agentName:"",agentAvatarUrl:null,messages:[o],items:[]});continue}e.push({key:`sys-${Tt(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-${Tt(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 f of this.itemsOf(l))a.push(f);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=ut(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:Tt,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=Tt(r);if(i&&t.has(i)){n=t.get(i);break}}n==null&&(n=++this._groupIdCounter);for(const r of e){const i=Tt(r);i&&t.set(i,n)}return`g-${n}`},isAtBottom(e){return e.scrollHeight-e.scrollTop-e.clientHeight<=wf},onScroll(){const e=this.$refs.scrollEl;e&&(this.loadingMore||!this.hasMore||this._pendingLoadMore||e.scrollTop<=kf&&(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 f=a.getBoundingClientRect().top-e.getBoundingClientRect().top-o.relY;Math.abs(f)>.5&&(e.scrollTop+=f)};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 U,ne,ge;const n=e.items,r=(U=n[t])==null?void 0:U.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,f=i==null?void 0:i.bottom,c=s==null?void 0:s.top,g=this.widthByKey[this.rowKeyOf(e,t)],A=this.widthByKey[this.rowKeyOf(e,t-1)],S=this.widthByKey[this.rowKeyOf(e,t+1)],H=.5,O=(he,ke,G)=>he!=null&&g!=null?he+H>=g:ke===G||ke==="card"&&G==="bubble";let J=a,z=a,$=a,Q=a;return o?(f&&(z=l),(c||!s)&&($=l),f&&O(A,f,r==null?void 0:r.top)&&(J=l),c&&O(S,c,r==null?void 0:r.bottom)&&(Q=l)):(f&&(J=l),(c||!s)&&(Q=l),f&&O(A,f,r==null?void 0:r.top)&&(z=l),c&&O(S,c,r==null?void 0:r.bottom)&&($=l)),{tl:J,tr:z,br:$,bl:Q}},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?`${Tt(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 go(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=bf[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)}}},Sf={key:0,class:"wm-list__loadMore",role:"status","aria-live":"polite"},Af={class:"wm-list__loadMore-lbl"},xf={key:1,class:"wm-list__historyEnd"},Tf={key:2,class:"wm-list__sep"},Mf={class:"wm-list__sep-label"},Ef={key:0,class:"wm-list__sep wm-list__sep--unread"},Of={class:"wm-list__sep-label wm-list__sep-label--unread"},If={key:0,class:"wm-list__sysep"},Rf={class:"wm-list__sysep-label"},Lf=["data-row-key"],Nf={key:0,class:"wm-list__avatarSlot"},Bf={key:5,class:"wm-list__body"},Pf={key:0},Ff={key:1,"aria-hidden":"true"},Df={key:2},jf={key:3,class:"wm-list__row wm-list__row--ai fade-up"},Uf={class:"wm-list__avatarSlot"};function Hf(e,t,n,r,i,s){const o=_e("AIAvatar"),a=_e("HumanAvatar"),l=_e("ActionResult"),f=_e("ArtifactRenderer"),c=_e("Bubble"),g=_e("AttachmentPreview"),A=_e("Typing");return p(),_("div",{ref:"scrollEl",class:re(["wm-list",{"wm-list--silent":i.silentFades}]),onScrollPassive:t[0]||(t[0]=(...S)=>s.onScroll&&s.onScroll(...S))},[n.loadingMore?(p(),_("div",Sf,[t[1]||(t[1]=u("span",{class:"wm-list__loadMore-spinner","aria-hidden":"true"},null,-1)),u("span",Af,I(s.t("messageList.loadingHistory")),1)])):s.historyExhausted?(p(),_("div",xf,I(s.t("messageList.conversationStart")),1)):D("",!0),n.dateLabel?(p(),_("div",Tf,[t[2]||(t[2]=u("div",{class:"wm-list__line"},null,-1)),u("span",Mf,I(n.dateLabel),1),t[3]||(t[3]=u("div",{class:"wm-list__line"},null,-1))])):D("",!0),(p(!0),_(Z,null,Me(s.groups,(S,H)=>(p(),_(Z,{key:S.key},[S.key===s.unreadGroupKey?(p(),_("div",Ef,[t[4]||(t[4]=u("div",{class:"wm-list__line wm-list__line--unread"},null,-1)),u("span",Of,I(s.t("messageList.unread")),1),t[5]||(t[5]=u("div",{class:"wm-list__line wm-list__line--unread"},null,-1))])):D("",!0),S.role==="system"||S.items.length?(p(),_("div",{key:1,class:re(["wm-list__group","wm-list__group--"+S.role])},[S.role==="system"?(p(),_("div",If,[t[6]||(t[6]=u("div",{class:"wm-list__line wm-list__line--strong"},null,-1)),u("span",Rf,I(S.systemLabel),1),t[7]||(t[7]=u("div",{class:"wm-list__line wm-list__line--strong"},null,-1))])):(p(),_(Z,{key:1},[(p(!0),_(Z,null,Me(S.items,(O,J)=>(p(),_("div",{key:`${s.messageKey(O.message)}-${O.partKey}`,"data-row-key":`${s.messageKey(O.message)}-${O.partKey}`,class:re(["wm-list__row fade-up",["wm-list__row--"+S.role,{"is-pending":O.message._pending,"is-failed":O.message._failed}]]),style:je(s.cornersStyle(S,J))},[S.role!=="user"?(p(),_("div",Nf,[J===S.items.length-1?(p(),_(Z,{key:0},[S.role==="ai"?(p(),be(o,{key:0,size:26,tail:!0,name:n.aiAgentName,"image-url":n.aiAgentAvatarUrl},null,8,["name","image-url"])):(p(),be(a,{key:1,name:S.agentName,"avatar-url":S.agentAvatarUrl,size:26,tail:!0},null,8,["name","avatar-url"]))],64)):D("",!0)])):D("",!0),O.renderAs==="action"?(p(),be(l,{key:1,state:O.message.payload.state,label:s.actionLabel(O.message),detail:s.actionDetail(O.message)},null,8,["state","label","detail"])):O.renderAs==="admin-pending"?(p(),be(l,{key:2,state:"awaiting",label:s.t("messageList.approvalRequestSent"),detail:O.message.text_md||""},null,8,["label","detail"])):O.renderAs==="artifact-of-action"?(p(),be(f,{key:3,artifact:s.actionArtifact(O.message)},null,8,["artifact"])):O.renderAs==="artifact"?(p(),be(f,{key:4,artifact:s.artifactOf(O.message)},null,8,["artifact"])):(p(),_("div",Bf,[O.message.text_md?(p(),be(c,{key:0,role:S.role,text:O.message.text_md},null,8,["role","text"])):D("",!0),s.attachmentsOf(O.message).length?(p(),_("div",{key:1,class:re(["wm-list__atts",{"wm-list__atts--align-end":S.role==="user"}])},[(p(!0),_(Z,null,Me(s.attachmentsOf(O.message),(z,$)=>(p(),be(g,{key:`${s.messageKey(O.message)}-att-${$}`,attachment:z},null,8,["attachment"]))),128))],2)):D("",!0)]))],14,Lf))),128)),(S.role!=="user"||s.lastTimeOf(S))&&!s.hasTrailingOverlay(S)?(p(),_("div",{key:0,class:re(["wm-list__meta",{"wm-list__meta--right":S.role==="user"}])},[S.role!=="user"?(p(),_("span",Pf,I(s.roleLabel(S)),1)):D("",!0),S.role!=="user"&&s.lastTimeOf(S)?(p(),_("span",Ff,"·")):D("",!0),s.lastTimeOf(S)?(p(),_("span",Df,I(s.lastTimeOf(S)),1)):D("",!0)],2)):D("",!0)],64))],2)):D("",!0)],64))),128)),n.streamingActive?(p(),_("div",jf,[u("div",Uf,[ye(o,{size:26,tail:!0,name:n.aiAgentName,"image-url":n.aiAgentAvatarUrl},null,8,["name","image-url"])]),ye(A)])):D("",!0)],34)}const $f=we(Cf,[["render",Hf],["__scopeId","data-v-d769b193"]]),Fn=typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function",Ws=typeof window<"u"&&typeof window.MediaRecorder<"u";function Vf(){return Ws&&["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 wo({audio:e}){return{video:!0,audio:!!e,selfBrowserSurface:"include",surfaceSwitching:"include",systemAudio:e?"include":"exclude"}}async function Kf(){if(!Fn)return null;let e;try{e=await navigator.mediaDevices.getDisplayMedia(wo({audio:!1}))}catch(t){return(t==null?void 0:t.name)!=="NotAllowedError"&&console.error("[media] screenshot picker",t),null}try{return await qf(e)}catch(t){return console.error("[media] screenshot capture",t),null}finally{e.getTracks().forEach(t=>{t.stop()})}}async function qf(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(f=>f?a(f):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 zf(e={}){var f;if(!Fn||!Ws)return null;let t;try{t=await navigator.mediaDevices.getDisplayMedia(wo({audio:!0}))}catch(c){return(c==null?void 0:c.name)!=="NotAllowedError"&&console.error("[media] record picker",c),null}const n=Vf();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(g=>{g.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,g;if(s&&clearInterval(s),t.getTracks().forEach(A=>{A.stop()}),i.length){const A=r.mimeType||n||"video/webm",S=new Blob(i,{type:A}),H=/mp4/.test(A)?"mp4":"webm",O=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),J=new File([S],`ecran-${O}.${H}`,{type:A});(c=e.onfinalize)==null||c.call(e,J)}else(g=e.oncancel)==null||g.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(g=>{g.stop()}),null}(f=e.onstart)==null||f.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 Wf=[{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"}],Gf={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 Wf.map(e=>({...e,label:this.t(e.labelKey),disabled:e.action==="screenshot"&&!Fn||e.action==="record"&&(!Fn||!Ws)}))},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.clientWidth<80||(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 Kf();e&&this.$emit("attach",e)},async startRecording(){if(this.recording||this.disabled)return;this.recordingElapsed=0;const e=await zf({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)}}}},Yf={class:"wm-compose-wrap"},Jf={key:0,class:"wm-rec"},Xf={class:"wm-rec__lbl"},Qf={key:1,class:"wm-compose__menu",role:"menu"},Zf=["disabled","onClick"],eh={class:"wm-compose__menuIcon"},th={viewBox:"0 0 24 24",width:"14",height:"14","aria-hidden":"true"},nh=["d"],sh=["placeholder","disabled"],rh={class:"wm-compose__actions"},ih=["title","aria-label","disabled"],oh=["disabled","aria-label"];function ah(e,t,n,r,i,s){return p(),_("div",Yf,[i.recording?(p(),_("div",Jf,[t[8]||(t[8]=u("span",{class:"wm-rec__dot","aria-hidden":"true"},null,-1)),u("span",Xf,I(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))},I(s.t("composer.stop")),1)])):D("",!0),u("form",{class:re(["wm-compose",{"has-attach":i.attachOpen}]),onSubmit:t[7]||(t[7]=vt((...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?(p(),_("div",{key:0,class:"wm-compose__overlay",onClick:t[2]||(t[2]=o=>i.attachOpen=!1)})):D("",!0),i.attachOpen?(p(),_("div",Qf,[(p(!0),_(Z,null,Me(s.attachItems,o=>(p(),_("button",{key:o.action,type:"button",class:"wm-compose__menuItem",disabled:o.disabled,onClick:a=>s.onAttachAction(o.action)},[u("span",eh,[(p(),_("svg",th,[u("path",{d:o.path,stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round",fill:"none"},null,8,nh)]))]),u("span",null,I(o.label),1)],8,Zf))),128))])):D("",!0),it(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,sh),[[Ot,i.local]]),u("div",rh,[u("button",{type:"button",class:re(["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,ih),u("button",{type:"submit",class:re(["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,oh)])],34)])}const lh=we(Gf,[["render",ah],["__scopeId","data-v-b88b1cbb"]]),ch={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("§")}}},uh=["onClick"];function dh(e,t,n,r,i,s){return n.items.length?(p(),_("div",{key:s.batchKey,class:"wm-chips"},[(p(!0),_(Z,null,Me(n.items,(o,a)=>(p(),_("button",{key:a,type:"button",class:"wm-chip",style:je({animationDelay:n.baseDelay+a*n.stepDelay+"ms"}),onClick:l=>e.$emit("select",o)},I(o.label),13,uh))),128))])):D("",!0)}const fh=we(ch,[["render",dh],["__scopeId","data-v-47ad8085"]]),hh={name:"WmApprovalCard",components:{AIAvatar:wn},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")}}},mh={class:"wm-approval"},ph={class:"wm-approval__head"},gh={class:"wm-approval__icon"},_h={class:"wm-approval__main"},yh={class:"wm-approval__title"},vh={key:0,class:"wm-approval__detail"},bh={class:"wm-approval__actions"};function wh(e,t,n,r,i,s){const o=_e("AIAvatar");return p(),_("div",mh,[u("div",ph,[u("div",gh,[ye(o,{size:24,name:n.agentName,"image-url":n.agentAvatarUrl},null,8,["name","image-url"])]),u("div",_h,[u("div",yh,I(n.action),1),n.detail?(p(),_("div",vh,I(n.detail),1)):D("",!0)])]),u("div",bh,[s.rejectId?(p(),_("button",{key:0,type:"button",class:"wm-approval__btn wm-approval__btn--neutral",onClick:t[0]||(t[0]=a=>e.$emit("callback",s.rejectId))},I(s.rejectLabel),1)):D("",!0),s.approveId?(p(),_("button",{key:1,type:"button",class:"wm-approval__btn wm-approval__btn--primary",onClick:t[1]||(t[1]=a=>e.$emit("callback",s.approveId))},I(s.approveLabel),1)):D("",!0)])])}const kh=we(hh,[["render",wh],["__scopeId","data-v-a2bed37e"]]);let Kr=0;const Ch=new Set(["text","textarea","number","boolean","select","multiselect","date"]),Sh={name:"WmFormCard",components:{AIAvatar:wn},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 Kr+=1,{_uid:Kr,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)||!Ch.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}}}},Ah={class:"wm-form"},xh={class:"wm-form__head"},Th={class:"wm-form__icon"},Mh={class:"wm-form__main"},Eh={class:"wm-form__title"},Oh={key:0,class:"wm-form__detail"},Ih=["for"],Rh={key:0,class:"wm-form__req","aria-hidden":"true"},Lh=["id","onUpdate:modelValue","placeholder","required","disabled"],Nh=["id","onUpdate:modelValue","placeholder","required","disabled"],Bh=["id","onUpdate:modelValue","placeholder","required","disabled"],Ph=["id","onUpdate:modelValue","required","disabled"],Fh={key:4,class:"wm-form__bool"},Dh=["id","onUpdate:modelValue","disabled"],jh=["id","onUpdate:modelValue","required","disabled"],Uh={value:"",disabled:""},Hh=["value"],$h={key:6,class:"wm-form__multi"},Vh=["value","checked","disabled","onChange"],Kh={key:0,class:"wm-form__err"},qh=["disabled"],zh={key:0,class:"wm-form__spinner","aria-hidden":"true"},Wh={key:2,class:"wm-form__doneLbl"};function Gh(e,t,n,r,i,s){const o=_e("AIAvatar");return p(),_("div",Ah,[u("div",xh,[u("div",Th,[ye(o,{size:24,name:n.agentName,"image-url":n.agentAvatarUrl},null,8,["name","image-url"])]),u("div",Mh,[u("div",Eh,I(n.form.title||s.t("form.title")),1),n.form.description?(p(),_("div",Oh,I(n.form.description),1)):D("",!0)])]),u("form",{class:"wm-form__body",onSubmit:t[0]||(t[0]=vt((...a)=>s.onSubmit&&s.onSubmit(...a),["prevent"]))},[(p(!0),_(Z,null,Me(s.normalizedFields,a=>(p(),_("div",{key:a.key,class:"wm-form__field"},[u("label",{for:`wm-f-${i._uid}-${a.key}`,class:"wm-form__label"},[Xn(I(a.label),1),a.required?(p(),_("span",Rh,"*")):D("",!0)],8,Ih),a.type==="text"?it((p(),_("input",{key:0,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,type:"text",class:"wm-form__input",placeholder:a.placeholder||"",required:a.required,disabled:n.readOnly||i.busy},null,8,Lh)),[[Ot,i.values[a.key]]]):a.type==="textarea"?it((p(),_("textarea",{key:1,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,class:"wm-form__textarea",rows:"3",placeholder:a.placeholder||"",required:a.required,disabled:n.readOnly||i.busy},null,8,Nh)),[[Ot,i.values[a.key]]]):a.type==="number"?it((p(),_("input",{key:2,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,type:"number",class:"wm-form__input",placeholder:a.placeholder||"",required:a.required,disabled:n.readOnly||i.busy},null,8,Bh)),[[Ot,i.values[a.key],void 0,{number:!0}]]):a.type==="date"?it((p(),_("input",{key:3,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,type:"date",class:"wm-form__input",required:a.required,disabled:n.readOnly||i.busy},null,8,Ph)),[[Ot,i.values[a.key]]]):a.type==="boolean"?(p(),_("label",Fh,[it(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,Dh),[[ql,i.values[a.key]]]),u("span",null,I(a.placeholder||s.t("common.yes")),1)])):a.type==="select"?it((p(),_("select",{key:5,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,class:"wm-form__select",required:a.required,disabled:n.readOnly||i.busy},[u("option",Uh,I(a.placeholder||s.t("form.choose")),1),(p(!0),_(Z,null,Me(a.options,l=>(p(),_("option",{key:l.value,value:l.value},I(l.label),9,Hh))),128))],8,jh)),[[zl,i.values[a.key]]]):a.type==="multiselect"?(p(),_("div",$h,[(p(!0),_(Z,null,Me(a.options,l=>(p(),_("label",{key:l.value,class:"wm-form__multiItem"},[u("input",{type:"checkbox",value:l.value,checked:Array.isArray(i.values[a.key])&&i.values[a.key].includes(l.value),disabled:n.readOnly||i.busy,onChange:f=>s.toggleMulti(a.key,l.value,f.target.checked)},null,40,Vh),u("span",null,I(l.label),1)]))),128))])):D("",!0)]))),128)),i.error?(p(),_("div",Kh,I(i.error),1)):D("",!0),n.readOnly?(p(),_("div",Wh,I(s.t("form.responseSent")),1)):(p(),_("button",{key:1,type:"submit",class:"wm-form__submit",disabled:i.busy},[i.busy?(p(),_("span",zh)):D("",!0),u("span",null,I(i.busy?s.t("common.sending"):n.form.submit_label||s.t("common.send")),1)],8,qh))],32)])}const Yh=we(Sh,[["render",Gh],["__scopeId","data-v-fe65cc56"]]),Jh={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})}}},Xh={class:"wm-fb"},Qh={class:"wm-fb__title"},Zh={class:"wm-fb__sub"},em={class:"wm-fb__row"},tm=["onClick"],nm={class:"wm-fb__emoji"},sm={class:"wm-fb__label"},rm=["disabled"],im={key:1,class:"wm-fb__done"},om={class:"wm-fb__doneTitle"},am={class:"wm-fb__doneSub"};function lm(e,t,n,r,i,s){return p(),_("div",Xh,[n.done?(p(),_("div",im,[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",om,I(s.t("feedback.doneTitle")),1),u("div",am,I(s.t("feedback.doneSubtitle")),1)])):(p(),_(Z,{key:0},[u("div",Qh,I(s.t("feedback.question")),1),u("div",Zh,I(s.t("feedback.subtitle")),1),u("div",em,[(p(!0),_(Z,null,Me(s.options,o=>(p(),_("button",{key:o.v,type:"button",class:re(["wm-fb__opt",{"is-selected":i.sel===o.v}]),onClick:a=>i.sel=o.v},[u("span",nm,I(o.e),1),u("span",sm,I(o.l),1)],10,tm))),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))},I(n.busy?s.t("common.sending"):s.t("feedback.submit")),9,rm)],64))])}const cm=we(Jh,[["render",lm],["__scopeId","data-v-9b630564"]]),um={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)}}},dm={class:"wm-mm"},fm={class:"wm-mm__pop",role:"menu"},hm={key:0,class:"wm-mm__section"},mm={class:"wm-mm__label"},pm={class:"wm-mm__label"},gm={key:1,class:"wm-mm__sep"},_m={class:"wm-mm__section"},ym={class:"wm-mm__label"},vm={class:"wm-mm__label"},bm={class:"wm-mm__section"},wm={class:"wm-mm__label"},km={class:"wm-mm__label"};function Cm(e,t,n,r,i,s){return p(),_("div",dm,[u("div",{class:"wm-mm__scrim",onClick:t[0]||(t[0]=o=>e.$emit("close"))}),u("div",fm,[n.canRename||n.canExport?(p(),_("div",hm,[n.canRename?(p(),_("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",mm,I(s.t("moreMenu.editTitle")),1)])):D("",!0),n.canExport?(p(),_("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",pm,I(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?(p(),_("div",gm)):D("",!0),u("div",_m,[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",ym,I(s.t("moreMenu.sound")),1),u("span",{class:re(["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",vm,I(s.t("moreMenu.browserNotifications")),1),u("span",{class:re(["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",bm,[n.statusUrl?(p(),_("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",wm,I(s.t("moreMenu.serviceStatus")),1)])):D("",!0),n.helpUrl?(p(),_("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",km,I(s.t("moreMenu.helpCenter")),1)])):D("",!0)])])])}const Sm=we(um,[["render",Cm],["__scopeId","data-v-76281e95"]]),Am={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())}}},xm={class:"wm-dialog"},Tm={class:"wm-dialog__card",role:"dialog","aria-modal":"true"},Mm={class:"wm-dialog__head"},Em={class:"wm-dialog__title"},Om=["aria-label"],Im={class:"wm-dialog__body"},Rm=["placeholder"],Lm={class:"wm-dialog__actions"},Nm=["disabled"];function Bm(e,t,n,r,i,s){return p(),_("div",xm,[u("div",{class:"wm-dialog__scrim",onClick:t[0]||(t[0]=o=>e.$emit("close"))}),u("div",Tm,[u("div",Mm,[u("div",Em,I(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,Om)]),u("div",Im,[it(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]=Pn(vt((...o)=>s.onSubmit&&s.onSubmit(...o),["prevent"]),["enter"])),t[4]||(t[4]=Pn(vt(o=>e.$emit("close"),["prevent"]),["esc"]))]},null,40,Rm),[[Ot,i.value]])]),u("div",Lm,[u("button",{type:"button",class:"wm-dialog__btn",onClick:t[5]||(t[5]=o=>e.$emit("close"))},I(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))},I(s.t("common.save")),9,Nm)])])])}const Pm=we(Am,[["render",Bm],["__scopeId","data-v-6d5f94a8"]]),qr="ww-messenger-tokens",Fm={name:"Messenger",components:{Launcher:Wc,Header:yu,Onboarding:Zu,MessageList:$f,Composer:lh,SuggestionChips:fh,ApprovalCard:kh,FormCard:Yh,Feedback:cm,MoreMenu:Sm,RenameDialog:Pm},mixins:[yc,Sc,Ac,Tc],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:uc},widgetId:{type:String,default:""},context:{type:Object,default:null},displayMode:{type:String,default:"floating"},devtools:{type:Boolean,default:!1},language:{type:String,default:""}},data(){return{transport:null,store:null,isOpen:!1,launcherHovered:!1,draft:"",busy:!1,bootError:null,pendingAttachments:[],feedbackBusy:!1,feedbackDone:!1,convOpenedAt:0,moreOpen:!1,renameDialogOpen:!1,draftConv:null,activeConvId:null,showOnboarding:!1,dismissedPeeks:{},floatHeight:0,floatRO:null,parentOrigin:"",parentToken:"",parentContext:null,parentAllowUnauthenticated:!1,parentInitReceived:!1,parentInitDeferred:null}},computed:{isEditor(){return!!this.devtools},isEmbedded(){return this.displayMode==="embedded"},customerLanguage(){var 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 zs(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 f;const i=e[r.id]||[],s=ut(r.last_read_message_id);let o=0,a=null;for(let c=i.length-1;c>=0;c--){const g=i[c];if(!g)continue;if(((f=g.author)==null?void 0:f.type)==="user")break;const A=ut(g.id);if(A!=null){if(s!=null&&A<=s)break;t[g.id]!==0&&(!a&&g.author&&(a=g.author),o++)}}if(!i.length){const c=ut(r.last_message_id);c!=null&&(s==null||c>s)&&(o=1,a=r.last_message_author||null)}const l=i.filter(c=>!((c==null?void 0:c.id)!=null&&t[c.id]===0));return{...r,_preview: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:Hr(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=Hr(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,f;return(i==null?void 0:i.type)==="action"&&((s=i==null?void 0:i.payload)==null?void 0:s.state)==="pending"||gn(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||(f=i==null?void 0:i.metadata)!=null&&f.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=>gn(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(([f,c])=>`${f}: ${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:go(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=ut((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=ut((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(qr)){const e=document.createElement("style");e.id=qr,e.textContent=_o,document.head.appendChild(e)}this._parentMessageHandler=this.onParentMessage.bind(this),window.addEventListener("message",this._parentMessageHandler),window.parent&&window.parent!==window&&window.parent.postMessage({type:"READY"},"*"),this.isEmbedded?(await this.boot(),this.store&&await this.open()):(await this.$nextTick(),this.sendCurrentLauncherSize(),this.observeLauncherSize())},beforeUnmount(){this._parentMessageHandler&&(window.removeEventListener("message",this._parentMessageHandler),this._parentMessageHandler=null),this._launcherRo&&(this._launcherRo.disconnect(),this._launcherRo=null),this.cancelReveals(),this.teardownLiveReveal(),this.disconnectFloatRO(),this.resetApprovalPacing(),this.teardownNotifications(),this.store&&this.store.destroy()},methods:{t(e,t){return this.translator(e,t)},waitForParentInit(){if(this.parentInitReceived)return Promise.resolve();if(!this.parentInitDeferred){let e;this.parentInitDeferred=new Promise(t=>{e=t}),this.parentInitDeferred._resolve=e}return this.parentInitDeferred},onParentMessage(e){var n;const t=e==null?void 0:e.data;!t||typeof t!="object"||t.type!=="INIT"||(this.parentOrigin=e.origin,this.parentToken=typeof t.token=="string"?t.token:"",this.parentContext=t.context&&typeof t.context=="object"?t.context:null,this.parentAllowUnauthenticated=t.allowUnauthenticated===!0,this.parentInitReceived=!0,(n=this.parentInitDeferred)!=null&&n._resolve&&this.parentInitDeferred._resolve(),!this.isEmbedded&&!this.isOpen&&!this.parentAllowUnauthenticated&&this.hasValidSessionMarker()&&this.boot().catch(r=>{console.warn("[messenger] eager boot failed",r)}))},hasValidSessionMarker(){if(typeof document>"u")return!1;const t=(document.cookie||"").match(/(?:^|; )messenger_session_marker=([^;]+)/);if(!t)return!1;const n=parseInt(t[1],10);return Number.isFinite(n)?n>Date.now():!1},async boot(){var e,t;if(!this.canBoot){console.warn("[messenger] boot skipped — missing creds");return}try{await this.waitForParentInit(),this.transport=ks(ic({baseUrl:this.baseUrl,widgetId:this.widgetId})),this.store=ks(cc(this.transport)),this.hydrateNotifPref();const n=((e=this.parentContext)==null?void 0:e.customer)||((t=this.context)==null?void 0:t.customer);n&&typeof n=="object"&&await this.store.applyCustomer(n),await this.store.start({origin:this.parentOrigin,token:this.parentToken||void 0,allowUnauthenticated:this.parentAllowUnauthenticated}),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(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.notifyParentResize("open"),this._launcherRo&&this._launcherRo.disconnect(),this.store||await this.boot(),this.store&&this.store.setPanelOpen(!0);const e=this.currentConv;if(e&&!e._draft){this.activeConvId==null&&(this.activeConvId=e.id);try{await this.store.openConversation(e.id)}catch(t){console.error("[ww-messenger] load messages failed",t)}this.markConvRead(e)}},async close(){this.isOpen=!1,await this.$nextTick(),this.sendCurrentLauncherSize(),this.observeLauncherSize(),this.store&&this.store.setPanelOpen(!1)},notifyParentResize(e,t){if(window.parent&&window.parent!==window)try{window.parent.postMessage({type:"RESIZE",state:e,displayMode:this.displayMode,...t||{}},"*")}catch(n){console.warn("[ww-messenger] notifyParentResize failed",n)}},onLauncherHover(e){this.launcherHovered=e,this.sendCurrentLauncherSize()},sendCurrentLauncherSize(){var g,A,S,H,O,J,z;if(this.isOpen)return;const e=(A=(g=this.$el)==null?void 0:g.querySelector)==null?void 0:A.call(g,".wm-launcherWrap");if(!e)return;const t=e.getBoundingClientRect();if(!t.width||!t.height)return;const n=(((S=this.launcherPeeks)==null?void 0:S.length)??0)>0,r=this.launcherHovered?28:16,i=Math.ceil(t.width),s=Math.ceil(t.height),o=(O=(H=this.$el)==null?void 0:H.querySelector)==null?void 0:O.call(H,".wm-launcher"),a=o==null?void 0:o.getBoundingClientRect(),l=(z=(J=this.$el)==null?void 0:J.querySelectorAll)==null?void 0:z.call(J,".wm-peek"),f=l&&l.length?l[l.length-1]:null;let c=null;if(f){const $=f.getBoundingClientRect();c={width:Math.ceil($.width),height:Math.ceil($.height),rightOffset:Math.max(0,Math.ceil(t.right-$.right)),bottomOffset:Math.max(0,Math.ceil(t.bottom-$.bottom))}}this.notifyParentResize("closed",{width:i+r,height:s+r,launcherWidth:a?Math.ceil(a.width):null,launcherHeight:a?Math.ceil(a.height):null,launcherHovered:this.launcherHovered,peek:c,peekHovered:this.launcherHovered&&n})},observeLauncherSize(){var n,r;if(typeof ResizeObserver>"u")return;const e=(r=(n=this.$el)==null?void 0:n.querySelector)==null?void 0:r.call(n,".wm-launcherWrap");if(!e)return;this._launcherRo&&this._launcherRo.disconnect();const t=new ResizeObserver(()=>{this.isOpen||this.sendCurrentLauncherSize()});t.observe(e),this._launcherRo=t},async openFromPeek(e){var n,r;const t=e||((n=this.latestUnreads[0])==null?void 0:n.convId);t&&t!==((r=this.currentConv)==null?void 0:r.id)&&(this.draftConv=null,this.activeConvId=t,this.showOnboarding=!1),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":_c(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=fc(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:hc(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}}}}},Dm={key:0,class:"wm-loading","aria-busy":"true","aria-live":"polite"},jm=["aria-label"],Um={key:0,class:"wm-state"},Hm={class:"wm-state__err"},$m={class:"wm-state__errTitle"},Vm={class:"wm-state__errSub"},Km={class:"wm-bottom"},qm={key:0,ref:"floatEl",class:"wm-float"},zm={key:1,class:"wm-actionWait",role:"status","aria-live":"polite"},Wm={class:"wm-actionWait__lbl"},Gm={key:2,class:"wm-attached"},Ym=["aria-label","onClick"];function Jm(e,t,n,r,i,s){const o=_e("Launcher"),a=_e("Header"),l=_e("Onboarding"),f=_e("MessageList"),c=_e("ApprovalCard"),g=_e("FormCard"),A=_e("Feedback"),S=_e("SuggestionChips"),H=_e("Composer"),O=_e("MoreMenu"),J=_e("RenameDialog");return p(),_("div",{class:re(["wm-root",`wm-root--${n.displayMode}`])},[!i.isOpen&&!s.isEmbedded?(p(),be(o,{key:0,"unread-count":s.unreadCount,peeks:s.launcherPeeks,onOpen:s.openFromPeek,onDismiss:s.dismissPeek,onHover:s.onLauncherHover},null,8,["unread-count","peeks","onOpen","onDismiss","onHover"])):D("",!0),i.isOpen||s.isEmbedded?(p(),_("section",{key:1,class:re(["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?(p(),_("div",Dm,[s.isEmbedded?D("",!0):(p(),_("button",{key:0,type:"button",class:"wm-loading__close","aria-label":s.t("loading.minimize"),onClick:t[0]||(t[0]=(...z)=>s.close&&s.close(...z))},[...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,jm)),t[6]||(t[6]=u("div",{class:"wm-loading__spinner","aria-hidden":"true"},null,-1))])):(p(),_(Z,{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?(p(),_("div",Um,[u("div",Hm,[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",$m,I(s.t("error.connectionFailed")),1),u("div",Vm,I(s.error),1)])])])):s.currentConv?(p(),_(Z,{key:2},[ye(f,{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",Km,[s.floatVisible?(p(),_("div",qm,[s.approvalReady?(p(),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?(p(),be(g,{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?(p(),be(A,{key:2,busy:i.feedbackBusy,done:i.feedbackDone,onSubmit:s.onFeedback},null,8,["busy","done","onSubmit"])):(p(),be(S,{key:3,items:s.suggestions,onSelect:s.onSuggestion},null,8,["items","onSelect"]))],512)):D("",!0),s.actionInFlight?(p(),_("div",zm,[t[8]||(t[8]=u("span",{class:"wm-actionWait__spinner","aria-hidden":"true"},null,-1)),u("span",Wm,I(s.t("action.inProgress",{name:s.actionInFlightName})),1)])):(p(),be(H,{key:2,ref:"composer",modelValue:i.draft,"onUpdate:modelValue":t[1]||(t[1]=z=>i.draft=z),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?(p(),be(O,{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]=z=>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?(p(),be(J,{key:1,"initial-value":s.currentConv.name||"",title:s.t("rename.dialogTitle"),onClose:t[3]||(t[3]=z=>i.renameDialogOpen=!1),onSubmit:s.onRenameSubmit},null,8,["initial-value","title","onSubmit"])):D("",!0),i.pendingAttachments.length?(p(),_("div",Gm,[(p(!0),_(Z,null,Me(i.pendingAttachments,(z,$)=>(p(),_("div",{key:$,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,I(z.name),1),u("button",{type:"button","aria-label":s.t("attachment.remove"),onClick:Q=>i.pendingAttachments.splice($,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,Ym)]))),128))])):D("",!0)],64)):(p(),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?(p(),be(O,{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]=z=>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 Xm=we(Fm,[["render",Jm],["__scopeId","data-v-608c117b"]]),zr=window.__WIDGET_ID,Wr=window.__BASE_URL,Qm=window.__DISPLAY_MODE||"floating",Gr=window.__LANGUAGE||"";window.__MESSENGER_IFRAME_VERSION="0.5.25";if(!zr||!Wr)console.error("[messenger-iframe] missing __WIDGET_ID or __BASE_URL globals");else{if(!document.getElementById("wm-tokens")){const e=document.createElement("style");e.id="wm-tokens",e.textContent=_o,document.head.appendChild(e)}Ql({render:()=>fo(Xm,{baseUrl:Wr,widgetId:zr,displayMode:Qm,...Gr?{language:Gr}:{}})}).mount("#app")}
|