@useago/sdk 1.5.6 → 1.7.0
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/CHANGELOG.md +223 -0
- package/README.md +59 -0
- package/dist/AgoClient-BHegN73y.cjs +9 -0
- package/dist/{AgoClient-B_R_qi2s.js → AgoClient-PWPaekcg.js} +656 -387
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +230 -5
- package/dist/angular.d.ts +230 -5
- package/dist/angular.js +10 -1
- package/dist/{createConversationSession-Dqh7NXK4.cjs → createConversationSession-BbUUukV0.cjs} +1 -1
- package/dist/{createConversationSession-CdtI4vrf.js → createConversationSession-BkruoOVm.js} +1 -1
- package/dist/{createFormCollector-BjO3oB63.cjs → createFormCollector-C1ixsjV0.cjs} +1 -1
- package/dist/{createFormCollector-YwaZ78wU.js → createFormCollector-CvVFNkp6.js} +1 -1
- package/dist/{createMockClient-DcuNlufr.js → createMockClient-BDLW6tVc.js} +5 -2
- package/dist/createMockClient-BSNuN3ys.cjs +1 -0
- package/dist/devtools.d.cts +220 -5
- package/dist/devtools.d.ts +220 -5
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +238 -6
- package/dist/index.d.ts +238 -6
- package/dist/index.js +111 -109
- package/dist/react.cjs +40 -3
- package/dist/react.d.cts +419 -7
- package/dist/react.d.ts +419 -7
- package/dist/react.js +1195 -743
- package/dist/sheetController-CBUVOroo.js +205 -0
- package/dist/sheetController-DY-sC13T.cjs +1 -0
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +220 -5
- package/dist/testing.d.ts +220 -5
- package/dist/testing.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +235 -5
- package/dist/vue.d.ts +235 -5
- package/dist/vue.js +121 -100
- package/dist/widget.cjs +4 -4
- package/dist/widget.d.cts +328 -5
- package/dist/widget.d.ts +328 -5
- package/dist/widget.js +721 -629
- package/llms-full.txt +202 -14
- package/package.json +1 -1
- package/dist/AgoClient-DLB9icvv.cjs +0 -8
- package/dist/createMockClient-Dw-cyISN.cjs +0 -1
package/dist/widget.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ae=require("./AgoClient-BHegN73y.cjs"),en=require("./createConversationSession-BbUUukV0.cjs"),Ct=require("./createFormCollector-C1ixsjV0.cjs"),t=require("./sheetController-DY-sC13T.cjs");function tn(o){let i=[];const s=document.createElement("form");t.css(s,{display:"flex",flexDirection:"column",gap:"8px",padding:"12px",borderTop:`1px solid ${t.BORDER_COLOR}`,backgroundColor:t.PANEL_BACKGROUND}),s.className="ago-chat-input";const r=t.div({display:"flex",flexWrap:"wrap",gap:"6px"}),C=t.div({display:"flex",gap:"8px",alignItems:"flex-end"}),a=document.createElement("textarea");a.placeholder=o.placeholder,a.setAttribute("aria-label",o.placeholder),a.rows=1,t.css(a,{flex:"1",resize:"none",boxSizing:"border-box",padding:"10px 12px",border:`1px solid ${t.BORDER_COLOR}`,borderRadius:"12px",fontSize:"16px",fontFamily:t.FONT_VAR,lineHeight:"1.4",maxHeight:"110px",overflowY:"hidden"});const _=()=>{a.style.height="auto";const g=Math.min(a.scrollHeight+2,110);a.style.height=`${g}px`,a.style.overflowY=a.scrollHeight+2>110?"auto":"hidden"};a.addEventListener("input",()=>{_(),H()});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>',y='<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>',u='<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><rect x="5" y="5" width="14" height="14" rx="2"/></svg>',p=document.createElement("button");p.type="submit",p.setAttribute("aria-label","Send"),p.innerHTML=m,t.css(p,{flexShrink:"0",width:"44px",height:"44px",padding:"0",border:"none",borderRadius:"50%",backgroundColor:t.BRAND_COLOR,color:t.BRAND_TEXT_COLOR,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"});let R=!1;const M=()=>R&&!!o.onStop,H=()=>{const c=a.value.trim()!==""||i.length>0,g=M(),A=!g&&(R||!c);p.disabled=A,p.type=g?"button":"submit",p.setAttribute("aria-label",g?"Stop generating":"Send"),p.innerHTML=g?u:R?y:m,p.style.opacity=A&&!R?"0.5":"1",p.style.cursor=A?"default":"pointer"};p.addEventListener("click",()=>{M()&&o.onStop?.()});let B=null,O=null;o.allowFiles&&(B=document.createElement("input"),B.type="file",B.multiple=!0,t.css(B,{display:"none"}),O=document.createElement("button"),O.type="button",O.setAttribute("aria-label","Attach file"),O.textContent="📎",t.css(O,{flexShrink:"0",minWidth:"44px",minHeight:"44px",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 12px",border:`1px solid ${t.BORDER_COLOR}`,borderRadius:"12px",backgroundColor:t.PANEL_BACKGROUND,cursor:"pointer",fontSize:"14px"}),O.addEventListener("click",()=>B?.click()),B.addEventListener("change",()=>{i=[...i,...Array.from(B?.files??[])],h()}));function h(){r.replaceChildren(),i.forEach((c,g)=>{const A=t.div({display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",backgroundColor:"#f0f4ff",border:`1px solid ${t.BORDER_COLOR}`,borderRadius:"8px",fontSize:"12px"}),q=document.createElement("span");q.textContent=c.name;const D=document.createElement("button");D.type="button",D.setAttribute("aria-label",`Remove ${c.name}`),D.textContent="×",t.css(D,{flexShrink:"0",width:"44px",height:"44px",margin:"-14px -12px -14px -4px",display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",fontSize:"14px",lineHeight:"1"}),D.addEventListener("click",()=>{i=i.filter((N,G)=>G!==g),h()}),A.append(q,D),r.appendChild(A)}),H()}const x=()=>{const c=a.value,g=i;return a.value="",_(),i=[],h(),{content:c,files:g}},v=()=>{const{content:c,files:g}=x();(c.trim()||g.length>0)&&o.onSend(c.trim(),g.length>0?g:void 0)};return s.addEventListener("submit",c=>{c.preventDefault(),v()}),a.addEventListener("keydown",c=>{c.key==="Enter"&&!c.shiftKey&&(c.preventDefault(),v())}),O&&C.appendChild(O),C.append(a,p),B&&s.appendChild(B),s.append(r,C),H(),{inputRow:s,getValueAndClear:x,setDisabled:c=>{a.disabled=c,R=c,H()},focus:()=>a.focus(),restoreDraft:(c,g)=>{c&&!a.value.trim()&&(a.value=c,_()),g?.length&&(i=[...g,...i],h()),H()}}}var nn={"&":"&","<":"<",">":">",'"':""","'":"'"};function se(o){return o.replace(/[&<>"']/g,i=>nn[i])}function yt(o){const i=o.trim();return/^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i.test(i)||!/^[a-z][a-z0-9+.-]*:/i.test(i)?i:null}var Rt='"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace',Oe="";function ee(o){const i=[],s=C=>(i.push(C),`${Oe}${i.length-1}${Oe}`);let r=o;return r=r.replace(/`([^`]+)`/g,(C,a)=>s(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${Rt}">${se(a)}</code>`)),r=r.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g,(C,a,_)=>{const m=yt(_);return m?s(`<img alt="${se(a)}" src="${se(m)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`):C}),r=r.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(C,a,_)=>{const m=yt(_);return m?s(`<a href="${se(m)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${ee(a)}</a>`):C}),r=se(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(`${Oe}(\\d+)${Oe}`,"g"),(C,a)=>i[Number(a)]),r}function U(o,i,s){const r=document.createElement(o);return Object.assign(r.style,i),s!==void 0&&(r.innerHTML=s),r}var St=/^ {0,3}([-*_])( *\1){2,} *$/,_t=/^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/,Ot=/^ {0,3}(```+|~~~+)/,Ae=/^ {0,3}>\s?/,le=/^(\s*)([-*+]|\d+[.)])\s+(.*)$/,on=["20px","18px","16px","15px","14px","13px"],Xe=o=>o.match(/^\s*/)?.[0].length??0;function rn(o){return o.trim()===""||St.test(o)||_t.test(o)||Ot.test(o)||Ae.test(o)||le.test(o)}function At(o){const i=o[0].match(le),s=i[1].length,r=/\d/.test(i[2]),C=U(r?"ol":"ul",{margin:"0 0 8px 0",paddingLeft:"20px",listStyleType:r?"decimal":"disc",listStylePosition:"outside"});let a=0;for(;a<o.length;){const _=o[a].match(le),m=[];for(a++;a<o.length&&Xe(o[a])>s;)m.push(o[a]),a++;const y=U("li",{display:"list-item",margin:"2px 0",lineHeight:"1.6"}),u=_[3].match(/^\[([ xX])\]\s+(.*)$/);u?(y.style.listStyleType="none",y.style.marginLeft="-20px",y.innerHTML=`<span style="margin-right:6px">${u[1].toLowerCase()==="x"?"☑":"☐"}</span>${ee(u[2])}`):y.innerHTML=ee(_[3]),m.filter(p=>le.test(p)).length>0&&y.appendChild(At(m.filter(p=>p.trim()!==""))),C.appendChild(y)}return C}function sn(o){const i=m=>m.replace(/^\s*\|?/,"").replace(/\|?\s*$/,"").split("|").map(y=>y.trim()),s=U("div",{overflowX:"auto",margin:"0 0 8px 0"}),r=U("table",{borderCollapse:"collapse",width:"100%",fontSize:"13px"}),C=document.createElement("thead"),a=document.createElement("tr");for(const m of i(o[0]))a.appendChild(U("th",{border:"1px solid #dee3e8",padding:"6px 10px",textAlign:"left",backgroundColor:"#f5f7fa",fontWeight:"600"},ee(m)));C.appendChild(a),r.appendChild(C);const _=document.createElement("tbody");for(const m of o.slice(2)){const y=document.createElement("tr");for(const u of i(m))y.appendChild(U("td",{border:"1px solid #dee3e8",padding:"6px 10px"},ee(u)));_.appendChild(y)}return r.appendChild(_),s.appendChild(r),s}var an=o=>!!o&&/^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(o);function Le(o){const i=document.createDocumentFragment(),s=o.replace(/\r\n?/g,`
|
|
2
2
|
`).split(`
|
|
3
|
-
`);let r=0;for(;r<
|
|
4
|
-
`)))),
|
|
5
|
-
`))),o.appendChild(f);continue}if(a.includes("|")&&ln(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(sn(p));continue}if(le.test(a)){const p=[],f=He(a);for(;r<i.length&&i[r].trim()!=="";)if(le.test(i[r])||He(i[r])>f)p.push(i[r]),r++;else break;o.appendChild(At(p));continue}const x=[a];for(r++;r<i.length&&!an(i[r]);)x.push(i[r]),r++;o.appendChild(O("p",{margin:"0 0 8px 0",lineHeight:"1.6"},x.map(p=>ne(p)).join("<br>")))}const b=o.lastElementChild;return b&&(b.style.marginBottom="0"),o}function dn(t,o){const{isLast:i,isLastOfBlock:r,bubbleStyle:b,showAgentName:a,agentBubble:C,followUpEnabled:m,followUpHandler:x,isMobile:p}=o,f=t.role==="user",I=b==="imessage",R=h({display:"flex",flexDirection:"column",alignItems:f?"flex-end":"flex-start",marginBottom:I&&!r?"2px":"16px"});if(R.className=`ago-message ago-message--${t.role}`,!f&&a&&t.agent){const g=h({fontSize:"13px",fontWeight:"500",color:ee,marginBottom:"6px",padding:"0 4px"});g.className="ago-message__agent",g.textContent=t.agent.displayName||t.agent.name,R.appendChild(g)}if(!f&&t.sources&&t.sources.length>0){const g=h({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px",marginBottom:"10px",width:"100%",maxWidth:"85%"});g.className="ago-message__sources",t.sources.forEach((l,c)=>{const w=l.url?document.createElement("a"):document.createElement("div");l.url&&w instanceof HTMLAnchorElement&&(w.href=l.url,w.target="_blank",w.rel="noopener noreferrer"),v(w,{display:"flex",alignItems:"center",gap:"8px",padding:"8px 10px",border:`1px solid ${N}`,borderRadius:"8px",backgroundColor:te,textDecoration:"none",color:ee,fontSize:"12px",overflow:"hidden"});const B=h({flexShrink:"0",width:"18px",height:"18px",borderRadius:"3px",border:`1px solid ${Fe}`,color:Fe,fontSize:"11px",fontWeight:"500",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f0f4ff"});B.textContent=String(c+1);const k=h({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"});k.textContent=l.title,k.title=l.title,w.append(B,k),g.appendChild(w)}),R.appendChild(g)}if(t.attachments&&t.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 l of t.attachments){const c=se.safeAttachmentUrl(l.url);if(se.canInlineImage(l)&&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=l.name,q.loading="lazy",v(q,{maxWidth:"180px",maxHeight:"160px",objectFit:"cover",borderRadius:"10px",border:`1px solid ${N}`,display:"block"}),M.appendChild(q),g.appendChild(M);continue}const w=c?document.createElement("a"):document.createElement("div");c&&w instanceof HTMLAnchorElement&&(w.href=c,w.target="_blank",w.rel="noopener noreferrer"),v(w,{display:"inline-flex",alignItems:"center",gap:"8px",padding:"8px 12px",borderRadius:"10px",border:`1px solid ${N}`,backgroundColor:f?"rgba(255,255,255,0.12)":te,color:f?Le:ee,fontSize:"13px",textDecoration:"none",maxWidth:"220px"});const B=document.createElement("span");B.textContent="📄",B.setAttribute("aria-hidden","true"),v(B,{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=l.name,j.title=l.name,k.appendChild(j);const V=se.formatFileSize(l.fileSize);if(V){const M=h({fontSize:"11px",color:Et});M.textContent=V,k.appendChild(M)}w.append(B,k),g.appendChild(w)}R.appendChild(g)}const A=f||C||I,Q=!!t.content||t.status==="IN_PROGRESS"||t.status==="WAITING_CLIENT",D=h({maxWidth:A?I||f?p?"88%":"75%":p?"92%":"85%":"100%",padding:A?"10px 14px":"2px 8px",borderRadius:I?Jt:A?Pe:"0",backgroundColor:f?_e:A?xt:"transparent",color:f?Le:ee,overflowWrap:"break-word",textWrap:"pretty",fontSize:"16px",lineHeight:"1.6"});if(D.className="ago-message__content",I&&r){D.style.position="relative";const g=h({position:"absolute",zIndex:"0",bottom:"-2px",width:"20px",height:"20px",background:f?_e:xt});g.className="ago-message__tail";const l=h({position:"absolute",zIndex:"1",bottom:"-2px",width:"10px",height:"20px",background:Ct});l.className="ago-message__tail-mask",f?(g.style.right="-8px",g.style.borderBottomLeftRadius="16px 14px",l.style.right="-10px",l.style.borderBottomLeftRadius="10px"):(g.style.left="-7px",g.style.borderBottomRightRadius="16px 14px",l.style.left="-10px",l.style.borderBottomRightRadius="10px"),D.append(g,l)}if(t.content?D.appendChild(Ne(t.content)):(t.status==="IN_PROGRESS"||t.status==="WAITING_CLIENT")&&D.appendChild(pn()),Q&&R.appendChild(D),i&&t.followUpReplies&&t.followUpReplies.length>0){const g=h({display:"flex",flexWrap:"wrap",gap:"8px",marginTop:"10px"});g.className="ago-message__followups";for(const l of t.followUpReplies){const c=document.createElement("button");c.type="button",c.className="ago-message__followup-btn",c.textContent=l,c.disabled=!m,v(c,{minHeight:"36px",padding:"6px 14px",fontSize:"14px",borderRadius:Pe,border:`1px solid ${N}`,backgroundColor:te,color:ee,cursor:m?"pointer":"default",transition:"border-color 0.15s"}),x&&c.addEventListener("click",()=>x(l)),c.addEventListener("mouseenter",()=>{c.style.borderColor=Fe}),c.addEventListener("mouseleave",()=>{c.style.borderColor=N}),g.appendChild(c)}R.appendChild(g)}return R}function cn(t){const o=h({display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",backgroundColor:"#f0fdf4",color:"#15803d",borderRadius:Pe,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=t,o.append(i,r),o}function pn(){const t=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`});t.appendChild(i)}return t}function fn(){const t="http://www.w3.org/2000/svg",o=document.createElementNS(t,"svg");o.setAttribute("width","26"),o.setAttribute("height","26"),o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("fill","none");const i=document.createElementNS(t,"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 yt="Form submitted.";function un(t){if(typeof t=="string")return t||null;if(!t||typeof t!="object")return null;const o=t;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 mn=0,We=0,Ue=0;function wt(){if(We++>0)return;Ue=window.scrollY;const{style:t}=document.body;t.position="fixed",t.top=`-${Ue}px`,t.left="0",t.right="0",t.width="100%",document.documentElement.style.overflow="hidden"}function ke(){if(We===0||--We>0)return;const{style:t}=document.body;t.removeProperty("position"),t.removeProperty("top"),t.removeProperty("left"),t.removeProperty("right"),t.removeProperty("width"),document.documentElement.style.removeProperty("overflow"),window.scrollTo(0,Ue)}function gn(t){const o=typeof t=="string"?document.querySelector(t):t;if(!o)throw new Error(`mountChatWidget: target "${String(t)}" not found.`);return o}function hn(t,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:I=!1,agentBubble:R=!1,bubbleStyle:A="default",showHeader:Q=!0,theme:D,loadThreads:g=!1,forms:l,formSubmittedMessage:c=yt,onFollowUpClick:w,onMessageSent:B,onMessageReceived:k,onFormSubmitted:j,onFormError:V,onOpen:M,onClose:q}=o,oe=typeof r=="string"?{message:r,mode:"static"}:r,Ge=oe.message,je=oe.mode??"static",_t="speed"in oe&&oe.speed||45,Ve="followUpReplies"in oe&&oe.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),qe=gn(t),z=m==="left"||m==="right",Lt=z&&(o.launcher??!0);let Z=z?p:!0,ge=!1;const Nt=o.mobile?.breakpoint??768,Te=o.mobile?.trigger??"tap",Ke=typeof window<"u"&&!!window.matchMedia,T=Ke?window.matchMedia(`(max-width: ${Nt}px)`):void 0,Tt=Ke?window.matchMedia("(prefers-reduced-motion: reduce)"):void 0,re=!z&&!!T,$e=o.persistConversation,he=$e?Xt.createConversationSession($e===!0?{}:$e):void 0;let H=o.conversationId??he?.getLastActiveThread()??void 0,u=[],J=!1,de=null,K;const Xe=[];function $t(e){if(typeof c=="function"){const s=c(e);if(typeof s=="string"&&s)return s}const n=un(e);return n||(typeof c=="string"?c:yt)}const xe=[],d=h({display:"flex",flexDirection:"column",height:z?"100%":typeof C=="number"?`${C}px`:C,border:`1px solid ${N}`,borderRadius:Zt,overflow:"hidden",backgroundColor:te,fontFamily:Ie,textAlign:"left",boxShadow:"rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"});d.className="ago-chat-widget",en(d,D);let F;if(Q){if(F=h({padding:"14px 16px",borderBottom:`1px solid ${N}`,backgroundColor:Qt,color:ht,display:"flex",alignItems:"center",gap:"10px"}),F.className="ago-chat-widget__header",f){const n=document.createElement("img");n.src=f,n.alt="Logo",v(n,{height:"24px",width:"auto"}),F.appendChild(n)}const e=document.createElement("h3");if(e.textContent=i,v(e,{margin:"0",fontSize:"15px",fontWeight:"600"}),F.appendChild(e),z){const n=document.createElement("button");n.type="button",n.className="ago-chat-widget__close",n.setAttribute("aria-label","Close"),n.textContent="×",v(n,{marginLeft:"auto",background:"transparent",border:"none",color:ht,fontSize:"22px",lineHeight:"1",cursor:"pointer",padding:"0 2px"}),n.addEventListener("click",()=>ze()),F.appendChild(n)}}const _=h({flex:"1",overflow:"auto",overscrollBehavior:"contain",padding:"16px",backgroundColor:Ct});_.className="ago-chat-widget__messages",_.setAttribute("role","log"),_.setAttribute("aria-live","polite"),_.setAttribute("aria-relevant","additions text"),_.setAttribute("aria-atomic","false");const{inputRow:Be,setDisabled:Bt,focus:be}=nn({placeholder:b,allowFiles:a,onSend:(e,n)=>{Ce(e,n)}});tn(),d.append(...F?[F]:[],_,Be);let ve=d,U,$;const ye=m==="left"?"left":"right";if(z&&(U=h({position:"fixed",top:"0",bottom:"0",[ye]:"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",[ye==="left"?"borderRight":"borderLeft"]:`1px solid ${N}`}),U.appendChild(d),ve=U),Lt){if($=document.createElement("button"),$.type="button",$.className="ago-chat-widget-launcher",$.setAttribute("aria-label",`Open ${i}`),v($,{position:"fixed",bottom:"20px",[ye]:"20px",width:"56px",height:"56px",borderRadius:"50%",border:"none",backgroundColor:_e,color:Le,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",zIndex:"2147483000",boxShadow:"rgba(15, 15, 15, 0.2) 0px 4px 14px 0px",fontFamily:Ie}),f){const e=document.createElement("img");e.src=f,e.alt="",v(e,{width:"26px",height:"26px",objectFit:"contain"}),$.appendChild(e)}else $.appendChild(fn());$.addEventListener("click",()=>De())}const ce=re?`ago-vt-${++mn}`:"",Ye=52;let W=!1,pe=0,ie=0,P,fe,X;const we={height:d.style.height,border:d.style.border,borderRadius:d.style.borderRadius,boxShadow:d.style.boxShadow};qe.appendChild(ve),$&&qe.appendChild($),Ee(),re&&(P=Vt(),d.insertBefore(P,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),(Te==="focus"||Te==="tap")&&(d.addEventListener("pointerdown",e=>{if(W||!T?.matches)return;const n=Be.contains(e.target);if(Te==="tap"){if((e.target instanceof Element?e.target:null)?.closest("button,a[href],[role='button']"))return}else if(!n)return;n&&e.preventDefault(),ue()},!0),d.addEventListener("focusin",e=>{T?.matches&&Be.contains(e.target)&&ue()})),document.addEventListener("keydown",at)),T&&T.addEventListener("change",st);const Mt=w!==!1,Ot=w===!1?void 0:w??(e=>{re&&T?.matches&&!W?ue().then(()=>Ce(e)):Ce(e)});function L(){if(_.replaceChildren(),u.length===0){if(je==="static"){const n=h({textAlign:"center",color:Et,padding:"24px 16px",fontSize:"16px",lineHeight:"1.5"});n.appendChild(Ne(Ge)),_.appendChild(n)}}else u.forEach((n,s)=>{const S=s===u.length-1||u[s+1].role!==n.role;_.appendChild(dn(n,{isLast:s===u.length-1,isLastOfBlock:S,bubbleStyle:A,showAgentName:I,agentBubble:R,followUpEnabled:Mt,followUpHandler:Ot,isMobile:!!T?.matches}))});for(const n of Xe)_.appendChild(cn(n));if(de){const n=h({padding:"10px 14px",backgroundColor:"#fef2f2",color:"#dc2626",borderRadius:"12px",marginTop:"8px",fontSize:"13px",border:"1px solid #fecaca"});n.setAttribute("role","alert"),n.textContent=de,_.appendChild(n)}_.scrollTop=_.scrollHeight;const e=u[u.length-1];Bt(J&&e?.role==="assistant"&&(e.status==="IN_PROGRESS"||e.status==="WAITING_CLIENT"))}function Dt(){for(let e=u.length-1;e>=0;e--){const n=u[e];if(n.role==="assistant"&&(n.status==="IN_PROGRESS"||n.status==="WAITING_CLIENT"))return n}}const Qe=e=>{H||(H=e.conversationId)},Ze=e=>{const n=Dt();n&&(n.content+=e.content,L())},Je=e=>{const n=u.findIndex(s=>s.id===e.id||s.role==="assistant"&&s.status==="IN_PROGRESS");n>=0?u[n]=e:u.push(e),L(),be()},et=e=>{const n=u.findIndex(s=>s.id===e.id||s.role==="assistant"&&s.status==="IN_PROGRESS");n>=0?u[n]=e:u.push(e),J=!1,L(),e.status==="DONE"&&k?.({id:e.id,content:e.content})},tt=e=>{de=e.error,J=!1,u=u.filter(n=>!n.id.startsWith("temp-")),L()};function zt(e){const n={id:`ago-intro-${Date.now()}`,conversationId:"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date};u.push(n),L();const s=e.match(/\S+\s*/g)??[e];let S=0;K=setInterval(()=>{if(S>=s.length){clearInterval(K),K=void 0,n.status="DONE",Ve&&(n.followUpReplies=Ve),L();return}n.content+=s[S],S++,L()},_t)}E.on("message:start",Qe),E.on("message:chunk",Ze),E.on("message:answer-complete",Je),E.on("message:complete",et),E.on("message:error",tt);const nt=e=>j?.(e),ot=e=>V?.(e);j&&E.on("form:submitted",nt),V&&E.on("form:error",ot);const Me=[];let rt=!1;const it=e=>{if(rt)return;Me.push(e.install(E));let n=e.store.get().submitted;const s=e.store.subscribe(S=>{S.submitted&&!n&&(Xe.push($t(S.submitResult)),L()),n=S.submitted});Me.push(s)};for(const e of l??[])e.schema!=null?it(mt.createFormCollector(e)):mt.loadFormCollector(E,e).then(n=>it(n)).catch(()=>{});async function Ce(e,n){const s=e.trim();if(!s&&!n?.length||J)return;if(B?.(s),J=!0,de=null,K){clearInterval(K),K=void 0;const y=u.find(G=>G.id.startsWith("ago-intro-"));y&&!y.content?u=u.filter(G=>G!==y):y&&(y.status="DONE")}const S=Date.now();u.push({id:`temp-user-${S}`,conversationId:H||"",content:s,role:"user",status:"DONE",attachments:n&&n.length>0?se.attachmentsFromFiles(n):void 0,createdAt:new Date}),u.push({id:`temp-assistant-${S}`,conversationId:H||"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date}),L();try{const y=await E.sendMessage(s,{conversationId:H,files:n});y.conversationId&&(H||(H=y.conversationId),he?.setActiveThread(y.conversationId,y.createdAt));const G=u.find(Y=>Y.id===`temp-user-${S}`);if(G&&(G.id=`user-${S}`,G.conversationId=y.conversationId),!u.some(Y=>Y.id===y.id)){const Y=u.findIndex(Kt=>Kt.id===`temp-assistant-${S}`);Y>=0?u[Y]=y:u.push(y)}u=u.filter(Y=>!Y.id.startsWith("temp-")),y.status!=="WAITING_CLIENT"&&(J=!1),L(),g&&Oe()}catch(y){de=y instanceof Error?y.message:"Failed to send message",J=!1,u=u.filter(G=>!G.id.startsWith("temp-")),L()}}async function Oe(){try{const{data:e}=await E.getConversations();xe.splice(0,xe.length,...e)}catch{}return xe}async function Ft(e){try{const n=(await E.getConversation(e))?.messages??[];n.length>0&&u.length===0&&(u=n,L())}catch{u.length===0&&(he?.clear(),H=void 0)}}return L(),re&&T?.matches||be(),H?Ft(H):je==="streaming"&&zt(Ge),g&&Oe(),{client:E,element:ve,sendMessage:Ce,...z||re?{open:Ht,close:Wt,toggle:Ut}:{},session:he,threads:xe,refreshThreads:Oe,destroy(){K&&clearInterval(K),E.off("message:start",Qe),E.off("message:chunk",Ze),E.off("message:answer-complete",Je),E.off("message:complete",et),E.off("message:error",tt),j&&E.off("form:submitted",nt),V&&E.off("form:error",ot),rt=!0,Me.forEach(e=>e()),ve.remove(),$?.remove(),P?.remove(),fe?.remove(),X?.remove(),T?.removeEventListener("change",st),re&&(document.removeEventListener("keydown",at),ct(),W&&ke()),ge&&(ge=!1,ke()),o.client||E.destroy()}};function Ee(){if(!U)return;{const s=ye==="left"?"border-right":"border-left";T?.matches?(U.style.width="100%",d.style.borderRadius="0",d.style.removeProperty(s)):(U.style.width=typeof x=="number"?`${x}px`:x,d.style.setProperty(s,`1px solid ${N}`))}const e=m==="left"?"translateX(-100%)":"translateX(100%)";U.style.transform=Z?"translateX(0)":e,U.setAttribute("aria-hidden",Z?"false":"true"),$&&($.style.display=Z?"none":"flex");const n=Z&&!!T?.matches;n!==ge&&(ge=n,n?wt():ke())}function De(){Z=!0,Ee(),be(),M?.()}function ze(){Z=!1,Ee(),q?.()}function Pt(){Z?ze():De()}function Ht(){z?De():ue()}function Wt(){z?ze():me()}function Ut(){z?Pt():W?me():ue()}function Gt(){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 at(e){if(!W)return;if(e.key==="Escape"){me();return}if(e.key!=="Tab")return;const n=Gt();if(n.length===0){e.preventDefault();return}const s=n[0],S=n[n.length-1],y=document.activeElement;e.shiftKey&&(y===s||!d.contains(y))?(e.preventDefault(),S.focus()):!e.shiftKey&&(y===S||!d.contains(y))&&(e.preventDefault(),s.focus())}function st(e){z?Ee():!e.matches&&W&&me(),L()}function lt(){return window.visualViewport?.height??window.innerHeight}function dt(){const e=window.visualViewport,n=e?.offsetTop??0,s=e?.height??pe,S=Math.min(0,n+s-pe);d.style.top=`${S}px`,P&&(P.style.top=`${n}px`)}function Se(){ie||(ie=requestAnimationFrame(()=>{ie=0,dt()}))}function jt(){window.visualViewport?.addEventListener("resize",Se),window.visualViewport?.addEventListener("scroll",Se)}function ct(){window.visualViewport?.removeEventListener("resize",Se),window.visualViewport?.removeEventListener("scroll",Se),ie&&(cancelAnimationFrame(ie),ie=0)}function pt(){_.scrollTop=_.scrollHeight}function Vt(){const e=h({position:"fixed",top:"0",left:"0",right:"0",height:`calc(${Ye}px + env(safe-area-inset-top))`,display:"none",alignItems:"center",justifyContent:"space-between",padding:"env(safe-area-inset-top) 14px 0",backgroundColor:te,borderBottom:`1px solid ${N}`,zIndex:"2147483001",fontFamily:Ie});if(e.className="ago-chat-widget-mobile-bar",f){const s=document.createElement("img");s.src=f,s.alt="",v(s,{height:"28px",width:"auto"}),e.appendChild(s)}else if(i){const s=document.createElement("span");s.textContent=i,v(s,{fontSize:"15px",fontWeight:"600",color:ee,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"}),e.appendChild(s)}else e.appendChild(h({}));const n=document.createElement("button");return n.type="button",n.setAttribute("aria-label","Close"),n.textContent="×",v(n,{border:"none",background:"transparent",fontSize:"26px",lineHeight:"1",color:ee,cursor:"pointer",padding:"4px 8px"}),n.addEventListener("click",()=>{me()}),e.appendChild(n),e}function qt(){return typeof document.startViewTransition=="function"&&!Tt?.matches&&!!T?.matches}function ft(e){const n=document;if(qt()&&n.startViewTransition){d.style.setProperty("view-transition-name",ce),P?.style.setProperty("view-transition-name",`${ce}-bar`);const s=()=>{d.style.removeProperty("view-transition-name"),P?.style.removeProperty("view-transition-name")};return n.startViewTransition(e).finished.then(s,s)}return e(),Promise.resolve()}function ut(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(${Ye}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),wt(),F&&(F.style.display="none"),P&&(P.style.display="flex");else{X?.remove(),X=void 0;for(const n of["position","top","left","right","bottom","z-index","padding-top","padding-bottom"])d.style.removeProperty(n);d.style.height=we.height,d.style.border=we.border,d.style.borderRadius=we.borderRadius,d.style.boxShadow=we.boxShadow,d.removeAttribute("role"),d.removeAttribute("aria-modal"),d.removeAttribute("aria-label"),ke(),F&&(F.style.display="flex"),P&&(P.style.display="none")}}function ue(){if(W||!T?.matches)return Promise.resolve();const e=d.getBoundingClientRect();if(e.height>=lt()*.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=lt(),d.style.setProperty("--ago-vh",`${pe}px`),dt(),jt();const n=ft(()=>ut(!0));return n.then(()=>{pt(),be()}),pt(),M?.(),n}function me(){if(!W)return Promise.resolve();W=!1,ct(),d.querySelector("textarea")?.blur();const e=ft(()=>ut(!1));return e.then(()=>d.style.removeProperty("--ago-vh")),pe=0,q?.(),e}}exports.mountChatWidget=hn;exports.renderMarkdown=Ne;
|
|
3
|
+
`);let r=0;for(;r<s.length;){const a=s[r];if(a.trim()===""){r++;continue}const _=a.match(Ot);if(_){const u=_[1][0],p=[];for(r++;r<s.length&&!new RegExp(`^ {0,3}${u==="`"?"`{3,}":"~{3,}"}\\s*$`).test(s[r]);)p.push(s[r]),r++;r++;const R=U("pre",{margin:"0 0 8px 0"});R.appendChild(U("code",{display:"block",background:"#f5f5f5",padding:"8px 12px",borderRadius:"6px",fontSize:"13px",overflowX:"auto",fontFamily:Rt,whiteSpace:"pre"},se(p.join(`
|
|
4
|
+
`)))),i.appendChild(R);continue}if(St.test(a)){i.appendChild(U("hr",{border:"none",borderTop:"1px solid #dee3e8",margin:"12px 0"})),r++;continue}const m=a.match(_t);if(m){const u=m[1].length;i.appendChild(U(`h${u}`,{margin:"16px 0 8px 0",fontSize:on[u-1],fontWeight:"600",lineHeight:"1.3"},ee(m[2]))),r++;continue}if(Ae.test(a)){const u=[];for(;r<s.length&&Ae.test(s[r]);)u.push(s[r].replace(Ae,"")),r++;const p=U("blockquote",{borderLeft:"4px solid #dee3e8",paddingLeft:"12px",margin:"0 0 8px 0",fontStyle:"italic",color:"#6b6d6f"});p.appendChild(Le(u.join(`
|
|
5
|
+
`))),i.appendChild(p);continue}if(a.includes("|")&&an(s[r+1])){const u=[a,s[r+1]];for(r+=2;r<s.length&&s[r].includes("|")&&s[r].trim();)u.push(s[r]),r++;i.appendChild(sn(u));continue}if(le.test(a)){const u=[],p=Xe(a);for(;r<s.length&&s[r].trim()!=="";)if(le.test(s[r])||Xe(s[r])>p)u.push(s[r]),r++;else break;i.appendChild(At(u));continue}const y=[a];for(r++;r<s.length&&!rn(s[r]);)y.push(s[r]),r++;i.appendChild(U("p",{margin:"0 0 8px 0",lineHeight:"1.6"},y.map(u=>ee(u)).join("<br>")))}const C=i.lastElementChild;return C&&(C.style.marginBottom="0"),i}function wt(o,i){const{isLast:s,isLastOfBlock:r,bubbleStyle:C,showAgentName:a,agentBubble:_,followUpEnabled:m,followUpHandler:y,isMobile:u}=i,p=o.role==="user",R=C==="imessage",M=t.div({display:"flex",flexDirection:"column",alignItems:p?"flex-end":"flex-start",marginBottom:R&&!r?"2px":"16px"});if(M.className=`ago-message ago-message--${o.role}`,!p&&a&&o.agent){const h=t.div({fontSize:"13px",fontWeight:"500",color:t.TEXT_COLOR,marginBottom:"6px",padding:"0 4px"});h.className="ago-message__agent",h.textContent=o.agent.displayName||o.agent.name,M.appendChild(h)}if(!p&&o.sources&&o.sources.length>0){const h=t.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px",marginBottom:"10px",width:"100%",maxWidth:"85%"});h.className="ago-message__sources",o.sources.forEach((x,v)=>{const c=x.url?document.createElement("a"):document.createElement("div");x.url&&c instanceof HTMLAnchorElement&&(c.href=x.url,c.target="_blank",c.rel="noopener noreferrer"),t.css(c,{display:"flex",alignItems:"center",gap:"8px",padding:"8px 10px",border:`1px solid ${t.BORDER_COLOR}`,borderRadius:"8px",backgroundColor:t.PANEL_BACKGROUND,textDecoration:"none",color:t.TEXT_COLOR,fontSize:"12px",overflow:"hidden"});const g=t.div({flexShrink:"0",width:"18px",height:"18px",borderRadius:"3px",border:`1px solid ${t.ACCENT_COLOR}`,color:t.ACCENT_COLOR,fontSize:"11px",fontWeight:"500",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f0f4ff"});g.textContent=String(v+1);const A=t.div({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"});A.textContent=x.title,A.title=x.title,c.append(g,A),h.appendChild(c)}),M.appendChild(h)}if(o.attachments&&o.attachments.length>0){const h=t.div({display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"6px",justifyContent:p?"flex-end":"flex-start",maxWidth:"75%"});h.className="ago-message__attachments";for(const x of o.attachments){const v=ae.safeAttachmentUrl(x.url);if(ae.canInlineImage(x)&&v){const N=document.createElement("a");N.href=v,N.target="_blank",N.rel="noopener noreferrer",t.css(N,{display:"inline-block",textDecoration:"none"});const G=document.createElement("img");G.src=v,G.alt=x.name,G.loading="lazy",t.css(G,{maxWidth:"180px",maxHeight:"160px",objectFit:"cover",borderRadius:"10px",border:`1px solid ${t.BORDER_COLOR}`,display:"block"}),N.appendChild(G),h.appendChild(N);continue}const c=v?document.createElement("a"):document.createElement("div");v&&c instanceof HTMLAnchorElement&&(c.href=v,c.target="_blank",c.rel="noopener noreferrer"),t.css(c,{display:"inline-flex",alignItems:"center",gap:"8px",padding:"8px 12px",borderRadius:"10px",border:`1px solid ${t.BORDER_COLOR}`,backgroundColor:p?"rgba(255,255,255,0.12)":t.PANEL_BACKGROUND,color:p?t.BRAND_TEXT_COLOR:t.TEXT_COLOR,fontSize:"13px",textDecoration:"none",maxWidth:"220px"});const g=document.createElement("span");g.textContent="📄",g.setAttribute("aria-hidden","true"),t.css(g,{fontSize:"16px",lineHeight:"1",flexShrink:"0"});const A=t.div({display:"flex",flexDirection:"column",minWidth:"0"}),q=t.div({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"160px"});q.textContent=x.name,q.title=x.name,A.appendChild(q);const D=ae.formatFileSize(x.fileSize);if(D){const N=t.div({fontSize:"11px",color:t.MUTED_TEXT_COLOR});N.textContent=D,A.appendChild(N)}c.append(g,A),h.appendChild(c)}M.appendChild(h)}const H=p||_||R,B=!!o.content||o.status==="IN_PROGRESS"||o.status==="WAITING_CLIENT",O=t.div({maxWidth:H?R||p?u?"88%":"75%":u?"92%":"85%":"100%",padding:H?"10px 14px":"2px 8px",borderRadius:R?t.MESSAGE_RADIUS_IMESSAGE:H?t.MESSAGE_RADIUS:"0",backgroundColor:p?t.BRAND_COLOR:H?t.AGENT_BUBBLE_BACKGROUND:"transparent",color:p?t.BRAND_TEXT_COLOR:t.TEXT_COLOR,overflowWrap:"break-word",textWrap:"pretty",fontSize:"16px",lineHeight:"1.6"});if(O.className="ago-message__content",R&&r){O.style.position="relative";const h=t.div({position:"absolute",zIndex:"0",bottom:"-2px",width:"20px",height:"20px",background:p?t.BRAND_COLOR:t.AGENT_BUBBLE_BACKGROUND});h.className="ago-message__tail";const x=t.div({position:"absolute",zIndex:"1",bottom:"-2px",width:"10px",height:"20px",background:t.MESSAGES_BACKGROUND});x.className="ago-message__tail-mask",p?(h.style.right="-8px",h.style.borderBottomLeftRadius="16px 14px",x.style.right="-10px",x.style.borderBottomLeftRadius="10px"):(h.style.left="-7px",h.style.borderBottomRightRadius="16px 14px",x.style.left="-10px",x.style.borderBottomRightRadius="10px"),O.append(h,x)}if(o.content?O.appendChild(Le(o.content)):(o.status==="IN_PROGRESS"||o.status==="WAITING_CLIENT")&&O.appendChild(dn()),B&&M.appendChild(O),s&&o.followUpReplies&&o.followUpReplies.length>0){const h=t.div({display:"flex",flexWrap:"wrap",gap:"8px",marginTop:"10px"});h.className="ago-message__followups";for(const x of o.followUpReplies){const v=document.createElement("button");v.type="button",v.className="ago-message__followup-btn",v.textContent=x,v.disabled=!m,t.css(v,{minHeight:"44px",padding:"6px 14px",fontSize:"14px",borderRadius:t.MESSAGE_RADIUS,border:`1px solid ${t.BORDER_COLOR}`,backgroundColor:t.PANEL_BACKGROUND,color:t.TEXT_COLOR,cursor:m?"pointer":"default",transition:"border-color 0.15s"}),y&&v.addEventListener("click",()=>y(x)),v.addEventListener("mouseenter",()=>{v.style.borderColor=t.ACCENT_COLOR}),v.addEventListener("mouseleave",()=>{v.style.borderColor=t.BORDER_COLOR}),h.appendChild(v)}M.appendChild(h)}return M}function ln(o){const i=t.div({display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",backgroundColor:"#f0fdf4",color:"#15803d",borderRadius:t.MESSAGE_RADIUS,marginTop:"8px",fontSize:"13px",border:"1px solid #bbf7d0"});i.className="ago-form-notice",i.setAttribute("role","status");const s=document.createElement("span");s.textContent="✓",s.setAttribute("aria-hidden","true"),t.css(s,{fontWeight:"700"});const r=document.createElement("span");return r.textContent=o,i.append(s,r),i}function dn(){const o=t.div({display:"flex",gap:"4px",padding:"4px 0"});for(let i=0;i<3;i++){const s=t.div({width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"currentColor",opacity:"0.55",animation:"ago-pulse 1.2s ease-in-out infinite",animationDelay:`${i*.2}s`});o.appendChild(s)}return o}function cn(){const o="http://www.w3.org/2000/svg",i=document.createElementNS(o,"svg");i.setAttribute("width","26"),i.setAttribute("height","26"),i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("fill","none");const s=document.createElementNS(o,"path");return s.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"),s.setAttribute("stroke","currentColor"),s.setAttribute("stroke-width","2"),s.setAttribute("stroke-linecap","round"),s.setAttribute("stroke-linejoin","round"),i.appendChild(s),i}var Et="Form submitted.";function pn(o){if(typeof o=="string")return o||null;if(!o||typeof o!="object")return null;const i=o;if(typeof i.message=="string"&&i.message)return i.message;const s=i.result;if(typeof s=="string"&&s)return s;if(s&&typeof s=="object"){const r=s.message;if(typeof r=="string"&&r)return r}return null}var fn=0;function un(o){const i=typeof o=="string"?document.querySelector(o):o;if(!i)throw new Error(`mountChatWidget: target "${String(o)}" not found.`);return i}function hn(o,i){const{title:s="Chat",welcomeMessage:r="Hello! How can I help you today?",placeholder:C="Type a message...",allowFiles:a=!1,allowStop:_=!0,height:m=500,placement:y="inline",width:u=400,defaultOpen:p=!1,logoUrl:R,showAgentName:M=!1,agentBubble:H=!1,bubbleStyle:B="default",showHeader:O=!0,theme:h,loadThreads:x=!1,forms:v,formSubmittedMessage:c=Et,onFollowUpClick:g,onMessageSent:A,onMessageReceived:q,onFormSubmitted:D,onFormError:N,onOpen:G,onClose:je}=i,te=typeof r=="string"?{message:r,mode:"static"}:r,qe=te.message,Ve=te.mode??"static",Lt="speed"in te&&te.speed||45,Ke="followUpReplies"in te&&te.followUpReplies||void 0;if(!i.client&&!i.config?.baseUrl)throw new ae.AgoError("mountChatWidget requires either `client` or `config` (with a baseUrl).","config_missing_base_url");const w=i.client??new ae.AgoClient(i.config),Qe=un(o),L=y==="left"||y==="right",Tt=L&&(i.launcher??!0);let Z=L?p:!0,Te=!1;const kt=i.mobile?.breakpoint??768,ke=i.mobile?.trigger??"tap",Je=typeof window<"u"&&!!window.matchMedia,I=Je?window.matchMedia(`(max-width: ${kt}px), (max-height: 500px) and (orientation: landscape)`):void 0,Nt=Je?window.matchMedia("(prefers-reduced-motion: reduce)"):void 0,It=!!I,de=!L&&!!I,ce=Symbol("ago-scroll-lock");let ne=!1;const Ne=i.persistConversation,me=Ne?en.createConversationSession(Ne===!0?{}:Ne):void 0;let W=i.conversationId??me?.getLastActiveThread()??void 0,f=[],ge=[],X=!1,oe=null,V;const Ie=[];function Bt(e){if(typeof c=="function"){const d=c(e);if(typeof d=="string"&&d)return d}const n=pn(e);return n||(typeof c=="string"?c:Et)}const xe=[],l=t.div({display:"flex",flexDirection:"column",height:L?"100%":typeof m=="number"?`${m}px`:m,border:`1px solid ${t.BORDER_COLOR}`,borderRadius:t.RADIUS,overflow:"hidden",backgroundColor:t.PANEL_BACKGROUND,fontFamily:t.FONT_VAR,textAlign:"left",boxShadow:"rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"});l.className="ago-chat-widget",t.applyTheme(l,h);let z;if(O){if(z=t.div({padding:"14px 16px",borderBottom:`1px solid ${t.BORDER_COLOR}`,backgroundColor:t.HEADER_BACKGROUND,color:t.HEADER_TEXT_COLOR,display:"flex",alignItems:"center",gap:"10px"}),z.className="ago-chat-widget__header",R){const n=document.createElement("img");n.src=R,n.alt="Logo",t.css(n,{height:"24px",width:"auto"}),z.appendChild(n)}const e=document.createElement("h3");if(e.textContent=s,t.css(e,{margin:"0",fontSize:"15px",fontWeight:"600"}),z.appendChild(e),L){const n=document.createElement("button");n.type="button",n.className="ago-chat-widget__close",n.setAttribute("aria-label","Close"),n.textContent="×",t.css(n,{marginLeft:"auto",flexShrink:"0",display:"flex",alignItems:"center",justifyContent:"center",width:"44px",height:"44px",margin:"-10px -10px -10px auto",background:"transparent",border:"none",color:t.HEADER_TEXT_COLOR,fontSize:"22px",lineHeight:"1",cursor:"pointer",padding:"0"}),n.addEventListener("click",()=>Se()),z.appendChild(n)}}const E=t.div({flex:"1",overflow:"auto",overscrollBehavior:"contain",padding:"16px",backgroundColor:t.MESSAGES_BACKGROUND});E.className="ago-chat-widget__messages",E.setAttribute("role","log"),E.setAttribute("aria-live","polite"),E.setAttribute("aria-relevant","additions text"),E.setAttribute("aria-atomic","false");const Dt=48;let ie=!0,Be=0;function be(e){Be++;try{e()}finally{const n=()=>{Be--};typeof queueMicrotask=="function"?queueMicrotask(n):n()}}function $t(){return E.scrollHeight-E.scrollTop-E.clientHeight<=Dt}const K=document.createElement("button");K.type="button",K.className="ago-chat-widget__jump",K.setAttribute("aria-label","Jump to latest message"),K.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 5v14M19 12l-7 7-7-7"/></svg>',t.css(K,{position:"absolute",left:"50%",bottom:"12px",transform:"translateX(-50%)",width:"44px",height:"44px",display:"none",alignItems:"center",justifyContent:"center",border:`1px solid ${t.BORDER_COLOR}`,borderRadius:"50%",backgroundColor:t.PANEL_BACKGROUND,color:t.TEXT_COLOR,boxShadow:"rgba(15, 15, 15, 0.16) 0px 2px 10px 0px",cursor:"pointer",zIndex:"2"}),K.addEventListener("click",()=>{ie=!0,be(()=>{E.scrollTop=E.scrollHeight}),De()});function De(){K.style.display=ie?"none":"flex"}function $e(){ie&&be(()=>{E.scrollTop=E.scrollHeight}),De()}E.addEventListener("scroll",()=>{Be>0||(ie=$t(),De())});const Ye=t.div({position:"relative",flex:"1",display:"flex",minHeight:"0"});Ye.append(E,K);const{inputRow:Me,setDisabled:Mt,focus:ve,restoreDraft:Ht}=tn({placeholder:C,allowFiles:a,onSend:(e,n)=>{Ee(e,n)},onStop:_?()=>{ft()}:void 0});t.ensureKeyframes(),l.append(...z?[z]:[],Ye,Me);let Ce=l,T,$;const ye=y==="left"?"left":"right";if(L&&(T=t.div({position:"fixed",top:"0",bottom:"0",[ye]:"0",width:typeof u=="number"?`${u}px`:u,maxWidth:"100vw",display:"flex",zIndex:"2147483000",transition:"transform 0.3s ease",boxShadow:"rgba(15, 15, 15, 0.18) 0px 0px 24px 0px"}),T.className="ago-chat-widget-panel",t.css(l,{height:"100%",width:"100%",borderRadius:"0",border:"none",boxShadow:"none",[ye==="left"?"borderRight":"borderLeft"]:`1px solid ${t.BORDER_COLOR}`}),T.appendChild(l),Ce=T),Tt){if($=document.createElement("button"),$.type="button",$.className="ago-chat-widget-launcher",$.setAttribute("aria-label",`Open ${s}`),t.css($,{position:"fixed",bottom:"20px",[ye]:"20px",width:"56px",height:"56px",borderRadius:"50%",border:"none",backgroundColor:t.BRAND_COLOR,color:t.BRAND_TEXT_COLOR,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",zIndex:"2147483000",boxShadow:"rgba(15, 15, 15, 0.2) 0px 4px 14px 0px",fontFamily:t.FONT_VAR}),R){const e=document.createElement("img");e.src=R,e.alt="",t.css(e,{width:"26px",height:"26px",objectFit:"contain"}),$.appendChild(e)}else $.appendChild(cn());$.addEventListener("click",()=>ze())}const pe=de?`ago-vt-${++fn}`:"",Ze=52;let j=!1,Q=0,re=0,P,fe,J;const we={height:l.style.height,border:l.style.border,borderRadius:l.style.borderRadius,boxShadow:l.style.boxShadow};Qe.appendChild(Ce),$&&Qe.appendChild($),Re(),de&&(P=Jt(),l.insertBefore(P,l.firstChild),fe=document.createElement("style"),fe.id=pe,fe.textContent=`::view-transition-group(${pe}),::view-transition-group(${pe}-bar){animation-duration:0.3s;animation-timing-function:cubic-bezier(0.4,0,0.2,1)}`,document.head.appendChild(fe),(ke==="focus"||ke==="tap")&&(l.addEventListener("pointerdown",e=>{if(j||!I?.matches)return;const n=Me.contains(e.target);if(ke==="tap"){if((e.target instanceof Element?e.target:null)?.closest("button,a[href],[role='button']"))return}else if(!n)return;n&&e.preventDefault(),ue()},!0),l.addEventListener("focusin",e=>{I?.matches&&Me.contains(e.target)&&ue()}))),It&&document.addEventListener("keydown",ht),I&&I.addEventListener("change",mt);const Ut=g!==!1,zt=g===!1?void 0:g??(e=>{de&&I?.matches&&!j?ue().then(()=>Ee(e)):Ee(e)});function et(e){const n=f.length-1;return{isLast:e===n,isLastOfBlock:e===n||f[e+1].role!==f[e].role,bubbleStyle:B,showAgentName:M,agentBubble:H,followUpEnabled:Ut,followUpHandler:zt,isMobile:!!I?.matches}}function Pt(){if(oe||Ie.length>0)return!1;const e=f.length-1,n=f[e];if(!n||n.role!=="assistant")return!1;const d=ge[e];if(!d||d.parentNode!==E)return!1;const S=wt(n,et(e));return be(()=>E.replaceChild(S,d)),ge[e]=S,$e(),!0}function k(){be(Ft),$e();const e=f[f.length-1],n=X&&e?.role==="assistant"&&(e.status==="IN_PROGRESS"||e.status==="WAITING_CLIENT");E.setAttribute("aria-busy",n?"true":"false"),Mt(n)}function Ft(){if(E.replaceChildren(),ge=[],f.length===0){if(Ve==="static"){const e=t.div({textAlign:"center",color:t.MUTED_TEXT_COLOR,padding:"24px 16px",fontSize:"16px",lineHeight:"1.5"});e.appendChild(Le(qe)),E.appendChild(e)}}else f.forEach((e,n)=>{const d=wt(e,et(n));ge[n]=d,E.appendChild(d)});for(const e of Ie)E.appendChild(ln(e));if(oe){const e=t.div({padding:"10px 14px",backgroundColor:"#fef2f2",color:"#dc2626",borderRadius:"12px",marginTop:"8px",fontSize:"13px",border:"1px solid #fecaca"});e.setAttribute("role","alert"),e.textContent=oe,E.appendChild(e)}}function tt(){for(let e=f.length-1;e>=0;e--){const n=f[e];if(n.role==="assistant"&&(n.status==="IN_PROGRESS"||n.status==="WAITING_CLIENT"))return n}}const nt=e=>{W||(W=e.conversationId)},ot=e=>{const n=tt();n&&(n.content+=e.content,Pt()||k())},it=e=>{const n=f.findIndex(d=>d.id===e.id||d.role==="assistant"&&d.status==="IN_PROGRESS");n>=0?f[n]=e:f.push(e),k(),Pe()||ve()},rt=e=>{const n=f.findIndex(d=>d.id===e.id||d.role==="assistant"&&d.status==="IN_PROGRESS");n>=0?f[n]=e:f.push(e),X=!1,k(),e.status==="DONE"&&q?.({id:e.id,content:e.content})},st=()=>{const e=tt();e&&(e.content?e.status="CANCELED":f=f.filter(n=>n!==e)),X=!1,k()},at=e=>{oe=e.error,X=!1,f=f.filter(n=>!n.id.startsWith("temp-")),k()};function Gt(e){const n={id:`ago-intro-${Date.now()}`,conversationId:"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date};f.push(n),k();const d=e.match(/\S+\s*/g)??[e];let S=0;V=setInterval(()=>{if(S>=d.length){clearInterval(V),V=void 0,n.status="DONE",Ke&&(n.followUpReplies=Ke),k();return}n.content+=d[S],S++,k()},Lt)}w.on("message:start",nt),w.on("message:chunk",ot),w.on("message:answer-complete",it),w.on("message:complete",rt),w.on("message:stopped",st),w.on("message:error",at);const lt=e=>D?.(e),dt=e=>N?.(e);D&&w.on("form:submitted",lt),N&&w.on("form:error",dt);const He=[];let ct=!1;const pt=e=>{if(ct)return;He.push(e.install(w));let n=e.store.get().submitted;const d=e.store.subscribe(S=>{S.submitted&&!n&&(Ie.push(Bt(S.submitResult)),k()),n=S.submitted});He.push(d)};for(const e of v??[])e.schema!=null?pt(Ct.createFormCollector(e)):Ct.loadFormCollector(w,e).then(n=>pt(n)).catch(()=>{});async function Ee(e,n){const d=e.trim();if(!d&&!n?.length||X)return;if(A?.(d),X=!0,oe=null,ie=!0,V){clearInterval(V),V=void 0;const b=f.find(F=>F.id.startsWith("ago-intro-"));b&&!b.content?f=f.filter(F=>F!==b):b&&(b.status="DONE")}const S=Date.now();f.push({id:`temp-user-${S}`,conversationId:W||"",content:d,role:"user",status:"DONE",attachments:n&&n.length>0?ae.attachmentsFromFiles(n):void 0,createdAt:new Date}),f.push({id:`temp-assistant-${S}`,conversationId:W||"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date}),k();try{const b=await w.sendMessage(d,{conversationId:W,files:n});b.conversationId&&(W||(W=b.conversationId),me?.setActiveThread(b.conversationId,b.createdAt));const F=f.find(Y=>Y.id===`temp-user-${S}`);if(F&&(F.id=`user-${S}`,F.conversationId=b.conversationId),b.id&&!f.some(Y=>Y.id===b.id)){const Y=f.findIndex(Zt=>Zt.id===`temp-assistant-${S}`);Y>=0?f[Y]=b:f.push(b)}f=f.filter(Y=>!Y.id.startsWith("temp-")),b.status!=="WAITING_CLIENT"&&(X=!1),k(),x&&Ue()}catch(b){oe=b instanceof Error?b.message:"Failed to send message",X=!1,f=f.filter(F=>!F.id.startsWith("temp-")),Ht(d,n),k()}}async function ft(){X&&await w.stop()}async function Ue(){try{const{data:e}=await w.getConversations();xe.splice(0,xe.length,...e)}catch{}return xe}async function Wt(e){try{const n=(await w.getConversation(e))?.messages??[];n.length>0&&f.length===0&&(f=n,k())}catch{f.length===0&&(me?.clear(),W=void 0)}}return k(),de&&I?.matches||ve(),W?Wt(W):Ve==="streaming"&&Gt(qe),x&&Ue(),{client:w,element:Ce,sendMessage:Ee,stop:ft,...L||de?{open:jt,close:qt,toggle:Vt}:{},session:me,threads:xe,refreshThreads:Ue,destroy(){ne||(ne=!0,V&&clearInterval(V),w.off("message:start",nt),w.off("message:chunk",ot),w.off("message:answer-complete",it),w.off("message:complete",rt),w.off("message:stopped",st),w.off("message:error",at),D&&w.off("form:submitted",lt),N&&w.off("form:error",dt),ct=!0,He.forEach(e=>e()),Ce.remove(),$?.remove(),P?.remove(),fe?.remove(),J?.remove(),I?.removeEventListener("change",mt),document.removeEventListener("keydown",ht),We(),Te=!1,t.unlockBackgroundScroll(ce),i.client||w.destroy())}};function Re(){if(!T)return;{const d=ye==="left"?"border-right":"border-left";I?.matches?(T.style.width="100%",l.style.borderRadius="0",l.style.removeProperty(d)):(T.style.width=typeof u=="number"?`${u}px`:u,l.style.setProperty(d,`1px solid ${t.BORDER_COLOR}`))}const e=y==="left"?"translateX(-100%)":"translateX(100%)";T.style.transform=Z?"translateX(0)":e,T.setAttribute("aria-hidden",Z?"false":"true"),$&&($.style.display=Z?"none":"flex");const n=ut();n!==Te&&(Te=n,n?(l.setAttribute("role","dialog"),l.setAttribute("aria-modal","true"),l.setAttribute("aria-label",s),l.tabIndex=-1,l.style.paddingBottom="env(safe-area-inset-bottom)",t.lockBackgroundScroll(ce),Q=Fe(),Ge(),gt()):(We(),Qt(),Q=0,l.removeAttribute("role"),l.removeAttribute("aria-modal"),l.removeAttribute("aria-label"),l.style.removeProperty("padding-bottom"),t.unlockBackgroundScroll(ce)))}function ze(){Z=!0,Re(),Pe()?l.focus({preventScroll:!0}):ve(),G?.()}function Se(){Z=!1,Re(),je?.()}function Xt(){Z?Se():ze()}function jt(){L?ze():ue()}function qt(){L?Se():he()}function Vt(){L?Xt():j?he():ue()}function Pe(){return!!I?.matches}function ut(){return Pe()&&(L?Z:j)}function Kt(){return Array.from(l.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 ht(e){if(!ut())return;if(e.key==="Escape"){L?Se():he();return}if(e.key!=="Tab")return;const n=Kt();if(n.length===0){e.preventDefault();return}const d=n[0],S=n[n.length-1],b=document.activeElement;e.shiftKey&&(b===d||!l.contains(b))?(e.preventDefault(),S.focus()):!e.shiftKey&&(b===S||!l.contains(b))&&(e.preventDefault(),d.focus())}function mt(e){L?Re():!e.matches&&j&&he(),k()}function Fe(){return window.visualViewport?.height??window.innerHeight}function Ge(){const e=window.visualViewport,n=e?.offsetTop??0,d=e?.height??Q;if(L){if(!T)return;const b=window.innerHeight||Q,F=Math.max(0,b-(n+d));T.style.bottom=`${F}px`,T.style.top=`${n}px`;return}const S=Math.min(0,n+d-Q);l.style.top=`${S}px`,P&&(P.style.top=`${n}px`)}function Qt(){L&&T&&(T.style.removeProperty("bottom"),T.style.removeProperty("top"))}function _e(){re||(re=requestAnimationFrame(()=>{re=0,!ne&&Ge()}))}function gt(){window.visualViewport?.addEventListener("resize",_e),window.visualViewport?.addEventListener("scroll",_e)}function We(){window.visualViewport?.removeEventListener("resize",_e),window.visualViewport?.removeEventListener("scroll",_e),re&&(cancelAnimationFrame(re),re=0)}function xt(){ie=!0,$e()}function Jt(){const e=t.div({position:"fixed",top:"0",left:"0",right:"0",height:`calc(${Ze}px + env(safe-area-inset-top))`,display:"none",alignItems:"center",justifyContent:"space-between",padding:"env(safe-area-inset-top) 14px 0",backgroundColor:t.PANEL_BACKGROUND,borderBottom:`1px solid ${t.BORDER_COLOR}`,zIndex:"2147483001",fontFamily:t.FONT_VAR});if(e.className="ago-chat-widget-mobile-bar",R){const d=document.createElement("img");d.src=R,d.alt="",t.css(d,{height:"28px",width:"auto"}),e.appendChild(d)}else if(s){const d=document.createElement("span");d.textContent=s,t.css(d,{fontSize:"15px",fontWeight:"600",color:t.TEXT_COLOR,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"}),e.appendChild(d)}else e.appendChild(t.div({}));const n=document.createElement("button");return n.type="button",n.setAttribute("aria-label","Close"),n.textContent="×",t.css(n,{flexShrink:"0",width:"44px",height:"44px",marginRight:"-10px",display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",fontSize:"26px",lineHeight:"1",color:t.TEXT_COLOR,cursor:"pointer",padding:"0"}),n.addEventListener("click",()=>{he()}),e.appendChild(n),e}function Yt(){return typeof document.startViewTransition=="function"&&!Nt?.matches&&!!I?.matches}function bt(e){const n=document;if(Yt()&&n.startViewTransition){l.style.setProperty("view-transition-name",pe),P?.style.setProperty("view-transition-name",`${pe}-bar`);const d=()=>{l.style.removeProperty("view-transition-name"),P?.style.removeProperty("view-transition-name")};return n.startViewTransition(e).finished.then(d,d)}return e(),Promise.resolve()}function vt(e){if(e)J&&l.parentElement?.insertBefore(J,l),t.css(l,{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(${Ze}px + env(safe-area-inset-top))`,paddingBottom:"env(safe-area-inset-bottom)"}),l.setAttribute("role","dialog"),l.setAttribute("aria-modal","true"),l.setAttribute("aria-label",s),z&&(z.style.display="none"),P&&(P.style.display="flex");else{J?.remove(),J=void 0;for(const n of["position","top","left","right","bottom","z-index","padding-top","padding-bottom"])l.style.removeProperty(n);l.style.height=we.height,l.style.border=we.border,l.style.borderRadius=we.borderRadius,l.style.boxShadow=we.boxShadow,l.removeAttribute("role"),l.removeAttribute("aria-modal"),l.removeAttribute("aria-label"),z&&(z.style.display="flex"),P&&(P.style.display="none")}}function ue(){if(ne||j||!I?.matches)return Promise.resolve();const e=l.getBoundingClientRect();if(e.height>=Fe()*.8)return Promise.resolve();j=!0,J=t.div({width:`${e.width}px`,height:`${e.height}px`}),J.className="ago-chat-widget-spacer",J.setAttribute("aria-hidden","true"),Q=Fe(),l.style.setProperty("--ago-vh",`${Q}px`),Ge(),gt(),t.lockBackgroundScroll(ce);const n=bt(()=>vt(!0));return n.then(()=>{ne||(xt(),ve())}),xt(),G?.(),n}function he(){if(!j)return Promise.resolve();j=!1,We(),t.unlockBackgroundScroll(ce),l.querySelector("textarea")?.blur();const e=bt(()=>vt(!1));return e.then(()=>{ne||l.style.removeProperty("--ago-vh")}),Q=0,je?.(),e}}exports.compactMediaQuery=t.compactMediaQuery;exports.createSheetController=t.createSheetController;exports.mountChatWidget=hn;exports.renderMarkdown=Le;
|