@useago/sdk 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/widget.cjs CHANGED
@@ -1,5 +1,5 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ae=require("./AgoClient-CzSmJQxl.cjs"),dt=require("./createFormCollector-BB3Uscuo.cjs"),Gt=require("./createConversationSession-DV0Xp_3O.cjs");var jt='"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',Se=`var(--ago-font, ${jt})`,ct={font:"--ago-font",radius:"--ago-radius",messageRadius:"--ago-message-radius",brand:"--ago-brand-color",brandText:"--ago-brand-text-color",headerBg:"--ago-header-background",headerText:"--ago-header-text-color",panelBg:"--ago-panel-background",messagesBg:"--ago-messages-background",text:"--ago-text-color",mutedText:"--ago-muted-text-color",border:"--ago-border-color",accent:"--ago-accent-color",agentBubbleBg:"--ago-agent-bubble-background"},ke="var(--ago-brand-color, #03182f)",Ae="var(--ago-brand-text-color, #fff)",Vt="var(--ago-header-background, var(--ago-brand-color, #03182f))",pt="var(--ago-header-text-color, #e8f0fe)",ee="var(--ago-panel-background, #fff)",ht="var(--ago-messages-background, #fbfbfb)",J="var(--ago-text-color, #30373e)",xt="var(--ago-muted-text-color, #6b6d6f)",L="var(--ago-border-color, #dee3e8)",Be="var(--ago-accent-color, #1b5fc4)",ft="var(--ago-agent-bubble-background, #f1f3f5)",qt="var(--ago-radius, 16px)",De="var(--ago-message-radius, 16px)",Kt="var(--ago-message-radius, 20px)";function Xt(n,o){if(o)for(const i of Object.keys(ct)){const r=o[i];r!=null&&n.style.setProperty(ct[i],r)}}function v(n,o){Object.assign(n.style,o)}function h(n={}){const o=document.createElement("div");return v(o,n),o}var ut="ago-chat-widget-keyframes";function Qt(){if(typeof document>"u"||document.getElementById(ut))return;const n=document.createElement("style");n.id=ut,n.textContent="@keyframes ago-pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }@keyframes ago-spin { to { transform: rotate(360deg); } }",document.head.appendChild(n)}function Yt(n){let o=[];const i=document.createElement("form");v(i,{display:"flex",flexDirection:"column",gap:"8px",padding:"12px",borderTop:`1px solid ${L}`,backgroundColor:ee}),i.className="ago-chat-input";const r=h({display:"flex",flexWrap:"wrap",gap:"6px"}),b=h({display:"flex",gap:"8px",alignItems:"flex-end"}),a=document.createElement("textarea");a.placeholder=n.placeholder,a.setAttribute("aria-label",n.placeholder),a.rows=1,v(a,{flex:"1",resize:"none",boxSizing:"border-box",padding:"10px 12px",border:`1px solid ${L}`,borderRadius:"12px",fontSize:"16px",fontFamily:Se,lineHeight:"1.4",maxHeight:"110px",overflowY:"hidden"});const C=()=>{a.style.height="auto";const c=Math.min(a.scrollHeight+2,110);a.style.height=`${c}px`,a.style.overflowY=a.scrollHeight+2>110?"auto":"hidden"};a.addEventListener("input",()=>{C(),A()});const m='<svg width="18" height="18" viewBox="0 -960 960 960" fill="currentColor" aria-hidden="true"><path d="M440-160v-487L216-423l-56-57 320-320 320 320-56 57-224-224v487h-80Z"/></svg>',x='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true" style="animation: ago-spin 0.8s linear infinite"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>',p=document.createElement("button");p.type="submit",p.setAttribute("aria-label","Send"),p.innerHTML=m,v(p,{flexShrink:"0",width:"40px",height:"40px",padding:"0",border:"none",borderRadius:"50%",backgroundColor:ke,color:Ae,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"});let f=!1;const A=()=>{const s=a.value.trim()!==""||o.length>0,c=f||!s;p.disabled=c,p.innerHTML=f?x:m,p.style.opacity=c&&!f?"0.5":"1",p.style.cursor=c?"default":"pointer"};let R=null,_=null;n.allowFiles&&(R=document.createElement("input"),R.type="file",R.multiple=!0,v(R,{display:"none"}),_=document.createElement("button"),_.type="button",_.setAttribute("aria-label","Attach file"),_.textContent="📎",v(_,{padding:"10px 12px",border:`1px solid ${L}`,borderRadius:"12px",backgroundColor:ee,cursor:"pointer",fontSize:"14px"}),_.addEventListener("click",()=>R?.click()),R.addEventListener("change",()=>{o=[...o,...Array.from(R?.files??[])],Y()}));function Y(){r.replaceChildren(),o.forEach((s,c)=>{const y=h({display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",backgroundColor:"#f0f4ff",border:`1px solid ${L}`,borderRadius:"8px",fontSize:"12px"}),T=document.createElement("span");T.textContent=s.name;const k=document.createElement("button");k.type="button",k.setAttribute("aria-label",`Remove ${s.name}`),k.textContent="×",v(k,{border:"none",background:"transparent",cursor:"pointer",fontSize:"14px",lineHeight:"1"}),k.addEventListener("click",()=>{o=o.filter((G,j)=>j!==c),Y()}),y.append(T,k),r.appendChild(y)}),A()}const B=()=>{const s=a.value,c=o;return a.value="",C(),o=[],Y(),{content:s,files:c}},g=()=>{const{content:s,files:c}=B();(s.trim()||c.length>0)&&n.onSend(s.trim(),c.length>0?c:void 0)};return i.addEventListener("submit",s=>{s.preventDefault(),g()}),a.addEventListener("keydown",s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),g())}),_&&b.appendChild(_),b.append(a,p),R&&i.appendChild(R),i.append(r,b),A(),{inputRow:i,getValueAndClear:B,setDisabled:s=>{a.disabled=s,f=s,A()},focus:()=>a.focus()}}var Zt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function ie(n){return n.replace(/[&<>"']/g,o=>Zt[o])}function mt(n){const o=n.trim();return/^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i.test(o)||!/^[a-z][a-z0-9+.-]*:/i.test(o)?o:null}var bt='"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace',Ee="";function te(n){const o=[],i=b=>(o.push(b),`${Ee}${o.length-1}${Ee}`);let r=n;return r=r.replace(/`([^`]+)`/g,(b,a)=>i(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${bt}">${ie(a)}</code>`)),r=r.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g,(b,a,C)=>{const m=mt(C);return m?i(`<img alt="${ie(a)}" src="${ie(m)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`):b}),r=r.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(b,a,C)=>{const m=mt(C);return m?i(`<a href="${ie(m)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${te(a)}</a>`):b}),r=ie(r),r=r.replace(/\*\*([^*]+?)\*\*/g,"<strong>$1</strong>").replace(/__([^_]+?)__/g,"<strong>$1</strong>").replace(/~~([^~]+?)~~/g,"<del>$1</del>").replace(/(^|[^*])\*(?!\s)([^*]+?)\*/g,"$1<em>$2</em>").replace(/(^|[^\w_])_(?!\s)([^_]+?)_/g,"$1<em>$2</em>"),r=r.replace(new RegExp(`${Ee}(\\d+)${Ee}`,"g"),(b,a)=>o[Number(a)]),r}function O(n,o,i){const r=document.createElement(n);return Object.assign(r.style,o),i!==void 0&&(r.innerHTML=i),r}var vt=/^ {0,3}([-*_])( *\1){2,} *$/,yt=/^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/,wt=/^ {0,3}(```+|~~~+)/,Re=/^ {0,3}>\s?/,se=/^(\s*)([-*+]|\d+[.)])\s+(.*)$/,Jt=["20px","18px","16px","15px","14px","13px"],ze=n=>n.match(/^\s*/)?.[0].length??0;function en(n){return n.trim()===""||vt.test(n)||yt.test(n)||wt.test(n)||Re.test(n)||se.test(n)}function Ct(n){const o=n[0].match(se),i=o[1].length,r=/\d/.test(o[2]),b=O(r?"ol":"ul",{margin:"0 0 8px 0",paddingLeft:"20px",listStyleType:r?"decimal":"disc",listStylePosition:"outside"});let a=0;for(;a<n.length;){const C=n[a].match(se),m=[];for(a++;a<n.length&&ze(n[a])>i;)m.push(n[a]),a++;const x=O("li",{display:"list-item",margin:"2px 0",lineHeight:"1.6"}),p=C[3].match(/^\[([ xX])\]\s+(.*)$/);p?(x.style.listStyleType="none",x.style.marginLeft="-20px",x.innerHTML=`<span style="margin-right:6px">${p[1].toLowerCase()==="x"?"☑":"☐"}</span>${te(p[2])}`):x.innerHTML=te(C[3]),m.filter(f=>se.test(f)).length>0&&x.appendChild(Ct(m.filter(f=>f.trim()!==""))),b.appendChild(x)}return b}function tn(n){const o=m=>m.replace(/^\s*\|?/,"").replace(/\|?\s*$/,"").split("|").map(x=>x.trim()),i=O("div",{overflowX:"auto",margin:"0 0 8px 0"}),r=O("table",{borderCollapse:"collapse",width:"100%",fontSize:"13px"}),b=document.createElement("thead"),a=document.createElement("tr");for(const m of o(n[0]))a.appendChild(O("th",{border:"1px solid #dee3e8",padding:"6px 10px",textAlign:"left",backgroundColor:"#f5f7fa",fontWeight:"600"},te(m)));b.appendChild(a),r.appendChild(b);const C=document.createElement("tbody");for(const m of n.slice(2)){const x=document.createElement("tr");for(const p of o(m))x.appendChild(O("td",{border:"1px solid #dee3e8",padding:"6px 10px"},te(p)));C.appendChild(x)}return r.appendChild(C),i.appendChild(r),i}var nn=n=>!!n&&/^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(n);function _e(n){const o=document.createDocumentFragment(),i=n.replace(/\r\n?/g,`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const se=require("./AgoClient-CzSmJQxl.cjs"),dt=require("./createFormCollector-BB3Uscuo.cjs"),Gt=require("./createConversationSession-DV0Xp_3O.cjs");var jt='"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',Re=`var(--ago-font, ${jt})`,ct={font:"--ago-font",radius:"--ago-radius",messageRadius:"--ago-message-radius",brand:"--ago-brand-color",brandText:"--ago-brand-text-color",headerBg:"--ago-header-background",headerText:"--ago-header-text-color",panelBg:"--ago-panel-background",messagesBg:"--ago-messages-background",text:"--ago-text-color",mutedText:"--ago-muted-text-color",border:"--ago-border-color",accent:"--ago-accent-color",agentBubbleBg:"--ago-agent-bubble-background"},Ae="var(--ago-brand-color, #03182f)",_e="var(--ago-brand-text-color, #fff)",Vt="var(--ago-header-background, var(--ago-brand-color, #03182f))",pt="var(--ago-header-text-color, #e8f0fe)",ee="var(--ago-panel-background, #fff)",ht="var(--ago-messages-background, #fbfbfb)",J="var(--ago-text-color, #30373e)",xt="var(--ago-muted-text-color, #6b6d6f)",L="var(--ago-border-color, #dee3e8)",Be="var(--ago-accent-color, #1b5fc4)",ft="var(--ago-agent-bubble-background, #f1f3f5)",qt="var(--ago-radius, 16px)",De="var(--ago-message-radius, 16px)",Kt="var(--ago-message-radius, 20px)";function Xt(n,o){if(o)for(const i of Object.keys(ct)){const r=o[i];r!=null&&n.style.setProperty(ct[i],r)}}function v(n,o){Object.assign(n.style,o)}function h(n={}){const o=document.createElement("div");return v(o,n),o}var ut="ago-chat-widget-keyframes";function Qt(){if(typeof document>"u"||document.getElementById(ut))return;const n=document.createElement("style");n.id=ut,n.textContent="@keyframes ago-pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }@keyframes ago-spin { to { transform: rotate(360deg); } }",document.head.appendChild(n)}function Yt(n){let o=[];const i=document.createElement("form");v(i,{display:"flex",flexDirection:"column",gap:"8px",padding:"12px",borderTop:`1px solid ${L}`,backgroundColor:ee}),i.className="ago-chat-input";const r=h({display:"flex",flexWrap:"wrap",gap:"6px"}),b=h({display:"flex",gap:"8px",alignItems:"flex-end"}),a=document.createElement("textarea");a.placeholder=n.placeholder,a.setAttribute("aria-label",n.placeholder),a.rows=1,v(a,{flex:"1",resize:"none",boxSizing:"border-box",padding:"10px 12px",border:`1px solid ${L}`,borderRadius:"12px",fontSize:"16px",fontFamily:Re,lineHeight:"1.4",maxHeight:"110px",overflowY:"hidden"});const C=()=>{a.style.height="auto";const c=Math.min(a.scrollHeight+2,110);a.style.height=`${c}px`,a.style.overflowY=a.scrollHeight+2>110?"auto":"hidden"};a.addEventListener("input",()=>{C(),A()});const m='<svg width="18" height="18" viewBox="0 -960 960 960" fill="currentColor" aria-hidden="true"><path d="M440-160v-487L216-423l-56-57 320-320 320 320-56 57-224-224v487h-80Z"/></svg>',x='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true" style="animation: ago-spin 0.8s linear infinite"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>',p=document.createElement("button");p.type="submit",p.setAttribute("aria-label","Send"),p.innerHTML=m,v(p,{flexShrink:"0",width:"40px",height:"40px",padding:"0",border:"none",borderRadius:"50%",backgroundColor:Ae,color:_e,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"});let f=!1;const A=()=>{const s=a.value.trim()!==""||o.length>0,c=f||!s;p.disabled=c,p.innerHTML=f?x:m,p.style.opacity=c&&!f?"0.5":"1",p.style.cursor=c?"default":"pointer"};let R=null,_=null;n.allowFiles&&(R=document.createElement("input"),R.type="file",R.multiple=!0,v(R,{display:"none"}),_=document.createElement("button"),_.type="button",_.setAttribute("aria-label","Attach file"),_.textContent="📎",v(_,{padding:"10px 12px",border:`1px solid ${L}`,borderRadius:"12px",backgroundColor:ee,cursor:"pointer",fontSize:"14px"}),_.addEventListener("click",()=>R?.click()),R.addEventListener("change",()=>{o=[...o,...Array.from(R?.files??[])],Y()}));function Y(){r.replaceChildren(),o.forEach((s,c)=>{const y=h({display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",backgroundColor:"#f0f4ff",border:`1px solid ${L}`,borderRadius:"8px",fontSize:"12px"}),T=document.createElement("span");T.textContent=s.name;const k=document.createElement("button");k.type="button",k.setAttribute("aria-label",`Remove ${s.name}`),k.textContent="×",v(k,{border:"none",background:"transparent",cursor:"pointer",fontSize:"14px",lineHeight:"1"}),k.addEventListener("click",()=>{o=o.filter((j,V)=>V!==c),Y()}),y.append(T,k),r.appendChild(y)}),A()}const D=()=>{const s=a.value,c=o;return a.value="",C(),o=[],Y(),{content:s,files:c}},g=()=>{const{content:s,files:c}=D();(s.trim()||c.length>0)&&n.onSend(s.trim(),c.length>0?c:void 0)};return i.addEventListener("submit",s=>{s.preventDefault(),g()}),a.addEventListener("keydown",s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),g())}),_&&b.appendChild(_),b.append(a,p),R&&i.appendChild(R),i.append(r,b),A(),{inputRow:i,getValueAndClear:D,setDisabled:s=>{a.disabled=s,f=s,A()},focus:()=>a.focus()}}var Zt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function ae(n){return n.replace(/[&<>"']/g,o=>Zt[o])}function mt(n){const o=n.trim();return/^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i.test(o)||!/^[a-z][a-z0-9+.-]*:/i.test(o)?o:null}var bt='"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace',Se="";function te(n){const o=[],i=b=>(o.push(b),`${Se}${o.length-1}${Se}`);let r=n;return r=r.replace(/`([^`]+)`/g,(b,a)=>i(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${bt}">${ae(a)}</code>`)),r=r.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g,(b,a,C)=>{const m=mt(C);return m?i(`<img alt="${ae(a)}" src="${ae(m)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`):b}),r=r.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(b,a,C)=>{const m=mt(C);return m?i(`<a href="${ae(m)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${te(a)}</a>`):b}),r=ae(r),r=r.replace(/\*\*([^*]+?)\*\*/g,"<strong>$1</strong>").replace(/__([^_]+?)__/g,"<strong>$1</strong>").replace(/~~([^~]+?)~~/g,"<del>$1</del>").replace(/(^|[^*])\*(?!\s)([^*]+?)\*/g,"$1<em>$2</em>").replace(/(^|[^\w_])_(?!\s)([^_]+?)_/g,"$1<em>$2</em>"),r=r.replace(new RegExp(`${Se}(\\d+)${Se}`,"g"),(b,a)=>o[Number(a)]),r}function B(n,o,i){const r=document.createElement(n);return Object.assign(r.style,o),i!==void 0&&(r.innerHTML=i),r}var vt=/^ {0,3}([-*_])( *\1){2,} *$/,yt=/^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/,wt=/^ {0,3}(```+|~~~+)/,ke=/^ {0,3}>\s?/,le=/^(\s*)([-*+]|\d+[.)])\s+(.*)$/,Jt=["20px","18px","16px","15px","14px","13px"],ze=n=>n.match(/^\s*/)?.[0].length??0;function en(n){return n.trim()===""||vt.test(n)||yt.test(n)||wt.test(n)||ke.test(n)||le.test(n)}function Ct(n){const o=n[0].match(le),i=o[1].length,r=/\d/.test(o[2]),b=B(r?"ol":"ul",{margin:"0 0 8px 0",paddingLeft:"20px",listStyleType:r?"decimal":"disc",listStylePosition:"outside"});let a=0;for(;a<n.length;){const C=n[a].match(le),m=[];for(a++;a<n.length&&ze(n[a])>i;)m.push(n[a]),a++;const x=B("li",{display:"list-item",margin:"2px 0",lineHeight:"1.6"}),p=C[3].match(/^\[([ xX])\]\s+(.*)$/);p?(x.style.listStyleType="none",x.style.marginLeft="-20px",x.innerHTML=`<span style="margin-right:6px">${p[1].toLowerCase()==="x"?"☑":"☐"}</span>${te(p[2])}`):x.innerHTML=te(C[3]),m.filter(f=>le.test(f)).length>0&&x.appendChild(Ct(m.filter(f=>f.trim()!==""))),b.appendChild(x)}return b}function tn(n){const o=m=>m.replace(/^\s*\|?/,"").replace(/\|?\s*$/,"").split("|").map(x=>x.trim()),i=B("div",{overflowX:"auto",margin:"0 0 8px 0"}),r=B("table",{borderCollapse:"collapse",width:"100%",fontSize:"13px"}),b=document.createElement("thead"),a=document.createElement("tr");for(const m of o(n[0]))a.appendChild(B("th",{border:"1px solid #dee3e8",padding:"6px 10px",textAlign:"left",backgroundColor:"#f5f7fa",fontWeight:"600"},te(m)));b.appendChild(a),r.appendChild(b);const C=document.createElement("tbody");for(const m of n.slice(2)){const x=document.createElement("tr");for(const p of o(m))x.appendChild(B("td",{border:"1px solid #dee3e8",padding:"6px 10px"},te(p)));C.appendChild(x)}return r.appendChild(C),i.appendChild(r),i}var nn=n=>!!n&&/^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(n);function Ie(n){const o=document.createDocumentFragment(),i=n.replace(/\r\n?/g,`
2
2
  `).split(`
3
- `);let r=0;for(;r<i.length;){const a=i[r];if(a.trim()===""){r++;continue}const C=a.match(wt);if(C){const p=C[1][0],f=[];for(r++;r<i.length&&!new RegExp(`^ {0,3}${p==="`"?"`{3,}":"~{3,}"}\\s*$`).test(i[r]);)f.push(i[r]),r++;r++;const A=O("pre",{margin:"0 0 8px 0"});A.appendChild(O("code",{display:"block",background:"#f5f5f5",padding:"8px 12px",borderRadius:"6px",fontSize:"13px",overflowX:"auto",fontFamily:bt,whiteSpace:"pre"},ie(f.join(`
4
- `)))),o.appendChild(A);continue}if(vt.test(a)){o.appendChild(O("hr",{border:"none",borderTop:"1px solid #dee3e8",margin:"12px 0"})),r++;continue}const m=a.match(yt);if(m){const p=m[1].length;o.appendChild(O(`h${p}`,{margin:"16px 0 8px 0",fontSize:Jt[p-1],fontWeight:"600",lineHeight:"1.3"},te(m[2]))),r++;continue}if(Re.test(a)){const p=[];for(;r<i.length&&Re.test(i[r]);)p.push(i[r].replace(Re,"")),r++;const f=O("blockquote",{borderLeft:"4px solid #dee3e8",paddingLeft:"12px",margin:"0 0 8px 0",fontStyle:"italic",color:"#6b6d6f"});f.appendChild(_e(p.join(`
5
- `))),o.appendChild(f);continue}if(a.includes("|")&&nn(i[r+1])){const p=[a,i[r+1]];for(r+=2;r<i.length&&i[r].includes("|")&&i[r].trim();)p.push(i[r]),r++;o.appendChild(tn(p));continue}if(se.test(a)){const p=[],f=ze(a);for(;r<i.length&&i[r].trim()!=="";)if(se.test(i[r])||ze(i[r])>f)p.push(i[r]),r++;else break;o.appendChild(Ct(p));continue}const x=[a];for(r++;r<i.length&&!en(i[r]);)x.push(i[r]),r++;o.appendChild(O("p",{margin:"0 0 8px 0",lineHeight:"1.6"},x.map(p=>te(p)).join("<br>")))}const b=o.lastElementChild;return b&&(b.style.marginBottom="0"),o}function on(n,o){const{isLast:i,isLastOfBlock:r,bubbleStyle:b,showAgentName:a,agentBubble:C,followUpEnabled:m,followUpHandler:x,isMobile:p}=o,f=n.role==="user",A=b==="imessage",R=h({display:"flex",flexDirection:"column",alignItems:f?"flex-end":"flex-start",marginBottom:A&&!r?"2px":"16px"});if(R.className=`ago-message ago-message--${n.role}`,!f&&a&&n.agent){const g=h({fontSize:"13px",fontWeight:"500",color:J,marginBottom:"6px",padding:"0 4px"});g.className="ago-message__agent",g.textContent=n.agent.displayName||n.agent.name,R.appendChild(g)}if(!f&&n.sources&&n.sources.length>0){const g=h({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px",marginBottom:"10px",width:"100%",maxWidth:"85%"});g.className="ago-message__sources",n.sources.forEach((s,c)=>{const y=s.url?document.createElement("a"):document.createElement("div");s.url&&y instanceof HTMLAnchorElement&&(y.href=s.url,y.target="_blank",y.rel="noopener noreferrer"),v(y,{display:"flex",alignItems:"center",gap:"8px",padding:"8px 10px",border:`1px solid ${L}`,borderRadius:"8px",backgroundColor:ee,textDecoration:"none",color:J,fontSize:"12px",overflow:"hidden"});const T=h({flexShrink:"0",width:"18px",height:"18px",borderRadius:"3px",border:`1px solid ${Be}`,color:Be,fontSize:"11px",fontWeight:"500",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f0f4ff"});T.textContent=String(c+1);const k=h({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"});k.textContent=s.title,k.title=s.title,y.append(T,k),g.appendChild(y)}),R.appendChild(g)}if(n.attachments&&n.attachments.length>0){const g=h({display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"6px",justifyContent:f?"flex-end":"flex-start",maxWidth:"75%"});g.className="ago-message__attachments";for(const s of n.attachments){const c=ae.safeAttachmentUrl(s.url);if(ae.canInlineImage(s)&&c){const M=document.createElement("a");M.href=c,M.target="_blank",M.rel="noopener noreferrer",v(M,{display:"inline-block",textDecoration:"none"});const V=document.createElement("img");V.src=c,V.alt=s.name,V.loading="lazy",v(V,{maxWidth:"180px",maxHeight:"160px",objectFit:"cover",borderRadius:"10px",border:`1px solid ${L}`,display:"block"}),M.appendChild(V),g.appendChild(M);continue}const y=c?document.createElement("a"):document.createElement("div");c&&y instanceof HTMLAnchorElement&&(y.href=c,y.target="_blank",y.rel="noopener noreferrer"),v(y,{display:"inline-flex",alignItems:"center",gap:"8px",padding:"8px 12px",borderRadius:"10px",border:`1px solid ${L}`,backgroundColor:f?"rgba(255,255,255,0.12)":ee,color:f?Ae:J,fontSize:"13px",textDecoration:"none",maxWidth:"220px"});const T=document.createElement("span");T.textContent="📄",T.setAttribute("aria-hidden","true"),v(T,{fontSize:"16px",lineHeight:"1",flexShrink:"0"});const k=h({display:"flex",flexDirection:"column",minWidth:"0"}),G=h({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"160px"});G.textContent=s.name,G.title=s.name,k.appendChild(G);const j=ae.formatFileSize(s.fileSize);if(j){const M=h({fontSize:"11px",color:xt});M.textContent=j,k.appendChild(M)}y.append(T,k),g.appendChild(y)}R.appendChild(g)}const _=f||C||A,Y=!!n.content||n.status==="IN_PROGRESS",B=h({maxWidth:_?A||f?p?"88%":"75%":p?"92%":"85%":"100%",padding:_?"10px 14px":"2px 8px",borderRadius:A?Kt:_?De:"0",backgroundColor:f?ke:_?ft:"transparent",color:f?Ae:J,overflowWrap:"break-word",textWrap:"pretty",fontSize:"16px",lineHeight:"1.6"});if(B.className="ago-message__content",A&&r){B.style.position="relative";const g=h({position:"absolute",zIndex:"0",bottom:"-2px",width:"20px",height:"20px",background:f?ke:ft});g.className="ago-message__tail";const s=h({position:"absolute",zIndex:"1",bottom:"-2px",width:"10px",height:"20px",background:ht});s.className="ago-message__tail-mask",f?(g.style.right="-8px",g.style.borderBottomLeftRadius="16px 14px",s.style.right="-10px",s.style.borderBottomLeftRadius="10px"):(g.style.left="-7px",g.style.borderBottomRightRadius="16px 14px",s.style.left="-10px",s.style.borderBottomRightRadius="10px"),B.append(g,s)}if(n.content?B.appendChild(_e(n.content)):n.status==="IN_PROGRESS"&&B.appendChild(an()),Y&&R.appendChild(B),i&&n.followUpReplies&&n.followUpReplies.length>0){const g=h({display:"flex",flexWrap:"wrap",gap:"8px",marginTop:"10px"});g.className="ago-message__followups";for(const s of n.followUpReplies){const c=document.createElement("button");c.type="button",c.className="ago-message__followup-btn",c.textContent=s,c.disabled=!m,v(c,{minHeight:"36px",padding:"6px 14px",fontSize:"14px",borderRadius:De,border:`1px solid ${L}`,backgroundColor:ee,color:J,cursor:m?"pointer":"default",transition:"border-color 0.15s"}),x&&c.addEventListener("click",()=>x(s)),c.addEventListener("mouseenter",()=>{c.style.borderColor=Be}),c.addEventListener("mouseleave",()=>{c.style.borderColor=L}),g.appendChild(c)}R.appendChild(g)}return R}function rn(n){const o=h({display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",backgroundColor:"#f0fdf4",color:"#15803d",borderRadius:De,marginTop:"8px",fontSize:"13px",border:"1px solid #bbf7d0"});o.className="ago-form-notice",o.setAttribute("role","status");const i=document.createElement("span");i.textContent="✓",i.setAttribute("aria-hidden","true"),v(i,{fontWeight:"700"});const r=document.createElement("span");return r.textContent=n,o.append(i,r),o}function an(){const n=h({display:"flex",gap:"4px",padding:"4px 0"});for(let o=0;o<3;o++){const i=h({width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#b5bfc8",animation:"ago-pulse 1.2s ease-in-out infinite",animationDelay:`${o*.2}s`});n.appendChild(i)}return n}function sn(){const n="http://www.w3.org/2000/svg",o=document.createElementNS(n,"svg");o.setAttribute("width","26"),o.setAttribute("height","26"),o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("fill","none");const i=document.createElementNS(n,"path");return i.setAttribute("d","M21 11.5a8.38 8.38 0 0 1-8.5 8.5 8.5 8.5 0 0 1-3.8-.9L3 21l1.9-5.7a8.5 8.5 0 0 1-.9-3.8 8.38 8.38 0 0 1 8.5-8.5 8.38 8.38 0 0 1 8.5 8.5z"),i.setAttribute("stroke","currentColor"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),o.appendChild(i),o}var gt="Form submitted.";function ln(n){if(typeof n=="string")return n||null;if(!n||typeof n!="object")return null;const o=n;if(typeof o.message=="string"&&o.message)return o.message;const i=o.result;if(typeof i=="string"&&i)return i;if(i&&typeof i=="object"){const r=i.message;if(typeof r=="string"&&r)return r}return null}var dn=0;function cn(n){const o=typeof n=="string"?document.querySelector(n):n;if(!o)throw new Error(`mountChatWidget: target "${String(n)}" not found.`);return o}function pn(n,o){const{title:i="Chat",welcomeMessage:r="Hello! How can I help you today?",placeholder:b="Type a message...",allowFiles:a=!1,height:C=500,placement:m="inline",width:x=400,defaultOpen:p=!1,logoUrl:f,showAgentName:A=!1,agentBubble:R=!1,bubbleStyle:_="default",showHeader:Y=!0,theme:B,loadThreads:g=!1,forms:s,formSubmittedMessage:c=gt,onFollowUpClick:y,onMessageSent:T,onMessageReceived:k,onFormSubmitted:G,onFormError:j,onOpen:M,onClose:V}=o,ne=typeof r=="string"?{message:r,mode:"static"}:r,Fe=ne.message,He=ne.mode??"static",Et="speed"in ne&&ne.speed||45,Pe="followUpReplies"in ne&&ne.followUpReplies||void 0;if(!o.client&&!o.config?.baseUrl)throw new ae.AgoError("mountChatWidget requires either `client` or `config` (with a baseUrl).","config_missing_base_url");const E=o.client??new ae.AgoClient(o.config),Ue=cn(n),D=m==="left"||m==="right",St=D&&(o.launcher??!0);let oe=D?p:!0;const Rt=o.mobile?.breakpoint??768,kt=o.mobile?.trigger??"focus",We=typeof window<"u"&&!!window.matchMedia,z=We?window.matchMedia(`(max-width: ${Rt}px)`):void 0,At=We?window.matchMedia("(prefers-reduced-motion: reduce)"):void 0,le=!D&&!!z,Ie=o.persistConversation,me=Ie?Gt.createConversationSession(Ie===!0?{}:Ie):void 0;let P=o.conversationId??me?.getLastActiveThread()??void 0,u=[],Z=!1,de=null,q;const Ge=[];function _t(e){if(typeof c=="function"){const l=c(e);if(typeof l=="string"&&l)return l}const t=ln(e);return t||(typeof c=="string"?c:gt)}const ge=[],d=h({display:"flex",flexDirection:"column",height:D?"100%":typeof C=="number"?`${C}px`:C,border:`1px solid ${L}`,borderRadius:qt,overflow:"hidden",backgroundColor:ee,fontFamily:Se,textAlign:"left",boxShadow:"rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"});d.className="ago-chat-widget",Xt(d,B);let F;if(Y){if(F=h({padding:"14px 16px",borderBottom:`1px solid ${L}`,backgroundColor:Vt,color:pt,display:"flex",alignItems:"center",gap:"10px"}),F.className="ago-chat-widget__header",f){const t=document.createElement("img");t.src=f,t.alt="Logo",v(t,{height:"24px",width:"auto"}),F.appendChild(t)}const e=document.createElement("h3");if(e.textContent=i,v(e,{margin:"0",fontSize:"15px",fontWeight:"600"}),F.appendChild(e),D){const t=document.createElement("button");t.type="button",t.className="ago-chat-widget__close",t.setAttribute("aria-label","Close"),t.textContent="×",v(t,{marginLeft:"auto",background:"transparent",border:"none",color:pt,fontSize:"22px",lineHeight:"1",cursor:"pointer",padding:"0 2px"}),t.addEventListener("click",()=>Oe()),F.appendChild(t)}}const I=h({flex:"1",overflow:"auto",padding:"16px",backgroundColor:ht});I.className="ago-chat-widget__messages",I.setAttribute("role","log"),I.setAttribute("aria-live","polite"),I.setAttribute("aria-relevant","additions text"),I.setAttribute("aria-atomic","false");const{inputRow:$e,setDisabled:It,focus:he}=Yt({placeholder:b,allowFiles:a,onSend:(e,t)=>{Ne(e,t)}});Qt(),d.append(...F?[F]:[],I,$e);let xe=d,U,N;const be=m==="left"?"left":"right";if(D&&(U=h({position:"fixed",top:"0",bottom:"0",[be]:"0",width:typeof x=="number"?`${x}px`:x,maxWidth:"100vw",display:"flex",zIndex:"2147483000",transition:"transform 0.3s ease",boxShadow:"rgba(15, 15, 15, 0.18) 0px 0px 24px 0px"}),U.className="ago-chat-widget-panel",v(d,{height:"100%",width:"100%",borderRadius:"0",border:"none",boxShadow:"none",[be==="left"?"borderRight":"borderLeft"]:`1px solid ${L}`}),U.appendChild(d),xe=U),St){if(N=document.createElement("button"),N.type="button",N.className="ago-chat-widget-launcher",N.setAttribute("aria-label",`Open ${i}`),v(N,{position:"fixed",bottom:"20px",[be]:"20px",width:"56px",height:"56px",borderRadius:"50%",border:"none",backgroundColor:ke,color:Ae,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",zIndex:"2147483000",boxShadow:"rgba(15, 15, 15, 0.2) 0px 4px 14px 0px",fontFamily:Se}),f){const e=document.createElement("img");e.src=f,e.alt="",v(e,{width:"26px",height:"26px",objectFit:"contain"}),N.appendChild(e)}else N.appendChild(sn());N.addEventListener("click",()=>Me())}const ce=le?`ago-vt-${++dn}`:"",je=52;let K=!1,pe=0,re=0,H,fe,X;const ve={height:d.style.height,border:d.style.border,borderRadius:d.style.borderRadius,boxShadow:d.style.boxShadow};Ue.appendChild(xe),N&&Ue.appendChild(N),ye(),le&&(H=Pt(),d.insertBefore(H,d.firstChild),fe=document.createElement("style"),fe.id=ce,fe.textContent=`::view-transition-group(${ce}),::view-transition-group(${ce}-bar){animation-duration:0.3s;animation-timing-function:cubic-bezier(0.4,0,0.2,1)}`,document.head.appendChild(fe),kt==="focus"&&(d.addEventListener("pointerdown",e=>{K||!z?.matches||$e.contains(e.target)&&(e.preventDefault(),Ce())},!0),d.addEventListener("focusin",e=>{z?.matches&&$e.contains(e.target)&&Ce()})),document.addEventListener("keydown",tt)),z&&z.addEventListener("change",nt);const $t=y!==!1,Lt=y===!1?void 0:y??(e=>{Ne(e)});function $(){if(I.replaceChildren(),u.length===0){if(He==="static"){const t=h({textAlign:"center",color:xt,padding:"24px 16px",fontSize:"16px",lineHeight:"1.5"});t.appendChild(_e(Fe)),I.appendChild(t)}}else u.forEach((t,l)=>{const S=l===u.length-1||u[l+1].role!==t.role;I.appendChild(on(t,{isLast:l===u.length-1,isLastOfBlock:S,bubbleStyle:_,showAgentName:A,agentBubble:R,followUpEnabled:$t,followUpHandler:Lt,isMobile:!!z?.matches}))});for(const t of Ge)I.appendChild(rn(t));if(de){const t=h({padding:"10px 14px",backgroundColor:"#fef2f2",color:"#dc2626",borderRadius:"12px",marginTop:"8px",fontSize:"13px",border:"1px solid #fecaca"});t.setAttribute("role","alert"),t.textContent=de,I.appendChild(t)}I.scrollTop=I.scrollHeight;const e=u[u.length-1];It(Z&&e?.role==="assistant"&&e.status==="IN_PROGRESS")}function Nt(){for(let e=u.length-1;e>=0;e--){const t=u[e];if(t.role==="assistant"&&t.status==="IN_PROGRESS")return t}}const Ve=e=>{P||(P=e.conversationId)},qe=e=>{const t=Nt();t&&(t.content+=e.content,$())},Ke=e=>{const t=u.findIndex(l=>l.id===e.id||l.role==="assistant"&&l.status==="IN_PROGRESS");t>=0?u[t]=e:u.push(e),$(),he()},Xe=e=>{const t=u.findIndex(l=>l.id===e.id||l.role==="assistant"&&l.status==="IN_PROGRESS");t>=0?u[t]=e:u.push(e),Z=!1,$(),e.status==="DONE"&&k?.({id:e.id,content:e.content})},Qe=e=>{de=e.error,Z=!1,u=u.filter(t=>!t.id.startsWith("temp-")),$()};function Tt(e){const t={id:`ago-intro-${Date.now()}`,conversationId:"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date};u.push(t),$();const l=e.match(/\S+\s*/g)??[e];let S=0;q=setInterval(()=>{if(S>=l.length){clearInterval(q),q=void 0,t.status="DONE",Pe&&(t.followUpReplies=Pe),$();return}t.content+=l[S],S++,$()},Et)}E.on("message:start",Ve),E.on("message:chunk",qe),E.on("message:answer-complete",Ke),E.on("message:complete",Xe),E.on("message:error",Qe);const Ye=e=>G?.(e),Ze=e=>j?.(e);G&&E.on("form:submitted",Ye),j&&E.on("form:error",Ze);const Le=[];let Je=!1;const et=e=>{if(Je)return;Le.push(e.install(E));let t=e.store.get().submitted;const l=e.store.subscribe(S=>{S.submitted&&!t&&(Ge.push(_t(S.submitResult)),$()),t=S.submitted});Le.push(l)};for(const e of s??[])e.schema!=null?et(dt.createFormCollector(e)):dt.loadFormCollector(E,e).then(t=>et(t)).catch(()=>{});async function Ne(e,t){const l=e.trim();if(!l&&!t?.length||Z)return;if(T?.(l),Z=!0,de=null,q){clearInterval(q),q=void 0;const w=u.find(W=>W.id.startsWith("ago-intro-"));w&&!w.content?u=u.filter(W=>W!==w):w&&(w.status="DONE")}const S=Date.now();u.push({id:`temp-user-${S}`,conversationId:P||"",content:l,role:"user",status:"DONE",attachments:t&&t.length>0?ae.attachmentsFromFiles(t):void 0,createdAt:new Date}),u.push({id:`temp-assistant-${S}`,conversationId:P||"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date}),$();try{const w=await E.sendMessage(l,{conversationId:P,files:t});w.conversationId&&(P||(P=w.conversationId),me?.setActiveThread(w.conversationId,w.createdAt));const W=u.find(Q=>Q.id===`temp-user-${S}`);if(W&&(W.id=`user-${S}`,W.conversationId=w.conversationId),!u.some(Q=>Q.id===w.id)){const Q=u.findIndex(Wt=>Wt.id===`temp-assistant-${S}`);Q>=0?u[Q]=w:u.push(w)}u=u.filter(Q=>!Q.id.startsWith("temp-")),Z=!1,$(),g&&Te()}catch(w){de=w instanceof Error?w.message:"Failed to send message",Z=!1,u=u.filter(W=>!W.id.startsWith("temp-")),$()}}async function Te(){try{const e=await E.getConversations();ge.splice(0,ge.length,...e)}catch{}return ge}async function Mt(e){try{const t=(await E.getConversation(e))?.messages??[];t.length>0&&u.length===0&&(u=t,$())}catch{u.length===0&&(me?.clear(),P=void 0)}}return $(),le&&z?.matches||he(),P?Mt(P):He==="streaming"&&Tt(Fe),g&&Te(),{client:E,element:xe,sendMessage:Ne,...D||le?{open:Bt,close:Dt,toggle:zt}:{},session:me,threads:ge,refreshThreads:Te,destroy(){q&&clearInterval(q),E.off("message:start",Ve),E.off("message:chunk",qe),E.off("message:answer-complete",Ke),E.off("message:complete",Xe),E.off("message:error",Qe),G&&E.off("form:submitted",Ye),j&&E.off("form:error",Ze),Je=!0,Le.forEach(e=>e()),xe.remove(),N?.remove(),H?.remove(),fe?.remove(),X?.remove(),z?.removeEventListener("change",nt),le&&(document.removeEventListener("keydown",tt),it(),document.documentElement.style.removeProperty("overflow")),o.client||E.destroy()}};function ye(){if(!U)return;{const t=be==="left"?"border-right":"border-left";z?.matches?(U.style.width="100%",d.style.borderRadius="0",d.style.removeProperty(t)):(U.style.width=typeof x=="number"?`${x}px`:x,d.style.setProperty(t,`1px solid ${L}`))}const e=m==="left"?"translateX(-100%)":"translateX(100%)";U.style.transform=oe?"translateX(0)":e,U.setAttribute("aria-hidden",oe?"false":"true"),N&&(N.style.display=oe?"none":"flex")}function Me(){oe=!0,ye(),he(),M?.()}function Oe(){oe=!1,ye(),V?.()}function Ot(){oe?Oe():Me()}function Bt(){D?Me():Ce()}function Dt(){D?Oe():ue()}function zt(){D?Ot():K?ue():Ce()}function Ft(){return Array.from(d.querySelectorAll('a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])')).filter(e=>e.getClientRects().length>0)}function tt(e){if(!K)return;if(e.key==="Escape"){ue();return}if(e.key!=="Tab")return;const t=Ft();if(t.length===0){e.preventDefault();return}const l=t[0],S=t[t.length-1],w=document.activeElement;e.shiftKey&&(w===l||!d.contains(w))?(e.preventDefault(),S.focus()):!e.shiftKey&&(w===S||!d.contains(w))&&(e.preventDefault(),l.focus())}function nt(e){D?ye():!e.matches&&K&&ue(),$()}function ot(){return window.visualViewport?.height??window.innerHeight}function rt(){const e=window.visualViewport,t=e?.offsetTop??0,l=e?.height??pe,S=Math.min(0,t+l-pe);d.style.top=`${S}px`,H&&(H.style.top=`${t}px`)}function we(){re||(re=requestAnimationFrame(()=>{re=0,rt()}))}function Ht(){window.visualViewport?.addEventListener("resize",we),window.visualViewport?.addEventListener("scroll",we)}function it(){window.visualViewport?.removeEventListener("resize",we),window.visualViewport?.removeEventListener("scroll",we),re&&(cancelAnimationFrame(re),re=0)}function at(){I.scrollTop=I.scrollHeight}function Pt(){const e=h({position:"fixed",top:"0",left:"0",right:"0",height:`calc(${je}px + env(safe-area-inset-top))`,display:"none",alignItems:"center",justifyContent:"space-between",padding:"env(safe-area-inset-top) 14px 0",backgroundColor:ee,borderBottom:`1px solid ${L}`,zIndex:"2147483001",fontFamily:Se});if(e.className="ago-chat-widget-mobile-bar",f){const l=document.createElement("img");l.src=f,l.alt="",v(l,{height:"28px",width:"auto"}),e.appendChild(l)}else if(i){const l=document.createElement("span");l.textContent=i,v(l,{fontSize:"15px",fontWeight:"600",color:J,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"}),e.appendChild(l)}else e.appendChild(h({}));const t=document.createElement("button");return t.type="button",t.setAttribute("aria-label","Close"),t.textContent="×",v(t,{border:"none",background:"transparent",fontSize:"26px",lineHeight:"1",color:J,cursor:"pointer",padding:"4px 8px"}),t.addEventListener("click",()=>{ue()}),e.appendChild(t),e}function Ut(){return typeof document.startViewTransition=="function"&&!At?.matches&&!!z?.matches}function st(e){const t=document;if(Ut()&&t.startViewTransition){d.style.setProperty("view-transition-name",ce),H?.style.setProperty("view-transition-name",`${ce}-bar`);const l=()=>{d.style.removeProperty("view-transition-name"),H?.style.removeProperty("view-transition-name")};return t.startViewTransition(e).finished.then(l,l)}return e(),Promise.resolve()}function lt(e){if(e)X&&d.parentElement?.insertBefore(X,d),v(d,{position:"fixed",top:"0",left:"0",right:"0",bottom:"0",height:"var(--ago-vh, 100dvh)",zIndex:"2147483000",border:"none",borderRadius:"0",boxShadow:"none",paddingTop:`calc(${je}px + env(safe-area-inset-top))`,paddingBottom:"env(safe-area-inset-bottom)"}),d.setAttribute("role","dialog"),d.setAttribute("aria-modal","true"),d.setAttribute("aria-label",i),document.documentElement.style.overflow="hidden",F&&(F.style.display="none"),H&&(H.style.display="flex");else{X?.remove(),X=void 0;for(const t of["position","top","left","right","bottom","z-index","padding-top","padding-bottom"])d.style.removeProperty(t);d.style.height=ve.height,d.style.border=ve.border,d.style.borderRadius=ve.borderRadius,d.style.boxShadow=ve.boxShadow,d.removeAttribute("role"),d.removeAttribute("aria-modal"),d.removeAttribute("aria-label"),document.documentElement.style.removeProperty("overflow"),F&&(F.style.display="flex"),H&&(H.style.display="none")}}function Ce(){if(K||!z?.matches)return Promise.resolve();const e=d.getBoundingClientRect();if(e.height>=ot()*.8)return Promise.resolve();K=!0,X=h({width:`${e.width}px`,height:`${e.height}px`}),X.className="ago-chat-widget-spacer",X.setAttribute("aria-hidden","true"),pe=ot(),d.style.setProperty("--ago-vh",`${pe}px`),rt(),Ht();const t=st(()=>lt(!0));return t.then(()=>{at(),he()}),at(),M?.(),t}function ue(){if(!K)return Promise.resolve();K=!1,it(),d.querySelector("textarea")?.blur();const e=st(()=>lt(!1));return e.then(()=>d.style.removeProperty("--ago-vh")),pe=0,V?.(),e}}exports.mountChatWidget=pn;exports.renderMarkdown=_e;
3
+ `);let r=0;for(;r<i.length;){const a=i[r];if(a.trim()===""){r++;continue}const C=a.match(wt);if(C){const p=C[1][0],f=[];for(r++;r<i.length&&!new RegExp(`^ {0,3}${p==="`"?"`{3,}":"~{3,}"}\\s*$`).test(i[r]);)f.push(i[r]),r++;r++;const A=B("pre",{margin:"0 0 8px 0"});A.appendChild(B("code",{display:"block",background:"#f5f5f5",padding:"8px 12px",borderRadius:"6px",fontSize:"13px",overflowX:"auto",fontFamily:bt,whiteSpace:"pre"},ae(f.join(`
4
+ `)))),o.appendChild(A);continue}if(vt.test(a)){o.appendChild(B("hr",{border:"none",borderTop:"1px solid #dee3e8",margin:"12px 0"})),r++;continue}const m=a.match(yt);if(m){const p=m[1].length;o.appendChild(B(`h${p}`,{margin:"16px 0 8px 0",fontSize:Jt[p-1],fontWeight:"600",lineHeight:"1.3"},te(m[2]))),r++;continue}if(ke.test(a)){const p=[];for(;r<i.length&&ke.test(i[r]);)p.push(i[r].replace(ke,"")),r++;const f=B("blockquote",{borderLeft:"4px solid #dee3e8",paddingLeft:"12px",margin:"0 0 8px 0",fontStyle:"italic",color:"#6b6d6f"});f.appendChild(Ie(p.join(`
5
+ `))),o.appendChild(f);continue}if(a.includes("|")&&nn(i[r+1])){const p=[a,i[r+1]];for(r+=2;r<i.length&&i[r].includes("|")&&i[r].trim();)p.push(i[r]),r++;o.appendChild(tn(p));continue}if(le.test(a)){const p=[],f=ze(a);for(;r<i.length&&i[r].trim()!=="";)if(le.test(i[r])||ze(i[r])>f)p.push(i[r]),r++;else break;o.appendChild(Ct(p));continue}const x=[a];for(r++;r<i.length&&!en(i[r]);)x.push(i[r]),r++;o.appendChild(B("p",{margin:"0 0 8px 0",lineHeight:"1.6"},x.map(p=>te(p)).join("<br>")))}const b=o.lastElementChild;return b&&(b.style.marginBottom="0"),o}function on(n,o){const{isLast:i,isLastOfBlock:r,bubbleStyle:b,showAgentName:a,agentBubble:C,followUpEnabled:m,followUpHandler:x,isMobile:p}=o,f=n.role==="user",A=b==="imessage",R=h({display:"flex",flexDirection:"column",alignItems:f?"flex-end":"flex-start",marginBottom:A&&!r?"2px":"16px"});if(R.className=`ago-message ago-message--${n.role}`,!f&&a&&n.agent){const g=h({fontSize:"13px",fontWeight:"500",color:J,marginBottom:"6px",padding:"0 4px"});g.className="ago-message__agent",g.textContent=n.agent.displayName||n.agent.name,R.appendChild(g)}if(!f&&n.sources&&n.sources.length>0){const g=h({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px",marginBottom:"10px",width:"100%",maxWidth:"85%"});g.className="ago-message__sources",n.sources.forEach((s,c)=>{const y=s.url?document.createElement("a"):document.createElement("div");s.url&&y instanceof HTMLAnchorElement&&(y.href=s.url,y.target="_blank",y.rel="noopener noreferrer"),v(y,{display:"flex",alignItems:"center",gap:"8px",padding:"8px 10px",border:`1px solid ${L}`,borderRadius:"8px",backgroundColor:ee,textDecoration:"none",color:J,fontSize:"12px",overflow:"hidden"});const T=h({flexShrink:"0",width:"18px",height:"18px",borderRadius:"3px",border:`1px solid ${Be}`,color:Be,fontSize:"11px",fontWeight:"500",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f0f4ff"});T.textContent=String(c+1);const k=h({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"});k.textContent=s.title,k.title=s.title,y.append(T,k),g.appendChild(y)}),R.appendChild(g)}if(n.attachments&&n.attachments.length>0){const g=h({display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"6px",justifyContent:f?"flex-end":"flex-start",maxWidth:"75%"});g.className="ago-message__attachments";for(const s of n.attachments){const c=se.safeAttachmentUrl(s.url);if(se.canInlineImage(s)&&c){const M=document.createElement("a");M.href=c,M.target="_blank",M.rel="noopener noreferrer",v(M,{display:"inline-block",textDecoration:"none"});const q=document.createElement("img");q.src=c,q.alt=s.name,q.loading="lazy",v(q,{maxWidth:"180px",maxHeight:"160px",objectFit:"cover",borderRadius:"10px",border:`1px solid ${L}`,display:"block"}),M.appendChild(q),g.appendChild(M);continue}const y=c?document.createElement("a"):document.createElement("div");c&&y instanceof HTMLAnchorElement&&(y.href=c,y.target="_blank",y.rel="noopener noreferrer"),v(y,{display:"inline-flex",alignItems:"center",gap:"8px",padding:"8px 12px",borderRadius:"10px",border:`1px solid ${L}`,backgroundColor:f?"rgba(255,255,255,0.12)":ee,color:f?_e:J,fontSize:"13px",textDecoration:"none",maxWidth:"220px"});const T=document.createElement("span");T.textContent="📄",T.setAttribute("aria-hidden","true"),v(T,{fontSize:"16px",lineHeight:"1",flexShrink:"0"});const k=h({display:"flex",flexDirection:"column",minWidth:"0"}),j=h({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"160px"});j.textContent=s.name,j.title=s.name,k.appendChild(j);const V=se.formatFileSize(s.fileSize);if(V){const M=h({fontSize:"11px",color:xt});M.textContent=V,k.appendChild(M)}y.append(T,k),g.appendChild(y)}R.appendChild(g)}const _=f||C||A,Y=!!n.content||n.status==="IN_PROGRESS",D=h({maxWidth:_?A||f?p?"88%":"75%":p?"92%":"85%":"100%",padding:_?"10px 14px":"2px 8px",borderRadius:A?Kt:_?De:"0",backgroundColor:f?Ae:_?ft:"transparent",color:f?_e:J,overflowWrap:"break-word",textWrap:"pretty",fontSize:"16px",lineHeight:"1.6"});if(D.className="ago-message__content",A&&r){D.style.position="relative";const g=h({position:"absolute",zIndex:"0",bottom:"-2px",width:"20px",height:"20px",background:f?Ae:ft});g.className="ago-message__tail";const s=h({position:"absolute",zIndex:"1",bottom:"-2px",width:"10px",height:"20px",background:ht});s.className="ago-message__tail-mask",f?(g.style.right="-8px",g.style.borderBottomLeftRadius="16px 14px",s.style.right="-10px",s.style.borderBottomLeftRadius="10px"):(g.style.left="-7px",g.style.borderBottomRightRadius="16px 14px",s.style.left="-10px",s.style.borderBottomRightRadius="10px"),D.append(g,s)}if(n.content?D.appendChild(Ie(n.content)):n.status==="IN_PROGRESS"&&D.appendChild(an()),Y&&R.appendChild(D),i&&n.followUpReplies&&n.followUpReplies.length>0){const g=h({display:"flex",flexWrap:"wrap",gap:"8px",marginTop:"10px"});g.className="ago-message__followups";for(const s of n.followUpReplies){const c=document.createElement("button");c.type="button",c.className="ago-message__followup-btn",c.textContent=s,c.disabled=!m,v(c,{minHeight:"36px",padding:"6px 14px",fontSize:"14px",borderRadius:De,border:`1px solid ${L}`,backgroundColor:ee,color:J,cursor:m?"pointer":"default",transition:"border-color 0.15s"}),x&&c.addEventListener("click",()=>x(s)),c.addEventListener("mouseenter",()=>{c.style.borderColor=Be}),c.addEventListener("mouseleave",()=>{c.style.borderColor=L}),g.appendChild(c)}R.appendChild(g)}return R}function rn(n){const o=h({display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",backgroundColor:"#f0fdf4",color:"#15803d",borderRadius:De,marginTop:"8px",fontSize:"13px",border:"1px solid #bbf7d0"});o.className="ago-form-notice",o.setAttribute("role","status");const i=document.createElement("span");i.textContent="✓",i.setAttribute("aria-hidden","true"),v(i,{fontWeight:"700"});const r=document.createElement("span");return r.textContent=n,o.append(i,r),o}function an(){const n=h({display:"flex",gap:"4px",padding:"4px 0"});for(let o=0;o<3;o++){const i=h({width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#b5bfc8",animation:"ago-pulse 1.2s ease-in-out infinite",animationDelay:`${o*.2}s`});n.appendChild(i)}return n}function sn(){const n="http://www.w3.org/2000/svg",o=document.createElementNS(n,"svg");o.setAttribute("width","26"),o.setAttribute("height","26"),o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("fill","none");const i=document.createElementNS(n,"path");return i.setAttribute("d","M21 11.5a8.38 8.38 0 0 1-8.5 8.5 8.5 8.5 0 0 1-3.8-.9L3 21l1.9-5.7a8.5 8.5 0 0 1-.9-3.8 8.38 8.38 0 0 1 8.5-8.5 8.38 8.38 0 0 1 8.5 8.5z"),i.setAttribute("stroke","currentColor"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),o.appendChild(i),o}var gt="Form submitted.";function ln(n){if(typeof n=="string")return n||null;if(!n||typeof n!="object")return null;const o=n;if(typeof o.message=="string"&&o.message)return o.message;const i=o.result;if(typeof i=="string"&&i)return i;if(i&&typeof i=="object"){const r=i.message;if(typeof r=="string"&&r)return r}return null}var dn=0;function cn(n){const o=typeof n=="string"?document.querySelector(n):n;if(!o)throw new Error(`mountChatWidget: target "${String(n)}" not found.`);return o}function pn(n,o){const{title:i="Chat",welcomeMessage:r="Hello! How can I help you today?",placeholder:b="Type a message...",allowFiles:a=!1,height:C=500,placement:m="inline",width:x=400,defaultOpen:p=!1,logoUrl:f,showAgentName:A=!1,agentBubble:R=!1,bubbleStyle:_="default",showHeader:Y=!0,theme:D,loadThreads:g=!1,forms:s,formSubmittedMessage:c=gt,onFollowUpClick:y,onMessageSent:T,onMessageReceived:k,onFormSubmitted:j,onFormError:V,onOpen:M,onClose:q}=o,ne=typeof r=="string"?{message:r,mode:"static"}:r,Fe=ne.message,He=ne.mode??"static",Et="speed"in ne&&ne.speed||45,Pe="followUpReplies"in ne&&ne.followUpReplies||void 0;if(!o.client&&!o.config?.baseUrl)throw new se.AgoError("mountChatWidget requires either `client` or `config` (with a baseUrl).","config_missing_base_url");const E=o.client??new se.AgoClient(o.config),Ue=cn(n),z=m==="left"||m==="right",St=z&&(o.launcher??!0);let oe=z?p:!0;const Rt=o.mobile?.breakpoint??768,kt=o.mobile?.trigger??"focus",We=typeof window<"u"&&!!window.matchMedia,O=We?window.matchMedia(`(max-width: ${Rt}px)`):void 0,At=We?window.matchMedia("(prefers-reduced-motion: reduce)"):void 0,re=!z&&!!O,$e=o.persistConversation,ge=$e?Gt.createConversationSession($e===!0?{}:$e):void 0;let P=o.conversationId??ge?.getLastActiveThread()??void 0,u=[],Z=!1,de=null,K;const Ge=[];function _t(e){if(typeof c=="function"){const l=c(e);if(typeof l=="string"&&l)return l}const t=ln(e);return t||(typeof c=="string"?c:gt)}const he=[],d=h({display:"flex",flexDirection:"column",height:z?"100%":typeof C=="number"?`${C}px`:C,border:`1px solid ${L}`,borderRadius:qt,overflow:"hidden",backgroundColor:ee,fontFamily:Re,textAlign:"left",boxShadow:"rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"});d.className="ago-chat-widget",Xt(d,D);let F;if(Y){if(F=h({padding:"14px 16px",borderBottom:`1px solid ${L}`,backgroundColor:Vt,color:pt,display:"flex",alignItems:"center",gap:"10px"}),F.className="ago-chat-widget__header",f){const t=document.createElement("img");t.src=f,t.alt="Logo",v(t,{height:"24px",width:"auto"}),F.appendChild(t)}const e=document.createElement("h3");if(e.textContent=i,v(e,{margin:"0",fontSize:"15px",fontWeight:"600"}),F.appendChild(e),z){const t=document.createElement("button");t.type="button",t.className="ago-chat-widget__close",t.setAttribute("aria-label","Close"),t.textContent="×",v(t,{marginLeft:"auto",background:"transparent",border:"none",color:pt,fontSize:"22px",lineHeight:"1",cursor:"pointer",padding:"0 2px"}),t.addEventListener("click",()=>Oe()),F.appendChild(t)}}const I=h({flex:"1",overflow:"auto",padding:"16px",backgroundColor:ht});I.className="ago-chat-widget__messages",I.setAttribute("role","log"),I.setAttribute("aria-live","polite"),I.setAttribute("aria-relevant","additions text"),I.setAttribute("aria-atomic","false");const{inputRow:Le,setDisabled:It,focus:xe}=Yt({placeholder:b,allowFiles:a,onSend:(e,t)=>{we(e,t)}});Qt(),d.append(...F?[F]:[],I,Le);let be=d,U,N;const ve=m==="left"?"left":"right";if(z&&(U=h({position:"fixed",top:"0",bottom:"0",[ve]:"0",width:typeof x=="number"?`${x}px`:x,maxWidth:"100vw",display:"flex",zIndex:"2147483000",transition:"transform 0.3s ease",boxShadow:"rgba(15, 15, 15, 0.18) 0px 0px 24px 0px"}),U.className="ago-chat-widget-panel",v(d,{height:"100%",width:"100%",borderRadius:"0",border:"none",boxShadow:"none",[ve==="left"?"borderRight":"borderLeft"]:`1px solid ${L}`}),U.appendChild(d),be=U),St){if(N=document.createElement("button"),N.type="button",N.className="ago-chat-widget-launcher",N.setAttribute("aria-label",`Open ${i}`),v(N,{position:"fixed",bottom:"20px",[ve]:"20px",width:"56px",height:"56px",borderRadius:"50%",border:"none",backgroundColor:Ae,color:_e,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",zIndex:"2147483000",boxShadow:"rgba(15, 15, 15, 0.2) 0px 4px 14px 0px",fontFamily:Re}),f){const e=document.createElement("img");e.src=f,e.alt="",v(e,{width:"26px",height:"26px",objectFit:"contain"}),N.appendChild(e)}else N.appendChild(sn());N.addEventListener("click",()=>Me())}const ce=re?`ago-vt-${++dn}`:"",je=52;let W=!1,pe=0,ie=0,H,fe,X;const ye={height:d.style.height,border:d.style.border,borderRadius:d.style.borderRadius,boxShadow:d.style.boxShadow};Ue.appendChild(be),N&&Ue.appendChild(N),Ce(),re&&(H=Pt(),d.insertBefore(H,d.firstChild),fe=document.createElement("style"),fe.id=ce,fe.textContent=`::view-transition-group(${ce}),::view-transition-group(${ce}-bar){animation-duration:0.3s;animation-timing-function:cubic-bezier(0.4,0,0.2,1)}`,document.head.appendChild(fe),kt==="focus"&&(d.addEventListener("pointerdown",e=>{W||!O?.matches||Le.contains(e.target)&&(e.preventDefault(),ue())},!0),d.addEventListener("focusin",e=>{O?.matches&&Le.contains(e.target)&&ue()})),document.addEventListener("keydown",tt)),O&&O.addEventListener("change",nt);const $t=y!==!1,Lt=y===!1?void 0:y??(e=>{re&&O?.matches&&!W?ue().then(()=>we(e)):we(e)});function $(){if(I.replaceChildren(),u.length===0){if(He==="static"){const t=h({textAlign:"center",color:xt,padding:"24px 16px",fontSize:"16px",lineHeight:"1.5"});t.appendChild(Ie(Fe)),I.appendChild(t)}}else u.forEach((t,l)=>{const S=l===u.length-1||u[l+1].role!==t.role;I.appendChild(on(t,{isLast:l===u.length-1,isLastOfBlock:S,bubbleStyle:_,showAgentName:A,agentBubble:R,followUpEnabled:$t,followUpHandler:Lt,isMobile:!!O?.matches}))});for(const t of Ge)I.appendChild(rn(t));if(de){const t=h({padding:"10px 14px",backgroundColor:"#fef2f2",color:"#dc2626",borderRadius:"12px",marginTop:"8px",fontSize:"13px",border:"1px solid #fecaca"});t.setAttribute("role","alert"),t.textContent=de,I.appendChild(t)}I.scrollTop=I.scrollHeight;const e=u[u.length-1];It(Z&&e?.role==="assistant"&&e.status==="IN_PROGRESS")}function Nt(){for(let e=u.length-1;e>=0;e--){const t=u[e];if(t.role==="assistant"&&t.status==="IN_PROGRESS")return t}}const Ve=e=>{P||(P=e.conversationId)},qe=e=>{const t=Nt();t&&(t.content+=e.content,$())},Ke=e=>{const t=u.findIndex(l=>l.id===e.id||l.role==="assistant"&&l.status==="IN_PROGRESS");t>=0?u[t]=e:u.push(e),$(),xe()},Xe=e=>{const t=u.findIndex(l=>l.id===e.id||l.role==="assistant"&&l.status==="IN_PROGRESS");t>=0?u[t]=e:u.push(e),Z=!1,$(),e.status==="DONE"&&k?.({id:e.id,content:e.content})},Qe=e=>{de=e.error,Z=!1,u=u.filter(t=>!t.id.startsWith("temp-")),$()};function Tt(e){const t={id:`ago-intro-${Date.now()}`,conversationId:"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date};u.push(t),$();const l=e.match(/\S+\s*/g)??[e];let S=0;K=setInterval(()=>{if(S>=l.length){clearInterval(K),K=void 0,t.status="DONE",Pe&&(t.followUpReplies=Pe),$();return}t.content+=l[S],S++,$()},Et)}E.on("message:start",Ve),E.on("message:chunk",qe),E.on("message:answer-complete",Ke),E.on("message:complete",Xe),E.on("message:error",Qe);const Ye=e=>j?.(e),Ze=e=>V?.(e);j&&E.on("form:submitted",Ye),V&&E.on("form:error",Ze);const Ne=[];let Je=!1;const et=e=>{if(Je)return;Ne.push(e.install(E));let t=e.store.get().submitted;const l=e.store.subscribe(S=>{S.submitted&&!t&&(Ge.push(_t(S.submitResult)),$()),t=S.submitted});Ne.push(l)};for(const e of s??[])e.schema!=null?et(dt.createFormCollector(e)):dt.loadFormCollector(E,e).then(t=>et(t)).catch(()=>{});async function we(e,t){const l=e.trim();if(!l&&!t?.length||Z)return;if(T?.(l),Z=!0,de=null,K){clearInterval(K),K=void 0;const w=u.find(G=>G.id.startsWith("ago-intro-"));w&&!w.content?u=u.filter(G=>G!==w):w&&(w.status="DONE")}const S=Date.now();u.push({id:`temp-user-${S}`,conversationId:P||"",content:l,role:"user",status:"DONE",attachments:t&&t.length>0?se.attachmentsFromFiles(t):void 0,createdAt:new Date}),u.push({id:`temp-assistant-${S}`,conversationId:P||"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date}),$();try{const w=await E.sendMessage(l,{conversationId:P,files:t});w.conversationId&&(P||(P=w.conversationId),ge?.setActiveThread(w.conversationId,w.createdAt));const G=u.find(Q=>Q.id===`temp-user-${S}`);if(G&&(G.id=`user-${S}`,G.conversationId=w.conversationId),!u.some(Q=>Q.id===w.id)){const Q=u.findIndex(Wt=>Wt.id===`temp-assistant-${S}`);Q>=0?u[Q]=w:u.push(w)}u=u.filter(Q=>!Q.id.startsWith("temp-")),Z=!1,$(),g&&Te()}catch(w){de=w instanceof Error?w.message:"Failed to send message",Z=!1,u=u.filter(G=>!G.id.startsWith("temp-")),$()}}async function Te(){try{const e=await E.getConversations();he.splice(0,he.length,...e)}catch{}return he}async function Mt(e){try{const t=(await E.getConversation(e))?.messages??[];t.length>0&&u.length===0&&(u=t,$())}catch{u.length===0&&(ge?.clear(),P=void 0)}}return $(),re&&O?.matches||xe(),P?Mt(P):He==="streaming"&&Tt(Fe),g&&Te(),{client:E,element:be,sendMessage:we,...z||re?{open:Bt,close:Dt,toggle:zt}:{},session:ge,threads:he,refreshThreads:Te,destroy(){K&&clearInterval(K),E.off("message:start",Ve),E.off("message:chunk",qe),E.off("message:answer-complete",Ke),E.off("message:complete",Xe),E.off("message:error",Qe),j&&E.off("form:submitted",Ye),V&&E.off("form:error",Ze),Je=!0,Ne.forEach(e=>e()),be.remove(),N?.remove(),H?.remove(),fe?.remove(),X?.remove(),O?.removeEventListener("change",nt),re&&(document.removeEventListener("keydown",tt),it(),document.documentElement.style.removeProperty("overflow")),o.client||E.destroy()}};function Ce(){if(!U)return;{const t=ve==="left"?"border-right":"border-left";O?.matches?(U.style.width="100%",d.style.borderRadius="0",d.style.removeProperty(t)):(U.style.width=typeof x=="number"?`${x}px`:x,d.style.setProperty(t,`1px solid ${L}`))}const e=m==="left"?"translateX(-100%)":"translateX(100%)";U.style.transform=oe?"translateX(0)":e,U.setAttribute("aria-hidden",oe?"false":"true"),N&&(N.style.display=oe?"none":"flex")}function Me(){oe=!0,Ce(),xe(),M?.()}function Oe(){oe=!1,Ce(),q?.()}function Ot(){oe?Oe():Me()}function Bt(){z?Me():ue()}function Dt(){z?Oe():me()}function zt(){z?Ot():W?me():ue()}function Ft(){return Array.from(d.querySelectorAll('a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])')).filter(e=>e.getClientRects().length>0)}function tt(e){if(!W)return;if(e.key==="Escape"){me();return}if(e.key!=="Tab")return;const t=Ft();if(t.length===0){e.preventDefault();return}const l=t[0],S=t[t.length-1],w=document.activeElement;e.shiftKey&&(w===l||!d.contains(w))?(e.preventDefault(),S.focus()):!e.shiftKey&&(w===S||!d.contains(w))&&(e.preventDefault(),l.focus())}function nt(e){z?Ce():!e.matches&&W&&me(),$()}function ot(){return window.visualViewport?.height??window.innerHeight}function rt(){const e=window.visualViewport,t=e?.offsetTop??0,l=e?.height??pe,S=Math.min(0,t+l-pe);d.style.top=`${S}px`,H&&(H.style.top=`${t}px`)}function Ee(){ie||(ie=requestAnimationFrame(()=>{ie=0,rt()}))}function Ht(){window.visualViewport?.addEventListener("resize",Ee),window.visualViewport?.addEventListener("scroll",Ee)}function it(){window.visualViewport?.removeEventListener("resize",Ee),window.visualViewport?.removeEventListener("scroll",Ee),ie&&(cancelAnimationFrame(ie),ie=0)}function at(){I.scrollTop=I.scrollHeight}function Pt(){const e=h({position:"fixed",top:"0",left:"0",right:"0",height:`calc(${je}px + env(safe-area-inset-top))`,display:"none",alignItems:"center",justifyContent:"space-between",padding:"env(safe-area-inset-top) 14px 0",backgroundColor:ee,borderBottom:`1px solid ${L}`,zIndex:"2147483001",fontFamily:Re});if(e.className="ago-chat-widget-mobile-bar",f){const l=document.createElement("img");l.src=f,l.alt="",v(l,{height:"28px",width:"auto"}),e.appendChild(l)}else if(i){const l=document.createElement("span");l.textContent=i,v(l,{fontSize:"15px",fontWeight:"600",color:J,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"}),e.appendChild(l)}else e.appendChild(h({}));const t=document.createElement("button");return t.type="button",t.setAttribute("aria-label","Close"),t.textContent="×",v(t,{border:"none",background:"transparent",fontSize:"26px",lineHeight:"1",color:J,cursor:"pointer",padding:"4px 8px"}),t.addEventListener("click",()=>{me()}),e.appendChild(t),e}function Ut(){return typeof document.startViewTransition=="function"&&!At?.matches&&!!O?.matches}function st(e){const t=document;if(Ut()&&t.startViewTransition){d.style.setProperty("view-transition-name",ce),H?.style.setProperty("view-transition-name",`${ce}-bar`);const l=()=>{d.style.removeProperty("view-transition-name"),H?.style.removeProperty("view-transition-name")};return t.startViewTransition(e).finished.then(l,l)}return e(),Promise.resolve()}function lt(e){if(e)X&&d.parentElement?.insertBefore(X,d),v(d,{position:"fixed",top:"0",left:"0",right:"0",bottom:"0",height:"var(--ago-vh, 100dvh)",zIndex:"2147483000",border:"none",borderRadius:"0",boxShadow:"none",paddingTop:`calc(${je}px + env(safe-area-inset-top))`,paddingBottom:"env(safe-area-inset-bottom)"}),d.setAttribute("role","dialog"),d.setAttribute("aria-modal","true"),d.setAttribute("aria-label",i),document.documentElement.style.overflow="hidden",F&&(F.style.display="none"),H&&(H.style.display="flex");else{X?.remove(),X=void 0;for(const t of["position","top","left","right","bottom","z-index","padding-top","padding-bottom"])d.style.removeProperty(t);d.style.height=ye.height,d.style.border=ye.border,d.style.borderRadius=ye.borderRadius,d.style.boxShadow=ye.boxShadow,d.removeAttribute("role"),d.removeAttribute("aria-modal"),d.removeAttribute("aria-label"),document.documentElement.style.removeProperty("overflow"),F&&(F.style.display="flex"),H&&(H.style.display="none")}}function ue(){if(W||!O?.matches)return Promise.resolve();const e=d.getBoundingClientRect();if(e.height>=ot()*.8)return Promise.resolve();W=!0,X=h({width:`${e.width}px`,height:`${e.height}px`}),X.className="ago-chat-widget-spacer",X.setAttribute("aria-hidden","true"),pe=ot(),d.style.setProperty("--ago-vh",`${pe}px`),rt(),Ht();const t=st(()=>lt(!0));return t.then(()=>{at(),xe()}),at(),M?.(),t}function me(){if(!W)return Promise.resolve();W=!1,it(),d.querySelector("textarea")?.blur();const e=st(()=>lt(!1));return e.then(()=>d.style.removeProperty("--ago-vh")),pe=0,q?.(),e}}exports.mountChatWidget=pn;exports.renderMarkdown=Ie;
package/dist/widget.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { a as Ut, i as Wt, m as Gt, o as Vt, s as jt, t as qt } from "./AgoClient-Cwx_eYSu.js";
2
2
  import { r as Kt, t as Xt } from "./createFormCollector-CyWisAkI.js";
3
3
  import { t as Qt } from "./createConversationSession-B3h567tt.js";
4
- var Yt = '"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif', Ee = `var(--ago-font, ${Yt})`, lt = {
4
+ var Yt = '"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif', Se = `var(--ago-font, ${Yt})`, lt = {
5
5
  font: "--ago-font",
6
6
  radius: "--ago-radius",
7
7
  messageRadius: "--ago-message-radius",
@@ -16,7 +16,7 @@ var Yt = '"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto
16
16
  border: "--ago-border-color",
17
17
  accent: "--ago-accent-color",
18
18
  agentBubbleBg: "--ago-agent-bubble-background"
19
- }, Re = "var(--ago-brand-color, #03182f)", ke = "var(--ago-brand-text-color, #fff)", Zt = "var(--ago-header-background, var(--ago-brand-color, #03182f))", dt = "var(--ago-header-text-color, #e8f0fe)", ee = "var(--ago-panel-background, #fff)", mt = "var(--ago-messages-background, #fbfbfb)", J = "var(--ago-text-color, #30373e)", gt = "var(--ago-muted-text-color, #6b6d6f)", L = "var(--ago-border-color, #dee3e8)", Be = "var(--ago-accent-color, #1b5fc4)", ct = "var(--ago-agent-bubble-background, #f1f3f5)", Jt = "var(--ago-radius, 16px)", Me = "var(--ago-message-radius, 16px)", en = "var(--ago-message-radius, 20px)";
19
+ }, ke = "var(--ago-brand-color, #03182f)", Ae = "var(--ago-brand-text-color, #fff)", Zt = "var(--ago-header-background, var(--ago-brand-color, #03182f))", dt = "var(--ago-header-text-color, #e8f0fe)", ee = "var(--ago-panel-background, #fff)", mt = "var(--ago-messages-background, #fbfbfb)", J = "var(--ago-text-color, #30373e)", gt = "var(--ago-muted-text-color, #6b6d6f)", L = "var(--ago-border-color, #dee3e8)", Be = "var(--ago-accent-color, #1b5fc4)", ct = "var(--ago-agent-bubble-background, #f1f3f5)", Jt = "var(--ago-radius, 16px)", Me = "var(--ago-message-radius, 16px)", en = "var(--ago-message-radius, 20px)";
20
20
  function tn(n, o) {
21
21
  if (o)
22
22
  for (const i of Object.keys(lt)) {
@@ -65,7 +65,7 @@ function on(n) {
65
65
  border: `1px solid ${L}`,
66
66
  borderRadius: "12px",
67
67
  fontSize: "16px",
68
- fontFamily: Ee,
68
+ fontFamily: Se,
69
69
  lineHeight: "1.4",
70
70
  maxHeight: "110px",
71
71
  overflowY: "hidden"
@@ -86,8 +86,8 @@ function on(n) {
86
86
  padding: "0",
87
87
  border: "none",
88
88
  borderRadius: "50%",
89
- backgroundColor: Re,
90
- color: ke,
89
+ backgroundColor: ke,
90
+ color: Ae,
91
91
  display: "flex",
92
92
  alignItems: "center",
93
93
  justifyContent: "center",
@@ -130,18 +130,18 @@ function on(n) {
130
130
  fontSize: "14px",
131
131
  lineHeight: "1"
132
132
  }), k.addEventListener("click", () => {
133
- o = o.filter((G, V) => V !== c), Y();
133
+ o = o.filter((V, j) => j !== c), Y();
134
134
  }), y.append(T, k), r.appendChild(y);
135
135
  }), A();
136
136
  }
137
- const O = () => {
137
+ const D = () => {
138
138
  const s = a.value, c = o;
139
139
  return a.value = "", C(), o = [], Y(), {
140
140
  content: s,
141
141
  files: c
142
142
  };
143
143
  }, g = () => {
144
- const { content: s, files: c } = O();
144
+ const { content: s, files: c } = D();
145
145
  (s.trim() || c.length > 0) && n.onSend(s.trim(), c.length > 0 ? c : void 0);
146
146
  };
147
147
  return i.addEventListener("submit", (s) => {
@@ -150,7 +150,7 @@ function on(n) {
150
150
  s.key === "Enter" && !s.shiftKey && (s.preventDefault(), g());
151
151
  }), _ && b.appendChild(_), b.append(a, p), R && i.appendChild(R), i.append(r, b), A(), {
152
152
  inputRow: i,
153
- getValueAndClear: O,
153
+ getValueAndClear: D,
154
154
  setDisabled: (s) => {
155
155
  a.disabled = s, f = s, A();
156
156
  },
@@ -164,30 +164,30 @@ var rn = {
164
164
  '"': "&quot;",
165
165
  "'": "&#39;"
166
166
  };
167
- function ie(n) {
167
+ function ae(n) {
168
168
  return n.replace(/[&<>"']/g, (o) => rn[o]);
169
169
  }
170
170
  function ft(n) {
171
171
  const o = n.trim();
172
172
  return /^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i.test(o) || !/^[a-z][a-z0-9+.-]*:/i.test(o) ? o : null;
173
173
  }
174
- var ht = '"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace', Ce = "";
174
+ var ht = '"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace', Ee = "";
175
175
  function te(n) {
176
- const o = [], i = (b) => (o.push(b), `${Ce}${o.length - 1}${Ce}`);
176
+ const o = [], i = (b) => (o.push(b), `${Ee}${o.length - 1}${Ee}`);
177
177
  let r = n;
178
- return r = r.replace(/`([^`]+)`/g, (b, a) => i(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${ht}">${ie(a)}</code>`)), r = r.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g, (b, a, C) => {
178
+ return r = r.replace(/`([^`]+)`/g, (b, a) => i(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${ht}">${ae(a)}</code>`)), r = r.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g, (b, a, C) => {
179
179
  const m = ft(C);
180
- return m ? i(`<img alt="${ie(a)}" src="${ie(m)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`) : b;
180
+ return m ? i(`<img alt="${ae(a)}" src="${ae(m)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`) : b;
181
181
  }), r = r.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, (b, a, C) => {
182
182
  const m = ft(C);
183
- return m ? i(`<a href="${ie(m)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${te(a)}</a>`) : b;
184
- }), r = ie(r), r = r.replace(/\*\*([^*]+?)\*\*/g, "<strong>$1</strong>").replace(/__([^_]+?)__/g, "<strong>$1</strong>").replace(/~~([^~]+?)~~/g, "<del>$1</del>").replace(/(^|[^*])\*(?!\s)([^*]+?)\*/g, "$1<em>$2</em>").replace(/(^|[^\w_])_(?!\s)([^_]+?)_/g, "$1<em>$2</em>"), r = r.replace(new RegExp(`${Ce}(\\d+)${Ce}`, "g"), (b, a) => o[Number(a)]), r;
183
+ return m ? i(`<a href="${ae(m)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${te(a)}</a>`) : b;
184
+ }), r = ae(r), r = r.replace(/\*\*([^*]+?)\*\*/g, "<strong>$1</strong>").replace(/__([^_]+?)__/g, "<strong>$1</strong>").replace(/~~([^~]+?)~~/g, "<del>$1</del>").replace(/(^|[^*])\*(?!\s)([^*]+?)\*/g, "$1<em>$2</em>").replace(/(^|[^\w_])_(?!\s)([^_]+?)_/g, "$1<em>$2</em>"), r = r.replace(new RegExp(`${Ee}(\\d+)${Ee}`, "g"), (b, a) => o[Number(a)]), r;
185
185
  }
186
- function M(n, o, i) {
186
+ function O(n, o, i) {
187
187
  const r = document.createElement(n);
188
188
  return Object.assign(r.style, o), i !== void 0 && (r.innerHTML = i), r;
189
189
  }
190
- var xt = /^ {0,3}([-*_])( *\1){2,} *$/, bt = /^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/, vt = /^ {0,3}(```+|~~~+)/, Se = /^ {0,3}>\s?/, ae = /^(\s*)([-*+]|\d+[.)])\s+(.*)$/, an = [
190
+ var xt = /^ {0,3}([-*_])( *\1){2,} *$/, bt = /^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/, vt = /^ {0,3}(```+|~~~+)/, Re = /^ {0,3}>\s?/, se = /^(\s*)([-*+]|\d+[.)])\s+(.*)$/, an = [
191
191
  "20px",
192
192
  "18px",
193
193
  "16px",
@@ -196,10 +196,10 @@ var xt = /^ {0,3}([-*_])( *\1){2,} *$/, bt = /^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/,
196
196
  "13px"
197
197
  ], Oe = (n) => n.match(/^\s*/)?.[0].length ?? 0;
198
198
  function sn(n) {
199
- return n.trim() === "" || xt.test(n) || bt.test(n) || vt.test(n) || Se.test(n) || ae.test(n);
199
+ return n.trim() === "" || xt.test(n) || bt.test(n) || vt.test(n) || Re.test(n) || se.test(n);
200
200
  }
201
201
  function yt(n) {
202
- const o = n[0].match(ae), i = o[1].length, r = /\d/.test(o[2]), b = M(r ? "ol" : "ul", {
202
+ const o = n[0].match(se), i = o[1].length, r = /\d/.test(o[2]), b = O(r ? "ol" : "ul", {
203
203
  margin: "0 0 8px 0",
204
204
  paddingLeft: "20px",
205
205
  listStyleType: r ? "decimal" : "disc",
@@ -207,28 +207,28 @@ function yt(n) {
207
207
  });
208
208
  let a = 0;
209
209
  for (; a < n.length; ) {
210
- const C = n[a].match(ae), m = [];
210
+ const C = n[a].match(se), m = [];
211
211
  for (a++; a < n.length && Oe(n[a]) > i; )
212
212
  m.push(n[a]), a++;
213
- const x = M("li", {
213
+ const x = O("li", {
214
214
  display: "list-item",
215
215
  margin: "2px 0",
216
216
  lineHeight: "1.6"
217
217
  }), p = C[3].match(/^\[([ xX])\]\s+(.*)$/);
218
- p ? (x.style.listStyleType = "none", x.style.marginLeft = "-20px", x.innerHTML = `<span style="margin-right:6px">${p[1].toLowerCase() === "x" ? "☑" : "☐"}</span>${te(p[2])}`) : x.innerHTML = te(C[3]), m.filter((f) => ae.test(f)).length > 0 && x.appendChild(yt(m.filter((f) => f.trim() !== ""))), b.appendChild(x);
218
+ p ? (x.style.listStyleType = "none", x.style.marginLeft = "-20px", x.innerHTML = `<span style="margin-right:6px">${p[1].toLowerCase() === "x" ? "☑" : "☐"}</span>${te(p[2])}`) : x.innerHTML = te(C[3]), m.filter((f) => se.test(f)).length > 0 && x.appendChild(yt(m.filter((f) => f.trim() !== ""))), b.appendChild(x);
219
219
  }
220
220
  return b;
221
221
  }
222
222
  function ln(n) {
223
- const o = (m) => m.replace(/^\s*\|?/, "").replace(/\|?\s*$/, "").split("|").map((x) => x.trim()), i = M("div", {
223
+ const o = (m) => m.replace(/^\s*\|?/, "").replace(/\|?\s*$/, "").split("|").map((x) => x.trim()), i = O("div", {
224
224
  overflowX: "auto",
225
225
  margin: "0 0 8px 0"
226
- }), r = M("table", {
226
+ }), r = O("table", {
227
227
  borderCollapse: "collapse",
228
228
  width: "100%",
229
229
  fontSize: "13px"
230
230
  }), b = document.createElement("thead"), a = document.createElement("tr");
231
- for (const m of o(n[0])) a.appendChild(M("th", {
231
+ for (const m of o(n[0])) a.appendChild(O("th", {
232
232
  border: "1px solid #dee3e8",
233
233
  padding: "6px 10px",
234
234
  textAlign: "left",
@@ -239,7 +239,7 @@ function ln(n) {
239
239
  const C = document.createElement("tbody");
240
240
  for (const m of n.slice(2)) {
241
241
  const x = document.createElement("tr");
242
- for (const p of o(m)) x.appendChild(M("td", {
242
+ for (const p of o(m)) x.appendChild(O("td", {
243
243
  border: "1px solid #dee3e8",
244
244
  padding: "6px 10px"
245
245
  }, te(p)));
@@ -265,8 +265,8 @@ function De(n) {
265
265
  for (r++; r < i.length && !new RegExp(`^ {0,3}${p === "`" ? "`{3,}" : "~{3,}"}\\s*$`).test(i[r]); )
266
266
  f.push(i[r]), r++;
267
267
  r++;
268
- const A = M("pre", { margin: "0 0 8px 0" });
269
- A.appendChild(M("code", {
268
+ const A = O("pre", { margin: "0 0 8px 0" });
269
+ A.appendChild(O("code", {
270
270
  display: "block",
271
271
  background: "#f5f5f5",
272
272
  padding: "8px 12px",
@@ -275,12 +275,12 @@ function De(n) {
275
275
  overflowX: "auto",
276
276
  fontFamily: ht,
277
277
  whiteSpace: "pre"
278
- }, ie(f.join(`
278
+ }, ae(f.join(`
279
279
  `)))), o.appendChild(A);
280
280
  continue;
281
281
  }
282
282
  if (xt.test(a)) {
283
- o.appendChild(M("hr", {
283
+ o.appendChild(O("hr", {
284
284
  border: "none",
285
285
  borderTop: "1px solid #dee3e8",
286
286
  margin: "12px 0"
@@ -290,7 +290,7 @@ function De(n) {
290
290
  const m = a.match(bt);
291
291
  if (m) {
292
292
  const p = m[1].length;
293
- o.appendChild(M(`h${p}`, {
293
+ o.appendChild(O(`h${p}`, {
294
294
  margin: "16px 0 8px 0",
295
295
  fontSize: an[p - 1],
296
296
  fontWeight: "600",
@@ -298,11 +298,11 @@ function De(n) {
298
298
  }, te(m[2]))), r++;
299
299
  continue;
300
300
  }
301
- if (Se.test(a)) {
301
+ if (Re.test(a)) {
302
302
  const p = [];
303
- for (; r < i.length && Se.test(i[r]); )
304
- p.push(i[r].replace(Se, "")), r++;
305
- const f = M("blockquote", {
303
+ for (; r < i.length && Re.test(i[r]); )
304
+ p.push(i[r].replace(Re, "")), r++;
305
+ const f = O("blockquote", {
306
306
  borderLeft: "4px solid #dee3e8",
307
307
  paddingLeft: "12px",
308
308
  margin: "0 0 8px 0",
@@ -320,10 +320,10 @@ function De(n) {
320
320
  o.appendChild(ln(p));
321
321
  continue;
322
322
  }
323
- if (ae.test(a)) {
323
+ if (se.test(a)) {
324
324
  const p = [], f = Oe(a);
325
325
  for (; r < i.length && i[r].trim() !== ""; )
326
- if (ae.test(i[r]) || Oe(i[r]) > f)
326
+ if (se.test(i[r]) || Oe(i[r]) > f)
327
327
  p.push(i[r]), r++;
328
328
  else break;
329
329
  o.appendChild(yt(p));
@@ -332,7 +332,7 @@ function De(n) {
332
332
  const x = [a];
333
333
  for (r++; r < i.length && !sn(i[r]); )
334
334
  x.push(i[r]), r++;
335
- o.appendChild(M("p", {
335
+ o.appendChild(O("p", {
336
336
  margin: "0 0 8px 0",
337
337
  lineHeight: "1.6"
338
338
  }, x.map((p) => te(p)).join("<br>")));
@@ -422,15 +422,15 @@ function cn(n, o) {
422
422
  display: "inline-block",
423
423
  textDecoration: "none"
424
424
  });
425
- const j = document.createElement("img");
426
- j.src = c, j.alt = s.name, j.loading = "lazy", v(j, {
425
+ const q = document.createElement("img");
426
+ q.src = c, q.alt = s.name, q.loading = "lazy", v(q, {
427
427
  maxWidth: "180px",
428
428
  maxHeight: "160px",
429
429
  objectFit: "cover",
430
430
  borderRadius: "10px",
431
431
  border: `1px solid ${L}`,
432
432
  display: "block"
433
- }), B.appendChild(j), g.appendChild(B);
433
+ }), B.appendChild(q), g.appendChild(B);
434
434
  continue;
435
435
  }
436
436
  const y = c ? document.createElement("a") : document.createElement("div");
@@ -442,7 +442,7 @@ function cn(n, o) {
442
442
  borderRadius: "10px",
443
443
  border: `1px solid ${L}`,
444
444
  backgroundColor: f ? "rgba(255,255,255,0.12)" : ee,
445
- color: f ? ke : J,
445
+ color: f ? Ae : J,
446
446
  fontSize: "13px",
447
447
  textDecoration: "none",
448
448
  maxWidth: "220px"
@@ -457,45 +457,45 @@ function cn(n, o) {
457
457
  display: "flex",
458
458
  flexDirection: "column",
459
459
  minWidth: "0"
460
- }), G = h({
460
+ }), V = h({
461
461
  overflow: "hidden",
462
462
  textOverflow: "ellipsis",
463
463
  whiteSpace: "nowrap",
464
464
  maxWidth: "160px"
465
465
  });
466
- G.textContent = s.name, G.title = s.name, k.appendChild(G);
467
- const V = Vt(s.fileSize);
468
- if (V) {
466
+ V.textContent = s.name, V.title = s.name, k.appendChild(V);
467
+ const j = Vt(s.fileSize);
468
+ if (j) {
469
469
  const B = h({
470
470
  fontSize: "11px",
471
471
  color: gt
472
472
  });
473
- B.textContent = V, k.appendChild(B);
473
+ B.textContent = j, k.appendChild(B);
474
474
  }
475
475
  y.append(T, k), g.appendChild(y);
476
476
  }
477
477
  R.appendChild(g);
478
478
  }
479
- const _ = f || C || A, Y = !!n.content || n.status === "IN_PROGRESS", O = h({
479
+ const _ = f || C || A, Y = !!n.content || n.status === "IN_PROGRESS", D = h({
480
480
  maxWidth: _ ? A || f ? p ? "88%" : "75%" : p ? "92%" : "85%" : "100%",
481
481
  padding: _ ? "10px 14px" : "2px 8px",
482
482
  borderRadius: A ? en : _ ? Me : "0",
483
- backgroundColor: f ? Re : _ ? ct : "transparent",
484
- color: f ? ke : J,
483
+ backgroundColor: f ? ke : _ ? ct : "transparent",
484
+ color: f ? Ae : J,
485
485
  overflowWrap: "break-word",
486
486
  textWrap: "pretty",
487
487
  fontSize: "16px",
488
488
  lineHeight: "1.6"
489
489
  });
490
- if (O.className = "ago-message__content", A && r) {
491
- O.style.position = "relative";
490
+ if (D.className = "ago-message__content", A && r) {
491
+ D.style.position = "relative";
492
492
  const g = h({
493
493
  position: "absolute",
494
494
  zIndex: "0",
495
495
  bottom: "-2px",
496
496
  width: "20px",
497
497
  height: "20px",
498
- background: f ? Re : ct
498
+ background: f ? ke : ct
499
499
  });
500
500
  g.className = "ago-message__tail";
501
501
  const s = h({
@@ -506,9 +506,9 @@ function cn(n, o) {
506
506
  height: "20px",
507
507
  background: mt
508
508
  });
509
- s.className = "ago-message__tail-mask", f ? (g.style.right = "-8px", g.style.borderBottomLeftRadius = "16px 14px", s.style.right = "-10px", s.style.borderBottomLeftRadius = "10px") : (g.style.left = "-7px", g.style.borderBottomRightRadius = "16px 14px", s.style.left = "-10px", s.style.borderBottomRightRadius = "10px"), O.append(g, s);
509
+ s.className = "ago-message__tail-mask", f ? (g.style.right = "-8px", g.style.borderBottomLeftRadius = "16px 14px", s.style.right = "-10px", s.style.borderBottomLeftRadius = "10px") : (g.style.left = "-7px", g.style.borderBottomRightRadius = "16px 14px", s.style.left = "-10px", s.style.borderBottomRightRadius = "10px"), D.append(g, s);
510
510
  }
511
- if (n.content ? O.appendChild(De(n.content)) : n.status === "IN_PROGRESS" && O.appendChild(fn()), Y && R.appendChild(O), i && n.followUpReplies && n.followUpReplies.length > 0) {
511
+ if (n.content ? D.appendChild(De(n.content)) : n.status === "IN_PROGRESS" && D.appendChild(fn()), Y && R.appendChild(D), i && n.followUpReplies && n.followUpReplies.length > 0) {
512
512
  const g = h({
513
513
  display: "flex",
514
514
  flexWrap: "wrap",
@@ -602,16 +602,16 @@ function hn(n) {
602
602
  if (!o) throw new Error(`mountChatWidget: target "${String(n)}" not found.`);
603
603
  return o;
604
604
  }
605
- function yn(n, o) {
606
- const { title: i = "Chat", welcomeMessage: r = "Hello! How can I help you today?", placeholder: b = "Type a message...", allowFiles: a = !1, height: C = 500, placement: m = "inline", width: x = 400, defaultOpen: p = !1, logoUrl: f, showAgentName: A = !1, agentBubble: R = !1, bubbleStyle: _ = "default", showHeader: Y = !0, theme: O, loadThreads: g = !1, forms: s, formSubmittedMessage: c = ut, onFollowUpClick: y, onMessageSent: T, onMessageReceived: k, onFormSubmitted: G, onFormError: V, onOpen: B, onClose: j } = o, ne = typeof r == "string" ? {
605
+ function wn(n, o) {
606
+ const { title: i = "Chat", welcomeMessage: r = "Hello! How can I help you today?", placeholder: b = "Type a message...", allowFiles: a = !1, height: C = 500, placement: m = "inline", width: x = 400, defaultOpen: p = !1, logoUrl: f, showAgentName: A = !1, agentBubble: R = !1, bubbleStyle: _ = "default", showHeader: Y = !0, theme: D, loadThreads: g = !1, forms: s, formSubmittedMessage: c = ut, onFollowUpClick: y, onMessageSent: T, onMessageReceived: k, onFormSubmitted: V, onFormError: j, onOpen: B, onClose: q } = o, ne = typeof r == "string" ? {
607
607
  message: r,
608
608
  mode: "static"
609
609
  } : r, ze = ne.message, Fe = ne.mode ?? "static", wt = "speed" in ne && ne.speed || 45, He = "followUpReplies" in ne && ne.followUpReplies || void 0;
610
610
  if (!o.client && !o.config?.baseUrl) throw new Gt("mountChatWidget requires either `client` or `config` (with a baseUrl).", "config_missing_base_url");
611
- const E = o.client ?? new qt(o.config), Pe = hn(n), D = m === "left" || m === "right", Ct = D && (o.launcher ?? !0);
612
- let oe = D ? p : !0;
613
- const Et = o.mobile?.breakpoint ?? 768, St = o.mobile?.trigger ?? "focus", Ue = typeof window < "u" && !!window.matchMedia, z = Ue ? window.matchMedia(`(max-width: ${Et}px)`) : void 0, Rt = Ue ? window.matchMedia("(prefers-reduced-motion: reduce)") : void 0, se = !D && !!z, Ae = o.persistConversation, ue = Ae ? Qt(Ae === !0 ? {} : Ae) : void 0;
614
- let P = o.conversationId ?? ue?.getLastActiveThread() ?? void 0, u = [], Z = !1, le = null, q;
611
+ const E = o.client ?? new qt(o.config), Pe = hn(n), z = m === "left" || m === "right", Ct = z && (o.launcher ?? !0);
612
+ let oe = z ? p : !0;
613
+ const Et = o.mobile?.breakpoint ?? 768, St = o.mobile?.trigger ?? "focus", Ue = typeof window < "u" && !!window.matchMedia, M = Ue ? window.matchMedia(`(max-width: ${Et}px)`) : void 0, Rt = Ue ? window.matchMedia("(prefers-reduced-motion: reduce)") : void 0, re = !z && !!M, _e = o.persistConversation, me = _e ? Qt(_e === !0 ? {} : _e) : void 0;
614
+ let P = o.conversationId ?? me?.getLastActiveThread() ?? void 0, u = [], Z = !1, le = null, K;
615
615
  const We = [];
616
616
  function kt(e) {
617
617
  if (typeof c == "function") {
@@ -621,19 +621,19 @@ function yn(n, o) {
621
621
  const t = mn(e);
622
622
  return t || (typeof c == "string" ? c : ut);
623
623
  }
624
- const me = [], d = h({
624
+ const ge = [], d = h({
625
625
  display: "flex",
626
626
  flexDirection: "column",
627
- height: D ? "100%" : typeof C == "number" ? `${C}px` : C,
627
+ height: z ? "100%" : typeof C == "number" ? `${C}px` : C,
628
628
  border: `1px solid ${L}`,
629
629
  borderRadius: Jt,
630
630
  overflow: "hidden",
631
631
  backgroundColor: ee,
632
- fontFamily: Ee,
632
+ fontFamily: Se,
633
633
  textAlign: "left",
634
634
  boxShadow: "rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"
635
635
  });
636
- d.className = "ago-chat-widget", tn(d, O);
636
+ d.className = "ago-chat-widget", tn(d, D);
637
637
  let F;
638
638
  if (Y) {
639
639
  if (F = h({
@@ -656,7 +656,7 @@ function yn(n, o) {
656
656
  margin: "0",
657
657
  fontSize: "15px",
658
658
  fontWeight: "600"
659
- }), F.appendChild(e), D) {
659
+ }), F.appendChild(e), z) {
660
660
  const t = document.createElement("button");
661
661
  t.type = "button", t.className = "ago-chat-widget__close", t.setAttribute("aria-label", "Close"), t.textContent = "×", v(t, {
662
662
  marginLeft: "auto",
@@ -677,21 +677,21 @@ function yn(n, o) {
677
677
  backgroundColor: mt
678
678
  });
679
679
  I.className = "ago-chat-widget__messages", I.setAttribute("role", "log"), I.setAttribute("aria-live", "polite"), I.setAttribute("aria-relevant", "additions text"), I.setAttribute("aria-atomic", "false");
680
- const { inputRow: _e, setDisabled: At, focus: ge } = on({
680
+ const { inputRow: Ie, setDisabled: At, focus: he } = on({
681
681
  placeholder: b,
682
682
  allowFiles: a,
683
683
  onSend: (e, t) => {
684
- $e(e, t);
684
+ ye(e, t);
685
685
  }
686
686
  });
687
- nn(), d.append(...F ? [F] : [], I, _e);
688
- let he = d, U, N;
689
- const xe = m === "left" ? "left" : "right";
690
- if (D && (U = h({
687
+ nn(), d.append(...F ? [F] : [], I, Ie);
688
+ let xe = d, U, N;
689
+ const be = m === "left" ? "left" : "right";
690
+ if (z && (U = h({
691
691
  position: "fixed",
692
692
  top: "0",
693
693
  bottom: "0",
694
- [xe]: "0",
694
+ [be]: "0",
695
695
  width: typeof x == "number" ? `${x}px` : x,
696
696
  maxWidth: "100vw",
697
697
  display: "flex",
@@ -704,25 +704,25 @@ function yn(n, o) {
704
704
  borderRadius: "0",
705
705
  border: "none",
706
706
  boxShadow: "none",
707
- [xe === "left" ? "borderRight" : "borderLeft"]: `1px solid ${L}`
708
- }), U.appendChild(d), he = U), Ct) {
707
+ [be === "left" ? "borderRight" : "borderLeft"]: `1px solid ${L}`
708
+ }), U.appendChild(d), xe = U), Ct) {
709
709
  if (N = document.createElement("button"), N.type = "button", N.className = "ago-chat-widget-launcher", N.setAttribute("aria-label", `Open ${i}`), v(N, {
710
710
  position: "fixed",
711
711
  bottom: "20px",
712
- [xe]: "20px",
712
+ [be]: "20px",
713
713
  width: "56px",
714
714
  height: "56px",
715
715
  borderRadius: "50%",
716
716
  border: "none",
717
- backgroundColor: Re,
718
- color: ke,
717
+ backgroundColor: ke,
718
+ color: Ae,
719
719
  cursor: "pointer",
720
720
  display: "flex",
721
721
  alignItems: "center",
722
722
  justifyContent: "center",
723
723
  zIndex: "2147483000",
724
724
  boxShadow: "rgba(15, 15, 15, 0.2) 0px 4px 14px 0px",
725
- fontFamily: Ee
725
+ fontFamily: Se
726
726
  }), f) {
727
727
  const e = document.createElement("img");
728
728
  e.src = f, e.alt = "", v(e, {
@@ -733,21 +733,21 @@ function yn(n, o) {
733
733
  } else N.appendChild(un());
734
734
  N.addEventListener("click", () => Ne());
735
735
  }
736
- const de = se ? `ago-vt-${++gn}` : "", Ge = 52;
737
- let K = !1, ce = 0, re = 0, H, pe, X;
738
- const be = {
736
+ const de = re ? `ago-vt-${++gn}` : "", Ge = 52;
737
+ let W = !1, ce = 0, ie = 0, H, pe, X;
738
+ const ve = {
739
739
  height: d.style.height,
740
740
  border: d.style.border,
741
741
  borderRadius: d.style.borderRadius,
742
742
  boxShadow: d.style.boxShadow
743
743
  };
744
- Pe.appendChild(he), N && Pe.appendChild(N), ve(), se && (H = Ft(), d.insertBefore(H, d.firstChild), pe = document.createElement("style"), pe.id = de, pe.textContent = `::view-transition-group(${de}),::view-transition-group(${de}-bar){animation-duration:0.3s;animation-timing-function:cubic-bezier(0.4,0,0.2,1)}`, document.head.appendChild(pe), St === "focus" && (d.addEventListener("pointerdown", (e) => {
745
- K || !z?.matches || _e.contains(e.target) && (e.preventDefault(), we());
744
+ Pe.appendChild(xe), N && Pe.appendChild(N), we(), re && (H = Ft(), d.insertBefore(H, d.firstChild), pe = document.createElement("style"), pe.id = de, pe.textContent = `::view-transition-group(${de}),::view-transition-group(${de}-bar){animation-duration:0.3s;animation-timing-function:cubic-bezier(0.4,0,0.2,1)}`, document.head.appendChild(pe), St === "focus" && (d.addEventListener("pointerdown", (e) => {
745
+ W || !M?.matches || Ie.contains(e.target) && (e.preventDefault(), fe());
746
746
  }, !0), d.addEventListener("focusin", (e) => {
747
- z?.matches && _e.contains(e.target) && we();
748
- })), document.addEventListener("keydown", et)), z && z.addEventListener("change", tt);
747
+ M?.matches && Ie.contains(e.target) && fe();
748
+ })), document.addEventListener("keydown", et)), M && M.addEventListener("change", tt);
749
749
  const _t = y !== !1, It = y === !1 ? void 0 : y ?? ((e) => {
750
- $e(e);
750
+ re && M?.matches && !W ? fe().then(() => ye(e)) : ye(e);
751
751
  });
752
752
  function $() {
753
753
  if (I.replaceChildren(), u.length === 0) {
@@ -771,7 +771,7 @@ function yn(n, o) {
771
771
  agentBubble: R,
772
772
  followUpEnabled: _t,
773
773
  followUpHandler: It,
774
- isMobile: !!z?.matches
774
+ isMobile: !!M?.matches
775
775
  }));
776
776
  });
777
777
  for (const t of We) I.appendChild(pn(t));
@@ -804,7 +804,7 @@ function yn(n, o) {
804
804
  t && (t.content += e.content, $());
805
805
  }, qe = (e) => {
806
806
  const t = u.findIndex((l) => l.id === e.id || l.role === "assistant" && l.status === "IN_PROGRESS");
807
- t >= 0 ? u[t] = e : u.push(e), $(), ge();
807
+ t >= 0 ? u[t] = e : u.push(e), $(), he();
808
808
  }, Ke = (e) => {
809
809
  const t = u.findIndex((l) => l.id === e.id || l.role === "assistant" && l.status === "IN_PROGRESS");
810
810
  t >= 0 ? u[t] = e : u.push(e), Z = !1, $(), e.status === "DONE" && k?.({
@@ -826,37 +826,37 @@ function yn(n, o) {
826
826
  u.push(t), $();
827
827
  const l = e.match(/\S+\s*/g) ?? [e];
828
828
  let S = 0;
829
- q = setInterval(() => {
829
+ K = setInterval(() => {
830
830
  if (S >= l.length) {
831
- clearInterval(q), q = void 0, t.status = "DONE", He && (t.followUpReplies = He), $();
831
+ clearInterval(K), K = void 0, t.status = "DONE", He && (t.followUpReplies = He), $();
832
832
  return;
833
833
  }
834
834
  t.content += l[S], S++, $();
835
835
  }, wt);
836
836
  }
837
837
  E.on("message:start", Ve), E.on("message:chunk", je), E.on("message:answer-complete", qe), E.on("message:complete", Ke), E.on("message:error", Xe);
838
- const Qe = (e) => G?.(e), Ye = (e) => V?.(e);
839
- G && E.on("form:submitted", Qe), V && E.on("form:error", Ye);
840
- const Ie = [];
838
+ const Qe = (e) => V?.(e), Ye = (e) => j?.(e);
839
+ V && E.on("form:submitted", Qe), j && E.on("form:error", Ye);
840
+ const $e = [];
841
841
  let Ze = !1;
842
842
  const Je = (e) => {
843
843
  if (Ze) return;
844
- Ie.push(e.install(E));
844
+ $e.push(e.install(E));
845
845
  let t = e.store.get().submitted;
846
846
  const l = e.store.subscribe((S) => {
847
847
  S.submitted && !t && (We.push(kt(S.submitResult)), $()), t = S.submitted;
848
848
  });
849
- Ie.push(l);
849
+ $e.push(l);
850
850
  };
851
851
  for (const e of s ?? []) e.schema != null ? Je(Xt(e)) : Kt(E, e).then((t) => Je(t)).catch(() => {
852
852
  });
853
- async function $e(e, t) {
853
+ async function ye(e, t) {
854
854
  const l = e.trim();
855
855
  if (!l && !t?.length || Z) return;
856
- if (T?.(l), Z = !0, le = null, q) {
857
- clearInterval(q), q = void 0;
858
- const w = u.find((W) => W.id.startsWith("ago-intro-"));
859
- w && !w.content ? u = u.filter((W) => W !== w) : w && (w.status = "DONE");
856
+ if (T?.(l), Z = !0, le = null, K) {
857
+ clearInterval(K), K = void 0;
858
+ const w = u.find((G) => G.id.startsWith("ago-intro-"));
859
+ w && !w.content ? u = u.filter((G) => G !== w) : w && (w.status = "DONE");
860
860
  }
861
861
  const S = Date.now();
862
862
  u.push({
@@ -880,83 +880,83 @@ function yn(n, o) {
880
880
  conversationId: P,
881
881
  files: t
882
882
  });
883
- w.conversationId && (P || (P = w.conversationId), ue?.setActiveThread(w.conversationId, w.createdAt));
884
- const W = u.find((Q) => Q.id === `temp-user-${S}`);
885
- if (W && (W.id = `user-${S}`, W.conversationId = w.conversationId), !u.some((Q) => Q.id === w.id)) {
883
+ w.conversationId && (P || (P = w.conversationId), me?.setActiveThread(w.conversationId, w.createdAt));
884
+ const G = u.find((Q) => Q.id === `temp-user-${S}`);
885
+ if (G && (G.id = `user-${S}`, G.conversationId = w.conversationId), !u.some((Q) => Q.id === w.id)) {
886
886
  const Q = u.findIndex((Pt) => Pt.id === `temp-assistant-${S}`);
887
887
  Q >= 0 ? u[Q] = w : u.push(w);
888
888
  }
889
889
  u = u.filter((Q) => !Q.id.startsWith("temp-")), Z = !1, $(), g && Le();
890
890
  } catch (w) {
891
- le = w instanceof Error ? w.message : "Failed to send message", Z = !1, u = u.filter((W) => !W.id.startsWith("temp-")), $();
891
+ le = w instanceof Error ? w.message : "Failed to send message", Z = !1, u = u.filter((G) => !G.id.startsWith("temp-")), $();
892
892
  }
893
893
  }
894
894
  async function Le() {
895
895
  try {
896
896
  const e = await E.getConversations();
897
- me.splice(0, me.length, ...e);
897
+ ge.splice(0, ge.length, ...e);
898
898
  } catch {
899
899
  }
900
- return me;
900
+ return ge;
901
901
  }
902
902
  async function Nt(e) {
903
903
  try {
904
904
  const t = (await E.getConversation(e))?.messages ?? [];
905
905
  t.length > 0 && u.length === 0 && (u = t, $());
906
906
  } catch {
907
- u.length === 0 && (ue?.clear(), P = void 0);
907
+ u.length === 0 && (me?.clear(), P = void 0);
908
908
  }
909
909
  }
910
- return $(), se && z?.matches || ge(), P ? Nt(P) : Fe === "streaming" && Lt(ze), g && Le(), {
910
+ return $(), re && M?.matches || he(), P ? Nt(P) : Fe === "streaming" && Lt(ze), g && Le(), {
911
911
  client: E,
912
- element: he,
913
- sendMessage: $e,
914
- ...D || se ? {
912
+ element: xe,
913
+ sendMessage: ye,
914
+ ...z || re ? {
915
915
  open: Bt,
916
916
  close: Mt,
917
917
  toggle: Ot
918
918
  } : {},
919
- session: ue,
920
- threads: me,
919
+ session: me,
920
+ threads: ge,
921
921
  refreshThreads: Le,
922
922
  destroy() {
923
- q && clearInterval(q), E.off("message:start", Ve), E.off("message:chunk", je), E.off("message:answer-complete", qe), E.off("message:complete", Ke), E.off("message:error", Xe), G && E.off("form:submitted", Qe), V && E.off("form:error", Ye), Ze = !0, Ie.forEach((e) => e()), he.remove(), N?.remove(), H?.remove(), pe?.remove(), X?.remove(), z?.removeEventListener("change", tt), se && (document.removeEventListener("keydown", et), rt(), document.documentElement.style.removeProperty("overflow")), o.client || E.destroy();
923
+ K && clearInterval(K), E.off("message:start", Ve), E.off("message:chunk", je), E.off("message:answer-complete", qe), E.off("message:complete", Ke), E.off("message:error", Xe), V && E.off("form:submitted", Qe), j && E.off("form:error", Ye), Ze = !0, $e.forEach((e) => e()), xe.remove(), N?.remove(), H?.remove(), pe?.remove(), X?.remove(), M?.removeEventListener("change", tt), re && (document.removeEventListener("keydown", et), rt(), document.documentElement.style.removeProperty("overflow")), o.client || E.destroy();
924
924
  }
925
925
  };
926
- function ve() {
926
+ function we() {
927
927
  if (!U) return;
928
928
  {
929
- const t = xe === "left" ? "border-right" : "border-left";
930
- z?.matches ? (U.style.width = "100%", d.style.borderRadius = "0", d.style.removeProperty(t)) : (U.style.width = typeof x == "number" ? `${x}px` : x, d.style.setProperty(t, `1px solid ${L}`));
929
+ const t = be === "left" ? "border-right" : "border-left";
930
+ M?.matches ? (U.style.width = "100%", d.style.borderRadius = "0", d.style.removeProperty(t)) : (U.style.width = typeof x == "number" ? `${x}px` : x, d.style.setProperty(t, `1px solid ${L}`));
931
931
  }
932
932
  const e = m === "left" ? "translateX(-100%)" : "translateX(100%)";
933
933
  U.style.transform = oe ? "translateX(0)" : e, U.setAttribute("aria-hidden", oe ? "false" : "true"), N && (N.style.display = oe ? "none" : "flex");
934
934
  }
935
935
  function Ne() {
936
- oe = !0, ve(), ge(), B?.();
936
+ oe = !0, we(), he(), B?.();
937
937
  }
938
938
  function Te() {
939
- oe = !1, ve(), j?.();
939
+ oe = !1, we(), q?.();
940
940
  }
941
941
  function Tt() {
942
942
  oe ? Te() : Ne();
943
943
  }
944
944
  function Bt() {
945
- D ? Ne() : we();
945
+ z ? Ne() : fe();
946
946
  }
947
947
  function Mt() {
948
- D ? Te() : fe();
948
+ z ? Te() : ue();
949
949
  }
950
950
  function Ot() {
951
- D ? Tt() : K ? fe() : we();
951
+ z ? Tt() : W ? ue() : fe();
952
952
  }
953
953
  function Dt() {
954
954
  return Array.from(d.querySelectorAll('a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])')).filter((e) => e.getClientRects().length > 0);
955
955
  }
956
956
  function et(e) {
957
- if (!K) return;
957
+ if (!W) return;
958
958
  if (e.key === "Escape") {
959
- fe();
959
+ ue();
960
960
  return;
961
961
  }
962
962
  if (e.key !== "Tab") return;
@@ -969,7 +969,7 @@ function yn(n, o) {
969
969
  e.shiftKey && (w === l || !d.contains(w)) ? (e.preventDefault(), S.focus()) : !e.shiftKey && (w === S || !d.contains(w)) && (e.preventDefault(), l.focus());
970
970
  }
971
971
  function tt(e) {
972
- D ? ve() : !e.matches && K && fe(), $();
972
+ z ? we() : !e.matches && W && ue(), $();
973
973
  }
974
974
  function nt() {
975
975
  return window.visualViewport?.height ?? window.innerHeight;
@@ -978,16 +978,16 @@ function yn(n, o) {
978
978
  const e = window.visualViewport, t = e?.offsetTop ?? 0, l = e?.height ?? ce, S = Math.min(0, t + l - ce);
979
979
  d.style.top = `${S}px`, H && (H.style.top = `${t}px`);
980
980
  }
981
- function ye() {
982
- re || (re = requestAnimationFrame(() => {
983
- re = 0, ot();
981
+ function Ce() {
982
+ ie || (ie = requestAnimationFrame(() => {
983
+ ie = 0, ot();
984
984
  }));
985
985
  }
986
986
  function zt() {
987
- window.visualViewport?.addEventListener("resize", ye), window.visualViewport?.addEventListener("scroll", ye);
987
+ window.visualViewport?.addEventListener("resize", Ce), window.visualViewport?.addEventListener("scroll", Ce);
988
988
  }
989
989
  function rt() {
990
- window.visualViewport?.removeEventListener("resize", ye), window.visualViewport?.removeEventListener("scroll", ye), re && (cancelAnimationFrame(re), re = 0);
990
+ window.visualViewport?.removeEventListener("resize", Ce), window.visualViewport?.removeEventListener("scroll", Ce), ie && (cancelAnimationFrame(ie), ie = 0);
991
991
  }
992
992
  function it() {
993
993
  I.scrollTop = I.scrollHeight;
@@ -1006,7 +1006,7 @@ function yn(n, o) {
1006
1006
  backgroundColor: ee,
1007
1007
  borderBottom: `1px solid ${L}`,
1008
1008
  zIndex: "2147483001",
1009
- fontFamily: Ee
1009
+ fontFamily: Se
1010
1010
  });
1011
1011
  if (e.className = "ago-chat-widget-mobile-bar", f) {
1012
1012
  const l = document.createElement("img");
@@ -1035,11 +1035,11 @@ function yn(n, o) {
1035
1035
  cursor: "pointer",
1036
1036
  padding: "4px 8px"
1037
1037
  }), t.addEventListener("click", () => {
1038
- fe();
1038
+ ue();
1039
1039
  }), e.appendChild(t), e;
1040
1040
  }
1041
1041
  function Ht() {
1042
- return typeof document.startViewTransition == "function" && !Rt?.matches && !!z?.matches;
1042
+ return typeof document.startViewTransition == "function" && !Rt?.matches && !!M?.matches;
1043
1043
  }
1044
1044
  function at(e) {
1045
1045
  const t = document;
@@ -1080,30 +1080,30 @@ function yn(n, o) {
1080
1080
  "padding-top",
1081
1081
  "padding-bottom"
1082
1082
  ]) d.style.removeProperty(t);
1083
- d.style.height = be.height, d.style.border = be.border, d.style.borderRadius = be.borderRadius, d.style.boxShadow = be.boxShadow, d.removeAttribute("role"), d.removeAttribute("aria-modal"), d.removeAttribute("aria-label"), document.documentElement.style.removeProperty("overflow"), F && (F.style.display = "flex"), H && (H.style.display = "none");
1083
+ d.style.height = ve.height, d.style.border = ve.border, d.style.borderRadius = ve.borderRadius, d.style.boxShadow = ve.boxShadow, d.removeAttribute("role"), d.removeAttribute("aria-modal"), d.removeAttribute("aria-label"), document.documentElement.style.removeProperty("overflow"), F && (F.style.display = "flex"), H && (H.style.display = "none");
1084
1084
  }
1085
1085
  }
1086
- function we() {
1087
- if (K || !z?.matches) return Promise.resolve();
1086
+ function fe() {
1087
+ if (W || !M?.matches) return Promise.resolve();
1088
1088
  const e = d.getBoundingClientRect();
1089
1089
  if (e.height >= nt() * 0.8) return Promise.resolve();
1090
- K = !0, X = h({
1090
+ W = !0, X = h({
1091
1091
  width: `${e.width}px`,
1092
1092
  height: `${e.height}px`
1093
1093
  }), X.className = "ago-chat-widget-spacer", X.setAttribute("aria-hidden", "true"), ce = nt(), d.style.setProperty("--ago-vh", `${ce}px`), ot(), zt();
1094
1094
  const t = at(() => st(!0));
1095
1095
  return t.then(() => {
1096
- it(), ge();
1096
+ it(), he();
1097
1097
  }), it(), B?.(), t;
1098
1098
  }
1099
- function fe() {
1100
- if (!K) return Promise.resolve();
1101
- K = !1, rt(), d.querySelector("textarea")?.blur();
1099
+ function ue() {
1100
+ if (!W) return Promise.resolve();
1101
+ W = !1, rt(), d.querySelector("textarea")?.blur();
1102
1102
  const e = at(() => st(!1));
1103
- return e.then(() => d.style.removeProperty("--ago-vh")), ce = 0, j?.(), e;
1103
+ return e.then(() => d.style.removeProperty("--ago-vh")), ce = 0, q?.(), e;
1104
1104
  }
1105
1105
  }
1106
1106
  export {
1107
- yn as mountChatWidget,
1107
+ wn as mountChatWidget,
1108
1108
  De as renderMarkdown
1109
1109
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useago/sdk",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Create In-APP AI agents that answers question and performs actions. Works with React, Vue, Angular and vanilla JS/TS.",
5
5
  "type": "module",
6
6
  "sideEffects": false,