@helpai/elements 0.32.0 → 0.32.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.d.ts +4 -1
- package/index.mjs +2 -3
- package/package.json +1 -1
- package/schema.d.ts +26 -26
- package/web-component.mjs +2 -3
package/elements.esm.js
CHANGED
|
@@ -8,7 +8,7 @@ var sc=Object.defineProperty;var lc=(e,t,n)=>t in e?sc(e,t,{enumerable:!0,config
|
|
|
8
8
|
|
|
9
9
|
`))!==-1;){let l=o.slice(0,s);o=o.slice(s+2);let c=Ci(l);c&&(yield c)}}}finally{n.releaseLock()}}function Ci(e){let t="",n;for(let o of e.split(`
|
|
10
10
|
`))if(!(o===""||o.startsWith(":"))){if(o.startsWith("data:")){let a=o.slice(5).replace(/^ /,"");t=t?`${t}
|
|
11
|
-
${a}`:a;continue}o.startsWith("id:")&&(n=o.slice(3).trim())}if(!t||t==="[DONE]")return null;try{let o=JSON.parse(t);return ki.trace("chunk",{type:o.type,eventId:n}),{chunk:o,eventId:n}}catch(o){return ki.trace("frame parse failed",{err:o,payload:t.slice(0,200)}),null}}function Ld(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 Ti=e=>e&&Object.keys(e).length>0?e:void 0;function Ei(e,t){let n=Ti(e),o=Ti(t);if(!n&&!o)return;let a={};return n&&(a.user=n),o&&(a.page=o),Ld(JSON.stringify(a))}function eo(e){if(!e)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}var Me={handshake:"/pai/handshake",streamMessage:"/pai/stream-message",streamResume:"/pai/stream-resume",cancelStream:"/pai/cancel-stream",listConversations:"/pai/list-conversations",listMessages:"/pai/list-messages",updateSettings:"/pai/update-settings",markRead:"/pai/mark-read",bootstrap:"/pai/bootstrap",content:"/pai/content",submitForm:"/pai/submit-form"},Ii="context";function Ai(e){let n={messages:e.messages.map(i=>({id:i.id,parts:Nd(i),role:i.role,createdAt:i.createdAt!==void 0?new Date(i.createdAt).toISOString():void 0})),conversationId:e.conversationId,trigger:e.trigger??"submit-message"};e.visitorId&&(n.visitorId=e.visitorId),e.userPrefs&&(n.userPrefs=e.userPrefs);let o={},a=e.tools?.map(Od).filter(i=>i!==null);return a?.length&&(o.tools=a),e.responseMode&&(o.responseMode=e.responseMode),Object.keys(o).length>0&&(n.data=o),n}function Md(e){return e.state==="output"||e.state==="error"||e.approval?.approved!==void 0}function Od(e){return typeof e=="string"?e?{code:e}:null:e?.code?e:null}function Nd(e){let t=[];for(let n of e.parts)if(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}),n.kind==="tool"&&Md(n)){let o={type:"tool",toolCallId:n.toolCallId,toolName:n.toolName,state:n.state};n.input!==void 0&&(o.input=n.input),n.output!==void 0&&(o.output=n.output),n.error!==void 0&&(o.errorText=n.error),n.approval&&n.approval.approved!==void 0&&(o.approval=n.approval),t.push(o)}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 J=U.scope("transport"),Dd=3,Mi=400,$d=6e4,Ri=3,Hd=new Set([408,425,429,500,502,503,504]);function Li(e){return Mi*2**e+Math.floor(Math.random()*250)}function Fd(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 Pr(e,t){return new Promise(n=>{if(t?.aborted)return n();let o=setTimeout(i,e),a=()=>i();t?.addEventListener("abort",a,{once:!0});function i(){clearTimeout(o),t?.removeEventListener("abort",a),n()}})}var to=class{constructor(t){X(this,"opts",t);X(this,"visitorId");X(this,"conversationId");X(this,"userContext");X(this,"pageContext");X(this,"locale");X(this,"contentCache",new Map)}setContext(t,n){this.userContext=t,this.pageContext=n}setLocale(t){this.locale=t}primeIdentity(t,n){t&&(this.visitorId=t),n&&(this.conversationId=n)}envelope(){let t={};this.visitorId&&(t.visitorId=this.visitorId),this.conversationId&&(t.conversationId=this.conversationId),this.locale&&(t.locale=this.locale);let n=Ei(this.userContext,this.pageContext);return n&&(t[Ii]=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,a]of Object.entries(this.envelope()))n.searchParams.has(o)||n.searchParams.set(o,a);return n.toString()}async handshake(t){J.debug("handshake \u2192",{visitorId:t.visitorId,conversationId:t.conversationId,locale:t.locale});let n=await this.postJson(Me.handshake,t,"handshake");return J.debug("handshake \u2190",{visitorId:n.visitorId,conversationId:n.conversationId,hasWelcome:!!n.welcome,hasConfig:!!n.config,rebind:n.rebind}),zd(n)||J.warn("handshake response did not match expected shape; using raw response",{response:n}),this.visitorId=n.visitorId??t.visitorId,this.conversationId=n.conversationId,n}async uploadFile(t){J.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 J.debug("uploadFile \u2190",{id:o.id,url:o.url}),o}async transcribe(t,n="audio/webm"){J.debug("transcribe \u2192",{size:t.size,mimeType:n});let o=new FormData;o.append("audio",t,`voice.${Bd(n)}`),o.append("mimeType",n);let a=await this.postForm(this.transcribePath,o,"transcribe");return J.debug("transcribe \u2190",{textLen:a.text.length}),a}async listConversations(t={}){let n=new URL(this.url(Me.listConversations));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),J.debug("listConversations \u2192",{visitorId:t.visitorId??this.visitorId,limit:t.limit,cursor:t.cursor});let o=await this.getJson(n.toString(),"listConversations"),a=o.conversations??[];return J.debug("listConversations \u2190",{count:a.length,nextCursor:o.nextCursor}),{conversations:a.map(i=>({conversationId:i.conversationId,title:i.title,lastMessageAt:i.lastMessageAt,preview:i.preview,canContinue:i.canContinue,unreadCount:i.unreadCount})),nextCursor:o.nextCursor}}async loadConversation(t){let n=new URL(this.url(Me.listMessages));n.searchParams.set("conversationId",t),J.debug("loadConversation \u2192",{conversationId:t,visitorId:this.visitorId});let o=await this.getJson(n.toString(),"loadConversation"),a=o.messages??[];return J.debug("loadConversation \u2190",{conversationId:o.conversationId,canContinue:o.canContinue,messageCount:a.length,hasSuggestions:!!o.suggestions}),{conversationId:o.conversationId,canContinue:o.canContinue??!0,messages:a,agent:o.agent,suggestions:o.suggestions}}async markRead(t){if(!(!this.visitorId||!t)){J.debug("markRead \u2192",{conversationId:t,visitorId:this.visitorId});try{await this.postJson(Me.markRead,{conversationId:t},"markRead")}catch(n){J.debug("markRead failed (non-fatal)",{err:n})}}}listContent(t={}){let n=`${this.locale??""}|${JSON.stringify(t,Object.keys(t).toSorted())}`,o=this.contentCache.get(n);if(o&&Date.now()-o.at<$d)return J.debug("listContent \u2192 cache",t),o.result;let a=this.fetchContent(t).catch(i=>{throw this.contentCache.delete(n),i});return this.contentCache.set(n,{at:Date.now(),result:a}),a}async fetchContent(t){let n=new URL(this.dataUrl(Me.content));for(let[i,s]of Object.entries(t))s!==void 0&&n.searchParams.set(i,Array.isArray(s)?s.join(","):String(s));J.debug("listContent \u2192",t);let o=await this.getJson(n.toString(),"listContent"),a=(o.items??[]).map(i=>Ta(i,this.locale));return J.debug("listContent \u2190",{count:a.length,total:o.pagination?.total}),{...o,items:a}}async bootstrap(t){let n=new URL(this.dataUrl(Me.bootstrap));t&&n.searchParams.set("conversationId",t),J.debug("bootstrap \u2192",{conversationId:t??this.conversationId});let o=await this.getJson(n.toString(),"bootstrap"),a=o.forms??[],i=o.formSubmissions??[];return J.debug("bootstrap \u2190",{forms:a.length,formSubmissions:i.length}),{forms:a,formSubmissions:i}}async saveUserPrefs(t){J.debug("saveUserPrefs \u2192",{visitorId:this.visitorId,conversationId:this.conversationId,settingsKeys:Object.keys(t)});let n=await this.postJson(Me.updateSettings,{userPrefs:t},"saveUserPrefs");return J.debug("saveUserPrefs \u2190",{ok:n.ok}),n}get uploadPath(){return this.opts.endpoints?.upload??"/pai/upload-file"}get transcribePath(){return this.opts.endpoints?.transcribe??"/pai/transcribe-audio"}get submitFormPath(){return this.opts.endpoints?.submitForm??Me.submitForm}async submitForm(t){J.debug("submitForm \u2192",{formId:t.formId,trigger:t.trigger,fields:Object.keys(t.values).length});try{await this.postJson(this.dataUrl(this.submitFormPath),t,"submitForm")}catch(n){J.debug("submitForm failed (non-fatal)",{err:n})}}sendMessage(t){J.debug("message \u2192",{conversationId:t.conversationId,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.conversationId)}}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 a=1;a<=Dd&&!t.signal.aborted;a++){if((!o||a>1)&&(await Pr(Mi*a,t.signal),t.signal.aborted))return;let i;try{i=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;J.debug("resume fetch failed \u2014 retrying",{attempt:a,err:l});continue}if(i.status===204||!i.ok){J.debug("resume \u2192 no in-flight stream",{status:i.status});return}let s=n.size;if(yield*this.drain(xr(i,t.signal),n,t))return;if(n.size===s){J.debug("resume \u2192 stream closed with no new events; nothing to resume");return}}if(!t.signal.aborted)throw new Le("stream incomplete after resume attempts","server")}async*drain(t,n,o){try{for await(let a of t){if(o.signal.aborted)return!0;if(a.eventId){if(n.has(a.eventId))continue;n.add(a.eventId)}if(yield a,a.chunk.type==="finish"||a.chunk.type==="error")return!0}}catch(a){if(o.signal.aborted)return!0;if(a instanceof Le&&a.status!==void 0)throw a;J.debug("stream segment dropped",{err:a})}return!1}cancelStream(t,n){t.signal.aborted||(J.debug("cancel stream",{conversationId:n,visitorId:this.visitorId}),t.abort(),!(!this.visitorId||!n)&&this.fetchImpl(this.url(Me.cancelStream),{method:"POST",credentials:"omit",headers:{"content-type":"application/json",...this.opts.auth.headers()},body:JSON.stringify(this.withEnvelope({})),keepalive:!0}).catch(o=>J.debug("cancel POST failed (non-fatal)",{err:o})))}async*openMessageStream(t,n){let o=await this.fetchImpl(this.url(Me.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*xr(o,n)}resumeUrl(t){let n=new URL(this.withEnvelopeQuery(Me.streamResume));return n.searchParams.set("resumeAt",String(t)),n.toString()}async postJson(t,n,o){let a=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(a,o)}async postForm(t,n,o){let a=await this.fetchImpl(this.url(t),{method:"POST",credentials:"omit",headers:this.opts.auth.headers(),body:this.appendEnvelope(n)});return this.assertOk(a,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[a,i]=t(),s;try{s=await this.fetchImpl(a,i)}catch(c){if(o>=Ri)throw new Le(`${n} failed: network error`,"network",void 0,c);J.debug("request network error \u2014 retrying",{label:n,attempt:o}),await Pr(Li(o));continue}if(s.ok||!Hd.has(s.status)||o>=Ri)return s;let l=Fd(s.headers)??Li(o);J.debug("request retryable status \u2014 retrying",{label:n,status:s.status,attempt:o,wait:l}),await Pr(l)}}async assertOk(t,n){if(!t.ok)throw new Le(`${n} failed: ${t.status}`,"server",t.status);return await t.json()}url(t){return/^https?:\/\//i.test(t)?t:`${this.opts.agentApiBaseUrl}${t}`}dataUrl(t){return/^https?:\/\//i.test(t)?t:`${this.opts.dataApiBaseUrl}${t}`}get fetchImpl(){return this.opts.fetchImpl??globalThis.fetch.bind(globalThis)}};function Bd(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 zd(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.visitorId=="string"&&typeof t.conversationId=="string"}function Oi(e,t){let n=e?[{kind:"text",id:"t0",textSig:F(e),doneSig:F(!0)}]:[];return{id:$e(),role:"user",createdAt:Date.now(),status:"complete",attachments:t,partsSig:F(n)}}function no(){return{id:$e(),role:"assistant",createdAt:Date.now(),status:"streaming",partsSig:F([])}}function yr(e){return Ud({id:e.id,role:e.role,createdAt:Date.now(),status:"complete",parts:[{kind:"text",id:`${e.id}-t0`,text:e.text,done:!0}]})}function Ud(e){return{id:e.id,role:e.role,createdAt:e.createdAt,status:e.status,errorText:e.errorText,finishReason:e.finishReason,attachments:e.attachments,partsSig:F(e.parts.map(Wd))}}function Sr(e){let t=e.parts.map((n,o)=>n.type==="text"?{kind:"text",id:`${e.id}-t${o}`,textSig:F(n.text),doneSig:F(!0)}:n.type==="file"?{kind:"file",url:n.url,mediaType:n.mediaType}:n.type==="tool"?{kind:"tool",toolCallId:n.toolCallId,toolName:n.toolName,inputPartialSig:F(""),inputSig:F(n.input),outputSig:F(n.output),errorSig:F(n.errorText),stateSig:F(n.state),approvalSig:F(n.approval)}:null).filter(n=>n!==null);return{id:e.id,role:e.role,createdAt:eo(e.createdAt)??Date.now(),status:"complete",partsSig:F(t)}}function Ni(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(Gd)}}function wr(e){let t="";for(let n of e.partsSig.value)n.kind==="text"&&(t+=n.textSig.value);return t}function Wd(e){return e.kind==="text"||e.kind==="reasoning"?{kind:e.kind,id:e.id,textSig:F(e.text),doneSig:F(e.done)}:e.kind==="tool"?{kind:"tool",toolCallId:e.toolCallId,toolName:e.toolName,inputPartialSig:F(e.inputPartial),inputSig:F(e.input),outputSig:F(e.output),errorSig:F(e.error),stateSig:F(e.state),approvalSig:F(e.approval)}:e}function Gd(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,approval:e.approvalSig.value}:e}function oo(e){if(!e)return!1;let t=e.startsWith("tool:")?e.slice(5):e;return t==="ask-user-input"||t==="ask_user_input"||t==="request-user-input"||t==="request_user_input"}var ro={submitMessage:"submit-message",toolResult:"tool-result",toolApproval:"tool-approval"};var Di=U.scope("reducer"),ao=class{constructor(t){X(this,"messagesSig",t);X(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":Di.debug("finish",{reason:t.finishReason,canContinue:t.canContinue}),n.status="complete",t.finishReason&&(n.finishReason=t.finishReason),this.bumpDone(n);return;case"error":Di.warn("stream error chunk",{errorText:t.errorText}),n.status="error",n.errorText=t.errorText,this.bumpDone(n);return;case"text-start":Tt(n,"text",t.id);return;case"text-delta":{let o=Tt(n,"text",t.id);o.textSig.value+=t.delta;return}case"text-end":Tt(n,"text",t.id).doneSig.value=!0;return;case"reasoning-start":Tt(n,"reasoning",t.id).doneSig.value=!1;return;case"reasoning-delta":{let o=Tt(n,"reasoning",t.id);o.textSig.value+=t.delta;return}case"reasoning-end":Tt(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":case"tool-approval-request":Vd(n,t);return;case"file":io(n,{kind:"file",url:t.url,mediaType:t.mediaType});return;case"source-url":{if(n.partsSig.value.some(a=>a.kind==="source"&&a.sourceId===t.sourceId))return;io(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 Tt(e,t,n){let o=e.partsSig.value.find(i=>i.kind===t&&i.id===n);if(o)return o;let a={kind:t,id:n,textSig:F(""),doneSig:F(!1)};return io(e,a),a}function Et(e,t,n){let o=e.partsSig.value.find(i=>i.kind==="tool"&&i.toolCallId===t);if(o)return o;let a={kind:"tool",toolCallId:t,toolName:n??"tool",inputPartialSig:F(""),inputSig:F(void 0),outputSig:F(void 0),errorSig:F(void 0),stateSig:F("input"),approvalSig:F(void 0)};return io(e,a),a}function io(e,t){e.partsSig.value=[...e.partsSig.value,t]}function Vd(e,t){switch(t.type){case"tool-input-start":Et(e,t.toolCallId,t.toolName);return;case"tool-input-delta":{let n=Et(e,t.toolCallId);n.inputPartialSig.value+=t.delta;return}case"tool-input-available":{let n=Et(e,t.toolCallId,t.toolName);n.inputSig.value=t.input,n.stateSig.value=oo(n.toolName)?"awaiting-input":"awaiting";return}case"tool-approval-request":{let n=Et(e,t.toolCallId,t.toolName);n.approvalSig.value={id:t.approvalId},n.stateSig.value="awaiting-approval";return}case"tool-output-available":{let n=Et(e,t.toolCallId);n.outputSig.value=t.output,n.stateSig.value="output";return}case"tool-output-error":{let n=Et(e,t.toolCallId);n.errorSig.value=t.errorText,n.stateSig.value="error";return}default:return}}var $i=U.scope("feedback:audio"),so=class{constructor(){X(this,"ctx",null);X(this,"master",null);X(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){$i.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 a=n.currentTime,i=t.noteMs/1e3;t.notes.forEach((s,l)=>{let c=n.createOscillator();c.type=t.type,c.frequency.value=s;let d=n.createGain(),u=a+l*i;d.gain.setValueAtTime(1e-4,u),d.gain.exponentialRampToValueAtTime(t.peakGain,u+.005),d.gain.exponentialRampToValueAtTime(1e-4,u+i),c.connect(d).connect(o),c.start(u),c.stop(u+i+.01)})}async playUrl(t){let n=this.ctx,o=this.master;if(!n||!o||n.state!=="running")return;let a=await this.getBuffer(t);if(!a)return;let i=n.createBufferSource();i.buffer=a,i.connect(o),i.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,a=fetch(t).then(i=>i.ok?i.arrayBuffer():Promise.reject(new Error(`fetch ${i.status}`))).then(i=>o.decodeAudioData(i)).then(i=>(this.buffers.set(t,i),i)).catch(i=>($i.warn("audio fetch/decode failed",{url:t,err:i}),this.buffers.delete(t),null));return this.buffers.set(t,a),a}};var Hi={messageReceived:10,messageSent:0,error:[20,40,20],voiceStart:10,voiceStop:0},Fi={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 Qe=null,lo=0;function Kd(){return typeof navigator<"u"&&typeof navigator.vibrate=="function"}function qd(){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=`__${x.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 Bi(e){if(!(e===0||Array.isArray(e)&&e.every(t=>t===0))){if(Kd())try{navigator.vibrate(e);return}catch{}if(Qe||(Qe=qd()),!!Qe)try{Qe.label.click()}catch{}}}function zi(){lo++;let e=!1;return()=>{e||(e=!0,lo=Math.max(0,lo-1),lo===0&&Qe&&(Qe.input.remove(),Qe.label.remove(),Qe=null))}}var jd=U.scope("feedback"),Xd=100,co=class{constructor(t,n){X(this,"mutedSig",F(!1));X(this,"audio",new so);X(this,"releaseHaptics");X(this,"sound");X(this,"haptics");X(this,"lastPlayed",new Map);X(this,"reducedMotionMq",null);this.sound=t,this.haptics=n,this.releaseHaptics=zi(),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<Xd}playSound(t){let n=this.sound.events?.[t];if(n===!1)return;if(typeof n=="string"){this.audio.playUrl(n).catch(a=>jd.warn("audio play failed",{err:a,url:n}));return}let o=Fi[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?Hi[t]:n;Bi(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 ot(e,t){return e instanceof Le&&e.status===429?t.errorRateLimited:t.errorGeneric}var Jd=0;function r(e,t,n,o,a,i){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 d={type:e,props:c,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Jd,__i:-1,__u:0,__source:a,__self:i};if(typeof e=="function"&&(s=e.defaultProps))for(l in s)c[l]===void 0&&(c[l]=s[l]);return q.vnode&&q.vnode(d),d}var $={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24"},Yd=()=>r("svg",{...$,"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"})}),Fe=()=>r("svg",{...$,"aria-hidden":"true",children:r("path",{d:"M18 6 6 18M6 6l12 12"})}),Ui=()=>r("svg",{...$,"aria-hidden":"true",children:r("path",{d:"M12 5v14M5 12h14"})}),Wi=()=>r("svg",{...$,"aria-hidden":"true",children:[r("path",{d:"m22 2-7 20-4-9-9-4Z"}),r("path",{d:"M22 2 11 13"})]}),Gi=()=>r("svg",{...$,"aria-hidden":"true",children:r("path",{d:"M12 19V5M5 12l7-7 7 7"})}),Vi=()=>r("svg",{...$,"aria-hidden":"true",children:r("path",{d:"M3 20V4l18 8-18 8Z"})}),It=()=>r("svg",{...$,"aria-hidden":"true",children:r("path",{d:"m9 18 6-6-6-6"})}),Ki=()=>r("svg",{...$,"aria-hidden":"true",children:r("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})}),qi=()=>r("svg",{...$,"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"})}),ji=()=>r("svg",{...$,"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"})]}),Xi=()=>r("svg",{...$,"aria-hidden":"true",children:r("path",{d:"M3 8V3h5M21 8V3h-5M3 16v5h5M21 16v5h-5"})}),Ji=()=>r("svg",{...$,"aria-hidden":"true",children:r("path",{d:"M8 3v5H3M16 3v5h5M8 21v-5H3M16 21v-5h5"})}),Yi=()=>r("svg",{...$,"aria-hidden":"true",children:r("path",{d:"M3 3h7v2H5v5H3zM21 3h-7v2h5v5h2zM3 21h7v-2H5v-5H3zM21 21h-7v-2h5v-5h2z"})}),Qi=()=>r("svg",{...$,"aria-hidden":"true",children:r("path",{d:"M10 3v5H3M14 3v5h7M10 21v-5H3M14 21v-5h7"})}),Zi=()=>r("svg",{...$,"aria-hidden":"true",viewBox:"0 0 10 10",children:r("path",{d:"M9 1L1 9M9 5L5 9M9 9H9",strokeWidth:"1.5"})}),es=()=>r("svg",{...$,"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"})]}),ts=()=>r("svg",{...$,"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"})}),ns=()=>r("svg",{...$,"aria-hidden":"true",children:r("path",{d:"M11 5 6 9H2v6h4l5 4zM22 9l-6 6M16 9l6 6"})}),os=()=>r("svg",{...$,"aria-hidden":"true",children:[r("path",{d:"M3 18 8 6l5 12M4.7 14h6.6"}),r("path",{d:"M14.5 18l3.2-7 3.2 7M15.6 15.8h4.2"})]}),rs=()=>r("svg",{...$,"aria-hidden":"true",children:r("path",{d:"m5 6 6 6-6 6M13 6l6 6-6 6"})}),Zt=()=>r("svg",{...$,"aria-hidden":"true",children:r("path",{d:"M20 6 9 17l-5-5"})}),as=()=>r("svg",{...$,"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"})]}),is=()=>r("svg",{...$,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"10"}),r("path",{d:"M2 12h20"}),r("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),en=()=>r("svg",{...$,"aria-hidden":"true",children:r("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),ss=()=>r("svg",{...$,"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"})}),ls=()=>r("svg",{...$,"aria-hidden":"true",children:[r("path",{d:"M12 20h9"}),r("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"})]}),cs=()=>r("svg",{...$,"aria-hidden":"true",children:r("path",{d:"m6 9 6 6 6-6"})}),ds=()=>r("svg",{...$,"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"})]}),Qd=()=>r("svg",{...$,"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"})]}),kr=()=>r("svg",{...$,"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"})}),Cr=()=>r("svg",{...$,"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"})]}),Zd=()=>r("svg",{...$,"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"})]}),e_=()=>r("svg",{...$,"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"})]}),t_=()=>r("svg",{...$,"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"})]}),n_=()=>r("svg",{...$,"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"})]}),Tr=()=>r("svg",{...$,"aria-hidden":"true",children:[r("circle",{cx:"11",cy:"11",r:"7"}),r("path",{d:"m21 21-4.3-4.3"})]}),_s=()=>r("svg",{...$,"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"})]}),us=()=>r("svg",{...$,"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"})]}),ps=()=>r("svg",{...$,"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"})]}),tn=()=>r("svg",{...$,"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"})]}),fs=()=>r("svg",{...$,"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"})]}),ms=()=>r("svg",{...$,"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"})}),gs=()=>r("svg",{...$,"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"})]}),o_=()=>r("svg",{...$,"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"})]}),r_=()=>r("svg",{...$,"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"})]}),a_=()=>r("svg",{...$,"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"})]}),i_=()=>r("svg",{...$,"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"})]}),hs={chat:Yd,message:kr,bubbles:tn,spark:Qd,wand:Zd,bot:e_,help:Cr,lifebuoy:n_,headset:t_,search:o_,sparkles:r_,concierge:a_,wave:i_};var E=x.cssPrefix,y={launcher:`${E}-launcher`,callout:`${E}-callout`,calloutDismiss:`${E}-callout-dismiss`,panel:`${E}-panel`,panelHeader:`${E}-panel-header`,resizeGrip:`${E}-resize-grip`,scrollToBottom:`${E}-scroll-to-bottom`,actionHistory:`${E}-action-history`,actionClose:`${E}-action-close`,langSegment:`${E}-lang-segment`,composer:`${E}-composer`,composerInput:`${E}-composer-input`,composerSend:`${E}-composer-send`,composerStop:`${E}-composer-stop`,composerAttach:`${E}-composer-attach`,composerFileInput:`${E}-composer-file-input`,composerVoice:`${E}-composer-voice`,attachmentChip:`${E}-attachment-chip`,attachmentRemove:`${E}-attachment-remove`,suggestion:`${E}-suggestion`,messageBubble:`${E}-message`,messageRetry:`${E}-message-retry`,historyPane:`${E}-history-pane`,historyBack:`${E}-history-back`,historyItem:`${E}-history-item`,sidebar:`${E}-sidebar`,sidebarToggle:`${E}-sidebar-toggle`,sidebarNewConversation:`${E}-sidebar-new-conversation`,sidebarItem:`${E}-sidebar-item`,messengerHome:`${E}-messenger-home`,modulesEmpty:`${E}-modules-empty`,tab:`${E}-tab`,tabBadge:`${E}-tab-badge`,homeView:`${E}-home-view`,homeGreeting:`${E}-home-greeting`,homeBrand:`${E}-home-brand`,backHeader:`${E}-back-header`,contentView:`${E}-content-view`,contentScroll:`${E}-content-scroll`,homeSearch:`${E}-home-search`,helpSearch:`${E}-help-search`,homeRecent:`${E}-home-recent`,homeContentRow:`${E}-home-content-row`,helpArticle:`${E}-help-article`,newsItem:`${E}-news-item`,formGate:`${E}-form-gate`,formDone:`${E}-form-done`,formDoneToggle:`${E}-form-done-toggle`,formAnswers:`${E}-form-answers`,formFill:`${E}-form-fill`,formSubmit:`${E}-form-submit`,formSkip:`${E}-form-skip`,formField:`${E}-form-field`,toolAskInput:`${E}-tool-ask-input`,toolInputSubmit:`${E}-tool-input-submit`,toolInputSkip:`${E}-tool-input-skip`,toolApproval:`${E}-tool-approval`,toolApprove:`${E}-tool-approve`,toolReject:`${E}-tool-reject`,toolDecision:`${E}-tool-decision`};function he(e,t){return`${e}-${t}`}var _o=x.cssPrefix;function vs({onToggle:e,launcher:t,strings:n,leaving:o,edgeTab:a}){let i=t.variant!=="circle"&&!!t.label;return r("button",{type:"button",class:`${_o}-fab`,"data-variant":t.variant,"data-size":t.size,"data-edge-tab":a?"true":void 0,"data-leaving":o?"true":void 0,"data-testid":y.launcher,onClick:e,"aria-label":n.launcherOpen,children:[s_(t.icon),i?r("span",{class:`${_o}-fab-label`,children:t.label}):null]})}function s_(e){let t=hs[e];return t?r(t,{}):r(l_,{source:e})}function l_({source:e}){return r("span",{ref:t=>{t&&c_(t,e)},"aria-hidden":"true"})}function c_(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 bs({callout:e,launcherPosition:t,strings:n,closeLabel:o,onDismiss:a}){let[i,s]=k(!1);return w(()=>{let l=setTimeout(()=>s(!0),e.delayMs);return()=>clearTimeout(l)},[e.delayMs]),w(()=>{if(!i||e.autoDismissMs<=0)return;let l=setTimeout(a,e.autoDismissMs);return()=>clearTimeout(l)},[i,e.autoDismissMs,a]),i?r("div",{class:`${_o}-callout`,role:"status","data-shape":e.shape,"data-position":d_(e.position,t),"data-animated":e.animated?"true":void 0,"data-testid":y.callout,children:[r("span",{children:mt(n,e.text)}),r("button",{type:"button",class:`${_o}-callout-close`,onClick:a,"aria-label":o,title:o,"data-testid":y.calloutDismiss,children:r(Fe,{})})]}):null}function d_(e,t){let n=t.endsWith("-right"),o=t.startsWith("bottom-");return e==="vertical"?o?"top":"bottom":n?"left":"right"}function uo({panelEl:e,resize:t,position:n,initialSize:o,onSizeChange:a,strings:i}){let s=x.cssPrefix,l=M(null);if(w(()=>{if(!e)return;let m=e.style;t.minWidth&&m.setProperty(`--${s}-resize-min-w`,t.minWidth),t.maxWidth&&m.setProperty(`--${s}-resize-max-w`,t.maxWidth),t.minHeight&&m.setProperty(`--${s}-resize-min-h`,t.minHeight),t.maxHeight&&m.setProperty(`--${s}-resize-max-h`,t.maxHeight),o&&(m.setProperty(`--${s}-widget-w`,`${o.width}px`),m.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-"),d=n.endsWith("-right"),u=`${s}-resize-grip ${s}-resize-grip--${c?"bottom":"top"}-${d?"left":"right"}`,_=m=>{if(!e)return;let g=m.currentTarget,v=e.getBoundingClientRect();l.current={pointerId:m.pointerId,startX:m.clientX,startY:m.clientY,startW:v.width,startH:v.height,dirX:d?-1:1,dirY:c?1:-1},g.setPointerCapture(m.pointerId),e.setAttribute("data-resizing",""),m.preventDefault()},h=m=>{let g=l.current;if(!g||m.pointerId!==g.pointerId||!e)return;let v=(m.clientX-g.startX)*g.dirX,A=(m.clientY-g.startY)*g.dirY;e.style.setProperty(`--${s}-widget-w`,`${g.startW+v}px`),e.style.setProperty(`--${s}-widget-h`,`${g.startH+A}px`)},p=m=>{let g=l.current;if(!g||m.pointerId!==g.pointerId||!e)return;m.currentTarget.releasePointerCapture(m.pointerId),e.removeAttribute("data-resizing");let v=e.getBoundingClientRect();a({width:Math.round(v.width),height:Math.round(v.height)}),l.current=null};return r("div",{class:u,role:"separator","aria-orientation":"vertical","aria-label":i.resizeHandle,title:i.resizeHandle,onPointerDown:_,onPointerMove:h,onPointerUp:p,onPointerCancel:p,"data-testid":y.resizeGrip,children:r(Zi,{})})}var rt=x.cssPrefix,__=`.${rt}-header, .${rt}-back-header, .${rt}-home-hero`,u_='button, a, input, textarea, select, [role="tab"], [contenteditable]',xs=56;function po(e,t){w(()=>{if(!t||!e)return;let n=c=>Number.parseFloat(c)||0,o=(c,d)=>Math.min(d,Math.max(-d,c)),a=null,i=c=>{let d=c.target;if(!(d instanceof Element)||!d.closest(__)||d.closest(u_))return;let u=e.getBoundingClientRect();a={id:c.pointerId,x:c.clientX,y:c.clientY,dx:n(e.style.getPropertyValue(`--${rt}-modal-dx`)),dy:n(e.style.getPropertyValue(`--${rt}-modal-dy`)),maxX:(window.innerWidth+u.width)/2-xs,maxY:(window.innerHeight+u.height)/2-xs},e.dataset.dragging="true",c.preventDefault()},s=c=>{if(!a||c.pointerId!==a.id)return;let d=o(a.dx+c.clientX-a.x,a.maxX),u=o(a.dy+c.clientY-a.y,a.maxY);e.style.setProperty(`--${rt}-modal-dx`,`${d}px`),e.style.setProperty(`--${rt}-modal-dy`,`${u}px`)},l=c=>{!a||c.pointerId!==a.id||(a=null,delete e.dataset.dragging)};return e.addEventListener("pointerdown",i),window.addEventListener("pointermove",s),window.addEventListener("pointerup",l),window.addEventListener("pointercancel",l),()=>{e.removeEventListener("pointerdown",i),window.removeEventListener("pointermove",s),window.removeEventListener("pointerup",l),window.removeEventListener("pointercancel",l)}},[e,t])}function nn(e,t,n,o){switch(e){case"clear":case"sound":case"history":case"language":case"theme":case"textSize":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 fo(e,t,n){return nn("close",e,t)?n.includes("close"):!1}function Ps(e,t){return e==="inline"&&t==="fullscreen"?"exit-fullscreen":"close"}var p_='a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),[tabindex]:not([tabindex="-1"])';function mo(e){let t=n=>{if(n.key!=="Tab")return;let o=[...e.querySelectorAll(p_)].filter(l=>l.offsetParent!==null||l===document.activeElement);if(o.length===0){n.preventDefault();return}let a=o[0],i=o[o.length-1];if(!a||!i)return;let s=e.getRootNode().activeElement;n.shiftKey&&s===a?(n.preventDefault(),i.focus()):!n.shiftKey&&s===i&&(n.preventDefault(),a.focus())};return e.addEventListener("keydown",t),()=>e.removeEventListener("keydown",t)}function go(e){return e.trim().split(/\s+/).slice(0,2).map(t=>t.charAt(0).toUpperCase()).join("")}var Er=x.cssPrefix;function ys({agent:e}){let t=e.status??"online";return r("div",{class:`${Er}-agent`,children:[r("div",{class:`${Er}-agent-avatar`,"data-status":t,children:e.avatar?r("img",{src:e.avatar,alt:""}):r("span",{children:go(e.name)})}),r("div",{class:`${Er}-agent-meta`,children:[r("strong",{children:e.name}),e.title?r("span",{children:e.title}):null]})]})}var Ss=U.scope("attachments");function ho(e,t,n){let o=m_(e),a=[],i=[],s=v_(n.accept),l=t.reduce((d,u)=>d+u.size,0),c=t.length;for(let d of o){let u=f_(d,c,l,n,s);if(u){i.push({file:d,reason:u});continue}a.push(h_(d)),l+=d.size,c+=1}return(a.length||i.length)&&Ss.debug("ingest",{accepted:a.length,rejected:i.map(d=>({name:d.file.name,reason:d.reason}))}),{accepted:a,rejected:i}}function Ir(e){try{URL.revokeObjectURL(e.previewUrl)}catch(t){Ss.debug("revokeObjectURL failed",{error:t})}}function f_(e,t,n,o,a){return t>=o.maxCount?"count":n+e.size>o.maxBytes?"bytes":b_(e,a)?null:"mime"}function m_(e){return e?Array.isArray(e)?e.filter(t=>t instanceof File):[...e].map(t=>t instanceof File?t:g_(t)).filter(t=>t!==null):[]}function g_(e){let t=e;return!t?.getAsFile||t.kind!=="file"?null:t.getAsFile()}function h_(e){return{file:e,id:$e(),mediaType:e.type||"application/octet-stream",name:e.name||"pasted-file",previewUrl:URL.createObjectURL(e),size:e.size}}function v_(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 b_(e,t){if(t.length===0)return!0;let[n="*",o="*"]=(e.type||"").toLowerCase().split("/"),a=(e.name||"").toLowerCase();return t.some(i=>i.kind==="ext"?a.endsWith(i.ext):(i.type==="*"||i.type===n)&&(i.subtype==="*"||i.subtype===o))}var on=x.cssPrefix;function ws({attachment:e,onRemove:t}){let n=e.mediaType.startsWith("image/");return r("span",{class:`${on}-attachment-chip`,title:e.name,"data-testid":he(y.attachmentChip,e.id),children:[n?r("img",{class:`${on}-attachment-thumb`,src:e.previewUrl,alt:""}):r("span",{class:`${on}-attachment-thumb`,"aria-hidden":"true",children:r(ds,{})}),r("span",{class:`${on}-attachment-name`,children:e.name}),r("button",{type:"button",class:`${on}-attachment-remove`,onClick:t,"aria-label":`Remove ${e.name}`,"data-testid":he(y.attachmentRemove,e.id),children:r(Fe,{})})]})}var Ar={isSupported:!1,start:()=>{},stop:()=>{}};function Rr(e,t,n){return e==="disabled"?Ar:e==="server"?S_(n):x_(t)}function x_(e){let t=P_();if(!t)return Ar;let n=null;return{isSupported:!0,start(o,a){n=new t,n.continuous=!0,n.interimResults=!0,n.lang=e,n.addEventListener("result",s=>{let l=s,c="",d=!1;for(let u=l.resultIndex;u<l.results.length;u++){let _=l.results[u];_&&(c+=_[0].transcript,_.isFinal&&(d=!0))}o(c,d)});let i=()=>{n=null,a()};n.addEventListener("end",i),n.addEventListener("error",i),n.start()},stop(){n?.stop()}}}function P_(){let e=globalThis;return e.SpeechRecognition??e.webkitSpeechRecognition}var y_=["audio/webm;codecs=opus","audio/webm","audio/ogg;codecs=opus","audio/mp4"];function S_(e){if(typeof MediaRecorder>"u"||!navigator?.mediaDevices?.getUserMedia)return Ar;let t=null,n=null,o=[],a=()=>{for(let i of n?.getTracks()??[])i.stop();n=null};return{isSupported:!0,async start(i,s){try{n=await navigator.mediaDevices.getUserMedia({audio:!0});let l=w_();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";a();let d=new Blob(o,{type:c});o=[];try{let{text:u}=await e(d,c);u&&i(u,!0)}catch{}finally{s()}}),t.start()}catch{a(),s()}},stop(){t?.stop()}}}function w_(){for(let e of y_)if(MediaRecorder.isTypeSupported(e))return e}var Te=x.cssPrefix,at=U.scope("composer");function At(e){return e.reduce((t,n)=>t+n.size,0)}var k_={arrowUp:Gi,paperPlane:Wi,send:Vi,chevron:It};function ks({options:e,transport:t,feedback:n,bus:o,isStreaming:a,onSend:i,onStop:s,attachApiRef:l}){let c=e.strings,[d,u]=k(""),[_,h]=k([]),[p,m]=k(!1),g=M(null),v=M(null),A=e.features.files,S=e.features.voice,[B,I]=k(()=>Rr(S,e.locale,(T,O)=>t.transcribe(T,O)));w(()=>{p||S==="disabled"||I(Rr(S,e.locale,(T,O)=>t.transcribe(T,O)))},[e.locale,S,t,p]),w(()=>{let T=g.current;if(!T)return;let O=T.getRootNode(),Q="activeElement"in O?O.activeElement:null;Q&&T.closest(`.${Te}-panel`)?.contains(Q)||T.focus({preventScroll:!0})},[]),w(()=>{let T=g.current;if(T){if(d.length===0){T.style.height="";return}T.style.height="auto",T.style.height=`${Math.min(T.scrollHeight,160)}px`}},[d]);let W=M(_);W.current=_,w(()=>()=>W.current.forEach(Ir),[]),w(()=>{if(l)return l.current={attachFromDrop:T=>{let O=ho(T,W.current,e.attachments);O.accepted.length!==0&&(at.info("attach (drop)",{count:O.accepted.length,totalBytes:At(O.accepted)}),o.emit("attach",{count:O.accepted.length,totalBytes:At(O.accepted)}),h(Q=>[...Q,...O.accepted]))}},()=>{l.current&&(l.current=null)}},[l,e.attachments]),w(()=>{let T=g.current;if(!T)return;let O=T.closest(`.${Te}-panel`);if(!O)return;let Q=pe=>{let fe=pe.clipboardData;if(!fe)return;if(A){let D=ho(fe.items,W.current,e.attachments);if(D.accepted.length>0){pe.preventDefault(),at.info("attach (paste)",{count:D.accepted.length,totalBytes:At(D.accepted)}),o.emit("attach",{count:D.accepted.length,totalBytes:At(D.accepted)}),h(me=>[...me,...D.accepted]);return}}if(pe.target===T)return;let P=fe.getData("text/plain");P&&(pe.preventDefault(),u(D=>D+P),T.focus())};return O.addEventListener("paste",Q),()=>O.removeEventListener("paste",Q)},[A,e.attachments,Te]);let K=()=>{let T=d.trim();!T&&_.length===0||a||(i(T,_),u(""),h([]))},N=T=>{T.key!=="Enter"||T.shiftKey||T.isComposing||(T.preventDefault(),a?s():K())},ue=T=>{let O=T.target,Q=ho(O.files,_,e.attachments);Q.accepted.length>0&&(at.info("attach (file picker)",{count:Q.accepted.length,totalBytes:At(Q.accepted)}),o.emit("attach",{count:Q.accepted.length,totalBytes:At(Q.accepted)}),h(pe=>[...pe,...Q.accepted])),O.value=""},z=T=>{at.info("removeAttachment",{id:T}),o.emit("removeAttachment",{id:T}),h(O=>{let Q=O.find(pe=>pe.id===T);return Q&&Ir(Q),O.filter(pe=>pe.id!==T)})},te=M(null),ve=()=>{if(B.isSupported){if(p){let T=te.current?Date.now()-te.current:0;at.info("voiceStop",{durationMs:T}),o.emit("voiceStop",{durationMs:T}),B.stop(),m(!1),n.play("voiceStop"),te.current=null;return}te.current=Date.now(),at.info("voiceStart"),o.emit("voiceStart",void 0),m(!0),n.play("voiceStart"),B.start((T,O)=>u(Q=>O?`${Q}${T} `:Q),()=>{if(m(!1),te.current){let T=Date.now()-te.current;at.debug("voiceStop (auto)",{durationMs:T}),o.emit("voiceStop",{durationMs:T}),te.current=null}})}},we=k_[e.composer.sendButton.icon];return r("div",{class:`${Te}-composer`,"data-testid":y.composer,children:[_.length>0?r("div",{class:`${Te}-attachments`,children:_.map(T=>r(ws,{attachment:T,onRemove:()=>z(T.id)},T.id))}):null,r("div",{class:`${Te}-composer-row`,children:[r("div",{class:`${Te}-composer-actions`,children:[A?r("button",{type:"button",class:`${Te}-icon-btn`,onClick:()=>v.current?.click(),"aria-label":c.attach,"data-testid":y.composerAttach,children:r(qi,{})}):null,B.isSupported?r("button",{type:"button",class:`${Te}-icon-btn`,onClick:ve,"aria-label":p?c.micStop:c.micStart,"aria-pressed":p,"data-recording":p?"true":void 0,"data-testid":y.composerVoice,children:r(ji,{})}):null]}),r("textarea",{ref:g,class:`${Te}-textarea`,rows:1,value:d,placeholder:c.composerPlaceholder,onInput:T=>u(T.target.value),onKeyDown:N,"aria-label":c.composerPlaceholder,"data-testid":y.composerInput}),a?r("button",{type:"button",class:`${Te}-send`,onClick:s,"aria-label":c.stop,"data-testid":y.composerStop,children:r(Ki,{})}):r("button",{type:"button",class:`${Te}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:K,disabled:!d.trim()&&_.length===0,"aria-label":c.send,"data-testid":y.composerSend,children:r(we,{})})]}),r("input",{ref:v,type:"file",multiple:!0,accept:e.attachments.accept,onChange:ue,class:`${Te}-sr-only`,"data-testid":y.composerFileInput})]})}var C_=x.cssPrefix;function Cs({visible:e,strings:t}){return e?r("div",{class:`${C_}-dropzone`,role:"status","aria-live":"polite",children:t.dropZone}):null}function vo({containerRef:e,onDrop:t}){let[n,o]=k(!1);return w(()=>{let a=e.current;if(!a)return;let i=0,s=u=>{i+=1,u.dataTransfer?.types.includes("Files")&&(u.preventDefault(),o(!0))},l=()=>{i-=1,!(i>0)&&(i=0,o(!1))},c=u=>{u.dataTransfer?.types.includes("Files")&&u.preventDefault()},d=u=>{i=0,o(!1),u.dataTransfer&&(u.preventDefault(),t(u.dataTransfer.items))};return a.addEventListener("dragenter",s),a.addEventListener("dragleave",l),a.addEventListener("dragover",c),a.addEventListener("drop",d),()=>{a.removeEventListener("dragenter",s),a.removeEventListener("dragleave",l),a.removeEventListener("dragover",c),a.removeEventListener("drop",d)}},[e,t]),{visible:n}}function Ts({itemCount:e,initialFocusIndex:t}){let[n,o]=k(!1),a=M(null),i=M(null),[s,l]=k(-1),c=H(()=>{o(!1),l(-1),a.current?.focus()},[]),d=H(()=>o(h=>!h),[]);w(()=>{if(!n)return;let h=p=>{let m=i.current,g=a.current;if(!m||!g)return;let v=p.composedPath();v.includes(m)||v.includes(g)||(o(!1),l(-1))};return document.addEventListener("click",h,!0),()=>document.removeEventListener("click",h,!0)},[n]),w(()=>{if(!n||e===0)return;let h=t?.()??0,p=h<0||h>=e?0:h;l(p)},[n,e,t]),w(()=>{if(!n||s<0)return;i.current?.querySelectorAll("[role='menuitem']")?.[s]?.focus()},[n,s]);let u=H(h=>{(h.key==="ArrowDown"||h.key==="Enter"||h.key===" ")&&(h.preventDefault(),o(!0))},[]),_=H(h=>{if(e!==0)switch(h.key){case"Escape":h.preventDefault(),c();return;case"ArrowDown":h.preventDefault(),l(p=>(p+1)%e);return;case"ArrowUp":h.preventDefault(),l(p=>(p-1+e)%e);return;case"Home":h.preventDefault(),l(0);return;case"End":h.preventDefault(),l(e-1)}},[e,c]);return{open:n,focusIndex:s,triggerRef:a,menuRef:i,toggle:d,close:c,onTriggerKey:u,onMenuKey:_}}function Es({items:e,triggerLabel:t}){let n=x.cssPrefix,o=Ts({itemCount:e.length}),a=l=>{l.disabled||(l.onSelect?.(),l.keepOpen||o.close())},i=(l,c)=>l.onSelectValue?.(c),s=(l,c)=>{let d=c.segments;if(!d?.length)return;let u=Math.max(0,d.findIndex(h=>h.value===c.value)),_=-1;if(l.key==="ArrowRight"||l.key==="Enter"||l.key===" ")_=(u+1)%d.length;else if(l.key==="ArrowLeft")_=(u-1+d.length)%d.length;else return;l.preventDefault(),l.stopPropagation(),i(c,d[_].value)};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(es,{})}),o.open?r("div",{ref:o.menuRef,class:`${n}-menu`,role:"menu","aria-label":t,onKeyDown:o.onMenuKey,tabIndex:-1,children:e.map(l=>l.segments?r("div",{role:"menuitem",class:`${n}-menu-item ${n}-menu-item-segmented`,"aria-label":l.label,tabIndex:-1,onKeyDown:c=>s(c,l),children:[l.icon?r("span",{class:`${n}-menu-icon`,children:l.icon}):null,r("span",{class:`${n}-menu-label`,children:l.label}),r("span",{class:`${n}-segmented`,role:"group","aria-label":l.label,children:l.segments.map(c=>{let d=c.value===l.value;return r("button",{type:"button",role:"menuitemradio","aria-checked":d,class:`${n}-segment`,"data-on":d?"true":void 0,lang:c.lang,title:c.value,tabIndex:-1,"data-testid":`${y.langSegment}-${c.value}`,onClick:()=>i(l,c.value),children:c.label},c.value)})})]},l.id):r("button",{type:"button",role:"menuitem",class:`${n}-menu-item`,"aria-pressed":l.type==="switch"?l.on:void 0,disabled:l.disabled,lang:l.lang,onClick:()=>a(l),children:[l.icon?r("span",{class:`${n}-menu-icon`,children:l.icon}):null,r("span",{class:`${n}-menu-label`,children:l.label}),l.type==="switch"&&l.on?r("span",{class:`${n}-menu-check`,"aria-hidden":"true",children:r(Zt,{})}):null]},l.id))}):null]})}var Lr=x.cssPrefix;function T_(e){let t=typeof matchMedia=="function"?matchMedia("(prefers-color-scheme: dark)").matches:!0;return e==="auto"?t?"light":"dark":t?e==="light"?"dark":"auto":e==="dark"?"light":"auto"}var E_={normal:"large",large:"small",small:"normal"};function I_(e){return e==="light"?r(fs,{}):e==="dark"?r(ms,{}):r(gs,{})}function A_(e){return(e.split("-")[0]||e).toUpperCase()}function Be({panelProps:e,variant:t}){let{options:n,panelSize:o,feedback:a,onClose:i,onClear:s,onExpand:l,onFullscreen:c,onPopOut:d,onSoundToggle:u}=e,{onToggleHistory:_,onLocaleChange:h,onThemeChange:p,onTextSizeChange:m}=e,g=n.strings,v=n.mode,A=t==="chat",S=re(()=>a.mutedSig.value).value,B=new Set(n.actions),I=O=>B.has(O),W=typeof matchMedia=="function"&&matchMedia("(max-width: 640px)").matches,K=O=>W&&(O==="expand"||O==="fullscreen")?!1:nn(O,v,o,{popOutUrl:n.popOutUrl}),N=n.themeMode,ue={auto:g.themeAuto,light:g.themeLight,dark:g.themeDark},z=n.textSize,te={small:g.textSizeSmall,normal:g.textSizeNormal,large:g.textSizeLarge},ve=[];if(A&&I("clear")&&ve.push({id:"clear",icon:r(ls,{}),label:g.newConversation,onSelect:s}),I("expand")&&K("expand")){let O=o==="expanded";ve.push({id:"expand",icon:O?r(Ji,{}):r(Xi,{}),label:O?g.collapse:g.expand,type:"switch",on:O,onSelect:l})}if(I("fullscreen")&&K("fullscreen")){let O=o==="fullscreen";ve.push({id:"fullscreen",icon:O?r(Qi,{}):r(Yi,{}),label:O?g.exitFullscreen:g.fullscreen,type:"switch",on:O,onSelect:c})}I("popOut")&&K("popOut")&&ve.push({id:"popOut",icon:r(ss,{}),label:g.popOut,onSelect:d}),A&&I("sound")&&ve.push({id:"sound",icon:S?r(ns,{}):r(ts,{}),label:S?g.soundOff:g.soundOn,type:"switch",on:!S,onSelect:u}),I("theme")&&ve.push({id:"theme",icon:I_(N),label:`${g.theme}: ${ue[N]}`,onSelect:()=>p(T_(N)),keepOpen:!0}),I("textSize")&&ve.push({id:"textSize",icon:r(os,{}),label:`${g.textSize}: ${te[z]}`,onSelect:()=>m(E_[z]),keepOpen:!0}),I("language")&&n.availableLocales.length>1&&ve.push({id:"language",icon:r(is,{}),label:g.language,segments:n.availableLocales.map(O=>({value:O,label:A_(O),lang:O})),value:n.locale,onSelectValue:h});let we=!!i&&fo(v,o,n.actions),T=A&&I("history");return r("div",{class:`${Lr}-header-actions`,children:[T?r("button",{type:"button",class:`${Lr}-icon-btn`,onClick:_,"aria-label":g.history,title:g.history,"data-testid":y.actionHistory,children:r(as,{})}):null,ve.length>0?r(Es,{items:ve,triggerLabel:g.moreActions}):null,we?r("button",{type:"button",class:`${Lr}-icon-btn`,onClick:i,"aria-label":g.close,title:g.close,"data-testid":y.actionClose,children:r(Fe,{})}):null]})}var R_=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,L_=/^https?:\/\/[^\s.]+\.[^\s]+$/i,M_=/^[+]?[\d\s().-]{6,}$/;function Rt(e,t){return e.replace(/\{(\w+)\}/g,(n,o)=>String(t[o]??`{${o}}`))}function O_(e){return Array.isArray(e)?e.length:e&&e.trim()?1:0}function N_(e,t,n){let o=e.required??!0,a=e.validation;if(e.type==="multiselect"){let s=O_(t);return o&&s===0?n.formRequired:s===0?void 0:a?.minSelections!=null&&s<a.minSelections?Rt(n.formChooseAtLeast,{min:a.minSelections}):a?.maxSelections!=null&&s>a.maxSelections?Rt(n.formChooseAtMost,{max:a.maxSelections}):void 0}let i=typeof t=="string"?t.trim():"";if(!i)return o?n.formRequired:void 0;switch(e.type){case"email":if(!R_.test(i))return n.formInvalidEmail;break;case"url":if(!L_.test(i))return n.formInvalidUrl;break;case"tel":if(!M_.test(i))return n.formInvalidTel;break;case"number":{let s=Number(i);if(!Number.isFinite(s))return n.formInvalidNumber;if(a?.min!=null&&s<a.min)return Rt(n.formNumberTooSmall,{min:a.min});if(a?.max!=null&&s>a.max)return Rt(n.formNumberTooLarge,{max:a.max});break}default:break}if(a?.minLength!=null&&i.length<a.minLength)return Rt(n.formTooShort,{min:a.minLength});if(a?.maxLength!=null&&i.length>a.maxLength)return Rt(n.formTooLong,{max:a.maxLength});if(a?.pattern)try{if(!new RegExp(a.pattern).test(i))return n.formPatternMismatch}catch{}}function Is(e,t,n){let o={};for(let a of e){let i=N_(a,t[a.name],n);i&&(o[a.name]=i)}return o}function As(e){let t={};for(let[n,o]of Object.entries(e)){let a=Array.isArray(o)?o.join(", "):o;a&&a.trim()&&(t[n]=a.trim())}return t}var le=x.cssPrefix,bo="__other__";function xo({fields:e,strings:t,submitLabel:n,onSubmit:o,skipLabel:a,onSkip:i,disabled:s,rootTestId:l,submitTestId:c,skipTestId:d}){let[u,_]=k(()=>F_(e)),[h,p]=k({}),[m,g]=k({}),v=I=>{m[I]&&g(W=>({...W,[I]:""}))},A=(I,W)=>{_(K=>({...K,[I]:W})),v(I)},S=(I,W)=>{p(K=>({...K,[I]:W})),v(I)},B=I=>{if(I.preventDefault(),s)return;let W=B_(e,u,h),K=Is(e,W,t);if(Object.keys(K).length>0){g(K);return}o(As(W))};return r("form",{class:`${le}-form`,onSubmit:B,"data-testid":l,noValidate:!0,children:[e.map(I=>r(D_,{field:I,value:u[I.name],otherText:h[I.name]??"",error:m[I.name],disabled:s,strings:t,onChange:W=>A(I.name,W),onOtherChange:W=>S(I.name,W)},I.name)),r("div",{class:`${le}-form-actions`,children:[a&&i?r("button",{type:"button",class:`${le}-form-skip`,onClick:i,disabled:s,"data-testid":d,children:a}):null,r("button",{type:"submit",class:`${le}-form-submit`,disabled:s,"data-testid":c,children:n})]})]})}function D_({field:e,value:t,otherText:n,error:o,disabled:a,strings:i,onChange:s,onOtherChange:l}){let c=he(y.formField,e.name),d=$_({field:e,value:t,otherText:n,disabled:a,strings:i,onChange:s,onOtherChange:l,fieldTid:c});return r("label",{class:`${le}-field`,"data-field":e.name,"data-invalid":o?"true":void 0,children:[r("span",{class:`${le}-field-label`,children:[e.label,e.required??!0?r("span",{class:`${le}-field-req`,"aria-hidden":"true",children:" *"}):null]}),d,e.validationHint&&!o?r("span",{class:`${le}-field-hint`,children:e.validationHint}):null,o?r("span",{class:`${le}-field-error`,role:"alert",children:o}):null]})}function $_(e){let{field:t,value:n,otherText:o,disabled:a,strings:i,onChange:s,onOtherChange:l,fieldTid:c}=e,d=typeof n=="string"?n:"";switch(t.type){case"textarea":return r("textarea",{class:`${le}-field-input`,rows:3,value:d,placeholder:t.placeholder,disabled:a,onInput:u=>s(u.target.value),"data-testid":c});case"select":return r("select",{class:`${le}-field-input`,value:d,disabled:a,onChange:u=>s(u.target.value),"data-testid":c,children:[r("option",{value:"",children:t.placeholder??"\u2014"}),(t.options??[]).map(u=>r("option",{value:u.value,children:u.label??u.value},u.value))]});case"radio":{let u=t.allowOther&&d===bo;return r("div",{class:`${le}-field-choices`,role:"radiogroup","data-testid":c,children:[(t.options??[]).map(_=>r("label",{class:`${le}-choice`,children:[r("input",{type:"radio",name:`${le}-${t.name}`,checked:d===_.value,disabled:a,onChange:()=>s(_.value)}),r("span",{children:_.label??_.value})]},_.value)),t.allowOther?r("label",{class:`${le}-choice`,children:[r("input",{type:"radio",name:`${le}-${t.name}`,checked:d===bo,disabled:a,onChange:()=>s(bo)}),r("span",{children:i.formOther})]}):null,u?r("input",{class:`${le}-field-input`,value:o,placeholder:t.placeholder??i.formOtherPlaceholder,disabled:a,onInput:_=>l(_.target.value)}):null]})}case"checkbox":return r("label",{class:`${le}-choice`,children:[r("input",{type:"checkbox",checked:d==="true",disabled:a,onChange:u=>s(u.target.checked?"true":""),"data-testid":c}),r("span",{children:t.placeholder??t.label})]});case"multiselect":{let u=Array.isArray(n)?n:[],_=(h,p)=>s(p?[...u,h]:u.filter(m=>m!==h));return r("div",{class:`${le}-field-choices`,"data-testid":c,children:[(t.options??[]).map(h=>r("label",{class:`${le}-choice`,children:[r("input",{type:"checkbox",checked:u.includes(h.value),disabled:a,onChange:p=>_(h.value,p.target.checked)}),r("span",{children:h.label??h.value})]},h.value)),t.allowOther||(t.options??[]).length===0?r("textarea",{class:`${le}-field-input`,rows:2,value:o,placeholder:t.placeholder??i.formOtherPlaceholder,disabled:a,onInput:h=>l(h.target.value)}):null]})}default:return r("input",{class:`${le}-field-input`,type:H_(t.type),value:d,placeholder:t.placeholder,disabled:a,onInput:u=>s(u.target.value),"data-testid":c})}}function H_(e){switch(e){case"number":case"email":case"tel":case"url":case"date":case"time":return e;default:return"text"}}function F_(e){let t={};for(let n of e)n.defaultValue!=null&&(t[n.name]=n.type==="multiselect"?n.defaultValue.split(",").map(o=>o.trim()).filter(Boolean):n.defaultValue);return t}function B_(e,t,n){let o={...t};for(let a of e){let i=n[a.name]?.trim();if(a.type==="radio"&&a.allowOther&&t[a.name]===bo)o[a.name]=i??"";else if(a.type==="multiselect"&&i){let s=i.split(/[,\n;]+/).map(c=>c.trim()).filter(Boolean),l=Array.isArray(t[a.name])?t[a.name]:[];o[a.name]=[...l,...s]}}return o}var ze=x.cssPrefix;function Rs({form:e,strings:t,onSubmit:n,onSkip:o}){return r("div",{class:`${ze}-form-gate`,"data-testid":y.formGate,children:[e.title?r("h3",{class:`${ze}-form-gate-title`,children:e.title}):null,e.description?r("p",{class:`${ze}-form-gate-desc`,children:e.description}):null,r(xo,{fields:e.fields,strings:t,submitLabel:e.submitLabel??t.formSubmit,onSubmit:n,skipLabel:e.skippable?t.formSkip:void 0,onSkip:e.skippable?o:void 0,submitTestId:y.formSubmit,skipTestId:y.formSkip})]})}function Ls({marker:e,strings:t,onFill:n}){let o=e.outcome==="skipped",a=o?t.formSkipped:t.formSubmitted,i=e.title?r(ne,{children:[r("span",{children:e.title}),r("span",{class:`${ze}-sr-only`,children:a})]}):r("span",{children:a}),s=e.form?.reviewable??!1,l=!o&&s&&e.values&&Object.keys(e.values).length>0?e.values:null;if(l){let c=d=>e.form?.fields.find(u=>u.name===d)?.label??d;return r("details",{class:`${ze}-form-done`,"data-outcome":e.outcome,"data-testid":y.formDone,children:[r("summary",{class:`${ze}-form-done-summary`,"data-testid":y.formDoneToggle,children:[r(Zt,{}),i,r(It,{})]}),r("dl",{class:`${ze}-form-answers`,"data-testid":y.formAnswers,children:Object.entries(l).map(([d,u])=>r("div",{class:`${ze}-form-answer`,children:[r("dt",{children:c(d)}),r("dd",{children:u})]},d))})]})}return r("div",{class:`${ze}-form-done`,"data-outcome":e.outcome,"data-testid":y.formDone,role:"status",children:[o?r(rs,{}):r(Zt,{}),i,o&&e.form?.reopenable&&n?r("button",{type:"button",class:`${ze}-form-done-fill`,"data-testid":y.formFill,onClick:n,children:t.formFillOut}):null]})}var Nr=1,Os=2,Ns=4,Ds=8,$s=16;function z_(e){switch(e){case Nr:return"href";case Os:return"src";case Ns:return"class";case Ds:return"checked";case $s:return"start"}}var U_=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}},W_=U_;var Ms=24;function $r(e){let t=new Uint32Array(Ms);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(Ms),indent:"",indent_len:0,table_state:0}}function Hs(e){e.pending.length>0&&be(e,`
|
|
11
|
+
${a}`:a;continue}o.startsWith("id:")&&(n=o.slice(3).trim())}if(!t||t==="[DONE]")return null;try{let o=JSON.parse(t);return ki.trace("chunk",{type:o.type,eventId:n}),{chunk:o,eventId:n}}catch(o){return ki.trace("frame parse failed",{err:o,payload:t.slice(0,200)}),null}}function Ld(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 Ti=e=>e&&Object.keys(e).length>0?e:void 0;function Ei(e,t){let n=Ti(e),o=Ti(t);if(!n&&!o)return;let a={};return n&&(a.user=n),o&&(a.page=o),Ld(JSON.stringify(a))}function eo(e){if(!e)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}var Me={handshake:"/pai/handshake",streamMessage:"/pai/stream-message",streamResume:"/pai/stream-resume",cancelStream:"/pai/cancel-stream",listConversations:"/pai/list-conversations",listMessages:"/pai/list-messages",updateSettings:"/pai/update-settings",markRead:"/pai/mark-read",bootstrap:"/pai/bootstrap",content:"/pai/content",submitForm:"/pai/submit-form"},Ii="context";function Ai(e){let n={messages:e.messages.map(i=>({id:i.id,parts:Nd(i),role:i.role,createdAt:i.createdAt!==void 0?new Date(i.createdAt).toISOString():void 0})),conversationId:e.conversationId,trigger:e.trigger??"submit-message"};e.visitorId&&(n.visitorId=e.visitorId),e.userPrefs&&(n.userPrefs=e.userPrefs);let o={},a=e.tools?.map(Od).filter(i=>i!==null);return a?.length&&(o.tools=a),e.responseMode&&(o.responseMode=e.responseMode),Object.keys(o).length>0&&(n.data=o),n}function Md(e){return e.state==="output"||e.state==="error"||e.approval?.approved!==void 0}function Od(e){return typeof e=="string"?e?{code:e}:null:e?.code?e:null}function Nd(e){let t=[];for(let n of e.parts)if(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}),n.kind==="tool"&&Md(n)){let o={type:"tool",toolCallId:n.toolCallId,toolName:n.toolName,state:n.state};n.input!==void 0&&(o.input=n.input),n.output!==void 0&&(o.output=n.output),n.error!==void 0&&(o.errorText=n.error),n.approval&&n.approval.approved!==void 0&&(o.approval=n.approval),t.push(o)}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 J=U.scope("transport"),Dd=3,Mi=400,$d=6e4,Ri=3,Hd=new Set([408,425,429,500,502,503,504]);function Li(e){return Mi*2**e+Math.floor(Math.random()*250)}function Fd(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 Pr(e,t){return new Promise(n=>{if(t?.aborted)return n();let o=setTimeout(i,e),a=()=>i();t?.addEventListener("abort",a,{once:!0});function i(){clearTimeout(o),t?.removeEventListener("abort",a),n()}})}var to=class{constructor(t){X(this,"opts",t);X(this,"visitorId");X(this,"conversationId");X(this,"userContext");X(this,"pageContext");X(this,"locale");X(this,"contentCache",new Map)}setContext(t,n){this.userContext=t,this.pageContext=n}setLocale(t){this.locale=t}primeIdentity(t,n){t&&(this.visitorId=t),n&&(this.conversationId=n)}envelope(){let t={};this.visitorId&&(t.visitorId=this.visitorId),this.conversationId&&(t.conversationId=this.conversationId),this.locale&&(t.locale=this.locale);let n=Ei(this.userContext,this.pageContext);return n&&(t[Ii]=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,a]of Object.entries(this.envelope()))n.searchParams.has(o)||n.searchParams.set(o,a);return n.toString()}async handshake(t){J.debug("handshake \u2192",{visitorId:t.visitorId,conversationId:t.conversationId,locale:t.locale});let n=await this.postJson(Me.handshake,t,"handshake");return J.debug("handshake \u2190",{visitorId:n.visitorId,conversationId:n.conversationId,hasWelcome:!!n.welcome,hasConfig:!!n.config,rebind:n.rebind}),zd(n)||J.warn("handshake response did not match expected shape; using raw response",{response:n}),this.visitorId=n.visitorId??t.visitorId,this.conversationId=n.conversationId,n}async uploadFile(t){J.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 J.debug("uploadFile \u2190",{id:o.id,url:o.url}),o}async transcribe(t,n="audio/webm"){J.debug("transcribe \u2192",{size:t.size,mimeType:n});let o=new FormData;o.append("audio",t,`voice.${Bd(n)}`),o.append("mimeType",n);let a=await this.postForm(this.transcribePath,o,"transcribe");return J.debug("transcribe \u2190",{textLen:a.text.length}),a}async listConversations(t={}){let n=new URL(this.url(Me.listConversations));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),J.debug("listConversations \u2192",{visitorId:t.visitorId??this.visitorId,limit:t.limit,cursor:t.cursor});let o=await this.getJson(n.toString(),"listConversations"),a=o.conversations??[];return J.debug("listConversations \u2190",{count:a.length,nextCursor:o.nextCursor}),{conversations:a.map(i=>({conversationId:i.conversationId,title:i.title,lastMessageAt:i.lastMessageAt,preview:i.preview,canContinue:i.canContinue,unreadCount:i.unreadCount})),nextCursor:o.nextCursor}}async loadConversation(t){let n=new URL(this.url(Me.listMessages));n.searchParams.set("conversationId",t),J.debug("loadConversation \u2192",{conversationId:t,visitorId:this.visitorId});let o=await this.getJson(n.toString(),"loadConversation"),a=o.messages??[];return J.debug("loadConversation \u2190",{conversationId:o.conversationId,canContinue:o.canContinue,messageCount:a.length,hasSuggestions:!!o.suggestions}),{conversationId:o.conversationId,canContinue:o.canContinue??!0,messages:a,agent:o.agent,suggestions:o.suggestions}}async markRead(t){if(!(!this.visitorId||!t)){J.debug("markRead \u2192",{conversationId:t,visitorId:this.visitorId});try{await this.postJson(Me.markRead,{conversationId:t},"markRead")}catch(n){J.debug("markRead failed (non-fatal)",{err:n})}}}listContent(t={}){let n=`${this.locale??""}|${JSON.stringify(t,Object.keys(t).toSorted())}`,o=this.contentCache.get(n);if(o&&Date.now()-o.at<$d)return J.debug("listContent \u2192 cache",t),o.result;let a=this.fetchContent(t).catch(i=>{throw this.contentCache.delete(n),i});return this.contentCache.set(n,{at:Date.now(),result:a}),a}async fetchContent(t){let n=new URL(this.dataUrl(Me.content));for(let[i,s]of Object.entries(t))s!==void 0&&n.searchParams.set(i,Array.isArray(s)?s.join(","):String(s));J.debug("listContent \u2192",t);let o=await this.getJson(n.toString(),"listContent"),a=(o.items??[]).map(i=>Ta(i,this.locale));return J.debug("listContent \u2190",{count:a.length,total:o.pagination?.total}),{...o,items:a}}async bootstrap(t){let n=new URL(this.dataUrl(Me.bootstrap));t&&n.searchParams.set("conversationId",t),J.debug("bootstrap \u2192",{conversationId:t??this.conversationId});let o=await this.getJson(n.toString(),"bootstrap"),a=o.forms??[],i=o.formSubmissions??[];return J.debug("bootstrap \u2190",{forms:a.length,formSubmissions:i.length}),{forms:a,formSubmissions:i}}async saveUserPrefs(t){J.debug("saveUserPrefs \u2192",{visitorId:this.visitorId,conversationId:this.conversationId,settingsKeys:Object.keys(t)});let n=await this.postJson(Me.updateSettings,{userPrefs:t},"saveUserPrefs");return J.debug("saveUserPrefs \u2190",{ok:n.ok}),n}get uploadPath(){return this.opts.endpoints?.upload??"/pai/upload-file"}get transcribePath(){return this.opts.endpoints?.transcribe??"/pai/transcribe-audio"}get submitFormPath(){return this.opts.endpoints?.submitForm??Me.submitForm}async submitForm(t){J.debug("submitForm \u2192",{formId:t.formId,trigger:t.trigger,fields:Object.keys(t.values).length});try{await this.postJson(this.dataUrl(this.submitFormPath),t,"submitForm")}catch(n){J.debug("submitForm failed (non-fatal)",{err:n})}}sendMessage(t){J.debug("message \u2192",{conversationId:t.conversationId,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.conversationId)}}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 a=1;a<=Dd&&!t.signal.aborted;a++){if((!o||a>1)&&(await Pr(Mi*a,t.signal),t.signal.aborted))return;let i;try{i=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;J.debug("resume fetch failed \u2014 retrying",{attempt:a,err:l});continue}if(i.status===204||!i.ok){J.debug("resume \u2192 no in-flight stream",{status:i.status});return}let s=n.size;if(yield*this.drain(xr(i,t.signal),n,t))return;if(n.size===s){J.debug("resume \u2192 stream closed with no new events; nothing to resume");return}}if(!t.signal.aborted)throw new Le("stream incomplete after resume attempts","server")}async*drain(t,n,o){try{for await(let a of t){if(o.signal.aborted)return!0;if(a.eventId){if(n.has(a.eventId))continue;n.add(a.eventId)}if(yield a,a.chunk.type==="finish"||a.chunk.type==="error")return!0}}catch(a){if(o.signal.aborted)return!0;if(a instanceof Le&&a.status!==void 0)throw a;J.debug("stream segment dropped",{err:a})}return!1}cancelStream(t,n){t.signal.aborted||(J.debug("cancel stream",{conversationId:n,visitorId:this.visitorId}),t.abort(),!(!this.visitorId||!n)&&this.fetchImpl(this.url(Me.cancelStream),{method:"POST",credentials:"omit",headers:{"content-type":"application/json",...this.opts.auth.headers()},body:JSON.stringify(this.withEnvelope({})),keepalive:!0}).catch(o=>J.debug("cancel POST failed (non-fatal)",{err:o})))}async*openMessageStream(t,n){let o=await this.fetchImpl(this.url(Me.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*xr(o,n)}resumeUrl(t){let n=new URL(this.withEnvelopeQuery(Me.streamResume));return n.searchParams.set("resumeAt",String(t)),n.toString()}async postJson(t,n,o){let a=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(a,o)}async postForm(t,n,o){let a=await this.fetchImpl(this.url(t),{method:"POST",credentials:"omit",headers:this.opts.auth.headers(),body:this.appendEnvelope(n)});return this.assertOk(a,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[a,i]=t(),s;try{s=await this.fetchImpl(a,i)}catch(c){if(o>=Ri)throw new Le(`${n} failed: network error`,"network",void 0,c);J.debug("request network error \u2014 retrying",{label:n,attempt:o}),await Pr(Li(o));continue}if(s.ok||!Hd.has(s.status)||o>=Ri)return s;let l=Fd(s.headers)??Li(o);J.debug("request retryable status \u2014 retrying",{label:n,status:s.status,attempt:o,wait:l}),await Pr(l)}}async assertOk(t,n){if(!t.ok)throw new Le(`${n} failed: ${t.status}`,"server",t.status);return await t.json()}url(t){return/^https?:\/\//i.test(t)?t:`${this.opts.agentApiBaseUrl}${t}`}dataUrl(t){return/^https?:\/\//i.test(t)?t:`${this.opts.dataApiBaseUrl}${t}`}get fetchImpl(){return this.opts.fetchImpl??globalThis.fetch.bind(globalThis)}};function Bd(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 zd(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.visitorId=="string"&&typeof t.conversationId=="string"}function Oi(e,t){let n=e?[{kind:"text",id:"t0",textSig:F(e),doneSig:F(!0)}]:[];return{id:$e(),role:"user",createdAt:Date.now(),status:"complete",attachments:t,partsSig:F(n)}}function no(){return{id:$e(),role:"assistant",createdAt:Date.now(),status:"streaming",partsSig:F([])}}function yr(e){return Ud({id:e.id,role:e.role,createdAt:Date.now(),status:"complete",parts:[{kind:"text",id:`${e.id}-t0`,text:e.text,done:!0}]})}function Ud(e){return{id:e.id,role:e.role,createdAt:e.createdAt,status:e.status,errorText:e.errorText,finishReason:e.finishReason,attachments:e.attachments,partsSig:F(e.parts.map(Wd))}}function Sr(e){let t=e.parts.map((n,o)=>n.type==="text"?{kind:"text",id:`${e.id}-t${o}`,textSig:F(n.text),doneSig:F(!0)}:n.type==="file"?{kind:"file",url:n.url,mediaType:n.mediaType}:n.type==="tool"?{kind:"tool",toolCallId:n.toolCallId,toolName:n.toolName,inputPartialSig:F(""),inputSig:F(n.input),outputSig:F(n.output),errorSig:F(n.errorText),stateSig:F(n.state),approvalSig:F(n.approval)}:null).filter(n=>n!==null);return{id:e.id,role:e.role,createdAt:eo(e.createdAt)??Date.now(),status:"complete",partsSig:F(t)}}function Ni(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(Gd)}}function wr(e){let t="";for(let n of e.partsSig.value)n.kind==="text"&&(t+=n.textSig.value);return t}function Wd(e){return e.kind==="text"||e.kind==="reasoning"?{kind:e.kind,id:e.id,textSig:F(e.text),doneSig:F(e.done)}:e.kind==="tool"?{kind:"tool",toolCallId:e.toolCallId,toolName:e.toolName,inputPartialSig:F(e.inputPartial),inputSig:F(e.input),outputSig:F(e.output),errorSig:F(e.error),stateSig:F(e.state),approvalSig:F(e.approval)}:e}function Gd(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,approval:e.approvalSig.value}:e}function oo(e){if(!e)return!1;let t=e.startsWith("tool:")?e.slice(5):e;return t==="ask-user-input"||t==="ask_user_input"||t==="request-user-input"||t==="request_user_input"}var ro={submitMessage:"submit-message",toolResult:"tool-result",toolApproval:"tool-approval"};var Di=U.scope("reducer"),ao=class{constructor(t){X(this,"messagesSig",t);X(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":Di.debug("finish",{reason:t.finishReason,canContinue:t.canContinue}),n.status="complete",t.finishReason&&(n.finishReason=t.finishReason),this.bumpDone(n);return;case"error":Di.warn("stream error chunk",{errorText:t.errorText}),n.status="error",n.errorText=t.errorText,this.bumpDone(n);return;case"text-start":Tt(n,"text",t.id);return;case"text-delta":{let o=Tt(n,"text",t.id);o.textSig.value+=t.delta;return}case"text-end":Tt(n,"text",t.id).doneSig.value=!0;return;case"reasoning-start":Tt(n,"reasoning",t.id).doneSig.value=!1;return;case"reasoning-delta":{let o=Tt(n,"reasoning",t.id);o.textSig.value+=t.delta;return}case"reasoning-end":Tt(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":case"tool-approval-request":Vd(n,t);return;case"file":io(n,{kind:"file",url:t.url,mediaType:t.mediaType});return;case"source-url":{if(n.partsSig.value.some(a=>a.kind==="source"&&a.sourceId===t.sourceId))return;io(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 Tt(e,t,n){let o=e.partsSig.value.find(i=>i.kind===t&&i.id===n);if(o)return o;let a={kind:t,id:n,textSig:F(""),doneSig:F(!1)};return io(e,a),a}function Et(e,t,n){let o=e.partsSig.value.find(i=>i.kind==="tool"&&i.toolCallId===t);if(o)return o;let a={kind:"tool",toolCallId:t,toolName:n??"tool",inputPartialSig:F(""),inputSig:F(void 0),outputSig:F(void 0),errorSig:F(void 0),stateSig:F("input"),approvalSig:F(void 0)};return io(e,a),a}function io(e,t){e.partsSig.value=[...e.partsSig.value,t]}function Vd(e,t){switch(t.type){case"tool-input-start":Et(e,t.toolCallId,t.toolName);return;case"tool-input-delta":{let n=Et(e,t.toolCallId);n.inputPartialSig.value+=t.delta;return}case"tool-input-available":{let n=Et(e,t.toolCallId,t.toolName);n.inputSig.value=t.input,n.stateSig.value=oo(n.toolName)?"awaiting-input":"awaiting";return}case"tool-approval-request":{let n=Et(e,t.toolCallId,t.toolName);n.approvalSig.value={id:t.approvalId},n.stateSig.value="awaiting-approval";return}case"tool-output-available":{let n=Et(e,t.toolCallId);n.outputSig.value=t.output,n.stateSig.value="output";return}case"tool-output-error":{let n=Et(e,t.toolCallId);n.errorSig.value=t.errorText,n.stateSig.value="error";return}default:return}}var $i=U.scope("feedback:audio"),so=class{constructor(){X(this,"ctx",null);X(this,"master",null);X(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){$i.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 a=n.currentTime,i=t.noteMs/1e3;t.notes.forEach((s,l)=>{let c=n.createOscillator();c.type=t.type,c.frequency.value=s;let d=n.createGain(),u=a+l*i;d.gain.setValueAtTime(1e-4,u),d.gain.exponentialRampToValueAtTime(t.peakGain,u+.005),d.gain.exponentialRampToValueAtTime(1e-4,u+i),c.connect(d).connect(o),c.start(u),c.stop(u+i+.01)})}async playUrl(t){let n=this.ctx,o=this.master;if(!n||!o||n.state!=="running")return;let a=await this.getBuffer(t);if(!a)return;let i=n.createBufferSource();i.buffer=a,i.connect(o),i.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,a=fetch(t).then(i=>i.ok?i.arrayBuffer():Promise.reject(new Error(`fetch ${i.status}`))).then(i=>o.decodeAudioData(i)).then(i=>(this.buffers.set(t,i),i)).catch(i=>($i.warn("audio fetch/decode failed",{url:t,err:i}),this.buffers.delete(t),null));return this.buffers.set(t,a),a}};var Hi={messageReceived:10,messageSent:0,error:[20,40,20],voiceStart:10,voiceStop:0},Fi={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 Qe=null,lo=0;function Kd(){return typeof navigator<"u"&&typeof navigator.vibrate=="function"}function qd(){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=`__${x.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 Bi(e){if(!(e===0||Array.isArray(e)&&e.every(t=>t===0))){if(Kd())try{navigator.vibrate(e);return}catch{}if(Qe||(Qe=qd()),!!Qe)try{Qe.label.click()}catch{}}}function zi(){lo++;let e=!1;return()=>{e||(e=!0,lo=Math.max(0,lo-1),lo===0&&Qe&&(Qe.input.remove(),Qe.label.remove(),Qe=null))}}var jd=U.scope("feedback"),Xd=100,co=class{constructor(t,n){X(this,"mutedSig",F(!1));X(this,"audio",new so);X(this,"releaseHaptics");X(this,"sound");X(this,"haptics");X(this,"lastPlayed",new Map);X(this,"reducedMotionMq",null);this.sound=t,this.haptics=n,this.releaseHaptics=zi(),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<Xd}playSound(t){let n=this.sound.events?.[t];if(n===!1)return;if(typeof n=="string"){this.audio.playUrl(n).catch(a=>jd.warn("audio play failed",{err:a,url:n}));return}let o=Fi[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?Hi[t]:n;Bi(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 ot(e,t){return e instanceof Le&&e.status===429?t.errorRateLimited:t.errorGeneric}var Jd=0;function r(e,t,n,o,a,i){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 d={type:e,props:c,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Jd,__i:-1,__u:0,__source:a,__self:i};if(typeof e=="function"&&(s=e.defaultProps))for(l in s)c[l]===void 0&&(c[l]=s[l]);return q.vnode&&q.vnode(d),d}var $={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24"},Yd=()=>r("svg",{...$,"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"})}),Fe=()=>r("svg",{...$,"aria-hidden":"true",children:r("path",{d:"M18 6 6 18M6 6l12 12"})}),Ui=()=>r("svg",{...$,"aria-hidden":"true",children:r("path",{d:"M12 5v14M5 12h14"})}),Wi=()=>r("svg",{...$,"aria-hidden":"true",children:[r("path",{d:"m22 2-7 20-4-9-9-4Z"}),r("path",{d:"M22 2 11 13"})]}),Gi=()=>r("svg",{...$,"aria-hidden":"true",children:r("path",{d:"M12 19V5M5 12l7-7 7 7"})}),Vi=()=>r("svg",{...$,"aria-hidden":"true",children:r("path",{d:"M3 20V4l18 8-18 8Z"})}),It=()=>r("svg",{...$,"aria-hidden":"true",children:r("path",{d:"m9 18 6-6-6-6"})}),Ki=()=>r("svg",{...$,"aria-hidden":"true",children:r("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})}),qi=()=>r("svg",{...$,"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"})}),ji=()=>r("svg",{...$,"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"})]}),Xi=()=>r("svg",{...$,"aria-hidden":"true",children:r("path",{d:"M3 8V3h5M21 8V3h-5M3 16v5h5M21 16v5h-5"})}),Ji=()=>r("svg",{...$,"aria-hidden":"true",children:r("path",{d:"M8 3v5H3M16 3v5h5M8 21v-5H3M16 21v-5h5"})}),Yi=()=>r("svg",{...$,"aria-hidden":"true",children:r("path",{d:"M3 3h7v2H5v5H3zM21 3h-7v2h5v5h2zM3 21h7v-2H5v-5H3zM21 21h-7v-2h5v-5h2z"})}),Qi=()=>r("svg",{...$,"aria-hidden":"true",children:r("path",{d:"M10 3v5H3M14 3v5h7M10 21v-5H3M14 21v-5h7"})}),Zi=()=>r("svg",{...$,"aria-hidden":"true",viewBox:"0 0 10 10",children:r("path",{d:"M9 1L1 9M9 5L5 9M9 9H9",strokeWidth:"1.5"})}),es=()=>r("svg",{...$,"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"})]}),ts=()=>r("svg",{...$,"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"})}),ns=()=>r("svg",{...$,"aria-hidden":"true",children:r("path",{d:"M11 5 6 9H2v6h4l5 4zM22 9l-6 6M16 9l6 6"})}),os=()=>r("svg",{...$,"aria-hidden":"true",children:[r("path",{d:"M3 18 8 6l5 12M4.7 14h6.6"}),r("path",{d:"M14.5 18l3.2-7 3.2 7M15.6 15.8h4.2"})]}),rs=()=>r("svg",{...$,"aria-hidden":"true",children:r("path",{d:"m5 6 6 6-6 6M13 6l6 6-6 6"})}),Zt=()=>r("svg",{...$,"aria-hidden":"true",children:r("path",{d:"M20 6 9 17l-5-5"})}),as=()=>r("svg",{...$,"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"})]}),is=()=>r("svg",{...$,"aria-hidden":"true",children:[r("circle",{cx:"12",cy:"12",r:"10"}),r("path",{d:"M2 12h20"}),r("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),en=()=>r("svg",{...$,"aria-hidden":"true",children:r("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),ss=()=>r("svg",{...$,"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"})}),ls=()=>r("svg",{...$,"aria-hidden":"true",children:[r("path",{d:"M12 20h9"}),r("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"})]}),cs=()=>r("svg",{...$,"aria-hidden":"true",children:r("path",{d:"m6 9 6 6 6-6"})}),ds=()=>r("svg",{...$,"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"})]}),Qd=()=>r("svg",{...$,"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"})]}),kr=()=>r("svg",{...$,"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"})}),Cr=()=>r("svg",{...$,"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"})]}),Zd=()=>r("svg",{...$,"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"})]}),e_=()=>r("svg",{...$,"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"})]}),t_=()=>r("svg",{...$,"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"})]}),n_=()=>r("svg",{...$,"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"})]}),Tr=()=>r("svg",{...$,"aria-hidden":"true",children:[r("circle",{cx:"11",cy:"11",r:"7"}),r("path",{d:"m21 21-4.3-4.3"})]}),_s=()=>r("svg",{...$,"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"})]}),us=()=>r("svg",{...$,"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"})]}),ps=()=>r("svg",{...$,"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"})]}),tn=()=>r("svg",{...$,"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"})]}),fs=()=>r("svg",{...$,"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"})]}),ms=()=>r("svg",{...$,"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"})}),gs=()=>r("svg",{...$,"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"})]}),o_=()=>r("svg",{...$,"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"})]}),r_=()=>r("svg",{...$,"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"})]}),a_=()=>r("svg",{...$,"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"})]}),i_=()=>r("svg",{...$,"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"})]}),hs={chat:Yd,message:kr,bubbles:tn,spark:Qd,wand:Zd,bot:e_,help:Cr,lifebuoy:n_,headset:t_,search:o_,sparkles:r_,concierge:a_,wave:i_};var E=x.cssPrefix,y={launcher:`${E}-launcher`,callout:`${E}-callout`,calloutDismiss:`${E}-callout-dismiss`,panel:`${E}-panel`,panelHeader:`${E}-panel-header`,resizeGrip:`${E}-resize-grip`,scrollToBottom:`${E}-scroll-to-bottom`,actionHistory:`${E}-action-history`,actionClose:`${E}-action-close`,langSegment:`${E}-lang-segment`,composer:`${E}-composer`,composerInput:`${E}-composer-input`,composerSend:`${E}-composer-send`,composerStop:`${E}-composer-stop`,composerAttach:`${E}-composer-attach`,composerFileInput:`${E}-composer-file-input`,composerVoice:`${E}-composer-voice`,attachmentChip:`${E}-attachment-chip`,attachmentRemove:`${E}-attachment-remove`,suggestion:`${E}-suggestion`,messageBubble:`${E}-message`,messageRetry:`${E}-message-retry`,historyPane:`${E}-history-pane`,historyBack:`${E}-history-back`,historyItem:`${E}-history-item`,sidebar:`${E}-sidebar`,sidebarToggle:`${E}-sidebar-toggle`,sidebarNewConversation:`${E}-sidebar-new-conversation`,sidebarItem:`${E}-sidebar-item`,messengerHome:`${E}-messenger-home`,modulesEmpty:`${E}-modules-empty`,tab:`${E}-tab`,tabBadge:`${E}-tab-badge`,homeView:`${E}-home-view`,homeGreeting:`${E}-home-greeting`,homeBrand:`${E}-home-brand`,backHeader:`${E}-back-header`,contentView:`${E}-content-view`,contentScroll:`${E}-content-scroll`,homeSearch:`${E}-home-search`,helpSearch:`${E}-help-search`,homeRecent:`${E}-home-recent`,homeContentRow:`${E}-home-content-row`,helpArticle:`${E}-help-article`,newsItem:`${E}-news-item`,formGate:`${E}-form-gate`,formDone:`${E}-form-done`,formDoneToggle:`${E}-form-done-toggle`,formAnswers:`${E}-form-answers`,formFill:`${E}-form-fill`,formSubmit:`${E}-form-submit`,formSkip:`${E}-form-skip`,formField:`${E}-form-field`,toolAskInput:`${E}-tool-ask-input`,toolInputSubmit:`${E}-tool-input-submit`,toolInputSkip:`${E}-tool-input-skip`,toolApproval:`${E}-tool-approval`,toolApprove:`${E}-tool-approve`,toolReject:`${E}-tool-reject`,toolDecision:`${E}-tool-decision`};function he(e,t){return`${e}-${t}`}var _o=x.cssPrefix;function vs({onToggle:e,launcher:t,strings:n,leaving:o,edgeTab:a}){let i=t.variant!=="circle"&&!!t.label;return r("button",{type:"button",class:`${_o}-fab`,"data-variant":t.variant,"data-size":t.size,"data-edge-tab":a?"true":void 0,"data-leaving":o?"true":void 0,"data-testid":y.launcher,onClick:e,"aria-label":n.launcherOpen,children:[s_(t.icon),i?r("span",{class:`${_o}-fab-label`,children:t.label}):null]})}function s_(e){let t=hs[e];return t?r(t,{}):r(l_,{source:e})}function l_({source:e}){return r("span",{ref:t=>{t&&c_(t,e)},"aria-hidden":"true"})}function c_(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 bs({callout:e,launcherPosition:t,strings:n,closeLabel:o,onDismiss:a}){let[i,s]=k(!1);return w(()=>{let l=setTimeout(()=>s(!0),e.delayMs);return()=>clearTimeout(l)},[e.delayMs]),w(()=>{if(!i||e.autoDismissMs<=0)return;let l=setTimeout(a,e.autoDismissMs);return()=>clearTimeout(l)},[i,e.autoDismissMs,a]),i?r("div",{class:`${_o}-callout`,role:"status","data-shape":e.shape,"data-position":d_(e.position,t),"data-animated":e.animated?"true":void 0,"data-testid":y.callout,children:[r("span",{children:mt(n,e.text)}),r("button",{type:"button",class:`${_o}-callout-close`,onClick:a,"aria-label":o,title:o,"data-testid":y.calloutDismiss,children:r(Fe,{})})]}):null}function d_(e,t){let n=t.endsWith("-right"),o=t.startsWith("bottom-");return e==="vertical"?o?"top":"bottom":n?"left":"right"}function uo({panelEl:e,resize:t,position:n,initialSize:o,onSizeChange:a,strings:i}){let s=x.cssPrefix,l=M(null);if(w(()=>{if(!e)return;let m=e.style;t.minWidth&&m.setProperty(`--${s}-resize-min-w`,t.minWidth),t.maxWidth&&m.setProperty(`--${s}-resize-max-w`,t.maxWidth),t.minHeight&&m.setProperty(`--${s}-resize-min-h`,t.minHeight),t.maxHeight&&m.setProperty(`--${s}-resize-max-h`,t.maxHeight),o&&(m.setProperty(`--${s}-widget-w`,`${o.width}px`),m.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-"),d=n.endsWith("-right"),u=`${s}-resize-grip ${s}-resize-grip--${c?"bottom":"top"}-${d?"left":"right"}`,_=m=>{if(!e)return;let g=m.currentTarget,v=e.getBoundingClientRect();l.current={pointerId:m.pointerId,startX:m.clientX,startY:m.clientY,startW:v.width,startH:v.height,dirX:d?-1:1,dirY:c?1:-1},g.setPointerCapture(m.pointerId),e.setAttribute("data-resizing",""),m.preventDefault()},h=m=>{let g=l.current;if(!g||m.pointerId!==g.pointerId||!e)return;let v=(m.clientX-g.startX)*g.dirX,A=(m.clientY-g.startY)*g.dirY;e.style.setProperty(`--${s}-widget-w`,`${g.startW+v}px`),e.style.setProperty(`--${s}-widget-h`,`${g.startH+A}px`)},p=m=>{let g=l.current;if(!g||m.pointerId!==g.pointerId||!e)return;m.currentTarget.releasePointerCapture(m.pointerId),e.removeAttribute("data-resizing");let v=e.getBoundingClientRect();a({width:Math.round(v.width),height:Math.round(v.height)}),l.current=null};return r("div",{class:u,role:"separator","aria-orientation":"vertical","aria-label":i.resizeHandle,title:i.resizeHandle,onPointerDown:_,onPointerMove:h,onPointerUp:p,onPointerCancel:p,"data-testid":y.resizeGrip,children:r(Zi,{})})}var rt=x.cssPrefix,__=`.${rt}-header, .${rt}-back-header, .${rt}-home-hero`,u_='button, a, input, textarea, select, [role="tab"], [contenteditable]',xs=56;function po(e,t){w(()=>{if(!t||!e)return;let n=c=>Number.parseFloat(c)||0,o=(c,d)=>Math.min(d,Math.max(-d,c)),a=null,i=c=>{let d=c.target;if(!(d instanceof Element)||!d.closest(__)||d.closest(u_))return;let u=e.getBoundingClientRect();a={id:c.pointerId,x:c.clientX,y:c.clientY,dx:n(e.style.getPropertyValue(`--${rt}-modal-dx`)),dy:n(e.style.getPropertyValue(`--${rt}-modal-dy`)),maxX:(window.innerWidth+u.width)/2-xs,maxY:(window.innerHeight+u.height)/2-xs},e.dataset.dragging="true",c.preventDefault()},s=c=>{if(!a||c.pointerId!==a.id)return;let d=o(a.dx+c.clientX-a.x,a.maxX),u=o(a.dy+c.clientY-a.y,a.maxY);e.style.setProperty(`--${rt}-modal-dx`,`${d}px`),e.style.setProperty(`--${rt}-modal-dy`,`${u}px`)},l=c=>{!a||c.pointerId!==a.id||(a=null,delete e.dataset.dragging)};return e.addEventListener("pointerdown",i),window.addEventListener("pointermove",s),window.addEventListener("pointerup",l),window.addEventListener("pointercancel",l),()=>{e.removeEventListener("pointerdown",i),window.removeEventListener("pointermove",s),window.removeEventListener("pointerup",l),window.removeEventListener("pointercancel",l)}},[e,t])}function nn(e,t,n,o){switch(e){case"clear":case"sound":case"history":case"language":case"theme":case"textSize":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 fo(e,t,n){return nn("close",e,t)?n.includes("close"):!1}function Ps(e,t){return e==="inline"&&t==="fullscreen"?"exit-fullscreen":"close"}var p_='a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),[tabindex]:not([tabindex="-1"])';function mo(e){let t=n=>{if(n.key!=="Tab")return;let o=[...e.querySelectorAll(p_)].filter(l=>l.offsetParent!==null||l===document.activeElement);if(o.length===0){n.preventDefault();return}let a=o[0],i=o[o.length-1];if(!a||!i)return;let s=e.getRootNode().activeElement;n.shiftKey&&s===a?(n.preventDefault(),i.focus()):!n.shiftKey&&s===i&&(n.preventDefault(),a.focus())};return e.addEventListener("keydown",t),()=>e.removeEventListener("keydown",t)}function go(e){return e.trim().split(/\s+/).slice(0,2).map(t=>t.charAt(0).toUpperCase()).join("")}var Er=x.cssPrefix;function ys({agent:e}){let t=e.status??"online";return r("div",{class:`${Er}-agent`,children:[r("div",{class:`${Er}-agent-avatar`,"data-status":t,children:e.avatar?r("img",{src:e.avatar,alt:""}):r("span",{children:go(e.name)})}),r("div",{class:`${Er}-agent-meta`,children:[r("strong",{children:e.name}),e.title?r("span",{children:e.title}):null]})]})}var Ss=U.scope("attachments");function ho(e,t,n){let o=m_(e),a=[],i=[],s=v_(n.accept),l=t.reduce((d,u)=>d+u.size,0),c=t.length;for(let d of o){let u=f_(d,c,l,n,s);if(u){i.push({file:d,reason:u});continue}a.push(h_(d)),l+=d.size,c+=1}return(a.length||i.length)&&Ss.debug("ingest",{accepted:a.length,rejected:i.map(d=>({name:d.file.name,reason:d.reason}))}),{accepted:a,rejected:i}}function Ir(e){try{URL.revokeObjectURL(e.previewUrl)}catch(t){Ss.debug("revokeObjectURL failed",{error:t})}}function f_(e,t,n,o,a){return t>=o.maxCount?"count":n+e.size>o.maxBytes?"bytes":b_(e,a)?null:"mime"}function m_(e){return e?Array.isArray(e)?e.filter(t=>t instanceof File):[...e].map(t=>t instanceof File?t:g_(t)).filter(t=>t!==null):[]}function g_(e){let t=e;return!t?.getAsFile||t.kind!=="file"?null:t.getAsFile()}function h_(e){return{file:e,id:$e(),mediaType:e.type||"application/octet-stream",name:e.name||"pasted-file",previewUrl:URL.createObjectURL(e),size:e.size}}function v_(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 b_(e,t){if(t.length===0)return!0;let[n="*",o="*"]=(e.type||"").toLowerCase().split("/"),a=(e.name||"").toLowerCase();return t.some(i=>i.kind==="ext"?a.endsWith(i.ext):(i.type==="*"||i.type===n)&&(i.subtype==="*"||i.subtype===o))}var on=x.cssPrefix;function ws({attachment:e,onRemove:t}){let n=e.mediaType.startsWith("image/");return r("span",{class:`${on}-attachment-chip`,title:e.name,"data-testid":he(y.attachmentChip,e.id),children:[n?r("img",{class:`${on}-attachment-thumb`,src:e.previewUrl,alt:""}):r("span",{class:`${on}-attachment-thumb`,"aria-hidden":"true",children:r(ds,{})}),r("span",{class:`${on}-attachment-name`,children:e.name}),r("button",{type:"button",class:`${on}-attachment-remove`,onClick:t,"aria-label":`Remove ${e.name}`,"data-testid":he(y.attachmentRemove,e.id),children:r(Fe,{})})]})}var Ar={isSupported:!1,start:()=>{},stop:()=>{}};function Rr(e,t,n){return e==="disabled"?Ar:e==="server"?S_(n):x_(t)}function x_(e){let t=P_();if(!t)return Ar;let n=null;return{isSupported:!0,start(o,a){n=new t,n.continuous=!0,n.interimResults=!0,n.lang=e,n.addEventListener("result",s=>{let l=s,c="",d=!1;for(let u=l.resultIndex;u<l.results.length;u++){let _=l.results[u];_&&(c+=_[0].transcript,_.isFinal&&(d=!0))}o(c,d)});let i=()=>{n=null,a()};n.addEventListener("end",i),n.addEventListener("error",i),n.start()},stop(){n?.stop()}}}function P_(){let e=globalThis;return e.SpeechRecognition??e.webkitSpeechRecognition}var y_=["audio/webm;codecs=opus","audio/webm","audio/ogg;codecs=opus","audio/mp4"];function S_(e){if(typeof MediaRecorder>"u"||!navigator?.mediaDevices?.getUserMedia)return Ar;let t=null,n=null,o=[],a=()=>{for(let i of n?.getTracks()??[])i.stop();n=null};return{isSupported:!0,async start(i,s){try{n=await navigator.mediaDevices.getUserMedia({audio:!0});let l=w_();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";a();let d=new Blob(o,{type:c});o=[];try{let{text:u}=await e(d,c);u&&i(u,!0)}catch{}finally{s()}}),t.start()}catch{a(),s()}},stop(){t?.stop()}}}function w_(){for(let e of y_)if(MediaRecorder.isTypeSupported(e))return e}var Te=x.cssPrefix,at=U.scope("composer");function At(e){return e.reduce((t,n)=>t+n.size,0)}var k_={arrowUp:Gi,paperPlane:Wi,send:Vi,chevron:It};function ks({options:e,transport:t,feedback:n,bus:o,isStreaming:a,onSend:i,onStop:s,attachApiRef:l}){let c=e.strings,[d,u]=k(""),[_,h]=k([]),[p,m]=k(!1),g=M(null),v=M(null),A=e.features.files,S=e.features.voice,[B,I]=k(()=>Rr(S,e.locale,(T,O)=>t.transcribe(T,O)));w(()=>{p||S==="disabled"||I(Rr(S,e.locale,(T,O)=>t.transcribe(T,O)))},[e.locale,S,t,p]),w(()=>{let T=g.current;if(!T)return;let O=T.getRootNode(),Q="activeElement"in O?O.activeElement:null;Q&&T.closest(`.${Te}-panel`)?.contains(Q)||T.focus({preventScroll:!0})},[]),w(()=>{let T=g.current;if(T){if(d.length===0){T.style.height="";return}T.style.height="auto",T.style.height=`${Math.min(T.scrollHeight,160)}px`}},[d]);let W=M(_);W.current=_,w(()=>()=>W.current.forEach(Ir),[]),w(()=>{if(l)return l.current={attachFromDrop:T=>{let O=ho(T,W.current,e.attachments);O.accepted.length!==0&&(at.info("attach (drop)",{count:O.accepted.length,totalBytes:At(O.accepted)}),o.emit("attach",{count:O.accepted.length,totalBytes:At(O.accepted)}),h(Q=>[...Q,...O.accepted]))}},()=>{l.current&&(l.current=null)}},[l,e.attachments]),w(()=>{let T=g.current;if(!T)return;let O=T.closest(`.${Te}-panel`);if(!O)return;let Q=pe=>{let fe=pe.clipboardData;if(!fe)return;if(A){let D=ho(fe.items,W.current,e.attachments);if(D.accepted.length>0){pe.preventDefault(),at.info("attach (paste)",{count:D.accepted.length,totalBytes:At(D.accepted)}),o.emit("attach",{count:D.accepted.length,totalBytes:At(D.accepted)}),h(me=>[...me,...D.accepted]);return}}if(pe.target===T)return;let P=fe.getData("text/plain");P&&(pe.preventDefault(),u(D=>D+P),T.focus())};return O.addEventListener("paste",Q),()=>O.removeEventListener("paste",Q)},[A,e.attachments,Te]);let K=()=>{let T=d.trim();!T&&_.length===0||a||(i(T,_),u(""),h([]))},N=T=>{T.key!=="Enter"||T.shiftKey||T.isComposing||(T.preventDefault(),a?s():K())},ue=T=>{let O=T.target,Q=ho(O.files,_,e.attachments);Q.accepted.length>0&&(at.info("attach (file picker)",{count:Q.accepted.length,totalBytes:At(Q.accepted)}),o.emit("attach",{count:Q.accepted.length,totalBytes:At(Q.accepted)}),h(pe=>[...pe,...Q.accepted])),O.value=""},z=T=>{at.info("removeAttachment",{id:T}),o.emit("removeAttachment",{id:T}),h(O=>{let Q=O.find(pe=>pe.id===T);return Q&&Ir(Q),O.filter(pe=>pe.id!==T)})},te=M(null),ve=()=>{if(B.isSupported){if(p){let T=te.current?Date.now()-te.current:0;at.info("voiceStop",{durationMs:T}),o.emit("voiceStop",{durationMs:T}),B.stop(),m(!1),n.play("voiceStop"),te.current=null;return}te.current=Date.now(),at.info("voiceStart"),o.emit("voiceStart",void 0),m(!0),n.play("voiceStart"),B.start((T,O)=>u(Q=>O?`${Q}${T} `:Q),()=>{if(m(!1),te.current){let T=Date.now()-te.current;at.debug("voiceStop (auto)",{durationMs:T}),o.emit("voiceStop",{durationMs:T}),te.current=null}})}},we=k_[e.composer.sendButton.icon];return r("div",{class:`${Te}-composer`,"data-testid":y.composer,children:[_.length>0?r("div",{class:`${Te}-attachments`,children:_.map(T=>r(ws,{attachment:T,onRemove:()=>z(T.id)},T.id))}):null,r("div",{class:`${Te}-composer-row`,children:[r("div",{class:`${Te}-composer-actions`,children:[A?r("button",{type:"button",class:`${Te}-icon-btn`,onClick:()=>v.current?.click(),"aria-label":c.attach,"data-testid":y.composerAttach,children:r(qi,{})}):null,B.isSupported?r("button",{type:"button",class:`${Te}-icon-btn`,onClick:ve,"aria-label":p?c.micStop:c.micStart,"aria-pressed":p,"data-recording":p?"true":void 0,"data-testid":y.composerVoice,children:r(ji,{})}):null]}),r("textarea",{ref:g,class:`${Te}-textarea`,rows:1,value:d,placeholder:c.composerPlaceholder,onInput:T=>u(T.target.value),onKeyDown:N,"aria-label":c.composerPlaceholder,"data-testid":y.composerInput}),a?r("button",{type:"button",class:`${Te}-send`,onClick:s,"aria-label":c.stop,"data-testid":y.composerStop,children:r(Ki,{})}):r("button",{type:"button",class:`${Te}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:K,disabled:!d.trim()&&_.length===0,"aria-label":c.send,"data-testid":y.composerSend,children:r(we,{})})]}),r("input",{ref:v,type:"file",multiple:!0,accept:e.attachments.accept,onChange:ue,class:`${Te}-sr-only`,"data-testid":y.composerFileInput})]})}var C_=x.cssPrefix;function Cs({visible:e,strings:t}){return e?r("div",{class:`${C_}-dropzone`,role:"status","aria-live":"polite",children:t.dropZone}):null}function vo({containerRef:e,onDrop:t}){let[n,o]=k(!1);return w(()=>{let a=e.current;if(!a)return;let i=0,s=u=>{i+=1,u.dataTransfer?.types.includes("Files")&&(u.preventDefault(),o(!0))},l=()=>{i-=1,!(i>0)&&(i=0,o(!1))},c=u=>{u.dataTransfer?.types.includes("Files")&&u.preventDefault()},d=u=>{i=0,o(!1),u.dataTransfer&&(u.preventDefault(),t(u.dataTransfer.items))};return a.addEventListener("dragenter",s),a.addEventListener("dragleave",l),a.addEventListener("dragover",c),a.addEventListener("drop",d),()=>{a.removeEventListener("dragenter",s),a.removeEventListener("dragleave",l),a.removeEventListener("dragover",c),a.removeEventListener("drop",d)}},[e,t]),{visible:n}}function Ts({itemCount:e,initialFocusIndex:t}){let[n,o]=k(!1),a=M(null),i=M(null),[s,l]=k(-1),c=H(()=>{o(!1),l(-1),a.current?.focus()},[]),d=H(()=>o(h=>!h),[]);w(()=>{if(!n)return;let h=p=>{let m=i.current,g=a.current;if(!m||!g)return;let v=p.composedPath();v.includes(m)||v.includes(g)||(o(!1),l(-1))};return document.addEventListener("click",h,!0),()=>document.removeEventListener("click",h,!0)},[n]),w(()=>{if(!n||e===0)return;let h=t?.()??0,p=h<0||h>=e?0:h;l(p)},[n,e,t]),w(()=>{if(!n||s<0)return;i.current?.querySelectorAll("[role='menuitem']")?.[s]?.focus()},[n,s]);let u=H(h=>{(h.key==="ArrowDown"||h.key==="Enter"||h.key===" ")&&(h.preventDefault(),o(!0))},[]),_=H(h=>{if(e!==0)switch(h.key){case"Escape":h.preventDefault(),c();return;case"ArrowDown":h.preventDefault(),l(p=>(p+1)%e);return;case"ArrowUp":h.preventDefault(),l(p=>(p-1+e)%e);return;case"Home":h.preventDefault(),l(0);return;case"End":h.preventDefault(),l(e-1)}},[e,c]);return{open:n,focusIndex:s,triggerRef:a,menuRef:i,toggle:d,close:c,onTriggerKey:u,onMenuKey:_}}function Es({items:e,triggerLabel:t}){let n=x.cssPrefix,o=Ts({itemCount:e.length}),a=l=>{l.disabled||(l.onSelect?.(),l.keepOpen||o.close())},i=(l,c)=>l.onSelectValue?.(c),s=(l,c)=>{let d=c.segments;if(!d?.length)return;let u=Math.max(0,d.findIndex(h=>h.value===c.value)),_=-1;if(l.key==="ArrowRight"||l.key==="Enter"||l.key===" ")_=(u+1)%d.length;else if(l.key==="ArrowLeft")_=(u-1+d.length)%d.length;else return;l.preventDefault(),l.stopPropagation(),i(c,d[_].value)};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(es,{})}),o.open?r("div",{ref:o.menuRef,class:`${n}-menu`,role:"menu","aria-label":t,onKeyDown:o.onMenuKey,tabIndex:-1,children:e.map(l=>l.segments?r("div",{role:"menuitem",class:`${n}-menu-item ${n}-menu-item-segmented`,"aria-label":l.label,tabIndex:-1,onKeyDown:c=>s(c,l),children:[l.icon?r("span",{class:`${n}-menu-icon`,children:l.icon}):null,r("span",{class:`${n}-menu-label`,children:l.label}),r("span",{class:`${n}-segmented`,role:"group","aria-label":l.label,children:l.segments.map(c=>{let d=c.value===l.value;return r("button",{type:"button",role:"menuitemradio","aria-checked":d,class:`${n}-segment`,"data-on":d?"true":void 0,lang:c.lang,title:c.value,tabIndex:-1,"data-testid":`${y.langSegment}-${c.value}`,onClick:()=>i(l,c.value),children:c.label},c.value)})})]},l.id):r("button",{type:"button",role:"menuitem",class:`${n}-menu-item`,"aria-pressed":l.type==="switch"?l.on:void 0,disabled:l.disabled,onClick:()=>a(l),children:[l.icon?r("span",{class:`${n}-menu-icon`,children:l.icon}):null,r("span",{class:`${n}-menu-label`,children:l.label}),l.type==="switch"&&l.on?r("span",{class:`${n}-menu-check`,"aria-hidden":"true",children:r(Zt,{})}):null]},l.id))}):null]})}var Lr=x.cssPrefix;function T_(e){let t=typeof matchMedia=="function"?matchMedia("(prefers-color-scheme: dark)").matches:!0;return e==="auto"?t?"light":"dark":t?e==="light"?"dark":"auto":e==="dark"?"light":"auto"}var E_={normal:"large",large:"small",small:"normal"};function I_(e){return e==="light"?r(fs,{}):e==="dark"?r(ms,{}):r(gs,{})}function A_(e){return(e.split("-")[0]||e).toUpperCase()}function Be({panelProps:e,variant:t}){let{options:n,panelSize:o,feedback:a,onClose:i,onClear:s,onExpand:l,onFullscreen:c,onPopOut:d,onSoundToggle:u}=e,{onToggleHistory:_,onLocaleChange:h,onThemeChange:p,onTextSizeChange:m}=e,g=n.strings,v=n.mode,A=t==="chat",S=re(()=>a.mutedSig.value).value,B=new Set(n.actions),I=O=>B.has(O),W=typeof matchMedia=="function"&&matchMedia("(max-width: 640px)").matches,K=O=>W&&(O==="expand"||O==="fullscreen")?!1:nn(O,v,o,{popOutUrl:n.popOutUrl}),N=n.themeMode,ue={auto:g.themeAuto,light:g.themeLight,dark:g.themeDark},z=n.textSize,te={small:g.textSizeSmall,normal:g.textSizeNormal,large:g.textSizeLarge},ve=[];if(A&&I("clear")&&ve.push({id:"clear",icon:r(ls,{}),label:g.newConversation,onSelect:s}),I("expand")&&K("expand")){let O=o==="expanded";ve.push({id:"expand",icon:O?r(Ji,{}):r(Xi,{}),label:O?g.collapse:g.expand,type:"switch",on:O,onSelect:l})}if(I("fullscreen")&&K("fullscreen")){let O=o==="fullscreen";ve.push({id:"fullscreen",icon:O?r(Qi,{}):r(Yi,{}),label:O?g.exitFullscreen:g.fullscreen,type:"switch",on:O,onSelect:c})}I("popOut")&&K("popOut")&&ve.push({id:"popOut",icon:r(ss,{}),label:g.popOut,onSelect:d}),A&&I("sound")&&ve.push({id:"sound",icon:S?r(ns,{}):r(ts,{}),label:S?g.soundOff:g.soundOn,type:"switch",on:!S,onSelect:u}),I("theme")&&ve.push({id:"theme",icon:I_(N),label:`${g.theme}: ${ue[N]}`,onSelect:()=>p(T_(N)),keepOpen:!0}),I("textSize")&&ve.push({id:"textSize",icon:r(os,{}),label:`${g.textSize}: ${te[z]}`,onSelect:()=>m(E_[z]),keepOpen:!0}),I("language")&&n.availableLocales.length>1&&ve.push({id:"language",icon:r(is,{}),label:g.language,segments:n.availableLocales.map(O=>({value:O,label:A_(O),lang:O})),value:n.locale,onSelectValue:h});let we=!!i&&fo(v,o,n.actions),T=A&&I("history");return r("div",{class:`${Lr}-header-actions`,children:[T?r("button",{type:"button",class:`${Lr}-icon-btn`,onClick:_,"aria-label":g.history,title:g.history,"data-testid":y.actionHistory,children:r(as,{})}):null,ve.length>0?r(Es,{items:ve,triggerLabel:g.moreActions}):null,we?r("button",{type:"button",class:`${Lr}-icon-btn`,onClick:i,"aria-label":g.close,title:g.close,"data-testid":y.actionClose,children:r(Fe,{})}):null]})}var R_=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,L_=/^https?:\/\/[^\s.]+\.[^\s]+$/i,M_=/^[+]?[\d\s().-]{6,}$/;function Rt(e,t){return e.replace(/\{(\w+)\}/g,(n,o)=>String(t[o]??`{${o}}`))}function O_(e){return Array.isArray(e)?e.length:e&&e.trim()?1:0}function N_(e,t,n){let o=e.required??!0,a=e.validation;if(e.type==="multiselect"){let s=O_(t);return o&&s===0?n.formRequired:s===0?void 0:a?.minSelections!=null&&s<a.minSelections?Rt(n.formChooseAtLeast,{min:a.minSelections}):a?.maxSelections!=null&&s>a.maxSelections?Rt(n.formChooseAtMost,{max:a.maxSelections}):void 0}let i=typeof t=="string"?t.trim():"";if(!i)return o?n.formRequired:void 0;switch(e.type){case"email":if(!R_.test(i))return n.formInvalidEmail;break;case"url":if(!L_.test(i))return n.formInvalidUrl;break;case"tel":if(!M_.test(i))return n.formInvalidTel;break;case"number":{let s=Number(i);if(!Number.isFinite(s))return n.formInvalidNumber;if(a?.min!=null&&s<a.min)return Rt(n.formNumberTooSmall,{min:a.min});if(a?.max!=null&&s>a.max)return Rt(n.formNumberTooLarge,{max:a.max});break}default:break}if(a?.minLength!=null&&i.length<a.minLength)return Rt(n.formTooShort,{min:a.minLength});if(a?.maxLength!=null&&i.length>a.maxLength)return Rt(n.formTooLong,{max:a.maxLength});if(a?.pattern)try{if(!new RegExp(a.pattern).test(i))return n.formPatternMismatch}catch{}}function Is(e,t,n){let o={};for(let a of e){let i=N_(a,t[a.name],n);i&&(o[a.name]=i)}return o}function As(e){let t={};for(let[n,o]of Object.entries(e)){let a=Array.isArray(o)?o.join(", "):o;a&&a.trim()&&(t[n]=a.trim())}return t}var le=x.cssPrefix,bo="__other__";function xo({fields:e,strings:t,submitLabel:n,onSubmit:o,skipLabel:a,onSkip:i,disabled:s,rootTestId:l,submitTestId:c,skipTestId:d}){let[u,_]=k(()=>F_(e)),[h,p]=k({}),[m,g]=k({}),v=I=>{m[I]&&g(W=>({...W,[I]:""}))},A=(I,W)=>{_(K=>({...K,[I]:W})),v(I)},S=(I,W)=>{p(K=>({...K,[I]:W})),v(I)},B=I=>{if(I.preventDefault(),s)return;let W=B_(e,u,h),K=Is(e,W,t);if(Object.keys(K).length>0){g(K);return}o(As(W))};return r("form",{class:`${le}-form`,onSubmit:B,"data-testid":l,noValidate:!0,children:[e.map(I=>r(D_,{field:I,value:u[I.name],otherText:h[I.name]??"",error:m[I.name],disabled:s,strings:t,onChange:W=>A(I.name,W),onOtherChange:W=>S(I.name,W)},I.name)),r("div",{class:`${le}-form-actions`,children:[a&&i?r("button",{type:"button",class:`${le}-form-skip`,onClick:i,disabled:s,"data-testid":d,children:a}):null,r("button",{type:"submit",class:`${le}-form-submit`,disabled:s,"data-testid":c,children:n})]})]})}function D_({field:e,value:t,otherText:n,error:o,disabled:a,strings:i,onChange:s,onOtherChange:l}){let c=he(y.formField,e.name),d=$_({field:e,value:t,otherText:n,disabled:a,strings:i,onChange:s,onOtherChange:l,fieldTid:c});return r("label",{class:`${le}-field`,"data-field":e.name,"data-invalid":o?"true":void 0,children:[r("span",{class:`${le}-field-label`,children:[e.label,e.required??!0?r("span",{class:`${le}-field-req`,"aria-hidden":"true",children:" *"}):null]}),d,e.validationHint&&!o?r("span",{class:`${le}-field-hint`,children:e.validationHint}):null,o?r("span",{class:`${le}-field-error`,role:"alert",children:o}):null]})}function $_(e){let{field:t,value:n,otherText:o,disabled:a,strings:i,onChange:s,onOtherChange:l,fieldTid:c}=e,d=typeof n=="string"?n:"";switch(t.type){case"textarea":return r("textarea",{class:`${le}-field-input`,rows:3,value:d,placeholder:t.placeholder,disabled:a,onInput:u=>s(u.target.value),"data-testid":c});case"select":return r("select",{class:`${le}-field-input`,value:d,disabled:a,onChange:u=>s(u.target.value),"data-testid":c,children:[r("option",{value:"",children:t.placeholder??"\u2014"}),(t.options??[]).map(u=>r("option",{value:u.value,children:u.label??u.value},u.value))]});case"radio":{let u=t.allowOther&&d===bo;return r("div",{class:`${le}-field-choices`,role:"radiogroup","data-testid":c,children:[(t.options??[]).map(_=>r("label",{class:`${le}-choice`,children:[r("input",{type:"radio",name:`${le}-${t.name}`,checked:d===_.value,disabled:a,onChange:()=>s(_.value)}),r("span",{children:_.label??_.value})]},_.value)),t.allowOther?r("label",{class:`${le}-choice`,children:[r("input",{type:"radio",name:`${le}-${t.name}`,checked:d===bo,disabled:a,onChange:()=>s(bo)}),r("span",{children:i.formOther})]}):null,u?r("input",{class:`${le}-field-input`,value:o,placeholder:t.placeholder??i.formOtherPlaceholder,disabled:a,onInput:_=>l(_.target.value)}):null]})}case"checkbox":return r("label",{class:`${le}-choice`,children:[r("input",{type:"checkbox",checked:d==="true",disabled:a,onChange:u=>s(u.target.checked?"true":""),"data-testid":c}),r("span",{children:t.placeholder??t.label})]});case"multiselect":{let u=Array.isArray(n)?n:[],_=(h,p)=>s(p?[...u,h]:u.filter(m=>m!==h));return r("div",{class:`${le}-field-choices`,"data-testid":c,children:[(t.options??[]).map(h=>r("label",{class:`${le}-choice`,children:[r("input",{type:"checkbox",checked:u.includes(h.value),disabled:a,onChange:p=>_(h.value,p.target.checked)}),r("span",{children:h.label??h.value})]},h.value)),t.allowOther||(t.options??[]).length===0?r("textarea",{class:`${le}-field-input`,rows:2,value:o,placeholder:t.placeholder??i.formOtherPlaceholder,disabled:a,onInput:h=>l(h.target.value)}):null]})}default:return r("input",{class:`${le}-field-input`,type:H_(t.type),value:d,placeholder:t.placeholder,disabled:a,onInput:u=>s(u.target.value),"data-testid":c})}}function H_(e){switch(e){case"number":case"email":case"tel":case"url":case"date":case"time":return e;default:return"text"}}function F_(e){let t={};for(let n of e)n.defaultValue!=null&&(t[n.name]=n.type==="multiselect"?n.defaultValue.split(",").map(o=>o.trim()).filter(Boolean):n.defaultValue);return t}function B_(e,t,n){let o={...t};for(let a of e){let i=n[a.name]?.trim();if(a.type==="radio"&&a.allowOther&&t[a.name]===bo)o[a.name]=i??"";else if(a.type==="multiselect"&&i){let s=i.split(/[,\n;]+/).map(c=>c.trim()).filter(Boolean),l=Array.isArray(t[a.name])?t[a.name]:[];o[a.name]=[...l,...s]}}return o}var ze=x.cssPrefix;function Rs({form:e,strings:t,onSubmit:n,onSkip:o}){return r("div",{class:`${ze}-form-gate`,"data-testid":y.formGate,children:[e.title?r("h3",{class:`${ze}-form-gate-title`,children:e.title}):null,e.description?r("p",{class:`${ze}-form-gate-desc`,children:e.description}):null,r(xo,{fields:e.fields,strings:t,submitLabel:e.submitLabel??t.formSubmit,onSubmit:n,skipLabel:e.skippable?t.formSkip:void 0,onSkip:e.skippable?o:void 0,submitTestId:y.formSubmit,skipTestId:y.formSkip})]})}function Ls({marker:e,strings:t,onFill:n}){let o=e.outcome==="skipped",a=o?t.formSkipped:t.formSubmitted,i=e.title?r(ne,{children:[r("span",{children:e.title}),r("span",{class:`${ze}-sr-only`,children:a})]}):r("span",{children:a}),s=e.form?.reviewable??!1,l=!o&&s&&e.values&&Object.keys(e.values).length>0?e.values:null;if(l){let c=d=>e.form?.fields.find(u=>u.name===d)?.label??d;return r("details",{class:`${ze}-form-done`,"data-outcome":e.outcome,"data-testid":y.formDone,children:[r("summary",{class:`${ze}-form-done-summary`,"data-testid":y.formDoneToggle,children:[r(Zt,{}),i,r(It,{})]}),r("dl",{class:`${ze}-form-answers`,"data-testid":y.formAnswers,children:Object.entries(l).map(([d,u])=>r("div",{class:`${ze}-form-answer`,children:[r("dt",{children:c(d)}),r("dd",{children:u})]},d))})]})}return r("div",{class:`${ze}-form-done`,"data-outcome":e.outcome,"data-testid":y.formDone,role:"status",children:[o?r(rs,{}):r(Zt,{}),i,o&&e.form?.reopenable&&n?r("button",{type:"button",class:`${ze}-form-done-fill`,"data-testid":y.formFill,onClick:n,children:t.formFillOut}):null]})}var Nr=1,Os=2,Ns=4,Ds=8,$s=16;function z_(e){switch(e){case Nr:return"href";case Os:return"src";case Ns:return"class";case Ds:return"checked";case $s:return"start"}}var U_=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}},W_=U_;var Ms=24;function $r(e){let t=new Uint32Array(Ms);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(Ms),indent:"",indent_len:0,table_state:0}}function Hs(e){e.pending.length>0&&be(e,`
|
|
12
12
|
`)}function Y(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 ce(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 Z(e,t){(e.tokens[e.len]===24||e.tokens[e.len]===23)&&t!==25&&ce(e),e.len+=1,e.tokens[e.len]=t,e.token=t,e.renderer.add_token(e.renderer.data,t)}function G_(e,t,n){for(;n<=e.len;){if(e.tokens[n]===t)return n;n+=1}return-1}function it(e,t){for(e.fence_start=0;e.len>t;)ce(e)}function Po(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;)ce(e);return t}function Mr(e,t){let n=-1,o=-1;for(let a=e.blockquote_idx+1;a<=e.len;a+=1)if(e.tokens[a]===25){if(e.indent_len<e.spaces[a]){o=-1;break}o=a}else e.tokens[a]===t&&(n=a);return o===-1?n===-1?(it(e,e.blockquote_idx),Z(e,t),!0):(it(e,n),!1):(it(e,o),Z(e,t),!0)}function Or(e,t){Z(e,25),e.spaces[e.len]=e.indent_len+t,qe(e),e.token=103}function qe(e){e.indent="",e.indent_len=0,e.pending=""}function Dr(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 V_(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 K_(e){return Dr(e)||V_(e)}function be(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 a=Po(e,e.indent_len);e.indent_len=0,e.token=e.tokens[e.len],a>0&&be(e," ".repeat(a))}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){ce(e),qe(e),e.pending=n;continue}it(e,e.blockquote_idx),qe(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" ":Po(e,e.indent_len),Z(e,W_(e.pending.length)),qe(e);continue}break;case">":{let i=G_(e,20,e.blockquote_idx+1);i===-1?(it(e,e.blockquote_idx),e.blockquote_idx+=1,e.fence_start=0,Z(e,20)):e.blockquote_idx=i,qe(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;Po(e,e.indent_len),e.renderer.add_token(e.renderer.data,22),e.renderer.end_token(e.renderer.data),qe(e),e.hr_chars=0;continue}e.hr_chars=0}if(e.pending[0]!=="_"&&e.pending[1]===" "){Mr(e,23),Or(e,2),be(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):(Z(e,2),qe(e),e.fence_start=0,be(e,o));continue;case`
|