@helpai/elements 0.10.0 → 0.10.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/elements-web-component.esm.js +1 -1
- package/elements-web-component.esm.js.map +3 -3
- package/elements.cjs.js +1 -1
- package/elements.cjs.js.map +3 -3
- package/elements.esm.js +1 -1
- package/elements.esm.js.map +3 -3
- package/elements.js +1 -1
- package/elements.js.map +3 -3
- package/index.mjs +2 -2
- package/package.json +1 -1
- package/web-component.mjs +2 -2
package/elements.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
`))!==-1;){let l=o.slice(0,s);o=o.slice(s+2);let c=Zi(l);c&&(yield c)}}}finally{n.releaseLock()}}function Zi(e){let t="",n;for(let o of e.split(`
|
|
10
10
|
`))if(!(o===""||o.startsWith(":"))){if(o.startsWith("data:")){let i=o.slice(5).replace(/^ /,"");t=t?`${t}
|
|
11
|
-
${i}`:i;continue}o.startsWith("id:")&&(n=o.slice(3).trim())}if(!t||t==="[DONE]")return null;try{let o=JSON.parse(t);return Qi.trace("chunk",{type:o.type,eventId:n}),{chunk:o,eventId:n}}catch(o){return Qi.trace("frame parse failed",{err:o,payload:t.slice(0,200)}),null}}function Hc(e){let t=new TextEncoder().encode(e),n="";for(let o of t)n+=String.fromCharCode(o);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}var ea=e=>e&&Object.keys(e).length>0?e:void 0;function ta(e,t){let n=ea(e),o=ea(t);if(!n&&!o)return;let i={};return n&&(i.user=n),o&&(i.page=o),Hc(JSON.stringify(i))}var Ee={startSession:"/ai/agent/start-session",streamMessage:"/ai/agent/stream-message",streamResume:"/ai/agent/stream-resume",cancelStream:"/ai/agent/cancel-stream",listSessions:"/ai/agent/list-sessions",listMessages:"/ai/agent/list-messages",updateSettings:"/ai/agent/update-settings",markRead:"/ai/agent/mark-read",content:"/ai/agent/content"},na="context";function oa(e){let n={messages:e.messages.map(a=>({id:a.id,parts:$c(a),role:a.role})),sessionId:e.sessionId,trigger:e.trigger??"submit-message"};e.visitorId&&(n.visitorId=e.visitorId),e.userPrefs&&(n.userPrefs=e.userPrefs);let o={},i=e.tools?.map(Bc).filter(a=>a!==null);return i?.length&&(o.tools=i),e.responseMode&&(o.responseMode=e.responseMode),Object.keys(o).length>0&&(n.data=o),n}function Bc(e){return typeof e=="string"?e?{code:e}:null:e?.code?e:null}function $c(e){let t=[];for(let n of e.parts)n.kind==="text"&&n.text&&t.push({text:n.text,type:"text"}),n.kind==="file"&&n.url&&t.push({mediaType:n.mediaType,type:"file",url:n.url});for(let n of e.attachments??[])n.url&&t.push({type:"file",url:n.url,mediaType:n.mediaType,filename:n.name,fileId:n.id,fileSize:n.size});return t}var q=M.scope("transport"),Uc=3,aa=400,ra=3,zc=new Set([408,425,429,500,502,503,504]);function ia(e){return aa*2**e+Math.floor(Math.random()*250)}function Fc(e){let t=e.get("retry-after");if(!t)return null;let n=Number(t),o=Number.isFinite(n)?n*1e3:Date.parse(t)-Date.now();return Number.isFinite(o)&&o>=0?Math.min(o,3e4):null}function Fo(e,t){return new Promise(n=>{if(t?.aborted)return n();let o=setTimeout(a,e),i=()=>a();t?.addEventListener("abort",i,{once:!0});function a(){clearTimeout(o),t?.removeEventListener("abort",i),n()}})}var Sn=class{constructor(t){H(this,"opts",t);H(this,"visitorId");H(this,"sessionId");H(this,"userContext");H(this,"pageContext")}setContext(t,n){this.userContext=t,this.pageContext=n}primeIdentity(t,n){t&&(this.visitorId=t),n&&(this.sessionId=n)}envelope(){let t={};this.visitorId&&(t.visitorId=this.visitorId),this.sessionId&&(t.sessionId=this.sessionId);let n=ta(this.userContext,this.pageContext);return n&&(t[na]=n),t}withEnvelope(t){return{...this.envelope(),...t}}appendEnvelope(t){for(let[n,o]of Object.entries(this.envelope()))t.append(n,o);return t}withEnvelopeQuery(t){let n=new URL(this.url(t));for(let[o,i]of Object.entries(this.envelope()))n.searchParams.has(o)||n.searchParams.set(o,i);return n.toString()}async startSession(t){q.debug("startSession \u2192",{visitorId:t.visitorId,sessionId:t.sessionId,locale:t.locale});let n=await this.postJson(Ee.startSession,t,"startSession");return q.debug("startSession \u2190",{visitorId:n.visitorId,sessionId:n.sessionId,canContinue:n.canContinue,hasMessages:!!n.messages?.length,hasWelcome:!!n.welcome,hasConfig:!!n.config,rebind:n.rebind}),Gc(n)||q.warn("startSession response did not match expected shape; using raw response",{response:n}),this.visitorId=n.visitorId??t.visitorId,this.sessionId=n.sessionId,n}async uploadFile(t){q.debug("uploadFile \u2192",{name:t.name,size:t.size,type:t.type});let n=new FormData;n.append("file",t,t.name);let o=await this.postForm(this.uploadPath,n,"upload");return q.debug("uploadFile \u2190",{id:o.id,url:o.url}),o}async transcribe(t,n="audio/webm"){q.debug("transcribe \u2192",{size:t.size,mimeType:n});let o=new FormData;o.append("audio",t,`voice.${Wc(n)}`),o.append("mimeType",n);let i=await this.postForm(this.transcribePath,o,"transcribe");return q.debug("transcribe \u2190",{textLen:i.text.length}),i}async listSessions(t={}){let n=new URL(this.url(Ee.listSessions));t.visitorId&&n.searchParams.set("visitorId",t.visitorId),t.limit&&n.searchParams.set("limit",String(t.limit)),t.cursor&&n.searchParams.set("cursor",t.cursor),q.debug("listSessions \u2192",{visitorId:t.visitorId??this.visitorId,limit:t.limit,cursor:t.cursor});let o=await this.getJson(n.toString(),"listSessions"),i=o.sessions??[];return q.debug("listSessions \u2190",{count:i.length,nextCursor:o.nextCursor}),{sessions:i.map(a=>({sessionId:a.sessionId,title:a.title,lastMessageAt:a.lastMessageAt,preview:a.preview,canContinue:a.canContinue,unreadCount:a.unreadCount})),nextCursor:o.nextCursor}}async loadSession(t){let n=new URL(this.url(Ee.listMessages));n.searchParams.set("sessionId",t),q.debug("loadSession \u2192",{sessionId:t,visitorId:this.visitorId});let o=await this.getJson(n.toString(),"loadSession"),i=o.messages??[];return q.debug("loadSession \u2190",{sessionId:o.sessionId,canContinue:o.canContinue,messageCount:i.length,hasSuggestions:!!o.suggestions}),{sessionId:o.sessionId,canContinue:o.canContinue??!0,messages:i,agent:o.agent,suggestions:o.suggestions}}async markRead(t){if(!(!this.visitorId||!t)){q.debug("markRead \u2192",{sessionId:t,visitorId:this.visitorId});try{await this.postJson(Ee.markRead,{sessionId:t},"markRead")}catch(n){q.debug("markRead failed (non-fatal)",{err:n})}}}async listContent(t={}){let n=new URL(this.url(Ee.content));for(let[a,s]of Object.entries(t))s!==void 0&&n.searchParams.set(a,Array.isArray(s)?s.join(","):String(s));q.debug("listContent \u2192",t);let o=await this.getJson(n.toString(),"listContent"),i=o.items??[];return q.debug("listContent \u2190",{count:i.length,total:o.pagination?.total}),{...o,items:i}}async saveUserPrefs(t){q.debug("saveUserPrefs \u2192",{visitorId:this.visitorId,sessionId:this.sessionId,settingsKeys:Object.keys(t)});let n=await this.postJson(Ee.updateSettings,{userPrefs:t},"saveUserPrefs");return q.debug("saveUserPrefs \u2190",{ok:n.ok}),n}get uploadPath(){return this.opts.endpoints?.upload??"/ai/agent/upload-file"}get transcribePath(){return this.opts.endpoints?.transcribe??"/ai/agent/transcribe-audio"}sendMessage(t){q.debug("message \u2192",{sessionId:t.sessionId,visitorId:t.visitorId,messageCount:t.messages.length,trigger:t.trigger,responseMode:t.data?.responseMode,tools:t.data?.tools?.map(s=>s.code)});let n=new AbortController,o=new Set;return{iter:this.runStream(t,n,o),cancel:()=>this.cancelStream(n,t.sessionId)}}resumeStream(){let t=new AbortController,n=new Set;return{iter:this.resumeStreamGen(t,n,!0),cancel:()=>t.abort()}}async*runStream(t,n,o){(yield*this.drain(this.openMessageStream(t,n.signal),o,n))||(yield*this.resumeStreamGen(n,o,!1))}async*resumeStreamGen(t,n,o){for(let i=1;i<=Uc&&!t.signal.aborted;i++){if((!o||i>1)&&(await Fo(aa*i,t.signal),t.signal.aborted))return;let a;try{a=await this.fetchImpl(this.resumeUrl(n.size),{method:"GET",credentials:"omit",headers:{accept:"text/event-stream",...this.opts.auth.headers()},signal:t.signal})}catch(l){if(t.signal.aborted)return;q.debug("resume fetch failed \u2014 retrying",{attempt:i,err:l});continue}if(a.status===204||!a.ok){q.debug("resume \u2192 no in-flight stream",{status:a.status});return}let s=n.size;if(yield*this.drain(zo(a,t.signal),n,t))return;if(n.size===s){q.debug("resume \u2192 stream closed with no new events; nothing to resume");return}}if(!t.signal.aborted)throw new ve("stream incomplete after resume attempts","server")}async*drain(t,n,o){try{for await(let i of t){if(o.signal.aborted)return!0;if(i.eventId){if(n.has(i.eventId))continue;n.add(i.eventId)}if(yield i,i.chunk.type==="finish"||i.chunk.type==="error")return!0}}catch(i){if(o.signal.aborted)return!0;if(i instanceof ve&&i.status!==void 0)throw i;q.debug("stream segment dropped",{err:i})}return!1}cancelStream(t,n){t.signal.aborted||(q.debug("cancel stream",{sessionId:n,visitorId:this.visitorId}),t.abort(),!(!this.visitorId||!n)&&this.fetchImpl(this.url(Ee.cancelStream),{method:"POST",credentials:"omit",headers:{"content-type":"application/json",...this.opts.auth.headers()},body:JSON.stringify(this.withEnvelope({})),keepalive:!0}).catch(o=>q.debug("cancel POST failed (non-fatal)",{err:o})))}async*openMessageStream(t,n){let o=await this.fetchImpl(this.url(Ee.streamMessage),{method:"POST",credentials:"omit",headers:{accept:"text/event-stream","content-type":"application/json",...this.opts.auth.headers()},body:JSON.stringify(this.withEnvelope(t)),signal:n});yield*zo(o,n)}resumeUrl(t){let n=new URL(this.withEnvelopeQuery(Ee.streamResume));return n.searchParams.set("resumeAt",String(t)),n.toString()}async postJson(t,n,o){let i=await this.fetchWithRetry(()=>[this.url(t),{method:"POST",credentials:"omit",headers:{"content-type":"application/json",...this.opts.auth.headers()},body:JSON.stringify(this.withEnvelope(n))}],o);return this.assertOk(i,o)}async postForm(t,n,o){let i=await this.fetchImpl(this.url(t),{method:"POST",credentials:"omit",headers:this.opts.auth.headers(),body:this.appendEnvelope(n)});return this.assertOk(i,o)}async getJson(t,n){let o=await this.fetchWithRetry(()=>[this.withEnvelopeQuery(t),{method:"GET",credentials:"omit",headers:{accept:"application/json",...this.opts.auth.headers()}}],n);return this.assertOk(o,n)}async fetchWithRetry(t,n){for(let o=0;;o++){let[i,a]=t(),s;try{s=await this.fetchImpl(i,a)}catch(c){if(o>=ra)throw new ve(`${n} failed: network error`,"network",void 0,c);q.debug("request network error \u2014 retrying",{label:n,attempt:o}),await Fo(ia(o));continue}if(s.ok||!zc.has(s.status)||o>=ra)return s;let l=Fc(s.headers)??ia(o);q.debug("request retryable status \u2014 retrying",{label:n,status:s.status,attempt:o,wait:l}),await Fo(l)}}async assertOk(t,n){if(!t.ok)throw new ve(`${n} failed: ${t.status}`,"server",t.status);return await t.json()}url(t){return/^https?:\/\//i.test(t)?t:`${this.opts.baseUrl}${t}`}get fetchImpl(){return this.opts.fetchImpl??globalThis.fetch.bind(globalThis)}};function Wc(e){return e.includes("webm")?"webm":e.includes("ogg")?"ogg":e.includes("mp4")||e.includes("m4a")?"m4a":e.includes("mpeg")?"mp3":e.includes("wav")?"wav":"bin"}function Gc(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.visitorId=="string"&&typeof t.sessionId=="string"&&typeof t.canContinue=="boolean"}function sa(e,t){let n=e?[{kind:"text",id:"t0",textSig:L(e),doneSig:L(!0)}]:[];return{id:ke(),role:"user",createdAt:Date.now(),status:"complete",attachments:t,partsSig:L(n)}}function Wo(){return{id:ke(),role:"assistant",createdAt:Date.now(),status:"streaming",partsSig:L([])}}function la(e){return{id:e.id,role:e.role,createdAt:Date.now(),status:"streaming",partsSig:L([{kind:"text",id:`${e.id}-t0`,textSig:L(""),doneSig:L(!1)}])}}function ca(e){return Kc({id:e.id,role:e.role,createdAt:Date.now(),status:"complete",parts:[{kind:"text",id:`${e.id}-t0`,text:e.text,done:!0}]})}function Kc(e){return{id:e.id,role:e.role,createdAt:e.createdAt,status:e.status,errorText:e.errorText,finishReason:e.finishReason,attachments:e.attachments,partsSig:L(e.parts.map(Vc))}}function Go(e){let t=e.parts.map((n,o)=>n.type==="text"?{kind:"text",id:`${e.id}-t${o}`,textSig:L(n.text),doneSig:L(!0)}:n.type==="file"?{kind:"file",url:n.url,mediaType:n.mediaType}:null).filter(n=>n!==null);return{id:e.id,role:e.role,createdAt:Date.now(),status:"complete",partsSig:L(t)}}function da(e){return{id:e.id,role:e.role,createdAt:e.createdAt,status:e.status,errorText:e.errorText,finishReason:e.finishReason,attachments:e.attachments,parts:e.partsSig.value.map(qc)}}function Ko(e){let t="";for(let n of e.partsSig.value)n.kind==="text"&&(t+=n.textSig.value);return t}function Vc(e){return e.kind==="text"||e.kind==="reasoning"?{kind:e.kind,id:e.id,textSig:L(e.text),doneSig:L(e.done)}:e.kind==="tool"?{kind:"tool",toolCallId:e.toolCallId,toolName:e.toolName,inputPartialSig:L(e.inputPartial),inputSig:L(e.input),outputSig:L(e.output),errorSig:L(e.error),stateSig:L(e.state)}:e}function qc(e){return e.kind==="text"||e.kind==="reasoning"?{kind:e.kind,id:e.id,text:e.textSig.value,done:e.doneSig.value}:e.kind==="tool"?{kind:"tool",toolCallId:e.toolCallId,toolName:e.toolName,inputPartial:e.inputPartialSig.value,input:e.inputSig.value,output:e.outputSig.value,error:e.errorSig.value,state:e.stateSig.value}:e}var _a=M.scope("reducer"),wn=class{constructor(t){H(this,"messagesSig",t);H(this,"active",null)}attach(t){this.active=t}detach(){this.active=null}apply(t){let n=this.active;if(n)switch(t.type){case"start":case"start-step":case"finish-step":return;case"finish":_a.debug("finish",{reason:t.finishReason,canContinue:t.canContinue}),n.status="complete",t.finishReason&&(n.finishReason=t.finishReason),this.bumpDone(n);return;case"error":_a.warn("stream error chunk",{errorText:t.errorText}),n.status="error",n.errorText=t.errorText,this.bumpDone(n);return;case"text-start":ft(n,"text",t.id);return;case"text-delta":{let o=ft(n,"text",t.id);o.textSig.value+=t.delta;return}case"text-end":ft(n,"text",t.id).doneSig.value=!0;return;case"reasoning-start":ft(n,"reasoning",t.id).doneSig.value=!1;return;case"reasoning-delta":{let o=ft(n,"reasoning",t.id);o.textSig.value+=t.delta;return}case"reasoning-end":ft(n,"reasoning",t.id).doneSig.value=!0;return;case"tool-input-start":case"tool-input-delta":case"tool-input-available":case"tool-output-available":case"tool-output-error":Xc(n,t);return;case"file":kn(n,{kind:"file",url:t.url,mediaType:t.mediaType});return;case"source-url":{if(n.partsSig.value.some(i=>i.kind==="source"&&i.sourceId===t.sourceId))return;kn(n,{kind:"source",sourceId:t.sourceId,url:t.url,title:t.title});return}case"data-notification":return;default:{let o=t}}}bumpDone(t){t.partsSig.value=[...t.partsSig.value],this.messagesSig.value=[...this.messagesSig.value]}};function ft(e,t,n){let o=e.partsSig.value.find(a=>a.kind===t&&a.id===n);if(o)return o;let i={kind:t,id:n,textSig:L(""),doneSig:L(!1)};return kn(e,i),i}function Lt(e,t,n){let o=e.partsSig.value.find(a=>a.kind==="tool"&&a.toolCallId===t);if(o)return o;let i={kind:"tool",toolCallId:t,toolName:n??"tool",inputPartialSig:L(""),inputSig:L(void 0),outputSig:L(void 0),errorSig:L(void 0),stateSig:L("input")};return kn(e,i),i}function kn(e,t){e.partsSig.value=[...e.partsSig.value,t]}function Xc(e,t){switch(t.type){case"tool-input-start":Lt(e,t.toolCallId,t.toolName);return;case"tool-input-delta":{let n=Lt(e,t.toolCallId);n.inputPartialSig.value+=t.delta;return}case"tool-input-available":{let n=Lt(e,t.toolCallId,t.toolName);n.inputSig.value=t.input,n.stateSig.value="awaiting";return}case"tool-output-available":{let n=Lt(e,t.toolCallId);n.outputSig.value=t.output,n.stateSig.value="output";return}case"tool-output-error":{let n=Lt(e,t.toolCallId);n.errorSig.value=t.errorText,n.stateSig.value="error";return}default:return}}var En=M.scope("persistence");function Xe(e,t=Yt){let n=`${v.cssPrefix}.${e}`,o=`${n}.visitorId`,i=`${n}.sessionId`,a=`${n}.userPrefs`,s=`${n}.panelOpen`,l=`${n}.panelSize`,c=`${n}.calloutDismissed`,u=`${n}.sidebarCollapsed`,p=`${n}.activeModule`,d={getVisitorId(){let _=t.get(o);if(_)return _;let f=ke();return t.set(o,f),f},setVisitorId(_){En.debug("setVisitorId (rebind)",{id:_,widgetId:e}),t.set(o,_)},loadSessionId(){return t.get(i)??void 0},saveSessionId(_){En.trace("saveSessionId",{id:_,widgetId:e}),_?t.set(i,_):t.remove(i)},loadUserPrefs(){let _=t.get(a);if(!_)return{};try{let f=JSON.parse(_);return jc(f)?f:{}}catch(f){return En.warn("loadUserPrefs parse failed",{error:f}),{}}},saveUserPrefs(_){try{t.set(a,JSON.stringify(_))}catch(f){En.warn("saveUserPrefs serialise failed",{error:f})}},patchUserPrefs(_){let f=d.loadUserPrefs();d.saveUserPrefs({...f,..._})},loadPanelOpen(){let _=t.get(s);return _==="1"?!0:_==="0"?!1:null},savePanelOpen(_){t.set(s,_?"1":"0")},loadPanelSize(){let _=t.get(l);return _==="normal"||_==="expanded"||_==="fullscreen"?_:null},savePanelSize(_){t.set(l,_)},loadCalloutDismissed(_){if(!_)return!1;let f=t.get(c);return!!f&&f===_},saveCalloutDismissed(_){_?t.set(c,_):t.remove(c)},loadSidebarCollapsed(){let _=t.get(u);return _==="1"?!0:_==="0"?!1:null},saveSidebarCollapsed(_){t.set(u,_?"1":"0")},loadActiveModule(){return t.get(p)||null},saveActiveModule(_){t.set(p,_)},clearSession(){t.remove(i)}};return d}function jc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var ua=M.scope("feedback:audio"),Cn=class{constructor(){H(this,"ctx",null);H(this,"master",null);H(this,"buffers",new Map)}unlock(){if(this.ctx){this.ctx.state==="suspended"&&this.ctx.resume();return}let t=globalThis.AudioContext??globalThis.webkitAudioContext;if(t)try{this.ctx=new t,this.master=this.ctx.createGain(),this.master.gain.value=1,this.master.connect(this.ctx.destination)}catch(n){ua.warn("AudioContext init failed",{err:n})}}setVolume(t){if(!this.master||!this.ctx)return;let n=Math.max(0,Math.min(1,t));this.master.gain.setTargetAtTime(n,this.ctx.currentTime,.01)}playTone(t){let n=this.ctx,o=this.master;if(!n||!o||n.state!=="running")return;let i=n.currentTime,a=t.noteMs/1e3;t.notes.forEach((s,l)=>{let c=n.createOscillator();c.type=t.type,c.frequency.value=s;let u=n.createGain(),p=i+l*a;u.gain.setValueAtTime(1e-4,p),u.gain.exponentialRampToValueAtTime(t.peakGain,p+.005),u.gain.exponentialRampToValueAtTime(1e-4,p+a),c.connect(u).connect(o),c.start(p),c.stop(p+a+.01)})}async playUrl(t){let n=this.ctx,o=this.master;if(!n||!o||n.state!=="running")return;let i=await this.getBuffer(t);if(!i)return;let a=n.createBufferSource();a.buffer=i,a.connect(o),a.start()}destroy(){this.ctx&&this.ctx.close().catch(()=>{}),this.ctx=null,this.master=null,this.buffers.clear()}async getBuffer(t){if(!this.ctx)return null;let n=this.buffers.get(t);if(n)return n instanceof Promise,n;let o=this.ctx,i=fetch(t).then(a=>a.ok?a.arrayBuffer():Promise.reject(new Error(`fetch ${a.status}`))).then(a=>o.decodeAudioData(a)).then(a=>(this.buffers.set(t,a),a)).catch(a=>(ua.warn("audio fetch/decode failed",{url:t,err:a}),this.buffers.delete(t),null));return this.buffers.set(t,i),i}};var pa={messageReceived:10,messageSent:0,error:[20,40,20],voiceStart:10,voiceStop:0},fa={messageReceived:{notes:[880,1318.51],noteMs:90,type:"sine",peakGain:.45},messageSent:{notes:[1568],noteMs:60,type:"sine",peakGain:.25},error:{notes:[523.25,392],noteMs:120,type:"triangle",peakGain:.55},voiceStart:{notes:[1318.51],noteMs:50,type:"sine",peakGain:.3},voiceStop:{notes:[880],noteMs:50,type:"sine",peakGain:.3}};var Ue=null,An=0;function Yc(){return typeof navigator<"u"&&typeof navigator.vibrate=="function"}function Jc(){if(typeof document>"u")return null;let e=document.createElement("input");e.type="checkbox",e.setAttribute("switch",""),e.setAttribute("aria-hidden","true"),e.tabIndex=-1,e.id=`__${v.cssPrefix}_haptic_${Math.random().toString(36).slice(2)}`;let t=document.createElement("label");t.htmlFor=e.id,t.setAttribute("aria-hidden","true");let n="position:absolute!important;width:1px!important;height:1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;opacity:0!important;pointer-events:none!important;";return e.style.cssText=n,t.style.cssText=n,document.body.append(e,t),{input:e,label:t}}function ga(e){if(!(e===0||Array.isArray(e)&&e.every(t=>t===0))){if(Yc())try{navigator.vibrate(e);return}catch{}if(Ue||(Ue=Jc()),!!Ue)try{Ue.label.click()}catch{}}}function ma(){An++;let e=!1;return()=>{e||(e=!0,An=Math.max(0,An-1),An===0&&Ue&&(Ue.input.remove(),Ue.label.remove(),Ue=null))}}var Qc=M.scope("feedback"),Zc=100,Tn=class{constructor(t,n){H(this,"mutedSig",L(!1));H(this,"audio",new Cn);H(this,"releaseHaptics");H(this,"sound");H(this,"haptics");H(this,"lastPlayed",new Map);H(this,"reducedMotionMq",null);this.sound=t,this.haptics=n,this.releaseHaptics=ma(),this.audio.setVolume(this.effectiveVolume()),typeof matchMedia<"u"&&(this.reducedMotionMq=matchMedia("(prefers-reduced-motion: reduce)"))}unlock(){this.audio.unlock(),this.audio.setVolume(this.effectiveVolume())}update(t,n){this.sound=t,this.haptics=n,this.audio.setVolume(this.effectiveVolume())}setMuted(t){this.mutedSig.value!==t&&(this.mutedSig.value=t)}toggleMuted(){this.mutedSig.value=!this.mutedSig.value}play(t){this.mutedSig.value||this.isDeduped(t)||(this.lastPlayed.set(t,performance.now()),this.sound.enabled&&this.playSound(t),this.haptics.enabled&&this.isTouchDevice()&&this.playHaptic(t))}destroy(){this.audio.destroy(),this.releaseHaptics()}isDeduped(t){let n=this.lastPlayed.get(t);return n===void 0?!1:performance.now()-n<Zc}playSound(t){let n=this.sound.events?.[t];if(n===!1)return;if(typeof n=="string"){this.audio.playUrl(n).catch(i=>Qc.warn("audio play failed",{err:i,url:n}));return}let o=fa[t];o&&this.audio.playTone(o)}playHaptic(t){if(this.reducedMotionMq?.matches)return;let n=this.haptics.events?.[t];if(n===!1)return;let o=n===!0||n===void 0?pa[t]:n;ga(o)}effectiveVolume(){let t=this.sound.volume??.3;return this.reducedMotionMq?.matches?t*.5:t}isTouchDevice(){return typeof window>"u"?!1:matchMedia("(hover: none) and (pointer: coarse)").matches}};function je(e,t){return e instanceof ve&&e.status===429?t.errorRateLimited:t.errorGeneric}var ed=0;function r(e,t,n,o,i,a){t||(t={});var s,l,c=t;if("ref"in c)for(l in c={},t)l=="ref"?s=t[l]:c[l]=t[l];var u={type:e,props:c,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ed,__i:-1,__u:0,__source:i,__self:a};if(typeof e=="function"&&(s=e.defaultProps))for(l in s)c[l]===void 0&&(c[l]=s[l]);return B.vnode&&B.vnode(u),u}var T={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24"},td=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M21 12a8 8 0 0 1-12 6.93L3 21l1.65-5.16A8 8 0 1 1 21 12Z"})}),Ce=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M18 6 6 18M6 6l12 12"})}),ha=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M12 5v14M5 12h14"})}),va=()=>r("svg",{...T,"aria-hidden":"true",children:[r("path",{d:"m22 2-7 20-4-9-9-4Z"}),r("path",{d:"M22 2 11 13"})]}),ba=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M12 19V5M5 12l7-7 7 7"})}),xa=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M3 20V4l18 8-18 8Z"})}),In=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"m9 18 6-6-6-6"})}),ya=()=>r("svg",{...T,"aria-hidden":"true",children:r("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})}),Pa=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"m21 11-9 9a5.5 5.5 0 0 1-7.78-7.78l8.49-8.49a3.67 3.67 0 0 1 5.19 5.19l-8.49 8.49a1.83 1.83 0 0 1-2.6-2.6l7.78-7.78"})}),Sa=()=>r("svg",{...T,"aria-hidden":"true",children:[r("rect",{x:"9",y:"2",width:"6",height:"12",rx:"3"}),r("path",{d:"M5 10a7 7 0 0 0 14 0M12 19v3"})]}),wa=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M3 8V3h5M21 8V3h-5M3 16v5h5M21 16v5h-5"})}),ka=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M8 3v5H3M16 3v5h5M8 21v-5H3M16 21v-5h5"})}),Ea=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M3 3h7v2H5v5H3zM21 3h-7v2h5v5h2zM3 21h7v-2H5v-5H3zM21 21h-7v-2h5v-5h2z"})}),Ca=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M10 3v5H3M14 3v5h7M10 21v-5H3M14 21v-5h7"})}),Aa=()=>r("svg",{...T,"aria-hidden":"true",viewBox:"0 0 10 10",children:r("path",{d:"M9 1L1 9M9 5L5 9M9 9H9",strokeWidth:"1.5"})}),Ta=()=>r("svg",{...T,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"5",r:"1.5",fill:"currentColor",stroke:"none"}),r("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor",stroke:"none"}),r("circle",{cx:"12",cy:"19",r:"1.5",fill:"currentColor",stroke:"none"})]}),Ia=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M11 5 6 9H2v6h4l5 4zM15 9a5 5 0 0 1 0 6M18 7a9 9 0 0 1 0 10"})}),Ra=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M11 5 6 9H2v6h4l5 4zM22 9l-6 6M16 9l6 6"})}),Ma=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M20 6 9 17l-5-5"})}),La=()=>r("svg",{...T,"aria-hidden":"true",children:[r("path",{d:"M3 3v6h6"}),r("path",{d:"M3.05 13A9 9 0 1 0 6 5.3L3 9"}),r("path",{d:"M12 7v5l3 2"})]});var Nt=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),Na=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M15 3h6v6M10 14 21 3M21 14v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5"})}),Oa=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"})}),Da=()=>r("svg",{...T,"aria-hidden":"true",children:[r("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z"}),r("path",{d:"M14 2v6h6"})]}),nd=()=>r("svg",{...T,"aria-hidden":"true",children:[r("path",{d:"m12 3-1.5 4.5L6 9l4.5 1.5L12 15l1.5-4.5L18 9l-4.5-1.5Z"}),r("path",{d:"M19 15v4M17 17h4M5 3v2M4 4h2"})]}),od=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2Z"})}),Vo=()=>r("svg",{...T,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"10"}),r("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),r("path",{d:"M12 17h.01"})]}),rd=()=>r("svg",{...T,"aria-hidden":"true",children:[r("path",{d:"m15 4 3 3-9 9-3-3z"}),r("path",{d:"M18 2v2M20 4h2M3 20l3-3M3 16h2M5 14v2"})]}),id=()=>r("svg",{...T,"aria-hidden":"true",children:[r("rect",{x:"4",y:"8",width:"16",height:"12",rx:"2"}),r("path",{d:"M12 8V4"}),r("circle",{cx:"12",cy:"3",r:"1"}),r("path",{d:"M2 14h2M20 14h2M9 13h.01M15 13h.01M9.5 17h5"})]}),ad=()=>r("svg",{...T,"aria-hidden":"true",children:[r("path",{d:"M4 14v-2a8 8 0 0 1 16 0v2"}),r("rect",{x:"2",y:"14",width:"4",height:"6",rx:"1.5"}),r("rect",{x:"18",y:"14",width:"4",height:"6",rx:"1.5"}),r("path",{d:"M20 20v1a3 3 0 0 1-3 3h-5"})]}),sd=()=>r("svg",{...T,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"10"}),r("circle",{cx:"12",cy:"12",r:"4"}),r("path",{d:"m4.93 4.93 4.24 4.24M14.83 14.83l4.24 4.24M14.83 9.17l4.24-4.24M4.93 19.07l4.24-4.24"})]}),qo=()=>r("svg",{...T,"aria-hidden":"true",children:[r("circle",{cx:"11",cy:"11",r:"7"}),r("path",{d:"m21 21-4.3-4.3"})]}),Ha=()=>r("svg",{...T,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"9"}),r("path",{d:"m8.5 12 2.5 2.5 4.5-5"})]}),Ba=()=>r("svg",{...T,"aria-hidden":"true",children:[r("path",{d:"M3 9.5 12 3l9 6.5"}),r("path",{d:"M5 9v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V9"})]}),$a=()=>r("svg",{...T,"aria-hidden":"true",children:[r("path",{d:"m3 11 15-5v12L3 13z"}),r("path",{d:"M3 11v2a2 2 0 0 0 2 2h1V9H5a2 2 0 0 0-2 2z"}),r("path",{d:"M7 15v3a2 2 0 0 0 4 0v-2"}),r("path",{d:"M21 10a3 3 0 0 1 0 4"})]}),Ot=()=>r("svg",{...T,"aria-hidden":"true",children:[r("path",{d:"M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z"}),r("path",{d:"M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1"})]}),Ua=()=>r("svg",{...T,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"4"}),r("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"})]}),za=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}),Fa=()=>r("svg",{...T,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"9"}),r("path",{d:"M12 3v18"}),r("path",{d:"M12 3a9 9 0 0 1 0 18z",fill:"currentColor",stroke:"none"})]}),ld=()=>r("svg",{...T,"aria-hidden":"true",children:[r("circle",{cx:"10.5",cy:"10.5",r:"6.5"}),r("path",{d:"M8 11a2.5 2.5 0 0 0 5 0"}),r("path",{d:"m20 20-4.4-4.4"})]}),cd=()=>r("svg",{...T,"aria-hidden":"true",children:[r("path",{d:"M12 3.5 13.6 9 19 10.5 13.6 12 12 17.5 10.4 12 5 10.5 10.4 9z"}),r("path",{d:"M18.5 4v3M20 5.5h-3M5.5 16v2.5M6.75 17.25h-2.5"})]}),dd=()=>r("svg",{...T,"aria-hidden":"true",children:[r("path",{d:"M4 18h16"}),r("path",{d:"M5 18a7 7 0 0 1 14 0"}),r("path",{d:"M12 8V6"}),r("path",{d:"M10 6h4"})]}),_d=()=>r("svg",{...T,"aria-hidden":"true",children:[r("path",{d:"M7 11V6.5a1.5 1.5 0 0 1 3 0V10"}),r("path",{d:"M10 10V5.5a1.5 1.5 0 0 1 3 0V10"}),r("path",{d:"M13 10V6.5a1.5 1.5 0 0 1 3 0V12"}),r("path",{d:"M16 9.5a1.5 1.5 0 0 1 3 0v2.5a7 7 0 0 1-7 7 7 7 0 0 1-6.4-4.2L4 12.5a1.5 1.5 0 0 1 2.6-1.5L7 11"})]}),Wa={chat:td,message:od,bubbles:Ot,spark:nd,wand:rd,bot:id,help:Vo,lifebuoy:sd,headset:ad,search:ld,sparkles:cd,concierge:dd,wave:_d};var C=v.cssPrefix,P={launcher:`${C}-launcher`,callout:`${C}-callout`,calloutDismiss:`${C}-callout-dismiss`,panel:`${C}-panel`,panelHeader:`${C}-panel-header`,resizeGrip:`${C}-resize-grip`,actionClear:`${C}-action-clear`,actionExpand:`${C}-action-expand`,actionFullscreen:`${C}-action-fullscreen`,actionPopOut:`${C}-action-popout`,actionSound:`${C}-action-sound`,actionHistory:`${C}-action-history`,actionLanguage:`${C}-action-language`,actionTheme:`${C}-action-theme`,actionClose:`${C}-action-close`,actionOverflow:`${C}-action-overflow`,languageOption:`${C}-language-option`,themeOption:`${C}-theme-option`,composer:`${C}-composer`,composerInput:`${C}-composer-input`,composerSend:`${C}-composer-send`,composerStop:`${C}-composer-stop`,composerAttach:`${C}-composer-attach`,composerFileInput:`${C}-composer-file-input`,composerVoice:`${C}-composer-voice`,attachmentChip:`${C}-attachment-chip`,attachmentRemove:`${C}-attachment-remove`,suggestion:`${C}-suggestion`,messageBubble:`${C}-message`,messageRetry:`${C}-message-retry`,historyPane:`${C}-history-pane`,historyBack:`${C}-history-back`,historyItem:`${C}-history-item`,sidebar:`${C}-sidebar`,sidebarToggle:`${C}-sidebar-toggle`,sidebarNewChat:`${C}-sidebar-new-chat`,sidebarItem:`${C}-sidebar-item`,messengerHome:`${C}-messenger-home`,modulesEmpty:`${C}-modules-empty`,tab:`${C}-tab`,tabBadge:`${C}-tab-badge`,homeView:`${C}-home-view`,homeGreeting:`${C}-home-greeting`,homeBrand:`${C}-home-brand`,backHeader:`${C}-back-header`,contentView:`${C}-content-view`,contentScroll:`${C}-content-scroll`,homeSearch:`${C}-home-search`,helpSearch:`${C}-help-search`,homeRecent:`${C}-home-recent`,homeContentRow:`${C}-home-content-row`,helpArticle:`${C}-help-article`,newsItem:`${C}-news-item`};function ce(e,t){return`${e}-${t}`}var Hp={clear:P.actionClear,expand:P.actionExpand,fullscreen:P.actionFullscreen,popOut:P.actionPopOut,sound:P.actionSound,history:P.actionHistory,language:P.actionLanguage,theme:P.actionTheme,close:P.actionClose};var Rn=v.cssPrefix;function Ga({onToggle:e,launcher:t,strings:n,leaving:o,edgeTab:i}){let a=t.variant!=="circle"&&!!t.label;return r("button",{type:"button",class:`${Rn}-fab`,"data-variant":t.variant,"data-size":t.size,"data-edge-tab":i?"true":void 0,"data-leaving":o?"true":void 0,"data-testid":P.launcher,onClick:e,"aria-label":n.launcherOpen,children:[ud(t.icon),a?r("span",{class:`${Rn}-fab-label`,children:t.label}):null]})}function ud(e){let t=Wa[e];return t?r(t,{}):r(pd,{source:e})}function pd({source:e}){return r("span",{ref:t=>{t&&fd(t,e)},"aria-hidden":"true"})}function fd(e,t){if(e.dataset.svgMounted!==t)try{let o=new DOMParser().parseFromString(t,"image/svg+xml").documentElement;o&&o.tagName.toLowerCase()==="svg"&&(e.replaceChildren(document.importNode(o,!0)),e.dataset.svgMounted=t)}catch{}}function Ka({callout:e,launcherPosition:t,closeLabel:n,onDismiss:o}){let[i,a]=k(!1);return w(()=>{let s=setTimeout(()=>a(!0),e.delayMs);return()=>clearTimeout(s)},[e.delayMs]),w(()=>{if(!i||e.autoDismissMs<=0)return;let s=setTimeout(o,e.autoDismissMs);return()=>clearTimeout(s)},[i,e.autoDismissMs,o]),i?r("div",{class:`${Rn}-callout`,role:"status","data-shape":e.shape,"data-position":gd(e.position,t),"data-animated":e.animated?"true":void 0,"data-testid":P.callout,children:[r("span",{children:e.text}),r("button",{type:"button",class:`${Rn}-callout-close`,onClick:o,"aria-label":n,title:n,"data-testid":P.calloutDismiss,children:r(Ce,{})})]}):null}function gd(e,t){let n=t.endsWith("-right"),o=t.startsWith("bottom-");return e==="vertical"?o?"top":"bottom":n?"left":"right"}function Mn({panelEl:e,resize:t,position:n,initialSize:o,onSizeChange:i,strings:a}){let s=v.cssPrefix,l=N(null);if(w(()=>{if(!e)return;let g=e.style;t.minWidth&&g.setProperty(`--${s}-resize-min-w`,t.minWidth),t.maxWidth&&g.setProperty(`--${s}-resize-max-w`,t.maxWidth),t.minHeight&&g.setProperty(`--${s}-resize-min-h`,t.minHeight),t.maxHeight&&g.setProperty(`--${s}-resize-max-h`,t.maxHeight),o&&(g.setProperty(`--${s}-widget-w`,`${o.width}px`),g.setProperty(`--${s}-widget-h`,`${o.height}px`))},[e,t.minWidth,t.maxWidth,t.minHeight,t.maxHeight,s,o]),!e)return null;let c=n.startsWith("top-"),u=n.endsWith("-right"),p=`${s}-resize-grip ${s}-resize-grip--${c?"bottom":"top"}-${u?"left":"right"}`,d=g=>{if(!e)return;let h=g.currentTarget,b=e.getBoundingClientRect();l.current={pointerId:g.pointerId,startX:g.clientX,startY:g.clientY,startW:b.width,startH:b.height,dirX:u?-1:1,dirY:c?1:-1},h.setPointerCapture(g.pointerId),g.preventDefault()},_=g=>{let h=l.current;if(!h||g.pointerId!==h.pointerId||!e)return;let b=(g.clientX-h.startX)*h.dirX,x=(g.clientY-h.startY)*h.dirY;e.style.setProperty(`--${s}-widget-w`,`${h.startW+b}px`),e.style.setProperty(`--${s}-widget-h`,`${h.startH+x}px`)},f=g=>{let h=l.current;if(!h||g.pointerId!==h.pointerId||!e)return;g.currentTarget.releasePointerCapture(g.pointerId);let b=e.getBoundingClientRect();i({width:Math.round(b.width),height:Math.round(b.height)}),l.current=null};return r("div",{class:p,role:"separator","aria-orientation":"vertical","aria-label":a.resizeHandle,title:a.resizeHandle,onPointerDown:d,onPointerMove:_,onPointerUp:f,onPointerCancel:f,"data-testid":P.resizeGrip,children:r(Aa,{})})}var Ye=v.cssPrefix,md=`.${Ye}-header, .${Ye}-back-header, .${Ye}-home-hero`,hd='button, a, input, textarea, select, [role="tab"], [contenteditable]',Va=56;function Ln(e,t){w(()=>{if(!t||!e)return;let n=c=>Number.parseFloat(c)||0,o=(c,u)=>Math.min(u,Math.max(-u,c)),i=null,a=c=>{let u=c.target;if(!(u instanceof Element)||!u.closest(md)||u.closest(hd))return;let p=e.getBoundingClientRect();i={id:c.pointerId,x:c.clientX,y:c.clientY,dx:n(e.style.getPropertyValue(`--${Ye}-modal-dx`)),dy:n(e.style.getPropertyValue(`--${Ye}-modal-dy`)),maxX:(window.innerWidth+p.width)/2-Va,maxY:(window.innerHeight+p.height)/2-Va},e.dataset.dragging="true",c.preventDefault()},s=c=>{if(!i||c.pointerId!==i.id)return;let u=o(i.dx+c.clientX-i.x,i.maxX),p=o(i.dy+c.clientY-i.y,i.maxY);e.style.setProperty(`--${Ye}-modal-dx`,`${u}px`),e.style.setProperty(`--${Ye}-modal-dy`,`${p}px`)},l=c=>{!i||c.pointerId!==i.id||(i=null,delete e.dataset.dragging)};return e.addEventListener("pointerdown",a),window.addEventListener("pointermove",s),window.addEventListener("pointerup",l),window.addEventListener("pointercancel",l),()=>{e.removeEventListener("pointerdown",a),window.removeEventListener("pointermove",s),window.removeEventListener("pointerup",l),window.removeEventListener("pointercancel",l)}},[e,t])}function Dt(e,t,n,o){switch(e){case"clear":case"sound":case"history":case"language":case"theme":return!0;case"expand":return t==="floating";case"fullscreen":return t!=="standalone";case"popOut":return t!=="standalone"&&!!o?.popOutUrl;case"close":return t==="standalone"||t==="page"?!1:t==="inline"?n==="fullscreen":!0}}function Nn(e,t,n){return Dt("close",e,t)?n.main.includes("close")||n.overflow.includes("close"):!1}function qa(e,t){return e==="inline"&&t==="fullscreen"?"exit-fullscreen":"close"}var vd='a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),[tabindex]:not([tabindex="-1"])';function On(e){let t=n=>{if(n.key!=="Tab")return;let o=[...e.querySelectorAll(vd)].filter(l=>l.offsetParent!==null||l===document.activeElement);if(o.length===0){n.preventDefault();return}let i=o[0],a=o[o.length-1];if(!i||!a)return;let s=e.getRootNode().activeElement;n.shiftKey&&s===i?(n.preventDefault(),a.focus()):!n.shiftKey&&s===a&&(n.preventDefault(),i.focus())};return e.addEventListener("keydown",t),()=>e.removeEventListener("keydown",t)}function Dn(e){return e.trim().split(/\s+/).slice(0,2).map(t=>t.charAt(0).toUpperCase()).join("")}var Xo=v.cssPrefix;function Xa({agent:e}){let t=e.status??"online";return r("div",{class:`${Xo}-agent`,children:[r("div",{class:`${Xo}-agent-avatar`,"data-status":t,children:e.avatar?r("img",{src:e.avatar,alt:""}):r("span",{children:Dn(e.name)})}),r("div",{class:`${Xo}-agent-meta`,children:[r("strong",{children:e.name}),e.title?r("span",{children:e.title}):null]})]})}var ja=M.scope("attachments");function Hn(e,t,n){let o=xd(e),i=[],a=[],s=Sd(n.accept),l=t.reduce((u,p)=>u+p.size,0),c=t.length;for(let u of o){let p=bd(u,c,l,n,s);if(p){a.push({file:u,reason:p});continue}i.push(Pd(u)),l+=u.size,c+=1}return(i.length||a.length)&&ja.debug("ingest",{accepted:i.length,rejected:a.map(u=>({name:u.file.name,reason:u.reason}))}),{accepted:i,rejected:a}}function jo(e){try{URL.revokeObjectURL(e.previewUrl)}catch(t){ja.debug("revokeObjectURL failed",{error:t})}}function bd(e,t,n,o,i){return t>=o.maxCount?"count":n+e.size>o.maxBytes?"bytes":wd(e,i)?null:"mime"}function xd(e){return e?Array.isArray(e)?e.filter(t=>t instanceof File):[...e].map(t=>t instanceof File?t:yd(t)).filter(t=>t!==null):[]}function yd(e){let t=e;return!t?.getAsFile||t.kind!=="file"?null:t.getAsFile()}function Pd(e){return{file:e,id:ke(),mediaType:e.type||"application/octet-stream",name:e.name||"pasted-file",previewUrl:URL.createObjectURL(e),size:e.size}}function Sd(e){return e.split(",").map(t=>t.trim().toLowerCase()).filter(Boolean).map(t=>{if(t.startsWith("."))return{kind:"ext",ext:t};let[n="*",o="*"]=t.split("/");return{kind:"mime",type:n,subtype:o}})}function wd(e,t){if(t.length===0)return!0;let[n="*",o="*"]=(e.type||"").toLowerCase().split("/"),i=(e.name||"").toLowerCase();return t.some(a=>a.kind==="ext"?i.endsWith(a.ext):(a.type==="*"||a.type===n)&&(a.subtype==="*"||a.subtype===o))}var Ht=v.cssPrefix;function Ya({attachment:e,onRemove:t}){let n=e.mediaType.startsWith("image/");return r("span",{class:`${Ht}-attachment-chip`,title:e.name,"data-testid":ce(P.attachmentChip,e.id),children:[n?r("img",{class:`${Ht}-attachment-thumb`,src:e.previewUrl,alt:""}):r("span",{class:`${Ht}-attachment-thumb`,"aria-hidden":"true",children:r(Da,{})}),r("span",{class:`${Ht}-attachment-name`,children:e.name}),r("button",{type:"button",class:`${Ht}-attachment-remove`,onClick:t,"aria-label":`Remove ${e.name}`,"data-testid":ce(P.attachmentRemove,e.id),children:r(Ce,{})})]})}var Yo={isSupported:!1,start:()=>{},stop:()=>{}};function Jo(e,t,n){return e==="disabled"?Yo:e==="server"?Ad(n):kd(t)}function kd(e){let t=Ed();if(!t)return Yo;let n=null;return{isSupported:!0,start(o,i){n=new t,n.continuous=!0,n.interimResults=!0,n.lang=e,n.addEventListener("result",s=>{let l=s,c="",u=!1;for(let p=l.resultIndex;p<l.results.length;p++){let d=l.results[p];d&&(c+=d[0].transcript,d.isFinal&&(u=!0))}o(c,u)});let a=()=>{n=null,i()};n.addEventListener("end",a),n.addEventListener("error",a),n.start()},stop(){n?.stop()}}}function Ed(){let e=globalThis;return e.SpeechRecognition??e.webkitSpeechRecognition}var Cd=["audio/webm;codecs=opus","audio/webm","audio/ogg;codecs=opus","audio/mp4"];function Ad(e){if(typeof MediaRecorder>"u"||!navigator?.mediaDevices?.getUserMedia)return Yo;let t=null,n=null,o=[],i=()=>{for(let a of n?.getTracks()??[])a.stop();n=null};return{isSupported:!0,async start(a,s){try{n=await navigator.mediaDevices.getUserMedia({audio:!0});let l=Td();t=new MediaRecorder(n,l?{mimeType:l}:void 0),o=[],t.addEventListener("dataavailable",c=>{c.data.size>0&&o.push(c.data)}),t.addEventListener("stop",async()=>{let c=t?.mimeType??"audio/webm";i();let u=new Blob(o,{type:c});o=[];try{let{text:p}=await e(u,c);p&&a(p,!0)}catch{}finally{s()}}),t.start()}catch{i(),s()}},stop(){t?.stop()}}}function Td(){for(let e of Cd)if(MediaRecorder.isTypeSupported(e))return e}var he=v.cssPrefix,Je=M.scope("composer");function gt(e){return e.reduce((t,n)=>t+n.size,0)}var Id={arrowUp:ba,paperPlane:va,send:xa,chevron:In};function Ja({options:e,transport:t,feedback:n,bus:o,isStreaming:i,onSend:a,onStop:s,attachApiRef:l}){let c=e.strings,[u,p]=k(""),[d,_]=k([]),[f,g]=k(!1),h=N(null),b=N(null),x=e.features.files,S=e.features.voice,[I,j]=k(()=>Jo(S,e.locale,(E,F)=>t.transcribe(E,F)));w(()=>{f||S==="disabled"||j(Jo(S,e.locale,(E,F)=>t.transcribe(E,F)))},[e.locale,S,t,f]),w(()=>{let E=h.current;if(!E)return;let F=E.getRootNode(),Y="activeElement"in F?F.activeElement:null;Y&&E.closest(`.${he}-panel`)?.contains(Y)||E.focus({preventScroll:!0})},[]),w(()=>{let E=h.current;if(E){if(u.length===0){E.style.height="";return}E.style.height="auto",E.style.height=`${Math.min(E.scrollHeight,160)}px`}},[u]);let z=N(d);z.current=d,w(()=>()=>z.current.forEach(jo),[]),w(()=>{if(l)return l.current={attachFromDrop:E=>{let F=Hn(E,z.current,e.attachments);F.accepted.length!==0&&(Je.info("attach (drop)",{count:F.accepted.length,totalBytes:gt(F.accepted)}),o.emit("attach",{count:F.accepted.length,totalBytes:gt(F.accepted)}),_(Y=>[...Y,...F.accepted]))}},()=>{l.current&&(l.current=null)}},[l,e.attachments]),w(()=>{let E=h.current;if(!E)return;let F=E.closest(`.${he}-panel`);if(!F)return;let Y=fe=>{let Fe=fe.clipboardData;if(!Fe)return;if(x){let ue=Hn(Fe.items,z.current,e.attachments);if(ue.accepted.length>0){fe.preventDefault(),Je.info("attach (paste)",{count:ue.accepted.length,totalBytes:gt(ue.accepted)}),o.emit("attach",{count:ue.accepted.length,totalBytes:gt(ue.accepted)}),_(zt=>[...zt,...ue.accepted]);return}}if(fe.target===E)return;let _e=Fe.getData("text/plain");_e&&(fe.preventDefault(),p(ue=>ue+_e),E.focus())};return F.addEventListener("paste",Y),()=>F.removeEventListener("paste",Y)},[x,e.attachments,he]);let oe=()=>{let E=u.trim();!E&&d.length===0||i||(a(E,d),p(""),_([]))},O=E=>{E.key!=="Enter"||E.shiftKey||E.isComposing||(E.preventDefault(),i?s():oe())},le=E=>{let F=E.target,Y=Hn(F.files,d,e.attachments);Y.accepted.length>0&&(Je.info("attach (file picker)",{count:Y.accepted.length,totalBytes:gt(Y.accepted)}),o.emit("attach",{count:Y.accepted.length,totalBytes:gt(Y.accepted)}),_(fe=>[...fe,...Y.accepted])),F.value=""},$=E=>{Je.info("removeAttachment",{id:E}),o.emit("removeAttachment",{id:E}),_(F=>{let Y=F.find(fe=>fe.id===E);return Y&&jo(Y),F.filter(fe=>fe.id!==E)})},R=N(null),tt=()=>{if(I.isSupported){if(f){let E=R.current?Date.now()-R.current:0;Je.info("voiceStop",{durationMs:E}),o.emit("voiceStop",{durationMs:E}),I.stop(),g(!1),n.play("voiceStop"),R.current=null;return}R.current=Date.now(),Je.info("voiceStart"),o.emit("voiceStart",void 0),g(!0),n.play("voiceStart"),I.start((E,F)=>p(Y=>F?`${Y}${E} `:Y),()=>{if(g(!1),R.current){let E=Date.now()-R.current;Je.debug("voiceStop (auto)",{durationMs:E}),o.emit("voiceStop",{durationMs:E}),R.current=null}})}},de=Id[e.composer.sendButton.icon];return r("div",{class:`${he}-composer`,"data-testid":P.composer,children:[d.length>0?r("div",{class:`${he}-attachments`,children:d.map(E=>r(Ya,{attachment:E,onRemove:()=>$(E.id)},E.id))}):null,r("div",{class:`${he}-composer-row`,children:[r("div",{class:`${he}-composer-actions`,children:[x?r("button",{type:"button",class:`${he}-icon-btn`,onClick:()=>b.current?.click(),"aria-label":c.attach,"data-testid":P.composerAttach,children:r(Pa,{})}):null,I.isSupported?r("button",{type:"button",class:`${he}-icon-btn`,onClick:tt,"aria-label":f?c.micStop:c.micStart,"aria-pressed":f,"data-recording":f?"true":void 0,"data-testid":P.composerVoice,children:r(Sa,{})}):null]}),r("textarea",{ref:h,class:`${he}-textarea`,rows:1,value:u,placeholder:c.composerPlaceholder,onInput:E=>p(E.target.value),onKeyDown:O,"aria-label":c.composerPlaceholder,"data-testid":P.composerInput}),i?r("button",{type:"button",class:`${he}-send`,onClick:s,"aria-label":c.stop,"data-testid":P.composerStop,children:r(ya,{})}):r("button",{type:"button",class:`${he}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:oe,disabled:!u.trim()&&d.length===0,"aria-label":c.send,"data-testid":P.composerSend,children:r(de,{})})]}),r("input",{ref:b,type:"file",multiple:!0,accept:e.attachments.accept,onChange:le,class:`${he}-sr-only`,"data-testid":P.composerFileInput})]})}var Rd=v.cssPrefix;function Qa({visible:e,strings:t}){return e?r("div",{class:`${Rd}-dropzone`,role:"status","aria-live":"polite",children:t.dropZone}):null}function Bn({containerRef:e,onDrop:t}){let[n,o]=k(!1);return w(()=>{let i=e.current;if(!i)return;let a=0,s=p=>{a+=1,p.dataTransfer?.types.includes("Files")&&(p.preventDefault(),o(!0))},l=()=>{a-=1,!(a>0)&&(a=0,o(!1))},c=p=>{p.dataTransfer?.types.includes("Files")&&p.preventDefault()},u=p=>{a=0,o(!1),p.dataTransfer&&(p.preventDefault(),t(p.dataTransfer.items))};return i.addEventListener("dragenter",s),i.addEventListener("dragleave",l),i.addEventListener("dragover",c),i.addEventListener("drop",u),()=>{i.removeEventListener("dragenter",s),i.removeEventListener("dragleave",l),i.removeEventListener("dragover",c),i.removeEventListener("drop",u)}},[e,t]),{visible:n}}function Za({itemCount:e,initialFocusIndex:t}){let[n,o]=k(!1),i=N(null),a=N(null),[s,l]=k(-1),c=D(()=>{o(!1),l(-1),i.current?.focus()},[]),u=D(()=>o(_=>!_),[]);w(()=>{if(!n)return;let _=f=>{let g=a.current,h=i.current;if(!g||!h)return;let b=f.composedPath();b.includes(g)||b.includes(h)||(o(!1),l(-1))};return document.addEventListener("click",_,!0),()=>document.removeEventListener("click",_,!0)},[n]),w(()=>{if(!n||e===0)return;let _=t?.()??0,f=_<0||_>=e?0:_;l(f)},[n,e,t]),w(()=>{if(!n||s<0)return;a.current?.querySelectorAll("[role='menuitem']")?.[s]?.focus()},[n,s]);let p=D(_=>{(_.key==="ArrowDown"||_.key==="Enter"||_.key===" ")&&(_.preventDefault(),o(!0))},[]),d=D(_=>{if(e!==0)switch(_.key){case"Escape":_.preventDefault(),c();return;case"ArrowDown":_.preventDefault(),l(f=>(f+1)%e);return;case"ArrowUp":_.preventDefault(),l(f=>(f-1+e)%e);return;case"Home":_.preventDefault(),l(0);return;case"End":_.preventDefault(),l(e-1)}},[e,c]);return{open:n,focusIndex:s,triggerRef:i,menuRef:a,toggle:u,close:c,onTriggerKey:p,onMenuKey:d}}function es({items:e,triggerLabel:t}){let n=v.cssPrefix,o=Za({itemCount:e.length}),i=a=>{a.disabled||(a.onSelect(),a.keepOpen||o.close())};return r("div",{class:`${n}-menu-wrap`,children:[r("button",{ref:o.triggerRef,type:"button",class:`${n}-icon-btn`,"aria-label":t,"aria-haspopup":"menu","aria-expanded":o.open,title:t,onClick:o.toggle,onKeyDown:o.onTriggerKey,children:r(Ta,{})}),o.open?r("div",{ref:o.menuRef,class:`${n}-menu`,role:"menu","aria-label":t,onKeyDown:o.onMenuKey,tabIndex:-1,children:e.map(a=>r("button",{type:"button",role:"menuitem",class:`${n}-menu-item`,"aria-pressed":a.type==="switch"?a.on:void 0,disabled:a.disabled,lang:a.lang,onClick:()=>i(a),children:[a.icon?r("span",{class:`${n}-menu-icon`,children:a.icon}):null,r("span",{class:`${n}-menu-label`,children:a.label}),a.type==="switch"&&a.on?r("span",{class:`${n}-menu-check`,"aria-hidden":"true",children:r(Ma,{})}):null]},a.id))}):null]})}var Qo=v.cssPrefix,Md={auto:"dark",dark:"light",light:"auto"};function Ld(e){return e==="light"?r(Ua,{}):e==="dark"?r(za,{}):r(Fa,{})}function Ae({panelProps:e,variant:t}){let{options:n,panelSize:o,feedback:i,onClose:a,onClear:s,onExpand:l,onFullscreen:c,onPopOut:u,onSoundToggle:p}=e,{onToggleHistory:d,onLocaleChange:_,onThemeChange:f}=e,g=n.strings,h=n.mode,b=t==="chat",x=we(()=>i.mutedSig.value).value,S=new Set([...n.actions.main,...n.actions.overflow]),I=R=>S.has(R),j=R=>Dt(R,h,o,{popOutUrl:n.popOutUrl}),z=n.themeMode,oe={auto:g.themeAuto,light:g.themeLight,dark:g.themeDark},O=[];if(I("theme")&&O.push({id:"theme",icon:Ld(z),label:`${g.theme}: ${oe[z]}`,onSelect:()=>f(Md[z]),keepOpen:!0}),I("language")&&n.availableLocales.length>1)for(let R of n.availableLocales)O.push({id:`language:${R}`,label:`${g.language} \u2014 ${R}`,lang:R,type:"switch",on:R===n.locale,onSelect:()=>_(R)});if(I("expand")&&j("expand")){let R=o==="expanded";O.push({id:"expand",icon:R?r(ka,{}):r(wa,{}),label:R?g.collapse:g.expand,type:"switch",on:R,onSelect:l})}if(I("fullscreen")&&j("fullscreen")){let R=o==="fullscreen";O.push({id:"fullscreen",icon:R?r(Ca,{}):r(Ea,{}),label:R?g.exitFullscreen:g.fullscreen,type:"switch",on:R,onSelect:c})}I("popOut")&&j("popOut")&&O.push({id:"popOut",icon:r(Na,{}),label:g.popOut,onSelect:u}),b&&I("sound")&&O.push({id:"sound",icon:x?r(Ra,{}):r(Ia,{}),label:x?g.soundOff:g.soundOn,type:"switch",on:!x,onSelect:p}),b&&I("clear")&&O.push({id:"clear",icon:r(Oa,{}),label:g.newConversation,onSelect:s});let le=!!a&&Nn(h,o,n.actions),$=b&&I("history");return r("div",{class:`${Qo}-header-actions`,children:[$?r("button",{type:"button",class:`${Qo}-icon-btn`,onClick:d,"aria-label":g.history,title:g.history,"data-testid":P.actionHistory,children:r(La,{})}):null,le?r("button",{type:"button",class:`${Qo}-icon-btn`,onClick:a,"aria-label":g.close,title:g.close,"data-testid":P.actionClose,children:r(Ce,{})}):null,O.length>0?r(es,{items:O,triggerLabel:g.moreActions}):null]})}var tr=1,ns=2,os=4,rs=8,is=16;function Nd(e){switch(e){case tr:return"href";case ns:return"src";case os:return"class";case rs:return"checked";case is:return"start"}}var Od=e=>{switch(e){case 1:return 3;case 2:return 4;case 3:return 5;case 4:return 6;case 5:return 7;default:return 8}},Dd=Od;var ts=24;function or(e){let t=new Uint32Array(ts);return t[0]=1,{renderer:e,text:"",pending:"",tokens:t,len:0,token:1,fence_end:0,blockquote_idx:0,hr_char:"",hr_chars:0,fence_start:0,spaces:new Uint8Array(ts),indent:"",indent_len:0,table_state:0}}function as(e){e.pending.length>0&&se(e,`
|
|
11
|
+
${i}`:i;continue}o.startsWith("id:")&&(n=o.slice(3).trim())}if(!t||t==="[DONE]")return null;try{let o=JSON.parse(t);return Qi.trace("chunk",{type:o.type,eventId:n}),{chunk:o,eventId:n}}catch(o){return Qi.trace("frame parse failed",{err:o,payload:t.slice(0,200)}),null}}function Hc(e){let t=new TextEncoder().encode(e),n="";for(let o of t)n+=String.fromCharCode(o);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}var ea=e=>e&&Object.keys(e).length>0?e:void 0;function ta(e,t){let n=ea(e),o=ea(t);if(!n&&!o)return;let i={};return n&&(i.user=n),o&&(i.page=o),Hc(JSON.stringify(i))}var Ee={startSession:"/ai/agent/start-session",streamMessage:"/ai/agent/stream-message",streamResume:"/ai/agent/stream-resume",cancelStream:"/ai/agent/cancel-stream",listSessions:"/ai/agent/list-sessions",listMessages:"/ai/agent/list-messages",updateSettings:"/ai/agent/update-settings",markRead:"/ai/agent/mark-read",content:"/ai/agent/content"},na="context";function oa(e){let n={messages:e.messages.map(a=>({id:a.id,parts:$c(a),role:a.role})),sessionId:e.sessionId,trigger:e.trigger??"submit-message"};e.visitorId&&(n.visitorId=e.visitorId),e.userPrefs&&(n.userPrefs=e.userPrefs);let o={},i=e.tools?.map(Bc).filter(a=>a!==null);return i?.length&&(o.tools=i),e.responseMode&&(o.responseMode=e.responseMode),Object.keys(o).length>0&&(n.data=o),n}function Bc(e){return typeof e=="string"?e?{code:e}:null:e?.code?e:null}function $c(e){let t=[];for(let n of e.parts)n.kind==="text"&&n.text&&t.push({text:n.text,type:"text"}),n.kind==="file"&&n.url&&t.push({mediaType:n.mediaType,type:"file",url:n.url});for(let n of e.attachments??[])n.url&&t.push({type:"file",url:n.url,mediaType:n.mediaType,filename:n.name,fileId:n.id,fileSize:n.size});return t}var q=M.scope("transport"),Uc=3,aa=400,ra=3,zc=new Set([408,425,429,500,502,503,504]);function ia(e){return aa*2**e+Math.floor(Math.random()*250)}function Fc(e){let t=e.get("retry-after");if(!t)return null;let n=Number(t),o=Number.isFinite(n)?n*1e3:Date.parse(t)-Date.now();return Number.isFinite(o)&&o>=0?Math.min(o,3e4):null}function Fo(e,t){return new Promise(n=>{if(t?.aborted)return n();let o=setTimeout(a,e),i=()=>a();t?.addEventListener("abort",i,{once:!0});function a(){clearTimeout(o),t?.removeEventListener("abort",i),n()}})}var Sn=class{constructor(t){H(this,"opts",t);H(this,"visitorId");H(this,"sessionId");H(this,"userContext");H(this,"pageContext")}setContext(t,n){this.userContext=t,this.pageContext=n}primeIdentity(t,n){t&&(this.visitorId=t),n&&(this.sessionId=n)}envelope(){let t={};this.visitorId&&(t.visitorId=this.visitorId),this.sessionId&&(t.sessionId=this.sessionId);let n=ta(this.userContext,this.pageContext);return n&&(t[na]=n),t}withEnvelope(t){return{...this.envelope(),...t}}appendEnvelope(t){for(let[n,o]of Object.entries(this.envelope()))t.append(n,o);return t}withEnvelopeQuery(t){let n=new URL(this.url(t));for(let[o,i]of Object.entries(this.envelope()))n.searchParams.has(o)||n.searchParams.set(o,i);return n.toString()}async startSession(t){q.debug("startSession \u2192",{visitorId:t.visitorId,sessionId:t.sessionId,locale:t.locale});let n=await this.postJson(Ee.startSession,t,"startSession");return q.debug("startSession \u2190",{visitorId:n.visitorId,sessionId:n.sessionId,canContinue:n.canContinue,hasMessages:!!n.messages?.length,hasWelcome:!!n.welcome,hasConfig:!!n.config,rebind:n.rebind}),Gc(n)||q.warn("startSession response did not match expected shape; using raw response",{response:n}),this.visitorId=n.visitorId??t.visitorId,this.sessionId=n.sessionId,n}async uploadFile(t){q.debug("uploadFile \u2192",{name:t.name,size:t.size,type:t.type});let n=new FormData;n.append("file",t,t.name);let o=await this.postForm(this.uploadPath,n,"upload");return q.debug("uploadFile \u2190",{id:o.id,url:o.url}),o}async transcribe(t,n="audio/webm"){q.debug("transcribe \u2192",{size:t.size,mimeType:n});let o=new FormData;o.append("audio",t,`voice.${Wc(n)}`),o.append("mimeType",n);let i=await this.postForm(this.transcribePath,o,"transcribe");return q.debug("transcribe \u2190",{textLen:i.text.length}),i}async listSessions(t={}){let n=new URL(this.url(Ee.listSessions));t.visitorId&&n.searchParams.set("visitorId",t.visitorId),t.limit&&n.searchParams.set("limit",String(t.limit)),t.cursor&&n.searchParams.set("cursor",t.cursor),q.debug("listSessions \u2192",{visitorId:t.visitorId??this.visitorId,limit:t.limit,cursor:t.cursor});let o=await this.getJson(n.toString(),"listSessions"),i=o.sessions??[];return q.debug("listSessions \u2190",{count:i.length,nextCursor:o.nextCursor}),{sessions:i.map(a=>({sessionId:a.sessionId,title:a.title,lastMessageAt:a.lastMessageAt,preview:a.preview,canContinue:a.canContinue,unreadCount:a.unreadCount})),nextCursor:o.nextCursor}}async loadSession(t){let n=new URL(this.url(Ee.listMessages));n.searchParams.set("sessionId",t),q.debug("loadSession \u2192",{sessionId:t,visitorId:this.visitorId});let o=await this.getJson(n.toString(),"loadSession"),i=o.messages??[];return q.debug("loadSession \u2190",{sessionId:o.sessionId,canContinue:o.canContinue,messageCount:i.length,hasSuggestions:!!o.suggestions}),{sessionId:o.sessionId,canContinue:o.canContinue??!0,messages:i,agent:o.agent,suggestions:o.suggestions}}async markRead(t){if(!(!this.visitorId||!t)){q.debug("markRead \u2192",{sessionId:t,visitorId:this.visitorId});try{await this.postJson(Ee.markRead,{sessionId:t},"markRead")}catch(n){q.debug("markRead failed (non-fatal)",{err:n})}}}async listContent(t={}){let n=new URL(this.url(Ee.content));for(let[a,s]of Object.entries(t))s!==void 0&&n.searchParams.set(a,Array.isArray(s)?s.join(","):String(s));q.debug("listContent \u2192",t);let o=await this.getJson(n.toString(),"listContent"),i=o.items??[];return q.debug("listContent \u2190",{count:i.length,total:o.pagination?.total}),{...o,items:i}}async saveUserPrefs(t){q.debug("saveUserPrefs \u2192",{visitorId:this.visitorId,sessionId:this.sessionId,settingsKeys:Object.keys(t)});let n=await this.postJson(Ee.updateSettings,{userPrefs:t},"saveUserPrefs");return q.debug("saveUserPrefs \u2190",{ok:n.ok}),n}get uploadPath(){return this.opts.endpoints?.upload??"/ai/agent/upload-file"}get transcribePath(){return this.opts.endpoints?.transcribe??"/ai/agent/transcribe-audio"}sendMessage(t){q.debug("message \u2192",{sessionId:t.sessionId,visitorId:t.visitorId,messageCount:t.messages.length,trigger:t.trigger,responseMode:t.data?.responseMode,tools:t.data?.tools?.map(s=>s.code)});let n=new AbortController,o=new Set;return{iter:this.runStream(t,n,o),cancel:()=>this.cancelStream(n,t.sessionId)}}resumeStream(){let t=new AbortController,n=new Set;return{iter:this.resumeStreamGen(t,n,!0),cancel:()=>t.abort()}}async*runStream(t,n,o){(yield*this.drain(this.openMessageStream(t,n.signal),o,n))||(yield*this.resumeStreamGen(n,o,!1))}async*resumeStreamGen(t,n,o){for(let i=1;i<=Uc&&!t.signal.aborted;i++){if((!o||i>1)&&(await Fo(aa*i,t.signal),t.signal.aborted))return;let a;try{a=await this.fetchImpl(this.resumeUrl(n.size),{method:"GET",credentials:"omit",headers:{accept:"text/event-stream",...this.opts.auth.headers()},signal:t.signal})}catch(l){if(t.signal.aborted)return;q.debug("resume fetch failed \u2014 retrying",{attempt:i,err:l});continue}if(a.status===204||!a.ok){q.debug("resume \u2192 no in-flight stream",{status:a.status});return}let s=n.size;if(yield*this.drain(zo(a,t.signal),n,t))return;if(n.size===s){q.debug("resume \u2192 stream closed with no new events; nothing to resume");return}}if(!t.signal.aborted)throw new ve("stream incomplete after resume attempts","server")}async*drain(t,n,o){try{for await(let i of t){if(o.signal.aborted)return!0;if(i.eventId){if(n.has(i.eventId))continue;n.add(i.eventId)}if(yield i,i.chunk.type==="finish"||i.chunk.type==="error")return!0}}catch(i){if(o.signal.aborted)return!0;if(i instanceof ve&&i.status!==void 0)throw i;q.debug("stream segment dropped",{err:i})}return!1}cancelStream(t,n){t.signal.aborted||(q.debug("cancel stream",{sessionId:n,visitorId:this.visitorId}),t.abort(),!(!this.visitorId||!n)&&this.fetchImpl(this.url(Ee.cancelStream),{method:"POST",credentials:"omit",headers:{"content-type":"application/json",...this.opts.auth.headers()},body:JSON.stringify(this.withEnvelope({})),keepalive:!0}).catch(o=>q.debug("cancel POST failed (non-fatal)",{err:o})))}async*openMessageStream(t,n){let o=await this.fetchImpl(this.url(Ee.streamMessage),{method:"POST",credentials:"omit",headers:{accept:"text/event-stream","content-type":"application/json",...this.opts.auth.headers()},body:JSON.stringify(this.withEnvelope(t)),signal:n});yield*zo(o,n)}resumeUrl(t){let n=new URL(this.withEnvelopeQuery(Ee.streamResume));return n.searchParams.set("resumeAt",String(t)),n.toString()}async postJson(t,n,o){let i=await this.fetchWithRetry(()=>[this.url(t),{method:"POST",credentials:"omit",headers:{"content-type":"application/json",...this.opts.auth.headers()},body:JSON.stringify(this.withEnvelope(n))}],o);return this.assertOk(i,o)}async postForm(t,n,o){let i=await this.fetchImpl(this.url(t),{method:"POST",credentials:"omit",headers:this.opts.auth.headers(),body:this.appendEnvelope(n)});return this.assertOk(i,o)}async getJson(t,n){let o=await this.fetchWithRetry(()=>[this.withEnvelopeQuery(t),{method:"GET",credentials:"omit",headers:{accept:"application/json",...this.opts.auth.headers()}}],n);return this.assertOk(o,n)}async fetchWithRetry(t,n){for(let o=0;;o++){let[i,a]=t(),s;try{s=await this.fetchImpl(i,a)}catch(c){if(o>=ra)throw new ve(`${n} failed: network error`,"network",void 0,c);q.debug("request network error \u2014 retrying",{label:n,attempt:o}),await Fo(ia(o));continue}if(s.ok||!zc.has(s.status)||o>=ra)return s;let l=Fc(s.headers)??ia(o);q.debug("request retryable status \u2014 retrying",{label:n,status:s.status,attempt:o,wait:l}),await Fo(l)}}async assertOk(t,n){if(!t.ok)throw new ve(`${n} failed: ${t.status}`,"server",t.status);return await t.json()}url(t){return/^https?:\/\//i.test(t)?t:`${this.opts.baseUrl}${t}`}get fetchImpl(){return this.opts.fetchImpl??globalThis.fetch.bind(globalThis)}};function Wc(e){return e.includes("webm")?"webm":e.includes("ogg")?"ogg":e.includes("mp4")||e.includes("m4a")?"m4a":e.includes("mpeg")?"mp3":e.includes("wav")?"wav":"bin"}function Gc(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.visitorId=="string"&&typeof t.sessionId=="string"&&typeof t.canContinue=="boolean"}function sa(e,t){let n=e?[{kind:"text",id:"t0",textSig:L(e),doneSig:L(!0)}]:[];return{id:ke(),role:"user",createdAt:Date.now(),status:"complete",attachments:t,partsSig:L(n)}}function Wo(){return{id:ke(),role:"assistant",createdAt:Date.now(),status:"streaming",partsSig:L([])}}function la(e){return{id:e.id,role:e.role,createdAt:Date.now(),status:"streaming",partsSig:L([{kind:"text",id:`${e.id}-t0`,textSig:L(""),doneSig:L(!1)}])}}function ca(e){return Kc({id:e.id,role:e.role,createdAt:Date.now(),status:"complete",parts:[{kind:"text",id:`${e.id}-t0`,text:e.text,done:!0}]})}function Kc(e){return{id:e.id,role:e.role,createdAt:e.createdAt,status:e.status,errorText:e.errorText,finishReason:e.finishReason,attachments:e.attachments,partsSig:L(e.parts.map(Vc))}}function Go(e){let t=e.parts.map((n,o)=>n.type==="text"?{kind:"text",id:`${e.id}-t${o}`,textSig:L(n.text),doneSig:L(!0)}:n.type==="file"?{kind:"file",url:n.url,mediaType:n.mediaType}:null).filter(n=>n!==null);return{id:e.id,role:e.role,createdAt:Date.now(),status:"complete",partsSig:L(t)}}function da(e){return{id:e.id,role:e.role,createdAt:e.createdAt,status:e.status,errorText:e.errorText,finishReason:e.finishReason,attachments:e.attachments,parts:e.partsSig.value.map(qc)}}function Ko(e){let t="";for(let n of e.partsSig.value)n.kind==="text"&&(t+=n.textSig.value);return t}function Vc(e){return e.kind==="text"||e.kind==="reasoning"?{kind:e.kind,id:e.id,textSig:L(e.text),doneSig:L(e.done)}:e.kind==="tool"?{kind:"tool",toolCallId:e.toolCallId,toolName:e.toolName,inputPartialSig:L(e.inputPartial),inputSig:L(e.input),outputSig:L(e.output),errorSig:L(e.error),stateSig:L(e.state)}:e}function qc(e){return e.kind==="text"||e.kind==="reasoning"?{kind:e.kind,id:e.id,text:e.textSig.value,done:e.doneSig.value}:e.kind==="tool"?{kind:"tool",toolCallId:e.toolCallId,toolName:e.toolName,inputPartial:e.inputPartialSig.value,input:e.inputSig.value,output:e.outputSig.value,error:e.errorSig.value,state:e.stateSig.value}:e}var _a=M.scope("reducer"),wn=class{constructor(t){H(this,"messagesSig",t);H(this,"active",null)}attach(t){this.active=t}detach(){this.active=null}apply(t){let n=this.active;if(n)switch(t.type){case"start":case"start-step":case"finish-step":return;case"finish":_a.debug("finish",{reason:t.finishReason,canContinue:t.canContinue}),n.status="complete",t.finishReason&&(n.finishReason=t.finishReason),this.bumpDone(n);return;case"error":_a.warn("stream error chunk",{errorText:t.errorText}),n.status="error",n.errorText=t.errorText,this.bumpDone(n);return;case"text-start":ft(n,"text",t.id);return;case"text-delta":{let o=ft(n,"text",t.id);o.textSig.value+=t.delta;return}case"text-end":ft(n,"text",t.id).doneSig.value=!0;return;case"reasoning-start":ft(n,"reasoning",t.id).doneSig.value=!1;return;case"reasoning-delta":{let o=ft(n,"reasoning",t.id);o.textSig.value+=t.delta;return}case"reasoning-end":ft(n,"reasoning",t.id).doneSig.value=!0;return;case"tool-input-start":case"tool-input-delta":case"tool-input-available":case"tool-output-available":case"tool-output-error":Xc(n,t);return;case"file":kn(n,{kind:"file",url:t.url,mediaType:t.mediaType});return;case"source-url":{if(n.partsSig.value.some(i=>i.kind==="source"&&i.sourceId===t.sourceId))return;kn(n,{kind:"source",sourceId:t.sourceId,url:t.url,title:t.title});return}case"data-notification":return;default:{let o=t}}}bumpDone(t){t.partsSig.value=[...t.partsSig.value],this.messagesSig.value=[...this.messagesSig.value]}};function ft(e,t,n){let o=e.partsSig.value.find(a=>a.kind===t&&a.id===n);if(o)return o;let i={kind:t,id:n,textSig:L(""),doneSig:L(!1)};return kn(e,i),i}function Lt(e,t,n){let o=e.partsSig.value.find(a=>a.kind==="tool"&&a.toolCallId===t);if(o)return o;let i={kind:"tool",toolCallId:t,toolName:n??"tool",inputPartialSig:L(""),inputSig:L(void 0),outputSig:L(void 0),errorSig:L(void 0),stateSig:L("input")};return kn(e,i),i}function kn(e,t){e.partsSig.value=[...e.partsSig.value,t]}function Xc(e,t){switch(t.type){case"tool-input-start":Lt(e,t.toolCallId,t.toolName);return;case"tool-input-delta":{let n=Lt(e,t.toolCallId);n.inputPartialSig.value+=t.delta;return}case"tool-input-available":{let n=Lt(e,t.toolCallId,t.toolName);n.inputSig.value=t.input,n.stateSig.value="awaiting";return}case"tool-output-available":{let n=Lt(e,t.toolCallId);n.outputSig.value=t.output,n.stateSig.value="output";return}case"tool-output-error":{let n=Lt(e,t.toolCallId);n.errorSig.value=t.errorText,n.stateSig.value="error";return}default:return}}var En=M.scope("persistence");function Xe(e,t=Yt){let n=`${v.cssPrefix}.${e}`,o=`${n}.visitorId`,i=`${n}.sessionId`,a=`${n}.userPrefs`,s=`${n}.panelOpen`,l=`${n}.panelSize`,c=`${n}.calloutDismissed`,u=`${n}.sidebarCollapsed`,p=`${n}.activeModule`,d={getVisitorId(){let _=t.get(o);if(_)return _;let f=ke();return t.set(o,f),f},setVisitorId(_){En.debug("setVisitorId (rebind)",{id:_,widgetId:e}),t.set(o,_)},loadSessionId(){return t.get(i)??void 0},saveSessionId(_){En.trace("saveSessionId",{id:_,widgetId:e}),_?t.set(i,_):t.remove(i)},loadUserPrefs(){let _=t.get(a);if(!_)return{};try{let f=JSON.parse(_);return jc(f)?f:{}}catch(f){return En.warn("loadUserPrefs parse failed",{error:f}),{}}},saveUserPrefs(_){try{t.set(a,JSON.stringify(_))}catch(f){En.warn("saveUserPrefs serialise failed",{error:f})}},patchUserPrefs(_){let f=d.loadUserPrefs();d.saveUserPrefs({...f,..._})},loadPanelOpen(){let _=t.get(s);return _==="1"?!0:_==="0"?!1:null},savePanelOpen(_){t.set(s,_?"1":"0")},loadPanelSize(){let _=t.get(l);return _==="normal"||_==="expanded"||_==="fullscreen"?_:null},savePanelSize(_){t.set(l,_)},loadCalloutDismissed(_){if(!_)return!1;let f=t.get(c);return!!f&&f===_},saveCalloutDismissed(_){_?t.set(c,_):t.remove(c)},loadSidebarCollapsed(){let _=t.get(u);return _==="1"?!0:_==="0"?!1:null},saveSidebarCollapsed(_){t.set(u,_?"1":"0")},loadActiveModule(){return t.get(p)||null},saveActiveModule(_){t.set(p,_)},clearSession(){t.remove(i)}};return d}function jc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var ua=M.scope("feedback:audio"),Cn=class{constructor(){H(this,"ctx",null);H(this,"master",null);H(this,"buffers",new Map)}unlock(){if(this.ctx){this.ctx.state==="suspended"&&this.ctx.resume();return}let t=globalThis.AudioContext??globalThis.webkitAudioContext;if(t)try{this.ctx=new t,this.master=this.ctx.createGain(),this.master.gain.value=1,this.master.connect(this.ctx.destination)}catch(n){ua.warn("AudioContext init failed",{err:n})}}setVolume(t){if(!this.master||!this.ctx)return;let n=Math.max(0,Math.min(1,t));this.master.gain.setTargetAtTime(n,this.ctx.currentTime,.01)}playTone(t){let n=this.ctx,o=this.master;if(!n||!o||n.state!=="running")return;let i=n.currentTime,a=t.noteMs/1e3;t.notes.forEach((s,l)=>{let c=n.createOscillator();c.type=t.type,c.frequency.value=s;let u=n.createGain(),p=i+l*a;u.gain.setValueAtTime(1e-4,p),u.gain.exponentialRampToValueAtTime(t.peakGain,p+.005),u.gain.exponentialRampToValueAtTime(1e-4,p+a),c.connect(u).connect(o),c.start(p),c.stop(p+a+.01)})}async playUrl(t){let n=this.ctx,o=this.master;if(!n||!o||n.state!=="running")return;let i=await this.getBuffer(t);if(!i)return;let a=n.createBufferSource();a.buffer=i,a.connect(o),a.start()}destroy(){this.ctx&&this.ctx.close().catch(()=>{}),this.ctx=null,this.master=null,this.buffers.clear()}async getBuffer(t){if(!this.ctx)return null;let n=this.buffers.get(t);if(n)return n instanceof Promise,n;let o=this.ctx,i=fetch(t).then(a=>a.ok?a.arrayBuffer():Promise.reject(new Error(`fetch ${a.status}`))).then(a=>o.decodeAudioData(a)).then(a=>(this.buffers.set(t,a),a)).catch(a=>(ua.warn("audio fetch/decode failed",{url:t,err:a}),this.buffers.delete(t),null));return this.buffers.set(t,i),i}};var pa={messageReceived:10,messageSent:0,error:[20,40,20],voiceStart:10,voiceStop:0},fa={messageReceived:{notes:[880,1318.51],noteMs:90,type:"sine",peakGain:.45},messageSent:{notes:[1568],noteMs:60,type:"sine",peakGain:.25},error:{notes:[523.25,392],noteMs:120,type:"triangle",peakGain:.55},voiceStart:{notes:[1318.51],noteMs:50,type:"sine",peakGain:.3},voiceStop:{notes:[880],noteMs:50,type:"sine",peakGain:.3}};var Ue=null,An=0;function Yc(){return typeof navigator<"u"&&typeof navigator.vibrate=="function"}function Jc(){if(typeof document>"u")return null;let e=document.createElement("input");e.type="checkbox",e.setAttribute("switch",""),e.setAttribute("aria-hidden","true"),e.tabIndex=-1,e.id=`__${v.cssPrefix}_haptic_${Math.random().toString(36).slice(2)}`;let t=document.createElement("label");t.htmlFor=e.id,t.setAttribute("aria-hidden","true");let n="position:absolute!important;width:1px!important;height:1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;opacity:0!important;pointer-events:none!important;";return e.style.cssText=n,t.style.cssText=n,document.body.append(e,t),{input:e,label:t}}function ga(e){if(!(e===0||Array.isArray(e)&&e.every(t=>t===0))){if(Yc())try{navigator.vibrate(e);return}catch{}if(Ue||(Ue=Jc()),!!Ue)try{Ue.label.click()}catch{}}}function ma(){An++;let e=!1;return()=>{e||(e=!0,An=Math.max(0,An-1),An===0&&Ue&&(Ue.input.remove(),Ue.label.remove(),Ue=null))}}var Qc=M.scope("feedback"),Zc=100,Tn=class{constructor(t,n){H(this,"mutedSig",L(!1));H(this,"audio",new Cn);H(this,"releaseHaptics");H(this,"sound");H(this,"haptics");H(this,"lastPlayed",new Map);H(this,"reducedMotionMq",null);this.sound=t,this.haptics=n,this.releaseHaptics=ma(),this.audio.setVolume(this.effectiveVolume()),typeof matchMedia<"u"&&(this.reducedMotionMq=matchMedia("(prefers-reduced-motion: reduce)"))}unlock(){this.audio.unlock(),this.audio.setVolume(this.effectiveVolume())}update(t,n){this.sound=t,this.haptics=n,this.audio.setVolume(this.effectiveVolume())}setMuted(t){this.mutedSig.value!==t&&(this.mutedSig.value=t)}toggleMuted(){this.mutedSig.value=!this.mutedSig.value}play(t){this.mutedSig.value||this.isDeduped(t)||(this.lastPlayed.set(t,performance.now()),this.sound.enabled&&this.playSound(t),this.haptics.enabled&&this.isTouchDevice()&&this.playHaptic(t))}destroy(){this.audio.destroy(),this.releaseHaptics()}isDeduped(t){let n=this.lastPlayed.get(t);return n===void 0?!1:performance.now()-n<Zc}playSound(t){let n=this.sound.events?.[t];if(n===!1)return;if(typeof n=="string"){this.audio.playUrl(n).catch(i=>Qc.warn("audio play failed",{err:i,url:n}));return}let o=fa[t];o&&this.audio.playTone(o)}playHaptic(t){if(this.reducedMotionMq?.matches)return;let n=this.haptics.events?.[t];if(n===!1)return;let o=n===!0||n===void 0?pa[t]:n;ga(o)}effectiveVolume(){let t=this.sound.volume??.3;return this.reducedMotionMq?.matches?t*.5:t}isTouchDevice(){return typeof window>"u"?!1:matchMedia("(hover: none) and (pointer: coarse)").matches}};function je(e,t){return e instanceof ve&&e.status===429?t.errorRateLimited:t.errorGeneric}var ed=0;function r(e,t,n,o,i,a){t||(t={});var s,l,c=t;if("ref"in c)for(l in c={},t)l=="ref"?s=t[l]:c[l]=t[l];var u={type:e,props:c,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ed,__i:-1,__u:0,__source:i,__self:a};if(typeof e=="function"&&(s=e.defaultProps))for(l in s)c[l]===void 0&&(c[l]=s[l]);return B.vnode&&B.vnode(u),u}var T={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24"},td=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M21 12a8 8 0 0 1-12 6.93L3 21l1.65-5.16A8 8 0 1 1 21 12Z"})}),Ce=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M18 6 6 18M6 6l12 12"})}),ha=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M12 5v14M5 12h14"})}),va=()=>r("svg",{...T,"aria-hidden":"true",children:[r("path",{d:"m22 2-7 20-4-9-9-4Z"}),r("path",{d:"M22 2 11 13"})]}),ba=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M12 19V5M5 12l7-7 7 7"})}),xa=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M3 20V4l18 8-18 8Z"})}),In=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"m9 18 6-6-6-6"})}),ya=()=>r("svg",{...T,"aria-hidden":"true",children:r("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})}),Pa=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"m21 11-9 9a5.5 5.5 0 0 1-7.78-7.78l8.49-8.49a3.67 3.67 0 0 1 5.19 5.19l-8.49 8.49a1.83 1.83 0 0 1-2.6-2.6l7.78-7.78"})}),Sa=()=>r("svg",{...T,"aria-hidden":"true",children:[r("rect",{x:"9",y:"2",width:"6",height:"12",rx:"3"}),r("path",{d:"M5 10a7 7 0 0 0 14 0M12 19v3"})]}),wa=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M3 8V3h5M21 8V3h-5M3 16v5h5M21 16v5h-5"})}),ka=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M8 3v5H3M16 3v5h5M8 21v-5H3M16 21v-5h5"})}),Ea=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M3 3h7v2H5v5H3zM21 3h-7v2h5v5h2zM3 21h7v-2H5v-5H3zM21 21h-7v-2h5v-5h2z"})}),Ca=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M10 3v5H3M14 3v5h7M10 21v-5H3M14 21v-5h7"})}),Aa=()=>r("svg",{...T,"aria-hidden":"true",viewBox:"0 0 10 10",children:r("path",{d:"M9 1L1 9M9 5L5 9M9 9H9",strokeWidth:"1.5"})}),Ta=()=>r("svg",{...T,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"5",r:"1.5",fill:"currentColor",stroke:"none"}),r("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor",stroke:"none"}),r("circle",{cx:"12",cy:"19",r:"1.5",fill:"currentColor",stroke:"none"})]}),Ia=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M11 5 6 9H2v6h4l5 4zM15 9a5 5 0 0 1 0 6M18 7a9 9 0 0 1 0 10"})}),Ra=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M11 5 6 9H2v6h4l5 4zM22 9l-6 6M16 9l6 6"})}),Ma=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M20 6 9 17l-5-5"})}),La=()=>r("svg",{...T,"aria-hidden":"true",children:[r("path",{d:"M3 3v6h6"}),r("path",{d:"M3.05 13A9 9 0 1 0 6 5.3L3 9"}),r("path",{d:"M12 7v5l3 2"})]});var Nt=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),Na=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M15 3h6v6M10 14 21 3M21 14v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5"})}),Oa=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"})}),Da=()=>r("svg",{...T,"aria-hidden":"true",children:[r("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z"}),r("path",{d:"M14 2v6h6"})]}),nd=()=>r("svg",{...T,"aria-hidden":"true",children:[r("path",{d:"m12 3-1.5 4.5L6 9l4.5 1.5L12 15l1.5-4.5L18 9l-4.5-1.5Z"}),r("path",{d:"M19 15v4M17 17h4M5 3v2M4 4h2"})]}),od=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2Z"})}),Vo=()=>r("svg",{...T,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"10"}),r("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),r("path",{d:"M12 17h.01"})]}),rd=()=>r("svg",{...T,"aria-hidden":"true",children:[r("path",{d:"m15 4 3 3-9 9-3-3z"}),r("path",{d:"M18 2v2M20 4h2M3 20l3-3M3 16h2M5 14v2"})]}),id=()=>r("svg",{...T,"aria-hidden":"true",children:[r("rect",{x:"4",y:"8",width:"16",height:"12",rx:"2"}),r("path",{d:"M12 8V4"}),r("circle",{cx:"12",cy:"3",r:"1"}),r("path",{d:"M2 14h2M20 14h2M9 13h.01M15 13h.01M9.5 17h5"})]}),ad=()=>r("svg",{...T,"aria-hidden":"true",children:[r("path",{d:"M4 14v-2a8 8 0 0 1 16 0v2"}),r("rect",{x:"2",y:"14",width:"4",height:"6",rx:"1.5"}),r("rect",{x:"18",y:"14",width:"4",height:"6",rx:"1.5"}),r("path",{d:"M20 20v1a3 3 0 0 1-3 3h-5"})]}),sd=()=>r("svg",{...T,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"10"}),r("circle",{cx:"12",cy:"12",r:"4"}),r("path",{d:"m4.93 4.93 4.24 4.24M14.83 14.83l4.24 4.24M14.83 9.17l4.24-4.24M4.93 19.07l4.24-4.24"})]}),qo=()=>r("svg",{...T,"aria-hidden":"true",children:[r("circle",{cx:"11",cy:"11",r:"7"}),r("path",{d:"m21 21-4.3-4.3"})]}),Ha=()=>r("svg",{...T,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"9"}),r("path",{d:"m8.5 12 2.5 2.5 4.5-5"})]}),Ba=()=>r("svg",{...T,"aria-hidden":"true",children:[r("path",{d:"M3 9.5 12 3l9 6.5"}),r("path",{d:"M5 9v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V9"})]}),$a=()=>r("svg",{...T,"aria-hidden":"true",children:[r("path",{d:"m3 11 15-5v12L3 13z"}),r("path",{d:"M3 11v2a2 2 0 0 0 2 2h1V9H5a2 2 0 0 0-2 2z"}),r("path",{d:"M7 15v3a2 2 0 0 0 4 0v-2"}),r("path",{d:"M21 10a3 3 0 0 1 0 4"})]}),Ot=()=>r("svg",{...T,"aria-hidden":"true",children:[r("path",{d:"M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z"}),r("path",{d:"M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1"})]}),Ua=()=>r("svg",{...T,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"4"}),r("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"})]}),za=()=>r("svg",{...T,"aria-hidden":"true",children:r("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}),Fa=()=>r("svg",{...T,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"9"}),r("path",{d:"M12 3v18"}),r("path",{d:"M12 3a9 9 0 0 1 0 18z",fill:"currentColor",stroke:"none"})]}),ld=()=>r("svg",{...T,"aria-hidden":"true",children:[r("circle",{cx:"10.5",cy:"10.5",r:"6.5"}),r("path",{d:"M8 11a2.5 2.5 0 0 0 5 0"}),r("path",{d:"m20 20-4.4-4.4"})]}),cd=()=>r("svg",{...T,"aria-hidden":"true",children:[r("path",{d:"M12 3.5 13.6 9 19 10.5 13.6 12 12 17.5 10.4 12 5 10.5 10.4 9z"}),r("path",{d:"M18.5 4v3M20 5.5h-3M5.5 16v2.5M6.75 17.25h-2.5"})]}),dd=()=>r("svg",{...T,"aria-hidden":"true",children:[r("path",{d:"M4 18h16"}),r("path",{d:"M5 18a7 7 0 0 1 14 0"}),r("path",{d:"M12 8V6"}),r("path",{d:"M10 6h4"})]}),_d=()=>r("svg",{...T,"aria-hidden":"true",children:[r("path",{d:"M7 11V6.5a1.5 1.5 0 0 1 3 0V10"}),r("path",{d:"M10 10V5.5a1.5 1.5 0 0 1 3 0V10"}),r("path",{d:"M13 10V6.5a1.5 1.5 0 0 1 3 0V12"}),r("path",{d:"M16 9.5a1.5 1.5 0 0 1 3 0v2.5a7 7 0 0 1-7 7 7 7 0 0 1-6.4-4.2L4 12.5a1.5 1.5 0 0 1 2.6-1.5L7 11"})]}),Wa={chat:td,message:od,bubbles:Ot,spark:nd,wand:rd,bot:id,help:Vo,lifebuoy:sd,headset:ad,search:ld,sparkles:cd,concierge:dd,wave:_d};var C=v.cssPrefix,P={launcher:`${C}-launcher`,callout:`${C}-callout`,calloutDismiss:`${C}-callout-dismiss`,panel:`${C}-panel`,panelHeader:`${C}-panel-header`,resizeGrip:`${C}-resize-grip`,actionClear:`${C}-action-clear`,actionExpand:`${C}-action-expand`,actionFullscreen:`${C}-action-fullscreen`,actionPopOut:`${C}-action-popout`,actionSound:`${C}-action-sound`,actionHistory:`${C}-action-history`,actionLanguage:`${C}-action-language`,actionTheme:`${C}-action-theme`,actionClose:`${C}-action-close`,actionOverflow:`${C}-action-overflow`,languageOption:`${C}-language-option`,themeOption:`${C}-theme-option`,composer:`${C}-composer`,composerInput:`${C}-composer-input`,composerSend:`${C}-composer-send`,composerStop:`${C}-composer-stop`,composerAttach:`${C}-composer-attach`,composerFileInput:`${C}-composer-file-input`,composerVoice:`${C}-composer-voice`,attachmentChip:`${C}-attachment-chip`,attachmentRemove:`${C}-attachment-remove`,suggestion:`${C}-suggestion`,messageBubble:`${C}-message`,messageRetry:`${C}-message-retry`,historyPane:`${C}-history-pane`,historyBack:`${C}-history-back`,historyItem:`${C}-history-item`,sidebar:`${C}-sidebar`,sidebarToggle:`${C}-sidebar-toggle`,sidebarNewChat:`${C}-sidebar-new-chat`,sidebarItem:`${C}-sidebar-item`,messengerHome:`${C}-messenger-home`,modulesEmpty:`${C}-modules-empty`,tab:`${C}-tab`,tabBadge:`${C}-tab-badge`,homeView:`${C}-home-view`,homeGreeting:`${C}-home-greeting`,homeBrand:`${C}-home-brand`,backHeader:`${C}-back-header`,contentView:`${C}-content-view`,contentScroll:`${C}-content-scroll`,homeSearch:`${C}-home-search`,helpSearch:`${C}-help-search`,homeRecent:`${C}-home-recent`,homeContentRow:`${C}-home-content-row`,helpArticle:`${C}-help-article`,newsItem:`${C}-news-item`};function ce(e,t){return`${e}-${t}`}var Hp={clear:P.actionClear,expand:P.actionExpand,fullscreen:P.actionFullscreen,popOut:P.actionPopOut,sound:P.actionSound,history:P.actionHistory,language:P.actionLanguage,theme:P.actionTheme,close:P.actionClose};var Rn=v.cssPrefix;function Ga({onToggle:e,launcher:t,strings:n,leaving:o,edgeTab:i}){let a=t.variant!=="circle"&&!!t.label;return r("button",{type:"button",class:`${Rn}-fab`,"data-variant":t.variant,"data-size":t.size,"data-edge-tab":i?"true":void 0,"data-leaving":o?"true":void 0,"data-testid":P.launcher,onClick:e,"aria-label":n.launcherOpen,children:[ud(t.icon),a?r("span",{class:`${Rn}-fab-label`,children:t.label}):null]})}function ud(e){let t=Wa[e];return t?r(t,{}):r(pd,{source:e})}function pd({source:e}){return r("span",{ref:t=>{t&&fd(t,e)},"aria-hidden":"true"})}function fd(e,t){if(e.dataset.svgMounted!==t)try{let o=new DOMParser().parseFromString(t,"image/svg+xml").documentElement;o&&o.tagName.toLowerCase()==="svg"&&(e.replaceChildren(document.importNode(o,!0)),e.dataset.svgMounted=t)}catch{}}function Ka({callout:e,launcherPosition:t,closeLabel:n,onDismiss:o}){let[i,a]=k(!1);return w(()=>{let s=setTimeout(()=>a(!0),e.delayMs);return()=>clearTimeout(s)},[e.delayMs]),w(()=>{if(!i||e.autoDismissMs<=0)return;let s=setTimeout(o,e.autoDismissMs);return()=>clearTimeout(s)},[i,e.autoDismissMs,o]),i?r("div",{class:`${Rn}-callout`,role:"status","data-shape":e.shape,"data-position":gd(e.position,t),"data-animated":e.animated?"true":void 0,"data-testid":P.callout,children:[r("span",{children:e.text}),r("button",{type:"button",class:`${Rn}-callout-close`,onClick:o,"aria-label":n,title:n,"data-testid":P.calloutDismiss,children:r(Ce,{})})]}):null}function gd(e,t){let n=t.endsWith("-right"),o=t.startsWith("bottom-");return e==="vertical"?o?"top":"bottom":n?"left":"right"}function Mn({panelEl:e,resize:t,position:n,initialSize:o,onSizeChange:i,strings:a}){let s=v.cssPrefix,l=N(null);if(w(()=>{if(!e)return;let g=e.style;t.minWidth&&g.setProperty(`--${s}-resize-min-w`,t.minWidth),t.maxWidth&&g.setProperty(`--${s}-resize-max-w`,t.maxWidth),t.minHeight&&g.setProperty(`--${s}-resize-min-h`,t.minHeight),t.maxHeight&&g.setProperty(`--${s}-resize-max-h`,t.maxHeight),o&&(g.setProperty(`--${s}-widget-w`,`${o.width}px`),g.setProperty(`--${s}-widget-h`,`${o.height}px`))},[e,t.minWidth,t.maxWidth,t.minHeight,t.maxHeight,s,o]),!e)return null;let c=n.startsWith("top-"),u=n.endsWith("-right"),p=`${s}-resize-grip ${s}-resize-grip--${c?"bottom":"top"}-${u?"left":"right"}`,d=g=>{if(!e)return;let h=g.currentTarget,b=e.getBoundingClientRect();l.current={pointerId:g.pointerId,startX:g.clientX,startY:g.clientY,startW:b.width,startH:b.height,dirX:u?-1:1,dirY:c?1:-1},h.setPointerCapture(g.pointerId),g.preventDefault()},_=g=>{let h=l.current;if(!h||g.pointerId!==h.pointerId||!e)return;let b=(g.clientX-h.startX)*h.dirX,x=(g.clientY-h.startY)*h.dirY;e.style.setProperty(`--${s}-widget-w`,`${h.startW+b}px`),e.style.setProperty(`--${s}-widget-h`,`${h.startH+x}px`)},f=g=>{let h=l.current;if(!h||g.pointerId!==h.pointerId||!e)return;g.currentTarget.releasePointerCapture(g.pointerId);let b=e.getBoundingClientRect();i({width:Math.round(b.width),height:Math.round(b.height)}),l.current=null};return r("div",{class:p,role:"separator","aria-orientation":"vertical","aria-label":a.resizeHandle,title:a.resizeHandle,onPointerDown:d,onPointerMove:_,onPointerUp:f,onPointerCancel:f,"data-testid":P.resizeGrip,children:r(Aa,{})})}var Ye=v.cssPrefix,md=`.${Ye}-header, .${Ye}-back-header, .${Ye}-home-hero`,hd='button, a, input, textarea, select, [role="tab"], [contenteditable]',Va=56;function Ln(e,t){w(()=>{if(!t||!e)return;let n=c=>Number.parseFloat(c)||0,o=(c,u)=>Math.min(u,Math.max(-u,c)),i=null,a=c=>{let u=c.target;if(!(u instanceof Element)||!u.closest(md)||u.closest(hd))return;let p=e.getBoundingClientRect();i={id:c.pointerId,x:c.clientX,y:c.clientY,dx:n(e.style.getPropertyValue(`--${Ye}-modal-dx`)),dy:n(e.style.getPropertyValue(`--${Ye}-modal-dy`)),maxX:(window.innerWidth+p.width)/2-Va,maxY:(window.innerHeight+p.height)/2-Va},e.dataset.dragging="true",c.preventDefault()},s=c=>{if(!i||c.pointerId!==i.id)return;let u=o(i.dx+c.clientX-i.x,i.maxX),p=o(i.dy+c.clientY-i.y,i.maxY);e.style.setProperty(`--${Ye}-modal-dx`,`${u}px`),e.style.setProperty(`--${Ye}-modal-dy`,`${p}px`)},l=c=>{!i||c.pointerId!==i.id||(i=null,delete e.dataset.dragging)};return e.addEventListener("pointerdown",a),window.addEventListener("pointermove",s),window.addEventListener("pointerup",l),window.addEventListener("pointercancel",l),()=>{e.removeEventListener("pointerdown",a),window.removeEventListener("pointermove",s),window.removeEventListener("pointerup",l),window.removeEventListener("pointercancel",l)}},[e,t])}function Dt(e,t,n,o){switch(e){case"clear":case"sound":case"history":case"language":case"theme":return!0;case"expand":return t==="floating";case"fullscreen":return t!=="standalone";case"popOut":return t!=="standalone"&&!!o?.popOutUrl;case"close":return t==="standalone"||t==="page"?!1:t==="inline"?n==="fullscreen":!0}}function Nn(e,t,n){return Dt("close",e,t)?n.main.includes("close")||n.overflow.includes("close"):!1}function qa(e,t){return e==="inline"&&t==="fullscreen"?"exit-fullscreen":"close"}var vd='a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),[tabindex]:not([tabindex="-1"])';function On(e){let t=n=>{if(n.key!=="Tab")return;let o=[...e.querySelectorAll(vd)].filter(l=>l.offsetParent!==null||l===document.activeElement);if(o.length===0){n.preventDefault();return}let i=o[0],a=o[o.length-1];if(!i||!a)return;let s=e.getRootNode().activeElement;n.shiftKey&&s===i?(n.preventDefault(),a.focus()):!n.shiftKey&&s===a&&(n.preventDefault(),i.focus())};return e.addEventListener("keydown",t),()=>e.removeEventListener("keydown",t)}function Dn(e){return e.trim().split(/\s+/).slice(0,2).map(t=>t.charAt(0).toUpperCase()).join("")}var Xo=v.cssPrefix;function Xa({agent:e}){let t=e.status??"online";return r("div",{class:`${Xo}-agent`,children:[r("div",{class:`${Xo}-agent-avatar`,"data-status":t,children:e.avatar?r("img",{src:e.avatar,alt:""}):r("span",{children:Dn(e.name)})}),r("div",{class:`${Xo}-agent-meta`,children:[r("strong",{children:e.name}),e.title?r("span",{children:e.title}):null]})]})}var ja=M.scope("attachments");function Hn(e,t,n){let o=xd(e),i=[],a=[],s=Sd(n.accept),l=t.reduce((u,p)=>u+p.size,0),c=t.length;for(let u of o){let p=bd(u,c,l,n,s);if(p){a.push({file:u,reason:p});continue}i.push(Pd(u)),l+=u.size,c+=1}return(i.length||a.length)&&ja.debug("ingest",{accepted:i.length,rejected:a.map(u=>({name:u.file.name,reason:u.reason}))}),{accepted:i,rejected:a}}function jo(e){try{URL.revokeObjectURL(e.previewUrl)}catch(t){ja.debug("revokeObjectURL failed",{error:t})}}function bd(e,t,n,o,i){return t>=o.maxCount?"count":n+e.size>o.maxBytes?"bytes":wd(e,i)?null:"mime"}function xd(e){return e?Array.isArray(e)?e.filter(t=>t instanceof File):[...e].map(t=>t instanceof File?t:yd(t)).filter(t=>t!==null):[]}function yd(e){let t=e;return!t?.getAsFile||t.kind!=="file"?null:t.getAsFile()}function Pd(e){return{file:e,id:ke(),mediaType:e.type||"application/octet-stream",name:e.name||"pasted-file",previewUrl:URL.createObjectURL(e),size:e.size}}function Sd(e){return e.split(",").map(t=>t.trim().toLowerCase()).filter(Boolean).map(t=>{if(t.startsWith("."))return{kind:"ext",ext:t};let[n="*",o="*"]=t.split("/");return{kind:"mime",type:n,subtype:o}})}function wd(e,t){if(t.length===0)return!0;let[n="*",o="*"]=(e.type||"").toLowerCase().split("/"),i=(e.name||"").toLowerCase();return t.some(a=>a.kind==="ext"?i.endsWith(a.ext):(a.type==="*"||a.type===n)&&(a.subtype==="*"||a.subtype===o))}var Ht=v.cssPrefix;function Ya({attachment:e,onRemove:t}){let n=e.mediaType.startsWith("image/");return r("span",{class:`${Ht}-attachment-chip`,title:e.name,"data-testid":ce(P.attachmentChip,e.id),children:[n?r("img",{class:`${Ht}-attachment-thumb`,src:e.previewUrl,alt:""}):r("span",{class:`${Ht}-attachment-thumb`,"aria-hidden":"true",children:r(Da,{})}),r("span",{class:`${Ht}-attachment-name`,children:e.name}),r("button",{type:"button",class:`${Ht}-attachment-remove`,onClick:t,"aria-label":`Remove ${e.name}`,"data-testid":ce(P.attachmentRemove,e.id),children:r(Ce,{})})]})}var Yo={isSupported:!1,start:()=>{},stop:()=>{}};function Jo(e,t,n){return e==="disabled"?Yo:e==="server"?Ad(n):kd(t)}function kd(e){let t=Ed();if(!t)return Yo;let n=null;return{isSupported:!0,start(o,i){n=new t,n.continuous=!0,n.interimResults=!0,n.lang=e,n.addEventListener("result",s=>{let l=s,c="",u=!1;for(let p=l.resultIndex;p<l.results.length;p++){let d=l.results[p];d&&(c+=d[0].transcript,d.isFinal&&(u=!0))}o(c,u)});let a=()=>{n=null,i()};n.addEventListener("end",a),n.addEventListener("error",a),n.start()},stop(){n?.stop()}}}function Ed(){let e=globalThis;return e.SpeechRecognition??e.webkitSpeechRecognition}var Cd=["audio/webm;codecs=opus","audio/webm","audio/ogg;codecs=opus","audio/mp4"];function Ad(e){if(typeof MediaRecorder>"u"||!navigator?.mediaDevices?.getUserMedia)return Yo;let t=null,n=null,o=[],i=()=>{for(let a of n?.getTracks()??[])a.stop();n=null};return{isSupported:!0,async start(a,s){try{n=await navigator.mediaDevices.getUserMedia({audio:!0});let l=Td();t=new MediaRecorder(n,l?{mimeType:l}:void 0),o=[],t.addEventListener("dataavailable",c=>{c.data.size>0&&o.push(c.data)}),t.addEventListener("stop",async()=>{let c=t?.mimeType??"audio/webm";i();let u=new Blob(o,{type:c});o=[];try{let{text:p}=await e(u,c);p&&a(p,!0)}catch{}finally{s()}}),t.start()}catch{i(),s()}},stop(){t?.stop()}}}function Td(){for(let e of Cd)if(MediaRecorder.isTypeSupported(e))return e}var he=v.cssPrefix,Je=M.scope("composer");function gt(e){return e.reduce((t,n)=>t+n.size,0)}var Id={arrowUp:ba,paperPlane:va,send:xa,chevron:In};function Ja({options:e,transport:t,feedback:n,bus:o,isStreaming:i,onSend:a,onStop:s,attachApiRef:l}){let c=e.strings,[u,p]=k(""),[d,_]=k([]),[f,g]=k(!1),h=N(null),b=N(null),x=e.features.files,S=e.features.voice,[I,j]=k(()=>Jo(S,e.locale,(E,F)=>t.transcribe(E,F)));w(()=>{f||S==="disabled"||j(Jo(S,e.locale,(E,F)=>t.transcribe(E,F)))},[e.locale,S,t,f]),w(()=>{let E=h.current;if(!E)return;let F=E.getRootNode(),Y="activeElement"in F?F.activeElement:null;Y&&E.closest(`.${he}-panel`)?.contains(Y)||E.focus({preventScroll:!0})},[]),w(()=>{let E=h.current;if(E){if(u.length===0){E.style.height="";return}E.style.height="auto",E.style.height=`${Math.min(E.scrollHeight,160)}px`}},[u]);let z=N(d);z.current=d,w(()=>()=>z.current.forEach(jo),[]),w(()=>{if(l)return l.current={attachFromDrop:E=>{let F=Hn(E,z.current,e.attachments);F.accepted.length!==0&&(Je.info("attach (drop)",{count:F.accepted.length,totalBytes:gt(F.accepted)}),o.emit("attach",{count:F.accepted.length,totalBytes:gt(F.accepted)}),_(Y=>[...Y,...F.accepted]))}},()=>{l.current&&(l.current=null)}},[l,e.attachments]),w(()=>{let E=h.current;if(!E)return;let F=E.closest(`.${he}-panel`);if(!F)return;let Y=fe=>{let Fe=fe.clipboardData;if(!Fe)return;if(x){let ue=Hn(Fe.items,z.current,e.attachments);if(ue.accepted.length>0){fe.preventDefault(),Je.info("attach (paste)",{count:ue.accepted.length,totalBytes:gt(ue.accepted)}),o.emit("attach",{count:ue.accepted.length,totalBytes:gt(ue.accepted)}),_(zt=>[...zt,...ue.accepted]);return}}if(fe.target===E)return;let _e=Fe.getData("text/plain");_e&&(fe.preventDefault(),p(ue=>ue+_e),E.focus())};return F.addEventListener("paste",Y),()=>F.removeEventListener("paste",Y)},[x,e.attachments,he]);let oe=()=>{let E=u.trim();!E&&d.length===0||i||(a(E,d),p(""),_([]))},O=E=>{E.key!=="Enter"||E.shiftKey||E.isComposing||(E.preventDefault(),i?s():oe())},le=E=>{let F=E.target,Y=Hn(F.files,d,e.attachments);Y.accepted.length>0&&(Je.info("attach (file picker)",{count:Y.accepted.length,totalBytes:gt(Y.accepted)}),o.emit("attach",{count:Y.accepted.length,totalBytes:gt(Y.accepted)}),_(fe=>[...fe,...Y.accepted])),F.value=""},$=E=>{Je.info("removeAttachment",{id:E}),o.emit("removeAttachment",{id:E}),_(F=>{let Y=F.find(fe=>fe.id===E);return Y&&jo(Y),F.filter(fe=>fe.id!==E)})},R=N(null),tt=()=>{if(I.isSupported){if(f){let E=R.current?Date.now()-R.current:0;Je.info("voiceStop",{durationMs:E}),o.emit("voiceStop",{durationMs:E}),I.stop(),g(!1),n.play("voiceStop"),R.current=null;return}R.current=Date.now(),Je.info("voiceStart"),o.emit("voiceStart",void 0),g(!0),n.play("voiceStart"),I.start((E,F)=>p(Y=>F?`${Y}${E} `:Y),()=>{if(g(!1),R.current){let E=Date.now()-R.current;Je.debug("voiceStop (auto)",{durationMs:E}),o.emit("voiceStop",{durationMs:E}),R.current=null}})}},de=Id[e.composer.sendButton.icon];return r("div",{class:`${he}-composer`,"data-testid":P.composer,children:[d.length>0?r("div",{class:`${he}-attachments`,children:d.map(E=>r(Ya,{attachment:E,onRemove:()=>$(E.id)},E.id))}):null,r("div",{class:`${he}-composer-row`,children:[r("div",{class:`${he}-composer-actions`,children:[x?r("button",{type:"button",class:`${he}-icon-btn`,onClick:()=>b.current?.click(),"aria-label":c.attach,"data-testid":P.composerAttach,children:r(Pa,{})}):null,I.isSupported?r("button",{type:"button",class:`${he}-icon-btn`,onClick:tt,"aria-label":f?c.micStop:c.micStart,"aria-pressed":f,"data-recording":f?"true":void 0,"data-testid":P.composerVoice,children:r(Sa,{})}):null]}),r("textarea",{ref:h,class:`${he}-textarea`,rows:1,value:u,placeholder:c.composerPlaceholder,onInput:E=>p(E.target.value),onKeyDown:O,"aria-label":c.composerPlaceholder,"data-testid":P.composerInput}),i?r("button",{type:"button",class:`${he}-send`,onClick:s,"aria-label":c.stop,"data-testid":P.composerStop,children:r(ya,{})}):r("button",{type:"button",class:`${he}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:oe,disabled:!u.trim()&&d.length===0,"aria-label":c.send,"data-testid":P.composerSend,children:r(de,{})})]}),r("input",{ref:b,type:"file",multiple:!0,accept:e.attachments.accept,onChange:le,class:`${he}-sr-only`,"data-testid":P.composerFileInput})]})}var Rd=v.cssPrefix;function Qa({visible:e,strings:t}){return e?r("div",{class:`${Rd}-dropzone`,role:"status","aria-live":"polite",children:t.dropZone}):null}function Bn({containerRef:e,onDrop:t}){let[n,o]=k(!1);return w(()=>{let i=e.current;if(!i)return;let a=0,s=p=>{a+=1,p.dataTransfer?.types.includes("Files")&&(p.preventDefault(),o(!0))},l=()=>{a-=1,!(a>0)&&(a=0,o(!1))},c=p=>{p.dataTransfer?.types.includes("Files")&&p.preventDefault()},u=p=>{a=0,o(!1),p.dataTransfer&&(p.preventDefault(),t(p.dataTransfer.items))};return i.addEventListener("dragenter",s),i.addEventListener("dragleave",l),i.addEventListener("dragover",c),i.addEventListener("drop",u),()=>{i.removeEventListener("dragenter",s),i.removeEventListener("dragleave",l),i.removeEventListener("dragover",c),i.removeEventListener("drop",u)}},[e,t]),{visible:n}}function Za({itemCount:e,initialFocusIndex:t}){let[n,o]=k(!1),i=N(null),a=N(null),[s,l]=k(-1),c=D(()=>{o(!1),l(-1),i.current?.focus()},[]),u=D(()=>o(_=>!_),[]);w(()=>{if(!n)return;let _=f=>{let g=a.current,h=i.current;if(!g||!h)return;let b=f.composedPath();b.includes(g)||b.includes(h)||(o(!1),l(-1))};return document.addEventListener("click",_,!0),()=>document.removeEventListener("click",_,!0)},[n]),w(()=>{if(!n||e===0)return;let _=t?.()??0,f=_<0||_>=e?0:_;l(f)},[n,e,t]),w(()=>{if(!n||s<0)return;a.current?.querySelectorAll("[role='menuitem']")?.[s]?.focus()},[n,s]);let p=D(_=>{(_.key==="ArrowDown"||_.key==="Enter"||_.key===" ")&&(_.preventDefault(),o(!0))},[]),d=D(_=>{if(e!==0)switch(_.key){case"Escape":_.preventDefault(),c();return;case"ArrowDown":_.preventDefault(),l(f=>(f+1)%e);return;case"ArrowUp":_.preventDefault(),l(f=>(f-1+e)%e);return;case"Home":_.preventDefault(),l(0);return;case"End":_.preventDefault(),l(e-1)}},[e,c]);return{open:n,focusIndex:s,triggerRef:i,menuRef:a,toggle:u,close:c,onTriggerKey:p,onMenuKey:d}}function es({items:e,triggerLabel:t}){let n=v.cssPrefix,o=Za({itemCount:e.length}),i=a=>{a.disabled||(a.onSelect(),a.keepOpen||o.close())};return r("div",{class:`${n}-menu-wrap`,children:[r("button",{ref:o.triggerRef,type:"button",class:`${n}-icon-btn`,"aria-label":t,"aria-haspopup":"menu","aria-expanded":o.open,title:t,onClick:o.toggle,onKeyDown:o.onTriggerKey,children:r(Ta,{})}),o.open?r("div",{ref:o.menuRef,class:`${n}-menu`,role:"menu","aria-label":t,onKeyDown:o.onMenuKey,tabIndex:-1,children:e.map(a=>r("button",{type:"button",role:"menuitem",class:`${n}-menu-item`,"aria-pressed":a.type==="switch"?a.on:void 0,disabled:a.disabled,lang:a.lang,onClick:()=>i(a),children:[a.icon?r("span",{class:`${n}-menu-icon`,children:a.icon}):null,r("span",{class:`${n}-menu-label`,children:a.label}),a.type==="switch"&&a.on?r("span",{class:`${n}-menu-check`,"aria-hidden":"true",children:r(Ma,{})}):null]},a.id))}):null]})}var Qo=v.cssPrefix,Md={auto:"dark",dark:"light",light:"auto"};function Ld(e){return e==="light"?r(Ua,{}):e==="dark"?r(za,{}):r(Fa,{})}function Ae({panelProps:e,variant:t}){let{options:n,panelSize:o,feedback:i,onClose:a,onClear:s,onExpand:l,onFullscreen:c,onPopOut:u,onSoundToggle:p}=e,{onToggleHistory:d,onLocaleChange:_,onThemeChange:f}=e,g=n.strings,h=n.mode,b=t==="chat",x=we(()=>i.mutedSig.value).value,S=new Set([...n.actions.main,...n.actions.overflow]),I=R=>S.has(R),j=R=>Dt(R,h,o,{popOutUrl:n.popOutUrl}),z=n.themeMode,oe={auto:g.themeAuto,light:g.themeLight,dark:g.themeDark},O=[];if(I("theme")&&O.push({id:"theme",icon:Ld(z),label:`${g.theme}: ${oe[z]}`,onSelect:()=>f(Md[z]),keepOpen:!0}),I("language")&&n.availableLocales.length>1)for(let R of n.availableLocales)O.push({id:`language:${R}`,label:`${g.language} \u2014 ${R}`,lang:R,type:"switch",on:R===n.locale,onSelect:()=>_(R)});if(I("expand")&&j("expand")){let R=o==="expanded";O.push({id:"expand",icon:R?r(ka,{}):r(wa,{}),label:R?g.collapse:g.expand,type:"switch",on:R,onSelect:l})}if(I("fullscreen")&&j("fullscreen")){let R=o==="fullscreen";O.push({id:"fullscreen",icon:R?r(Ca,{}):r(Ea,{}),label:R?g.exitFullscreen:g.fullscreen,type:"switch",on:R,onSelect:c})}I("popOut")&&j("popOut")&&O.push({id:"popOut",icon:r(Na,{}),label:g.popOut,onSelect:u}),b&&I("sound")&&O.push({id:"sound",icon:x?r(Ra,{}):r(Ia,{}),label:x?g.soundOff:g.soundOn,type:"switch",on:!x,onSelect:p}),b&&I("clear")&&O.push({id:"clear",icon:r(Oa,{}),label:g.newConversation,onSelect:s});let le=!!a&&Nn(h,o,n.actions),$=b&&I("history");return r("div",{class:`${Qo}-header-actions`,children:[$?r("button",{type:"button",class:`${Qo}-icon-btn`,onClick:d,"aria-label":g.history,title:g.history,"data-testid":P.actionHistory,children:r(La,{})}):null,O.length>0?r(es,{items:O,triggerLabel:g.moreActions}):null,le?r("button",{type:"button",class:`${Qo}-icon-btn`,onClick:a,"aria-label":g.close,title:g.close,"data-testid":P.actionClose,children:r(Ce,{})}):null]})}var tr=1,ns=2,os=4,rs=8,is=16;function Nd(e){switch(e){case tr:return"href";case ns:return"src";case os:return"class";case rs:return"checked";case is:return"start"}}var Od=e=>{switch(e){case 1:return 3;case 2:return 4;case 3:return 5;case 4:return 6;case 5:return 7;default:return 8}},Dd=Od;var ts=24;function or(e){let t=new Uint32Array(ts);return t[0]=1,{renderer:e,text:"",pending:"",tokens:t,len:0,token:1,fence_end:0,blockquote_idx:0,hr_char:"",hr_chars:0,fence_start:0,spaces:new Uint8Array(ts),indent:"",indent_len:0,table_state:0}}function as(e){e.pending.length>0&&se(e,`
|
|
12
12
|
`)}function U(e){e.text.length!==0&&(console.assert(e.len>0,"Never adding text to root"),e.renderer.add_text(e.renderer.data,e.text),e.text="")}function Z(e){console.assert(e.len>0,"No nodes to end"),e.len-=1,e.token=e.tokens[e.len],e.renderer.end_token(e.renderer.data)}function G(e,t){(e.tokens[e.len]===24||e.tokens[e.len]===23)&&t!==25&&Z(e),e.len+=1,e.tokens[e.len]=t,e.token=t,e.renderer.add_token(e.renderer.data,t)}function Hd(e,t,n){for(;n<=e.len;){if(e.tokens[n]===t)return n;n+=1}return-1}function Qe(e,t){for(e.fence_start=0;e.len>t;)Z(e)}function $n(e,t){let n=0;for(let o=0;o<=e.len&&(t-=e.spaces[o],!(t<0));o+=1)switch(e.tokens[o]){case 9:case 10:case 20:case 25:n=o;break}for(;e.len>n;)Z(e);return t}function Zo(e,t){let n=-1,o=-1;for(let i=e.blockquote_idx+1;i<=e.len;i+=1)if(e.tokens[i]===25){if(e.indent_len<e.spaces[i]){o=-1;break}o=i}else e.tokens[i]===t&&(n=i);return o===-1?n===-1?(Qe(e,e.blockquote_idx),G(e,t),!0):(Qe(e,n),!1):(Qe(e,o),G(e,t),!0)}function er(e,t){G(e,25),e.spaces[e.len]=e.indent_len+t,Le(e),e.token=103}function Le(e){e.indent="",e.indent_len=0,e.pending=""}function nr(e){switch(e){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return!0;default:return!1}}function Bd(e){switch(e){case 32:case 58:case 59:case 41:case 44:case 33:case 46:case 63:case 93:case 10:return!0;default:return!1}}function $d(e){return nr(e)||Bd(e)}function se(e,t){for(let n of t){if(e.token===101){switch(n){case" ":e.indent_len+=1;continue;case" ":e.indent_len+=4;continue}let i=$n(e,e.indent_len);e.indent_len=0,e.token=e.tokens[e.len],i>0&&se(e," ".repeat(i))}let o=e.pending+n;switch(e.token){case 21:case 1:case 20:case 24:case 23:switch(console.assert(e.text.length===0,"Root should not have any text"),e.pending[0]){case void 0:e.pending=n;continue;case" ":console.assert(e.pending.length===1),e.pending=n,e.indent+=" ",e.indent_len+=1;continue;case" ":console.assert(e.pending.length===1),e.pending=n,e.indent+=" ",e.indent_len+=4;continue;case`
|
|
13
13
|
`:if(console.assert(e.pending.length===1),e.tokens[e.len]===25&&e.token===21){Z(e),Le(e),e.pending=n;continue}Qe(e,e.blockquote_idx),Le(e),e.blockquote_idx=0,e.fence_start=0,e.pending=n;continue;case"#":switch(n){case"#":if(e.pending.length<6){e.pending=o;continue}break;case" ":$n(e,e.indent_len),G(e,Dd(e.pending.length)),Le(e);continue}break;case">":{let a=Hd(e,20,e.blockquote_idx+1);a===-1?(Qe(e,e.blockquote_idx),e.blockquote_idx+=1,e.fence_start=0,G(e,20)):e.blockquote_idx=a,Le(e),e.pending=n;continue}case"-":case"*":case"_":if(e.hr_chars===0&&(console.assert(e.pending.length===1,"Pending should be one character"),e.hr_chars=1,e.hr_char=e.pending),e.hr_chars>0){switch(n){case e.hr_char:e.hr_chars+=1,e.pending=o;continue;case" ":e.pending=o;continue;case`
|
|
14
14
|
`:if(e.hr_chars<3)break;$n(e,e.indent_len),e.renderer.add_token(e.renderer.data,22),e.renderer.end_token(e.renderer.data),Le(e),e.hr_chars=0;continue}e.hr_chars=0}if(e.pending[0]!=="_"&&e.pending[1]===" "){Zo(e,23),er(e,2),se(e,o.slice(2));continue}break;case"`":if(e.pending.length<3){if(n==="`"){e.pending=o,e.fence_start=o.length;continue}e.fence_start=0;break}switch(n){case"`":e.pending.length===e.fence_start?(e.pending=o,e.fence_start=o.length):(G(e,2),Le(e),e.fence_start=0,se(e,o));continue;case`
|